コード例 #1
0
  /**
   * Draw this list entry as a list item
   *
   * @param mouseX
   * @param mouseY
   * @param partialTicks
   * @param xPosition
   * @param yPosition
   * @param width
   * @param selected
   * @return
   */
  public int draw(
      int mouseX,
      int mouseY,
      float partialTicks,
      int xPosition,
      int yPosition,
      int width,
      boolean selected) {
    int gradientColour = this.getGradientColour(selected);
    int titleColour = this.getTitleColour(selected);
    int statusColour = this.getStatusColour(selected);

    this.drawGradientRect(
        xPosition,
        yPosition,
        xPosition + width,
        yPosition + GuiModListPanel.PANEL_HEIGHT,
        gradientColour,
        GuiModListPanel.GRADIENT_COLOUR2);

    String titleText = this.owner.getTitleText();
    String versionText = this.owner.getVersionText();
    String statusText = this.owner.getStatusText();

    for (ModInfoDecorator decorator : this.decorators) {
      String newStatusText = decorator.modifyStatusText(this.modInfo, statusText);
      if (newStatusText != null) statusText = newStatusText;
    }

    this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, titleColour);
    this.fontRenderer.drawString(
        versionText, xPosition + 5, yPosition + 12, GuiModListPanel.VERSION_TEXT_COLOUR);
    this.fontRenderer.drawString(statusText, xPosition + 5, yPosition + 22, statusColour);

    this.mouseOver = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT);
    int hangerColour =
        this.mouseOver ? GuiModListPanel.HANGER_COLOUR_MOUSEOVER : GuiModListPanel.HANGER_COLOUR;
    drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, hangerColour);

    for (ModInfoDecorator decorator : this.decorators) {
      decorator.onDrawListEntry(
          mouseX,
          mouseY,
          partialTicks,
          xPosition,
          yPosition,
          width,
          GuiModListPanel.PANEL_HEIGHT,
          selected,
          this.modInfo,
          gradientColour,
          titleColour,
          statusColour);
    }

    return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING;
  }
コード例 #2
0
  public GuiModListPanel(
      ModListEntry owner,
      FontRenderer fontRenderer,
      int brandColour,
      ModInfo<?> modInfo,
      List<ModInfoDecorator> decorators) {
    this.owner = owner;
    this.fontRenderer = fontRenderer;
    this.brandColour = brandColour;
    this.modInfo = modInfo;
    this.decorators = decorators;

    for (ModInfoDecorator decorator : this.decorators) {
      decorator.addIcons(modInfo, this.modIcons);
    }
  }