diff --git a/src/Config.template.h b/src/Config.template.h index df259cc38..9f81be2ae 100644 --- a/src/Config.template.h +++ b/src/Config.template.h @@ -18,6 +18,7 @@ constexpr bool ENFORCE_HTTPS = @ENFORCE_HTTPS@; constexpr bool SECURE_CIPHERS_ONLY = @SECURE_CIPHERS_ONLY@; constexpr bool FFTW_PLAN_MEASURE = @FFTW_PLAN_MEASURE@; constexpr bool DEFAULT_VSYNC = @DEFAULT_VSYNC@; +constexpr bool ALLOW_QUIT = @ALLOW_QUIT@; constexpr char PATH_SEP_CHAR = '@PATH_SEP_CHAR@'; constexpr char SERVER[] = "@SERVER@"; diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 55f735f01..56fe5a8a1 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -223,6 +223,7 @@ bool RecreateWindow() //SDL_SetWindowResizable(sdl_window, SDL_TRUE); LoadWindowPosition(); + UpdateFpsLimit(); return true; } @@ -233,15 +234,17 @@ void EventProcess(const SDL_Event &event) switch (event.type) { case SDL_QUIT: - if (engine.GetFastQuit() || engine.CloseWindow()) + if (ALLOW_QUIT && (engine.GetFastQuit() || engine.CloseWindow())) + { engine.Exit(); + } break; case SDL_KEYDOWN: if (SDL_GetModState() & KMOD_GUI) { break; } - if (!event.key.repeat && event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL)) + if (ALLOW_QUIT && !event.key.repeat && event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL)) engine.ConfirmExit(); else engine.onKeyPress(event.key.keysym.sym, event.key.keysym.scancode, event.key.repeat, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT); diff --git a/src/PowderToySDL.h b/src/PowderToySDL.h index 728daf4e7..e54dc4703 100644 --- a/src/PowderToySDL.h +++ b/src/PowderToySDL.h @@ -49,3 +49,4 @@ void SaveWindowPosition(); void LargeScreenDialog(); void TickClient(); void EventProcess(const SDL_Event &event); +void UpdateFpsLimit(); diff --git a/src/PowderToySDLCommon.cpp b/src/PowderToySDLCommon.cpp index 294c45a9d..c1d27fa46 100644 --- a/src/PowderToySDLCommon.cpp +++ b/src/PowderToySDLCommon.cpp @@ -12,3 +12,7 @@ void MainLoop() void SetFpsLimit(FpsLimit newFpsLimit) { } + +void UpdateFpsLimit() +{ +} diff --git a/src/PowderToySDLEmscripten.cpp b/src/PowderToySDLEmscripten.cpp index 056c0ea87..cdde6963f 100644 --- a/src/PowderToySDLEmscripten.cpp +++ b/src/PowderToySDLEmscripten.cpp @@ -39,10 +39,15 @@ void SetFpsLimit(FpsLimit newFpsLimit) } } +void UpdateFpsLimit() +{ + SetFpsLimit(ui::Engine::Ref().GetFpsLimit()); +} + // Is actually only called once at startup, the real main loop body is MainLoopBody. void MainLoop() { - SetFpsLimit(ui::Engine::Ref().GetFpsLimit()); + UpdateFpsLimit(); MainLoopBody(); EM_ASM({ let canvas = document.querySelector("canvas.emscripten"); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index bf0fc09ae..bb1fdaed8 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1495,7 +1495,10 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, break; case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_Q: - ui::Engine::Ref().ConfirmExit(); + if (ALLOW_QUIT) + { + ui::Engine::Ref().ConfirmExit(); + } break; case SDL_SCANCODE_U: if (ctrl) diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index f3da7f231..eaa355d62 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -18,6 +18,7 @@ #include "gui/interface/Textbox.h" #include "gui/interface/DirectionSelector.h" #include "PowderToySDL.h" +#include "Config.h" #include #include #include @@ -264,9 +265,12 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340)) c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); }); addSeparator(); - fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] { - c->SetFastQuit(fastquit->GetChecked()); - }); + if (ALLOW_QUIT) + { + fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] { + c->SetFastQuit(fastquit->GetChecked()); + }); + } showAvatars = addCheckbox(0, "Show avatars", "Disable if you have a slow connection", [this] { c->SetShowAvatars(showAvatars->GetChecked()); }); @@ -424,7 +428,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender) fullscreen->SetChecked(sender->GetFullscreen()); altFullscreen->SetChecked(sender->GetAltFullscreen()); forceIntegerScaling->SetChecked(sender->GetForceIntegerScaling()); - fastquit->SetChecked(sender->GetFastQuit()); + if (fastquit) + { + fastquit->SetChecked(sender->GetFastQuit()); + } showAvatars->SetChecked(sender->GetShowAvatars()); mouseClickRequired->SetChecked(sender->GetMouseClickRequired()); includePressure->SetChecked(sender->GetIncludePressure()); diff --git a/src/gui/options/OptionsView.h b/src/gui/options/OptionsView.h index ee9a6c1a4..fb67e64c1 100644 --- a/src/gui/options/OptionsView.h +++ b/src/gui/options/OptionsView.h @@ -31,7 +31,7 @@ class OptionsView: public ui::Window ui::Checkbox * fullscreen; ui::Checkbox * altFullscreen; ui::Checkbox * forceIntegerScaling; - ui::Checkbox * fastquit; + ui::Checkbox * fastquit = nullptr; ui::DropDown * decoSpace; ui::Checkbox * showAvatars; ui::Checkbox * momentumScroll; diff --git a/src/meson.build b/src/meson.build index 14e56386f..3122783a9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -21,10 +21,15 @@ conf_data.set('UPDATESERVER', update_server) conf_data.set('USE_UPDATESERVER', update_server != '' ? 'true' : 'false') enforce_https = get_option('enforce_https') +allow_quit = true +if host_platform == 'emscripten' + allow_quit = false +endif secure_ciphers_only = get_option('secure_ciphers_only') if not is_debug and not enforce_https error('refusing to build a release binary without enforcing HTTPS, configure with -Denforce_https=true to fix this error') endif +conf_data.set('ALLOW_QUIT', allow_quit ? 'true' : 'false') conf_data.set('ENFORCE_HTTPS', enforce_https ? 'true' : 'false') conf_data.set('SECURE_CIPHERS_ONLY', secure_ciphers_only ? 'true' : 'false')