Example #1
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);
}
Example #2
0
void tlobby_main::process_room_join(const config& data)
{
	const std::string& room = data["room"];
	const std::string& player = data["player"];
	room_info* r = lobby_info_.get_room(room);
	DBG_LB << "room join: " << room << " " << player << " "
		   << static_cast<void*>(r) << "\n";

	if(r) {
		if(player == preferences::login()) {
			if(const config& members = data.child("members")) {
				r->process_room_members(members);
			}
		} else {
			r->add_member(player);
			/* TODO: add/use preference */
			utils::string_map symbols;
			symbols["player"] = player;
			add_room_window_message(
					room,
					"server",
					VGETTEXT("$player has entered the room", symbols));
		}
		if(r == active_window_room()) {
			player_list_dirty_ = true;
		}
	} else {
		if(player == preferences::login()) {
			tlobby_chat_window* t = room_window_open(room, true);
			lobby_info_.open_room(room);
			r = lobby_info_.get_room(room);
			assert(r);
			if(const config& members = data.child("members")) {
				r->process_room_members(members);
			}
			switch_to_window(t);

			const std::string& topic = data["topic"];
			if(!topic.empty()) {
				add_chat_room_message_received(
						"room", "server", room + ": " + topic);
			}
		} else {
			LOG_LB << "Discarding join info for a room the player is not in\n";
		}
	}
}
Example #3
0
void tchatbox::process_room_join(const ::config& data)
{
	const std::string& room = data["room"];
	const std::string& player = data["player"];

	DBG_LB << "room join: " << room << " " << player << "\n";

	room_info* r = lobby_info().get_room(room);
	if(r) {
		if(player == preferences::login()) {
			if(const auto& members = data.child("members")) {
				r->process_room_members(members);
			}
		} else {
			r->add_member(player);

			/* TODO: add/use preference */
			add_room_window_message(room, "server", vgettext("$player has entered the room", {{"player", player}}));
		}

		if(r == active_window_room()) {
			active_window_changed_callback_();
		}
	} else {
		if(player == preferences::login()) {
			tlobby_chat_window* t = room_window_open(room, true);
			lobby_info().open_room(room);
			r = lobby_info().get_room(room);
			assert(r);
			if(const auto& members = data.child("members")) {
				r->process_room_members(members);
			}
			switch_to_window(t);

			const std::string& topic = data["topic"];
			if(!topic.empty()) {
				add_chat_room_message_received("room", "server", room + ": " + topic);
			}
		} else {
			LOG_LB << "Discarding join info for a room the player is not in\n";
		}
	}
}
Example #4
0
void tchatbox::process_room_part(const ::config& data)
{
	// TODO: close room window when the part message is sent
	const std::string& room = data["room"];
	const std::string& player = data["player"];

	DBG_LB << "Room part: " << room << " " << player << "\n";

	if(room_info* r = lobby_info().get_room(room)) {
		r->remove_member(player);

		/* TODO: add/use preference */
		add_room_window_message(room, "server", vgettext("$player has left the room", {{"player", player}}));
		if(active_window_room() == r) {
			active_window_changed_callback_();
		}
	} else {
		LOG_LB << "Discarding part info for a room the player is not in\n";
	}
}
Example #5
0
void tlobby_main::process_room_part(const config& data)
{
	// todo close room window when the part message is sent
	const std::string& room = data["room"];
	const std::string& player = data["player"];
	DBG_LB << "Room part: " << room << " " << player << "\n";
	room_info* r = lobby_info_.get_room(room);
	if(r) {
		r->remove_member(player);
		/* TODO: add/use preference */
		utils::string_map symbols;
		symbols["player"] = player;
		add_room_window_message(
				room, "server", VGETTEXT("$player has left the room", symbols));
		if(active_window_room() == r) {
			player_list_dirty_ = true;
		}
	} else {
		LOG_LB << "Discarding part info for a room the player is not in\n";
	}
}