void tchatbox::add_whisper_received(const std::string& sender, const std::string& message) { bool can_go_to_active = !preferences::whisper_friends_only() || preferences::is_friend(sender); bool can_open_new = preferences::auto_open_whisper_windows() && can_go_to_active; lobby_info().get_whisper_log(sender).add_message(sender, message); if(whisper_window_open(sender, can_open_new)) { if(whisper_window_active(sender)) { add_active_window_message(sender, message); do_notify(NOTIFY_WHISPER, sender, message); } else { add_whisper_window_whisper(sender, message); increment_waiting_whsipers(sender); do_notify(NOTIFY_WHISPER_OTHER_WINDOW, sender, message); } } else if(can_go_to_active) { add_active_window_whisper(sender, message); do_notify(NOTIFY_WHISPER, sender, message); } else { LOG_LB << "Ignoring whisper from " << sender << "\n"; } }
void tchatbox::add_whisper_window_whisper(const std::string& sender, const std::string& message) { tlobby_chat_window* t = whisper_window_open(sender, false); if(!t) { ERR_LB << "Whisper window not open in add_whisper_window_whisper for " << sender << "\n"; return; } const std::string text = formatter() << "<b>" << sender << ":</b> " << font::escape_text(message); append_to_chatbox(text, t - &open_windows_[0], false); }
void tchatbox::add_whisper_sent(const std::string& receiver, const std::string& message) { if(whisper_window_active(receiver)) { add_active_window_message(preferences::login(), message, true); } else if(tlobby_chat_window* t = whisper_window_open(receiver, preferences::auto_open_whisper_windows())) { switch_to_window(t); add_active_window_message(preferences::login(), message, true); } else { add_active_window_whisper(vgettext("whisper to $receiver", {{"receiver", receiver}}), message, true); } lobby_info().get_whisper_log(receiver).add_message(preferences::login(), message); }
void tlobby_main::add_whisper_window_whisper(const std::string& sender, const std::string& message) { std::stringstream ss; ss << "<" << sender << "> " << message; tlobby_chat_window* t = whisper_window_open(sender, false); if(!t) { ERR_LB << "Whisper window not open in add_whisper_window_whisper for " << sender << "\n"; return; } append_to_chatbox(ss.str(), t - &open_windows_[0], false); }
void tchatbox::increment_waiting_whsipers(const std::string& name) { if(tlobby_chat_window* t = whisper_window_open(name, false)) { t->pending_messages++; if(t->pending_messages == 1) { DBG_LB << "do whisper pending mark row " << (t - &open_windows_[0]) << " with " << t->name << "\n"; tgrid* grid = roomlistbox_->get_row_grid(t - &open_windows_[0]); // this breaks for some reason // tlabel& label = grid->get_widget<tlabel>("room", false); // label.set_use_markup(true); // label.set_label(colorize("<" + t->name + ">", "red")); find_widget<timage>(grid, "pending_messages", false).set_visible(twidget::tvisible::visible); } } }
void tlobby_main::add_whisper_sent(const std::string& receiver, const std::string& message) { if(whisper_window_active(receiver)) { add_active_window_message(preferences::login(), message, true); } else if(tlobby_chat_window* t = whisper_window_open( receiver, preferences::auto_open_whisper_windows())) { switch_to_window(t); add_active_window_message(preferences::login(), message, true); } else { utils::string_map symbols; symbols["receiver"] = receiver; add_active_window_whisper(VGETTEXT("whisper to $receiver", symbols), message, true); } lobby_info_.get_whisper_log(receiver) .add_message(preferences::login(), message); }
void tlobby_main::user_dialog_callback(user_info* info) { tlobby_player_info dlg(*this, *info, lobby_info_); lobby_delay_gamelist_update_guard g(*this); dlg.show(window_->video()); delay_playerlist_update_ = true; if(dlg.result_open_whisper()) { tlobby_chat_window* t = whisper_window_open(info->name, true); switch_to_window(t); window_->invalidate_layout(); } selected_game_id_ = info->game_id; // the commented out code below should be enough, but that'd delete the // playerlist and the widget calling this callback, so instead the game // will be selected on the next gamelist update. /* if (info->game_id != 0) { for (unsigned i = 0; i < lobby_info_.games_filtered().size(); ++i) { game_info& g = *lobby_info_.games_filtered()[i]; if (info->game_id == g.id) { gamelistbox_->select_row(i); update_selected_game(); break; } } } */ // do not update here as it can cause issues with removing the widget // from within it's event handler. Should get updated as soon as possible // update_gamelist(); delay_playerlist_update_ = false; player_list_dirty_ = true; wesnothd_connection_.send_data(config("refresh_lobby")); }