ソースを参照

misc: More minor style changes.

Evan Husted 1 年間 前
コミット
5b6e3521d8

+ 2 - 2
src/Ryujinx.Common/Logging/Logger.cs

@@ -24,7 +24,7 @@ namespace Ryujinx.Common.Logging
         public readonly struct Log
         public readonly struct Log
         {
         {
             private static readonly string _homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
             private static readonly string _homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
-            private static readonly string _homeDirRedacted = Path.Combine(Directory.GetParent(_homeDir).FullName, "[redacted]");
+            private static readonly string _homeDirRedacted = Path.Combine(Directory.GetParent(_homeDir)!.FullName, "[redacted]");
 
 
             internal readonly LogLevel Level;
             internal readonly LogLevel Level;
 
 
@@ -233,7 +233,7 @@ namespace Ryujinx.Common.Logging
                 case LogLevel.AccessLog : AccessLog = enabled ? new Log(LogLevel.AccessLog) : new Log?(); break;
                 case LogLevel.AccessLog : AccessLog = enabled ? new Log(LogLevel.AccessLog) : new Log?(); break;
                 case LogLevel.Stub      : Stub      = enabled ? new Log(LogLevel.Stub)      : new Log?(); break;
                 case LogLevel.Stub      : Stub      = enabled ? new Log(LogLevel.Stub)      : new Log?(); break;
                 case LogLevel.Trace     : Trace     = enabled ? new Log(LogLevel.Trace)     : new Log?(); break;
                 case LogLevel.Trace     : Trace     = enabled ? new Log(LogLevel.Trace)     : new Log?(); break;
-                default: throw new ArgumentException("Unknown Log Level");
+                default: throw new ArgumentException("Unknown Log Level", nameof(logLevel));
 #pragma warning restore IDE0055
 #pragma warning restore IDE0055
             }
             }
         }
         }

+ 1 - 1
src/Ryujinx/App.axaml.cs

@@ -112,7 +112,7 @@ namespace Ryujinx.Ava
             }
             }
             catch (Exception)
             catch (Exception)
             {
             {
-                Logger.Warning?.Print(LogClass.Application, "Failed to Apply Theme. A restart is needed to apply the selected theme");
+                Logger.Warning?.Print(LogClass.Application, "Failed to apply theme. A restart is needed to apply the selected theme.");
 
 
                 ShowRestartDialog();
                 ShowRestartDialog();
             }
             }

+ 7 - 17
src/Ryujinx/Common/Locale/LocaleManager.cs

@@ -57,40 +57,32 @@ namespace Ryujinx.Ava.Common.Locale
                 {
                 {
                     // Check if the localized string needs to be formatted.
                     // Check if the localized string needs to be formatted.
                     if (_dynamicValues.TryGetValue(key, out var dynamicValue))
                     if (_dynamicValues.TryGetValue(key, out var dynamicValue))
-                    {
                         try
                         try
                         {
                         {
                             return string.Format(value, dynamicValue);
                             return string.Format(value, dynamicValue);
                         }
                         }
-                        catch (Exception)
+                        catch
                         {
                         {
                             // If formatting failed use the default text instead.
                             // If formatting failed use the default text instead.
                             if (_localeDefaultStrings.TryGetValue(key, out value))
                             if (_localeDefaultStrings.TryGetValue(key, out value))
-                            {
                                 try
                                 try
                                 {
                                 {
                                     return string.Format(value, dynamicValue);
                                     return string.Format(value, dynamicValue);
                                 }
                                 }
-                                catch (Exception)
+                                catch
                                 {
                                 {
                                     // If formatting the default text failed return the key.
                                     // If formatting the default text failed return the key.
                                     return key.ToString();
                                     return key.ToString();
                                 }
                                 }
-                            }
                         }
                         }
-                    }
 
 
                     return value;
                     return value;
                 }
                 }
 
 
                 // If the locale doesn't contain the key return the default one.
                 // If the locale doesn't contain the key return the default one.
-                if (_localeDefaultStrings.TryGetValue(key, out string defaultValue))
-                {
-                    return defaultValue;
-                }
-
-                // If the locale text doesn't exist return the key.
-                return key.ToString();
+                return _localeDefaultStrings.TryGetValue(key, out string defaultValue) 
+                    ? defaultValue 
+                    : key.ToString(); // If the locale text doesn't exist return the key.
             }
             }
             set
             set
             {
             {
@@ -100,14 +92,12 @@ namespace Ryujinx.Ava.Common.Locale
             }
             }
         }
         }
 
 
-        public bool IsRTL()
-        {
-            return _localeLanguageCode switch
+        public bool IsRTL() =>
+            _localeLanguageCode switch
             {
             {
                 "ar_SA" or "he_IL" => true,
                 "ar_SA" or "he_IL" => true,
                 _ => false
                 _ => false
             };
             };
-        }
 
 
         public string UpdateAndGetDynamicValue(LocaleKeys key, params object[] values)
         public string UpdateAndGetDynamicValue(LocaleKeys key, params object[] values)
         {
         {

+ 10 - 18
src/Ryujinx/Program.cs

@@ -182,41 +182,33 @@ namespace Ryujinx.Ava
             UseHardwareAcceleration = ConfigurationState.Instance.EnableHardwareAcceleration.Value;
             UseHardwareAcceleration = ConfigurationState.Instance.EnableHardwareAcceleration.Value;
 
 
             // Check if graphics backend was overridden
             // Check if graphics backend was overridden
-            if (CommandLineState.OverrideGraphicsBackend != null)
-            {
-                if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl")
-                {
-                    ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
-                }
-                else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
+            if (CommandLineState.OverrideGraphicsBackend is not null)
+                ConfigurationState.Instance.Graphics.GraphicsBackend.Value = CommandLineState.OverrideGraphicsBackend.ToLower() switch
                 {
                 {
-                    ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
-                }
-            }
+                    "opengl" => GraphicsBackend.OpenGl,
+                    "vulkan" => GraphicsBackend.Vulkan,
+                    _ => ConfigurationState.Instance.Graphics.GraphicsBackend
+                };
 
 
             // Check if docked mode was overriden.
             // Check if docked mode was overriden.
             if (CommandLineState.OverrideDockedMode.HasValue)
             if (CommandLineState.OverrideDockedMode.HasValue)
-            {
                 ConfigurationState.Instance.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
                 ConfigurationState.Instance.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
-            }
+            
 
 
             // Check if HideCursor was overridden.
             // Check if HideCursor was overridden.
             if (CommandLineState.OverrideHideCursor is not null)
             if (CommandLineState.OverrideHideCursor is not null)
-            {
-                ConfigurationState.Instance.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch
+                ConfigurationState.Instance.HideCursor.Value = CommandLineState.OverrideHideCursor.ToLower() switch
                 {
                 {
                     "never" => HideCursorMode.Never,
                     "never" => HideCursorMode.Never,
                     "onidle" => HideCursorMode.OnIdle,
                     "onidle" => HideCursorMode.OnIdle,
                     "always" => HideCursorMode.Always,
                     "always" => HideCursorMode.Always,
-                    _ => ConfigurationState.Instance.HideCursor.Value,
+                    _ => ConfigurationState.Instance.HideCursor,
                 };
                 };
-            }
+            
 
 
             // Check if hardware-acceleration was overridden.
             // Check if hardware-acceleration was overridden.
             if (CommandLineState.OverrideHardwareAcceleration != null)
             if (CommandLineState.OverrideHardwareAcceleration != null)
-            {
                 UseHardwareAcceleration = CommandLineState.OverrideHardwareAcceleration.Value;
                 UseHardwareAcceleration = CommandLineState.OverrideHardwareAcceleration.Value;
-            }
         }
         }
 
 
         private static void PrintSystemInfo()
         private static void PrintSystemInfo()

