Last active
May 16, 2022 16:30
-
-
Save LinkOFF7/5b27ff35a2ef6be9e124fefc384de9ad to your computer and use it in GitHub Desktop.
Salt and Sacrifice dialog.zdx Reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Dialog | |
{ | |
public string filename; | |
List<NPCDialog> npcDialogs; | |
struct NPCDialog | |
{ | |
public string name; | |
public List<DialogNode> nodes; | |
} | |
struct DialogNode | |
{ | |
public string name; | |
public TextSeries[] text; | |
public List<NodeOption> nodeOption; | |
public List<NodePrecheck> nodePrecheck; | |
public string postSetFlagStr; | |
public string postGoto; | |
public bool coopGive; | |
public string[] giveScript; | |
public string[] storeScript; | |
public bool postSetCoop; | |
public bool bLeave; | |
} | |
struct TextSeries | |
{ | |
public string[] text; | |
} | |
struct NodeOption | |
{ | |
public string[] text; | |
public string action; | |
public string coopAction; | |
} | |
struct NodePrecheck | |
{ | |
public string precheckFlag; | |
public string precheckGoto; | |
} | |
public void Serialize() | |
{ | |
BinaryReader reader = new BinaryReader(File.OpenRead(filename)); | |
Read(reader); | |
var json = JsonConvert.SerializeObject(npcDialogs, Formatting.Indented); | |
File.WriteAllText(filename + ".json", json); | |
} | |
private void Read(BinaryReader reader) | |
{ | |
//NPCDialog | |
int num = reader.ReadInt32(); | |
npcDialogs = new List<NPCDialog>(); | |
for(int i = 0; i < num; i++) | |
{ | |
NPCDialog npcDialog = new NPCDialog(); | |
npcDialog.name = reader.ReadString(); | |
int num2 = reader.ReadInt32(); | |
npcDialog.nodes = new List<DialogNode>(); | |
for(int j = 0; j < num2; j++) | |
{ | |
DialogNode node = new DialogNode(); | |
node.name = reader.ReadString(); | |
node.text = new TextSeries[13]; | |
for(int k = 0; k < 13; k++) | |
{ | |
node.text[k] = new TextSeries(); | |
string text = reader.ReadString(); | |
if (text == "") | |
node.text[k].text = null; | |
else if (k == 6) | |
{ | |
if (text.StartsWith(">") && text.Length > 1) | |
text = text.Substring(1); | |
node.text[k].text = text.Split('>'); | |
} | |
else | |
node.text[k].text = text.Split('\n'); | |
} | |
//nodeOption | |
node.nodeOption = new List<NodeOption>(); | |
int num3 = reader.ReadInt32(); | |
for (int k = 0; k < num3; k++) | |
{ | |
NodeOption nodeOption = new NodeOption(); | |
nodeOption.text = new string[13]; | |
for(int q = 0; q < nodeOption.text.Length; q++) | |
{ | |
nodeOption.text[q] = reader.ReadString(); | |
} | |
nodeOption.action = reader.ReadString(); | |
nodeOption.coopAction = reader.ReadString(); | |
node.nodeOption.Add(nodeOption); | |
} | |
//nodePrecheck | |
node.nodePrecheck = new List<NodePrecheck>(); | |
int num4 = reader.ReadInt32(); | |
for(int k = 0; k < num4; k++) | |
{ | |
NodePrecheck nodePrecheck = new NodePrecheck(); | |
nodePrecheck.precheckFlag = reader.ReadString(); | |
nodePrecheck.precheckGoto = reader.ReadString(); | |
node.nodePrecheck.Add(nodePrecheck); | |
} | |
node.postSetFlagStr = reader.ReadString(); | |
node.postGoto = reader.ReadString(); | |
node.coopGive = reader.ReadBoolean(); | |
string text2 = reader.ReadString(); | |
if (text2 != "") | |
{ | |
node.giveScript = text2.Split('\r'); | |
text2 = ""; | |
string[] array = node.giveScript; | |
foreach (string text3 in array) | |
{ | |
text2 += text3; | |
} | |
node.giveScript = text2.Split('\n'); | |
} | |
else | |
node.giveScript = null; | |
text2 = reader.ReadString(); | |
if (text2 != "") | |
{ | |
node.storeScript = text2.Split('\r'); | |
text2 = ""; | |
string[] array = node.storeScript; | |
foreach (string text4 in array) | |
{ | |
text2 += text4; | |
} | |
node.storeScript = text2.Split('\n'); | |
} | |
else | |
node.storeScript = null; | |
node.postSetCoop = reader.ReadBoolean(); | |
node.bLeave = reader.ReadBoolean(); | |
npcDialog.nodes.Add(node); | |
} | |
npcDialogs.Add(npcDialog); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment