aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/co/fantabos/bscv/modules/hud/ActiveModules.java3
-rw-r--r--src/main/java/co/fantabos/bscv/modules/hud/Coordinates.java2
-rw-r--r--src/main/java/co/fantabos/bscv/tools/Anchor.java19
-rw-r--r--src/main/java/co/fantabos/bscv/tools/Text.java27
4 files changed, 33 insertions, 18 deletions
diff --git a/src/main/java/co/fantabos/bscv/modules/hud/ActiveModules.java b/src/main/java/co/fantabos/bscv/modules/hud/ActiveModules.java
index f7d2c8a..ad195b8 100644
--- a/src/main/java/co/fantabos/bscv/modules/hud/ActiveModules.java
+++ b/src/main/java/co/fantabos/bscv/modules/hud/ActiveModules.java
@@ -21,7 +21,7 @@ public class ActiveModules extends HudModule {
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
if (event.getType() == ElementType.TEXT) {
- float offset = 0.0f;
+ int offset = 0;
for (Module m : BoSCoVicino.mods) {
if (m.enabled.get() && m.group != Group.HUD) {
TextBuilder()
@@ -29,6 +29,7 @@ public class ActiveModules extends HudModule {
.anchor(this.anchor.get())
.x(this.x.get())
.y(this.y.get() + offset)
+ .scale(this.scale.get())
.render(event.getMatrixStack(), event.getWindow());
offset += BoSCoVicino.minecraft.font.lineHeight;
}
diff --git a/src/main/java/co/fantabos/bscv/modules/hud/Coordinates.java b/src/main/java/co/fantabos/bscv/modules/hud/Coordinates.java
index 4acc893..b7e0225 100644
--- a/src/main/java/co/fantabos/bscv/modules/hud/Coordinates.java
+++ b/src/main/java/co/fantabos/bscv/modules/hud/Coordinates.java
@@ -26,10 +26,10 @@ public class Coordinates extends HudModule {
Vector3d position = mc.player.position();
TextBuilder()
.txt(String.format("[ X %.1f | %.1f Z ] %.1f Y", position.x(), position.z(), position.y()))
- // .anchor(this.anchor.get())
.anchor(this.anchor.get())
.x(this.x.get())
.y(this.y.get())
+ .scale(this.scale.get())
.render(event.getMatrixStack(), event.getWindow());
}
}
diff --git a/src/main/java/co/fantabos/bscv/tools/Anchor.java b/src/main/java/co/fantabos/bscv/tools/Anchor.java
index 2e5e8af..8d31b41 100644
--- a/src/main/java/co/fantabos/bscv/tools/Anchor.java
+++ b/src/main/java/co/fantabos/bscv/tools/Anchor.java
@@ -13,7 +13,7 @@ public enum Anchor {
private Anchor(String in) { }
- public Vector2f translate(Vector2f in, int textWidth, int lineHeight, MainWindow window) {
+ public Vector2f translate(Vector2f in, int textWidth, int lineHeight, float scale, MainWindow window) {
int offset = 0;
switch (this) {
case BOTTOMLEFT:
@@ -24,25 +24,26 @@ public enum Anchor {
}
default:
}
+ // TODO de-spaghetti this mess
switch (this) {
case TOPLEFT:
return new Vector2f(in.x, in.y);
case TOPCENTER:
- return new Vector2f((window.getWidth()/4.0f) + in.x - (textWidth / 2), in.y);
+ return new Vector2f((window.getWidth() / (scale * 4.0f)) + in.x - (textWidth / 2), in.y);
case TOPRIGHT:
- return new Vector2f((window.getWidth()/2.0f) - (in.x + textWidth), in.y);
+ return new Vector2f((window.getWidth() / (scale * 2.0f)) - (in.x + textWidth), in.y);
case MIDDLELEFT:
- return new Vector2f(in.x, (window.getHeight()/4.0f) + in.y - (lineHeight / 2));
+ return new Vector2f(in.x, (window.getHeight() / (scale * 4.0f)) + in.y - (lineHeight / 2));
case MIDDLECENTER:
- return new Vector2f((window.getWidth()/4.0f) + in.x - (textWidth / 2), (window.getHeight()/4.0f) + in.y - (lineHeight / 2));
+ return new Vector2f((window.getWidth() / (scale * 4.0f)) + in.x - (textWidth / 2), (window.getHeight() / (scale * 4.0f)) + in.y - (lineHeight / 2));
case MIDDLERIGHT:
- return new Vector2f((window.getWidth()/2.0f) - (in.x + textWidth), (window.getHeight()/4.0f) + in.y - (lineHeight / 2));
+ return new Vector2f((window.getWidth() / (scale * 2.0f)) - (in.x + textWidth ), (window.getHeight() / (scale * 4.0f)) + in.y - (lineHeight / 2));
case BOTTOMLEFT:
- return new Vector2f(in.x, (window.getHeight()/2.0f) - (in.y + lineHeight + offset));
+ return new Vector2f(in.x, (window.getHeight() / (scale * 2.0f)) - (in.y + lineHeight + offset));
case BOTTOMCENTER:
- return new Vector2f((window.getWidth()/4.0f) + in.x - (textWidth / 2), (window.getHeight()/2.0f) - (in.y + lineHeight + offset));
+ return new Vector2f((window.getWidth() / (scale * 4.0f)) + in.x - (textWidth / 2), (window.getHeight() / (scale * 2.0f)) - (in.y + lineHeight + offset));
case BOTTOMRIGHT:
- return new Vector2f((window.getWidth()/2.0f) - (in.x + textWidth), (window.getHeight()/2.0f) - (in.y + lineHeight + offset));
+ return new Vector2f((window.getWidth() / (scale * 4.0f)) - (in.x + textWidth), (window.getHeight() / (scale * 2.0f)) - (in.y + lineHeight + offset));
default:
return new Vector2f(0.0f, 0.0f);
}
diff --git a/src/main/java/co/fantabos/bscv/tools/Text.java b/src/main/java/co/fantabos/bscv/tools/Text.java
index a0ee92e..8c8adb5 100644
--- a/src/main/java/co/fantabos/bscv/tools/Text.java
+++ b/src/main/java/co/fantabos/bscv/tools/Text.java
@@ -1,6 +1,7 @@
package co.fantabos.bscv.tools;
import com.mojang.blaze3d.matrix.MatrixStack;
+import com.mojang.blaze3d.systems.RenderSystem;
import co.fantabos.bscv.BoSCoVicino;
import co.fantabos.bscv.tools.Anchor;
@@ -17,15 +18,17 @@ public final class Text {
String text;
Anchor anchor;
Style style;
- float x;
- float y;
+ int x;
+ int y;
+ double scale;
private Text() {
this.text = "";
this.anchor = Anchor.TOPLEFT;
this.style = Style.EMPTY.withColor(Color.fromRgb(16777215));
- this.x = 0.0f;
- this.y = 0.0f;
+ this.x = 0;
+ this.y = 0;
+ this.scale = 1.0;
}
public static Text TextBuilder() {
@@ -47,16 +50,21 @@ public final class Text {
return this;
}
- public Text x(float x) {
+ public Text x(int x) {
this.x = x;
return this;
}
- public Text y(float y) {
+ public Text y(int y) {
this.y = y;
return this;
}
+ public Text scale(double scale) {
+ this.scale = scale;
+ return this;
+ }
+
public void render(MatrixStack stack, MainWindow window) {
FontRenderer font = BoSCoVicino.minecraft.font;
ITextComponent text = new StringTextComponent(this.text).setStyle(this.style);
@@ -64,14 +72,19 @@ public final class Text {
new Vector2f(this.x, this.y),
font.width(text),
font.lineHeight,
+ (float) this.scale,
window
);
+ // TODO is there any non-deprecated way?
+ RenderSystem.pushMatrix();
+ RenderSystem.scaled(this.scale, this.scale, this.scale);
font.drawShadow(
stack,
text,
abs_coords.x,
abs_coords.y,
- 0 // ???? TODO!
+ 10 // ???? TODO!
);
+ RenderSystem.popMatrix();
}
}