From a4b7425440f85be2b2450ebf8bf7270a1218b730 Mon Sep 17 00:00:00 2001 From: Zuxelus Date: Wed, 6 Sep 2023 21:47:15 +0300 Subject: [PATCH] 1.12.2-0.3.1j --- build.gradle_old | 8 ++--- .../energycontrol/gui/GuiHowlerAlarm.java | 32 +++++++++++++++--- .../gui/controls/GuiHowlerAlarmListBox.java | 31 +++++++++++------ .../energycontrol/proxy/ClientProxy.java | 9 +++-- .../textures/gui/gui_howler_alarm_big.png | Bin 0 -> 821 bytes 5 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/assets/energycontrol/textures/gui/gui_howler_alarm_big.png diff --git a/build.gradle_old b/build.gradle_old index 24a42147..363407ac 100644 --- a/build.gradle_old +++ b/build.gradle_old @@ -9,7 +9,7 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "1.12.2-0.3.1i" +version = "1.12.2-0.3.1j" group= "com.zuxelus.energycontrol" archivesBaseName = "EnergyControl" @@ -45,15 +45,15 @@ dependencies { 'libs_/Galacticraft-Planets-Dev-1.12.2-4.0.2.261.jar', 'libs_/GalacticraftCore-Dev-1.12.2-4.0.2.261.jar', 'libs_/gregtech-1.12.2-1.17.1.770.jar', - 'libs_/NTM-Extended-1.12.2-1.9.6.jar', + 'libs_/NTM-Extended-1.12.2-1.9.8.jar', 'libs_/IC2Classic+1.12-1.5.4.5+Dev.jar', 'libs_/industrialcraft-2-2.8.197-ex112-dev.jar', 'libs_/jei_1.12.2-4.16.1.302.jar', 'libs_/Mekanism-1.12.2-9.8.3.390.jar', 'libs_/MekanismGenerators-1.12.2-9.8.3.390.jar', 'libs_/MicdoodleCore-Dev-1.12.2-4.0.2.261.jar', - 'libs_/NuclearCraft-2.18x-1.12.2.jar', - 'libs_/NuclearCraft-2o.5.5-1.12.2.jar', + 'libs_/NuclearCraft-2.18zzz-1.12.2.jar', + 'libs_/NuclearCraft-2o.6.2-1.12.2.jar', 'libs_/OpenComputers-MC1.12.2-1.7.5.192.jar', 'libs_/pneumaticcraft-repressurized-1.12.2-0.11.15-398.jar', 'libs_/railcraft-12.1.0-beta-2.jar', diff --git a/src/main/java/com/zuxelus/energycontrol/gui/GuiHowlerAlarm.java b/src/main/java/com/zuxelus/energycontrol/gui/GuiHowlerAlarm.java index d4505671..1e9e8be6 100644 --- a/src/main/java/com/zuxelus/energycontrol/gui/GuiHowlerAlarm.java +++ b/src/main/java/com/zuxelus/energycontrol/gui/GuiHowlerAlarm.java @@ -1,8 +1,11 @@ package com.zuxelus.energycontrol.gui; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.lwjgl.input.Mouse; + import com.zuxelus.energycontrol.EnergyControl; import com.zuxelus.energycontrol.gui.controls.GuiHowlerAlarmListBox; import com.zuxelus.energycontrol.gui.controls.GuiHowlerAlarmSlider; @@ -18,10 +21,14 @@ public class GuiHowlerAlarm extends GuiBase { private TileEntityHowlerAlarm alarm; private GuiHowlerAlarmSlider slider; private GuiHowlerAlarmListBox listBox; + private boolean isBig; - public GuiHowlerAlarm(TileEntityHowlerAlarm alarm) { - super("tile.howler_alarm.name", 131, 136, EnergyControl.MODID + ":textures/gui/gui_howler_alarm.png"); + public GuiHowlerAlarm(TileEntityHowlerAlarm alarm, boolean isBig) { + super("tile.howler_alarm.name", 131, isBig ? 236 : 136, isBig ? + EnergyControl.MODID + ":textures/gui/gui_howler_alarm_big.png" : + EnergyControl.MODID + ":textures/gui/gui_howler_alarm.png"); this.alarm = alarm; + this.isBig = isBig; } @Override @@ -29,10 +36,10 @@ public void initGui() { super.initGui(); slider = new GuiHowlerAlarmSlider(3, guiLeft + 12, guiTop + 33, alarm); - List items = new ArrayList<>(EnergyControl.instance.availableAlarms); + List items = new ArrayList(EnergyControl.instance.availableAlarms); items.retainAll(EnergyControl.instance.serverAllowedAlarms); - listBox = new GuiHowlerAlarmListBox(4, guiLeft + 13, guiTop + 63, 105, 65, items, alarm); + listBox = new GuiHowlerAlarmListBox(4, guiLeft + 13, guiTop + 63, 105, isBig? 165 : 65, items, alarm); addButton(slider); addButton(listBox); } @@ -51,4 +58,21 @@ protected void mouseReleased(int mouseX, int mouseY, int which) { listBox.mouseReleased(mouseX, mouseY); } } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + listBox.keyPressed(typedChar, keyCode); + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + int wheel = Mouse.getEventDWheel(); + if (wheel != 0) { + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + listBox.mouseScrolled(i, j, wheel); + } + } } diff --git a/src/main/java/com/zuxelus/energycontrol/gui/controls/GuiHowlerAlarmListBox.java b/src/main/java/com/zuxelus/energycontrol/gui/controls/GuiHowlerAlarmListBox.java index 1736d701..2b8c07be 100644 --- a/src/main/java/com/zuxelus/energycontrol/gui/controls/GuiHowlerAlarmListBox.java +++ b/src/main/java/com/zuxelus/energycontrol/gui/controls/GuiHowlerAlarmListBox.java @@ -2,6 +2,7 @@ import java.util.List; +import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import com.zuxelus.energycontrol.EnergyControl; @@ -59,19 +60,15 @@ private void scrollTo(int pos) { scrollTop = pos; if (scrollTop < 0) scrollTop = 0; - int max = lineHeight * items.size() + BASIC_Y_OFFSET - height; - if (max < 0) max = 0; - if (scrollTop > max) scrollTop = max; } public void scrollUp() { scrollTop -= 8; - if (scrollTop < 0) scrollTop = 0; } @@ -79,10 +76,8 @@ public void scrollUp() { public void scrollDown() { scrollTop += 8; int max = lineHeight * items.size() + BASIC_Y_OFFSET - height; - if (max < 0) max = 0; - if (scrollTop > max) scrollTop = max; } @@ -107,16 +102,13 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) scrollTop = (currentIndex + 1) * lineHeight + BASIC_Y_OFFSET - height; } float scale = height / ((float) lineHeight * items.size() + BASIC_Y_OFFSET); - if (scale > 1) scale = 1; - sliderHeight = Math.round(scale * (height - 2 * SCROLL_BUTTON_HEIGHT)); - if (sliderHeight < 4) sliderHeight = 4; } - + int rowTop = BASIC_Y_OFFSET; GL11.glEnable(GL11.GL_SCISSOR_TEST); ScaledResolution scaler = new ScaledResolution(mc); @@ -172,6 +164,14 @@ private void setCurrent(int targetY) { } } + public void keyPressed(char typedChar, int keyCode) { + if (keyCode == Keyboard.KEY_DOWN) { + scrollDown(); + } else if (keyCode == Keyboard.KEY_UP) { + scrollUp(); + } + } + @Override public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { if (super.mousePressed(mc, mouseX, mouseY)) { @@ -192,6 +192,17 @@ else if (mouseY >= sliderY && mouseY <= sliderY + sliderHeight) { return false; } + public void mouseScrolled(double mouseX, double mouseY, double wheel) { + if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height) { + if (wheel > 0) { + scrollUp(); + } + if (wheel < 0) { + scrollDown(); + } + } + } + @Override public void mouseReleased(int mouseX, int mouseY) { super.mouseReleased(mouseX, mouseY); diff --git a/src/main/java/com/zuxelus/energycontrol/proxy/ClientProxy.java b/src/main/java/com/zuxelus/energycontrol/proxy/ClientProxy.java index 5228c98d..ae0dfc6c 100644 --- a/src/main/java/com/zuxelus/energycontrol/proxy/ClientProxy.java +++ b/src/main/java/com/zuxelus/energycontrol/proxy/ClientProxy.java @@ -1,6 +1,7 @@ package com.zuxelus.energycontrol.proxy; import com.zuxelus.energycontrol.ClientTickHandler; +import com.zuxelus.energycontrol.EnergyControl; import com.zuxelus.energycontrol.ServerTickHandler; import com.zuxelus.energycontrol.blocks.BlockDamages; import com.zuxelus.energycontrol.containers.*; @@ -28,6 +29,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.io.File; +import java.util.ArrayList; import java.util.List; public class ClientProxy implements IProxy { @@ -61,8 +63,11 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int return new GuiThermalMonitor((TileEntityThermalMonitor) te); break; case BlockDamages.DAMAGE_HOWLER_ALARM: - if (te instanceof TileEntityHowlerAlarm) - return new GuiHowlerAlarm((TileEntityHowlerAlarm) te); + if (te instanceof TileEntityHowlerAlarm) { + List items = new ArrayList(EnergyControl.instance.availableAlarms); + items.retainAll(EnergyControl.instance.serverAllowedAlarms); + return new GuiHowlerAlarm((TileEntityHowlerAlarm) te, items.size() > 10); + } case BlockDamages.DAMAGE_INDUSTRIAL_ALARM: if (te instanceof TileEntityIndustrialAlarm) return new GuiIndustrialAlarm((TileEntityIndustrialAlarm) te); diff --git a/src/main/resources/assets/energycontrol/textures/gui/gui_howler_alarm_big.png b/src/main/resources/assets/energycontrol/textures/gui/gui_howler_alarm_big.png new file mode 100644 index 0000000000000000000000000000000000000000..cd2cfaf624c620ec57ba0887eae3f73867e04de7 GIT binary patch literal 821 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBzI1?3h%1o(|Nnn?clWVl$IQ*mLqkI?EiM22`2!UHZgcY!km4)}@(Tv4 z0Rx6${|X_HV1Y+uF#`kNVGw3Kp1&f6fq|*d)5S5QBJS;N@4O`r0xSV9mf7Ct~j;I`r`a6|Diw z!NUS%z0rHF1{rxEBN7xMh#&=7pK?!>!O{-M!1Ul9K7;s7?g`!N=k8*ZiPq_5{5Jc4 zk;SEVf-|Q7O;2w4zA-+%K{=K&?)20(HoOTjn;su#&|+e6$ZvSdzc{I(^p