예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            MobFiles   = new List <MobFile>();
            CurrentMob = null;
            listView1.AllowColumnReorder = true;
            StringEdit    = new StringEditForm();
            NumberEdit    = new NumberEditForm();
            Settings      = new SettingsForm();
            About         = new AboutBox();
            UnitStatsEdit = new UnitStatsEditForm();

            loadSettings();

            Text = String.Format("MobExplorer {0}", Application.ProductVersion);
            initRecentlyList();
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length > 1)
            {
                for (int i = 1; i < args.Length; ++i)
                {
                    openMob(args[i]);
                }
            }

            ShowCurrentSection();
        }
예제 #2
0
 private void returnSection()
 {
     if (CurrentMob == null || CurrentMob.CurrentSection == null)
     {
         return;
     }
     if (CurrentMob.CurrentSection.Owner == null)
     {
         CurrentMob = null;
     }
     else
     {
         CurrentMob.ReturnSection();
     }
     ShowCurrentSection();
 }
예제 #3
0
        private void openlistViewItem()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }
            int index        = listView1.SelectedItems[0].Index;
            int sectionIndex = getRealIndex(index);

            if (CurrentMob == null)
            {
                CurrentMob = MobFiles[index];
            }
            else if (index == 0 || sectionIndex < 0)
            {
                returnSection();
                return;
            }
            else if (CurrentMob.CurrentSection.Items[sectionIndex].info.Type == SectionType.ST_REC)
            {
                if (CurrentMob.CurrentSection.UserValue == null || ((int[])CurrentMob.CurrentSection.UserValue).Length == 0)
                {
                    CurrentMob.CurrentSection.UserValue = new int[1];
                }
                ((int[])CurrentMob.CurrentSection.UserValue)[0] = listView1.TopItem.Index;
                //MessageBox.Show(listView1.TopItem.Text);

                CurrentMob.CurrentSection = CurrentMob.CurrentSection.Items[sectionIndex];
                CurrentMob.CurrentSection.ReadSubsections();
            }
            else
            {
                var sec = CurrentMob.CurrentSection;
                CurrentMob.CurrentSection = CurrentMob.CurrentSection.Items[sectionIndex];
                if (!EditSection())
                {
                    CurrentMob.CurrentSection = sec;
                    return;
                }
                else
                {
                    CurrentMob.Changed = true;
                }
            }

            ShowCurrentSection();
        }
예제 #4
0
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CurrentMob != null)
     {
         MobFiles.Remove(CurrentMob);
     }
     else
     {
         for (int i = listView1.SelectedItems.Count - 1; i >= 0; --i)
         {
             MobFiles.RemoveAt(listView1.SelectedIndices[i]);
             listView1.SelectedItems[i].Remove();
         }
     }
     CurrentMob = null;
     ShowCurrentSection();
 }
예제 #5
0
        private void openMob(string path)
        {
            var        mob    = new MobFile();
            ErrorCodes result = mob.OpenMobFile(path);

            if (result == ErrorCodes.OK)
            {
                MobFiles.Add(mob);
                addFileToRecentlyList(path);
                CurrentMob = mob;
                if (scriptShowAtStartup)
                {
                    if (MobHelper.openSectionById(mob, SectionId.ID_OBJECTDBFILE) &&
                        (MobHelper.openSectionById(mob, SectionId.ID_SS_TEXT) || MobHelper.openSectionById(mob, SectionId.ID_SS_TEXT_OLD)))
                    {
                        if (EditSection())
                        {
                            CurrentMob.Changed = true;
                        }
                        else
                        {
                            CurrentMob.CurrentSection = mob.CurrentSection.Owner;
                        }
                    }
                }
            }
            else
            {
                if (result == ErrorCodes.CannotOpen)
                {
                    MessageBox.Show("Cannot open " + path, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Invalid mob " + path, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                CurrentMob = null;
            }
            ShowCurrentSection();
        }
예제 #6
0
        private void SaveMobFile()
        {
            MobFile mob = null;

            if (CurrentMob != null)
            {
                mob = CurrentMob;
            }
            else if (listView1.SelectedItems.Count > 0)
            {
                mob = MobFiles[listView1.SelectedIndices[0]];
            }
            if (mob == null)
            {
                return;
            }
            saveFileDialog1.InitialDirectory = mob.Filename.Substring(0, mob.Filename.LastIndexOf('\\'));
            saveFileDialog1.FileName         = mob.Filename.Substring(mob.Filename.LastIndexOf('\\') + 1);
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                mob.SaveMobFile(saveFileDialog1.FileName);
            }
            ShowCurrentSection();
        }