Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::layer_units Class Reference

Draws units on the map. More...

#include <layer_units.h>

+ Inheritance diagram for freeciv::layer_units:
+ Collaboration diagram for freeciv::layer_units:

Public Member Functions

 layer_units (struct tileset *ts, mapview_layer layer, const QPoint &activity_offset, const QPoint &select_offset, const QPoint &unit_offset, const QPoint &unit_flag_offset)
 Constructor. More...
 
virtual ~layer_units ()=default
 
void load_sprites () override
 Loads all static sprites needed by this layer (activities etc). More...
 
std::vector< drawn_spritefill_sprite_array (const tile *ptile, const tile_edge *pedge, const tile_corner *pcorner, const unit *punit) const override
 Returns the list of sprites drawn by this layer somewhere on the map. More...
 
auto focus_unit_state_count () const
 Returns the number of steps in the focused unit animation. More...
 
int focus_unit_state () const
 Returns the current state of the focused unit animation. More...
 
int & focus_unit_state ()
 Returns the current state of the focused unit animation. More...
 
- Public Member Functions inherited from freeciv::layer_abstract_activities
void initialize_extra (const extra_type *extra, const QString &tag, extrastyle_id style) override
 Loads the extra activity and remove activity sprites. More...
 
void reset_ruleset () override
 Resets data about extras. More...
 
QPixmap * activity_sprite (unit_activity id, const extra_type *extra) const
 Returns the sprite used to represent a given activity on the map. More...
 
 layer (struct tileset *ts, mapview_layer layer)
 Inherited constructor. More...
 
- Public Member Functions inherited from freeciv::layer
 layer (struct tileset *ts, mapview_layer layer)
 Constructor. More...
 
virtual ~layer ()=default
 Destructor. More...
 
virtual void initialize_player (const player *player)
 Initializes data specific to one player. More...
 
virtual void free_player (int player_id)
 Frees data initialized by initialize_player. More...
 
virtual void initialize_city_style (const citystyle &style, int index)
 Initializes data for a city style. More...
 
virtual void initialize_terrain (const terrain *terrain)
 Initializes terrain-specific data. More...
 
mapview_layer type () const
 

Private Member Functions

void add_automated_sprite (std::vector< drawn_sprite > &sprs, const unit *punit, const QPoint &full_offset) const
 Adds the sprite used to represent an automated unit on the map to sprs. More...
 
void add_orders_sprite (std::vector< drawn_sprite > &sprs, const unit *punit, const QPoint &full_offset) const
 Adds the sprite used to represent unit orders to sprs. More...
 

Private Attributes

int m_focus_unit_state = 0
 State of the focused unit animation. More...
 
QPixmap * m_auto_attack
 
QPixmap * m_auto_settler
 
QPixmap * m_auto_explore
 
QPixmap * m_connect
 
QPixmap * m_loaded
 
QPixmap * m_lowfuel
 
QPixmap * m_patrol
 
QPixmap * m_stack
 
QPixmap * m_tired
 
QPixmap * m_action_decision_want
 
std::vector< QPixmap * > m_hp_bar
 
std::vector< QPixmap * > m_select
 
std::array< QPixmap *, MAX_NUM_BATTLEGROUPSm_battlegroup = {nullptr}
 
std::array< QPixmap *, MAX_VET_LEVELSm_veteran_level = {nullptr}
 
QPoint m_activity_offset
 
QPoint m_select_offset
 
QPoint m_unit_offset
 
QPoint m_unit_flag_offset
 

Additional Inherited Members

- Protected Member Functions inherited from freeciv::layer
struct tilesettileset () const
 
bool do_draw_unit (const tile *ptile, const unit *punit) const
 Whether a unit should be drawn. More...
 
bool solid_background (const tile *ptile, const unit *punit, const city *pcity) const
 Whether a solid background should be drawn on a tile instead of its terrain. More...
 
QPixmap * load_sprite (const QStringList &possible_names, bool required=false, bool verbose=true) const
 Shortcut to load a sprite from the tileset. More...
 

Detailed Description

Draws units on the map.

Definition at line 17 of file layer_units.h.

Constructor & Destructor Documentation

◆ layer_units()

freeciv::layer_units::layer_units ( struct tileset ts,
mapview_layer  layer,
const QPoint &  activity_offset,
const QPoint &  select_offset,
const QPoint &  unit_offset,
const QPoint &  unit_flag_offset 
)
explicit

Constructor.

Definition at line 25 of file layer_units.cpp.

◆ ~layer_units()

virtual freeciv::layer_units::~layer_units ( )
virtualdefault

Member Function Documentation

◆ add_automated_sprite()

void freeciv::layer_units::add_automated_sprite ( std::vector< drawn_sprite > &  sprs,
const unit punit,
const QPoint &  full_offset 
) const
private

Adds the sprite used to represent an automated unit on the map to sprs.

Definition at line 211 of file layer_units.cpp.

Referenced by fill_sprite_array().

◆ add_orders_sprite()

