rnd-20140110-1-src
authorHolger Schemel <info@artsoft.org>
Fri, 10 Jan 2014 22:07:36 +0000 (23:07 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:33 +0000 (11:00 +0200)
src/conftime.h
src/events.c
src/libgame/sdl.c
src/libgame/setup.c
src/libgame/system.c
src/screens.c

index 2227c40afcd426c756887871b57f9d59b98004e7..51d2a8647c65349260433c15930ebbe0d4651244 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-01-08 00:59"
+#define COMPILE_DATE_STRING "2014-01-10 23:04"
index 4bbd8a523c37a5913c49d466111d3757c99b862b..f428eeb316f5b49587097ec58240fecbf4a69eb9 100644 (file)
@@ -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();
 
index a9fd895907da1116f0c2af362c91c439fabd3ea8..6561171de16d4a216c16ea18f9994b5e8214c17c 100644 (file)
@@ -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
index 5fb7e466875f3e62d524c35548162457594c5f4a..39f805fc718f5f77f305bc889c3edb95be8bcbb5 100644 (file)
@@ -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);
 }
 
index b6cdf649725b3fd08feccd44f152430e4a3069ca..6bc36f961d657070221cf508db993210fff49aff 100644 (file)
@@ -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;
index 1a37d1882977e562bf661b8e2600f97b5bd79a2a..d3cb7b1f806b76902d6fd7c982a7f2da5e756e10 100644 (file)
@@ -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();
   }