From 002f075e004edf7d6533cfdccc255e5901e79f9e Mon Sep 17 00:00:00 2001 From: TriumphantBass <32756996+TriumphantBass@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:37:36 -0700 Subject: [PATCH 1/5] Add individual settings menu resets --- TsRandomizer/Screens/GameSettingsScreen.cs | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/TsRandomizer/Screens/GameSettingsScreen.cs b/TsRandomizer/Screens/GameSettingsScreen.cs index 365dfb69..d318f580 100644 --- a/TsRandomizer/Screens/GameSettingsScreen.cs +++ b/TsRandomizer/Screens/GameSettingsScreen.cs @@ -87,9 +87,9 @@ void Noop() return (GameScreen)Activator.CreateInstance(JournalMenuType, GameSave.DemoSave, gcm, (Action)Noop); } - object CreateDefaultsMenu() + object CreateDefaultsMenu(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) { - var defaultsMenu = MenuEntry.Create("Defaults", OnDefaultsSelected).AsTimeSpinnerMenuEntry(); + var defaultsMenu = MenuEntry.Create("Defaults", () => OnDefaultsSelected(menusToClear, isSubmenu)).AsTimeSpinnerMenuEntry(); defaultsMenu.AsDynamic().Description = "Restore all values to their defaults"; defaultsMenu.AsDynamic().IsCenterAligned = false; @@ -97,8 +97,23 @@ object CreateDefaultsMenu() return defaultsMenu; } - void OnDefaultsSelected() + void OnDefaultsSelected(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) { + if (isSubmenu) + { + foreach (var category in menusToClear) + { + foreach (var settingsFunc in category.SettingsPerCategory) + { + var setting = settingsFunc(settings); + setting.SetDefault(); + } + } + ResetMenu(); + Dynamic.GoToPreviousMenuCollection(); + return; + } + // Clear the root menu if (!IsInGame) { var defaultSettings = new SettingCollection(); @@ -109,7 +124,7 @@ void OnDefaultsSelected() } else { - foreach (var category in SettingCollection.Categories) + foreach (var category in menusToClear) { foreach (var settingsFunc in category.SettingsPerCategory) { @@ -144,7 +159,7 @@ void ResetMenu() menuEntryList.Add(submenu.AsTimeSpinnerMenuEntry()); } - menuEntryList.Add(CreateDefaultsMenu()); + menuEntryList.Add(CreateDefaultsMenu(SettingCollection.Categories, false)); ((object)Dynamic._primaryMenuCollection).AsDynamic()._entries = menuEntryList; ((object)Dynamic._selectedMenuCollection).AsDynamic().SetSelectedIndex(0); @@ -173,8 +188,7 @@ void CreateMenuForCategory(GameSettingCategoryInfo category) foreach (var settingFunc in category.SettingsPerCategory) submenu.Add(CreateMenuForSetting(settingFunc(settings)).AsTimeSpinnerMenuEntry()); - // Exclude submenu defaults for now, enable when they don't wipe the current view - // submenu.Add(CreateDefaultsMenu(category.Settings)); + submenu.Add(CreateDefaultsMenu(new GameSettingCategoryInfo[] { category }, true)); Dynamic.ChangeMenuCollection(collection, true); ((object)Dynamic._selectedMenuCollection).AsDynamic().SetSelectedIndex(0); From 2fcef08c004a0a4eeed0fcd3c545a927836da9be Mon Sep 17 00:00:00 2001 From: TriumphantBass <32756996+TriumphantBass@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:49:34 -0700 Subject: [PATCH 2/5] Fix AP menu display overflow --- TsRandomizer/Screens/GameSettingsScreen.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TsRandomizer/Screens/GameSettingsScreen.cs b/TsRandomizer/Screens/GameSettingsScreen.cs index d318f580..d9334989 100644 --- a/TsRandomizer/Screens/GameSettingsScreen.cs +++ b/TsRandomizer/Screens/GameSettingsScreen.cs @@ -203,6 +203,9 @@ object FetchCollection(string submenu) { // Currently using quest layout for most, other layouts may be useful for other menus // Leaving as switch to easily add new menus as Memories, Letters, Files, Quests, Bestiary, Feats + case "Archipelago": + collection = Dynamic._bestiaryInventory; + break; case "Sprite": collection = Dynamic._featsInventory; break; From 0db1e1b546cf150bf0740a219140fe56c2e4ec20 Mon Sep 17 00:00:00 2001 From: TriumphantBass <32756996+TriumphantBass@users.noreply.github.com> Date: Mon, 6 Jun 2022 08:17:42 -0700 Subject: [PATCH 3/5] Adjust default menu text --- TsRandomizer/Screens/GameSettingsScreen.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TsRandomizer/Screens/GameSettingsScreen.cs b/TsRandomizer/Screens/GameSettingsScreen.cs index d9334989..57268d89 100644 --- a/TsRandomizer/Screens/GameSettingsScreen.cs +++ b/TsRandomizer/Screens/GameSettingsScreen.cs @@ -91,7 +91,8 @@ object CreateDefaultsMenu(GameSettingCategoryInfo[] menusToClear, bool isSubmenu { var defaultsMenu = MenuEntry.Create("Defaults", () => OnDefaultsSelected(menusToClear, isSubmenu)).AsTimeSpinnerMenuEntry(); - defaultsMenu.AsDynamic().Description = "Restore all values to their defaults"; + string menuDescription = isSubmenu ? menusToClear[0].Name : "all"; + defaultsMenu.AsDynamic().Description = $"Restore {menuDescription} settings to their defaults"; defaultsMenu.AsDynamic().IsCenterAligned = false; return defaultsMenu; From b28c12d67f58cd20ac47210a7293a1804113a3b4 Mon Sep 17 00:00:00 2001 From: TriumphantBass <32756996+TriumphantBass@users.noreply.github.com> Date: Mon, 6 Jun 2022 21:34:27 -0700 Subject: [PATCH 4/5] Add in-game safety for submenu --- TsRandomizer/Screens/GameSettingsScreen.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TsRandomizer/Screens/GameSettingsScreen.cs b/TsRandomizer/Screens/GameSettingsScreen.cs index 57268d89..d7a00070 100644 --- a/TsRandomizer/Screens/GameSettingsScreen.cs +++ b/TsRandomizer/Screens/GameSettingsScreen.cs @@ -107,6 +107,8 @@ void OnDefaultsSelected(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) foreach (var settingsFunc in category.SettingsPerCategory) { var setting = settingsFunc(settings); + if (IsInGame && !setting.CanBeChangedInGame) + continue; setting.SetDefault(); } } From e6a3a1da52f8b7c24ddfc4f42662155d0336d3bf Mon Sep 17 00:00:00 2001 From: TriumphantBass <32756996+TriumphantBass@users.noreply.github.com> Date: Mon, 6 Jun 2022 21:46:23 -0700 Subject: [PATCH 5/5] Reduce redundancy in defaults menu --- TsRandomizer/Screens/GameSettingsScreen.cs | 33 ++++++---------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/TsRandomizer/Screens/GameSettingsScreen.cs b/TsRandomizer/Screens/GameSettingsScreen.cs index d7a00070..167f4894 100644 --- a/TsRandomizer/Screens/GameSettingsScreen.cs +++ b/TsRandomizer/Screens/GameSettingsScreen.cs @@ -100,30 +100,10 @@ object CreateDefaultsMenu(GameSettingCategoryInfo[] menusToClear, bool isSubmenu void OnDefaultsSelected(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) { - if (isSubmenu) - { - foreach (var category in menusToClear) - { - foreach (var settingsFunc in category.SettingsPerCategory) - { - var setting = settingsFunc(settings); - if (IsInGame && !setting.CanBeChangedInGame) - continue; - setting.SetDefault(); - } - } - ResetMenu(); - Dynamic.GoToPreviousMenuCollection(); - return; - } // Clear the root menu - if (!IsInGame) + if (!IsInGame && !isSubmenu) { - var defaultSettings = new SettingCollection(); - - GameSettingsLoader.WriteSettingsToFile(defaultSettings); - - settings = defaultSettings; + settings = new SettingCollection(); } else { @@ -133,17 +113,22 @@ void OnDefaultsSelected(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) { var setting = settingsFunc(settings); - if(!setting.CanBeChangedInGame) + if(IsInGame && !setting.CanBeChangedInGame) continue; setting.SetDefault(); } } + } + if (IsInGame) save.SetSettings(settings); - } + else + GameSettingsLoader.WriteSettingsToFile(settings); ResetMenu(); + if (isSubmenu) + Dynamic.GoToPreviousMenuCollection(); } void ResetMenu()