/// <summary> /// The swap item_ click. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void SwapItem_Click(object sender, EventArgs e) { if (parsedCheckBox.Checked) { MessageBox.Show("Turn off parsing first"); return; } if (references.SelectedIndices.Count == 0) { return; } List<int> idTags = new List<int>(); List<int> idOffs = new List<int>(); for (int x = 0; x < references.SelectedIndices.Count; x++) { int d = references.SelectedIndices[x]; int tempcount = 0; // Tag contains the position value of the item in SelectedMeta.Items int selectedIndex = (int)formFuncs.ListItems[d].Tag; Meta.Item item = map.SelectedMeta.items[selectedIndex]; if (item.type == map.DisplayType) { switch (item.type) { case Meta.ItemType.Ident: Meta.Ident id = (Meta.Ident)item; IdentSwapper iSwap = new IdentSwapper(); int iOffx = map.MetaInfo.Offset[map.SelectedMeta.TagIndex] + id.offset; idTags.Add(id.pointstoTagIndex); idOffs.Add(iOffx); if (x == references.SelectedIndices.Count - 1) { iSwap.LoadStuff(idTags, idOffs, map); iSwap.ShowDialog(); iSwap.Dispose(); x = references.SelectedIndices.Count; } break; case Meta.ItemType.String: Meta.String str = (Meta.String)item; if (sSwap == null) { sSwap = new MEStringsSelector(map, this); } sSwap.SelectedID = str.id; sSwap.ShowDialog(); // this.Enabled = true; if (str.id != sSwap.SelectedID) { str.id = sSwap.SelectedID; str.name = map.Strings.Name[sSwap.SelectedID]; // int sOffx = Map.MetaInfo.Offset[Map.SelectedMeta.TagIndex] + str.offset; int sOffx = str.mapOffset; map.OpenMap(MapTypes.Internal); map.BW.BaseStream.Position = sOffx; map.BW.Write((UInt16)str.id); map.BR.ReadByte(); map.BW.Write((Byte)map.Strings.Length[sSwap.SelectedID]); map.CloseMap(); } break; default: break; } } } map.CloseMap(); LoadMeta(map.SelectedMeta.TagIndex); sortReferences(-1, false); }
/// <summary> /// is only available for Idents, so we don't need to check /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void FloodfillSwapItem_Click(object sender, EventArgs e) { if (parsedCheckBox.Checked) { MessageBox.Show("Turn off parsing first"); return; } if (references.SelectedIndices.Count == 0) { return; } List<int> idTags = new List<int>(); List<int> idOffs = new List<int>(); Meta.Item item = null; // Find our first ident int selectedIndex = (int)formFuncs.ListItems[references.SelectedIndices[0]].Tag; item = map.SelectedMeta.items[selectedIndex]; Meta.Ident id = (Meta.Ident)item; int iOffx = map.MetaInfo.Offset[map.SelectedMeta.TagIndex] + id.offset; idTags.Add(id.pointstoTagIndex); idOffs.Add(iOffx); IdentSwapper iSwap = new IdentSwapper(); iSwap.LoadStuff(idTags, idOffs, map); if (iSwap.ShowDialog() != DialogResult.OK) { iSwap.Dispose(); return; } string tType = ((identSwapLayout)iSwap.Controls[1]).tagtype.Text; string tName = ((identSwapLayout)iSwap.Controls[1]).tagname.Text; iSwap.Dispose(); map.OpenMap(MapTypes.Internal); // Start at position #1 as we just did #0 for (int x = 1; x < references.SelectedIndices.Count; x++) { selectedIndex = (int)formFuncs.ListItems[references.SelectedIndices[x]].Tag; item = map.SelectedMeta.items[selectedIndex]; map.BW.BaseStream.Position = map.MetaInfo.Offset[map.SelectedMeta.TagIndex] + item.offset; int temp = map.Functions.ForMeta.FindByNameAndTagType(tType, tName); if (temp != -1) { map.BW.Write(map.MetaInfo.Ident[temp]); } else { map.BW.Write(temp); } } map.CloseMap(); LoadMeta(map.SelectedMeta.TagIndex); sortReferences(-1, false); }