MCPcopy Create free account
hub / github.com/DFHack/dfhack / add_binding_if_valid

Function add_binding_if_valid

plugins/hotkeys.cpp:68–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68static void add_binding_if_valid(color_ostream &out, const string &sym, const string &cmdline, df::viewscreen *screen, bool filtermenu) {
69 if (!can_invoke(cmdline, screen))
70 return;
71
72 if (filtermenu && (cmdline.starts_with(INVOKE_MENU_PREFIX) ||
73 cmdline == INVOKE_HOTKEYS_COMMAND)) {
74 DEBUG(log).print("filtering out hotkey menu keybinding\n");
75 return;
76 }
77
78 if (should_hide_armok(out, cmdline)) {
79 DEBUG(log).print("filtering out armok keybinding\n");
80 return;
81 }
82
83 current_bindings[sym] = cmdline;
84 sorted_keys.push_back(sym);
85 string keyspec = sym + "@" + MENU_SCREEN_FOCUS_STRING;
86 string binding = "hotkeys invoke " + int_to_string(sorted_keys.size() - 1);
87 DEBUG(log).print("adding keybinding: {} -> {}\n", keyspec, binding);
88 Core::getInstance().getHotkeyManager()->addKeybind(keyspec, binding);
89}
90
91static void find_active_keybindings(color_ostream &out, df::viewscreen *screen, bool filtermenu) {
92 if (valid)

Callers 1

find_active_keybindingsFunction · 0.85

Calls 6

can_invokeFunction · 0.85
should_hide_armokFunction · 0.85
int_to_stringFunction · 0.85
addKeybindMethod · 0.80
printMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected