mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-23 06:09:59 -06:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d311dfc1a | |||
5b6e3521d8 |
@ -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,6 +1,8 @@
|
|||||||
using DiscordRPC;
|
using DiscordRPC;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
using LibHac.Bcat;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
using Ryujinx.HLE.Loaders.Processes;
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
using Ryujinx.UI.Common.Configuration;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -13,7 +15,7 @@ namespace Ryujinx.UI.Common
|
|||||||
{
|
{
|
||||||
public static Timestamps StartedAt { get; set; }
|
public static Timestamps StartedAt { get; set; }
|
||||||
|
|
||||||
private const string Description = "A simple, experimental Nintendo Switch emulator.";
|
private static readonly string _description = $"{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo} {ReleaseInformation.Version}";
|
||||||
private const string ApplicationId = "1293250299716173864";
|
private const string ApplicationId = "1293250299716173864";
|
||||||
|
|
||||||
private const int ApplicationByteLimit = 128;
|
private const int ApplicationByteLimit = 128;
|
||||||
@ -29,7 +31,7 @@ namespace Ryujinx.UI.Common
|
|||||||
Assets = new Assets
|
Assets = new Assets
|
||||||
{
|
{
|
||||||
LargeImageKey = "ryujinx",
|
LargeImageKey = "ryujinx",
|
||||||
LargeImageText = Description
|
LargeImageText = TruncateToByteLength(_description)
|
||||||
},
|
},
|
||||||
Details = "Main Menu",
|
Details = "Main Menu",
|
||||||
State = "Idling",
|
State = "Idling",
|
||||||
@ -62,19 +64,21 @@ namespace Ryujinx.UI.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SwitchToPlayingState(string titleId, ApplicationMetadata appMeta)
|
public static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResult procRes)
|
||||||
{
|
{
|
||||||
_discordClient?.SetPresence(new RichPresence
|
_discordClient?.SetPresence(new RichPresence
|
||||||
{
|
{
|
||||||
Assets = new Assets
|
Assets = new Assets
|
||||||
{
|
{
|
||||||
LargeImageKey = _discordGameAssets.Contains(titleId.ToLower()) ? titleId : "game",
|
LargeImageKey = _discordGameAssets.Contains(procRes.ProgramIdText.ToLower()) ? procRes.ProgramIdText : "game",
|
||||||
LargeImageText = TruncateToByteLength(appMeta.Title),
|
LargeImageText = TruncateToByteLength($"{appMeta.Title} | {procRes.DisplayVersion}"),
|
||||||
SmallImageKey = "ryujinx",
|
SmallImageKey = "ryujinx",
|
||||||
SmallImageText = Description
|
SmallImageText = TruncateToByteLength(_description)
|
||||||
},
|
},
|
||||||
Details = TruncateToByteLength($"Playing {appMeta.Title}"),
|
Details = TruncateToByteLength($"Playing {appMeta.Title}"),
|
||||||
State = $"Total play time: {appMeta.TimePlayed.Humanize(2, false)}",
|
State = appMeta.LastPlayed.HasValue
|
||||||
|
? $"Total play time: {appMeta.TimePlayed.Humanize(2, false)}"
|
||||||
|
: "Never played",
|
||||||
Timestamps = Timestamps.Now
|
Timestamps = Timestamps.Now
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -785,12 +785,11 @@ namespace Ryujinx.Ava
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata =>
|
ApplicationMetadata appMeta = ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
|
||||||
{
|
appMetadata => appMetadata.UpdatePreGame()
|
||||||
appMetadata.UpdatePreGame();
|
);
|
||||||
});
|
|
||||||
|
|
||||||
DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, appMeta);
|
DiscordIntegrationModule.SwitchToPlayingState(appMeta, Device.Processes.ActiveApplication);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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,42 +182,34 @@ 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")
|
"opengl" => GraphicsBackend.OpenGl,
|
||||||
{
|
"vulkan" => GraphicsBackend.Vulkan,
|
||||||
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
|
_ => ConfigurationState.Instance.Graphics.GraphicsBackend
|
||||||
}
|
};
|
||||||
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
|
|
||||||
{
|
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user