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

Localization not affecting tab nodes & Language Metadata #536

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed localization not affecting tab nodes
  • Loading branch information
Metious committed Mar 5, 2024
commit 62885900acaff1d34e6410de2a0f20acd5fa3ebf
19 changes: 16 additions & 3 deletions Nautilus/Crafting/TabNode.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using Nautilus.Handlers;
using Nautilus.Utility;

namespace Nautilus.Crafting;

using Nautilus.Assets;
Expand All @@ -15,15 +18,25 @@ internal class TabNode : Node
internal Sprite Sprite { get; set; }
internal string DisplayName { get; set; }
internal string Name { get; set; }
internal string Id { get; }

internal TabNode(string[] path, CraftTree.Type scheme, Sprite sprite, string name, string displayName, string language = "English") : base(path, scheme)
internal TabNode(string[] path, CraftTree.Type scheme, Sprite sprite, string name, string displayName) : base(path, scheme)
{
Sprite = sprite;
DisplayName = displayName;
Name = name;
Id = $"{Scheme.ToString()}_{Name}";

ModSprite.Add(new ModSprite(SpriteManager.Group.Category, Id, Sprite));

ModSprite.Add(new ModSprite(SpriteManager.Group.Category, $"{Scheme.ToString()}_{Name}", Sprite));
LanguagePatcher.AddCustomLanguageLine($"{Scheme.ToString()}Menu_{Name}", DisplayName, language);
if (!string.IsNullOrEmpty(displayName))
{
LanguageHandler.SetLanguageLine(Id, displayName);
}
else if (string.IsNullOrEmpty(Language.main.Get(name)))
{
InternalLogger.Warn($"Display name was not specified and no existing language line has been found for Tab node '{name}'.");
}
}

}
12 changes: 6 additions & 6 deletions Nautilus/Handlers/CraftTreeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void AddCraftingNode(CraftTree.Type craftTree, TechType craftingIt
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>
public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, Atlas.Sprite sprite)
{
Expand All @@ -75,7 +75,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>

public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, UnityEngine.Sprite sprite)
Expand All @@ -95,7 +95,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>
/// <param name="stepsToTab">
/// <para>The steps to the target tab.</para>
Expand All @@ -120,7 +120,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>
/// <param name="stepsToTab">
/// <para>The steps to the target tab.</para>
Expand All @@ -146,7 +146,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>
public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, UnityEngine.Sprite sprite)
{
Expand All @@ -165,7 +165,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp
/// </summary>
/// <param name="craftTree">The target craft tree to edit.</param>
/// <param name="name">The ID of the tab node. Must be unique!</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab.</param>
/// <param name="displayName">The display name of the tab, which will show up when you hover your mouse on the tab. If null or empty, this will use the language line "{craftTreeName}_{tabName}" instead.</param>
/// <param name="sprite">The sprite of the tab.</param>
/// <param name="stepsToTab">
/// <para>The steps to the target tab.</para>
Expand Down