@@ -56,9 +56,6 @@ internal static class MajEnv
5656 ".mp4"
5757 } ;
5858
59- public static event Action ? OnApplicationQuit ;
60- public static event Action ? OnSave ;
61-
6259#if UNITY_ANDROID // Android Only (User Agent)
6360 public static string HTTP_USER_AGENT { get ; } = $ "MajdataPlay Android/{ MajInstances . GameVersion . ToString ( ) } ";
6461#elif UNITY_IOS // iOS Only (User Agent)
@@ -149,6 +146,7 @@ static MajEnv()
149146 {
150147 UnityWebRequestFactory . Timeout = TimeSpan . FromMilliseconds ( HTTP_TIMEOUT_MS ) ;
151148 UnityWebRequestFactory . UserAgent = HTTP_USER_AGENT ;
149+ GameManager . OnAppQuit += OnApplicationQuit ;
152150 }
153151
154152 [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . SubsystemRegistration ) ]
@@ -492,7 +490,7 @@ internal static void Init()
492490 MainThread . Name = "MajdataPlay MainThread" ;
493491 }
494492#endif
495- OnSave += SaveConfig ;
493+ GameManager . OnSave += OnSave ;
496494#if UNITY_STANDALONE_WIN
497495 MajDebug . LogInfo ( "[VLC] init" ) ;
498496 if ( VLCLibrary != null )
@@ -522,8 +520,10 @@ static void TryDeleteDirectory(string path)
522520 }
523521 }
524522
525- internal static void OnApplicationQuitRequested ( )
523+ static void OnApplicationQuit ( object ? sender , EventArgs ? e )
526524 {
525+ GameManager . OnAppQuit -= OnApplicationQuit ;
526+ GameManager . OnSave -= OnSave ;
527527 SharedHttpClient . CancelPendingRequests ( ) ;
528528 SharedHttpClient . Dispose ( ) ;
529529#if UNITY_STANDALONE_WIN
@@ -533,40 +533,13 @@ internal static void OnApplicationQuitRequested()
533533 }
534534#endif
535535 _globalCTS . Cancel ( ) ;
536- RequestSave ( ) ;
537- try
538- {
539- if ( OnApplicationQuit is not null )
540- {
541- OnApplicationQuit ( ) ;
542- }
543- }
544- finally
545- {
546536#if UNITY_STANDALONE_WIN
547537 WinHidManager . QuitThisBs ( ) ;
548538#elif UNITY_STANDALONE_OSX
549539 MacHidManager . QuitThisBs ( ) ;
550540#endif
551- }
552541 }
553-
554- internal static void RequestSave ( )
555- {
556- try
557- {
558- if ( OnSave is not null )
559- {
560- OnSave ( ) ;
561- }
562- }
563- catch ( Exception ex )
564- {
565- MajDebug . LogException ( ex ) ;
566- }
567- }
568-
569- static void SaveConfig ( )
542+ static void OnSave ( object ? sender , EventArgs ? e )
570543 {
571544 //var listConfig = RuntimeConfig.List;
572545 //listConfig.SelectedSongIndex = SongStorage.WorkingCollection.Index;
0 commit comments