Add a "terrain def.: 60%" (with color) to the main sidebar

to give more visibility to this important stat and because the topbar
defense is really not nice.
This commit is contained in:
Ali El Gariani 2009-09-08 01:32:58 +00:00
parent e089ad53f1
commit 1a5cbd6cef
3 changed files with 27 additions and 2 deletions

View file

@ -452,10 +452,18 @@
xanchor=right
yanchor=fixed
[/unit_abilities]
[unit_defense]
id=unit-defense
font_size={DEFAULT_FONT_SMALL}
rect="=,+0,=,+16"
prefix= _ "statuspanel^terrain def."
prefix_literal=": "
xanchor=right
yanchor=fixed
[/unit_defense]
[unit_moves]
id=unit-moves
font_size={DEFAULT_FONT_SMALL}
ref=unit-abilities
rect="=,+0,=+2,+16"
prefix= _ "statuspanel^movement"
prefix_literal=": "

View file

@ -392,10 +392,18 @@
xanchor=right
yanchor=fixed
[/unit_abilities]
[unit_defense]
id=unit-defense
font_size={DEFAULT_FONT_SMALL}
rect="=,+0,=,+16"
prefix= _ "statuspanel^terrain def."
prefix_literal=": "
xanchor=right
yanchor=fixed
[/unit_defense]
[unit_moves]
id=unit-moves
font_size={EXPERIMENTAL_FONT_SMALL}
ref=unit-abilities
rect="=,+0,=+2,+16"
prefix= _ "statuspanel^movement"
prefix_literal=": "

View file

@ -207,6 +207,15 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
}
return(res);
}
case UNIT_DEFENSE: {
const t_translation::t_terrain terrain = map[displayed_unit_hex];
int def = 100 - u->defense_modifier(terrain);
int val = (game_config::defense_color_scale.size()-1) * def/100;
SDL_Color color = int_to_color(game_config::defense_color_scale[val]);
str << font::color2markup(color);
str << def << "%";
break;
}
case UNIT_MOVES: {
float movement_frac = 1.0;
if (u->side() == playing_side) {