mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add localized warp rich presence
This commit is contained in:
parent
e7bfb53c58
commit
301e36bb37
@ -13,7 +13,8 @@
|
|||||||
"ENGAGE_WARP_PROMPT": "Engage Warp To {0}",
|
"ENGAGE_WARP_PROMPT": "Engage Warp To {0}",
|
||||||
"WARP_LOCKED": "AUTOPILOT LOCKED TO:\n{0}",
|
"WARP_LOCKED": "AUTOPILOT LOCKED TO:\n{0}",
|
||||||
"LOCK_AUTOPILOT_WARP": "Lock Autopilot to Star System",
|
"LOCK_AUTOPILOT_WARP": "Lock Autopilot to Star System",
|
||||||
"RICH_PRESENCE_EXPLORING": "Exploring {0}."
|
"RICH_PRESENCE_EXPLORING": "Exploring {0}.",
|
||||||
|
"RICH_PRESENCE_WARPING": "Warping to {0}."
|
||||||
},
|
},
|
||||||
"AchievementTranslations": {
|
"AchievementTranslations": {
|
||||||
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
||||||
|
|||||||
@ -13,7 +13,8 @@
|
|||||||
"ENGAGE_WARP_PROMPT": "Engagez la distorsion vers {0}",
|
"ENGAGE_WARP_PROMPT": "Engagez la distorsion vers {0}",
|
||||||
"WARP_LOCKED": "PILOTE AUTOMATIQUE VISÉ SUR:\n{0}",
|
"WARP_LOCKED": "PILOTE AUTOMATIQUE VISÉ SUR:\n{0}",
|
||||||
"LOCK_AUTOPILOT_WARP": "Visez le pilote automatique",
|
"LOCK_AUTOPILOT_WARP": "Visez le pilote automatique",
|
||||||
"RICH_PRESENCE_EXPLORING": "En explorant {0}."
|
"RICH_PRESENCE_EXPLORING": "En explorant {0}.",
|
||||||
|
"RICH_PRESENCE_WARPING": "En route vers {0}."
|
||||||
},
|
},
|
||||||
"AchievementTranslations": {
|
"AchievementTranslations": {
|
||||||
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
"NH_EATEN_OUTSIDE_BRAMBLE": {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ using NewHorizons.External.Configs;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
public static class TranslationHandler
|
public static class TranslationHandler
|
||||||
@ -18,11 +20,6 @@ namespace NewHorizons.Handlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string GetTranslation(string text, TextType type)
|
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<TextTranslation.Language, Dictionary<string, string>> dictionary;
|
Dictionary<TextTranslation.Language, Dictionary<string, string>> dictionary;
|
||||||
var language = TextTranslation.Get().m_language;
|
var language = TextTranslation.Get().m_language;
|
||||||
@ -39,31 +36,25 @@ namespace NewHorizons.Handlers
|
|||||||
dictionary = _uiTranslationDictionary;
|
dictionary = _uiTranslationDictionary;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
translatedLanguage = TextTranslation.Language.UNKNOWN;
|
Logger.LogVerbose($"Invalid TextType {type}");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the translated text
|
||||||
if (dictionary.TryGetValue(language, out var table))
|
if (dictionary.TryGetValue(language, out var table))
|
||||||
{
|
|
||||||
if (table.TryGetValue(text, out var translatedText))
|
if (table.TryGetValue(text, out var translatedText))
|
||||||
{
|
|
||||||
translatedLanguage = language;
|
|
||||||
return translatedText;
|
return translatedText;
|
||||||
}
|
|
||||||
}
|
Logger.LogVerbose($"Defaulting to english for {text}");
|
||||||
|
|
||||||
// Try to default to English
|
// Try to default to English
|
||||||
if (dictionary.TryGetValue(TextTranslation.Language.ENGLISH, out var englishTable))
|
if (dictionary.TryGetValue(TextTranslation.Language.ENGLISH, out var englishTable))
|
||||||
{
|
|
||||||
if (englishTable.TryGetValue(text, out var englishText))
|
if (englishTable.TryGetValue(text, out var englishText))
|
||||||
{
|
|
||||||
translatedLanguage = TextTranslation.Language.ENGLISH;
|
|
||||||
return englishText;
|
return englishText;
|
||||||
}
|
|
||||||
}
|
Logger.LogVerbose($"Defaulting to key for {text}");
|
||||||
|
|
||||||
// Default to the key
|
// Default to the key
|
||||||
translatedLanguage = TextTranslation.Language.UNKNOWN;
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -200,7 +200,8 @@ namespace NewHorizons
|
|||||||
AchievementHandler.Init();
|
AchievementHandler.Init();
|
||||||
VoiceHandler.Init();
|
VoiceHandler.Init();
|
||||||
RichPresenceHandler.Init();
|
RichPresenceHandler.Init();
|
||||||
OnStarSystemLoaded.AddListener(RichPresenceHandler.SetUpSolarSystem);
|
OnStarSystemLoaded.AddListener(RichPresenceHandler.OnStarSystemLoaded);
|
||||||
|
OnChangeStarSystem.AddListener(RichPresenceHandler.OnChangeStarSystem);
|
||||||
|
|
||||||
LoadAddonManifest("Assets/addon-manifest.json", this);
|
LoadAddonManifest("Assets/addon-manifest.json", this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.OtherMods.OWRichPresence
|
namespace NewHorizons.OtherMods.OWRichPresence
|
||||||
@ -49,7 +50,7 @@ namespace NewHorizons.OtherMods.OWRichPresence
|
|||||||
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").ToLowerInvariant());
|
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetUpSolarSystem(string name)
|
public static void OnStarSystemLoaded(string name)
|
||||||
{
|
{
|
||||||
if (name == "SolarSystem") return;
|
if (name == "SolarSystem") return;
|
||||||
|
|
||||||
@ -58,5 +59,13 @@ namespace NewHorizons.OtherMods.OWRichPresence
|
|||||||
|
|
||||||
API.SetCurrentRootPresence(message, "sun");
|
API.SetCurrentRootPresence(message, "sun");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnChangeStarSystem(string destination)
|
||||||
|
{
|
||||||
|
var localizedName = ShipLogStarChartMode.UniqueIDToName(destination);
|
||||||
|
var message = TranslationHandler.GetTranslation("RICH_PRESENCE_WARPING", TranslationHandler.TextType.UI).Replace("{0}", localizedName);
|
||||||
|
|
||||||
|
API.SetRichPresence(message, "newhorizons");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user