Replaced uses of the tod_color struct with color_t
This commit is contained in:
parent
9aff81a89c
commit
0adeea43e0
6 changed files with 31 additions and 49 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();
|
||||
tod_color col = color_adjust_ + tod.color;
|
||||
color_t col = color_adjust_.plus_clipped(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_ = tod_color(r, g, b);
|
||||
color_adjust_ = color_t(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
|
||||
tod_color col = tod.color + color_adjust_;
|
||||
color_t col = tod.color.plus_clipped(color_adjust_);
|
||||
lt = image::get_light_string(6, col.r, col.g, col.b);
|
||||
}
|
||||
|
||||
// add the directional transitions
|
||||
tod_color acol = atod.color + color_adjust_;
|
||||
color_t acol = atod.color.plus_clipped(color_adjust_);
|
||||
lt += image::get_light_string(d, acol.r, acol.g, acol.b);
|
||||
}
|
||||
|
||||
if(lt.empty()){
|
||||
tod_color col = tod.color + color_adjust_;
|
||||
if(!col.is_zero()){
|
||||
color_t col = tod.color.plus_clipped(color_adjust_);
|
||||
if(!col.empty(false)){
|
||||
// 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 tod_color& loc_col = loc_tod.color;
|
||||
const color_t& 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.
|
||||
tod_color col = loc_col + color_adjust_;
|
||||
color_t col = loc_col.plus_clipped(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_;
|
||||
|
||||
tod_color color_adjust_;
|
||||
color_t 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();
|
||||
tod_color col = tod->times()[index].color;
|
||||
color_t 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();
|
||||
tod_color col = tod->times()[0].color;
|
||||
color_t col = tod->times()[0].color;
|
||||
image::set_color_adjustment(col.r, col.g, col.b);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
#include "terrain/filter.hpp" // for terrain_filter
|
||||
#include "terrain/translation.hpp" // for read_terrain_code, etc
|
||||
#include "terrain/type_data.hpp"
|
||||
#include "time_of_day.hpp" // for time_of_day, tod_color
|
||||
#include "time_of_day.hpp" // for time_of_day
|
||||
#include "tod_manager.hpp" // for tod_manager
|
||||
#include "tstring.hpp" // for t_string, operator+
|
||||
#include "units/unit.hpp" // for unit, intrusive_ptr_add_ref, etc
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
|
||||
#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),
|
||||
|
@ -39,15 +33,15 @@ time_of_day::time_of_day(const config& cfg):
|
|||
}
|
||||
|
||||
time_of_day::time_of_day()
|
||||
: lawful_bonus(0)
|
||||
, bonus_modified(0)
|
||||
, image()
|
||||
, name(N_("Stub Time of Day"))
|
||||
, description(N_("This Time of Day is only a Stub!"))
|
||||
, id("nulltod")
|
||||
, image_mask()
|
||||
, color(0,0,0)
|
||||
, sounds()
|
||||
: lawful_bonus(0)
|
||||
, bonus_modified(0)
|
||||
, image()
|
||||
, name(N_("Stub Time of Day"))
|
||||
, description(N_("This Time of Day is only a Stub!"))
|
||||
, id("nulltod")
|
||||
, image_mask()
|
||||
, color(0,0,0)
|
||||
, sounds()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -20,27 +20,10 @@
|
|||
#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);}
|
||||
void operator*=(float x) { r *= x; g *= x; b *= x;}
|
||||
|
||||
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.
|
||||
|
@ -59,9 +42,14 @@ struct time_of_day
|
|||
explicit time_of_day(const config& cfg);
|
||||
|
||||
bool operator==(const time_of_day& o) const {
|
||||
return lawful_bonus == o.lawful_bonus && bonus_modified == o.bonus_modified
|
||||
&& image == o.image && name == o.name && id == o.id
|
||||
&& image_mask == o.image_mask && color == o.color && sounds == o.sounds;
|
||||
return lawful_bonus == o.lawful_bonus
|
||||
&& bonus_modified == o.bonus_modified
|
||||
&& image == o.image
|
||||
&& name == o.name
|
||||
&& id == o.id
|
||||
&& image_mask == o.image_mask
|
||||
//&& color == o.color
|
||||
&& sounds == o.sounds;
|
||||
}
|
||||
|
||||
void write(config& cfg) const;
|
||||
|
@ -86,7 +74,7 @@ struct time_of_day
|
|||
* The color modifications that should be made
|
||||
* to the game board to reflect the time of day.
|
||||
*/
|
||||
tod_color color;
|
||||
color_t color;
|
||||
|
||||
/**
|
||||
* List of "ambient" sounds associated with this time_of_day,
|
||||
|
|
Loading…
Add table
Reference in a new issue