Sfoglia il codice sorgente

misc: Forgot about ReactiveObject

Evan Husted 1 anno fa
parent
commit
cbd851d00e

+ 2 - 2
src/Ryujinx.Common/Extensions/StreamExtensions.cs

@@ -8,10 +8,10 @@ namespace Ryujinx.Common
     public static class StreamExtensions
     public static class StreamExtensions
     {
     {
         /// <summary>
         /// <summary>
-        /// Writes a <see cref="ReadOnlySpan{int}" /> to this stream.
+        /// Writes an int span to this stream.
         ///
         ///
         /// This default implementation converts each buffer value to a stack-allocated
         /// This default implementation converts each buffer value to a stack-allocated
-        /// byte array, then writes it to the Stream using <cref="System.Stream.Write(byte[])" />.
+        /// byte array, then writes it to the Stream using <see cref="Stream.Write(ReadOnlySpan{byte})" />.
         /// </summary>
         /// </summary>
         /// <param name="stream">The stream to be written to</param>
         /// <param name="stream">The stream to be written to</param>
         /// <param name="buffer">The buffer of values to be written</param>
         /// <param name="buffer">The buffer of values to be written</param>

+ 1 - 14
src/Ryujinx.Common/TitleIDs.cs

@@ -8,20 +8,7 @@ namespace Ryujinx.Common
 {
 {
     public static class TitleIDs
     public static class TitleIDs
     {
     {
-        private static string _currentApplication;
-
-        public static Optional<string> CurrentApplication
-        {
-            get => _currentApplication;
-            set
-            {
-                _currentApplication = value.OrElse(null);
-                
-                CurrentApplicationChanged?.Invoke(_currentApplication);
-            }
-        }
-
-        public static event Action<Optional<string>> CurrentApplicationChanged;
+        public static ReactiveObject<Optional<string>> CurrentApplication { get; set; } = new();
         
         
         public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend)
         public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend)
         {
         {

+ 1 - 1
src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs

@@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
                 using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
                 using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
                 Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
                 Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
                 
                 
-                if (context.Device.DirtyHacks.HasFlag(DirtyHacks.Xc2MenuSoftlockFix) && TitleIDs.CurrentApplication == Xc2TitleId)
+                if (context.Device.DirtyHacks.HasFlag(DirtyHacks.Xc2MenuSoftlockFix) && TitleIDs.CurrentApplication.Value == Xc2TitleId)
                 {
                 {
                     // Add a load-bearing sleep to avoid XC2 softlock
                     // Add a load-bearing sleep to avoid XC2 softlock
                     // https://web.archive.org/web/20240728045136/https://github.com/Ryujinx/Ryujinx/issues/2357
                     // https://web.archive.org/web/20240728045136/https://github.com/Ryujinx/Ryujinx/issues/2357

+ 7 - 7
src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs

@@ -61,7 +61,7 @@ namespace Ryujinx.HLE.Loaders.Processes
                 {
                 {
                     _latestPid = processResult.ProcessId;
                     _latestPid = processResult.ProcessId;
 
 
-                    TitleIDs.CurrentApplication = processResult.ProgramIdText;
+                    TitleIDs.CurrentApplication.Value = processResult.ProgramIdText;
 
 
                     return true;
                     return true;
                 }
                 }
@@ -90,7 +90,7 @@ namespace Ryujinx.HLE.Loaders.Processes
                 {
                 {
                     _latestPid = processResult.ProcessId;
                     _latestPid = processResult.ProcessId;
 
 
-                    TitleIDs.CurrentApplication = processResult.ProgramIdText;
+                    TitleIDs.CurrentApplication.Value = processResult.ProgramIdText;
 
 
                     return true;
                     return true;
                 }
                 }
@@ -120,7 +120,7 @@ namespace Ryujinx.HLE.Loaders.Processes
                     {
                     {
                         _latestPid = processResult.ProcessId;
                         _latestPid = processResult.ProcessId;
 
 
-                        TitleIDs.CurrentApplication = processResult.ProgramIdText;
+                        TitleIDs.CurrentApplication.Value = processResult.ProgramIdText;
                     }
                     }
 
 
                     return true;
                     return true;
@@ -140,7 +140,7 @@ namespace Ryujinx.HLE.Loaders.Processes
                 {
                 {
                     _latestPid = processResult.ProcessId;
                     _latestPid = processResult.ProcessId;
 
 
-                    TitleIDs.CurrentApplication = processResult.ProgramIdText;
+                    TitleIDs.CurrentApplication.Value = processResult.ProgramIdText;
 
 
                     return true;
                     return true;
                 }
                 }
@@ -193,17 +193,17 @@ namespace Ryujinx.HLE.Loaders.Processes
                     if (nacpData.Value.PresenceGroupId != 0)
                     if (nacpData.Value.PresenceGroupId != 0)
                     {
                     {
                         programId = nacpData.Value.PresenceGroupId;
                         programId = nacpData.Value.PresenceGroupId;
-                        TitleIDs.CurrentApplication = programId.ToString("X16");
+                        TitleIDs.CurrentApplication.Value = programId.ToString("X16");
                     }
                     }
                     else if (nacpData.Value.SaveDataOwnerId != 0)
                     else if (nacpData.Value.SaveDataOwnerId != 0)
                     {
                     {
                         programId = nacpData.Value.SaveDataOwnerId;
                         programId = nacpData.Value.SaveDataOwnerId;
-                        TitleIDs.CurrentApplication = programId.ToString("X16");
+                        TitleIDs.CurrentApplication.Value = programId.ToString("X16");
                     }
                     }
                     else if (nacpData.Value.AddOnContentBaseId != 0)
                     else if (nacpData.Value.AddOnContentBaseId != 0)
                     {
                     {
                         programId = nacpData.Value.AddOnContentBaseId - 0x1000;
                         programId = nacpData.Value.AddOnContentBaseId - 0x1000;
-                        TitleIDs.CurrentApplication = programId.ToString("X16");
+                        TitleIDs.CurrentApplication.Value = programId.ToString("X16");
                     }
                     }
                 }
                 }
 
 

+ 1 - 1
src/Ryujinx.HLE/Switch.cs

@@ -151,7 +151,7 @@ namespace Ryujinx.HLE
                 FileSystem.Dispose();
                 FileSystem.Dispose();
                 Memory.Dispose();
                 Memory.Dispose();
 
 
-                TitleIDs.CurrentApplication = null;
+                TitleIDs.CurrentApplication.Value = null;
                 Shared = null;
                 Shared = null;
             }
             }
         }
         }

+ 4 - 4
src/Ryujinx.UI.Common/DiscordIntegrationModule.cs

@@ -45,13 +45,13 @@ namespace Ryujinx.UI.Common
             };
             };
 
 
             ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
             ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
-            TitleIDs.CurrentApplicationChanged += titleId =>
+            TitleIDs.CurrentApplication.Event += (_, e) =>
             {
             {
-                if (titleId)
+                if (e.NewValue)
                     SwitchToPlayingState(
                     SwitchToPlayingState(
-                        ApplicationLibrary.LoadAndSaveMetaData(titleId),
+                        ApplicationLibrary.LoadAndSaveMetaData(e.NewValue),
                         Switch.Shared.Processes.ActiveApplication
                         Switch.Shared.Processes.ActiveApplication
-                        );
+                    );
                 else 
                 else 
                     SwitchToMainState();
                     SwitchToMainState();
             };
             };