Lock selection mode toggle

develop
Anuradha Dissanayake 2013-02-07 22:57:07 +13:00
parent dff16c3c1d
commit 1956f8b92d
1 changed files with 16 additions and 1 deletions

@ -58,7 +58,7 @@ using df::global::world;
using df::global::enabler; using df::global::enabler;
DFHACK_PLUGIN("buildingplan"); DFHACK_PLUGIN("buildingplan");
#define PLUGIN_VERSION 0.4 #define PLUGIN_VERSION 0.5
#ifndef HAVE_NULLPTR #ifndef HAVE_NULLPTR
#define nullptr 0L #define nullptr 0L
@ -1072,6 +1072,13 @@ private:
class Planner class Planner
{ {
public: public:
bool lock_selection;
Planner() : lock_selection(true)
{
}
bool isPlanableBuilding(const df::building_type type) const bool isPlanableBuilding(const df::building_type type) const
{ {
return item_for_building_type.find(type) != item_for_building_type.end(); return item_for_building_type.find(type) != item_for_building_type.end();
@ -1366,10 +1373,16 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
{ {
send_key(interface_key::CURSOR_DOWN_Z); send_key(interface_key::CURSOR_DOWN_Z);
send_key(interface_key::CURSOR_UP_Z); send_key(interface_key::CURSOR_UP_Z);
if (!planner.lock_selection)
send_key(interface_key::LEAVESCREEN);
} }
return true; return true;
} }
else if (input->count(interface_key::CUSTOM_L))
{
planner.lock_selection = !planner.lock_selection;
}
else if (input->count(interface_key::CUSTOM_M)) else if (input->count(interface_key::CUSTOM_M))
{ {
Screen::show(new ViewscreenChooseMaterial(planner.getDefaultItemFilterForType(type))); Screen::show(new ViewscreenChooseMaterial(planner.getDefaultItemFilterForType(type)));
@ -1447,6 +1460,8 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
if (is_planmode_enabled(type)) if (is_planmode_enabled(type))
{ {
OutputToggleString(x, y, "Lock Selection", "l", planner.lock_selection, true, left_margin);
auto filter = planner.getDefaultItemFilterForType(type); auto filter = planner.getDefaultItemFilterForType(type);
OutputHotkeyString(x, y, "Min Quality: ", "q"); OutputHotkeyString(x, y, "Min Quality: ", "q");