This commit is contained in:
Jess H 2024-05-27 10:21:39 +01:00
commit 5674d94163
2 changed files with 35 additions and 40 deletions

View file

@ -69,19 +69,16 @@ public class HUD extends Feature {
Left, Center, Right Left, Center, Right
} }
@Config("Notifications") @Config("Include status in length")
@Marker(1) @Description("By default, status (greyed out information tucked on the end of module names) is not factored into the sorting. This setting lets you change that.")
@Gate(Integer.MIN_VALUE) public boolean includeStatus = false;
public boolean notifications = true;
@Config("Notification location") @Config("Notification location")
@Description("Where to display notifications. Left and Right display the most recent at the top, Center displays the most recent at the bottom.") @Description("Where to display notifications. Left and Right display the most recent at the top, Center displays the most recent at the bottom.")
@Gate(1)
public NotificationLocation nLocation = NotificationLocation.Center; public NotificationLocation nLocation = NotificationLocation.Center;
@Config("Advanced") @Config("Advanced")
@Description("Show rendering controls for notifications.") @Description("Show rendering controls for notifications.")
@Gate(1)
@Marker(2) @Marker(2)
public boolean advancedNotifs = false; public boolean advancedNotifs = false;
@ -132,47 +129,45 @@ public class HUD extends Feature {
mc.fontRenderer.drawStringWithShadow("§lBaseBand§r - \"" + BaseBand.buildString + "\"", 2,2, BaseBand.getFeature(Client.class).getTheme().getGreenColor()); mc.fontRenderer.drawStringWithShadow("§lBaseBand§r - \"" + BaseBand.buildString + "\"", 2,2, BaseBand.getFeature(Client.class).getTheme().getGreenColor());
int y = 11; int y = 11;
for (Feature f : Arrays.stream(features).filter(m -> m.enabled && m.category != Category.COMMAND && m.getClass() != Client.class && m != this).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(value.toString()))).toArray(Feature[]::new)) { for (Feature f : Arrays.stream(features).filter(m -> m.enabled && m.category != Category.COMMAND && m.getClass() != Client.class && m != this).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(includeStatus ? value.text : value.toString()))).toArray(Feature[]::new)) {
mc.fontRenderer.drawStringWithShadow(f.text, 2, y, BaseBand.getFeature(Client.class).getTheme().getGreenColor()); mc.fontRenderer.drawStringWithShadow(f.text, 2, y, BaseBand.getFeature(Client.class).getTheme().getGreenColor());
y = y + mc.fontRenderer.FONT_HEIGHT; y = y + mc.fontRenderer.FONT_HEIGHT;
} }
if(notifications) {
int dir = (nLocation == NotificationLocation.Center ? -1 : 1); int dir = (nLocation == NotificationLocation.Center ? -1 : 1);
int isCenter = (nLocation == NotificationLocation.Center ? 1 : 0); int isCenter = (nLocation == NotificationLocation.Center ? 1 : 0);
int xSize = this.nSize * 100; int xSize = this.nSize * 100;
int ySize = this.nVSize * 10; int ySize = this.nVSize * 10;
int textOffset = (ySize / 2 - (mc.fontRenderer.FONT_HEIGHT / 2)); int textOffset = (ySize / 2 - (mc.fontRenderer.FONT_HEIGHT / 2));
int x = 2; int x = 2;
if(nLocation == NotificationLocation.Center) { if(nLocation == NotificationLocation.Center) {
x = sr.getScaledWidth() / 2 - (xSize / 2); x = sr.getScaledWidth() / 2 - (xSize / 2);
y = sr.getScaledHeight() / 4; y = sr.getScaledHeight() / 4;
} else { } else {
if(nLocation == NotificationLocation.Right) { if(nLocation == NotificationLocation.Right) {
y = -5; y = -5;
x = sr.getScaledWidth() - x - xSize; x = sr.getScaledWidth() - x - xSize;
}
y += 5;
y += nVSpace;
} }
y += 5;
y += nVSpace;
}
Notification[] notifs = HUD.notifs.toArray(new Notification[0]); Notification[] notifs = HUD.notifs.toArray(new Notification[0]);
for (int i = notifs.length - 1; i >= 0; i--) { for (int i = notifs.length - 1; i >= 0; i--) {
Notification notif = notifs[i]; Notification notif = notifs[i];
int localYSize = ySize; int localYSize = ySize;
String text = TextSplitter.breakText(notif.text, xSize - textOffset * 2); String text = TextSplitter.breakText(notif.text, xSize - textOffset * 2);
localYSize -= TextSplitter.getStringHeight(text) - mc.fontRenderer.FONT_HEIGHT; localYSize -= TextSplitter.getStringHeight(text) - mc.fontRenderer.FONT_HEIGHT;
int textboxYSize = localYSize; int textboxYSize = localYSize;
localYSize = notif.opacity(localYSize, 1); localYSize = notif.opacity(localYSize, 1);
drawSizedBox(x, y, xSize, localYSize, 0x202040 + (notif.opacity(0x80, 1) << 24), isCenter == 1); drawSizedBox(x, y, xSize, localYSize, 0x202040 + (notif.opacity(0x80, 1) << 24), isCenter == 1);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
renderSplit(text, x + textOffset, y + textOffset - isCenter * textboxYSize, 0xffffff + (Math.max(8, notif.opacity(0xff, 2)) << 24), notif.opacity(2) == 1.0); renderSplit(text, x + textOffset, y + textOffset - isCenter * textboxYSize, 0xffffff + (Math.max(8, notif.opacity(0xff, 2)) << 24), notif.opacity(2) == 1.0);
GlStateManager.disableBlend(); GlStateManager.disableBlend();
y += (localYSize + nVSpace) * dir; y += (localYSize + nVSpace) * dir;
}
} }
} }

View file

@ -17,8 +17,8 @@ public class Ping extends Feature {
@Config("Seconds") @Config("Seconds")
@Description("How many seconds to add to your ping.\n" + @Description("How many seconds to add to your ping.\n" +
"§lWarning§r: You might get timed out on high settings (Time-out happens at 30 seconds including real ping).") "§lWarning§r: You might get timed out on high settings (Time-out happens at 15 seconds including real ping).")
@Range("0..28") @Range("0..14")
public int seconds; public int seconds;
@Override @Override