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