mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-01-09 03:02:00 +00:00
misc: Move dirty hack related stuff into a separate viewmodel, only show slider when translation delay is enabled.
This commit is contained in:
parent
d10a478cce
commit
0ab5b41c4b
7 changed files with 108 additions and 85 deletions
77
src/Ryujinx/UI/ViewModels/SettingsHacksViewModel.cs
Normal file
77
src/Ryujinx/UI/ViewModels/SettingsHacksViewModel.cs
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
using Gommon;
|
||||||
|
using Ryujinx.Ava.Utilities.Configuration;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
{
|
||||||
|
public class SettingsHacksViewModel : BaseModel
|
||||||
|
{
|
||||||
|
private readonly SettingsViewModel _baseViewModel;
|
||||||
|
|
||||||
|
public SettingsHacksViewModel() {}
|
||||||
|
|
||||||
|
public SettingsHacksViewModel(SettingsViewModel settingsVm)
|
||||||
|
{
|
||||||
|
_baseViewModel = settingsVm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _xc2MenuSoftlockFix = ConfigurationState.Instance.Hacks.Xc2MenuSoftlockFix;
|
||||||
|
private bool _shaderTranslationThreadSleep = ConfigurationState.Instance.Hacks.EnableShaderTranslationDelay;
|
||||||
|
private int _shaderTranslationSleepDelay = ConfigurationState.Instance.Hacks.ShaderTranslationDelay;
|
||||||
|
|
||||||
|
public bool Xc2MenuSoftlockFixEnabled
|
||||||
|
{
|
||||||
|
get => _xc2MenuSoftlockFix;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_xc2MenuSoftlockFix = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShaderTranslationDelayEnabled
|
||||||
|
{
|
||||||
|
get => _shaderTranslationThreadSleep;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_shaderTranslationThreadSleep = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ShaderTranslationDelayTooltipText => $"Current value: {ShaderTranslationDelay}";
|
||||||
|
|
||||||
|
public int ShaderTranslationDelay
|
||||||
|
{
|
||||||
|
get => _shaderTranslationSleepDelay;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_shaderTranslationSleepDelay = value;
|
||||||
|
|
||||||
|
OnPropertiesChanged(nameof(ShaderTranslationDelay), nameof(ShaderTranslationDelayTooltipText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Xc2MenuFixTooltip { get; } = Lambda.String(sb =>
|
||||||
|
{
|
||||||
|
sb.AppendLine(
|
||||||
|
"This fix applies a 2ms delay (via 'Thread.Sleep(2)') every time the game tries to read data from the emulated Switch filesystem.")
|
||||||
|
.AppendLine();
|
||||||
|
|
||||||
|
sb.AppendLine("From the issue on GitHub:").AppendLine();
|
||||||
|
sb.Append(
|
||||||
|
"When clicking very fast from game main menu to 2nd submenu, " +
|
||||||
|
"there is a low chance that the game will softlock, " +
|
||||||
|
"the submenu won't show up, while background music is still there.");
|
||||||
|
});
|
||||||
|
|
||||||
|
public static string ShaderTranslationDelayTooltip { get; } = Lambda.String(sb =>
|
||||||
|
{
|
||||||
|
sb.AppendLine("This hack applies the delay you specify every time shaders are attempted to be translated.")
|
||||||
|
.AppendLine();
|
||||||
|
|
||||||
|
sb.Append("Configurable via slider, only when this option is enabled.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,9 +65,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
private string _ldnPassphrase;
|
private string _ldnPassphrase;
|
||||||
private string _ldnServer;
|
private string _ldnServer;
|
||||||
|
|
||||||
private bool _xc2MenuSoftlockFix = ConfigurationState.Instance.Hacks.Xc2MenuSoftlockFix;
|
public SettingsHacksViewModel DirtyHacks { get; }
|
||||||
private bool _shaderTranslationThreadSleep = ConfigurationState.Instance.Hacks.EnableShaderCompilationThreadSleep;
|
|
||||||
private int _shaderTranslationSleepDelay = ConfigurationState.Instance.Hacks.ShaderCompilationThreadSleepDelay;
|
|
||||||
|
|
||||||
public int ResolutionScale
|
public int ResolutionScale
|
||||||
{
|
{
|
||||||
|
@ -279,41 +277,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Xc2MenuSoftlockFixEnabled
|
|
||||||
{
|
|
||||||
get => _xc2MenuSoftlockFix;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_xc2MenuSoftlockFix = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShaderTranslationDelayEnabled
|
|
||||||
{
|
|
||||||
get => _shaderTranslationThreadSleep;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_shaderTranslationThreadSleep = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ShaderTranslationDelayTooltipText => $"Current value: {ShaderTranslationDelay}";
|
|
||||||
|
|
||||||
public int ShaderTranslationDelay
|
|
||||||
{
|
|
||||||
get => _shaderTranslationSleepDelay;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_shaderTranslationSleepDelay = value;
|
|
||||||
|
|
||||||
OnPropertiesChanged(nameof(ShaderTranslationDelay), nameof(ShaderTranslationDelayTooltipText));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Language { get; set; }
|
public int Language { get; set; }
|
||||||
public int Region { get; set; }
|
public int Region { get; set; }
|
||||||
public int FsGlobalAccessLogMode { get; set; }
|
public int FsGlobalAccessLogMode { get; set; }
|
||||||
|
@ -426,9 +389,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
_virtualFileSystem = virtualFileSystem;
|
_virtualFileSystem = virtualFileSystem;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
|
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
Task.Run(LoadTimeZones);
|
Task.Run(LoadTimeZones);
|
||||||
|
|
||||||
|
DirtyHacks = new SettingsHacksViewModel(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,6 +414,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
Task.Run(LoadAvailableGpus);
|
Task.Run(LoadAvailableGpus);
|
||||||
LoadCurrentConfiguration();
|
LoadCurrentConfiguration();
|
||||||
|
|
||||||
|
DirtyHacks = new SettingsHacksViewModel(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,9 +630,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
||||||
|
|
||||||
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
||||||
DisableP2P = config.Multiplayer.DisableP2p.Value;
|
DisableP2P = config.Multiplayer.DisableP2p;
|
||||||
LdnPassphrase = config.Multiplayer.LdnPassphrase.Value;
|
LdnPassphrase = config.Multiplayer.LdnPassphrase;
|
||||||
LdnServer = config.Multiplayer.LdnServer.Value;
|
LdnServer = config.Multiplayer.LdnServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveSettings()
|
public void SaveSettings()
|
||||||
|
@ -788,9 +756,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
config.Multiplayer.LdnServer.Value = LdnServer;
|
config.Multiplayer.LdnServer.Value = LdnServer;
|
||||||
|
|
||||||
// Dirty Hacks
|
// Dirty Hacks
|
||||||
config.Hacks.Xc2MenuSoftlockFix.Value = Xc2MenuSoftlockFixEnabled;
|
config.Hacks.Xc2MenuSoftlockFix.Value = DirtyHacks.Xc2MenuSoftlockFixEnabled;
|
||||||
config.Hacks.EnableShaderCompilationThreadSleep.Value = ShaderTranslationDelayEnabled;
|
config.Hacks.EnableShaderTranslationDelay.Value = DirtyHacks.ShaderTranslationDelayEnabled;
|
||||||
config.Hacks.ShaderCompilationThreadSleepDelay.Value = ShaderTranslationDelay;
|
config.Hacks.ShaderTranslationDelay.Value = DirtyHacks.ShaderTranslationDelay;
|
||||||
|
|
||||||
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
||||||
|
|
||||||
|
@ -824,24 +792,5 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
RevertIfNotSaved();
|
RevertIfNotSaved();
|
||||||
CloseWindow?.Invoke();
|
CloseWindow?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Xc2MenuFixTooltip { get; } = Lambda.String(sb =>
|
|
||||||
{
|
|
||||||
sb.AppendLine(
|
|
||||||
"This fix applies a 2ms delay (via 'Thread.Sleep(2)') every time the game tries to read data from the emulated Switch filesystem.")
|
|
||||||
.AppendLine();
|
|
||||||
|
|
||||||
sb.AppendLine("From the issue on GitHub:").AppendLine();
|
|
||||||
sb.Append(
|
|
||||||
"When clicking very fast from game main menu to 2nd submenu, " +
|
|
||||||
"there is a low chance that the game will softlock, " +
|
|
||||||
"the submenu won't show up, while background music is still there.");
|
|
||||||
});
|
|
||||||
|
|
||||||
public static string ShaderTranslationDelayTooltip { get; } = Lambda.String(sb =>
|
|
||||||
{
|
|
||||||
sb.Append(
|
|
||||||
"This hack applies the delay you specify every time shaders are attempted to be translated.");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
Margin="0,10,0,0"
|
Margin="0,10,0,0"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
ToolTip.Tip="{Binding Xc2MenuFixTooltip}">
|
ToolTip.Tip="{Binding DirtyHacks.Xc2MenuFixTooltip}">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
Margin="0"
|
Margin="0"
|
||||||
IsChecked="{Binding Xc2MenuSoftlockFixEnabled}"/>
|
IsChecked="{Binding DirtyHacks.Xc2MenuSoftlockFixEnabled}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="Xenoblade Chronicles 2 Menu Softlock Fix" />
|
Text="Xenoblade Chronicles 2 Menu Softlock Fix" />
|
||||||
|
@ -47,16 +47,17 @@
|
||||||
Margin="0,10,0,0"
|
Margin="0,10,0,0"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
ToolTip.Tip="{Binding ShaderTranslationDelayTooltip}">
|
ToolTip.Tip="{Binding DirtyHacks.ShaderTranslationDelayTooltip}">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
Margin="0"
|
Margin="0"
|
||||||
IsChecked="{Binding ShaderTranslationDelayEnabled}"/>
|
IsChecked="{Binding DirtyHacks.ShaderTranslationDelayEnabled}"/>
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
Text="Arbitrary Delay on Shader Translation"/>
|
Text="Arbitrary Delay on Shader Translation"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Slider HorizontalAlignment="Center"
|
<Slider IsVisible="{Binding DirtyHacks.ShaderTranslationDelayEnabled}"
|
||||||
Value="{Binding ShaderTranslationDelay}"
|
HorizontalAlignment="Center"
|
||||||
ToolTip.Tip="{Binding ShaderTranslationDelayTooltipText}"
|
Value="{Binding DirtyHacks.ShaderTranslationDelay}"
|
||||||
|
ToolTip.Tip="{Binding DirtyHacks.ShaderTranslationDelayTooltipText}"
|
||||||
Width="175"
|
Width="175"
|
||||||
Margin="0,-3,0,0"
|
Margin="0,-3,0,0"
|
||||||
Height="32"
|
Height="32"
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Settings
|
namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsHacksView : UserControl
|
public partial class SettingsHacksView : UserControl
|
||||||
{
|
{
|
||||||
public SettingsViewModel ViewModel;
|
|
||||||
|
|
||||||
public SettingsHacksView()
|
public SettingsHacksView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
NavPanel.Content = LoggingPage;
|
NavPanel.Content = LoggingPage;
|
||||||
break;
|
break;
|
||||||
case nameof(HacksPage):
|
case nameof(HacksPage):
|
||||||
HacksPage.ViewModel = ViewModel;
|
HacksPage.DataContext = ViewModel;
|
||||||
NavPanel.Content = HacksPage;
|
NavPanel.Content = HacksPage;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -758,8 +758,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
|
|
||||||
var shaderCompilationThreadSleep = hacks.FirstOrDefault(it =>
|
var shaderCompilationThreadSleep = hacks.FirstOrDefault(it =>
|
||||||
it.Hack == DirtyHacks.ShaderCompilationThreadSleep);
|
it.Hack == DirtyHacks.ShaderCompilationThreadSleep);
|
||||||
Hacks.EnableShaderCompilationThreadSleep.Value = shaderCompilationThreadSleep != null;
|
Hacks.EnableShaderTranslationDelay.Value = shaderCompilationThreadSleep != null;
|
||||||
Hacks.ShaderCompilationThreadSleepDelay.Value = shaderCompilationThreadSleep?.Value ?? 0;
|
Hacks.ShaderTranslationDelay.Value = shaderCompilationThreadSleep?.Value ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configurationFileUpdated)
|
if (configurationFileUpdated)
|
||||||
|
|
|
@ -629,18 +629,18 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
|
|
||||||
public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }
|
public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }
|
||||||
|
|
||||||
public ReactiveObject<bool> EnableShaderCompilationThreadSleep { get; private set; }
|
public ReactiveObject<bool> EnableShaderTranslationDelay { get; private set; }
|
||||||
|
|
||||||
public ReactiveObject<int> ShaderCompilationThreadSleepDelay { get; private set; }
|
public ReactiveObject<int> ShaderTranslationDelay { get; private set; }
|
||||||
|
|
||||||
public HacksSection()
|
public HacksSection()
|
||||||
{
|
{
|
||||||
ShowDirtyHacks = new ReactiveObject<bool>();
|
ShowDirtyHacks = new ReactiveObject<bool>();
|
||||||
Xc2MenuSoftlockFix = new ReactiveObject<bool>();
|
Xc2MenuSoftlockFix = new ReactiveObject<bool>();
|
||||||
Xc2MenuSoftlockFix.Event += HackChanged;
|
Xc2MenuSoftlockFix.Event += HackChanged;
|
||||||
EnableShaderCompilationThreadSleep = new ReactiveObject<bool>();
|
EnableShaderTranslationDelay = new ReactiveObject<bool>();
|
||||||
EnableShaderCompilationThreadSleep.Event += HackChanged;
|
EnableShaderTranslationDelay.Event += HackChanged;
|
||||||
ShaderCompilationThreadSleepDelay = new ReactiveObject<int>();
|
ShaderTranslationDelay = new ReactiveObject<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
|
private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
|
||||||
|
@ -651,7 +651,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
if (newHacks != _lastHackCollection)
|
if (newHacks != _lastHackCollection)
|
||||||
{
|
{
|
||||||
RyuLogger.Info?.Print(LogClass.Configuration,
|
RyuLogger.Info?.Print(LogClass.Configuration,
|
||||||
$"EnabledDirtyHacks set to: [{_lastHackCollection}]", "LogValueChange");
|
$"EnabledDirtyHacks set to: [{newHacks}]", "LogValueChange");
|
||||||
|
|
||||||
_lastHackCollection = newHacks;
|
_lastHackCollection = newHacks;
|
||||||
}
|
}
|
||||||
|
@ -668,8 +668,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
||||||
if (Xc2MenuSoftlockFix)
|
if (Xc2MenuSoftlockFix)
|
||||||
Apply(DirtyHacks.Xc2MenuSoftlockFix);
|
Apply(DirtyHacks.Xc2MenuSoftlockFix);
|
||||||
|
|
||||||
if (EnableShaderCompilationThreadSleep)
|
if (EnableShaderTranslationDelay)
|
||||||
Apply(DirtyHacks.ShaderCompilationThreadSleep, ShaderCompilationThreadSleepDelay);
|
Apply(DirtyHacks.ShaderCompilationThreadSleep, ShaderTranslationDelay);
|
||||||
|
|
||||||
return enabledHacks.ToArray();
|
return enabledHacks.ToArray();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue