diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-05-02 03:29:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-02 03:29:47 +0200 |
| commit | dd574146fb5f05c1c0a469a4ad4a20c46bb37d74 (patch) | |
| tree | 581cf26bcc2a5a31da00a66fd3255cfd489faced /src/Ryujinx.Ava | |
| parent | 2c94ac455ead867aac0a7a689a55d814a8bcc0da (diff) | |
Add hide-cursor command line argument & always hide cursor option (#4613)
* Add hide-cursor command line argument
* gtk: Adjust SettingsWindow for hide cursor options
* ava: Adjust SettingsWindow for hide cursor options
* ava: Add override check for HideCursor arg
* Remove copy&paste sins
* ava: Leave a little more room between the options
* gtk: Fix hide cursor issues
* ava: Only hide cursor if it's within the embedded window
Diffstat (limited to 'src/Ryujinx.Ava')
| -rw-r--r-- | src/Ryujinx.Ava/AppHost.cs | 44 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/Assets/Locales/en_US.json | 5 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/Program.cs | 14 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs | 6 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml | 31 |
5 files changed, 69 insertions, 31 deletions
diff --git a/src/Ryujinx.Ava/AppHost.cs b/src/Ryujinx.Ava/AppHost.cs index 957a1c9d..e11a954d 100644 --- a/src/Ryujinx.Ava/AppHost.cs +++ b/src/Ryujinx.Ava/AppHost.cs @@ -157,7 +157,7 @@ namespace Ryujinx.Ava _isFirmwareTitle = true; } - ConfigurationState.Instance.HideCursorOnIdle.Event += HideCursorState_Changed; + ConfigurationState.Instance.HideCursor.Event += HideCursorState_Changed; _topLevel.PointerMoved += TopLevel_PointerMoved; @@ -468,9 +468,9 @@ namespace Ryujinx.Ava (_rendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.MakeCurrent(null); } - private void HideCursorState_Changed(object sender, ReactiveEventArgs<bool> state) + private void HideCursorState_Changed(object sender, ReactiveEventArgs<HideCursorMode> state) { - if (state.NewValue) + if (state.NewValue == HideCursorMode.OnIdle) { _lastCursorMoveTime = Stopwatch.GetTimestamp(); } @@ -965,30 +965,38 @@ namespace Ryujinx.Ava if (_viewModel.IsActive) { - if (ConfigurationState.Instance.Hid.EnableMouse) + if (_isCursorInRenderer) { - if (_isCursorInRenderer) + if (ConfigurationState.Instance.Hid.EnableMouse) { HideCursor(); } else { - ShowCursor(); + switch (ConfigurationState.Instance.HideCursor.Value) + { + case HideCursorMode.Never: + ShowCursor(); + break; + case HideCursorMode.OnIdle: + if (Stopwatch.GetTimestamp() - _lastCursorMoveTime >= CursorHideIdleTime * Stopwatch.Frequency) + { + HideCursor(); + } + else + { + ShowCursor(); + } + break; + case HideCursorMode.Always: + HideCursor(); + break; + } } } else { - if (ConfigurationState.Instance.HideCursorOnIdle) - { - if (Stopwatch.GetTimestamp() - _lastCursorMoveTime >= CursorHideIdleTime * Stopwatch.Frequency) - { - HideCursor(); - } - else - { - ShowCursor(); - } - } + ShowCursor(); } Dispatcher.UIThread.Post(() => @@ -1133,4 +1141,4 @@ namespace Ryujinx.Ava return state; } } -} +}
\ No newline at end of file diff --git a/src/Ryujinx.Ava/Assets/Locales/en_US.json b/src/Ryujinx.Ava/Assets/Locales/en_US.json index 3a4bfc65..617cad34 100644 --- a/src/Ryujinx.Ava/Assets/Locales/en_US.json +++ b/src/Ryujinx.Ava/Assets/Locales/en_US.json @@ -80,7 +80,10 @@ "SettingsTabGeneralEnableDiscordRichPresence": "Enable Discord Rich Presence", "SettingsTabGeneralCheckUpdatesOnLaunch": "Check for Updates on Launch", "SettingsTabGeneralShowConfirmExitDialog": "Show \"Confirm Exit\" Dialog", - "SettingsTabGeneralHideCursorOnIdle": "Hide Cursor on Idle", + "SettingsTabGeneralHideCursor": "Hide Cursor:", + "SettingsTabGeneralHideCursorNever": "Never", + "SettingsTabGeneralHideCursorOnIdle": "On Idle", + "SettingsTabGeneralHideCursorAlways": "Always", "SettingsTabGeneralGameDirectories": "Game Directories", "SettingsTabGeneralAdd": "Add", "SettingsTabGeneralRemove": "Remove", diff --git a/src/Ryujinx.Ava/Program.cs b/src/Ryujinx.Ava/Program.cs index 7f35c62a..0629e606 100644 --- a/src/Ryujinx.Ava/Program.cs +++ b/src/Ryujinx.Ava/Program.cs @@ -183,6 +183,18 @@ namespace Ryujinx.Ava { ConfigurationState.Instance.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value; } + + // Check if HideCursor was overridden. + if (CommandLineState.OverrideHideCursor is not null) + { + ConfigurationState.Instance.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch + { + "never" => HideCursorMode.Never, + "onidle" => HideCursorMode.OnIdle, + "always" => HideCursorMode.Always, + _ => ConfigurationState.Instance.HideCursor.Value + }; + } } private static void PrintSystemInfo() @@ -226,4 +238,4 @@ namespace Ryujinx.Ava Logger.Shutdown(); } } -} +}
\ No newline at end of file diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index 232c9d43..08612117 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -132,7 +132,7 @@ namespace Ryujinx.Ava.UI.ViewModels public bool EnableDiscordIntegration { get; set; } public bool CheckUpdatesOnStart { get; set; } public bool ShowConfirmExit { get; set; } - public bool HideCursorOnIdle { get; set; } + public int HideCursor { get; set; } public bool EnableDockedMode { get; set; } public bool EnableKeyboard { get; set; } public bool EnableMouse { get; set; } @@ -375,7 +375,7 @@ namespace Ryujinx.Ava.UI.ViewModels EnableDiscordIntegration = config.EnableDiscordIntegration; CheckUpdatesOnStart = config.CheckUpdatesOnStart; ShowConfirmExit = config.ShowConfirmExit; - HideCursorOnIdle = config.HideCursorOnIdle; + HideCursor = (int)config.HideCursor.Value; GameDirectories.Clear(); GameDirectories.AddRange(config.Ui.GameDirs.Value); @@ -458,7 +458,7 @@ namespace Ryujinx.Ava.UI.ViewModels config.EnableDiscordIntegration.Value = EnableDiscordIntegration; config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart; config.ShowConfirmExit.Value = ShowConfirmExit; - config.HideCursorOnIdle.Value = HideCursorOnIdle; + config.HideCursor.Value = (HideCursorMode)HideCursor; if (_directoryChanged) { diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml b/src/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml index 61b6c433..acc5e2b7 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsUIView.axaml @@ -1,4 +1,4 @@ -<UserControl +<UserControl x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsUIView" xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" @@ -12,7 +12,7 @@ <Design.DataContext> <viewModels:SettingsViewModel /> </Design.DataContext> - <ScrollViewer + <ScrollViewer Name="UiPage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" @@ -37,9 +37,24 @@ <CheckBox IsChecked="{Binding ShowConfirmExit}"> <TextBlock Text="{locale:Locale SettingsTabGeneralShowConfirmExitDialog}" /> </CheckBox> - <CheckBox IsChecked="{Binding HideCursorOnIdle}"> - <TextBlock Text="{locale:Locale SettingsTabGeneralHideCursorOnIdle}" /> - </CheckBox> + <StackPanel Margin="0, 15, 0, 10" Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center" + Text="{locale:Locale SettingsTabGeneralHideCursor}" + Width="150" /> + <ComboBox SelectedIndex="{Binding HideCursor}" + HorizontalContentAlignment="Left" + MinWidth="100"> + <ComboBoxItem> + <TextBlock Text="{locale:Locale SettingsTabGeneralHideCursorNever}" /> + </ComboBoxItem> + <ComboBoxItem> + <TextBlock Text="{locale:Locale SettingsTabGeneralHideCursorOnIdle}" /> + </ComboBoxItem> + <ComboBoxItem> + <TextBlock Text="{locale:Locale SettingsTabGeneralHideCursorAlways}" /> + </ComboBoxItem> + </ComboBox> + </StackPanel> </StackPanel> <Separator Height="1" /> <TextBlock Classes="h1" Text="{locale:Locale SettingsTabGeneralGameDirectories}" /> @@ -105,7 +120,7 @@ <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> - <CheckBox + <CheckBox IsChecked="{Binding EnableCustomTheme}" ToolTip.Tip="{locale:Locale CustomThemeCheckTooltip}"> <TextBlock Text="{locale:Locale SettingsTabGeneralThemeEnableCustomTheme}" /> @@ -122,7 +137,7 @@ Grid.Column="1" Margin="0,10,0,0" Text="{Binding CustomThemePath}" /> - <Button + <Button Grid.Row="1" Grid.Column="2" Margin="10,10,0,0" @@ -153,4 +168,4 @@ </StackPanel> </Border> </ScrollViewer> -</UserControl>
\ No newline at end of file +</UserControl> |
