Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.70 KB | None | 0 0
  1. private GeneralPath pathFrom(int[] xs, int[] ys) {
  2.         GeneralPath gp = new GeneralPath();
  3.         gp.moveTo(xs[0], ys[0]);
  4.         for (int i = 1; i < xs.length; i++)
  5.             gp.lineTo(xs[i], ys[i]);
  6.         gp.closePath();
  7.         return gp;
  8.     }
  9.  
  10.     private final RenderingHints antialiasing = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
  11.                                                                    RenderingHints.VALUE_ANTIALIAS_ON);
  12.  
  13.     private final Color color1 = new Color(153, 0, 0);
  14.     private final Color color2 = new Color(0, 0, 0);
  15.     private final Color color3 = new Color(102, 102, 102);
  16.     private final Color color4 = new Color(255, 255, 255);
  17.     private final Color color5 = new Color(51, 51, 51, 225);
  18.  
  19.     private final BasicStroke stroke1 = new BasicStroke(1);
  20.  
  21.     private final Font font1 = new Font("Arial", 0, 10);
  22.     private final Font font2 = new Font("Arial", 0, 15);
  23.  
  24.  
  25.     public void onRepaint(Graphics render) {
  26.         Graphics2D g = (Graphics2D) render;
  27. //        PaintDebug.repaint(g);
  28.         g.setRenderingHints(antialiasing);
  29.         g.setColor(color5);
  30.         g.fillRoundRect(3, 338, 514, 139, 16, 16);
  31.         g.setColor(color1);
  32.         g.setStroke(stroke1);
  33.         g.drawRoundRect(3, 338, 514, 139, 16, 16);
  34.         String timeRan = getTime(System.currentTimeMillis() - startTime);
  35.         g.setFont(font2);
  36.         g.setColor(color2);
  37.         String[] skillNames = {"Attack", "Strength", "Defence", "HP"};
  38.         int[] xp = {
  39.                 Skills.getCurrentExp(com.rsbuddy.script.methods.Skills.ATTACK)
  40.                 - startAttXp,
  41.                 Skills.getCurrentExp(com.rsbuddy.script.methods.Skills.STRENGTH)
  42.                 - startStrXp,
  43.                 Skills.getCurrentExp(com.rsbuddy.script.methods.Skills.DEFENSE)
  44.                 - startDefXp,
  45.                 Skills.getCurrentExp(com.rsbuddy.script.methods.Skills.CONSTITUTION)
  46.                 - startHPXp};
  47.         int[] skillIndex = {
  48.                 com.rsbuddy.script.methods.Skills.ATTACK,
  49.                 com.rsbuddy.script.methods.Skills.STRENGTH,
  50.                 com.rsbuddy.script.methods.Skills.DEFENSE,
  51.                 com.rsbuddy.script.methods.Skills.CONSTITUTION};
  52.         int y = 350;
  53.         for (int i = 0; i < skillNames.length; i++) {
  54.             if (xp[i] > 0) {
  55.                 drawSkill(g, skillIndex[i], skillNames[i], xp[i], 10, y);
  56.                 y += 25;
  57.             }
  58.         }
  59.         g.setColor(color4);
  60.         g.drawString("Status: " + status, 240, 366);
  61.         g.drawString("Time running: " + timeRan, 240, 381);
  62.         g.drawString("Dungeons completed: " + dungeonsDone, 240, 397);
  63.         g.drawString("Dungeons aborted: " + timesAborted, 240, 413);
  64.         drawSkill(g,
  65.                   com.rsbuddy.script.methods.Skills.DUNGEONEERING,
  66.                   "Dungeoneering",
  67.                   Skills.getCurrentExp(com.rsbuddy.script.methods.Skills.DUNGEONEERING)
  68.                   - startDungXp,
  69.                   240,
  70.                   428);
  71.         if (debug) {
  72.             try {
  73.                 for (Iterator<Door> it = Explore.doors.iterator(); it.hasNext();) {
  74.                     Door door = it.next();
  75.                     if (door == null)
  76.                         continue;
  77.                     String[] text = {"Open: " + door.isOpen(),
  78.                                      "Locked: " + door.isLocked(),
  79.                                      "Connector: " + Explore.rooms.indexOf(door.getConnector()),
  80.                                      "Can Open: " + door.canOpen(),};
  81.                     drawDoor(g, door, text, color4);
  82.                 }
  83.                 for (Iterator<Room> it = Explore.rooms.iterator(); it.hasNext();) {
  84.                     Room room = it.next();
  85.                     drawRoom(g, room, color4);
  86.                 }
  87.  
  88.             } catch (ArrayIndexOutOfBoundsException aioob) {
  89.                 aioob.printStackTrace();
  90.                 StackTraceElement[] elements = Thread.currentThread().getStackTrace();
  91.                 log(elements[0]);
  92.             } catch (Exception e) {
  93.                 e.printStackTrace();
  94.             }
  95.         }
  96.     }
  97.  
  98.     private void drawDoor(Graphics2D g, Door door, String[] text, Color tc) {
  99.         Color oldColor = g.getColor();
  100.         g.setColor(tc);
  101.         Point point;
  102.         point = Calculations.tileToScreen(door.getLocation(), 0.5, 0.5, 1);
  103.         if (point.x == -1 || !Calculations.isPointOnScreen(point))
  104.             return;
  105.         g.setColor(tc);
  106.         int x = point.x;
  107.         int y = point.y;
  108.         for (String s : text) {
  109.             final FontMetrics fm = g.getFontMetrics(font2);
  110.             final LineMetrics lm = fm.getLineMetrics(s, g);
  111.             g.drawString(s, x, y += lm.getHeight());
  112.         }
  113.         g.setColor(oldColor);
  114.     }
  115.  
  116.     private void drawRoom(Graphics2D g, Room room, Color tc) {
  117.         try {
  118.             Color oldColor = g.getColor();
  119.             g.setColor(tc);
  120.             Polygon roomArea = new Polygon();
  121.             for (Tile tile : room.getArea().getEdgeTiles()) {
  122.                 if (Calculations.isTileOnMap(tile)) {
  123.                     Point tom = Calculations.tileToMap(tile);
  124.                     roomArea.addPoint(tom.x, tom.y);
  125.                 }
  126.             }
  127.             for (int i = 0; i < roomArea.xpoints.length; i++) {
  128.                 g.fillRect(roomArea.xpoints[i], roomArea.ypoints[i], 3, 3);
  129.             }
  130.             if (Calculations.isTileOnMap(room.getArea().getCentralTile())) {
  131.                 Point tom = Calculations.tileToMap(room.getArea().getCentralTile());
  132.                 g.drawString(String.valueOf(Explore.rooms.indexOf(room)), tom.x, tom.y);
  133.             }
  134.             g.setColor(oldColor);
  135.         } catch (Exception e) {
  136.             e.printStackTrace();
  137.         }
  138.     }
  139.  
  140.     private void drawSkill(Graphics2D g, int skill, String name, int xpGained,
  141.                            int x, int y) {
  142.         Color start = g.getColor();
  143.         int width = 225;
  144.         int height = 20;
  145.         Rectangle hover = new Rectangle(x, y, width, height);
  146.         int percentTL = Skills.getPercentToNextLevel(skill);
  147.         int xpTL = Skills.getExpToNextLevel(skill);
  148.         int xpPH = (int) ((xpGained) * 3600000D / (System.currentTimeMillis() - startTime));
  149.         String TTL = "Calculating..";
  150.         long ttlCalculations;
  151.         if (xpPH != 0) {
  152.             ttlCalculations = (long) (xpTL * 3600000D) / xpPH;
  153.             TTL = getTime(ttlCalculations);
  154.         }
  155.         Font oldFont = g.getFont();
  156.         g.setColor(color1);
  157.         g.fillRoundRect(x, y, width, height, 16, 16);
  158.         g.setColor(color2);
  159.         g.setStroke(stroke1);
  160.         g.drawRoundRect(x, y, width, height, 16, 16);
  161.         g.setColor(color3);
  162.         g.fillRoundRect(x, y, (int) (percentTL * 2.25), 20, 16, 16);
  163.         g.setFont(font1);
  164.         g.setColor(color4);
  165.         NumberFormat nf = NumberFormat.getIntegerInstance();
  166.         g.drawString(name + " - " + percentTL + "% - " + nf.format(xpTL),
  167.                      x + 30,
  168.                      y + 15);
  169.         if (hover.contains(m)) {
  170.             final GeneralPath polygon1 = pathFrom(new int[]{
  171.                     (int) (x + (width / 3.25) + 35),
  172.                     (int) (x + (width / 3.25) + 49),
  173.                     (int) (x + (width / 3.25) + 52 + 12)}, new int[]{
  174.                     y - 10,
  175.                     y - 4,
  176.                     y - 10});
  177.             g.setColor(color3);
  178.             g.fillRoundRect((int) (x + (width / 3.25)),
  179.                             (int) (y - (height * 2.45)),
  180.                             110,
  181.                             38,
  182.                             16,
  183.                             16);
  184.             g.setColor(color1);
  185.             g.drawRoundRect((int) (x + (width / 3.25)),
  186.                             (int) (y - (height * 2.45)),
  187.                             110,
  188.                             38,
  189.                             16,
  190.                             16);
  191.             g.setFont(font1);
  192.             g.setColor(color4);
  193.             g.drawString("P/H: " + xpPH,
  194.                          (int) (x + (width / 3.25)) + 5,
  195.                          y - (height * 2) + 2);
  196.             g.drawString("TTL: " + TTL,
  197.                          (int) (x + (width / 3.25)) + 5,
  198.                          y - (height * 2) + 11);
  199.             g.drawString("Gained: " + nf.format(xpGained),
  200.                          (int) (x + (width / 3.25)) + 5,
  201.                          20 + y - (height * 2));
  202.             g.setColor(color2);
  203.             g.fill(polygon1);
  204.             g.setColor(color1);
  205.             g.setStroke(stroke1);
  206.             g.draw(polygon1);
  207.  
  208.         }
  209.         g.setColor(start);
  210.         g.setFont(oldFont);
  211.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement