示例#1
0
void ttent::add_row_to_factions(tlistbox& list, const config& cfg)
{
	// Add list item
	string_map list_item;
	std::map<std::string, string_map> list_item_item;

	int number = cfg["leader"].to_int();
	list_item["label"] = heros_[number].image();
	list_item_item.insert(std::make_pair("icon", list_item));
	
	const config& art_cfg = cfg.child("artifical");
	std::vector<std::string> vstr = utils::split(art_cfg["service_heros"].str());
	list_item["label"] = lexical_cast_default<std::string>(vstr.size());
	list_item_item.insert(std::make_pair("fresh", list_item));

	vstr = utils::split(art_cfg["wander_heros"].str());
	list_item["label"] = lexical_cast_default<std::string>(vstr.size());
	list_item_item.insert(std::make_pair("wander", list_item));

	number = art_cfg["heros_army"].to_int();
	list_item["label"] = heros_[number].name();
	list_item_item.insert(std::make_pair("city", list_item));

	list.add_row(list_item_item);
}
示例#2
0
	void add_row_to_stuff_list(const std::string& id, const std::string& label)
	{
		std::map<std::string, string_map> data;
		string_map item;
		item["id"] = id;
		item["label"] = label;
		data.insert(std::make_pair("name", item));
		stuff_list->add_row(data);
	}
示例#3
0
void tbrowse::add_row(twindow& window, tlistbox& list, const std::string& name, bool dir)
{
	std::stringstream ss;

	string_map list_item;
	std::map<std::string, string_map> list_item_item;

	list_item["label"] = "misc/open.png~SCALE(32, 32)";
	list_item_item.insert(std::make_pair("open", list_item));

	ss << tintegrate::generate_img(get_browse_icon(dir) + "~SCALE(24, 24)") << name;
	list_item["label"] = ss.str();
	list_item_item.insert(std::make_pair("name", list_item));

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

	list_item["label"] = dir? null_str: "---";
	list_item_item.insert(std::make_pair("size", list_item));

	list.add_row(list_item_item);

	int index = list.get_item_count() - 1;
	ttoggle_panel* panel = dynamic_cast<ttoggle_panel*>(list.get_row_panel(index));

	tbutton* button = find_widget<tbutton>(panel, "open", false, true);
	if (dir) {
		connect_signal_mouse_left_click(
			*button
			, boost::bind(
				&tbrowse::open
				, this
				, boost::ref(window)
				, _3
				, _4
				, (int)true
				, (int)index));

		panel->connect_signal<event::LEFT_BUTTON_DOUBLE_CLICK>(boost::bind(
				  &tbrowse::open
				, this
				, boost::ref(window)
				, _3
				, _4
				, (int)true
				, (int)index)
			, event::tdispatcher::back_pre_child);

	} else {
		button->set_visible(twidget::HIDDEN);
		button->set_active(false);
	}
}
示例#4
0
	void add_nick(const std::string& nick, const std::string& label)
	{
		DBG_GUI << "Nicks list: adding item (nick: \"" << nick << "\" label: \""
				<< label << "\")\n";
		nicks.push_back(nick);
		std::map<std::string, string_map> data;
		string_map item;
		item["id"] = nick;
		item["label"] = label;
		item["use_markup"] = "true";
		data.insert(std::make_pair("nick", item));
		nicks_list->add_row(data);
	}
示例#5
0
	void add_side(int side_num, const std::string& label)
	{
		sides.push_back(side_num);
		DBG_GUI << "Sides list: adding item (side_num: \"" << side_num
				<< "\" label: \"" << label << "\")\n";
		std::map<std::string, string_map> data;
		string_map item;
		item["id"] = std::string("side_") + str_cast(side_num);
		item["label"] = label;
		item["use_markup"] = "true";
		data.insert(std::make_pair("side", item));
		sides_list->add_row(data);
	}
