rnd-20020601-1-src
authorHolger Schemel <info@artsoft.org>
Fri, 31 May 2002 22:34:36 +0000 (00:34 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:52 +0000 (10:37 +0200)
src/files.c
src/init.c
src/libgame/misc.c
src/libgame/setup.c
src/libgame/sound.c
src/libgame/system.h
src/screens.c
src/timestamp.h
src/tools.c

index 7683103022d5eab1ce410a2badb9a76e174692d7..4de97c6c89736aeba2381600806ef3fae9fe8d85 100644 (file)
@@ -1157,57 +1157,60 @@ void SaveScore(int level_nr)
 /* setup file functions                                                      */
 /* ========================================================================= */
 
-#define TOKEN_STR_PLAYER_PREFIX                "player_"
+#define TOKEN_STR_PLAYER_PREFIX                        "player_"
 
 /* global setup */
-#define SETUP_TOKEN_PLAYER_NAME                0
-#define SETUP_TOKEN_SOUND              1
-#define SETUP_TOKEN_SOUND_LOOPS                2
-#define SETUP_TOKEN_SOUND_MUSIC                3
-#define SETUP_TOKEN_SOUND_SIMPLE       4
-#define SETUP_TOKEN_TOONS              5
-#define SETUP_TOKEN_SCROLL_DELAY       6
-#define SETUP_TOKEN_SOFT_SCROLLING     7
-#define SETUP_TOKEN_FADING             8
-#define SETUP_TOKEN_AUTORECORD         9
-#define SETUP_TOKEN_QUICK_DOORS                10
-#define SETUP_TOKEN_TEAM_MODE          11
-#define SETUP_TOKEN_HANDICAP           12
-#define SETUP_TOKEN_TIME_LIMIT         13
-#define SETUP_TOKEN_FULLSCREEN         14
-#define SETUP_TOKEN_ASK_ON_ESCAPE      15
-#define SETUP_TOKEN_GRAPHICS_SET       16
-#define SETUP_TOKEN_SOUNDS_SET         17
-#define SETUP_TOKEN_MUSIC_SET          18
-
-#define NUM_GLOBAL_SETUP_TOKENS                19
+#define SETUP_TOKEN_PLAYER_NAME                        0
+#define SETUP_TOKEN_SOUND                      1
+#define SETUP_TOKEN_SOUND_LOOPS                        2
+#define SETUP_TOKEN_SOUND_MUSIC                        3
+#define SETUP_TOKEN_SOUND_SIMPLE               4
+#define SETUP_TOKEN_TOONS                      5
+#define SETUP_TOKEN_SCROLL_DELAY               6
+#define SETUP_TOKEN_SOFT_SCROLLING             7
+#define SETUP_TOKEN_FADING                     8
+#define SETUP_TOKEN_AUTORECORD                 9
+#define SETUP_TOKEN_QUICK_DOORS                        10
+#define SETUP_TOKEN_TEAM_MODE                  11
+#define SETUP_TOKEN_HANDICAP                   12
+#define SETUP_TOKEN_TIME_LIMIT                 13
+#define SETUP_TOKEN_FULLSCREEN                 14
+#define SETUP_TOKEN_ASK_ON_ESCAPE              15
+#define SETUP_TOKEN_GRAPHICS_SET               16
+#define SETUP_TOKEN_SOUNDS_SET                 17
+#define SETUP_TOKEN_MUSIC_SET                  18
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    19
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      20
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       21
+
+#define NUM_GLOBAL_SETUP_TOKENS                        22
 
 /* shortcut setup */
-#define SETUP_TOKEN_SAVE_GAME          0
-#define SETUP_TOKEN_LOAD_GAME          1
-#define SETUP_TOKEN_TOGGLE_PAUSE       2
+#define SETUP_TOKEN_SAVE_GAME                  0
+#define SETUP_TOKEN_LOAD_GAME                  1
+#define SETUP_TOKEN_TOGGLE_PAUSE               2
 
-#define NUM_SHORTCUT_SETUP_TOKENS      3
+#define NUM_SHORTCUT_SETUP_TOKENS              3
 
 /* player setup */
-#define SETUP_TOKEN_USE_JOYSTICK       0
-#define SETUP_TOKEN_JOY_DEVICE_NAME    1
-#define SETUP_TOKEN_JOY_XLEFT          2
-#define SETUP_TOKEN_JOY_XMIDDLE                3
-#define SETUP_TOKEN_JOY_XRIGHT         4
-#define SETUP_TOKEN_JOY_YUPPER         5
-#define SETUP_TOKEN_JOY_YMIDDLE                6
-#define SETUP_TOKEN_JOY_YLOWER         7
-#define SETUP_TOKEN_JOY_SNAP           8
-#define SETUP_TOKEN_JOY_BOMB           9
-#define SETUP_TOKEN_KEY_LEFT           10
-#define SETUP_TOKEN_KEY_RIGHT          11
-#define SETUP_TOKEN_KEY_UP             12
-#define SETUP_TOKEN_KEY_DOWN           13
-#define SETUP_TOKEN_KEY_SNAP           14
-#define SETUP_TOKEN_KEY_BOMB           15
-
-#define NUM_PLAYER_SETUP_TOKENS                16
+#define SETUP_TOKEN_USE_JOYSTICK               0
+#define SETUP_TOKEN_JOY_DEVICE_NAME            1
+#define SETUP_TOKEN_JOY_XLEFT                  2
+#define SETUP_TOKEN_JOY_XMIDDLE                        3
+#define SETUP_TOKEN_JOY_XRIGHT                 4
+#define SETUP_TOKEN_JOY_YUPPER                 5
+#define SETUP_TOKEN_JOY_YMIDDLE                        6
+#define SETUP_TOKEN_JOY_YLOWER                 7
+#define SETUP_TOKEN_JOY_SNAP                   8
+#define SETUP_TOKEN_JOY_BOMB                   9
+#define SETUP_TOKEN_KEY_LEFT                   10
+#define SETUP_TOKEN_KEY_RIGHT                  11
+#define SETUP_TOKEN_KEY_UP                     12
+#define SETUP_TOKEN_KEY_DOWN                   13
+#define SETUP_TOKEN_KEY_SNAP                   14
+#define SETUP_TOKEN_KEY_BOMB                   15
+
+#define NUM_PLAYER_SETUP_TOKENS                        16
 
 static struct SetupInfo si;
 static struct SetupShortcutInfo ssi;
@@ -1235,14 +1238,17 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_STRING, &si.graphics_set,     "graphics_set"                  },
   { TYPE_STRING, &si.sounds_set,       "sounds_set"                    },
   { TYPE_STRING, &si.music_set,                "music_set"                     },
