From 6a00cb22b48d657bb03d8db33d65494ec4ab0933 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 8 May 2020 13:27:15 -0700 Subject: [PATCH] Add extension tile property manipulation --- NHSE.WinForms/Controls/ItemEditor.Designer.cs | 181 +++++++++++++++--- NHSE.WinForms/Controls/ItemEditor.cs | 58 +++++- 2 files changed, 207 insertions(+), 32 deletions(-) diff --git a/NHSE.WinForms/Controls/ItemEditor.Designer.cs b/NHSE.WinForms/Controls/ItemEditor.Designer.cs index 7b87bad..f146475 100644 --- a/NHSE.WinForms/Controls/ItemEditor.Designer.cs +++ b/NHSE.WinForms/Controls/ItemEditor.Designer.cs @@ -75,6 +75,14 @@ private void InitializeComponent() this.CHK_WV6 = new System.Windows.Forms.CheckBox(); this.CHK_WV9 = new System.Windows.Forms.CheckBox(); this.CHK_Gold = new System.Windows.Forms.CheckBox(); + this.FLP_Extension = new System.Windows.Forms.FlowLayoutPanel(); + this.NUD_ExtensionX = new System.Windows.Forms.NumericUpDown(); + this.L_ExtensionX = new System.Windows.Forms.Label(); + this.NUD_ExtensionY = new System.Windows.Forms.NumericUpDown(); + this.L_ExtensionY = new System.Windows.Forms.Label(); + this.CHK_IsExtension = new System.Windows.Forms.CheckBox(); + this.FLP_Item = new System.Windows.Forms.FlowLayoutPanel(); + this.FLP_Flower = new System.Windows.Forms.FlowLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Uses)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Flag0)).BeginInit(); @@ -88,6 +96,11 @@ private void InitializeComponent() this.FLP_Genetics.SuspendLayout(); this.FLP_FlowerFlags.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_WaterDays)).BeginInit(); + this.FLP_Extension.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ExtensionX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ExtensionY)).BeginInit(); + this.FLP_Item.SuspendLayout(); + this.FLP_Flower.SuspendLayout(); this.SuspendLayout(); // // CB_ItemID @@ -231,7 +244,7 @@ private void InitializeComponent() this.CB_Recipe.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.CB_Recipe.DropDownWidth = 322; this.CB_Recipe.FormattingEnabled = true; - this.CB_Recipe.Location = new System.Drawing.Point(3, 24); + this.CB_Recipe.Location = new System.Drawing.Point(3, 1); this.CB_Recipe.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1); this.CB_Recipe.Name = "CB_Recipe"; this.CB_Recipe.Size = new System.Drawing.Size(141, 21); @@ -242,21 +255,16 @@ private void InitializeComponent() // // FLP_Controls // + this.FLP_Controls.AutoSize = true; this.FLP_Controls.Controls.Add(this.CB_ItemID); - this.FLP_Controls.Controls.Add(this.CB_Recipe); - this.FLP_Controls.Controls.Add(this.CB_Fossil); - this.FLP_Controls.Controls.Add(this.FLP_Count); - this.FLP_Controls.Controls.Add(this.L_RemakeBody); - this.FLP_Controls.Controls.Add(this.L_RemakeFabric); - this.FLP_Controls.Controls.Add(this.FLP_Uses); - this.FLP_Controls.Controls.Add(this.FLP_Flag0); - this.FLP_Controls.Controls.Add(this.FLP_Flag1); - this.FLP_Controls.Controls.Add(this.FLP_Genetics); - this.FLP_Controls.Controls.Add(this.FLP_FlowerFlags); + this.FLP_Controls.Controls.Add(this.CHK_IsExtension); + this.FLP_Controls.Controls.Add(this.FLP_Extension); + this.FLP_Controls.Controls.Add(this.FLP_Item); this.FLP_Controls.Dock = System.Windows.Forms.DockStyle.Fill; this.FLP_Controls.Location = new System.Drawing.Point(0, 0); + this.FLP_Controls.Margin = new System.Windows.Forms.Padding(0); this.FLP_Controls.Name = "FLP_Controls"; - this.FLP_Controls.Size = new System.Drawing.Size(211, 408); + this.FLP_Controls.Size = new System.Drawing.Size(211, 517); this.FLP_Controls.TabIndex = 15; // // CB_Fossil @@ -265,7 +273,7 @@ private void InitializeComponent() this.CB_Fossil.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.CB_Fossil.DropDownWidth = 322; this.CB_Fossil.FormattingEnabled = true; - this.CB_Fossil.Location = new System.Drawing.Point(3, 47); + this.CB_Fossil.Location = new System.Drawing.Point(3, 24); this.CB_Fossil.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1); this.CB_Fossil.Name = "CB_Fossil"; this.CB_Fossil.Size = new System.Drawing.Size(141, 21); @@ -278,9 +286,9 @@ private void InitializeComponent() // this.FLP_Count.Controls.Add(this.NUD_Count); this.FLP_Count.Controls.Add(this.L_Count); - this.FLP_Controls.SetFlowBreak(this.FLP_Count, true); + this.FLP_Item.SetFlowBreak(this.FLP_Count, true); this.FLP_Count.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_Count.Location = new System.Drawing.Point(0, 69); + this.FLP_Count.Location = new System.Drawing.Point(0, 46); this.FLP_Count.Margin = new System.Windows.Forms.Padding(0); this.FLP_Count.Name = "FLP_Count"; this.FLP_Count.Size = new System.Drawing.Size(147, 26); @@ -289,8 +297,8 @@ private void InitializeComponent() // L_RemakeBody // this.L_RemakeBody.AutoSize = true; - this.FLP_Controls.SetFlowBreak(this.L_RemakeBody, true); - this.L_RemakeBody.Location = new System.Drawing.Point(3, 101); + this.FLP_Item.SetFlowBreak(this.L_RemakeBody, true); + this.L_RemakeBody.Location = new System.Drawing.Point(3, 78); this.L_RemakeBody.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6); this.L_RemakeBody.Name = "L_RemakeBody"; this.L_RemakeBody.Size = new System.Drawing.Size(75, 13); @@ -301,8 +309,8 @@ private void InitializeComponent() // L_RemakeFabric // this.L_RemakeFabric.AutoSize = true; - this.FLP_Controls.SetFlowBreak(this.L_RemakeFabric, true); - this.L_RemakeFabric.Location = new System.Drawing.Point(3, 126); + this.FLP_Item.SetFlowBreak(this.L_RemakeFabric, true); + this.L_RemakeFabric.Location = new System.Drawing.Point(3, 103); this.L_RemakeFabric.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6); this.L_RemakeFabric.Name = "L_RemakeFabric"; this.L_RemakeFabric.Size = new System.Drawing.Size(80, 13); @@ -315,7 +323,7 @@ private void InitializeComponent() this.FLP_Uses.Controls.Add(this.NUD_Uses); this.FLP_Uses.Controls.Add(this.L_Uses); this.FLP_Uses.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_Uses.Location = new System.Drawing.Point(0, 145); + this.FLP_Uses.Location = new System.Drawing.Point(0, 122); this.FLP_Uses.Margin = new System.Windows.Forms.Padding(0); this.FLP_Uses.Name = "FLP_Uses"; this.FLP_Uses.Size = new System.Drawing.Size(147, 26); @@ -326,7 +334,7 @@ private void InitializeComponent() this.FLP_Flag0.Controls.Add(this.NUD_Flag0); this.FLP_Flag0.Controls.Add(this.L_Flag0); this.FLP_Flag0.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_Flag0.Location = new System.Drawing.Point(0, 171); + this.FLP_Flag0.Location = new System.Drawing.Point(0, 148); this.FLP_Flag0.Margin = new System.Windows.Forms.Padding(0); this.FLP_Flag0.Name = "FLP_Flag0"; this.FLP_Flag0.Size = new System.Drawing.Size(147, 26); @@ -337,7 +345,7 @@ private void InitializeComponent() this.FLP_Flag1.Controls.Add(this.NUD_Flag1); this.FLP_Flag1.Controls.Add(this.L_Flag1); this.FLP_Flag1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_Flag1.Location = new System.Drawing.Point(0, 197); + this.FLP_Flag1.Location = new System.Drawing.Point(0, 174); this.FLP_Flag1.Margin = new System.Windows.Forms.Padding(0); this.FLP_Flag1.Name = "FLP_Flag1"; this.FLP_Flag1.Size = new System.Drawing.Size(147, 26); @@ -353,8 +361,9 @@ private void InitializeComponent() this.FLP_Genetics.Controls.Add(this.CHK_W1); this.FLP_Genetics.Controls.Add(this.CHK_S2); this.FLP_Genetics.Controls.Add(this.CHK_S1); + this.FLP_Flower.SetFlowBreak(this.FLP_Genetics, true); this.FLP_Genetics.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_Genetics.Location = new System.Drawing.Point(0, 223); + this.FLP_Genetics.Location = new System.Drawing.Point(0, 0); this.FLP_Genetics.Margin = new System.Windows.Forms.Padding(0); this.FLP_Genetics.Name = "FLP_Genetics"; this.FLP_Genetics.Size = new System.Drawing.Size(106, 65); @@ -481,7 +490,7 @@ private void InitializeComponent() this.FLP_FlowerFlags.Controls.Add(this.CHK_WV9); this.FLP_FlowerFlags.Controls.Add(this.CHK_Gold); this.FLP_FlowerFlags.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.FLP_FlowerFlags.Location = new System.Drawing.Point(0, 288); + this.FLP_FlowerFlags.Location = new System.Drawing.Point(0, 65); this.FLP_FlowerFlags.Margin = new System.Windows.Forms.Padding(0); this.FLP_FlowerFlags.Name = "FLP_FlowerFlags"; this.FLP_FlowerFlags.Size = new System.Drawing.Size(147, 105); @@ -672,13 +681,119 @@ private void InitializeComponent() this.CHK_Gold.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.CHK_Gold.UseVisualStyleBackColor = true; // + // FLP_Extension + // + this.FLP_Extension.AutoSize = true; + this.FLP_Extension.Controls.Add(this.L_ExtensionX); + this.FLP_Extension.Controls.Add(this.NUD_ExtensionX); + this.FLP_Extension.Controls.Add(this.L_ExtensionY); + this.FLP_Extension.Controls.Add(this.NUD_ExtensionY); + this.FLP_Extension.Location = new System.Drawing.Point(0, 63); + this.FLP_Extension.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Extension.Name = "FLP_Extension"; + this.FLP_Extension.Size = new System.Drawing.Size(88, 40); + this.FLP_Extension.TabIndex = 24; + this.FLP_Extension.Visible = false; + // + // NUD_ExtensionX + // + this.FLP_Extension.SetFlowBreak(this.NUD_ExtensionX, true); + this.NUD_ExtensionX.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.NUD_ExtensionX.Location = new System.Drawing.Point(53, 0); + this.NUD_ExtensionX.Margin = new System.Windows.Forms.Padding(0); + this.NUD_ExtensionX.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_ExtensionX.Name = "NUD_ExtensionX"; + this.NUD_ExtensionX.Size = new System.Drawing.Size(35, 20); + this.NUD_ExtensionX.TabIndex = 7; + // + // L_ExtensionX + // + this.L_ExtensionX.AutoSize = true; + this.L_ExtensionX.Location = new System.Drawing.Point(33, 3); + this.L_ExtensionX.Margin = new System.Windows.Forms.Padding(33, 3, 3, 3); + this.L_ExtensionX.Name = "L_ExtensionX"; + this.L_ExtensionX.Size = new System.Drawing.Size(17, 13); + this.L_ExtensionX.TabIndex = 8; + this.L_ExtensionX.Text = "X:"; + // + // NUD_ExtensionY + // + this.NUD_ExtensionY.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.NUD_ExtensionY.Location = new System.Drawing.Point(53, 20); + this.NUD_ExtensionY.Margin = new System.Windows.Forms.Padding(0); + this.NUD_ExtensionY.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_ExtensionY.Name = "NUD_ExtensionY"; + this.NUD_ExtensionY.Size = new System.Drawing.Size(35, 20); + this.NUD_ExtensionY.TabIndex = 25; + // + // L_ExtensionY + // + this.L_ExtensionY.AutoSize = true; + this.L_ExtensionY.Location = new System.Drawing.Point(33, 23); + this.L_ExtensionY.Margin = new System.Windows.Forms.Padding(33, 3, 3, 3); + this.L_ExtensionY.Name = "L_ExtensionY"; + this.L_ExtensionY.Size = new System.Drawing.Size(17, 13); + this.L_ExtensionY.TabIndex = 26; + this.L_ExtensionY.Text = "Y:"; + // + // CHK_IsExtension + // + this.CHK_IsExtension.AutoSize = true; + this.FLP_Controls.SetFlowBreak(this.CHK_IsExtension, true); + this.CHK_IsExtension.Location = new System.Drawing.Point(17, 26); + this.CHK_IsExtension.Margin = new System.Windows.Forms.Padding(17, 3, 3, 3); + this.CHK_IsExtension.Name = "CHK_IsExtension"; + this.CHK_IsExtension.Size = new System.Drawing.Size(72, 17); + this.CHK_IsExtension.TabIndex = 27; + this.CHK_IsExtension.Text = "Extension"; + this.CHK_IsExtension.UseVisualStyleBackColor = true; + this.CHK_IsExtension.CheckedChanged += new System.EventHandler(this.CHK_IsExtension_CheckedChanged); + // + // FLP_Item + // + this.FLP_Item.AutoSize = true; + this.FLP_Item.Controls.Add(this.CB_Recipe); + this.FLP_Item.Controls.Add(this.CB_Fossil); + this.FLP_Item.Controls.Add(this.FLP_Count); + this.FLP_Item.Controls.Add(this.L_RemakeBody); + this.FLP_Item.Controls.Add(this.L_RemakeFabric); + this.FLP_Item.Controls.Add(this.FLP_Uses); + this.FLP_Item.Controls.Add(this.FLP_Flag0); + this.FLP_Item.Controls.Add(this.FLP_Flag1); + this.FLP_Item.Controls.Add(this.FLP_Flower); + this.FLP_Item.Location = new System.Drawing.Point(0, 103); + this.FLP_Item.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Item.Name = "FLP_Item"; + this.FLP_Item.Size = new System.Drawing.Size(167, 370); + this.FLP_Item.TabIndex = 25; + // + // FLP_Flower + // + this.FLP_Flower.AutoSize = true; + this.FLP_Flower.Controls.Add(this.FLP_Genetics); + this.FLP_Flower.Controls.Add(this.FLP_FlowerFlags); + this.FLP_Flower.Location = new System.Drawing.Point(0, 200); + this.FLP_Flower.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Flower.Name = "FLP_Flower"; + this.FLP_Flower.Size = new System.Drawing.Size(147, 170); + this.FLP_Flower.TabIndex = 24; + this.FLP_Flower.Visible = false; + // // ItemEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.FLP_Controls); this.Name = "ItemEditor"; - this.Size = new System.Drawing.Size(211, 408); + this.Size = new System.Drawing.Size(211, 517); ((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Uses)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Flag0)).EndInit(); @@ -698,7 +813,15 @@ private void InitializeComponent() this.FLP_FlowerFlags.ResumeLayout(false); this.FLP_FlowerFlags.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_WaterDays)).EndInit(); + this.FLP_Extension.ResumeLayout(false); + this.FLP_Extension.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ExtensionX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ExtensionY)).EndInit(); + this.FLP_Item.ResumeLayout(false); + this.FLP_Item.PerformLayout(); + this.FLP_Flower.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -749,5 +872,13 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox CB_Fossil; private System.Windows.Forms.Label L_RemakeBody; private System.Windows.Forms.Label L_RemakeFabric; + private System.Windows.Forms.FlowLayoutPanel FLP_Extension; + private System.Windows.Forms.CheckBox CHK_IsExtension; + private System.Windows.Forms.Label L_ExtensionX; + private System.Windows.Forms.NumericUpDown NUD_ExtensionX; + private System.Windows.Forms.Label L_ExtensionY; + private System.Windows.Forms.NumericUpDown NUD_ExtensionY; + private System.Windows.Forms.FlowLayoutPanel FLP_Item; + private System.Windows.Forms.FlowLayoutPanel FLP_Flower; } } diff --git a/NHSE.WinForms/Controls/ItemEditor.cs b/NHSE.WinForms/Controls/ItemEditor.cs index d7aff00..410c3c4 100644 --- a/NHSE.WinForms/Controls/ItemEditor.cs +++ b/NHSE.WinForms/Controls/ItemEditor.cs @@ -12,6 +12,7 @@ public partial class ItemEditor : UserControl private readonly CheckBox[] Watered; private bool Loading = true; + private bool CanExtend; public ItemEditor() { @@ -27,8 +28,10 @@ public ItemEditor() }; } - public void Initialize(List items) + public void Initialize(IList items, bool canExtend = false) { + CHK_IsExtension.Visible = CanExtend = canExtend; + CB_ItemID.DisplayMember = nameof(ComboItem.Text); CB_ItemID.ValueMember = nameof(ComboItem.Value); CB_ItemID.DataSource = items; @@ -47,8 +50,13 @@ public void Initialize(List items) public Item LoadItem(Item item) { Loading = true; - CB_ItemID.SelectedValue = (int)item.ItemId; - var kind = ItemInfo.GetItemKind(item.ItemId); + var id = item.ItemId; + if (CanExtend && id == Item.EXTENSION) + return LoadExtensionItem(item); + + CHK_IsExtension.Checked = false; + CB_ItemID.SelectedValue = (int)id; + var kind = ItemInfo.GetItemKind(id); if (kind.IsFlower()) { @@ -73,8 +81,20 @@ public Item LoadItem(Item item) return item; } + private Item LoadExtensionItem(Item item) + { + CB_ItemID.SelectedValue = (int) item.ExtensionItemId; + CHK_IsExtension.Checked = true; + NUD_ExtensionX.Value = item.ExtensionX; + NUD_ExtensionY.Value = item.ExtensionY; + return item; + } + public Item SetItem(Item item) { + if (CHK_IsExtension.Checked) + return SetExtensionItem(item); + var id = (ushort)WinFormsUtil.GetIndex(CB_ItemID); var kind = ItemInfo.GetItemKind(id); @@ -98,6 +118,16 @@ public Item SetItem(Item item) return item; } + private Item SetExtensionItem(Item item) + { + var id = (ushort)WinFormsUtil.GetIndex(CB_ItemID); + item.ItemId = Item.EXTENSION; + item.ExtensionItemId = id; + item.ExtensionX = (byte) NUD_ExtensionX.Value; + item.ExtensionY = (byte) NUD_ExtensionY.Value; + return item; + } + private void CB_ItemID_SelectedValueChanged(object sender, EventArgs e) { var itemID = (ushort)WinFormsUtil.GetIndex(CB_ItemID); @@ -147,7 +177,7 @@ private void ToggleEditorVisibility(ItemKind k) { CB_Recipe.Visible = false; FLP_Uses.Visible = FLP_Count.Visible = FLP_Flag0.Visible = FLP_Flag1.Visible = false; - FLP_FlowerFlags.Visible = FLP_Genetics.Visible = true; + FLP_Flower.Visible = true; return; } @@ -158,7 +188,7 @@ private void ToggleEditorVisibility(ItemKind k) CB_Recipe.Visible = false; FLP_Uses.Visible = FLP_Count.Visible = FLP_Flag0.Visible = FLP_Flag1.Visible = false; - FLP_FlowerFlags.Visible = FLP_Genetics.Visible = false; + FLP_Flower.Visible = false; break; case ItemKind.Kind_DIYRecipe: @@ -167,14 +197,14 @@ private void ToggleEditorVisibility(ItemKind k) CB_Fossil.Visible = false; FLP_Uses.Visible = FLP_Count.Visible = FLP_Flag0.Visible = FLP_Flag1.Visible = false; - FLP_FlowerFlags.Visible = FLP_Genetics.Visible = false; + FLP_Flower.Visible = false; break; default: CB_Fossil.Visible = false; CB_Recipe.Visible = false; FLP_Uses.Visible = FLP_Count.Visible = FLP_Flag0.Visible = FLP_Flag1.Visible = true; - FLP_FlowerFlags.Visible = FLP_Genetics.Visible = false; + FLP_Flower.Visible = false; break; } } @@ -222,5 +252,19 @@ private void L_WaterDays_Click(object sender, EventArgs e) } private void CB_KeyDown(object sender, KeyEventArgs e) => WinFormsUtil.RemoveDropCB(sender, e); + + private void CHK_IsExtension_CheckedChanged(object sender, EventArgs e) + { + if (CHK_IsExtension.Checked) + { + FLP_Item.Visible = false; + FLP_Extension.Visible = true; + } + else + { + FLP_Item.Visible = true; + FLP_Extension.Visible = false; + } + } } }