diff --git a/NewHorizons/AssetBundle/translations/english.json b/NewHorizons/AssetBundle/translations/english.json index 5de572c5..ddd88a5b 100644 --- a/NewHorizons/AssetBundle/translations/english.json +++ b/NewHorizons/AssetBundle/translations/english.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/master/NewHorizons/translation_schema.json", + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", "DialogueDictionary": { "NEW_HORIZONS_WARP_DRIVE_DIALOGUE_1" : "Your ship is now equiped with a warp drive!", @@ -11,6 +11,8 @@ "INTERSTELLAR_MODE" : "Interstellar Mode", "FREQ_STATUE" : "Nomai Statue", "FREQ_WARP_CORE" : "Anti-Graviton Flux", - "FREQ_UNKNOWN" : "???" + "FREQ_UNKNOWN" : "???", + "ENGAGE_WARP_PROMPT" : "Engage Warp To {0}", + "WARP_LOCKED" : "AUTOPILOT LOCKED TO:\n{0}" } } \ No newline at end of file diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 70a6e48f..1b25d99b 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; +using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components { @@ -105,12 +106,15 @@ namespace NewHorizons.Components } var newCard = GameObject.Instantiate(_cardTemplate, parent); - var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); + var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); var name = UniqueIDToName(uniqueID); textComponent.text = name; if (name.Length > 17) textComponent.fontSize = 10; + // Do it next frame + var fontPath = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot/TH_VILLAGE/EntryCardRoot/NameBackground/Name"; + Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => textComponent.font = SearchUtilities.Find(fontPath).GetComponent().font); newCard.SetActive(true); newCard.transform.name = uniqueID; @@ -273,16 +277,20 @@ namespace NewHorizons.Components private void SetWarpTarget(ShipLogEntryCard shipLogEntryCard) { RemoveWarpTarget(false); - _oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f); + _oneShotSource.PlayOneShot(AudioType.ShipLogUnmarkLocation, 1f); _target = shipLogEntryCard; _target.SetMarkedOnHUD(true); Locator._rfTracker.UntargetReferenceFrame(); - GlobalMessenger.FireEvent("UntargetReferenceFrame"); - _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueIDToName(shipLogEntryCard.name).ToUpper()}"); + + var name = UniqueIDToName(shipLogEntryCard.name); + + var warpNotificationDataText = TranslationHandler.GetTranslation("WARP_LOCKED", TranslationHandler.TextType.UI).Replace("{0}", name.ToUpper()); + _warpNotificationData = new NotificationData(warpNotificationDataText); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); - _warpPrompt.SetText($" Engage Warp To {UniqueIDToName(shipLogEntryCard.name)}"); + var warpPromptText = " " + TranslationHandler.GetTranslation("ENGAGE_WARP_PROMPT", TranslationHandler.TextType.UI).Replace("{0}", name); + _warpPrompt.SetText(warpPromptText); } private void RemoveWarpTarget(bool playSound = false) diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 9987fb96..634bbe4d 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -1,4 +1,4 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +18,11 @@ namespace NewHorizons.Handlers } public static string GetTranslation(string text, TextType type) + { + return GetTranslation(text, type, out var _); + } + + public static string GetTranslation(string text, TextType type, out TextTranslation.Language translatedLanguage) { Dictionary> dictionary; var language = TextTranslation.Get().m_language; @@ -34,6 +39,7 @@ namespace NewHorizons.Handlers dictionary = _uiTranslationDictionary; break; default: + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } @@ -41,6 +47,7 @@ namespace NewHorizons.Handlers { if (table.TryGetValue(text, out var translatedText)) { + translatedLanguage = language; return translatedText; } } @@ -51,11 +58,13 @@ namespace NewHorizons.Handlers if (englishTable.TryGetValue(text, out var englishText)) { + translatedLanguage = TextTranslation.Language.ENGLISH; return englishText; } } // Default to the key + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; }