mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-22 18:05:46 +00:00
misc: More minor style changes.
This commit is contained in:
parent
e1dda4cef1
commit
5b6e3521d8
6 changed files with 35 additions and 64 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 _localeDefaultStrings.TryGetValue(key, out string defaultValue)
|
||||||
{
|
? defaultValue
|
||||||
return defaultValue;
|
: key.ToString(); // If the locale text doesn't exist return the key.
|
||||||
}
|
|
||||||
|
|
||||||
// If the locale text doesn't exist return the key.
|
|
||||||
return key.ToString();
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -100,14 +92,12 @@ namespace Ryujinx.Ava.Common.Locale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRTL()
|
public bool IsRTL() =>
|
||||||
{
|
_localeLanguageCode switch
|
||||||
return _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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 is not null)
|
||||||
{
|
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = CommandLineState.OverrideGraphicsBackend.ToLower() switch
|
||||||
if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl")
|
|
||||||
{
|
{
|
||||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
|
"opengl" => GraphicsBackend.OpenGl,
|
||||||
}
|
"vulkan" => GraphicsBackend.Vulkan,
|
||||||
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
|
_ => ConfigurationState.Instance.Graphics.GraphicsBackend
|
||||||
{
|
};
|
||||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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()
|
||||||
|
|
|
@ -443,10 +443,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
/// <summary>
|
PlatformSettings!.ColorValuesChanged += OnPlatformColorValuesChanged;
|
||||||
/// Subscribe to the ColorValuesChanged event
|
|
||||||
/// </summary>
|
|
||||||
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)
|
if (msg is null) return;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue