You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.2 KiB

  1. using CustomUI.BeatSaber;
  2. using CustomUI.Utilities;
  3. using IPA.Loader;
  4. using System;
  5. using System.Linq;
  6. using System.Reflection;
  7. using UnityEngine;
  8. using VRUI;
  9. namespace BSIPA_ModList.UI
  10. {
  11. internal class ModListFlowCoordinator : FlowCoordinator
  12. {
  13. private BackButtonNavigationController navigationController;
  14. private ModListController modList;
  15. #pragma warning disable CS0618
  16. protected override void DidActivate(bool firstActivation, ActivationType activationType)
  17. { // thx Caeden
  18. if (firstActivation && activationType == ActivationType.AddedToHierarchy)
  19. {
  20. title = "Installed Mods";
  21. navigationController = BeatSaberUI.CreateViewController<BackButtonNavigationController>();
  22. navigationController.didFinishEvent += backButton_DidFinish;
  23. modList = BeatSaberUI.CreateViewController<ModListController>();
  24. modList.Init(navigationController, PluginManager.AllPlugins, PluginLoader.ignoredPlugins, PluginManager.Plugins);
  25. PushViewControllerToNavigationController(navigationController, modList);
  26. }
  27. ProvideInitialViewControllers(navigationController);
  28. }
  29. #pragma warning restore
  30. private delegate void PresentFlowCoordDel(FlowCoordinator self, FlowCoordinator newF, Action finished, bool immediate, bool replaceTop);
  31. private static PresentFlowCoordDel presentFlow;
  32. public void PresentOn(FlowCoordinator main, Action finished = null, bool immediate = false, bool replaceTop = false)
  33. {
  34. if (presentFlow == null)
  35. {
  36. var ty = typeof(FlowCoordinator);
  37. var m = ty.GetMethod("PresentFlowCoordinator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
  38. presentFlow = (PresentFlowCoordDel)Delegate.CreateDelegate(typeof(PresentFlowCoordDel), m);
  39. }
  40. presentFlow(main, this, finished, immediate, replaceTop);
  41. }
  42. private void backButton_DidFinish()
  43. {
  44. MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll<MainFlowCoordinator>().First();
  45. mainFlow.InvokeMethod("DismissFlowCoordinator", this, null, false);
  46. }
  47. }
  48. }