Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Pretty Atmosphère mod names #601

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Ryujinx/UI/Models/ModModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ryujinx.Ava.UI.ViewModels;
using System.IO;
using System.Globalization;

namespace Ryujinx.Ava.UI.Models
{
Expand All @@ -21,6 +21,11 @@ public bool Enabled
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Windows/ModManagerWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
MaxLines="2"
TextWrapping="Wrap"
TextTrimming="CharacterEllipsis"
Text="{Binding Name}" />
Text="{Binding FormattedName}" />
<StackPanel
Grid.Column="1"
Spacing="10"
Expand Down
24 changes: 24 additions & 0 deletions src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ private ApplicationData GetApplicationFromExeFs(PartitionFileSystem pfs, string
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>
Expand Down