Add translator text to the API

This commit is contained in:
Nick 2023-08-04 23:54:04 -04:00
parent c1f1859648
commit 9bbfb8d4d8
3 changed files with 18 additions and 1 deletions

View File

@ -546,7 +546,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
// make an entry in the cache for all these spirals
if (nhBody.Cache != null)
if (nhBody?.Cache != null)
{
var cacheData = arranger.spirals.Select(spiralManipulator => new ArcCacheData()
{

View File

@ -147,6 +147,15 @@ namespace NewHorizons
/// <returns></returns>
(CharacterDialogueTree, RemoteDialogueTrigger) CreateDialogueFromXML(string textAssetID, string xml, string dialogueInfo, GameObject planetGO);
/// <summary>
/// Allows the creation of Nomai text by directly passing the xml and translatorTextInfo json contents as strings
/// </summary>
/// <param name="xml">The contents of the translator text file as a string</param>
/// <param name="textInfo">The json translator text info as a string. See the documentation/schema for what this can contain.</param>
/// <param name="planetGO">The root planet rigidbody that this text is attached to. Any paths in the translatorTextInfo are relative to this body.</param>
/// <returns></returns>
GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO);
/// <summary>
/// Directly add ship logs from XML. Call this method right before ShipLogManager awake.
/// </summary>

View File

@ -1,5 +1,6 @@
using NewHorizons.Builder.Props;
using NewHorizons.Builder.Props.Audio;
using NewHorizons.Builder.Props.TranslatorText;
using NewHorizons.Builder.ShipLog;
using NewHorizons.External;
using NewHorizons.External.Configs;
@ -7,6 +8,7 @@ using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.Audio;
using NewHorizons.External.Modules.Props.Dialogue;
using NewHorizons.External.Modules.TranslatorText;
using NewHorizons.External.SerializableData;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
@ -259,6 +261,12 @@ namespace NewHorizons
return DialogueBuilder.Make(planetGO, null, info, xml, textAssetID);
}
public GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO)
{
var info = JsonConvert.DeserializeObject<TranslatorTextInfo>(textInfo);
return TranslatorTextBuilder.Make(planetGO, null, info, null, xml);
}
public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary<string, Vector2> entryPositions, Dictionary<string, (Color colour, Color highlight)> curiousityColours)
{
// This method has to be called each time the ship log manager is created, i.e. each time a system loads so it will only ever be relevant to the current one.