rnd-20060802-3-src
[rocksndiamonds.git] / src / screens.c
index 199d83761e0e7e077564ddec5f647651db3f3a28..fbe8007298591b372fb1386f81bace9f1e10e645 100644 (file)
@@ -231,12 +231,20 @@ void DrawHeadline()
 
 static void ToggleFullscreenIfNeeded()
 {
-  if (setup.fullscreen != video.fullscreen_enabled)
+  if (setup.fullscreen != video.fullscreen_enabled ||
+      setup.fullscreen_mode != video.fullscreen_mode_current)
   {
     /* save old door content */
     BlitBitmap(backbuffer, bitmap_db_door,
               DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
 
+    if (setup.fullscreen && video.fullscreen_enabled)
+    {
+      /* keep fullscreen mode, but change screen mode */
+      video.fullscreen_mode_current = setup.fullscreen_mode;
+      video.fullscreen_enabled = FALSE;
+    }
+
     /* toggle fullscreen */
     ChangeVideoModeIfNeeded(setup.fullscreen);
     setup.fullscreen = video.fullscreen_enabled;
@@ -1114,7 +1122,7 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
   {
     if (dx)
     {
-      int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU);
+      int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
 
       if (info_info[choice].type & menu_navigation_type ||
          info_info[choice].type & TYPE_ENTER_SCREEN ||
@@ -2563,12 +2571,15 @@ static void execSetupGraphics()
       char identifier[20], name[20];
       int x = video.fullscreen_modes[i].width;
       int y = video.fullscreen_modes[i].height;
+      int xx, yy;
+
+      get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
 
       ti->node_top = &screen_modes;
       ti->sort_priority = x * y;
 
       sprintf(identifier, "%dx%d", x, y);
-      sprintf(name,     "%d x %d", x, y);
+      sprintf(name,     "%d x %d [%d:%d]", x, y, xx, yy);
 
       setString(&ti->identifier, identifier);
       setString(&ti->name, name);
@@ -2578,11 +2589,19 @@ static void execSetupGraphics()
       pushTreeInfo(&screen_modes, ti);
     }
 
+    /* sort fullscreen modes to start with lowest available screen resolution */
     sortTreeInfo(&screen_modes);
 
-    /* set current screen mode for fullscreen mode to reliable default value */
+    /* set current screen mode for fullscreen mode to configured setup value */
     screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
-                                                   DEFAULT_FULLSCREEN_MODE);
+                                                   setup.fullscreen_mode);
+
+    /* if that fails, set current screen mode to reliable default value */
+    if (screen_mode_current == NULL)
+      screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
+                                                     DEFAULT_FULLSCREEN_MODE);
+
+    /* if that also fails, set current screen mode to first available mode */
     if (screen_mode_current == NULL)
       screen_mode_current = screen_modes;
 
@@ -3192,6 +3211,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
     choice_store[setup_mode] = choice;
 
     drawCursor(choice, FC_RED);
+
     return;
   }
   else if (button == MB_MENU_LEAVE)
@@ -3203,6 +3223,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
        void (*menu_callback_function)(void) = setup_info[y].value;
 
        menu_callback_function();
+
        break;  /* absolutely needed because function changes 'setup_info'! */
       }
     }
@@ -3219,7 +3240,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
   {
     if (dx)
     {
-      int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU);
+      int menu_navigation_type = (dx < 0 ? TYPE_LEAVE : TYPE_ENTER);
 
       if (setup_info[choice].type & menu_navigation_type ||
          setup_info[choice].type & TYPE_BOOLEAN_STYLE)
@@ -3234,6 +3255,44 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
       y += dy;
   }
 
+#if 1
+  if (IN_VIS_FIELD(x, y) && y >= 0 && y < num_setup_info)
+  {
+    if (button)
+    {
+      if (y != choice && setup_info[y].type & ~TYPE_SKIP_ENTRY)
+      {
+       drawCursor(y, FC_RED);
+       drawCursor(choice, FC_BLUE);
+       choice = choice_store[setup_mode] = y;
+      }
+    }
+    else if (!(setup_info[y].type & TYPE_GHOSTED))
+    {
+      /* when selecting key headline, execute function for key value change */
+      if (setup_info[y].type & TYPE_KEYTEXT &&
+         setup_info[y + 1].type & TYPE_KEY)
+       y++;
+
+      /* when selecting string value, execute function for list selection */
+      if (setup_info[y].type & TYPE_STRING && y > 0 &&
+         setup_info[y - 1].type & TYPE_ENTER_LIST)
+       y--;
+
+      if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
+      {
+       void (*menu_callback_function)(void) = setup_info[y].value;
+
+       menu_callback_function();
+      }
+      else
+      {
+       if (setup_info[y].type & TYPE_VALUE)
+         changeSetupValue(y);
+      }
+    }
+  }
+#else
   if (IN_VIS_FIELD(x, y) &&
       y >= 0 && y < num_setup_info && setup_info[y].type & ~TYPE_SKIP_ENTRY)
   {
@@ -3265,6 +3324,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
       }
     }
   }
+#endif
 }
 
 void DrawSetupScreen_Input()