示例#1
0
const color_range team::get_side_color_range(int side)
{
	std::string index = get_side_color_id(side);
	std::map<std::string, color_range>::iterator gp = game_config::team_rgb_range.find(index);

	if(gp != game_config::team_rgb_range.end()) {
		return (gp->second);
	}

	return color_range({255, 0, 0}, {255, 255, 255}, {0, 0, 0}, {255, 0, 0});
}
示例#2
0
文件: team.cpp 项目: aquileia/wesnoth
const color_range team::get_side_color_range(int side)
{
	std::string index = get_side_color_index(side);
	std::map<std::string, color_range>::iterator gp=game_config::team_rgb_range.find(index);

	if(gp != game_config::team_rgb_range.end()){
		return(gp->second);
	}

	return(color_range(0x00FF0000,0x00FFFFFF,0x00000000,0x00FF0000));
}
示例#3
0
	const color_range& color_info(const std::string& name)
	{
		std::map<std::string, color_range>::const_iterator i = team_rgb_range.find(name);
		if(i == team_rgb_range.end()) {
			std::vector<Uint32> temp;
			if(!string2rgb(name, temp))
				throw config::error(_("Invalid color range: ") + name);
			team_rgb_range.insert(std::make_pair(name,color_range(temp)));
			return color_info(name);
		}
		return i->second;
	}
示例#4
0
	void add_color_info(const config &v)
	{
		BOOST_FOREACH(const config &teamC, v.child_range("color_range"))
		{
			const config::attribute_value *a1 = teamC.get("id"),
				*a2 = teamC.get("rgb");
			if (!a1 || !a2) {
				continue;
			}
			std::string id = *a1;
			std::vector<Uint32> temp;
			if(!string2rgb(*a2, temp)) {
				std::stringstream ss;
				ss << "can't parse color string:\n" << teamC.debug() << "\n";
				throw config::error(ss.str());
			}
			team_rgb_range.insert(std::make_pair(id,color_range(temp)));
			team_rgb_name[id] = teamC["name"];
			//generate palette of same name;
			std::vector<Uint32> tp = palette(team_rgb_range[id]);
			if (tp.empty()) {
				continue;
			}
			team_rgb_colors.insert(std::make_pair(id,tp));
			//if this is being used, output log of palette for artists use.
			DBG_NG << "color palette creation:\n";
			std::ostringstream str;
			str << id << " = ";
			for (std::vector<Uint32>::const_iterator r = tp.begin(),
			     r_end = tp.end(), r_beg = r; r != r_end; ++r)
			{
				int red = ((*r) & 0x00FF0000) >> 16;
				int green = ((*r) & 0x0000FF00) >> 8;
				int blue = ((*r) & 0x000000FF);
				if (r != r_beg) str << ',';
				str << red << ',' << green << ',' << blue;
			}
			DBG_NG << str.str() << '\n';
		}

		BOOST_FOREACH(const config &cp, v.child_range("color_palette"))
		{
			BOOST_FOREACH(const config::attribute &rgb, cp.attribute_range())
			{
				std::vector<Uint32> temp;
				if(!string2rgb(rgb.second, temp)) {
					ERR_NG << "Invalid color palette: " << rgb.second << std::endl;
				}
				team_rgb_colors.insert(std::make_pair(rgb.first, temp));
			}
		}
	}
示例#5
0
color_range parser::get_color_range(const std::string& sym)
{
	const std::string asym = this->resolve_symbol( sym );
	std::map< std::string, color_range >::const_iterator aentry = rc_range_tab_.find(asym);

	if (aentry == rc_range_tab_.end()) {
		if (this->is_pal(asym)) {
			throw symbol_type_mismatch();
		}
		else {
			throw symbol_not_found();
		}

		return color_range(0x00000000);
	}

	return (*aentry).second;
}
示例#6
0
	void add_color_info(const config &v)
	{
		BOOST_FOREACH(const config &teamC, v.child_range("color_range"))
		{
			const config::attribute_value *a1 = teamC.get("id"),
				*a2 = teamC.get("rgb");
			if (!a1 || !a2) {
				continue;
			}
			std::string id = *a1;
			std::vector<Uint32> temp;
			if(!string2rgb(*a2, temp)) {
				std::stringstream ss;
				ss << "can't parse color string:\n" << teamC.debug() << "\n";
				throw config::error(ss.str());
			}
			team_rgb_range.insert(std::make_pair(id,color_range(temp)));
			team_rgb_name[id] = teamC["name"];

			LOG_NG << "registered color range '" << id << "': " << team_rgb_range[id].debug() << '\n';

			//generate palette of same name;
			std::vector<Uint32> tp = palette(team_rgb_range[id]);
			if (tp.empty()) {
				continue;
			}
			team_rgb_colors.insert(std::make_pair(id,tp));
		}

		BOOST_FOREACH(const config &cp, v.child_range("color_palette"))
		{
			BOOST_FOREACH(const config::attribute &rgb, cp.attribute_range())
			{
				std::vector<Uint32> temp;
				if(!string2rgb(rgb.second, temp)) {
					ERR_NG << "Invalid color palette: " << rgb.second << std::endl;
				}
				team_rgb_colors.insert(std::make_pair(rgb.first, temp));
				LOG_NG << "registered color palette: " << rgb.first << '\n';
			}
		}
	}