Plugin.cs 2.5 KB

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