Modified UI and ConfigurationState to add a

changeable idle timeout for the cursor called
CursorHideIdleTime. (What the hardcoded variable
was called beforehand)
This commit is contained in:
ProfOzpin 2024-03-07 14:24:10 +04:00
parent 2505a1abcd
commit 443dd92464
7 changed files with 50 additions and 4 deletions

View file

@ -56,6 +56,7 @@ namespace Ryujinx.UI.Windows
[GUI] RadioButton _hideCursorNever;
[GUI] RadioButton _hideCursorOnIdle;
[GUI] RadioButton _hideCursorAlways;
[GUI] Entry _cursorHideIdleTime;
[GUI] CheckButton _vSyncToggle;
[GUI] CheckButton _shaderCacheToggle;
[GUI] CheckButton _textureRecompressionToggle;
@ -232,6 +233,7 @@ namespace Ryujinx.UI.Windows
switch (ConfigurationState.Instance.HideCursor.Value)
{
case HideCursorMode.Never:
_hideCursorNever.Click();
break;
@ -241,6 +243,7 @@ namespace Ryujinx.UI.Windows
case HideCursorMode.Always:
_hideCursorAlways.Click();
break;
}
if (ConfigurationState.Instance.Graphics.EnableVsync)
@ -640,6 +643,7 @@ namespace Ryujinx.UI.Windows
ConfigurationState.Instance.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
ConfigurationState.Instance.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
ConfigurationState.Instance.Hid.EnableMouse.Value = _directMouseAccess.Active;
ConfigurationState.Instance.CursorHideIdleTime.Value = int.Parse(_cursorHideIdleTime.Text);
ConfigurationState.Instance.UI.EnableCustomTheme.Value = _custThemeToggle.Active;
ConfigurationState.Instance.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
ConfigurationState.Instance.System.Region.Value = Enum.Parse<Common.Configuration.System.Region>(_systemRegionSelect.ActiveId);

View file

@ -15,7 +15,7 @@ namespace Ryujinx.UI.Common.Configuration
/// <summary>
/// The current version of the file format
/// </summary>
public const int CurrentVersion = 49;
public const int CurrentVersion = 50;
/// <summary>
/// Version of the configuration file format
@ -167,6 +167,11 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary>
public HideCursorMode HideCursor { get; set; }
/// <summary>
/// Amount of seconds needed by the mouse to be spent idle for cursor to hide.
/// </summary>
public int CursorHideIdleTime { get; set; }
/// <summary>
/// Enables or disables Vertical Sync
/// </summary>

View file

