Little bonus feature to check out terrain defense...

...for the units you select when it's not your turn.

Feedback needed, if people like it I'll do a bit of code cleanup,
otherwise this revision will be easy to revert.

This feature will be useful for the whiteboard's out-of-turn planning,
but I can always re-implement it specifically for the whiteboard move
arrows.

Note: the feature doesn't work while enemy units (at least AI units)
are moving/attacking.
This commit is contained in:
Gabriel Morin 2010-07-22 08:43:19 +00:00
parent e9e24e7fe6
commit efd6983ccf
3 changed files with 20 additions and 0 deletions

View File

@ -188,6 +188,7 @@ Version 1.9.0-svn:
to override them without first removing them
* [effect] violate_maximum= (for use when increasing HP) takes a real boolean
value now instead of taking any non-empty value as "true".
* Allow checking out terrain defense for units when it's not your turn.
* Miscellaneous and bug fixes:
* Added help entry when new unit is created directly in the recall list
* Defaulted log level to warning again

View File

@ -69,6 +69,7 @@ Version 1.9.0-svn:
* Display weapon stats in recruit/recall dialog the same way as in sidebar.
* Remember recall list sorting order.
* New mouseover image instead of simply highlighting the hex
* Allow checking out terrain defense for units when it's not your turn.
* Miscellaneous and bug fixes:
* All villages except water and swamp villages can now be placed on any base

View File

@ -628,6 +628,24 @@ void game_display::draw_movement_info(const map_location& loc)
return;
}
}
// When out-of-turn, it's still interesting to check out the terrain defs of the selected unit
else if (selectedHex_.valid() && loc == mouseoverHex_)
{
const unit_map::const_iterator selectedUnit = units_.find(selectedHex_);
const unit_map::const_iterator mouseoveredUnit = units_.find(mouseoverHex_);
if(selectedUnit != units_.end() && mouseoveredUnit == units_.end()) {
// Display the def% of this terrain
int def = 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc));
std::stringstream def_text;
def_text << def << "%";
SDL_Color color = int_to_color(game_config::red_to_green(def, false));
// use small font
int def_font = 16;
draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
}
}
if (!reach_map_.empty()) {
reach_map::iterator reach = reach_map_.find(loc);