add "select type" plugin callback to multiplayer create

This is needed to select different level types.
This commit is contained in:
Chris Beck 2014-12-02 17:48:20 -05:00
parent 7aedfad426
commit 13d77377d8
2 changed files with 14 additions and 0 deletions

View File

@ -216,12 +216,24 @@ create::create(game_display& disp, const config& cfg, saved_game& state,
plugins_context_->set_callback("load", boost::bind(&create::plugin_event_helper, this, process_event_data (false, true, false)));
plugins_context_->set_callback("quit", boost::bind(&create::plugin_event_helper, this, process_event_data (false, false, true)));
plugins_context_->set_callback("select_level", boost::bind(&gui::menu::move_selection, &levels_menu_, boost::bind(get_size_t, _1, "index", 0u)), true);
plugins_context_->set_callback("select_type", boost::bind(&create::select_level_type_helper, this, boost::bind(get_str, _1, "type")), true);
plugins_context_->set_accessor("game_config", boost::bind(&create::game_config, this));
plugins_context_->set_accessor("get_selected", boost::bind(&get_selected_helper, &engine_));
plugins_context_->set_accessor("find_level", boost::bind(&find_helper, &engine_, _1));
}
void create::select_level_type_helper(const std::string & str)
{
for (size_t idx = 0; idx < available_level_types_.size(); idx++) {
if (ng::level::TYPE_to_string(available_level_types_[idx]) == str) {
level_type_combo_.set_selected(idx);
init_level_type_changed(0);
process_event_impl(process_event_data(false, false, false));
}
}
}
create::~create()
{
try {

View File

@ -107,6 +107,8 @@ private:
void process_event_impl(const process_event_data &);
bool plugin_event_helper(const process_event_data &);
void select_level_type_helper(const std::string & str);
};
} // end namespace mp