summaryrefslogtreecommitdiff
path: root/plugins/cleaners.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/cleaners.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/cleaners.cpp')
-rw-r--r--plugins/cleaners.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp
index b93b18f3..17800dd5 100644
--- a/plugins/cleaners.cpp
+++ b/plugins/cleaners.cpp
@@ -27,7 +27,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{
commands.clear();
commands.push_back(PluginCommand("clean","Removes contaminants from map tiles, items and creatures.",clean));
- commands.push_back(PluginCommand("spotclean","Cleans map tile under cursor.",spotclean));
+ commands.push_back(PluginCommand("spotclean","Cleans map tile under cursor.",spotclean,cursor_hotkey));
return CR_OK;
}
@@ -165,7 +165,7 @@ command_result cleanunits (Core * c)
DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
{
- c->Suspend();
+ // HOTKEY COMMAND: CORE ALREADY SUSPENDED
vector<DFHack::t_spattervein *> splatter;
DFHack::Maps *Mapz = c->getMaps();
DFHack::Gui *Gui = c->getGui();
@@ -173,7 +173,6 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
if(!Mapz->Start())
{
c->con.printerr("Can't init map.\n");
- c->Resume();
return CR_FAILURE;
}
int32_t cursorX, cursorY, cursorZ;
@@ -181,7 +180,6 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
if(cursorX == -30000)
{
c->con.printerr("The cursor is not active.\n");
- c->Resume();
return CR_FAILURE;
}
int32_t blockX = cursorX / 16, blockY = cursorY / 16;
@@ -193,7 +191,6 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
{
spatters[i]->intensity[tileX][tileY] = 0;
}
- c->Resume();
return CR_OK;
}