Scroll Wheel now works in EVERY MENU!!!

This commit is contained in:
Kam committed 2024-03-17 22:48:06 -04:00
1 parent 50be68f33a
commit ae0effdf99
3 files changed
+6 -26

No files matched your search

@@ -17,6 +17,7 @@ import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import tconstruct.client.tabs.AbstractTab;
import tconstruct.client.tabs.InventoryTabCustomNpc;
@@ -234,7 +235,7 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen
int maxScroll = Math.max(0, this.sideButtons.size() - 9) * 22;
// Adjust scrolling only if the mouse is in the scroll zone
if (isMouseInScrollZone(i, j)) {
this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(this.mouseWheel) * 22, -maxScroll, 0);
this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(Mouse.getDWheel()) * 22, -maxScroll, 0);
}
// Apply smoothing to the scroll transition
this.sideButtonScroll += (this.destSideButtonScroll - this.sideButtonScroll) * SMOOTHING_FACTOR;
@@ -101,8 +101,6 @@ public class GuiCustomScroll extends GuiScreen
GL11.glTranslatef(guiLeft, guiTop, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean isMouseOverComponent = isMouseOver(i, j);
if(selectable)
hover = getMouseOver(i,j);
@@ -147,7 +145,7 @@ public class GuiCustomScroll extends GuiScreen
}
}
if(mouseScrolled != 0 && isMouseOverComponent){
if(mouseScrolled != 0){
scrollY += mouseScrolled > 0?-14:14;
if(scrollY > maxScrollY)
scrollY = maxScrollY;
@@ -157,7 +155,7 @@ public class GuiCustomScroll extends GuiScreen
}
}
public void drawHover(int i, int j, float f, int mouseScrolled){
public void drawHover(int i, int j){
if(!visible)
return;
@@ -28,7 +28,6 @@ import java.util.HashMap;
public abstract class GuiNPCInterface extends GuiScreen
{
public static Window AWTWindow;
public EntityClientPlayerMP player;
public boolean drawDefaultBackground = true;
public EntityNPCInterface npc;
@@ -52,8 +51,6 @@ public abstract class GuiNPCInterface extends GuiScreen
public float bgScaleY = 1;
public float bgScaleZ = 1;
public int mouseWheel;
public GuiNPCInterface(EntityNPCInterface npc)
{
this.player = Minecraft.getMinecraft().thePlayer;
@@ -113,8 +110,6 @@ public abstract class GuiNPCInterface extends GuiScreen
public void mouseClicked(int i, int j, int k)
{
if(AWTWindow != null)
return;
if(subgui != null)
subgui.mouseClicked(i,j,k);
else{
@@ -145,8 +140,6 @@ public abstract class GuiNPCInterface extends GuiScreen
@Override
public void keyTyped(char c, int i){
if(AWTWindow != null)
return;
if(subgui != null)
subgui.keyTyped(c,i);
for(GuiNpcTextField tf : textfields.values())
@@ -218,18 +211,6 @@ public abstract class GuiNPCInterface extends GuiScreen
@Override
public void drawScreen(int i, int j, float f){
this.mouseWheel = Mouse.getDWheel();
if(AWTWindow != null){
if(!AWTWindow.isVisible()){
AWTWindow.dispose();
AWTWindow = null;
}
else if(Display.isActive()){
Toolkit.getDefaultToolkit().beep();
AWTWindow.setVisible(true);
}
}
mouseX = i;
mouseY = j;
if(drawDefaultBackground && subgui == null)
@@ -248,14 +229,14 @@ public abstract class GuiNPCInterface extends GuiScreen
}
for(GuiCustomScroll scroll : scrolls.values()){
scroll.updateSubGUI(subGui);
scroll.drawScreen(i, j, f, subGui?0:this.mouseWheel);
scroll.drawScreen(i, j, f, !subGui && scroll.isMouseOver(i, j)?Mouse.getDWheel():0);
}
for(GuiScreen gui : extra.values())
gui.drawScreen(i, j, f);
super.drawScreen(i, j, f);
for(GuiCustomScroll scroll : scrolls.values())
if(scroll.hoverableText){
scroll.drawHover(i, j, f, subGui?0:this.mouseWheel);
scroll.drawHover(i, j);
}
for(GuiNpcButton button : buttons.values()){
button.updateSubGUI(subGui);