From 4797a3f046a9a5b730211c6d53e7bcbf52d4c028 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 19 May 2019 03:26:00 -0500 Subject: [PATCH] Added better support for enabling and disabling mods --- BSIPA-ModList/Plugin.cs | 2 - BSIPA-ModList/Properties/AssemblyInfo.cs | 4 +- BSIPA-ModList/UI/ModListFlowCoordinator.cs | 31 ++++- .../DownloadProgressViewController.cs | 13 +- BSIPA-ModList/UI/ViewControllers/ModCells.cs | 81 +++++++++++- .../ViewControllers/ModInfoViewController.cs | 95 ++++++++++--- .../UI/ViewControllers/ModListController.cs | 12 ++ BSIPA-ModList/manifest.json | 2 +- IPA.Loader/Loader/PluginLoader.cs | 19 ++- IPA.Loader/Loader/PluginManager.cs | 125 ++++++++++++++++-- IPA.Loader/Updating/BeatMods/Updater.cs | 7 +- Refs/Unity.TextMeshPro.dll | Bin 84480 -> 84480 bytes 12 files changed, 344 insertions(+), 47 deletions(-) diff --git a/BSIPA-ModList/Plugin.cs b/BSIPA-ModList/Plugin.cs index 08a555ab..aaa3a2cd 100644 --- a/BSIPA-ModList/Plugin.cs +++ b/BSIPA-ModList/Plugin.cs @@ -24,8 +24,6 @@ namespace BSIPA_ModList Logger.log = logger; IPA.Updating.BeatMods.Updater.ModListPresent = true; - - } public void OnActiveSceneChanged(Scene prevScene, Scene nextScene) diff --git a/BSIPA-ModList/Properties/AssemblyInfo.cs b/BSIPA-ModList/Properties/AssemblyInfo.cs index e9517ee8..ae2c363c 100644 --- a/BSIPA-ModList/Properties/AssemblyInfo.cs +++ b/BSIPA-ModList/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.2.2.0")] +[assembly: AssemblyFileVersion("1.2.2.0")] diff --git a/BSIPA-ModList/UI/ModListFlowCoordinator.cs b/BSIPA-ModList/UI/ModListFlowCoordinator.cs index 5459173b..5252ca07 100644 --- a/BSIPA-ModList/UI/ModListFlowCoordinator.cs +++ b/BSIPA-ModList/UI/ModListFlowCoordinator.cs @@ -3,9 +3,12 @@ using CustomUI.BeatSaber; using CustomUI.Utilities; using IPA.Loader; using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEngine; +using UnityEngine.Events; +using UnityEngine.SceneManagement; using VRUI; namespace BSIPA_ModList.UI @@ -100,6 +103,8 @@ namespace BSIPA_ModList.UI PopViewControllerFromNavigationController(navigationController, callback, immediate); } + internal HashSet exitActions = new HashSet(); + private delegate void DismissFlowDel(FlowCoordinator self, FlowCoordinator newF, Action finished, bool immediate); private static DismissFlowDel dismissFlow; @@ -112,8 +117,30 @@ namespace BSIPA_ModList.UI dismissFlow = (DismissFlowDel)Delegate.CreateDelegate(typeof(DismissFlowDel), m); } - MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll().First(); - dismissFlow(mainFlow, this, null, false); + if (exitActions.Count == 0) + { + MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll().First(); + dismissFlow(mainFlow, this, null, false); + } + else + { + var actions = exitActions; + UnityAction releaseAction = null; + releaseAction = (a, b) => SceneManager_sceneLoaded(actions, releaseAction, a, b); + SceneManager.sceneLoaded += releaseAction; + Resources.FindObjectsOfTypeAll().First().RestartGame(true); + } + } + + private static void SceneManager_sceneLoaded(HashSet actions, UnityAction self, Scene arg0, LoadSceneMode arg1) + { + if (arg0.name == "Init") + { + SceneManager.sceneLoaded -= self; + + foreach (var act in actions) + act(); + } } } } diff --git a/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs b/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs index e7c35e12..b3329d41 100644 --- a/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs +++ b/BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs @@ -18,6 +18,7 @@ namespace BSIPA_ModList.UI.ViewControllers internal class DownloadProgressViewController : VRUIViewController, TableView.IDataSource { private TextMeshProUGUI _titleText; + private TextMeshProUGUI _manualDownloadText; private Button _checkForUpdates; private Button _downloadUpdates; @@ -44,6 +45,11 @@ namespace BSIPA_ModList.UI.ViewControllers _titleText.alignment = TextAlignmentOptions.Top; _titleText.fontSize = 6f; + _manualDownloadText = BeatSaberUI.CreateText(rectTransform, "Manual Restart Required", new Vector2(37f, -3f)); + _manualDownloadText.alignment = TextAlignmentOptions.Top; + _manualDownloadText.fontSize = 4f; + _manualDownloadText.gameObject.SetActive(false); + _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll