Skip to content

Commit

Permalink
Per Line Only
Browse files Browse the repository at this point in the history
Block mode didn't look that good tbh
  • Loading branch information
machiecodes committed Jan 8, 2025
1 parent a26e62b commit c4804b9
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,18 @@ public class ActiveModulesHud extends HudElement {

// Background

private final Setting<Background> background = sgBackground.add(new EnumSetting.Builder<Background>()
private final Setting<Boolean> background = sgBackground.add(new BoolSetting.Builder()
.name("background")
.description("How to render the background.")
.defaultValue(Background.None)
.description("Displays background.")
.defaultValue(false)
.build()
);

private final Setting<SettingColor> backgroundColor = sgBackground.add(new ColorSetting.Builder()
.name("background-color")
.description("Color of the background.")
.defaultValue(new SettingColor(0, 0, 0, 75))
.visible(() -> background.get() != Background.None)
.description("Color used for the background.")
.visible(background::get)
.defaultValue(new SettingColor(25, 25, 25, 50))
.build()
);

Expand Down Expand Up @@ -250,10 +250,6 @@ public void render(HudRenderer renderer) {
prevX = x + offset;
y += renderer.textHeight(shadow.get(), getScale());
}

if (background.get() == Background.Block) {
renderer.quad(this.x - 2, this.y - 2, getWidth() + 4, getHeight() + 4, backgroundColor.get());
}
}

private void renderModule(HudRenderer renderer, int index, double x, double y) {
Expand Down Expand Up @@ -296,7 +292,7 @@ private void renderModule(HudRenderer renderer, int index, double x, double y) {
renderer.quad(x - 2 - outlineWidth.get(), lineStartY - outlineWidth.get(),
textLength + 4 + 2 * outlineWidth.get(),
outlineWidth.get(), prevColor, prevColor, color, color);
} else if (background.get() != Background.Block) { // Otherwise render the inbetween quads that connect each side quad
} else { // Inbetweens are rendered above the current line so don't need for the top
renderer.quad(Math.min(prevX, x) - 2 - outlineWidth.get(), Math.max(prevX, x) == x ? y : y - outlineWidth.get(),
(Math.max(prevX, x) - 2) - (Math.min(prevX, x) - 2 - outlineWidth.get()), outlineWidth.get(),
prevColor, prevColor, color, color); // Left inbetween quad
Expand All @@ -323,7 +319,7 @@ private void renderModule(HudRenderer renderer, int index, double x, double y) {
prevColor, prevColor, color, color);
}

if (background.get() == Background.Text) {
if (background.get()) {
renderer.quad( x - 2, lineStartY, textLength + 4, lineHeight, backgroundColor.get());
}

Expand Down

0 comments on commit c4804b9

Please sign in to comment.