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 SECURE_CIPHERS_ONLY = @SECURE_CIPHERS_ONLY@;
|
||||||
constexpr bool FFTW_PLAN_MEASURE = @FFTW_PLAN_MEASURE@;
|
constexpr bool FFTW_PLAN_MEASURE = @FFTW_PLAN_MEASURE@;
|
||||||
constexpr bool DEFAULT_VSYNC = @DEFAULT_VSYNC@;
|
constexpr bool DEFAULT_VSYNC = @DEFAULT_VSYNC@;
|
||||||
|
constexpr bool ALLOW_QUIT = @ALLOW_QUIT@;
|
||||||
constexpr char PATH_SEP_CHAR = '@PATH_SEP_CHAR@';
|
constexpr char PATH_SEP_CHAR = '@PATH_SEP_CHAR@';
|
||||||
|
|
||||||
constexpr char SERVER[] = "@SERVER@";
|
constexpr char SERVER[] = "@SERVER@";
|
||||||
|
@ -223,6 +223,7 @@ bool RecreateWindow()
|
|||||||
//SDL_SetWindowResizable(sdl_window, SDL_TRUE);
|
//SDL_SetWindowResizable(sdl_window, SDL_TRUE);
|
||||||
|
|
||||||
LoadWindowPosition();
|
LoadWindowPosition();
|
||||||
|
UpdateFpsLimit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -233,15 +234,17 @@ void EventProcess(const SDL_Event &event)
|
|||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
if (engine.GetFastQuit() || engine.CloseWindow())
|
if (ALLOW_QUIT && (engine.GetFastQuit() || engine.CloseWindow()))
|
||||||
|
{
|
||||||
engine.Exit();
|
engine.Exit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (SDL_GetModState() & KMOD_GUI)
|
if (SDL_GetModState() & KMOD_GUI)
|
||||||
{
|
{
|
||||||
break;
|
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();
|
engine.ConfirmExit();
|
||||||
else
|
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);
|
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 LargeScreenDialog();
|
||||||
void TickClient();
|
void TickClient();
|
||||||
void EventProcess(const SDL_Event &event);
|
void EventProcess(const SDL_Event &event);
|
||||||
|
void UpdateFpsLimit();
|
||||||
|
@ -12,3 +12,7 @@ void MainLoop()
|
|||||||
void SetFpsLimit(FpsLimit newFpsLimit)
|
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.
|
// Is actually only called once at startup, the real main loop body is MainLoopBody.
|
||||||
void MainLoop()
|
void MainLoop()
|
||||||
{
|
{
|
||||||
SetFpsLimit(ui::Engine::Ref().GetFpsLimit());
|
UpdateFpsLimit();
|
||||||
MainLoopBody();
|
MainLoopBody();
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
let canvas = document.querySelector("canvas.emscripten");
|
let canvas = document.querySelector("canvas.emscripten");
|
||||||
|
@ -1495,7 +1495,10 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl,
|
|||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
case SDL_SCANCODE_Q:
|
case SDL_SCANCODE_Q:
|
||||||
ui::Engine::Ref().ConfirmExit();
|
if (ALLOW_QUIT)
|
||||||
|
{
|
||||||
|
ui::Engine::Ref().ConfirmExit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_SCANCODE_U:
|
case SDL_SCANCODE_U:
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
#include "gui/interface/DirectionSelector.h"
|
#include "gui/interface/DirectionSelector.h"
|
||||||
#include "PowderToySDL.h"
|
#include "PowderToySDL.h"
|
||||||
|
#include "Config.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -264,9 +265,12 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
|
|||||||
c->SetForceIntegerScaling(forceIntegerScaling->GetChecked());
|
c->SetForceIntegerScaling(forceIntegerScaling->GetChecked());
|
||||||
});
|
});
|
||||||
addSeparator();
|
addSeparator();
|
||||||
fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] {
|
if (ALLOW_QUIT)
|
||||||
c->SetFastQuit(fastquit->GetChecked());
|
{
|
||||||
});
|
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] {
|
showAvatars = addCheckbox(0, "Show avatars", "Disable if you have a slow connection", [this] {
|
||||||
c->SetShowAvatars(showAvatars->GetChecked());
|
c->SetShowAvatars(showAvatars->GetChecked());
|
||||||
});
|
});
|
||||||
@ -424,7 +428,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
|||||||
fullscreen->SetChecked(sender->GetFullscreen());
|
fullscreen->SetChecked(sender->GetFullscreen());
|
||||||
altFullscreen->SetChecked(sender->GetAltFullscreen());
|
altFullscreen->SetChecked(sender->GetAltFullscreen());
|
||||||
forceIntegerScaling->SetChecked(sender->GetForceIntegerScaling());
|
forceIntegerScaling->SetChecked(sender->GetForceIntegerScaling());
|
||||||
fastquit->SetChecked(sender->GetFastQuit());
|
if (fastquit)
|
||||||
|
{
|
||||||
|
fastquit->SetChecked(sender->GetFastQuit());
|
||||||
|
}
|
||||||
showAvatars->SetChecked(sender->GetShowAvatars());
|
showAvatars->SetChecked(sender->GetShowAvatars());
|
||||||
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
||||||
includePressure->SetChecked(sender->GetIncludePressure());
|
includePressure->SetChecked(sender->GetIncludePressure());
|
||||||
|
@ -31,7 +31,7 @@ class OptionsView: public ui::Window
|
|||||||
ui::Checkbox * fullscreen;
|
ui::Checkbox * fullscreen;
|
||||||
ui::Checkbox * altFullscreen;
|
ui::Checkbox * altFullscreen;
|
||||||
ui::Checkbox * forceIntegerScaling;
|
ui::Checkbox * forceIntegerScaling;
|
||||||
ui::Checkbox * fastquit;
|
ui::Checkbox * fastquit = nullptr;
|
||||||
ui::DropDown * decoSpace;
|
ui::DropDown * decoSpace;
|
||||||
ui::Checkbox * showAvatars;
|
ui::Checkbox * showAvatars;
|
||||||
ui::Checkbox * momentumScroll;
|
ui::Checkbox * momentumScroll;
|
||||||
|
@ -21,10 +21,15 @@ conf_data.set('UPDATESERVER', update_server)
|
|||||||
conf_data.set('USE_UPDATESERVER', update_server != '' ? 'true' : 'false')
|
conf_data.set('USE_UPDATESERVER', update_server != '' ? 'true' : 'false')
|
||||||
|
|
||||||
enforce_https = get_option('enforce_https')
|
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')
|
secure_ciphers_only = get_option('secure_ciphers_only')
|
||||||
if not is_debug and not enforce_https
|
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')
|
error('refusing to build a release binary without enforcing HTTPS, configure with -Denforce_https=true to fix this error')
|
||||||
endif
|
endif
|
||||||
|
conf_data.set('ALLOW_QUIT', allow_quit ? 'true' : 'false')
|
||||||
conf_data.set('ENFORCE_HTTPS', enforce_https ? 'true' : 'false')
|
conf_data.set('ENFORCE_HTTPS', enforce_https ? 'true' : 'false')
|
||||||
conf_data.set('SECURE_CIPHERS_ONLY', secure_ciphers_only ? 'true' : 'false')
|
conf_data.set('SECURE_CIPHERS_ONLY', secure_ciphers_only ? 'true' : 'false')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user