added config parameters for native BD graphics/sound engine (not used yet)
[rocksndiamonds.git] / src / files.c
index 994d854dc798cc24220323457d618165f1ad58c6..ae0dbf7dc053f11ad0c966185bc2b0115227c2d7 100644 (file)
@@ -2891,7 +2891,7 @@ static int LoadLevel_CUS3(File *file, int chunk_size, struct LevelInfo *level)
     ei->change->delay_random = getFile16BitBE(file);
     ei->change->delay_frames = getFile16BitBE(file);
 
-    ei->change->initial_trigger_element= getMappedElement(getFile16BitBE(file));
+    ei->change->initial_trigger_element = getMappedElement(getFile16BitBE(file));
 
     ei->change->explode = getFile8Bit(file);
     ei->change->use_target_content = getFile8Bit(file);
@@ -8160,7 +8160,7 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape)
       byte action = tape->pos[i].action[0];
       int k, num_moves = 0;
 
-      for (k = 0; k<4; k++)
+      for (k = 0; k < 4; k++)
       {
        if (action & joy_dir[k])
        {
@@ -9868,6 +9868,10 @@ static struct TokenInfo editor_cascade_setup_tokens[] =
     TYPE_SWITCH,
     &setup.editor_cascade.el_bd,               "editor.cascade.el_bd"
   },
+  {
+    TYPE_SWITCH,
+    &setup.editor_cascade.el_bd_native,                "editor.cascade.el_bd_native"
+  },
   {
     TYPE_SWITCH,
     &setup.editor_cascade.el_em,               "editor.cascade.el_em"
@@ -10557,6 +10561,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->touch.overlay_buttons            = FALSE;
 
   si->editor.el_boulderdash            = TRUE;
+  si->editor.el_boulderdash_native     = TRUE;
   si->editor.el_emerald_mine           = TRUE;
   si->editor.el_emerald_mine_club      = TRUE;
   si->editor.el_more                   = TRUE;
@@ -10616,7 +10621,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   for (i = 0; i < MAX_PLAYERS; i++)
   {
     si->input[i].use_joystick = FALSE;
-    si->input[i].joy.device_name=getStringCopy(getDeviceNameFromJoystickNr(i));
+    si->input[i].joy.device_name = getStringCopy(getDeviceNameFromJoystickNr(i));
     si->input[i].joy.xleft   = JOYSTICK_XLEFT;
     si->input[i].joy.xmiddle = JOYSTICK_XMIDDLE;
     si->input[i].joy.xright  = JOYSTICK_XRIGHT;
@@ -10730,6 +10735,7 @@ static void setSetupInfoToDefaults_ServerSetup(struct SetupInfo *si)
 static void setSetupInfoToDefaults_EditorCascade(struct SetupInfo *si)
 {
   si->editor_cascade.el_bd             = TRUE;
+  si->editor_cascade.el_bd_native      = TRUE;
   si->editor_cascade.el_em             = TRUE;
   si->editor_cascade.el_emc            = TRUE;
   si->editor_cascade.el_rnd            = TRUE;
@@ -12888,6 +12894,65 @@ void LoadMenuDesignSettings_AfterGraphics(void)
   InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics();
 }
 
+void InitSoundSettings_FromHash(SetupFileHash *setup_file_hash,
+                               boolean ignore_defaults)
+{
+  int i;
+
+  for (i = 0; sound_config_vars[i].token != NULL; i++)
+  {
+    char *value = getHashEntry(setup_file_hash, sound_config_vars[i].token);
+
+    // (ignore definitions set to "[DEFAULT]" which are already initialized)
+    if (ignore_defaults && strEqual(value, ARG_DEFAULT))
+      continue;
+
+    if (value != NULL)
+      *sound_config_vars[i].value =
+       get_token_parameter_value(sound_config_vars[i].token, value);
+  }
+}
+
+void InitSoundSettings_Static(void)
+{
+  // always start with reliable default values from static default config
+  InitSoundSettings_FromHash(sound_config_hash, FALSE);
+}
+
+static void LoadSoundSettingsFromFilename(char *filename)
+{
+  SetupFileHash *setup_file_hash;
+
+  if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
+    return;
+
+  // read (and overwrite with) values that may be specified in config file
+  InitSoundSettings_FromHash(setup_file_hash, TRUE);
+
+  freeSetupFileHash(setup_file_hash);
+}
+
+void LoadSoundSettings(void)
+{
+  char *filename_base = UNDEFINED_FILENAME, *filename_local;
+
+  InitSoundSettings_Static();
+
+  if (!GFX_OVERRIDE_ARTWORK(ARTWORK_TYPE_SOUNDS))
+  {
+    // first look for special settings configured in level series config
+    filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_SOUNDS);
+
+    if (fileExists(filename_base))
+      LoadSoundSettingsFromFilename(filename_base);
+  }
+
+  filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_SOUNDS);
+
+  if (filename_local != NULL && !strEqual(filename_base, filename_local))
+    LoadSoundSettingsFromFilename(filename_local);
+}
+
 void LoadUserDefinedEditorElementList(int **elements, int *num_elements)
 {
   char *filename = getEditorSetupFilename();