Compare commits

...

4 Commits

Author SHA1 Message Date
TSRBerry
31a9eb9419
Merge 869732e8ed into 5dbba07e33 2024-09-28 16:01:10 +02:00
TSR Berry
869732e8ed
Catch HorizonResultException in TryLoad 2024-08-28 17:52:27 +02:00
TSR Berry
7fca6ad333
Fix check for application id when launching directly from the command line 2024-08-28 17:52:27 +02:00
TSR Berry
32b4e9d136
optimization: Avoid enumerating applications multiple times 2024-08-28 17:52:27 +02:00
4 changed files with 32 additions and 26 deletions

View File

@ -318,15 +318,13 @@ namespace Ryujinx
{ {
if (mainWindow.ApplicationLibrary.TryGetApplicationsFromFile(CommandLineState.LaunchPathArg, out List<ApplicationData> applications)) if (mainWindow.ApplicationLibrary.TryGetApplicationsFromFile(CommandLineState.LaunchPathArg, out List<ApplicationData> applications))
{ {
ApplicationData applicationData;
if (CommandLineState.LaunchApplicationId != null) if (CommandLineState.LaunchApplicationId != null)
{ {
applicationData = applications.Find(application => application.IdString == CommandLineState.LaunchApplicationId); int applicationIndex = applications.FindIndex(application => application.IdString.Equals(CommandLineState.LaunchApplicationId, StringComparison.InvariantCultureIgnoreCase));
if (applicationData != null) if (applicationIndex != -1)
{ {
mainWindow.RunApplication(applicationData, CommandLineState.StartFullscreenArg); mainWindow.RunApplication(applications[applicationIndex], CommandLineState.StartFullscreenArg);
} }
else else
{ {
@ -336,8 +334,7 @@ namespace Ryujinx
} }
else else
{ {
applicationData = applications[0]; mainWindow.RunApplication(applications[0], CommandLineState.StartFullscreenArg);
mainWindow.RunApplication(applicationData, CommandLineState.StartFullscreenArg);
} }
} }
else else

View File

@ -71,10 +71,11 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
if (applicationId == 0) if (applicationId == 0)
{ {
foreach ((ulong _, ContentMetaData content) in applications) foreach ((ulong id, ContentMetaData content) in applications)
{ {
mainNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Program, device.Configuration.UserChannelPersistence.Index); mainNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Program, device.Configuration.UserChannelPersistence.Index);
controlNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Control, device.Configuration.UserChannelPersistence.Index); controlNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Control, device.Configuration.UserChannelPersistence.Index);
applicationId = id;
break; break;
} }
} }
@ -142,7 +143,24 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
} }
} }
return (true, mainNca.Load(device, patchNca, controlNca)); try
{
return (true, mainNca.Load(device, patchNca, controlNca));
}
catch (HorizonResultException ex)
{
// The exception message already contains enough information here.
errorMessage = $"Failed to load: {ex.Message}";
return (false, ProcessResult.Failed);
}
catch (Exception ex)
{
// Add the stacktrace in addition to the exception message.
errorMessage = $"Failed to load: {ex}";
return (false, ProcessResult.Failed);
}
} }
errorMessage = $"Unable to load: Could not find Main NCA for title \"{applicationId:X16}\""; errorMessage = $"Unable to load: Could not find Main NCA for title \"{applicationId:X16}\"";

View File

@ -576,19 +576,13 @@ namespace Ryujinx.UI.App.Common
{ {
AppData = application, AppData = application,
}); });
}
if (applications.Count > 1) numApplicationsFound++;
{ numApplicationsLoaded++;
numApplicationsFound += applications.Count - 1;
} }
}
numApplicationsLoaded += applications.Count; numApplicationsFound--;
}
else
{
numApplicationsFound--;
}
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{ {

View File

@ -325,15 +325,13 @@ namespace Ryujinx.Ava.UI.Windows
if (ApplicationLibrary.TryGetApplicationsFromFile(_launchPath, out List<ApplicationData> applications)) if (ApplicationLibrary.TryGetApplicationsFromFile(_launchPath, out List<ApplicationData> applications))
{ {
ApplicationData applicationData;
if (_launchApplicationId != null) if (_launchApplicationId != null)
{ {
applicationData = applications.Find(application => application.IdString == _launchApplicationId); int applicationIndex = applications.FindIndex(application => application.IdString.Equals(_launchApplicationId, StringComparison.InvariantCultureIgnoreCase));
if (applicationData != null) if (applicationIndex != -1)
{ {
await ViewModel.LoadApplication(applicationData, _startFullscreen); await ViewModel.LoadApplication(applications[applicationIndex], _startFullscreen);
} }
else else
{ {
@ -343,8 +341,7 @@ namespace Ryujinx.Ava.UI.Windows
} }
else else
{ {
applicationData = applications[0]; await ViewModel.LoadApplication(applications[0], _startFullscreen);
await ViewModel.LoadApplication(applicationData, _startFullscreen);
} }
} }
else else