From ec8bcf261ef7c8b90114b704a9dccc26a6d88c53 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 28 Jul 2021 23:09:04 -0700 Subject: [PATCH] Add remove item like in editor Closes #492 --- .../Structures/Map/Layers/FieldItemLayer.cs | 4 +- .../Subforms/Map/FieldItemEditor.Designer.cs | 62 +++++++++++-------- NHSE.WinForms/Subforms/Map/FieldItemEditor.cs | 3 + 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/NHSE.Core/Structures/Map/Layers/FieldItemLayer.cs b/NHSE.Core/Structures/Map/Layers/FieldItemLayer.cs index fde0bba..a9fbe25 100644 --- a/NHSE.Core/Structures/Map/Layers/FieldItemLayer.cs +++ b/NHSE.Core/Structures/Map/Layers/FieldItemLayer.cs @@ -97,8 +97,8 @@ public int ModifyAll(int xmin, int ymin, int width, int height, Func public int RemoveAll(int xmin, int ymin, int width, int height) => RemoveAll(xmin, ymin, width, height, _ => true); public int RemoveAllShells(int xmin, int ymin, int width, int height) => RemoveAll(xmin, ymin, width, height, z => GameLists.Shells.Contains(z.DisplayItemId)); public int RemoveAllBranches(int xmin, int ymin, int width, int height) => RemoveAll(xmin, ymin, width, height, z => z.DisplayItemId == 2500); - public int RemoveAllPlacedItems(int xmin, int ymin, int width, int height) => RemoveAll(xmin, ymin, width, - height, z => !z.IsNone && !FieldItemList.Items.ContainsKey(z.DisplayItemId)); + public int RemoveAllPlacedItems(int xmin, int ymin, int width, int height) => RemoveAll(xmin, ymin, width, height, z => !z.IsNone && !FieldItemList.Items.ContainsKey(z.DisplayItemId)); + public int RemoveAllLike(int xmin, int ymin, int width, int height, Item item) => RemoveAll(xmin, ymin, width, height, z => !z.IsNone && item.DisplayItemId == z.DisplayItemId); public int WaterAllFlowers(int xmin, int ymin, int width, int height, bool all) { diff --git a/NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs b/NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs index e9f3271..a58de52 100644 --- a/NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs +++ b/NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs @@ -112,6 +112,7 @@ private void InitializeComponent() this.B_Help = new System.Windows.Forms.Button(); this.LB_Items = new System.Windows.Forms.ListBox(); this.Tab_Terrain = new System.Windows.Forms.TabPage(); + this.B_TerrainBrush = new System.Windows.Forms.Button(); this.L_TerrainTileLabelTransparency = new System.Windows.Forms.Label(); this.TR_Terrain = new System.Windows.Forms.TrackBar(); this.TR_BuildingTransparency = new System.Windows.Forms.TrackBar(); @@ -150,7 +151,7 @@ private void InitializeComponent() this.CHK_RedirectExtensionLoad = new System.Windows.Forms.CheckBox(); this.CHK_MoveOnDrag = new System.Windows.Forms.CheckBox(); this.CHK_FieldItemSnap = new System.Windows.Forms.CheckBox(); - this.B_TerrainBrush = new System.Windows.Forms.Button(); + this.B_RemoveEditor = new System.Windows.Forms.ToolStripMenuItem(); this.CM_Click.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit(); this.CM_Picture.SuspendLayout(); @@ -474,6 +475,7 @@ private void InitializeComponent() this.B_RemoveFlowers, this.B_RemoveBushes, this.B_FillHoles, + this.B_RemoveEditor, this.B_RemoveAll, this.toolStripSeparator1, this.B_WaterFlowers, @@ -481,115 +483,115 @@ private void InitializeComponent() this.Menu_Batch}); this.CM_Remove.Name = "CM_Picture"; this.CM_Remove.ShowImageMargin = false; - this.CM_Remove.Size = new System.Drawing.Size(124, 340); + this.CM_Remove.Size = new System.Drawing.Size(156, 384); // // B_RemoveAllWeeds // this.B_RemoveAllWeeds.Name = "B_RemoveAllWeeds"; - this.B_RemoveAllWeeds.Size = new System.Drawing.Size(123, 22); + this.B_RemoveAllWeeds.Size = new System.Drawing.Size(155, 22); this.B_RemoveAllWeeds.Text = "Weeds"; this.B_RemoveAllWeeds.Click += new System.EventHandler(this.B_RemoveAllWeeds_Click); // // B_RemoveAllTrees // this.B_RemoveAllTrees.Name = "B_RemoveAllTrees"; - this.B_RemoveAllTrees.Size = new System.Drawing.Size(123, 22); + this.B_RemoveAllTrees.Size = new System.Drawing.Size(155, 22); this.B_RemoveAllTrees.Text = "Trees"; this.B_RemoveAllTrees.Click += new System.EventHandler(this.B_RemoveAllTrees_Click); // // B_RemovePlants // this.B_RemovePlants.Name = "B_RemovePlants"; - this.B_RemovePlants.Size = new System.Drawing.Size(123, 22); + this.B_RemovePlants.Size = new System.Drawing.Size(155, 22); this.B_RemovePlants.Text = "Plants"; this.B_RemovePlants.Click += new System.EventHandler(this.B_RemovePlants_Click); // // B_RemoveObjects // this.B_RemoveObjects.Name = "B_RemoveObjects"; - this.B_RemoveObjects.Size = new System.Drawing.Size(123, 22); + this.B_RemoveObjects.Size = new System.Drawing.Size(155, 22); this.B_RemoveObjects.Text = "Objects"; this.B_RemoveObjects.Click += new System.EventHandler(this.B_RemoveObjects_Click); // // B_RemovePlacedItems // this.B_RemovePlacedItems.Name = "B_RemovePlacedItems"; - this.B_RemovePlacedItems.Size = new System.Drawing.Size(123, 22); + this.B_RemovePlacedItems.Size = new System.Drawing.Size(155, 22); this.B_RemovePlacedItems.Text = "Placed Items"; this.B_RemovePlacedItems.Click += new System.EventHandler(this.B_RemovePlacedItems_Click); // // B_RemoveFences // this.B_RemoveFences.Name = "B_RemoveFences"; - this.B_RemoveFences.Size = new System.Drawing.Size(123, 22); + this.B_RemoveFences.Size = new System.Drawing.Size(155, 22); this.B_RemoveFences.Text = "Fences"; this.B_RemoveFences.Click += new System.EventHandler(this.B_RemoveFences_Click); // // B_RemoveBranches // this.B_RemoveBranches.Name = "B_RemoveBranches"; - this.B_RemoveBranches.Size = new System.Drawing.Size(123, 22); + this.B_RemoveBranches.Size = new System.Drawing.Size(155, 22); this.B_RemoveBranches.Text = "Branches"; this.B_RemoveBranches.Click += new System.EventHandler(this.B_RemoveBranches_Click); // // B_RemoveShells // this.B_RemoveShells.Name = "B_RemoveShells"; - this.B_RemoveShells.Size = new System.Drawing.Size(123, 22); + this.B_RemoveShells.Size = new System.Drawing.Size(155, 22); this.B_RemoveShells.Text = "Shells"; this.B_RemoveShells.Click += new System.EventHandler(this.B_RemoveShells_Click); // // B_RemoveFlowers // this.B_RemoveFlowers.Name = "B_RemoveFlowers"; - this.B_RemoveFlowers.Size = new System.Drawing.Size(123, 22); + this.B_RemoveFlowers.Size = new System.Drawing.Size(155, 22); this.B_RemoveFlowers.Text = "Flowers"; this.B_RemoveFlowers.Click += new System.EventHandler(this.B_RemoveFlowers_Click); // // B_RemoveBushes // this.B_RemoveBushes.Name = "B_RemoveBushes"; - this.B_RemoveBushes.Size = new System.Drawing.Size(123, 22); + this.B_RemoveBushes.Size = new System.Drawing.Size(155, 22); this.B_RemoveBushes.Text = "Bushes"; this.B_RemoveBushes.Click += new System.EventHandler(this.B_RemoveBushes_Click); // // B_FillHoles // this.B_FillHoles.Name = "B_FillHoles"; - this.B_FillHoles.Size = new System.Drawing.Size(123, 22); + this.B_FillHoles.Size = new System.Drawing.Size(155, 22); this.B_FillHoles.Text = "Holes"; this.B_FillHoles.Click += new System.EventHandler(this.B_FillHoles_Click); // // B_RemoveAll // this.B_RemoveAll.Name = "B_RemoveAll"; - this.B_RemoveAll.Size = new System.Drawing.Size(123, 22); + this.B_RemoveAll.Size = new System.Drawing.Size(155, 22); this.B_RemoveAll.Text = "All"; this.B_RemoveAll.Click += new System.EventHandler(this.B_RemoveAll_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(152, 6); // // B_WaterFlowers // this.B_WaterFlowers.Name = "B_WaterFlowers"; - this.B_WaterFlowers.Size = new System.Drawing.Size(123, 22); + this.B_WaterFlowers.Size = new System.Drawing.Size(155, 22); this.B_WaterFlowers.Text = "Water Flowers"; this.B_WaterFlowers.Click += new System.EventHandler(this.B_WaterFlowers_Click); // // Menu_Spawn // this.Menu_Spawn.Name = "Menu_Spawn"; - this.Menu_Spawn.Size = new System.Drawing.Size(123, 22); + this.Menu_Spawn.Size = new System.Drawing.Size(155, 22); this.Menu_Spawn.Text = "Spawn..."; this.Menu_Spawn.Click += new System.EventHandler(this.Menu_Spawn_Click); // // Menu_Batch // this.Menu_Batch.Name = "Menu_Batch"; - this.Menu_Batch.Size = new System.Drawing.Size(123, 22); + this.Menu_Batch.Size = new System.Drawing.Size(155, 22); this.Menu_Batch.Text = "Batch Editor"; this.Menu_Batch.Click += new System.EventHandler(this.Menu_Bulk_Click); // @@ -1029,6 +1031,16 @@ private void InitializeComponent() this.Tab_Terrain.Text = "Terrain"; this.Tab_Terrain.UseVisualStyleBackColor = true; // + // B_TerrainBrush + // + this.B_TerrainBrush.Location = new System.Drawing.Point(155, 413); + this.B_TerrainBrush.Name = "B_TerrainBrush"; + this.B_TerrainBrush.Size = new System.Drawing.Size(83, 40); + this.B_TerrainBrush.TabIndex = 48; + this.B_TerrainBrush.Text = "Terrain brushes"; + this.B_TerrainBrush.UseVisualStyleBackColor = true; + this.B_TerrainBrush.Click += new System.EventHandler(this.B_TerrainBrush_Click); + // // L_TerrainTileLabelTransparency // this.L_TerrainTileLabelTransparency.AutoSize = true; @@ -1396,15 +1408,12 @@ private void InitializeComponent() this.CHK_FieldItemSnap.Text = "Snap Field Items to Grid on Set"; this.CHK_FieldItemSnap.UseVisualStyleBackColor = true; // - // B_TerrainBrush + // B_RemoveEditor // - this.B_TerrainBrush.Location = new System.Drawing.Point(155, 413); - this.B_TerrainBrush.Name = "B_TerrainBrush"; - this.B_TerrainBrush.Size = new System.Drawing.Size(83, 40); - this.B_TerrainBrush.TabIndex = 48; - this.B_TerrainBrush.Text = "Terrain brushes"; - this.B_TerrainBrush.UseVisualStyleBackColor = true; - this.B_TerrainBrush.Click += new System.EventHandler(this.B_TerrainBrush_Click); + this.B_RemoveEditor.Name = "B_RemoveEditor"; + this.B_RemoveEditor.Size = new System.Drawing.Size(155, 22); + this.B_RemoveEditor.Text = "Editor Item"; + this.B_RemoveEditor.Click += new System.EventHandler(this.B_RemoveEditor_Click); // // FieldItemEditor // @@ -1603,5 +1612,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem Menu_Batch; private System.Windows.Forms.ToolStripMenuItem B_RemoveBushes; private System.Windows.Forms.Button B_TerrainBrush; + private System.Windows.Forms.ToolStripMenuItem B_RemoveEditor; } } \ No newline at end of file diff --git a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs index 507c618..e1d745e 100644 --- a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs +++ b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs @@ -820,6 +820,9 @@ private void Modify(ToolStripItem sender, Func action) WinFormsUtil.Alert(string.Format(MessageStrings.MsgFieldItemModifyCount, count)); } + private void B_RemoveEditor_Click(object sender, EventArgs e) => Remove(B_RemoveEditor, (min, max, x, y) + => Map.CurrentLayer.RemoveAllLike(min, max, x, y, ItemEdit.SetItem(new Item()))); + private void B_RemoveAllWeeds_Click(object sender, EventArgs e) => Remove(B_RemoveAllWeeds, Map.CurrentLayer.RemoveAllWeeds); private void B_RemoveAllTrees_Click(object sender, EventArgs e) => Remove(B_RemoveAllTrees, Map.CurrentLayer.RemoveAllTrees);