Exemplo n.º 1
0
void tinapp_purchase::purchase_status(bool exit)
{
	twindow* window = purchase_->get_window();
	tlabel* status_anim_ = find_widget<tlabel>(window, "status-anim", false, true);

	if (!exit) {
        restore_->set_active(false);
		purchase_->set_active(false);

		std::stringstream ss;
		utils::string_map symbols;
		if (ing_item_ >= 0) {
			symbols["name"] = tintegrate::generate_format(items_[ing_item_].name, "blue");
			ss << vgettext2("Purchasing '$name'", symbols);
		} else {
			ss << vgettext2("Restoring purchased items", symbols);
		}
		status_->set_label(ss.str());
		window->invalidate_layout();

		config cfg;
		cfg["id"] = anim2::rfind(anim2::OPERATING);
		operating_anim_ = status_anim_->insert_animation(cfg, false);

	} else {
		status_anim_->erase_animation(operating_anim_);
        operating_anim_ = twidget::npos;

        restore_->set_active(true);
		purchase_->set_active(!items_[list_->get_selected_row()].purchased);

		ing_item_ = -1;
	}
}
Exemplo n.º 2
0
void tinapp_purchase::refresh_tip(twindow& window, const tinapp_item& item)
{
	std::stringstream strstr;
	utils::string_map symbols;

	strstr.str("");
	strstr << tintegrate::generate_format(_("Description"), "green") << "\n";
	strstr << item.description;
	strstr << "\n\n";
	strstr << tintegrate::generate_format(_("Notice"), "red") << "\n";
	if (item.index == game_config::transaction_type_vip) {
#if (defined(__APPLE__) && TARGET_OS_IPHONE)
#else
		if (preferences::vip2()) {
			int day = 30;
			if (preferences::vip_expire() >= time(NULL)) {
				day = (preferences::vip_expire() - time(NULL)) / (24 * 3600);
			}
			symbols["day"] = tintegrate::generate_format(day, "green");
			strstr << vgettext2("You is VIP currently, hold $day day still", symbols) << "\n";
		} else {
			strstr << _("You isn't VIP currently") << "\n";
		}
#endif
	} else {
		symbols["username"] = tintegrate::generate_format(_("You"));
		symbols["coin"] = tintegrate::generate_format(preferences::coin(), "yellow");
		symbols["score"] = tintegrate::generate_format(preferences::score(), "yellow");
		strstr << vgettext2("$username has $coin coin and $score score", symbols) << "\n";
	}
	tscroll_label* tip = find_widget<tscroll_label>(&window, "tip", false, true);
	tip->set_label(strstr.str());
}
Exemplo n.º 3
0
void tsignin::refresh_signin_information(twindow& window) const
{
	std::stringstream strstr;
	utils::string_map symbols;

	tscroll_label* label = find_widget<tscroll_label>(&window, "remark", false, true);
	symbols["continue"] = tintegrate::generate_format(group.signin().continue_days, "green");
	symbols["break"] = tintegrate::generate_format(group.signin().break_days, "red");
	symbols["have"] = group.signin().today? _("been^have"): _("been^haven't");
	strstr.str("");
	strstr << vgettext2("You have been sign in $continue days, broken $break days. Today $have sign in.", symbols);
	label->set_label(strstr.str());

	label = find_widget<tscroll_label>(&window, "fillup_remark", false, true);
	tbutton* button = find_widget<tbutton>(&window, "fillup", false, true);
	if (group.signin().break_days) {
		symbols.clear();
		symbols["ps"] = tintegrate::generate_format(_("PS"), "red");
		symbols["break"] = tintegrate::generate_format(group.signin().break_days, "red");
		symbols["max_break"] = tintegrate::generate_format(game_config::max_breaks, "yellow");
		symbols["fillup"] = tintegrate::generate_format(_("signin^Fill up"), "blue");

		strstr.str("");
		strstr << vgettext2("fill up sign in($ps, $break, $max_break, $fillup)", symbols);
		label->set_label(strstr.str());

		strstr.str("");
		strstr << tintegrate::generate_format(_("signin^Fill up"), "blue");
		button->set_label(strstr.str());
	} else {
		label->set_visible(twidget::INVISIBLE);
		button->set_visible(twidget::INVISIBLE);
	}
}
Exemplo n.º 4
0
void tsignin::fillup(twindow& window)
{
	if (!group.signin().break_days) {
		return;
	}

	utils::string_map symbols;
	std::stringstream err;
	int coin = 0;
	int score = 200;

	symbols["score"] = tintegrate::generate_format(score, "red");
	symbols["do"] = tintegrate::generate_format(_("signin^Fill up"), "yellow");
	std::string message = vgettext2("Do you want to spend $score score to $do?", symbols);
	int res = gui2::show_message(disp_.video(), "", message, gui2::tmessage::yes_no_buttons);
	if (res == gui2::twindow::CANCEL) {
		return;
	}

	if (sum_score(group.coin(), group.score()) < score) {
		symbols.clear();
		symbols["coin"] = tintegrate::generate_format(coin, "red");
		symbols["score"] = tintegrate::generate_format(score, "red");
		err << vgettext2("Repertory is not enough to pay $coin coin and $score score. If lack one only, can exchange between coin and score.", symbols);
		gui2::show_message(disp_.video(), "", err.str());
		return;
	}

	http::membership m = http::signin(disp_, heros_, http::signin_tag_fillup);
	if (m.uid >= 0) {
		group.from_local_membership(disp_, heros_, m, false);
		refresh_signin_information(window);
	}
}
Exemplo n.º 5
0
t_string missing_widget(const std::string& id)
{
	utils::string_map symbols;
	symbols["id"] = id;

	return t_string(vgettext2("Mandatory widget '$id' hasn't been defined.", symbols));
}
Exemplo n.º 6
0
void tinapp_purchase::pre_show(CVideo& /*video*/, twindow& window)
{
	std::stringstream strstr;
	if (browse_) {
		utils::string_map symbols;
		symbols["platforms"] = tintegrate::generate_format("iOS", "green");

		tlabel* label = find_widget<tlabel>(&window, "flag", false, true);
		strstr.str("");
		strstr << "(";
		strstr << vgettext2("Only $platforms support in-app purchase", symbols);
		strstr << ")";
		label->set_label(strstr.str());
	}

	restore_ = find_widget<tbutton>(&window, "restore", false, true);
	purchase_ = find_widget<tbutton>(&window, "purchase", false, true);
	status_ = find_widget<tlabel>(&window, "status", false, true);
	list_ = find_widget<tlistbox>(&window, "item_list", false, true);

	refresh_list(true);
	list_->set_callback_value_change(dialog_callback3<tinapp_purchase, tlistbox, &tinapp_purchase::item_selected>);

	// current no non-consumable in-purchase, don't use restore
	purchase_->set_active(!browse_);
	bool no_nonconsumable = true;
	for (std::vector<tinapp_item>::const_iterator it = items_.begin(); it != items_.end(); ++ it) {
		if (!it->consumable) {
			no_nonconsumable = false;
			break;
		}
	}
	if (no_nonconsumable) {
		restore_->set_visible(twidget::INVISIBLE);
	}

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "restore", false)
		, boost::bind(
			&tinapp_purchase::restore
			, this
			, boost::ref(window)));
	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "purchase", false)
		, boost::bind(
			&tinapp_purchase::purchase
			, this
			, boost::ref(window)));

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

	startShop();
}
Exemplo n.º 7
0
void fill_anims(const config& cfg)
{
	if (!instance) {
		// normally instance must not NULL. but now editor.exe, kingdomd.exe
		return;
	}

	fill_tags();
	instance->clear_anims();

	utils::string_map symbols;
	std::stringstream ss;

	std::set<int> constructed;

	symbols["child"] = tintegrate::generate_format("animation", "yellow");
	BOOST_FOREACH (const config &anim, cfg.child_range("animation")) {
		const std::string& app = anim["app"].str();

		if (!app.empty() && app != game_config::app) {
			continue;
		}

		const std::string& id = anim["id"].str();
		VALIDATE(!id.empty(), vgettext2("[$child] child, $child must has id attribute!", symbols));

		symbols["id"] = tintegrate::generate_format(id, "red");

		const config& sub = anim.child("anim");
		VALIDATE(sub, vgettext2("[$child] child, $child must has [anim] child!", symbols));

		bool area = sub["area_mode"].to_bool();
		bool tpl = !area && anim["template"].to_bool();

		int at = NONE;
		if (area || !tpl) {
			at = find(id);
			VALIDATE(at != NONE, vgettext2("[$child] child, WML defined $id, but cannot find corresponding code id!", symbols));
			VALIDATE(constructed.find(at) == constructed.end(), vgettext2("[$child] child, $id is defined repeatly!", symbols));
			constructed.insert(at);
		}

		instance->fill_anim(at, id, area, tpl, sub);
	}
}
Exemplo n.º 8
0
void tgame_load::evaluate_summary_string(std::stringstream& str, const config& cfg_summary) const
{

	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 << vgettext2("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"];
		}
	}
}
Exemplo n.º 9
0
void show_fail_tip(display& disp, const std::string& item)
{
	std::stringstream err;
	utils::string_map symbols;

	symbols["mail"] = tintegrate::generate_format(game_config::service_email, "green");
	symbols["date"] = tintegrate::generate_format(format_time_local2(time(NULL)), "yellow");
	symbols["item"] = tintegrate::generate_format(item, "yellow");
	symbols["username"] = tintegrate::generate_format(preferences::login(), "yellow");
	err << vgettext2("Update database fail when execute In-App Purchase! In order to compensate data you should get, please send In-App Purchase information to $mail. In-App Purchase information include: date($date), item($item), username($username).", symbols);
	gui2::show_message(disp.video(), "", err.str());
}
Exemplo n.º 10
0
void tsignin::pre_show(CVideo& /*video*/, twindow& window)
{
	window.set_canvas_variable("border", variant("default-border"));

	refresh_signin_information(window);

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

	strstr.str("");
	symbols["fillup"] = tintegrate::generate_format(_("signin^Fill up"), "blue");
	strstr << vgettext2("sign in remark($fillup)", symbols);
	tscroll_label* label = find_widget<tscroll_label>(&window, "signin_remark", false, true);
	label->set_label(strstr.str());

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "fillup", false)
		, boost::bind(
		&tsignin::fillup
		, this
		, boost::ref(window)));
}
Exemplo n.º 11
0
static bool save_if_dirty()
{
    if (integrate_get_save_btn()) {
        std::stringstream title, message;
        utils::string_map symbols;
        HWND hdlgP = gdmgr._hdlg_integrate;

        DLGHDR *pHdr = (DLGHDR *) GetWindowLong(hdlgP, GWL_USERDATA);

        symbols["campaign"] = "";
        title << utf8_2_ansi(_("Save"));
        message << utf8_2_ansi(vgettext2("Integrate is dirty, do you want to save modify?", symbols).c_str());
        int retval = MessageBox(hdlgP, message.str().c_str(), title.str().c_str(), MB_YESNO);
        if (retval == IDYES) {
            integrate.save(gdmgr._hdlg_integrate);
            return true;
        } else {
            integrate_enable_save_btn(FALSE);
            return false;
        }
    }
    return false;
}
Exemplo n.º 12
0
extern "C" void inapp_purchase_cb(const char* identifier, int complete)
{
	const std::string id = identifier;
	std::string short_id;
	bool restoring = std::string(identifier) == "@restore";
	int cursel = -1;

	if (!restoring) {
		size_t pos = id.rfind(".");
		if (pos != std::string::npos) {
			short_id = id.substr(pos + 1);
		} else {
			short_id = id;
		}
		for (std::map<int, std::string>::const_iterator it = game_config::inapp_items.begin(); it != game_config::inapp_items.end(); ++ it) {
			if (it->second == short_id) {
				cursel = it->first;
				break;
			}
		}
		if (cursel < 0) {
			return;
		}

		if (complete) {
			gui2::tinapp_purchase* dlg = gui2::tinapp_purchase::get_singleton();
			if (dlg) {
				gui2::tinapp_item& item = dlg->get_item(cursel);
				upload_inapp_2_data_server(cursel, dlg->disp(), dlg->heros(), item.name);
			}
		}
	}

	if (gui2::tinapp_purchase::get_singleton()) {
		gui2::tinapp_purchase& dlg = *gui2::tinapp_purchase::get_singleton();

		dlg.purchase_status(true);

		std::stringstream strstr;
		utils::string_map symbols;
		if (complete) {
			symbols["result"] = tintegrate::generate_format(_("Success"), "green");
		} else {
			symbols["result"] = tintegrate::generate_format(_("Failed"), "red");
		}

		if (!restoring) {
			gui2::tinapp_item& item = dlg.get_item(cursel);

			if (complete) {
				if (!item.consumable) {
					item.purchased = true;
				}
				dlg.refresh_list(false, true);
			}

			symbols["name"] = tintegrate::generate_format(item.name, "blue");
			strstr << vgettext2("Purchas '$name' $result|!", symbols);
		} else {
			strstr << vgettext2("Restore purchased items $result|!", symbols);
		}
		dlg.status().set_label(strstr.str());
        dlg.status().get_window()->invalidate_layout();
	}
}
Exemplo n.º 13
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_)));
}
Exemplo n.º 14
0
void tfinal_battle::pre_show(CVideo& /*video*/, twindow& window)
{
	window.set_canvas_variable("border", variant("default-border"));

	int side_num = current_team_.side();
	std::stringstream str;

	size_t cities = 0;
	for (size_t side = 0; side != teams_.size(); side ++) {
		std::vector<artifical*>& side_cities = teams_[side].holden_cities();
		cities += side_cities.size();
	}
	size_t again = cities / 3 + ((cities % 3)? 1: 0);
	if (again > current_team_.holden_cities().size()) {
		again -= current_team_.holden_cities().size();
	} else {
		again = 0;
	}

	tlabel* label = find_widget<tlabel>(&window, "tip", false, true);
	utils::string_map symbols;
	str << again;
	symbols["count"] = str.str();
	str.str("");
	str << tintegrate::generate_format(vgettext2("If capture $count cities again, all AI will ally.", symbols), "red");
	label->set_label(str.str());

	tlistbox* list = find_widget<tlistbox>(&window, "city_list", false, true);

	int index = 0;
	for (unit_map::iterator it2 = units_.begin(); it2 != units_.end(); ++ it2) {
		unit* it = dynamic_cast<unit*>(&*it2);
		if (!it->is_city() || it->side() != side_num) {
			continue;
		}
		artifical& city = *unit_2_artifical(&*it);
		/*** Add list item ***/
		string_map list_item;
		std::map<std::string, string_map> list_item_item;

		list_item["label"] = city.absolute_image();
		list_item_item.insert(std::make_pair("icon", list_item));

		list_item["label"] = city.name();
		list_item_item.insert(std::make_pair("name", list_item));

		// hp
		str.str("");
		str << city.hitpoints() << "/\n" << city.max_hitpoints();
		list_item["label"] = str.str();
		list_item_item.insert(std::make_pair("hp", list_item));

		// xp
		str.str("");
		str << city.experience() << "/\n";
		if (it->can_advance()) {
			str << city.max_experience();
		} else {
			str << "-";
		}
		list_item["label"] = str.str();
		list_item_item.insert(std::make_pair("xp", list_item));

		str.str("");
		str << city.finish_heros().size() + city.fresh_heros().size();
		list_item["label"] = str.str();
		list_item_item.insert(std::make_pair("reside_hero", list_item));

		list->add_row(list_item_item);

		candidate_cities_.push_back(&city);
	}

	list->set_callback_value_change(dialog_callback3<tfinal_battle, tlistbox, &tfinal_battle::type_selected>);

	tbutton* ok = find_widget<tbutton>(&window, "ok", false, true);
	if (rpg::stratum != hero_stratum_leader) {
		ok->set_visible(twidget::INVISIBLE);
	}
}