rnd-20060802-3-src
authorHolger Schemel <info@artsoft.org>
Wed, 2 Aug 2006 19:31:35 +0000 (21:31 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:52:33 +0000 (10:52 +0200)
* added selection of preferred fullscreen mode to setup / graphics menu
  (useful if default mode 800 x 600 does not match screen aspect ratio)

ChangeLog
src/conftime.h
src/files.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sdl.c
src/libgame/setup.c
src/libgame/system.c
src/libgame/system.h
src/screens.c

index d90c4d41205e38ab47d397008dd583d0c8198b33..27efedea865f52627ccb64596190164a8aac6c2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-08-01
+       * added selection of preferred fullscreen mode to setup / graphics menu
+         (useful if default mode 800 x 600 does not match screen aspect ratio)
+
 2006-07-30
        * improved down-scaling of images for better level and preview graphics
        * changed user data directory for Mac OS X from Unix style to new place
index 81bf69db8a92adeee236786bd7c35221ee3093a8..c5375e169f9960fc833dca4a49aa82a6a6b43412 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-08-02 19:10]"
+#define COMPILE_DATE_STRING "[2006-08-02 21:27]"
index dd841f4863e1f820297474cb89264c1f2ec363ce..0185e4f602f5125c00e4e6e3c263fe9b270857ce 100644 (file)
@@ -6977,7 +6977,7 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_SWITCH, &si.skip_levels,      "skip_levels"                   },
   { TYPE_SWITCH, &si.time_limit,       "time_limit"                    },
   { TYPE_SWITCH, &si.fullscreen,       "fullscreen"                    },
-  { TYPE_SWITCH, &si.fullscreen_mode,  "fullscreen_mode"               },
+  { TYPE_STRING, &si.fullscreen_mode,  "fullscreen_mode"               },
   { TYPE_SWITCH, &si.ask_on_escape,    "ask_on_escape"                 },
   { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor"      },
   { TYPE_SWITCH, &si.quick_switch,     "quick_player_switch"           },
index 1ea2a2edb823e909267815575b6eb3121ddb6dba..0d19ff9c16eadf9844d3ada6371c35e685cb3748 100644 (file)
@@ -1923,6 +1923,25 @@ struct ScreenModeInfo *get_screen_mode_from_string(char *screen_mode_string)
   return &screen_mode;
 }
 
+void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *screen_mode,
+                                      int *x, int *y)
+{
+  float aspect_ratio = (float)screen_mode->width / (float)screen_mode->height;
+  float aspect_ratio_new;
+  int i = 1;
+
+  do
+  {
+    *x = i * aspect_ratio;
+    *y = i;
+
+    aspect_ratio_new = (float)*x / (float)*y;
+
+    i++;
+  }
+  while (aspect_ratio_new != aspect_ratio && *x < screen_mode->width);
+}
+
 static void FreeCustomArtworkList(struct ArtworkListInfo *,
                                  struct ListNodeInfo ***, int *);
 
index a410a11174eeb7e2b7b215b27180bc18a2f1a7df..4319ceede53c70c4820ba9d4365ff407fd6932d8 100644 (file)
@@ -181,6 +181,7 @@ int get_parameter_value(char *, char *, int);
 int get_auto_parameter_value(char *, char *);
 
 struct ScreenModeInfo *get_screen_mode_from_string(char *);
+void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *, int *x, int *y);
 
 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
                                           struct ConfigTypeInfo *,
index e384f45c978e0410c16c0a97c2a6fbec7acd2674..e478e8aaddb27df22630345f5385705f00492bdd 100644 (file)
@@ -41,6 +41,9 @@ static void setFullscreenParameters()
 
   fullscreen_mode = get_screen_mode_from_string(setup.fullscreen_mode);
 
+  if (fullscreen_mode == NULL)
+    return;
+
   for (i = 0; video.fullscreen_modes[i].width != -1; i++)
   {
     if (fullscreen_mode->width  == video.fullscreen_modes[i].width &&
index 2cafc863a7890881244115576091c962407b5a5a..4fea0cde0b5fe8b1d45eaac417338c7b3d6e0156 100644 (file)
@@ -1176,7 +1176,7 @@ char *getCommonDataDir(void)
 
     if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, dir))
        && !strEqual(dir, ""))          /* empty for Windows 95/98 */
-      common_data_dir = getPath2(dir, program.userdata_directory);
+      common_data_dir = getPath2(dir, program.userdata_subdir);
     else
       common_data_dir = options.rw_base_directory;
   }
index 14d4f1c089311632e9a449366b22e218b98a62e8..632dd45106bf3ae64cbe6fa08feb6d15511e4482 100644 (file)
@@ -329,6 +329,7 @@ void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
   video.fullscreen_available = FULLSCREEN_STATUS;
   video.fullscreen_enabled = FALSE;
   video.fullscreen_modes = NULL;
+  video.fullscreen_mode_current = NULL;
 
 #if defined(TARGET_SDL)
   SDLInitVideoBuffer(backbuffer, window, fullscreen);
index 6161b2746e9829bb72b0f888d64759efbe531431..4fde8ea672a9f55f65d36e9993d1431ed1bc1e9c 100644 (file)
@@ -597,9 +597,11 @@ struct VideoSystemInfo
 {
   int default_depth;
   int width, height, depth;
+
   boolean fullscreen_available;
   boolean fullscreen_enabled;
   struct ScreenModeInfo *fullscreen_modes;
+  char *fullscreen_mode_current;
 };
 
 struct AudioSystemInfo
index 6655bd88ac34ea271f013a07917ae3033d981a36..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;
@@ -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;