From 62885900acaff1d34e6410de2a0f20acd5fa3ebf Mon Sep 17 00:00:00 2001 From: Metious <71298690+Metious@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:38:52 +0330 Subject: [PATCH] Fixed localization not affecting tab nodes --- Nautilus/Crafting/TabNode.cs | 19 ++++++++++++++++--- Nautilus/Handlers/CraftTreeHandler.cs | 12 ++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Nautilus/Crafting/TabNode.cs b/Nautilus/Crafting/TabNode.cs index 0cc2378b..8b908800 100644 --- a/Nautilus/Crafting/TabNode.cs +++ b/Nautilus/Crafting/TabNode.cs @@ -1,3 +1,6 @@ +using Nautilus.Handlers; +using Nautilus.Utility; + namespace Nautilus.Crafting; using Nautilus.Assets; @@ -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}'."); + } } } diff --git a/Nautilus/Handlers/CraftTreeHandler.cs b/Nautilus/Handlers/CraftTreeHandler.cs index 7034edf0..d7fbaaf3 100644 --- a/Nautilus/Handlers/CraftTreeHandler.cs +++ b/Nautilus/Handlers/CraftTreeHandler.cs @@ -56,7 +56,7 @@ public static void AddCraftingNode(CraftTree.Type craftTree, TechType craftingIt /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, Atlas.Sprite sprite) { @@ -75,7 +75,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, UnityEngine.Sprite sprite) @@ -95,7 +95,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. /// /// The steps to the target tab. @@ -120,7 +120,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. /// /// The steps to the target tab. @@ -146,7 +146,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. public static void AddTabNode(CraftTree.Type craftTree, string name, string displayName, UnityEngine.Sprite sprite) { @@ -165,7 +165,7 @@ public static void AddTabNode(CraftTree.Type craftTree, string name, string disp /// /// The target craft tree to edit. /// The ID of the tab node. Must be unique! - /// The display name of the tab, which will show up when you hover your mouse on the tab. + /// 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. /// The sprite of the tab. /// /// The steps to the target tab.