+  { TYPE_SWITCH, &si.override_level_graphics, "override_level_graphics"        },
+  { TYPE_SWITCH, &si.override_level_sounds,   "override_level_sounds"  },
+  { TYPE_SWITCH, &si.override_level_music,    "override_level_music"   },
 };
 
 static struct TokenInfo shortcut_setup_tokens[] =
 {
   /* shortcut setup */
-  { TYPE_KEY_X11, &ssi.save_game,              "shortcut.save_game"    },
-  { TYPE_KEY_X11, &ssi.load_game,              "shortcut.load_game"    },
-  { TYPE_KEY_X11, &ssi.toggle_pause,           "shortcut.toggle_pause" }
+  { TYPE_KEY_X11, &ssi.save_game,      "shortcut.save_game"            },
+  { TYPE_KEY_X11, &ssi.load_game,      "shortcut.load_game"            },
+  { TYPE_KEY_X11, &ssi.toggle_pause,   "shortcut.toggle_pause"         }
 };
 
 static struct TokenInfo player_setup_tokens[] =
@@ -1293,6 +1299,9 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->graphics_set = getStringCopy(GRAPHICS_SUBDIR);
   si->sounds_set = getStringCopy(SOUNDS_SUBDIR);
   si->music_set = getStringCopy(MUSIC_SUBDIR);
+  si->override_level_graphics = FALSE;
+  si->override_level_sounds = FALSE;
+  si->override_level_music = FALSE;
 
   si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME;
   si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME;
