Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to hide the hud while in guis #3875

Merged
merged 4 commits into from
Jul 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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