private void CloneFromSaveEchoes_Click(object sender, EventArgs e) { int index = GetSelectedEchoList(); if (index == -1) { MessageBox.Show("Select a single echo list to import to first."); return; } Util.WTOpenFileDialog tempOpen = new Util.WTOpenFileDialog("sav", ""); if (tempOpen.ShowDialog() == DialogResult.OK) { WillowSaveGame OtherSave = new WillowSaveGame(); try { OtherSave.LoadWsg(tempOpen.FileName()); } catch { MessageBox.Show("Couldn't open the other save file."); return; } if (OtherSave.NumberOfEchoLists - 1 < index) { MessageBox.Show("The echo list does not exist in the other savegame file."); return; } // Replace the old entries in the echo table with the new ones CurrentWSG.EchoLists[index] = OtherSave.EchoLists[index]; WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; EchoTree.BeginUpdate(); TreeNodeAdv parent = EchoTree.Root.Children[index]; // Remove the old entries from the tree view TreeNodeAdv[] children = parent.Children.ToArray(); foreach (TreeNodeAdv child in children) { child.Remove(); } // Add the new entries to the tree view foreach (WillowSaveGame.EchoEntry ee in et.Echoes) { string name = ee.Name; ColoredTextNode node = new ColoredTextNode(); node.Tag = name; node.Text = EchoesXml.XmlReadValue(name, "Subject"); if (node.Text == "") { node.Text = "(" + name + ")"; } parent.AddNode(node); } EchoTree.EndUpdate(); } }
private void SaveToXmlEchoes(string filename, int index) { XmlTextWriter writer = new XmlTextWriter(filename, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartDocument(); writer.WriteComment("WillowTree Echo File"); writer.WriteComment("Note: the XML tags are case sensitive"); writer.WriteStartElement("WT"); writer.WriteStartElement("Echoes"); WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; int count = CurrentWSG.EchoLists[index].TotalEchoes; for (int i = 0; i < count; i++) { WillowSaveGame.EchoEntry ee = et.Echoes[i]; writer.WriteStartElement("Echo"); writer.WriteElementString("Name", ee.Name); writer.WriteElementString("DLCValue1", ee.DlcValue1.ToString()); writer.WriteElementString("DLCValue2", ee.DlcValue2.ToString()); writer.WriteEndElement(); } writer.WriteEndDocument(); writer.Close(); }
private void AddListEchoes_Click(object sender, EventArgs e) { int index = CurrentWSG.NumberOfEchoLists; // Create an empty echo table WillowSaveGame.EchoTable et = new WillowSaveGame.EchoTable(); et.Index = CurrentWSG.NumberOfEchoLists; et.Echoes = new List <WillowSaveGame.EchoEntry>(); et.TotalEchoes = 0; // Add the new table to the list CurrentWSG.EchoLists.Add(et); CurrentWSG.NumberOfEchoLists++; EchoTree.BeginUpdate(); //Add the new table to the tree view ColoredTextNode categoryNode = new ColoredTextNode(); categoryNode.Tag = index.ToString(); categoryNode.Text = "Playthrough " + (CurrentWSG.EchoLists[index].Index + 1) + " Echo Logs"; (EchoTree.Model as TreeModel).Nodes.Add(categoryNode); EchoTree.EndUpdate(); }
public void MergeAllFromXmlEchoes(string filename, int index) { XmlDocument doc = new XmlDocument(); doc.Load(filename); if (doc.SelectSingleNode("WT/Echoes") == null) { throw new ApplicationException("NoEchoes"); } XmlNodeList echonodes = doc.SelectNodes("WT/Echoes/Echo"); if (echonodes == null) { return; } WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; EchoTree.BeginUpdate(); // Copy only the echos that are not duplicates from the XML file foreach (XmlNode node in echonodes) { string name = node.GetElement("Name", ""); // Make sure the echo is not already in the list EchoSearchKey = name; if (et.Echoes.FindIndex(EchoSearchByName) != -1) { continue; } // Create a new echo entry an populate it from the node WillowSaveGame.EchoEntry ee = new WillowSaveGame.EchoEntry(); ee.Name = name; ee.DlcValue1 = node.GetElementAsInt("DLCValue1", 0); ee.DlcValue2 = node.GetElementAsInt("DLCValue2", 0); // Add the echo entry to the echo list et.Echoes.Add(ee); et.TotalEchoes++; // Add the echo to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = EchoesXml.XmlReadValue(name, "Subject"); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } EchoTree.Root.Children[index].AddNode(treeNode); } EchoTree.EndUpdate(); }
public void DeleteAllEchoes(int index) { WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; et.Echoes.Clear(); et.TotalEchoes = 0; TreeNodeAdv[] children = EchoTree.Root.Children[index].Children.ToArray(); foreach (TreeNodeAdv child in children) { child.Remove(); } }
private void EchoList_Click(object sender, EventArgs e) { newToolStripMenuItem1.HideDropDown(); if (EchoList.SelectedIndex == -1) { return; } int index = GetSelectedEchoList(); if (index == -1) { MessageBox.Show("Select an echo list first."); return; } string name = EchoesXml.stListSectionNames()[EchoList.SelectedIndex]; // Create a new echo entry and populate it WillowSaveGame.EchoEntry ee = new WillowSaveGame.EchoEntry(); ee.Name = name; // TODO: These values shouldn't always be zero, but the data doesn't // exist in the data files yet. When the proper data is in the data // file then it needs to be looked up here. ee.DlcValue1 = 0; ee.DlcValue2 = 0; // Add the new echo to the echo list WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; et.Echoes.Add(ee); et.TotalEchoes++; // Add the new echo to the echo tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = EchoesXml.XmlReadValue(name, "Subject"); if (treeNode.Text == "") { treeNode.Text = "(" + treeNode.Tag as string + ")"; } TreeNodeAdv parent = EchoTree.Root.Children[index]; parent.AddNode(treeNode); // Select the newly added node so the user will know it was added EchoTree.SelectedNode = parent.Children[parent.Children.Count - 1]; EchoTree.EnsureVisible(EchoTree.SelectedNode); }
private void SaveSelectedToXmlEchoes(string filename, int index) { TreeNodeAdv[] selected; // There are two valid ways a user can select nodes to save to xml. // He can choose exactly one category node or he can choose multiple // echo nodes. Figure out which and create an array of the nodes. if (EchoTree.SelectedNode.Parent == EchoTree.Root && EchoTree.SelectedNodes.Count == 1) { selected = EchoTree.Root.Children[index].Children.ToArray(); } else { selected = EchoTree.SelectedNodes.ToArray(); } XmlTextWriter writer = new XmlTextWriter(filename, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartDocument(); writer.WriteComment("WillowTree Echo File"); writer.WriteComment("Note: the XML tags are case sensitive"); writer.WriteStartElement("WT"); writer.WriteStartElement("Echoes"); WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; foreach (TreeNodeAdv nodeAdv in selected) { string key = nodeAdv.GetKey(); EchoSearchKey = nodeAdv.GetKey(); int i = et.Echoes.FindIndex(EchoSearchByName); if (i == -1) { continue; } WillowSaveGame.EchoEntry ee = et.Echoes[i]; writer.WriteStartElement("Echo"); writer.WriteElementString("Name", ee.Name); writer.WriteElementString("DLCValue1", ee.DlcValue1.ToString()); writer.WriteElementString("DLCValue2", ee.DlcValue2.ToString()); writer.WriteEndElement(); } writer.WriteEndDocument(); writer.Close(); }
public void LoadEchoes(string filename, int index) { XmlDocument doc = new XmlDocument(); doc.Load(filename); if (doc.SelectSingleNode("WT/Echoes") == null) { throw new ApplicationException("NoEchoes"); } XmlNodeList echonodes = doc.SelectNodes("WT/Echoes/Echo"); int count = echonodes.Count; WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; et.Echoes.Clear(); et.TotalEchoes = 0; EchoTree.BeginUpdate(); for (int i = 0; i < count; i++) { // Create a new echo entry and populate it from the xml node WillowSaveGame.EchoEntry ee = new WillowSaveGame.EchoEntry(); XmlNode node = echonodes[i]; string name = node.GetElement("Name", ""); ee.Name = name; ee.DlcValue1 = node.GetElementAsInt("DLCValue1", 0); ee.DlcValue2 = node.GetElementAsInt("DLCValue2", 0); // Add the echo to the list et.Echoes.Add(ee); et.TotalEchoes++; // Add the echo to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = EchoesXml.XmlReadValue(name, "Subject"); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } EchoTree.Root.Children[index].AddNode(treeNode); } EchoTree.EndUpdate(); }
public void MergeFromSaveEchoes(string filename, int index) { WillowSaveGame OtherSave = new WillowSaveGame(); OtherSave.LoadWsg(filename); if (OtherSave.NumberOfEchoLists - 1 < index) { return; } WillowSaveGame.EchoTable etOther = OtherSave.EchoLists[index]; WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; EchoTree.BeginUpdate(); // Copy only the locations that are not duplicates from the other save foreach (WillowSaveGame.EchoEntry ee in CurrentWSG.EchoLists[index].Echoes) { string name = ee.Name; // Make sure the echo is not already in the list EchoSearchKey = name; if (et.Echoes.FindIndex(EchoSearchByName) != -1) { continue; } // Add the echo entry to the echo list et.Echoes.Add(ee); et.TotalEchoes++; // Add the echo to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = EchoesXml.XmlReadValue(name, "Subject"); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } EchoTree.Root.Children[index].AddNode(treeNode); } EchoTree.EndUpdate(); }
private void DeleteEcho_Click(object sender, EventArgs e) { // Get out if no node is selected int index = GetSelectedEchoList(); if (index == -1 || EchoTree.SelectedNode.Parent == EchoTree.Root) { return; } TreeNodeAdv NextSelection = null; TreeNodeAdv[] selected = EchoTree.SelectedNodes.ToArray(); foreach (TreeNodeAdv nodeAdv in selected) { // Just remove the node from the selection if it is a // category node if (nodeAdv.Parent == EchoTree.Root) { NextSelection = nodeAdv; nodeAdv.IsSelected = false; continue; } WillowSaveGame.EchoTable et = CurrentWSG.EchoLists[index]; // Remove the echo from the echo list et.TotalEchoes--; et.Echoes.RemoveAt(nodeAdv.Index); // Remove the echo from the tree view NextSelection = nodeAdv.NextVisibleNode; nodeAdv.Remove(); } // Select a new selected node if the selected node was removed if (EchoTree.SelectedNode == null) { EchoTree.SelectedNode = NextSelection; } }