Example #1
0
void ttower_tent::turns(twindow& window)
{
	// The possible eras to play
	std::vector<std::string> items;
	std::map<int, tval_str> turns_map;
	int actived_index = 0;

	turns_map.insert(std::make_pair(0, tval_str(20, "20")));
	turns_map.insert(std::make_pair(1, tval_str(30, "30")));
	turns_map.insert(std::make_pair(2, tval_str(50, "50")));
	turns_map.insert(std::make_pair(3, tval_str(70, "70")));
	turns_map.insert(std::make_pair(4, tval_str(100, "100")));

	for (std::map<int, tval_str>::iterator it = turns_map.begin(); it != turns_map.end(); ++ it) {
		items.push_back(it->second.str);
		if (tent::turns == it->second.val) {
			actived_index = std::distance(turns_map.begin(), it);
		}
	}
	
	gui2::tcombo_box dlg(items, actived_index);
	dlg.show(gui_.video());

	int selected = dlg.selected_index();
	tent::turns = turns_map.find(selected)->second.val;

	std::stringstream strstr;
	strstr << tent::turns;
	turns_->set_label(strstr.str());
}
Example #2
0
void ttower_tent::employ_count(twindow& window)
{
	std::vector<std::string> items;
	std::vector<tval_str> employ_count_map;
	int actived_index = 0;
	
	employ_count_map.push_back(tval_str(0, "0"));
	employ_count_map.push_back(tval_str(3, "3"));
	employ_count_map.push_back(tval_str(6, "6"));
	employ_count_map.push_back(tval_str(9, "9"));

	for (std::vector<tval_str>::iterator it = employ_count_map.begin(); it != employ_count_map.end(); ++ it) {
		items.push_back(it->str);
		if (tent::employ_count == it->val) {
			actived_index = std::distance(employ_count_map.begin(), it);
		}
	}
	
	gui2::tcombo_box dlg(items, actived_index);
	dlg.show(gui_.video());

	int selected = dlg.selected_index();
	tent::employ_count = employ_count_map[selected].val;

	std::stringstream strstr;
	strstr << tent::employ_count;
	employ_count_->set_label(strstr.str());
}
Example #3
0
void tcontrol_setting::set_textdomain(twindow& window, bool label)
{
	std::stringstream ss;
	std::vector<tval_str> items;

	std::string& textdomain = label? cell_.widget.label_textdomain: cell_.widget.tooltip_textdomain;
	
	int index = -1;
	int def = -1;
	items.push_back(tval_str(index ++, ""));
	for (std::vector<std::string>::const_iterator it = textdomains_.begin(); it != textdomains_.end(); ++ it) {
		ss.str("");
		ss << *it;
		if (*it == textdomain) {
			def = index;
		}
		items.push_back(tval_str(index ++, ss.str()));
	}

	gui2::tcombo_box dlg(items, def);
	dlg.show(disp_.video());

	index = dlg.selected_val();
	if (index >= 0) {
		textdomain = textdomains_[index];
	} else {
		textdomain.clear();
	}

	set_textdomain_label(window, label);
}
Example #4
0
void tpreferences::duel(twindow& window)
{
	// The possible eras to play
	std::vector<tval_str> items;

	items.push_back(tval_str(NO_DUEL, _("Hasn't")));
	items.push_back(tval_str(RANDOM_DUEL, _("Random")));

	gui2::tcombo_box dlg(items, env_.duel);
	dlg.show(disp_.video());

	int selected = dlg.selected_index();
	env_.duel = items[selected].val;

	duel_->set_label(items[selected].str);
}
Example #5
0
//
// multiplayer
//
void tpreferences::maximal_defeated_activity(twindow& window)
{
	std::vector<tval_str> items;

	items.push_back(tval_str(0, "0"));
	items.push_back(tval_str(50, "50"));
	items.push_back(tval_str(100, "100"));
	items.push_back(tval_str(150, "150"));

	gui2::tcombo_box dlg(items, env_.maximal_defeated_activity);
	dlg.show(disp_.video());

	if (dlg.selected_val() == env_.maximal_defeated_activity) {
		return;
	}
	int selected = dlg.selected_index();
	env_.maximal_defeated_activity = items[selected].val;

	maximal_defeated_activity_->set_label(items[selected].str);
}
Example #6
0
void ttower_tent::turns(twindow& window)
{
	// The possible eras to play
	std::vector<tval_str> items;

	items.push_back(tval_str(20, "20"));
	items.push_back(tval_str(30, "30"));
	items.push_back(tval_str(50, "50"));
	items.push_back(tval_str(70, "70"));
	items.push_back(tval_str(100, "100"));

	gui2::tcombo_box dlg(items, tent::turns);
	dlg.show(gui_.video());

	int selected = dlg.selected_index();
	tent::turns = items[selected].val;

	std::stringstream strstr;
	strstr << tent::turns;
	turns_->set_label(strstr.str());
}
Example #7
0
void ttower_tent::ai_count(twindow& window)
{
	// The possible eras to play
	std::vector<tval_str> items;

	items.push_back(tval_str(30, "30"));
	items.push_back(tval_str(40, "40"));
	items.push_back(tval_str(50, "50"));
	items.push_back(tval_str(60, "60"));
	items.push_back(tval_str(70, "70"));

	gui2::tcombo_box dlg(items, tent::ai_count);
	dlg.show(gui_.video());

	int selected = dlg.selected_index();
	tent::ai_count = items[selected].val;

	std::stringstream strstr;
	strstr << tent::ai_count;
	ai_count_->set_label(strstr.str());
}
Example #8
0
void ttent::player_faction(twindow& window)
{
	// The possible eras to play
	std::vector<std::string> items;
	std::map<int, tval_str> factions_map;
	int actived_index = 0;

	const config::const_child_itors& factions = cfg_.child_range("faction");
	int index = 0;
	BOOST_FOREACH (const config &cfg, factions) {
		int number = cfg["leader"].to_int();
		factions_map.insert(std::make_pair(index ++, tval_str(number, heros_[number].name())));
	}
Example #9
0
void tpreferences::zoom_button(twindow& window)
{
	std::vector<tval_str> items;
	items.push_back(tval_str(display::ZOOM_72, "72 x 72"));
	items.push_back(tval_str(display::ZOOM_64, "64 x 64"));
	items.push_back(tval_str(display::ZOOM_56, "56 x 56"));
	items.push_back(tval_str(display::ZOOM_48, "48 x 48"));

	gui2::tcombo_box dlg(items, display::initial_zoom);
	dlg.show(disp_.video());

	if (dlg.selected_val() != display::initial_zoom) {
		display::initial_zoom = dlg.selected_val();
		preferences::_set_zoom(display::initial_zoom);

		std::stringstream str;
		str << _("Grid Size") << ": " << display::initial_zoom << " x " << display::initial_zoom;
		zoom_->set_label(str.str());

		image::set_zoom(display::initial_zoom);
	}
}
Example #10
0
void tcontrol_setting::set_linked_group(twindow& window)
{
	std::stringstream ss;
	std::vector<tval_str> items;

	int index = -1;
	int def = -1;
	items.push_back(tval_str(index ++, ""));
	for (std::vector<tlinked_group>::const_iterator it = linkeds_.begin(); it != linkeds_.end(); ++ it) {
		const tlinked_group& linked = *it;
		ss.str("");
		ss << tintegrate::generate_format(linked.id, "yellow");
		if (linked.fixed_width) {
			ss << "  " << tintegrate::generate_format("width", "blue");
		}
		if (linked.fixed_height) {
			ss << "  " << tintegrate::generate_format("height", "blue");
		}
		if (cell_.widget.linked_group == linked.id) {
			def = index;
		}
		items.push_back(tval_str(index ++, ss.str()));
	}

	gui2::tcombo_box dlg(items, def);
	dlg.show(disp_.video());

	index = dlg.selected_val();
	if (index >= 0) {
		cell_.widget.linked_group = linkeds_[index].id;
	} else {
		cell_.widget.linked_group.clear();
	}

	set_linked_group_label(window);
}
Example #11
0
void tcontrol_setting::set_vertical_layout(twindow& window)
{
	std::stringstream ss;
	std::vector<tval_str> items;

	for (std::map<int, tlayout>::const_iterator it = vertical_layout.begin(); it != vertical_layout.end(); ++ it) {
		ss.str("");
		ss << tintegrate::generate_img(it->second.icon + "~SCALE(24, 24)") << it->second.description;
		items.push_back(tval_str(it->first, ss.str()));
	}

	unsigned h_flag = cell_.widget.cell.flags_ & tgrid::VERTICAL_MASK;
	gui2::tcombo_box dlg(items, h_flag);
	dlg.show(disp_.video());

	h_flag = dlg.selected_val();
	cell_.widget.cell.flags_ = (cell_.widget.cell.flags_ & ~tgrid::VERTICAL_MASK) | h_flag;

	set_vertical_layout_label(window);
}