mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-04-24 20:12:58 +00:00
known bugs are a missing prod.keys popup after setup (how), as well as the dialog for autoload kinda cluttering up the screen after you hit next on the game dir page
154 lines
5.8 KiB
C#
154 lines
5.8 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Platform.Storage;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Gommon;
|
|
using Ryujinx.Ava.Common.Locale;
|
|
using Ryujinx.Ava.UI.Helpers;
|
|
using Ryujinx.Ava.Utilities;
|
|
using Ryujinx.Common;
|
|
using Ryujinx.Common.Configuration;
|
|
using Ryujinx.HLE.FileSystem;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ryujinx.Ava.UI.SetupWizard.Pages
|
|
{
|
|
public partial class SetupFirmwarePageContext() : SetupWizardPageContext(LocaleKeys.SetupWizardFirmwarePageTitle)
|
|
{
|
|
[ObservableProperty]
|
|
public partial string FirmwareSourcePath { get; set; }
|
|
|
|
[RelayCommand]
|
|
private static async Task BrowseFile(TextBox tb)
|
|
{
|
|
Optional<IStorageFile> result = await RyujinxApp.MainWindow.ViewModel.StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions
|
|
{
|
|
Title = LocaleManager.Instance[LocaleKeys.SetupWizardFirmwarePageFilePopupTitle],
|
|
FileTypeFilter = new List<FilePickerFileType>
|
|
{
|
|
new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
|
|
{
|
|
Patterns = ["*.xci", "*.zip"],
|
|
AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"],
|
|
MimeTypes = ["application/x-nx-xci", "application/zip"],
|
|
},
|
|
new("XCI")
|
|
{
|
|
Patterns = ["*.xci"],
|
|
AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
|
|
MimeTypes = ["application/x-nx-xci"],
|
|
},
|
|
new("ZIP")
|
|
{
|
|
Patterns = ["*.zip"],
|
|
AppleUniformTypeIdentifiers = ["public.zip-archive"],
|
|
MimeTypes = ["application/zip"],
|
|
}
|
|
}
|
|
});
|
|
|
|
if (result.TryGet(out IStorageFile firmwareFile))
|
|
{
|
|
tb.Text = firmwareFile.TryGetLocalPath();
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static async Task BrowseFolder(TextBox tb)
|
|
{
|
|
Optional<IStorageFolder> result = await RyujinxApp.MainWindow.ViewModel.StorageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions
|
|
{
|
|
Title = LocaleManager.Instance[LocaleKeys.SetupWizardFirmwarePageFolderPopupTitle]
|
|
});
|
|
|
|
if (result.TryGet(out IStorageFolder firmwareFolder))
|
|
{
|
|
tb.Text = firmwareFolder.TryGetLocalPath();
|
|
}
|
|
}
|
|
|
|
public override object CreateHelpContent()
|
|
{
|
|
Grid grid = new()
|
|
{
|
|
RowDefinitions = [new(GridLength.Auto), new(GridLength.Auto)],
|
|
HorizontalAlignment = HorizontalAlignment.Center
|
|
};
|
|
|
|
grid.Children.Add(new TextBlock
|
|
{
|
|
Text = "Not sure how to get your firmware off of your Switch?",
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
GridRow = 0
|
|
});
|
|
|
|
grid.Children.Add(new HyperlinkButton
|
|
{
|
|
Content = "Click here to view a guide.",
|
|
NavigateUri = new Uri(SharedConstants.DumpFirmwareWikiUrl),
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
GridRow = 1
|
|
});
|
|
|
|
return grid;
|
|
}
|
|
|
|
public override Result CompleteStep()
|
|
{
|
|
if (string.IsNullOrEmpty(FirmwareSourcePath) && RyujinxSetupWizard.HasFirmware)
|
|
{
|
|
NotificationManager.Information(
|
|
title: LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
|
|
"Skipped setting up firmware as you already have a valid firmware installation and did not choose a folder or file to install from.\n\nClick 'Back' if you wish to overwrite your firmware.");
|
|
return Result.Success; // This handles the user selecting no file/dir and just hitting Next.
|
|
}
|
|
|
|
if (!Directory.Exists(FirmwareSourcePath))
|
|
return Result.Fail;
|
|
|
|
try
|
|
{
|
|
RyujinxApp.MainWindow.ContentManager.InstallFirmware(FirmwareSourcePath);
|
|
SystemVersion installedFwVer = RyujinxApp.MainWindow.ContentManager.GetCurrentFirmwareVersion();
|
|
if (installedFwVer != null)
|
|
{
|
|
NotificationManager.Information(
|
|
"Firmware installed",
|
|
$"Installed firmware version {installedFwVer.VersionString}."
|
|
);
|
|
}
|
|
else
|
|
{
|
|
NotificationManager.Error(
|
|
"Firmware not installed",
|
|
$"It seems some error occurred when trying to install the firmware at path '{FirmwareSourcePath}'." +
|
|
"\nDid that folder contain a firmware dump?"
|
|
);
|
|
}
|
|
RyujinxApp.MainWindow.ViewModel.RefreshFirmwareStatus(installedFwVer, allowNullVersion: true);
|
|
|
|
// Purge Applet Cache.
|
|
|
|
DirectoryInfo miiEditorCacheFolder = new(
|
|
Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache")
|
|
);
|
|
|
|
if (miiEditorCacheFolder.Exists)
|
|
{
|
|
miiEditorCacheFolder.Delete(true);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
NotificationManager.Error(e.Message, waitingExit: true);
|
|
return Result.Fail;
|
|
}
|
|
|
|
return Result.Success;
|
|
}
|
|
}
|
|
}
|