Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [DFHack] [plugins] getting all the lists and keybindings of a given viewscreen  (Read 1904 times)

jeancallisti

  • Bay Watcher
    • View Profile

There's something I don't quite understand. In the existing plugins I've observed, the programmer just declares a ListColumn (ListColumn<df::dfhack_material_category> masks_column;) or a keybinding (OutputHotkeyString(x, y, "Toggle", "Enter");) as-is, but nevers calls any function to bind them to a viewscreen.

--> How does the engine know that this column/keybinding will apply to that viewscreen?
--> And afterwards, is there a way to know all the keybindings and columns (and other relevant elements) of a viewscreen?
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist

Yes, there is. Check Falconnes Utility Plugins, he has one that shows all active hotkeys/keybindings. Very useful if you use custom scripts a lot.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

jeancallisti

  • Bay Watcher
    • View Profile

Yes, there is. Check Falconnes Utility Plugins, he has one that shows all active hotkeys/keybindings. Very useful if you use custom scripts a lot.

Oh yes, I didn't notice that "hotkeys" plugin. I'll have a look at the source. Unless I'm  mistaken it's not shipped directly with DFHack.
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

--> How does the engine know that this column/keybinding will apply to that viewscreen?
Within DF's own viewscreens, it doesn't - when you press a particular key, it makes a list of all keybinding codes that match (e.g. press "y" and it turns that into A_STATUS_CUSTOMIZE, UNITVIEW_CUSTOMIZE, HOTKEY_CLOTHES_MAT_YARN, HOTKEY_CRAFTS_YARN, HOTKEY_BUILDING_WINDOW_GLASS, HOTKEY_BUILDING_WORKSHOP_ASHERY, MENU_CONFIRM, HOTKEY_LOOM_WEAVE_YARN, STOCKPILE_GRAVEYARD, BUILDING_TRIGGER_MIN_TRACK_CART_UP, STRING_A121, and CUSTOM_Y) and sends that entire list to the currently active viewscreen, then the viewscreen itself just checks for the specific ones it uses (e.g. if you're in the Build menu, it looks for HOTKEY_BUILDING_WINDOW_GLASS and in the Build Workshop menu it looks for HOTKEY_BUILDING_WORKSHOP_ASHERY).

Custom viewscreens typically just use the CUSTOM_etc. keybindings, resulting in them being unconfigurable (unless special support was added); augmentation of existing viewscreens (such as the various Search functions added in Falconne's plugins) are additionally prone to conflicts if the player customized their keybindings on those screens.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.