Beispiel #1
0
void chatbox::add_active_window_message(const std::string& sender,
	const std::string& message,
	const bool force_scroll)
{
	const std::string text = formatter() << "<b>" << sender << ":</b> " << font::escape_text(message);
	append_to_chatbox(text, force_scroll);
}
Beispiel #2
0
void chatbox::chat_input_keypress_callback(bool& handled, bool& halt, const SDL_Keycode key)
{
	if(key == SDLK_RETURN || key == SDLK_KP_ENTER) {
		send_message_button_callback();
		handled = true;
		halt = true;
	} else if (key == SDLK_TAB) {
		std::string text = chat_input_->get_value();

		std::vector<std::string> matches;
		for(const auto& ui : lobby_info_->users()) {
			if(ui.name != preferences::login()) {
				matches.push_back(ui.name);
			}
		}

		const bool line_start = utils::word_completion(text, matches);

		if(matches.empty()) {
			return;
		}

		if(matches.size() == 1) {
			text.append(line_start ? ": " : " ");
		} else {
			std::string completion_list = utils::join(matches, " ");
			append_to_chatbox(completion_list);
		}

		chat_input_->set_value(text);

		handled = true;
		halt = true;
	}
}
Beispiel #3
0
void tlobby_main::add_active_window_message(const std::string& sender,
											const std::string& message,
											const bool force_scroll)
{
	std::stringstream ss;
	ss << "<b>" << sender << ":</b> " << font::escape_text(message);
	append_to_chatbox(ss.str(), force_scroll);
}
Beispiel #4
0
void tchatbox::add_chat_message(const time_t& /*time*/,
	const std::string& speaker,
	int /*side*/,
	const std::string& message,
	events::chat_handler::MESSAGE_TYPE /*type*/)
{
	const std::string text = formatter() << "<b>" << speaker << ":</b> " << font::escape_text(message);
	append_to_chatbox(text);
}
Beispiel #5
0
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);
}
Beispiel #6
0
void tlobby_main::add_chat_message(const time_t& /*time*/,
								   const std::string& speaker,
								   int /*side*/,
								   const std::string& message,
								   events::chat_handler::MESSAGE_TYPE /*type*/)
{
	std::stringstream ss;
	ss << "<b>" << speaker << ":</b> ";
	ss << font::escape_text(message);
	append_to_chatbox(ss.str());
}
Beispiel #7
0
void tchatbox::add_room_window_message(const std::string& room,
	const std::string& sender,
	const std::string& message)
{
	tlobby_chat_window* t = room_window_open(room, false);
	if(!t) {
		ERR_LB << "Room window not open in add_room_window_message for " << room << "\n";
		return;
	}

	const std::string text = formatter() << "<b>" << sender << ":</b> " << font::escape_text(message);
	append_to_chatbox(text, t - &open_windows_[0], false);
}
Beispiel #8
0
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);
}
Beispiel #9
0
void tlobby_main::add_room_window_message(const std::string& room,
										  const std::string& sender,
										  const std::string& message)
{
	std::stringstream ss;
	ss << "<b>" << sender << ":</b> " << font::escape_text(message);
	tlobby_chat_window* t = room_window_open(room, false);
	if(!t) {
		ERR_LB << "Room window not open in add_room_window_message for " << room
			   << "\n";
		return;
	}
	append_to_chatbox(ss.str(), t - &open_windows_[0], false);
}
Beispiel #10
0
void tchatbox::append_to_chatbox(const std::string& text, const bool force_scroll)
{
	append_to_chatbox(text, active_window_, force_scroll);
}