Skip to content

Commit

Permalink
Fixed localization not affecting tab nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Mar 5, 2024
1 parent cc80268 commit 6288590
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
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

0 comments on commit 6288590

Please sign in to comment.