diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 0c606227..9309da30 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -841,9 +841,9 @@ bool cDialog::toast(bool triggerFocus){ return true; } -void cDialog::untoast() { +void cDialog::untoast(bool triggerFocusHandler) { dialogNotToast = true; - if(!currentFocus.empty()) + if(!currentFocus.empty() && triggerFocusHandler) this->getControl(currentFocus).triggerFocusHandler(*this, currentFocus, false); } diff --git a/src/dialogxml/dialogs/dialog.hpp b/src/dialogxml/dialogs/dialog.hpp index bcf8103c..e1dc6e90 100644 --- a/src/dialogxml/dialogs/dialog.hpp +++ b/src/dialogxml/dialogs/dialog.hpp @@ -194,7 +194,7 @@ public: /// Reopen the dialog after closing it. /// This is meant to be called from within an event handler to reverse a previous call to toast(); /// if you're already out of the dialog's event loop, you should instead call run() to reopen it. - void untoast(); + void untoast(bool triggerFocusHandler = true); /// Determine how the dialog exited. /// @return the argument passed to toast() when the dialog was closed bool accepted() const; diff --git a/src/game/boe.party.cpp b/src/game/boe.party.cpp index 59ea28e5..a72d0e07 100644 --- a/src/game/boe.party.cpp +++ b/src/game/boe.party.cpp @@ -1729,10 +1729,9 @@ static void draw_spell_pc_info(cDialog& me) { static void put_pc_caster_buttons(cDialog& me) { for(short i = 0; i < 6; i++) { std::string n = boost::lexical_cast(i + 1); - if(me["caster" + n].isVisible()) { - if(i == pc_casting) - me["pc" + n].setColour(SELECTED_COLOUR); - else me["pc" + n].setColour(me.getDefTextClr()); + me["pc" + n].setColour(me.getDefTextClr()); + if(me["caster" + n].isVisible() && i == pc_casting){ + me["pc" + n].setColour(SELECTED_COLOUR); } } } @@ -2062,6 +2061,10 @@ eSpell pick_spell(short pc_num,eSkill type) { // 70 - no spell OW spell num extern std::unique_ptr storeCastSpell; cDialog& castSpell = *storeCastSpell; + // untoast() is not usually called directly, but here it must be so that the reused dialog initializes + // correctly, because cControl::isVisible() returns false for toasted dialogs + castSpell.untoast(false); + castSpell.attachClickHandlers(std::bind(pick_spell_caster, _1, _2, type, std::ref(dark), std::ref(former_spell)), {"caster1","caster2","caster3","caster4","caster5","caster6"}); castSpell.attachClickHandlers(std::bind(pick_spell_target,_1,_2, type, std::ref(dark), std::ref(former_spell)), {"target1","target2","target3","target4","target5","target6"}); castSpell.attachClickHandlers(std::bind(pick_spell_event_filter, _1, _2, type,std::ref(former_spell)), {"other", "help"}); @@ -2086,9 +2089,9 @@ eSpell pick_spell(short pc_num,eSkill type) { // 70 - no spell OW spell num put_spell_list(castSpell, type); draw_spell_info(castSpell, type, former_spell); - put_pc_caster_buttons(castSpell); draw_spell_pc_info(castSpell); draw_caster_buttons(castSpell, type); + put_pc_caster_buttons(castSpell); put_spell_led_buttons(castSpell, type, former_spell); castSpell.runWithHelp(7, 8);