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

#include <layer_background.h>

+ Inheritance diagram for freeciv::layer_background:
+ Collaboration diagram for freeciv::layer_background:

Public Member Functions

 layer_background (struct tileset *ts)
 
virtual ~layer_background ()=default
 
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...
 
void initialize_player (const player *player) override
 Initializes data specific to one player. More...
 
void free_player (int player_id) override
 Frees data initialized by initialize_player. More...
 
- Public Member Functions inherited from freeciv::layer
 layer (struct tileset *ts, mapview_layer layer)
 Constructor. More...
 
virtual ~layer ()=default
 Destructor. More...
 
virtual void load_sprites ()
 Loads all sprites that do not depend on the ruleset. More...
 
virtual void initialize_city_style (const citystyle &style, int index)
 Initializes data for a city style. More...
 
virtual void initialize_extra (const extra_type *extra, const QString &tag, extrastyle_id style)
 Initializes extra-specific data. More...
 
virtual void initialize_terrain (const terrain *terrain)
 Initializes terrain-specific data. More...
 
virtual void reset_ruleset ()
 Resets cached data that depends on the ruleset. More...
 
mapview_layer type () const
 

Private Member Functions

std::unique_ptr< QPixmap > create_player_sprite (const QColor &pcolor) const
 Create a sprite with the given color. More...
 

Private Attributes

std::array< std::unique_ptr< QPixmap >, MAX_NUM_PLAYER_SLOTSm_player_background
 

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

Definition at line 25 of file layer_background.h.

Constructor & Destructor Documentation

◆ layer_background()

freeciv::layer_background::layer_background ( struct tileset ts)
explicit

Definition at line 24 of file layer_background.cpp.

◆ ~layer_background()

virtual freeciv::layer_background::~layer_background ( )
virtualdefault

Member Function Documentation

◆ create_player_sprite()

std::unique_ptr< QPixmap > freeciv::layer_background::create_player_sprite ( const QColor &  pcolor) const
private

Create a sprite with the given color.

Definition at line 82 of file layer_background.cpp.

Referenced by initialize_player().

◆ fill_sprite_array()

std::vector< drawn_sprite > freeciv::layer_background::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 29 of file layer_background.cpp.

◆ free_player()

void freeciv::layer_background::free_player ( int  player_id)
overridevirtual

Frees data initialized by initialize_player.

Note that this takes the player ID and not a pointer to the player; the player may have never existed.

See also
initialize_player

Reimplemented from freeciv::layer.

Definition at line 73 of file layer_background.cpp.

◆ initialize_player()

void freeciv::layer_background::initialize_player ( const player player)
overridevirtual

Initializes data specific to one player.

This allows to cache tiles depending on the actual players in a game.

See also
free_player

Reimplemented from freeciv::layer.

Definition at line 58 of file layer_background.cpp.

Member Data Documentation

◆ m_player_background

std::array<std::unique_ptr<QPixmap>, MAX_NUM_PLAYER_SLOTS> freeciv::layer_background::m_player_background
private

Definition at line 42 of file layer_background.h.

Referenced by fill_sprite_array(), free_player(), and initialize_player().