Beispiel #1
0
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);
}
Beispiel #2
0
void tchatbox::add_chat_room_message_received(const std::string& room,
	const std::string& speaker,
	const std::string& message)
{
	room_info* ri = lobby_info().get_room(room);
	if(!ri) {
		LOG_LB << "Discarding message to room " << room << " from " << speaker << " (room not open)\n";
		return;
	}

	t_notify_mode notify_mode = NOTIFY_NONE;
	ri->log().add_message(speaker, message);

	if(room_window_active(room)) {
		add_active_window_message(speaker, message);
		notify_mode = NOTIFY_MESSAGE;
	} else {
		add_room_window_message(room, speaker, message);
		increment_waiting_messages(room);
		notify_mode = NOTIFY_MESSAGE_OTHER_WINDOW;
	}

	if(speaker == "server") {
		notify_mode = NOTIFY_SERVER_MESSAGE;
	} else if (utils::word_match(message, preferences::login())) {
		notify_mode = NOTIFY_OWN_NICK;
	} else if (preferences::is_friend(speaker)) {
		notify_mode = NOTIFY_FRIEND_MESSAGE;
	}

	do_notify(notify_mode, speaker, message);
}
Beispiel #3
0
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";
	}
}
Beispiel #4
0
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);
}
Beispiel #5
0
void tchatbox::process_room_query_response(const ::config& data)
{
	const std::string& room = data["room"];
	const std::string& message = data["message"];

	DBG_LB << "room query response: " << room << " " << message << "\n";

	if(room.empty()) {
		if(!message.empty()) {
			add_active_window_message("server", message);
		}

		if(const ::config& rooms = data.child("rooms")) {
			// TODO: this should really open a nice join room dialog instead
			std::stringstream ss;
			ss << "Rooms:";

			for(const auto & r : rooms.child_range("room")) {
				ss << " " << r["name"];
			}

			add_active_window_message("server", ss.str());
		}
	} else {
		if(room_window_open(room, false)) {
			if(!message.empty()) {
				add_chat_room_message_received(room, "server", message);
			}

			if(const ::config& members = data.child("members")) {
				room_info* r = lobby_info().get_room(room);
				assert(r);
				r->process_room_members(members);
				if(r == active_window_room()) {
					active_window_changed_callback_();
				}
			}
		} else {
			if(!message.empty()) {
				add_active_window_message("server", room + ": " + message);
			}
		}
	}
}
Beispiel #6
0
void tlobby_main::add_chat_room_message_sent(const std::string& room,
											 const std::string& message)
{
	// do not open room window here, player should be in the room before sending
	// messages yo it should be allowed to happen
	if(tlobby_chat_window* t = room_window_open(room, false)) {
		room_info* ri = lobby_info_.get_room(room);
		assert(ri);
		if(!room_window_active(room)) {
			switch_to_window(t);
		}
		ri->log().add_message(preferences::login(), message);
		add_active_window_message(preferences::login(), message, true);
	} else {
		LOG_LB << "Cannot add sent message to ui for room " << room
			   << ", player not in the room\n";
	}
}
Beispiel #7
0
void tchatbox::add_chat_room_message_sent(const std::string& room,
	const std::string& message)
{
	tlobby_chat_window* t = room_window_open(room, false);
	if(!t) {
		LOG_LB << "Cannot add sent message to ui for room " << room << ", player not in the room\n";
		return;
	}

	// Do not open room window here. The player should be in the room before sending messages
	room_info* ri = lobby_info().get_room(room);
	assert(ri);

	if(!room_window_active(room)) {
		switch_to_window(t);
	}

	ri->log().add_message(preferences::login(), message);
	add_active_window_message(preferences::login(), message, true);
}