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.java16
3 files changed, 18 insertions, 35 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 6e1ce6c..7620a26 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
@@ -47,10 +47,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)
@@ -68,8 +66,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);
@@ -87,28 +84,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 723a09e..cce2440 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
@@ -55,9 +55,7 @@ public abstract class BasicHud {
}
private void drawBackground(float x, float y, float scale) {
- Renderer.drawRoundRect((int) x, (int) y,
- (int) (getTotalWidth(scale) + paddingX * scale), (int) (getTotalHeight(scale) + paddingY * scale),
- (int) (2 * scale), new Color(0, 0, 0, 120).getRGB());
+ Renderer.drawRoundRect((int) x, (int) y, (int) (getTotalWidth(scale) + paddingX * scale), (int) (getTotalHeight(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 33bbd79..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,20 +57,18 @@ 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) {
for (int i = 0; i < lines.size(); i++) {
- Renderer.drawTextScale(lines.get(i), x, y + i * 12, 0xffffff, shadow, scale);
+ Renderer.drawScaledString(lines.get(i), x, y + i * 12, 0xffffff, shadow, scale);
}
}