HLE: Deal with empty title names properly (#4643)
* hle: Deal with empty titleNames in some languages * gui: Fix displaying the wrong title name * Remove unnecessary bounds check * Fix a NRE when getting the version string * Restore empty string logic
This commit is contained in:
parent
a64fee29dc
commit
e187a8870a
3 changed files with 23 additions and 37 deletions
|
@ -321,17 +321,15 @@ namespace Ryujinx.Ava
|
||||||
_viewModel.IsGameRunning = true;
|
_viewModel.IsGameRunning = true;
|
||||||
|
|
||||||
var activeProcess = Device.Processes.ActiveApplication;
|
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 titleNameSection = string.IsNullOrWhiteSpace(activeProcess.Name) ? string.Empty : $" {activeProcess.Name}";
|
||||||
string titleVersionSection = string.IsNullOrWhiteSpace(nacp.DisplayVersionString.ToString()) ? string.Empty : $" v{nacp.DisplayVersionString.ToString()}";
|
string titleVersionSection = string.IsNullOrWhiteSpace(activeProcess.DisplayVersion) ? string.Empty : $" v{activeProcess.DisplayVersion}";
|
||||||
string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})";
|
string titleIdSection = $" ({activeProcess.ProgramIdText.ToUpper()})";
|
||||||
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
|
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
|
||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
_viewModel.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
_viewModel.Title = $"Ryujinx {Program.Version} -{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
||||||
});
|
});
|
||||||
|
|
||||||
_viewModel.SetUIProgressHandlers(Device);
|
_viewModel.SetUIProgressHandlers(Device);
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Ryujinx.Cpu;
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
using Ryujinx.Horizon.Common;
|
using Ryujinx.Horizon.Common;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.Loaders.Processes
|
namespace Ryujinx.HLE.Loaders.Processes
|
||||||
{
|
{
|
||||||
|
@ -21,8 +22,9 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
public readonly ApplicationControlProperty ApplicationControlProperties;
|
public readonly ApplicationControlProperty ApplicationControlProperties;
|
||||||
|
|
||||||
public readonly ulong ProcessId;
|
public readonly ulong ProcessId;
|
||||||
public string Name;
|
public readonly string Name;
|
||||||
public ulong ProgramId;
|
public readonly string DisplayVersion;
|
||||||
|
public readonly ulong ProgramId;
|
||||||
public readonly string ProgramIdText;
|
public readonly string ProgramIdText;
|
||||||
public readonly bool Is64Bit;
|
public readonly bool Is64Bit;
|
||||||
public readonly bool DiskCacheEnabled;
|
public readonly bool DiskCacheEnabled;
|
||||||
|
@ -52,17 +54,14 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
{
|
{
|
||||||
ulong programId = metaLoader.GetProgramId();
|
ulong programId = metaLoader.GetProgramId();
|
||||||
|
|
||||||
if (ApplicationControlProperties.Title.ItemsRo.Length > 0)
|
Name = ApplicationControlProperties.Title[(int)titleLanguage].NameString.ToString();
|
||||||
{
|
|
||||||
var langIndex = ApplicationControlProperties.Title.ItemsRo.Length > (int)titleLanguage ? (int)titleLanguage : 0;
|
|
||||||
|
|
||||||
Name = ApplicationControlProperties.Title[langIndex].NameString.ToString();
|
if (string.IsNullOrWhiteSpace(Name))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Name = metaLoader.GetProgramName();
|
Name = ApplicationControlProperties.Title.ItemsRo.ToArray().FirstOrDefault(x => x.Name[0] != 0).NameString.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisplayVersion = ApplicationControlProperties.DisplayVersionString.ToString();
|
||||||
ProgramId = programId;
|
ProgramId = programId;
|
||||||
ProgramIdText = $"{programId:x16}";
|
ProgramIdText = $"{programId:x16}";
|
||||||
Is64Bit = metaLoader.IsProgram64Bit();
|
Is64Bit = metaLoader.IsProgram64Bit();
|
||||||
|
@ -85,16 +84,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: LibHac npdm currently doesn't support version field.
|
// TODO: LibHac npdm currently doesn't support version field.
|
||||||
string version;
|
string version = ProgramId > 0x0100000000007FFF ? DisplayVersion : device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? "?";
|
||||||
|
|
||||||
if (ProgramId > 0x0100000000007FFF)
|
|
||||||
{
|
|
||||||
version = ApplicationControlProperties.DisplayVersionString.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
version = device.System.ContentManager.GetCurrentFirmwareVersion().VersionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Loader, $"Application Loaded: {Name} v{version} [{ProgramIdText}] [{(Is64Bit ? "64-bit" : "32-bit")}]");
|
Logger.Info?.Print(LogClass.Loader, $"Application Loaded: {Name} v{version} [{ProgramIdText}] [{(Is64Bit ? "64-bit" : "32-bit")}]");
|
||||||
|
|
||||||
|
|
|
@ -496,15 +496,13 @@ namespace Ryujinx.Ui
|
||||||
parent.Present();
|
parent.Present();
|
||||||
|
|
||||||
var activeProcess = Device.Processes.ActiveApplication;
|
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 titleNameSection = string.IsNullOrWhiteSpace(activeProcess.Name) ? string.Empty : $" {activeProcess.Name}";
|
||||||
string titleVersionSection = string.IsNullOrWhiteSpace(nacp.DisplayVersionString.ToString()) ? string.Empty : $" v{nacp.DisplayVersionString.ToString()}";
|
string titleVersionSection = string.IsNullOrWhiteSpace(activeProcess.DisplayVersion) ? string.Empty : $" v{activeProcess.DisplayVersion}";
|
||||||
string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})";
|
string titleIdSection = $" ({activeProcess.ProgramIdText.ToUpper()})";
|
||||||
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
|
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
|
||||||
|
|
||||||
parent.Title = $"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
parent.Title = $"Ryujinx {Program.Version} -{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}";
|
||||||
});
|
});
|
||||||
|
|
||||||
Thread renderLoopThread = new Thread(Render)
|
Thread renderLoopThread = new Thread(Render)
|
||||||
|
|
Loading…
Reference in a new issue