Пример #1
0
void tgui_definition::load_widget_definitions(
		const std::string& definition_type,
		const std::vector<tcontrol_definition_ptr>& definitions)
{
	for(const auto & def : definitions)
	{

		// We assume all definitions are unique if not we would leak memory.
		assert(control_definition[definition_type].find(def->id)
			   == control_definition[definition_type].end());

		control_definition[definition_type]
				.insert(std::make_pair(def->id, def));
	}

	utils::string_map symbols;
	symbols["definition"] = definition_type;
	symbols["id"] = "default";
	t_string msg(vgettext("Widget definition '$definition' "
						  "doesn't contain the definition for '$id'.",
						  symbols));

	VALIDATE(control_definition[definition_type].find("default")
			 != control_definition[definition_type].end(),
			 msg);
}
Пример #2
0
bool addons_client::delete_remote_addon(const std::string& id, std::string& response_message)
{
	response_message.clear();

	config cfg;
	get_addon_pbl_info(id, cfg);

	utils::string_map i18n_symbols;
	i18n_symbols["addon_title"] = cfg["title"];
	if(i18n_symbols["addon_title"].empty()) {
		i18n_symbols["addon_title"] = make_addon_title(id);
	}

	config request_buf, response_buf;
	config& request_body = request_buf.add_child("delete");

	request_body["name"] = id;
	request_body["passphrase"] = cfg["passphrase"];

	LOG_ADDONS << "requesting server to delete " << id << '\n';

	this->send_request(request_buf, response_buf);
	this->wait_for_transfer_done(vgettext("Removing add-on <i>$addon_title</i> from the server...", i18n_symbols
	));

	if(const config& message_cfg = response_buf.child("message")) {
		response_message = message_cfg["message"].str();
		LOG_ADDONS << "server response: " << response_message << '\n';
	}

	return !this->update_last_error(response_buf);
}
Пример #3
0
void texile::discard(twindow& window)
{
	tlistbox& list = find_widget<tlistbox>(&window, "type_list", false);

	hero& h = heros_[selected_number_];
	int coin_income = 0, score_income = 0;
	
	const tgroup::tmember& m = group_.exile(h);

	utils::string_map symbols;
	std::string message;
	symbols["name"] = tintegrate::generate_format(h.name(), "red");
	symbols["coin"] = tintegrate::generate_format(coin_income, "green");
	symbols["score"] = tintegrate::generate_format(score_income, "green");
	message = vgettext("wesnoth-lib", "May get $coin coin and $score score, do you want to discard $name?", symbols);
	int res = gui2::show_message(disp_.video(), "", message, gui2::tmessage::yes_no_buttons);
	if (res == gui2::twindow::CANCEL) {
		return;
	}

	std::vector<std::pair<int, int> > m2;
	m2.push_back(std::make_pair(m.base->number_, m.level));
	http::membership member = http::exile(disp_, heros_, http::exile_tag_erase, m2, coin_income, score_income);
	if (member.uid < 0) {
		return;
	}
	group_.from_local_membership(disp_, heros_, member, false);

	fill_exile_table(window, list.get_selected_row());
	dirty_ = true;
}
Пример #4
0
addons_client::addons_client(display& disp, const std::string& address)
	: disp_(disp)
	, addr_(address)
	, host_()
	, port_()
	, conn_(NULL)
	, stat_(NULL)
	, last_error_()
{
	const std::vector<std::string>& address_components =
		utils::split(addr_, ':');

	if(address_components.empty()) {
		throw invalid_server_address();
	}

	// FIXME: this parsing will break IPv6 numeric addresses! */
	host_ = address_components[0];
	port_ = address_components.size() == 2 ?
		address_components[1] : str_cast(default_campaignd_port);

	LOG_ADDONS << "connecting to server " << host_ << " on port " << port_ << '\n';

	utils::string_map i18n_symbols;
	i18n_symbols["server_address"] = addr_;

	conn_ = new network_asio::connection(host_, port_);

	this->wait_for_transfer_done(
		vgettext("Connecting to $server_address|...", i18n_symbols));
}
Пример #5
0
t_string missing_widget(const std::string& id)
{
	utils::string_map symbols;
	symbols["id"] = id;

	return t_string(
			vgettext("Mandatory widget '$id' hasn't been defined.", symbols));
}
Пример #6
0
void turn_changed(const std::string & player_name)
{
	std::string id = "turn_changed";
	if (notif_pref(id)) {
		utils::string_map player;
		player["name"] = player_name;
		desktop::notifications::send(_("Turn changed"), vgettext("$name has taken control", player), desktop::notifications::TURN_CHANGED);
	}
}
/*WIKI
 * @page = GUIWidgetInstanceWML
 * @order = 1
 *
 * THIS PAGE IS AUTOMATICALLY GENERATED, DO NOT MODIFY DIRECTLY !!!
 *
 * = Widget instance =
 *
 * Inside a grid (which is inside all container widgets) a widget is
 * instantiated. With this instantiation some more variables of a widget can
 * be tuned. This page will describe what can be tuned.
 *
 */
