void tlobby_main::join_global_button_callback(twindow& window) { if(do_game_join(gamelistbox_->get_selected_row(), false)) { legacy_result_ = JOIN; window.close(); } }
void tlobby_main::observe_global_button_callback(twindow& window) { if(do_game_join(gamelistbox_->get_selected_row(), true)) { legacy_result_ = OBSERVE; window.close(); } }
void tmp_side_wait::cancel(twindow& window) { legacy_result_ = QUIT; window.close(); }
void tmp_side_wait::join_game(twindow& window, bool observe) { // if we have got valid side data // the first condition is to make sure that we don't have another // WML message with a side-tag in it while (!level_.has_attribute("version") || !level_.child("side")) { level_.clear(); // below function has BUG!!! network::connection data_res = dialogs::network_receive_dialog(disp_, _("Getting game data..."), level_); if (!data_res) { legacy_result_ = QUIT; window.close(); return; } mp::check_response(data_res, level_); if (level_.child("leave_game")) { legacy_result_ = QUIT; window.close(); return; } } if (!observe) { //search for an appropriate vacant slot. If a description is set //(i.e. we're loading from a saved game), then prefer to get the side //with the same description as our login. Otherwise just choose the first //available side. const config *side_choice = NULL; int side_num = -1, nb_sides = 0; BOOST_FOREACH (const config &sd, level_.child_range("side")) { if (sd["controller"] == "network" && sd["current_player"].empty()) { if (!side_choice) { // found the first empty side side_choice = &sd; side_num = nb_sides; } if (sd["current_player"] == preferences::login()) { side_choice = &sd; side_num = nb_sides; break; // found the preferred one } } ++nb_sides; } if (!side_choice) { legacy_result_ = QUIT; window.close(); return; } bool allow_changes = (*side_choice)["allow_changes"].to_bool(true); //if the client is allowed to choose their team, instead of having //it set by the server, do that here. std::string leader_choice, gender_choice; int faction_choice = 0; if(allow_changes) { events::event_context context; const config &era = level_.child("era"); /** @todo Check whether we have the era. If we don't inform the user. */ if (!era) throw config::error(_("No era information found.")); /* config::const_child_itors possible_sides = era.child_range("multiplayer_side"); if (possible_sides.first == possible_sides.second) { set_result(QUIT); throw config::error(_("No multiplayer sides found")); return; } */ int color = side_num; const std::string color_str = (*side_choice)["color"].str(); if (!color_str.empty()) color = game_config::color_info(color_str).index() - 1; config faction; config& change = faction.add_child("change_faction"); change["name"] = preferences::login(); change["faction"] = 0; // now, it is ignored change["leader"] = "random"; // now, it is ignored change["gender"] = "random"; // now, it is ignored network::send_data(lobby->chat, faction); } } generate_menu(window); }
void tlobby_player_info::kick_ban_button_callback(twindow& w) { do_kick_ban(true); w.close(); }
void tlobby_player_info::check_status_button_callback(twindow& w) { chat_.send_command("query", "status " + info_.name); w.close(); }
void tlobby_player_info::start_whisper_button_callback(twindow& w) { result_open_whisper_ = true; w.close(); }
void tlobby_main::create_button_callback(twindow& window) { legacy_result_ = CREATE; window.close(); }
void tsystem::set_retval(twindow& window, int val) { retval_ = val; window.close(); }