diff --git a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/ColorComponent.java b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/ColorComponent.java index 18c2648..a1ef297 100644 --- a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/ColorComponent.java +++ b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/ColorComponent.java @@ -21,7 +21,6 @@ public class ColorComponent extends TextComponent { private final Texture gearTexture; private final Texture gearTextureEnabled; - private final Texture checkTexture; public ColorComponent(String name, int defaultColor) { super(name, String.valueOf(defaultColor), false); @@ -29,7 +28,6 @@ public class ColorComponent extends TextComponent { this.displayValue = "#" + Integer.toHexString(this.currentColor.getRGB()).toLowerCase().substring(2); this.gearTexture = new Texture("gear_wheel.png"); this.gearTextureEnabled = new Texture("gear_wheel-enabled.png"); - this.checkTexture = new Texture("check.png"); this.setH(9); } @@ -77,10 +75,12 @@ public class ColorComponent extends TextComponent { RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF); // draw gear + RenderUtil.drawRect(this.getX() + this.getW() - 10, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010); this.gearTextureEnabled.bind(); this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8); // check + RenderUtil.drawRect(this.getX() + this.getW() - 20, this.getY(), this.getX() + this.getW() - 10, this.getY() + this.getH(), 0xFF101010); this.checkTexture.bind(); this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8); @@ -107,15 +107,13 @@ public class ColorComponent extends TextComponent { public void mouseRelease(int mouseX, int mouseY, int button) { super.mouseRelease(mouseX, mouseY, button); - if (!this.focused || !this.isMouseInside(mouseX, mouseY)) // must be focused & inside + if (!this.focused) // must be focused return; - if (this.isMouseInside(mouseX, mouseY)) { - if (button == 0) { - // check for clicking check - if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) { - this.enterPressed(); - } + if (button == 0) { + // check for clicking check + if (mouseX >= this.getX() + this.getW() - 20 && mouseX <= this.getX() + this.getW() - 10 && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) { + this.enterPressed(); } } } diff --git a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/TextComponent.java b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/TextComponent.java index ceff387..9b8b11b 100644 --- a/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/TextComponent.java +++ b/src/main/java/me/rigamortis/seppuku/api/gui/hud/component/TextComponent.java @@ -1,5 +1,6 @@ package me.rigamortis.seppuku.api.gui.hud.component; +import me.rigamortis.seppuku.api.texture.Texture; import me.rigamortis.seppuku.api.util.RenderUtil; import me.rigamortis.seppuku.api.util.Timer; import net.minecraft.client.Minecraft; @@ -16,6 +17,8 @@ public class TextComponent extends HudComponent { public ComponentListener returnListener; public TextComponentListener textListener; + protected Texture checkTexture; + protected Timer backspaceTimer = new Timer(), backspaceWaitTimer = new Timer(); protected boolean doBackspacing = false; @@ -25,6 +28,8 @@ public class TextComponent extends HudComponent { this.displayValue = displayValue; this.focused = false; this.digitOnly = digitOnly; + + this.checkTexture = new Texture("check.png"); } @Override @@ -44,6 +49,11 @@ public class TextComponent extends HudComponent { int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2; RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF); + // check + RenderUtil.drawRect(this.getX() + this.getW() - 10, this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF101010); + this.checkTexture.bind(); + this.checkTexture.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8); + if (Keyboard.isKeyDown(Keyboard.KEY_BACK) || Keyboard.isKeyDown(Keyboard.KEY_DELETE)) { if (this.doBackspacing && this.backspaceWaitTimer.passed(750)) { if (this.backspaceTimer.passed(75)) { @@ -63,12 +73,18 @@ public class TextComponent extends HudComponent { public void mouseRelease(int mouseX, int mouseY, int button) { super.mouseRelease(mouseX, mouseY, button); - if (!this.isMouseInside(mouseX, mouseY) || button != 0) { - this.focused = false; - return; - } + if (this.isMouseInside(mouseX, mouseY) && button == 0) { + this.focused = true; - this.focused = true; + // check for clicking check + if (!(this instanceof ColorComponent)) { + if (mouseX >= this.getX() + this.getW() - 10 && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH()) { + this.enterPressed(); + } + } + } else { + this.focused = false; + } } @Override diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TrayComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TrayComponent.java index ed610c4..3e0336b 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TrayComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TrayComponent.java @@ -28,6 +28,7 @@ public class TrayComponent extends DraggableHudComponent { super("Tray"); buttons.add(new TrayButtonComponent("hub")); + buttons.add(new TrayButtonComponent("colors")); buttons.add(new TrayButtonComponent("combat")); buttons.add(new TrayButtonComponent("movement")); buttons.add(new TrayButtonComponent("render")); diff --git a/src/main/resources/assets/seppukumod/textures/module-colors-enabled.png b/src/main/resources/assets/seppukumod/textures/module-colors-enabled.png new file mode 100644 index 0000000..055a3ea Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/module-colors-enabled.png differ diff --git a/src/main/resources/assets/seppukumod/textures/module-colors.png b/src/main/resources/assets/seppukumod/textures/module-colors.png new file mode 100644 index 0000000..b7d5268 Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/module-colors.png differ