39#define LOG_DP LOG_STREAM(info, log_display)
47std::unique_ptr<image::locator> get_orb_image(
orb_status os)
54 + moved_color +
")~RC(magenta>" + partial_color +
")");
70std::unique_ptr<image::locator> get_playing_ally_orb_image(
orb_status os)
87 + allied_color +
")~RC(magenta>" + status_color +
")");
102 static constexpr point def_origin{14, 13};
105 static constexpr int def_w = 4;
108 static constexpr int spacing = def_w + 1;
111 static constexpr color_t background_color{0, 0, 0, 80};
114 static constexpr color_t border_color{213, 213, 213, 200};
117 static constexpr auto get_height(
int size,
double scaling)
119 return int(size * scaling);
123 static constexpr auto get_filled(
int size,
int max)
125 return std::clamp(
float(size) / max, 0.0f, 1.0f);
129 static constexpr auto get_color(
const color_t&
c,
bool focused)
135void draw_bar(
int index,
const energy_bar&
data,
const rect& bounds)
141 float(energy_bar::def_origin.x + energy_bar::spacing * index) / tile_size,
142 float(energy_bar::def_origin.y ) / tile_size,
148 std::min(p1.x +
float(
data.def_w) / tile_size, 1.0f - p1.x),
149 std::min(p1.y +
float(
data.bar_h) / tile_size, 1.0f - p1.y)
154 draw::fill(bar_rect, energy_bar::border_color);
157 const float one_pixel = 1.0f / tile_size;
159 SDL_FPoint bg1{ p1.x + one_pixel, p1.y + one_pixel };
160 SDL_FPoint bg2{ p2.x - one_pixel, p2.y - one_pixel };
164 draw::fill(inner_rect, energy_bar::background_color);
166 SDL_FPoint fill1{ 0.0f, 1.0f -
data.filled };
167 SDL_FPoint fill2{ 1.0f, 1.0f };
180 , halo_man(thedisp.get_halo_manager())
181 , viewing_team_ref(disp.viewing_team())
182 , playing_team_ref(disp.playing_team())
183 , is_blindfolded(disp.is_blindfolded())
184 , show_everything(disp.show_everything())
186 , mouse_hex(disp.mouseover_hex())
187 , zoom_factor(disp.get_zoom_factor())
188 , hex_size(disp.hex_size())
189 , hex_size_by_2(disp.hex_size() / 2)
220 ac.anim_->try_advance_to_current_frame();
227 if (!
ac.anim_)
return;
230 if (
ac.refreshing_)
return;
231 ac.refreshing_ =
true;
233 ac.anim_->try_advance_to_current_frame();
256 double blend_ratio = 0;
322 std::unique_ptr<image::locator>
orb_img =
nullptr;
371 std::vector<energy_bar>
bars;
374 bars.AGGREGATE_EMPLACE(
382 bars.AGGREGATE_EMPLACE(
398 for(std::size_t
i = 0;
i <
bars.size(); ++
i) {
433 bool has_halo =
ac.unit_halo_ &&
ac.unit_halo_->valid();
443 ac.unit_halo_.reset();
466 ac.abil_halos_.clear();
488 ac.refreshing_ =
false;
494 if(ellipse ==
"none") {
499 if(!ellipse.empty()) {
502 path <<
"misc/ellipse";
531 [images = std::move(images),
y_shift](
const rect& dest) {
532 for(const texture& tex : images) {
534 draw::blit(tex, dest.shifted_by(0, y_shift));
orb_status unit_orb_status(const unit &u) const
Returns an enumurated summary of whether this unit can move and/or attack.
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
static rect scaled_to_zoom(const rect &r)
Scale the width and height of a rect by the current zoom factor.
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
const std::set< map_location > & units_that_can_reach_goal() const
Return the locations of units that can reach goal (.
bool empty() const
Tell if the map is of 0 size.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
void set_location(const handle &h, int x, int y)
Set the position of an existing haloing effect, according to its handle.
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).
void remove(const handle &h)
Remove the halo with the given handle.
Generic locator abstracting the location of an image.
bool is_enemy(int n) const
static std::string get_side_color_id(unsigned side)
int unit_height_adjust() const
double unit_submerge() const
Wrapper class to encapsulate creation and management of an SDL_Texture.
bool selected_or_reachable(const map_location &loc) const
const team & viewing_team_ref
void redraw_unit(const unit &u) const
draw a unit.
const display_context & dc
const team & playing_team_ref
void draw_ellipses(const unit &u, const frame_parameters ¶ms) const
std::set< map_location > units_that_can_reach_goal
unit_drawer(display &thedisp)
const config & get_cfg() const
This class represents a single unit of a specific type.
static const std::string & leader_crown()
The path to the leader crown overlay.
constexpr uint8_t float_to_color(double n)
Convert a double in the range [0.0,1.0] to an 8-bit colour value.
map_display and display: classes which take care of displaying the map and game-data on the screen.
Drawing functions, for drawing things on the screen.
static lg::log_domain log_display("display")
@ unit_bar
Unit bars and overlays are drawn on this layer (for testing here)
@ unit_first
Reserve layers to be selected for wml.
@ selected_hex
Image on the selected unit.
Frame for unit's animation sequence.
bool invisible(const map_location &loc, bool see_all=true) const
bool is_visible_to_team(const team &team, bool const see_all=true) const
int max_hitpoints() const
The max number of hitpoints this unit can have.
bool incapacitated() const
Check if the unit has been petrified.
int level() const
The current level of this unit.
const unit_type & type() const
This unit's type, accounting for gender and variation.
int hitpoints() const
The current number of hitpoints this unit has.
bool slowed() const
Check if the unit has been slowed.
bool get_hidden() const
Gets whether this unit is currently hidden on the map.
int experience() const
The current number of experience points this unit has.
bool can_recruit() const
Whether this unit can recruit other units - ie, are they a leader unit.
int side() const
The side this unit belongs to.
bool poisoned() const
Check if the unit has been poisoned.
double xp_bar_scaling() const
The factor by which the XP bar should be scaled.
double hp_bar_scaling() const
The factor by which the HP bar should be scaled.
int max_experience() const
The max number of experience points this unit can have.
bool can_advance() const
Checks whether this unit has any options to advance to.
const std::vector< std::string > & overlays() const
Get the unit's overlay images.
color_t xp_color() const
Color for this unit's XP.
std::vector< std::string > halo_abilities() const
Get the [halo] abilities halo image(s).
color_t hp_color() const
Color for this unit's current hitpoints.
std::string TC_image_mods() const
Constructs a recolor (RC) IPF string for this unit's team color.
std::string image_ellipse() const
Get the unit's ellipse image.
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
std::string image_halo() const
Get the unit's halo image.
unit_animation_component & anim_comp() const
std::vector< std::string > overlays_abilities() const
Get the [overlay] ability overlay images.
bool emits_zoc() const
Tests whether the unit has a zone-of-control, considering incapacitated.
const map_location & get_location() const
The current map location this unit is at.
map_location::direction facing() const
The current direction this unit is facing within its hex.
bool is_flying() const
Check if the unit is a flying unit.
Standard logging facilities (interface).
void blit(const texture &tex, const ::rect &dst)
Draws a texture, or part of a texture, at the given location.
std::string orb_two_color
std::shared_ptr< halo_record > handle
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
point get_size(const locator &i_locator, bool skip_cache)
Returns the width and height of an image.
std::string get_orb_color(orb_status os)
Wrapper for the various prefs::get().unmoved_color(), moved_color(), etc methods, using the enum inst...
bool prefs_show_orb(orb_status os)
Wrapper for the various prefs::get().show_..._orb() methods, using the enum instead of exposing a sep...
constexpr SDL_FRect precise_subrect(const Rect &base, const SDL_FPoint &tl, const SDL_FPoint &br)
orb_status
Corresponds to the colored orbs displayed above units' hp-bar and xp-bar.
@ partial
There are still moves and/or attacks possible, but the unit doesn't fit in the "unmoved" status.
@ moved
All moves and possible attacks have been done.
@ disengaged
The unit can move but can't attack, and wouldn't be able to attack even if it was moved to a hex adja...
@ allied
Belongs to a friendly side.
@ enemy
Belongs to a non-friendly side; normally visualised by not displaying an orb.
rect dst
Location on the final composed sheet.
The basic class for representing 8-bit RGB or RGBA colour values.
All parameters from a frame at a given instant.
utils::optional< color_t > blend_with
boost::tribool primary_frame
Encapsulates the map of the game.
map_location get_direction(direction dir, unsigned int n=1u) const
direction
Valid directions which can be moved in our hexagonal world.
An abstract description of a rectangle with integer coordinates.
rect shifted_by(int x, int y) const
Returns a new rectangle shifted by the given relative position.
static map_location::direction s