Fix dialogue reuse thing not including dialogue added by other mods

This commit is contained in:
Nick 2024-04-30 18:00:07 -04:00
parent 037d3e02f5
commit 5392a1f3b5
2 changed files with 29 additions and 5 deletions

View File

@ -130,8 +130,6 @@ namespace NewHorizons.Builder.Props
var characterName = existingDialogueTree.SelectSingleNode("NameField").InnerText; var characterName = existingDialogueTree.SelectSingleNode("NameField").InnerText;
AddTranslation(additionalDialogueDoc.GetChildNode("DialogueTree"), characterName); AddTranslation(additionalDialogueDoc.GetChildNode("DialogueTree"), characterName);
DoDialogueOptionsListReplacement(existingDialogueTree);
var newTextAsset = new TextAsset(existingDialogueDoc.OuterXml) var newTextAsset = new TextAsset(existingDialogueDoc.OuterXml)
{ {
name = existingDialogue._xmlCharacterDialogueAsset.name name = existingDialogue._xmlCharacterDialogueAsset.name
@ -139,9 +137,32 @@ namespace NewHorizons.Builder.Props
existingDialogue.SetTextXml(newTextAsset); existingDialogue.SetTextXml(newTextAsset);
FixDialogueNextFrame(existingDialogue);
return existingDialogue; return existingDialogue;
} }
private static void FixDialogueNextFrame(CharacterDialogueTree characterDialogueTree)
{
Delay.FireOnNextUpdate(() =>
{
var rawText = characterDialogueTree._xmlCharacterDialogueAsset.text;
var doc = new XmlDocument();
doc.LoadXml(rawText);
var dialogueTree = doc.DocumentElement.SelectSingleNode("//DialogueTree");
DoDialogueOptionsListReplacement(dialogueTree);
var newTextAsset = new TextAsset(doc.OuterXml)
{
name = characterDialogueTree._xmlCharacterDialogueAsset.name
};
characterDialogueTree.SetTextXml(newTextAsset);
});
}
/// <summary> /// <summary>
/// Always call this after adding translations, else it won't update them properly /// Always call this after adding translations, else it won't update them properly
/// </summary> /// </summary>
@ -253,7 +274,7 @@ namespace NewHorizons.Builder.Props
dialogueDoc.LoadXml(xml); dialogueDoc.LoadXml(xml);
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree"); var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
AddTranslation(xmlNode); AddTranslation(xmlNode);
DoDialogueOptionsListReplacement(xmlNode);
xml = xmlNode.OuterXml; xml = xmlNode.OuterXml;
var text = new TextAsset(xml) var text = new TextAsset(xml)
@ -282,6 +303,8 @@ namespace NewHorizons.Builder.Props
conversationZone.SetActive(true); conversationZone.SetActive(true);
FixDialogueNextFrame(dialogueTree);
return dialogueTree; return dialogueTree;
} }
@ -499,12 +522,13 @@ namespace NewHorizons.Builder.Props
dialogueDoc.LoadXml(text); dialogueDoc.LoadXml(text);
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree"); var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
AddTranslation(xmlNode, null); AddTranslation(xmlNode, null);
DoDialogueOptionsListReplacement(xmlNode);
var newTextAsset = new TextAsset(dialogueDoc.OuterXml) var newTextAsset = new TextAsset(dialogueDoc.OuterXml)
{ {
name = dialogue._xmlCharacterDialogueAsset.name name = dialogue._xmlCharacterDialogueAsset.name
}; };
dialogue.SetTextXml(newTextAsset); dialogue.SetTextXml(newTextAsset);
FixDialogueNextFrame(dialogue);
} }
} }
} }

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.20.1", "version": "1.20.2",
"owmlVersion": "2.10.3", "owmlVersion": "2.10.3",
"dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "PacificEngine.OW_CommonResources" ], "conflicts": [ "PacificEngine.OW_CommonResources" ],