diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 6a05cb09..65a37584 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -156,7 +156,7 @@ namespace NewHorizons.Builder.Props // If they're adding dialogue we have to manually register the xml text if (isFromAssetBundle && component is CharacterDialogueTree dialogue) { - DialogueBuilder.AddTranslation(dialogue._xmlCharacterDialogueAsset.text, null); + DialogueBuilder.HandleUnityCreatedDialogue(dialogue); } FixComponent(component, go, detail.ignoreSun); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 93898e6d..779b9a37 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -5,7 +5,9 @@ using NewHorizons.Utility; using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML; using OWML.Common; +using System; using System.Collections.Generic; +using System.Data.SqlTypes; using System.IO; using System.Xml; using System.Xml.Linq; @@ -130,20 +132,11 @@ namespace NewHorizons.Builder.Props // Chracter name is required for adding translations, something to do with how OW prefixes its dialogue var characterName = existingDialogueTree.SelectSingleNode("NameField").InnerText; - AddTranslation(xml, characterName); + AddTranslation(additionalDialogueDoc.GetChildNode("DialogueTree"), characterName); return existingDialogue; } - private static string DoDialogueOptionsListReplacement(string xmlString) - { - var dialogueDoc = new XmlDocument(); - dialogueDoc.LoadXml(xmlString); - var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree"); - DoDialogueOptionsListReplacement(xmlNode); - return xmlNode.OuterXml; - } - private static void DoDialogueOptionsListReplacement(XmlNode dialogueTree) { var optionsListsByName = new Dictionary(); @@ -235,7 +228,12 @@ namespace NewHorizons.Builder.Props var dialogueTree = conversationZone.AddComponent(); - xml = DoDialogueOptionsListReplacement(xml); + var dialogueDoc = new XmlDocument(); + dialogueDoc.LoadXml(xml); + var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree"); + DoDialogueOptionsListReplacement(xmlNode); + AddTranslation(xmlNode); + xml = xmlNode.OuterXml; var text = new TextAsset(xml) { @@ -243,7 +241,6 @@ namespace NewHorizons.Builder.Props name = dialogueName }; dialogueTree.SetTextXml(text); - AddTranslation(xml); switch (info.flashlightToggle) { @@ -428,11 +425,17 @@ namespace NewHorizons.Builder.Props } } + [Obsolete("Pass in the DialogueTree XmlNode instead, this is still here because Pikpik was using it in EOTP")] public static void AddTranslation(string xml, string characterName = null) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); var xmlNode = xmlDocument.SelectSingleNode("DialogueTree"); + AddTranslation(xmlNode, characterName); + } + + public static void AddTranslation(XmlNode xmlNode, string characterName = null) + { var xmlNodeList = xmlNode.SelectNodes("DialogueNode"); // When adding dialogue to existing stuff, we have to pass in the character name @@ -467,5 +470,20 @@ namespace NewHorizons.Builder.Props } } } + + public static void HandleUnityCreatedDialogue(CharacterDialogueTree dialogue) + { + var text = dialogue._xmlCharacterDialogueAsset.text; + var dialogueDoc = new XmlDocument(); + dialogueDoc.LoadXml(text); + var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree"); + AddTranslation(xmlNode, null); + DoDialogueOptionsListReplacement(xmlNode); + var newTextAsset = new TextAsset(dialogueDoc.OuterXml) + { + name = dialogue._xmlCharacterDialogueAsset.name + }; + dialogue.SetTextXml(newTextAsset); + } } }