From 4f59eb260203af263ee7093e08c2811f405f4afa Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 17 Apr 2022 01:57:50 -0500 Subject: [PATCH] GUI: add toggle full-screen keybind --- src/gui/doAction.cpp | 4 ++++ src/gui/gui.cpp | 5 ++--- src/gui/gui.h | 1 + src/gui/guiConst.cpp | 1 + src/gui/settings.cpp | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index cd4dda075..b68d684d3 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -136,6 +136,10 @@ void FurnaceGUI::doAction(int what) { case GUI_ACTION_FOLLOW_PATTERN: followPattern=!followPattern; break; + case GUI_ACTION_FULLSCREEN: + fullScreen=!fullScreen; + SDL_SetWindowFullscreen(sdlWin,fullScreen?(SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP):0); + break; case GUI_ACTION_PANIC: e->syncReset(); break; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 30b90793e..fab19120b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2476,9 +2476,8 @@ bool FurnaceGUI::loop() { ImGui::EndMenu(); } if (ImGui::BeginMenu("settings")) { - if (ImGui::MenuItem("full screen",NULL,fullScreen)) { - fullScreen=!fullScreen; - SDL_SetWindowFullscreen(sdlWin,fullScreen?(SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP):0); + if (ImGui::MenuItem("full screen",BIND_FOR(GUI_ACTION_FULLSCREEN),fullScreen)) { + doAction(GUI_ACTION_FULLSCREEN); } if (ImGui::MenuItem("lock layout",NULL,lockLayout)) { lockLayout=!lockLayout; diff --git a/src/gui/gui.h b/src/gui/gui.h index 4743a0002..b193e39a5 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -297,6 +297,7 @@ enum FurnaceGUIActions { GUI_ACTION_REPEAT_PATTERN, GUI_ACTION_FOLLOW_ORDERS, GUI_ACTION_FOLLOW_PATTERN, + GUI_ACTION_FULLSCREEN, GUI_ACTION_PANIC, GUI_ACTION_WINDOW_EDIT_CONTROLS, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 10b004421..7cc173c52 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -167,6 +167,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("REPEAT_PATTERN", "Toggle repeat pattern", 0), D("FOLLOW_ORDERS", "Follow orders", 0), D("FOLLOW_PATTERN", "Follow pattern", 0), + D("FULLSCREEN", "Toggle full-screen", FURKMOD_ALT|SDLK_RETURN), D("PANIC", "Panic", SDLK_F12), D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0), diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index be0805f3a..7ead6c204 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1249,6 +1249,7 @@ void FurnaceGUI::drawSettings() { UI_KEYBIND_CONFIG(GUI_ACTION_REPEAT_PATTERN); UI_KEYBIND_CONFIG(GUI_ACTION_FOLLOW_ORDERS); UI_KEYBIND_CONFIG(GUI_ACTION_FOLLOW_PATTERN); + UI_KEYBIND_CONFIG(GUI_ACTION_FULLSCREEN); UI_KEYBIND_CONFIG(GUI_ACTION_PANIC); KEYBIND_CONFIG_END;