// 0 references - Build composite string by combining the attribute from each part in a thing with a space between
        // OBSOLETE - Nothing uses this.  It couid be removed.
        public static string GetInventoryAttributeComposite(XmlFile xml, string[,] InventoryArray, int InventoryIndex, int InventoryPartCount, string AttributeName)
        {
            string Name = "";

            for (int build = 0; build < InventoryPartCount; build++)
            {
                string readValue = xml.XmlReadValue(InventoryArray[InventoryIndex, build], AttributeName);

                if (Name == "" && readValue != null)
                {
                    Name = readValue;
                }
                else if (readValue != null && readValue != "")
                {
                    Name = (Name + " " + readValue);
                }
            }

            return(Name);
        }
        // 27 references - Fetch a given attribute from a part
        public static string GetPartAttribute(string part, string AttributeName)
        {
            string Database = part.Before('.');

            if (Database == "")
            {
                return("");
            }

            string PartName = part.After('.');

            string DbFileName = DataPath + Database + ".txt";

            if (!System.IO.File.Exists(DbFileName))
            {
                return("");
            }

            XmlFile DataFile = XmlFile.XmlFileFromCache(DbFileName);

            string ComponentText = DataFile.XmlReadValue(PartName, AttributeName);

            return(ComponentText);
        }
        private void ImportSkills_Click(object sender, EventArgs e)
        {
            OpenFileDialog tempImport = new OpenFileDialog();
            tempImport.DefaultExt = "*.skills";
            tempImport.Filter = "Skills Data(*.skills)|*.skills";

            tempImport.FileName = CurrentWSG.CharacterName + "'s Skills.skills";
            if (tempImport.ShowDialog() == DialogResult.OK)
            {

                //Ini.IniFile ImportSkills = new Ini.IniFile(tempImport.FileName);
                XmlFile ImportSkills = new XmlFile(tempImport.FileName);
                string[] TempSkillNames = new string[ImportSkills.stListSectionNames().Count];
                int[] TempSkillLevels = new int[ImportSkills.stListSectionNames().Count];
                int[] TempSkillExp = new int[ImportSkills.stListSectionNames().Count];
                int[] TempSkillInUse = new int[ImportSkills.stListSectionNames().Count];
                for (int Progress = 0; Progress < ImportSkills.stListSectionNames().Count; Progress++)
                {
                    TempSkillNames[Progress] = ImportSkills.stListSectionNames()[Progress];
                    TempSkillLevels[Progress] = Convert.ToInt32(ImportSkills.XmlReadValue(ImportSkills.stListSectionNames()[Progress], "Level"));
                    TempSkillExp[Progress] = Convert.ToInt32(ImportSkills.XmlReadValue(ImportSkills.stListSectionNames()[Progress], "Experience"));
                    TempSkillInUse[Progress] = Convert.ToInt32(ImportSkills.XmlReadValue(ImportSkills.stListSectionNames()[Progress], "InUse"));
                }
                CurrentWSG.SkillNames = TempSkillNames;
                CurrentWSG.LevelOfSkills = TempSkillLevels;
                CurrentWSG.ExpOfSkills = TempSkillExp;
                CurrentWSG.InUse = TempSkillInUse;
                CurrentWSG.NumberOfSkills = ImportSkills.stListSectionNames().Count;
                DoSkillTree();
            }
        }
        private void ImportQuests_Click(object sender, EventArgs e)
        {
            try
            {
                if (QuestTree.SelectedNode.Name == "PT2")
                {
                    OpenFileDialog tempImport = new OpenFileDialog();
                    tempImport.DefaultExt = "*.quests";
                    tempImport.Filter = "Quest Data(*.quests)|*.quests";

                    tempImport.FileName = CurrentWSG.CharacterName + "'s PT2 Quests.quests";
                    if (tempImport.ShowDialog() == DialogResult.OK)
                    {
                        //Ini.IniFile ImportQuests = new Ini.IniFile(tempImport.FileName);
                        XmlFile ImportQuests = new XmlFile(tempImport.FileName);
                        string[] TempQuestStrings = new string[ImportQuests.stListSectionNames().Count];
                        int[,] TempQuestValues = new int[ImportQuests.stListSectionNames().Count, 10];
                        string[,] TempQuestSubfolders = new string[ImportQuests.stListSectionNames().Count, 7];
                        for (int Progress = 0; Progress < ImportQuests.stListSectionNames().Count; Progress++)
                        {
                            TempQuestStrings[Progress] = ImportQuests.stListSectionNames()[Progress];
                            TempQuestValues[Progress, 0] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "Progress"));
                            TempQuestValues[Progress, 1] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "DLCValue1"));
                            TempQuestValues[Progress, 2] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "DLCValue2"));
                            TempQuestValues[Progress, 3] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "Objectives"));
                            for (int Folders = 0; Folders < TempQuestValues[Progress, 3]; Folders++)
                            {
                                TempQuestValues[Progress, Folders + 4] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "FolderValue" + Folders));
                                TempQuestSubfolders[Progress, Folders] = ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "FolderName" + Folders);
                            }
                        }
                        CurrentWSG.PT2Strings = TempQuestStrings;
                        CurrentWSG.PT2Values = TempQuestValues;
                        CurrentWSG.PT2Subfolders = TempQuestSubfolders;
                        CurrentWSG.TotalPT2Quests = ImportQuests.stListSectionNames().Count;
                        DoQuestTree();
                    }
                }
                else if (QuestTree.SelectedNode.Name == "PT1")
                {
                    OpenFileDialog tempImport = new OpenFileDialog();
                    tempImport.DefaultExt = "*.quests";
                    tempImport.Filter = "Quest Data(*.quests)|*.quests";

                    tempImport.FileName = CurrentWSG.CharacterName + "'s PT1 Quests.quests";
                    if (tempImport.ShowDialog() == DialogResult.OK)
                    {
                        XmlFile ImportQuests = new XmlFile(tempImport.FileName);
                        string[] TempQuestStrings = new string[ImportQuests.stListSectionNames().Count];
                        int[,] TempQuestValues = new int[ImportQuests.stListSectionNames().Count, 10];
                        string[,] TempQuestSubfolders = new string[ImportQuests.stListSectionNames().Count, 7];
                        for (int Progress = 0; Progress < ImportQuests.stListSectionNames().Count; Progress++)
                        {
                            TempQuestStrings[Progress] = ImportQuests.stListSectionNames()[Progress];
                            TempQuestValues[Progress, 0] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "Progress"));
                            TempQuestValues[Progress, 1] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "DLCValue1"));
                            TempQuestValues[Progress, 2] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "DLCValue2"));
                            TempQuestValues[Progress, 3] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "Objectives"));
                            for (int Folders = 0; Folders < TempQuestValues[Progress, 3]; Folders++)
                            {
                                TempQuestValues[Progress, Folders + 4] = Convert.ToInt32(ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "FolderValue" + Folders));
                                TempQuestSubfolders[Progress, Folders] = ImportQuests.XmlReadValue(ImportQuests.stListSectionNames()[Progress], "FolderName" + Folders);
                            }
                        }
                        CurrentWSG.PT1Strings = TempQuestStrings;
                        CurrentWSG.PT1Values = TempQuestValues;
                        CurrentWSG.PT1Subfolders = TempQuestSubfolders;
                        CurrentWSG.TotalPT1Quests = ImportQuests.stListSectionNames().Count;
                        DoQuestTree();
                    }
                }
            }
            catch { MessageBox.Show("Select a playthrough to replace first."); }
        }
        private void ImportEchoes_Click(object sender, EventArgs e)
        {
            //try
            //{
            if (EchoTree.SelectedNode == null)
            {
                MessageBox.Show("Select a playthrough to import first.");
                return;
            }
            OpenFileDialog tempImport = new OpenFileDialog();
            if (EchoTree.SelectedNode.Name == "PT2" || EchoTree.SelectedNode.Text == "Playthrough 2 Echo Logs")
            {

                tempImport.DefaultExt = "*.echologs";
                tempImport.Filter = "Echo Logs(*.echologs)|*.echologs";

                tempImport.FileName = CurrentWSG.CharacterName + "'s PT2 Echo Logs.echologs";
                if (tempImport.ShowDialog() == DialogResult.OK)
                {
                    if (EchoTree.SelectedNode.Name == "PT2" || EchoTree.SelectedNode.Text == "Playthrough 2 Echo Logs")
                    {
                        //Ini.IniFile ImportLogs = new Ini.IniFile(tempImport.FileName);
                        XmlFile ImportLogs = new XmlFile(tempImport.FileName);
                        string[] TempEchoStrings = new string[ImportLogs.stListSectionNames().Count];
                        int[,] TempEchoValues = new int[ImportLogs.stListSectionNames().Count, 10];
                        for (int Progress = 0; Progress < ImportLogs.stListSectionNames().Count; Progress++)
                        {
                            TempEchoStrings[Progress] = ImportLogs.stListSectionNames()[Progress];
                            TempEchoValues[Progress, 0] = Convert.ToInt32(ImportLogs.XmlReadValue(ImportLogs.stListSectionNames()[Progress], "DLCValue1"));
                            TempEchoValues[Progress, 1] = Convert.ToInt32(ImportLogs.XmlReadValue(ImportLogs.stListSectionNames()[Progress], "DLCValue2"));

                        }
                        CurrentWSG.EchoStringsPT2 = TempEchoStrings;
                        CurrentWSG.EchoValuesPT2 = TempEchoValues;
                        CurrentWSG.NumberOfEchosPT2 = ImportLogs.stListSectionNames().Count;
                        DoEchoTree();
                    }
                }
            }
            else if (EchoTree.SelectedNode.Name == "PT1" || EchoTree.SelectedNode.Text == "Playthrough 1 Echo Logs")
            {
                tempImport.DefaultExt = "*.echologs";
                tempImport.Filter = "Echo Logs(*.echologs)|*.echologs";

                tempImport.FileName = CurrentWSG.CharacterName + "'s PT1 Echo Logs.echologs";

                if (tempImport.ShowDialog() == DialogResult.OK)
                {
                    //Ini.IniFile ImportLogs = new Ini.IniFile(tempImport.FileName);
                    XmlFile ImportLogs = new XmlFile(tempImport.FileName);
                    string[] TempEchoStrings = new string[ImportLogs.stListSectionNames().Count];
                    int[,] TempEchoValues = new int[ImportLogs.stListSectionNames().Count, 10];
                    for (int Progress = 0; Progress < ImportLogs.stListSectionNames().Count; Progress++)
                    {
                        TempEchoStrings[Progress] = ImportLogs.stListSectionNames()[Progress];
                        TempEchoValues[Progress, 0] = Convert.ToInt32(ImportLogs.XmlReadValue(ImportLogs.stListSectionNames()[Progress], "DLCValue1"));
                        TempEchoValues[Progress, 1] = Convert.ToInt32(ImportLogs.XmlReadValue(ImportLogs.stListSectionNames()[Progress], "DLCValue2"));

                    }
                    CurrentWSG.EchoStrings = TempEchoStrings;
                    CurrentWSG.EchoValues = TempEchoValues;
                    CurrentWSG.NumberOfEchos = ImportLogs.stListSectionNames().Count;
                    DoEchoTree();
                }

            }

            try
            {
            }
            catch { MessageBox.Show("Select a playthrough to import first."); }
        }
        public void DoLocationTree()
        {
            //Ini.IniFile PartList = new Ini.IniFile(AppDir + "\\Data\\Locations.ini");
            XmlFile PartList = new XmlFile(AppDir + "\\Data\\Locations.ini");
            //Ini.IniFile PartList = new Ini.IniFile(AppDir + "\\Data\\Locations.ini");
            LocationTree.Nodes.Clear();

            for (int build = 0; build < CurrentWSG.TotalLocations; build++)
            {
                //string name = PartList.IniReadValue(CurrentWSG.LocationStrings[build], "OutpostDisplayName");
                string name = PartList.XmlReadValue(CurrentWSG.LocationStrings[build], "OutpostDisplayName");
                Node TempNode = new Node();
                if (name != "")
                    TempNode.Text = name;
                else TempNode.Text = CurrentWSG.LocationStrings[build];

                LocationTree.Nodes.Add(TempNode);

            }
        }
        private void QuestProgress_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                XmlFile Quests = new XmlFile(AppDir + "\\Data\\Quests.ini");
                if (QuestTree.SelectedNode.Name == "PT1" && Clicked == true)
                {
                    if (CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] == 4 && QuestProgress.SelectedIndex < 3)
                    {
                        Objectives.Items.Clear();
                        int TotalObjectives = 0;

                        //string curTxt;
                        for (int Progress = 0; Progress < 5; Progress++)
                        {
                            //curTxt = Quests.IniReadValue(QuestString.Text, "Objectives[" + Progress + "]");
                            if (Quests.XmlReadValue(QuestString.Text, "Objectives" + Progress) == "") break;
                            else TotalObjectives = Progress + 1;
                        }
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 3] = TotalObjectives;
                        for (int Progress = 0; Progress < 5; Progress++)
                            CurrentWSG.PT1Subfolders[QuestTree.SelectedNode.Index, Progress] = "None";
                        NumberOfObjectives.Value = TotalObjectives;
                        if (TotalObjectives > 0)
                            for (int Progress = 0; Progress < TotalObjectives; Progress++)
                                Objectives.Items.Add(Quests.XmlReadValue(QuestString.Text, "Objectives" + Progress));
                        ObjectiveValue.Value = 0;
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] = QuestProgress.SelectedIndex;
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 3] = TotalObjectives;
                        for (int Progress = 0; Progress < 5; Progress++)
                            CurrentWSG.PT1Subfolders[QuestTree.SelectedNode.Index, Progress] = "None";
                    }
                    else if (CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] != 4 && QuestProgress.SelectedIndex == 3)
                    {
                        Objectives.Items.Clear();
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] = 4;
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 3] = 0;
                    }
                    else if (CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] != 4 && QuestProgress.SelectedIndex < 3)
                        CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] = QuestProgress.SelectedIndex;
                }
                else if (QuestTree.SelectedNode.Name == "PT2" && Clicked == true)
                {
                    if (CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] == 4 && QuestProgress.SelectedIndex < 3)
                    {
                        Objectives.Items.Clear();
                        int TotalObjectives = 0;
                        for (int Progress = 0; Progress < 5; Progress++)
                            if (Quests.XmlReadValue(QuestString.Text, "Objectives" + Progress) == "") break;
                            else TotalObjectives = Progress + 1;
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 3] = TotalObjectives;
                        for (int Progress = 0; Progress < 5; Progress++)
                            CurrentWSG.PT2Subfolders[QuestTree.SelectedNode.Index, Progress] = "None";
                        NumberOfObjectives.Value = TotalObjectives;
                        if (NumberOfObjectives.Value > 0)
                            for (int Progress = 0; Progress < NumberOfObjectives.Value; Progress++)
                                Objectives.Items.Add(Quests.XmlReadValue(QuestString.Text, "Objectives" + Progress));
                        ObjectiveValue.Value = 0;
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] = QuestProgress.SelectedIndex;
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 3] = TotalObjectives;
                    }
                    else if (CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] != 4 && QuestProgress.SelectedIndex == 3)
                    {
                        Objectives.Items.Clear();
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] = 4;
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 3] = 0;
                        //for (int Progress = 0; Progress < 5; Progress++)
                        //    CurrentWSG.PT2Subfolders[QuestTree.SelectedNode.Index, Progress] = "None";
                    }
                    else if (CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] != 4 && QuestProgress.SelectedIndex < 3)
                        CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] = QuestProgress.SelectedIndex;

                }
            }
            catch { }
        }
        private void Open_Click(object sender, EventArgs e)
        {
            textBox1.Clear();

            OpenFileDialog tempOpen = new OpenFileDialog();
            tempOpen.DefaultExt = "*.sav";
            tempOpen.Filter = "WillowSaveGame(*.sav)|*.sav";

            if (tempOpen.ShowDialog() == DialogResult.OK)
                try
                {
                    BankSpace.Enabled = false;
                    BankSpace.Value = 0;
                    CurrentWSG = new WillowSaveGame();
                    CurrentWSG.OpenWSG(tempOpen.FileName);
                    //Ini.IniFile Locations = new Ini.IniFile(AppDir + "\\Data\\Locations.ini");
                    XmlFile Locations = new XmlFile(AppDir + "\\Data\\Locations.ini");
                    setXPchart();
                    textBox1.AppendText(CurrentWSG.Platform);
                    CharacterName.Text = CurrentWSG.CharacterName;
                    try
                    {
                        //Experience.Maximum = XPChart[(int)Level.Value];
                        if (CurrentWSG.Level <= Level.Maximum)
                            Level.Value = CurrentWSG.Level;
                        else
                            Level.Value = Level.Maximum;

                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        MessageBox.Show("The level value was outside the acceptable range. Adjust your level and experience to their correct values.\r\nLevel: " + CurrentWSG.Level + "\r\nExperience: " + CurrentWSG.Experience);
                        Level.Value = 1;
                        Experience.Value = 0;
                    }
                    try
                    {
                        //Experience.Maximum = XPChart[(int)Level.Value];

                        if (CurrentWSG.Experience >= Experience.Minimum)
                            Experience.Value = CurrentWSG.Experience;
                        else
                            Experience.Value = Experience.Minimum;

                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        MessageBox.Show("The experience value was outside the acceptable range. Adjust your level and experience to their correct values.\r\nLevel: " + CurrentWSG.Level + "\r\nExperience: " + CurrentWSG.Experience);

                        Experience.Value = Experience.Minimum;
                    }
                    if (CurrentWSG.SkillPoints <= SkillPoints.Maximum)
                        SkillPoints.Value = CurrentWSG.SkillPoints;
                    else
                        SkillPoints.Value = SkillPoints.Maximum;
                    PT2Unlocked.SelectedIndex = CurrentWSG.FinishedPlaythrough1;
                    try
                    {
                        Cash.Value = CurrentWSG.Cash;
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        Cash.Value = Cash.Maximum;
                        MessageBox.Show("This save has $" + CurrentWSG.Cash + ", which is outside of WillowTree#'s limits and can cause in-game issues. Because of this, your cash has been lowered. It is suggested that you further reduce your cash to prevent future problems.");
                    }
                    BackpackSpace.Value = CurrentWSG.BackpackSize;
                    EquipSlots.Value = CurrentWSG.EquipSlots;
                    SaveNumber.Value = CurrentWSG.SaveNumber;
                    CurrentLocation.SelectedItem = Locations.XmlReadValue(CurrentWSG.CurrentLocation, "OutpostDisplayName");
                    if (CurrentWSG.Class == "gd_Roland.Character.CharacterClass_Roland") Class.SelectedIndex = 0;
                    else if (CurrentWSG.Class == "gd_lilith.Character.CharacterClass_Lilith") Class.SelectedIndex = 1;
                    else if (CurrentWSG.Class == "gd_mordecai.Character.CharacterClass_Mordecai") Class.SelectedIndex = 2;
                    else if (CurrentWSG.Class == "gd_Brick.Character.CharacterClass_Brick") Class.SelectedIndex = 3;
                    textBox1.AppendText("\r\nHeader: " + CurrentWSG.MagicHeader + "\r\nVersion: " + CurrentWSG.VersionNumber + "\r\nPlyr String: " + CurrentWSG.PLYR + "\r\nRevision Number: " + CurrentWSG.RevisionNumber + "\r\nClass: " + CurrentWSG.Class + "\r\nLevel: " + CurrentWSG.Level + "\r\nExp: " + CurrentWSG.Experience + "\r\nSkill Points: " + CurrentWSG.SkillPoints + "\r\nunknown1: " + CurrentWSG.Unknown1 + "\r\nMoney: " + CurrentWSG.Cash + "\r\nFinished Game: " + CurrentWSG.FinishedPlaythrough1 + "\r\nNumber of skills: " + CurrentWSG.NumberOfSkills + "\r\nCurrent Quest: " + CurrentWSG.CurrentQuest + "\r\nTotal PT1 Quests: " + CurrentWSG.TotalPT1Quests + "\r\nSecondary Quest: " + CurrentWSG.SecondaryQuest + "\r\nTotal PT2 Quests: " + CurrentWSG.TotalPT2Quests + "\r\nUnknown PT1 Quest Value: " + CurrentWSG.UnknownPT1QuestValue);
                    ActivePT1Quest.Text = CurrentWSG.CurrentQuest;
                    ActivePT2Quest.Text = CurrentWSG.SecondaryQuest;
                    DoQuestTree();
                    DoLocationTree();
                    DoSkillTree();
                    DoEchoTree();
                    DoAmmoTree();
                    DoWeaponTree();
                    DoItemTree();
                    DoSkillList();

                    GeneralTab.Enabled = true;
                    AmmoTab.Enabled = true;
                    SkillsTab.Enabled = true;
                    EchosTab.Enabled = true;
                    WTLTab.Enabled = true;
                    ExportToBackpack.Enabled = true;
                    ImportAllFromItems.Enabled = true;
                    ImportAllFromWeapons.Enabled = true;
                    WeaponsTab.Enabled = true;
                    ItemsTab.Enabled = true;
                    QuestsTab.Enabled = true;
                    Save.Enabled = true;
                    SaveAs.Enabled = true;
                    SelectFormat.Enabled = true;

                    if (CurrentWSG.DLC.BankSize > 0)
                    {
                        BankSpace.Value = CurrentWSG.DLC.BankSize;
                        BankSpace.Enabled = true;
                    }
                    DoWindowTitle();
                }
                //if (VersionFromServer == "f")
                //try {
                //  DoAmmoTree();
                //}
                catch
                {

                    if (CurrentWSG.EchoStringsPT2 == null && CurrentWSG.NumberOfEchosPT2 > 0 && CurrentWSG.TotalPT2Quests > 1 && CurrentWSG.NumberOfEchosPT2 < 300)
                        MessageBox.Show("Error reading PT2 echo logs.");
                    else
                        MessageBox.Show("Could not open save.");
                    BankSpace.Enabled = false;
                    BankSpace.Value = 0;
                    GeneralTab.Enabled = false;
                    AmmoTab.Enabled = false;
                    SkillsTab.Enabled = false;
                    EchosTab.Enabled = false;
                    //WTLTab.Enabled = false;
                    ExportToBackpack.Enabled = false;
                    ImportAllFromItems.Enabled = false;
                    ImportAllFromWeapons.Enabled = false;
                    WeaponsTab.Enabled = false;
                    ItemsTab.Enabled = false;
                    QuestsTab.Enabled = false;
                    Save.Enabled = false;
                    SaveAs.Enabled = false;
                    MainTab.Select();
                    textBox1.AppendText("\r\nHeader: " + CurrentWSG.MagicHeader + "\r\nVersion: " + CurrentWSG.VersionNumber + "\r\nPlyr String: " + CurrentWSG.PLYR + "\r\nRevision Number: " + CurrentWSG.RevisionNumber + "\r\nClass: " + CurrentWSG.Class + "\r\nLevel: " + CurrentWSG.Level + "\r\nExp: " + CurrentWSG.Experience + "\r\nSkill Points: " + CurrentWSG.SkillPoints + "\r\nunknown1: " + CurrentWSG.Unknown1 + "\r\nMoney: " + CurrentWSG.Cash + "\r\nFinished Game: " + CurrentWSG.FinishedPlaythrough1 + "\r\nNumber of skills: " + CurrentWSG.NumberOfSkills + "\r\nCurrent Quest: " + CurrentWSG.CurrentQuest + "\r\nTotal PT1 Quests: " + CurrentWSG.TotalPT1Quests + "\r\nSecondary Quest: " + CurrentWSG.SecondaryQuest + "\r\nTotal PT2 Quests: " + CurrentWSG.TotalPT2Quests + "\r\nUnknown PT1 Quest Value: " + CurrentWSG.UnknownPT1QuestValue);
                }
        }
        // 3 references - read name from xml of 12+13 weapon or 7+8 item, analyze 1 weapon or 2 item for class - output is class + name
        public string GetName(XmlFile xml, List<string> PartArray, int NumberOfSubParts, string INIValueToRetrieve, string Itemtype)
        {
            string Name = "";
            string itemtypeprefix = "";
            for (int build = 0; build < NumberOfSubParts; build++)
            {

                // Get the Weapontype from part0 (Itemgrade)
                //gd_itemgrades.Weapons_Eridan.ItemGrade_Eridan_SMG_Blaster
                if ((Itemtype == "Item") && (build == 1))
                {
                    //Type in Part2 -> strParts[2]
                    itemtypeprefix = PartArray[build].Substring(PartArray[build].LastIndexOf(".") + 1);
                    itemtypeprefix = itemtypeprefix.Substring(itemtypeprefix.IndexOf("_") + 1) + " ";
                }

                if ((Itemtype == "Weapon") && (build == 0))
                {
                    //Type in Part1 -> strParts[1]

                    itemtypeprefix = PartArray[build].Substring(PartArray[build].LastIndexOf(".") + 1);
                    itemtypeprefix = itemtypeprefix.Substring(itemtypeprefix.IndexOf("_") + 1) + " ";
                    if (itemtypeprefix.StartsWith("Weapon_"))
                        itemtypeprefix = itemtypeprefix.Substring(7);
                }

                // Names in Weapons only in Build 12,13 Items only in 7,8
                if (((Itemtype == "Weapon") && (build == 12 || build == 13)) || ((Itemtype == "Item") && (build == 7 || build == 8)))
                {
                    string iniReadvalue = xml.XmlReadValue(PartArray[build], INIValueToRetrieve);

                    if (Name == "" && iniReadvalue != "")
                        Name = iniReadvalue;
                    else if (iniReadvalue != null && iniReadvalue != "")
                        Name = (Name + " " + iniReadvalue);
                }
            }

            return itemtypeprefix + Name;
        }
        /*public string GetName(Ini.IniFile INI, string[] PartArray, int DesiredPart, string INIValueToRetrieve)
        {
            string Name = "";

            Name = (INI.IniReadValue(PartArray[DesiredPart], INIValueToRetrieve));

            return Name;
        }*/
        // 29 references - Fetch single xml value from name in part array
        public string GetName(XmlFile xml, string[] PartArray, int DesiredPart, string INIValueToRetrieve)
        {
            string Name = "";

            Name = (xml.XmlReadValue(PartArray[DesiredPart], INIValueToRetrieve));

            return Name;
        }
        //Grabs the name of a weapon/item from an INI.
        /*public string GetName(Ini.IniFile INI, string[,] PartArray, int DesiredPart, int NumberOfSubParts, string INIValueToRetrieve)
        {
            string Name = "";
            for (int build = 0; build < NumberOfSubParts; build++)
            {

                string readValue = INI.IniReadValue(PartArray[DesiredPart, build], INIValueToRetrieve);

                if (Name == "" && readValue != null)
                    Name = readValue;
                else if (readValue != null && readValue != "")
                    Name = (Name + " " + readValue);
            }

            return Name;
        }*/
        // 0 references - Build composite string from xmlvalues in string array.  Looks up xmlvalue of every part not just 12+13 or 7+8.  Don't need to specify item type. output is name only, no prefix
        public string GetName(XmlFile xml, string[,] PartArray, int DesiredPart, int NumberOfSubParts, string INIValueToRetrieve)
        {
            string Name = "";
            for (int build = 0; build < NumberOfSubParts; build++)
            {

                string readValue = xml.XmlReadValue(PartArray[DesiredPart, build], INIValueToRetrieve);

                if (Name == "" && readValue != null)
                    Name = readValue;
                else if (readValue != null && readValue != "")
                    Name = (Name + " " + readValue);
            }

            return Name;
        }
        public string GetLongName(XmlFile xml, string CategoryPart, string PrefixPart, string NamePart)
        {
            string category = xml.XmlReadValue(CategoryPart, "Prefix");
            string prefix = xml.XmlReadValue(PrefixPart, "PartName");
            string name = xml.XmlReadValue(NamePart, "PartName");

            if (prefix != "")
                name = prefix + " " + name;
            if (category != "")
                name = category + " " + name;
            return name;
        }
        public void DoSkillTree()
        {
            List<string> filestoconvert = new List<string>();
            filestoconvert.Add(AppDir + "\\Data\\gd_skills_common.txt");
            filestoconvert.Add(AppDir + "\\Data\\gd_Skills2_Roland.txt");
            filestoconvert.Add(AppDir + "\\Data\\gd_Skills2_Lilith.txt");
            filestoconvert.Add(AppDir + "\\Data\\gd_skills2_Mordecai.txt");
            filestoconvert.Add(AppDir + "\\Data\\gd_Skills2_Brick.txt");

            XmlFile AllSkills = new XmlFile(filestoconvert, AppDir + "\\Data\\xml\\gd_skills.xml");

            /*
                        XmlFile Common = new XmlFile();
                        Common.XmlFilename(AppDir + "\\Data\\gd_skills_common.txt");
                        XmlFile Roland = new XmlFile();
                        Roland.XmlFilename(AppDir + "\\Data\\gd_Skills2_Roland.txt");
                        XmlFile Lilith = new XmlFile();
                        Lilith.XmlFilename(AppDir + "\\Data\\gd_Skills2_Lilith.txt");
                        XmlFile Mordecai = new XmlFile();
                        Mordecai.XmlFilename(AppDir + "\\Data\\gd_skills2_Mordecai.txt");
                        XmlFile Brick = new XmlFile();
                        Brick.XmlFilename(AppDir + "\\Data\\gd_Skills2_Brick.txt");
            */
            //Ini.IniFile Common = new Ini.IniFile(AppDir + "\\Data\\gd_skills_common.txt");
            //Ini.IniFile Roland = new Ini.IniFile(AppDir + "\\Data\\gd_Skills2_Roland.txt");
            //Ini.IniFile Lilith = new Ini.IniFile(AppDir + "\\Data\\gd_Skills2_Lilith.txt");
            //Ini.IniFile Mordecai = new Ini.IniFile(AppDir + "\\Data\\gd_skills2_Mordecai.txt");
            //Ini.IniFile Brick = new Ini.IniFile(AppDir + "\\Data\\gd_Skills2_Brick.txt");
            SkillTree.Nodes.Clear();
            SkillLevel.Value = 0;
            SkillExp.Value = 0;
            SkillActive.SelectedItem = "No";
            for (int build = 0; build < CurrentWSG.NumberOfSkills; build++)
            {
                Node TempNode = new Node();
                if (AllSkills.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                    TempNode.Text = AllSkills.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                else
                    TempNode.Text = CurrentWSG.SkillNames[build];

                /*                if (Common.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                                    TempNode.Text = Common.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                                else if (Roland.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                                    TempNode.Text = Roland.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                                else if (Lilith.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                                    TempNode.Text = Lilith.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                                else if (Mordecai.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                                    TempNode.Text = Mordecai.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                                else if (Brick.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName") != "")
                                    TempNode.Text = Brick.XmlReadValue(CurrentWSG.SkillNames[build], "SkillName");
                                else
                                    TempNode.Text = CurrentWSG.SkillNames[build];
                */
                SkillTree.Nodes.Add(TempNode);

            }
        }
 public void DoSkillList()
 {
     SkillList.Items.Clear();
     if ((string)Class.SelectedItem == "Soldier")
     {
         //Ini.IniFile SkillINI = new Ini.IniFile(AppDir + "\\Data\\gd_skills2_Roland.txt");
         XmlFile SkillXML = new XmlFile(AppDir + "\\Data\\gd_skills2_Roland.txt");
         foreach (string section in SkillXML.stListSectionNames())
             SkillList.Items.Add((string)SkillXML.XmlReadValue(section, "SkillName"));
     }
     else if ((string)Class.SelectedItem == "Siren")
     {
         //Ini.IniFile SkillINI = new Ini.IniFile(AppDir + "\\Data\\gd_Skills2_Lilith.txt");
         XmlFile SkillXML = new XmlFile(AppDir + "\\Data\\gd_Skills2_Lilith.txt");
         foreach (string section in SkillXML.stListSectionNames())
             SkillList.Items.Add((string)SkillXML.XmlReadValue(section, "SkillName"));
     }
     else if ((string)Class.SelectedItem == "Hunter")
     {
         //Ini.IniFile SkillINI = new Ini.IniFile(AppDir + "\\Data\\gd_skills2_Mordecai.txt");
         XmlFile SkillXML = new XmlFile(AppDir + "\\Data\\gd_skills2_Mordecai.txt");
         foreach (string section in SkillXML.stListSectionNames())
             SkillList.Items.Add((string)SkillXML.XmlReadValue(section, "SkillName"));
     }
     else if ((string)Class.SelectedItem == "Berserker")
     {
         //Ini.IniFile SkillINI = new Ini.IniFile(AppDir + "\\Data\\gd_Skills2_Brick.txt");
         XmlFile SkillXML = new XmlFile(AppDir + "\\Data\\gd_Skills2_Brick.txt");
         foreach (string section in SkillXML.stListSectionNames())
             SkillList.Items.Add((string)SkillXML.XmlReadValue(section, "SkillName"));
     }
     else
     {
         //Ini.IniFile SkillINI = new Ini.IniFile(AppDir + "\\Data\\gd_skills_common.txt");
         XmlFile SkillXML = new XmlFile(AppDir + "\\Data\\gd_skills_common.txt");
         foreach (string section in SkillXML.stListSectionNames())
             SkillList.Items.Add((string)SkillXML.XmlReadValue(section, "SkillName"));
     }
 }
        public void DoQuestList()
        {
            XmlFile PartList = new XmlFile(AppDir + "\\Data\\Quests.ini");

            foreach (string section in PartList.stListSectionNames())
                QuestList.Items.Add(PartList.XmlReadValue(section, "MissionName"));

            //Ini.IniFile PartList = new Ini.IniFile(AppDir + "\\Data\\Quests.ini");
            //for (int Progress = 0; Progress < PartList.ListSectionNames().Length; Progress++)
            //    QuestList.Items.Add(PartList.IniReadValue(PartList.ListSectionNames()[Progress], "MissionName"));
        }
        private void ImportWeaponsFromXml_Click(object sender, EventArgs e)
        {
            OpenFileDialog tempImport = new OpenFileDialog();
            tempImport.DefaultExt = "*.xml";
            tempImport.Filter = "WillowTree Locker(*.xml)|*.xml";

            tempImport.FileName = CurrentWSG.CharacterName + "'s Weapons.xml";
            if (tempImport.ShowDialog() == DialogResult.OK)
            {
                //Ini.IniFile ImportWTL = new Ini.IniFile(tempImport.FileName);
                XmlFile ImportWTL = new XmlFile(tempImport.FileName);
                if (IsDLCWeaponMode)
                {

                    for (int Progress = 0; Progress < ImportWTL.stListSectionNames("Weapon").Count; Progress++)
                    {
                        CurrentWSG.DLC.WeaponParts.Add(new List<string>());
                        for (int ProgressStrings = 0; ProgressStrings < 14; ProgressStrings++)
                            CurrentWSG.DLC.WeaponParts[CurrentWSG.DLC.WeaponParts.Count - 1].Add(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Weapon")[Progress], "Part" + (ProgressStrings + 1)));

                        CurrentWSG.DLC.WeaponAmmo.Add(0);
                        CurrentWSG.DLC.WeaponQuality.Add(0);
                        CurrentWSG.DLC.WeaponLevel.Add(0);
                        CurrentWSG.DLC.WeaponEquippedSlot.Add(0);
                        CurrentWSG.DLC.TotalWeapons++;
                    }
                    DoDLCWeaponTree();
                }

                else
                {
                    for (int Progress = 0; Progress < ImportWTL.stListSectionNames("Weapon").Count; Progress++)
                    {
                        List<String> wpnstrings = new List<string>();
                        List<int> wpnvalues = new List<int>();
                        try
                        {
                            for (int ProgressStrings = 0; ProgressStrings < 14; ProgressStrings++)
                            {
                                string part = ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Weapon")[Progress], "Part" + (ProgressStrings + 1));
                                ThrowExceptionIfIntString(part);
                                wpnstrings.Add(part);
                            }

                            wpnvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Weapon")[Progress], "RemAmmo_Quantity"),0));
                            wpnvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Weapon")[Progress], "Quality"),0));
                            wpnvalues.Add(0); // set equipped slot to 0
                            wpnvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Weapon")[Progress], "Level"),0));
                        }
                        catch
                        {
                            MessageBox.Show("Error reading XML file.  Skipping item.");
                            continue;
                        }

                        CurrentWSG.WeaponStrings.Add(wpnstrings);
                        CurrentWSG.WeaponValues.Add(wpnvalues);
                        CurrentWSG.NumberOfWeapons++;
                    }

                    DoWeaponTree();
                }
            }
        }
        private void InsertItemsFromXml_Click(object sender, EventArgs e)
        {
            OpenFileDialog tempImport = new OpenFileDialog();
            tempImport.DefaultExt = "*.xml";
            tempImport.Filter = "WillowTree Locker(*.xml)|*.xml";

            tempImport.FileName = CurrentWSG.CharacterName + "'s Items.xml";
            if (tempImport.ShowDialog() == DialogResult.OK)
            {
                //Ini.IniFile ImportWTL = new Ini.IniFile(tempImport.FileName);
                XmlFile ImportWTL = new XmlFile(tempImport.FileName);
                if (IsDLCItemMode)
                {

                    for (int Progress = 0; Progress < ImportWTL.stListSectionNames("Item").Count; Progress++)
                    {
                        CurrentWSG.DLC.ItemParts.Add(new List<string>());

                        for (int ProgressStrings = 0; ProgressStrings < 9; ProgressStrings++)
                            CurrentWSG.DLC.ItemParts[CurrentWSG.DLC.ItemParts.Count - 1].Add(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Item")[Progress], "Part" + (ProgressStrings + 1)));

                        CurrentWSG.DLC.ItemQuantity.Add(1);
                        CurrentWSG.DLC.ItemQuality.Add(0);
                        CurrentWSG.DLC.ItemLevel.Add(0);
                        CurrentWSG.DLC.ItemEquipped.Add(0);
                        CurrentWSG.DLC.TotalItems++;
                    }
                    DoDLCItemTree();
                }

                else
                {
                    for (int Progress = 0; Progress < ImportWTL.stListSectionNames("Item").Count; Progress++)
                    {
                        List<string> itemstrings = new List<string>();
                        List<int> itemvalues = new List<int>();

                        try
                        {
                            for (int ProgressStrings = 0; ProgressStrings < 9; ProgressStrings++)
                            {
                                string part = ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Item")[Progress], "Part" + (ProgressStrings + 1));
                                ThrowExceptionIfIntString(part);
                                itemstrings.Add(part);
                            }

                            itemvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Item")[Progress], "RemAmmo_Quantity"),0));
                            itemvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Item")[Progress], "Quality"),0));
                            itemvalues.Add(0); // set equipped slot to 0
                            itemvalues.Add(Int32FromString(ImportWTL.XmlReadValue(ImportWTL.stListSectionNames("Item")[Progress], "Level"),0));
                        }
                        catch
                        {
                            MessageBox.Show("Error reading XML file.  Some items were not read.");
                            break;
                        }

                        CurrentWSG.ItemStrings.Add(itemstrings);
                        CurrentWSG.ItemValues.Add(itemvalues);
                        CurrentWSG.NumberOfItems++;
                    }
                    DoItemTree();
                }
            }
        }
        public int GetWeaponDamage(string[] WeaponParts)
        {
            try
            {
                string ItemGradeFile = WeaponParts[0].Substring(0, WeaponParts[0].IndexOf(".")) + ".txt";
                string ItemGradePart = WeaponParts[0].Substring(WeaponParts[0].IndexOf(".") + 1);
                string Manufacturer = WeaponParts[1].Substring(WeaponParts[1].LastIndexOf(".") + 1);
                XmlFile ItemGrade = new XmlFile(AppDir + "\\Data\\" + ItemGradeFile);

                double ExtraDamage = 0;
                double Multiplier = Conversion.Val(new XmlFile(AppDir + "\\Data\\" + WeaponParts[2].Substring(0, WeaponParts[2].IndexOf(".")) + ".txt").XmlReadValue(WeaponParts[2].Substring(WeaponParts[2].IndexOf(".") + 1), "WeaponDamageFormulaMultiplier")); ;
                double Level = Conversion.Val(ItemGrade.XmlReadValue(ItemGradePart, Manufacturer + "(" + WeaponQuality.Value + ")"));
                double Power = 1.3;
                double Offset = 9;
                for (int i = 3; i < 14; i++)
                    if (WeaponParts[i].Contains("."))
                        ExtraDamage = ExtraDamage + Conversion.Val(new XmlFile(AppDir + "\\Data\\" + WeaponParts[i].Substring(0, WeaponParts[i].IndexOf(".")) + ".txt").XmlReadValue(WeaponParts[i].Substring(WeaponParts[i].IndexOf(".") + 1), "WeaponDamage"));

                return (int)(ExtraDamage * (Multiplier * (Math.Pow(Level, Power) + Offset))) + (int)(Multiplier * (Math.Pow(Level, Power) + Offset));
            }
            catch
            {
                return 1337;
            }
        }
        private void QuestList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int SelectedItem = QuestList.SelectedIndex;
            NewQuest.ClosePopup();
            try
            {
                //Ini.IniFile Quests = new Ini.IniFile(AppDir + "\\Data\\Quests.ini");
                XmlFile Quests = new XmlFile(AppDir + "\\Data\\Quests.ini");
                if (QuestTree.SelectedNode.Name == "PT1" || QuestTree.SelectedNode == QuestTree.Nodes[0])
                {
                    int TotalObjectives = 0;
                    CurrentWSG.TotalPT1Quests = CurrentWSG.TotalPT1Quests + 1;
                    ResizeArrayLarger(ref CurrentWSG.PT1Strings, CurrentWSG.TotalPT1Quests);
                    ResizeArrayLarger(ref CurrentWSG.PT1Values, CurrentWSG.TotalPT1Quests, 9);
                    ResizeArrayLarger(ref CurrentWSG.PT1Subfolders, CurrentWSG.TotalPT1Quests, 5);
                    CurrentWSG.PT1Strings[CurrentWSG.TotalPT1Quests - 1] = Quests.stListSectionNames()[SelectedItem];
                    CurrentWSG.PT1Values[CurrentWSG.TotalPT1Quests - 1, 0] = 1;
                    for (int Progress = 0; Progress < 5; Progress++)
                        if (Quests.XmlReadValue(Quests.stListSectionNames()[SelectedItem], "Objectives" + Progress) == "") break;
                        else TotalObjectives = Progress + 1;
                    CurrentWSG.PT1Values[CurrentWSG.TotalPT1Quests - 1, 3] = TotalObjectives;
                    for (int Progress = 0; Progress < 5; Progress++)
                        CurrentWSG.PT1Subfolders[CurrentWSG.TotalPT1Quests - 1, Progress] = "None";

                    DoQuestTree();
                    QuestTree.SelectedNode = QuestTree.Nodes[0].Nodes[CurrentWSG.TotalPT1Quests - 1];
                }
                if (QuestTree.SelectedNode.Name == "PT2" || QuestTree.SelectedNode.Text == "Playthrough 2 Quests")
                {
                    int TotalObjectives = 0;
                    CurrentWSG.TotalPT2Quests = CurrentWSG.TotalPT2Quests + 1;
                    ResizeArrayLarger(ref CurrentWSG.PT2Strings, CurrentWSG.TotalPT2Quests);
                    ResizeArrayLarger(ref CurrentWSG.PT2Values, CurrentWSG.TotalPT2Quests, 9);
                    ResizeArrayLarger(ref CurrentWSG.PT2Subfolders, CurrentWSG.TotalPT2Quests, 5);
                    CurrentWSG.PT2Strings[CurrentWSG.TotalPT2Quests - 1] = Quests.stListSectionNames()[SelectedItem];
                    CurrentWSG.PT2Values[CurrentWSG.TotalPT2Quests - 1, 0] = 1;
                    for (int Progress = 0; Progress < 5; Progress++)
                        if (Quests.XmlReadValue(Quests.stListSectionNames()[SelectedItem], "Objectives[" + Progress + "]") == "") break;
                        else TotalObjectives = Progress + 1;
                    CurrentWSG.PT2Values[CurrentWSG.TotalPT2Quests - 1, 3] = TotalObjectives;
                    for (int Progress = 0; Progress < 5; Progress++)
                        CurrentWSG.PT2Subfolders[CurrentWSG.TotalPT2Quests - 1, Progress] = "None";

                    DoQuestTree();
                    QuestTree.SelectedNode = QuestTree.Nodes[1].Nodes[CurrentWSG.TotalPT2Quests - 1];
                }
            }
            catch { }
        }
        public void DoEchoList()
        {
            //Ini.IniFile PartList = new Ini.IniFile(AppDir + "\\Data\\Echos.ini");
            XmlFile PartList = new XmlFile(AppDir + "\\Data\\Echos.ini");

            foreach (string section in PartList.stListSectionNames())
            {
                string name = PartList.XmlReadValue(section, "Subject");
                if (name != "")
                    EchoList.Items.Add(name);
                else
                    EchoList.Items.Add(section);
            }

            //for (int Progress = 0; Progress < PartList.stListSectionNames().Count; Progress++)
            //{
            //    string name = PartList.XmlReadValue(PartList.stListSectionNames()[Progress], "Subject");
            //    if (name != "")
            //        EchoList.Items.Add(name);
            //    else EchoList.Items.Add(PartList.stListSectionNames()[Progress]);
            //}
        }
        //  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< QUESTS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  \\
        private void QuestTree_AfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
        {
            Clicked = false;
            try
            {
                SelectedQuestGroup.Text = QuestTree.SelectedNode.Text;
                //if (QuestTree.SelectedNode.Parent.Text == "Playthrough 1 Quests" && QuestTree.SelectedNode.HasChildNodes == false)

                //else if (QuestTree.SelectedNode.Parent.Text == "Playthrough 2 Quests" && QuestTree.SelectedNode.HasChildNodes == false)
                if (QuestTree.SelectedNode.Name == "PT1")
                {

                    QuestString.Text = CurrentWSG.PT1Strings[QuestTree.SelectedNode.Index];
                    if (CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0] > 2)
                        QuestProgress.SelectedIndex = 3;
                    else QuestProgress.SelectedIndex = CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 0];
                    NumberOfObjectives.Value = CurrentWSG.PT1Values[QuestTree.SelectedNode.Index, 3];
                    Objectives.Items.Clear();
                    XmlFile Quest = new XmlFile(AppDir + "\\Data\\Quests.ini");
                    if (NumberOfObjectives.Value > 0)
                        for (int Progress = 0; Progress < NumberOfObjectives.Value; Progress++)
                            Objectives.Items.Add(Quest.XmlReadValue(QuestString.Text, "Objectives" + Progress));
                    ObjectiveValue.Value = 0;
                    QuestSummary.Text = Quest.XmlReadValue(QuestString.Text, "MissionSummary");
                    QuestDescription.Text = Quest.XmlReadValue(QuestString.Text, "MissionDescription");
                }
                else if (QuestTree.SelectedNode.Name == "PT2")
                {
                    QuestString.Text = CurrentWSG.PT2Strings[QuestTree.SelectedNode.Index];
                    if (CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0] > 2)
                        QuestProgress.SelectedIndex = 3;
                    else QuestProgress.SelectedIndex = CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 0];
                    NumberOfObjectives.Value = CurrentWSG.PT2Values[QuestTree.SelectedNode.Index, 3];
                    Objectives.Items.Clear();
                    XmlFile Quest = new XmlFile(AppDir + "\\Data\\Quests.ini");
                    if (NumberOfObjectives.Value > 0)
                        for (int Progress = 0; Progress < NumberOfObjectives.Value; Progress++)
                            Objectives.Items.Add(Quest.XmlReadValue(QuestString.Text, "Objectives" + Progress));
                    ObjectiveValue.Value = 0;
                    QuestSummary.Text = Quest.XmlReadValue(QuestString.Text, "MissionSummary");
                    QuestDescription.Text = Quest.XmlReadValue(QuestString.Text, "MissionDescription");
                }
            }
            catch { QuestString.Text = ""; Objectives.Items.Clear(); NumberOfObjectives.Value = 0; ObjectiveValue.Value = 0; QuestProgress.SelectedIndex = 0; }
        }
 public void DoLocationsList()
 {
     LocationsList.Items.Clear();
     CurrentLocation.Items.Clear();
     //Ini.IniFile Locations = new Ini.IniFile(AppDir + "\\Data\\Locations.ini");
     XmlFile Locations = new XmlFile(AppDir + "\\Data\\Locations.ini");
     foreach (string section in Locations.stListSectionNames())
     {
         string outpostname = Locations.XmlReadValue(section, "OutpostDisplayName");
         LocationsList.Items.Add(outpostname);
         CurrentLocation.Items.Add(outpostname);
     }
 }