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.

80 lines
1.8 KiB

  1. using IPA;
  2. using UnityEngine.SceneManagement;
  3. using IPALogger = IPA.Logging.Logger;
  4. using BSIPA_ModList.UI;
  5. using UnityEngine;
  6. using IPA.Logging;
  7. using BSIPA_ModList.UI.ViewControllers;
  8. using System.Collections;
  9. using IPA.Loader;
  10. namespace BSIPA_ModList
  11. {
  12. internal static class Logger
  13. {
  14. internal static IPALogger log { get; set; }
  15. internal static IPALogger md => log.GetChildLogger("MarkDown");
  16. }
  17. public class Plugin : IBeatSaberPlugin
  18. {
  19. public void Init(IPALogger logger)
  20. {
  21. Logger.log = logger;
  22. IPA.Updating.BeatMods.Updater.ModListPresent = true;
  23. }
  24. public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
  25. {
  26. }
  27. public void OnApplicationQuit()
  28. {
  29. }
  30. public void OnApplicationStart()
  31. {
  32. // Load resources ahead of time
  33. MarkdownView.StartLoadResourcesAsync();
  34. SharedCoroutineStarter.instance.StartCoroutine(LoadPluginIcons());
  35. }
  36. private static IEnumerator LoadPluginIcons()
  37. {
  38. foreach (var p in PluginManager.AllPlugins)
  39. {
  40. yield return null;
  41. Logger.log.Debug($"Loading icon for {p.Metadata.Name}");
  42. var _ = p.Metadata.GetIcon();
  43. }
  44. }
  45. public void OnFixedUpdate()
  46. {
  47. }
  48. public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
  49. {
  50. if (scene.name == "MenuCore")
  51. {
  52. FloatingNotification.Create();
  53. if (ButtonUI.Instance == null)
  54. new GameObject("BSIPA Mod List Object").AddComponent<ButtonUI>().Init();
  55. }
  56. }
  57. public void OnSceneUnloaded(Scene scene)
  58. {
  59. }
  60. public void OnUpdate()
  61. {
  62. }
  63. }
  64. }