index 763ed518dd35ff6d894eef70f03c31a40a5f23a4..1f724a11a8088294c6c0781013a7202c5e60d909 100644 (file)
@@ -409,7 +409,23 @@ void InitGfxBackground()
 
 void ReloadCustomArtwork()
 {
-  if (artwork.graphics_set_current != artwork.gfx_current->name)
+  static char *leveldir_current_name = NULL;
+  static boolean last_override_level_graphics = FALSE;
+  static boolean last_override_level_sounds = FALSE;
+  static boolean last_override_level_music = FALSE;
+
+  if (leveldir_current_name != leveldir_current->name)
+  {
+    /* force reload of custom artwork after new level series was selected */
+    artwork.graphics_set_current_name = NULL;
+    artwork.sounds_set_current_name = NULL;
+    artwork.music_set_current_name = NULL;
+
+    leveldir_current_name = leveldir_current->name;
+  }
+
+  if (artwork.graphics_set_current_name != artwork.gfx_current->name ||
+      last_override_level_graphics != setup.override_level_graphics)
   {
     int i;
 
@@ -427,21 +443,26 @@ void ReloadCustomArtwork()
 
     SetDoorState(DOOR_OPEN_1 | DOOR_CLOSE_2);
 
-    artwork.graphics_set_current = artwork.gfx_current->name;
+    artwork.graphics_set_current_name = artwork.gfx_current->name;
+    last_override_level_graphics = setup.override_level_graphics;
   }
 
-  if (artwork.sounds_set_current != artwork.snd_current->name)
+  if (artwork.sounds_set_current_name != artwork.snd_current->name ||
+      last_override_level_sounds != setup.override_level_sounds)
   {
     InitReloadSounds(artwork.snd_current->name);
 
-    artwork.sounds_set_current = artwork.snd_current->name;
+    artwork.sounds_set_current_name = artwork.snd_current->name;
+    last_override_level_sounds = setup.override_level_sounds;
   }
 
-  if (artwork.music_set_current != artwork.mus_current->name)
+  if (artwork.music_set_current_name != artwork.mus_current->name ||
+      last_override_level_music != setup.override_level_music)
   {
     InitReloadMusic(artwork.mus_current->name);
 
-    artwork.music_set_current = artwork.mus_current->name;
+    artwork.music_set_current_name = artwork.mus_current->name;
+    last_override_level_music = setup.override_level_music;
   }
 }
 
index b344ba6f2a9e65365ea36b4fe7c14359b13c9aeb..78a5d13e0938ea113457c11806326d41c19d9f95 100644 (file)
@@ -111,10 +111,12 @@ static void sleep_milliseconds(unsigned long milliseconds_delay)
 {
   boolean do_busy_waiting = (milliseconds_delay < 5 ? TRUE : FALSE);
 
+#if 0
 #if defined(PLATFORM_MSDOS)
   /* don't use select() to perform waiting operations under DOS
      environment; always use a busy loop for waiting instead */
   do_busy_waiting = TRUE;
+#endif
 #endif
 
   if (do_busy_waiting)
@@ -134,6 +136,8 @@ static void sleep_milliseconds(unsigned long milliseconds_delay)
   {
 #if defined(TARGET_SDL)
     SDL_Delay(milliseconds_delay);
+#elif defined(TARGET_ALLEGRO)
+    rest(milliseconds_delay);
 #else
     struct timeval delay;
 
@@ -1196,12 +1200,19 @@ boolean FileIsSound(char *basename)
 
 boolean FileIsMusic(char *basename)
 {
+  /* "music" can be a WAV (loop) file or (if compiled with SDL) a MOD file */
+
+  if (FileIsSound(basename))
+    return TRUE;
+
+#if defined(TARGET_SDL)
   if (strlen(basename) > 4 &&
       (strcmp(&basename[strlen(basename) - 4], ".mod") == 0 ||
        strcmp(&basename[strlen(basename) - 4], ".MOD") == 0 ||
        strncmp(basename, "mod.", 4) == 0 ||
        strncmp(basename, "MOD.", 4) == 0))
     return TRUE;
+#endif
 
   return FALSE;
 }
index 6ad11351d1dca59eea56a49bb080f0dd5a7dd915..5ce14db2245335eb9b72044ba3171e7442cf5a66 100644 (file)
@@ -385,32 +385,30 @@ char *getCustomImageFilename(char *basename)
 
   basename = getCorrectedImageBasename(basename);
 
-  /* 1st try: look for special artwork in current level series directory */
-  filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
-  if (fileExists(filename))
-    return filename;
-
-  /* 2nd try: look for special artwork in private artwork directory */
-  filename = getPath2(getUserGraphicsDir(), basename);
-  if (fileExists(filename))
-    return filename;
+  if (!setup.override_level_graphics)
+  {
+    /* 1st try: look for special artwork in current level series directory */
+    filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
+    if (fileExists(filename))
+      return filename;
+  }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
+  /* 2nd try: look for special artwork in configured artwork directory */
   filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
   if (fileExists(filename))
     return filename;
 
-  /* 4th try: look for default artwork in new default artwork directory */
+  /* 3rd try: look for default artwork in new default artwork directory */
   filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
   if (fileExists(filename))
     return filename;
 
-  /* 5th try: look for default artwork in old default artwork directory */
+  /* 4th try: look for default artwork in old default artwork directory */
   filename = getPath2(options.graphics_directory, basename);
   if (fileExists(filename))
     return filename;
 
-  return NULL;                                 /* cannot find image file */
+  return NULL;         /* cannot find specified artwork file anywhere */
 }
 
 char *getCustomSoundFilename(char *basename)
@@ -420,36 +418,30 @@ char *getCustomSoundFilename(char *basename)
   if (filename != NULL)
     free(filename);
 
-#if 0
-  /* 1st try: look for special artwork in current level series directory */
-  filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
-  if (fileExists(filename))
-    return filename;
-#endif
-
-#if 0
-  /* 2nd try: look for special artwork in private artwork directory */
-  filename = getPath2(getUserSoundsDir(), basename);
-  if (fileExists(filename))
-    return filename;
-#endif
+  if (!setup.override_level_sounds)
+  {
+    /* 1st try: look for special artwork in current level series directory */
+    filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
+    if (fileExists(filename))
+      return filename;
+  }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
+  /* 2nd try: look for special artwork in configured artwork directory */
   filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
   if (fileExists(filename))
     return filename;
 
-  /* 4th try: look for default artwork in new default artwork directory */
+  /* 3rd try: look for default artwork in new default artwork directory */
   filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename);
   if (fileExists(filename))
     return filename;
 
