From 0d9efec062f4fd63e46266e1cfecde7d726c11df Mon Sep 17 00:00:00 2001 From: Anuradha Dissanayake Date: Wed, 21 Nov 2012 20:17:36 +1300 Subject: [PATCH] Disable plugin in non construction menu --- plugins/automaterial.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/automaterial.cpp b/plugins/automaterial.cpp index 2e39f3411..d05e13a3e 100644 --- a/plugins/automaterial.cpp +++ b/plugins/automaterial.cpp @@ -102,19 +102,28 @@ void OutputHotkeyString(int &x, int &y, const char *text, const char *hotkey, bo static inline bool in_material_choice_stage() { return Gui::build_selector_hotkey(Core::getTopViewscreen()) && + ui_build_selector->building_type == df::building_type::Construction && ui->main.mode == ui_sidebar_mode::Build && ui_build_selector->stage == 2; } -static inline bool in_type_choice_stage() +static inline bool in_placement_stage() { return Gui::dwarfmode_hotkey(Core::getTopViewscreen()) && ui->main.mode == ui_sidebar_mode::Build && ui_build_selector && - ui_build_selector->building_type >= 0 && + ui_build_selector->building_type == df::building_type::Construction && ui_build_selector->stage == 1; } +static inline bool in_type_choice_stage() +{ + return Gui::dwarfmode_hotkey(Core::getTopViewscreen()) && + ui->main.mode == ui_sidebar_mode::Build && + ui_build_selector && + ui_build_selector->building_type < 0; +} + static inline vector &get_curr_constr_prefs() { if (preferred_materials.find(ui_build_selector->building_subtype) == preferred_materials.end()) @@ -281,7 +290,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest } } } - else if (in_type_choice_stage()) + else if (in_placement_stage()) { if (input->count(interface_key::CUSTOM_A)) { @@ -358,7 +367,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest OutputHotkeyString(x, y, toggle_string.c_str(), "a", true, left_margin); } } - else if (in_type_choice_stage() && ui_build_selector->building_subtype != 7) + else if (in_placement_stage() && ui_build_selector->building_subtype != 7) { int left_margin = gps->dimx - 30; int x = left_margin;