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