Esempio n. 1
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;
}
Esempio n. 2
0
void tgame_load::xmit_button_callback(twindow& window)
{
	const size_t index = size_t(savegame_list_->get_selected_row());
	if (current_page_ == LOCAL_PAGE) {
		if (index < games_.size()) {
			// See if we should ask the user for deletion confirmation
			std::string message = dsgettext("wesnoth", "You can upload one only, it will delete existed, continue?");
			const int res = gui2::show_message(disp_.video(), dsgettext("wesnoth", "Confirm"), message, gui2::tmessage::yes_no_buttons);
			if (res == gui2::twindow::CANCEL) {
				return;
			}
			http::upload_save(disp_, get_saves_dir() + "/" + games_[index].name);
		}
	} else if (current_page_ == NETWORK_PAGE) {
		if (index < www_saves_.size()) {

			std::string fname = http::download_save(disp_, www_saves_[index].sid);
			if (!fname.empty()) {
				sheet_.find(LOCAL_PAGE)->second->set_value(true);
				sheet_toggled(sheet_.find(LOCAL_PAGE)->second);
			}
		}
	}
}
Esempio n. 3
0
void texile::refresh_title_flag(twindow& window) const
{
	std::stringstream strstr;
	
	tlabel* label = find_widget<tlabel>(&window, "title", false, true);
	strstr.str("");
	strstr << dsgettext("wesnoth-lib", "Exile");
	label->set_label(strstr.str());

	label = find_widget<tlabel>(&window, "flag", false, true);
	strstr.str("");
	strstr << "(" << tintegrate::generate_img("misc/coin.png~SCALE(24, 24)") << group_.coin();
	strstr << "  " << tintegrate::generate_img("misc/score.png~SCALE(24, 24)") << group_.score();
	// end
	strstr << ")";
	label->set_label(strstr.str());
}
Esempio n. 4
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>);
}
Esempio n. 5
0
const std::string& t_string_base::str() const
{
	if(!translatable_)
		return value_;

	if (translatable_ && !translated_value_.empty() && translation_timestamp_ == language_counter)
		return translated_value_;

	translated_value_.clear();

	for(walker w(*this); !w.eos(); w.next()) {
		std::string part(w.begin(), w.end());

		if(w.translatable()) {
			translated_value_ += dsgettext(w.textdomain().c_str(), part.c_str());
		} else {
			translated_value_ += part;
		}
	}

	translation_timestamp_ = language_counter;
	return translated_value_;
}
Esempio n. 6
0
void trpg_detail::rpg_2_ui(twindow& window)
{
	int value;
	std::stringstream str;
	const team& current_team = teams_[rpg::h->side_];
	bool in_troop = !units_.find_unit(*rpg::h)->is_artifical();

	// refresh to gui
	tlabel* label = find_widget<tlabel>(&window, "tip_name", false, true);
	str << _("Hero") << ": " << rpg::h->name();
	label->set_label(str.str());

	str.str("");
	label = find_widget<tlabel>(&window, "tip_loyalty", false, true);
	int loyalty = rpg::h->loyalty(*teams_[rpg::h->side_].leader());
	str << _("Loyalty") << ": " << loyalty;
	label->set_label(str.str());

	// stratum
	str.str("");
	label = find_widget<tlabel>(&window, "tip_stratum", false, true);
	str << _("Stratum") << ": " << hero::stratum_str(rpg::stratum);
	label->set_label(str.str());

	// official
	str.str("");
	label = find_widget<tlabel>(&window, "tip_official", false, true);
	str << dsgettext("wesnoth-hero", "official") << ": " << hero::official_str(rpg::h->official_);
	label->set_label(str.str());

	// ownership
	str.str("");
	str << _("Ownership") << ": ";
	str << units_.city_from_cityno(rpg::h->city_)->name();
	label = find_widget<tlabel>(&window, "tip_ownership", false, true);
	label->set_label(str.str());

	// meritorious
	str.str("");
	value = rpg::h->meritorious_;
	str << dsgettext("wesnoth-hero", "meritorious") << ": " << value;
	label = find_widget<tlabel>(&window, "tip_meritorious", false, true);
	label->set_label(str.str());
	str.str("");
	if (rpg::stratum == hero_stratum_citizen) {
		utils::string_map symbols;
		std::string message;
		int statement_type = -1;
		if (!rpg::h->meritorious_ && !in_troop) {
			str << _("Wait, leader will order you to recruit");
		} else if (rpg::h->meritorious_ < 1000) {
			symbols["meritorious"] = "1000";
			statement_type = 0;
		} else if (rpg::h->meritorious_ < 2500) {
			symbols["meritorious"] = "2500";
			statement_type = 0;
		} else if (rpg::h->meritorious_ < 5000) {
			symbols["meritorious"] = "5000";
			statement_type = 0;
		} else if (rpg::h->meritorious_ < 8000) {
			symbols["meritorious"] = "8000";
			statement_type = 1;
		} else {
			str << _("Get mroe meritorious, will be appointed mayor");
		}
		if (statement_type == 0) {
			str << vgettext2("To $meritorious, will control more troops", symbols);
		} else if (statement_type == 1) {
			str << vgettext2("To $meritorious, will be appointed mayor", symbols);
		}
	} else if (rpg::stratum == hero_stratum_mayor) {
		if (current_team.holden_cities().size() < 2) {
			str << _("Capture more city, can be independent");
		} else {
			str << _("Be independent will be to leader");
		}
	}
	if (str.str().empty()) {
		str << _("---");
	}
	label = find_widget<tlabel>(&window, "tip_meritorious2", false, true);
	label->set_label(str.str());

	// leadership
	label = find_widget<tlabel>(&window, "tip_leadership", false, true);
	label->set_label(lexical_cast<std::string>(fxptoi9(rpg::h->leadership_)));

	// force
	label = find_widget<tlabel>(&window, "tip_force", false, true);
	label->set_label(lexical_cast<std::string>(fxptoi9(rpg::h->force_)));

	// intellect
	label = find_widget<tlabel>(&window, "tip_intellect", false, true);
	label->set_label(lexical_cast<std::string>(fxptoi9(rpg::h->intellect_)));

	// spirit
	label = find_widget<tlabel>(&window, "tip_spirit", false, true);
	label->set_label(lexical_cast<std::string>(fxptoi9(rpg::h->spirit_)));

	// charm
	label = find_widget<tlabel>(&window, "tip_charm", false, true);
	label->set_label(lexical_cast<std::string>(fxptoi9(rpg::h->charm_)));
}
Esempio n. 7
0
void tcore::update_to_ui_formation(HWND hdlgP)
{
	char text[_MAX_PATH];
	std::stringstream strstr;

	HWND hctl = GetDlgItem(hdlgP, IDC_TV_FORMATION_EXPLORER);

	// 1. clear treeview
	TreeView_DeleteAllItems(hctl);

	// 2. fill content
	htvroot_formation_ = TreeView_AddLeaf(hctl, TVI_ROOT);
	strstr.str("");
	strstr << dgettext_2_ansi("kingdom-lib", "tactical^Formation");
	strcpy(text, strstr.str().c_str());
	// must set TVIF_CHILDREN
	TreeView_SetItem1(hctl, htvroot_formation_, TVIF_TEXT | TVIF_PARAM | TVIF_CHILDREN, 0, 0, 0, 
		1, text);

	HTREEITEM htvi_formation, htvi_branch, htvi;
	utils::string_map symbols;

	const std::map<int, tformation_profile>& formations = unit_types.formations();
	for (std::map<int, tformation_profile>::const_iterator it = formations.begin(); it != formations.end(); ++ it) {
		const tformation_profile& f = it->second;

		htvi_formation = TreeView_AddLeaf(hctl, htvroot_formation_);
		LPARAM lParam = f.index();
		strstr.str("");
		strstr << std::setw(2) << std::setfill('0') << f.index() << ": " << utf8_2_ansi(f.name().c_str()) << "(" << f.id() << ")";
		strstr << utf8_2_ansi(_("Description")) << ": ";
		strstr << utf8_2_ansi(f.description().c_str());
		strcpy(text, strstr.str().c_str());
		TreeView_SetItem2(hctl, htvi_formation, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_CHILDREN, lParam, gdmgr._iico_dir, gdmgr._iico_dir, 1, text);

		// arms requrie
		htvi = TreeView_AddLeaf(hctl, htvi_formation);
		strstr.str("");
		strstr << _("Arms require");
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 1, text);

		htvi_branch = htvi;

		htvi = TreeView_AddLeaf(hctl, htvi_branch);
		strstr.str("");
		strstr << _("Type") << ": ";
		for (std::set<std::string>::const_iterator it2 = f.arms_type_.begin(); it2 != f.arms_type_.end(); ++ it2) {
			if (it2 != f.arms_type_.begin()) {
				strstr << ", ";
			}
			strstr << dsgettext("kingdom-lib", it2->c_str());
		}

		strstr << "     ";
		strstr << _("attack^Range") << ": " << dsgettext("kingdom-lib", unit_types.range_ids()[f.arms_range_].c_str());
		strstr << "(" << f.arms_range_id_ << ")";
		
		strstr << "     ";
		strstr << _("Quantity") << ": " << f.arms_count_;
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);

		TreeView_Expand(hctl, htvi_branch, TVE_EXPAND);

		if (f.attack_flag_) {
			bool first = true;
			htvi = TreeView_AddLeaf(hctl, htvi_formation);
			strstr.str("");
			strstr << _("Attack") << ": ";
			if (f.attack_flag_ & tformation_profile::SLOW) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "slowed");
			}
			if (f.attack_flag_ & tformation_profile::BREAK) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "broken");
			}
			if (f.attack_flag_ & tformation_profile::POISON) {
				if (!first) {
					strstr << ", ";
				} else {
					first = false;
				}
				strstr << dsgettext("kingdom-lib", "poisoned");
			}
			strcpy(text, utf8_2_ansi(strstr.str().c_str()));
			TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);
		}

		htvi = TreeView_AddLeaf(hctl, htvi_formation);
		strstr.str("");
		strstr << _("Icon") << "/" << _("Image") << ": ";
		strstr << f.icon() << "        " << f.bg_image();
		strcpy(text, utf8_2_ansi(strstr.str().c_str()));
		TreeView_SetItem2(hctl, htvi, TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN, 0, gdmgr._iico_txt, gdmgr._iico_txt, 0, text);

		TreeView_Expand(hctl, htvi_formation, TVE_EXPAND);
	}

	TreeView_Expand(hctl, htvroot_formation_, TVE_EXPAND);
}