rnd-20060802-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 2 Aug 2006 00:27:01 +0000 (02:27 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:52:31 +0000 (10:52 +0200)
14 files changed:
src/conf_gfx.c
src/conftime.h
src/files.c
src/init.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sdl.c
src/libgame/setup.c
src/libgame/setup.h
src/libgame/system.c
src/libgame/system.h
src/main.h
src/screens.c
src/tools.c

index a0ce19ebb8ce5c2d26e78c5ff6c2c2c9def749cc..3421d9a578291aca6b78c30046a0a5b0aed54453 100644 (file)
@@ -4457,6 +4457,25 @@ struct ConfigInfo image_config[] =
   { "door_2.step_delay",                       "10"                    },
   { "door_2.anim_mode",                                "default"               },
 
+#if DEBUG
+  { "game.level.x",                            "-1"                    },
+  { "game.level.y",                            "-1"                    },
+  { "game.gems.x",                             "-1"                    },
+  { "game.gems.y",                             "-1"                    },
+  { "game.bombs.x",                            "-1"                    },
+  { "game.bombs.y",                            "-1"                    },
+  { "game.keys.x",                             "-1"                    },
+  { "game.keys.y",                             "-1"                    },
+  { "game.score.x",                            "-1"                    },
+  { "game.score.y",                            "-1"                    },
+  { "game.time.x",                             "-1"                    },
+  { "game.time.y",                             "-1"                    },
+#if 0
+  { "game.tape.x",                             "-1"                    },
+  { "game.tape.y",                             "-1"                    },
+#endif
+#endif
+
   { "[player].boring_delay_fixed",             "1000"                  },
   { "[player].boring_delay_random",            "1000"                  },
   { "[player].sleeping_delay_fixed",           "2000"                  },
index 529c2b1da10df4685090823c4d9c861fce9b678e..cd365815f9207e911175af0e2f29a44296f78e06 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-07-30 22:09]"
+#define COMPILE_DATE_STRING "[2006-08-02 01:51]"
index 152d6528b6648dcb164d9f1b7f41a4ca66f104a5..dd841f4863e1f820297474cb89264c1f2ec363ce 100644 (file)
@@ -6853,19 +6853,20 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_SKIP_LEVELS                        14
 #define SETUP_TOKEN_TIME_LIMIT                 15
 #define SETUP_TOKEN_FULLSCREEN                 16
-#define SETUP_TOKEN_ASK_ON_ESCAPE              17
-#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       18
-#define SETUP_TOKEN_QUICK_SWITCH               19
-#define SETUP_TOKEN_INPUT_ON_FOCUS             20
-#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                21
-#define SETUP_TOKEN_GRAPHICS_SET               22
-#define SETUP_TOKEN_SOUNDS_SET                 23
-#define SETUP_TOKEN_MUSIC_SET                  24
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    25
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      26
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       27
-
-#define NUM_GLOBAL_SETUP_TOKENS                        28
+#define SETUP_TOKEN_FULLSCREEN_MODE            17
+#define SETUP_TOKEN_ASK_ON_ESCAPE              18
+#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR       19
+#define SETUP_TOKEN_QUICK_SWITCH               20
+#define SETUP_TOKEN_INPUT_ON_FOCUS             21
+#define SETUP_TOKEN_PREFER_AGA_GRAPHICS                22
+#define SETUP_TOKEN_GRAPHICS_SET               23
+#define SETUP_TOKEN_SOUNDS_SET                 24
+#define SETUP_TOKEN_MUSIC_SET                  25
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    26
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      27
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       28
+
+#define NUM_GLOBAL_SETUP_TOKENS                        29
 
 /* editor setup */
 #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH      0
@@ -6976,6 +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_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"           },
@@ -7125,6 +7127,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->skip_levels = TRUE;
   si->time_limit = TRUE;
   si->fullscreen = FALSE;
+  si->fullscreen_mode = getStringCopy(DEFAULT_FULLSCREEN_MODE);
   si->ask_on_escape = TRUE;
   si->ask_on_escape_editor = TRUE;
   si->quick_switch = FALSE;
index a73dec0e9d0042f8e042e4b551094732abfe2ab6..cb3703b441a789c74e597e85d72e2eecd1615a09 100644 (file)
@@ -4249,8 +4249,8 @@ void Execute_Command(char *command)
     }
     else
     {
-      /* print valid modes */
       printf("Available Modes:\n");
+
       for(i = 0; modes[i]; i++)
        printf("  %d x %d\n", modes[i]->w, modes[i]->h);
     }
index ea5ed01a06a8898b9a60bd6a667fee291a9b8c1d..1ea2a2edb823e909267815575b6eb3121ddb6dba 100644 (file)
@@ -1900,6 +1900,29 @@ int get_auto_parameter_value(char *token, char *value_raw)
   return get_parameter_value(value_raw, suffix, TYPE_INTEGER);
 }
 
+struct ScreenModeInfo *get_screen_mode_from_string(char *screen_mode_string)
+{
+  static struct ScreenModeInfo screen_mode;
+  char *screen_mode_string_x = strchr(screen_mode_string, 'x');
+  char *screen_mode_string_copy;
+  char *screen_mode_string_pos_w;
+  char *screen_mode_string_pos_h;
+
+  if (screen_mode_string_x == NULL)    /* invalid screen mode format */
+    return NULL;
+
+  screen_mode_string_copy = getStringCopy(screen_mode_string);
+
+  screen_mode_string_pos_w = screen_mode_string_copy;
+  screen_mode_string_pos_h = strchr(screen_mode_string_copy, 'x');
+  *screen_mode_string_pos_h++ = '\0';
+
+  screen_mode.width  = atoi(screen_mode_string_pos_w);
+  screen_mode.height = atoi(screen_mode_string_pos_h);
+
+  return &screen_mode;
+}
+
 static void FreeCustomArtworkList(struct ArtworkListInfo *,
                                  struct ListNodeInfo ***, int *);
 
index 7c84c94b21e1c2480528580c9458fc183638f3b0..a410a11174eeb7e2b7b215b27180bc18a2f1a7df 100644 (file)
@@ -180,6 +180,8 @@ char *get_mapped_token(char *);
 int get_parameter_value(char *, char *, int);
 int get_auto_parameter_value(char *, char *);
 
+struct ScreenModeInfo *get_screen_mode_from_string(char *);
+
 struct FileInfo *getFileListFromConfigList(struct ConfigInfo *,
                                           struct ConfigTypeInfo *,
                                           char **, int);
index 406c022638499282e91080006e5e328b7150e11c..e384f45c978e0410c16c0a97c2a6fbec7acd2674 100644 (file)
 /* functions from SGE library */
 void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
 
-/* #ifdef PLATFORM_WIN32 */
-#define FULLSCREEN_BUG
-/* #endif */
-
 /* stuff needed to work around SDL/Windows fullscreen drawing bug */
 static int fullscreen_width;
 static int fullscreen_height;
