You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: add checkbox if recipe is on the page (#439)
This adds a (yellow) checkbox to recipes already added to the sheet, but
not part of the current sub-table (those are already marked with a
greencheckbx).

Also works for the see full list:

A list of nice-to-have things:
* [x] A changelog entry.
* The link from the PR to the issue that it fixes. -> This Pr describes
the function.
* A description of what testing was done. -> Tried various recipe
combinations, including recipes part of parent nodes, sibling nodes,
also green checkbox should always override yellow.
@@ -461,9 +464,10 @@ public record DisplayAmount(float Value, UnitOfMeasure Unit = UnitOfMeasure.None
461
464
/// Not used (treated as <see langword="false"/>) when selecting with a 'None' item.</param>
462
465
/// <param name="Checkmark">If not <see langword="null"/>, this will be called to determine if a checkmark should be drawn on the item.
463
466
/// Not used when selecting with a 'None' item or when <paramref name="Multiple"/> is <see langword="false"/>.</param>
467
+
/// <param name="YellowMark">If Checkmark is not set, draw a less distinct checkmark instead.</param>
464
468
/// <param name="ExtraText">If not <see langword="null"/>, this will be called to get extra text to be displayed right-justified after the item's name.</param>
/// Opens a <see cref="SelectMultiObjectPanel"/> to allow the user to select one or more <see cref="FactorioObject"/>s.
@@ -20,8 +24,8 @@ public class SelectMultiObjectPanel : SelectObjectPanel<IEnumerable<FactorioObje
20
24
/// <param name="header">The string that describes to the user why they're selecting these items.</param>
21
25
/// <param name="selectItem">An action to be called for each selected item when the panel is closed.</param>
22
26
/// <param name="ordering">An optional ordering specifying how to sort the displayed items. If <see langword="null"/>, defaults to <see cref="DataUtils.DefaultOrdering"/>.</param>
SelectMultiObjectPanelpanel=new(o =>checkMark?.Invoke((T)o)??false);// This casting is messy, but pushing T all the way around the call stack and type tree was messier.
SelectMultiObjectPanelpanel=new(o =>checkMark?.Invoke((T)o)??false, o =>yellowMark?.Invoke((T)o)??false);// This casting is messy, but pushing T all the way around the call stack and type tree was messier.
25
29
panel.Select(list,header,selectItem!,ordering,(objs,mappedAction)=>{// null-forgiving: selectItem will not be called with null, because allowNone is false.
26
30
foreach(varobjinobjs!){// null-forgiving: mapResult will not be called with null, because allowNone is false.
/// <param name="selectItem">An action to be called for each selected item when the panel is closed.</param>
38
42
/// <param name="ordering">An optional ordering specifying how to sort the displayed items. If <see langword="null"/>, defaults to <see cref="DataUtils.DefaultOrdering"/>.</param>
SelectMultiObjectPanelpanel=new(o =>checkMark?.Invoke((T)o)??false);// This casting is messy, but pushing T all the way around the call stack and type tree was messier.
46
+
SelectMultiObjectPanelpanel=new(o =>checkMark?.Invoke((T)o)??false, o =>yellowMark?.Invoke((T)o)??false);// This casting is messy, but pushing T all the way around the call stack and type tree was messier.
43
47
panel.SelectWithQuality(list,header,selectItem!,ordering,(objs,mappedAction)=>{// null-forgiving: selectItem will not be called with null, because allowNone is false.
44
48
foreach(varobjinobjs!){// null-forgiving: mapResult will not be called with null, because allowNone is false.
r =>table.AddRecipe(new(r,Quality.Normal),DefaultVariantOrdering),checkMark: r =>table.recipes.Any(rr =>rr.recipe.target==r));
270
+
r =>table.AddRecipe(new(r,Quality.Normal),DefaultVariantOrdering),checkMark: r =>table.recipes.Any(rr =>rr.recipe.target==r),yellowMark: r =>table.GetAllRecipes().Any(rr =>rr.recipe.target==r));
SelectMultiObjectPanel.SelectWithQuality(Database.recipes.explorable.AsEnumerable<RecipeOrTechnology>(),"Select raw recipe",
273
-
r =>table.AddRecipe(r,DefaultVariantOrdering),Quality.Normal,checkMark: r =>table.recipes.Any(rr =>rr.recipe.target==r));
275
+
r =>table.AddRecipe(r,DefaultVariantOrdering),Quality.Normal,checkMark: r =>table.recipes.Any(rr =>rr.recipe.target==r),yellowMark: r =>prodTable?.GetAllRecipes().Any(rr =>rr.recipe.target==r)??false);
if(!allRecipes.Contains(qualityRecipe)||(awaitMessageBox.Show("Recipe already exists",$"Add a second copy of {rec.locName}?","Add a copy","Cancel")).choice){
910
+
if(!curLevelRecipes.Contains(qualityRecipe)||(awaitMessageBox.Show("Recipe already exists",$"Add a second copy of {rec.locName}?","Add a copy","Cancel")).choice){
0 commit comments