34 #define ERR_HL LOG_STREAM(err, log_halo) 35 #define WRN_HL LOG_STREAM(warn, log_halo) 36 #define LOG_HL LOG_STREAM(info, log_halo) 37 #define DBG_HL LOG_STREAM(debug, log_halo) 68 bool on_location(
const std::set<map_location>& locations)
const;
129 invalidated_haloes(),
159 assert(
disp !=
nullptr);
175 DBG_HL <<
"setting halo location " <<
point{new_x,new_y};
213 ERR_HL <<
"no texture found for current halo animation frame";
225 const int xpos = zero_x +
abs_mid_.x -
w/2;
226 const int ypos = zero_y +
abs_mid_.y -
h/2;
318 for(
const std::string&
item : items) {
320 std::string str =
item;
323 if(sub_items.size() > 1) {
324 str = sub_items.front();
326 time = std::stoi(sub_items.back());
327 }
catch(
const std::invalid_argument&) {
328 ERR_HL <<
"Invalid time value found when constructing halo: " << sub_items.back();
334 haloes.emplace(
id,
effect(x, y, image_vector, loc, orientation, infinite));
336 if(
haloes.find(
id)->second.does_change() || !infinite) {
345 if(itor !=
haloes.end()) {
346 itor->second.set_location(x,y);
376 DBG_HL <<
"invalidating deleted halo " <<
id;
380 for(
int id : deleted_haloes) {
385 deleted_haloes.clear();
388 for(
auto& [
id,
halo] : haloes) { (void)
id;
394 auto&
halo = haloes.at(
id);
395 if(
halo.need_update() &&
halo.visible()) {
396 DBG_HL <<
"invalidating changed halo " <<
id;
410 DBG_HL <<
"drawing intersected halo " <<
id;
429 int new_halo =
impl_->add(x,y,image, loc, orientation, infinite);
436 impl_->set_location(h->id_,x,y);
442 impl_->remove(h->id_);
475 if (!
valid())
return;
477 std::shared_ptr<halo_impl> man =
my_manager_.lock();
Drawing functions, for drawing things on the screen.
static lg::log_domain log_halo("halo")
bool visible()
Whether the halo is currently visible.
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 ...
int w() const
The draw-space width of the texture, in pixels.
static const map_location & ZERO()
animated< image::locator > images_
static double get_zoom_factor()
Returns the current zoom factor.
void render(const rect &)
Render all halos overlapping the given region.
int h() const
The draw-space height of the texture, in pixels.
void update()
Update the current location, animation frame, etc.
const std::vector< std::string > items
std::set< int > deleted_haloes
Upon deleting, a halo isn't deleted but added to this set, upon unrendering the image is unrendered a...
void update()
Process animations, remove deleted halos, and invalidate screen regions now requiring redraw...
std::map< int, effect > haloes
std::weak_ptr< halo_impl > my_manager_
Wrapper class to encapsulate creation and management of an SDL_Texture.
halo_record()
halo::halo_record implementation
bool location_not_known() const
bool does_not_change() const
map_display and display: classes which take care of displaying the map and game-data on the screen...
effect(int xpos, int ypos, const animated< image::locator >::anim_description &img, const map_location &loc, ORIENTATION, bool infinite)
void remove(int handle)
Remove the halo with the given handle.
bool overlaps(const SDL_Rect &r) const
Whether the given rectangle and this rectangle overlap.
Generic locator abstracting the location of an image.
void render(const rect &r)
Render halos in region.
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).
bool on_location(const std::set< map_location > &locations) const
halo_impl()
impl's of exposed functions
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)
clip_setter reduce_clip(const SDL_Rect &clip)
Set the clipping area to the intersection of the current clipping area and the given rectangle...
std::string id
Text to match against addon_info.tags()
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
void start_animation(int start_time, bool cycles=false)
Starts an animation cycle.
An abstract description of a rectangle with integer coordinates.
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.
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
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.
Contains the SDL_Rect helper code.
std::vector< std::string > split(const config_attribute_value &val)
void flipped(const texture &tex, const SDL_Rect &dst, bool flip_h=true, bool flip_v=false)
Draws a texture, or part of a texture, at the given location, also mirroring/flipping the texture hor...
Functions to load and save images from/to disk.
Standard logging facilities (interface).
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
RAII object which manages a halo.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
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
void invalidate_region(const rect ®ion)
Mark a region of the screen as requiring redraw.
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.