예제 #1
0
        private bool EditSection()
        {
            MobFileSection     cur      = CurrentMob.CurrentSection;
            var                encoding = Encoding.GetEncoding(1251);
            MobFileSectionInfo info     = cur.info;

            switch (info.Type)
            {
            case SectionType.ST_STRING:
            case SectionType.ST_SCRIPT:
            case SectionType.ST_SCRIPT_ENC:
                StringEdit.textBox1.Text = cur.toString();
                if (StringEdit.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }

                cur.setString(StringEdit.textBox1.Text);
                break;

            case SectionType.ST_BYTE:
                NumberEdit.type          = Edit_Type.BYTE;
                NumberEdit.textBox1.Text = cur.toNumber().ToString();
                if (NumberEdit.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
                cur.setNumber(byte.Parse(NumberEdit.textBox1.Text));
                break;

            case SectionType.ST_DWORD:
                NumberEdit.type          = Edit_Type.DWORD;
                NumberEdit.textBox1.Text = cur.toNumber().ToString();
                if (NumberEdit.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
                cur.setNumber(uint.Parse(NumberEdit.textBox1.Text));
                break;

            case SectionType.ST_FLOAT:
                NumberEdit.type          = Edit_Type.FLOAT;
                NumberEdit.textBox1.Text = cur.toNumber().ToString();
                if (NumberEdit.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
                cur.setNumber(float.Parse(NumberEdit.textBox1.Text));
                break;

            case SectionType.ST_STR_S06:
                UnitStatsEdit.Data = cur.Data;
                UnitStatsEdit.ShowDialog();
                break;

            default:
                return(false);
            }

            CurrentMob.ReturnSection();
            return(true);
        }
예제 #2
0
        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);
            }
        }