void tlobby_player_info::remove_from_list_button_callback(twindow& w) { preferences::remove_friend(info_.name); preferences::remove_ignore(info_.name); info_.relation = user_info::NEUTRAL; update_relation(w); }
user_info::user_info(const config& c) : name(c["name"]) , game_id(c["game_id"]) , relation(ME) , state(game_id == 0 ? LOBBY : GAME) , registered(c["registered"].to_bool()) , observing(c["status"] == "observing") { update_relation(); }
void user_info::update_state(int selected_game_id, const room_info* current_room /*= NULL*/) { if(game_id != 0) { if(game_id == selected_game_id) { state = SEL_GAME; } else { state = GAME; } } else { if(current_room != NULL && current_room->is_member(name)) { state = SEL_ROOM; } else { state = LOBBY; } } update_relation(); }
void tlobby_player_info::pre_show(CVideo& /*video*/, twindow& window) { relation_ = find_widget<tlabel>(&window, "relation_info", false, true); GUI2_EASY_BUTTON_CALLBACK(start_whisper, tlobby_player_info); GUI2_EASY_BUTTON_CALLBACK(add_to_friends, tlobby_player_info); GUI2_EASY_BUTTON_CALLBACK(add_to_ignores, tlobby_player_info); GUI2_EASY_BUTTON_CALLBACK(remove_from_list, tlobby_player_info); add_to_friends_ = add_to_friends_btn; add_to_ignores_ = add_to_ignores_btn; remove_from_list_ = remove_from_list_btn; GUI2_EASY_BUTTON_CALLBACK(check_status, tlobby_player_info); GUI2_EASY_BUTTON_CALLBACK(kick, tlobby_player_info); GUI2_EASY_BUTTON_CALLBACK(kick_ban, tlobby_player_info); find_widget<tlabel>(&window, "player_name", false) .set_label(info_.name); std::stringstream loc; const game_info* game = lobby_info_.get_game_by_id(info_.game_id); if (game != NULL) { loc << _("In game:") << " " << game->name << " "; if (info_.observing) { loc << _("(observing)"); } else { loc << _("(playing)"); } } else { loc << _("In lobby"); } find_widget<tlabel>(&window, "location_info", false).set_label(loc.str()); update_relation(window); if (!preferences::is_authenticated()) { twidget* aw = window.find("admin", false); aw->set_visible(twidget::INVISIBLE); } }
void tlobby_player_info::pre_show(twindow& window) { relation_ = find_widget<tlabel>(&window, "relation_info", false, true); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "start_whisper", false), std::bind(&tlobby_player_info::start_whisper_button_callback, this, std::ref(window))); add_to_friends_ = &find_widget<tbutton>(&window, "add_to_friends", false); connect_signal_mouse_left_click( *add_to_friends_, std::bind(&tlobby_player_info::add_to_friends_button_callback, this, std::ref(window))); add_to_ignores_ = &find_widget<tbutton>(&window, "add_to_ignores", false); connect_signal_mouse_left_click( *add_to_ignores_, std::bind(&tlobby_player_info::add_to_ignores_button_callback, this, std::ref(window))); remove_from_list_ = &find_widget<tbutton>(&window, "remove_from_list", false); connect_signal_mouse_left_click( *remove_from_list_, std::bind(&tlobby_player_info::remove_from_list_button_callback, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "check_status", false), std::bind(&tlobby_player_info::check_status_button_callback, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "kick", false), std::bind(&tlobby_player_info::kick_button_callback, this, std::ref(window))); connect_signal_mouse_left_click( find_widget<tbutton>(&window, "kick_ban", false), std::bind(&tlobby_player_info::kick_ban_button_callback, this, std::ref(window))); find_widget<tlabel>(&window, "player_name", false).set_label(info_.name); std::stringstream loc; const game_info* game = lobby_info_.get_game_by_id(info_.game_id); if(game != nullptr) { loc << _("In game:") << " " << game->name << " "; if(info_.observing) { loc << _("(observing)"); } else { loc << _("(playing)"); } } else { loc << _("In lobby"); } find_widget<tlabel>(&window, "location_info", false).set_label(loc.str()); update_relation(window); if(!preferences::is_authenticated()) { twidget* aw = window.find("admin", false); aw->set_visible(twidget::tvisible::invisible); } }
void tlobby_player_info::add_to_ignores_button_callback(twindow& w) { preferences::add_ignore(info_.name, ""); info_.relation = user_info::IGNORED; update_relation(w); }
void tlobby_player_info::add_to_friends_button_callback(twindow& w) { preferences::add_friend(info_.name, ""); info_.relation = user_info::FRIEND; update_relation(w); }