mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 15:03:07 +00:00
better implementation for right clicking on buttons - should no longer ignore clicks or cause the impression of lag
This commit is contained in:
1 parent
d99aa045ba
commit
1b1c4155d5
4 files changed
+54
-46
No files matched your search
@@ -1,9 +1,5 @@
|
||||
package crazypants.enderio.gui;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import crazypants.enderio.machine.IRedstoneModeControlable;
|
||||
import crazypants.enderio.machine.PacketRedstoneMode;
|
||||
@@ -20,8 +16,6 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
|
||||
private IRedstoneModeControlable model;
|
||||
private RedstoneControlMode curMode;
|
||||
|
||||
private boolean rightMouseDown = false;
|
||||
|
||||
private BlockCoord bc;
|
||||
|
||||
@@ -49,6 +43,15 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressedButton(Minecraft mc, int x, int y, int button) {
|
||||
boolean result = button == 1 && super.checkMousePress(mc, x, y);
|
||||
if(result) {
|
||||
prevMode();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getTooltipKey() {
|
||||
return tooltipKey;
|
||||
}
|
||||
@@ -84,21 +87,4 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketRedstoneMode(model, bc.x, bc.y, bc.z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
super.drawButton(mc, mouseX, mouseY);
|
||||
|
||||
Rectangle r = new Rectangle(xPosition, yPosition, width, height);
|
||||
if(r.contains(mouseX, mouseY)) {
|
||||
if(rightMouseDown && Mouse.getEventButton() == 1 && !Mouse.getEventButtonState()) {
|
||||
prevMode();
|
||||
gui.doActionPerformed(this);
|
||||
}
|
||||
rightMouseDown = Mouse.getEventButton() == 1 && Mouse.getEventButtonState();
|
||||
} else {
|
||||
rightMouseDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user