From b843e9a6cbfba9927013557f61399640dc2556bb Mon Sep 17 00:00:00 2001 From: prototux Date: Wed, 29 Sep 2021 02:21:21 +0200 Subject: [PATCH 1/3] Added an option to show or hide the menu. --- SpaceCadetPinball/options.cpp | 6 ++++++ SpaceCadetPinball/options.h | 2 ++ SpaceCadetPinball/winmain.cpp | 21 ++++++++++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/SpaceCadetPinball/options.cpp b/SpaceCadetPinball/options.cpp index 658e96d..4040595 100644 --- a/SpaceCadetPinball/options.cpp +++ b/SpaceCadetPinball/options.cpp @@ -65,6 +65,7 @@ void options::init() Options.Sounds = 1; Options.Music = 0; + Options.ShowMenu = 1; Options.FullScreen = 0; Options.LeftFlipperKeyDft = SDLK_z; Options.RightFlipperKeyDft = SDLK_SLASH; @@ -88,6 +89,7 @@ void options::init() Options.UniformScaling = true; Options.Sounds = get_int("Sounds", Options.Sounds); Options.Music = get_int("Music", Options.Music); + Options.ShowMenu = get_int("ShowMenu", Options.ShowMenu); Options.FullScreen = get_int("FullScreen", Options.FullScreen); Options.Players = get_int("Players", Options.Players); Options.LeftFlipperKey = get_int("Left Flipper key", Options.LeftFlipperKey); @@ -118,6 +120,7 @@ void options::uninit() { set_int("Sounds", Options.Sounds); set_int("Music", Options.Music); + set_int("ShowMenu", Options.ShowMenu); set_int("FullScreen", Options.FullScreen); set_int("Players", Options.Players); set_int("Left Flipper key", Options.LeftFlipperKey); @@ -186,6 +189,9 @@ void options::toggle(Menu1 uIDCheckItem) else midi::play_pb_theme(0); return; + case Menu1::Show_Menu: + Options.ShowMenu = Options.ShowMenu == 0; + return; case Menu1::Full_Screen: newValue = Options.FullScreen == 0; Options.FullScreen = Options.FullScreen == 0; diff --git a/SpaceCadetPinball/options.h b/SpaceCadetPinball/options.h index accdbb9..0ee6de2 100644 --- a/SpaceCadetPinball/options.h +++ b/SpaceCadetPinball/options.h @@ -20,6 +20,7 @@ enum class Menu1:int TwoPlayers = 409, ThreePlayers = 410, FourPlayers = 411, + Show_Menu = 412, MaximumResolution = 500, R640x480 = 501, R800x600 = 502, @@ -32,6 +33,7 @@ struct optionsStruct { int Sounds; int Music; + int ShowMenu; int FullScreen; int Players; int LeftFlipperKey; diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index a8bfbea..5499567 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -244,16 +244,23 @@ int winmain::WinMain(LPCSTR lpCmdLine) if (UpdateToFrameCounter >= UpdateToFrameRatio) { UpdateToFrameCounter -= UpdateToFrameRatio; - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - RenderUi(); + if (options::Options.ShowMenu) + { + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); + + RenderUi(); + } SDL_RenderClear(renderer); render::PresentVScreen(); - ImGui::Render(); - ImGuiSDL::Render(ImGui::GetDrawData()); + if (options::Options.ShowMenu) + { + ImGui::Render(); + ImGuiSDL::Render(ImGui::GetDrawData()); + } SDL_RenderPresent(renderer); frameCounter++; @@ -353,6 +360,10 @@ void winmain::RenderUi() if (ImGui::BeginMenu("Options")) { + if (ImGui::MenuItem("Show Menu", "F5", options::Options.ShowMenu)) + { + options::toggle(Menu1::Show_Menu); + } if (ImGui::MenuItem("Full Screen", "F4", options::Options.FullScreen)) { options::toggle(Menu1::Full_Screen); From 89f4b6d53590ff3685d6e59822d7e47ca7739ab7 Mon Sep 17 00:00:00 2001 From: prototux Date: Wed, 29 Sep 2021 03:17:05 +0200 Subject: [PATCH 2/3] Fixed the keyboard shortcut for show menu --- SpaceCadetPinball/winmain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index 5499567..a913c6c 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -360,7 +360,7 @@ void winmain::RenderUi() if (ImGui::BeginMenu("Options")) { - if (ImGui::MenuItem("Show Menu", "F5", options::Options.ShowMenu)) + if (ImGui::MenuItem("Show Menu", "F9", options::Options.ShowMenu)) { options::toggle(Menu1::Show_Menu); } @@ -584,6 +584,9 @@ int winmain::event_handler(const SDL_Event* event) pause(); options::keyboard(); break; + case SDLK_F0: + options::toggle(Menu1::Show_Menu); + break; default: break; } From 7c29c05d644a6fb7f1ba97e73fab5b3ceb481c36 Mon Sep 17 00:00:00 2001 From: prototux Date: Wed, 29 Sep 2021 06:09:16 +0200 Subject: [PATCH 3/3] Fixed the keyboard shortcut for show menu --- SpaceCadetPinball/winmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index a913c6c..fbf0491 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -584,7 +584,7 @@ int winmain::event_handler(const SDL_Event* event) pause(); options::keyboard(); break; - case SDLK_F0: + case SDLK_F9: options::toggle(Menu1::Show_Menu); break; default: