From ff571cf2ccf087834df53f441fd14626348ad5e8 Mon Sep 17 00:00:00 2001 From: Dale McCoy <21223975+DaleStan@users.noreply.github.com> Date: Wed, 30 Oct 2024 23:17:16 -0400 Subject: [PATCH] fix: Hide non-functional fixed counts on disabled recipe rows. --- .../ProductionTable/ProductionTableView.cs | 46 ++++++++++--------- changelog.txt | 2 + 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Yafc/Workspace/ProductionTable/ProductionTableView.cs b/Yafc/Workspace/ProductionTable/ProductionTableView.cs index f5e8d76a..6346455a 100644 --- a/Yafc/Workspace/ProductionTable/ProductionTableView.cs +++ b/Yafc/Workspace/ProductionTable/ProductionTableView.cs @@ -296,7 +296,7 @@ public override void BuildElement(ImGui gui, RecipeRow recipe) { Click click; using (var group = gui.EnterGroup(default, RectAllocator.Stretch, spacing: 0f)) { group.SetWidth(3f); - if (recipe.fixedBuildings > 0 && !recipe.fixedFuel && recipe.fixedIngredient == null && recipe.fixedProduct == null) { + if (recipe is { fixedBuildings: > 0, fixedFuel: false, fixedIngredient: null, fixedProduct: null, hierarchyEnabled: true }) { DisplayAmount amount = recipe.fixedBuildings; GoodsWithAmountEvent evt = gui.BuildFactorioObjectWithEditableAmount(recipe.entity, amount, ButtonDisplayStyle.ProductionTableUnscaled, setKeyboardFocus: recipe.ShouldFocusFixedCountThisTime()); @@ -400,7 +400,7 @@ private static void ShowEntityDropdown(ImGui imgui, RecipeRow recipe) => imgui.S gui.AllocateSpacing(0.5f); - if (recipe.fixedBuildings > 0f && (recipe.fixedFuel || recipe.fixedIngredient != null || recipe.fixedProduct != null)) { + if (recipe.fixedBuildings > 0f && (recipe.fixedFuel || recipe.fixedIngredient != null || recipe.fixedProduct != null || !recipe.hierarchyEnabled)) { ButtonEvent evt = gui.BuildButton("Clear fixed recipe multiplier"); if (willResetFixed) { _ = evt.WithTooltip(gui, "Shortcut: right-click"); @@ -410,28 +410,30 @@ private static void ShowEntityDropdown(ImGui imgui, RecipeRow recipe) => imgui.S } } - string fixedBuildingsTip = "Tell YAFC how many buildings it must use when solving this page.\n" + - "Use this to ask questions like 'What does it take to handle the output of ten miners?'"; + if (recipe.hierarchyEnabled) { + string fixedBuildingsTip = "Tell YAFC how many buildings it must use when solving this page.\n" + + "Use this to ask questions like 'What does it take to handle the output of ten miners?'"; - using (gui.EnterRowWithHelpIcon(fixedBuildingsTip)) { - gui.allocator = RectAllocator.RemainingRow; - if (recipe.fixedBuildings > 0f && !recipe.fixedFuel && recipe.fixedIngredient == null && recipe.fixedProduct == null) { - ButtonEvent evt = gui.BuildButton("Clear fixed building count"); + using (gui.EnterRowWithHelpIcon(fixedBuildingsTip)) { + gui.allocator = RectAllocator.RemainingRow; + if (recipe.fixedBuildings > 0f && !recipe.fixedFuel && recipe.fixedIngredient == null && recipe.fixedProduct == null) { + ButtonEvent evt = gui.BuildButton("Clear fixed building count"); - if (willResetFixed) { - _ = evt.WithTooltip(gui, "Shortcut: right-click"); - } + if (willResetFixed) { + _ = evt.WithTooltip(gui, "Shortcut: right-click"); + } - if (evt && gui.CloseDropdown()) { - recipe.RecordUndo().fixedBuildings = 0f; + if (evt && gui.CloseDropdown()) { + recipe.RecordUndo().fixedBuildings = 0f; + } + } + else if (gui.BuildButton("Set fixed building count") && gui.CloseDropdown()) { + recipe.RecordUndo().fixedBuildings = recipe.buildingCount <= 0f ? 1f : recipe.buildingCount; + recipe.fixedFuel = false; + recipe.fixedIngredient = null; + recipe.fixedProduct = null; + recipe.FocusFixedCountOnNextDraw(); } - } - else if (gui.BuildButton("Set fixed building count") && gui.CloseDropdown()) { - recipe.RecordUndo().fixedBuildings = recipe.buildingCount <= 0f ? 1f : recipe.buildingCount; - recipe.fixedFuel = false; - recipe.fixedIngredient = null; - recipe.fixedProduct = null; - recipe.FocusFixedCountOnNextDraw(); } } @@ -987,7 +989,7 @@ void dropDownContent(ImGui gui) { #endregion #region Fixed production/consumption - if (goods != null && recipe != null) { + if (goods != null && recipe != null && recipe.hierarchyEnabled) { if (recipe.fixedBuildings == 0 || (type == ProductDropdownType.Fuel && !recipe.fixedFuel) || (type == ProductDropdownType.Ingredient && recipe.fixedIngredient != goods) @@ -1162,7 +1164,7 @@ private void BuildGoodsIcon(ImGui gui, Goods? goods, ProductionLink? link, float }; } - if (recipe != null && recipe.fixedBuildings > 0 + if (recipe != null && recipe.fixedBuildings > 0 && recipe.hierarchyEnabled && ((dropdownType == ProductDropdownType.Fuel && recipe.fixedFuel) || (dropdownType == ProductDropdownType.Ingredient && recipe.fixedIngredient == goods) || (dropdownType == ProductDropdownType.Product && recipe.fixedProduct == goods))) { diff --git a/changelog.txt b/changelog.txt index 2a9101f9..1a5e1c70 100644 --- a/changelog.txt +++ b/changelog.txt @@ -19,6 +19,8 @@ Version: Date: Features: - Add pseudo-items representing a recipe's total sushi-inputs and sushi-outputs. + Bugfixes: + - Fixed counts are hidden on disabled recipes, since editing them won't work properly. ---------------------------------------------------------------------------------------------------------------------- Version: 2.1.0 Date: October 29th 2024