From 46c8129bf57a3df3e0a2db27e6611ca4210614be Mon Sep 17 00:00:00 2001 From: Ac_K Date: Fri, 29 Jul 2022 00:41:34 +0200 Subject: [PATCH] Avalonia: Another Cleanup (#3494) * Avalonia: Another Cleanup This PR is a cleanup to the avalonia code recently added: - Some XAML file are autoformatted like a previous PR. - Dlc is renamed to DownloadableContent (Locale exclude). - DownloadableContentManagerWindow is a bit improved (Fixes #3491). - Some nits here and there. * Fix GTK * Remove AttachDebugDevTools * Fix last warning * Fix JSON fields --- Ryujinx.Ava/Ui/Controls/GameGridView.axaml | 2 +- Ryujinx.Ava/Ui/Controls/GameListView.axaml | 2 +- .../Ui/Controls/UpdateWaitWindow.axaml.cs | 3 - Ryujinx.Ava/Ui/Models/CheatModel.cs | 7 +- Ryujinx.Ava/Ui/Models/CheatsList.cs | 32 +-- Ryujinx.Ava/Ui/Models/DlcModel.cs | 18 -- .../Ui/Models/DownloadableContentModel.cs | 18 ++ .../Ui/ViewModels/AmiiboWindowViewModel.cs | 4 +- .../Ui/ViewModels/MainWindowViewModel.cs | 6 +- Ryujinx.Ava/Ui/Windows/AboutWindow.axaml.cs | 4 - Ryujinx.Ava/Ui/Windows/AmiiboWindow.axaml.cs | 9 +- Ryujinx.Ava/Ui/Windows/CheatWindow.axaml | 73 ++--- Ryujinx.Ava/Ui/Windows/CheatWindow.axaml.cs | 13 +- .../Windows/ControllerSettingsWindow.axaml.cs | 10 - .../Ui/Windows/DlcManagerWindow.axaml.cs | 254 ----------------- ...=> DownloadableContentManagerWindow.axaml} | 10 +- .../DownloadableContentManagerWindow.axaml.cs | 266 ++++++++++++++++++ Ryujinx.Ava/Ui/Windows/MainWindow.axaml | 2 +- Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs | 19 +- .../Ui/Windows/MotionSettingsWindow.axaml.cs | 1 - .../Ui/Windows/RumbleSettingsWindow.axaml.cs | 1 - .../Ui/Windows/SettingsWindow.axaml.cs | 15 - Ryujinx.Ava/Ui/Windows/StyleableWindow.cs | 1 - .../Ui/Windows/TitleUpdateWindow.axaml.cs | 67 +++-- Ryujinx.Ava/Ui/Windows/UpdaterWindow.axaml.cs | 5 +- Ryujinx.Common/Configuration/DlcContainer.cs | 10 - Ryujinx.Common/Configuration/DlcNca.cs | 9 - .../DownloadableContentContainer.cs | 13 + .../Configuration/DownloadableContentNca.cs | 14 + Ryujinx.HLE/HOS/ApplicationLoader.cs | 12 +- Ryujinx/Ui/Windows/DlcWindow.cs | 46 +-- 31 files changed, 456 insertions(+), 490 deletions(-) delete mode 100644 Ryujinx.Ava/Ui/Models/DlcModel.cs create mode 100644 Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs delete mode 100644 Ryujinx.Ava/Ui/Windows/DlcManagerWindow.axaml.cs rename Ryujinx.Ava/Ui/Windows/{DlcManagerWindow.axaml => DownloadableContentManagerWindow.axaml} (94%) create mode 100644 Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs delete mode 100644 Ryujinx.Common/Configuration/DlcContainer.cs delete mode 100644 Ryujinx.Common/Configuration/DlcNca.cs create mode 100644 Ryujinx.Common/Configuration/DownloadableContentContainer.cs create mode 100644 Ryujinx.Common/Configuration/DownloadableContentNca.cs diff --git a/Ryujinx.Ava/Ui/Controls/GameGridView.axaml b/Ryujinx.Ava/Ui/Controls/GameGridView.axaml index 431bcf00f1..bcf38e7a0e 100644 --- a/Ryujinx.Ava/Ui/Controls/GameGridView.axaml +++ b/Ryujinx.Ava/Ui/Controls/GameGridView.axaml @@ -37,7 +37,7 @@ Header="{locale:Locale GameListContextMenuManageTitleUpdates}" ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" /> $"{BuildId}-{Name}"; + public string Name { get; } public string CleanName => Name.Substring(1, Name.Length - 8); diff --git a/Ryujinx.Ava/Ui/Models/CheatsList.cs b/Ryujinx.Ava/Ui/Models/CheatsList.cs index f2b0592e97..8231e5211e 100644 --- a/Ryujinx.Ava/Ui/Models/CheatsList.cs +++ b/Ryujinx.Ava/Ui/Models/CheatsList.cs @@ -10,26 +10,13 @@ namespace Ryujinx.Ava.Ui.Models public CheatsList(string buildId, string path) { BuildId = buildId; - Path = path; + Path = path; + CollectionChanged += CheatsList_CollectionChanged; } - private void CheatsList_CollectionChanged(object sender, - NotifyCollectionChangedEventArgs e) - { - if (e.Action == NotifyCollectionChangedAction.Add) - { - (e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled; - } - } - - private void Item_EnableToggled(object sender, bool e) - { - OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); - } - public string BuildId { get; } - public string Path { get; } + public string Path { get; } public bool IsEnabled { @@ -47,5 +34,18 @@ namespace Ryujinx.Ava.Ui.Models OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); } } + + private void CheatsList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + (e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled; + } + } + + private void Item_EnableToggled(object sender, bool e) + { + OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); + } } } \ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/DlcModel.cs b/Ryujinx.Ava/Ui/Models/DlcModel.cs deleted file mode 100644 index 7e5f4a62fc..0000000000 --- a/Ryujinx.Ava/Ui/Models/DlcModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Ryujinx.Ava.Ui.Models -{ - public class DlcModel - { - public bool IsEnabled { get; set; } - public string TitleId { get; } - public string ContainerPath { get; } - public string FullPath { get; } - - public DlcModel(string titleId, string containerPath, string fullPath, bool isEnabled) - { - TitleId = titleId; - ContainerPath = containerPath; - FullPath = fullPath; - IsEnabled = isEnabled; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs b/Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs new file mode 100644 index 0000000000..67530f62c4 --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Ava.Ui.Models +{ + public class DownloadableContentModel + { + public bool Enabled { get; set; } + public string TitleId { get; } + public string ContainerPath { get; } + public string FullPath { get; } + + public DownloadableContentModel(string titleId, string containerPath, string fullPath, bool enabled) + { + TitleId = titleId; + ContainerPath = containerPath; + FullPath = fullPath; + Enabled = enabled; + } + } +} \ No newline at end of file diff --git a/Ryujinx.Ava/Ui/ViewModels/AmiiboWindowViewModel.cs b/Ryujinx.Ava/Ui/ViewModels/AmiiboWindowViewModel.cs index 7015df44e6..fc809e52ba 100644 --- a/Ryujinx.Ava/Ui/ViewModels/AmiiboWindowViewModel.cs +++ b/Ryujinx.Ava/Ui/ViewModels/AmiiboWindowViewModel.cs @@ -382,9 +382,9 @@ namespace Ryujinx.Ava.Ui.ViewModels { string amiiboJsonString = await response.Content.ReadAsStringAsync(); - using (FileStream dlcJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough)) + using (FileStream amiiboJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough)) { - dlcJsonStream.Write(Encoding.UTF8.GetBytes(amiiboJsonString)); + amiiboJsonStream.Write(Encoding.UTF8.GetBytes(amiiboJsonString)); } return amiiboJsonString; diff --git a/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs b/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs index 7e6452f989..bd9242e7ca 100644 --- a/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs +++ b/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs @@ -1261,15 +1261,15 @@ namespace Ryujinx.Ava.Ui.ViewModels } } - public async void OpenDlcManager() + public async void OpenDownloadableContentManager() { var selection = SelectedApplication; if (selection != null) { - DlcManagerWindow dlcManager = new(_owner.VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName); + DownloadableContentManagerWindow downloadableContentManager = new(_owner.VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName); - await dlcManager.ShowDialog(_owner); + await downloadableContentManager.ShowDialog(_owner); } } diff --git a/Ryujinx.Ava/Ui/Windows/AboutWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/AboutWindow.axaml.cs index 75e9901b02..90b870aafa 100644 --- a/Ryujinx.Ava/Ui/Windows/AboutWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/AboutWindow.axaml.cs @@ -2,7 +2,6 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; using Avalonia.Threading; using Ryujinx.Ava.Common.Locale; using Ryujinx.Common.Utilities; @@ -27,9 +26,6 @@ namespace Ryujinx.Ava.Ui.Windows DataContext = this; InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif _ = DownloadPatronsJson(); } diff --git a/Ryujinx.Ava/Ui/Windows/AmiiboWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/AmiiboWindow.axaml.cs index 5ed845710d..9333a40e28 100644 --- a/Ryujinx.Ava/Ui/Windows/AmiiboWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/AmiiboWindow.axaml.cs @@ -1,6 +1,5 @@ using Avalonia; using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Ui.Models; using Ryujinx.Ava.Ui.ViewModels; @@ -18,9 +17,7 @@ namespace Ryujinx.Ava.Ui.Windows DataContext = ViewModel; InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif + Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["Amiibo"]; } @@ -31,9 +28,7 @@ namespace Ryujinx.Ava.Ui.Windows DataContext = ViewModel; InitializeComponent(); -#if DEBUG - this.AttachDevTools(); -#endif + if (Program.PreviewerDetached) { Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["Amiibo"]; diff --git a/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml b/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml index a5a4b0eeb1..8d91161161 100644 --- a/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml +++ b/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml @@ -1,21 +1,24 @@ - + - + @@ -24,14 +27,14 @@ + TextAlignment="Center" + TextWrapping="Wrap" /> - + - - - + + + - - - + + + @@ -79,8 +88,8 @@ Name="SaveButton" MinWidth="90" Margin="5" - IsVisible="{Binding !NoCheatsFound}" - Command="{Binding Save}"> + Command="{Binding Save}" + IsVisible="{Binding !NoCheatsFound}">