Refactor SettingsWindow

This commit is contained in:
Isaac Marovitz 2024-04-18 18:24:30 -04:00
parent 7821d4581a
commit b3262302fc
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
5 changed files with 30 additions and 19 deletions

View file

@ -1,11 +1,15 @@
using Avalonia.Controls; using Avalonia.Controls;
using Ryujinx.Ava.UI.ViewModels;
namespace Ryujinx.Ava.UI.Views.Settings namespace Ryujinx.Ava.UI.Views.Settings
{ {
public partial class SettingsInputView : UserControl public partial class SettingsInputView : UserControl
{ {
public SettingsInputView() public SettingsViewModel ViewModel;
public SettingsInputView(SettingsViewModel viewModel)
{ {
ViewModel = viewModel;
InitializeComponent(); InitializeComponent();
} }

View file

@ -8,8 +8,9 @@ namespace Ryujinx.Ava.UI.Views.Settings
{ {
public SettingsViewModel ViewModel; public SettingsViewModel ViewModel;
public SettingsSystemView() public SettingsSystemView(SettingsViewModel viewModel)
{ {
ViewModel = viewModel;
InitializeComponent(); InitializeComponent();
} }

View file

@ -2,7 +2,6 @@ using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.VisualTree; using Avalonia.VisualTree;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -14,8 +13,9 @@ namespace Ryujinx.Ava.UI.Views.Settings
{ {
public SettingsViewModel ViewModel; public SettingsViewModel ViewModel;
public SettingsUiView() public SettingsUiView(SettingsViewModel viewModel)
{ {
ViewModel = viewModel;
InitializeComponent(); InitializeComponent();
} }

View file

@ -8,7 +8,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows" xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows"
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels" xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
xmlns:settings="clr-namespace:Ryujinx.Ava.UI.Views.Settings"
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers" xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
Width="1100" Width="1100"
Height="768" Height="768"
@ -32,17 +31,6 @@
Grid.Row="1" Grid.Row="1"
IsVisible="False" IsVisible="False"
KeyboardNavigation.IsTabStop="False"/> KeyboardNavigation.IsTabStop="False"/>
<Grid Name="Pages" IsVisible="False" Grid.Row="2">
<settings:SettingsUiView Name="UiPage" />
<settings:SettingsInputView Name="InputPage" />
<settings:SettingsHotkeysView Name="HotkeysPage" />
<settings:SettingsSystemView Name="SystemPage" />
<settings:SettingsCPUView Name="CpuPage" />
<settings:SettingsGraphicsView Name="GraphicsPage" />
<settings:SettingsAudioView Name="AudioPage" />
<settings:SettingsNetworkView Name="NetworkPage" />
<settings:SettingsLoggingView Name="LoggingPage" />
</Grid>
<ui:NavigationView <ui:NavigationView
Grid.Row="1" Grid.Row="1"
IsSettingsVisible="False" IsSettingsVisible="False"

View file

@ -3,6 +3,7 @@ using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Views.Settings;
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using System; using System;
@ -12,6 +13,16 @@ namespace Ryujinx.Ava.UI.Windows
{ {
private SettingsViewModel ViewModel { get; } private SettingsViewModel ViewModel { get; }
public readonly SettingsUiView UiPage;
public readonly SettingsInputView InputPage;
public readonly SettingsHotkeysView HotkeysPage;
public readonly SettingsSystemView SystemPage;
public readonly SettingsCPUView CpuPage;
public readonly SettingsGraphicsView GraphicsPage;
public readonly SettingsAudioView AudioPage;
public readonly SettingsNetworkView NetworkPage;
public readonly SettingsLoggingView LoggingPage;
public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager) public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager)
{ {
Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}"; Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}";
@ -24,6 +35,16 @@ namespace Ryujinx.Ava.UI.Windows
ViewModel.DirtyEvent += UpdateDirtyTitle; ViewModel.DirtyEvent += UpdateDirtyTitle;
ViewModel.ToggleButtons += ToggleButtons; ViewModel.ToggleButtons += ToggleButtons;
UiPage = new SettingsUiView(ViewModel);
InputPage = new SettingsInputView(ViewModel);
HotkeysPage = new SettingsHotkeysView();
SystemPage = new SettingsSystemView(ViewModel);
CpuPage = new SettingsCPUView();
GraphicsPage = new SettingsGraphicsView();
AudioPage = new SettingsAudioView();
NetworkPage = new SettingsNetworkView();
LoggingPage = new SettingsLoggingView();
InitializeComponent(); InitializeComponent();
Load(); Load();
} }
@ -68,7 +89,6 @@ namespace Ryujinx.Ava.UI.Windows
private void Load() private void Load()
{ {
Pages.Children.Clear();
NavPanel.SelectionChanged += NavPanelOnSelectionChanged; NavPanel.SelectionChanged += NavPanelOnSelectionChanged;
NavPanel.SelectedItem = NavPanel.MenuItems.ElementAt(0); NavPanel.SelectedItem = NavPanel.MenuItems.ElementAt(0);
} }
@ -80,7 +100,6 @@ namespace Ryujinx.Ava.UI.Windows
switch (navItem.Tag.ToString()) switch (navItem.Tag.ToString())
{ {
case "UiPage": case "UiPage":
UiPage.ViewModel = ViewModel;
NavPanel.Content = UiPage; NavPanel.Content = UiPage;
break; break;
case "InputPage": case "InputPage":
@ -90,7 +109,6 @@ namespace Ryujinx.Ava.UI.Windows
NavPanel.Content = HotkeysPage; NavPanel.Content = HotkeysPage;
break; break;
case "SystemPage": case "SystemPage":
SystemPage.ViewModel = ViewModel;
NavPanel.Content = SystemPage; NavPanel.Content = SystemPage;
break; break;
case "CpuPage": case "CpuPage":