2022-07-08 18:47:11 +00:00
|
|
|
using Avalonia.Controls;
|
2023-01-15 11:11:52 +00:00
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Avalonia.Styling;
|
|
|
|
using FluentAvalonia.UI.Controls;
|
2022-07-08 18:47:11 +00:00
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-12-29 14:24:05 +00:00
|
|
|
using Ryujinx.Ava.UI.Helpers;
|
|
|
|
using Ryujinx.Ava.UI.Models;
|
2023-01-15 11:11:52 +00:00
|
|
|
using Ryujinx.Ava.UI.ViewModels;
|
2022-07-08 18:47:11 +00:00
|
|
|
using Ryujinx.HLE.FileSystem;
|
2023-01-15 11:11:52 +00:00
|
|
|
using Ryujinx.Ui.Common.Helper;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Button = Avalonia.Controls.Button;
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2022-12-29 14:24:05 +00:00
|
|
|
namespace Ryujinx.Ava.UI.Windows
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
public partial class TitleUpdateWindow : UserControl
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
public TitleUpdateViewModel ViewModel;
|
2022-07-08 18:47:11 +00:00
|
|
|
|
|
|
|
public TitleUpdateWindow()
|
|
|
|
{
|
|
|
|
DataContext = this;
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
2022-11-25 16:55:08 +00:00
|
|
|
public TitleUpdateWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
DataContext = ViewModel = new TitleUpdateViewModel(virtualFileSystem, titleId, titleName);
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
InitializeComponent();
|
|
|
|
}
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
public static async Task Show(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
|
|
|
|
{
|
|
|
|
ContentDialog contentDialog = new()
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
PrimaryButtonText = "",
|
|
|
|
SecondaryButtonText = "",
|
|
|
|
CloseButtonText = "",
|
|
|
|
Content = new TitleUpdateWindow(virtualFileSystem, titleId, titleName),
|
2023-01-21 01:06:19 +00:00
|
|
|
Title = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.GameUpdateWindowHeading, titleName, titleId.ToString("X16"))
|
2023-01-15 11:11:52 +00:00
|
|
|
};
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
Style bottomBorder = new(x => x.OfType<Grid>().Name("DialogSpace").Child().OfType<Border>());
|
|
|
|
bottomBorder.Setters.Add(new Setter(IsVisibleProperty, false));
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
contentDialog.Styles.Add(bottomBorder);
|
2022-07-28 22:41:34 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
await ContentDialogHelper.ShowAsync(contentDialog);
|
2022-11-25 16:55:08 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
private void Close(object sender, RoutedEventArgs e)
|
2022-11-25 16:55:08 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
((ContentDialog)Parent).Hide();
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
public void Save(object sender, RoutedEventArgs e)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-22 00:42:55 +00:00
|
|
|
ViewModel.Save();
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
if (VisualRoot is MainWindow window)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
window.ViewModel.LoadApplications();
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
((ContentDialog)Parent).Hide();
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
private void OpenLocation(object sender, RoutedEventArgs e)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
if (sender is Button button)
|
2022-07-28 22:41:34 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
if (button.DataContext is TitleUpdateModel model)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
OpenHelper.LocateFile(model.Path);
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
private void RemoveUpdate(object sender, RoutedEventArgs e)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
if (sender is Button button)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
ViewModel.RemoveUpdate((TitleUpdateModel)button.DataContext);
|
|
|
|
}
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
private void RemoveAll(object sender, RoutedEventArgs e)
|
2022-07-08 18:47:11 +00:00
|
|
|
{
|
2023-01-15 11:11:52 +00:00
|
|
|
ViewModel.TitleUpdates.Clear();
|
2022-07-08 18:47:11 +00:00
|
|
|
|
2023-01-15 11:11:52 +00:00
|
|
|
ViewModel.SortUpdates();
|
2022-07-08 18:47:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|