Advertisement
Guest User

Cakestory HudEx Menu

a guest
Apr 8th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.17 KB | None | 0 0
  1. package com.cakestory.hudex.gui;
  2.  
  3. import java.awt.Color;
  4. import java.util.Arrays;
  5. import java.util.List;
  6.  
  7. import com.cakestory.hudex.HudEx;
  8.  
  9. import cpw.mods.fml.relauncher.Side;
  10. import cpw.mods.fml.relauncher.SideOnly;
  11. import net.minecraft.client.Minecraft;
  12. import net.minecraft.client.gui.GuiButton;
  13. import net.minecraft.client.gui.GuiScreen;
  14. import net.minecraft.client.resources.I18n;
  15. import net.minecraft.util.EnumChatFormatting;
  16.  
  17. @SideOnly(Side.CLIENT)
  18. public class GuiScreenOptions extends GuiScreen {
  19.  
  20. // -------- Button labels --------
  21. private String effectBtnLabel;
  22. private String armorBtnLabel;
  23. private String durationBtnLabel;
  24. private String formatArmorBtnLabel;
  25. private String formatToolBtnLabel;
  26. private String chargeArmorBtnLabel;
  27. private String toolBtnLabel;
  28. private String chargeToolBtnLabel;
  29. private String colorBtnLabel;
  30.  
  31. // -------------------------------
  32.  
  33. @Override
  34. public void initGui() {
  35. getButtonLabels();
  36. drawButtonList();
  37. }
  38.  
  39. @Override
  40. public boolean doesGuiPauseGame() {
  41. return false;
  42. }
  43.  
  44. @Override
  45. public void drawScreen(int x, int y, float f) {
  46. this.drawDefaultBackground();
  47.  
  48. drawRect(width / 2 - 105, 60, width / 2 - 35, height / 2 + 5, new Color(50, 170, 170, 70).getRGB());
  49. drawRect(width / 2 + 35, 60, width / 2 + 105, height / 2 + 30, new Color(85, 75, 170, 70).getRGB());
  50. drawRect(width / 2 - 105, height / 2 + 10, width / 2 - 35, height / 2 + 105, new Color(170, 155, 75, 70).getRGB());
  51. drawRect(width / 2 + 125, 60, width / 2 + 195, height / 2 + 30, new Color(185, 35, 50, 70).getRGB());
  52.  
  53. this.drawCenteredString(fontRendererObj, I18n.format("menu.title"), width / 2, 25, Color.WHITE.getRGB());
  54. this.drawCenteredString(fontRendererObj, I18n.format("label.buff"), width / 2 - 70, 63, Color.WHITE.getRGB());
  55. this.drawCenteredString(fontRendererObj, I18n.format("label.armor"), width / 2 + 71, 63, Color.WHITE.getRGB());
  56. this.drawCenteredString(fontRendererObj, I18n.format("label.tool"), width / 2 + 161, 63, Color.WHITE.getRGB());
  57. this.drawCenteredString(fontRendererObj, I18n.format("label.options"), width / 2 - 69, height / 2 + 15, Color.WHITE.getRGB());
  58.  
  59. for (int i = 0; i < buttonList.size(); i++) {
  60. if (buttonList.get(i) instanceof GuiButtonAdvanced) {
  61. GuiButtonAdvanced btn = (GuiButtonAdvanced) buttonList.get(i);
  62. if (btn.func_146115_a()) {
  63. String[] desc = { btn.description };
  64. @SuppressWarnings("rawtypes")
  65. List temp = Arrays.asList(desc);
  66. drawHoveringText(temp, x, y, fontRendererObj);
  67. }
  68. }
  69. }
  70.  
  71. super.drawScreen(x, y, f);
  72. }
  73.  
  74. public void actionPerformed(GuiButton btn) {
  75. switch (btn.id) {
  76. case 0:
  77. if (GuiOverlay.options.get("buffs")) {
  78. effectBtnLabel = EnumChatFormatting.RED + I18n.format("button.buff");
  79. GuiOverlay.options.put("buffs", false);
  80. } else {
  81. effectBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.buff");
  82. GuiOverlay.options.put("buffs", true);
  83. }
  84. break;
  85. case 1:
  86. if (GuiOverlay.options.get("armor")) {
  87. armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.armor");
  88. GuiOverlay.options.put("armor", false);
  89. } else {
  90. armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.armor");
  91. GuiOverlay.options.put("armor", true);
  92. }
  93. break;
  94.  
  95. case 2:
  96. if (GuiOverlay.options.get("duration")) {
  97. durationBtnLabel = EnumChatFormatting.RED + I18n.format("button.duration");
  98. GuiOverlay.options.put("duration", false);
  99. } else {
  100. durationBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.duration");
  101. GuiOverlay.options.put("duration", true);
  102. }
  103. break;
  104.  
  105. case 3:
  106. if (GuiOverlay.toggles.get("armor") == 0) {
  107. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
  108. GuiOverlay.toggles.put("armor", 1);
  109. } else if (GuiOverlay.toggles.get("armor") == 1) {
  110. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
  111. GuiOverlay.toggles.put("armor", 2);
  112. } else if (GuiOverlay.toggles.get("armor") == 2) {
  113. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
  114. GuiOverlay.toggles.put("armor", 3);
  115. } else {
  116. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
  117. GuiOverlay.toggles.put("armor", 0);
  118. }
  119. break;
  120.  
  121. case 4:
  122. HudEx.proxy.displayGUI(Minecraft.getMinecraft().thePlayer, new GuiScreenScaling());
  123. break;
  124.  
  125. case 5:
  126. if (GuiOverlay.options.get("charge_armor")) {
  127. chargeArmorBtnLabel = EnumChatFormatting.RED + I18n.format("button.charge");
  128. GuiOverlay.options.put("charge_armor", false);
  129. } else {
  130. chargeArmorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.charge");
  131. GuiOverlay.options.put("charge_armor", true);
  132. }
  133. break;
  134.  
  135. case 6:
  136. if (GuiOverlay.options.get("tool")) {
  137. armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.tool");
  138. GuiOverlay.options.put("tool", false);
  139. } else {
  140. armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.tool");
  141. GuiOverlay.options.put("tool", true);
  142. }
  143. break;
  144.  
  145. case 7:
  146. if (GuiOverlay.toggles.get("tool") == 0) {
  147. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
  148. GuiOverlay.toggles.put("tool", 1);
  149. } else if (GuiOverlay.toggles.get("tool") == 1) {
  150. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
  151. GuiOverlay.toggles.put("tool", 2);
  152. } else if (GuiOverlay.toggles.get("tool") == 2) {
  153. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
  154. GuiOverlay.toggles.put("tool", 3);
  155. } else {
  156. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
  157. GuiOverlay.toggles.put("tool", 0);
  158. }
  159. break;
  160.  
  161. case 8:
  162. if (GuiOverlay.options.get("charge_tool")) {
  163. armorBtnLabel = EnumChatFormatting.RED + I18n.format("button.charge");
  164. GuiOverlay.options.put("charge_tool", false);
  165. } else {
  166. armorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.charge");
  167. GuiOverlay.options.put("charge_tool", true);
  168. }
  169. break;
  170. case 9:
  171. if (GuiOverlay.options.get("color")) {
  172. colorBtnLabel = EnumChatFormatting.RED + I18n.format("button.color");
  173. GuiOverlay.options.put("color", false);
  174. } else {
  175. colorBtnLabel = EnumChatFormatting.GREEN + I18n.format("button.color");
  176. GuiOverlay.options.put("color", true);
  177. }
  178. break;
  179.  
  180. case 10:
  181. GuiOverlay.resetAll();
  182. break;
  183. }
  184.  
  185. // Update Buttons
  186. getButtonLabels();
  187. drawButtonList();
  188. }
  189.  
  190. /** Used to get the label for each button based on its incoperating variable */
  191. private void getButtonLabels() {
  192. // Switch button labels of hud elements
  193. effectBtnLabel = GuiOverlay.options.get("buffs") ? EnumChatFormatting.GREEN + I18n.format("button.buff") : EnumChatFormatting.RED + I18n.format("button.buff");
  194. armorBtnLabel = GuiOverlay.options.get("armor") ? EnumChatFormatting.GREEN + I18n.format("button.armor") : EnumChatFormatting.RED + I18n.format("button.armor");
  195. toolBtnLabel = GuiOverlay.options.get("tool") ? EnumChatFormatting.GREEN + I18n.format("button.tool") : EnumChatFormatting.RED + I18n.format("button.tool");
  196.  
  197. // Switch button labels of hud text
  198. durationBtnLabel = GuiOverlay.options.get("duration") ? EnumChatFormatting.GREEN + I18n.format("button.duration") : EnumChatFormatting.RED + I18n.format("button.duration");
  199. chargeArmorBtnLabel = GuiOverlay.options.get("charge_armor") ? EnumChatFormatting.GREEN + I18n.format("button.charge") : EnumChatFormatting.RED + I18n.format("button.charge");
  200. chargeToolBtnLabel = GuiOverlay.options.get("charge_tool") ? EnumChatFormatting.GREEN + I18n.format("button.charge") : EnumChatFormatting.RED + I18n.format("button.charge");
  201. colorBtnLabel = GuiOverlay.options.get("color") ? EnumChatFormatting.GREEN + I18n.format("button.color") : EnumChatFormatting.RED + I18n.format("button.color");
  202.  
  203. switch (GuiOverlay.toggles.get("armor")) {
  204. case 0:
  205. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
  206. break;
  207. case 1:
  208. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
  209. break;
  210. case 2:
  211. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
  212. break;
  213. case 3:
  214. formatArmorBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
  215. }
  216.  
  217. switch (GuiOverlay.toggles.get("tool")) {
  218. case 0:
  219. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.nodamage");
  220. break;
  221. case 1:
  222. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.percent");
  223. break;
  224. case 2:
  225. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.rest");
  226. break;
  227. case 3:
  228. formatToolBtnLabel = EnumChatFormatting.GOLD + I18n.format("button.compare");
  229. }
  230. }
  231.  
  232. /** Draws all buttons. Also used for updating button labels. */
  233. @SuppressWarnings("unchecked")
  234. private void drawButtonList() {
  235. buttonList.clear();
  236. buttonList.add(new GuiButtonAdvanced(0, width / 2 - 100, height / 2 - 50, 60, 20, effectBtnLabel, "Test"));
  237. buttonList.add(new GuiButtonAdvanced(1, width / 2 + 40, height / 2 - 50, 60, 20, armorBtnLabel, "Test"));
  238. buttonList.add(new GuiButtonAdvanced(2, width / 2 - 100, height / 2 - 25, 60, 20, durationBtnLabel, "Test"));
  239. buttonList.add(new GuiButtonAdvanced(3, width / 2 + 40, height / 2 - 25, 60, 20, formatArmorBtnLabel, "Test"));
  240. buttonList.add(new GuiButtonAdvanced(4, width / 2 - 100, height / 2 + 27, 60, 20, I18n.format("button.options"), "Test"));
  241. buttonList.add(new GuiButtonAdvanced(5, width / 2 + 40, height / 2, 60, 20, chargeArmorBtnLabel, "Test"));
  242. buttonList.add(new GuiButtonAdvanced(6, width / 2 + 130, height / 2 - 50, 60, 20, toolBtnLabel, "Test"));
  243. buttonList.add(new GuiButtonAdvanced(7, width / 2 + 130, height / 2 - 25, 60, 20, formatToolBtnLabel, "Test"));
  244. buttonList.add(new GuiButtonAdvanced(8, width / 2 + 130, height / 2, 60, 20, chargeToolBtnLabel, "Test"));
  245. buttonList.add(new GuiButtonAdvanced(9, width / 2 - 100, height / 2 + 73, 60, 20, I18n.format(colorBtnLabel), "Test"));
  246. buttonList.add(new GuiButtonAdvanced(10, width / 2 - 100, height / 2 + 50, 60, 20, I18n.format("button.reset"), "Test"));
  247.  
  248. }
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement