From 3e863c906139c03dc5d3f357241b562c10afee5a Mon Sep 17 00:00:00 2001 From: noil Date: Sun, 27 Dec 2020 20:46:08 -0500 Subject: [PATCH] New Cape system, Updated ColorComponent --- .../api/gui/hud/component/ColorComponent.java | 45 +++++++++++++++++- .../gui/hud/component/ColorsComponent.java | 7 +-- .../gui/hud/component/TpsGraphComponent.java | 2 +- .../component/module/ModuleListComponent.java | 2 +- .../seppuku/impl/management/CapeManager.java | 6 +-- .../assets/seppukumod/textures/check.png | Bin 0 -> 1410 bytes .../textures/gear_wheel-enabled.png | Bin 0 -> 1649 bytes .../assets/seppukumod/textures/gear_wheel.png | Bin 0 -> 1526 bytes 8 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/assets/seppukumod/textures/check.png create mode 100644 src/main/resources/assets/seppukumod/textures/gear_wheel-enabled.png create mode 100644 src/main/resources/assets/seppukumod/textures/gear_wheel.png 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 0000000000000000000000000000000000000000..2a54b906bec0e4733af2a63aae13b1b1bed094f0 GIT binary patch literal 1410 zcmV-|1%3L7P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U1vB5~L~&h2L4lT>?o6f#o1b)$CxFe-BFAzcV%6 zcFn`RS}I0N!ubMryY=Uf?*75Xp1cccDdreGwva>Sf=2TDwqMDI?L2S%rEzC>$AjTk zaFzWwuCsrEU9T@#nD*t~?yOEfX*#-io(^S1W;EJNayk;;?KJOQ=Dktk&2Z+?E9YU- zWqTp>I`c3-*^_fh6VJ{?*iFCO)UGzPhGMlS%N zJ~h=%Uvm4!KW+o8fS_(NCk(LoWp}YCU297=&f?XfYw-JgA#2kCBtmROG9)12BZ*QZ zZ_Gvn9TWHzWX=+J0Rd8{+>j*)kq9`6M{K-fwDo1>-Hhc0AXK6l&}1oq6@rF{`Ib;Z z#i?je)u^UPvz90^M2#_89P3muv0!S^%#vj*Nm59fVzQJ{P9<{|EMw|&%$8HmxfBE~ zp}9-d}^p#W3`%UuBCC4h9$tY*sP_NTUlvEDXn4EHLkX% zHLsF%AUcHVB}g zc`);dLf}DeF!Pzki6|pW9dH^AVjvh+V(oOWyOR4QHwSg!<;Jhbxq)w%dKpH#w>)USRn<|4;|K2IF<2T`snIDeer+gsFzZvt!Is&x^o}C_!Qo~Hox!O zoyp?0*eA1cXR^5M<-S4eR~r3s7Pr0JS?rgm?tCuqPLbC^4y$`@{`(m{)zOJu-k%~T zhxUh4=gZ5;hgqD}=w&$fW(|FPspa2S_K7cv`^Kl}zvQUnrw#tyx_<#8v&+1&%wFLD z00D(*LqkwWLqi~Na&Km7Y-IodD3N`UJxIe)6opSyMUjew9i()~P{qN5sEDIhp$HX1 ztfkB}fK+|nAolJ)O(glehxvqHp#<}RSz%#>UCOuCaCKihwtaLCd znHupFaZJ^8$``U8tDLtuYn2*n-IKp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