@@ -38,6 +34,29 @@ static int fullscreen_yoffset;
 static int video_xoffset;
 static int video_yoffset;
 
+static void setFullscreenParameters()
+{
+  struct ScreenModeInfo *fullscreen_mode;
+  int i;
+
+  fullscreen_mode = get_screen_mode_from_string(setup.fullscreen_mode);
+
+  for (i = 0; video.fullscreen_modes[i].width != -1; i++)
+  {
+    if (fullscreen_mode->width  == video.fullscreen_modes[i].width &&
+       fullscreen_mode->height == video.fullscreen_modes[i].height)
+    {
+      fullscreen_width  = fullscreen_mode->width;
+      fullscreen_height = fullscreen_mode->height;
+
+      fullscreen_xoffset = (fullscreen_width  - video.width)  / 2;
+      fullscreen_yoffset = (fullscreen_height - video.height) / 2;
+
+      break;
+    }
+  }
+}
+
 void SDLInitVideoDisplay(void)
 {
   putenv("SDL_VIDEO_CENTERED=1");
@@ -53,8 +72,6 @@ void SDLInitVideoDisplay(void)
 void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
                        boolean fullscreen)
 {
-#ifdef FULLSCREEN_BUG
-  int i;
   static int screen_xy[][2] =
   {
     {  640, 480 },
@@ -62,7 +79,8 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
     { 1024, 768 },
     {   -1,  -1 }
   };
-#endif
+  SDL_Rect **modes;
+  int i, j;
 
   /* default: normal game window size */
   fullscreen_width = video.width;
@@ -70,20 +88,83 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
   fullscreen_xoffset = 0;
   fullscreen_yoffset = 0;
 
-#ifdef FULLSCREEN_BUG
   for (i = 0; screen_xy[i][0] != -1; i++)
   {
-    if (video.width <= screen_xy[i][0] && video.height <= screen_xy[i][1])
+    if (screen_xy[i][0] >= video.width && screen_xy[i][1] >= video.height)
     {
-      fullscreen_width = screen_xy[i][0];
+      fullscreen_width  = screen_xy[i][0];
       fullscreen_height = screen_xy[i][1];
+
       break;
     }
   }
 
-  fullscreen_xoffset = (fullscreen_width - video.width) / 2;
+  fullscreen_xoffset = (fullscreen_width  - video.width)  / 2;
   fullscreen_yoffset = (fullscreen_height - video.height) / 2;
-#endif
+
+  /* get available hardware supported fullscreen modes */
+  modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
+
+  if (modes == NULL)
+  {
+    /* no screen modes available => no fullscreen mode support */
+    video.fullscreen_available = FALSE;
+  }
+  else if (modes == (SDL_Rect **)-1)
+  {
+    /* fullscreen resolution is not restricted -- all resolutions available */
+    video.fullscreen_modes = checked_calloc(2 * sizeof(struct ScreenModeInfo));
+
+    /* use native video buffer size for fullscreen mode */
+    video.fullscreen_modes[0].width  = video.width;
+    video.fullscreen_modes[0].height = video.height;
+
+    video.fullscreen_modes[1].width  = -1;
+    video.fullscreen_modes[1].height = -1;
+  }
+  else
+  {
+    /* in this case, a certain number of screen modes is available */
+    int num_modes = 0;
+
+    for(i = 0; modes[i] != NULL; i++)
+    {
+      boolean found_mode = FALSE;
+
+      /* screen mode is smaller than video buffer size -- skip it */
+      if (modes[i]->w < video.width || modes[i]->h < video.height)
+       continue;
+
+      if (video.fullscreen_modes != NULL)
+       for (j = 0; video.fullscreen_modes[j].width != -1; j++)
+         if (modes[i]->w == video.fullscreen_modes[j].width &&
+             modes[i]->h == video.fullscreen_modes[j].height)
+           found_mode = TRUE;
+
+      if (found_mode)          /* screen mode already stored -- skip it */
+       continue;
+
+      /* new mode found; add it to list of available fullscreen modes */
+
+      num_modes++;
+
+      video.fullscreen_modes = checked_realloc(video.fullscreen_modes,
+                                              (num_modes + 1) *
+                                              sizeof(struct ScreenModeInfo));
+
+      video.fullscreen_modes[num_modes - 1].width  = modes[i]->w;
+      video.fullscreen_modes[num_modes - 1].height = modes[i]->h;
+
+      video.fullscreen_modes[num_modes].width  = -1;
+      video.fullscreen_modes[num_modes].height = -1;
+    }
+
+    if (num_modes == 0)
+    {
+      /* no appropriate screen modes available => no fullscreen mode support */
+      video.fullscreen_available = FALSE;
+    }
+  }
 
   /* open SDL video output device (window or fullscreen mode) */
   if (!SDLSetVideoMode(backbuffer, fullscreen))
@@ -121,6 +202,8 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 
   if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available)
   {
+    setFullscreenParameters();
+
     video_xoffset = fullscreen_xoffset;
     video_yoffset = fullscreen_yoffset;
 
@@ -207,26 +290,22 @@ void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
   Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap);
   SDL_Rect src_rect, dst_rect;
 
-#ifdef FULLSCREEN_BUG
   if (src_bitmap == backbuffer)
   {
     src_x += video_xoffset;
     src_y += video_yoffset;
   }
-#endif
 
   src_rect.x = src_x;
   src_rect.y = src_y;
   src_rect.w = width;
   src_rect.h = height;
 
-#ifdef FULLSCREEN_BUG
   if (dst_bitmap == backbuffer || dst_bitmap == window)
   {
     dst_x += video_xoffset;
     dst_y += video_yoffset;
   }
-#endif
 
   dst_rect.x = dst_x;
   dst_rect.y = dst_y;
@@ -248,13 +327,11 @@ void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y,
   Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap);
   SDL_Rect rect;
 
-#ifdef FULLSCREEN_BUG
   if (dst_bitmap == backbuffer || dst_bitmap == window)
   {
     x += video_xoffset;
     y += video_yoffset;
   }
-#endif
 
   rect.x = x;
   rect.y = y;
@@ -288,10 +365,8 @@ void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay,
   src_rect.w = video.width;
   src_rect.h = video.height;
 
-#ifdef FULLSCREEN_BUG
   dst_x += video_xoffset;
   dst_y += video_yoffset;
-#endif
 
   dst_rect.x = dst_x;
   dst_rect.y = dst_y;
@@ -411,13 +486,11 @@ void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y,
   rect.w = (to_x - from_x + 1);
   rect.h = (to_y - from_y + 1);
 
-#ifdef FULLSCREEN_BUG
   if (dst_bitmap == backbuffer || dst_bitmap == window)
   {
     rect.x += video_xoffset;
     rect.y += video_yoffset;
   }
-#endif
 
   SDL_FillRect(surface, &rect, color);
 }
