Skip to content

Commit

Permalink
UI: More advanced customization for what happens when Ryujinx loses f…
Browse files Browse the repository at this point in the history
…ocus
  • Loading branch information
GreemDev committed Feb 13, 2025
1 parent 7591b07 commit 17e8ae1
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Ryujinx/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ private void UpdateDockedModeState(object sender, ReactiveEventArgs<bool> e)
Device?.System.ChangeDockedModeState(e.NewValue);
}

private void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
public void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
{
Device?.SetVolume(e.NewValue);

Expand Down
152 changes: 151 additions & 1 deletion src/Ryujinx/Assets/locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -3447,6 +3447,156 @@
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossType",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "On Emulator Focus Lost:",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossTypeDoNothing",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Do Nothing",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossTypeBlockInput",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Block Input",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossTypeMuteAudio",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Mute Volume",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossTypeBlockInputAndMuteAudio",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Block Input & Mute Volume",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralFocusLossTypePauseEmulation",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "Pause Emulation",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"sv_SE": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{
"ID": "SettingsTabGeneralShowConfirmExitDialog",
"Translations": {
Expand Down Expand Up @@ -23923,4 +24073,4 @@
}
}
]
}
}
14 changes: 0 additions & 14 deletions src/Ryujinx/Common/ThemeManager.cs

This file was deleted.

4 changes: 3 additions & 1 deletion src/Ryujinx/RyujinxApp.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Ryujinx.Ava
{
public class RyujinxApp : Application
{
public static event Action ThemeChanged;

internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
=> windowTitleKey is null
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
Expand Down Expand Up @@ -112,7 +114,7 @@ public void ApplyConfiguredTheme(string baseStyle)
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
}

ThemeManager.OnThemeChanged();
ThemeChanged?.Invoke();

RequestedThemeVariant = baseStyle switch
{
Expand Down
6 changes: 3 additions & 3 deletions src/Ryujinx/UI/ViewModels/AboutWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public AboutWindowViewModel()
Version = RyujinxApp.FullAppName + "\n" + Program.Version;
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);

ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
RyujinxApp.ThemeChanged += Ryujinx_ThemeChanged;
}

private void ThemeManager_ThemeChanged()
private void Ryujinx_ThemeChanged()
{
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
}
Expand All @@ -49,7 +49,7 @@ private void UpdateLogoTheme(string theme)

public void Dispose()
{
ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
RyujinxApp.ThemeChanged -= Ryujinx_ThemeChanged;

GithubLogo.Dispose();
DiscordLogo.Dispose();
Expand Down
4 changes: 4 additions & 0 deletions src/Ryujinx/UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public float CustomResolutionScale
public bool EnableMouse { get; set; }
public bool DisableInputWhenOutOfFocus { get; set; }

public int FocusLostActionType { get; set; }

public VSyncMode VSyncMode
{
get => _vSyncMode;
Expand Down Expand Up @@ -481,6 +483,7 @@ public void LoadCurrentConfiguration()
ShowTitleBar = config.ShowTitleBar;
HideCursor = (int)config.HideCursor.Value;
UpdateCheckerType = (int)config.UpdateCheckerType.Value;
FocusLostActionType = (int)config.FocusLostActionType.Value;

GameDirectories.Clear();
GameDirectories.AddRange(config.UI.GameDirs.Value);
Expand Down Expand Up @@ -589,6 +592,7 @@ public void SaveSettings()
config.ShowTitleBar.Value = ShowTitleBar;
config.HideCursor.Value = (HideCursorMode)HideCursor;
config.UpdateCheckerType.Value = (UpdaterType)UpdateCheckerType;
config.FocusLostActionType.Value = (FocusLostType)FocusLostActionType;

if (GameDirectoryChanged)
{
Expand Down
27 changes: 24 additions & 3 deletions src/Ryujinx/UI/Views/Settings/SettingsUIView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,33 @@
<CheckBox IsChecked="{Binding RememberWindowState}">
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
</CheckBox>
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
<TextBlock Text="{ext:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
</CheckBox>
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
</CheckBox>
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center"
Text="{ext:Locale SettingsTabGeneralFocusLossType}"
Width="150" />
<ComboBox SelectedIndex="{Binding FocusLostActionType}"
HorizontalContentAlignment="Left"
MinWidth="100">
<ComboBoxItem>
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeDoNothing}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInput}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeMuteAudio}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInputAndMuteAudio}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypePauseEmulation}" />
</ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center"
Text="{ext:Locale SettingsTabGeneralCheckUpdatesOnLaunch}"
Expand Down
Loading

0 comments on commit 17e8ae1

Please sign in to comment.