Make follow work as a hotkey plugin.

develop
Mike Stewart 2012-02-22 09:43:14 -08:00
parent 2249eb74ca
commit a779ac475d
1 changed files with 12 additions and 16 deletions

@ -29,7 +29,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{
commands.push_back(PluginCommand(
"follow", "Follow the selected unit until camera control is released",
follow, false,
follow, view_unit_hotkey,
" Select a unit and run this plugin to make the camera follow it. Moving the camera yourself deactivates the plugin.\n"
));
followedUnit = 0;
@ -126,11 +126,11 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
command_result follow (Core * c, std::vector <std::string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
if (!parameters.empty())
return CR_WRONG_USAGE;
CoreSuspender suspend(c);
if (followedUnit)
{
c->con.print("No longer following previously selected unit.\n");
@ -139,15 +139,11 @@ command_result follow (Core * c, std::vector <std::string> & parameters)
followedUnit = getSelectedUnit(c);
if (followedUnit)
{
c->con.print("Unpause to begin following ");
c->con.print(df::global::world->raws.creatures.all[followedUnit->race]->name[0].c_str());
if (followedUnit->name.has_name)
{
c->con.print(" %s", followedUnit->name.first_name.c_str());
}
c->con.print(". Simply manually move the view to break the following.\n");
prevX=prevY=prevZ = -1;
prevMenuWidth = 0;
std::ostringstream ss;
ss << "Unpause to begin following " << df::global::world->raws.creatures.all[followedUnit->race]->name[0];
if (followedUnit->name.has_name) ss << " " << followedUnit->name.first_name;
ss << ". Simply manually move the view to break the following.\n";
c->con.print(ss.str().c_str());
}
else followedUnit = 0;
return CR_OK;