Restore tod_color struct
Since it represents a colour delta rather than an absolute colour, the
color_t struct is not a sufficient substitute.
This partially reverts commit 0adeea43e0
.
The formatting changes from that commit were not reverted, nor was
including colour in time-of-day equality. The unused tod_color::operator*=
was not restored, either.
This commit is contained in:
parent
cb9ec9b225
commit
d0bb55159d
5 changed files with 35 additions and 13 deletions
|
@ -417,12 +417,12 @@ const tod_manager & display::get_tod_man() const
|
|||
|
||||
void display::update_tod() {
|
||||
const time_of_day& tod = get_time_of_day();
|
||||
color_t col = color_adjust_.plus_clipped(tod.color);
|
||||
tod_color col = color_adjust_ + tod.color;
|
||||
image::set_color_adjustment(col.r, col.g, col.b);
|
||||
}
|
||||
|
||||
void display::adjust_color_overlay(int r, int g, int b) {
|
||||
color_adjust_ = color_t(r, g, b);
|
||||
color_adjust_ = tod_color(r, g, b);
|
||||
update_tod();
|
||||
}
|
||||
|
||||
|
@ -1117,18 +1117,18 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
|
|||
|
||||
if(lt.empty()) {
|
||||
//color the full hex before adding transitions
|
||||
color_t col = tod.color.plus_clipped(color_adjust_);
|
||||
tod_color col = tod.color + color_adjust_;
|
||||
lt = image::get_light_string(6, col.r, col.g, col.b);
|
||||
}
|
||||
|
||||
// add the directional transitions
|
||||
color_t acol = atod.color.plus_clipped(color_adjust_);
|
||||
tod_color acol = atod.color + color_adjust_;
|
||||
lt += image::get_light_string(d, acol.r, acol.g, acol.b);
|
||||
}
|
||||
|
||||
if(lt.empty()){
|
||||
color_t col = tod.color.plus_clipped(color_adjust_);
|
||||
if(!col.empty(false)){
|
||||
tod_color col = tod.color + color_adjust_;
|
||||
if(!col.is_zero()){
|
||||
// no real lightmap needed but still color the hex
|
||||
lt = image::get_light_string(-1, col.r, col.g, col.b);
|
||||
}
|
||||
|
@ -2606,13 +2606,13 @@ void display::draw_hex(const map_location& loc) {
|
|||
|
||||
if(have_overlays) {
|
||||
const time_of_day& loc_tod = get_time_of_day(loc);
|
||||
const color_t& loc_col = loc_tod.color;
|
||||
const tod_color& loc_col = loc_tod.color;
|
||||
|
||||
if(loc_col != get_time_of_day().color) {
|
||||
// Continue with local light. image::get_lighted_image
|
||||
// doesn't take the image::TOD_COLORED type, so we need
|
||||
// to apply the color_adjust_ ourselves.
|
||||
color_t col = loc_col.plus_clipped(color_adjust_);
|
||||
tod_color col = loc_col + color_adjust_;
|
||||
lt = image::get_light_string(-1, col.r, col.g, col.b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1060,7 +1060,7 @@ private:
|
|||
/** Maps the list of arrows for each location */
|
||||
arrows_map_t arrows_map_;
|
||||
|
||||
color_t color_adjust_;
|
||||
tod_color color_adjust_;
|
||||
|
||||
bool dirty_;
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int i
|
|||
{
|
||||
context_manager_->get_map_context().set_starting_time(index);
|
||||
const tod_manager* tod = context_manager_->get_map_context().get_time_manager();
|
||||
color_t col = tod->times()[index].color;
|
||||
tod_color col = tod->times()[index].color;
|
||||
image::set_color_adjustment(col.r, col.g, col.b);
|
||||
return true;
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int i
|
|||
std::advance(iter, index);
|
||||
context_manager_->get_map_context().replace_schedule(iter->second.second);
|
||||
const tod_manager* tod = context_manager_->get_map_context().get_time_manager();
|
||||
color_t col = tod->times()[0].color;
|
||||
tod_color col = tod->times()[0].color;
|
||||
image::set_color_adjustment(col.r, col.g, col.b);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, const tod_color& c){
|
||||
s << c.r << "," << c.g << "," << c.b;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
time_of_day::time_of_day(const config& cfg):
|
||||
lawful_bonus(cfg["lawful_bonus"]),
|
||||
bonus_modified(0),
|
||||
|
|
|
@ -20,10 +20,26 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "tstring.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class config;
|
||||
|
||||
/** Small struct to store and manipulate ToD colors */
|
||||
|
||||
struct tod_color{
|
||||
explicit tod_color(int red = 0, int green = 0, int blue = 0) : r(red), g(green), b(blue) {}
|
||||
bool operator==(const tod_color& o) const { return r == o.r && g == o.g && b == o.b; }
|
||||
bool is_zero() const { return r == 0 && g == 0 && b == 0; }
|
||||
bool operator!=(const tod_color& o) const { return !operator==(o); }
|
||||
tod_color operator+(const tod_color& o) const { return tod_color(r+o.r, g+o.g, b+o.b);}
|
||||
|
||||
int r,g,b;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, const tod_color& tod);
|
||||
|
||||
|
||||
/**
|
||||
* Object which defines a time of day
|
||||
* with associated bonuses, image, sounds etc.
|
||||
|
@ -74,7 +90,7 @@ struct time_of_day
|
|||
* The color modifications that should be made
|
||||
* to the game board to reflect the time of day.
|
||||
*/
|
||||
color_t color;
|
||||
tod_color color;
|
||||
|
||||
/**
|
||||
* List of "ambient" sounds associated with this time_of_day,
|
||||
|
|
Loading…
Add table
Reference in a new issue