diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java | 21 | ||||
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java | 17 |
2 files changed, 25 insertions, 13 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java index 3ded1b1..a87e412 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -16,13 +16,10 @@ public class BasicButton extends BasicElement { private final int thisAlignment; private final float fontSize; private final int colorPalette; - public int x, y; public static final int ALIGNMENT_LEFT = 0; public static final int ALIGNMENT_CENTER = 1; - private boolean toggleable; - private Page page; private Runnable runnable; @@ -66,6 +63,11 @@ public class BasicButton extends BasicElement { this.runnable = runnable; } + public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) { + this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment, runnable); + this.toggleable = toggleable; + } + @Override public void draw(long vg, int x, int y) { this.x = x; @@ -84,6 +86,7 @@ public class BasicButton extends BasicElement { textColor = OneConfigConfig.WHITE_80; if (hovered) textColor = OneConfigConfig.WHITE; if (clicked) textColor = OneConfigConfig.WHITE_80; + if (page == null) textColor = OneConfigConfig.WHITE_50; } if (thisAlignment == ALIGNMENT_CENTER) { @@ -98,7 +101,7 @@ public class BasicButton extends BasicElement { } if (thisAlignment == ALIGNMENT_LEFT) { if (fileNameLeftIco != null) { - RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20); + RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20, textColor); RenderManager.drawString(vg, text, x + 40, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM); } else { RenderManager.drawString(vg, text, x + 12, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM); @@ -133,10 +136,20 @@ public class BasicButton extends BasicElement { } } + @Override + public void update(int x, int y) { + if (toggleable && toggled) return; + super.update(x, y); + } + public void setToggled(boolean state) { this.toggled = state; } + public Page getPage() { + return page; + } + public String getText() { return text; } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java index 09c6aa0..bb8b830 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java @@ -11,6 +11,8 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts; import io.polyfrost.oneconfig.utils.ColorUtils; import io.polyfrost.oneconfig.utils.InputUtils; import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.ModMetadata; import org.jetbrains.annotations.NotNull; @@ -94,15 +96,12 @@ public class ModCard extends BasicElement { if (mod.name.equalsIgnoreCase(modData.name)) { System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name); for (String commands : ClientCommandHandler.instance.getCommands().keySet()) { - if (commands.equalsIgnoreCase(mod.name)) { - System.out.println("Found command for mod: /" + commands); - Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands); - //Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + mod.name.toLowerCase()); - break; - } - if (commands.equalsIgnoreCase(mod.modId)) { - System.out.println("Found command for mod: /" + commands); - Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands); + if (commands.equalsIgnoreCase(mod.name) || commands.equalsIgnoreCase(mod.modId)) { + try { + ClientCommandHandler.instance.getCommands().get(commands).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{}); + } catch (CommandException e) { + throw new RuntimeException(e); + } break; } } |