@@ -425,7 +498,6 @@ void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y,
 void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y,
                 int to_x, int to_y, Uint32 color)
 {
-#ifdef FULLSCREEN_BUG
   if (dst_bitmap == backbuffer || dst_bitmap == window)
   {
     from_x += video_xoffset;
@@ -433,7 +505,6 @@ void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y,
     to_x += video_xoffset;
     to_y += video_yoffset;
   }
-#endif
 
   sge_Line(dst_bitmap->surface, from_x, from_y, to_x, to_y, color);
 }
@@ -472,13 +543,11 @@ Pixel SDLGetPixel(Bitmap *src_bitmap, int x, int y)
 {
   SDL_Surface *surface = src_bitmap->surface;
 
-#ifdef FULLSCREEN_BUG
   if (src_bitmap == backbuffer || src_bitmap == window)
   {
     x += video_xoffset;
     y += video_yoffset;
   }
-#endif
 
   switch (surface->format->BytesPerPixel)
   {
@@ -971,13 +1040,11 @@ void sge_LineRGB(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2,
 
 void SDLPutPixel(Bitmap *dst_bitmap, int x, int y, Pixel pixel)
 {
-#ifdef FULLSCREEN_BUG
   if (dst_bitmap == backbuffer || dst_bitmap == window)
   {
     x += video_xoffset;
     y += video_yoffset;
   }
-#endif
 
   sge_PutPixel(dst_bitmap->surface, x, y, pixel);
 }
@@ -1515,7 +1582,6 @@ void SDLNextEvent(Event *event)
 {
   SDL_WaitEvent(event);
 
-#ifdef FULLSCREEN_BUG
   if (event->type == EVENT_BUTTONPRESS ||
       event->type == EVENT_BUTTONRELEASE)
   {
@@ -1539,7 +1605,6 @@ void SDLNextEvent(Event *event)
     else
       ((MotionEvent *)event)->y = 0;
   }
-#endif
 }
 
 
index c7cc92f00c2dfc55d4a1d259392d4655c0e04843..2cafc863a7890881244115576091c962407b5a5a 100644 (file)
@@ -86,6 +86,9 @@ static char *levelclass_desc[NUM_LEVELCLASS_DESC] =
 
 #define MAX_COOKIE_LEN                         256
 
+static void setTreeInfoToDefaults(TreeInfo *, int);
+static int compareTreeInfoEntries(const void *, const void *);
+
 static int token_value_position   = TOKEN_VALUE_POSITION_DEFAULT;
 static int token_comment_position = TOKEN_COMMENT_POSITION_DEFAULT;
 
@@ -94,9 +97,9 @@ static int token_comment_position = TOKEN_COMMENT_POSITION_DEFAULT;
 /* file functions                                                            */
 /* ------------------------------------------------------------------------- */
 
-static char *getLevelClassDescription(TreeInfo *ldi)
+static char *getLevelClassDescription(TreeInfo *ti)
 {
-  int position = ldi->sort_priority / 100;
+  int position = ti->sort_priority / 100;
 
   if (position >= 0 && position < NUM_LEVELCLASS_DESC)
     return levelclass_desc[position];
@@ -814,6 +817,15 @@ TreeInfo *newTreeInfo()
   return checked_calloc(sizeof(TreeInfo));
 }
 
+TreeInfo *newTreeInfo_setDefaults(int type)
+{
+  TreeInfo *ti = newTreeInfo();
+
+  setTreeInfoToDefaults(ti, type);
+
+  return ti;
+}
+
 void pushTreeInfo(TreeInfo **node_first, TreeInfo *node_new)
 {
   node_new->next = *node_first;
@@ -1020,8 +1032,9 @@ void dumpTreeInfo(TreeInfo *node, int depth)
   }
 }
 
-void sortTreeInfo(TreeInfo **node_first,
-                 int (*compare_function)(const void *, const void *))
+void sortTreeInfoBySortFunction(TreeInfo **node_first,
+                               int (*compare_function)(const void *,
+                                                       const void *))
 {
   int num_nodes = numTreeInfo(*node_first);
   TreeInfo **sort_array;
@@ -1062,12 +1075,17 @@ void sortTreeInfo(TreeInfo **node_first,
   while (node)
   {
     if (node->node_group != NULL)
-      sortTreeInfo(&node->node_group, compare_function);
+      sortTreeInfoBySortFunction(&node->node_group, compare_function);
 
     node = node->next;
   }
 }
 
+void sortTreeInfo(TreeInfo **node_first)
+{
+  sortTreeInfoBySortFunction(node_first, compareTreeInfoEntries);
+}
+
 
 /* ========================================================================= */
 /* some stuff from "files.c"                                                 */
@@ -1194,7 +1212,7 @@ char *getUserGameDataDir(void)
   return program.userdata_path;
 }
 
-void fixUserGameDataDir()
+void updateUserGameDataDir()
 {
 #if defined(PLATFORM_MACOSX)
   char *userdata_dir_old = getPath2(getHomeDir(), program.userdata_subdir_unix);
@@ -1768,164 +1786,170 @@ static struct TokenInfo levelinfo_tokens[] =
   { TYPE_BOOLEAN,      &ldi.skip_levels,       "skip_levels"           }
 };
 
-static void setTreeInfoToDefaults(TreeInfo *ldi, int type)
+static void setTreeInfoToDefaults(TreeInfo *ti, int type)
 {
-  ldi->type = type;
+  ti->type = type;
 
-  ldi->node_top = (ldi->type == TREE_TYPE_LEVEL_DIR ? &leveldir_first :
-                  ldi->type == TREE_TYPE_GRAPHICS_DIR ? &artwork.gfx_first :
-                  ldi->type == TREE_TYPE_SOUNDS_DIR ? &artwork.snd_first :
-                  ldi->type == TREE_TYPE_MUSIC_DIR ? &artwork.mus_first :
-                  NULL);
+  ti->node_top = (ti->type == TREE_TYPE_LEVEL_DIR    ? &leveldir_first :
+                 ti->type == TREE_TYPE_GRAPHICS_DIR ? &artwork.gfx_first :
+                 ti->type == TREE_TYPE_SOUNDS_DIR   ? &artwork.snd_first :
+                 ti->type == TREE_TYPE_MUSIC_DIR    ? &artwork.mus_first :
+                 NULL);
 
-  ldi->node_parent = NULL;
-  ldi->node_group = NULL;
-  ldi->next = NULL;
+  ti->node_parent = NULL;
+  ti->node_group = NULL;
+  ti->next = NULL;
 
-  ldi->cl_first = -1;
-  ldi->cl_cursor = -1;
+  ti->cl_first = -1;
+  ti->cl_cursor = -1;
 
-  ldi->subdir = NULL;
-  ldi->fullpath = NULL;
-  ldi->basepath = NULL;
-  ldi->identifier = NULL;
-  ldi->name = getStringCopy(ANONYMOUS_NAME);
-  ldi->name_sorting = NULL;
-  ldi->author = getStringCopy(ANONYMOUS_NAME);
+  ti->subdir = NULL;
+  ti->fullpath = NULL;
+  ti->basepath = NULL;
+  ti->identifier = NULL;
+  ti->name = getStringCopy(ANONYMOUS_NAME);
+  ti->name_sorting = NULL;
+  ti->author = getStringCopy(ANONYMOUS_NAME);
 
-  ldi->sort_priority = LEVELCLASS_UNDEFINED;   /* default: least priority */
-  ldi->latest_engine = FALSE;                  /* default: get from level */
-  ldi->parent_link = FALSE;
-  ldi->in_user_dir = FALSE;
-  ldi->user_defined = FALSE;
-  ldi->color = 0;
-  ldi->class_desc = NULL;
+  ti->sort_priority = LEVELCLASS_UNDEFINED;    /* default: least priority */
+  ti->latest_engine = FALSE;                   /* default: get from level */
+  ti->parent_link = FALSE;
+  ti->in_user_dir = FALSE;
+  ti->user_defined = FALSE;
+  ti->color = 0;
+  ti->class_desc = NULL;
 
-  if (ldi->type == TREE_TYPE_LEVEL_DIR)
+  ti->infotext = getStringCopy(TREE_INFOTEXT(ti->type));
+
+  if (ti->type == TREE_TYPE_LEVEL_DIR)
   {
-    ldi->imported_from = NULL;
-    ldi->imported_by = NULL;
+    ti->imported_from = NULL;
+    ti->imported_by = NULL;
 
-    ldi->graphics_set_ecs = NULL;
-    ldi->graphics_set_aga = NULL;
-    ldi->graphics_set = NULL;
-    ldi->sounds_set = NULL;
-    ldi->music_set = NULL;
-    ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
-    ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
-    ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->graphics_set_ecs = NULL;
+    ti->graphics_set_aga = NULL;
+    ti->graphics_set = NULL;
+    ti->sounds_set = NULL;
+    ti->music_set = NULL;
+    ti->graphics_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->sounds_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->music_path = getStringCopy(UNDEFINED_FILENAME);
 
-    ldi->level_filename = NULL;
-    ldi->level_filetype = NULL;
+    ti->level_filename = NULL;
+    ti->level_filetype = NULL;
 
-    ldi->levels = 0;
-    ldi->first_level = 0;
-    ldi->last_level = 0;
-    ldi->level_group = FALSE;
-    ldi->handicap_level = 0;
-    ldi->readonly = TRUE;
-    ldi->handicap = TRUE;
-    ldi->skip_levels = FALSE;
+    ti->levels = 0;
+    ti->first_level = 0;
+    ti->last_level = 0;
+    ti->level_group = FALSE;
+    ti->handicap_level = 0;
+    ti->readonly = TRUE;
+    ti->handicap = TRUE;
+    ti->skip_levels = FALSE;
   }
 }
 
-static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent)
+static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent)
 {
   if (parent == NULL)
   {
     Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL");
 
-    setTreeInfoToDefaults(ldi, TREE_TYPE_UNDEFINED);
+    setTreeInfoToDefaults(ti, TREE_TYPE_UNDEFINED);
 
     return;
   }
 
   /* copy all values from the parent structure */
 
-  ldi->type = parent->type;
+  ti->type = parent->type;
+
+  ti->node_top = parent->node_top;
+  ti->node_parent = parent;
+  ti->node_group = NULL;
+  ti->next = NULL;
 
-  ldi->node_top = parent->node_top;
-  ldi->node_parent = parent;
-  ldi->node_group = NULL;
-  ldi->next = NULL;
+  ti->cl_first = -1;
+  ti->cl_cursor = -1;
 
-  ldi->cl_first = -1;
-  ldi->cl_cursor = -1;
+  ti->subdir = NULL;
+  ti->fullpath = NULL;
+  ti->basepath = NULL;
+  ti->identifier = NULL;
+  ti->name = getStringCopy(ANONYMOUS_NAME);
+  ti->name_sorting = NULL;
+  ti->author = getStringCopy(parent->author);
 
-  ldi->subdir = NULL;
-  ldi->fullpath = NULL;
-  ldi->basepath = NULL;
-  ldi->identifier = NULL;
-  ldi->name = getStringCopy(ANONYMOUS_NAME);
-  ldi->name_sorting = NULL;
-  ldi->author = getStringCopy(parent->author);
+  ti->sort_priority = parent->sort_priority;
+  ti->latest_engine = parent->latest_engine;
+  ti->parent_link = FALSE;
+  ti->in_user_dir = parent->in_user_dir;
+  ti->user_defined = parent->user_defined;
+  ti->color = parent->color;
+  ti->class_desc = getStringCopy(parent->class_desc);
 
-  ldi->sort_priority = parent->sort_priority;
-  ldi->latest_engine = parent->latest_engine;
-  ldi->parent_link = FALSE;
-  ldi->in_user_dir = parent->in_user_dir;
-  ldi->user_defined = parent->user_defined;
-  ldi->color = parent->color;
-  ldi->class_desc = getStringCopy(parent->class_desc);
+  ti->infotext = getStringCopy(parent->infotext);
 
-  if (ldi->type == TREE_TYPE_LEVEL_DIR)
+  if (ti->type == TREE_TYPE_LEVEL_DIR)
   {
-    ldi->imported_from = getStringCopy(parent->imported_from);
-    ldi->imported_by = getStringCopy(parent->imported_by);
+    ti->imported_from = getStringCopy(parent->imported_from);
+    ti->imported_by = getStringCopy(parent->imported_by);
 
-    ldi->graphics_set_ecs = NULL;
-    ldi->graphics_set_aga = NULL;
-    ldi->graphics_set = NULL;
-    ldi->sounds_set = NULL;
-    ldi->music_set = NULL;
-    ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
-    ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
-    ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->graphics_set_ecs = NULL;
+    ti->graphics_set_aga = NULL;
+    ti->graphics_set = NULL;
+    ti->sounds_set = NULL;
+    ti->music_set = NULL;
+    ti->graphics_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->sounds_path = getStringCopy(UNDEFINED_FILENAME);
+    ti->music_path = getStringCopy(UNDEFINED_FILENAME);
 
-    ldi->level_filename = NULL;
-    ldi->level_filetype = NULL;
+    ti->level_filename = NULL;
+    ti->level_filetype = NULL;
 
-    ldi->levels = 0;
-    ldi->first_level = 0;
-    ldi->last_level = 0;
-    ldi->level_group = FALSE;
-    ldi->handicap_level = 0;
-    ldi->readonly = TRUE;
-    ldi->handicap = TRUE;
-    ldi->skip_levels = FALSE;
+    ti->levels = 0;
+    ti->first_level = 0;
+    ti->last_level = 0;
+    ti->level_group = FALSE;
+    ti->handicap_level = 0;
+    ti->readonly = TRUE;
+    ti->handicap = TRUE;
+    ti->skip_levels = FALSE;
   }
 }
 
