Skip to content
Snippets Groups Projects
Unverified Commit 9c12f528 authored by Evan Husted's avatar Evan Husted Committed by GitHub
Browse files

UI: Pretty Atmosphère mod names (#601)

Changes the mods from the Atmosphère folder to show a pretty name
instead of just the name of the folder they're in, because those names
are always just a title ID.

NOTE: The DLC names are from the file names, not retrieved from the
content file itself like the main applications.
parent 059fc83d
No related branches found
Tags Canary-1.2.366 Canary-1.2.367
No related merge requests found
using Ryujinx.Ava.UI.ViewModels;
using System.IO;
using System.Globalization;
namespace Ryujinx.Ava.UI.Models
{
......@@ -21,6 +21,11 @@ namespace Ryujinx.Ava.UI.Models
public string Path { get; }
public string Name { get; }
public string FormattedName =>
InSd && ulong.TryParse(Name, NumberStyles.HexNumber, null, out ulong applicationId)
? $"Atmosphère: {System.IO.Path.GetFileNameWithoutExtension(RyujinxApp.MainWindow.ApplicationLibrary.GetNameForApplicationId(applicationId))}"
: Name;
public ModModel(string path, string name, bool enabled, bool inSd)
{
Path = path;
......
......@@ -81,7 +81,7 @@
MaxLines="2"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"
Text="{Binding Name}" />
Text="{Binding FormattedName}" />
<StackPanel
Grid.Column="1"
Spacing="10"
......
......@@ -111,6 +111,30 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return data;
}
/// <summary>
/// Gets a name for an available content file based on the Application ID '<paramref name="id"/>'.
/// <br/><br/>
/// For Applications, this returns the localized name of the app found in the file.
/// For DLCs, this returns the name of the file that contains the DLC, minus the file extension.
/// </summary>
/// <param name="id">The Application ID to search for.</param>
/// <remarks>
/// If the provided Application ID does not have a corresponding Application OR DLC file,
/// <paramref name="id"/> formatted as hexadecimal is returned.
/// </remarks>
/// <returns>A formatted Application name, or <paramref name="id"/> as hexadecimal if none is found.</returns>
public string GetNameForApplicationId(ulong id)
{
DynamicData.Kernel.Optional<ApplicationData> appData = Applications.Lookup(id);
if (appData.HasValue)
return appData.Value.Name;
if (DownloadableContents.Keys.FindFirst(x => x.TitleId == id).TryGet(out DownloadableContentModel dlcData))
return dlcData.FileName;
return id.ToString("X16");
}
/// <exception cref="LibHac.Common.Keys.MissingKeyException">The configured key set is missing a key.</exception>
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment