Пример #1
0
  @Override
  protected void drawGuiContainerForegroundLayer(int cursorX, int cursorY) {
    super.drawGuiContainerForegroundLayer(cursorX, cursorY);

    this.fontRendererObj.drawString(this.guiTitle, TITLE_POS_X, TITLE_POS_Y, 0x000000);

    // Draw the search field.
    this.searchField.drawTextBox();

    // Enable lighting
    GL11.glEnable(GL11.GL_LIGHTING);

    // Draw the widgets and get which one the mouse is over
    WidgetAEItem widgetUnderMouse = this.drawItemWidgets(cursorX, cursorY);

    // Should we force a tooltip update?
    boolean forceTooltipUpdate =
        ((System.currentTimeMillis() - this.lastTooltipUpdateTime)
            >= WIDGET_TOOLTIP_UPDATE_INTERVAL);

    // Has the mouse moved, or timeout reached?
    if (forceTooltipUpdate
        || (this.previousMouseX != cursorX)
        || (this.previousMouseY != cursorY)) {
      // Do we have a widget under the mouse?
      if (widgetUnderMouse != null) {
        // Has the widget changed?
        if (forceTooltipUpdate || (widgetUnderMouse != this.previousWidgetUnderMouse)) {
          // Clear the tooltip
          this.tooltip.clear();

          // Get the tooltip from the widget
          widgetUnderMouse.getTooltip(this.tooltip);

          // Set the time
          this.lastTooltipUpdateTime = System.currentTimeMillis();
        }
      } else {
        // Clear the tooltip
        this.tooltip.clear();

        // Set the time
        this.lastTooltipUpdateTime = System.currentTimeMillis();

        // Get the tooltip from the buttons
        this.addTooltipFromButtons(cursorX, cursorY);
      }

      // Set the previous position
      this.previousMouseX = cursorX;
      this.previousMouseY = cursorY;

      // Set the previous widget
      this.previousWidgetUnderMouse = widgetUnderMouse;
    }

    // Draw the tooltip
    this.drawTooltip(cursorX - this.guiLeft, cursorY - this.guiTop, false);
  }