twindow* build(CVideo& video, const std::string& type)
{
    std::vector<twindow_builder::tresolution>::const_iterator
    definition = get_window_builder(type);

    // We set the values from the definition since we can only determine the
    // best size (if needed) after all widgets have been placed.
    twindow* window = new twindow(video
                                  , definition->x
                                  , definition->y
                                  , definition->width
                                  , definition->height
                                  , definition->automatic_placement
                                  , definition->horizontal_placement
                                  , definition->vertical_placement
                                  , definition->maximum_width
                                  , definition->maximum_height
                                  , definition->definition);
    assert(window);
    window->set_id(type);

    foreach(const twindow_builder::tresolution::tlinked_group& lg,
            definition->linked_groups) {

        if(window->has_linked_size_group(lg.id)) {
            utils::string_map symbols;
            symbols["id"] = lg.id;
            t_string msg = vgettext(
                               "Linked '$id' group has multiple definitions."
                               , symbols);

            VALIDATE(false, msg);
        }

        window->init_linked_size_group(
            lg.id, lg.fixed_width, lg.fixed_height);
    }

    window->set_click_dismiss(definition->click_dismiss);

    boost::intrusive_ptr<const twindow_definition::tresolution> conf =
        boost::dynamic_pointer_cast<
        const twindow_definition::tresolution>(window->config());
    assert(conf);

    if(conf->grid) {
        window->init_grid(conf->grid);
        window->finalize(definition->grid);
    } else {
        window->init_grid(definition->grid);
    }

    window->add_to_keyboard_chain(window);

    return window;
}
Пример #8
0
bool addons_client::install_addon(config& archive_cfg, const addon_info& info)
{
	const cursor::setter cursor_setter(cursor::WAIT);

	utils::string_map i18n_symbols;
	i18n_symbols["addon_title"] = info.title;

	if(!check_names_legal(archive_cfg)) {
		gui2::show_error_message(disp_.video(),
			vgettext("The add-on <i>$addon_title</i> has an invalid file or directory "
				"name and cannot be installed.", i18n_symbols));
		return false;
	}

	// Add local version information before unpacking

	config* maindir = &archive_cfg.find_child("dir", "name", info.id);
	if(!*maindir) {
		LOG_ADDONS << "downloaded add-on '" << info.id << "' is missing its directory in the archive; creating it\n";
		maindir = &archive_cfg.add_child("dir");
		(*maindir)["name"] = info.id;
	}

	LOG_ADDONS << "generating version info for add-on '" << info.id << "'\n";

	std::ostringstream info_contents;
	config wml;

	info_contents <<
		"#\n"
		"# File automatically generated by Wesnoth to keep track\n"
		"# of version information on installed add-ons. DO NOT EDIT!\n"
		"#\n";

	info.write_minimal(wml.add_child("info"));
	write(info_contents, wml);

	config file;
	file["name"] = "_info.cfg";
	file["contents"] = info_contents.str();

	maindir->add_child("file", file);

	LOG_ADDONS << "unpacking " << info.id << '\n';

	// Remove any previously installed versions
	if(!remove_local_addon(info.id)) {
		WRN_ADDONS << "failed to uninstall previous version of " << info.id << "; the add-on may not work properly!\n";
	}

	unarchive_addon(archive_cfg);
	LOG_ADDONS << "unpacking finished\n";

	return true;
}
Пример #9
0
void texile::join(twindow& window)
{
	tlistbox& list = find_widget<tlistbox>(&window, "type_list", false);

	hero& h = heros_[selected_number_];
	int coin_income = 0, score_income = -1 * game_config::score_used_draw;
	
	const tgroup::tmember& m = group_.exile(h);

	std::stringstream strstr;
	utils::string_map symbols;

	if (sum_score(group_.coin(), group_.score()) < game_config::score_used_draw) {
		symbols["score"] = tintegrate::generate_format(game_config::score_used_draw, "red");
		symbols["do"] = tintegrate::generate_format(dsgettext("wesnoth-lib", "Join"), "yellow");
		std::string message = vgettext("wesnoth-lib", "Repertory is less than $score score, cannot $do.", symbols);
		gui2::show_message(disp_.video(), "", message);
		return;
	}
	symbols["score"] = tintegrate::generate_format(-1 * score_income, "red");
	symbols["do"] = tintegrate::generate_format(dsgettext("wesnoth-lib", "Join"), "yellow");
	strstr.str("");
	strstr << vgettext("wesnoth-lib", "Do you want to spend $score score to $do?", symbols) << "\n\n";
	symbols["name"] = tintegrate::generate_format(h.name(), "green");
	symbols["location"] = tintegrate::generate_format(dsgettext("wesnoth-lib", "member^Fix"), "yellow");
	strstr << vgettext("wesnoth-lib", "$name will put into $location.", symbols);
	int res = gui2::show_message(disp_.video(), "", strstr.str(), gui2::tmessage::yes_no_buttons);
	if (res == gui2::twindow::CANCEL) {
		return;
	}

	std::vector<std::pair<int, int> > m2;
	m2.push_back(std::make_pair(m.base->number_, m.level));
	http::membership member = http::exile(disp_, heros_, http::exile_tag_join, m2, coin_income, score_income);
	if (member.uid < 0) {
		return;
	}
	group_.from_local_membership(disp_, heros_, member, false);

	fill_exile_table(window, list.get_selected_row());
	dirty_ = true;
}
Пример #10
0
void tgame_load::evaluate_summary_string(std::stringstream& str
		, const config& cfg_summary){

	const std::string& campaign_type = cfg_summary["campaign_type"];
	if (cfg_summary["corrupt"].to_bool()) {
		str << "\n" << _("#(Invalid)");
	} else if (!campaign_type.empty()) {
		str << "\n";

		if(campaign_type == "scenario") {
			const std::string campaign_id = cfg_summary["campaign"];
			const config *campaign = NULL;
			if (!campaign_id.empty()) {
				if (const config &c = cache_config_.find_child(
						"campaign", "id", campaign_id))

					campaign = &c;
			}
			utils::string_map symbols;
			if (campaign != NULL) {
				symbols["campaign_name"] = (*campaign)["name"];
			} else {
				// Fallback to nontranslatable campaign id.
				symbols["campaign_name"] = "(" + campaign_id + ")";
			}
			str << vgettext("Campaign: $campaign_name", symbols);

			// Display internal id for debug purposes if we didn't above
			if (game_config::debug && (campaign != NULL)) {
				str << '\n' << "(" << campaign_id << ")";
			}
		} else if(campaign_type == "multiplayer") {
			str << _("Multiplayer");
		} else if(campaign_type == "tutorial") {
			str << _("Tutorial");
		} else {
			str << campaign_type;
		}

		str << "\n";

		if (cfg_summary["replay"].to_bool() && !cfg_summary["snapshot"].to_bool(true)) {
			str << _("replay");
		} else if (!cfg_summary["turn"].empty()) {
			str << _("Turn") << " " << cfg_summary["turn"];
		} else {
			str << _("Scenario Start");
		}

		if(!cfg_summary["version"].empty()) {
			str << "\n" << _("Version: ") << cfg_summary["version"];
		}
	}
}
Пример #11
0
void tlobby_main::update_gamelist_header()
{
#ifndef GUI2_EXPERIMENTAL_LISTBOX
	const std::string games_string = vgettext("Games: showing $num_shown out of $num_total", {
		{"num_shown", std::to_string(lobby_info_.games_filtered().size())},
		{"num_total", std::to_string(lobby_info_.games().size())}
	});

	find_widget<tlabel>(gamelistbox_, "map", false).set_label(games_string);
#endif
}
Пример #12
0
tmp_depcheck_confirm_change::tmp_depcheck_confirm_change
			(bool action,
			 const std::vector<std::string>& mods,
			 const std::string&	requester)
{
	utils::string_map symbols;
	symbols["requester"] = requester;
	std::string message;
	if (action) {
		message = vgettext("$requester requires the following modifications to be enabled:", symbols);
	} else {
		message = vgettext("$requester requires the following modifications to be disabled:", symbols);
	}

	std::string list = "\t";
	list += utils::join(mods, "\n\t");

	register_label("message", false, message);

	register_label("itemlist", false, list);
}
Пример #13
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);
}
Пример #14
0
/**
* Change the log level of a log domain.
*
* @param data string of the form: "@<level@> @<domain@>"
*/
void chat_handler::change_logging(const std::string& data) {
	const std::string::const_iterator j =
		std::find(data.begin(), data.end(), ' ');
	if (j == data.end()) return;
	const std::string level(data.begin(), j);
	const std::string domain(j + 1, data.end());
	int severity;
	if (level == "error") severity = lg::err().get_severity();
	else if (level == "warning") severity = lg::warn().get_severity();
	else if (level == "info") severity = lg::info().get_severity();
	else if (level == "debug") severity = lg::debug().get_severity();
	else {
		utils::string_map symbols;
		symbols["level"] = level;
		const std::string& msg =
			vgettext("Unknown debug level: '$level'.", symbols);
		ERR_NG << msg << std::endl;
		add_chat_message(time(nullptr), _("error"), 0, msg);
		return;
	}
	if (!lg::set_log_domain_severity(domain, severity)) {
		utils::string_map symbols;
		symbols["domain"] = domain;
		const std::string& msg =
			vgettext("Unknown debug domain: '$domain'.", symbols);
		ERR_NG << msg << std::endl;
		add_chat_message(time(nullptr), _("error"), 0, msg);
		return;
	}
	else {
		utils::string_map symbols;
		symbols["level"] = level;
		symbols["domain"] = domain;
		const std::string& msg =
			vgettext("Switched domain: '$domain' to level: '$level'.", symbols);
		LOG_NG << msg << "\n";
		add_chat_message(time(nullptr), "log", 0, msg);
	}
}
void create_engine::prepare_for_saved_game()
{
	DBG_MP << "preparing mp_game_settings for saved game\n";

	resources::config_manager->load_game_config_for_game(state_.classification());
	//The save migh be a start-of-scenario save so make sure we have the scenario data loaded.
	state_.expand_scenario();
	state_.mp_settings().saved_game = true;

	utils::string_map i18n_symbols;
	i18n_symbols["login"] = preferences::login();
	state_.mp_settings().name = vgettext("$login|’s game", i18n_symbols);
}
Пример #16
0
/*WIKI
 * @page = GUIWidgetInstanceWML
 * @order = 1
 *
 * {{Autogenerated}}
 *
 * = Widget instance =
 *
 * Inside a grid (which is inside all container widgets) a widget is
 * instantiated. With this instantiation some more variables of a widget can
 * be tuned. This page will describe what can be tuned.
 *
 */
