mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
emscripten: Handle fullscreen toggling manually
Works better than SDL's own handling thanks to our shell.
This commit is contained in:
parent
01423ead90
commit
7be786b88f
1 changed files with 16 additions and 2 deletions
18
src/utils.c
18
src/utils.c
|
@ -696,12 +696,16 @@ SYMBOL_EXPORT void QuitGame(struct Game* game, bool allow_pausing) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) {
|
SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) {
|
||||||
if (IS_EMSCRIPTEN && game->_priv.params.fixed_size) {
|
#ifdef __EMSCRIPTEN
|
||||||
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, true);
|
if (game->_priv.params.fixed_size) {
|
||||||
|
EM_ASM({
|
||||||
|
document.documentElement.requestFullscreen();
|
||||||
|
});
|
||||||
SetupViewport(game);
|
SetupViewport(game);
|
||||||
PrintConsole(game, "Fullscreen toggled");
|
PrintConsole(game, "Fullscreen toggled");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
game->config.fullscreen = !game->config.fullscreen;
|
game->config.fullscreen = !game->config.fullscreen;
|
||||||
if (game->config.fullscreen) {
|
if (game->config.fullscreen) {
|
||||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "1");
|
SetConfigOption(game, "SuperDerpy", "fullscreen", "1");
|
||||||
|
@ -711,7 +715,17 @@ SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) {
|
||||||
#ifdef ALLEGRO_ANDROID
|
#ifdef ALLEGRO_ANDROID
|
||||||
al_set_display_flag(game->display, ALLEGRO_FRAMELESS, game->config.fullscreen);
|
al_set_display_flag(game->display, ALLEGRO_FRAMELESS, game->config.fullscreen);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
EM_ASM({
|
||||||
|
if ($0) {
|
||||||
|
document.documentElement.requestFullscreen();
|
||||||
|
} else if (document.fullscreenElement) {
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
|
}, game->config.fullscreen);
|
||||||
|
#else
|
||||||
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->config.fullscreen);
|
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->config.fullscreen);
|
||||||
|
#endif
|
||||||
SetupViewport(game);
|
SetupViewport(game);
|
||||||
PrintConsole(game, "Fullscreen toggled: %s", game->config.fullscreen ? "on" : "off");
|
PrintConsole(game, "Fullscreen toggled: %s", game->config.fullscreen ? "on" : "off");
|
||||||
if (!game->_priv.params.show_cursor) {
|
if (!game->_priv.params.show_cursor) {
|
||||||
|
|
Loading…
Reference in a new issue