added hiding selection list style setup options marked with '.hide'
authorHolger Schemel <info@artsoft.org>
Sat, 21 Apr 2018 00:08:54 +0000 (02:08 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 26 Apr 2018 23:13:53 +0000 (01:13 +0200)
src/files.c
src/files.h
src/screens.c
src/screens.h

index c8cd45eade80078539e0b279bbc61aaadcfb272d..3f456937a028f80f6b1929211d4cc8fa44433541 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "files.h"
 #include "init.h"
+#include "screens.h"
 #include "tools.h"
 #include "tape.h"
 #include "config.h"
@@ -8896,17 +8897,22 @@ static char *getHideSetupToken(void *setup_value)
   return hide_setup_token;
 }
 
-static void setHideSetupEntry(void *setup_value_raw)
+void setHideSetupEntry(void *setup_value)
 {
-  /* !!! DIRTY WORKAROUND; TO BE FIXED AFTER THE MM ENGINE RELEASE !!! */
-  void *setup_value = setup_value_raw - (void *)&si + (void *)&setup;
-
   char *hide_setup_token = getHideSetupToken(setup_value);
 
   if (setup_value != NULL)
     setHashEntry(hide_setup_hash, hide_setup_token, "");
 }
 
+static void setHideSetupEntryRaw(char *token_text, void *setup_value_raw)
+{
+  /* !!! DIRTY WORKAROUND; TO BE FIXED AFTER THE MM ENGINE RELEASE !!! */
+  void *setup_value = setup_value_raw - (void *)&si + (void *)&setup;
+
+  setHideSetupEntry(setup_value);
+}
+
 boolean hideSetupEntry(void *setup_value)
 {
   char *hide_setup_token = getHideSetupToken(setup_value);
@@ -8927,7 +8933,7 @@ static void setSetupInfoFromTokenText(SetupFileHash *setup_file_hash,
 
   /* check if this setup option should be hidden in the setup menu */
   if (token_hide_value != NULL && get_boolean_from_string(token_hide_value))
-    setHideSetupEntry(token_info[token_nr].value);
+    setHideSetupEntryRaw(token_text, token_info[token_nr].value);
 }
 
 static void setSetupInfoFromTokenInfo(SetupFileHash *setup_file_hash,
@@ -9008,6 +9014,8 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash)
   for (i = 0; i < NUM_OPTIONS_SETUP_TOKENS; i++)
     setSetupInfoFromTokenInfo(setup_file_hash, options_setup_tokens, i);
   setup.options = soi;
+
+  setHideRelatedSetupEntries();
 }
 
 static void decodeSetupFileHash_AutoSetup(SetupFileHash *setup_file_hash)
index d9c0e2b6f2d227af060ec8b1f237dcf4b3a9f382..4579f88159dc975aa43e1e874879cd456db87ee1 100644 (file)
@@ -69,6 +69,7 @@ void SaveSetup_EditorCascade();
 
 void SaveSetup_AddGameControllerMapping(char *);
 
+void setHideSetupEntry(void *);
 boolean hideSetupEntry(void *);
 
 void LoadCustomElementDescriptions();
index 972e2109bc2a6edeffbc7552ec394d4989caafa5..dc28e237a19db3810867bf82440545bb782c1c41 100644 (file)
@@ -4974,7 +4974,6 @@ static void execSetupGraphics()
 #endif
 }
 
-#if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
 static void execSetupChooseWindowSize()
 {
   setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
@@ -4995,7 +4994,6 @@ static void execSetupChooseRenderingMode()
 
   DrawSetupScreen();
 }
-#endif
 
 static void execSetupChooseVolumeSimple()
 {
@@ -5512,6 +5510,69 @@ static void execSaveAndExitSetup()
   execExitSetup();
 }
 
+static struct
+{
+  void *value;
+  void *related_value;
+} hide_related_entry_list[] =
+{
+  { &setup.game_frame_delay,           execSetupChooseGameSpeed        },
+  { &setup.game_frame_delay,           &game_speed_text                },
+
+  { &setup.scroll_delay_value,         execSetupChooseScrollDelay      },
+  { &setup.scroll_delay_value,         &scroll_delay_text              },
+
+  { &setup.engine_snapshot_mode,       execSetupChooseSnapshotMode     },
+  { &setup.engine_snapshot_mode,       &snapshot_mode_text             },
+
+  { &setup.window_scaling_percent,     execSetupChooseWindowSize       },
+  { &setup.window_scaling_percent,     &window_size_text               },
+
+  { &setup.window_scaling_quality,     execSetupChooseScalingType      },
+  { &setup.window_scaling_quality,     &scaling_type_text              },
+
+  { &setup.screen_rendering_mode,      execSetupChooseRenderingMode    },
+  { &setup.screen_rendering_mode,      &rendering_mode_text            },
+
+  { &setup.graphics_set,               execSetupChooseGraphics         },
+  { &setup.graphics_set,               &graphics_set_name              },
+
+  { &setup.sounds_set,                 execSetupChooseSounds           },
+  { &setup.sounds_set,                 &sounds_set_name                },
+
+  { &setup.music_set,                  execSetupChooseMusic            },
+  { &setup.music_set,                  &music_set_name                 },
+
+  { &setup.volume_simple,              execSetupChooseVolumeSimple     },
+  { &setup.volume_simple,              &volume_simple_text             },
+
+  { &setup.volume_loops,               execSetupChooseVolumeLoops      },
+  { &setup.volume_loops,               &volume_loops_text              },
+
+  { &setup.volume_music,               execSetupChooseVolumeMusic      },
+  { &setup.volume_music,               &volume_music_text              },
+
+  { &setup.touch.control_type,         execSetupChooseTouchControls    },
+  { &setup.touch.control_type,         &touch_controls_text            },
+
+  { &setup.touch.move_distance,                execSetupChooseMoveDistance     },
+  { &setup.touch.move_distance,                &move_distance_text             },
+
+  { &setup.touch.drop_distance,                execSetupChooseDropDistance     },
+  { &setup.touch.drop_distance,                &drop_distance_text             },
+
+  { NULL,                              NULL                            }
+};
+
+void setHideRelatedSetupEntries()
+{
+  int i;
+
+  for (i = 0; hide_related_entry_list[i].value != NULL; i++)
+    if (hideSetupEntry(hide_related_entry_list[i].value))
+      setHideSetupEntry(hide_related_entry_list[i].related_value);
+}
+
 static struct TokenInfo setup_info_main[] =
 {
   { TYPE_ENTER_MENU,   execSetupGame,          STR_SETUP_GAME          },
index c5e9ea024f9688966172b282f8d2c5371e0e2dbd..7af2a0083bc55a3e1fcc69f8db6590902962afe8 100644 (file)
@@ -39,4 +39,6 @@ void HandleGameActions(void);
 void CreateScreenGadgets();
 void FreeScreenGadgets();
 
+void setHideRelatedSetupEntries();
+
 #endif /* SCREENS_H */