Plugin.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using UnityEngine.SceneManagement;
  2. using SongBrowser.UI;
  3. using Logger = SongBrowser.Logging.Logger;
  4. using SongBrowser.DataAccess;
  5. using System.Collections.Generic;
  6. using SongBrowser.Internals;
  7. using System;
  8. using IPA;
  9. namespace SongBrowser
  10. {
  11. public class Plugin : IBeatSaberPlugin
  12. {
  13. public const string VERSION_NUMBER = "5.5.0";
  14. public static Plugin Instance;
  15. public static IPA.Logging.Logger Log;
  16. public void Init(object nullObject, IPA.Logging.Logger logger)
  17. {
  18. Log = logger;
  19. }
  20. public void OnApplicationStart()
  21. {
  22. Instance = this;
  23. PluginConfig.LoadOrCreateConfig();
  24. Base64Sprites.Init();
  25. PlaylistsCollection.ReloadPlaylists();
  26. SongCore.Loader.SongsLoadedEvent += SongCore_SongsLoadedEvent;
  27. BSEvents.OnLoad();
  28. BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh;
  29. }
  30. public void OnApplicationQuit()
  31. {
  32. }
  33. private void OnMenuSceneLoadedFresh()
  34. {
  35. try
  36. {
  37. SongBrowserApplication.OnLoad();
  38. }
  39. catch (Exception e)
  40. {
  41. Logger.Exception("Exception on fresh menu scene change: " + e);
  42. }
  43. }
  44. public void SongCore_SongsLoadedEvent(SongCore.Loader sender, Dictionary<string, CustomPreviewBeatmapLevel> levels)
  45. {
  46. try
  47. {
  48. PlaylistsCollection.MatchSongsForAllPlaylists(true);
  49. }
  50. catch (Exception e)
  51. {
  52. Logger.Exception("Unable to match songs for all playlists! Exception: " + e);
  53. }
  54. }
  55. public void OnUpdate()
  56. {
  57. }
  58. public void OnFixedUpdate()
  59. {
  60. }
  61. public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
  62. {
  63. }
  64. public void OnSceneUnloaded(Scene scene)
  65. {
  66. }
  67. public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
  68. {
  69. }
  70. }
  71. }