Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.cakestory.hudex.gui;
- import java.awt.Color;
- import java.util.Arrays;
- import java.util.List;
- import com.cakestory.hudex.HudEx;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.resources.I18n;
- import net.minecraft.util.EnumChatFormatting;
- @SideOnly(Side.CLIENT)
- public class GuiScreenOptions extends GuiScreen {
- // -------- Button labels --------
- private String effectBtnLabel;
- private String armorBtnLabel;
- private String durationBtnLabel;
- private String formatArmorBtnLabel;
- private String formatToolBtnLabel;
- private String chargeArmorBtnLabel;
- private String toolBtnLabel;
- private String chargeToolBtnLabel;
- private String colorBtnLabel;
- // -------------------------------
- @Override
- public void initGui() {
- getButtonLabels();
- drawButtonList();
- }
- @Override
- public boolean doesGuiPauseGame() {
- return false;
- }
- @Override
- public void drawScreen(int x, int y, float f) {
- this.drawDefaultBackground();
- drawRect(width / 2 - 105, 60, width / 2 - 35, height / 2 + 5, new Color(50, 170, 170, 70).getRGB());
- drawRect(width / 2 + 35, 60, width / 2 + 105, height / 2 + 30, new Color(85, 75, 170, 70).getRGB());
- drawRect(width / 2 - 105, height / 2 + 10, width / 2 - 35, height / 2 + 105, new Color(170, 155, 75, 70).getRGB());
- drawRect(width / 2 + 125, 60, width / 2 + 195, height / 2 + 30, new Color(185, 35, 50, 70).getRGB());
- this.drawCenteredString(fontRendererObj, I18n.format("menu.title"), width / 2, 25, Color.WHITE.getRGB());
- this.drawCenteredString(fontRendererObj, I18n.format("label.buff"), width / 2 - 70, 63, Color.WHITE.getRGB());
- this.drawCenteredString(fontRendererObj, I18n.format("label.armor"), width / 2 + 71, 63, Color.WHITE.getRGB());
- this.drawCenteredString(fontRendererObj, I18n.format("label.tool"), width / 2 + 161, 63, Color.WHITE.getRGB());
- this.drawCenteredString(fontRendererObj, I18n.format("label.options"), width / 2 - 69, height / 2 + 15, Color.WHITE.getRGB());
- for (int i = 0; i < buttonList.size(); i++) {
- if (buttonList.get(i) instanceof GuiButtonAdvanced) {
- GuiButtonAdvanced btn = (GuiButtonAdvanced) buttonList.get(i);
- if (btn.func_146115_a()) {
- String[] desc = { btn.description };
- @SuppressWarnings("rawtypes")
- List temp = Arrays.asList(desc);
- drawHoveringText(temp, x, y, fontRendererObj);
- }
- }
- }
- super.drawScreen(x, y, f);
- }
- public void actionPerformed(GuiButton btn) {
- switch (btn.id) {
- case 0:
- if (GuiOverlay.options.get("buffs")) {
- effectBtnLabel = EnumChatFormatting.RED + I18n.format("button.buff");
- GuiOverlay.options.put("buffs", false);
- } else {
- effectBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.buff");
- GuiOverlay.options.put("buffs", true);
- }
- break;
- case 1:
- if (GuiOverlay.options.get("armor")) {
- armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.armor");
- GuiOverlay.options.put("armor", false);
- } else {
- armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.armor");
- GuiOverlay.options.put("armor", true);
- }
- break;
- case 2:
- if (GuiOverlay.options.get("duration")) {
- durationBtnLabel = EnumChatFormatting.RED + I18n.format("button.duration");
- GuiOverlay.options.put("duration", false);
- } else {
- durationBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.duration");
- GuiOverlay.options.put("duration", true);
- }
- break;
- case 3:
- if (GuiOverlay.toggles.get("armor") == 0) {
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
- GuiOverlay.toggles.put("armor", 1);
- } else if (GuiOverlay.toggles.get("armor") == 1) {
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
- GuiOverlay.toggles.put("armor", 2);
- } else if (GuiOverlay.toggles.get("armor") == 2) {
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
- GuiOverlay.toggles.put("armor", 3);
- } else {
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
- GuiOverlay.toggles.put("armor", 0);
- }
- break;
- case 4:
- HudEx.proxy.displayGUI(Minecraft.getMinecraft().thePlayer, new GuiScreenScaling());
- break;
- case 5:
- if (GuiOverlay.options.get("charge_armor")) {
- chargeArmorBtnLabel = EnumChatFormatting.RED + I18n.format("button.charge");
- GuiOverlay.options.put("charge_armor", false);
- } else {
- chargeArmorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.charge");
- GuiOverlay.options.put("charge_armor", true);
- }
- break;
- case 6:
- if (GuiOverlay.options.get("tool")) {
- armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.tool");
- GuiOverlay.options.put("tool", false);
- } else {
- armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.tool");
- GuiOverlay.options.put("tool", true);
- }
- break;
- case 7:
- if (GuiOverlay.toggles.get("tool") == 0) {
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
- GuiOverlay.toggles.put("tool", 1);
- } else if (GuiOverlay.toggles.get("tool") == 1) {
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
- GuiOverlay.toggles.put("tool", 2);
- } else if (GuiOverlay.toggles.get("tool") == 2) {
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
- GuiOverlay.toggles.put("tool", 3);
- } else {
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
- GuiOverlay.toggles.put("tool", 0);
- }
- break;
- case 8:
- if (GuiOverlay.options.get("charge_tool")) {
- armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.charge");
- GuiOverlay.options.put("charge_tool", false);
- } else {
- armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.charge");
- GuiOverlay.options.put("charge_tool", true);
- }
- break;
- case 9:
- if (GuiOverlay.options.get("color")) {
- colorBtnLabel = EnumChatFormatting.RED + I18n.format("button.color");
- GuiOverlay.options.put("color", false);
- } else {
- colorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.color");
- GuiOverlay.options.put("color", true);
- }
- break;
- case 10:
- GuiOverlay.resetAll();
- break;
- }
- // Update Buttons
- getButtonLabels();
- drawButtonList();
- }
- /** Used to get the label for each button based on its incoperating variable */
- private void getButtonLabels() {
- // Switch button labels of hud elements
- effectBtnLabel = GuiOverlay.options.get("buffs") ? EnumChatFormatting.GREEN + I18n.format("button.buff") : EnumChatFormatting.RED + I18n.format("button.buff");
- armorBtnLabel = GuiOverlay.options.get("armor") ? EnumChatFormatting.GREEN + I18n.format("button.armor") : EnumChatFormatting.RED + I18n.format("button.armor");
- toolBtnLabel = GuiOverlay.options.get("tool") ? EnumChatFormatting.GREEN + I18n.format("button.tool") : EnumChatFormatting.RED + I18n.format("button.tool");
- // Switch button labels of hud text
- durationBtnLabel = GuiOverlay.options.get("duration") ? EnumChatFormatting.GREEN + I18n.format("button.duration") : EnumChatFormatting.RED + I18n.format("button.duration");
- chargeArmorBtnLabel = GuiOverlay.options.get("charge_armor") ? EnumChatFormatting.GREEN + I18n.format("button.charge") : EnumChatFormatting.RED + I18n.format("button.charge");
- chargeToolBtnLabel = GuiOverlay.options.get("charge_tool") ? EnumChatFormatting.GREEN + I18n.format("button.charge") : EnumChatFormatting.RED + I18n.format("button.charge");
- colorBtnLabel = GuiOverlay.options.get("color") ? EnumChatFormatting.GREEN + I18n.format("button.color") : EnumChatFormatting.RED + I18n.format("button.color");
- switch (GuiOverlay.toggles.get("armor")) {
- case 0:
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
- break;
- case 1:
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
- break;
- case 2:
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
- break;
- case 3:
- formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
- }
- switch (GuiOverlay.toggles.get("tool")) {
- case 0:
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
- break;
- case 1:
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
- break;
- case 2:
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
- break;
- case 3:
- formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
- }
- }
- /** Draws all buttons. Also used for updating button labels. */
- @SuppressWarnings("unchecked")
- private void drawButtonList() {
- buttonList.clear();
- buttonList.add(new GuiButtonAdvanced(0, width / 2 - 100, height / 2 - 50, 60, 20, effectBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(1, width / 2 + 40, height / 2 - 50, 60, 20, armorBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(2, width / 2 - 100, height / 2 - 25, 60, 20, durationBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(3, width / 2 + 40, height / 2 - 25, 60, 20, formatArmorBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(4, width / 2 - 100, height / 2 + 27, 60, 20, I18n.format("button.options"), "Test"));
- buttonList.add(new GuiButtonAdvanced(5, width / 2 + 40, height / 2, 60, 20, chargeArmorBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(6, width / 2 + 130, height / 2 - 50, 60, 20, toolBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(7, width / 2 + 130, height / 2 - 25, 60, 20, formatToolBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(8, width / 2 + 130, height / 2, 60, 20, chargeToolBtnLabel, "Test"));
- buttonList.add(new GuiButtonAdvanced(9, width / 2 - 100, height / 2 + 73, 60, 20, I18n.format(colorBtnLabel), "Test"));
- buttonList.add(new GuiButtonAdvanced(10, width / 2 - 100, height / 2 + 50, 60, 20, I18n.format("button.reset"), "Test"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement