Restore ~TC imagepath mod feature...

...which was killed only for code-refactoring reasons.  This simply
intialize a vector of each TC colors when we load the side-coloring of
flags.  (note that we can always improve/kill it, but now the
implementation problem doesn't pollute the question)
This commit is contained in:
Ali El Gariani 2007-07-18 13:43:21 +00:00
parent 8a0e793091
commit ecc8a46423
3 changed files with 26 additions and 6 deletions

View file

@ -177,12 +177,19 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
{
singleton_ = this;
//inits the flag list
//inits the flag list and the team colors used by ~TC
flags_.reserve(teams_.size());
std::vector<std::string> side_colors;
side_colors.reserve(teams_.size());
for(size_t i = 0; i != teams_.size(); ++i) {
std::string side_color = team::get_side_colour_index(i+1);
side_colors.push_back(side_color);
std::string flag = teams_[i].flag();
std::string old_rgb = game_config::flag_rgb;
std::string new_rgb = team::get_side_colour_index(i+1);
std::string new_rgb = side_color;
if(flag.empty()) {
flag = game_config::flag_image;
@ -216,6 +223,7 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
flags_.back().start_animation(rand()%flags_.back().get_end_time(), true);
}
image::set_team_colors(side_colors);
//clear the screen contents
surface const disp(screen_.getSurface());

View file

@ -50,6 +50,9 @@ std::map<surface, surface> reversed_images_;
int red_adjust = 0, green_adjust = 0, blue_adjust = 0;
// list of colors used by the TC image modification
std::vector<std::string> team_colors;
std::string image_mask;
int zoom = image::tile_size;
@ -316,7 +319,7 @@ surface locator::load_image_sub_file() const
break;
}
std::string field = *j++;
#if 0
if("TC" == function){//deprecated team coloring syntax
//replace with proper RC syntax
std::string::size_type pos = 0;
@ -325,16 +328,16 @@ surface locator::load_image_sub_file() const
break;
std::string f1,f2;
int side_n = lexical_cast_default<int>(field.substr(0,pos),-1);
if (side_n < 0)
if (side_n > static_cast<int>(team_colors.size()) || side_n < 1)
break;
f1 = team::get_side_colour_index(side_n);
f1 = team_colors[side_n-1];
f2 = field.substr(pos+1);
if(game_config::tc_info(f2).size()){
function="RC";
field= f2 + ">" + f1;
}
}
#endif
if("RC" == function){ //re-color function
std::vector<std::string> recolor=utils::split(field,'>');
if(recolor.size()>1){
@ -449,6 +452,11 @@ void set_colour_adjustment(int r, int g, int b)
}
}
void set_team_colors(const std::vector<std::string>& colors)
{
team_colors = colors;
}
void set_image_mask(const std::string& /*image*/)
{

View file

@ -168,6 +168,10 @@ namespace image {
///for representing day/night. Invalidates all scaled images.
void set_colour_adjustment(int r, int g, int b);
///set the team colors used by the TC image modification
///use a vector with one string for each team
void set_team_colors(const std::vector<std::string>& colors);
///function which sets a certain image as a 'mask' for all scaled images.
///the 'mask' is blitted onto all scaled images.
void set_image_mask(const std::string& image_name);