Plugin.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using UnityEngine.SceneManagement;
  2. using IllusionPlugin;
  3. using SongBrowser.UI;
  4. using Logger = SongBrowser.Logging.Logger;
  5. using SongBrowser.DataAccess;
  6. using System.Collections.Generic;
  7. using SongBrowser.Internals;
  8. using System;
  9. namespace SongBrowser
  10. {
  11. public class Plugin : IPlugin
  12. {
  13. public const string VERSION_NUMBER = "5.2.1";
  14. public static Plugin Instance;
  15. public string Name
  16. {
  17. get { return "Song Browser"; }
  18. }
  19. public string Version
  20. {
  21. get { return VERSION_NUMBER; }
  22. }
  23. public void OnApplicationStart()
  24. {
  25. Instance = this;
  26. SceneManager.sceneLoaded += SceneManager_sceneLoaded;
  27. SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
  28. PluginConfig.LoadOrCreateConfig();
  29. Base64Sprites.Init();
  30. PlaylistsCollection.ReloadPlaylists();
  31. SongCore.Loader.SongsLoadedEvent += SongCore_SongsLoadedEvent;
  32. BSEvents.OnLoad();
  33. BSEvents.menuSceneLoadedFresh += OnMenuSceneLoadedFresh;
  34. }
  35. public void OnApplicationQuit()
  36. {
  37. }
  38. private void OnMenuSceneLoadedFresh()
  39. {
  40. try
  41. {
  42. SongBrowserApplication.OnLoad();
  43. }
  44. catch (Exception e)
  45. {
  46. Logger.Exception("Exception on fresh menu scene change: " + e);
  47. }
  48. }
  49. public void SongCore_SongsLoadedEvent(SongCore.Loader sender, Dictionary<string, CustomPreviewBeatmapLevel> levels)
  50. {
  51. try
  52. {
  53. PlaylistsCollection.MatchSongsForAllPlaylists(true);
  54. }
  55. catch (Exception e)
  56. {
  57. Logger.Exception("Unable to match songs for all playlists! Exception: " + e);
  58. }
  59. }
  60. private void SceneManager_activeSceneChanged(Scene from, Scene to)
  61. {
  62. Logger.Debug($"Active scene changed from \"{from.name}\" to \"{to.name}\"");
  63. }
  64. private void SceneManager_sceneLoaded(Scene to, LoadSceneMode loadMode)
  65. {
  66. Logger.Debug($"Loaded scene \"{to.name}\"");
  67. }
  68. public void OnLevelWasLoaded(int level)
  69. {
  70. }
  71. public void OnLevelWasInitialized(int level)
  72. {
  73. }
  74. public void OnUpdate()
  75. {
  76. }
  77. public void OnFixedUpdate()
  78. {
  79. }
  80. }
  81. }