From 491bae480efa93c8751003039a8d56639cf0f2c1 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 31 May 2020 18:12:46 -0700 Subject: [PATCH] Add CraftAll Closes #279 --- NHSE.Core/Structures/Misc/RecipeBook.cs | 14 ++++++++++- NHSE.WinForms/Resources/text/lang_de.txt | 3 ++- NHSE.WinForms/Resources/text/lang_en.txt | 3 ++- NHSE.WinForms/Resources/text/lang_es.txt | 3 ++- NHSE.WinForms/Resources/text/lang_fr.txt | 3 ++- NHSE.WinForms/Resources/text/lang_it.txt | 1 + NHSE.WinForms/Resources/text/lang_jp.txt | 3 ++- NHSE.WinForms/Resources/text/lang_ko.txt | 3 ++- NHSE.WinForms/Resources/text/lang_zhs.txt | 3 ++- NHSE.WinForms/Resources/text/lang_zht.txt | 3 ++- .../Player/RecipeListEditor.Designer.cs | 20 +++++++++++++--- .../Subforms/Player/RecipeListEditor.cs | 23 +++++-------------- 12 files changed, 53 insertions(+), 29 deletions(-) diff --git a/NHSE.Core/Structures/Misc/RecipeBook.cs b/NHSE.Core/Structures/Misc/RecipeBook.cs index 4b8cf2a..4072db3 100644 --- a/NHSE.Core/Structures/Misc/RecipeBook.cs +++ b/NHSE.Core/Structures/Misc/RecipeBook.cs @@ -51,5 +51,17 @@ public void ClearAll() SetIsFavorite(i, false); } } + + public void CraftAll() + { + for (int i = 0; i < RecipeCount; i++) + { + bool alreadyHave = GetIsKnown(i); + if (!alreadyHave) + continue; + SetIsMade(i); + SetIsNew(i, false); + } + } } -} \ No newline at end of file +} diff --git a/NHSE.WinForms/Resources/text/lang_de.txt b/NHSE.WinForms/Resources/text/lang_de.txt index 79c4b3a..6e379a6 100644 --- a/NHSE.WinForms/Resources/text/lang_de.txt +++ b/NHSE.WinForms/Resources/text/lang_de.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_en.txt b/NHSE.WinForms/Resources/text/lang_en.txt index 79c4b3a..6e379a6 100644 --- a/NHSE.WinForms/Resources/text/lang_en.txt +++ b/NHSE.WinForms/Resources/text/lang_en.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_es.txt b/NHSE.WinForms/Resources/text/lang_es.txt index 8cb3c1a..597189d 100644 --- a/NHSE.WinForms/Resources/text/lang_es.txt +++ b/NHSE.WinForms/Resources/text/lang_es.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_fr.txt b/NHSE.WinForms/Resources/text/lang_fr.txt index 79c4b3a..6e379a6 100644 --- a/NHSE.WinForms/Resources/text/lang_fr.txt +++ b/NHSE.WinForms/Resources/text/lang_fr.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_it.txt b/NHSE.WinForms/Resources/text/lang_it.txt index fac8e8c..c5be91f 100644 --- a/NHSE.WinForms/Resources/text/lang_it.txt +++ b/NHSE.WinForms/Resources/text/lang_it.txt @@ -370,6 +370,7 @@ ReactionEditor.B_Save=Salva RecipeListEditor.B_All=Impara Tutto RecipeListEditor.B_Cancel=Indietro RecipeListEditor.B_ClearAll=Elimina Tutto +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Salva RecipeListEditor.CHK_Favorite=Favorito RecipeListEditor.CHK_Known=Conosciuto diff --git a/NHSE.WinForms/Resources/text/lang_jp.txt b/NHSE.WinForms/Resources/text/lang_jp.txt index 79c4b3a..6e379a6 100644 --- a/NHSE.WinForms/Resources/text/lang_jp.txt +++ b/NHSE.WinForms/Resources/text/lang_jp.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_ko.txt b/NHSE.WinForms/Resources/text/lang_ko.txt index 79c4b3a..6e379a6 100644 --- a/NHSE.WinForms/Resources/text/lang_ko.txt +++ b/NHSE.WinForms/Resources/text/lang_ko.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=Days: ReactionEditor.B_Cancel=Cancel ReactionEditor.B_GiveAll=Give All ReactionEditor.B_Save=Save -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_zhs.txt b/NHSE.WinForms/Resources/text/lang_zhs.txt index 3298764..f88f1ea 100644 --- a/NHSE.WinForms/Resources/text/lang_zhs.txt +++ b/NHSE.WinForms/Resources/text/lang_zhs.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=天数: ReactionEditor.B_Cancel=取消 ReactionEditor.B_GiveAll=获得全部 ReactionEditor.B_Save=保存 -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Resources/text/lang_zht.txt b/NHSE.WinForms/Resources/text/lang_zht.txt index 3bd9e96..60117f1 100644 --- a/NHSE.WinForms/Resources/text/lang_zht.txt +++ b/NHSE.WinForms/Resources/text/lang_zht.txt @@ -367,9 +367,10 @@ PlayerItemEditor.L_WaterDays=天數: ReactionEditor.B_Cancel=取消 ReactionEditor.B_GiveAll=獲得全部 ReactionEditor.B_Save=儲存 -RecipeListEditor.B_All=Give All +RecipeListEditor.B_All=Learn All RecipeListEditor.B_Cancel=Cancel RecipeListEditor.B_ClearAll=Clear All +RecipeListEditor.B_CraftAll=Craft All RecipeListEditor.B_Save=Save RecipeListEditor.CHK_Favorite=Favorite RecipeListEditor.CHK_Known=Known diff --git a/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs b/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs index e2309b2..eaf0a58 100644 --- a/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs +++ b/NHSE.WinForms/Subforms/Player/RecipeListEditor.Designer.cs @@ -39,6 +39,7 @@ private void InitializeComponent() 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.B_CraftAll = new System.Windows.Forms.Button(); this.SuspendLayout(); // // B_Cancel @@ -66,11 +67,11 @@ private void InitializeComponent() // B_All // this.B_All.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.B_All.Location = new System.Drawing.Point(12, 347); + this.B_All.Location = new System.Drawing.Point(290, 200); this.B_All.Name = "B_All"; this.B_All.Size = new System.Drawing.Size(82, 23); this.B_All.TabIndex = 10; - this.B_All.Text = "Give All"; + this.B_All.Text = "Learn All"; this.B_All.UseVisualStyleBackColor = true; this.B_All.Click += new System.EventHandler(this.B_All_Click); // @@ -154,7 +155,7 @@ private void InitializeComponent() // 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.Location = new System.Drawing.Point(290, 275); this.B_ClearAll.Name = "B_ClearAll"; this.B_ClearAll.Size = new System.Drawing.Size(82, 23); this.B_ClearAll.TabIndex = 18; @@ -162,11 +163,23 @@ private void InitializeComponent() this.B_ClearAll.UseVisualStyleBackColor = true; this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click); // + // B_CraftAll + // + this.B_CraftAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_CraftAll.Location = new System.Drawing.Point(290, 229); + this.B_CraftAll.Name = "B_CraftAll"; + this.B_CraftAll.Size = new System.Drawing.Size(82, 23); + this.B_CraftAll.TabIndex = 19; + this.B_CraftAll.Text = "Craft All"; + this.B_CraftAll.UseVisualStyleBackColor = true; + this.B_CraftAll.Click += new System.EventHandler(this.B_CraftAll_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_CraftAll); this.Controls.Add(this.B_ClearAll); this.Controls.Add(this.CHK_New); this.Controls.Add(this.CHK_Favorite); @@ -201,5 +214,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_Favorite; private System.Windows.Forms.CheckBox CHK_New; private System.Windows.Forms.Button B_ClearAll; + private System.Windows.Forms.Button B_CraftAll; } } \ No newline at end of file diff --git a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs index 12e3ec5..00205e4 100644 --- a/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs +++ b/NHSE.WinForms/Subforms/Player/RecipeListEditor.cs @@ -76,7 +76,11 @@ private static object GetEntryText(RecipeBook recipeBook, ushort index, string i return $"0x{index:X3} - {known} {item}"; } - private void B_All_Click(object sender, EventArgs e) + private void B_All_Click(object sender, EventArgs e) => DoAll(() => Book.GiveAll(RecipeList.Recipes)); + private void B_ClearAll_Click(object sender, EventArgs e) => DoAll(Book.ClearAll); + private void B_CraftAll_Click(object sender, EventArgs e) => DoAll(Book.CraftAll); + + private void DoAll(Action action) { var index = LB_Recipes.SelectedIndex; var book = Book; @@ -84,22 +88,7 @@ private void B_All_Click(object sender, EventArgs e) var strings = GameInfo.Strings.itemlist; const ushort max = RecipeBook.RecipeCount; - 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(); + action(); LB_Recipes.Items.Clear(); FillListBox(max, recipes, strings, book); LoadIndex(index);