Turn from Window -> Dialog

This commit is contained in:
Isaac Marovitz 2023-10-30 00:04:06 -04:00
parent f4b74e9ce1
commit fc52e4ff47
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
4 changed files with 37 additions and 21 deletions

View file

@ -118,11 +118,11 @@ namespace Ryujinx.Ava.UI.Controls
if (viewModel?.SelectedApplication != null) if (viewModel?.SelectedApplication != null)
{ {
await new CheatWindow( await CheatWindow.Show(
viewModel.VirtualFileSystem, viewModel.VirtualFileSystem,
viewModel.SelectedApplication.TitleId, viewModel.SelectedApplication.TitleId,
viewModel.SelectedApplication.TitleName, viewModel.SelectedApplication.TitleName,
viewModel.SelectedApplication.Path).ShowDialog(viewModel.TopLevel as Window); viewModel.SelectedApplication.Path);
} }
} }

View file

@ -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(); 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, Window.VirtualFileSystem,
ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText, ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText,
name, name,
Window.ViewModel.SelectedApplication.Path).ShowDialog(Window); Window.ViewModel.SelectedApplication.Path);
ViewModel.AppHost.Device.EnableCheats(); ViewModel.AppHost.Device.EnableCheats();
} }

View file

@ -1,25 +1,16 @@
<window:StyleableWindow <UserControl
x:Class="Ryujinx.Ava.UI.Windows.CheatWindow" x:Class="Ryujinx.Ava.UI.Windows.CheatWindow"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale" xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="clr-namespace:Ryujinx.Ava.UI.Models"
xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows" xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows"
Width="500" Width="500"
Height="500" Height="500"
MinWidth="500"
MinHeight="500"
x:DataType="window:CheatWindow" x:DataType="window:CheatWindow"
WindowStartupLocation="CenterOwner"
mc:Ignorable="d" mc:Ignorable="d"
Focusable="True"> Focusable="True">
<Window.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
</Window.Styles>
<Grid Name="CheatGrid" Margin="15"> <Grid Name="CheatGrid" Margin="15">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -123,4 +114,4 @@
</DockPanel> </DockPanel>
</DockPanel> </DockPanel>
</Grid> </Grid>
</window:StyleableWindow> </UserControl>

View file

@ -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.Common.Locale;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.Models;
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS;
@ -9,10 +13,11 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public partial class CheatWindow : StyleableWindow public partial class CheatWindow : UserControl
{ {
private readonly string _enabledCheatsPath; private readonly string _enabledCheatsPath;
public bool NoCheatsFound { get; } public bool NoCheatsFound { get; }
@ -27,8 +32,6 @@ namespace Ryujinx.Ava.UI.Windows
DataContext = this; DataContext = this;
InitializeComponent(); InitializeComponent();
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle];
} }
public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath) public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath)
@ -89,8 +92,25 @@ namespace Ryujinx.Ava.UI.Windows
} }
DataContext = this; 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<Grid>().Name("DialogSpace").Child().OfType<Border>());
bottomBorder.Setters.Add(new Setter(IsVisibleProperty, false));
contentDialog.Styles.Add(bottomBorder);
await ContentDialogHelper.ShowAsync(contentDialog);
} }
public void Save() public void Save()
@ -117,7 +137,12 @@ namespace Ryujinx.Ava.UI.Windows
File.WriteAllLines(_enabledCheatsPath, enabledCheats); File.WriteAllLines(_enabledCheatsPath, enabledCheats);
Close(); ((ContentDialog)Parent).Hide();
}
public void Close()
{
((ContentDialog)Parent).Hide();
} }
} }
} }