-static void freeTreeInfo(TreeInfo *ldi)
+static void freeTreeInfo(TreeInfo *ti)
 {
-  checked_free(ldi->subdir);
-  checked_free(ldi->fullpath);
-  checked_free(ldi->basepath);
-  checked_free(ldi->identifier);
+  checked_free(ti->subdir);
+  checked_free(ti->fullpath);
+  checked_free(ti->basepath);
+  checked_free(ti->identifier);
+
+  checked_free(ti->name);
+  checked_free(ti->name_sorting);
+  checked_free(ti->author);
 
-  checked_free(ldi->name);
-  checked_free(ldi->name_sorting);
-  checked_free(ldi->author);
+  checked_free(ti->class_desc);
 
-  checked_free(ldi->class_desc);
+  checked_free(ti->infotext);
 
-  if (ldi->type == TREE_TYPE_LEVEL_DIR)
+  if (ti->type == TREE_TYPE_LEVEL_DIR)
   {
-    checked_free(ldi->imported_from);
-    checked_free(ldi->imported_by);
+    checked_free(ti->imported_from);
+    checked_free(ti->imported_by);
 
-    checked_free(ldi->graphics_set_ecs);
-    checked_free(ldi->graphics_set_aga);
-    checked_free(ldi->graphics_set);
-    checked_free(ldi->sounds_set);
-    checked_free(ldi->music_set);
+    checked_free(ti->graphics_set_ecs);
+    checked_free(ti->graphics_set_aga);
+    checked_free(ti->graphics_set);
+    checked_free(ti->sounds_set);
+    checked_free(ti->music_set);
 
-    checked_free(ldi->graphics_path);
-    checked_free(ldi->sounds_path);
-    checked_free(ldi->music_path);
+    checked_free(ti->graphics_path);
+    checked_free(ti->sounds_path);
+    checked_free(ti->music_path);
 
-    checked_free(ldi->level_filename);
-    checked_free(ldi->level_filetype);
+    checked_free(ti->level_filename);
+    checked_free(ti->level_filetype);
   }
 }
 
