Pathoschild / StardewMods

Mods for Stardew Valley using SMAPI.
MIT License
710 stars 379 forks source link

[Lookup Anything] Fix counts for collapsible fields when some results are grouped #1031

Closed b3nk3lly closed 1 month ago

b3nk3lly commented 2 months ago

When deciding whether to collapse a field, instead of using the total number of items / recipes in the field, we now use the length of the field's Value. This way, grouped results (e.g., "647 unrevealed items", which might appear when using progression mode) are counted as one result. This closes https://github.com/Pathoschild/StardewMods/issues/1025.

A special case is when displaying recipes grouped by type. In this case, the length of Value is always 0, so we instead need to manually sum up all the displayed recipes in each group.

Example: Collapsed fields, progression mode on (and collapse limit of 1, for the sake of demonstration):

image

Expanded fields, progression mode on:

image

Collapsed fields, progression mode off:

image
Pathoschild commented 1 month ago

Thanks for the help! Merged into develop for the upcoming Lookup Anything 1.46.0.

I made one change: after deciding whether to collapse the field per your PR, the label still shows the actual total number of items. For example, "click to show 15 results" → "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and 5 unrevealed gift tastes". That better reflects the intended meaning of the message (e.g. "this field covers 15 gift tastes" rather than "this field covers 11 comma-delimited values"), but we could change it in later versions if that causes confusion.