示例#1
0
	explicit tcampaign_selection(ng::create_engine& eng) :
		engine_(eng),
		choice_(-1),
		deterministic_(false)
	{
		set_restore(true);
	}
示例#2
0
taddon_connect::taddon_connect(std::string& host_name,
							   const bool allow_remove)
	: allow_remove_(allow_remove)
{
	set_restore(true);
	register_text("host_name", false, host_name, true);
}
示例#3
0
tgame_save::tgame_save(std::string& filename, const std::string& title)
{
	set_restore(true);

	register_text("txtFilename", false, filename, true);
	register_label("lblTitle", true, title);
}
示例#4
0
tmp_connect::tmp_connect()
	: host_name_(register_text("host_name",
							   true,
							   preferences::network_host,
							   preferences::set_network_host,
							   true))
{
	set_restore(true);
}
示例#5
0
tcampaign_difficulty::tcampaign_difficulty(const config& campaign)
	: difficulties_()
	, campaign_id_(campaign["id"])
	, selected_difficulty_()
{
	set_restore(true);

	difficulties_ = generate_difficulty_config(campaign);
}
tnetwork_transmission::tnetwork_transmission(
		connection_data& connection,
		const std::string& title,
		const std::string& subtitle)
	: connection_(&connection)
	, pump_monitor_(connection_)
	, subtitle_(subtitle)
{
	register_label("title", true, title, false);
	set_restore(true);
}
示例#7
0
/**
 * @todo This function enables the wml markup for all items, but the interface
 * is a bit hacky. Especially the fiddling in the internals of the listbox is
 * ugly. There needs to be a clean interface to set whether a widget has a
 * markup and what kind of markup. These fixes will be post 1.6.
 */