@@ -2278,7 +2302,7 @@ void LoadLevelInfo()
   if (leveldir_first == NULL)
     Error(ERR_EXIT, "cannot find any valid level series in any directory");
 
-  sortTreeInfo(&leveldir_first, compareTreeInfoEntries);
+  sortTreeInfo(&leveldir_first);
 
 #if 0
   dumpTreeInfo(leveldir_first, 0);
@@ -2573,9 +2597,9 @@ void LoadArtworkInfo()
   printf("music set == %s\n\n", artwork.mus_current_identifier);
 #endif
 
-  sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
-  sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
-  sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
+  sortTreeInfo(&artwork.gfx_first);
+  sortTreeInfo(&artwork.snd_first);
+  sortTreeInfo(&artwork.mus_first);
 
 #if 0
   dumpTreeInfo(artwork.gfx_first, 0);
@@ -2668,9 +2692,9 @@ void LoadLevelArtworkInfo()
       artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
   }
 
-  sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
-  sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries);
-  sortTreeInfo(&artwork.mus_first, compareTreeInfoEntries);
+  sortTreeInfo(&artwork.gfx_first);
+  sortTreeInfo(&artwork.snd_first);
+  sortTreeInfo(&artwork.mus_first);
 
 #if 0
   dumpTreeInfo(artwork.gfx_first, 0);
index 87cb4cbafb83eb91dfd7125cdda0cd69f3729cd9..e55217c01259ee73c0b6345dd07b03e4665887f9 100644 (file)
 
 /* additional values for setup screen */
 #define TYPE_ENTER_SCREEN              (1 << 9)
-#define TYPE_ENTER_MENU                        (1 << 10)
-#define TYPE_LEAVE_MENU                        (1 << 11)
-#define TYPE_EMPTY                     (1 << 12)
-#define TYPE_KEYTEXT                   (1 << 13)
+#define TYPE_LEAVE_SCREEN              (1 << 10)
+#define TYPE_ENTER_MENU                        (1 << 11)
+#define TYPE_LEAVE_MENU                        (1 << 12)
+#define TYPE_ENTER_LIST                        (1 << 13)
+#define TYPE_LEAVE_LIST                        (1 << 14)
+#define TYPE_EMPTY                     (1 << 15)
+#define TYPE_KEYTEXT                   (1 << 16)
 
-#define TYPE_GHOSTED                   (1 << 14)
-#define TYPE_QUERY                     (1 << 15)
+#define TYPE_GHOSTED                   (1 << 17)
+#define TYPE_QUERY                     (1 << 18)
 
 /* additional values for internal purposes */
-#define TYPE_BITFIELD                  (1 << 16)
-#define TYPE_ELEMENT                   (1 << 17)
-#define TYPE_CONTENT                   (1 << 18)
-#define TYPE_ELEMENT_LIST              (1 << 19)
-#define TYPE_CONTENT_LIST              (1 << 20)
+#define TYPE_BITFIELD                  (1 << 19)
+#define TYPE_ELEMENT                   (1 << 20)
+#define TYPE_CONTENT                   (1 << 21)
+#define TYPE_ELEMENT_LIST              (1 << 22)
+#define TYPE_CONTENT_LIST              (1 << 23)
 
 /* derived values for setup file handling */
 #define TYPE_BOOLEAN_STYLE             (TYPE_BOOLEAN | \
 
 #define TYPE_SKIP_ENTRY                        (TYPE_EMPTY             | \
                                         TYPE_KEY               | \
-                                        TYPE_STRING)
+                                        TYPE_STRING            | \
+                                        TYPE_GHOSTED)
 
-#define TYPE_ENTER_OR_LEAVE_MENU       (TYPE_ENTER_SCREEN      | \
+#define TYPE_ENTER_OR_LEAVE            (TYPE_ENTER_SCREEN      | \
+                                        TYPE_LEAVE_SCREEN      | \
                                         TYPE_ENTER_MENU        | \
-                                        TYPE_LEAVE_MENU)
+                                        TYPE_LEAVE_MENU        | \
+                                        TYPE_ENTER_LIST        | \
+                                        TYPE_LEAVE_LIST)
 
 /* cookie token for file identifier and version number */
 #define TOKEN_STR_FILE_IDENTIFIER      "file_identifier"
@@ -235,6 +242,7 @@ void InitUserLevelDirectory(char *);
 void InitLevelSetupDirectory(char *);
 
 TreeInfo *newTreeInfo();
+TreeInfo *newTreeInfo_setDefaults(int);
 void pushTreeInfo(TreeInfo **, TreeInfo *);
 int numTreeInfo(TreeInfo *);
 boolean validLevelSeries(TreeInfo *);
@@ -245,8 +253,10 @@ int posTreeInfo(TreeInfo *);
 TreeInfo *getTreeInfoFromPos(TreeInfo *, int);
 TreeInfo *getTreeInfoFromIdentifier(TreeInfo *, char *);
 void dumpTreeInfo(TreeInfo *, int);
