public GUI(String file): this() { fileName = file; if (!file.Equals("")) { conversation = MyXml.load(fileName); this.Text = "Dialog Manager - " + conversation.npcName; treeListView.Roots = new ArrayList(conversation. getRootNodes()); treeListView.ExpandAll(); changesMade = false; } }
public static void save(Conversation conversation, String fileName) { XmlDocument xmlDoc = new XmlDocument(); XmlElement conversationXE = xmlDoc.CreateElement("conversation"); XmlElement dialogXE = xmlDoc.CreateElement("dialog"); XmlElement npcNameXE = xmlDoc.CreateElement("npcName"); XmlElement resetConvXE = xmlDoc.CreateElement("resetConversation"); xmlDoc.AppendChild(conversationXE); conversationXE.AppendChild(npcNameXE); npcNameXE.SetAttribute("npcName", conversation.npcName); conversationXE.AppendChild(resetConvXE); resetConvXE.SetAttribute("resetConversation", conversation.resetConversationOnEnd.ToString()); conversationXE.AppendChild(dialogXE); DialogNode[] dialog = conversation.getRootNodes(); for (int i = 0; i < dialog.Length; i++) { saveNode(dialog[i], ref dialogXE, ref xmlDoc); } xmlDoc.Save(fileName); }
private void openMiClicked(Object sender, EventArgs e) { if (changesMade) { DialogResult result = discardChangesDialog(); if (result == DialogResult.No) { saveMiClicked(new object(), new EventArgs()); } else if (result == DialogResult.Cancel) return; } OpenFileDialog openFD = new OpenFileDialog(); openFD.Filter = "Dialog (*.xml)|*.xml"; openFD.RestoreDirectory = true; DialogResult dialogResult = openFD.ShowDialog(); if (dialogResult == DialogResult.OK) { fileName = openFD.FileName.ToString(); conversation = MyXml.load(fileName); NpcIdGenerator = new IdGenerator(); DialogNode[] nodes = conversation.getDialog(); for (int i = 0; i < nodes.Length; i++) NpcIdGenerator.addId(nodes[i].id); this.Text = "Dialog Manager - " + conversation.npcName; treeListView.Roots = new ArrayList(conversation. getRootNodes()); treeListView.ExpandAll(); changesMade = false; } }