Fixes for ToD and fading related bugs #18504 #18493 #18017

1.  Broke display::adjust_colors into 2 functions, update_tod() and
adjust_color_overlay().  Update_tod() called whenever (but at least
once per turn) to update the tod color shift.  Adjust_color_overlay()
called from the lua color_adjust handler to apply the color_adjust on
top and just once to the display.

2. Changed the startup code to prevent color shift after initial
dialog.  In play_controller start the scenario with the initial tod
not rgb=(0,0,0)
This commit is contained in:
Thonsew 2011-08-15 15:01:11 +00:00
parent bb15de6c40
commit ebbe106e49
5 changed files with 17 additions and 11 deletions

View file

@ -171,8 +171,12 @@ const time_of_day & display::get_time_of_day(const map_location& loc) const
return tod;
}
void display::adjust_colors(int r, int g, int b)
{
void display::update_tod() {
const time_of_day& tod = get_time_of_day();
image::set_color_adjustment(color_adjust_red_ + tod.red, color_adjust_green_ + tod.green, color_adjust_blue_ + tod.blue);
}
void display::adjust_color_overlay(int r, int g, int b) {
const time_of_day& tod = get_time_of_day();
image::set_color_adjustment(r + tod.red, g + tod.green, b + tod.blue);
color_adjust_red_ = r ;
@ -181,7 +185,6 @@ void display::adjust_colors(int r, int g, int b)
}
void display::fill_images_list(const std::string& prefix, std::vector<std::string>& images)
{
// search prefix.png, prefix1.png, prefix2.png ...

View file

@ -80,14 +80,18 @@ public:
static Uint32 max_rgb(Uint32 first,Uint32 second)
{ return rgb(std::max(red(first),red(second)),std::max(green(first),green(second)),std::max(blue(first),blue(second))) ; }
/**
* Add r,g,b from tod_manager to the map
*
*/
void update_tod();
/**
* Add r,g,b to the colors for all images displayed on the map.
*
* Used for special effects like flashes.
*/
void adjust_colors(int r, int g, int b);
void adjust_color_overlay(int r, int g, int b);
/** Gets the underlying screen object. */

View file

@ -197,7 +197,7 @@ void game_display::new_turn()
first_turn_ = false;
display::adjust_colors(tod.red,tod.green,tod.blue);
display::update_tod();
invalidate_all();
draw();

View file

@ -718,10 +718,9 @@ WML_HANDLER_FUNCTION(volume, /*event_info*/, cfg)
}
static void color_adjust(const vconfig& cfg)
{
static void color_adjust(const vconfig& cfg) {
game_display &screen = *resources::screen;
screen.adjust_colors(cfg["red"], cfg["green"], cfg["blue"]);
screen.adjust_color_overlay(cfg["red"], cfg["green"], cfg["blue"]);
screen.invalidate_all();
screen.draw(true,true);
}

View file

@ -537,7 +537,7 @@ void play_controller::fire_start(bool execute){
void play_controller::init_gui(){
gui_->begin_game();
gui_->adjust_colors(0,0,0);
gui_->update_tod();
for(std::vector<team>::iterator t = teams_.begin(); t != teams_.end(); ++t) {
::clear_shroud(t - teams_.begin() + 1);