Exemple #1
0
  public boolean paint(Graphics graphics) {
    if (!Game.isLoggedIn()) return false;
    try {
      Graphics2D g = (Graphics2D) graphics;
      PComponent clayout = null;
      try {
        clayout =
            new PColumnLayout(
                227,
                404,
                infoColumnValues,
                infoColumnData,
                new Font("Arial", 0, 9),
                PColumnLayout.ColorScheme.WHITE);
      } catch (Exception e) {
        e.printStackTrace();
      }
      getFrame("options").removeComponent(firstLayout);
      getFrame("options").removeComponent(secondLayout);
      int secondColx = -1;
      int bestLength = -1;
      firstColumn.clear();
      secondColumn.clear();
      if (checkBoxes.size() <= 6) firstColumn.putAll(checkBoxes);
      else {
        for (int i = 0; i < checkBoxes.size(); i++) {
          if (i <= 5) {
            String text;
            Iterator it = checkBoxes.keySet().iterator();
            for (int j = 0; j < i; j++) it.next();
            text = (String) it.next();
            int length = SwingUtilities.computeStringWidth(g.getFontMetrics(g.getFont()), text);
            if (length > bestLength) bestLength = length;
            firstColumn.put(text, checkBoxes.get(text));
          } else {
            String text;
            Iterator it = checkBoxes.keySet().iterator();
            for (int j = 0; j < i; j++) it.next();
            text = (String) it.next();
            secondColumn.put(text, checkBoxes.get(text));
          }
        }
      }
      secondColx = 8 + bestLength;
      firstLayout =
          new PCheckBoxLayout(
              8,
              407,
              firstColumn
                  .keySet()
                  .toArray(new String[(firstColumn.size() > 6) ? 6 : firstColumn.size()]),
              firstColumn
                  .values()
                  .toArray(new PCheckBox[(firstColumn.size() > 6) ? 6 : firstColumn.size()]),
              new Font("Arial", 0, 11),
              PCheckBoxLayout.ColorScheme.WHITE);
      secondLayout =
          new PCheckBoxLayout(
              secondColx + 12,
              407,
              secondColumn
                  .keySet()
                  .toArray(new String[(secondColumn.size() > 6) ? 6 : secondColumn.size()]),
              secondColumn
                  .values()
                  .toArray(new PCheckBox[(secondColumn.size() > 6) ? 6 : secondColumn.size()]),
              new Font("Arial", 0, 11),
              PCheckBoxLayout.ColorScheme.WHITE);
      getFrame("options").addComponent(firstLayout);
      getFrame("options").addComponent(secondLayout);
      if (showPaint) {
        Paint p = g.getPaint();
        g.setPaint(
            new GradientPaint(
                0, 1000, new Color(55, 55, 55, 240), 512, 472, new Color(15, 15, 15, 240)));
        g.fillRect(7, 396, 505, 128);
        final Point loc = Mouse.getLocation();
        if (Mouse.isPressed()) {
          g.fillOval(loc.x - 5, loc.y - 5, 10, 10);
          g.drawOval(loc.x - 5, loc.y - 5, 10, 10);
        }
        g.drawLine(0, loc.y + 1, 766, loc.y + 1);
        g.drawLine(0, loc.y - 1, 766, loc.y - 1);
        g.drawLine(loc.x + 1, 0, loc.x + 1, 505);
        g.drawLine(loc.x - 1, 0, loc.x - 1, 505);
        g.setPaint(p);
      }
      if (clayout != null) getFrame("info").addComponent(clayout);
      PaintController.onRepaint(graphics);
      if (clayout != null) getFrame("info").removeComponent(clayout);
      if (!showPaint) return false;
      String infoTxt = name + " - " + "v" + version;
      g.drawString(
          infoTxt,
          510 - SwingUtilities.computeStringWidth(g.getFontMetrics(g.getFont()), infoTxt),
          468);

      int offset = 0;
      for (Skill skill : skills) {
        if (skill.xpGained() > 0) {
          PSkill skillComp =
              new PSkill(8, 397 + offset, skill.getSkill(), PSkill.ColorScheme.GRAPHITE);
          if (!getFrame("info").containsComponent(skillComp)) {
            getFrame("info").addComponent(skillComp);
          }
          offset += 20;
        }
      }

      // == Mouse ==
      if (Mouse.isPressed()) {
        g.setColor(new Color(255, 252, 0, 150));

        g.setColor(new Color(255, 252, 0, 100));
      } else {
        g.setColor(new Color(255, 252, 0, 50));
      }

      g.setColor(new Color(0, 0, 0, 50));

      // == End mouse ==
    } catch (Exception ignored) {
      // if (Utils.isDevMode())
      //    ignored.printStackTrace();
    }
    return true;
  }