summaryrefslogtreecommitdiff
path: root/plugins/initflags.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2011-12-31 13:25:46 +0400
committerAlexander Gavrilov2011-12-31 13:25:46 +0400
commitb652ec4132ad97b88dfd648303bf7a99267f1742 (patch)
tree90b27e73785ee8f2082b4339ffcbfddacc6a8df6 /plugins/initflags.cpp
parent4aa77f55308236189f157f65ad9ce82c35b9dabc (diff)
downloaddfhack-b652ec4132ad97b88dfd648303bf7a99267f1742.tar.gz
dfhack-b652ec4132ad97b88dfd648303bf7a99267f1742.tar.bz2
dfhack-b652ec4132ad97b88dfd648303bf7a99267f1742.tar.xz
Implement context-sensitive keybinding support.
Allow defining commands with guard conditions, and binding one or more commands to alphabetic and function keys. When the relevant key is pressed, the first listed command with successfully evaluated guard is chosen. For consistency, the guard is also checked when the command is invoked from the console; this requires suspending the core inside PluginManager, before invoking plugin code.
Diffstat (limited to 'plugins/initflags.cpp')
-rw-r--r--plugins/initflags.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp
index f27a318a..e52f6ed3 100644
--- a/plugins/initflags.cpp
+++ b/plugins/initflags.cpp
@@ -26,8 +26,10 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &
{
commands.clear();
if (d_init) {
- commands.push_back(PluginCommand("twaterlvl", "Toggle display of water/magma depth.", twaterlvl));
- commands.push_back(PluginCommand("tidlers", "Toggle display of idlers.", tidlers));
+ commands.push_back(PluginCommand("twaterlvl", "Toggle display of water/magma depth.",
+ twaterlvl, dwarfmode_hotkey));
+ commands.push_back(PluginCommand("tidlers", "Toggle display of idlers.",
+ tidlers, dwarfmode_hotkey));
}
std::cerr << "d_init: " << sizeof(df::d_init) << endl;
return CR_OK;
@@ -40,21 +42,19 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters)
{
- c->Suspend();
+ // HOTKEY COMMAND: CORE ALREADY SUSPENDED
df::global::d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS);
c->con << "Toggled the display of water/magma depth." << endl;
- c->Resume();
return CR_OK;
}
DFhackCExport command_result tidlers(Core * c, vector <string> & parameters)
{
- c->Suspend();
+ // HOTKEY COMMAND: CORE ALREADY SUSPENDED
df::d_init_idlers iv = df::d_init_idlers(int(d_init->idlers) + 1);
if (!d_init_idlers::is_valid(iv))
iv = ENUM_FIRST_ITEM(d_init_idlers);
d_init->idlers = iv;
c->con << "Toggled the display of idlers to " << ENUM_KEY_STR(d_init_idlers, iv) << endl;
- c->Resume();
return CR_OK;
}