From ab16bdc6941effa790d6d3c904046b95f8dac8ef Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 31 May 2020 15:30:24 -0700 Subject: [PATCH] Add Clear All --- NHSE.Core/Structures/Misc/RecipeBook.cs | 2 +- .../Player/RecipeListEditor.Designer.cs | 14 ++++++++++++++ .../Subforms/Player/RecipeListEditor.cs | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/NHSE.Core/Structures/Misc/RecipeBook.cs b/NHSE.Core/Structures/Misc/RecipeBook.cs index aa1606f..4b8cf2a 100644 --- a/NHSE.Core/Structures/Misc/RecipeBook.cs +++ b/NHSE.Core/Structures/Misc/RecipeBook.cs @@ -47,7 +47,7 @@ public void ClearAll() { SetIsKnown(i, false); SetIsNew(i, false); - SetIsFavorite(i, false); + SetIsMade(i, false); SetIsFavorite(i, false); } } diff --git a/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs b/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs index 6d8de85..e2309b2 100644 --- a/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs +++ b/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs @@ -38,6 +38,7 @@ private void InitializeComponent() this.CHK_Made = new System.Windows.Forms.CheckBox(); this.CHK_Favorite = new System.Windows.Forms.CheckBox(); this.CHK_New = new System.Windows.Forms.CheckBox(); + this.B_ClearAll = new System.Windows.Forms.Button(); this.SuspendLayout(); // // B_Cancel @@ -150,11 +151,23 @@ private void InitializeComponent() this.CHK_New.Text = "New"; this.CHK_New.UseVisualStyleBackColor = true; // + // B_ClearAll + // + this.B_ClearAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_ClearAll.Location = new System.Drawing.Point(100, 347); + this.B_ClearAll.Name = "B_ClearAll"; + this.B_ClearAll.Size = new System.Drawing.Size(82, 23); + this.B_ClearAll.TabIndex = 18; + this.B_ClearAll.Text = "Clear All"; + this.B_ClearAll.UseVisualStyleBackColor = true; + this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click); + // // RecipeListEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(404, 381); + this.Controls.Add(this.B_ClearAll); this.Controls.Add(this.CHK_New); this.Controls.Add(this.CHK_Favorite); this.Controls.Add(this.CHK_Made); @@ -187,5 +200,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_Made; private System.Windows.Forms.CheckBox CHK_Favorite; private System.Windows.Forms.CheckBox CHK_New; + private System.Windows.Forms.Button B_ClearAll; } } \ No newline at end of file diff --git a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs index dd0916b..12e3ec5 100644 --- a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs +++ b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs @@ -39,12 +39,14 @@ private List FillCheckBoxes() private void FillListBox(ushort max, IReadOnlyDictionary recipes, string[] strings, RecipeBook book) { + Loading = true; for (ushort i = 0; i <= max; i++) { var name = GetItemName(i, recipes, strings); var text = GetEntryText(book, i, name); LB_Recipes.Items.Add(text); } + Loading = false; } private static List GetJumpList(ushort max, IReadOnlyDictionary recipes, string[] strings, List gotoSource) @@ -85,6 +87,22 @@ private void B_All_Click(object sender, EventArgs e) book.GiveAll(recipes); LB_Recipes.Items.Clear(); FillListBox(max, recipes, strings, book); + LoadIndex(index); + LB_Recipes.SelectedIndex = index; + } + + private void B_ClearAll_Click(object sender, EventArgs e) + { + var index = LB_Recipes.SelectedIndex; + var book = Book; + var recipes = RecipeList.Recipes; + var strings = GameInfo.Strings.itemlist; + const ushort max = RecipeBook.RecipeCount; + + book.ClearAll(); + LB_Recipes.Items.Clear(); + FillListBox(max, recipes, strings, book); + LoadIndex(index); LB_Recipes.SelectedIndex = index; }