Skip to content

Commit

Permalink
Add an option to hide the hud while in guis (MeteorDevelopment#3875)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat authored Jul 23, 2023
1 parent a52b91a commit 4586315
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import meteordevelopment.meteorclient.events.meteor.CustomFontChangedEvent;
import meteordevelopment.meteorclient.events.render.Render2DEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.gui.WidgetScreen;
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.System;
import meteordevelopment.meteorclient.systems.Systems;
Expand Down Expand Up @@ -51,6 +52,13 @@ public class Hud extends System<Hud> implements Iterable<HudElement> {
.build()
);

private final Setting<Boolean> hideInMenus = sgGeneral.add(new BoolSetting.Builder()
.name("hide-in-menus")
.description("Hides the meteor hud when in inventory screens or game menus.")
.defaultValue(false)
.build()
);

private final Setting<Double> textScale = sgGeneral.add(new DoubleSetting.Builder()
.name("text-scale")
.description("Scale of text if not overridden by the element.")
Expand Down Expand Up @@ -214,7 +222,9 @@ private void onTick(TickEvent.Post event) {
@EventHandler
private void onRender(Render2DEvent event) {
if (Utils.isLoading()) return;
if (!(active && ((!mc.options.hudHidden && !mc.options.debugEnabled) || HudEditorScreen.isOpen()))) return;

if (!active || shouldHideHud()) return;
if ((mc.options.hudHidden || mc.options.debugEnabled) && !HudEditorScreen.isOpen()) return;

HudRenderer.INSTANCE.begin(event.drawContext);

Expand All @@ -227,6 +237,10 @@ private void onRender(Render2DEvent event) {
HudRenderer.INSTANCE.end();
}

private boolean shouldHideHud() {
return hideInMenus.get() && mc.currentScreen != null && !(mc.currentScreen instanceof WidgetScreen);
}

@EventHandler
private void onCustomFontChanged(CustomFontChangedEvent event) {
if (customFont.get()) {
Expand Down

0 comments on commit 4586315

Please sign in to comment.