示例#6
0
void ttent::add_row_to_heros(tlistbox& list, int h, int leader, int city, int stratum)
{
	// Add list item
	string_map list_item;
	std::map<std::string, string_map> list_item_item;

	if (!rpg_mode_) {
		list_item["label"] = heros_[h].image();
		list_item_item.insert(std::make_pair("icon", list_item));
	}

	if (h != player_hero_->number_) {
		list_item["label"] = heros_[h].name();
	} else {
		list_item["label"] = player_hero_->name();
	}
	list_item_item.insert(std::make_pair("name", list_item));

	if (leader != -1) {
		list_item["label"] = heros_[leader].name();
	} else {
		list_item["label"] = "---";
	}
	list_item_item.insert(std::make_pair("side", list_item));

	if (city != -1) {
		list_item["label"] = heros_[city].name();
	} else {
		list_item["label"] = "---";
	}
	list_item_item.insert(std::make_pair("city", list_item));

	list_item["label"] = hero::stratum_str(stratum);
	list_item_item.insert(std::make_pair("stratum", list_item));
	
	list.add_row(list_item_item);

	if (rpg_mode_) {
		tgrid* grid_ptr = list.get_row_grid(mem_vsize_);
		tcontrol* control = dynamic_cast<tcontrol*>(grid_ptr->find("icon", true));
		control->set_visible(twidget::INVISIBLE);
	}

	rows_mem_[mem_vsize_].hero_ = h;
	rows_mem_[mem_vsize_].leader_ = leader;
	rows_mem_[mem_vsize_].city_ = city;
	rows_mem_[mem_vsize_ ++].stratum_ = stratum;
}
示例#7
0
void tgame_load::fill_local(twindow& window, tlistbox& list)
{
	find_widget<tcontrol>(&window, "delete", false).set_active(true);
	find_widget<tcontrol>(&window, "ok", false).set_active(true);
	std::string str = tintegrate::generate_format(_("Upload"), "blue");
	find_widget<tcontrol>(&window, "xmit", false).set_label(str);

	{
		cursor::setter cur(cursor::WAIT);
		games_ = savegame::manager::get_saves_list();
	}
	list.clear();
	BOOST_FOREACH (const savegame::save_info game, games_) {
		std::map<std::string, string_map> data;
		string_map item;

		item["label"] = game.name;
		data.insert(std::make_pair("filename", item));

		item["label"] = game.format_time_summary();
		data.insert(std::make_pair("date", item));

		list.add_row(data);
	}
示例#8
0
void tside_report::fill_table(tlistbox& list, int catalog)
{
	for (std::vector<artifical*>::const_iterator it = candidate_cities_.begin(); it != candidate_cities_.end(); ++ it) {
		artifical& city = **it;
		std::stringstream str;
		
		/*** Add list item ***/
		string_map table_item;
		std::map<std::string, string_map> table_item_item;

		str.str("");
		str << city.name();
		str << "(Lv";
		str << tintegrate::generate_format(city.level(), "green");
		str << ")";
		table_item["label"] = str.str();
		table_item_item.insert(std::make_pair("name", table_item));

		if (catalog == STATUS_PAGE) {
			str.str("");
			if (city.hitpoints() < city.max_hitpoints() / 2) {
				str << tintegrate::generate_format(city.hitpoints(), "red");
			} else if (city.hitpoints() < city.max_hitpoints()) {
				str << tintegrate::generate_format(city.hitpoints(), "yellow");
			} else {
				str << city.hitpoints();
			}
			str << "/" << city.max_hitpoints();
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("hp", table_item));

			str.str("");
			str << city.experience() << "/";
			if (city.can_advance()) {
				str << city.max_experience();
			} else {
				str << "-";
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("xp", table_item));

			str.str("");
			str << tintegrate::generate_format(city.fresh_heros().size(), "green");
			str << "/";
			str << tintegrate::generate_format(city.finish_heros().size(), "red");
			str << "/";
			str << tintegrate::generate_format(city.wander_heros().size(), "yellow");
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("hero", table_item));

			str.str("");
			str << tintegrate::generate_format(city.reside_troops().size(), "yellow");
			str << "/";
			str << city.field_troops().size();
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("troop", table_item));

			str.str("");
			str << tintegrate::generate_format(city.total_gold_income(current_team_.market_increase_), "yellow");
			str << "/";
			str << tintegrate::generate_format(city.total_technology_income(current_team_.technology_increase_), "green");
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("income", table_item));

			size_t built = 0;
			size_t building = 0;
			const std::vector<map_location>& ea = city.economy_area();
			for (std::vector<map_location>::const_iterator it2 = ea.begin(); it2 != ea.end(); ++ it2) {
				unit* u = units_.find_unit(*it2);
				if (!u || !hero::is_ea_artifical(u->type()->master())) {
					continue;
				}
				if (u->get_state(ustate_tag::BUILDING)) {
					building ++;
				} else {
					built ++;
				}
			}
			str.str("");
			str << tintegrate::generate_format(building + built, building? "yellow": "green");
			str << "/";
			if (building + built != ea.size()) {
				str << tintegrate::generate_format(ea.size(), "red");
			} else {
				str << ea.size();
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("ea", table_item));
		}
		list.add_row(table_item_item);

		unsigned hero_index = list.get_item_count() - 1;
		twidget* grid_ptr = list.get_row_panel(hero_index);
		ttoggle_panel* toggle = dynamic_cast<ttoggle_panel*>(grid_ptr);
		toggle->set_data(hero_index);
	}
}
示例#9
0
void thero_selection::fill_table(tlistbox& list, int catalog)
{
	std::vector<int> features;
	std::stringstream str;
	std::string color;

	hero& leader = *(*teams_)[side_ - 1].leader();
	int hero_index = 0;
	for (std::vector<std::pair<int, unit*> >::iterator itor = pairs_.begin(); itor != pairs_.end(); ++ itor, hero_index ++) {
		/*** Add list item ***/
		string_map table_item;
		std::map<std::string, string_map> table_item_item;

		hero& h = heros_[itor->first];
		unit& u = *itor->second;

		int catalog_diff = posix_abs((int)leader.base_catalog_ - h.base_catalog_);
		if (catalog_diff > HERO_MAX_LOYALTY / 2) {
			catalog_diff = HERO_MAX_LOYALTY - catalog_diff;
		}

		if (catalog == OWNERSHIP_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			if (h.side_ != HEROS_INVALID_SIDE) {
				table_item["label"] =  (*teams_)[h.side_].name();
			} else {
				table_item["label"] = "---";
			}
			table_item_item.insert(std::make_pair("side", table_item));

			artifical* city = units_? units_->city_from_cityno(h.city_): NULL;
			if (city) {
				table_item["label"] = city->name();
			} else {
				table_item["label"] = "---";
			}
			table_item_item.insert(std::make_pair("city", table_item));

			str.str("");
			if (h.side_ != HEROS_INVALID_SIDE) {
				str << h.loyalty(leader);
			} else {
				str << "--";
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("loyalty", table_item));

			str.str("");
			str << (int)h.base_catalog_;
			if (HERO_MAX_LOYALTY - catalog_diff >= game_config::move_loyalty_threshold) {
				color = "green";
			} else if (HERO_MAX_LOYALTY - catalog_diff >= game_config::wander_loyalty_threshold) {
				color = "yellow";
			} else {
				color = "red";
			}
			str << "(" << tintegrate::generate_format(catalog_diff, color) << ")";
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("hero_catalog", table_item));

			str.str("");
			if (!u.is_artifical()) {
				str << u.name() << _("name^Troop");
			} else if (u.is_city()) {
				str << u.name();
			} else {
				str << u.name() << u.type_name();
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("position", table_item));

			table_item["label"] = lexical_cast<std::string>(h.meritorious_);
			table_item_item.insert(std::make_pair("meritorious", table_item));

		} else if (catalog == ABILITY_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			table_item["label"] = lexical_cast<std::string>(fxptoi9(h.leadership_));
			table_item_item.insert(std::make_pair("leadership", table_item));

			table_item["label"] = lexical_cast<std::string>(fxptoi9(h.force_));
			table_item_item.insert(std::make_pair("force", table_item));

			table_item["label"] = lexical_cast<std::string>(fxptoi9(h.intellect_));
			table_item_item.insert(std::make_pair("intellect", table_item));

			table_item["label"] = lexical_cast<std::string>(fxptoi9(h.spirit_));
			table_item_item.insert(std::make_pair("spirit", table_item));

			table_item["label"] = lexical_cast<std::string>(fxptoi9(h.charm_));
			table_item_item.insert(std::make_pair("charm", table_item));

			table_item["label"] = hero::status_str(h.status_);
			table_item_item.insert(std::make_pair("action", table_item));

		} else if (catalog == FEATURE_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			table_item["label"] = hero::feature_str(h.feature_);
			table_item_item.insert(std::make_pair("feature", table_item));

			table_item["label"] = hero::feature_desc_str(h.feature_);
			table_item_item.insert(std::make_pair("explain", table_item));

		} else if (catalog == ADAPTABILITY_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			table_item["label"] = hero::adaptability_str2(h.arms_[0]);
			table_item_item.insert(std::make_pair("arm0", table_item));

			table_item["label"] = hero::adaptability_str2(h.arms_[1]);
			table_item_item.insert(std::make_pair("arm1", table_item));

			table_item["label"] = hero::adaptability_str2(h.arms_[2]);
			table_item_item.insert(std::make_pair("arm2", table_item));

			table_item["label"] = hero::adaptability_str2(h.arms_[3]);
			table_item_item.insert(std::make_pair("arm3", table_item));

			table_item["label"] = hero::adaptability_str2(h.arms_[4]);
			table_item_item.insert(std::make_pair("arm4", table_item));

		} else if (catalog == COMMAND_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			table_item["label"] = "----";
			table_item_item.insert(std::make_pair("command", table_item));

		} else if (catalog == PERSONAL_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			table_item["label"] = hero::gender_str(h.gender_);
			table_item_item.insert(std::make_pair("gender", table_item));

		} else if (catalog == RELATION_PAGE) {
			table_item["label"] = h.name();
			table_item_item.insert(std::make_pair("name", table_item));

			if (h.parent_[0].hero_ != HEROS_INVALID_NUMBER) {
				table_item["label"] = heros_[h.parent_[0].hero_].name();
			} else {
				table_item["label"] = "";
			}
			table_item_item.insert(std::make_pair("father", table_item));

			if (h.parent_[1].hero_ != HEROS_INVALID_NUMBER) {
				table_item["label"] = heros_[h.parent_[1].hero_].name();
			} else {
				table_item["label"] = "";
			}
			table_item_item.insert(std::make_pair("mother", table_item));

			str.str("");
			for (uint32_t i = 0; i < HEROS_MAX_OATH; i ++) {
				if (h.oath_[i].hero_ != HEROS_INVALID_NUMBER) {
					if (i == 0) {
						str << heros_[h.oath_[i].hero_].name();
					} else {
						str << " " << heros_[h.oath_[i].hero_].name();
					}
				}
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("oath", table_item));

			str.str("");
			for (uint32_t i = 0; i < HEROS_MAX_CONSORT; i ++) {
				if (h.consort_[i].hero_ != HEROS_INVALID_NUMBER) {
					if (i == 0) {
						str << heros_[h.consort_[i].hero_].name();
					} else {
						str << " " << heros_[h.consort_[i].hero_].name();
					}
				}
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("consort", table_item));

			str.str("");
			for (uint32_t i = 0; i < HEROS_MAX_INTIMATE; i ++) {
				if (h.intimate_[i].hero_ != HEROS_INVALID_NUMBER) {
					if (i == 0) {
						str << heros_[h.intimate_[i].hero_].name();
					} else {
						str << " " << heros_[h.intimate_[i].hero_].name();
					}
				}
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("intimate", table_item));

			str.str("");
			for (uint32_t i = 0; i < HEROS_MAX_HATE; i ++) {
				if (h.hate_[i].hero_ != HEROS_INVALID_NUMBER) {
					if (i == 0) {
						str << heros_[h.hate_[i].hero_].name();
					} else {
						str << " " << heros_[h.hate_[i].hero_].name();
					}
				}
			}
			table_item["label"] = str.str();
			table_item_item.insert(std::make_pair("hate", table_item));

		}
		list.add_row(table_item_item);

		twidget* grid_ptr = list.get_row_panel(hero_index);
		ttoggle_button* toggle = dynamic_cast<ttoggle_button*>(grid_ptr->find("prefix", true));
		toggle->set_callback_state_change(boost::bind(&thero_selection::hero_toggled, this, _1));
		toggle->set_data(hero_index);
		if (checked_pairs_.find(hero_index) != checked_pairs_.end()) {
			toggle->set_value(true);
		}

		bool enable = true;
		for (std::vector<std::string>::const_iterator it2 = disables_.begin(); it2 != disables_.end() && enable; ++ it2) {
			const std::string& tag = *it2;
			if (tag == "loyalty") {
				if (h.side_ != HEROS_INVALID_SIDE) {
					hero& ownership_leader = *(*teams_)[h.side_].leader();
					if (ownership_leader.base_catalog_ == h.base_catalog_) {
						enable = false;
					}
				}
			} else if (tag == "hate") {
				if (leader.is_hate(h)) {
					enable = false;
				}
			}
		}
		if (enable && h.player_ == HEROS_INVALID_NUMBER && std::find(disables_.begin(), disables_.end(), "member") != disables_.end()) {
			if (runtime_groups::exist_member(h, leader)) {
				toggle->set_active(false);
			}
		}
		if (!enable) {
			// grid_ptr->set_active(false);
			toggle->set_active(false);
		}
	}
}