Ejemplo n.º 1
0
        private void RemoveListQuests_Click(object sender, EventArgs e)
        {
            TreeNodeAdv[] selection = QuestTree.SelectedNodes.ToArray();

            QuestTree.BeginUpdate();
            foreach (TreeNodeAdv nodeAdv in selection)
            {
                if (nodeAdv.Parent == QuestTree.Root)
                {
                    CurrentWSG.NumberOfQuestLists--;
                    CurrentWSG.QuestLists.RemoveAt(nodeAdv.Index);
                    QuestTree.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 quest list indices
            int count = CurrentWSG.NumberOfQuestLists;

            for (int index = 0; index < count; index++)
            {
                TreeNodeAdv nodeAdv = QuestTree.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) + " Quests";
                parent.Tag  = index.ToString();

                // Adjust the quest list index to reflect its new position
                CurrentWSG.QuestLists[index].Index = index;
            }
            QuestTree.EndUpdate();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        public void DeleteAllQuests(int index)
        {
            WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index];
            qt.Quests.Clear();
            qt.TotalQuests = 0;

            QuestTree.BeginUpdate();
            TreeNodeAdv[] children = QuestTree.Root.Children[index].Children.ToArray();
            foreach (TreeNodeAdv child in children)
            {
                child.Remove();
            }

            string startQuest = "Z0_Missions.Missions.M_IntroStateSaver";

            AddQuestByName(startQuest, index);
            qt.CurrentQuest = startQuest;

            QuestTree.EndUpdate();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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();
            }
        }