예제 #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);
}
예제 #2
0
void tchatbox::finalize_setup()
{
	roomlistbox_ = find_widget<tlistbox>(this, "room_list", false, true);

	roomlistbox_->set_callback_value_change([this](twidget&) {
		switch_to_window(roomlistbox_->get_selected_row());
	});

	chat_log_container_ = find_widget<tmulti_page>(this, "chat_log_container", false, true);

	chat_input_ = find_widget<ttext_box>(this, "chat_input", false, true);

	connect_signal_pre_key_press(*chat_input_,
		std::bind(&tchatbox::chat_input_keypress_callback, this, _3, _4, _5));
}
예제 #3
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";
		}
	}
}
예제 #4
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";
	}
}
예제 #5
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);
}
예제 #6
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";
		}
	}
}
예제 #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);
}
예제 #8
0
static void on_rect_click (GtkWidget *widget, gpointer data)
{
  MosaicWindowBox *box = MOSAIC_WINDOW_BOX (widget);

  if (!options.read_stdin) {
    gtk_widget_hide (window);
    switch_to_window (mosaic_window_box_get_xwindow (box));
  } else {
    puts (mosaic_window_box_get_name (box));
  }

  if (options.persistent) {
    if (strlen (mosaic_search_box_get_text (MOSAIC_SEARCH_BOX (search)))) {
      gtk_widget_hide (search);
      mosaic_search_box_set_text (MOSAIC_SEARCH_BOX (search), "\0");
    }
  } else {
    gtk_main_quit ();
  }
}
예제 #9
0
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"));
}
예제 #10
0
void tchatbox::switch_to_window(tlobby_chat_window* t)
{
	switch_to_window(t - &open_windows_[0]);
}
예제 #11
0
void tlobby_main::room_switch_callback(twindow& /*window*/)
{
	switch_to_window(roomlistbox_->get_selected_row());
}