void btnAddRMap_Click(object sender, MouseButtonEventArgs e)
        {
            for (int i = nudRDungeonFloor.Value; i <= nudRDungeonFloorEnd.Value; i++)
            {
                int index = DungeonFloorIndex(nudRDungeonIndex.Value - 1, i - 1);
                if (index > -1)
                {
                    dungeon.RandomMaps.RemoveAt(index);
                }
            }

            lbxDungeonRMaps.Items.Clear();
            for (int maps = 0; maps < dungeon.RandomMaps.Count; maps++)
            {
                string mapText;
                if (dungeon.RandomMaps[maps].IsBadGoalMap)
                {
                    mapText = (maps + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(dungeon.RandomMaps[maps].Difficulty) + "] Dun #" + (dungeon.RandomMaps[maps].RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[dungeon.RandomMaps[maps].RDungeonIndex].Name + ") " + (dungeon.RandomMaps[maps].RDungeonFloor + 1) + "F";
                }
                else
                {
                    mapText = (maps + 1) + ": [" + Missions.MissionManager.DifficultyToString(dungeon.RandomMaps[maps].Difficulty) + "] Dun #" + (dungeon.RandomMaps[maps].RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[dungeon.RandomMaps[maps].RDungeonIndex].Name + ") " + (dungeon.RandomMaps[maps].RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }

            for (int i = nudRDungeonFloor.Value; i <= nudRDungeonFloorEnd.Value; i++)
            {
                Logic.Editors.Dungeons.EditableRandomDungeonMap map = new Logic.Editors.Dungeons.EditableRandomDungeonMap();
                map.RDungeonIndex = nudRDungeonIndex.Value - 1;
                map.RDungeonFloor = i - 1;
                map.Difficulty    = (Enums.JobDifficulty)nudRMapDifficulty.Value;
                map.IsBadGoalMap  = chkRMapBad.Checked;

                dungeon.RandomMaps.Add(map);

                string mapText;
                if (map.IsBadGoalMap)
                {
                    mapText = (lbxDungeonRMaps.Items.Count + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                else
                {
                    mapText = (lbxDungeonRMaps.Items.Count + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }
        }
        void btnAddRMap_Click(object sender, MouseButtonEventArgs e)
        {
            for (int i = nudRDungeonFloor.Value; i <= nudRDungeonFloorEnd.Value; i++)
            {
                int index = DungeonFloorIndex(nudRDungeonIndex.Value - 1, i - 1);
                if (index > -1)
                {
                    dungeon.RandomMaps.RemoveAt(index);
                }
            }

            lbxDungeonRMaps.Items.Clear();
            for (int maps = 0; maps < dungeon.RandomMaps.Count; maps++)
            {
                string mapText;
                if (dungeon.RandomMaps[maps].IsBadGoalMap)
                {
                    mapText = (maps + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(dungeon.RandomMaps[maps].Difficulty) + "] Dun #" + (dungeon.RandomMaps[maps].RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[dungeon.RandomMaps[maps].RDungeonIndex].Name + ") " + (dungeon.RandomMaps[maps].RDungeonFloor + 1) + "F";
                }
                else
                {
                    mapText = (maps + 1) + ": [" + Missions.MissionManager.DifficultyToString(dungeon.RandomMaps[maps].Difficulty) + "] Dun #" + (dungeon.RandomMaps[maps].RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[dungeon.RandomMaps[maps].RDungeonIndex].Name + ") " + (dungeon.RandomMaps[maps].RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }

            for (int i = nudRDungeonFloor.Value; i <= nudRDungeonFloorEnd.Value; i++)
            {

                Logic.Editors.Dungeons.EditableRandomDungeonMap map = new Logic.Editors.Dungeons.EditableRandomDungeonMap();
                map.RDungeonIndex = nudRDungeonIndex.Value - 1;
                map.RDungeonFloor = i - 1;
                map.Difficulty = (Enums.JobDifficulty)nudRMapDifficulty.Value;
                map.IsBadGoalMap = chkRMapBad.Checked;

                dungeon.RandomMaps.Add(map);

                string mapText;
                if (map.IsBadGoalMap)
                {
                    mapText = (lbxDungeonRMaps.Items.Count + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                else
                {
                    mapText = (lbxDungeonRMaps.Items.Count + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }
        }
        public void LoadDungeon(string[] parse)
        {
            this.Size = pnlDungeonEditor.Size;
            pnlDungeonList.Visible   = false;
            pnlDungeonEditor.Visible = true;
            btnGeneral_Click(null, null);
            lbxDungeonSMaps.Items.Clear();
            lbxDungeonRMaps.Items.Clear();
            lbxDungeonScripts.Items.Clear();
            //this.Size = new System.Drawing.Size(pnlDungeonGeneral.Width, pnlDungeonGeneral.Height);

            dungeon = new Logic.Editors.Dungeons.EditableDungeon();

            dungeon.Name         = parse[2];
            txtName.Text         = dungeon.Name;
            dungeon.AllowsRescue = parse[3].ToBool();
            chkRescue.Checked    = dungeon.AllowsRescue;
            int scriptCount = parse[4].ToInt();
            int n           = 5;

            for (int i = 0; i < scriptCount; i++)
            {
                dungeon.ScriptList.Add(parse[n].ToInt(), parse[n + 1]);

                n += 2;

                ListBoxTextItem lbiScript = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), dungeon.ScriptList.KeyByIndex(i) + ": " + dungeon.ScriptList.ValueByIndex(i));
                lbxDungeonScripts.Items.Add(lbiScript);
            }

            int mapCount = parse[n].ToInt();

            n++;

            for (int i = 0; i < mapCount; i++)
            {
                Logic.Editors.Dungeons.EditableStandardDungeonMap map = new Logic.Editors.Dungeons.EditableStandardDungeonMap();
                map.Difficulty   = (Enums.JobDifficulty)parse[n].ToInt();
                map.IsBadGoalMap = parse[n + 1].ToBool();
                map.MapNum       = parse[n + 2].ToInt();

                dungeon.StandardMaps.Add(map);

                string mapText;
                if (map.IsBadGoalMap)
                {
                    mapText = (i + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Map #" + map.MapNum;
                }
                else
                {
                    mapText = (i + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Map #" + map.MapNum;
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonSMaps.Items.Add(lbiMap);

                n += 3;
            }
            mapCount = parse[n].ToInt();
            n++;
            for (int i = 0; i < mapCount; i++)
            {
                Logic.Editors.Dungeons.EditableRandomDungeonMap map = new Logic.Editors.Dungeons.EditableRandomDungeonMap();
                map.Difficulty    = (Enums.JobDifficulty)parse[n].ToInt();
                map.IsBadGoalMap  = parse[n + 1].ToBool();
                map.RDungeonIndex = parse[n + 2].ToInt();
                map.RDungeonFloor = parse[n + 3].ToInt();
                dungeon.RandomMaps.Add(map);

                n += 4;
                string mapText;
                if (map.IsBadGoalMap)
                {
                    mapText = (i + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                else
                {
                    mapText = (i + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }

            dungeon.LegendaryId = parse[n++].ToInt();

            btnEdit.Text = "Edit";
        }
        public void LoadDungeon(string[] parse)
        {
            this.Size = pnlDungeonEditor.Size;
            pnlDungeonList.Visible = false;
            pnlDungeonEditor.Visible = true;
            btnGeneral_Click(null, null);
            lbxDungeonSMaps.Items.Clear();
            lbxDungeonRMaps.Items.Clear();
            lbxDungeonScripts.Items.Clear();
            //this.Size = new System.Drawing.Size(pnlDungeonGeneral.Width, pnlDungeonGeneral.Height);

            dungeon = new Logic.Editors.Dungeons.EditableDungeon();

            dungeon.Name = parse[2];
            txtName.Text = dungeon.Name;
            dungeon.AllowsRescue = parse[3].ToBool();
            chkRescue.Checked = dungeon.AllowsRescue;
            int scriptCount = parse[4].ToInt();
            int n = 5;
            for (int i = 0; i < scriptCount; i++) {
                dungeon.ScriptList.Add(parse[n].ToInt(), parse[n + 1]);

                n += 2;

                ListBoxTextItem lbiScript = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), dungeon.ScriptList.KeyByIndex(i) + ": " + dungeon.ScriptList.ValueByIndex(i));
                lbxDungeonScripts.Items.Add(lbiScript);

            }

            int mapCount = parse[n].ToInt();
            n++;

            for (int i = 0; i < mapCount; i++) {
                Logic.Editors.Dungeons.EditableStandardDungeonMap map = new Logic.Editors.Dungeons.EditableStandardDungeonMap();
                map.Difficulty = (Enums.JobDifficulty)parse[n].ToInt();
                map.IsBadGoalMap = parse[n + 1].ToBool();
                map.MapNum = parse[n + 2].ToInt();

                dungeon.StandardMaps.Add(map);

                string mapText;
                if (map.IsBadGoalMap) {
                    mapText = (i + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Map #" + map.MapNum;
                } else {
                    mapText = (i + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Map #" + map.MapNum;
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonSMaps.Items.Add(lbiMap);

                n += 3;
            }
            mapCount = parse[n].ToInt();
            n++;
            for (int i = 0; i < mapCount; i++)
            {
                Logic.Editors.Dungeons.EditableRandomDungeonMap map = new Logic.Editors.Dungeons.EditableRandomDungeonMap();
                map.Difficulty = (Enums.JobDifficulty)parse[n].ToInt();
                map.IsBadGoalMap = parse[n + 1].ToBool();
                map.RDungeonIndex = parse[n + 2].ToInt();
                map.RDungeonFloor = parse[n + 3].ToInt();
                dungeon.RandomMaps.Add(map);

                n += 4;
                string mapText;
                if (map.IsBadGoalMap) {
                    mapText = (i + 1) + ": (Boss)[" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                } else {
                    mapText = (i + 1) + ": [" + Missions.MissionManager.DifficultyToString(map.Difficulty) + "] Dun #" + (map.RDungeonIndex + 1) + " (" + RDungeons.RDungeonHelper.RDungeons[map.RDungeonIndex].Name + ") " + (map.RDungeonFloor + 1) + "F";
                }
                ListBoxTextItem lbiMap = new ListBoxTextItem(Logic.Graphics.FontManager.LoadFont("tahoma", 10), mapText);
                lbxDungeonRMaps.Items.Add(lbiMap);
            }

            btnEdit.Text = "Edit";
        }