Index: dataobj/environment.cc =================================================================== --- dataobj/environment.cc (revisión: 10142) +++ dataobj/environment.cc (copia de trabajo) @@ -17,6 +17,7 @@ void rdwr_win_settings(loadsave_t *file); // simwin sint16 env_t::menupos = MENU_TOP; +bool env_t::fullscreen = false; bool env_t::reselect_closes_tool = true; sint8 env_t::pak_tile_height_step = 16; @@ -559,6 +560,8 @@ file->rdwr_bool( single_line_gui ); file->rdwr_byte( show_factory_storage_bar ); + + file->rdwr_bool( fullscreen ); } // server settings are not saved, since they are server specific Index: dataobj/environment.h =================================================================== --- dataobj/environment.h (revisión: 10142) +++ dataobj/environment.h (copia de trabajo) @@ -37,6 +37,8 @@ static sint16 menupos; + static bool fullscreen; + static bool reselect_closes_tool; /// points to the current user directory for loading and saving Index: gui/display_settings.cc =================================================================== --- gui/display_settings.cc (revisión: 10142) +++ gui/display_settings.cc (copia de trabajo) @@ -18,6 +18,7 @@ #include "../simmenu.h" #include "../player/simplay.h" #include "../utils/simstring.h" +#include "../sys/simsys.h" #include "gui_theme.h" #include "themeselector.h" @@ -104,6 +105,10 @@ } add_component(&toolbar_pos); + fullscreen.init( button_t::square_state, "Fullscreen" ); + fullscreen.pressed = is_fullscreen(); + add_component( &fullscreen, 2 ); + reselect_closes_tool.init( button_t::square_state, "Reselect closes tools" ); reselect_closes_tool.pressed = env_t::reselect_closes_tool; add_component( &reselect_closes_tool, 2 ); @@ -498,6 +503,7 @@ buttons[ i ].add_listener( this ); } gui_settings.toolbar_pos.add_listener( this ); + gui_settings.fullscreen.add_listener( this ); gui_settings.reselect_closes_tool.add_listener(this); set_resizemode(diagonal_resize); @@ -528,6 +534,12 @@ return true; } + if( comp == &gui_settings.fullscreen ) { + env_t::fullscreen = toggle_fullscreen(); + gui_settings.fullscreen.pressed = is_fullscreen(); + return true; + } + if( comp == &gui_settings.reselect_closes_tool ) { env_t::reselect_closes_tool = !env_t::reselect_closes_tool; gui_settings.reselect_closes_tool.pressed = env_t::reselect_closes_tool; Index: gui/display_settings.h =================================================================== --- gui/display_settings.h (revisión: 10142) +++ gui/display_settings.h (copia de trabajo) @@ -29,7 +29,7 @@ simloops_value_label; public: - button_t toolbar_pos, reselect_closes_tool; + button_t toolbar_pos, reselect_closes_tool, fullscreen; gui_settings_t(); void draw( scr_coord offset ) OVERRIDE; Index: simmain.cc =================================================================== --- simmain.cc (revisión: 10142) +++ simmain.cc (copia de trabajo) @@ -889,6 +889,8 @@ } fullscreen |= args.has_arg("-fullscreen"); + // Only will be true if it has been set previously via GUI + fullscreen |= env_t::fullscreen; if(args.has_arg("-screensize")) { const char* res_str = args.gimme_arg("-screensize", 1); Index: sys/simsys.h =================================================================== --- sys/simsys.h (revisión: 10142) +++ sys/simsys.h (copia de trabajo) @@ -216,6 +216,17 @@ /// returns current two byte languange ID const char* dr_get_locale(); +/** + * Returns fullscreen state + */ +bool is_fullscreen(); + +/** + * Toggle fullscreen mode + * Returns the fullscreen state after the toggle + */ +bool toggle_fullscreen(); + int sysmain(int argc, char** argv); #endif Index: sys/simsys_d.cc =================================================================== --- sys/simsys_d.cc (revisión: 10142) +++ sys/simsys_d.cc (copia de trabajo) @@ -23,6 +23,7 @@ static int width = 800; static int height = 600; +static int fullscreen = false; /* event-handling */ @@ -223,10 +224,11 @@ } -int dr_os_open(int const w, int const h, bool fullscreen) +int dr_os_open(int const w, int const h, bool fs) { width = w; height = h; + fullscreen = fs; install_keyboard(); @@ -470,7 +472,16 @@ return ""; } +bool is_fullscreen() +{ + return fullscreen; +} +bool toggle_fullscreen() +{ + return fullscreen; +} + int main(int argc, char **argv) { return sysmain(argc, argv); Index: sys/simsys_posix.cc =================================================================== --- sys/simsys_posix.cc (revisión: 10142) +++ sys/simsys_posix.cc (copia de trabajo) @@ -186,7 +186,16 @@ return ""; } +bool is_fullscreen() +{ + return false; +} +bool toggle_fullscreen() +{ + return false; +} + int main(int argc, char **argv) { signal( SIGTERM, posix_sigterm ); Index: sys/simsys_s.cc =================================================================== --- sys/simsys_s.cc (revisión: 10142) +++ sys/simsys_s.cc (copia de trabajo) @@ -78,6 +78,7 @@ static SDL_Surface *screen; static int width = 16; static int height = 16; +static bool fullscreen = false; // switch on is a little faster (<3%) static int async_blit = 0; @@ -236,7 +237,7 @@ // open the window -int dr_os_open(int w, int const h, bool fullscreen) +int dr_os_open(int w, int const h, bool fs) { #ifdef MULTI_THREAD // init barrier @@ -269,6 +270,7 @@ width = w; height = h; + fullscreen = fs; flags |= (fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE); if( use_hw ) { @@ -739,6 +741,16 @@ return NULL; } +bool is_fullscreen() +{ + return fullscreen; +} + +bool toggle_fullscreen() +{ + return fullscreen; +} + #ifdef _MSC_VER // Needed for MS Visual C++ with /SUBSYSTEM:CONSOLE to work , if /SUBSYSTEM:WINDOWS this function is compiled but unreachable #undef main Index: sys/simsys_s2.cc =================================================================== --- sys/simsys_s2.cc (revisión: 10142) +++ sys/simsys_s2.cc (copia de trabajo) @@ -105,6 +105,7 @@ static int sync_blit = 0; static int use_dirty_tiles = 1; +static bool fullscreen = false; static SDL_Cursor *arrow; static SDL_Cursor *hourglass; @@ -296,12 +297,14 @@ // open the window -int dr_os_open(int screen_width, int screen_height, bool fullscreen) +int dr_os_open(int screen_width, int screen_height, bool fs) { // scale up const int tex_w = SCREEN_TO_TEX_X(screen_width); const int tex_h = SCREEN_TO_TEX_Y(screen_height); + fullscreen = fs; + // some cards need those alignments // especially 64bit want a border of 8bytes const int tex_pitch = max((tex_w + 15) & 0x7FF0, 16); @@ -938,7 +941,18 @@ return NULL; } +bool is_fullscreen() +{ + return fullscreen; +} +bool toggle_fullscreen() +{ + SDL_SetWindowFullscreen(window, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP); + fullscreen = !fullscreen; + return fullscreen; +} + #ifdef _MSC_VER // Needed for MS Visual C++ with /SUBSYSTEM:CONSOLE to work , if /SUBSYSTEM:WINDOWS this function is compiled but unreachable #undef main Index: sys/simsys_w.cc =================================================================== --- sys/simsys_w.cc (revisión: 10142) +++ sys/simsys_w.cc (copia de trabajo) @@ -53,7 +53,7 @@ static const LPCWSTR WINDOW_CLASS_NAME = L"Simu"; static volatile HWND hwnd; -static bool is_fullscreen = false; +static bool fullscreen = false; static bool is_not_top = false; static MSG msg; static RECT WindowSize = { 0, 0, 0, 0 }; @@ -145,10 +145,11 @@ // open the window -int dr_os_open(int const w, int const h, bool fullscreen) +int dr_os_open(int const w, int const h, bool fs) { MaxSize.right = ((w*x_scale)/32+15) & 0x7FF0; MaxSize.bottom = (h*y_scale)/32; + fullscreen = fs; #ifdef MULTI_THREAD InitializeCriticalSection( &redraw_underway ); @@ -182,7 +183,6 @@ else { ChangeDisplaySettings(&settings, CDS_FULLSCREEN); } - is_fullscreen = fullscreen; } if( fullscreen ) { create_window(WS_EX_TOPMOST, WS_POPUP, 0, 0, MaxSize.right, MaxSize.bottom); @@ -239,7 +239,7 @@ AllDibData = NULL; free(AllDib); AllDib = NULL; - if( is_fullscreen ) { + if( fullscreen ) { ChangeDisplaySettings(NULL, 0); } } @@ -426,7 +426,7 @@ return 0; case WM_ACTIVATE: // may check, if we have to restore color depth - if(is_fullscreen) { + if(fullscreen) { // avoid double calls static bool while_handling = false; if(while_handling) { @@ -479,7 +479,7 @@ break; case WM_GETMINMAXINFO: - if(is_fullscreen) { + if(fullscreen) { LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam; lpmmi->ptMaxPosition.x = 0; lpmmi->ptMaxPosition.y = 0; @@ -974,7 +974,16 @@ return LanguageCode; } +bool is_fullscreen() +{ + return fullscreen; +} +bool toggle_fullscreen() +{ + return fullscreen; +} + int CALLBACK WinMain(HINSTANCE const hInstance, HINSTANCE, LPSTR, int) { WNDCLASSW wc;