0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2025-01-08 18:52:01 +00:00

misc: Prevent value change logging when the value is changed to the same thing it was before the value change.

This commit is contained in:
Evan Husted 2024-12-31 22:23:08 -06:00
parent 3fa714bb72
commit 732aafd3bb
2 changed files with 24 additions and 66 deletions

View file

@ -53,6 +53,17 @@ namespace Ryujinx.Common
{
public static void LogValueChange<T>(LogClass logClass, ReactiveEventArgs<T> eventArgs, string valueName)
{
if ((eventArgs.NewValue == null || eventArgs.OldValue == null))
{
if (!(eventArgs.NewValue == null && eventArgs.OldValue == null))
goto Log;
}
else if (!eventArgs.NewValue!.Equals(eventArgs.OldValue))
goto Log;
return;
Log:
string message = string.Create(CultureInfo.InvariantCulture, $"{valueName} set to: {eventArgs.NewValue}");
Logger.Info?.Print(logClass, message);

View file

@ -1,6 +1,7 @@
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using Gommon;
using LibHac.Tools.FsSystem;
using Ryujinx.Audio.Backends.OpenAL;
@ -46,9 +47,9 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _resolutionScale;
private int _graphicsBackendMultithreadingIndex;
private float _volume;
private bool _isVulkanAvailable = true;
private bool _gameDirectoryChanged;
private bool _autoloadDirectoryChanged;
[ObservableProperty] private bool _isVulkanAvailable = true;
[ObservableProperty] private bool _gameDirectoryChanged;
[ObservableProperty] private bool _autoloadDirectoryChanged;
private readonly List<string> _gpuIds = new();
private int _graphicsBackendIndex;
private int _scalingFilter;
@ -63,7 +64,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _networkInterfaceIndex;
private int _multiplayerModeIndex;
private string _ldnPassphrase;
private string _ldnServer;
[ObservableProperty] private string _ldnServer;
public SettingsHacksViewModel DirtyHacks { get; }
@ -111,43 +112,10 @@ namespace Ryujinx.Ava.UI.ViewModels
}
}
public bool IsVulkanAvailable
{
get => _isVulkanAvailable;
set
{
_isVulkanAvailable = value;
OnPropertyChanged();
}
}
public bool IsOpenGLAvailable => !OperatingSystem.IsMacOS();
public bool IsAppleSiliconMac => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
public bool GameDirectoryChanged
{
get => _gameDirectoryChanged;
set
{
_gameDirectoryChanged = value;
OnPropertyChanged();
}
}
public bool AutoloadDirectoryChanged
{
get => _autoloadDirectoryChanged;
set
{
_autoloadDirectoryChanged = value;
OnPropertyChanged();
}
}
public bool IsMacOS => OperatingSystem.IsMacOS();
public bool EnableDiscordIntegration { get; set; }
@ -182,19 +150,12 @@ namespace Ryujinx.Ava.UI.ViewModels
_customVSyncInterval = newInterval;
_customVSyncIntervalPercentageProxy = value;
OnPropertiesChanged(
nameof(CustomVSyncInterval),
nameof(CustomVSyncInterval),
nameof(CustomVSyncIntervalPercentageText));
}
}
public string CustomVSyncIntervalPercentageText
{
get
{
string text = CustomVSyncIntervalPercentageProxy + "%";
return text;
}
}
public string CustomVSyncIntervalPercentageText => CustomVSyncIntervalPercentageProxy + "%";
public bool EnableCustomVSyncInterval
{
@ -356,7 +317,6 @@ namespace Ryujinx.Ava.UI.ViewModels
set
{
_networkInterfaceIndex = value != -1 ? value : 0;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[_networkInterfaceIndex]];
}
}
@ -366,7 +326,6 @@ namespace Ryujinx.Ava.UI.ViewModels
set
{
_multiplayerModeIndex = value;
ConfigurationState.Instance.Multiplayer.Mode.Value = (MultiplayerMode)_multiplayerModeIndex;
}
}
@ -375,16 +334,6 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool IsInvalidLdnPassphraseVisible { get; set; }
public string LdnServer
{
get => _ldnServer;
set
{
_ldnServer = value;
OnPropertyChanged();
}
}
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this()
{
_virtualFileSystem = virtualFileSystem;
@ -647,16 +596,14 @@ namespace Ryujinx.Ava.UI.ViewModels
config.ShowTitleBar.Value = ShowTitleBar;
config.HideCursor.Value = (HideCursorMode)HideCursor;
if (_gameDirectoryChanged)
if (GameDirectoryChanged)
{
List<string> gameDirs = new(GameDirectories);
config.UI.GameDirs.Value = gameDirs;
config.UI.GameDirs.Value = [..GameDirectories];
}
if (_autoloadDirectoryChanged)
if (AutoloadDirectoryChanged)
{
List<string> autoloadDirs = new(AutoloadDirectories);
config.UI.AutoloadDirs.Value = autoloadDirs;
config.UI.AutoloadDirs.Value = [..AutoloadDirectories];
}
config.UI.BaseStyle.Value = BaseStyleIndex switch
@ -766,8 +713,8 @@ namespace Ryujinx.Ava.UI.ViewModels
SaveSettingsEvent?.Invoke();
_gameDirectoryChanged = false;
_autoloadDirectoryChanged = false;
GameDirectoryChanged = false;
AutoloadDirectoryChanged = false;
}
private static void RevertIfNotSaved()