31 #define ERR_DP LOG_STREAM(err, log_display) 53 bool on_location(
const std::set<map_location>& locations)
const;
111 invalidated_haloes(),
132 void unrender(std::set<map_location> invalidated_locations);
150 assert(
disp !=
nullptr);
162 if (new_x !=
x_ || new_y !=
y_) {
172 if(
disp ==
nullptr) {
195 if(
surf_ ==
nullptr) {
208 const int xpos =
x_ + screenx -
surf_->w/2;
209 const int ypos =
y_ + screeny -
surf_->h/2;
211 SDL_Rect rect {xpos, ypos,
surf_->w,
surf_->h};
220 for (;i != end; ++
i) {
234 SDL_Rect rect2 =
rect_;
237 SDL_Rect rect2 =
rect_;
271 const int xpos =
x_ + screenx -
surf_->w/2;
272 const int ypos =
y_ + screeny -
surf_->h/2;
274 SDL_Rect rect {xpos, ypos,
surf_->w,
surf_->h};
280 for(std::vector<map_location>::const_iterator itor =
overlayed_hexes_.begin();
282 if(locations.find(*itor) != locations.end()) {
296 for(std::vector<map_location>::const_iterator itor =
overlayed_hexes_.begin();
299 locations.insert(*itor);
312 for(
const std::string&
item : items) {
314 std::string str =
item;
317 if(sub_items.size() > 1) {
318 str = sub_items.front();
320 time = std::stoi(sub_items.back());
321 }
catch(
const std::invalid_argument&) {
322 ERR_DP <<
"Invalid time value found when constructing halo: " << sub_items.back() <<
"\n";
328 haloes.emplace(
id,
effect(
disp, x, y, image_vector, loc, orientation, infinite));
330 if(
haloes.find(
id)->second.does_change() || !infinite) {
339 if(itor !=
haloes.end()) {
340 itor->second.set_location(x,y);
364 for(; itor !=
haloes.end(); ++itor ) {
365 if(itor->second.expired()) {
374 haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
380 if(
haloes.find(*set_itor)->second.need_update()) {
382 haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
393 for(itor =
haloes.begin(); itor !=
haloes.end(); ++itor) {
397 (itor->second.location_not_known() ||
398 itor->second.on_location(invalidated_locations))) {
402 itor->second.add_overlay_location(invalidated_locations);
408 if(halo_count == 0) {
414 for(std::map<int, effect>::reverse_iterator ritor =
haloes.rbegin(); ritor !=
haloes.rend(); ++ritor) {
416 ritor->second.unrender();
442 invalidated_haloes.clear();
455 int new_halo =
impl_->add(x,y,image, loc, orientation, infinite);
462 impl_->set_location(h->id_,x,y);
468 impl_->remove(h->id_);
480 impl_->unrender(invalidated_locations);
507 if (!
valid())
return;
509 std::shared_ptr<halo_impl> man =
my_manager_.lock();
surface get_image(const image::locator &i_locator, TYPE type)
Caches and returns an image.
std::vector< map_location > overlayed_hexes_
All locations over which the halo lies.
static int hex_size()
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
static const map_location & ZERO()
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)
Horizontally flips an image.
halo_impl(display &screen)
impl's of exposed functions
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...
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...
std::weak_ptr< halo_impl > my_manager_
static lg::log_domain log_display("display")
void unrender(std::set< map_location > invalidated_locations)
Render and unrender haloes.
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)
bool location_not_known() const
surface flop_surface(const surface &surf)
effect(display *screen, int xpos, int ypos, const animated< image::locator >::anim_description &img, const map_location &loc, ORIENTATION, bool infinite)
bool does_not_change() const
map_display and display: classes which take care of displaying the map and game-data on the screen...
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) ...
void remove(int handle)
Remove the halo with the given handle.
Generic locator abstracting the location of an image.
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).
Image rescaled according to the zoom settings.
bool on_location(const std::set< map_location > &locations) const
Encapsulates the map of the game.
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
int add(int x, int y, const std::string &image, const map_location &loc, ORIENTATION orientation=NORMAL, bool infinite=true)
surface & get_screen_surface()
return the screen surface or the surface used for map_screenshot.
const T & get_current_frame() const
std::shared_ptr< halo_impl > impl_
void update_last_draw_time(double acceleration=0)
std::set< int > changing_haloes
Haloes that have an animation or expiration time need to be checked every frame and are stored in thi...
int get_location_y(const map_location &loc) const
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
void start_animation(int start_time, bool cycles=false)
Starts an animation cycle.
void unrender(std::set< map_location > invalidated_locations)
Render and unrender haloes.
void set_location(int x, int y)
void set_location(const handle &h, int x, int y)
Set the position of an existing haloing effect, according to its handle.
std::set< int > invalidated_haloes
Upon unrendering, an invalidation list is send.
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
constexpr const SDL_Rect empty_rect
std::vector< std::string > split(const config_attribute_value &val)
Functions to load and save images from/to disk.
Standard logging facilities (interface).
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.
const image::locator & current_image() const
void set_location(int handle, int x, int y)
Set the position of an existing haloing effect, according to its handle.
std::shared_ptr< halo_record > handle
std::string::const_iterator iterator
bool animation_finished() const
Returns true if the current animation was finished.
std::vector< std::string > square_parenthetical_split(const std::string &val, const char separator, const std::string &left, const std::string &right, const int flags)
Similar to parenthetical_split, but also expands embedded square brackets.
std::pair< std::string, unsigned > item
void remove(const handle &h)
Remove the halo with the given handle.