From 69f75f2df17bb633e8bdf20590650880c6c9d3ad Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sun, 10 Nov 2024 19:58:02 -0600 Subject: [PATCH] misc: Fix small code formatting & styling issues --- .../Models/XCITrimmerFileModel.cs | 4 +- src/Ryujinx/Assets/Locales/ar_SA.json | 1 + src/Ryujinx/Assets/Locales/de_DE.json | 1 + src/Ryujinx/Assets/Locales/el_GR.json | 1 + src/Ryujinx/Assets/Locales/es_ES.json | 1 + src/Ryujinx/Assets/Locales/fr_FR.json | 1 + src/Ryujinx/Assets/Locales/he_IL.json | 1 + src/Ryujinx/Assets/Locales/it_IT.json | 1 + src/Ryujinx/Assets/Locales/ja_JP.json | 1 + src/Ryujinx/Assets/Locales/ko_KR.json | 1 + src/Ryujinx/Assets/Locales/pl_PL.json | 1 + src/Ryujinx/Assets/Locales/pt_BR.json | 1 + src/Ryujinx/Assets/Locales/ru_RU.json | 1 + src/Ryujinx/Assets/Locales/th_TH.json | 1 + src/Ryujinx/Assets/Locales/tr_TR.json | 1 + src/Ryujinx/Assets/Locales/uk_UA.json | 1 + src/Ryujinx/Assets/Locales/zh_CN.json | 1 + src/Ryujinx/Assets/Locales/zh_TW.json | 1 + src/Ryujinx/Program.cs | 1 - src/Ryujinx/UI/Helpers/ContentDialogHelper.cs | 6 +- .../Views/Input/ControllerInputView.axaml.cs | 66 ++++++++----------- src/Ryujinx/UI/Views/Input/InputView.axaml.cs | 23 ++----- src/Ryujinx/Updater.cs | 3 +- 23 files changed, 58 insertions(+), 62 deletions(-) diff --git a/src/Ryujinx.UI.Common/Models/XCITrimmerFileModel.cs b/src/Ryujinx.UI.Common/Models/XCITrimmerFileModel.cs index 05fa82920..95fb3985b 100644 --- a/src/Ryujinx.UI.Common/Models/XCITrimmerFileModel.cs +++ b/src/Ryujinx.UI.Common/Models/XCITrimmerFileModel.cs @@ -43,8 +43,8 @@ namespace Ryujinx.UI.Common.Models { if (obj == null) return false; - else - return this.Path == obj.Path; + + return this.Path == obj.Path; } public override int GetHashCode() diff --git a/src/Ryujinx/Assets/Locales/ar_SA.json b/src/Ryujinx/Assets/Locales/ar_SA.json index 129558395..495ab4b4d 100644 --- a/src/Ryujinx/Assets/Locales/ar_SA.json +++ b/src/Ryujinx/Assets/Locales/ar_SA.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "تعيين لون الخلفية", "AvatarClose": "إغلاق", "ControllerSettingsLoadProfileToolTip": "تحميل الملف الشخصي", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "إضافة ملف شخصي", "ControllerSettingsRemoveProfileToolTip": "إزالة الملف الشخصي", "ControllerSettingsSaveProfileToolTip": "حفظ الملف الشخصي", diff --git a/src/Ryujinx/Assets/Locales/de_DE.json b/src/Ryujinx/Assets/Locales/de_DE.json index 7b25336c3..e23f3b619 100644 --- a/src/Ryujinx/Assets/Locales/de_DE.json +++ b/src/Ryujinx/Assets/Locales/de_DE.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Hintergrundfarbe auswählen", "AvatarClose": "Schließen", "ControllerSettingsLoadProfileToolTip": "Lädt ein Profil", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Fügt ein Profil hinzu", "ControllerSettingsRemoveProfileToolTip": "Entfernt ein Profil", "ControllerSettingsSaveProfileToolTip": "Speichert ein Profil", diff --git a/src/Ryujinx/Assets/Locales/el_GR.json b/src/Ryujinx/Assets/Locales/el_GR.json index 95c2062b0..79975b892 100644 --- a/src/Ryujinx/Assets/Locales/el_GR.json +++ b/src/Ryujinx/Assets/Locales/el_GR.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Ορισμός Χρώματος Φόντου", "AvatarClose": "Κλείσιμο", "ControllerSettingsLoadProfileToolTip": "Φόρτωση Προφίλ", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Προσθήκη Προφίλ", "ControllerSettingsRemoveProfileToolTip": "Κατάργηση Προφίλ", "ControllerSettingsSaveProfileToolTip": "Αποθήκευση Προφίλ", diff --git a/src/Ryujinx/Assets/Locales/es_ES.json b/src/Ryujinx/Assets/Locales/es_ES.json index 183addade..e6da1d113 100644 --- a/src/Ryujinx/Assets/Locales/es_ES.json +++ b/src/Ryujinx/Assets/Locales/es_ES.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Establecer color de fondo", "AvatarClose": "Cerrar", "ControllerSettingsLoadProfileToolTip": "Cargar perfil", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Agregar perfil", "ControllerSettingsRemoveProfileToolTip": "Eliminar perfil", "ControllerSettingsSaveProfileToolTip": "Guardar perfil", diff --git a/src/Ryujinx/Assets/Locales/fr_FR.json b/src/Ryujinx/Assets/Locales/fr_FR.json index 34d53e16b..e52333cea 100644 --- a/src/Ryujinx/Assets/Locales/fr_FR.json +++ b/src/Ryujinx/Assets/Locales/fr_FR.json @@ -408,6 +408,7 @@ "AvatarClose": "Fermer", "ControllerSettingsLoadProfileToolTip": "Charger un profil", "ControllerSettingsAddProfileToolTip": "Ajouter un profil", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsRemoveProfileToolTip": "Supprimer un profil", "ControllerSettingsSaveProfileToolTip": "Enregistrer un profil", "MenuBarFileToolsTakeScreenshot": "Prendre une capture d'écran", diff --git a/src/Ryujinx/Assets/Locales/he_IL.json b/src/Ryujinx/Assets/Locales/he_IL.json index 6bd8f0470..d2bd21124 100644 --- a/src/Ryujinx/Assets/Locales/he_IL.json +++ b/src/Ryujinx/Assets/Locales/he_IL.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "הגדר צבע רקע", "AvatarClose": "סגור", "ControllerSettingsLoadProfileToolTip": "טען פרופיל", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "הוסף פרופיל", "ControllerSettingsRemoveProfileToolTip": "הסר פרופיל", "ControllerSettingsSaveProfileToolTip": "שמור פרופיל", diff --git a/src/Ryujinx/Assets/Locales/it_IT.json b/src/Ryujinx/Assets/Locales/it_IT.json index 0d0edb42c..ee2bd3a16 100644 --- a/src/Ryujinx/Assets/Locales/it_IT.json +++ b/src/Ryujinx/Assets/Locales/it_IT.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Imposta colore di sfondo", "AvatarClose": "Chiudi", "ControllerSettingsLoadProfileToolTip": "Carica profilo", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Aggiungi profilo", "ControllerSettingsRemoveProfileToolTip": "Rimuovi profilo", "ControllerSettingsSaveProfileToolTip": "Salva profilo", diff --git a/src/Ryujinx/Assets/Locales/ja_JP.json b/src/Ryujinx/Assets/Locales/ja_JP.json index 3eade3e6e..8d15ab678 100644 --- a/src/Ryujinx/Assets/Locales/ja_JP.json +++ b/src/Ryujinx/Assets/Locales/ja_JP.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "背景色を指定", "AvatarClose": "閉じる", "ControllerSettingsLoadProfileToolTip": "プロファイルをロード", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "プロファイルを追加", "ControllerSettingsRemoveProfileToolTip": "プロファイルを削除", "ControllerSettingsSaveProfileToolTip": "プロファイルをセーブ", diff --git a/src/Ryujinx/Assets/Locales/ko_KR.json b/src/Ryujinx/Assets/Locales/ko_KR.json index bd5bed962..2a62c415d 100644 --- a/src/Ryujinx/Assets/Locales/ko_KR.json +++ b/src/Ryujinx/Assets/Locales/ko_KR.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "배경색 설정", "AvatarClose": "닫기", "ControllerSettingsLoadProfileToolTip": "프로필 불러오기", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "프로필 추가", "ControllerSettingsRemoveProfileToolTip": "프로필 제거", "ControllerSettingsSaveProfileToolTip": "프로필 저장", diff --git a/src/Ryujinx/Assets/Locales/pl_PL.json b/src/Ryujinx/Assets/Locales/pl_PL.json index 6eb1118be..d6356dc76 100644 --- a/src/Ryujinx/Assets/Locales/pl_PL.json +++ b/src/Ryujinx/Assets/Locales/pl_PL.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Ustaw kolor tła", "AvatarClose": "Zamknij", "ControllerSettingsLoadProfileToolTip": "Wczytaj profil", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Dodaj profil", "ControllerSettingsRemoveProfileToolTip": "Usuń profil", "ControllerSettingsSaveProfileToolTip": "Zapisz profil", diff --git a/src/Ryujinx/Assets/Locales/pt_BR.json b/src/Ryujinx/Assets/Locales/pt_BR.json index 087098959..42a8e437b 100644 --- a/src/Ryujinx/Assets/Locales/pt_BR.json +++ b/src/Ryujinx/Assets/Locales/pt_BR.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Definir cor de fundo", "AvatarClose": "Fechar", "ControllerSettingsLoadProfileToolTip": "Carregar perfil", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Adicionar perfil", "ControllerSettingsRemoveProfileToolTip": "Remover perfil", "ControllerSettingsSaveProfileToolTip": "Salvar perfil", diff --git a/src/Ryujinx/Assets/Locales/ru_RU.json b/src/Ryujinx/Assets/Locales/ru_RU.json index f1a6f64e4..4ef6ff6d9 100644 --- a/src/Ryujinx/Assets/Locales/ru_RU.json +++ b/src/Ryujinx/Assets/Locales/ru_RU.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Установить цвет фона", "AvatarClose": "Закрыть", "ControllerSettingsLoadProfileToolTip": "Загрузить профиль", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Добавить профиль", "ControllerSettingsRemoveProfileToolTip": "Удалить профиль", "ControllerSettingsSaveProfileToolTip": "Сохранить профиль", diff --git a/src/Ryujinx/Assets/Locales/th_TH.json b/src/Ryujinx/Assets/Locales/th_TH.json index caf8f00ff..91169d9e2 100644 --- a/src/Ryujinx/Assets/Locales/th_TH.json +++ b/src/Ryujinx/Assets/Locales/th_TH.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "ตั้งค่าสีพื้นหลัง", "AvatarClose": "ปิด", "ControllerSettingsLoadProfileToolTip": "โหลด โปรไฟล์", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "เพิ่ม โปรไฟล์", "ControllerSettingsRemoveProfileToolTip": "ลบ โปรไฟล์", "ControllerSettingsSaveProfileToolTip": "บันทึก โปรไฟล์", diff --git a/src/Ryujinx/Assets/Locales/tr_TR.json b/src/Ryujinx/Assets/Locales/tr_TR.json index 83791752b..b9ce3e884 100644 --- a/src/Ryujinx/Assets/Locales/tr_TR.json +++ b/src/Ryujinx/Assets/Locales/tr_TR.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Arka Plan Rengi Ayarla", "AvatarClose": "Kapat", "ControllerSettingsLoadProfileToolTip": "Profil Yükle", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Profil Ekle", "ControllerSettingsRemoveProfileToolTip": "Profili Kaldır", "ControllerSettingsSaveProfileToolTip": "Profili Kaydet", diff --git a/src/Ryujinx/Assets/Locales/uk_UA.json b/src/Ryujinx/Assets/Locales/uk_UA.json index 807097f25..581d1bca1 100644 --- a/src/Ryujinx/Assets/Locales/uk_UA.json +++ b/src/Ryujinx/Assets/Locales/uk_UA.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "Встановити колір фону", "AvatarClose": "Закрити", "ControllerSettingsLoadProfileToolTip": "Завантажити профіль", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "Додати профіль", "ControllerSettingsRemoveProfileToolTip": "Видалити профіль", "ControllerSettingsSaveProfileToolTip": "Зберегти профіль", diff --git a/src/Ryujinx/Assets/Locales/zh_CN.json b/src/Ryujinx/Assets/Locales/zh_CN.json index 98f27b4c2..3426b8a4a 100644 --- a/src/Ryujinx/Assets/Locales/zh_CN.json +++ b/src/Ryujinx/Assets/Locales/zh_CN.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "设置背景色", "AvatarClose": "关闭", "ControllerSettingsLoadProfileToolTip": "加载配置文件", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "新增配置文件", "ControllerSettingsRemoveProfileToolTip": "删除配置文件", "ControllerSettingsSaveProfileToolTip": "保存配置文件", diff --git a/src/Ryujinx/Assets/Locales/zh_TW.json b/src/Ryujinx/Assets/Locales/zh_TW.json index 491c07dd8..fd02254e1 100644 --- a/src/Ryujinx/Assets/Locales/zh_TW.json +++ b/src/Ryujinx/Assets/Locales/zh_TW.json @@ -407,6 +407,7 @@ "AvatarSetBackgroundColor": "設定背景顏色", "AvatarClose": "關閉", "ControllerSettingsLoadProfileToolTip": "載入設定檔", + "ControllerSettingsViewProfileToolTip": "View Profile", "ControllerSettingsAddProfileToolTip": "新增設定檔", "ControllerSettingsRemoveProfileToolTip": "刪除設定檔", "ControllerSettingsSaveProfileToolTip": "儲存設定檔", diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index cdce023cb..76512a34a 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -30,7 +30,6 @@ namespace Ryujinx.Ava { internal partial class Program { - // public static double WindowScaleFactor { get; set; } public static double DesktopScaleFactor { get; set; } = 1.0; public static string Version { get; private set; } diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index bd8c1e3a7..a7fe3f0ce 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -226,11 +226,11 @@ namespace Ryujinx.Ava.UI.Helpers (int)Symbol.Help, primaryButtonResult); - internal static async Task CreateConfirmationDialogExtended( + internal static async Task CreateDeniableConfirmationDialog( string primaryText, string secondaryText, string acceptButtonText, - string noacceptButtonText, + string noAcceptButtonText, string cancelButtonText, string title, UserResult primaryButtonResult = UserResult.Yes) @@ -239,7 +239,7 @@ namespace Ryujinx.Ava.UI.Helpers primaryText, secondaryText, acceptButtonText, - noacceptButtonText, + noAcceptButtonText, cancelButtonText, (int)Symbol.Help, primaryButtonResult); diff --git a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs index c900ea532..ee84fbc37 100644 --- a/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/ControllerInputView.axaml.cs @@ -26,19 +26,17 @@ namespace Ryujinx.Ava.UI.Views.Input foreach (ILogical visual in SettingButtons.GetLogicalDescendants()) { - if (visual is ToggleButton button and not CheckBox) + switch (visual) { - button.IsCheckedChanged += Button_IsCheckedChanged; - } - - if (visual is CheckBox check) - { - check.IsCheckedChanged += CheckBox_IsCheckedChanged; - } - - if (visual is Slider slider) - { - slider.PropertyChanged += Slider_IsCheckedChanged; + case ToggleButton button and not CheckBox: + button.IsCheckedChanged += Button_IsCheckedChanged; + break; + case CheckBox check: + check.IsCheckedChanged += CheckBox_IsCheckedChanged; + break; + case Slider slider: + slider.PropertyChanged += Slider_ValueChanged; + break; } } } @@ -47,33 +45,28 @@ namespace Ryujinx.Ava.UI.Views.Input { base.OnPointerReleased(e); - if (_currentAssigner != null && _currentAssigner.ToggledButton != null && !_currentAssigner.ToggledButton.IsPointerOver) + if (_currentAssigner is { ToggledButton.IsPointerOver: false }) { _currentAssigner.Cancel(); } } - private float _changeSlider = -1.0f; + private float _changeSlider = float.NaN; - private void Slider_IsCheckedChanged(object sender, AvaloniaPropertyChangedEventArgs e) + private void Slider_ValueChanged(object sender, AvaloniaPropertyChangedEventArgs e) { if (sender is Slider check) { - if ((bool)check.IsPointerOver && _changeSlider == -1.0f) + _changeSlider = check.IsPointerOver switch { - _changeSlider = (float)check.Value; - - } - else if (!(bool)check.IsPointerOver) - { - _changeSlider = -1.0f; - } + true when float.IsNaN(_changeSlider) => (float)check.Value, + false => float.NaN, + _ => _changeSlider + }; - if (_changeSlider != -1.0f && _changeSlider != (float)check.Value) + if (!float.IsNaN(_changeSlider) && _changeSlider != (float)check.Value) { - - var viewModel = (DataContext as ControllerInputViewModel); - viewModel.ParentModel.IsModified = true; + (DataContext as ControllerInputViewModel)!.ParentModel.IsModified = true; _changeSlider = (float)check.Value; } } @@ -81,25 +74,20 @@ namespace Ryujinx.Ava.UI.Views.Input private void CheckBox_IsCheckedChanged(object sender, RoutedEventArgs e) { - if (sender is CheckBox check) + if (sender is CheckBox { IsPointerOver: true }) { - if ((bool)check.IsPointerOver) - { - - var viewModel = (DataContext as ControllerInputViewModel); - viewModel.ParentModel.IsModified = true; - _currentAssigner?.Cancel(); - _currentAssigner = null; - } + (DataContext as ControllerInputViewModel)!.ParentModel.IsModified = true; + _currentAssigner?.Cancel(); + _currentAssigner = null; } } private void Button_IsCheckedChanged(object sender, RoutedEventArgs e) { - if (sender is ToggleButton button ) + if (sender is ToggleButton button) { - if ((bool)button.IsChecked) + if (button.IsChecked is true) { if (_currentAssigner != null && button == _currentAssigner.ToggledButton) { @@ -204,7 +192,7 @@ namespace Ryujinx.Ava.UI.Views.Input } else { - if (_currentAssigner != null ) + if (_currentAssigner != null) { _currentAssigner.Cancel(); _currentAssigner = null; diff --git a/src/Ryujinx/UI/Views/Input/InputView.axaml.cs b/src/Ryujinx/UI/Views/Input/InputView.axaml.cs index 5fda7ef6a..3c9d4040f 100644 --- a/src/Ryujinx/UI/Views/Input/InputView.axaml.cs +++ b/src/Ryujinx/UI/Views/Input/InputView.axaml.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.Views.Input { _dialogOpen = true; - var result = await ContentDialogHelper.CreateConfirmationDialogExtended( + var result = await ContentDialogHelper.CreateDeniableConfirmationDialog( LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmMessage], LocaleManager.Instance[LocaleKeys.DialogControllerSettingsModifiedConfirmSubMessage], LocaleManager.Instance[LocaleKeys.InputDialogYes], @@ -53,28 +53,19 @@ namespace Ryujinx.Ava.UI.Views.Input _dialogOpen = false; - if (result == UserResult.Cancel) - { - - return; - } - - ViewModel.IsModified = false; - - if (result != UserResult.Cancel) - { - ViewModel.PlayerId = ViewModel.PlayerIdChoose; - } - if (result == UserResult.Cancel) { if (e.AddedItems.Count > 0) { ViewModel.IsModified = true; - var player = (PlayerModel)e.AddedItems[0]; - ViewModel.PlayerId = player.Id; + ViewModel.PlayerId = ((PlayerModel)e.AddedItems[0])!.Id; } + return; } + + ViewModel.PlayerId = ViewModel.PlayerIdChoose; + + ViewModel.IsModified = false; } } diff --git a/src/Ryujinx/Updater.cs b/src/Ryujinx/Updater.cs index 4754f2091..9deff5e86 100644 --- a/src/Ryujinx/Updater.cs +++ b/src/Ryujinx/Updater.cs @@ -32,7 +32,8 @@ namespace Ryujinx.Ava internal static class Updater { private const string GitHubApiUrl = "https://api.github.com"; - private const string LatestReleaseUrl = $"{GitHubApiUrl}/repos/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}/releases/latest"; + private const string LatestReleaseUrl = + $"{GitHubApiUrl}/repos/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}/releases/latest"; private static readonly GithubReleasesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());