aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2023-03-31 21:16:46 +0200
committerGitHub <noreply@github.com>2023-03-31 21:16:46 +0200
commit4c2d9ff3ff9d7afb1fd0bd764bee5931fa5f053c (patch)
tree1245f5ec356551bd20a9594d114d06a53c41d036 /Ryujinx.Ava
parent8198b99935f562ffb2fb9a75175a8df24d235152 (diff)
HLE: Refactoring of ApplicationLoader (#4480)
* HLE: Refactoring of ApplicationLoader * Fix SDL2 Headless * Addresses gdkchan feedback * Fixes LoadUnpackedNca RomFS loading * remove useless casting * Cleanup and fixe empty application name * Remove ProcessInfo * Fixes typo * ActiveProcess to ActiveApplication * Update check * Clean using. * Use the correct filepath when loading Homebrew.npdm * Fix NRE in ProcessResult if MetaLoader is null * Add more checks for valid processId & return success * Add missing logging statement for npdm error * Return result for LoadKip() * Move error logging out of PFS load extension method This avoids logging "Could not find Main NCA" followed by "Loading main..." when trying to start hbl. * Fix GUIs not checking load results * Fix style and formatting issues * Fix formatting and wording * gtk: Refactor LoadApplication() --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
Diffstat (limited to 'Ryujinx.Ava')
-rw-r--r--Ryujinx.Ava/AppHost.cs77
-rw-r--r--Ryujinx.Ava/Common/ApplicationHelper.cs3
-rw-r--r--Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs10
-rw-r--r--Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs3
-rw-r--r--Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs12
5 files changed, 72 insertions, 33 deletions
diff --git a/Ryujinx.Ava/AppHost.cs b/Ryujinx.Ava/AppHost.cs
index eb22b39e..3cdb3906 100644
--- a/Ryujinx.Ava/AppHost.cs
+++ b/Ryujinx.Ava/AppHost.cs
@@ -320,10 +320,14 @@ namespace Ryujinx.Ava
_viewModel.IsGameRunning = true;
- string titleNameSection = string.IsNullOrWhiteSpace(Device.Application.TitleName) ? string.Empty : $" - {Device.Application.TitleName}";
- string titleVersionSection = string.IsNullOrWhiteSpace(Device.Application.DisplayVersion) ? string.Empty : $" v{Device.Application.DisplayVersion}";
- string titleIdSection = string.IsNullOrWhiteSpace(Device.Application.TitleIdText) ? string.Empty : $" ({Device.Application.TitleIdText.ToUpper()})";
- string titleArchSection = Device.Application.TitleIs64Bit ? " (64-bit)" : " (32-bit)";
+ var activeProcess = Device.Processes.ActiveApplication;
+ var nacp = activeProcess.ApplicationControlProperties;
+ int desiredLanguage = (int)Device.System.State.DesiredTitleLanguage;
+
+ string titleNameSection = string.IsNullOrWhiteSpace(nacp.Title[desiredLanguage].NameString.ToString()) ? string.Empty : $" - {nacp.Title[desiredLanguage].NameString.ToString()}";
+ string titleVersionSection = string.IsNullOrWhiteSpace(nacp.DisplayVersionString.ToString()) ? string.Empty : $" v{nacp.DisplayVersionString.ToString()}";
+ string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})";
+ string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
Dispatcher.UIThread.InvokeAsync(() =>
{
@@ -423,9 +427,9 @@ namespace Ryujinx.Ava
private void Dispose()
{
- if (Device.Application != null)
+ if (Device.Processes != null)
{
- _viewModel.UpdateGameMetadata(Device.Application.TitleIdText);
+ _viewModel.UpdateGameMetadata(Device.Processes.ActiveApplication.ProgramIdText);
}
ConfigurationState.Instance.System.IgnoreMissingServices.Event -= UpdateIgnoreMissingServicesState;
@@ -539,7 +543,12 @@ namespace Ryujinx.Ava
{
Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
- Device.LoadNca(ApplicationPath);
+ if (!Device.LoadNca(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
}
else if (Directory.Exists(ApplicationPath))
{
@@ -554,13 +563,23 @@ namespace Ryujinx.Ava
{
Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
- Device.LoadCart(ApplicationPath, romFsFiles[0]);
+ if (!Device.LoadCart(ApplicationPath, romFsFiles[0]))
+ {
+ Device.Dispose();
+
+ return false;
+ }
}
else
{
Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
- Device.LoadCart(ApplicationPath);
+ if (!Device.LoadCart(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
}
}
else if (File.Exists(ApplicationPath))
@@ -571,7 +590,12 @@ namespace Ryujinx.Ava
{
Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
- Device.LoadXci(ApplicationPath);
+ if (!Device.LoadXci(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
break;
}
@@ -579,7 +603,12 @@ namespace Ryujinx.Ava
{
Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
- Device.LoadNca(ApplicationPath);
+ if (!Device.LoadNca(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
break;
}
@@ -588,7 +617,12 @@ namespace Ryujinx.Ava
{
Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
- Device.LoadNsp(ApplicationPath);
+ if (!Device.LoadNsp(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
break;
}
@@ -598,13 +632,18 @@ namespace Ryujinx.Ava
try
{
- Device.LoadProgram(ApplicationPath);
+ if (!Device.LoadProgram(ApplicationPath))
+ {
+ Device.Dispose();
+
+ return false;
+ }
}
catch (ArgumentOutOfRangeException)
{
Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
- Dispose();
+ Device.Dispose();
return false;
}
@@ -617,14 +656,14 @@ namespace Ryujinx.Ava
{
Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
- Dispose();
+ Device.Dispose();
return false;
}
- DiscordIntegrationModule.SwitchToPlayingState(Device.Application.TitleIdText, Device.Application.TitleName);
+ DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, Device.Processes.ActiveApplication.Name);
- _viewModel.ApplicationLibrary.LoadAndSaveMetaData(Device.Application.TitleIdText, appMetadata =>
+ _viewModel.ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata =>
{
appMetadata.LastPlayed = DateTime.UtcNow.ToString();
});
@@ -950,7 +989,7 @@ namespace Ryujinx.Ava
{
if (_keyboardInterface.GetKeyboardStateSnapshot().IsPressed(Key.Delete) && _viewModel.WindowState != WindowState.FullScreen)
{
- Device.Application.DiskCacheLoadState?.Cancel();
+ Device.Processes.ActiveApplication.DiskCacheLoadState?.Cancel();
}
});
@@ -1088,4 +1127,4 @@ namespace Ryujinx.Ava
return state;
}
}
-} \ No newline at end of file
+}
diff --git a/Ryujinx.Ava/Common/ApplicationHelper.cs b/Ryujinx.Ava/Common/ApplicationHelper.cs
index 276d1874..161ef859 100644
--- a/Ryujinx.Ava/Common/ApplicationHelper.cs
+++ b/Ryujinx.Ava/Common/ApplicationHelper.cs
@@ -19,6 +19,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS;
using Ryujinx.HLE.HOS.Services.Account.Acc;
+using Ryujinx.Ui.App.Common;
using Ryujinx.Ui.Common.Helper;
using System;
using System.Buffers;
@@ -227,7 +228,7 @@ namespace Ryujinx.Ava.Common
return;
}
- (Nca updatePatchNca, _) = ApplicationLoader.GetGameUpdateData(_virtualFileSystem, mainNca.Header.TitleId.ToString("x16"), programIndex, out _);
+ (Nca updatePatchNca, _) = ApplicationLibrary.GetGameUpdateData(_virtualFileSystem, mainNca.Header.TitleId.ToString("x16"), programIndex, out _);
if (updatePatchNca != null)
{
patchNca = updatePatchNca;
diff --git a/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs b/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs
index a3663af3..d5ff7854 100644
--- a/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs
+++ b/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs
@@ -1208,10 +1208,10 @@ namespace Ryujinx.Ava.UI.ViewModels
public void SetUIProgressHandlers(Switch emulationContext)
{
- if (emulationContext.Application.DiskCacheLoadState != null)
+ if (emulationContext.Processes.ActiveApplication.DiskCacheLoadState != null)
{
- emulationContext.Application.DiskCacheLoadState.StateChanged -= ProgressHandler;
- emulationContext.Application.DiskCacheLoadState.StateChanged += ProgressHandler;
+ emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged -= ProgressHandler;
+ emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged += ProgressHandler;
}
emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
@@ -1705,8 +1705,8 @@ namespace Ryujinx.Ava.UI.ViewModels
if (string.IsNullOrWhiteSpace(titleName))
{
- LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, AppHost.Device.Application.TitleName);
- TitleName = AppHost.Device.Application.TitleName;
+ LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, AppHost.Device.Processes.ActiveApplication.Name);
+ TitleName = AppHost.Device.Processes.ActiveApplication.Name;
}
SwitchToRenderer(startFullscreen);
diff --git a/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs b/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
index dd9e1b96..0798502c 100644
--- a/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
+++ b/Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs
@@ -17,6 +17,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS;
+using Ryujinx.Ui.App.Common;
using System;
using System.Collections.Generic;
using System.IO;
@@ -162,7 +163,7 @@ public class TitleUpdateViewModel : BaseModel
try
{
- (Nca patchNca, Nca controlNca) = ApplicationLoader.GetGameUpdateDataFromPartition(_virtualFileSystem, new PartitionFileSystem(file.AsStorage()), _titleId.ToString("x16"), 0);
+ (Nca patchNca, Nca controlNca) = ApplicationLibrary.GetGameUpdateDataFromPartition(_virtualFileSystem, new PartitionFileSystem(file.AsStorage()), _titleId.ToString("x16"), 0);
if (controlNca != null && patchNca != null)
{
diff --git a/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs b/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs
index 1c6f4265..30d41150 100644
--- a/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs
+++ b/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs
@@ -126,7 +126,7 @@ namespace Ryujinx.Ava.UI.Views.Main
if (ViewModel.AppHost.Device.System.SearchingForAmiibo(out int deviceId))
{
- string titleId = ViewModel.AppHost.Device.Application.TitleIdText.ToUpper();
+ string titleId = ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText.ToUpper();
AmiiboWindow window = new(ViewModel.ShowAll, ViewModel.LastScannedAmiiboId, titleId);
await window.ShowDialog(Window);
@@ -148,13 +148,11 @@ namespace Ryujinx.Ava.UI.Views.Main
return;
}
- ApplicationLoader application = ViewModel.AppHost.Device.Application;
- if (application != null)
- {
- await new CheatWindow(Window.VirtualFileSystem, application.TitleIdText, application.TitleName).ShowDialog(Window);
+ string name = ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage].NameString.ToString();
- ViewModel.AppHost.Device.EnableCheats();
- }
+ await new CheatWindow(Window.VirtualFileSystem, ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText, name).ShowDialog(Window);
+
+ ViewModel.AppHost.Device.EnableCheats();
}
private void ScanAmiiboMenuItem_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)