Emscripten: Disable hopefully all ways to quit
Also fix FPS going nuts when recreating the window by setting it again every time.
This commit is contained in:
parent
845e195ba5
commit
bfe7d765c4
@ -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@";
|
||||
|
@ -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);
|
||||
|
@ -49,3 +49,4 @@ void SaveWindowPosition();
|
||||
void LargeScreenDialog();
|
||||
void TickClient();
|
||||
void EventProcess(const SDL_Event &event);
|
||||
void UpdateFpsLimit();
|
||||
|
@ -12,3 +12,7 @@ void MainLoop()
|
||||
void SetFpsLimit(FpsLimit newFpsLimit)
|
||||
{
|
||||
}
|
||||
|
||||
void UpdateFpsLimit()
|
||||
{
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "gui/interface/Textbox.h"
|
||||
#include "gui/interface/DirectionSelector.h"
|
||||
#include "PowderToySDL.h"
|
||||
#include "Config.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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')
|
||||
|
||||
|
Reference in New Issue
Block a user