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.
This commit is contained in:
@@ -26,6 +26,7 @@ import net.minecraft.client.resource.language.I18n;
|
|||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||||
import com.replaymod.core.events.KeyEventCallback;
|
import com.replaymod.core.events.KeyEventCallback;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
//$$ import net.minecraftforge.fml.common.gameevent.InputEvent;
|
//$$ import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
@@ -67,6 +68,7 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
.setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(5));
|
.setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(5));
|
||||||
|
|
||||||
private final EventHandler eventHandler = new EventHandler();
|
private final EventHandler eventHandler = new EventHandler();
|
||||||
|
private boolean hidden;
|
||||||
|
|
||||||
public GuiReplayOverlay(final ReplayHandler replayHandler) {
|
public GuiReplayOverlay(final ReplayHandler replayHandler) {
|
||||||
timeline = new GuiMarkerTimeline(replayHandler){
|
timeline = new GuiMarkerTimeline(replayHandler){
|
||||||
@@ -162,8 +164,8 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
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
|
// Do not render overlay if all hud, or this one specifically, is hidden and we're not in some popup
|
||||||
if (getMinecraft().options.hudHidden && isAllowUserInput()) {
|
if ((getMinecraft().options.hudHidden || hidden) && isAllowUserInput()) {
|
||||||
// Note that this only applies to when the mouse is visible, otherwise
|
// Note that this only applies to when the mouse is visible, otherwise
|
||||||
// the draw method isn't called in the first place
|
// the draw method isn't called in the first place
|
||||||
return;
|
return;
|
||||||
@@ -207,10 +209,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
//$$ if (!Keyboard.getEventKeyState()) return;
|
//$$ if (!Keyboard.getEventKeyState()) return;
|
||||||
//$$ int key = Keyboard.getEventKey();
|
//$$ int key = Keyboard.getEventKey();
|
||||||
//#endif
|
//#endif
|
||||||
GameOptions gameSettings = getMinecraft().options;
|
// Allow F1 to be used to hide the replay gui (e.g. for recording with OBS)
|
||||||
// Handle the F1 key binding while the overlay is opened as a gui screen
|
|
||||||
if (isMouseVisible() && key == Keyboard.KEY_F1) {
|
if (isMouseVisible() && key == Keyboard.KEY_F1) {
|
||||||
gameSettings.hudHidden = !gameSettings.hudHidden;
|
hidden = !hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user