twindow* build(CVideo& video, const twindow_builder::tresolution* definition)
{
	// We set the values from the definition since we can only determine the
	// best size (if needed) after all widgets have been placed.
	twindow* window = new twindow(video,
								  definition->x,
								  definition->y,
								  definition->width,
								  definition->height,
								  definition->reevaluate_best_size,
								  definition->functions,
								  definition->automatic_placement,
								  definition->horizontal_placement,
								  definition->vertical_placement,
								  definition->maximum_width,
								  definition->maximum_height,
								  definition->definition,
								  definition->tooltip,
								  definition->helptip);
	assert(window);

	for(const auto & lg : definition->linked_groups)
	{

		if(window->has_linked_size_group(lg.id)) {
			t_string msg = vgettext("Linked '$id' group has multiple definitions.", {{"id", lg.id}});

			FAIL(msg);
		}

		window->init_linked_size_group(lg.id, lg.fixed_width, lg.fixed_height);
	}

	window->set_click_dismiss(definition->click_dismiss);

	std::shared_ptr<const twindow_definition::tresolution>
	conf = std::static_pointer_cast<const twindow_definition::tresolution>(
			window->config());
	assert(conf);

	if(conf->grid) {
		window->init_grid(conf->grid);
		window->finalize(definition->grid);
	} else {
		window->init_grid(definition->grid);
	}

	window->add_to_keyboard_chain(window);

	return window;
}
Пример #17
0
bool addons_client::upload_addon(const std::string& id, std::string& response_message)
{
	LOG_ADDONS << "preparing to upload " << id << '\n';

	response_message.clear();

	config cfg;
	get_addon_pbl_info(id, cfg);

	utils::string_map i18n_symbols;
	i18n_symbols["addon_title"] = cfg["title"];
	if(i18n_symbols["addon_title"].empty()) {
		i18n_symbols["addon_title"] = make_addon_title(id);
	}

	std::string passphrase = cfg["passphrase"];
	// generate a random passphrase and write it to disk
	// if the .pbl file doesn't provide one already
	if(passphrase.empty()) {
		passphrase.resize(8);
		for(size_t n = 0; n != 8; ++n) {
			passphrase[n] = 'a' + (rand()%26);
		}
		cfg["passphrase"] = passphrase;
		set_addon_pbl_info(id, cfg);

		LOG_ADDONS << "automatically generated an initial passphrase for " << id << '\n';
	}

	cfg["name"] = id;

	config addon_data;
	archive_addon(id, addon_data);

	config request_buf, response_buf;
	request_buf.add_child("upload", cfg).add_child("data", addon_data);

	LOG_ADDONS << "sending " << id << '\n';

	this->send_request(request_buf, response_buf);
	this->wait_for_transfer_done(vgettext("Sending add-on <i>$addon_title</i>...", i18n_symbols
	));

	if(const config& message_cfg = response_buf.child("message")) {
		response_message = message_cfg["message"].str();
		LOG_ADDONS << "server response: " << response_message << '\n';
	}

	return !this->update_last_error(response_buf);

}
Пример #18
0
std::string deprecate_wml_key_warning(
		  const std::string& key
		, const std::string& removal_version)
{
	assert(!key.empty());
	assert(!removal_version.empty());

	utils::string_map symbols;
	symbols["key"] = key;
	symbols["removal_version"] = removal_version;

	return vgettext("The key '$key' is deprecated and support "
			"will be removed in version $removal_version.", symbols);
}
Пример #19
0
void playsingle_controller::hotkey_handler::whiteboard_toggle() {
	whiteboard_manager_->set_active(!whiteboard_manager_->is_active());

	if (whiteboard_manager_->is_active()) {
		std::string hk = hotkey::get_names(hotkey::hotkey_command::get_command_by_command(hotkey::HOTKEY_WB_TOGGLE).command);
		utils::string_map symbols;
		symbols["hotkey"] = hk;

		gui()->announce(_("Planning mode activated!") + std::string("\n") + vgettext("(press $hotkey to deactivate)", symbols), font::NORMAL_COLOR);
	} else {
		gui()->announce(_("Planning mode deactivated!"), font::NORMAL_COLOR);
	}
	//@todo Stop printing whiteboard help in the chat once we have better documentation/help
	whiteboard_manager_->print_help_once();
}
Пример #20
0
void gamemap::set_usage(const std::string& usage)
{
	utils::string_map symbols;
	symbols["border_size_key"] = "border_size";
	symbols["usage_key"] = "usage";
	symbols["usage_val"] = usage;
	const std::string msg = "'$border_size_key|' should be "
		"'$border_size_val|' when '$usage_key| = $usage_val|'";

	if(usage == "map") {
		usage_ = IS_MAP;
		symbols["border_size_val"] = "1";
		VALIDATE(border_size_ == 1, vgettext(msg.c_str(), symbols));
	} else if(usage == "mask") {
		usage_ = IS_MASK;
		symbols["border_size_val"] = "0";
		VALIDATE(border_size_ == 0, vgettext(msg.c_str(), symbols));
	} else if(usage == "") {
		throw incorrect_map_format_error("Map has a header but no usage");
	} else {
		std::string msg = "Map has a header but an unknown usage:" + usage;
		throw incorrect_map_format_error(msg);
	}
}
Пример #21
0
void play_controller::hotkey_handler::toggle_accelerated_speed()
{
	preferences::set_turbo(!preferences::turbo());

	if (preferences::turbo())
	{
		utils::string_map symbols;
		symbols["hk"] = hotkey::get_names(hotkey::hotkey_command::get_command_by_command(hotkey::HOTKEY_ACCELERATED).command);
		gui()->announce(std::string(_("Accelerated speed enabled!")) + "\n" + vgettext("(press $hk to disable)", symbols), font::NORMAL_COLOR);
	}
	else
	{
		gui()->announce(_("Accelerated speed disabled!"), font::NORMAL_COLOR);
	}
}
Пример #22
0
bool addons_client::download_addon(config& archive_cfg, const std::string& id, const std::string& title)
{
	archive_cfg.clear();

	config request_buf;
	request_buf.add_child("request_campaign")["name"] = id;

	utils::string_map i18n_symbols;
	i18n_symbols["addon_title"] = title;

	LOG_ADDONS << "downloading " << id << '\n';

	this->send_request(request_buf, archive_cfg);
	this->wait_for_transfer_done(vgettext("Downloading add-on <i>$addon_title</i>...", i18n_symbols));

	return !this->update_last_error(archive_cfg);
}
Пример #23
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";
		}
	}
}
Пример #24
0
void texile::pre_show(CVideo& /*video*/, twindow& window)
{
	std::stringstream strstr;

	utils::string_map symbols;
	tlabel* label = find_widget<tlabel>(&window, "remark", false, true);
	symbols["count"] = tintegrate::generate_format(game_config::max_exile, "yellow");
	strstr.str("");
	strstr << tintegrate::generate_format(dsgettext("wesnoth-lib", "PS"), "green") << " ";
	strstr << vgettext("wesnoth-lib", "There are at most $count exiled hero. Half heros will be on stage in Siege mode.", symbols);
	label->set_label(strstr.str());

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "join", false)
		, boost::bind(
		&texile::join
		, this
		, boost::ref(window)));
	strstr.str("");
	strstr << tintegrate::generate_format(_("Join"), "blue");
	find_widget<tbutton>(&window, "join", false).set_label(strstr.str());
	
	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "discard", false)
		, boost::bind(
		&texile::discard
		, this
		, boost::ref(window)));
	strstr.str("");
	strstr << tintegrate::generate_format(_("Discard"), "blue");
	find_widget<tbutton>(&window, "discard", false).set_label(strstr.str());

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "detail", false)
		, boost::bind(
		&texile::detail
		, this
		, boost::ref(window)));

	tlistbox* list = find_widget<tlistbox>(&window, "type_list", false, true);
	fill_exile_table(window, 0);
	list->set_callback_value_change(dialog_callback<texile, &texile::type_selected>);
}
Пример #25
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";
	}
}
Пример #26
0
std::string deprecated_renamed_wml_key_warning(
		  const std::string& deprecated_key
		, const std::string& key
		, const std::string& removal_version)
{
	assert(!deprecated_key.empty());
	assert(!key.empty());
	assert(!removal_version.empty());

	utils::string_map symbols;
	symbols["deprecated_key"] = deprecated_key;
	symbols["key"] = key;
	symbols["removal_version"] = removal_version;

	return vgettext(
			  "The key '$deprecated_key' has been renamed to '$key'. "
				"Support for '$deprecated_key' will be removed in version "
				"$removal_version."
			, symbols);
}
Пример #27
0
	void show_sides_list()
	{
		DBG_GUI << "Sides list: filling\n";
		model_.clear_sides();
		int sides = resources::teams
							? static_cast<int>((*resources::teams).size())
							: 0;
		for(int side = 1; side <= sides; ++side) {
			if(!resources::teams->at(side - 1).hidden()) {
				string_map symbols;
				symbols["side"] = std::to_string(side);
				std::string side_str = vgettext("Side $side", symbols);
				side_str = font::span_color(team::get_side_color(side))
						   + side_str + "</span>";
				model_.add_side(side, side_str);
				side_controllers_.push_back(boost::shared_ptr<side_controller>(
						new side_controller(side_str, model_, side)));
			}
		}
	}
