diff --git a/Yafc/Windows/NeverEnoughItemsPanel.cs b/Yafc/Windows/NeverEnoughItemsPanel.cs index 16d4f24d..cc5db82c 100644 --- a/Yafc/Windows/NeverEnoughItemsPanel.cs +++ b/Yafc/Windows/NeverEnoughItemsPanel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Yafc.Model; using Yafc.UI; @@ -57,8 +58,8 @@ public RecipeEntry(Recipe recipe, bool isProduction, Goods currentItem, bool atC } } - private readonly List productions = []; - private readonly List usages = []; + private RecipeEntry[] productions = []; + private RecipeEntry[] usages = []; private NeverEnoughItemsPanel() : base(76f) { productionList = new ScrollArea(40f, BuildItemProduction, new Padding(0.5f)); @@ -89,20 +90,23 @@ private void SetItem(Goods current) { recent.Add(this.current); } - this.current = current; currentFlow = current.ApproximateFlow(atCurrentMilestones); - productions.Clear(); - foreach (var recipe in current.production) { - productions.Add(new RecipeEntry(recipe, true, current, atCurrentMilestones)); + var refreshedProductions = new RecipeEntry[current.production.Length]; + for (int i = 0; i < current.production.Length; i++) { + refreshedProductions[i] = new RecipeEntry(current.production[i], true, current, atCurrentMilestones); } + Array.Sort(refreshedProductions, this); - productions.Sort(this); - usages.Clear(); - foreach (var usage in current.usages) { - usages.Add(new RecipeEntry(usage, false, current, atCurrentMilestones)); + var refreshedUsages = new RecipeEntry[current.usages.Length]; + for (int i = 0; i < current.usages.Length; i++) { + refreshedUsages[i] = new RecipeEntry(current.usages[i], false, current, atCurrentMilestones); } + Array.Sort(refreshedUsages, this); + + this.current = current; + this.productions = refreshedProductions; + this.usages = refreshedUsages; - usages.Sort(this); Rebuild(); productionList.Rebuild(); usageList.Rebuild(); @@ -268,7 +272,7 @@ private void ChangeShowStatus(EntryStatus status) { usageList.Rebuild(); } - private void DrawEntryList(ImGui gui, List entries, bool production) { + private void DrawEntryList(ImGui gui, ReadOnlySpan entries, bool production) { bool footerDrawn = false; var prevEntryStatus = EntryStatus.Normal; FactorioObject? prevLatestMilestone = null; diff --git a/changelog.txt b/changelog.txt index c4a8d9ba..01c96046 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Version: 0.7.1 Date: soon Fixes: - Display spent fuel items in the production table and link summaries. + - Fix error when switching items in NEIE with middle-click ---------------------------------------------------------------------------------------------------------------------- Version: 0.7.0 Date: May 25th 2024