Search in sources :

Example 6 with GuiLabel

use of net.minecraft.client.gui.GuiLabel in project DynamicSurroundings by OreCruncher.

the class PresetInfoModifyGui method initGui.

@Override
public void initGui() {
    this.labelList.clear();
    this.buttonList.clear();
    this.anchorX = (this.width - REGION_WIDTH) / 2;
    this.anchorY = (this.height - REGION_HEIGHT) / 2;
    final String theTitle = this.editMode ? EDIT_TITLE : CREATE_TITLE;
    final int titleWidth = this.fontRenderer.getStringWidth(theTitle);
    int X = this.anchorX + (REGION_WIDTH - titleWidth) / 2;
    int Y = this.anchorY + MARGIN;
    GuiLabel label = new GuiLabel(this.fontRenderer, ID_TITLE, X, Y, REGION_WIDTH, BUTTON_HEIGHT, Color.MC_GOLD.rgb());
    label.addLine(theTitle);
    this.labelList.add(label);
    X = this.anchorX + MARGIN;
    Y += BUTTON_HEIGHT;
    final int entryWidth = REGION_WIDTH - MARGIN * 2;
    final int labelColor = Color.WHITE.rgb();
    final int requiredWidth = this.fontRenderer.getStringWidth(REQUIRED_TEXT);
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(FILENAME_LABEL);
    this.labelList.add(label);
    this.fileNameRequired = new GuiLabel(this.fontRenderer, ID_FILENAME_REQUIRED, X + entryWidth - requiredWidth, Y, LABEL_WIDTH, BUTTON_HEIGHT, Color.RED.rgb());
    this.fileNameRequired.addLine(REQUIRED_TEXT);
    this.fileNameRequired.visible = false;
    this.labelList.add(this.fileNameRequired);
    Y += BUTTON_HEIGHT;
    this.fileName = new GuiTextField(ID_PRESET_FILENAME_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.fileName.setMaxStringLength(32);
    this.fileName.setText(this.info.getFilename());
    this.fileName.setValidator(input -> !input.matches(FILENAME_VALIDATION_REGEX));
    Y += BUTTON_HEIGHT + INSET;
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(PRESET_TITLE_LABEL);
    this.labelList.add(label);
    this.presetTitleRequired = new GuiLabel(this.fontRenderer, ID_TITLE_REQUIRED, X + entryWidth - requiredWidth, Y, LABEL_WIDTH, BUTTON_HEIGHT, Color.RED.rgb());
    this.presetTitleRequired.addLine(REQUIRED_TEXT);
    this.presetTitleRequired.visible = false;
    this.labelList.add(this.presetTitleRequired);
    Y += BUTTON_HEIGHT;
    this.presetTitle = new GuiTextField(ID_PRESET_TITLE_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.presetTitle.setMaxStringLength(48);
    this.presetTitle.setText(this.info.getTitle());
    Y += BUTTON_HEIGHT + INSET;
    label = new GuiLabel(this.fontRenderer, ID_PRESET_FILENAME, X, Y, LABEL_WIDTH, BUTTON_HEIGHT, labelColor);
    label.addLine(PRESET_DESCRIPTION_LABEL);
    this.labelList.add(label);
    Y += BUTTON_HEIGHT;
    this.presetDescription = new GuiTextField(ID_PRESET_DESCRIPTION_TEXT, this.fontRenderer, X, Y, entryWidth, BUTTON_HEIGHT);
    this.presetDescription.setMaxStringLength(255);
    this.presetDescription.setText(this.info.getDescription());
    Y += BUTTON_HEIGHT * 2 + INSET * 2 + MARGIN;
    // Set the final size of the background panel;
    this.regionWidth = REGION_WIDTH;
    this.regionHeight = Y - this.anchorY;
    this.backgroundPanel.setWidth(this.regionWidth);
    this.backgroundPanel.setHeight(this.regionHeight);
    // Done button
    int doneX = this.anchorX + (this.regionWidth - BUTTON_WIDTH * 3) / 2;
    final int doneY = this.anchorY + this.regionHeight - (int) (BUTTON_HEIGHT * 1.5F);
    this.doneButton = new GuiButtonExt(ID_DONE, doneX, doneY, BUTTON_WIDTH, BUTTON_HEIGHT, DONE_BUTTON_LABEL);
    this.buttonList.add(this.doneButton);
    // Cancel button
    doneX += BUTTON_WIDTH * 2;
    final GuiButtonExt button = new GuiButtonExt(ID_CANCEL, doneX, doneY, BUTTON_WIDTH, BUTTON_HEIGHT, CANCEL_BUTTON_LABEL);
    this.buttonList.add(button);
    // Filename field has first focus
    this.fileName.setFocused(true);
    doneEnableCheck();
}
Also used : GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) GuiLabel(net.minecraft.client.gui.GuiLabel) GuiTextField(net.minecraft.client.gui.GuiTextField)

Example 7 with GuiLabel

use of net.minecraft.client.gui.GuiLabel in project BiomesOPlenty by Glitchfiend.

the class GuiBOPPageTable method createLabel.

private GuiLabel createLabel(int xPosition, int yPosition, GuiBOPPageList.GuiLabelEntry field, boolean hasNoNeighbor) {
    GuiLabel guilabel;
    if (hasNoNeighbor) {
        guilabel = new GuiLabel(this.mc.fontRenderer, field.getFieldId(), xPosition, yPosition, this.width - xPosition * 2, 20, -1);
    } else {
        guilabel = new GuiLabel(this.mc.fontRenderer, field.getFieldId(), xPosition, yPosition, 150, 20, -1);
    }
    guilabel.visible = field.isVisible();
    guilabel.addLine(field.getLabelText());
    guilabel.setCentered();
    return guilabel;
}
Also used : GuiLabel(net.minecraft.client.gui.GuiLabel)

Aggregations

GuiLabel (net.minecraft.client.gui.GuiLabel)7 GuiButton (net.minecraft.client.gui.GuiButton)2 GuiButtonExt (net.minecraftforge.fml.client.config.GuiButtonExt)2 Nutrient (ca.wescook.nutrition.nutrients.Nutrient)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 GuiElementInfoRegion (micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementInfoRegion)1 GuiSlider (net.minecraft.client.gui.GuiSlider)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 GuiTooltip (org.blockartistry.lib.gui.GuiTooltip)1