aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/hud
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/hud')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java33
-rw-r--r--src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java14
3 files changed, 17 insertions, 34 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
index 262e36d..cc55e59 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
@@ -44,10 +44,8 @@ public class HudGui extends GuiScreen {
float pos = getXSnapping(mouseX, true);
float newWidth = pos - xFloat;
float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale);
- if (newScale > 20)
- newScale = 20;
- else if (newScale < 0.3)
- newScale = 0.3f;
+ if (newScale > 20) newScale = 20;
+ else if (newScale < 0.3) newScale = 0.3f;
hud.scale = newScale;
if (xFloat / this.width > 0.5)
@@ -65,8 +63,7 @@ public class HudGui extends GuiScreen {
int color = new Color(215, 224, 235).getRGB();
if (editingHud == hud) {
color = new Color(43, 159, 235).getRGB();
- if (isDragging)
- Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB());
+ if (isDragging) Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB());
}
Renderer.drawLine(x - 2 / 4f, y, x + width + 2 / 4f, y, 2, color);
Renderer.drawLine(x, y, x, y + height, 2, color);
@@ -84,28 +81,20 @@ public class HudGui extends GuiScreen {
float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale;
float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale;
- if (newX < 0)
- newX = 0;
- else if (newX + width > this.width)
- newX = this.width - width;
- if (newY < 0)
- newY = 0;
- else if (newY + height > this.height)
- newY = this.height - height;
+ if (newX < 0) newX = 0;
+ else if (newX + width > this.width) newX = this.width - width;
+ if (newY < 0) newY = 0;
+ else if (newY + height > this.height) newY = this.height - height;
if (snap) {
newX = getXSnapping(newX, false);
newY = getYSnapping(newY);
}
- if (newX / this.width <= 0.5)
- editingHud.xUnscaled = newX / (double) this.width;
- else
- editingHud.xUnscaled = (newX + width) / (double) this.width;
- if (newY / this.height <= 0.5)
- editingHud.yUnscaled = newY / (double) this.height;
- else
- editingHud.yUnscaled = (newY + height) / (double) this.height;
+ if (newX / this.width <= 0.5) editingHud.xUnscaled = newX / (double) this.width;
+ else editingHud.xUnscaled = (newX + width) / (double) this.width;
+ if (newY / this.height <= 0.5) editingHud.yUnscaled = newY / (double) this.height;
+ else editingHud.yUnscaled = (newY + height) / (double) this.height;
}
private float getXSnapping(float pos, boolean rightOnly) {
diff --git a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
index ebc5459..419bccf 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
@@ -42,9 +42,7 @@ public abstract class BasicHud {
}
private void drawBackground(float x, float y, float scale) {
- Renderer.drawRoundRect((int) x, (int) y,
- (int) (getWidth(scale) + paddingX * scale), (int) (getHeight(scale) + paddingY * scale),
- (int) (2 * scale), new Color(0, 0, 0, 120).getRGB());
+ Renderer.drawRoundRect((int) x, (int) y, (int) (getWidth(scale) + paddingX * scale), (int) (getHeight(scale) + paddingY * scale), (int) (2 * scale), new Color(0, 0, 0, 120).getRGB());
}
public float getXScaled(int screenWidth) {
diff --git a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java
index 77f5880..3c9cf4c 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java
@@ -14,10 +14,10 @@ public class TextHud extends BasicHud {
*/
private final FontRenderer fb = Minecraft.getMinecraft().fontRendererObj;
boolean shadow = false;
+ boolean doExample = false;
private List<String> cachedLines;
private int cachedWidth;
private int cachedHeight;
- boolean doExample = false;
private List<String> cachedExampleLines;
private int cachedExampleWidth;
private int cachedExampleHeight;
@@ -35,8 +35,7 @@ public class TextHud extends BasicHud {
cachedWidth = 0;
for (String line : cachedLines) {
int width = fb.getStringWidth(line);
- if (width > cachedWidth)
- cachedWidth = width;
+ if (width > cachedWidth) cachedWidth = width;
}
}
if (doExample) {
@@ -46,8 +45,7 @@ public class TextHud extends BasicHud {
cachedExampleWidth = 0;
for (String line : cachedExampleLines) {
int width = fb.getStringWidth(line);
- if (width > cachedExampleWidth)
- cachedExampleWidth = width;
+ if (width > cachedExampleWidth) cachedExampleWidth = width;
}
}
}
@@ -59,15 +57,13 @@ public class TextHud extends BasicHud {
@Override
public void draw(int x, int y, float scale) {
- if (cachedLines != null)
- drawText(cachedLines, x, y, scale);
+ if (cachedLines != null) drawText(cachedLines, x, y, scale);
}
@Override
public void drawExample(int x, int y, float scale) {
doExample = true;
- if (cachedExampleLines != null)
- drawText(cachedExampleLines, x, y, scale);
+ if (cachedExampleLines != null) drawText(cachedExampleLines, x, y, scale);
}
private void drawText(List<String> lines, int x, int y, float scale) {