-void sortTreeInfo(TreeInfo **,
-                 int (*compare_function)(const void *, const void *));
+void sortTreeInfoBySortFunction(TreeInfo **,
+                               int (*compare_function)(const void *,
+                                                       const void *));
+void sortTreeInfo(TreeInfo **);
 
 char *getHomeDir(void);
 char *getCommonDataDir(void);
@@ -255,7 +265,7 @@ char *getUserGameDataDir(void);
 char *getSetupDir(void);
 char *getCurrentLevelDir(void);
 
-void fixUserGameDataDir(void);
+void updateUserGameDataDir(void);
 
 void createDirectory(char *, char *, int);
 void InitUserDataDirectory(void);
index 551f382413cd27718264623baaae19905de5fc5f..14d4f1c089311632e9a449366b22e218b98a62e8 100644 (file)
@@ -123,7 +123,7 @@ void InitPlatformDependentStuff(void)
 #endif
 
 #if defined(PLATFORM_MACOSX)
-  fixUserGameDataDir();
+  updateUserGameDataDir();
 #endif
 
 #if !defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX)
@@ -328,6 +328,7 @@ void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
   video.depth = GetRealDepth(depth);
   video.fullscreen_available = FULLSCREEN_STATUS;
   video.fullscreen_enabled = FALSE;
+  video.fullscreen_modes = NULL;
 
 #if defined(TARGET_SDL)
   SDLInitVideoBuffer(backbuffer, window, fullscreen);
index 74917b2141ad0caf5df4a9fa675144b86e5893c6..6161b2746e9829bb72b0f888d64759efbe531431 100644 (file)
 
 #define NUM_TREE_TYPES         4
 
+#define INFOTEXT_UNDEFINED     ""
+#define INFOTEXT_GRAPHICS_DIR  "Custom Graphics"
+#define INFOTEXT_SOUNDS_DIR    "Custom Sounds"
+#define INFOTEXT_MUSIC_DIR     "Custom Music"
+#define INFOTEXT_LEVEL_DIR     "Level Sets"
+
+#define TREE_INFOTEXT(t)       ((t) == TREE_TYPE_LEVEL_DIR ?           \
+                                INFOTEXT_LEVEL_DIR :                   \
+                                (t) == TREE_TYPE_GRAPHICS_DIR ?        \
+                                INFOTEXT_GRAPHICS_DIR :                \
+                                (t) == TREE_TYPE_SOUNDS_DIR ?          \
+                                INFOTEXT_SOUNDS_DIR :                  \
+                                (t) == TREE_TYPE_MUSIC_DIR ?           \
+                                INFOTEXT_MUSIC_DIR :                   \
+                                INFOTEXT_UNDEFINED)
 
 /* values for artwork handling */
 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type)                       \
@@ -573,12 +588,18 @@ struct OptionInfo
   boolean debug;
 };
 
+struct ScreenModeInfo
+{
+  int width, height;
+};
+
 struct VideoSystemInfo
 {
   int default_depth;
   int width, height, depth;
   boolean fullscreen_available;
   boolean fullscreen_enabled;
+  struct ScreenModeInfo *fullscreen_modes;
 };
 
 struct AudioSystemInfo
@@ -754,6 +775,7 @@ struct SetupInfo
   boolean skip_levels;
   boolean time_limit;
   boolean fullscreen;
+  char *fullscreen_mode;
   boolean ask_on_escape;
   boolean ask_on_escape_editor;
   boolean quick_switch;
@@ -829,6 +851,8 @@ struct TreeInfo
   int color;           /* color to use on selection screen for this level */
   char *class_desc;    /* description of level series class */
   int handicap_level;  /* number of the lowest unsolved level */
+
+  char *infotext;      /* optional text to describe the tree type (headline) */
 };
 
 typedef struct TreeInfo TreeInfo;
index b7ad953fd0be259376451b30b9fedbd74a6cfb06..9f9b253d4ca37f62f23b8c7cbd7cd034f0adf3dd 100644 (file)
@@ -42,6 +42,8 @@
 #define WIN_XSIZE                      672
 #define WIN_YSIZE                      560
 
+#define DEFAULT_FULLSCREEN_MODE                "800x600"
+
 #define SCR_FIELDX                     17
 #define SCR_FIELDY                     17
 #define MAX_BUF_XSIZE                  (SCR_FIELDX + 2)
index 09572357247d504838a4ec4f148f409814019c3e..199d83761e0e7e077564ddec5f647651db3f3a28 100644 (file)
 #define SETUP_MODE_SHORTCUT_1          4
 #define SETUP_MODE_SHORTCUT_2          5
 #define SETUP_MODE_GRAPHICS            6
-#define SETUP_MODE_SOUND               7
-#define SETUP_MODE_ARTWORK             8
-#define SETUP_MODE_CHOOSE_GRAPHICS     9
-#define SETUP_MODE_CHOOSE_SOUNDS       10
-#define SETUP_MODE_CHOOSE_MUSIC                11
+#define SETUP_MODE_CHOOSE_SCREEN_MODE  7
+#define SETUP_MODE_SOUND               8
+#define SETUP_MODE_ARTWORK             9
+#define SETUP_MODE_CHOOSE_GRAPHICS     10
+#define SETUP_MODE_CHOOSE_SOUNDS       11
+#define SETUP_MODE_CHOOSE_MUSIC                12
 
-#define MAX_SETUP_MODES                        12
+#define MAX_SETUP_MODES                        13
 
 /* for input setup functions */
 #define SETUPINPUT_SCREEN_POS_START    0
@@ -121,6 +122,7 @@ static void HandleSetupScreen_Generic(int, int, int, int, int);
 static void HandleSetupScreen_Input(int, int, int, int, int);
 static void CustomizeKeyboard(int);
 static void CalibrateJoystick(int);
+static void execSetupGraphics(void);
 static void execSetupArtwork(void);
 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
 
@@ -146,6 +148,9 @@ static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
 static int setup_mode = SETUP_MODE_MAIN;
 static int info_mode = INFO_MODE_MAIN;
 
+static TreeInfo *screen_modes = NULL;
+static TreeInfo *screen_mode_current = NULL;
+
 #define DRAW_OFFSET_MODE(x)    (x >= GAME_MODE_MAIN &&                 \
                                 x <= GAME_MODE_SETUP ? x :             \
                                 x == GAME_MODE_PSEUDO_TYPENAME ?       \
@@ -1034,9 +1039,9 @@ static void DrawInfoScreen_Main(int fade_delay)
 
     DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr);
 
-    if (info_info[i].type & TYPE_ENTER_MENU)
+    if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
       initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
-    else if (info_info[i].type & TYPE_LEAVE_MENU)
+    else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
       initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
     else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
       initCursor(i, IMG_MENU_BUTTON);
