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

#include <layer_city.h>

+ Inheritance diagram for freeciv::layer_city:
+ Collaboration diagram for freeciv::layer_city:

Public Types

using styles = std::vector< std::unique_ptr< freeciv::colorizer > >
 
using city_sprite = std::vector< styles >
 

Public Member Functions

 layer_city (struct tileset *ts, const QPoint &city_offset, const QPoint &city_flag_offset, const QPoint &occupied_offset)
 
virtual ~layer_city ()=default
 
void load_sprites () override
 Loads the disorder and happy sprites. More...
 
void initialize_city_style (const citystyle &style, int index) override
 Loads all sprites for a city style. More...
 
std::vector< drawn_spritefill_sprite_array (const tile *ptile, const tile_edge *pedge, const tile_corner *pcorner, const unit *punit) const override
 Fill in the given sprite array with any needed city sprites. More...
 
std::vector< drawn_spritefill_sprite_array_no_flag (const city *pcity, bool show_occupied) const
 Fill in the given sprite array with any city sprites. More...
 
QPixmap sample_sprite (int style_index=0) const
 Returns an example of what a city might look like. More...
 
void reset_ruleset () override
 All sprites depend on the ruleset-defined city styles and need to be reset. 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_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...
 
mapview_layer type () const
 

Static Public Attributes

constexpr static int NUM_WALL_TYPES = 7
 

Private Member Functions

layer_city::styles load_city_size_sprites (const QString &tag, const citystyle &style)
 Loads a set of size-dependent city sprites, with tags of the form graphic_tag_size. More...
 

Private Attributes

QPoint m_city_offset
 
QPoint m_city_flag_offset
 
QPoint m_occupied_offset
 
QPixmap * m_disorder
 
QPixmap * m_happy
 
city_sprite m_tile
 
city_sprite m_single_wall
 
city_sprite m_occupied
 
std::array< city_sprite, NUM_WALL_TYPESm_walls
 

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 20 of file layer_city.h.

Member Typedef Documentation

◆ city_sprite

Definition at line 23 of file layer_city.h.

◆ styles

using freeciv::layer_city::styles = std::vector<std::unique_ptr<freeciv::colorizer> >

Definition at line 22 of file layer_city.h.

Constructor & Destructor Documentation

◆ layer_city()

freeciv::layer_city::layer_city ( struct tileset ts,
const QPoint &  city_offset,
const QPoint &  city_flag_offset,
const QPoint &  occupied_offset 
)
explicit

Definition at line 17 of file layer_city.cpp.

◆ ~layer_city()

virtual freeciv::layer_city::~layer_city ( )
virtualdefault

Member Function Documentation

◆ fill_sprite_array()

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

Fill in the given sprite array with any needed city sprites.

The city size is not included.

Reimplemented from freeciv::layer.

Definition at line 165 of file layer_city.cpp.

◆ fill_sprite_array_no_flag()

std::vector< drawn_sprite > freeciv::layer_city::fill_sprite_array_no_flag ( const city pcity,
bool  show_occupied 
) const

Fill in the given sprite array with any city sprites.

Doesn't account for options->draw_cities. The flag and city size are not included, and the occupied city indicator is only shown if requested.

Definition at line 200 of file layer_city.cpp.

Referenced by fill_sprite_array(), freeciv::city_icon_widget::paintEvent(), and freeciv::city_icon_widget::sizeHint().

◆ initialize_city_style()

void freeciv::layer_city::initialize_city_style ( const citystyle style,
int  index 
)
overridevirtual

Loads all sprites for a city style.

Reimplemented from freeciv::layer.

Definition at line 87 of file layer_city.cpp.

◆ load_city_size_sprites()

layer_city::styles freeciv::layer_city::load_city_size_sprites ( const QString &  tag,
const citystyle style 
)
private

Loads a set of size-dependent city sprites, with tags of the form graphic_tag_size.

Definition at line 39 of file layer_city.cpp.

Referenced by initialize_city_style().

◆ load_sprites()

void freeciv::layer_city::load_sprites ( )
overridevirtual

Loads the disorder and happy sprites.

Reimplemented from freeciv::layer.

Definition at line 29 of file layer_city.cpp.

◆ reset_ruleset()

void freeciv::layer_city::reset_ruleset ( )
overridevirtual

All sprites depend on the ruleset-defined city styles and need to be reset.

Reimplemented from freeciv::layer.

Definition at line 268 of file layer_city.cpp.

◆ sample_sprite()

QPixmap freeciv::layer_city::sample_sprite ( int  style_index = 0) const
inline

Returns an example of what a city might look like.

Definition at line 46 of file layer_city.h.

Referenced by races_dialog::races_dialog().

Member Data Documentation

◆ m_city_flag_offset

QPoint freeciv::layer_city::m_city_flag_offset
private

Definition at line 58 of file layer_city.h.

Referenced by fill_sprite_array().

◆ m_city_offset

QPoint freeciv::layer_city::m_city_offset
private

Definition at line 58 of file layer_city.h.

Referenced by fill_sprite_array_no_flag().

◆ m_disorder

QPixmap* freeciv::layer_city::m_disorder
private

Definition at line 59 of file layer_city.h.

Referenced by fill_sprite_array_no_flag(), and load_sprites().

◆ m_happy

QPixmap * freeciv::layer_city::m_happy
private

Definition at line 59 of file layer_city.h.

Referenced by fill_sprite_array_no_flag(), and load_sprites().

◆ m_occupied

city_sprite freeciv::layer_city::m_occupied
private

Definition at line 61 of file layer_city.h.

Referenced by fill_sprite_array_no_flag(), initialize_city_style(), and reset_ruleset().

◆ m_occupied_offset

QPoint freeciv::layer_city::m_occupied_offset
private

Definition at line 58 of file layer_city.h.

Referenced by fill_sprite_array_no_flag().

◆ m_single_wall

city_sprite freeciv::layer_city::m_single_wall
private

Definition at line 61 of file layer_city.h.

Referenced by fill_sprite_array_no_flag(), initialize_city_style(), and reset_ruleset().

◆ m_tile

city_sprite freeciv::layer_city::m_tile
private

◆ m_walls

std::array<city_sprite, NUM_WALL_TYPES> freeciv::layer_city::m_walls
private

Definition at line 62 of file layer_city.h.

Referenced by fill_sprite_array_no_flag(), initialize_city_style(), and reset_ruleset().

◆ NUM_WALL_TYPES

constexpr static int freeciv::layer_city::NUM_WALL_TYPES = 7
staticconstexpr

Definition at line 24 of file layer_city.h.

Referenced by fill_sprite_array_no_flag().