void twml_message_::pre_show(twindow& window)
{
	set_restore(true);

	window.canvas(1).set_variable("portrait_image", variant(portrait_));
	window.canvas(1).set_variable("portrait_mirror", variant(mirror_));

	// Set the markup
	tlabel& title = find_widget<tlabel>(&window, "title", false);
	title.set_label(title_);
	title.set_use_markup(true);
	title.set_can_wrap(true);

	tcontrol& message = find_widget<tcontrol>(&window, "message", false);
	message.set_label(message_);
	message.set_use_markup(true);
	// The message label might not always be a scroll_label but the capturing
	// shouldn't hurt.
	window.keyboard_capture(&message);

	// Find the input box related fields.
	tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
	ttext_box& input = find_widget<ttext_box>(&window, "input", true);

	if(has_input_) {
		caption.set_label(input_caption_);
		caption.set_use_markup(true);
		input.set_value(*input_text_);
		input.set_maximum_length(input_maximum_length_);
		window.keyboard_capture(&input);
		window.set_click_dismiss(false);
		window.set_escape_disabled(true);
	} else {
		caption.set_visible(twidget::tvisible::invisible);
		input.set_visible(twidget::tvisible::invisible);
	}

	// Find the option list related fields.
	tlistbox& options = find_widget<tlistbox>(&window, "input_list", true);

	if(!option_list_.empty()) {
		std::map<std::string, string_map> data;
		BOOST_FOREACH(const twml_message_option& item, option_list_) {
			// Add the data.
			data["icon"]["label"] = item.image();
			data["label"]["label"] = item.label();
			data["label"]["use_markup"] = "true";
			data["description"]["label"] = item.description();
			data["description"]["use_markup"] = "true";
			options.add_row(data);
		}
示例#8
0
void ttitle_screen::pre_show(CVideo& video, twindow& window)
{
	set_restore(false);
	window.set_click_dismiss(false);
	window.set_enter_disabled(true);
	window.set_escape_disabled(true);

#ifdef DEBUG_TOOLTIP
	window.connect_signal<event::SDL_MOUSE_MOTION>(
			boost::bind(debug_tooltip, boost::ref(window), _3, _5),
			event::tdispatcher::front_child);
#endif

	/**** Set the version number ****/
	if(tcontrol* control
	   = find_widget<tcontrol>(&window, "revision_number", false, false)) {

		control->set_label(_("Version ") + game_config::revision);
	}
	window.canvas()[0].set_variable(
			"revision_number",
			variant(_("Version") + std::string(" ") + game_config::revision));

	/**** Set the tip of the day ****/
	tmulti_page& tip_pages = find_widget<tmulti_page>(&window, "tips", false);

	std::vector<ttip> tips(settings::get_tips());
	if(tips.empty()) {
		WRN_CF << "There are not tips of day available." << std::endl;
	}

	FOREACH(const AUTO & tip, tips)
	{

		string_map widget;
		std::map<std::string, string_map> page;

		widget["label"] = tip.text();
		widget["use_markup"] = "true";
		page["tip"] = widget;

		widget["label"] = tip.source();
		widget["use_markup"] = "true";
		page["source"] = widget;

		tip_pages.add_page(page);
	}
示例#9
0
void ttitle_screen::pre_show(CVideo& video, twindow& window)
{
	assert(!video_);
	video_ = &video;

	set_restore(false);
	window.set_click_dismiss(false);
	window.set_escape_disabled(true);

	window.canvas()[0].set_variable("revision_number",
		variant(_("Version") + std::string(" ") + game_config::revision));

	/**** Set the buttons ****/
//	find_widget<tbutton>(&window, "addons", false).
//			set_callback_mouse_left_click(show_dialog<gui2::taddon_connect>);

	// Note changing the language doesn't upate the title screen...
	find_widget<tbutton>(&window, "language", false).
			set_callback_mouse_left_click(
				show_dialog<gui2::tlanguage_selection>);

	/**** Set the tip of the day ****/
/*
	update_tip(window, true);

	find_widget<tbutton>(&window, "next_tip", false).
			set_callback_mouse_left_click(next_tip);

	find_widget<tbutton>(&window, "previous_tip", false).
			set_callback_mouse_left_click(previous_tip);
*/

	/***** Select a random game_title *****/
	std::vector<std::string> game_title_list =
		utils::split(game_config::game_title
				, ','
				, utils::STRIP_SPACES | utils::REMOVE_EMPTY);

	if(game_title_list.empty()) {
		ERR_CF << "No title image defined\n";
	} else {
		window.canvas()[0].set_variable("background_image",
			variant(game_title_list[rand()%game_title_list.size()]));
	}
}
示例#10
0
void ttitle_screen::pre_show(CVideo& video, twindow& window)
{
	set_restore(false);
	window.set_click_dismiss(false);
	window.set_enter_disabled(true);
	window.set_escape_disabled(true);

	/**** Set the version number ****/
	if(tcontrol* control
			= find_widget<tcontrol>(&window, "revision_number", false, false)) {

		control->set_label(_("Version ") + game_config::revision);
	}
	window.canvas()[0].set_variable("revision_number",
		variant(_("Version") + std::string(" ") + game_config::revision));

	/**** Set the tip of the day ****/
	tmulti_page& tip_pages = find_widget<tmulti_page>(&window, "tips", false);

	std::vector<ttip> tips(settings::get_tips());
	if(tips.empty()) {
		WRN_CF << "There are not tips of day available.\n";
	}

	foreach(const ttip& tip, tips) {

		string_map widget;
		std::map<std::string, string_map> page;

		widget["label"] = tip.text();
		widget["use_markup"] = "true";
		page["tip"] = widget;

		widget["label"] = tip.source();
		widget["use_markup"] = "true";
		page["source"] = widget;

		tip_pages.add_page(page);
	}
示例#11
0
void ttitle_screen::pre_show(CVideo& video, twindow& window)
{
    window_ = &window;

    set_restore(false);
    window.set_click_dismiss(false);
    window.set_escape_disabled(true);

    std::stringstream strstr;
    std::string color = game_config::local_only? "red": "green";

    strstr.str("");
    tlabel* label = find_widget<tlabel>(&window, "coin", true, true);
    strstr << tintegrate::generate_format(group.coin(), color, 17);
    label->set_label(strstr.str());

    strstr.str("");
    label = find_widget<tlabel>(&window, "score", true, true);
    strstr << tintegrate::generate_format(group.score(), color, 17);
    label->set_label(strstr.str());

    strstr.str("");
    label = find_widget<tlabel>(&window, "signin_data", true, true);
    if (!game_config::local_only) {
        strstr << tintegrate::generate_format(group.signin().continue_days, "green", 17) << "/";
        if (!group.signin().break_days) {
            color = "green";
        } else if (group.signin().break_days < game_config::max_breaks) {
            color = "yellow";
        } else {
            color = "red";
        }
        strstr << tintegrate::generate_format(group.signin().break_days, color, 17);
    } else {
        strstr << tintegrate::generate_format("---/-", "white", 17);
    }
    label->set_label(strstr.str());

    tcontrol* control = find_widget<tcontrol>(&window, "icon_vip", true, true);
    if (!preferences::vip2()) {
        control->set_visible(twidget::INVISIBLE);
    }

    // Set the version number
    control = find_widget<tcontrol>(&window, "revision_number", false, false);
    if (control) {
        control->set_label(_("V") + game_config::version);
        // control->set_label(_("V") + game_config::version + "-alpha");
        // control->set_label(_("v") + game_config::version + "-beta");
        // control->set_label(_("v") + game_config::version + "-beta3");
    }
    window.canvas()[0].set_variable("revision_number", variant(_("Version") + std::string(" ") + game_config::version));

    if (!game_config::images::game_title.empty()) {
        window.canvas()[0].set_variable("background_image",	variant(game_config::images::game_title));
    }

    /***** Set the logo *****/
    tcontrol* logo = find_widget<tcontrol>(&window, "logo", false, false);
    if (logo) {
        logo->set_label(game_config::logo_png);
    }

    label = find_widget<tlabel>(&window, "player_name", false, true);
    label->set_label(player_hero_.name());

    tbutton* b;
    for (int item = 0; item < nb_items; item ++) {
        b = find_widget<tbutton>(&window, menu_items[item], false, false);
        if (!b) {
            continue;
        }
        std::string str;
        if (!strcmp(menu_items[item], "player")) {
            str = player_hero_.image(true);

        } else if (!strcmp(menu_items[item], "signin")) {
            if (group.signin().today) {
                str = std::string("icons/") + "signin-ok" + ".png";
            } else {
                str = std::string("icons/") + "signin" + ".png";
            }

        } else {
            if (!strcmp(menu_items[item], "message")) {
                if (group.message_count()) {
                    b->set_label("misc/red-dot12.png");
                }
            }
            str = std::string("icons/") + menu_items[item] + ".png";
        }

        for (int i = 0; i < 4; i ++) {
            b->canvas()[i].set_variable("image", variant(str));
        }
    }

    if (game_config::tiny_gui) {
        b = find_widget<tbutton>(&window, "design", false, false);
        if (b) {
            b->set_visible(twidget::INVISIBLE);
        }
        b = find_widget<tbutton>(&window, "editor", false, false);
        if (b) {
            b->set_visible(twidget::INVISIBLE);
        }

    } else if (!preferences::developer()) {
        b = find_widget<tbutton>(&window, "design", false, false);
        if (b) {
            b->set_visible(twidget::INVISIBLE);
        }
    }

#if defined(__APPLE__) && TARGET_OS_IPHONE
    b = find_widget<tbutton>(&window, "quit", false, false);
    if (b) {
        b->set_visible(twidget::INVISIBLE);
    }
#endif

    for (int item = 0; item < nb_items; item ++) {
        std::string id = menu_items[item];
        int retval = twindow::NONE;
        if (id == "editor") {
            retval = START_MAP_EDITOR;
        } else if (id == "quit") {
            retval = QUIT_GAME;
        } else if (id == "help") {
            retval = HELP;
        } else if (id == "campaign") {
            retval = NEW_CAMPAIGN;
        } else if (id == "player") {
            retval = PLAYER;
        } else if (id == "side") {
            retval = PLAYER_SIDE;
        } else if (id == "multiplayer") {
            retval = MULTIPLAYER;
        } else if (id == "load") {
            retval = LOAD_GAME;
        } else if (id == "report") {
            retval = REPORT;
        } else if (id == "language") {
            retval = CHANGE_LANGUAGE;
        } else if (id == "message") {
            retval = MESSAGE;
        } else if (id == "preferences") {
            retval = EDIT_PREFERENCES;
        } else if (id == "signin") {
            retval = SIGNIN;
        } else if (id == "design") {
            retval = DESIGN;
        } else if (id == "shop") {
            retval = INAPP_PURCHASE;
        }

        connect_signal_mouse_left_click(
            find_widget<tbutton>(&window, id, false)
            , boost::bind(
                &ttitle_screen::set_retval
                , this
                , boost::ref(window)
                , retval));
    }

    join();

    title_screen_anim_id_ = unit_display::start_title_screen_anim();
}
void ttitle_screen::pre_show(CVideo& video, twindow& window)
{
	set_restore(false);
	window.set_click_dismiss(false);
	window.set_enter_disabled(true);
	window.set_escape_disabled(true);

	/**** Set the version number ****/
	if (tcontrol* control
			= find_widget<tcontrol>(&window, "revision_number", false, false)) {

		control->set_label(_("Version ") + game_config::revision);
		// control->set_label(_("Version ") + game_config::revision + "-alpha");
		// control->set_label(_("Version ") + game_config::revision + "-beta");
	}
	window.canvas()[0].set_variable("revision_number", variant(_("Version") + std::string(" ") + game_config::revision));

	if (game_config::images::game_title.empty()) {
		
	} else {
		window.canvas()[0].set_variable("background_image",
			variant(game_config::images::game_title));
	}

	/***** Set the logo *****/
	tcontrol* logo = find_widget<tcontrol>(&window, "logo", false, false);
	if (logo) {
		logo->set_label("misc/logo.png");
	}

	std::string player_name;
	tbutton* b = find_widget<tbutton>(&window, "player", false, false);
	if (b) {
		for (int i = 0; i < 4; i ++) {
			player_name = player_hero_.image(true);
			b->canvas()[i].set_variable("image", variant(player_name));
		}
	}
	player_name = player_hero_.name();
	ttext_box* user_widget = find_widget<ttext_box>(&window, "player_name", false, true);
	user_widget->set_value(player_name);
	// user_widget->set_maximum_length(max_login_size);
	user_widget->set_active(false);

	for (int item = 0; item < nb_items; item ++) {
		tbutton* b = find_widget<tbutton>(&window, menu_items[item], false, false);
		if (!b) {
			continue;
		}
		std::string str = std::string("icons/") + menu_items[item] + ".png";
		int i;
		for (i = 0; i < 4; i ++) {
			b->canvas()[i].set_variable("image", variant(str));
		}
	}

	if (game_config::tiny_gui) {
		tbutton* b = find_widget<tbutton>(&window, "editor", false, false);
		if (b) {
			b->set_visible(twidget::INVISIBLE);
		}
		b = find_widget<tbutton>(&window, "help", false, false);
		if (b) {
			b->set_visible(twidget::INVISIBLE);
		}
		b = find_widget<tbutton>(&window, "credits", false, false);
		if (b) {
			b->set_visible(twidget::INVISIBLE);
		}
		b = find_widget<tbutton>(&window, "quit", false, false);
		if (b) {
			// b->set_visible(twidget::INVISIBLE);
		}
	}

#if defined(__APPLE__) && TARGET_OS_IPHONE
	b = find_widget<tbutton>(&window, "editor", false, false);
	if (b) {
		b->set_visible(twidget::INVISIBLE);
	}
	b = find_widget<tbutton>(&window, "help", false, false);
	if (b) {
		b->set_visible(twidget::INVISIBLE);
	}
	b = find_widget<tbutton>(&window, "quit", false, false);
	if (b) {
		b->set_visible(twidget::INVISIBLE);
	}
#endif
	b = find_widget<tbutton>(&window, "tutorial", false, false);
	if (b) {
		b->set_visible(twidget::INVISIBLE);
	}

	connect_signal_mouse_left_click(
		find_widget<tbutton>(&window, "player", false)
		, boost::bind(
		&ttitle_screen::player
			, this
			, boost::ref(window)));
}
示例#13
0
void ttitle_screen::pre_show(twindow& window)
{
	set_restore(false);
	window.set_click_dismiss(false);
	window.set_enter_disabled(true);
	window.set_escape_disabled(true);

#ifdef DEBUG_TOOLTIP
	window.connect_signal<event::SDL_MOUSE_MOTION>(
			std::bind(debug_tooltip, std::ref(window), _3, _5),
			event::tdispatcher::front_child);
#endif

	/**** Set the version number ****/
	if(tcontrol* control
	   = find_widget<tcontrol>(&window, "revision_number", false, false)) {

		control->set_label(_("Version ") + game_config::revision);
	}
	window.canvas()[0].set_variable(
			"revision_number",
			variant(_("Version") + std::string(" ") + game_config::revision));

	/**** Set the tip of the day ****/
	tmulti_page& tip_pages = find_widget<tmulti_page>(&window, "tips", false);

	std::vector<ttip> tips(settings::get_tips());
	if(tips.empty()) {
		WRN_CF << "There are not tips of day available." << std::endl;
	}

	for(const auto & tip : tips)
	{

		string_map widget;
		std::map<std::string, string_map> page;

		widget["label"] = tip.text();
		widget["use_markup"] = "true";
		page["tip"] = widget;

		widget["label"] = tip.source();
		widget["use_markup"] = "true";
		page["source"] = widget;

		tip_pages.add_page(page);
	}

	update_tip(window, true);

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "next_tip", false),
			std::bind(&ttitle_screen::update_tip,
						this,
						std::ref(window),
						true));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "previous_tip", false),
			std::bind(&ttitle_screen::update_tip,
						this,
						std::ref(window),
						false));

	if(game_config::images::game_title.empty()) {
		ERR_CF << "No title image defined" << std::endl;
	} else {
		window.canvas()[0].set_variable(
				"title_image", variant(game_config::images::game_title));
	}

	if(game_config::images::game_title_background.empty()) {
		ERR_CF << "No title background image defined" << std::endl;
	} else {
		window.canvas()[0].set_variable(
				"background_image",
				variant(game_config::images::game_title_background));
	}

	/***** Logo *****/
	find_widget<timage>(&window, "logo", false).set_image("misc/logo.png");

	/***** About dialog button *****/
	tbutton& about = find_widget<tbutton>(&window, "about", false);
	connect_signal_mouse_left_click(
			about,
			std::bind(&tgame_version::display, std::ref(window.video())));

	/***** Set the clock button. *****/
	tbutton& clock = find_widget<tbutton>(&window, "clock", false);
	clock.set_visible(show_debug_clock_button ? twidget::tvisible::visible
											  : twidget::tvisible::invisible);

	connect_signal_mouse_left_click(
			clock,
			std::bind(&ttitle_screen::show_debug_clock_window,
						this,
						std::ref(window.video())));
}
示例#14
0
/**
 * @todo This function enables the wml markup for all items, but the interface
 * is a bit hacky. Especially the fiddling in the internals of the listbox is
 * ugly. There needs to be a clean interface to set whether a widget has a
 * markup and what kind of markup. These fixes will be post 1.6.
 */
