116 invalidated_haloes(),
138 void unrender(std::set<map_location> invalidated_locations);
146 orientation_(orientation),
156 assert(
disp !=
nullptr);
168 if (new_x !=
x_ || new_y !=
y_) {
172 buffer_.assign(
nullptr);
173 overlayed_hexes_.clear();
179 if(
disp ==
nullptr) {
200 images_.update_last_draw_time();
202 if(surf_ ==
nullptr) {
215 const int xpos =
x_ + screenx - surf_->w/2;
216 const int ypos =
y_ + screeny - surf_->h/2;
224 if(location_not_known()) {
227 for (;i !=
end; ++
i) {
228 overlayed_hexes_.push_back(*i);
233 buffer_.assign(
nullptr);
240 if(buffer_ ==
nullptr || buffer_->w != rect.w || buffer_->h != rect.h) {
241 SDL_Rect rect = rect_;
244 SDL_Rect rect = rect_;
248 sdl_blit(surf_,
nullptr,screen,&rect);
257 if (!surf_ || !buffer_) {
280 const int xpos =
x_ + screenx - surf_->w/2;
281 const int ypos =
y_ + screeny - surf_->h/2;
284 sdl_blit(buffer_,
nullptr,screen,&rect);
290 for(std::vector<map_location>::const_iterator
itor = overlayed_hexes_.begin();
291 itor != overlayed_hexes_.end(); ++
itor) {
292 if(locations.find(*
itor) != locations.end()) {
301 return overlayed_hexes_.empty();
306 for(std::vector<map_location>::const_iterator
itor = overlayed_hexes_.begin();
307 itor != overlayed_hexes_.end(); ++
itor) {
309 locations.insert(*
itor);
321 std::vector<std::string>::const_iterator
itor = items.begin();
322 for(; itor != items.end(); ++
itor) {
323 const std::vector<std::string>& items =
utils::split(*itor,
':');
327 if(items.size() > 1) {
329 time = std::stoi(items.back());
337 haloes.insert(std::pair<int,effect>(
id,
effect(
disp,x,y,image_vector,loc,orientation,infinite)));
339 if(
haloes.find(
id)->second.does_change() || !infinite) {
348 if(itor !=
haloes.end()) {
349 itor->second.set_location(x,y);
374 if(itor->second.expired()) {
383 haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
389 if(
haloes.find(*set_itor)->second.need_update()) {
391 haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
406 (itor->second.location_not_known() ||
407 itor->second.on_location(invalidated_locations))) {
411 itor->second.add_overlay_location(invalidated_locations);
417 if(halo_count == 0) {
423 for(std::map<int, effect>::reverse_iterator ritor =
haloes.rbegin(); ritor !=
haloes.rend(); ++ritor) {
425 ritor->second.unrender();
451 std::set<int> unrendered_new_haloes;
459 !
itor->second.render()) {
461 unrendered_new_haloes.insert(
itor->first);
463 itor->second.render();
481 int new_halo =
impl_->add(x,y,image, loc, orientation, infinite);
488 impl_->set_location(h->id_,x,y);
494 impl_->remove(h->id_);
506 impl_->unrender(invalidated_locations);
528 my_manager_(my_manager)
533 if (!
valid())
return;
540 }
catch (std::exception &
e) {
541 std::cerr <<
"Caught an exception in halo::halo_record destructor: \n" << e.what() << std::endl;
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
tformula< unsigned > x_
The x coordinate of the rectangle.
std::vector< map_location > overlayed_hexes_
All locations over which the halo lies.
animated< image::locator > images_
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
surface reverse_image(const surface &surf)
function to reverse an image.
const SDL_Rect empty_rect
halo_impl(display &screen)
impl's of exposed functions
static const map_location & ZERO()
Old implementation:
map_location loc_
The location of the center of the halo.
std::set< int > deleted_haloes
Upon deleting, a halo isn't deleted but added to this set, upon unrendering the image is unrendered a...
std::set< int > new_haloes
A newly added halo will be added to this list, these haloes don't need to be unrendered but do not to...
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
GLint GLint GLint GLint GLint GLint y
const std::vector< std::string > items
std::map< int, effect > haloes
surface get_surface_portion(const surface &src, SDL_Rect &area)
Get a portion of the screen.
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
void unrender(std::set< map_location > invalidated_locations)
Render and unrender haloes.
int get_location_y(const map_location &loc) const
very simple iterator to walk into the rect_of_hexes
halo_record()
halo::halo_record implementation
void add_overlay_location(std::set< map_location > &locations)
boost::weak_ptr< halo_impl > my_manager_
bool on_location(const std::set< map_location > &locations) const
effect(display *screen, int xpos, int ypos, const animated< image::locator >::anim_description &img, const map_location &loc, ORIENTATION, bool infinite)
const T & get_current_frame() const
boost::shared_ptr< halo_impl > impl_
const image::locator & current_image()
map_display and display: classes which take care of displaying the map and game-data on the screen...
void remove(int handle)
Remove the halo with the given handle.
GLsizei const GLint * locations
surface flop_surface(const surface &surf, bool optimize)
handle add(int x, int y, const std::string &image, const map_location &loc, halo::ORIENTATION orientation=NORMAL, bool infinite=true)
Add a haloing effect using 'image centered on (x,y).
Encapsulates the map of the game.
int add(int x, int y, const std::string &image, const map_location &loc, ORIENTATION orientation=NORMAL, bool infinite=true)
bool location_not_known() const
surface & get_screen_surface()
return the screen surface or the surface used for map_screenshot.
std::map< std::string, tfilter >::iterator itor
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
std::set< int > changing_haloes
Haloes that have an animation or expiration time need to be checked every frame and are stored in thi...
GLfloat GLfloat GLfloat GLfloat h
void unrender(std::set< map_location > invalidated_locations)
Render and unrender haloes.
void set_location(int x, int y)
GLint GLint GLint GLint GLint x
tformula< unsigned > y_
The y coordinate of the rectangle.
bool animation_finished() const
Returns true if the current animation was finished.
void set_location(const handle &h, int x, int y)
Set the position of an existing haloing effect, according to its handle.
const rect_of_hexes hexes_under_rect(const SDL_Rect &r) const
Return the rectangular area of hexes overlapped by r (r is in screen coordinates) ...
std::set< int > invalidated_haloes
Upon unrendering, an invalidation list is send.
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
this module manages the cache of images.
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
bool does_not_change() const
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
void sdl_copy_portion(const surface &screen, SDL_Rect *screen_rect, surface &dst, SDL_Rect *dst_rect)
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
RAII object which manages a halo.
int hex_size() const
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
void set_location(int handle, int x, int y)
Set the position of an existing haloing effect, according to its handle.
void update_rect(const SDL_Rect &)
std::vector< std::string > square_parenthetical_split(std::string const &val, const char separator, std::string const &left, std::string const &right, const int flags)
Similar to parenthetical_split, but also expands embedded square brackets.
GLsizei const GLcharARB ** string
boost::shared_ptr< halo_record > handle
void start_animation(int start_time, bool cycles=false)
Starts an animation cycle.
void remove(const handle &h)
Remove the halo with the given handle.