diff --git a/NHSE.Core/Structures/Item/ItemKind.cs b/NHSE.Core/Structures/Item/ItemKind.cs index 7ee0b03..33d792a 100644 --- a/NHSE.Core/Structures/Item/ItemKind.cs +++ b/NHSE.Core/Structures/Item/ItemKind.cs @@ -1,4 +1,5 @@ -using static NHSE.Core.ItemKind; +using System.Collections.Generic; +using static NHSE.Core.ItemKind; namespace NHSE.Core { @@ -157,6 +158,44 @@ public enum ItemKind : byte public static class ItemKindExtensions { + private static readonly HashSet Clothing = new HashSet + { + Bottoms_Long, + Bottoms_Middle, + Bottoms_Short, + Kind_Accessory, + Kind_Bag, + Kind_Cap, + Kind_Helmet, + Kind_NpcOutfit, + Kind_PlayerDemoOutfit, + Kind_Socks, + Onepiece_Dress, + Onepiece_Long, + Onepiece_Middle, + Onepiece_Short, + Shoes_Boots, + Shoes_Pumps, + Top_Long, + Top_Middle, + Top_Short, + }; + + private static readonly HashSet Furniture = new HashSet + { + Ftr_1x1_Chair, + Ftr_1x1_Floor, + Ftr_2x1_Bed, + Ftr_2x1_Floor, + Ftr_2x2_Floor, + Kind_DummyFtr, + Kind_EventObjFtr, + Kind_Ftr, + }; + public static bool IsFlower(this ItemKind k) => (Kind_Flower <= k && k <= Kind_FlowerBud) || (UnitIcon_FlwAnemone <= k && k <= UnitIcon_FlwTulip); + public static bool IsClothing(this ItemKind k) => Clothing.Contains(k); + public static bool IsCrafting(this ItemKind k) => k == Kind_Ore || k == Kind_CraftMaterial || k == Kind_CraftPhoneCase || k == Kind_CraftRemake; + public static bool IsFurniture(this ItemKind k) => Furniture.Contains(k); } } diff --git a/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs b/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs index fcb6d75..86af256 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs +++ b/NHSE.WinForms/Controls/ItemGridEditor.Designer.cs @@ -42,9 +42,17 @@ private void InitializeComponent() this.FLP_Controls = new System.Windows.Forms.FlowLayoutPanel(); this.PAN_Navigation = new System.Windows.Forms.Panel(); this.HoverTip = new System.Windows.Forms.ToolTip(this.components); + this.CM_Remove = new System.Windows.Forms.ContextMenuStrip(this.components); + this.B_ClearAll = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ClearClothing = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ClearCrafting = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ClearBugs = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ClearFish = new System.Windows.Forms.ToolStripMenuItem(); + this.B_ClearFurniture = new System.Windows.Forms.ToolStripMenuItem(); this.CM_Hand.SuspendLayout(); this.FLP_Controls.SuspendLayout(); this.PAN_Navigation.SuspendLayout(); + this.CM_Remove.SuspendLayout(); this.SuspendLayout(); // // ItemGrid @@ -142,6 +150,7 @@ private void InitializeComponent() // this.B_Clear.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.B_Clear.ContextMenuStrip = this.CM_Remove; this.B_Clear.Location = new System.Drawing.Point(3, 110); this.B_Clear.Name = "B_Clear"; this.B_Clear.Size = new System.Drawing.Size(64, 29); @@ -177,6 +186,61 @@ private void InitializeComponent() // this.HoverTip.AutomaticDelay = 100; // + // CM_Remove + // + this.CM_Remove.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.B_ClearAll, + this.B_ClearClothing, + this.B_ClearCrafting, + this.B_ClearBugs, + this.B_ClearFish, + this.B_ClearFurniture}); + this.CM_Remove.Name = "CM_Picture"; + this.CM_Remove.ShowImageMargin = false; + this.CM_Remove.Size = new System.Drawing.Size(156, 158); + // + // B_ClearAll + // + this.B_ClearAll.Name = "B_ClearAll"; + this.B_ClearAll.Size = new System.Drawing.Size(155, 22); + this.B_ClearAll.Text = "All"; + this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click); + // + // B_ClearClothing + // + this.B_ClearClothing.Name = "B_ClearClothing"; + this.B_ClearClothing.Size = new System.Drawing.Size(155, 22); + this.B_ClearClothing.Text = "Clothing"; + this.B_ClearClothing.Click += new System.EventHandler(this.B_ClearClothing_Click); + // + // B_ClearCrafting + // + this.B_ClearCrafting.Name = "B_ClearCrafting"; + this.B_ClearCrafting.Size = new System.Drawing.Size(155, 22); + this.B_ClearCrafting.Text = "Crafting Materials"; + this.B_ClearCrafting.Click += new System.EventHandler(this.B_ClearCrafting_Click); + // + // B_ClearBugs + // + this.B_ClearBugs.Name = "B_ClearBugs"; + this.B_ClearBugs.Size = new System.Drawing.Size(155, 22); + this.B_ClearBugs.Text = "Bugs"; + this.B_ClearBugs.Click += new System.EventHandler(this.B_ClearBugs_Click); + // + // B_ClearFish + // + this.B_ClearFish.Name = "B_ClearFish"; + this.B_ClearFish.Size = new System.Drawing.Size(155, 22); + this.B_ClearFish.Text = "Fish"; + this.B_ClearFish.Click += new System.EventHandler(this.B_ClearFish_Click); + // + // B_ClearFurniture + // + this.B_ClearFurniture.Name = "B_ClearFurniture"; + this.B_ClearFurniture.Size = new System.Drawing.Size(155, 22); + this.B_ClearFurniture.Text = "Furniture"; + this.B_ClearFurniture.Click += new System.EventHandler(this.B_ClearFurniture_Click); + // // ItemGridEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -187,6 +251,7 @@ private void InitializeComponent() this.CM_Hand.ResumeLayout(false); this.FLP_Controls.ResumeLayout(false); this.PAN_Navigation.ResumeLayout(false); + this.CM_Remove.ResumeLayout(false); this.ResumeLayout(false); } @@ -206,5 +271,12 @@ private void InitializeComponent() private System.Windows.Forms.FlowLayoutPanel FLP_Controls; private System.Windows.Forms.Panel PAN_Navigation; private System.Windows.Forms.ToolTip HoverTip; + private System.Windows.Forms.ContextMenuStrip CM_Remove; + private System.Windows.Forms.ToolStripMenuItem B_ClearAll; + private System.Windows.Forms.ToolStripMenuItem B_ClearClothing; + private System.Windows.Forms.ToolStripMenuItem B_ClearCrafting; + private System.Windows.Forms.ToolStripMenuItem B_ClearBugs; + private System.Windows.Forms.ToolStripMenuItem B_ClearFish; + private System.Windows.Forms.ToolStripMenuItem B_ClearFurniture; } } diff --git a/NHSE.WinForms/Controls/ItemGridEditor.cs b/NHSE.WinForms/Controls/ItemGridEditor.cs index 04e1514..db1a24e 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.cs +++ b/NHSE.WinForms/Controls/ItemGridEditor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Windows.Forms; using NHSE.Core; using NHSE.Sprites; @@ -220,17 +221,36 @@ public void LoadItems() ItemUpdated(); } - private void B_Clear_Click(object sender, EventArgs e) + private static void ShowContextMenuBelow(ToolStripDropDown c, Control n) => c.Show(n.PointToScreen(new Point(0, n.Height))); + private void B_Clear_Click(object sender, EventArgs e) => ShowContextMenuBelow(CM_Remove, B_Clear); + + + private void ClearItemIf(Func criteria) { - for (int i = 0; i < SlotPictureBoxes.Count; i++) + bool all = ModifierKeys == Keys.Shift; + int start = 0, end = Items.Count - 1; + if (!all) { - var item = GetItem(i); - item.Delete(); + start = ItemsPerPage * Page; + end = start + ItemsPerPage; + } + for (int i = start; i < end; i++) + { + var item = Items[i]; + if (criteria(item)) + item.Delete(); } LoadItems(); System.Media.SystemSounds.Asterisk.Play(); } + private void B_ClearAll_Click(object sender, EventArgs e) => ClearItemIf(_ => true); + private void B_ClearClothing_Click(object sender, EventArgs e) => ClearItemIf(z => ItemInfo.GetItemKind(z).IsClothing()); + private void B_ClearCrafting_Click(object sender, EventArgs e) => ClearItemIf(z => ItemInfo.GetItemKind(z).IsCrafting()); + private void B_ClearFurniture_Click(object sender, EventArgs e) => ClearItemIf(z => ItemInfo.GetItemKind(z).IsFurniture()); + private void B_ClearBugs_Click(object sender, EventArgs e) => ClearItemIf(z => GameLists.Bugs.Contains(z.ItemId)); + private void B_ClearFish_Click(object sender, EventArgs e) => ClearItemIf(z => GameLists.Fish.Contains(z.ItemId)); + private class GridSize : IGridItem { public int Width { get; set; } = 64; diff --git a/NHSE.WinForms/Controls/ItemGridEditor.resx b/NHSE.WinForms/Controls/ItemGridEditor.resx index f3153c9..9e40c71 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.resx +++ b/NHSE.WinForms/Controls/ItemGridEditor.resx @@ -120,6 +120,9 @@ 17, 17 + + 585, 17 + 122, 17