added the option to draw overlays on terrains filter by location,

...selected and mouseover hex
This commit is contained in:
Mark de Wever 2007-02-16 19:39:18 +00:00
parent 1233e5184e
commit 64dd7b02e5
3 changed files with 54 additions and 1 deletions

View file

@ -35,6 +35,8 @@ Version 1.3-svn:
* star shaped "ellipses" for leaders and hero units
* crown icons for heros and expendable allied leaders.
* item graphic improvements including animate-able campfire.
* added the option to draw overlays on terrains filter by
location, selected and mouseover hex
* terrain
* added peaks to the impassable mountains
* added bridges crossing swamp and deep water

View file

@ -1551,6 +1551,25 @@ void display::draw_tile(const gamemap::location &loc, const SDL_Rect &clip_rect)
}
}
// Add the top layer overlay surfaces
if(! hex_overlay_.empty()) {
std::map<gamemap::location, surface>::const_iterator itor = hex_overlay_.find(loc);
if(itor != hex_overlay_.end()) {
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
SDL_BlitSurface(itor->second,NULL,dst,&dstrect);
}
}
if(loc == selectedHex_ && map_.on_board(selectedHex_) && selected_hex_overlay_ != NULL) {
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
SDL_BlitSurface(selected_hex_overlay_,NULL,dst,&dstrect);
}
if(loc == mouseoverHex_ && map_.on_board(mouseoverHex_) && mouseover_hex_overlay_ != NULL) {
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
SDL_BlitSurface(mouseover_hex_overlay_,NULL,dst,&dstrect);
}
update_rect(xpos,ypos,zoom_,zoom_);
}
@ -2003,6 +2022,16 @@ void display::float_label(const gamemap::location& loc, const std::string& text,
0,-2,60,screen_area(),font::CENTER_ALIGN,NULL,0,font::ANCHOR_LABEL_MAP);
}
void display::clear_hex_overlay(const gamemap::location& loc)
{
if(! hex_overlay_.empty()) {
std::map<gamemap::location, surface>::iterator itor = hex_overlay_.find(loc);
if(itor != hex_overlay_.end()) {
hex_overlay_.erase(itor);
}
}
}
void display::draw_unit(int x, int y, surface image,
bool upside_down, fixed_t alpha, Uint32 blendto, double blend_ratio, double submerged,
surface ellipse_back, surface ellipse_front)

View file

@ -195,6 +195,24 @@ public:
int red, int green, int blue);
const gamemap& get_map()const { return map_;}
// The last action in drawing a tile is adding the overlays
// these overlays are drawn in the following order
// hex_overlay_ if the drawn location is in the map
// selected_hex_overlay_ if the drawn location is selected
// mouseover_hex_overlay_ if the drawn location is underneath the mouse
//
// These functions require a prerendered surface since they are
// drawn at the top, they are not influenced by TOD, shroud etc
void set_hex_overlay(const gamemap::location& loc, surface image) { hex_overlay_[loc] = image; }
void clear_hex_overlay(const gamemap::location& loc);
void set_selected_hex_overlay(const surface& image) { selected_hex_overlay_ = image; }
void clear_selected_hex_overlay() { selected_hex_overlay_ = NULL; }
void set_mouseover_hex_overlay(const surface& image) { mouseover_hex_overlay_ = image; }
void clear_mouseover_hex_overlay() { mouseover_hex_overlay_ = NULL; }
private:
enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND, ADJACENT_FOGSHROUD };
@ -419,6 +437,10 @@ private:
int xpos_, ypos_, zoom_;
const gamemap& map_;
std::map<gamemap::location, surface> hex_overlay_;
surface selected_hex_overlay_;
surface mouseover_hex_overlay_;
gamemap::location selectedHex_;
gamemap::location mouseoverHex_;
@ -457,7 +479,7 @@ private:
struct overlay {
overlay(const std::string& img, const std::string& halo_img,
int handle) : image(img), halo(halo_img),
halo_handle(handle) {}
halo_handle(handle) {}
std::string image;
std::string halo;
int halo_handle;