void twml_message_::pre_show(twindow& window)
{
	set_restore(true);

	window.canvas(1).set_variable("portrait_image", variant(portrait_));
	window.canvas(1).set_variable("portrait_mirror", variant(mirror_));

	// Set the markup
	tlabel& title = find_widget<tlabel>(&window, "title", false);
	title.set_label(title_);
	title.set_use_markup(true);
	title.set_can_wrap(true);

	tcontrol& message = find_widget<tcontrol>(&window, "message", false);
	message.set_label(message_);
	message.set_use_markup(true);
	// The message label might not always be a scroll_label but the capturing
	// shouldn't hurt.
	window.keyboard_capture(&message);

	// Find the input box related fields.
	tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
	ttext_box& input = find_widget<ttext_box>(&window, "input", true);

	if(has_input_) {
		caption.set_label(input_caption_);
		caption.set_use_markup(true);
		input.set_value(*input_text_);
		input.set_maximum_length(input_maximum_length_);
		window.keyboard_capture(&input);
		window.set_click_dismiss(false);
		window.set_escape_disabled(true);
	} else {
		caption.set_visible(twidget::tvisible::invisible);
		input.set_visible(twidget::tvisible::invisible);
	}

	// Find the option list related fields.
	tlistbox& options = find_widget<tlistbox>(&window, "input_list", true);

	if(!option_list_.empty()) {
		std::map<std::string, string_map> data;
		for(const twml_message_option& item : option_list_) {
			// Add the data.
			data["icon"]["label"] = item.image();
			data["label"]["label"] = item.label();
			data["label"]["use_markup"] = "true";
			data["description"]["label"] = item.description();
			data["description"]["use_markup"] = "true";
			options.add_row(data);
		}

		// Avoid negative and 0 since item 0 is already selected.
		if(*chosen_option_ > 0 && static_cast<size_t>(*chosen_option_)
								  < option_list_.size()) {

			options.select_row(*chosen_option_);
		}

		if(!has_input_) {
			window.keyboard_capture(&options);
			window.set_click_dismiss(false);
			window.set_escape_disabled(true);
		} else {
			window.add_to_keyboard_chain(&options);
			// click_dismiss has been disabled due to the input.
		}
	} else {
		options.set_visible(twidget::tvisible::invisible);
	}
	window.set_click_dismiss(!has_input_ && option_list_.empty());
}