misc: Overhaul DirtyHacks saving to support storing a value alongside an off/off flag.

This commit is contained in:
Evan Husted
2024-12-29 21:17:01 -06:00
parent f5ce539de9
commit f362bef43d
13 changed files with 190 additions and 27 deletions

View File

@@ -17,7 +17,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// <summary>
/// The current version of the file format
/// </summary>
public const int CurrentVersion = 58;
public const int CurrentVersion = 59;
/// <summary>
/// Version of the configuration file format
@@ -436,9 +436,9 @@ namespace Ryujinx.Ava.Utilities.Configuration
public bool ShowDirtyHacks { get; set; }
/// <summary>
/// The packed value of the enabled dirty hacks.
/// The packed values of the enabled dirty hacks.
/// </summary>
public int EnabledDirtyHacks { get; set; }
public ulong[] DirtyHacks { get; set; }
/// <summary>
/// Loads a configuration file from disk

View File

@@ -9,6 +9,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -637,6 +638,18 @@ namespace Ryujinx.Ava.Utilities.Configuration
configurationFileUpdated = true;
}
// 58 migration accidentally got skipped but it worked with no issues somehow lol
if (configurationFileFormat.Version < 59)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 59.");
configurationFileFormat.ShowDirtyHacks = false;
configurationFileFormat.DirtyHacks = [];
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
@@ -737,7 +750,16 @@ namespace Ryujinx.Ava.Utilities.Configuration
Multiplayer.LdnServer.Value = configurationFileFormat.LdnServer;
Hacks.ShowDirtyHacks.Value = configurationFileFormat.ShowDirtyHacks;
Hacks.Xc2MenuSoftlockFix.Value = ((DirtyHacks)configurationFileFormat.EnabledDirtyHacks).HasFlag(DirtyHacks.Xc2MenuSoftlockFix);
{
EnabledDirtyHack[] hacks = configurationFileFormat.DirtyHacks.Select(EnabledDirtyHack.FromPacked).ToArray();
Hacks.Xc2MenuSoftlockFix.Value = hacks.Any(it => it.Hack == DirtyHacks.Xc2MenuSoftlockFix);
var shaderCompilationThreadSleep = hacks.FirstOrDefault(it => it.Hack == DirtyHacks.ShaderCompilationThreadSleep);
Hacks.EnableShaderCompilationThreadSleep.Value = shaderCompilationThreadSleep != null;
Hacks.ShaderCompilationThreadSleepDelay.Value = shaderCompilationThreadSleep?.Value ?? 0;
}
if (configurationFileUpdated)
{

View File

@@ -9,6 +9,7 @@ using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using Ryujinx.HLE;
using System.Collections.Generic;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -626,36 +627,43 @@ namespace Ryujinx.Ava.Utilities.Configuration
public ReactiveObject<bool> ShowDirtyHacks { get; private set; }
public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }
public ReactiveObject<bool> EnableShaderCompilationThreadSleep { get; private set; }
public ReactiveObject<int> ShaderCompilationThreadSleepDelay { get; private set; }
public HacksSection()
{
ShowDirtyHacks = new ReactiveObject<bool>();
Xc2MenuSoftlockFix = new ReactiveObject<bool>();
Xc2MenuSoftlockFix.Event += HackChanged;
EnableShaderCompilationThreadSleep = new ReactiveObject<bool>();
EnableShaderCompilationThreadSleep.Event += HackChanged;
ShaderCompilationThreadSleepDelay = new ReactiveObject<int>();
}
private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
{
Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"EnabledDirtyHacks set to: {EnabledHacks}", "LogValueChange");
Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"EnabledDirtyHacks set to: [{EnabledHacks.Select(x => x.Hack).JoinToString(", ")}]", "LogValueChange");
}
public DirtyHacks EnabledHacks
public EnabledDirtyHack[] EnabledHacks
{
get
{
DirtyHacks dirtyHacks = DirtyHacks.None;
List<EnabledDirtyHack> enabledHacks = [];
if (Xc2MenuSoftlockFix)
Apply(DirtyHacks.Xc2MenuSoftlockFix);
return dirtyHacks;
if (EnableShaderCompilationThreadSleep)
Apply(DirtyHacks.ShaderCompilationThreadSleep, ShaderCompilationThreadSleepDelay);
return enabledHacks.ToArray();
void Apply(DirtyHacks hack)
void Apply(DirtyHacks hack, int value = 0)
{
if (dirtyHacks is not DirtyHacks.None)
dirtyHacks |= hack;
else
dirtyHacks = hack;
enabledHacks.Add(new EnabledDirtyHack(hack, value));
}
}
}

View File

@@ -7,6 +7,7 @@ using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Graphics.Vulkan;
using Ryujinx.HLE;
using System;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -139,7 +140,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
MultiplayerLdnPassphrase = Multiplayer.LdnPassphrase,
LdnServer = Multiplayer.LdnServer,
ShowDirtyHacks = Hacks.ShowDirtyHacks,
EnabledDirtyHacks = (int)Hacks.EnabledHacks,
DirtyHacks = Hacks.EnabledHacks.Select(it => it.Pack()).ToArray(),
};
return configurationFile;