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 e7ad3df..2ec28f6 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 @@ -1,6 +1,7 @@ package me.rigamortis.seppuku.api.gui.hud.component; import me.rigamortis.seppuku.Seppuku; +import me.rigamortis.seppuku.api.texture.Texture; import me.rigamortis.seppuku.api.util.ColorUtil; import me.rigamortis.seppuku.api.util.RenderUtil; import net.minecraft.client.Minecraft; @@ -17,10 +18,17 @@ public class ColorComponent extends TextComponent { private String customDisplayValue; + private final Texture gearTexture; + private final Texture gearTextureEnabled; + private final Texture checkTexture; + public ColorComponent(String name, int defaultColor) { super(name, String.valueOf(defaultColor), false); this.currentColor = new Color(defaultColor); 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"); } public ColorComponent(String name, int defaultColor, String customDisplayValue) { @@ -35,7 +43,10 @@ public class ColorComponent extends TextComponent { if (isMouseInside(mouseX, mouseY)) RenderUtil.drawGradientRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x30909090, 0x00101010); - RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45303030); + // draw bg rect + RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW() - (this.focused ? 20 : 10), this.getY() + this.getH(), 0x45303030); + + // draw color rect RenderUtil.drawRect(this.getX() + BORDER, this.getY() + BORDER, this.getX() + BORDER + COLOR_SIZE, this.getY() + BORDER + COLOR_SIZE, ColorUtil.changeAlpha(this.currentColor.getRGB(), 0xFF)); // draw name / display value @@ -47,12 +58,44 @@ public class ColorComponent extends TextComponent { } Minecraft.getMinecraft().fontRenderer.drawString(displayedName, (int) this.getX() + BORDER + COLOR_SIZE + BORDER, (int) this.getY() + BORDER, this.focused ? 0xFFFFFFFF : 0xFFAAAAAA); + // draw bg rect behind right button + RenderUtil.drawRect(this.getX() + this.getW() - (this.focused ? 20 : 10), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x45202020); + if (this.focused) { float blockX = this.getX() + BORDER + Minecraft.getMinecraft().fontRenderer.getStringWidth(this.displayValue) + COLOR_SIZE + BORDER + TEXT_BLOCK_PADDING; float blockY = this.getY() + TEXT_BLOCK_PADDING; int blockWidth = 2; int blockHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2; RenderUtil.drawRect(blockX, blockY, blockX + blockWidth, blockY + blockHeight, 0xFFFFFFFF); + + // draw gear + this.gearTextureEnabled.bind(); + this.gearTextureEnabled.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8); + + // check + this.checkTexture.bind(); + this.checkTexture.render(this.getX() + this.getW() - 19, this.getY() + 0.5f, 8, 8); + } else { + // draw gear + this.gearTexture.bind(); + this.gearTexture.render(this.getX() + this.getW() - 9, this.getY() + 0.5f, 8, 8); + } + } + + @Override + 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 + 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(); + } + } } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ColorsComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ColorsComponent.java index cba5383..24a83eb 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ColorsComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/ColorsComponent.java @@ -37,6 +37,7 @@ public final class ColorsComponent extends ResizableHudComponent { public ColorsComponent() { super("Colors", 100, 120); + this.setVisible(true); this.setSnappable(false); this.setW(120); @@ -179,7 +180,7 @@ public final class ColorsComponent extends ResizableHudComponent { this.currentColorComponent.setX(this.getX() + 20); this.currentColorComponent.setY(this.getY() + (this.getH() / 2)); this.currentColorComponent.setW(this.getW() - 40); - this.currentColorComponent.setH(10); + this.currentColorComponent.setH(9); // draw bg RenderUtil.drawRect(this.currentColorComponent.getX(), this.currentColorComponent.getY(), this.currentColorComponent.getX() + this.currentColorComponent.getW(), this.currentColorComponent.getY() + this.currentColorComponent.getH(), 0xFF101010); @@ -217,7 +218,7 @@ public final class ColorsComponent extends ResizableHudComponent { final boolean insideComponent = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT * 2) + 1 + offsetY - this.scroll); if (insideComponent && this.currentColorComponent == null) { - ColorComponent colorComponent = new ColorComponent(component.getName() + " " + value.getName(), ((Color) value.getValue()).getRGB(), ChatFormatting.WHITE + "Click to edit..."); + ColorComponent colorComponent = new ColorComponent(component.getName() + " " + value.getName(), ((Color) value.getValue()).getRGB(), ChatFormatting.WHITE + "Click to edit"); colorComponent.returnListener = new ComponentListener() { @Override public void onComponentEvent() { @@ -240,7 +241,7 @@ public final class ColorsComponent extends ResizableHudComponent { final boolean insideComponent = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT * 2) + 1 + offsetY - this.scroll); if (insideComponent && this.currentColorComponent == null) { - ColorComponent colorComponent = new ColorComponent(module.getDisplayName() + " " + value.getName(), ((Color) value.getValue()).getRGB(), ChatFormatting.WHITE + "Click to edit..."); + ColorComponent colorComponent = new ColorComponent(module.getDisplayName() + " " + value.getName(), ((Color) value.getValue()).getRGB(), ChatFormatting.WHITE + "Click to edit"); colorComponent.returnListener = new ComponentListener() { @Override public void onComponentEvent() { diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TpsGraphComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TpsGraphComponent.java index 938cdb3..1046f96 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TpsGraphComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/TpsGraphComponent.java @@ -34,7 +34,7 @@ public final class TpsGraphComponent extends ResizableHudComponent { public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - if (mc.world != null && mc.getCurrentServerData() != null) { + if (mc.world != null) { if (this.tpsNodes.size() > (this.getW() / 2)) { // overflow protection this.tpsNodes.clear(); } diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java index 7d6f3c8..5a830c7 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java @@ -434,7 +434,7 @@ public final class ModuleListComponent extends ResizableHudComponent { components.add(keybindText); ColorComponent colorComponent = new ColorComponent("List Color", module.getColor()); - colorComponent.setTooltipText("The hex color for this module in the enabled mods list."); + //colorComponent.setTooltipText("The hex color for this module in the enabled mods list."); colorComponent.returnListener = new ComponentListener() { @Override public void onComponentEvent() { diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/CapeManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/CapeManager.java index 89f6430..fdb14e9 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/CapeManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/CapeManager.java @@ -58,7 +58,7 @@ public final class CapeManager { final ResourceLocation cape = this.findResource(user.getCape()); if (cape == null) { - URL url = new URL("https://seppuku.pw/files/" + user.getCape()); + URL url = new URL(user.getCape()); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76"); final DynamicTexture texture = new DynamicTexture(ImageIO.read(httpURLConnection.getInputStream())); @@ -92,14 +92,14 @@ public final class CapeManager { */ protected void downloadCapeUsers() { try { - URL url = new URL("https://seppuku.pw/files/capes.txt"); + URL url = new URL("https://seppuku.pw/files/capes_new.txt"); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76"); final BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream())); String line; while ((line = reader.readLine()) != null) { - final String[] split = line.split(":"); + final String[] split = line.split(";"); this.capeUserList.add(new CapeUser(split[0], split[1])); } diff --git a/src/main/resources/assets/seppukumod/textures/check.png b/src/main/resources/assets/seppukumod/textures/check.png new file mode 100644 index 0000000..2a54b90 Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/check.png differ diff --git a/src/main/resources/assets/seppukumod/textures/gear_wheel-enabled.png b/src/main/resources/assets/seppukumod/textures/gear_wheel-enabled.png new file mode 100644 index 0000000..a2e71f8 Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/gear_wheel-enabled.png differ diff --git a/src/main/resources/assets/seppukumod/textures/gear_wheel.png b/src/main/resources/assets/seppukumod/textures/gear_wheel.png new file mode 100644 index 0000000..e5660f3 Binary files /dev/null and b/src/main/resources/assets/seppukumod/textures/gear_wheel.png differ