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(); } }
public void DoLocationTree() { // Clear the tree TreeModel model = new TreeModel(); LocationTree.Model = model; LocationTree.BeginUpdate(); for (int build = 0; build < CurrentWSG.TotalLocations; build++) { string key = CurrentWSG.LocationStrings[build]; string name = LocationsXml.XmlReadAssociatedValue("OutpostDisplayName", "OutpostName", key); if (name == "") { name = key; } ColoredTextNode node = new ColoredTextNode(name); node.Tag = key; model.Nodes.Add(node); } //LocationTree.Update(); LocationTree.EndUpdate(); }
public void AddToTreeView(InventoryEntry entry) { _parent = CreateNavigationNodes(entry); _node = new ColoredTextNode(); _node.Tag = entry; _node.ForeColor = entry.Color; _node.Text = entry.Name; Collection <Node> nodes; if (_parent == null) { _parent = Tree.Root; nodes = (Tree.Model as TreeModel).Nodes; } else { nodes = (_parent.Tag as Node).Nodes; } IComparer <InventoryEntry> Comparer = IEComparisonEngine.CurrentComparer(); for (int i = nodes.Count - 1; i >= 0; i--) { if (Comparer.Compare(nodes[i].Tag as InventoryEntry, entry) == -1) { _lastNodeIndex = i + 1; nodes.Insert(_lastNodeIndex, _node); return; } } nodes.Insert(0, _node); _lastNodeIndex = 0; }
private void AddListQuests_Click(object sender, EventArgs e) { int index = CurrentWSG.NumberOfQuestLists; // Create an empty quest table WillowSaveGame.QuestTable qt = new WillowSaveGame.QuestTable(); qt.Index = index; qt.TotalQuests = 0; qt.Quests = new List <WillowSaveGame.QuestEntry>(); // Add the new table to the list CurrentWSG.QuestLists.Add(qt); CurrentWSG.NumberOfQuestLists++; QuestTree.BeginUpdate(); //Add the new table to the tree view ColoredTextNode categoryNode = new ColoredTextNode(); categoryNode.Text = "Playthrough " + (index + 1) + " Quests"; categoryNode.Tag = index.ToString(); (QuestTree.Model as TreeModel).Nodes.Add(categoryNode); // Add Fresh Off the Bus (the first quest) to the table string startQuest = "Z0_Missions.Missions.M_IntroStateSaver"; AddQuestByName(startQuest, index); qt.CurrentQuest = startQuest; QuestTree.EndUpdate(); }
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(); }
private void RemoveListEchoes_Click(object sender, EventArgs e) { TreeNodeAdv[] selection = EchoTree.SelectedNodes.ToArray(); foreach (TreeNodeAdv nodeAdv in selection) { if (nodeAdv.Parent == EchoTree.Root) { CurrentWSG.NumberOfEchoLists--; CurrentWSG.EchoLists.RemoveAt(nodeAdv.Index); EchoTree.Root.Children[nodeAdv.Index].Remove(); } } // The indexes will be messed up if a list that is not the last one is // removed, so update the tree text, tree indexes, and echo list indices int count = CurrentWSG.NumberOfEchoLists; for (int index = 0; index < count; index++) { TreeNodeAdv nodeAdv = EchoTree.Root.Children[index]; // Adjust the category node's text and tag to reflect its new position ColoredTextNode parent = nodeAdv.Data(); parent.Text = "Playthrough " + (index + 1) + " Echo Logs"; parent.Tag = index.ToString(); // Adjust the echo list index to reflect its new position CurrentWSG.EchoLists[index].Index = index; } EchoTree.EndUpdate(); }
public void DoSkillTree() { // Skill tree // Key = name of the skill as stored in CurrentWSG.SkillNames // Text = human readable display name of the skill SkillTree.BeginUpdate(); TreeModel model = new TreeModel(); SkillTree.Model = model; Util.SetNumericUpDown(SkillLevel, 0); Util.SetNumericUpDown(SkillExp, 0); SkillActive.SelectedItem = "No"; for (int build = 0; build < CurrentWSG.NumberOfSkills; build++) { ColoredTextNode node = new ColoredTextNode(); string key = CurrentWSG.SkillNames[build]; node.Key = key; string name = SkillsAllXml.XmlReadValue(key, "SkillName"); if (name != "") { node.Text = name; } else { node.Text = CurrentWSG.SkillNames[build]; } model.Nodes.Add(node); } SkillTree.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(); }
private void AddQuestByName(string name, int index) { WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry(); qe.Name = name; // TODO: These should not always be zero. They are non-zero for // missions that are from the DLCs. The data files dont // contain the values they should be yet, so once that data // is added to the data files these should be changed. qe.DlcValue1 = 0; qe.DlcValue2 = 0; List <WillowSaveGame.QuestObjective> objectives = new List <WillowSaveGame.QuestObjective>(); int objectiveCount; for (objectiveCount = 0; ; objectiveCount++) { WillowSaveGame.QuestObjective objective; string desc = QuestsXml.XmlReadValue(qe.Name, "Objectives" + objectiveCount); if (desc == "") { break; } objective.Description = desc; objective.Progress = 0; objectives.Add(objective); } qe.NumberOfObjectives = objectiveCount; qe.Objectives = objectives.ToArray(); if (objectiveCount > 0) { qe.Progress = 1; } else { qe.Progress = 2; } // Add the quest entry to the quest list WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; qt.Quests.Add(qe); qt.TotalQuests++; // Add the quest entry to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = QuestsXml.XmlReadValue(name, "MissionName"); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } QuestTree.Root.Children[index].AddNode(treeNode); }
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); }
public void DoAmmoTree() { AmmoTree.BeginUpdate(); TreeModel model = new TreeModel(); AmmoTree.Model = model; for (int build = 0; build < CurrentWSG.NumberOfPools; build++) { string ammoName = GetAmmoName(CurrentWSG.ResourcePools[build]); ColoredTextNode node = new ColoredTextNode(ammoName); model.Nodes.Add(node); } AmmoTree.EndUpdate(); }
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 DoQuestTree() { QuestTree.BeginUpdate(); // Make a new quest tree or clear the old one if (QuestTree.Model == null) { QuestTree.Model = new TreeModel(); } else { QuestTree.Clear(); } TreeModel model = QuestTree.Model as TreeModel; for (int listIndex = 0; listIndex < CurrentWSG.NumberOfQuestLists; listIndex++) { // Create the category node for this playthrough // Quest tree category nodes: // Text = human readable quest category ("Playthrough 1 Quests", etc) // Tag = quest list index as string (0 based) ColoredTextNode parent = new ColoredTextNode(); parent.Text = "Playthrough " + (listIndex + 1) + " Quests"; parent.Tag = listIndex.ToString(); model.Nodes.Add(parent); WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[listIndex]; // Create all the actual quest nodes for this playthrough // Text = human readable quest name // Tag = internal quest name for (int questIndex = 0; questIndex < qt.TotalQuests; questIndex++) { string nodeName = qt.Quests[questIndex].Name; ColoredTextNode node = new ColoredTextNode(); node.Tag = nodeName; node.Text = QuestsXml.XmlReadValue(nodeName, "MissionName"); if (node.Text == "") { node.Text = "(" + nodeName + ")"; } parent.Nodes.Add(node); } } QuestTree.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(); }
public void DoEchoTree() { EchoTree.BeginUpdate(); TreeModel model = new TreeModel(); EchoTree.Model = model; for (int i = 0; i < CurrentWSG.NumberOfEchoLists; i++) { // Category nodes // Text = human readable category heading // Tag = echo list index stored as a string (0 based) ColoredTextNode parent = new ColoredTextNode(); parent.Tag = i.ToString(); parent.Text = "Playthrough " + (CurrentWSG.EchoLists[i].Index + 1) + " Echo Logs"; model.Nodes.Add(parent); for (int build = 0; build < CurrentWSG.EchoLists[i].TotalEchoes; build++) { string name = CurrentWSG.EchoLists[i].Echoes[build].Name; // Echo nodes // Text = human readable echo name // Tag = internal echo name ColoredTextNode node = new ColoredTextNode(); node.Tag = name; node.Text = EchoesXml.XmlReadValue(name, "Subject"); if (node.Text == "") { node.Text = "(" + name + ")"; } parent.Nodes.Add(node); } } EchoTree.EndUpdate(); }
public TreeNodeAdv CreateNavigationNodes(InventoryEntry entry) { int[] sortmodes = IEComparisonEngine.CurrentComparer().comparisons; int loopcount = (NavigationLayers < sortmodes.Length) ? NavigationLayers : sortmodes.Length; TreeNodeAdv navnode = null; TreeNodeAdv newbranch = null; string currentcategory; string categorytext; for (int i = 0; i < loopcount; i++) { // 0: Name // 1: Rarity // 2: Category // 3: Title // 4: Prefix // 5: Model // 6: Manufacturer // 7: Level // 8: Key switch (sortmodes[i]) { case 2: currentcategory = entry.Category; if (currentcategory == "") { currentcategory = "none"; } if (!CategoryLookup.TryGetValue(currentcategory, out categorytext)) { currentcategory = "(Unknown)"; categorytext = "(Unknown)"; } break; case 6: currentcategory = entry.NameParts[0]; if (currentcategory == "") { currentcategory = "No Manufacturer"; } categorytext = currentcategory; break; case 7: currentcategory = "Level " + entry.EffectiveLevel.ToString(); categorytext = currentcategory; break; case 3: currentcategory = entry.NameParts[3]; if (currentcategory == "") { currentcategory = "No Title"; } categorytext = currentcategory; break; case 4: currentcategory = entry.NameParts[2]; if (currentcategory == "") { currentcategory = "No Prefix"; } categorytext = currentcategory; break; case 5: currentcategory = entry.NameParts[1]; if (currentcategory == "") { currentcategory = "No Model"; } categorytext = currentcategory; break; case 1: currentcategory = entry.Name; categorytext = currentcategory; break; default: return(navnode); } //Debugger.Break(); //if (navnode == null) // newbranch = Tree.FindFirstNodeByTag(currentcategory, false); //else if (navnode != null) { newbranch = navnode.FindFirstByTag(currentcategory, false); } else { newbranch = Tree.Root.FindFirstByTag(currentcategory, false); } if (newbranch == null) { // This category does not exist yet. Create a node for it. ColoredTextNode data = new ColoredTextNode(); data.Tag = currentcategory; data.ForeColor = Color.LightSkyBlue; if (GlobalSettings.UseColor) { data.Text = categorytext; } else { data.Text = "--- " + categorytext + " ---"; } if (navnode == null) { (Tree.Model as TreeModel).Nodes.Add(data); navnode = Tree.Root; } else { navnode.AddNode(data); } newbranch = navnode.Children[navnode.Children.Count - 1]; //newbranch = navnode.FindFirstByTag(currentcategory, false); //if (navnode == null) //{ // (Tree.Model as TreeModel).Nodes.Add(data); // newbranch = Tree.FindNodeByTag(data).Tag as Node; //} //else // navnode.Nodes.Add(newbranch); } // Update the navnode then iterate again for the next tier of // category nodes until all category nodes are present navnode = newbranch; } return(navnode); }
private void ImportFromSaveQuests_Click(object sender, EventArgs e) { int index = GetSelectedQuestList(); if (index == -1) { MessageBox.Show("Select a playthrough 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 { return; } if (OtherSave.NumberOfQuestLists - 1 < index) { MessageBox.Show("This quest list does not exist in the other savegame file."); return; } // Note that when you set lists equal to one another like this it doesn't copy // the elements, only the pointer to the list. This is only safe here because // OtherSave will be disposed of right away and not modify the values. If OtherSave // was being used actively then a new copy of all the elements in the quest list // would have to be made or else changes to one would affect the quest // list of the other. // Replace the old entries in the quest table with the new ones CurrentWSG.QuestLists[index] = OtherSave.QuestLists[index]; WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; QuestTree.BeginUpdate(); TreeNodeAdv parent = QuestTree.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.QuestEntry qe in qt.Quests) { string nodeName = qe.Name; ColoredTextNode node = new ColoredTextNode(); node.Tag = nodeName; node.Text = QuestsXml.XmlReadValue(nodeName, "MissionName"); if (node.Text == "") { node.Text = "(" + node.Tag as string + ")"; } parent.AddNode(node); } QuestTree.EndUpdate(); } }
public void LoadQuests(string filename, int index) { XmlDocument doc = new XmlDocument(); doc.Load(filename); if (doc.SelectSingleNode("WT/Quests") == null) { throw new ApplicationException("NoQuests"); } XmlNodeList questnodes = doc.SelectNodes("WT/Quests/Quest"); int count = questnodes.Count; WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; qt.Quests.Clear(); qt.TotalQuests = count; QuestTree.BeginUpdate(); TreeNodeAdv parent = QuestTree.Root.Children[index]; // Remove the old entries from the tree view TreeNodeAdv[] children = parent.Children.ToArray(); foreach (TreeNodeAdv child in children) { child.Remove(); } for (int nodeIndex = 0; nodeIndex < count; nodeIndex++) { XmlNode node = questnodes[nodeIndex]; WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry(); qe.Name = node.GetElement("Name", ""); qe.Progress = node.GetElementAsInt("Progress", 0); qe.DlcValue1 = node.GetElementAsInt("DLCValue1", 0); qe.DlcValue2 = node.GetElementAsInt("DLCValue2", 0); int objectiveCount = node.GetElementAsInt("Objectives", 0); qe.NumberOfObjectives = objectiveCount; qe.Objectives = new WillowSaveGame.QuestObjective[objectiveCount]; for (int objectiveIndex = 0; objectiveIndex < objectiveCount; objectiveIndex++) { qe.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, ""); qe.Objectives[objectiveIndex].Progress = node.GetElementAsInt("FolderValue" + objectiveIndex, 0); } qt.Quests.Add(qe); // Add the quest to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = qe.Name; treeNode.Text = QuestsXml.XmlReadValue(qe.Name, "MissionName"); if (treeNode.Text == "") { treeNode.Text = "(" + treeNode.Tag as string + ")"; } QuestTree.Root.Children[index].AddNode(treeNode); } // TODO: The current quest is not currently stored in a quest file. // It should be stored when the entire list is stored and restored // when the list is loaded here. qt.CurrentQuest = ""; QuestTree.EndUpdate(); }
public void MergeFromSaveQuests(string filename, int index) { WillowSaveGame OtherSave = new WillowSaveGame(); OtherSave.LoadWsg(filename); if (OtherSave.NumberOfQuestLists - 1 < index) { return; } WillowSaveGame.QuestTable qtOther = OtherSave.QuestLists[index]; WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; QuestTree.BeginUpdate(); foreach (WillowSaveGame.QuestEntry qe in OtherSave.QuestLists[index].Quests) { string name = qe.Name; int progress = qe.Progress; // Check to see if the quest is already in the list QuestSearchKey = name; int prevIndex = qt.Quests.FindIndex(QuestSearchByName); if (prevIndex != -1) { // This quest entry exists in both lists. If the progress is // not greater then don't do anything with it. WillowSaveGame.QuestEntry old = qt.Quests[prevIndex]; if (progress < old.Progress) { continue; } if (progress == old.Progress) { // If the progress of the quest is the same, there may be // individual objectives that don't have the same progress // so check and update them. int objectiveCount = qe.NumberOfObjectives; // The number of objectives should be the same with the same // level of progress. If they aren't then there's something // wrong so just ignore the new quest and keep the old. if (objectiveCount != old.NumberOfObjectives) { continue; } for (int i = 0; i < objectiveCount; i++) { int objectiveProgress = old.Objectives[i].Progress; if (qe.Objectives[i].Progress < objectiveProgress) { qe.Objectives[i].Progress = objectiveProgress; } } } // This quest progress is further advanced than the existing one // so replace the existing one in the list. qt.Quests[prevIndex] = qe; // The quest doesn't need to be added to the quest list since we // modified an existing entry. The tree view doesn't need to be // changed because the name and text should still be the same. continue; } // Add the quest entry to the quest list qt.Quests.Add(qe); qt.TotalQuests++; // Add the quest to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = qe.Name; treeNode.Text = QuestsXml.XmlReadValue(qe.Name, "MissionName"); if (treeNode.Text == "") { treeNode.Text = "(" + treeNode.Tag as string + ")"; } QuestTree.Root.Children[index].AddNode(treeNode); } QuestTree.EndUpdate(); // In case the operation modified the currently selected quest, refresh // the quest group panel by signalizing the selection changed event. QuestTree_SelectionChanged(null, null); }
public void MergeAllFromXmlQuests(string filename, int index) { XmlDocument doc = new XmlDocument(); doc.Load(filename); if (doc.SelectSingleNode("/WT/Quests") == null) { throw new ApplicationException("NoQuests"); } XmlNodeList questnodes = doc.SelectNodes("/WT/Quests/Quest"); if (questnodes == null) { return; } WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; QuestTree.BeginUpdate(); // Copy only the quests that are not duplicates from the XML file foreach (XmlNode node in questnodes) { string name = node.GetElement("Name", ""); int progress = node.GetElementAsInt("Progress", 0); // Check to see if the quest is already in the list QuestSearchKey = name; int prevIndex = qt.Quests.FindIndex(QuestSearchByName); if (prevIndex != -1) { // This quest entry exists in both lists. If the progress is // not greater then don't do anything with it. WillowSaveGame.QuestEntry old = qt.Quests[prevIndex]; if (progress <= old.Progress) { continue; } // This quest progress is further advanced than the existing one // so copy all its values. old.Progress = progress; old.DlcValue1 = node.GetElementAsInt("DLCValue1", 0); old.DlcValue2 = node.GetElementAsInt("DLCValue2", 0); int newObjectiveCount = node.GetElementAsInt("Objectives", 0); old.NumberOfObjectives = newObjectiveCount; old.Objectives = new WillowSaveGame.QuestObjective[newObjectiveCount]; for (int objectiveIndex = 0; objectiveIndex < newObjectiveCount; objectiveIndex++) { old.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, ""); old.Objectives[objectiveIndex].Progress = node.GetElementAsInt("FolderValue" + objectiveIndex, 0); } // The quest doesn't need to be added to the quest list since we // modified an existing entry. The tree view doesn't need to be // changed because the name and text should still be the same. continue; } // Create a new quest entry from the quest's xml node data WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry(); qe.Name = name; qe.Progress = progress; qe.DlcValue1 = node.GetElementAsInt("DLCValue1", 0); qe.DlcValue2 = node.GetElementAsInt("DLCValue2", 0); int objectiveCount = node.GetElementAsInt("Objectives", 0); qe.NumberOfObjectives = objectiveCount; qe.Objectives = new WillowSaveGame.QuestObjective[objectiveCount]; for (int objectiveIndex = 0; objectiveIndex < objectiveCount; objectiveIndex++) { qe.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, ""); qe.Objectives[objectiveIndex].Progress = node.GetElementAsInt("FolderValue" + objectiveIndex, 0); } // Add the quest entry to the quest list qt.Quests.Add(qe); qt.TotalQuests++; // Add the quest to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = QuestsXml.XmlReadValue(name, "MissionName"); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } QuestTree.Root.Children[index].AddNode(treeNode); } QuestTree.EndUpdate(); // In case the operation modified the currently selected quest, refresh // the quest group panel by signalizing the selection changed event. QuestTree_SelectionChanged(null, null); }
private void QuestList_SelectedIndexChanged(object sender, EventArgs e) { int index = GetSelectedQuestList(); if (index == -1) { MessageBox.Show("Select a playthrough to add to first."); return; } int SelectedItem = QuestList.SelectedIndex; NewQuest.HideDropDown(); try { if (SelectedItem != -1) { WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; List <string> sectionNames = QuestsXml.stListSectionNames(); WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry(); string name = sectionNames[SelectedItem]; qe.Name = name; qe.Progress = 1; // TODO: These should not always be zero. They are non-zero for // missions that are from the DLCs. The data files dont // contain the values they should be yet, so once that data // is added to the data files these should be changed. qe.DlcValue1 = 0; qe.DlcValue2 = 0; List <WillowSaveGame.QuestObjective> objectives = new List <WillowSaveGame.QuestObjective>(); int objectiveCount; XmlNode questXmlNode = QuestsXml.XmlReadNode(name); System.Diagnostics.Debug.Assert(questXmlNode != null); for (objectiveCount = 0; ; objectiveCount++) { WillowSaveGame.QuestObjective objective; string desc = questXmlNode.GetElement("Objectives" + objectiveCount, ""); if (desc == "") { break; } objective.Description = desc; objective.Progress = 0; objectives.Add(objective); } qe.NumberOfObjectives = objectiveCount; qe.Objectives = objectives.ToArray(); qt.Quests.Add(qe); qt.TotalQuests++; ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = name; treeNode.Text = questXmlNode.GetElement("MissionName", ""); if (treeNode.Text == "") { treeNode.Text = "(" + name + ")"; } TreeNodeAdv parent = QuestTree.Root.Children[index]; parent.AddNode(treeNode); QuestTree.SelectedNode = parent.Children[parent.Children.Count - 1]; } } catch { } }