Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 5

Author Topic: Search plugin (Now with Room List, Military Screen and several more)  (Read 7423 times)

falconne

  • Bay Watcher
    • View Profile

Update: DFHack r3 comes with this plugin built in. There is no need for a separate download

I've been working on a DFHack plugin to add search/filtering functionality to some of the screens with long lists, similar to what exists in the "Move to Depot" and "Manager" screens. This should hopefully make it a bit easier to find specific items in those lists (e.g. the Trade window; to find the items you want to buy).

I've added it to the Stocks, Trading, Unit List, Stockpile, Animals, Military positions assignment, Announcements, Room list, Job list, Burrow assignment, as you can see in the screenshots below. It's fairly simple to use; works the same way as the search option in "Move to Depot" does. You will see the Search option displayed on screen with a hotkey (usually 's'). Pressing it lets you start typing a query and the relevant list will start filtering automatically. Pressing ENTER, ESC or the arrow keys will return you to browsing the now filtered list, which still functions as normal. You can clear the filter by either going back into search mode and backspacing to delete it, or pressing the "shifted" version of the search hotkey while browsing the list (e.g. if the hotkey is 's', then hitting 'shift-s' will clear any filter). Leaving any screen automatically clears the filter.

This is how it looks on the Stocks screen, here filtering the crossbows with "cro". The search option is only enabled when you have "tabbed" to see individual items. The filter will persist as you scroll through categories. Since DFHack knows about item quality and decorations, you can also use the search to filter objects by quality (use '-', '+', '*', '=', '@' to define quality and '<' or '>' to match decorated items).




This is the Trade window. This one has two search options, to filter the merchant's goods and your goods separately. I couldn't use 's' as a hotkey here as it was already in use, so went with 'q' and 'w'. As you can see, when typing in a filter, the active search option is highlighted green.

Note that the Trade Value you see will always be of the active filtered lists. For example, if you search for "cloth b" to find all the cloth bins, mark them all, then do another search for "cages", you'll notice that the "Trade Value" field has gone to zero. That's because the cloth bins are not in this set of search results. However, they are still tracked behind the scenes, so you can mark all the cages you found, then clear the filter and you'll notice the trade value goes up to include the marked cloth bins too... if you scroll through the list you should find everything marked correctly.

If you press 't' to trade with the filter active, instead of doing the trade the filter will be cleared... otherwise the trade itself will not work correctly.




Here's how it looks on the Unit list screen. The search will work on any tab, including the Animals (and filters on animal types too).



Filtering animal types:
Spoiler (click to show/hide)


Anyway, I hope this is useful for some people. Let me know if you notice any issues.
« Last Edit: March 14, 2013, 02:26:13 pm by falconne »
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

Blakmane

  • Bay Watcher
    • View Profile

looks fantastic. Giving it a try this week and will let you know how it goes.
Logged

sayke

  • Bay Watcher
    • View Profile

ummmmm this is amazing...! 5 stars, dude, seriously - well done =)
Logged
i play the incredibly awesome Masterwork DF mod - a wonderful blend of simplicity and new features that actually improves FPS!

falconne

  • Bay Watcher
    • View Profile

Thanks for the comments :)

I've uploaded a new version (0.2) that fixes the issues with tracking marked items in the Trade screen. I also made sure that if you use the sort plugin to re-order the filtered results, the marks vector is preserved correctly.

The actual trade will always only act on items that are actually visible in the list, so sometimes you may want to clear the filter before pressing the 't' key. For example, if you search for "cloth b" to find all the cloth bins, mark them all, then do another search for "cages", you'll notice that the "Trade Value" field has gone to zero. That's because the cloth bins are not in this set of search results and if you press 't' now, they will not be included in a trade. However, they are still tracked behind the scenes, so you can mark all the cages you found, then clear the filter and you'll notice the trade value goes up to include the marked cloth bins too... if you scroll through the list you should find everything marked correctly.
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

ag

  • Bay Watcher
    • View Profile

There is a way actually:

Code: [Select]
IMPLEMENT_VMETHOD_INTERPOSE_PRIO(hook, method, priority)
Other things being equal, hooks are called in order of decreasing priority. The default priority is 0, and it can be negative. In order to give later plugins chance to decide where they want to go, it is better to initially set priority in steps of 100 or similar:

https://github.com/peterix/dfhack/commit/038d62367eea44ba625989b8cd4c1380ba544607#L2R133
Logged

falconne

  • Bay Watcher
    • View Profile

Ah neat thanks, that worked. Now I can reset the filter before the manipulator is called.

Just uploaded a new version with the fix.
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

ag

  • Bay Watcher
    • View Profile

A suggestion from one of dfhack developers on the #dfhack channel: allow searching by the animal type in the animals page of units. I think just adding the result of Units::getProfessionName to the searchable string should do it.
Logged

falconne

  • Bay Watcher
    • View Profile

Good idea. I'd meant to add that but forgot about it.

Just uploaded v0.4 with that in.

I think I'll add the search to the Animals screen in the Z menu at some point... but I'll need to generalise my search a lot more, because that screen uses several modifiable independent vectors.
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

Meph

  • Bay Watcher
    • View Profile
    • Unlocked Achievements

May I add this to the MasterworkMod ? Because I really do like features that increase user friendliness, and this is most certianly one. :)
Logged
::: ☼MASTERWORK☼ Dwarf Fortress - A comprehensive mod pack with 25% higher FPS :::
::: Accelerated DF - The FPS boost of Masterwork with no other changes :::
::: www.unlocked-achievements.com - Follow my bike tours around the world :::
- Donate -