@@ -1139,7 +1144,7 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
     }
     else if (!(info_info[y].type & TYPE_GHOSTED))
     {
-      if (info_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
+      if (info_info[y].type & TYPE_ENTER_OR_LEAVE)
       {
        void (*menu_callback_function)(void) = info_info[choice].value;
 
@@ -2059,11 +2064,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
 #endif
   int last_game_status = game_status;  /* save current game status */
 
-  title_string =
-    (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Sets" :
-     ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" :
-     ti->type == TREE_TYPE_SOUNDS_DIR ? "Custom Sounds" :
-     ti->type == TREE_TYPE_MUSIC_DIR ? "Custom Music" : "");
+  title_string = ti->infotext;
 
 #if 1
   DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
@@ -2213,7 +2214,13 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
     }
     else if (game_status == GAME_MODE_SETUP)
     {
-      execSetupArtwork();
+      if (game_status == GAME_MODE_SETUP)
+      {
+       if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
+         execSetupGraphics();
+       else
+         execSetupArtwork();
+      }
     }
     else
     {
@@ -2366,7 +2373,10 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
        if (game_status == GAME_MODE_SETUP)
        {
-         execSetupArtwork();
+         if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
+           execSetupGraphics();
+         else
+           execSetupArtwork();
        }
        else
        {
@@ -2518,6 +2528,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
 static struct TokenInfo *setup_info;
 static int num_setup_info;
 
+static char *screen_mode_text;
 static char *graphics_set_name;
 static char *sounds_set_name;
 static char *music_set_name;
@@ -2542,10 +2553,64 @@ static void execSetupEditor()
 
 static void execSetupGraphics()
 {
+  if (video.fullscreen_available && screen_modes == NULL)
+  {
+    int i;
+
+    for (i = 0; video.fullscreen_modes[i].width != -1; i++)
+    {
+      TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+      char identifier[20], name[20];
+      int x = video.fullscreen_modes[i].width;
+      int y = video.fullscreen_modes[i].height;
+
+      ti->node_top = &screen_modes;
+      ti->sort_priority = x * y;
+
+      sprintf(identifier, "%dx%d", x, y);
+      sprintf(name,     "%d x %d", x, y);
+
+      setString(&ti->identifier, identifier);
+      setString(&ti->name, name);
+      setString(&ti->name_sorting, name);
+      setString(&ti->infotext, "Fullscreen Mode");
+
+      pushTreeInfo(&screen_modes, ti);
+    }
+
+    sortTreeInfo(&screen_modes);
+
+    /* set current screen mode for fullscreen mode to reliable default value */
+    screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
+                                                   DEFAULT_FULLSCREEN_MODE);
+    if (screen_mode_current == NULL)
+      screen_mode_current = screen_modes;
+
+    if (screen_mode_current == NULL)
+      video.fullscreen_available = FALSE;
+  }
+
+  if (video.fullscreen_available)
+  {
+    setup.fullscreen_mode = screen_mode_current->identifier;
+
+    /* needed for displaying screen mode name instead of identifier */
+    screen_mode_text = screen_mode_current->name;
+  }
+
   setup_mode = SETUP_MODE_GRAPHICS;
   DrawSetupScreen();
 }
 
+static void execSetupChooseScreenMode()
+{
+  if (!video.fullscreen_available)
+    return;
+
+  setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
+  DrawSetupScreen();
+}
+
 static void execSetupSound()
 {
   setup_mode = SETUP_MODE_SOUND;
@@ -2683,7 +2748,9 @@ static struct TokenInfo setup_info_editor[] =
 
 static struct TokenInfo setup_info_graphics[] =
 {
-  { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen Mode:"      },
+  { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen:"           },
+  { TYPE_ENTER_LIST,   execSetupChooseScreenMode, "Fullscreen Mode:"   },
+  { TYPE_STRING,       &screen_mode_text,      ""                      },
   { TYPE_SWITCH,       &setup.scroll_delay,    "Delayed Scrolling:"    },
 #if 0
   { TYPE_SWITCH,       &setup.soft_scrolling,  "Soft Scrolling:"       },
@@ -2714,11 +2781,11 @@ static struct TokenInfo setup_info_sound[] =
 
 static struct TokenInfo setup_info_artwork[] =
 {
-  { TYPE_ENTER_MENU,   execSetupChooseGraphics,"Custom Graphics"       },
+  { TYPE_ENTER_LIST,   execSetupChooseGraphics,"Custom Graphics:"      },
   { TYPE_STRING,       &graphics_set_name,     ""                      },
-  { TYPE_ENTER_MENU,   execSetupChooseSounds,  "Custom Sounds"         },
+  { TYPE_ENTER_LIST,   execSetupChooseSounds,  "Custom Sounds:"        },
   { TYPE_STRING,       &sounds_set_name,       ""                      },
-  { TYPE_ENTER_MENU,   execSetupChooseMusic,   "Custom Music"          },
+  { TYPE_ENTER_LIST,   execSetupChooseMusic,   "Custom Music:"         },
   { TYPE_STRING,       &music_set_name,        ""                      },
   { TYPE_EMPTY,                NULL,                   ""                      },
 #if 1
@@ -2825,7 +2892,8 @@ static int getSetupTextFont(int type)
              TYPE_YES_NO |
              TYPE_STRING |
              TYPE_ECS_AGA |
-             TYPE_KEYTEXT))
+             TYPE_KEYTEXT |
+             TYPE_ENTER_LIST))
     return FONT_MENU_2;
   else
     return FONT_MENU_1;
@@ -3063,7 +3131,8 @@ static void DrawSetupScreen_Generic()
     if ((value_ptr == &setup.sound_simple && !audio.sound_available) ||
        (value_ptr == &setup.sound_loops  && !audio.loops_available) ||
        (value_ptr == &setup.sound_music  && !audio.music_available) ||
-       (value_ptr == &setup.fullscreen   && !video.fullscreen_available))
+       (value_ptr == &setup.fullscreen   && !video.fullscreen_available) ||
+       (value_ptr == &screen_mode_text   && !video.fullscreen_available))
       setup_info[i].type |= TYPE_GHOSTED;
 
 #if 1
@@ -3084,9 +3153,9 @@ static void DrawSetupScreen_Generic()
 
     DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr);
 
-    if (setup_info[i].type & TYPE_ENTER_MENU)
+    if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
       initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
-    else if (setup_info[i].type & TYPE_LEAVE_MENU)
+    else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
       initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
     else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
       initCursor(i, IMG_MENU_BUTTON);
@@ -3179,7 +3248,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
     }
     else if (!(setup_info[y].type & TYPE_GHOSTED))
     {
-      if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
+      if (setup_info[y].type & TYPE_ENTER_OR_LEAVE)
       {
        void (*menu_callback_function)(void) = setup_info[choice].value;
 
@@ -3847,6 +3916,8 @@ void DrawSetupScreen()
 
   if (setup_mode == SETUP_MODE_INPUT)
     DrawSetupScreen_Input();
+  else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
+    DrawChooseTree(&screen_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
     DrawChooseTree(&artwork.gfx_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
@@ -3864,6 +3935,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
 {
   if (setup_mode == SETUP_MODE_INPUT)
     HandleSetupScreen_Input(mx, my, dx, dy, button);
+  else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
+    HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
     HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
index 3a2b962a3469435f1d8f00d6acf497f5be894d87..f1fd599ead465894a43b1044ab6219e7466d6da6 100644 (file)
@@ -44,6 +44,8 @@ static int el_act2crm(int, int);
 static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS];
 static int request_gadget_id = -1;
 
+static int preview_tilesize = 4;
+
 static char *print_if_not_empty(int element)
 {
   static char *s = NULL;
@@ -1493,6 +1495,37 @@ void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
   *y = src_y;
 }
 
+void getPreviewGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y,
+                            int tilesize)
+{
+  struct
+  {
+    int width_mult, width_div;
+    int height_mult, height_div;
+  } offset_calc[4] =
+  {
+    { 0, 1,    0, 1    },
+    { 0, 1,    2, 3    },
+    { 1, 2,    2, 3    },
+    { 3, 4,    2, 3    },
+  };
+  int offset_calc_pos = (tilesize < MICRO_TILESIZE || tilesize > TILESIZE ? 3 :
+                        5 - log_2(tilesize));
+  Bitmap *src_bitmap = graphic_info[graphic].bitmap;
+  int width_mult = offset_calc[offset_calc_pos].width_mult;
+  int width_div = offset_calc[offset_calc_pos].width_div;
+  int height_mult = offset_calc[offset_calc_pos].height_mult;
+  int height_div = offset_calc[offset_calc_pos].height_div;
+  int mini_startx = src_bitmap->width * width_mult / width_div;
+  int mini_starty = src_bitmap->height * height_mult / height_div;
+  int src_x = mini_startx + graphic_info[graphic].src_x * tilesize / TILESIZE;
+  int src_y = mini_starty + graphic_info[graphic].src_y * tilesize / TILESIZE;
+
+  *bitmap = src_bitmap;
+  *x = src_x;
+  *y = src_y;
+}
+
 void DrawMicroElement(int xpos, int ypos, int element)
 {
   Bitmap *src_bitmap;
@@ -1504,6 +1537,16 @@ void DrawMicroElement(int xpos, int ypos, int element)
             xpos, ypos);
 }
 
+void DrawPreviewElement(int xpos, int ypos, int element, int tilesize)
+{
+  Bitmap *src_bitmap;
+  int src_x, src_y;
+  int graphic = el2preimg(element);
+
+  getPreviewGraphicSource(graphic, &src_bitmap, &src_x, &src_y, tilesize);
+  BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, xpos, ypos);
+}
+
 void DrawLevel()
 {
   int x,y;
@@ -1529,33 +1572,37 @@ void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y)
   redraw_mask |= REDRAW_FIELD;
 }
 
-static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y)
+static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y,
+                             int preview_size_x, int preview_size_y)
 {
   int x, y;
 
   DrawBackground(xpos, ypos, MICROLEVEL_XSIZE, MICROLEVEL_YSIZE);
 
-  if (lev_fieldx < STD_LEV_FIELDX)
-    xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX;
-  if (lev_fieldy < STD_LEV_FIELDY)
-    ypos += (STD_LEV_FIELDY - lev_fieldy) / 2 * MICRO_TILEY;
+  if (lev_fieldx < preview_size_x)
+    xpos += (preview_size_x - lev_fieldx) / 2 * preview_tilesize;
+  if (lev_fieldy < preview_size_y)
+    ypos += (preview_size_y - lev_fieldy) / 2 * preview_tilesize;
 
-  xpos += MICRO_TILEX;
-  ypos += MICRO_TILEY;
+  xpos += preview_tilesize;
+  ypos += preview_tilesize;
 
-  for (x = -1; x <= STD_LEV_FIELDX; x++)
+  for (x = -1; x <= preview_size_x; x++)
   {
-    for (y = -1; y <= STD_LEV_FIELDY; y++)
+    for (y = -1; y <= preview_size_y; y++)
     {
       int lx = from_x + x, ly = from_y + y;
 
-      if (lx >= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy)
-       DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY,
-                        level.field[lx][ly]);
-      else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1
-              && BorderElement != EL_EMPTY)
-       DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY,
-                        getBorderElement(lx, ly));
+      if (lx >= 0 && lx < lev_fieldx &&
+         ly >= 0 && ly < lev_fieldy)
+       DrawPreviewElement(xpos + x * preview_tilesize,
+                          ypos + y * preview_tilesize,
+                          level.field[lx][ly], preview_tilesize);
+      else if (lx >= -1 && lx < lev_fieldx+1 &&
+              ly >= -1 && ly < lev_fieldy+1 && BorderElement != EL_EMPTY)
+       DrawPreviewElement(xpos + x * preview_tilesize,
+                          ypos + y * preview_tilesize,
+                          getBorderElement(lx, ly), preview_tilesize);
     }
   }
 
