From bdf201c6705619dfc0bfe0769ef119167e7ef726 Mon Sep 17 00:00:00 2001 From: myk002 Date: Fri, 11 Nov 2022 18:05:07 -0800 Subject: [PATCH] ensure keybinding shows up in hotkeys command not overlay --- data/init/dfhack.keybindings.init | 2 +- plugins/hotkeys.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/data/init/dfhack.keybindings.init b/data/init/dfhack.keybindings.init index 697641ab1..330260b06 100644 --- a/data/init/dfhack.keybindings.init +++ b/data/init/dfhack.keybindings.init @@ -13,7 +13,7 @@ keybinding add ` gui/launcher keybinding add Ctrl-Shift-D gui/launcher # show hotkey popup menu -keybinding add Ctrl-Shift-C "overlay trigger hotkeys.menu" +keybinding add Ctrl-Shift-C hotkeys # on-screen keyboard keybinding add Ctrl-Shift-K gui/cp437-table diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 77db827bd..8f980cb2b 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -22,6 +22,7 @@ using std::vector; using namespace DFHack; static const string INVOKE_MENU_COMMAND = "overlay trigger hotkeys.menu"; +static const string INVOKE_HOTKEYS_COMMAND = "hotkeys"; static const std::string MENU_SCREEN_FOCUS_STRING = "dfhack/lua/hotkeys/menu"; static bool valid = false; // whether the following two vars contain valid data @@ -32,8 +33,6 @@ static vector sorted_keys; static bool can_invoke(const string &cmdline, df::viewscreen *screen) { vector cmd_parts; split_string(&cmd_parts, cmdline, " "); - if (toLower(cmd_parts[0]) == "hotkeys") - return false; return Core::getInstance().getPluginManager()->CanInvokeHotkey(cmd_parts[0], screen); } @@ -56,7 +55,8 @@ static void add_binding_if_valid(const string &sym, const string &cmdline, df::v if (!can_invoke(cmdline, screen)) return; - if (filtermenu && cmdline == INVOKE_MENU_COMMAND) { + if (filtermenu && (cmdline == INVOKE_MENU_COMMAND || + cmdline == INVOKE_HOTKEYS_COMMAND)) { DEBUG(log).print("filtering out hotkey menu keybinding\n"); return; } @@ -178,6 +178,7 @@ static command_result hotkeys_cmd(color_ostream &out, vector & paramete return CR_OK; } + // internal command -- intentionally undocumented if (parameters.size() != 2 || parameters[0] != "invoke") return CR_WRONG_USAGE;