+ 13 - 24
src/Ryujinx/UI/Windows/MainWindow.axaml.cs

@@ -443,10 +443,7 @@ namespace Ryujinx.Ava.UI.Windows
 
 
             Initialize();
             Initialize();
 
 
-            /// <summary>
-            /// Subscribe to the ColorValuesChanged event
-            /// </summary>
-            PlatformSettings.ColorValuesChanged += OnPlatformColorValuesChanged;
+            PlatformSettings!.ColorValuesChanged += OnPlatformColorValuesChanged;
 
 
             ViewModel.Initialize(
             ViewModel.Initialize(
                 ContentManager,
                 ContentManager,
@@ -467,7 +464,7 @@ namespace Ryujinx.Ava.UI.Windows
             _appLibraryAppsSubscription?.Dispose();
             _appLibraryAppsSubscription?.Dispose();
             _appLibraryAppsSubscription = ApplicationLibrary.Applications
             _appLibraryAppsSubscription = ApplicationLibrary.Applications
                     .Connect()
                     .Connect()
-                    .ObserveOn(SynchronizationContext.Current)
+                    .ObserveOn(SynchronizationContext.Current!)
                     .Bind(ViewModel.Applications)
                     .Bind(ViewModel.Applications)
                     .Subscribe();
                     .Subscribe();
 
 
@@ -656,28 +653,20 @@ namespace Ryujinx.Ava.UI.Windows
             applicationLibraryThread.Start();
             applicationLibraryThread.Start();
         }
         }
 
 
-        private Task ShowNewContentAddedDialog(int numDlcAdded, int numUpdatesAdded)
+        private void ShowNewContentAddedDialog(int numDlcAdded, int numUpdatesAdded)
         {
         {
-            var msg = "";
+            string msg = numDlcAdded > 0 && numUpdatesAdded > 0
+                ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAndUpdateAddedMessage], numDlcAdded, numUpdatesAdded)
+                : numDlcAdded > 0
+                    ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded)
+                    : numUpdatesAdded > 0
+                        ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded)
+                        : null;
 
 
-            if (numDlcAdded > 0 && numUpdatesAdded > 0)
-            {
-                msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAndUpdateAddedMessage], numDlcAdded, numUpdatesAdded);
-            }
-            else if (numDlcAdded > 0)
-            {
-                msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded);
-            }
-            else if (numUpdatesAdded > 0)
-            {
-                msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded);
-            }
-            else
-            {
-                return Task.CompletedTask;
-            }
+            if (msg is null) return;
+            
 
 
-            return Dispatcher.UIThread.InvokeAsync(async () =>
+            Dispatcher.UIThread.InvokeAsync(async () =>
             {
             {
                 await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
                 await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
                     msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
                     msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);

+ 2 - 2
src/Ryujinx/UI/Windows/StyleableWindow.cs

@@ -17,9 +17,9 @@ namespace Ryujinx.Ava.UI.Windows
         public StyleableWindow()
         public StyleableWindow()
         {
         {
             WindowStartupLocation = WindowStartupLocation.CenterOwner;
             WindowStartupLocation = WindowStartupLocation.CenterOwner;
-            TransparencyLevelHint = new[] { WindowTransparencyLevel.None };
+            TransparencyLevelHint = [WindowTransparencyLevel.None];
 
 
-            using Stream stream = Assembly.GetAssembly(typeof(ConfigurationState)).GetManifestResourceStream("Ryujinx.UI.Common.Resources.Logo_Ryujinx.png");
+            using Stream stream = Assembly.GetAssembly(typeof(ConfigurationState))!.GetManifestResourceStream("Ryujinx.UI.Common.Resources.Logo_Ryujinx.png")!;
 
 
             Icon = new WindowIcon(stream);
             Icon = new WindowIcon(stream);
             stream.Position = 0;
             stream.Position = 0;