Beispiel #1
0
  public void drawIcons(Graphics2D g2d) {
    for (int i = 0; i < stateIcons.length; i++) {
      g2d.setColor(Color.BLACK);
      UnitState state = (main.getMH().getUnit() != null) ? main.getMH().getUnit().getState() : null;

      if (state != null && i == state.getValue())
        g2d.drawRect(
            middleX / 4 + 390 + (i % div) * 70,
            middleY * 2 - middleX / 6 + 10 + (i / div) * 70,
            70,
            70);
      g2d.drawImage(
          stateIcons[i],
          middleX / 4 + 390 + (i % div) * 70,
          middleY * 2 - middleX / 6 + 10 + (i / div) * 70,
          null);

      String s = getHoveringMessage();
      if (s != null) {
        g2d.drawString(
            s,
            middleX / 4 + 390 + (selectedHoverableNr % div) * 70,
            middleY * 2 - middleX / 6 + 10 + (selectedHoverableNr / div) * 70);
      }
    }
  }
Beispiel #2
0
  public void handleStateSelection(MouseEvent e) {
    for (int i = 0; i < stateIcons.length; i++) {
      if (rects[i].contains(e.getX(), e.getY())) {
        selectedStateNr = i;
      }
    }

    if (selectedStateNr != -1) {
      main.getMH().getUnit().setState(UnitState.getStateOfValue(selectedStateNr));
      main.getCurrentPlayer().setRessourcesChanged(true);
    }
  }