mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-18 19:39:14 +00:00
Right mouse button now goes 'back' on the color and redstone mode buttons.
This commit is contained in:
1 parent
b74904c6be
commit
decdd3a87b
3 files changed
+60
-4
No files matched your search
@@ -1,10 +1,13 @@
|
||||
package crazypants.enderio.gui;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.gui.IGuiScreen;
|
||||
@@ -15,6 +18,8 @@ public class ColorButton extends IconButtonEIO {
|
||||
private int colorIndex = 0;
|
||||
|
||||
private String tooltipPrefix = "";
|
||||
|
||||
private boolean rightMouseDown = false;
|
||||
|
||||
public ColorButton(IGuiScreen gui, int id, int x, int y) {
|
||||
super(gui, id, x, y, null);
|
||||
@@ -48,6 +53,14 @@ public class ColorButton extends IconButtonEIO {
|
||||
}
|
||||
setColorIndex(colorIndex);
|
||||
}
|
||||
|
||||
private void prevColor() {
|
||||
colorIndex--;
|
||||
if(colorIndex < 0) {
|
||||
colorIndex = ItemDye.field_150923_a.length - 1;
|
||||
}
|
||||
setColorIndex(colorIndex);
|
||||
}
|
||||
|
||||
public int getColorIndex() {
|
||||
return colorIndex;
|
||||
@@ -67,6 +80,17 @@ public class ColorButton extends IconButtonEIO {
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
super.drawButton(mc, mouseX, mouseY);
|
||||
if(visible) {
|
||||
|
||||
Rectangle r = new Rectangle(xPosition, yPosition, width, height);
|
||||
if(r.contains(mouseX, mouseY)) {
|
||||
if(rightMouseDown && Mouse.getEventButton() == 1 && !Mouse.getEventButtonState()) {
|
||||
prevColor();
|
||||
}
|
||||
rightMouseDown = Mouse.getEventButton() == 1 && Mouse.getEventButtonState();
|
||||
} else {
|
||||
rightMouseDown = false;
|
||||
}
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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;
|
||||
@@ -14,12 +18,14 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
private static IconEIO[] ICONS = new IconEIO[] { IconEIO.REDSTONE_MODE_ALWAYS, IconEIO.REDSTONE_MODE_WITH_SIGNAL, IconEIO.REDSTONE_MODE_WITHOUT_SIGNAL,
|
||||
IconEIO.REDSTONE_MODE_NEVER };
|
||||
|
||||
IRedstoneModeControlable model;
|
||||
RedstoneControlMode curMode;
|
||||
private IRedstoneModeControlable model;
|
||||
private RedstoneControlMode curMode;
|
||||
|
||||
private boolean rightMouseDown = false;
|
||||
|
||||
BlockCoord bc;
|
||||
private BlockCoord bc;
|
||||
|
||||
String tooltipKey = "enderio.gui.tooltip.redstoneControlMode";
|
||||
private String tooltipKey = "enderio.gui.tooltip.redstoneControlMode";
|
||||
|
||||
public RedstoneModeButton(IGuiScreen gui, int id, int x, int y, IRedstoneModeControlable model) {
|
||||
this(gui, id, x, y, model, null);
|
||||
@@ -58,6 +64,13 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
}
|
||||
setMode(curMode.next());
|
||||
}
|
||||
|
||||
private void prevMode() {
|
||||
if(curMode == null) {
|
||||
curMode = RedstoneControlMode.ON;
|
||||
}
|
||||
setMode(curMode.previous());
|
||||
}
|
||||
|
||||
public void setMode(RedstoneControlMode mode) {
|
||||
if(mode == curMode) {
|
||||
@@ -75,6 +88,16 @@ public class RedstoneModeButton extends IconButtonEIO {
|
||||
@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();
|
||||
}
|
||||
rightMouseDown = Mouse.getEventButton() == 1 && Mouse.getEventButtonState();
|
||||
} else {
|
||||
rightMouseDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,4 +47,13 @@ public enum RedstoneControlMode {
|
||||
return values()[ord];
|
||||
}
|
||||
|
||||
public RedstoneControlMode previous() {
|
||||
int ord = ordinal();
|
||||
ord--;
|
||||
if(ord < 0) {
|
||||
ord = values().length - 1;
|
||||
}
|
||||
return values()[ord];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user