コード例 #1
0
ファイル: MainForm.cs プロジェクト: koteyur/MobExplorer
        private MobFileObjectInfo GetObjectInfo(MobFileSection section)
        {
            if (!section.Readed)
            {
                section.ReadSubsections();
            }
            MobFileObjectInfo obj = new MobFileObjectInfo();
            ASCIIEncoding     encoding = new System.Text.ASCIIEncoding();
            int    delta, int_val = -1;
            string str_val = "";

            for (int i = 0; i < section.Items.Count; ++i)
            {
                SectionType type = section.Items[i].info.Type;

                delta = BitConverter.ToInt32(section.Items[i].Data, 4) - 8;
                if (type == SectionType.ST_STRING)
                {
                    str_val = encoding.GetString(section.Items[i].Data, 8, delta);
                }
                else if (type == SectionType.ST_DWORD)
                {
                    int_val = BitConverter.ToInt32(section.Items[i].Data, 8);
                }
                switch (section.Items[i].info.Id)
                {
                case SectionId.ID_OBJNAME: obj.Name = str_val; break;

                case SectionId.ID_UNIT_PROTOTYPE: obj.Prototype = str_val; break;

                case SectionId.ID_NID: obj.Id = int_val.ToString(); break;
                }
            }

            return(obj);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: koteyur/MobExplorer
        private void ShowCurrentSection()
        {
            listView1.Clear();
            if (MobFiles.Count == 0)
            {
                FixColumns();
                statusStrip1.Items[0].Text = "0";
                statusStrip1.Items[1].Text = "";
                return;
            }
            listView1.ListViewItemSorter = null;
            listView1.SuspendLayout();

            if (CurrentMob == null)
            {
                statusStrip1.Items[0].Text = MobFiles.Count.ToString();
                statusStrip1.Items[1].Text = "";
                for (int i = 0; i < MobFiles.Count; ++i)
                {
                    listView1.Items.Add(MobFiles[i].Filename.Substring(MobFiles[i].Filename.LastIndexOf('\\') + 1), 0);
                }
            }
            else
            {
                MobFileSectionInfo parent_info = null;
                if (CurrentMob.CurrentSection.Owner != null)
                {
                    parent_info = CurrentMob.CurrentSection.info;
                }

                statusStrip1.Items[0].Text = CurrentMob.CurrentSection.Items.Count.ToString();
                statusStrip1.Items[1].Text = CurrentMob.Filename;
                if (CurrentMob.Changed)
                {
                    statusStrip1.Items[1].Text += " *";
                }
                listView1.Items.Add("Up", 3);
                for (int i = 0; i < CurrentMob.CurrentSection.Items.Count; ++i)
                {
                    MobFileSectionInfo info = CurrentMob.CurrentSection.Items[i].info;
                    string             name = info.Id.ToString("g");
                    switch (info.Type)
                    {
                    case SectionType.ST_REC:
                        listView1.Items.Add(name, 0);
                        break;

                    case SectionType.ST_SCRIPT:
                    case SectionType.ST_SCRIPT_ENC:
                    case SectionType.ST_STRING:
                        listView1.Items.Add(name, 2);
                        break;

                    case SectionType.ST_UNK:
                        listView1.Items.Add(name, 4);
                        break;

                    default:
                        listView1.Items.Add(name, 1);
                        break;
                    }

                    listView1.Items[i + 1].SubItems.Add((i + 1).ToString());
                    listView1.Items[i + 1].SubItems.Add(info.Type.ToString());
                    listView1.Items[i + 1].SubItems.Add(BitConverter.ToInt32(
                                                            CurrentMob.CurrentSection.Items[i].Data, 4).ToString());

                    if (parent_info != null && parent_info.Id == SectionId.ID_OBJECTSECTION)
                    {
                        MobFileObjectInfo obj = GetObjectInfo(CurrentMob.CurrentSection.Items[i]);
                        listView1.Items[i + 1].SubItems.Add(obj.Id);
                        listView1.Items[i + 1].SubItems.Add(obj.Name);
                        listView1.Items[i + 1].SubItems.Add(obj.Prototype);
                    }
                }
            }
            FixColumns();
            listView1.ResumeLayout();

            if (CurrentMob != null && CurrentMob.CurrentSection.UserValue != null && ((int[])CurrentMob.CurrentSection.UserValue).Length > 0)
            {
                listView1.TopItem = listView1.Items[((int[])CurrentMob.CurrentSection.UserValue)[0]];
                listView1.TopItem = listView1.Items[((int[])CurrentMob.CurrentSection.UserValue)[0]];
                listView1.TopItem = listView1.Items[((int[])CurrentMob.CurrentSection.UserValue)[0]];
                //MessageBox.Show(listView1.Items[CurrentMob.CurrentSection.UserValue[0]].Text + " <-> " + listView1.TopItem.Text);
            }
        }