Search in sources :

Example 1 with GuiLabel

use of net.minecraft.client.gui.GuiLabel in project Nutrition by WesCook.

the class NutritionGui method redrawLabels.

// Called when needing to propagate the window with new information
public void redrawLabels() {
    // Clear existing labels for nutrition value or screen changes
    labelList.clear();
    // Draw title
    String nutritionTitle = I18n.format("gui." + Nutrition.MODID + ":nutrition_title");
    labelList.add(label = new GuiLabel(fontRenderer, 0, (width / 2) - (fontRenderer.getStringWidth(nutritionTitle) / 2), top + TITLE_VERTICAL_OFFSET, 0, 0, 0xffffffff));
    label.addLine(nutritionTitle);
    // Nutrients names and values
    int i = 0;
    for (Nutrient nutrient : NutrientList.get()) {
        // Create labels for each nutrient type name
        labelList.add(label = new GuiLabel(fontRenderer, 0, left + LABEL_NAME_HORIZONTAL_OFFSET, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
        // Add name from localization file
        label.addLine(I18n.format("nutrient." + Nutrition.MODID + ":" + nutrient.name));
        // Create percent value labels for each nutrient value
        labelList.add(label = new GuiLabel(fontRenderer, 0, left + LABEL_VALUE_HORIZONTAL_OFFSET + labelCharacterPadding, top + LABEL_VERTICAL_OFFSET + (i * NUTRITION_DISTANCE), 0, 0, 0xffffffff));
        if (// Ensure local nutrition data exists
        ClientProxy.nutrientData != null && ClientProxy.nutrientData.get(nutrient) != null)
            label.addLine(Math.round(ClientProxy.nutrientData.get(nutrient)) + "%%");
        else
            label.addLine(I18n.format("gui." + Nutrition.MODID + ":updating"));
        i++;
    }
}
Also used : Nutrient(ca.wescook.nutrition.nutrients.Nutrient) GuiLabel(net.minecraft.client.gui.GuiLabel)

Example 2 with GuiLabel

use of net.minecraft.client.gui.GuiLabel in project Galacticraft by micdoodle8.

the class GuiLaunchController method drawScreen.

@Override
public void drawScreen(int par1, int par2, float par3) {
    if (this.launchController.disableCooldown > 0) {
        this.enableControllerButton.enabled = false;
        this.hideDestinationFrequency.enabled = false;
    } else {
        boolean isOwner = PlayerUtil.getName(this.mc.thePlayer).equals(this.launchController.getOwnerName());
        this.enableControllerButton.enabled = isOwner;
        this.hideDestinationFrequency.enabled = isOwner;
    }
    this.enableControllerButton.displayString = this.launchController.getDisabled(0) ? GCCoreUtil.translate("gui.button.enable.name") : GCCoreUtil.translate("gui.button.disable.name");
    this.hideDestinationFrequency.displayString = !this.launchController.getDisabled(2) ? GCCoreUtil.translate("gui.button.unhide_dest.name") : GCCoreUtil.translate("gui.button.hide_dest.name");
    // Hacky way of rendering buttons properly, possibly bugs here:
    List<GuiButton> buttonList = new ArrayList<>(this.buttonList);
    List<GuiLabel> labelList = new ArrayList<>(this.labelList);
    List<GuiElementInfoRegion> infoRegions = new ArrayList<>(this.infoRegions);
    this.buttonList.clear();
    this.labelList.clear();
    this.infoRegions.clear();
    super.drawScreen(par1, par2, par3);
    GL11.glColor3f(1, 1, 1);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    int k;
    for (k = 0; k < buttonList.size(); ++k) {
        ((GuiButton) buttonList.get(k)).drawButton(this.mc, par1, par2);
    }
    for (k = 0; k < labelList.size(); ++k) {
        ((GuiLabel) labelList.get(k)).drawLabel(this.mc, par1, par2);
    }
    for (k = 0; k < infoRegions.size(); ++k) {
        infoRegions.get(k).drawRegion(par1, par2);
    }
    this.buttonList = buttonList;
    this.labelList = labelList;
    this.infoRegions = infoRegions;
    // GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    RenderHelper.enableStandardItemLighting();
    if (Math.random() < 0.025 && !destinationFrequency.isTextFocused) {
        if (!PlayerUtil.getName(this.mc.thePlayer).equals(this.launchController.getOwnerName()) && !this.launchController.getDisabled(2)) {
            // in case the player is not equal to the owner of the controller,
            // scramble the destination number such that other players can't
            // fly to it directly
            Random r = new Random();
            String fakefrequency = "";
            for (int i = 0; i < this.destinationFrequency.getMaxLength(); i++) {
                fakefrequency += (char) (r.nextInt(126 - 33) + 33);
            }
            destinationFrequency.text = fakefrequency;
        } else {
            destinationFrequency.text = String.valueOf(this.launchController.destFrequency);
        }
    }
}
Also used : GuiElementInfoRegion(micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementInfoRegion) GuiButton(net.minecraft.client.gui.GuiButton) Random(java.util.Random) ArrayList(java.util.ArrayList) GuiLabel(net.minecraft.client.gui.GuiLabel)

Example 3 with GuiLabel

use of net.minecraft.client.gui.GuiLabel 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 4 with GuiLabel

use of net.minecraft.client.gui.GuiLabel in project MC-Prefab by Brian-Wuest.

the class GuiStructure method drawControlBackgroundAndButtonsAndLabels.

protected void drawControlBackgroundAndButtonsAndLabels(int grayBoxX, int grayBoxY, int mouseX, int mouseY) {
    this.mc.getTextureManager().bindTexture(this.backgroundTextures);
    this.drawTexturedModalRect(grayBoxX, grayBoxY, 0, 0, 256, 256);
    for (int i = 0; i < this.buttonList.size(); ++i) {
        GuiButton currentButton = this.buttonList.get(i);
        if (currentButton != null) {
            currentButton.drawButton(this.mc, mouseX, mouseY, this.mc.getRenderPartialTicks());
        }
    }
    for (int j = 0; j < this.labelList.size(); ++j) {
        GuiLabel currentLabel = this.labelList.get(j);
        if (currentLabel != null) {
            currentLabel.drawLabel(this.mc, mouseX, mouseY);
        }
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) GuiLabel(net.minecraft.client.gui.GuiLabel)

Example 5 with GuiLabel

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

the class VolumeControlGui method initGui.

@Override
public void initGui() {
    final int drawX = (this.width + 1) / 2 - SLIDER_WIDTH / 2;
    final int drawY = 40;
    addSlider(new GuiSlider(this, ID_MASTER_SOUND, drawX, drawY, "dsurround.dlg.name.MasterSound", 0F, 1F, this.master, FORMAT));
    addSlider(new GuiSlider(this, ID_BIOME_SOUND, drawX, drawY + 25, "dsurround.dlg.name.BiomeSound", 0F, 1F, this.biome, FORMAT));
    addSlider(new GuiSlider(this, ID_FOOTSTEP_SOUND, drawX, drawY + 50, "dsurround.dlg.name.FootstepSound", 0F, 1F, this.footstep, FORMAT));
    final GuiLabel label = new GuiLabel(this.mc.fontRenderer, ID_LABEL, drawX, drawY + 75, SLIDER_WIDTH, 10, Color.MC_WHITE.rgb());
    label.setCentered().addLine(Localization.format("dsurround.dlg.name.Close"));
    this.labelList.add(label);
    this.panel.setMinimumWidth(SLIDER_WIDTH + this.mc.fontRenderer.FONT_HEIGHT * 2);
    this.panel.setMinimumHeight(4 * 25);
}
Also used : GuiSlider(net.minecraft.client.gui.GuiSlider) 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