-  /* 5th try: look for default artwork in old default artwork directory */
+  /* 4th try: look for default artwork in old default artwork directory */
   filename = getPath2(options.sounds_directory, basename);
   if (fileExists(filename))
     return filename;
 
-  return NULL;                                 /* cannot find image file */
+  return NULL;         /* cannot find specified artwork file anywhere */
 }
 
 char *getCustomSoundConfigFilename()
@@ -464,32 +456,30 @@ char *getCustomMusicDirectory(void)
   if (directory != NULL)
     free(directory);
 
-  /* 1st try: look for special artwork in current level series directory */
-  directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
-  if (fileExists(directory))
-    return directory;
-
-  /* 2nd try: look for special artwork in private artwork directory */
-  directory = getStringCopy(getUserMusicDir());
-  if (fileExists(directory))
-    return directory;
+  if (!setup.override_level_music)
+  {
+    /* 1st try: look for special artwork in current level series directory */
+    directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
+    if (fileExists(directory))
+      return directory;
+  }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
+  /* 2nd try: look for special artwork in configured artwork directory */
   directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
   if (fileExists(directory))
     return directory;
 
-  /* 4th try: look for default artwork in new default artwork directory */
+  /* 3rd try: look for default artwork in new default artwork directory */
   directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR));
   if (fileExists(directory))
     return directory;
 
-  /* 5th try: look for default artwork in old default artwork directory */
+  /* 4th try: look for default artwork in old default artwork directory */
   directory = getStringCopy(options.music_directory);
   if (fileExists(directory))
     return directory;
 
-  return NULL;                                 /* cannot find image file */
+  return NULL;         /* cannot find specified artwork file anywhere */
 }
 
 void InitTapeDirectory(char *level_subdir)
@@ -1847,14 +1837,14 @@ void LoadArtworkInfo()
   if (artwork.mus_current == NULL)
   artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
 
-  artwork.graphics_set_current = artwork.gfx_current->name;
-  artwork.sounds_set_current = artwork.snd_current->name;
-  artwork.music_set_current = artwork.mus_current->name;
+  artwork.graphics_set_current_name = artwork.gfx_current->name;
+  artwork.sounds_set_current_name = artwork.snd_current->name;
+  artwork.music_set_current_name = artwork.mus_current->name;
 
 #if 0
-  printf("graphics set == %s\n\n", artwork.graphics_set_current);
-  printf("sounds set == %s\n\n", artwork.sounds_set_current);
-  printf("music set == %s\n\n", artwork.music_set_current);
+  printf("graphics set == %s\n\n", artwork.graphics_set_current_name);
+  printf("sounds set == %s\n\n", artwork.sounds_set_current_name);
+  printf("music set == %s\n\n", artwork.music_set_current_name);
 #endif
 
   sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries);