@@ -1625,6 +1672,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
   static unsigned long label_delay = 0;
   static int from_x, from_y, scroll_direction;
   static int label_state, label_counter;
+  int preview_size_x = STD_LEV_FIELDX * MICRO_TILESIZE / preview_tilesize;
+  int preview_size_y = STD_LEV_FIELDY * MICRO_TILESIZE / preview_tilesize;
   int last_game_status = game_status;  /* save current game status */
 
   /* force PREVIEW font on preview level */
@@ -1637,7 +1686,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
     label_state = 1;
     label_counter = 0;
 
-    DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+    DrawMicroLevelExt(xpos, ypos, from_x, from_y,
+                     preview_size_x, preview_size_y);
     DrawMicroLevelLabelExt(label_state);
 
     /* initialize delay counters */
@@ -1666,7 +1716,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
   }
 
   /* scroll micro level, if needed */
-  if ((lev_fieldx > STD_LEV_FIELDX || lev_fieldy > STD_LEV_FIELDY) &&
+  if ((lev_fieldx > preview_size_x || lev_fieldy > preview_size_y) &&
       DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY))
   {
     switch (scroll_direction)
@@ -1679,7 +1729,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
        break;
 
       case MV_RIGHT:
-       if (from_x < lev_fieldx - STD_LEV_FIELDX)
+       if (from_x < lev_fieldx - preview_size_x)
          from_x++;
        else
          scroll_direction = MV_DOWN;
@@ -1693,7 +1743,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
        break;
 
       case MV_DOWN:
-       if (from_y < lev_fieldy - STD_LEV_FIELDY)
+       if (from_y < lev_fieldy - preview_size_y)
          from_y++;
        else
          scroll_direction = MV_LEFT;
@@ -1703,7 +1753,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
        break;
     }
 
-    DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+    DrawMicroLevelExt(xpos, ypos, from_x, from_y,
+                     preview_size_x, preview_size_y);
   }
 
   /* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */