|
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +package com.gamesense.client.clickgui; |
| 6 | + |
| 7 | +import com.gamesense.client.module.modules.gui.*; |
| 8 | +import java.awt.*; |
| 9 | +import com.lukflug.panelstudio.mc12.*; |
| 10 | +import com.gamesense.api.util.render.*; |
| 11 | +import com.gamesense.api.util.font.*; |
| 12 | +import java.util.*; |
| 13 | +import com.gamesense.client.module.*; |
| 14 | +import com.lukflug.panelstudio.hud.*; |
| 15 | +import com.lukflug.panelstudio.theme.*; |
| 16 | +import com.lukflug.panelstudio.*; |
| 17 | +import com.gamesense.client.*; |
| 18 | +import com.gamesense.api.setting.*; |
| 19 | +import com.lukflug.panelstudio.settings.*; |
| 20 | +import net.minecraft.item.*; |
| 21 | +import org.lwjgl.opengl.*; |
| 22 | +import net.minecraft.client.*; |
| 23 | +import net.minecraft.client.renderer.*; |
| 24 | +import net.minecraft.entity.*; |
| 25 | +import net.minecraft.client.gui.inventory.*; |
| 26 | + |
| 27 | +public class GameSenseGUI extends MinecraftHUDGUI |
| 28 | +{ |
| 29 | + public static final int WIDTH = 100; |
| 30 | + public static final int HEIGHT = 12; |
| 31 | + public static final int DISTANCE = 10; |
| 32 | + public static final int HUD_BORDER = 2; |
| 33 | + private final Toggleable colorToggle; |
| 34 | + public final GUIInterface guiInterface; |
| 35 | + public final HUDClickGUI gui; |
| 36 | + private final Theme theme; |
| 37 | + private final Theme gamesenseTheme; |
| 38 | + private final Theme clearTheme; |
| 39 | + private final Theme cleargradientTheme; |
| 40 | + |
| 41 | + public GameSenseGUI() { |
| 42 | + final ColorScheme scheme = new SettingsColorScheme((ColorSetting)ClickGuiModule.enabledColor, (ColorSetting)ClickGuiModule.backgroundColor, (ColorSetting)ClickGuiModule.settingBackgroundColor, (ColorSetting)ClickGuiModule.outlineColor, (ColorSetting)ClickGuiModule.fontColor, (NumberSetting)ClickGuiModule.opacity); |
| 43 | + this.gamesenseTheme = new GameSenseTheme(scheme, 12, 2, 5); |
| 44 | + this.clearTheme = new ClearTheme(scheme, false, 12, 1); |
| 45 | + this.cleargradientTheme = new ClearTheme(scheme, true, 12, 1); |
| 46 | + this.theme = new ThemeMultiplexer() { |
| 47 | + @Override |
| 48 | + protected Theme getTheme() { |
| 49 | + if (ClickGuiModule.theme.getValue().equals("2.0")) { |
| 50 | + return GameSenseGUI.this.clearTheme; |
| 51 | + } |
| 52 | + if (ClickGuiModule.theme.getValue().equals("2.1.2")) { |
| 53 | + return GameSenseGUI.this.cleargradientTheme; |
| 54 | + } |
| 55 | + return GameSenseGUI.this.gamesenseTheme; |
| 56 | + } |
| 57 | + }; |
| 58 | + this.colorToggle = new Toggleable() { |
| 59 | + @Override |
| 60 | + public void toggle() { |
| 61 | + ColorMain.colorModel.increment(); |
| 62 | + } |
| 63 | + |
| 64 | + @Override |
| 65 | + public boolean isOn() { |
| 66 | + return ColorMain.colorModel.getValue().equals("HSB"); |
| 67 | + } |
| 68 | + }; |
| 69 | + this.guiInterface = new GUIInterface(true) { |
| 70 | + @Override |
| 71 | + public void drawString(final Point pos, final String s, final Color c) { |
| 72 | + GLInterface.end(); |
| 73 | + int x = pos.x + 2; |
| 74 | + int y = pos.y + 1; |
| 75 | + if (!ColorMain.customFont.getValue()) { |
| 76 | + ++x; |
| 77 | + ++y; |
| 78 | + } |
| 79 | + FontUtil.drawStringWithShadow(ColorMain.customFont.getValue(), s, x, y, new GSColor(c)); |
| 80 | + GLInterface.begin(); |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + public int getFontWidth(final String s) { |
| 85 | + return Math.round((float)FontUtil.getStringWidth(ColorMain.customFont.getValue(), s)) + 4; |
| 86 | + } |
| 87 | + |
| 88 | + @Override |
| 89 | + public int getFontHeight() { |
| 90 | + return Math.round((float)FontUtil.getFontHeight(ColorMain.customFont.getValue())) + 2; |
| 91 | + } |
| 92 | + |
| 93 | + public String getResourcePrefix() { |
| 94 | + return "gamesense:gui/"; |
| 95 | + } |
| 96 | + }; |
| 97 | + this.gui = new HUDClickGUI(this.guiInterface, null) { |
| 98 | + @Override |
| 99 | + public void handleScroll(final int diff) { |
| 100 | + super.handleScroll(diff); |
| 101 | + if (ClickGuiModule.scrolling.getValue().equals("Screen")) { |
| 102 | + for (final FixedComponent component : this.components) { |
| 103 | + if (!this.hudComponents.contains(component)) { |
| 104 | + final Point p = component.getPosition(GameSenseGUI.this.guiInterface); |
| 105 | + p.translate(0, -diff); |
| 106 | + component.setPosition(GameSenseGUI.this.guiInterface, p); |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + }; |
| 112 | + final Toggleable hudToggle = new Toggleable() { |
| 113 | + @Override |
| 114 | + public void toggle() { |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public boolean isOn() { |
| 119 | + return (GameSenseGUI.this.gui.isOn() && ClickGuiModule.showHUD.isOn()) || GameSenseGUI.this.hudEditor; |
| 120 | + } |
| 121 | + }; |
| 122 | + for (final Module module : ModuleManager.getModules()) { |
| 123 | + if (module instanceof HUDModule) { |
| 124 | + ((HUDModule)module).populate(this.theme); |
| 125 | + this.gui.addHUDComponent(new HUDPanel(((HUDModule)module).getComponent(), this.theme.getPanelRenderer(), module, new SettingsAnimation((NumberSetting)ClickGuiModule.animationSpeed), hudToggle, 2)); |
| 126 | + } |
| 127 | + } |
| 128 | + final Point pos = new Point(10, 10); |
| 129 | + for (final Module.Category category : Module.Category.values()) { |
| 130 | + final DraggableContainer panel = new DraggableContainer(category.name(), null, this.theme.getPanelRenderer(), new SimpleToggleable(false), new SettingsAnimation((NumberSetting)ClickGuiModule.animationSpeed), null, new Point(pos), 100) { |
| 131 | + @Override |
| 132 | + protected int getScrollHeight(final int childHeight) { |
| 133 | + if (ClickGuiModule.scrolling.getValue().equals("Screen")) { |
| 134 | + return childHeight; |
| 135 | + } |
| 136 | + return Math.min(childHeight, Math.max(48, GameSenseGUI.this.height - this.getPosition(GameSenseGUI.this.guiInterface).y - this.renderer.getHeight(this.open.getValue() != 0.0) - 12)); |
| 137 | + } |
| 138 | + }; |
| 139 | + this.gui.addComponent(panel); |
| 140 | + pos.translate(110, 0); |
| 141 | + for (final Module module2 : ModuleManager.getModulesInCategory(category)) { |
| 142 | + this.addModule(panel, module2); |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + private void addModule(final CollapsibleContainer panel, final Module module) { |
| 148 | + final CollapsibleContainer container = new CollapsibleContainer(module.getName(), null, this.theme.getContainerRenderer(), new SimpleToggleable(false), new SettingsAnimation((NumberSetting)ClickGuiModule.animationSpeed), module); |
| 149 | + panel.addComponent(container); |
| 150 | + for (final Setting property : GameSense.getInstance().settingsManager.getSettingsForMod(module)) { |
| 151 | + if (property instanceof Setting.Boolean) { |
| 152 | + container.addComponent(new BooleanComponent(property.getName(), null, this.theme.getComponentRenderer(), (Toggleable)property)); |
| 153 | + } |
| 154 | + else if (property instanceof Setting.Integer) { |
| 155 | + container.addComponent(new NumberComponent(property.getName(), null, this.theme.getComponentRenderer(), (NumberSetting)property, ((Setting.Integer)property).getMin(), ((Setting.Integer)property).getMax())); |
| 156 | + } |
| 157 | + else if (property instanceof Setting.Double) { |
| 158 | + container.addComponent(new NumberComponent(property.getName(), null, this.theme.getComponentRenderer(), (NumberSetting)property, ((Setting.Double)property).getMin(), ((Setting.Double)property).getMax())); |
| 159 | + } |
| 160 | + else if (property instanceof Setting.Mode) { |
| 161 | + container.addComponent(new EnumComponent(property.getName(), null, this.theme.getComponentRenderer(), (EnumSetting)property)); |
| 162 | + } |
| 163 | + else { |
| 164 | + if (!(property instanceof Setting.ColorSetting)) { |
| 165 | + continue; |
| 166 | + } |
| 167 | + container.addComponent(new SyncableColorComponent(this.theme, (Setting.ColorSetting)property, this.colorToggle, new SettingsAnimation((NumberSetting)ClickGuiModule.animationSpeed))); |
| 168 | + } |
| 169 | + } |
| 170 | + container.addComponent(new GameSenseKeybind(this.theme.getComponentRenderer(), module)); |
| 171 | + } |
| 172 | + |
| 173 | + public static void renderItem(final ItemStack item, final Point pos) { |
| 174 | + GlStateManager.enableTexture2D(); |
| 175 | + GlStateManager.depthMask(true); |
| 176 | + GL11.glPushAttrib(524288); |
| 177 | + GL11.glDisable(3089); |
| 178 | + GlStateManager.clear(256); |
| 179 | + GL11.glPopAttrib(); |
| 180 | + GlStateManager.enableDepth(); |
| 181 | + GlStateManager.disableAlpha(); |
| 182 | + GlStateManager.pushMatrix(); |
| 183 | + Minecraft.getMinecraft().getRenderItem().zLevel = -150.0f; |
| 184 | + RenderHelper.enableGUIStandardItemLighting(); |
| 185 | + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(item, pos.x, pos.y); |
| 186 | + Minecraft.getMinecraft().getRenderItem().renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, item, pos.x, pos.y); |
| 187 | + RenderHelper.disableStandardItemLighting(); |
| 188 | + Minecraft.getMinecraft().getRenderItem().zLevel = 0.0f; |
| 189 | + GlStateManager.popMatrix(); |
| 190 | + GlStateManager.disableDepth(); |
| 191 | + GlStateManager.depthMask(false); |
| 192 | + GLInterface.begin(); |
| 193 | + } |
| 194 | + |
| 195 | + public static void renderEntity(final EntityLivingBase entity, final Point pos, final int scale) { |
| 196 | + GlStateManager.enableTexture2D(); |
| 197 | + GlStateManager.depthMask(true); |
| 198 | + GL11.glPushAttrib(524288); |
| 199 | + GL11.glDisable(3089); |
| 200 | + GlStateManager.clear(256); |
| 201 | + GL11.glPopAttrib(); |
| 202 | + GlStateManager.enableDepth(); |
| 203 | + GlStateManager.disableAlpha(); |
| 204 | + GlStateManager.pushMatrix(); |
| 205 | + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); |
| 206 | + GuiInventory.drawEntityOnScreen(pos.x, pos.y, scale, 28.0f, 60.0f, entity); |
| 207 | + GlStateManager.popMatrix(); |
| 208 | + GlStateManager.disableDepth(); |
| 209 | + GlStateManager.depthMask(false); |
| 210 | + GLInterface.begin(); |
| 211 | + } |
| 212 | + |
| 213 | + @Override |
| 214 | + protected HUDClickGUI getHUDGUI() { |
| 215 | + return this.gui; |
| 216 | + } |
| 217 | + |
| 218 | + @Override |
| 219 | + protected GUIInterface getInterface() { |
| 220 | + return this.guiInterface; |
| 221 | + } |
| 222 | + |
| 223 | + @Override |
| 224 | + protected int getScrollSpeed() { |
| 225 | + return ClickGuiModule.scrollSpeed.getValue(); |
| 226 | + } |
| 227 | +} |
0 commit comments