Skip to content

Commit

Permalink
Removed InfoHud in place of separate HUD elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonk9043 committed Sep 17, 2024
1 parent cec27b1 commit f220be2
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 91 deletions.
8 changes: 5 additions & 3 deletions src/main/java/net/aoba/gui/GuiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public class GuiManager implements KeyDownListener, PostTickListener, Render2DLi
public ModuleSelectorHud moduleSelector;
public ArmorHud armorHud;
public RadarHud radarHud;
public InfoHud infoHud;
public TimeHud timeHud;
public DayHud dayHud;
public ModuleArrayListHud moduleArrayListHud;
public WatermarkHud watermarkHud;
public CoordsHud coordsHud;
Expand Down Expand Up @@ -133,7 +134,8 @@ public void Initialize() {
moduleSelector = new ModuleSelectorHud();
armorHud = new ArmorHud(0, 0);
radarHud = new RadarHud(0, 0);
infoHud = new InfoHud(0, 0);
timeHud = new TimeHud(0, 0);
dayHud = new DayHud(0, 0);
moduleArrayListHud = new ModuleArrayListHud(0, 0);
watermarkHud = new WatermarkHud(0, 0);
coordsHud = new CoordsHud(0, 0);
Expand All @@ -143,7 +145,7 @@ public void Initialize() {
speedHud = new SpeedHud(0, 0);


ArrayList<HudWindow> huds = Lists.newArrayList(moduleSelector, armorHud, radarHud, infoHud, moduleArrayListHud, watermarkHud, coordsHud, netherCoordsHud, fpsHud, pingHud, speedHud);
ArrayList<HudWindow> huds = Lists.newArrayList(moduleSelector, armorHud, radarHud, timeHud, dayHud, moduleArrayListHud, watermarkHud, coordsHud, netherCoordsHud, fpsHud, pingHud, speedHud);
hudPane.AddWindow(new HudOptionsTab());
hudPane.AddWindow(new ToggleHudsTab(huds));

Expand Down
41 changes: 41 additions & 0 deletions src/main/java/net/aoba/gui/navigation/huds/DayHud.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.aoba.gui.navigation.huds;

import net.aoba.gui.GuiManager;
import net.aoba.gui.Rectangle;
import net.aoba.gui.navigation.HudWindow;
import net.aoba.utils.render.Render2D;
import net.minecraft.client.gui.DrawContext;

public class DayHud extends HudWindow {
private String timeText = null;

public DayHud(int x, int y) {
super("DayHud", x, y, 0, 20);
inheritHeightFromChildren = false;

this.minHeight = 20f;
this.maxHeight = 20f;

resizeable = false;
}

@Override
public void update() {
super.update();
timeText = "Day: " + (int) (MC.world.getTime() / 24000);
int textWidth = MC.textRenderer.getWidth(timeText);
setWidth(textWidth * 2);
}

@Override
public void draw(DrawContext drawContext, float partialTicks) {
if (timeText != null && getVisible()) {
Rectangle pos = position.getValue();
if (pos.isDrawable()) {
Render2D.drawString(drawContext, timeText, pos.getX(), pos.getY(), GuiManager.foregroundColor.getValue().getColorAsInt());
}
}

super.draw(drawContext, partialTicks);
}
}
86 changes: 0 additions & 86 deletions src/main/java/net/aoba/gui/navigation/huds/InfoHud.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/java/net/aoba/gui/navigation/huds/SpeedHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import net.minecraft.entity.player.PlayerEntity;

public class SpeedHud extends HudWindow {

private static final MinecraftClient MC = MinecraftClient.getInstance();
private String speedText = null;

public SpeedHud(int x, int y) {
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/net/aoba/gui/navigation/huds/TimeHud.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.aoba.gui.navigation.huds;

import net.aoba.gui.GuiManager;
import net.aoba.gui.Rectangle;
import net.aoba.gui.navigation.HudWindow;
import net.aoba.utils.render.Render2D;
import net.minecraft.client.gui.DrawContext;

public class TimeHud extends HudWindow {
private String timeText = null;

public TimeHud(int x, int y) {
super("TimeHud", x, y, 0, 20);
inheritHeightFromChildren = false;

this.minHeight = 20f;
this.maxHeight = 20f;

resizeable = false;
}

@Override
public void update() {
super.update();
int time = ((int) MC.world.getTime() + 6000) % 24000;
String suffix = time >= 12000 ? "PM" : "AM";
StringBuilder timeString = new StringBuilder((time / 10) % 1200 + "");
for (int n = timeString.length(); n < 4; ++n) {
timeString.insert(0, "0");
}
final String[] strsplit = timeString.toString().split("");
String hours = strsplit[0] + strsplit[1];
if (hours.equalsIgnoreCase("00")) {
hours = "12";
}
final int minutes = (int) Math.floor(Double.parseDouble(strsplit[2] + strsplit[3]) / 100.0 * 60.0);
String sm = minutes + "";
if (minutes < 10) {
sm = "0" + minutes;
}
timeString = new StringBuilder(hours + ":" + sm.charAt(0) + sm.charAt(1) + suffix);

timeText = timeString.toString();
int textWidth = MC.textRenderer.getWidth(timeText);
setWidth(textWidth * 2);
}

@Override
public void draw(DrawContext drawContext, float partialTicks) {
if (timeText != null && getVisible()) {
Rectangle pos = position.getValue();
if (pos.isDrawable()) {
Render2D.drawString(drawContext, timeText, pos.getX(), pos.getY(), GuiManager.foregroundColor.getValue().getColorAsInt());
}
}

super.draw(drawContext, partialTicks);
}
}

0 comments on commit f220be2

Please sign in to comment.