diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs index e211441f..b5361421 100644 --- a/Ryujinx/Config.cs +++ b/Ryujinx/Config.cs @@ -20,7 +20,9 @@ namespace Ryujinx public static void Read() { - IniParser Parser = new IniParser(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Ryujinx.conf")); + var iniFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var iniPath = Path.Combine(iniFolder, "Ryujinx.conf"); + IniParser Parser = new IniParser(iniPath); LoggingEnableInfo = Convert.ToBoolean(Parser.Value("Logging_Enable_Info")); LoggingEnableTrace = Convert.ToBoolean(Parser.Value("Logging_Enable_Trace")); @@ -70,23 +72,24 @@ namespace Ryujinx // https://stackoverflow.com/a/37772571 public class IniParser { - private Dictionary Values; + private readonly Dictionary Values; public IniParser(string Path) { Values = File.ReadLines(Path) - .Where(Line => (!String.IsNullOrWhiteSpace(Line) && !Line.StartsWith("#"))) - .Select(Line => Line.Split(new char[] { '=' }, 2, 0)) + .Where(Line => !string.IsNullOrWhiteSpace(Line) && !Line.StartsWith('#')) + .Select(Line => Line.Split('=', 2)) .ToDictionary(Parts => Parts[0].Trim(), Parts => Parts.Length > 1 ? Parts[1].Trim() : null); } - public string Value(string Name, string Value = null) + /// + /// Gets the setting value for the requested setting . + /// + /// Setting Name + /// Default value of the setting + public string Value(string Name, string defaultValue = null) { - if (Values != null && Values.ContainsKey(Name)) - { - return Values[Name]; - } - return Value; + return Values.TryGetValue(Name, out var value) ? value : defaultValue; } } } diff --git a/Ryujinx/Cpu/Translation/AILOpCodeStore.cs b/Ryujinx/Cpu/Translation/AILOpCodeStore.cs index 34b26fe2..c4ea53ab 100644 --- a/Ryujinx/Cpu/Translation/AILOpCodeStore.cs +++ b/Ryujinx/Cpu/Translation/AILOpCodeStore.cs @@ -10,10 +10,8 @@ namespace ChocolArm64.Translation public AIoType IoType { get; private set; } public ARegisterSize RegisterSize { get; private set; } - - public AILOpCodeStore(int Index, AIoType IoType) : this(Index, IoType, ARegisterSize.Int64) { } - public AILOpCodeStore(int Index, AIoType IoType, ARegisterSize RegisterSize) + public AILOpCodeStore(int Index, AIoType IoType, ARegisterSize RegisterSize = ARegisterSize.Int64) { this.IoType = IoType; this.Index = Index; diff --git a/Ryujinx/Hid/HidController.cs b/Ryujinx/Hid/HidController.cs index 433d7b9b..7dd19841 100644 --- a/Ryujinx/Hid/HidController.cs +++ b/Ryujinx/Hid/HidController.cs @@ -1,7 +1,9 @@ -using System.Runtime.InteropServices; +using System; +using System.Runtime.InteropServices; namespace Ryujinx { + [Flags] public enum HidControllerKeys { KEY_A = (1 << 0), @@ -79,12 +81,14 @@ namespace Ryujinx Main } + [Flags] public enum HidControllerConnectionState { Controller_State_Connected = (1 << 0), Controller_State_Wired = (1 << 1) } + [Flags] public enum HidControllerType { ControllerType_ProController = (1 << 0), diff --git a/Ryujinx/Hid/JoyCon.cs b/Ryujinx/Hid/JoyCon.cs index 9dde2b70..8c9518e5 100644 --- a/Ryujinx/Hid/JoyCon.cs +++ b/Ryujinx/Hid/JoyCon.cs @@ -1,5 +1,8 @@ namespace Ryujinx { + /// + /// Common RGB color hex codes for JoyCon coloring. + /// public enum JoyConColor //Thanks to CTCaer { Body_Grey = 0x828282, diff --git a/Ryujinx/Logging.cs b/Ryujinx/Logging.cs index 308f068f..2ae858b4 100644 --- a/Ryujinx/Logging.cs +++ b/Ryujinx/Logging.cs @@ -7,7 +7,7 @@ namespace Ryujinx public static class Logging { private static Stopwatch ExecutionTime = new Stopwatch(); - private static string LogFileName = "Ryujinx.log"; + private const string LogFileName = "Ryujinx.log"; public static bool EnableInfo = Config.LoggingEnableInfo; public static bool EnableTrace = Config.LoggingEnableTrace; diff --git a/Ryujinx/OsHle/Handles/HSharedMem.cs b/Ryujinx/OsHle/Handles/HSharedMem.cs index a493276a..4f943ebc 100644 --- a/Ryujinx/OsHle/Handles/HSharedMem.cs +++ b/Ryujinx/OsHle/Handles/HSharedMem.cs @@ -23,10 +23,7 @@ namespace Ryujinx.OsHle.Handles { Positions.Add(Position); - if (MemoryMapped != null) - { - MemoryMapped(this, EventArgs.Empty); - } + MemoryMapped?.Invoke(this, EventArgs.Empty); } } @@ -36,10 +33,7 @@ namespace Ryujinx.OsHle.Handles { Positions.Remove(Position); - if (MemoryUnmapped != null) - { - MemoryUnmapped(this, EventArgs.Empty); - } + MemoryUnmapped?.Invoke(this, EventArgs.Empty); } } diff --git a/Ryujinx/OsHle/Horizon.cs b/Ryujinx/OsHle/Horizon.cs index e72c62dc..b9af69c2 100644 --- a/Ryujinx/OsHle/Horizon.cs +++ b/Ryujinx/OsHle/Horizon.cs @@ -165,12 +165,7 @@ namespace Ryujinx.OsHle internal bool TryGetProcess(int ProcessId, out Process Process) { - if (!Processes.TryGetValue(ProcessId, out Process)) - { - return false; - } - - return true; + return Processes.TryGetValue(ProcessId, out Process); } internal void CloseHandle(int Handle) diff --git a/Ryujinx/Switch.cs b/Ryujinx/Switch.cs index b5874051..4022061b 100644 --- a/Ryujinx/Switch.cs +++ b/Ryujinx/Switch.cs @@ -30,10 +30,7 @@ namespace Ryujinx internal virtual void OnFinish(EventArgs e) { - if (Finish != null) - { - Finish(this, e); - } + Finish?.Invoke(this, e); } public void Dispose() diff --git a/Ryujinx/VirtualFs.cs b/Ryujinx/VirtualFs.cs index e5579bcf..98298053 100644 --- a/Ryujinx/VirtualFs.cs +++ b/Ryujinx/VirtualFs.cs @@ -37,7 +37,7 @@ namespace Ryujinx public string GetGameSavesPath() => MakeDirAndGetFullPath(SavesPath); - private string MakeDirAndGetFullPath(string Dir) + private static string MakeDirAndGetFullPath(string Dir) { string FullPath = Path.Combine(GetBasePath(), Dir); @@ -49,7 +49,7 @@ namespace Ryujinx return FullPath; } - public string GetBasePath() + public static string GetBasePath() { return Path.Combine(Directory.GetCurrentDirectory(), BasePath); } @@ -61,9 +61,9 @@ namespace Ryujinx protected virtual void Dispose(bool disposing) { - if (disposing && RomFs != null) + if (disposing) { - RomFs.Dispose(); + RomFs?.Dispose(); } } }