From fc52e4ff4752ea0274bde07df446caa6fa1fd391 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Mon, 30 Oct 2023 00:04:06 -0400 Subject: [PATCH] Turn from Window -> Dialog --- .../Controls/ApplicationContextMenu.axaml.cs | 4 +- .../UI/Views/Main/MainMenuBarView.axaml.cs | 4 +- src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml | 13 +------ .../UI/Windows/CheatWindow.axaml.cs | 37 ++++++++++++++++--- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs b/src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs index 0f0071065..397eabe21 100644 --- a/src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs +++ b/src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs @@ -118,11 +118,11 @@ namespace Ryujinx.Ava.UI.Controls if (viewModel?.SelectedApplication != null) { - await new CheatWindow( + await CheatWindow.Show( viewModel.VirtualFileSystem, viewModel.SelectedApplication.TitleId, viewModel.SelectedApplication.TitleName, - viewModel.SelectedApplication.Path).ShowDialog(viewModel.TopLevel as Window); + viewModel.SelectedApplication.Path); } } diff --git a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs index 9c0e683a0..f56249933 100644 --- a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs @@ -170,11 +170,11 @@ namespace Ryujinx.Ava.UI.Views.Main string name = ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage].NameString.ToString(); - await new CheatWindow( + await CheatWindow.Show( Window.VirtualFileSystem, ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText, name, - Window.ViewModel.SelectedApplication.Path).ShowDialog(Window); + Window.ViewModel.SelectedApplication.Path); ViewModel.AppHost.Device.EnableCheats(); } diff --git a/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml b/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml index 57d5f7eff..00047bdac 100644 --- a/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml +++ b/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml @@ -1,25 +1,16 @@ - - - - @@ -123,4 +114,4 @@ - + diff --git a/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml.cs index c2de67ab2..c035b2afb 100644 --- a/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml.cs +++ b/src/Ryujinx.Ava/UI/Windows/CheatWindow.axaml.cs @@ -1,5 +1,9 @@ -using Avalonia.Collections; +using Avalonia.Collections; +using Avalonia.Controls; +using Avalonia.Styling; +using FluentAvalonia.UI.Controls; using Ryujinx.Ava.Common.Locale; +using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Models; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; @@ -9,10 +13,11 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Threading.Tasks; namespace Ryujinx.Ava.UI.Windows { - public partial class CheatWindow : StyleableWindow + public partial class CheatWindow : UserControl { private readonly string _enabledCheatsPath; public bool NoCheatsFound { get; } @@ -27,8 +32,6 @@ namespace Ryujinx.Ava.UI.Windows DataContext = this; InitializeComponent(); - - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle]; } public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath) @@ -89,8 +92,25 @@ namespace Ryujinx.Ava.UI.Windows } DataContext = this; + } - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle]; + public static async Task Show(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath) + { + ContentDialog contentDialog = new() + { + PrimaryButtonText = "", + SecondaryButtonText = "", + CloseButtonText = "", + Content = new CheatWindow(virtualFileSystem, titleId, titleName, titlePath), + Title = string.Format(LocaleManager.Instance[LocaleKeys.CheatWindowTitle]), + }; + + Style bottomBorder = new(x => x.OfType().Name("DialogSpace").Child().OfType()); + bottomBorder.Setters.Add(new Setter(IsVisibleProperty, false)); + + contentDialog.Styles.Add(bottomBorder); + + await ContentDialogHelper.ShowAsync(contentDialog); } public void Save() @@ -117,7 +137,12 @@ namespace Ryujinx.Ava.UI.Windows File.WriteAllLines(_enabledCheatsPath, enabledCheats); - Close(); + ((ContentDialog)Parent).Hide(); + } + + public void Close() + { + ((ContentDialog)Parent).Hide(); } } }