aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java
diff options
context:
space:
mode:
authorDaniel She <shekwancheung0528@gmail.com>2019-02-14 14:38:18 +0100
committerGitHub <noreply@github.com>2019-02-14 14:38:18 +0100
commit93dc019f11596f7a9386a6e3f597667fa1b50eb8 (patch)
tree063961a16d01e45461b61e22c9d71659a99bff05 /src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java
parent32cc30ef0d63e64915ef647978b0546a9c0e800a (diff)
downloadRoughlyEnoughItems-2.3.0.51.tar.gz
RoughlyEnoughItems-2.3.0.51.tar.bz2
RoughlyEnoughItems-2.3.0.51.zip
REI Update v2.3 (#35)v2.3.0.51
* Fixes #33 * Fixes #32 * Fix #29 * Highlight Cursor * Fix #15 * Remove Unwanted Imports * Making it actually v2.3 * LOLCATS & Upside Down Lanuage + Credits Screen * better credits * Better Config * Better Config Button Handling + Campfire text using container sub-colour * Better Plugin Handling * Split ItemRegisterer out from ClientHelper * Option to disable default plugin.
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java
index 96fbc54b3..eb6584798 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ButtonWidget.java
@@ -16,32 +16,22 @@ import java.util.List;
public abstract class ButtonWidget extends Drawable implements IWidget {
protected static final Identifier WIDGET_TEX = new Identifier("textures/gui/widgets.png");
- public int x;
- public int y;
public String text;
public boolean enabled;
public boolean visible;
- protected int width;
- protected int height;
protected boolean hovered;
private boolean pressed;
private Rectangle bounds;
public ButtonWidget(Rectangle rectangle, String text) {
- this(rectangle.x, rectangle.y, rectangle.width, rectangle.height, text);
- }
-
- public ButtonWidget(int x, int y, int width, int height, String text) {
- this.width = 200;
- this.height = 20;
+ this.bounds = rectangle;
this.enabled = true;
this.visible = true;
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
this.text = text;
- this.bounds = new Rectangle(x, this.y, this.width, this.height);
+ }
+
+ public ButtonWidget(int x, int y, int width, int height, String text) {
+ this(new Rectangle(x, y, width, height), text);
}
public Rectangle getBounds() {
@@ -66,8 +56,8 @@ public abstract class ButtonWidget extends Drawable implements IWidget {
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
-
if (this.visible) {
+ int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
MinecraftClient minecraftClient_1 = MinecraftClient.getInstance();
FontRenderer fontRenderer_1 = minecraftClient_1.fontRenderer;
minecraftClient_1.getTextureManager().bindTexture(WIDGET_TEX);
@@ -78,18 +68,18 @@ public abstract class ButtonWidget extends Drawable implements IWidget {
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
//Four Corners
- this.drawTexturedRect(this.x, this.y, 0, 46 + textureOffset * 20, 4, 4);
- this.drawTexturedRect(this.x + this.width - 4, this.y, 196, 46 + textureOffset * 20, 4, 4);
- this.drawTexturedRect(this.x, this.y + this.height - 4, 0, 62 + textureOffset * 20, 4, 4);
- this.drawTexturedRect(this.x + this.width - 4, this.y + this.height - 4, 196, 62 + textureOffset * 20, 4, 4);
+ this.drawTexturedRect(x, y, 0, 46 + textureOffset * 20, 4, 4);
+ this.drawTexturedRect(x + width - 4, y, 196, 46 + textureOffset * 20, 4, 4);
+ this.drawTexturedRect(x, y + height - 4, 0, 62 + textureOffset * 20, 4, 4);
+ this.drawTexturedRect(x + width - 4, y + height - 4, 196, 62 + textureOffset * 20, 4, 4);
//Sides
- this.drawTexturedRect(this.x + 4, this.y, 4, 46 + textureOffset * 20, this.width - 8, 4);
- this.drawTexturedRect(this.x + 4, this.y + this.height - 4, 4, 62 + textureOffset * 20, this.width - 8, 4);
+ this.drawTexturedRect(x + 4, y, 4, 46 + textureOffset * 20, width - 8, 4);
+ this.drawTexturedRect(x + 4, y + height - 4, 4, 62 + textureOffset * 20, width - 8, 4);
- for(int i = this.y + 4; i < this.y + this.height - 4; i += 4) {
- this.drawTexturedRect(this.x, i, 0, 50 + textureOffset * 20, this.width / 2, MathHelper.clamp(this.y + this.height - 4 - i, 0, 4));
- this.drawTexturedRect(this.x + this.width / 2, i, 200 - this.width / 2, 50 + textureOffset * 20, this.width / 2, MathHelper.clamp(this.y + this.height - 4 - i, 0, 4));
+ for(int i = y + 4; i < y + height - 4; i += 4) {
+ this.drawTexturedRect(x, i, 0, 50 + textureOffset * 20, width / 2, MathHelper.clamp(y + height - 4 - i, 0, 4));
+ this.drawTexturedRect(x + width / 2, i, 200 - width / 2, 50 + textureOffset * 20, width / 2, MathHelper.clamp(y + height - 4 - i, 0, 4));
}
int colour = 14737632;
@@ -99,7 +89,7 @@ public abstract class ButtonWidget extends Drawable implements IWidget {
colour = 16777120;
}
- this.drawStringCentered(fontRenderer_1, this.text, this.x + this.width / 2, this.y + (this.height - 8) / 2, colour);
+ this.drawStringCentered(fontRenderer_1, this.text, x + width / 2, y + (height - 8) / 2, colour);
}
}