コード例 #1
0
  @Override
  public void mouseClick(GuiBase gui, int x, int y, int button) {
    if (!isActive()) {
      return;
    }

    for (int i = 0; i < list.size(); i++) {
      if (list.get(i) != null) {
        int[] rect = getItemButtonRect(i);

        if ((rect[3] > 0) && (inRect(gui, x, y, rect))) {
          if (selectedIndex == i) {
            selectedIndex = -1;
          } else {
            selectedIndex = i;
          }
          onClick(i);
          break;
        }
      }
    }
    int[] pos = {getScrollBar()[0], getScrollBar()[1], getScrollBar()[2], getScrollBar()[3]};
    if ((list.size() >= maxItemDisplayed) && (inRect(gui, x, y, pos))) {
      y -= gui.getTop();
      doScroll(y);
      isScrolling = true;
    }
  }
コード例 #2
0
  @Override
  public void mouseMoveClick(GuiBase gui, int x, int y, int button, long timeSinceClicked) {
    if (!isActive()) {
      return;
    }
    y -= gui.getTop();

    if (isScrolling) {
      if (button == -1) {
        this.isScrolling = false;
      } else {
        doScroll(y);
      }
    }
  }
コード例 #3
0
  @Override
  public void drawForeground(GuiBase gui, int x, int y) {
    if (!isActive()) {
      return;
    }

    for (int i = 0; i < list.size(); i++) {
      int[] rect = getItemButtonRect(i);

      int x1 = rect[0] + 3;
      int textY = (int) Math.ceil(itemHeight / 2F - 4F);
      int y1 = rect[1] + (textY < 0 ? 0 : textY);
      if (rect[4] < 0) {
        y1 += rect[4];
      }

      int maxScroll = getScrollBar()[3] - (int) getScrollBarSize().y;
      if ((rect[4] >= -textY) && (rect[4] <= maxScroll)) {
        gui.getFontRenderer()
            .drawString(list.get(i) == null ? "" : list.get(i), x1, y1, textColor.toRGB());
      }
    }
  }