diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 7797ff07..986d097b 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -87,9 +87,9 @@ namespace NewHorizons.Components */ } - public void AddSystemCard(string starSystem) + public void AddSystemCard(string uniqueID) { - var card = CreateCard(starSystem, root.transform, new Vector2(_nextCardIndex++ * 200, 0)); + var card = CreateCard(uniqueID, root.transform, new Vector2(_nextCardIndex++ * 200, 0)); _starSystemCards.Add(card); } @@ -132,7 +132,7 @@ namespace NewHorizons.Components } } - public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position) + public GameObject CreateCard(string uniqueID, Transform parent, Vector2 position) { if (_cardTemplate == null) { @@ -143,12 +143,14 @@ namespace NewHorizons.Components var newCard = GameObject.Instantiate(_cardTemplate, parent); var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); - var name = UniqueNameToString(uniqueName); + + var name = UniqueIDToName(uniqueID); + textComponent.text = name; if (name.Length > 17) textComponent.fontSize = 10; newCard.SetActive(true); - newCard.transform.name = uniqueName; + newCard.transform.name = uniqueID; newCard.transform.localPosition = new Vector3(position.x, position.y, 40); newCard.transform.localRotation = Quaternion.Euler(0, 0, 0); @@ -157,15 +159,15 @@ namespace NewHorizons.Components Texture texture = null; try { - if (uniqueName.Equals("SolarSystem")) + if (uniqueID.Equals("SolarSystem")) { texture = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/hearthian system.png"); } else { - var path = $"planets/{uniqueName}.png"; + var path = $"planets/{uniqueID}.png"; Logger.Log($"Trying to load {path}"); - texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueName].Mod, path); + texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueID].Mod, path); } } catch (Exception) { } @@ -272,13 +274,19 @@ namespace NewHorizons.Components } } - public string UniqueNameToString(string uniqueName) + public string UniqueIDToName(string uniqueID) { - if (uniqueName.Equals("SolarSystem")) return "Hearthian System"; + var name = TranslationHandler.GetTranslation(uniqueID, TranslationHandler.TextType.UI); - var splitString = uniqueName.Split('.'); + // If it can't find a translation it just returns the key + if (!name.Equals(uniqueID)) return name; + + // Else we return a default name + if (uniqueID.Equals("SolarSystem")) return "Hearthian System"; + + var splitString = uniqueID.Split('.'); if (splitString.Length > 1) splitString = splitString.Skip(1).ToArray(); - var name = string.Join("", splitString).SplitCamelCase(); + name = string.Join("", splitString).SplitCamelCase(); return name; } @@ -308,10 +316,10 @@ namespace NewHorizons.Components Locator._rfTracker.UntargetReferenceFrame(); GlobalMessenger.FireEvent("UntargetReferenceFrame"); - _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}"); + _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueIDToName(shipLogEntryCard.name).ToUpper()}"); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); - _warpPrompt.SetText($" Engage Warp To {UniqueNameToString(shipLogEntryCard.name)}"); + _warpPrompt.SetText($" Engage Warp To {UniqueIDToName(shipLogEntryCard.name)}"); } private void RemoveWarpTarget(bool playSound = false) diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index ee1f724a..627206fc 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -54,7 +54,7 @@ namespace NewHorizons.Handlers { if (system.Config.factRequiredForWarp != default) { - RegisterFactForSystem(system.Config.factRequiredForWarp, system.Name); + RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID); } } @@ -68,7 +68,7 @@ namespace NewHorizons.Handlers { foreach (var system in _systems) { - if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.Name)) + if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.UniqueID)) { return true; } diff --git a/NewHorizons/Utility/NewHorizonsSystem.cs b/NewHorizons/Utility/NewHorizonsSystem.cs index 4d22a946..41d8c2cc 100644 --- a/NewHorizons/Utility/NewHorizonsSystem.cs +++ b/NewHorizons/Utility/NewHorizonsSystem.cs @@ -5,14 +5,14 @@ namespace NewHorizons.Utility { public class NewHorizonsSystem { - public NewHorizonsSystem(string name, StarSystemConfig config, IModBehaviour mod) + public NewHorizonsSystem(string uniqueID, StarSystemConfig config, IModBehaviour mod) { - Name = name; + UniqueID = uniqueID; Config = config; Mod = mod; } - public string Name; + public string UniqueID; public SpawnModule Spawn = null; public SpawnPoint SpawnPoint = null; public StarSystemConfig Config;