From 937b7215557b4e36e36623f28ac274c3c404d1cf Mon Sep 17 00:00:00 2001 From: Astoria Date: Mon, 10 Apr 2023 14:26:38 -0500 Subject: [PATCH] Better scrolling, and configurable to boot! --- .../afloydwiremod/WiremodConfig.java | 3 + .../afloydwiremod/gui/GuiProgrammer.java | 78 +++++++++--------- .../assets/afloydwiremod/config.toml | 5 +- .../assets/afloydwiremod/gui/programmer.ase | Bin 770 -> 771 bytes .../assets/afloydwiremod/gui/programmer.png | Bin 639 -> 637 bytes 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/brokenmoon/afloydwiremod/WiremodConfig.java b/src/main/java/net/brokenmoon/afloydwiremod/WiremodConfig.java index 625d5e6..9d16513 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/WiremodConfig.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/WiremodConfig.java @@ -26,6 +26,7 @@ public class WiremodConfig { public int redsilicaID; public int dieID; public int dieOvercookedID; + public int scrollrate; public WiremodConfig(){ @@ -49,6 +50,8 @@ public class WiremodConfig { redsilicaID = toml.getLong("ids.item.redSilica", (long)911).intValue(); dieID = toml.getLong("ids.item.chipDie", (long)912).intValue(); dieOvercookedID = toml.getLong("ids.item.chipDieOvercooked", (long)913).intValue(); + //Various settings + scrollrate = toml.getLong("misc.scrollrate", (long)5).intValue(); } public static File getConfig() { diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java index d509fc0..ca04dd1 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiProgrammer.java @@ -1,5 +1,6 @@ package net.brokenmoon.afloydwiremod.gui; +import net.brokenmoon.afloydwiremod.WireMod; import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity; import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket; import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; @@ -14,40 +15,40 @@ public class GuiProgrammer extends GuiScrollable { public int xSize = 100; public int ySize = 180; - private int slot = 0; + private int numOfElements = 0; @Override public void initGui() { //this.height - 240 is top //This.width / 2 - slot = 0; - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Constant")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Increment")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Decrement")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Increment/Decrement")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Duplicate")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Addition")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Subtraction")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Multiplication")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Division")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Memory")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "Pulse")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "TRUE")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "FALSE")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "AND")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "NAND")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "OR")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "NOR")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "XOR")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "XNOR")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "NOT")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "==")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "!=")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, ">")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, ">=")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "<")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "<=")); - this.controlList.add(new GuiButtonExtended(slot++, this.width, "<=>")); + numOfElements = 0; + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Constant")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Increment")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Decrement")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Counter")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Duplicate")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Addition")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Subtraction")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Multiplication")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Division")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Memory")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "Pulse")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "TRUE")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "FALSE")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "AND")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NAND")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "OR")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NOR")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "XOR")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "XNOR")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "NOT")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "==")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "!=")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, ">")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, ">=")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<=")); + this.controlList.add(new GuiButtonExtended(numOfElements++, this.width, "<=>")); } public GuiProgrammer(EntityPlayer player, ChipTileEntity wireEntity) { @@ -83,7 +84,7 @@ public class GuiProgrammer extends GuiScrollable { case "Decrement": this.setMode("dec"); break; - case "Increment/Decrement": + case "Counter": this.setMode("incdec"); break; case "Memory": @@ -129,23 +130,24 @@ public class GuiProgrammer extends GuiScrollable { this.drawGuiBackground(renderPartialTicks); GL11.glPushMatrix(); GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GL11.glScissor((width / 2 - 60) * this.mc.resolution.scale, (height / 2 - 80) * this.mc.resolution.scale, 120 * this.mc.resolution.scale, 160 * this.mc.resolution.scale); int k = (this.height - this.ySize) / 2; int wheel = Mouse.getDWheel(); if(wheel > 0) - scroll++; + scroll += WireMod.config.scrollrate; if (wheel < 0) - scroll--; + scroll -= WireMod.config.scrollrate; if(scroll > 0) scroll = 0; - if(-scroll > slot - 16) - scroll = -(slot - 16); + if(-scroll > (numOfElements - 16) * GuiButtonExtended.height) + scroll = -((numOfElements - 16) * GuiButtonExtended.height); for (int i = 0; i < this.controlList.size(); ++i) { GuiButtonExtended guibutton = (GuiButtonExtended)this.controlList.get(i); - guibutton.yPosition = k + (guibutton.height * (guibutton.id + 1) + scroll * GuiButtonExtended.height); - if(guibutton.yPosition > k && guibutton.yPosition < k + 170){ - guibutton.drawButton(this.mc, x, y); - } + guibutton.yPosition = k + (guibutton.height * (guibutton.id + 1) + scroll); + guibutton.drawButton(this.mc, x, y); } + GL11.glDisable(GL11.GL_SCISSOR_TEST); } protected void drawGuiBackground(float f) { diff --git a/src/main/resources/assets/afloydwiremod/config.toml b/src/main/resources/assets/afloydwiremod/config.toml index 90dc827..40b2c5b 100644 --- a/src/main/resources/assets/afloydwiremod/config.toml +++ b/src/main/resources/assets/afloydwiremod/config.toml @@ -20,4 +20,7 @@ wiring = 111 wiringGui = 112 wiringSettingsGui = 113 sync = 114 -chipSettingsGui = 115 \ No newline at end of file +chipSettingsGui = 115 + +[misc] +scrollrate = 5 \ No newline at end of file diff --git a/src/main/resources/assets/afloydwiremod/gui/programmer.ase b/src/main/resources/assets/afloydwiremod/gui/programmer.ase index 934d7c6c7a98b51b34f1306239cab159a8ad075a..ef937a47cf9ba62d2eef99073e04263eb7dc007e 100644 GIT binary patch delta 137 zcmZo-Yi46)p2%3w*u1gv5o7QI1_lOJ1qKEdApFk+?w50)&*V*Yn=iZ8{J`Aprwf1HGP7p9$fZ3809OAtX#fBK delta 147 zcmZo>Yhq($n#fqs*tD_n5o7Rt1_lOJ1qKEdApFk+E6B>C2v#dH^*~V0}M!wxTDnBA=RBlT88EFaV%q zH4*>-0002E*Kl_cz~^HFtqy=I2XOkbhozoC%LCW~^9FnK^j-fn{SWNAUXxJ*7n5HC c1{W3e0=;T0oHCv7ga7~l07*qoM6N<$g54NTM*si- delta 171 zcmV;c0960|1pfq(@ltt7L_t(|obA-X3BxcHL_xP9_g`otlH6s`B9_c6VDTS>uS=3< zV|%ABdeZ#fdvi?&`>+2QoW5+a(EV?L)0eH4dH^*~V0=GzZ$(dFL_RgMlZXMElZ63A zDe(6I_t@NB1n~LTK%)cT$^o3dY_Zf6Xn6orV86lKJbl-bcK-vru9uTg0v3~C0tOeU ZsTZe+EYP91q$vOZ002ovPDHLkV1iJVP|E-S