tlobby_chat_window* tchatbox::search_create_window(const std::string& name, bool whisper, bool open_new) { for(auto& t : open_windows_) { if(t.name == name && t.whisper == whisper) { return &t; } } if(!open_new) { return nullptr; } open_windows_.push_back(tlobby_chat_window(name, whisper)); std::map<std::string, string_map> data; string_map item; item["use_markup"] = "true"; if(whisper) { item["label"] = vgettext("Whisper session with $name started. " "If you do not want to receive messages from this user, type <i>/ignore $name</i>\n", {{"name", name}}); data.emplace("log_text", item); } else { item["label"] = vgettext("<i>Room</i> $name <i>joined</i>", {{"name", name}}); data.emplace("log_text", item); lobby_info().open_room(name); } chat_log_container_->add_page(data); data.clear(); item["label"] = whisper ? font::escape_text("<" + name + ">") : name; data.emplace("room", item); tgrid& row_grid = roomlistbox_->add_row(data); tbutton& close_button = find_widget<tbutton>(&row_grid, "close_window", false); connect_signal_mouse_left_click(close_button, std::bind(&tchatbox::close_window_button_callback, this, open_windows_.back(), _3, _4)); if(name == "lobby") { close_button.set_visible(tcontrol::tvisible::hidden); } return &open_windows_.back(); }
tlobby_chat_window* tlobby_main::search_create_window(const std::string& name, bool whisper, bool open_new) { for(auto & t : open_windows_) { if(t.name == name && t.whisper == whisper) return &t; } if(open_new) { open_windows_.push_back(tlobby_chat_window(name, whisper)); std::map<std::string, string_map> data; utils::string_map symbols; symbols["name"] = name; if(whisper) { add_label_data(data, "log_text", VGETTEXT("Whisper session with $name started. " "If you do not want to receive messages " "from this user, " "type /ignore $name\n", symbols)); } else { add_label_data(data, "log_text", VGETTEXT("<i>Room $name joined</i>", symbols)); lobby_info_.open_room(name); } chat_log_container_->add_page(data); std::map<std::string, string_map> data2; add_label_data(data2, "room", whisper ? "<" + name + ">" : name); tgrid* row_grid = &roomlistbox_->add_row(data2); tbutton& close_button = find_widget<tbutton>(row_grid, "close_window", false); connect_signal_mouse_left_click(close_button, std::bind(&tlobby_main::close_window_button_callback, this, roomlistbox_->get_item_count() - 1)); if(name == "lobby") { close_button.set_visible(tcontrol::tvisible::hidden); } return &open_windows_.back(); } return nullptr; }