Search in sources :

Example 1 with GuiTooltip

use of org.blockartistry.lib.gui.GuiTooltip in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method initGui.

@Override
public void initGui() {
    this.presetButtons.clear();
    this.tooltips.clear();
    this.buttonTips.clear();
    this.labelList.clear();
    this.buttonList.clear();
    this.anchorX = (this.width - REGION_WIDTH) / 2;
    this.anchorY = (this.height - REGION_HEIGHT) / 2;
    final int titleWidth = this.fontRenderer.getStringWidth(this.TITLE);
    final int titleX = this.anchorX + (REGION_WIDTH - titleWidth) / 2;
    int Y = this.anchorY + INSET;
    final GuiLabel title = new GuiLabel(this.fontRenderer, ID_TITLE, titleX, Y, REGION_WIDTH, BUTTON_HEIGHT, Color.MC_GOLD.rgb());
    title.addLine(this.TITLE);
    this.labelList.add(title);
    Y += INSET + BUTTON_HEIGHT;
    final int presetWidth = PRESET_BUTTON_WIDTH + INSET * 2;
    final int presetHeight = (int) (PRESET_BUTTON_HEIGHT * (MAX_PRESETS_PAGE + 1.5F)) + INSET;
    this.presetPanel.setWidth(presetWidth);
    this.presetPanel.setHeight(presetHeight);
    for (int i = 0; i < MAX_PRESETS_PAGE; i++) {
        final int id = ID_PRESET_BASE + i;
        final int x = this.anchorX + MARGIN + INSET;
        final int y = Y + i * BUTTON_HEIGHT;
        final GuiButtonExt button = new GuiButtonExt(id, x, y, PRESET_BUTTON_WIDTH, PRESET_BUTTON_HEIGHT, "<NOT SET>");
        button.visible = false;
        this.presetButtons.add(button);
        this.tooltips.add(new GuiTooltip(this, button, ""));
    }
    Y += PRESET_BUTTON_HEIGHT * MAX_PRESETS_PAGE;
    this.buttonList.addAll(this.presetButtons);
    // Do the previous and next buttons
    Y += INSET;
    int navButtonX = this.anchorX + MARGIN + NAV_BUTTON_INSET + INSET;
    this.previousButton = new GuiButtonExt(ID_PREV_PAGE, navButtonX, Y, NAV_BUTTON_WIDTH, PRESET_BUTTON_HEIGHT, PREV_BUTTON_TEXT);
    this.buttonList.add(this.previousButton);
    navButtonX = this.anchorX + MARGIN + presetWidth - INSET - NAV_BUTTON_WIDTH - NAV_BUTTON_INSET;
    this.nextButton = new GuiButtonExt(ID_NEXT_PAGE, navButtonX, Y, NAV_BUTTON_WIDTH, PRESET_BUTTON_HEIGHT, NEXT_BUTTON_TEXT);
    this.buttonList.add(this.nextButton);
    // Buttons to the side. Offset is the spacing between the buttons based
    // on the preset region size and the number of buttons to render.
    final int offset = (presetHeight - 6 * BUTTON_HEIGHT) / 7;
    final int buttonsX = this.anchorX + MARGIN + presetWidth + INSET;
    int buttonsY = this.anchorY + MARGIN * 2 + INSET + offset;
    this.refreshButton = setupButton(ID_REFRESH, buttonsX, buttonsY, "presets.button.Refresh");
    buttonsY += BUTTON_HEIGHT + offset;
    this.createButton = setupButton(ID_CREATE, buttonsX, buttonsY, "presets.button.Create");
    buttonsY += BUTTON_HEIGHT + offset;
    this.editButton = setupButton(ID_EDIT, buttonsX, buttonsY, "presets.button.Edit");
    buttonsY += BUTTON_HEIGHT + offset;
    this.applyButton = setupButton(ID_APPLY, buttonsX, buttonsY, "presets.button.Apply");
    buttonsY += BUTTON_HEIGHT + offset;
    this.saveButton = setupButton(ID_SAVE, buttonsX, buttonsY, "presets.button.Save");
    buttonsY += BUTTON_HEIGHT + offset;
    this.deleteButton = setupButton(ID_DELETE, buttonsX, buttonsY, "presets.button.Delete");
    // Set the final size of the background panel
    this.regionWidth = MARGIN * 2 + presetWidth + INSET + BUTTON_WIDTH;
    this.regionHeight = MARGIN * 2 + presetHeight + BUTTON_HEIGHT * 2;
    this.backgroundPanel.setWidth(this.regionWidth);
    this.backgroundPanel.setHeight(this.regionHeight);
    // Done button
    final int doneX = (this.regionWidth - BUTTON_WIDTH) / 2 + this.anchorX;
    final int doneY = this.anchorY + this.regionHeight - (int) (BUTTON_HEIGHT * 1.5F);
    setupButton(ID_DONE, doneX, doneY, "presets.button.Done");
    reload();
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiLabel(net.minecraft.client.gui.GuiLabel) GuiTooltip(org.blockartistry.lib.gui.GuiTooltip)

Example 2 with GuiTooltip

use of org.blockartistry.lib.gui.GuiTooltip in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method setupButton.

protected GuiButtonExt setupButton(final int id, final int x, final int y, @Nonnull final String buttonLabel) {
    final String label = Localization.format(buttonLabel);
    final String tip = Localization.format(buttonLabel + ".tooltip");
    final GuiButtonExt button = new GuiButtonExt(id, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, label);
    this.buttonList.add(button);
    if (!tip.endsWith(".tooltip"))
        this.buttonTips.add(new GuiTooltip(this, button, tip));
    return button;
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiTooltip(org.blockartistry.lib.gui.GuiTooltip)

Example 3 with GuiTooltip

use of org.blockartistry.lib.gui.GuiTooltip in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method setPresetButtonText.

public void setPresetButtonText() {
    final int start = this.currentPage * MAX_PRESETS_PAGE;
    for (int i = 0; i < MAX_PRESETS_PAGE; i++) {
        final GuiButtonExt button = this.presetButtons.get(i);
        final int idx = start + i;
        if (idx >= this.presets.size()) {
            button.visible = false;
        } else {
            final PresetInfo info = this.presets.get(idx);
            button.displayString = info.getTitle();
            button.enabled = this.selectedPreset != idx;
            button.visible = true;
            final StringBuilder builder = new StringBuilder();
            builder.append(TextFormatting.GOLD + info.getTitle()).append('\n');
            builder.append(TextFormatting.AQUA + info.getFilename());
            if (info.isRestartRequired())
                builder.append('\n').append(this.TOOLTIP_RESTART_REQUIRED);
            if (!StringUtils.isEmpty(info.getDescription().trim()))
                builder.append("\n\n").append(TextFormatting.RESET).append(info.getDescription());
            this.tooltips.set(i, new GuiTooltip(this, button, builder.toString(), PRESET_TOOLTIP_WIDTH));
        }
    }
    updateButtonState();
}
Also used : PresetInfo(org.blockartistry.Presets.data.PresetInfo) GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiTooltip(org.blockartistry.lib.gui.GuiTooltip)

Example 4 with GuiTooltip

use of org.blockartistry.lib.gui.GuiTooltip in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method drawScreen.

@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
    drawDefaultBackground();
    this.backgroundPanel.render(this.anchorX, this.anchorY, Reference.UPPER_LEFT);
    this.presetPanel.render(this.anchorX + MARGIN, this.anchorY + MARGIN + INSET * 3, Reference.UPPER_LEFT);
    super.drawScreen(mouseX, mouseY, partialTicks);
    for (int i = 0; i < MAX_PRESETS_PAGE; i++) {
        final GuiButtonExt button = this.presetButtons.get(i);
        if (button.visible && this.tooltips.get(i).handle(mouseX, mouseY))
            return;
    }
    for (final GuiTooltip tip : this.buttonTips) if (tip.handle(mouseX, mouseY))
        return;
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiTooltip(org.blockartistry.lib.gui.GuiTooltip)

Aggregations

GuiButtonExt (net.minecraftforge.fml.client.config.GuiButtonExt)4 GuiTooltip (org.blockartistry.lib.gui.GuiTooltip)4 GuiLabel (net.minecraft.client.gui.GuiLabel)1 PresetInfo (org.blockartistry.Presets.data.PresetInfo)1