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.

72 lines
1.9 KiB

  1. using IPA;
  2. using UnityEngine.SceneManagement;
  3. using IPALogger = IPA.Logging.Logger;
  4. using CustomUI.BeatSaber;
  5. using BSIPA_ModList.UI;
  6. using CustomUI.MenuButton;
  7. using UnityEngine.Events;
  8. using UnityEngine;
  9. using System.Linq;
  10. namespace BSIPA_ModList
  11. {
  12. internal static class Logger
  13. {
  14. internal static IPALogger log { get; set; }
  15. }
  16. public class Plugin : IBeatSaberPlugin
  17. {
  18. public void Init(IPALogger logger)
  19. {
  20. Logger.log = logger;
  21. Logger.log.Debug("Init");
  22. }
  23. public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
  24. {
  25. }
  26. public void OnApplicationQuit()
  27. {
  28. }
  29. private MainFlowCoordinator mainFlow;
  30. private ModListFlowCoordinator menuFlow;
  31. private MenuButton button;
  32. public void OnApplicationStart()
  33. {
  34. Logger.log.Debug("Creating Menu");
  35. }
  36. public void OnFixedUpdate()
  37. {
  38. }
  39. public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
  40. {
  41. if (scene.name == "MenuCore")
  42. {
  43. if (mainFlow == null)
  44. mainFlow = Resources.FindObjectsOfTypeAll<MainFlowCoordinator>().First();
  45. if (menuFlow == null)
  46. menuFlow = new GameObject("BSIPA Mod List Flow Coordinator").AddComponent<ModListFlowCoordinator>();
  47. if (button == null)
  48. button = MenuButtonUI.AddButton("Mod List", "Look at installed mods, and control updating", () =>
  49. {
  50. Logger.log.Debug("Presenting own flow controller");
  51. menuFlow.PresentOn(mainFlow);
  52. });
  53. }
  54. }
  55. public void OnSceneUnloaded(Scene scene)
  56. {
  57. }
  58. public void OnUpdate()
  59. {
  60. }
  61. }
  62. }