Misc language usage simplifications (#26)
un-nest some logic add some xmldoc simplify ini parse
This commit is contained in:
parent
dff28df84e
commit
068f9bff2e
9 changed files with 31 additions and 37 deletions
|
@ -20,7 +20,9 @@ namespace Ryujinx
|
||||||
|
|
||||||
public static void Read()
|
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"));
|
LoggingEnableInfo = Convert.ToBoolean(Parser.Value("Logging_Enable_Info"));
|
||||||
LoggingEnableTrace = Convert.ToBoolean(Parser.Value("Logging_Enable_Trace"));
|
LoggingEnableTrace = Convert.ToBoolean(Parser.Value("Logging_Enable_Trace"));
|
||||||
|
@ -70,23 +72,24 @@ namespace Ryujinx
|
||||||
// https://stackoverflow.com/a/37772571
|
// https://stackoverflow.com/a/37772571
|
||||||
public class IniParser
|
public class IniParser
|
||||||
{
|
{
|
||||||
private Dictionary<string, string> Values;
|
private readonly Dictionary<string, string> Values;
|
||||||
|
|
||||||
public IniParser(string Path)
|
public IniParser(string Path)
|
||||||
{
|
{
|
||||||
Values = File.ReadLines(Path)
|
Values = File.ReadLines(Path)
|
||||||
.Where(Line => (!String.IsNullOrWhiteSpace(Line) && !Line.StartsWith("#")))
|
.Where(Line => !string.IsNullOrWhiteSpace(Line) && !Line.StartsWith('#'))
|
||||||
.Select(Line => Line.Split(new char[] { '=' }, 2, 0))
|
.Select(Line => Line.Split('=', 2))
|
||||||
.ToDictionary(Parts => Parts[0].Trim(), Parts => Parts.Length > 1 ? Parts[1].Trim() : null);
|
.ToDictionary(Parts => Parts[0].Trim(), Parts => Parts.Length > 1 ? Parts[1].Trim() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Value(string Name, string Value = null)
|
/// <summary>
|
||||||
|
/// Gets the setting value for the requested setting <see cref="Name"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name">Setting Name</param>
|
||||||
|
/// <param name="defaultValue">Default value of the setting</param>
|
||||||
|
public string Value(string Name, string defaultValue = null)
|
||||||
{
|
{
|
||||||
if (Values != null && Values.ContainsKey(Name))
|
return Values.TryGetValue(Name, out var value) ? value : defaultValue;
|
||||||
{
|
|
||||||
return Values[Name];
|
|
||||||
}
|
|
||||||
return Value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,7 @@ namespace ChocolArm64.Translation
|
||||||
|
|
||||||
public ARegisterSize RegisterSize { 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 = ARegisterSize.Int64)
|
||||||
|
|
||||||
public AILOpCodeStore(int Index, AIoType IoType, ARegisterSize RegisterSize)
|
|
||||||
{
|
{
|
||||||
this.IoType = IoType;
|
this.IoType = IoType;
|
||||||
this.Index = Index;
|
this.Index = Index;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx
|
namespace Ryujinx
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
public enum HidControllerKeys
|
public enum HidControllerKeys
|
||||||
{
|
{
|
||||||
KEY_A = (1 << 0),
|
KEY_A = (1 << 0),
|
||||||
|
@ -79,12 +81,14 @@ namespace Ryujinx
|
||||||
Main
|
Main
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum HidControllerConnectionState
|
public enum HidControllerConnectionState
|
||||||
{
|
{
|
||||||
Controller_State_Connected = (1 << 0),
|
Controller_State_Connected = (1 << 0),
|
||||||
Controller_State_Wired = (1 << 1)
|
Controller_State_Wired = (1 << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum HidControllerType
|
public enum HidControllerType
|
||||||
{
|
{
|
||||||
ControllerType_ProController = (1 << 0),
|
ControllerType_ProController = (1 << 0),
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
namespace Ryujinx
|
namespace Ryujinx
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Common RGB color hex codes for JoyCon coloring.
|
||||||
|
/// </summary>
|
||||||
public enum JoyConColor //Thanks to CTCaer
|
public enum JoyConColor //Thanks to CTCaer
|
||||||
{
|
{
|
||||||
Body_Grey = 0x828282,
|
Body_Grey = 0x828282,
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx
|
||||||
public static class Logging
|
public static class Logging
|
||||||
{
|
{
|
||||||
private static Stopwatch ExecutionTime = new Stopwatch();
|
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 EnableInfo = Config.LoggingEnableInfo;
|
||||||
public static bool EnableTrace = Config.LoggingEnableTrace;
|
public static bool EnableTrace = Config.LoggingEnableTrace;
|
||||||
|
|
|
@ -23,10 +23,7 @@ namespace Ryujinx.OsHle.Handles
|
||||||
{
|
{
|
||||||
Positions.Add(Position);
|
Positions.Add(Position);
|
||||||
|
|
||||||
if (MemoryMapped != null)
|
MemoryMapped?.Invoke(this, EventArgs.Empty);
|
||||||
{
|
|
||||||
MemoryMapped(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +33,7 @@ namespace Ryujinx.OsHle.Handles
|
||||||
{
|
{
|
||||||
Positions.Remove(Position);
|
Positions.Remove(Position);
|
||||||
|
|
||||||
if (MemoryUnmapped != null)
|
MemoryUnmapped?.Invoke(this, EventArgs.Empty);
|
||||||
{
|
|
||||||
MemoryUnmapped(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,12 +165,7 @@ namespace Ryujinx.OsHle
|
||||||
|
|
||||||
internal bool TryGetProcess(int ProcessId, out Process Process)
|
internal bool TryGetProcess(int ProcessId, out Process Process)
|
||||||
{
|
{
|
||||||
if (!Processes.TryGetValue(ProcessId, out Process))
|
return Processes.TryGetValue(ProcessId, out Process);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void CloseHandle(int Handle)
|
internal void CloseHandle(int Handle)
|
||||||
|
|
|
@ -30,10 +30,7 @@ namespace Ryujinx
|
||||||
|
|
||||||
internal virtual void OnFinish(EventArgs e)
|
internal virtual void OnFinish(EventArgs e)
|
||||||
{
|
{
|
||||||
if (Finish != null)
|
Finish?.Invoke(this, e);
|
||||||
{
|
|
||||||
Finish(this, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx
|
||||||
|
|
||||||
public string GetGameSavesPath() => MakeDirAndGetFullPath(SavesPath);
|
public string GetGameSavesPath() => MakeDirAndGetFullPath(SavesPath);
|
||||||
|
|
||||||
private string MakeDirAndGetFullPath(string Dir)
|
private static string MakeDirAndGetFullPath(string Dir)
|
||||||
{
|
{
|
||||||
string FullPath = Path.Combine(GetBasePath(), Dir);
|
string FullPath = Path.Combine(GetBasePath(), Dir);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace Ryujinx
|
||||||
return FullPath;
|
return FullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetBasePath()
|
public static string GetBasePath()
|
||||||
{
|
{
|
||||||
return Path.Combine(Directory.GetCurrentDirectory(), BasePath);
|
return Path.Combine(Directory.GetCurrentDirectory(), BasePath);
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ namespace Ryujinx
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && RomFs != null)
|
if (disposing)
|
||||||
{
|
{
|
||||||
RomFs.Dispose();
|
RomFs?.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue