From a375412650ede30883327dba34b3feafd9a3bf38 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 10 Jan 2014 23:07:36 +0100 Subject: [PATCH] rnd-20140110-1-src --- src/conftime.h | 2 +- src/events.c | 7 ++ src/libgame/sdl.c | 10 ++- src/libgame/setup.c | 8 ++ src/libgame/system.c | 2 + src/screens.c | 182 +++++++++++++++++++++++++------------------ 6 files changed, 134 insertions(+), 77 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index 2227c40a..51d2a864 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-01-08 00:59" +#define COMPILE_DATE_STRING "2014-01-10 23:04" diff --git a/src/events.c b/src/events.c index 4bbd8a52..f428eeb3 100644 --- a/src/events.c +++ b/src/events.c @@ -403,6 +403,7 @@ void HandleMotionEvent(MotionEvent *event) #if defined(TARGET_SDL2) void HandleWindowEvent(WindowEvent *event) { +#if DEBUG_EVENTS int subtype = event->event; char *event_name = @@ -424,6 +425,7 @@ void HandleWindowEvent(WindowEvent *event) Error(ERR_DEBUG, "WINDOW EVENT: '%s', %ld, %ld", event_name, event->data1, event->data2); +#endif if (event->event == SDL_WINDOWEVENT_EXPOSED) SDLRedrawWindow(); @@ -468,6 +470,9 @@ void HandleWindowEvent(WindowEvent *event) printf("::: setup.window_scaling_percent set to %d\n", setup.window_scaling_percent); + + if (game_status == GAME_MODE_SETUP) + RedrawSetupScreenAfterFullscreenToggle(); } #else // prevent slightly wrong scaling factor due to rounding differences @@ -1092,7 +1097,9 @@ void HandleKey(Key key, int key_status) { setup.fullscreen = !setup.fullscreen; +#if 0 printf("::: %d\n", setup.window_scaling_percent); +#endif ToggleFullscreenIfNeeded(); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index a9fd8959..6561171d 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -420,7 +420,9 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer, // store if initial screen mode on game start is fullscreen mode if (sdl_window == NULL) { +#if 0 printf("::: GAME STARTS WITH FULLSCREEN %d\n", fullscreen); +#endif video.fullscreen_initial = fullscreen; } @@ -432,7 +434,7 @@ static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer, video.window_width = window_scaling_factor * width; video.window_height = window_scaling_factor * height; -#if 1 +#if 0 printf("::: use window scaling factor %f\n", screen_scaling_factor); #endif @@ -805,7 +807,9 @@ void SDLSetWindowScaling(int window_scaling_percent) int new_window_width = (int)(window_scaling_factor * video.width); int new_window_height = (int)(window_scaling_factor * video.height); +#if 0 Error(ERR_DEBUG, "::: SDLSetWindowScaling(%d) ...", window_scaling_percent); +#endif SDL_SetWindowSize(sdl_window, new_window_width, new_window_height); @@ -825,13 +829,17 @@ void SDLSetWindowFullscreen(boolean fullscreen) int flags = (fullscreen ? SDL_WINDOW_FULLSCREEN : 0); #endif +#if 0 Error(ERR_DEBUG, "::: SDL_SetWindowFullscreen(%d) ...", fullscreen); +#endif if (SDL_SetWindowFullscreen(sdl_window, flags) == 0) video.fullscreen_enabled = fullscreen; +#if 0 printf("::: SDLSetWindowFullscreen: %d, %d\n", fullscreen, video.fullscreen_initial); +#endif #if 1 // if game started in fullscreen mode, window will also get fullscreen size diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5fb7e466..39f805fc 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -2926,6 +2926,14 @@ void freeTreeInfo(TreeInfo *ti) checked_free(ti->special_flags); } + // recursively free child node + if (ti->node_group) + freeTreeInfo(ti->node_group); + + // recursively free next node + if (ti->next) + freeTreeInfo(ti->next); + checked_free(ti); } diff --git a/src/libgame/system.c b/src/libgame/system.c index b6cdf649..6bc36f96 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -438,7 +438,9 @@ void CloseVideoDisplay(void) void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) { +#if 0 printf("::: InitVideoBuffer\n"); +#endif video.width = width; video.height = height; diff --git a/src/screens.c b/src/screens.c index 1a37d188..d3cb7b1f 100644 --- a/src/screens.c +++ b/src/screens.c @@ -3789,7 +3789,11 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } else { +#if 1 + FadeSetEnterMenu(); +#else FadeSetEnterScreen(); +#endif node_cursor->cl_first = ti->cl_first; node_cursor->cl_cursor = ti->cl_cursor; @@ -4161,7 +4165,92 @@ static void execSetupEditor() DrawSetupScreen(); } -static void execSetupGraphics() +static void execSetupGraphics_setWindowSizes(boolean update_list) +{ + if (window_sizes != NULL && update_list) + { + freeTreeInfo(window_sizes); + + window_sizes = NULL; + } + + if (window_sizes == NULL) + { + boolean current_window_size_found = FALSE; + int i; + + for (i = 0; window_sizes_list[i].value != -1; i++) + { + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + int value = window_sizes_list[i].value; + char *text = window_sizes_list[i].text; + + ti->node_top = &window_sizes; + ti->sort_priority = value; + + sprintf(identifier, "%d", value); + sprintf(name, "%s", text); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + setString(&ti->infotext, "Window Scaling"); + + pushTreeInfo(&window_sizes, ti); + + if (value == setup.window_scaling_percent) + current_window_size_found = TRUE; + } + + if (!current_window_size_found) + { + // add entry for non-preset window scaling value + + TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); + char identifier[32], name[32]; + int value = setup.window_scaling_percent; + + ti->node_top = &window_sizes; + ti->sort_priority = value; + + sprintf(identifier, "%d", value); + sprintf(name, "%d %% (Current)", value); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + setString(&ti->infotext, "Window Scaling"); + + pushTreeInfo(&window_sizes, ti); + } + + /* sort window size values to start with lowest window size value */ + sortTreeInfo(&window_sizes); + + /* set current window size value to configured window size value */ + window_size_current = + getTreeInfoFromIdentifier(window_sizes, + i_to_a(setup.window_scaling_percent)); + + /* if that fails, set current window size to reliable default value */ + if (window_size_current == NULL) + window_size_current = + getTreeInfoFromIdentifier(window_sizes, + i_to_a(STD_WINDOW_SCALING_PERCENT)); + + /* if that also fails, set current window size to first available value */ + if (window_size_current == NULL) + window_size_current = window_sizes; + } + + setup.window_scaling_percent = atoi(window_size_current->identifier); + + /* needed for displaying window size text instead of identifier */ + window_size_text = window_size_current->name; +} + +static void execSetupGraphics_setScreenModes() { // if (screen_modes == NULL && video.fullscreen_available) if (screen_modes == NULL && video.fullscreen_modes != NULL) @@ -4220,57 +4309,10 @@ static void execSetupGraphics() /* needed for displaying screen mode name instead of identifier */ screen_mode_text = screen_mode_current->name; } +} - if (window_sizes == NULL) - { - int i; - - for (i = 0; window_sizes_list[i].value != -1; i++) - { - TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); - char identifier[32], name[32]; - int value = window_sizes_list[i].value; - char *text = window_sizes_list[i].text; - - ti->node_top = &window_sizes; - ti->sort_priority = value; - - sprintf(identifier, "%d", value); - sprintf(name, "%s", text); - - setString(&ti->identifier, identifier); - setString(&ti->name, name); - setString(&ti->name_sorting, name); - setString(&ti->infotext, "Window Scaling"); - - pushTreeInfo(&window_sizes, ti); - } - - /* sort window size values to start with lowest window size value */ - sortTreeInfo(&window_sizes); - - /* set current window size value to configured window size value */ - window_size_current = - getTreeInfoFromIdentifier(window_sizes, - i_to_a(setup.window_scaling_percent)); - - /* if that fails, set current window size to reliable default value */ - if (window_size_current == NULL) - window_size_current = - getTreeInfoFromIdentifier(window_sizes, - i_to_a(STD_WINDOW_SCALING_PERCENT)); - - /* if that also fails, set current window size to first available value */ - if (window_size_current == NULL) - window_size_current = window_sizes; - } - - setup.window_scaling_percent = atoi(window_size_current->identifier); - - /* needed for displaying window size text instead of identifier */ - window_size_text = window_size_current->name; - -#if 1 +static void execSetupGraphics_setScrollDelays() +{ if (scroll_delays == NULL) { int i; @@ -4317,7 +4359,17 @@ static void execSetupGraphics() /* needed for displaying scroll delay text instead of identifier */ scroll_delay_text = scroll_delay_current->name; -#endif +} + +static void execSetupGraphics() +{ + // update "setup.window_scaling_percent" from list selection + execSetupGraphics_setWindowSizes(FALSE); + // maybe remove non-preset value (if standard value was selected) + execSetupGraphics_setWindowSizes(TRUE); + + execSetupGraphics_setScreenModes(); + execSetupGraphics_setScrollDelays(); setup_mode = SETUP_MODE_GRAPHICS; @@ -6090,32 +6142,12 @@ void DrawSetupScreen() void RedrawSetupScreenAfterFullscreenToggle() { -#if 0 +#if 1 if (setup_mode == SETUP_MODE_GRAPHICS || setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE) { - if (window_sizes != NULL) - { - /* set current window size value to configured window size value */ - window_size_current = - getTreeInfoFromIdentifier(window_sizes, - i_to_a(setup.window_scaling_percent)); - - /* if that fails, set current window size to reliable default value */ - if (window_size_current == NULL) - window_size_current = - getTreeInfoFromIdentifier(window_sizes, - i_to_a(STD_WINDOW_SCALING_PERCENT)); - - /* if that also fails, set current window size to first available value */ - if (window_size_current == NULL) - window_size_current = window_sizes; - } - - setup.window_scaling_percent = atoi(window_size_current->identifier); - - /* needed for displaying window size text instead of identifier */ - window_size_text = window_size_current->name; + // update "setup.window_scaling_percent" from list selection + execSetupGraphics_setWindowSizes(TRUE); DrawSetupScreen(); } -- 2.34.1