@ -631,6 +631,11 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary>
public ReactiveObject<HideCursorMode> HideCursor { get; private set; }
/// <summary>
/// Amount of seconds needed by the mouse to be spent idle to hide the cursor.
/// </summary>
public ReactiveObject<int> CursorHideIdleTime {get; private set; }
private ConfigurationState()
{
UI = new UISection();
@ -643,6 +648,7 @@ namespace Ryujinx.UI.Common.Configuration
CheckUpdatesOnStart = new ReactiveObject<bool>();
ShowConfirmExit = new ReactiveObject<bool>();
HideCursor = new ReactiveObject<HideCursorMode>();
CursorHideIdleTime = new ReactiveObject<int>();
}
public ConfigurationFileFormat ToFileFormat()
@ -679,6 +685,7 @@ namespace Ryujinx.UI.Common.Configuration
CheckUpdatesOnStart = CheckUpdatesOnStart,
ShowConfirmExit = ShowConfirmExit,
HideCursor = HideCursor,
CursorHideIdleTime = CursorHideIdleTime,
EnableVsync = Graphics.EnableVsync,
EnableShaderCache = Graphics.EnableShaderCache,
EnableTextureRecompression = Graphics.EnableTextureRecompression,
@ -843,6 +850,7 @@ namespace Ryujinx.UI.Common.Configuration
UI.WindowStartup.WindowMaximized.Value = false;
Hid.EnableKeyboard.Value = false;
Hid.EnableMouse.Value = false;
CursorHideIdleTime.Value = 5;
Hid.Hotkeys.Value = new KeyboardHotkeys
{
ToggleVsync = Key.F1,
@ -1442,6 +1450,15 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileUpdated = true;
}
if(configurationFileFormat.Version < 50)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 50.");
configurationFileFormat.CursorHideIdleTime = 5;
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
@ -1473,6 +1490,7 @@ namespace Ryujinx.UI.Common.Configuration
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
HideCursor.Value = configurationFileFormat.HideCursor;
CursorHideIdleTime.Value = configurationFileFormat.CursorHideIdleTime;
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
@ -1527,7 +1545,7 @@ namespace Ryujinx.UI.Common.Configuration
Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
Hid.InputConfig.Value = configurationFileFormat.InputConfig;
if (Hid.InputConfig.Value == null)
{
Hid.InputConfig.Value = new List<InputConfig>();

View file

@ -65,7 +65,6 @@ namespace Ryujinx.Ava
{
internal class AppHost
{
private const int CursorHideIdleTime = 5; // Hide Cursor seconds.
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
private const int TargetFps = 60;
private const float VolumeDelta = 0.05f;
@ -1029,7 +1028,7 @@ namespace Ryujinx.Ava
ShowCursor();
break;
case HideCursorMode.OnIdle:
if (Stopwatch.GetTimestamp() - _lastCursorMoveTime >= CursorHideIdleTime * Stopwatch.Frequency)
if (Stopwatch.GetTimestamp() - _lastCursorMoveTime >= ConfigurationState.Instance.CursorHideIdleTime.Value * Stopwatch.Frequency)
{
HideCursor();
}

View file

@ -96,6 +96,8 @@
"SettingsTabGeneralHideCursorNever": "Never",
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
"SettingsTabGeneralHideCursorAlways": "Always",
"SettingsTabGeneralCursorHideIdleTime": "Seconds:",
"SettingsTabGeneralCursorHideIdleTimeTooltip": "Amount of seconds needed by the mouse to be spent idle to hide the cursor.",
"SettingsTabGeneralGameDirectories": "Game Directories",
"SettingsTabGeneralAdd": "Add",
"SettingsTabGeneralRemove": "Remove",

View file

@ -133,6 +133,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool CheckUpdatesOnStart { get; set; }
public bool ShowConfirmExit { get; set; }
public int HideCursor { get; set; }
public int CursorHideIdleTime { get; set; }
public bool EnableDockedMode { get; set; }
public bool EnableKeyboard { get; set; }
public bool EnableMouse { get; set; }
@ -406,6 +407,7 @@ namespace Ryujinx.Ava.UI.ViewModels
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
ShowConfirmExit = config.ShowConfirmExit;
HideCursor = (int)config.HideCursor.Value;
CursorHideIdleTime = config.CursorHideIdleTime.Value;
GameDirectories.Clear();
GameDirectories.AddRange(config.UI.GameDirs.Value);
@ -490,6 +492,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
config.ShowConfirmExit.Value = ShowConfirmExit;
config.HideCursor.Value = (HideCursorMode)HideCursor;
config.CursorHideIdleTime.Value = CursorHideIdleTime;
if (_directoryChanged)
{

View file

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
mc:Ignorable="d"
@ -53,6 +54,20 @@
<TextBlock Text="{locale:Locale SettingsTabGeneralHideCursorAlways}" />
</ComboBoxItem>
</ComboBox>
<TextBlock
VerticalAlignment="Center"
Text="{locale:Locale SettingsTabGeneralCursorHideIdleTime}"
Width="150"
Margin="10,0,0,0"/>
<ui:NumberBox
MinWidth="100"
SmallChange="1"
LargeChange="5"
SimpleNumberFormat="F0"
Maximum="100"
Minimum="1"
ToolTip.Tip="{locale:Locale SettingsTabGeneralCursorHideIdleTimeTooltip}"
Value="{Binding CursorHideIdleTime}" />
</StackPanel>
<StackPanel Margin="0, 15, 0, 10" Orientation="Horizontal">
<TextBlock