dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

Animal search gets cleared on Select Trainer

Open KABoissonneault opened this issue 3 years ago • 3 comments

Steps:

  1. search for an animal type you got (ex: mountain goat)
  2. put the cursor on an animal
  3. press t to Select trainer

Issue: If your cursor was on the second mountain goat, the trainer gets assigned to the second animal in your complete creature list, instead of the second mountain goat you had selected. It seems to be because the search gets cleared once you press t This is not the case for other features of that screen, such as Slaughter, Geld, Toggle pet availability, etc

Before pressing t: image

After pressing t: image

Notice the cursor is now on a Stray water buffalo, not the mountain goat.

This seems to be because the "trainer selection" popup has its own dfhack search, and by default a screen can only have one search at a time

KABoissonneault avatar Nov 29 '22 16:11 KABoissonneault

I can reproduce this.

The way we allow multiple search instances per screen is by passing an "ID" parameter to the generic_search_base template. And we are doing exactly that for all searches on the pets screen, with different ID parameters:

  • https://github.com/DFHack/dfhack/blob/23e467deaf1dffaf5c82d13707c4af54a764f460/plugins/search.cpp#L892
  • https://github.com/DFHack/dfhack/blob/23e467deaf1dffaf5c82d13707c4af54a764f460/plugins/search.cpp#L942
  • https://github.com/DFHack/dfhack/blob/23e467deaf1dffaf5c82d13707c4af54a764f460/plugins/search.cpp#L1010

I'm not really sure what's going wrong here. You'll see the same issue with searching in the "Overall training" tab clearing the search in the "Creatures" tab, and I'm pretty sure that used to not be an issue.

lethosor avatar Nov 29 '22 17:11 lethosor

maybe an unexpected interaction with 4e08357aaf3dc222f7d5dac4bf20e88f9b5d2d5d? that change could cause the reset of one search to reset other open searches, maybe?

ab9rf avatar Nov 30 '22 14:11 ab9rf

I don't think that would explain it, because the same screen (viewscreen_petst) instance manages both tabs in question here (which is why the ID for the hooks is needed). There should be no way for breakdown_level to be nonzero and still have this screen displayed, since it's on the top of the stack.

lethosor avatar Dec 24 '22 04:12 lethosor