~TC was incompletely restored after the adhesion storm

Now initialize and reset TC in titlescreen for add-ons and campaigns icons
(previously was only initialized after having played a game)
This also restore coloring for case like ~TC(not a playing side)
This commit is contained in:
Ali El Gariani 2007-09-03 20:02:28 +00:00
parent 4b44214d85
commit bab30040d8
4 changed files with 23 additions and 7 deletions

View File

@ -2013,6 +2013,10 @@ static int play_game(int argc, char** argv)
//make sure the game config is always set to how it should be at the title screen
game.reset_game_cfg();
// reset the TC, since a game can modify it, and it may be used
// by images in add-ons or campaigns dialogs
image::set_team_colors();
statistics::fresh_stats();
sound::play_music_repeatedly(game_config::title_music);

View File

@ -117,7 +117,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);
image::set_team_colors(&side_colors);
// Clear the screen contents
surface const disp(screen_.getSurface());

View File

@ -335,9 +335,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 > static_cast<int>(team_colors.size()) || side_n < 1)
break;
f1 = team_colors[side_n-1];
if (side_n < 1)
break;
else if (side_n < static_cast<int>(team_colors.size())) {
f1 = team_colors[side_n-1];
} else {
// this side is not inialized use default "n"
f1 = lexical_cast<std::string>(side_n);
}
f2 = field.substr(pos+1);
if(game_config::tc_info(f2).size()){
function="RC";
@ -461,9 +468,13 @@ void set_colour_adjustment(int r, int g, int b)
}
}
void set_team_colors(const std::vector<std::string>& colors)
void set_team_colors(const std::vector<std::string>* colors)
{
team_colors = colors;
if (colors == NULL)
team_colors.clear();
else {
team_colors = *colors;
}
}
void set_image_mask(const std::string& /*image*/)

View File

@ -171,7 +171,8 @@ namespace image {
///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);
///using NULL will reset to default TC
void set_team_colors(const std::vector<std::string>* colors = NULL);
///function which sets a certain image as a 'mask' for all scaled images.
///the 'mask' is blitted onto all scaled images.