Skip to content

Commit

Permalink
Added support for color= in [unstore_unit] and [print]
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Dec 15, 2015
1 parent 43709fe commit c43df77
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/game_events/action_wml.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/map_label.cpp
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/scripting/game_lua_kernel.cpp
Expand Up @@ -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();

Expand Down

0 comments on commit c43df77

Please sign in to comment.