mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow adding an xml to an existing dialogue that had a null asset
This commit is contained in:
parent
f27bb25f86
commit
aa73043480
@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (AddToExistingDialogue(go, info, xml), null);
|
return (AddToExistingDialogue(go, info, xml, dialogueName), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
return (dialogue, remoteTrigger);
|
return (dialogue, remoteTrigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharacterDialogueTree AddToExistingDialogue(GameObject go, DialogueInfo info, string xml)
|
private static CharacterDialogueTree AddToExistingDialogue(GameObject go, DialogueInfo info, string xml, string dialogueName)
|
||||||
{
|
{
|
||||||
var dialogueObject = go.FindChild(info.pathToExistingDialogue);
|
var dialogueObject = go.FindChild(info.pathToExistingDialogue);
|
||||||
if (dialogueObject == null) dialogueObject = SearchUtilities.Find(info.pathToExistingDialogue);
|
if (dialogueObject == null) dialogueObject = SearchUtilities.Find(info.pathToExistingDialogue);
|
||||||
@ -82,7 +82,29 @@ namespace NewHorizons.Builder.Props
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var existingText = existingDialogue._xmlCharacterDialogueAsset.text;
|
var existingAsset = existingDialogue._xmlCharacterDialogueAsset;
|
||||||
|
if (existingAsset == null)
|
||||||
|
{
|
||||||
|
var dialogueDoc = new XmlDocument();
|
||||||
|
dialogueDoc.LoadXml(xml);
|
||||||
|
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
|
||||||
|
AddTranslation(xmlNode);
|
||||||
|
|
||||||
|
xml = xmlNode.OuterXml;
|
||||||
|
|
||||||
|
var text = new TextAsset(xml)
|
||||||
|
{
|
||||||
|
// Text assets need a name to be used with VoiceMod
|
||||||
|
name = dialogueName
|
||||||
|
};
|
||||||
|
existingDialogue.SetTextXml(text);
|
||||||
|
|
||||||
|
FixDialogueNextFrame(existingDialogue);
|
||||||
|
|
||||||
|
return existingDialogue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var existingText = existingAsset.text;
|
||||||
|
|
||||||
var existingDialogueDoc = new XmlDocument();
|
var existingDialogueDoc = new XmlDocument();
|
||||||
existingDialogueDoc.LoadXml(existingText);
|
existingDialogueDoc.LoadXml(existingText);
|
||||||
@ -519,14 +541,16 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static void HandleUnityCreatedDialogue(CharacterDialogueTree dialogue)
|
public static void HandleUnityCreatedDialogue(CharacterDialogueTree dialogue)
|
||||||
{
|
{
|
||||||
var text = dialogue._xmlCharacterDialogueAsset.text;
|
var asset = dialogue._xmlCharacterDialogueAsset;
|
||||||
|
if (asset == null) return;
|
||||||
|
var text = asset.text;
|
||||||
var dialogueDoc = new XmlDocument();
|
var dialogueDoc = new XmlDocument();
|
||||||
dialogueDoc.LoadXml(text);
|
dialogueDoc.LoadXml(text);
|
||||||
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
|
var xmlNode = dialogueDoc.SelectSingleNode("DialogueTree");
|
||||||
AddTranslation(xmlNode, null);
|
AddTranslation(xmlNode, null);
|
||||||
var newTextAsset = new TextAsset(dialogueDoc.OuterXml)
|
var newTextAsset = new TextAsset(dialogueDoc.OuterXml)
|
||||||
{
|
{
|
||||||
name = dialogue._xmlCharacterDialogueAsset.name
|
name = asset.name
|
||||||
};
|
};
|
||||||
dialogue.SetTextXml(newTextAsset);
|
dialogue.SetTextXml(newTextAsset);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user