falconne

  • Bay Watcher
    • View Profile

May I add this to the MasterworkMod ? Because I really do like features that increase user friendliness, and this is most certianly one. :)

Sure :) glad you like it. The code's all there on my fork, though I should probably add some comments...
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

Meph

  • Bay Watcher
    • View Profile
    • Unlocked Achievements
Re: New plugin to add "Search" functionality to Stock, Trade and Unit screens
« Reply #10 on: October 22, 2012, 04:29:45 am »

Well, I do have my own fork of dfhack already for the mod, so I guess I would just need one dll from yours ?
Logged
::: ☼MASTERWORK☼ Dwarf Fortress - A comprehensive mod pack with 25% higher FPS :::
::: Accelerated DF - The FPS boost of Masterwork with no other changes :::
::: www.unlocked-achievements.com - Follow my bike tours around the world :::
- Donate -

falconne

  • Bay Watcher
    • View Profile
Re: New plugin to add "Search" functionality to Stock, Trade and Unit screens
« Reply #11 on: October 22, 2012, 04:39:22 am »

I meant you could just pull the commits from my fork into yours (after adding my fork as a remote), since that's all I've done there (aside from a bugfix to autobutcher I copied off ag).

Or you could just copy https://github.com/Falconne/dfhack/blob/master/plugins/search.cpp into your fork along with the addition to the plugin cmake list: https://github.com/Falconne/dfhack/commit/fd60db44ab415c0e59266380133c64ef3230b660#plugins/CMakeLists.txt

Or if you just want to include the compiled dll as is then you can just get it off the download page.
« Last Edit: October 22, 2012, 05:24:49 am by falconne »
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

Replica

  • Bay Watcher
  • Temp. leave of absence
    • View Profile
Re: New plugin to add "Search" functionality to Stock, Trade and Unit screens
« Reply #12 on: October 22, 2012, 06:05:43 am »

This is perfect, well done.
Logged
Quote from: tahujdt
I don't know about unicorns, but back in .95, one of my PA soldiers was diagnosed with power armor. I drew a fairly good picture about it, but my science project (a bunny) pissed all over it.
Fallout: Equestria - Index of Stable Reports x Fallout: Equestria - Orange

luppolo

  • Bay Watcher
    • View Profile
Re: New plugin to add "Search" functionality to Stock, Trade and Unit screens
« Reply #13 on: October 22, 2012, 04:19:19 pm »

this is should be part of the main game, not just a plugin
Logged

radost

  • Escaped Lunatic
    • View Profile
Re: New plugin to add "Search" functionality to Stock, Trade and Unit screens
« Reply #14 on: November 03, 2012, 12:28:45 pm »

It looks like a greate plugin! Have you ever tried to compile it on linux? I've tried and got this error on make install:
Code: [Select]
[ 89%] Building CXX object plugins/CMakeFiles/search.dir/search.cpp.o
In file included from /home/me/game/DF/dfhack/dfhack_serach/dfhack/library/include/df/unit.h:47:0,
                 from /home/me/game/DF/dfhack/dfhack_serach/dfhack/library/include/modules/Units.h:34,
                 from /home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:3:
/home/me/game/DF/dfhack/dfhack_serach/dfhack/library/include/df/tile_designation.h:19:38: warning: ‘df::tile_designation::<anonymous struct>::dig’ is too small to hold all values of ‘enum df::enums::tile_dig_designation::tile_dig_designation’ [enabled by default]
/home/me/game/DF/dfhack/dfhack_serach/dfhack/library/include/df/tile_designation.h:27:37: warning: ‘df::tile_designation::<anonymous struct>::liquid_type’ is too small to hold all values of ‘enum df::enums::tile_liquid::tile_liquid’ [enabled by default]
/home/me/game/DF/dfhack/dfhack_serach/dfhack/library/include/df/tile_designation.h:30:34: warning: ‘df::tile_designation::<anonymous struct>::traffic’ is too small to hold all values of ‘enum df::enums::tile_traffic::tile_traffic’ [enabled by default]
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:443:1: error: specializing member ‘search_hook<df::viewscreen_storesst, stocks_search>::interpose_feed’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:444:1: error: specializing member ‘search_hook<df::viewscreen_storesst, stocks_search>::interpose_render’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:505:1: error: specializing member ‘search_hook<df::viewscreen_unitlistst, unitlist_search>::interpose_feed’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:506:1: error: specializing member ‘search_hook<df::viewscreen_unitlistst, unitlist_search>::interpose_render’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:555:1: error: specializing member ‘search_hook<df::viewscreen_tradegoodsst, trade_search_merc, int>::interpose_feed’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:556:1: error: specializing member ‘search_hook<df::viewscreen_tradegoodsst, trade_search_merc, int>::interpose_render’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:579:1: error: specializing member ‘search_hook<df::viewscreen_tradegoodsst, trade_search_fort, char>::interpose_feed’ requires ‘template<>’ syntax
/home/me/game/DF/dfhack/dfhack_serach/dfhack/plugins/search.cpp:580:1: error: specializing member ‘search_hook<df::viewscreen_tradegoodsst, trade_search_fort, char>::interpose_render’ requires ‘template<>’ syntax
make[2]: *** [plugins/CMakeFiles/search.dir/search.cpp.o] Error 1
make[1]: *** [plugins/CMakeFiles/search.dir/all] Error 2
make: *** [all] Error 2
Logged
Pages: [1] 2 3 ... 5