diff --git a/BSIPA-ModList/BSIPA-ModList.csproj b/BSIPA-ModList/BSIPA-ModList.csproj index 48171cb8..d42fde39 100644 --- a/BSIPA-ModList/BSIPA-ModList.csproj +++ b/BSIPA-ModList/BSIPA-ModList.csproj @@ -73,6 +73,7 @@ + diff --git a/BSIPA-ModList/DownloadController.cs b/BSIPA-ModList/DownloadController.cs index b9021817..6624debd 100644 --- a/BSIPA-ModList/DownloadController.cs +++ b/BSIPA-ModList/DownloadController.cs @@ -146,11 +146,10 @@ namespace BSIPA_ModList OnDownloaderListChanged?.Invoke(); - if (SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate) - StartDownloads(); - if (downloads.Count == 0) OnAllDownloadsCompleted(); + else if (SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate) + StartDownloads(); } public void StartDownloads() diff --git a/BSIPA-ModList/UI/ModListFlowCoordinator.cs b/BSIPA-ModList/UI/ModListFlowCoordinator.cs index 0dbb8ea5..f3549a82 100644 --- a/BSIPA-ModList/UI/ModListFlowCoordinator.cs +++ b/BSIPA-ModList/UI/ModListFlowCoordinator.cs @@ -15,6 +15,7 @@ namespace BSIPA_ModList.UI private BackButtonNavigationController navigationController; private ModListController modList; private DownloadProgressViewController downloads; + private VRUIViewController settings; #pragma warning disable CS0618 protected override void DidActivate(bool firstActivation, ActivationType activationType) @@ -29,12 +30,14 @@ namespace BSIPA_ModList.UI modList = BeatSaberUI.CreateViewController(); modList.Init(this, PluginManager.AllPlugins, PluginLoader.ignoredPlugins, PluginManager.Plugins); + settings = SettingsViewController.Create(); + downloads = BeatSaberUI.CreateViewController(); PushViewControllerToNavigationController(navigationController, modList); } - ProvideInitialViewControllers(navigationController, rightViewController: downloads); + ProvideInitialViewControllers(navigationController, settings, downloads); } #pragma warning restore diff --git a/BSIPA-ModList/UI/SettingsViewController.cs b/BSIPA-ModList/UI/SettingsViewController.cs new file mode 100644 index 00000000..b48be680 --- /dev/null +++ b/BSIPA-ModList/UI/SettingsViewController.cs @@ -0,0 +1,39 @@ +using CustomUI.Settings; +using IPA.Config; +using VRUI; + +namespace BSIPA_ModList.UI +{ + internal static class SettingsViewController + { + private static SubMenu menu; + private static BoolViewController autoUpdate; + private static BoolViewController autoCheck; + + public static VRUIViewController Create() + { + menu = SettingsUI.CreateSubMenu("ModListSettings", false); + + autoCheck = menu.AddBool("Auto Update Check", "If enabled, automatically checks for updates on game start."); + autoUpdate = menu.AddBool("Auto Update", "If enabled, automatically installs updates after checking for them."); + + autoCheck.applyImmediately = true; + autoCheck.GetValue += () => SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates; + autoCheck.SetValue += val => + { + SelfConfig.SelfConfigRef.Value.Updates.AutoCheckUpdates = val; + SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value); + }; + + autoUpdate.applyImmediately = true; + autoUpdate.GetValue += () => SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate; + autoUpdate.SetValue += val => + { + SelfConfig.SelfConfigRef.Value.Updates.AutoUpdate = val; + SelfConfig.LoaderConfig.Store(SelfConfig.SelfConfigRef.Value); + }; + + return menu.viewController; + } + } +}