diff --git a/Yafc/Windows/DependencyExplorer.cs b/Yafc/Windows/DependencyExplorer.cs index d59a7029..dc6b75c2 100644 --- a/Yafc/Windows/DependencyExplorer.cs +++ b/Yafc/Windows/DependencyExplorer.cs @@ -130,15 +130,18 @@ public override void Build(ImGui gui) { gui.BuildText("Manually marked as accessible."); if (gui.BuildLink("Clear mark")) { SetFlag(ProjectPerItemFlags.MarkedAccessible, false); + NeverEnoughItemsPanel.Refresh(); } } else { if (gui.BuildLink("Mark as inaccessible")) { SetFlag(ProjectPerItemFlags.MarkedInaccessible, true); + NeverEnoughItemsPanel.Refresh(); } if (gui.BuildLink("Mark as accessible without milestones")) { SetFlag(ProjectPerItemFlags.MarkedAccessible, true); + NeverEnoughItemsPanel.Refresh(); } } } @@ -147,12 +150,14 @@ public override void Build(ImGui gui) { gui.BuildText("Status: Marked as inaccessible"); if (gui.BuildLink("Clear mark")) { SetFlag(ProjectPerItemFlags.MarkedInaccessible, false); + NeverEnoughItemsPanel.Refresh(); } } else { gui.BuildText("Status: Not accessible. Wrong?"); if (gui.BuildLink("Manually mark as accessible")) { SetFlag(ProjectPerItemFlags.MarkedAccessible, true); + NeverEnoughItemsPanel.Refresh(); } } } diff --git a/Yafc/Windows/MainScreen.cs b/Yafc/Windows/MainScreen.cs index 41cb513a..cf607e06 100644 --- a/Yafc/Windows/MainScreen.cs +++ b/Yafc/Windows/MainScreen.cs @@ -66,7 +66,7 @@ private void SetProject(Project project) { DataUtils.SetupForProject(project); this.project = project; if (project.justCreated) { - _ = ShowPseudoScreen(MilestonesPanel.Instance); + _ = ShowPseudoScreen(new MilestonesPanel()); } if (project.pages.Count == 0) { @@ -401,7 +401,7 @@ private void SettingsDropdown(ImGui gui) { BuildSubHeader(gui, "Tools"); if (gui.BuildContextMenuButton("Milestones") && gui.CloseDropdown()) { - _ = ShowPseudoScreen(MilestonesPanel.Instance); + _ = ShowPseudoScreen(new MilestonesPanel()); } if (gui.BuildContextMenuButton("Preferences") && gui.CloseDropdown()) { diff --git a/Yafc/Windows/MilestonesPanel.cs b/Yafc/Windows/MilestonesPanel.cs index 913fb2b0..f46cdab6 100644 --- a/Yafc/Windows/MilestonesPanel.cs +++ b/Yafc/Windows/MilestonesPanel.cs @@ -4,8 +4,6 @@ namespace Yafc { public class MilestonesWidget : VirtualScrollList { - public static readonly MilestonesWidget Instance = new MilestonesWidget(); - public MilestonesWidget() : base(30f, new Vector2(3f, 3f), MilestoneDrawer) => data = Project.current.settings.milestones; private static void MilestoneDrawer(ImGui gui, FactorioObject element, int index) { @@ -31,18 +29,17 @@ private static void MilestoneDrawer(ImGui gui, FactorioObject element, int index gui.DrawIcon(gui.lastRect, Icon.Check, SchemeColor.Error); } } - } public class MilestonesPanel : PseudoScreen { - public static readonly MilestonesPanel Instance = new MilestonesPanel(); + private readonly MilestonesWidget milestonesWidget = new(); public override void Build(ImGui gui) { gui.spacing = 1f; BuildHeader(gui, "Milestones"); gui.BuildText("Please select objects that you already have access to:"); gui.AllocateSpacing(2f); - MilestonesWidget.Instance.Build(gui); + milestonesWidget.Build(gui); gui.AllocateSpacing(2f); gui.BuildText("For your convenience, YAFC will show objects you DON'T have access to based on this selection", wrap: true); gui.BuildText("These are called 'Milestones'. By default all science packs are added as milestones, but this does not have to be this way! " + diff --git a/Yafc/Windows/NeverEnoughItemsPanel.cs b/Yafc/Windows/NeverEnoughItemsPanel.cs index d33063a6..4083b91f 100644 --- a/Yafc/Windows/NeverEnoughItemsPanel.cs +++ b/Yafc/Windows/NeverEnoughItemsPanel.cs @@ -60,11 +60,21 @@ public RecipeEntry(Recipe recipe, bool isProduction, Goods currentItem, bool atC private readonly List productions = []; private readonly List usages = []; - public NeverEnoughItemsPanel() : base(76f) { + private NeverEnoughItemsPanel() : base(76f) { productionList = new ScrollArea(40f, BuildItemProduction, new Padding(0.5f)); usageList = new ScrollArea(40f, BuildItemUsages, new Padding(0.5f)); } + /// + /// Call to make sure that any recent setting changes (e.g. object accessibility) are reflected in the NEIE display. + /// It is only necessary to call this from screens that could be displayed on top of the NEIE display. + /// + public static void Refresh() { + var item = Instance.current; + Instance.current = null; + Instance.SetItem(item); + } + private void SetItem(Goods current) { if (current == this.current) { return; @@ -368,6 +378,10 @@ public override void Build(ImGui gui) { } public static void Show(Goods goods) { + // This call handles any updates required by milestone changes. The milestones window can't + // easily handle that since the setting updates happen after the milestones screens are closed. + Refresh(); + if (Instance.opened) { Instance.changing = goods; return; diff --git a/Yafc/Workspace/AutoPlannerView.cs b/Yafc/Workspace/AutoPlannerView.cs index b0bad0b3..8ca5e16a 100644 --- a/Yafc/Workspace/AutoPlannerView.cs +++ b/Yafc/Workspace/AutoPlannerView.cs @@ -55,7 +55,7 @@ void Page1(ImGui gui, ref bool valid) { } gui.AllocateSpacing(2f); gui.BuildText("Review active milestones, as they will restrict recipes that are considered:", wrap: true); - MilestonesWidget.Instance.Build(gui); + new MilestonesWidget().Build(gui); gui.AllocateSpacing(2f); valid = !string.IsNullOrEmpty(pageName) && goal.Count > 0; } diff --git a/changelog.txt b/changelog.txt index 967e0b0e..f6e55649 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,8 @@ Date: soon - Removed default pollution cost from calculation. Added a setting to customize pollution cost. - Add fuel consumption recipe for products - Fix list displays below search boxes. If necessary, they now scroll up until items are visible. + - Fix the milestones display and the milestones editor displaying different milestones. + - Fix the NEI Explorer not always reflecting milestone unlocks and changed accessibility flags. ---------------------------------------------------------------------------------------------------------------------- Version: 0.6.4 Date: April 16th 2024