Added support for color= in [unstore_unit] and [print]

This commit is contained in:
Charles Dang 2015-12-14 00:10:54 +11:00
parent 43709fe49d
commit c43df77725
3 changed files with 23 additions and 3 deletions

View file

@ -84,6 +84,7 @@ static lg::log_domain log_display("display");
static lg::log_domain log_wml("wml");
#define LOG_WML LOG_STREAM(info, log_wml)
#define WRN_WML LOG_STREAM(warn, log_wml)
#define ERR_WML LOG_STREAM(err, log_wml)
static lg::log_domain log_config("config");
@ -1342,7 +1343,15 @@ WML_HANDLER_FUNCTION(unstore_unit, /*event_info*/, cfg)
if(!text.empty() && !controller->is_skipping_replay())
{
// Print floating label
resources::screen->float_label(loc, text, create_color(cfg["red"], cfg["green"], cfg["blue"]));
SDL_Color color = font::LABEL_COLOR;
if(!cfg["color"].empty()) {
color = string_to_color(cfg["color"]);
} else if(cfg.has_attribute("red") || cfg.has_attribute("green") || cfg.has_attribute("blue")) {
color = create_color(cfg["red"], cfg["green"], cfg["blue"]);
}
resources::screen->float_label(loc, text, color);
}
if(advance) {
advance_unit_at(advance_unit_params(loc)

View file

@ -397,7 +397,11 @@ void terrain_label::read(const config &cfg)
team_name_ = utils::interpolate_variables_into_string(team_name_, vs);
tmp_color = utils::interpolate_variables_into_string(tmp_color, vs);
color_ = (color = string_to_color(tmp_color));
if(!tmp_color.empty()) {
color = string_to_color(tmp_color);
}
color_ = color;
}
void terrain_label::write(config& cfg) const

View file

@ -2255,7 +2255,14 @@ int game_lua_kernel::intf_print(lua_State *L) {
int size = cfg["size"].to_int(font::SIZE_SMALL);
int lifetime = cfg["duration"].to_int(50);
SDL_Color color = create_color(cfg["red"], cfg["green"], cfg["blue"]);
SDL_Color color = font::LABEL_COLOR;
if(!cfg["color"].empty()) {
color = string_to_color(cfg["color"]);
} else if(cfg.has_attribute("red") || cfg.has_attribute("green") || cfg.has_attribute("blue")) {
color = create_color(cfg["red"], cfg["green"], cfg["blue"]);
}
const SDL_Rect& rect = game_display_->map_outside_area();