yafc icon indicating copy to clipboard operation
yafc copied to clipboard

Delete unused recipe rows in the production table

Open DaleStan opened this issue 2 years ago • 1 comments

This is a follow-up to #168. After adding all the recipes in existence, I want to delete the ones the solver decided not to use. It can be merged without #168, if desired.

This adds two buttons to the dropdown on the Recipe column: image

The first button deletes all recipe rows that have zero assigned buildings, recursively through all nested tables. The second button also unpacks any nested tables that only have a header recipe.

Given this nested table, image the first button converts it to this image and the second button converts it to this image

Omit 1c0d336 to omit the second button. I can create a new PR if that's desired.

Required additional work

  • The undo system cannot reliably undo the actions performed by either of these new buttons. I haven't been able to figure out what I'm doing wrong, so I've marked this as a draft.

Potential future concerns

  • The handling of the header recipes for the nested tables may conflict with plans for #158. Any conflicts there are probably show-stoppers for this PR.
  • The combination of this PR and either #118 and #144 will cause these new buttons to delete recipe rows that have a builtBuildings, but that the solver didn't use. I'm guessing those rows should be preserved, and can update this PR to do that once one or both of those are merged.

DaleStan avatar Jul 06 '22 04:07 DaleStan

Here's a demonstration of me mis-handling the undo system. Load DeleteUnusedTest.yafc.zip with this mod list, and use either of the two new buttons. Then try to undo the changes. After undo, the page will unexpectedly consume five of the six "Purified *" items, among other things. It will also unexpectedly produce gold ore, titanium sheet coil, uranium ore, nickel carbonyl, and tungsten ore.

If the modlist doesn't work, you should also be able to sync with this save: DeleteUnusedTest.zip

DaleStan avatar Jul 06 '22 04:07 DaleStan