From 98efed7c51cca39758f8a5b7326c69206b4ab881 Mon Sep 17 00:00:00 2001 From: Heaven Volkoff Date: Sun, 17 May 2020 23:29:41 -0300 Subject: [PATCH] Reset Window now exit fullscreen Change configFullscreen to configWindow.fullscreen --- src/game/options_menu.c | 2 +- src/pc/configfile.c | 4 ++-- src/pc/configfile.h | 2 +- src/pc/gfx/gfx_sdl2.c | 17 ++++++++++------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 61b50b50..b9033bee 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -216,7 +216,7 @@ static struct Option optsControls[] = { }; static struct Option optsVideo[] = { - DEF_OPT_TOGGLE( optsVideoStr[0], &configFullscreen ), + DEF_OPT_TOGGLE( optsVideoStr[0], &configWindow.fullscreen ), DEF_OPT_CHOICE( optsVideoStr[1], &configFiltering, filterChoices ), DEF_OPT_BUTTON( optsVideoStr[4], optvide_reset_window ), }; diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 2b97c5f1..0b6fe370 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -35,7 +35,6 @@ struct ConfigOption { */ // Video/audio stuff -bool configFullscreen = false; ConfigWindow configWindow = { .x = SDL_WINDOWPOS_CENTERED, .y = SDL_WINDOWPOS_CENTERED, @@ -43,6 +42,7 @@ ConfigWindow configWindow = { .h = DESIRED_SCREEN_HEIGHT, .reset = false, .vsync = false, + .fullscreen = false, .exiting_fullscreen = false, }; unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point @@ -79,7 +79,7 @@ bool configCameraMouse = false; unsigned int configSkipIntro = 0; static const struct ConfigOption options[] = { - {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen}, + {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen}, {.name = "window_x", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.x}, {.name = "window_y", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.y}, {.name = "window_w", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.w}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index b2368c89..4343ebdc 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -11,10 +11,10 @@ typedef struct { unsigned int x, y, w, h; bool reset; bool vsync; + bool fullscreen; bool exiting_fullscreen; } ConfigWindow; -extern bool configFullscreen; extern ConfigWindow configWindow; extern unsigned int configFiltering; extern unsigned int configMasterVolume; diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 3c534d00..e34086bf 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -97,9 +97,9 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { #define IS_FULLSCREEN (SDL_GetWindowFlags(wnd) & SDL_WINDOW_FULLSCREEN_DESKTOP) static void gfx_sdl_set_fullscreen() { - if (configFullscreen == IS_FULLSCREEN) + if (configWindow.fullscreen == IS_FULLSCREEN) return; - if (configFullscreen) { + if (configWindow.fullscreen) { SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_ShowCursor(SDL_DISABLE); } else { @@ -119,7 +119,10 @@ static void gfx_sdl_reset_dimension_and_pos() { configWindow.h = DESIRED_SCREEN_HEIGHT; configWindow.reset = false; - if (IS_FULLSCREEN) return; + if (IS_FULLSCREEN) { + configWindow.fullscreen = false; + return; + } } else return; @@ -161,7 +164,7 @@ static void gfx_sdl_init(void) { //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); if (gCLIOpts.FullScreen) - configFullscreen = true; + configWindow.fullscreen = true; const char* window_title = #ifndef USE_GLES @@ -221,9 +224,9 @@ static void gfx_sdl_onkeydown(int scancode) { const Uint8 *state = SDL_GetKeyboardState(NULL); if (state[SDL_SCANCODE_LALT] && state[SDL_SCANCODE_RETURN]) - configFullscreen = !configFullscreen; - else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen) - configFullscreen = false; + configWindow.fullscreen = !configWindow.fullscreen; + else if (state[SDL_SCANCODE_ESCAPE] && configWindow.fullscreen) + configWindow.fullscreen = false; } static void gfx_sdl_onkeyup(int scancode) {