Added the ability to highlight several hexes.
This commit is contained in:
parent
3f31ecac47
commit
7938e82745
2 changed files with 39 additions and 1 deletions
|
@ -1310,6 +1310,9 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
|
|||
loc == selectedHex_ && (un != units_.end())) {
|
||||
image_type = image::BRIGHTENED;
|
||||
}
|
||||
else if (highlighted_locations_.find(loc) != highlighted_locations_.end()) {
|
||||
image_type = image::BRIGHTENED;
|
||||
}
|
||||
|
||||
scoped_sdl_surface surface(getTerrain(terrain,image_type,x,y));
|
||||
|
||||
|
@ -2117,7 +2120,32 @@ void display::prune_chat_messages(bool remove_all)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void display::rebuild_terrain(const gamemap::location &loc) {
|
||||
builder_.rebuild_terrain(loc);
|
||||
}
|
||||
|
||||
void display::add_highlighted_loc(const gamemap::location &hex) {
|
||||
// Only invalidate and insert if this is a new addition, for
|
||||
// efficiency.
|
||||
if (highlighted_locations_.find(hex) == highlighted_locations_.end()) {
|
||||
highlighted_locations_.insert(hex);
|
||||
invalidate(hex);
|
||||
}
|
||||
}
|
||||
|
||||
void display::clear_highlighted_locs(const gamemap::location &hex) {
|
||||
for (std::set<gamemap::location>::const_iterator it = highlighted_locations_.begin();
|
||||
it != highlighted_locations_.end(); it++) {
|
||||
invalidate(*it);
|
||||
}
|
||||
highlighted_locations_.clear();
|
||||
}
|
||||
|
||||
void display::remove_highlighted_loc(const gamemap::location &hex) {
|
||||
std::set<gamemap::location>::iterator it = highlighted_locations_.find(hex);
|
||||
// Only invalidate and remove if the hex was found, for efficiency.
|
||||
if (it != highlighted_locations_.end()) {
|
||||
highlighted_locations_.erase(it);
|
||||
invalidate(hex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,6 +310,14 @@ public:
|
|||
|
||||
//rebuild the dynamic terrain at the given location.
|
||||
void rebuild_terrain(const gamemap::location &location);
|
||||
|
||||
//Add a location to highlight. Note that this has nothign to do with
|
||||
//selecting hexes, it is pure highlighting.
|
||||
void add_highlighted_loc(const gamemap::location &hex);
|
||||
|
||||
void clear_highlighted_locs(const gamemap::location &hex);
|
||||
|
||||
void remove_highlighted_loc(const gamemap::location &hex);
|
||||
|
||||
private:
|
||||
display(const display&);
|
||||
|
@ -441,6 +449,8 @@ private:
|
|||
|
||||
//for debug mode
|
||||
static std::map<gamemap::location,double> debugHighlights_;
|
||||
|
||||
std::set<gamemap::location> highlighted_locations_;
|
||||
};
|
||||
|
||||
//an object which will lock the display for the duration of its lifetime.
|
||||
|
|
Loading…
Add table
Reference in a new issue