Change new TC function to RC function and restore old

TC function definition.
This commit is contained in:
John W. C. McNabb 2006-11-17 01:23:03 +00:00
parent 1668e073d0
commit c165ad2cde
12 changed files with 52 additions and 30 deletions

View file

@ -228,7 +228,7 @@ name=moveto
[item]
x,y=12,6
image="terrain/color-hex.png~TC(red>4)~TC(blue>5)"
image="terrain/color-hex.png~RC(red>4)~RC(blue>5)"
[/item]
[label]
x,y=12,6
@ -257,7 +257,7 @@ name=moveto
description= _ "Oooh tingly!!!"
[effect]
apply_to=image_mod
replace="TC(thief>blonde)"
add="RC(thief>blonde)"
[color_palette]
thief=133,167,202,73,102,151,215,240,240,185,206,228,41,61,95,97,124,171
@ -279,7 +279,7 @@ name=moveto
[/filter]
[message]
speaker=narrator
image=units/elves-wood/captain.png~TC(magenta>3)
image=units/elves-wood/captain.png~RC(magenta>3)
message=_ "Send me a thief to spy on the blondes"
[/message]
[/event]

View file

@ -339,7 +339,7 @@ void save_preview_pane::draw_contents()
#ifdef LOW_MEM
const surface image(image::get_image(leader->second.image(),image::UNSCALED));
#else
const surface image(image::get_image(leader->second.image() + "~TC(" + leader->second.flag_rgb() + ">1)",image::UNSCALED));
const surface image(image::get_image(leader->second.image() + "~RC(" + leader->second.flag_rgb() + ">1)",image::UNSCALED));
#endif
if(image != NULL) {

View file

@ -134,7 +134,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
time = 100;
}
std::stringstream temp;
temp << str << "~TC(" << old_rgb << ">"<< new_rgb << ")";
temp << str << "~RC(" << old_rgb << ">"<< new_rgb << ")";
image::locator flag_image(temp.str());
temp_anim.add_frame(time, flag_image);
}

View file

@ -1090,14 +1090,14 @@ public:
#ifdef LOW_MEM
ss << "<img>src='" << male_type.image() << "'</img> ";
#else
ss << "<img>src='" << male_type.image() << "~TC(" << male_type.flag_rgb() << ">1)" << "'</img> ";
ss << "<img>src='" << male_type.image() << "~RC(" << male_type.flag_rgb() << ">1)" << "'</img> ";
#endif
if (&female_type != &male_type)
#ifdef LOW_MEM
ss << "<img>src='" << female_type.image() << "'</img> ";
#else
ss << "<img>src='" << female_type.image() << "~TC(" << female_type.flag_rgb() << ">1)" << "'</img> ";
ss << "<img>src='" << female_type.image() << "~RC(" << female_type.flag_rgb() << ">1)" << "'</img> ";
#endif

View file

@ -318,7 +318,7 @@ surface locator::load_image_sub_file() const
if(val_.modifications_.size()){
std::map<Uint32, Uint32> recolor_map;
std::vector<std::string> modlist = utils::split(val_.modifications_,'~');
std::vector<std::string> modlist = utils::paranthetical_split(val_.modifications_,'~');
for(std::vector<std::string>::const_iterator i=modlist.begin();
i!= modlist.end();i++){
std::vector<std::string> tmpmod = utils::paranthetical_split(*i);
@ -333,7 +333,21 @@ surface locator::load_image_sub_file() const
break;
}
std::string field = *j++;
if("TC" == function){
if("TC" == function){//deprecated team coloring syntax
//replace with proper RC syntax
std::string::size_type pos = 0;
pos = field.find(',');
if (pos == std::string::npos)
break;
std::string f1,f2;
f1 = field.substr(0,pos);
f2 = field.substr(pos,field.size()-pos-1);
if(game_config::tc_info(f2).size()){
function="RC";
field= f2 + ">" + f1;
}
}
if("RC" == function){
std::vector<std::string> recolor=utils::split(field,'>');
if(recolor.size()>1){
std::map<std::string, color_range>::const_iterator nc = game_config::team_rgb_range.find(recolor[1]);

View file

@ -101,7 +101,7 @@ void leader_list_manager::populate_combo(int selected_index) {
#ifdef LOW_MEM
leader_strings.push_back(IMAGE_PREFIX + image + COLUMN_SEPARATOR + name);
#else
leader_strings.push_back(IMAGE_PREFIX + image + std::string("~TC(" + utypes.find(*itor)->second.flag_rgb() + ">1)") + COLUMN_SEPARATOR + name);
leader_strings.push_back(IMAGE_PREFIX + image + std::string("~RC(" + utypes.find(*itor)->second.flag_rgb() + ">1)") + COLUMN_SEPARATOR + name);
#endif
} else {
if(*itor == "random") {

View file

@ -273,7 +273,7 @@ namespace events{
str << IMAGE_PREFIX << type->second.image();
#ifndef LOW_MEM
str << "~TC(" << type->second.flag_rgb() << ">" << team << ")";
str << "~RC(" << type->second.flag_rgb() << ">" << team << ")";
#endif
str << COLUMN_SEPARATOR << type->second.language_name() << COLUMN_SEPARATOR << i->second << "\n";
table.push_back(str.str());
@ -398,7 +398,7 @@ namespace events{
}
#ifndef LOW_MEM
str << "~TC(" << leader->second.team_color() << ">" << team::get_side_colour_index(n+1) << ")";
str << "~RC(" << leader->second.team_color() << ">" << team::get_side_colour_index(n+1) << ")";
#endif
str << COLUMN_SEPARATOR << "\033[3" << lexical_cast<char, size_t>(n+1) << 'm';
// Delete all tags before name
@ -667,7 +667,7 @@ namespace events{
std::stringstream description;
description << font::IMAGE << type.image();
#ifndef LOW_MEM
description << "~TC(" << type.flag_rgb() << ">" << team::get_side_colour_index(team_num) << ")";
description << "~RC(" << type.flag_rgb() << ">" << team::get_side_colour_index(team_num) << ")";
#endif
description << COLUMN_SEPARATOR << font::LARGE_TEXT << prefix << type.language_name() << "\n"
<< prefix << type.cost() << " " << sgettext("unit^Gold");
@ -808,7 +808,7 @@ namespace events{
option << IMAGE_PREFIX << u->absolute_image();
#ifndef LOW_MEM
option << "~TC(" << u->team_color() << ">" << team::get_side_colour_index(team_num) << ")";
option << "~RC(" << u->team_color() << ">" << team::get_side_colour_index(team_num) << ")";
#endif
option << COLUMN_SEPARATOR
<< u->language_name() << COLUMN_SEPARATOR

View file

@ -93,7 +93,7 @@ void wait::leader_preview_pane::draw_contents()
#ifdef LOW_MEM
image = utypes.find(leader)->second.image();
#else
image = utypes.find(leader)->second.image() + "~TC(" + utypes.find(leader)->second.flag_rgb() + ">1)";
image = utypes.find(leader)->second.image() + "~RC(" + utypes.find(leader)->second.flag_rgb() + ">1)";
#endif
}
@ -401,7 +401,7 @@ void wait::generate_menu()
#ifdef LOW_MEM
leader_image = utypes.find(leader_type)->second.image();
#else
leader_image = utypes.find(leader_type)->second.image() + std::string("~TC(") + std::string(utypes.find(leader_type)->second.flag_rgb() + ">" + sd["side"] + ")");
leader_image = utypes.find(leader_type)->second.image() + std::string("~RC(") + std::string(utypes.find(leader_type)->second.flag_rgb() + ">" + sd["side"] + ")");
#endif
} else {

View file

@ -441,7 +441,7 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
flag = game_config::flag_image;
old_rgb = game_config::flag_rgb;
new_rgb = team::get_side_colour_index(playing_side);
mods = "~TC(" + old_rgb + ">" + new_rgb + ")";
mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
} else {
flag = current_team.flag();
}

View file

@ -200,13 +200,17 @@ std::vector< std::string > split(std::string const &val, char c, int flags)
}
//splits a function based either on a separator where text within paranthesis is protected from splitting,
//or it splits a string into an odd number of parts. The part before the first '(', the part between the
//first '(' and the matching right ')', etc ... and the remainder of the string. Note that this
//note that one can use the same character for both the left and right paranthesis
//or if the separator == 0 it splits a string into an odd number of parts:
//The part before the first '(', the part between the first '(' and the matching right ')',
// etc ... and the remainder of the string. Note that this
//will find the first matching char in the left string and match against the corresponding
//char in the right string. A correctly processed string should return with an odd number of elements to the vector.
//Empty elements are never removed as they are placeholders.
//parenthetical_split("a(b)c{d}e(f{g})h","({",")}") should return a vector of
// <"a","b","c","d","e","f{g}","h"> REMOVE EMPTY only works for the separator split
//char in the right string. In this mode, a correctly processed string should return with
//an odd number of elements to the vector and an empty elements are never removed as they are placeholders.
//hence REMOVE EMPTY only works for the separator split
//parenthetical_split("a(b)c{d}e(f{g})h",0,"({",")}") should return a vector of
// <"a","b","c","d","e","f{g}","h">
std::vector< std::string > paranthetical_split(std::string const &val, const char separator, std::string const &left, std::string const &right,int flags)
{
std::vector< std::string > res;
@ -231,8 +235,12 @@ std::vector< std::string > paranthetical_split(std::string const &val, const cha
if (!(flags & REMOVE_EMPTY) || !new_val.empty())
res.push_back(new_val);
++i2;
if (flags & STRIP_SPACES) {
while (i2 != val.end() && *i2 == ' ')
++i2;
}
i1=i2;
break;
continue;
}
if(part.size() && *i2 == part.back()){
part.pop_back();
@ -246,7 +254,7 @@ std::vector< std::string > paranthetical_split(std::string const &val, const cha
}else{
++i2;
}
break;
continue;
}
bool found=false;
for(size_t i=0; i < lp.size(); i++){

View file

@ -49,7 +49,7 @@ bool notspace(char c);
// STRIP_SPACES : strips leading and trailing blank spaces
enum { REMOVE_EMPTY = 0x01, STRIP_SPACES = 0x02 };
std::vector< std::string > split(std::string const &val, char c = ',', int flags = REMOVE_EMPTY | STRIP_SPACES);
std::vector< std::string > paranthetical_split(std::string const &val, const char separator = 0 , std::string const &left="(", std::string const &right=")",int flags = STRIP_SPACES);
std::vector< std::string > paranthetical_split(std::string const &val, const char separator = 0 , std::string const &left="(", std::string const &right=")",int flags = REMOVE_EMPTY | STRIP_SPACES);
std::string join(std::vector< std::string > const &v, char c = ',');
std::vector< std::string > quoted_split(std::string const &val, char c= ',',
int flags = REMOVE_EMPTY | STRIP_SPACES, char quote = '\\');

View file

@ -1961,9 +1961,9 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
std::string tc=team::get_side_colour_index(side_);
snprintf(buf,sizeof(buf),"%s-%stop.png~TC(%s>%s)",ellipse.c_str(),selected,"red",tc.c_str());
snprintf(buf,sizeof(buf),"%s-%stop.png~RC(%s>%s)",ellipse.c_str(),selected,"red",tc.c_str());
ellipse_back.assign(image::get_image(image::locator(buf)));
snprintf(buf,sizeof(buf),"%s-%sbottom.png~TC(%s>%s)",ellipse.c_str(),selected,"red",tc.c_str());
snprintf(buf,sizeof(buf),"%s-%sbottom.png~RC(%s>%s)",ellipse.c_str(),selected,"red",tc.c_str());
ellipse_front.assign(image::get_image(image::locator(buf)));
}
@ -2682,7 +2682,7 @@ void unit::add_modification(const std::string& type, const config& mod,
}
LOG_UT << "applying image_mod \n";
mod = (**i.first)["add"];
if (mod.empty()){
if (!mod.empty()){
image_mods_ += mod;
}
@ -3269,7 +3269,7 @@ temporary_unit_placer::~temporary_unit_placer()
std::string unit::image_mods() const{
std::stringstream modifier;
if(flag_rgb_.size()){
modifier << "~TC("<< flag_rgb_ << ">" << team::get_side_colour_index(side()) << ")";
modifier << "~RC("<< flag_rgb_ << ">" << team::get_side_colour_index(side()) << ")";
}
if(image_mods_.size()){
modifier << "~" << image_mods_;