From 9c6f04036414a8597c3be9f0a1622a411aaa09b5 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 29 Aug 2020 09:31:30 +0200 Subject: [PATCH] Change F1 while replay gui is focused to only hide it (closes #259) Previously pressing F1 while the replay gui is focused (i.e. while the mouse is visible) would toggle the global hudHidden state. Now it only toggles the hidden state for the replay itself, allowing the remainder to still be recorded with e.g. OBS where a full render isn't needed. --- .../replay/gui/overlay/GuiReplayOverlay.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/replaymod/replay/gui/overlay/GuiReplayOverlay.java b/src/main/java/com/replaymod/replay/gui/overlay/GuiReplayOverlay.java index 48fced31..ac999d50 100644 --- a/src/main/java/com/replaymod/replay/gui/overlay/GuiReplayOverlay.java +++ b/src/main/java/com/replaymod/replay/gui/overlay/GuiReplayOverlay.java @@ -26,6 +26,7 @@ import net.minecraft.client.resource.language.I18n; //#if MC>=11400 import com.replaymod.core.events.KeyBindingEventCallback; import com.replaymod.core.events.KeyEventCallback; +import org.lwjgl.glfw.GLFW; //#else //$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //$$ import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -67,6 +68,7 @@ public class GuiReplayOverlay extends AbstractGuiOverlay { .setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(5)); private final EventHandler eventHandler = new EventHandler(); + private boolean hidden; public GuiReplayOverlay(final ReplayHandler replayHandler) { timeline = new GuiMarkerTimeline(replayHandler){ @@ -162,8 +164,8 @@ public class GuiReplayOverlay extends AbstractGuiOverlay { @Override public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) { - // Do not render overlay when user pressed F1 and we are not currently in some popup - if (getMinecraft().options.hudHidden && isAllowUserInput()) { + // Do not render overlay if all hud, or this one specifically, is hidden and we're not in some popup + if ((getMinecraft().options.hudHidden || hidden) && isAllowUserInput()) { // Note that this only applies to when the mouse is visible, otherwise // the draw method isn't called in the first place return; @@ -207,10 +209,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay { //$$ if (!Keyboard.getEventKeyState()) return; //$$ int key = Keyboard.getEventKey(); //#endif - GameOptions gameSettings = getMinecraft().options; - // Handle the F1 key binding while the overlay is opened as a gui screen + // Allow F1 to be used to hide the replay gui (e.g. for recording with OBS) if (isMouseVisible() && key == Keyboard.KEY_F1) { - gameSettings.hudHidden = !gameSettings.hudHidden; + hidden = !hidden; } } }