Skip to content

Commit

Permalink
1.12.2-0.3.1j
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuxelus committed Sep 6, 2023
1 parent 893aeaf commit a4b7425
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 20 deletions.
8 changes: 4 additions & 4 deletions build.gradle_old
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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',
Expand Down
32 changes: 28 additions & 4 deletions src/main/java/com/zuxelus/energycontrol/gui/GuiHowlerAlarm.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,21 +21,25 @@ 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
public void initGui() {
super.initGui();
slider = new GuiHowlerAlarmSlider(3, guiLeft + 12, guiTop + 33, alarm);

List<String> items = new ArrayList<>(EnergyControl.instance.availableAlarms);
List<String> items = new ArrayList<String>(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);
}
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import com.zuxelus.energycontrol.EnergyControl;
Expand Down Expand Up @@ -59,30 +60,24 @@ 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;
}

public void scrollDown() {
scrollTop += 8;
int max = lineHeight * items.size() + BASIC_Y_OFFSET - height;

if (max < 0)
max = 0;

if (scrollTop > max)
scrollTop = max;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<String> items = new ArrayList<String>(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);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a4b7425

Please sign in to comment.