From fd74e20373b0b471724433e88c07d647376efcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= Date: Fri, 15 May 2020 12:51:06 -0300 Subject: [PATCH] Add a `--fullscreen` CLI option --- src/pc/cliopts.c | 6 +++++- src/pc/cliopts.h | 3 ++- src/pc/gfx/gfx_sdl2.c | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index cd77ef12..602de098 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -6,7 +6,8 @@ struct PCCLIOptions gCLIOpts; void parse_cli_opts(int argc, char* argv[]) { // Initialize options with false values. - gCLIOpts.SkipIntro = 0; + gCLIOpts.SkipIntro = 0; + gCLIOpts.FullScreen = 0; // Scan arguments for options if (argc > 1) @@ -16,6 +17,9 @@ void parse_cli_opts(int argc, char* argv[]) { if (strcmp(argv[i], "--skip-intro") == 0) // Skip Peach Intro gCLIOpts.SkipIntro = 1; + + if (strcmp(argv[i], "--fullscreen") == 0) // Open game in fullscreen + gCLIOpts.FullScreen = 1; } } } \ No newline at end of file diff --git a/src/pc/cliopts.h b/src/pc/cliopts.h index 2f08cc4e..b4a0b613 100644 --- a/src/pc/cliopts.h +++ b/src/pc/cliopts.h @@ -3,8 +3,9 @@ struct PCCLIOptions { u8 SkipIntro; + u8 FullScreen; }; extern struct PCCLIOptions gCLIOpts; -void parse_cli_opts(int argc, char* argv[]); \ No newline at end of file +void parse_cli_opts(int argc, char* argv[]); diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index a794c6d3..561ac95b 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -19,6 +19,7 @@ #include "gfx_window_manager_api.h" #include "gfx_screen_config.h" #include "../configfile.h" +#include "../cliopts.h" #include "src/pc/controller/controller_keyboard.h" @@ -113,6 +114,10 @@ static void gfx_sdl_init(void) { window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; + if (gCLIOpts.FullScreen) { + configFullscreen = true; + } + if (configFullscreen) { window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; }