private void Paste() { if (CurrentMob == null || SectionBuffer == null || SectionBuffer.Length <= 0) { return; } MobFileSection cur = CurrentMob.CurrentSection, newsect; int delta = 0; for (int i = 0; i < SectionBuffer.Length; ++i) { newsect = SectionBuffer[i].Clone(cur); CurrentMob.CurrentSection.Items.Add(newsect); delta += BitConverter.ToInt32(newsect.Data, 4); } CurrentMob.FixSize(delta); CurrentMob.Changed = true; ShowCurrentSection(); }
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); }
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); }