Пример #28
0
void ttreasure::down(twindow& window)
{
	std::vector<size_t>& holded_treasures = current_team_.holded_treasures();
	hero& h = heros_[human_pairs_[human_index_].first];

	if (!can_up_treasure(units_, h)) {
		utils::string_map symbols;
		symbols["treasure"] = tintegrate::generate_format(unit_types.treasure(h.treasure_).name(), "green");
		symbols["hero"] = tintegrate::generate_format(h.name(), "yellow");
		std::string message = vgettext("wesnoth-lib", "Duration this time, if remove $treasure from $hero, cannot assemble treasure to $hero again. Do you want to remove?", symbols);
		int res = gui2::show_message(disp_.video(), "", message, gui2::tmessage::yes_no_buttons);
		if (res == gui2::twindow::CANCEL) {
			return;
		}
	}

	holded_treasures.push_back(h.treasure_);
	h.treasure_ = HEROS_NO_TREASURE;

	std::sort(holded_treasures.begin(), holded_treasures.end());
	set_internal(window);
}
Пример #29
0
void tgui_definition::load_definitions(
	const std::string &definition_type, const config &cfg, const char *key)
{
	foreach (const config &d, cfg.child_range(key ? key : definition_type + "_definition"))
	{
		T* def = new T(d);

		// We assume all definitions are unique if not we would leak memory.
		assert(control_definition[definition_type].find(def->id)
			== control_definition[definition_type].end());

		control_definition[definition_type].insert(std::make_pair(def->id, def));
	}

	utils::string_map symbols;
	symbols["definition"] = definition_type;
	symbols["id"] = "default";
	t_string msg(vgettext(
		"Widget definition '$definition' doesn't contain the definition for '$id'.",
		symbols));
	VALIDATE(control_definition[definition_type].find("default")
		!= control_definition[definition_type].end(), msg);
}
std::vector<linked_group_definition> parse_linked_group_definitions(const config& cfg)
{
	std::vector<linked_group_definition> definitions;

	for(const auto& lg : cfg.child_range("linked_group")) {
		definitions.emplace_back();
		linked_group_definition& linked_group = definitions.back();

		linked_group.id = lg["id"].str();
		linked_group.fixed_width = lg["fixed_width"].to_bool();
		linked_group.fixed_height = lg["fixed_height"].to_bool();

		VALIDATE(!linked_group.id.empty(), missing_mandatory_wml_key("linked_group", "id"));

		if(!linked_group.fixed_width && !linked_group.fixed_height) {
			const t_string msg = vgettext(
				"Linked group '$id' needs a 'fixed_width' or 'fixed_height' key.", {{"id", linked_group.id}});

			FAIL(msg);
		}
	}

	return definitions;
}