give plugins a chance to run in gui1 dialogs when disp is faked

Otherwise they cannot use any of the dialogs and we cannot do
leader select when joining a game.

This commit also adds an "any_running" helper to plugins_manager.
This commit is contained in:
Chris Beck 2014-12-03 00:08:45 -05:00
parent 60bb254f69
commit 1f93699c8b
3 changed files with 30 additions and 1 deletions

View File

@ -286,7 +286,24 @@ int dialog::show(int xloc, int yloc)
int dialog::show()
{
if (disp_.video().faked()) return CLOSE_DIALOG;
if (disp_.video().faked()) {
plugins_manager * pm = plugins_manager::get();
if (pm && pm->any_running()) {
pm->notify_event("show_dialog", config(config_of
("title", title_)
("message", message_->get_text())
));
plugins_context pc("Dialog");
pc.set_callback("set_result", boost::bind(&dialog::set_result, this, boost::bind(get_int, _1, "result", CLOSE_DIALOG)), false);
while (pm->any_running() && result() == CONTINUE_DIALOG) {
pc.play_slice();
}
return result();
}
return CLOSE_DIALOG;
}
if(disp_.video().update_locked()) {
ERR_DP << "display locked ignoring dialog '" << title_ << "' '" << message_->get_text() << "'" << std::endl;

View File

@ -205,3 +205,13 @@ void plugins_manager::play_slice(const plugins_context & ctxt)
}
*local = false;
}
bool plugins_manager::any_running()
{
for (size_t i = 0; i < size(); ++i) {
if (RUNNING == get_status(i)) {
return true;
}
}
return false;
}

View File

@ -57,6 +57,8 @@ public:
std::string get_detailed_status(size_t idx);
std::string get_name (size_t idx);
bool any_running();
size_t load_plugin(const std::string & name, const std::string & filename); //throws exceptions in case of failure
size_t add_plugin(const std::string & name, const std::string & prog); //throws exceptions in case of failure