Skip to content

Commit

Permalink
Synchronise defence percentage colouring for Help with that used for …
Browse files Browse the repository at this point in the history
…the side-bar.

Resolves #1531.

(cherry picked from commit 495f60d)
  • Loading branch information
Wedge009 committed Oct 25, 2019
1 parent 4dda5af commit b8ef1da
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/help/help_topic_generators.cpp
Expand Up @@ -724,19 +724,11 @@ std::string unit_topic_generator::operator()() const {
font::line_width(m.name, normal_font_size) + (high_res ? 32 : 16) );

//defense - range: +10 % .. +70 %
std::string color;
if (m.defense <= 10) {
color = "red";
} else if (m.defense <= 30) {
color = "yellow";
} else if (m.defense <= 50) {
color = "white";
} else {
color = "green";
}
// passing false to select the more saturated red-to-green scale
std::string color = game_config::red_to_green(m.defense, false).to_hex_string();

std::stringstream str;
str << "<format>color=" << color << " text='"<< m.defense << "%'</format>";
str << "<format>color='" << color << "' text='"<< m.defense << "%'</format>";
std::string markup = str.str();
str.str(clear_stringstream);
str << m.defense << "%";
Expand Down

0 comments on commit b8ef1da

Please sign in to comment.