@@ -1978,6 +1968,9 @@ char *getSetupValue(int type, void *value)
 {
   static char value_string[MAX_LINE_LEN];
 
+  if (value == NULL)
+    return NULL;
+
   switch (type)
   {
     case TYPE_BOOLEAN:
index 414ab122befa69174fd501a16ec44763f0a41797..ae4028d74589bd98e6d41f6eb32155f9d8263f71 100644 (file)
@@ -497,6 +497,9 @@ static void WriteReloadInfoToPipe(char *set_name, int type)
   unsigned long str_size1 = strlen(leveldir_current->fullpath) + 1;
   unsigned long str_size2 = strlen(ti->basepath) + 1;
   unsigned long str_size3 = strlen(ti->fullpath) + 1;
+  boolean override_level_artwork = (type == SND_CTRL_RELOAD_SOUNDS ?
+                                   setup.override_level_sounds :
+                                   setup.override_level_music);
 
   if (IS_CHILD_PROCESS(audio.mixer_pid))
     return;
@@ -512,6 +515,8 @@ static void WriteReloadInfoToPipe(char *set_name, int type)
            sizeof(snd_ctrl)) < 0 ||
       write(audio.mixer_pipe[1], set_name,
            snd_ctrl.data_len) < 0 ||
+      write(audio.mixer_pipe[1], &override_level_artwork,
+           sizeof(boolean)) < 0 ||
       write(audio.mixer_pipe[1], leveldir_current,
            sizeof(TreeInfo)) < 0 ||
       write(audio.mixer_pipe[1], ti,
@@ -542,6 +547,9 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
   TreeInfo *ti = *ti_ptr;
   unsigned long str_size1, str_size2, str_size3;
   static char *set_name = NULL;
+  boolean *override_level_artwork = (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS ?
+                                    &setup.override_level_sounds :
+                                    &setup.override_level_music);
 
   if (set_name)
     free(set_name);
@@ -561,6 +569,8 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
 
   if (read(audio.mixer_pipe[0], set_name,
           snd_ctrl->data_len) != snd_ctrl->data_len ||
+      read(audio.mixer_pipe[0], override_level_artwork,
+          sizeof(boolean)) != sizeof(boolean) ||
       read(audio.mixer_pipe[0], leveldir_current,
           sizeof(TreeInfo)) != sizeof(TreeInfo) ||
       read(audio.mixer_pipe[0], ti,
@@ -586,9 +596,9 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
     Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
 
   if (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS)
-    artwork.sounds_set_current = set_name;
+    artwork.sounds_set_current_name = set_name;
   else
-    artwork.music_set_current = set_name;
+    artwork.music_set_current_name = set_name;
 }
 
 #endif /* AUDIO_UNIX_NATIVE */
@@ -1831,6 +1841,7 @@ static MusicInfo *Load_MOD(char *filename)
 void LoadCustomMusic(void)
 {
   static boolean draw_init_text = TRUE;                /* only draw at startup */
+  static char *last_music_directory = NULL;
   char *music_directory = getCustomMusicDirectory();
   DIR *dir;
   struct dirent *dir_entry;
@@ -1838,6 +1849,14 @@ void LoadCustomMusic(void)
   if (!audio.sound_available)
     return;
 
+  if (last_music_directory != NULL &&
+      strcmp(last_music_directory, music_directory) == 0)
+    return;    /* old and new music directory are the same */
+
+  last_music_directory = music_directory;
+
+  FreeAllMusic();
+
   if ((dir = opendir(music_directory)) == NULL)
   {
     Error(ERR_WARN, "cannot read music directory '%s'", music_directory);
@@ -2108,7 +2127,7 @@ static void ReloadCustomSounds()
   int i;
 
 #if 0
-  printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current);
+  printf("DEBUG: reloading sounds '%s' ...\n",artwork.sounds_set_current_name);
 #endif
 
   LoadSoundsInfo();
@@ -2145,10 +2164,13 @@ static void ReloadCustomSounds()
 static void ReloadCustomMusic()
 {
 #if 0
-  printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
+  printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current_name);
 #endif
 
+#if 0
+  /* this is done directly in LoadCustomMusic() now */
   FreeAllMusic();
+#endif
 
   LoadCustomMusic();
 }
index b21f866cfa4cbec0cc7203a69e07a669f5d1675b..1ade3147a3705ae787d2fca34cdb78b71982a5b3 100644 (file)
@@ -333,6 +333,9 @@ struct SetupInfo
   char *graphics_set;
   char *sounds_set;
   char *music_set;
+  boolean override_level_graphics;
+  boolean override_level_sounds;
+  boolean override_level_music;
 
   struct SetupShortcutInfo shortcut;
   struct SetupInputInfo input[MAX_PLAYERS];
@@ -395,9 +398,9 @@ struct ArtworkInfo
   MusicDirTree *mus_first;
   MusicDirTree *mus_current;
 
-  char *graphics_set_current;
-  char *sounds_set_current;
-  char *music_set_current;
+  char *graphics_set_current_name;
+  char *sounds_set_current_name;
+  char *music_set_current_name;
 };
 
 
index 1e3f941f834fda863a21888781ed5f8e96e8a9d0..a04d75dc3e6b204e7538d9c384ccd323ea8a62fe 100644 (file)
 
 /* screens in the setup menu */
 #define SETUP_MODE_MAIN                        0
-#define SETUP_MODE_INPUT               1
-#define SETUP_MODE_SHORTCUT            2
-#define SETUP_MODE_GRAPHICS            3
-#define SETUP_MODE_SOUND               4
-#define SETUP_MODE_CHOOSE_GRAPHICS     5
-#define SETUP_MODE_CHOOSE_SOUNDS       6
-#define SETUP_MODE_CHOOSE_MUSIC                7
-
-#define MAX_SETUP_MODES                        8
+#define SETUP_MODE_GAME                        1
+#define SETUP_MODE_INPUT               2
+#define SETUP_MODE_SHORTCUT            3
+#define SETUP_MODE_GRAPHICS            4
+#define SETUP_MODE_SOUND               5
+#define SETUP_MODE_ARTWORK             6
+#define SETUP_MODE_CHOOSE_GRAPHICS     7
+#define SETUP_MODE_CHOOSE_SOUNDS       8
+#define SETUP_MODE_CHOOSE_MUSIC                9
+
+#define MAX_SETUP_MODES                        10
 
 /* for input setup functions */
 #define SETUPINPUT_SCREEN_POS_START    0
 
 /* forward declarations of internal functions */
 static void HandleScreenGadgets(struct GadgetInfo *);
-static void execExitSetupChooseArtwork(void);
 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 execSetupArtwork(void);
 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
 
 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
@@ -1081,7 +1083,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
     }
     else if (game_status == SETUP)
     {
-      execExitSetupChooseArtwork();
+      execSetupArtwork();
     }
     else
     {
@@ -1218,7 +1220,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
        if (game_status == SETUP)
        {
-         execExitSetupChooseArtwork();
+         execSetupArtwork();
        }
        else
        {
@@ -1360,6 +1362,12 @@ static void execSetupMain()
   DrawSetupScreen();
 }
 
+static void execSetupGame()
+{
+  setup_mode = SETUP_MODE_GAME;
+  DrawSetupScreen();
+}
+
 static void execSetupGraphics()
 {
   setup.graphics_set = artwork.gfx_current->name;
@@ -1377,6 +1385,12 @@ static void execSetupSound()
   DrawSetupScreen();
 }
 
+static void execSetupArtwork()
+{
+  setup_mode = SETUP_MODE_ARTWORK;
+  DrawSetupScreen();
+}
+
 static void execSetupChooseGraphics()
 {
   setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
@@ -1407,14 +1421,6 @@ static void execSetupShortcut()
   DrawSetupScreen();
 }
 
-static void execExitSetupChooseArtwork()
-{
-  if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
-    execSetupGraphics();
-  else
-    execSetupSound();
-}
-
 static void execExitSetup()
 {
   game_status = MAINMENU;
@@ -1429,36 +1435,40 @@ static void execSaveAndExitSetup()
 
 static struct TokenInfo setup_info_main[] =
 {
-  { TYPE_ENTER_MENU,   execSetupGraphics,      "Graphics Setup"        },
-  { TYPE_ENTER_MENU,   execSetupSound,         "Sound Setup"           },
+  { TYPE_ENTER_MENU,   execSetupGame,          "Game Settings"         },
+  { TYPE_ENTER_MENU,   execSetupGraphics,      "Graphics"              },
+  { TYPE_ENTER_MENU,   execSetupSound,         "Sound & Music"         },
+  { TYPE_ENTER_MENU,   execSetupArtwork,       "Custom Artwork"        },
   { TYPE_ENTER_MENU,   execSetupInput,         "Input Devices"         },
   { TYPE_ENTER_MENU,   execSetupShortcut,      "Key Shortcuts"         },
   { TYPE_EMPTY,                NULL,                   ""                      },
-#if 0
-  { TYPE_SWITCH,       &setup.double_buffering,"Buffered gfx:"         },
-  { TYPE_SWITCH,       &setup.fading,          "Fading:"               },
-#endif
-  { TYPE_SWITCH,       &setup.quick_doors,     "Quick Doors:"          },
-  { TYPE_SWITCH,       &setup.ask_on_escape,   "Ask on Esc:"           },
-  { TYPE_SWITCH,       &setup.toons,           "Toons:"                },
-  { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record:"          },
+  { TYPE_LEAVE_MENU,   execExitSetup,          "Exit"                  },
+  { TYPE_LEAVE_MENU,   execSaveAndExitSetup,   "Save and exit"         },
+  { 0,                 NULL,                   NULL                    }
+};
+
+static struct TokenInfo setup_info_game[] =
+{
   { TYPE_SWITCH,       &setup.team_mode,       "Team-Mode:"            },
   { TYPE_SWITCH,       &setup.handicap,        "Handicap:"             },
   { TYPE_SWITCH,       &setup.time_limit,      "Timelimit:"            },
+  { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record:"          },
   { TYPE_EMPTY,                NULL,                   ""                      },
-  { TYPE_LEAVE_MENU,   execExitSetup,          "Exit"                  },
-  { TYPE_LEAVE_MENU,   execSaveAndExitSetup,   "Save and exit"         },
+  { TYPE_LEAVE_MENU,   execSetupMain,          "Exit"                  },
   { 0,                 NULL,                   NULL                    }
 };
 
 static struct TokenInfo setup_info_graphics[] =
 {
-  { TYPE_ENTER_MENU,   execSetupChooseGraphics,"Custom Graphics"       },
-  { TYPE_STRING,       &setup.graphics_set,    ""                      },
-  { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen:"           },
   { TYPE_SWITCH,       &setup.scroll_delay,    "Scroll Delay:"         },
   { TYPE_SWITCH,       &setup.soft_scrolling,  "Soft Scroll.:"         },
+#if 0
+  { TYPE_SWITCH,       &setup.double_buffering,"Buffered gfx:"         },
+  { TYPE_SWITCH,       &setup.fading,          "Fading:"               },
+#endif
+  { TYPE_SWITCH,       &setup.quick_doors,     "Quick Doors:"          },
+  { TYPE_SWITCH,       &setup.toons,           "Toons:"                },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Exit"                  },
   { 0,                 NULL,                   NULL                    }
@@ -1472,11 +1482,24 @@ static struct TokenInfo setup_info_sound[] =
   { TYPE_SWITCH,       &setup.sound_loops,     "Sound Loops:"          },
   { TYPE_SWITCH,       &setup.sound_music,     "Game Music:"           },
   { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_LEAVE_MENU,   execSetupMain,          "Exit"                  },
+  { 0,                 NULL,                   NULL                    }
+};
+
+static struct TokenInfo setup_info_artwork[] =
+{
+  { TYPE_ENTER_MENU,   execSetupChooseGraphics,"Custom Graphics"       },
+  { TYPE_STRING,       &setup.graphics_set,    ""                      },
   { TYPE_ENTER_MENU,   execSetupChooseSounds,  "Custom Sounds"         },
   { TYPE_STRING,       &setup.sounds_set,      ""                      },
   { TYPE_ENTER_MENU,   execSetupChooseMusic,   "Custom Music"          },
   { TYPE_STRING,       &setup.music_set,       ""                      },
   { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_STRING,       NULL,                   "Override Level Artwork:"},
+  { TYPE_YES_NO,       &setup.override_level_graphics, "Graphics:"     },
+  { TYPE_YES_NO,       &setup.override_level_sounds,   "Sounds:"       },
+  { TYPE_YES_NO,       &setup.override_level_music,    "Music:"        },
+  { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Exit"                  },
   { 0,                 NULL,                   NULL                    }
 };
@@ -1490,6 +1513,8 @@ static struct TokenInfo setup_info_shortcut[] =
   { TYPE_KEYTEXT,      NULL,                   "Toggle Pause:",        },
   { TYPE_KEY,          &setup.shortcut.toggle_pause,   ""              },
   { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_YES_NO,       &setup.ask_on_escape,   "Ask on Esc:"           },
+  { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Exit"                  },
   { 0,                 NULL,                   NULL                    }
 };
@@ -1550,6 +1575,9 @@ static void drawSetupValue(int pos)
   char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED,
                                     setup_info[pos].value);
 
+  if (value_string == NULL)
+    return;
+
   if (setup_info[pos].type & TYPE_KEY)
   {
     xpos = 3;
@@ -1615,6 +1643,11 @@ static void DrawSetupScreen_Generic()
     setup_info = setup_info_main;
     title_string = "Setup";
   }
+  else if (setup_mode == SETUP_MODE_GAME)
+  {
+    setup_info = setup_info_game;
+    title_string = "Setup Game";
+  }
   else if (setup_mode == SETUP_MODE_GRAPHICS)
   {
     setup_info = setup_info_graphics;
@@ -1625,6 +1658,11 @@ static void DrawSetupScreen_Generic()
     setup_info = setup_info_sound;
     title_string = "Setup Sound";
   }
+  else if (setup_mode == SETUP_MODE_ARTWORK)
+  {
+    setup_info = setup_info_artwork;
+    title_string = "Setup Sound";
+  }
   else if (setup_mode == SETUP_MODE_SHORTCUT)
   {
     setup_info = setup_info_shortcut;
@@ -1644,12 +1682,11 @@ static void DrawSetupScreen_Generic()
     if ((value_ptr == &setup.sound       && !audio.sound_available) ||
        (value_ptr == &setup.sound_loops && !audio.loops_available) ||
        (value_ptr == &setup.sound_music && !audio.music_available) ||
-       (value_ptr == &setup.sound_music && !audio.music_available) ||
        (value_ptr == &setup.fullscreen  && !video.fullscreen_available))
       setup_info[i].type |= TYPE_GHOSTED;
 
-    if (setup_info[i].type & TYPE_ENTER_OR_LEAVE_MENU)
-      font_size = FS_BIG;
+    if (setup_info[i].type & TYPE_STRING)
+      font_size = FS_MEDIUM;
 
     DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, font_size, FC_GREEN);
 
@@ -1737,26 +1774,6 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
     }
     else if (!(setup_info[y].type & TYPE_GHOSTED))
     {
-#if 0
-      if (setup_info[y].type & TYPE_BOOLEAN_STYLE)
-      {
-       boolean new_value = !*(boolean *)(setup_info[y].value);
-
-       *(boolean *)setup_info[y].value = new_value;
-       drawSetupValue(y);
-      }
-      else if (setup_info[y].type == TYPE_KEYTEXT &&
-              setup_info[y + 1].type == TYPE_KEY)
-      {
-       changeSetupValue(y + 1);
-      }
-      else if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
-      {
-       void (*menu_callback_function)(void) = setup_info[choice].value;
-
-       menu_callback_function();
-      }
-#else
       if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
       {
        void (*menu_callback_function)(void) = setup_info[choice].value;
@@ -1772,7 +1789,6 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
        if (setup_info[y].type & TYPE_VALUE)
          changeSetupValue(y);
       }
-#endif
     }
   }
 
index 062fe59a5a1ce893e232ef7912d079ea5841ce47..0b27fae4dc6753772c21c79966e6ada1be89fcb2 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-05-31 17:39]"
+#define COMPILE_DATE_STRING "[2002-06-01 00:23]"
index 801eb6b5b7f9c6e432d964407afe5c30b7565ecc..9aea7b4c7fcc64e29f951c2d214a1c4b365d79bb 100644 (file)
@@ -2100,9 +2100,10 @@ unsigned int MoveDoor(unsigned int door_state)
   {
     if (!(door_state & DOOR_NO_DELAY))
     {
+      /* opening door sound has priority over simultaneously closing door */
       if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2))
        PlaySoundStereo(SND_MENU_DOOR_OPENING, SOUND_MAX_RIGHT);
-      if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2))
+      else if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2))
        PlaySoundStereo(SND_MENU_DOOR_CLOSING, SOUND_MAX_RIGHT);
     }