aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Windows
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2022-11-25 12:41:34 +0100
committerGitHub <noreply@github.com>2022-11-25 12:41:34 +0100
commit3fbacd0f495f087af5a6316da5abe2b4595d8c9d (patch)
treeac444a50ef8f85af172069a49b70f98514082d67 /Ryujinx.Ava/Ui/Windows
parent7aa6abc12038b949f26c5f1ad1d4559c81fdc1af (diff)
ava: Rework DLC Manager, Add various fixes and cleanup (#3896)
* Fixes Everything Part.2 * Change sorting, fix remove and heading
Diffstat (limited to 'Ryujinx.Ava/Ui/Windows')
-rw-r--r--Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml145
-rw-r--r--Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs151
-rw-r--r--Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs23
-rw-r--r--Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml2
-rw-r--r--Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml.cs62
-rw-r--r--Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs7
6 files changed, 234 insertions, 156 deletions
diff --git a/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml b/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml
index 068ea826..0189c505 100644
--- a/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml
+++ b/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml
@@ -3,89 +3,126 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:window="clr-namespace:Ryujinx.Ava.Ui.Windows"
+ Width="800"
+ Height="500"
+ MinWidth="600"
+ MinHeight="500"
SizeToContent="Height"
- Width="600" MinHeight="500" Height="500"
WindowStartupLocation="CenterOwner"
- MinWidth="600"
mc:Ignorable="d">
<Grid Name="DownloadableContentGrid" Margin="15">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
+ Name="Heading"
Grid.Row="1"
+ MaxWidth="500"
Margin="20,15,20,20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
- MaxWidth="500"
LineHeight="18"
- TextWrapping="Wrap"
- Text="{Binding Heading}"
- TextAlignment="Center" />
- <Border
+ TextAlignment="Center"
+ TextWrapping="Wrap" />
+ <DockPanel
Grid.Row="2"
+ Margin="0"
+ HorizontalAlignment="Left">
+ <Button
+ Name="EnableAllButton"
+ MinWidth="90"
+ Margin="5"
+ Command="{Binding EnableAll}">
+ <TextBlock Text="{locale:Locale DlcManagerEnableAllButton}" />
+ </Button>
+ <Button
+ Name="DisableAllButton"
+ MinWidth="90"
+ Margin="5"
+ Command="{Binding DisableAll}">
+ <TextBlock Text="{locale:Locale DlcManagerDisableAllButton}" />
+ </Button>
+ </DockPanel>
+ <Border
+ Grid.Row="3"
Margin="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="Gray"
BorderThickness="1">
- <DataGrid
- MinHeight="200"
- HorizontalAlignment="Stretch"
+ <ScrollViewer
VerticalAlignment="Stretch"
HorizontalScrollBarVisibility="Auto"
- Items="{Binding DownloadableContents}"
VerticalScrollBarVisibility="Auto">
- <DataGrid.Columns>
- <DataGridTemplateColumn Width="90">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <CheckBox
- Width="50"
- MinWidth="40"
- HorizontalAlignment="Right"
- IsChecked="{Binding Enabled}" />
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- <DataGridTemplateColumn.Header>
- <TextBlock Text="{locale:Locale DlcManagerTableHeadingEnabledLabel}" />
- </DataGridTemplateColumn.Header>
- </DataGridTemplateColumn>
- <DataGridTextColumn
- Width="190"
- Binding="{Binding TitleId}"
- CanUserResize="True">
- <DataGridTextColumn.Header>
- <TextBlock Text="{locale:Locale DlcManagerTableHeadingTitleIdLabel}" />
- </DataGridTextColumn.Header>
- </DataGridTextColumn>
- <DataGridTextColumn
- Width="*"
- Binding="{Binding ContainerPath}"
- CanUserResize="True">
- <DataGridTextColumn.Header>
- <TextBlock Text="{locale:Locale DlcManagerTableHeadingContainerPathLabel}" />
- </DataGridTextColumn.Header>
- </DataGridTextColumn>
- <DataGridTextColumn
- Width="*"
- Binding="{Binding FullPath}"
- CanUserResize="True">
- <DataGridTextColumn.Header>
- <TextBlock Text="{locale:Locale DlcManagerTableHeadingFullPathLabel}" />
- </DataGridTextColumn.Header>
- </DataGridTextColumn>
- </DataGrid.Columns>
- </DataGrid>
+ <DataGrid
+ Name="DlcDataGrid"
+ MinHeight="200"
+ HorizontalAlignment="Stretch"
+ VerticalAlignment="Stretch"
+ CanUserReorderColumns="False"
+ CanUserResizeColumns="True"
+ CanUserSortColumns="True"
+ HorizontalScrollBarVisibility="Auto"
+ Items="{Binding _downloadableContents}"
+ SelectionMode="Extended"
+ VerticalScrollBarVisibility="Auto">
+ <DataGrid.Styles>
+ <Styles>
+ <Style Selector="DataGridCell:nth-child(3), DataGridCell:nth-child(4)">
+ <Setter Property="HorizontalAlignment" Value="Left" />
+ <Setter Property="HorizontalContentAlignment" Value="Left" />
+ </Style>
+ </Styles>
+ <Styles>
+ <Style Selector="DataGridCell:nth-child(1)">
+ <Setter Property="HorizontalAlignment" Value="Right" />
+ <Setter Property="HorizontalContentAlignment" Value="Right" />
+ </Style>
+ </Styles>
+ </DataGrid.Styles>
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Width="90">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <CheckBox
+ Width="50"
+ MinWidth="40"
+ HorizontalAlignment="Center"
+ IsChecked="{Binding Enabled}" />
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ <DataGridTemplateColumn.Header>
+ <TextBlock Text="{locale:Locale DlcManagerTableHeadingEnabledLabel}" />
+ </DataGridTemplateColumn.Header>
+ </DataGridTemplateColumn>
+ <DataGridTextColumn Width="140" Binding="{Binding TitleId}">
+ <DataGridTextColumn.Header>
+ <TextBlock Text="{locale:Locale DlcManagerTableHeadingTitleIdLabel}" />
+ </DataGridTextColumn.Header>
+ </DataGridTextColumn>
+ <DataGridTextColumn Width="280" Binding="{Binding FullPath}">
+ <DataGridTextColumn.Header>
+ <TextBlock Text="{locale:Locale DlcManagerTableHeadingFullPathLabel}" />
+ </DataGridTextColumn.Header>
+ </DataGridTextColumn>
+ <DataGridTextColumn Binding="{Binding ContainerPath}">
+ <DataGridTextColumn.Header>
+ <TextBlock Text="{locale:Locale DlcManagerTableHeadingContainerPathLabel}" />
+ </DataGridTextColumn.Header>
+ </DataGridTextColumn>
+ </DataGrid.Columns>
+ </DataGrid>
+ </ScrollViewer>
</Border>
<DockPanel
- Grid.Row="3"
+ Grid.Row="4"
Margin="0"
HorizontalAlignment="Stretch">
<DockPanel Margin="0" HorizontalAlignment="Left">
diff --git a/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs
index 972ffbc3..b1c86afc 100644
--- a/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs
+++ b/Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs
@@ -8,6 +8,7 @@ using LibHac.FsSystem;
using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.NcaUtils;
+using LibHac.Tools.FsSystem.Save;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Ui.Controls;
using Ryujinx.Ava.Ui.Models;
@@ -16,8 +17,11 @@ using Ryujinx.Common.Utilities;
using Ryujinx.HLE.FileSystem;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Path = System.IO.Path;
@@ -27,14 +31,13 @@ namespace Ryujinx.Ava.Ui.Windows
public partial class DownloadableContentManagerWindow : StyleableWindow
{
private readonly List<DownloadableContentContainer> _downloadableContentContainerList;
- private readonly string _downloadableContentJsonPath;
+ private readonly string _downloadableContentJsonPath;
- public VirtualFileSystem VirtualFileSystem { get; }
- public AvaloniaList<DownloadableContentModel> DownloadableContents { get; set; } = new AvaloniaList<DownloadableContentModel>();
- public ulong TitleId { get; }
- public string TitleName { get; }
+ private VirtualFileSystem _virtualFileSystem { get; }
+ private AvaloniaList<DownloadableContentModel> _downloadableContents { get; set; }
- public string Heading => string.Format(LocaleManager.Instance["DlcWindowHeading"], TitleName, TitleId.ToString("X16"));
+ private ulong TitleId { get; }
+ private string TitleName { get; }
public DownloadableContentManagerWindow()
{
@@ -42,14 +45,15 @@ namespace Ryujinx.Ava.Ui.Windows
InitializeComponent();
- Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
+ Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance["DlcWindowTitle"]} - {TitleName} ({TitleId:X16})";
}
public DownloadableContentManagerWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
{
- VirtualFileSystem = virtualFileSystem;
- TitleId = titleId;
- TitleName = titleName;
+ _virtualFileSystem = virtualFileSystem;
+ _downloadableContents = new AvaloniaList<DownloadableContentModel>();
+ TitleId = titleId;
+ TitleName = titleName;
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId.ToString("x16"), "dlc.json");
@@ -66,9 +70,24 @@ namespace Ryujinx.Ava.Ui.Windows
InitializeComponent();
- Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
+ RemoveButton.IsEnabled = false;
+
+ DlcDataGrid.SelectionChanged += DlcDataGrid_SelectionChanged;
+
+ Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance["DlcWindowTitle"]} - {TitleName} ({TitleId:X16})";
LoadDownloadableContents();
+ PrintHeading();
+ }
+
+ private void DlcDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ RemoveButton.IsEnabled = (DlcDataGrid.SelectedItems.Count > 0);
+ }
+
+ private void PrintHeading()
+ {
+ Heading.Text = string.Format(LocaleManager.Instance["DlcWindowHeading"], _downloadableContents.Count, TitleName, TitleId.ToString("X16"));
}
private void LoadDownloadableContents()
@@ -79,23 +98,23 @@ namespace Ryujinx.Ava.Ui.Windows
{
using FileStream containerFile = File.OpenRead(downloadableContentContainer.ContainerPath);
- PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
+ PartitionFileSystem pfs = new(containerFile.AsStorage());
- VirtualFileSystem.ImportTickets(pfs);
+ _virtualFileSystem.ImportTickets(pfs);
foreach (DownloadableContentNca downloadableContentNca in downloadableContentContainer.DownloadableContentNcaList)
{
- using var ncaFile = new UniqueRef<IFile>();
+ using UniqueRef<IFile> ncaFile = new();
pfs.OpenFile(ref ncaFile.Ref(), downloadableContentNca.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
- Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), downloadableContentContainer.ContainerPath);
+ Nca nca = TryOpenNca(ncaFile.Get.AsStorage(), downloadableContentContainer.ContainerPath);
if (nca != null)
{
- DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"),
- downloadableContentContainer.ContainerPath,
- downloadableContentNca.FullPath,
- downloadableContentNca.Enabled));
+ _downloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"),
+ downloadableContentContainer.ContainerPath,
+ downloadableContentNca.FullPath,
+ downloadableContentNca.Enabled));
}
}
}
@@ -105,11 +124,11 @@ namespace Ryujinx.Ava.Ui.Windows
Save();
}
- private Nca TryCreateNca(IStorage ncaStorage, string containerPath)
+ private Nca TryOpenNca(IStorage ncaStorage, string containerPath)
{
try
{
- return new Nca(VirtualFileSystem.KeySet, ncaStorage);
+ return new Nca(_virtualFileSystem.KeySet, ncaStorage);
}
catch (Exception ex)
{
@@ -124,48 +143,46 @@ namespace Ryujinx.Ava.Ui.Windows
private async Task AddDownloadableContent(string path)
{
- if (!File.Exists(path) || DownloadableContents.FirstOrDefault(x => x.ContainerPath == path) != null)
+ if (!File.Exists(path) || _downloadableContents.FirstOrDefault(x => x.ContainerPath == path) != null)
{
return;
}
- using (FileStream containerFile = File.OpenRead(path))
- {
- PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
- bool containsDownloadableContent = false;
+ using FileStream containerFile = File.OpenRead(path);
- VirtualFileSystem.ImportTickets(pfs);
+ PartitionFileSystem partitionFileSystem = new(containerFile.AsStorage());
+ bool containsDownloadableContent = false;
- foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
- {
- using var ncaFile = new UniqueRef<IFile>();
+ _virtualFileSystem.ImportTickets(partitionFileSystem);
+
+ foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.nca"))
+ {
+ using var ncaFile = new UniqueRef<IFile>();
- pfs.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
+ partitionFileSystem.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
- Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), path);
+ Nca nca = TryOpenNca(ncaFile.Get.AsStorage(), path);
+ if (nca == null)
+ {
+ continue;
+ }
- if (nca == null)
+ if (nca.Header.ContentType == NcaContentType.PublicData)
+ {
+ if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000) != TitleId)
{
- continue;
+ break;
}
- if (nca.Header.ContentType == NcaContentType.PublicData)
- {
- if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000) != TitleId)
- {
- break;
- }
-
- DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true));
+ _downloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true));
- containsDownloadableContent = true;
- }
+ containsDownloadableContent = true;
}
+ }
- if (!containsDownloadableContent)
- {
- await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]);
- }
+ if (!containsDownloadableContent)
+ {
+ await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]);
}
}
@@ -173,12 +190,26 @@ namespace Ryujinx.Ava.Ui.Windows
{
if (removeSelectedOnly)
{
- DownloadableContents.RemoveAll(DownloadableContents.Where(x => x.Enabled).ToList());
+ AvaloniaList<DownloadableContentModel> removedItems = new();
+
+ foreach (var item in DlcDataGrid.SelectedItems)
+ {
+ removedItems.Add(item as DownloadableContentModel);
+ }
+
+ DlcDataGrid.SelectedItems.Clear();
+
+ foreach (var item in removedItems)
+ {
+ _downloadableContents.RemoveAll(_downloadableContents.Where(x => x.TitleId == item.TitleId).ToList());
+ }
}
else
{
- DownloadableContents.Clear();
+ _downloadableContents.Clear();
}
+
+ PrintHeading();
}
public void RemoveSelected()
@@ -191,6 +222,22 @@ namespace Ryujinx.Ava.Ui.Windows
RemoveDownloadableContents();
}
+ public void EnableAll()
+ {
+ foreach(var item in _downloadableContents)
+ {
+ item.Enabled = true;
+ }
+ }
+
+ public void DisableAll()
+ {
+ foreach (var item in _downloadableContents)
+ {
+ item.Enabled = false;
+ }
+ }
+
public async void Add()
{
OpenFileDialog dialog = new OpenFileDialog()
@@ -214,6 +261,8 @@ namespace Ryujinx.Ava.Ui.Windows
await AddDownloadableContent(file);
}
}
+
+ PrintHeading();
}
public void Save()
@@ -222,7 +271,7 @@ namespace Ryujinx.Ava.Ui.Windows
DownloadableContentContainer container = default;
- foreach (DownloadableContentModel downloadableContent in DownloadableContents)
+ foreach (DownloadableContentModel downloadableContent in _downloadableContents)
{
if (container.ContainerPath != downloadableContent.ContainerPath)
{
diff --git a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs
index be4517c8..e874982a 100644
--- a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs
+++ b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs
@@ -90,8 +90,8 @@ namespace Ryujinx.Ava.Ui.Windows
Title = $"Ryujinx {Program.Version}";
- Height = Height / Program.WindowScaleFactor;
- Width = Width / Program.WindowScaleFactor;
+ Height /= Program.WindowScaleFactor;
+ Width /= Program.WindowScaleFactor;
if (Program.PreviewerDetached)
{
@@ -523,23 +523,20 @@ namespace Ryujinx.Ava.Ui.Windows
public static void UpdateGraphicsConfig()
{
- int resScale = ConfigurationState.Instance.Graphics.ResScale;
- float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
-
- GraphicsConfig.ResScale = resScale == -1 ? resScaleCustom : resScale;
- GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
- GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
- GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
+ GraphicsConfig.ResScale = ConfigurationState.Instance.Graphics.ResScale == -1 ? ConfigurationState.Instance.Graphics.ResScaleCustom : ConfigurationState.Instance.Graphics.ResScale;
+ GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
+ GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
+ GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
- GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
+ GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
}
public void LoadHotKeys()
{
- HotKeyManager.SetHotKey(FullscreenHotKey, new KeyGesture(Key.Enter, KeyModifiers.Alt));
+ HotKeyManager.SetHotKey(FullscreenHotKey, new KeyGesture(Key.Enter, KeyModifiers.Alt));
HotKeyManager.SetHotKey(FullscreenHotKey2, new KeyGesture(Key.F11));
- HotKeyManager.SetHotKey(DockToggleHotKey, new KeyGesture(Key.F9));
- HotKeyManager.SetHotKey(ExitHotKey, new KeyGesture(Key.Escape));
+ HotKeyManager.SetHotKey(DockToggleHotKey, new KeyGesture(Key.F9));
+ HotKeyManager.SetHotKey(ExitHotKey, new KeyGesture(Key.Escape));
}
public static void SaveConfig()
diff --git a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
index 0946a2eb..1791d8ea 100644
--- a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
+++ b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml
@@ -75,7 +75,7 @@
Spacing="10">
<ListBox
Name="GameList"
- MinHeight="150"
+ MinHeight="250"
Items="{Binding GameDirectories}" />
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
diff --git a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml.cs
index 810beb3e..0e610d77 100644
--- a/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml.cs
+++ b/Ryujinx.Ava/Ui/Windows/SettingsWindow.axaml.cs
@@ -16,7 +16,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Threading.Tasks;
using TimeZone = Ryujinx.Ava.Ui.Models.TimeZone;
namespace Ryujinx.Ava.Ui.Windows
@@ -31,7 +30,7 @@ namespace Ryujinx.Ava.Ui.Windows
{
Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance["Settings"]}";
- ViewModel = new SettingsViewModel(virtualFileSystem, contentManager, this);
+ ViewModel = new SettingsViewModel(virtualFileSystem, contentManager, this);
DataContext = ViewModel;
InitializeComponent();
@@ -48,7 +47,7 @@ namespace Ryujinx.Ava.Ui.Windows
public SettingsWindow()
{
- ViewModel = new SettingsViewModel();
+ ViewModel = new SettingsViewModel();
DataContext = ViewModel;
InitializeComponent();
@@ -79,7 +78,7 @@ namespace Ryujinx.Ava.Ui.Windows
PointerPressed += MouseClick;
- IKeyboard keyboard = (IKeyboard)ViewModel.AvaloniaKeyboardDriver.GetGamepad(ViewModel.AvaloniaKeyboardDriver.GamepadsIds[0]);
+ IKeyboard keyboard = (IKeyboard)ViewModel.AvaloniaKeyboardDriver.GetGamepad(ViewModel.AvaloniaKeyboardDriver.GamepadsIds[0]);
IButtonAssigner assigner = new KeyboardKeyAssigner(keyboard);
_currentAssigner.GetInputAndAssign(assigner);
@@ -92,6 +91,7 @@ namespace Ryujinx.Ava.Ui.Windows
_currentAssigner.Cancel();
_currentAssigner = null;
+
button.IsChecked = false;
}
}
@@ -122,36 +122,19 @@ namespace Ryujinx.Ava.Ui.Windows
{
if (e.SelectedItem is NavigationViewItem navitem)
{
- switch (navitem.Tag.ToString())
+ NavPanel.Content = navitem.Tag.ToString() switch
{
- case "UiPage":
- NavPanel.Content = UiPage;
- break;
- case "InputPage":
- NavPanel.Content = InputPage;
- break;
- case "HotkeysPage":
- NavPanel.Content = HotkeysPage;
- break;
- case "SystemPage":
- NavPanel.Content = SystemPage;
- break;
- case "CpuPage":
- NavPanel.Content = CpuPage;
- break;
- case "GraphicsPage":
- NavPanel.Content = GraphicsPage;
- break;
- case "AudioPage":
- NavPanel.Content = AudioPage;
- break;
- case "NetworkPage":
- NavPanel.Content = NetworkPage;
- break;
- case "LoggingPage":
- NavPanel.Content = LoggingPage;
- break;
- }
+ "UiPage" => UiPage,
+ "InputPage" => InputPage,
+ "HotkeysPage" => HotkeysPage,
+ "SystemPage" => SystemPage,
+ "CpuPage" => CpuPage,
+ "GraphicsPage" => GraphicsPage,
+ "AudioPage" => AudioPage,
+ "NetworkPage" => NetworkPage,
+ "LoggingPage" => LoggingPage,
+ _ => throw new NotImplementedException()
+ };
}
}
@@ -178,13 +161,18 @@ namespace Ryujinx.Ava.Ui.Windows
private void RemoveButton_OnClick(object sender, RoutedEventArgs e)
{
- List<string> selected = new(GameList.SelectedItems.Cast<string>());
+ int oldIndex = GameList.SelectedIndex;
- foreach (string path in selected)
+ foreach (string path in new List<string>(GameList.SelectedItems.Cast<string>()))
{
ViewModel.GameDirectories.Remove(path);
ViewModel.DirectoryChanged = true;
}
+
+ if (GameList.ItemCount > 0)
+ {
+ GameList.SelectedIndex = oldIndex < GameList.ItemCount ? oldIndex : 0;
+ }
}
private void TimeZoneBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -214,7 +202,6 @@ namespace Ryujinx.Ava.Ui.Windows
private void SaveButton_Clicked(object sender, RoutedEventArgs e)
{
SaveSettings();
-
Close();
}
@@ -232,7 +219,6 @@ namespace Ryujinx.Ava.Ui.Windows
private void SaveSettings()
{
ViewModel.SaveSettings();
-
ControllerSettings?.SaveCurrentProfile();
if (Owner is MainWindow window && ViewModel.DirectoryChanged)
@@ -246,8 +232,10 @@ namespace Ryujinx.Ava.Ui.Windows
protected override void OnClosed(EventArgs e)
{
ControllerSettings.Dispose();
+
_currentAssigner?.Cancel();
_currentAssigner = null;
+
base.OnClosed(e);
}
}
diff --git a/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs
index b4d5d5b5..751c7afc 100644
--- a/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs
+++ b/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs
@@ -131,6 +131,13 @@ namespace Ryujinx.Ava.Ui.Windows
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure();
TitleUpdates.Add(new TitleUpdateModel(controlData, path));
+
+ foreach (var update in TitleUpdates)
+ {
+ update.IsEnabled = false;
+ }
+
+ TitleUpdates.Last().IsEnabled = true;
}
else
{