void freeciv::layer_units::add_orders_sprite ( std::vector< drawn_sprite > &  sprs,
const unit punit,
const QPoint &  full_offset 
) const
private

Adds the sprite used to represent unit orders to sprs.

Definition at line 242 of file layer_units.cpp.

Referenced by fill_sprite_array().

◆ fill_sprite_array()

std::vector< drawn_sprite > freeciv::layer_units::fill_sprite_array ( const tile ptile,
const tile_edge pedge,
const tile_corner pcorner,
const unit punit 
) const
overridevirtual

Returns the list of sprites drawn by this layer somewhere on the map.

Only one of ptile, pedge, or pcorner should be non-null.

Reimplemented from freeciv::layer.

Definition at line 93 of file layer_units.cpp.

◆ focus_unit_state() [1/2]

int& freeciv::layer_units::focus_unit_state ( )
inline

Returns the current state of the focused unit animation.

Definition at line 49 of file layer_units.h.

◆ focus_unit_state() [2/2]

int freeciv::layer_units::focus_unit_state ( ) const
inline

Returns the current state of the focused unit animation.

Definition at line 44 of file layer_units.h.

Referenced by fill_sprite_array(), get_drawable_unit(), reset_focus_unit_state(), and toggle_focus_unit_state().

◆ focus_unit_state_count()

auto freeciv::layer_units::focus_unit_state_count ( ) const
inline

Returns the number of steps in the focused unit animation.

Definition at line 39 of file layer_units.h.

Referenced by focus_unit_in_combat(), get_drawable_unit(), get_focus_unit_toggle_timeout(), and toggle_focus_unit_state().

◆ load_sprites()

void freeciv::layer_units::load_sprites ( )
overridevirtual

Loads all static sprites needed by this layer (activities etc).

Reimplemented from freeciv::layer_abstract_activities.

Definition at line 39 of file layer_units.cpp.

Member Data Documentation

◆ m_action_decision_want

QPixmap * freeciv::layer_units::m_action_decision_want
private

Definition at line 62 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_activity_offset

QPoint freeciv::layer_units::m_activity_offset
private

Definition at line 67 of file layer_units.h.

Referenced by add_automated_sprite(), add_orders_sprite(), and fill_sprite_array().

◆ m_auto_attack

QPixmap* freeciv::layer_units::m_auto_attack
private

Definition at line 60 of file layer_units.h.

Referenced by add_automated_sprite(), and load_sprites().

◆ m_auto_explore

QPixmap * freeciv::layer_units::m_auto_explore
private

Definition at line 60 of file layer_units.h.

Referenced by add_automated_sprite(), and load_sprites().

◆ m_auto_settler

QPixmap * freeciv::layer_units::m_auto_settler
private

Definition at line 60 of file layer_units.h.

Referenced by add_automated_sprite(), and load_sprites().

◆ m_battlegroup

std::array<QPixmap *, MAX_NUM_BATTLEGROUPS> freeciv::layer_units::m_battlegroup = {nullptr}
private

Definition at line 64 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_connect

QPixmap * freeciv::layer_units::m_connect
private

Definition at line 60 of file layer_units.h.

Referenced by add_orders_sprite(), and load_sprites().

◆ m_focus_unit_state

int freeciv::layer_units::m_focus_unit_state = 0
private

State of the focused unit animation.

Definition at line 58 of file layer_units.h.

Referenced by focus_unit_state().

◆ m_hp_bar

std::vector<QPixmap *> freeciv::layer_units::m_hp_bar
private

Definition at line 63 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_loaded

QPixmap * freeciv::layer_units::m_loaded
private

Definition at line 61 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_lowfuel

QPixmap * freeciv::layer_units::m_lowfuel
private

Definition at line 61 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_patrol

QPixmap * freeciv::layer_units::m_patrol
private

Definition at line 61 of file layer_units.h.

Referenced by add_orders_sprite(), and load_sprites().

◆ m_select

std::vector<QPixmap *> freeciv::layer_units::m_select
private

Definition at line 63 of file layer_units.h.

Referenced by fill_sprite_array(), focus_unit_state_count(), and load_sprites().

◆ m_select_offset

QPoint freeciv::layer_units::m_select_offset
private

Definition at line 67 of file layer_units.h.

Referenced by fill_sprite_array().

◆ m_stack

QPixmap * freeciv::layer_units::m_stack
private

Definition at line 61 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_tired

QPixmap * freeciv::layer_units::m_tired
private

Definition at line 61 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().

◆ m_unit_flag_offset

QPoint freeciv::layer_units::m_unit_flag_offset
private

Definition at line 68 of file layer_units.h.

Referenced by fill_sprite_array().

◆ m_unit_offset

QPoint freeciv::layer_units::m_unit_offset
private

Definition at line 67 of file layer_units.h.

Referenced by fill_sprite_array().

◆ m_veteran_level

std::array<QPixmap *, MAX_VET_LEVELS> freeciv::layer_units::m_veteran_level = {nullptr}
private

Definition at line 65 of file layer_units.h.

Referenced by fill_sprite_array(), and load_sprites().