![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
Draws "road" extras on the map. More...
#include <layer_roads.h>
Inheritance diagram for freeciv::layer_roads:
Collaboration diagram for freeciv::layer_roads:Classes | |
| struct | corner_sprites |
| Stores the data common to all road types. More... | |
| struct | data |
| Helper. More... | |
Public Member Functions | |
| layer_roads (struct tileset *ts) | |
| Constructor. More... | |
| virtual | ~layer_roads ()=default |
| void | initialize_extra (const extra_type *extra, const QString &tag, extrastyle_id style) override |
| Collects all extras to be drawn. More... | |
| std::vector< drawn_sprite > | fill_sprite_array (const tile *ptile, const tile_edge *pedge, const tile_corner *pcorner, const unit *punit) const override |
| Returns the sprites to draw roads. More... | |
| void | reset_ruleset () override |
| Resets cached data that depends on the ruleset. 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_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 Types | |
| using | all_combined_data = data< std::array< QPixmap *, MAX_INDEX_VALID > > |
| Data for RoadAllCombined. More... | |
| using | all_separate_data = data< std::array< QPixmap *, DIR8_MAGIC_MAX > > |
| Data for RoadAllSeparate. More... | |
| using | parity_combined_data = data< std::pair< std::array< QPixmap *, MAX_INDEX_HALF >, std::array< QPixmap *, MAX_INDEX_HALF > >> |
| Data for RoadParityCombined. .first = even, .second = odd. More... | |
Private Member Functions | |
| void | initialize_corners (corner_sprites &data, const extra_type *extra, const QString &tag, const terrain *terrain) |
| Initializes "corner" sprite data. More... | |
| void | fill_corners (std::vector< drawn_sprite > &sprs, const corner_sprites &data, const tile *ptile) const |
| Fills "corner" sprites that help complete diagonal roads where they overlap with adjacent tiles. More... | |
| void | initialize_all_combined (all_combined_data &data, const QString &tag, const terrain *terrain) |
| Initializes sprite data for RoadAllCombined. More... | |
| void | fill_all_combined (std::vector< drawn_sprite > &sprs, const all_combined_data &data, const tile *ptile) const |
| Fill sprites for extras with type RoadAllCombined. More... | |
| void | initialize_all_separate (all_separate_data &data, const QString &tag, const terrain *terrain) |
| Initializes sprite data for RoadAllSeparate. More... | |
| void | fill_all_separate (std::vector< drawn_sprite > &sprs, const all_separate_data &data, const tile *ptile) const |
| Fill sprites for extras with type RoadAllSeparate. More... | |
| void | initialize_parity_combined (parity_combined_data &data, const QString &tag, const terrain *terrain) |
| Initializes sprite data for RoadAllSeparate. More... | |
| void | fill_parity_combined (std::vector< drawn_sprite > &sprs, const parity_combined_data &data, const tile *ptile) const |
| Fill sprites for extras with type RoadAllSeparate. More... | |
Private Attributes | |
| std::vector< std::vector< all_combined_data > > | m_all_combined |
| std::vector< std::vector< all_separate_data > > | m_all_separate |
| std::vector< std::vector< parity_combined_data > > | m_parity_combined |
Additional Inherited Members | |
Protected Member Functions inherited from freeciv::layer | |
| struct tileset * | tileset () 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... | |
Draws "road" extras on the map.
Road extras are those with style RoadAllSeparate, RoadParityCombined, and RoadAllCombined.
Definition at line 18 of file layer_roads.h.
|
private |
Data for RoadAllCombined.
Definition at line 32 of file layer_roads.h.
|
private |
Data for RoadAllSeparate.
Definition at line 34 of file layer_roads.h.
|
private |
Data for RoadParityCombined. .first = even, .second = odd.
Definition at line 36 of file layer_roads.h.
|
explicit |
Constructor.
Definition at line 31 of file layer_roads.cpp.
|
virtualdefault |
|
private |
Fill sprites for extras with type RoadAllCombined.
It is a very simple method that lets us simply retrieve entire finished tiles, with a bitwise index of the presence of roads in each direction.
Definition at line 425 of file layer_roads.cpp.
Referenced by fill_sprite_array().
|
private |
Fill sprites for extras with type RoadAllSeparate.
We simply draw one sprite for every connection. This means we only need a few sprites, but a lot of drawing is necessary and it generally doesn't look very good.
Definition at line 442 of file layer_roads.cpp.
Referenced by fill_sprite_array().
|
private |
Fills "corner" sprites that help complete diagonal roads where they overlap with adjacent tiles.
Only relevant for overhead square tilesets.
Definition at line 341 of file layer_roads.cpp.
Referenced by fill_sprite_array().
|
private |
Fill sprites for extras with type RoadAllSeparate.
We draw one sprite for cardinal road connections, one sprite for diagonal road connections. This means we need about 4x more sprites than in style 0, but up to 4x less drawing is needed. The drawing quality may also be improved.
Definition at line 467 of file layer_roads.cpp.
Referenced by fill_sprite_array().
|
overridevirtual |
Returns the sprites to draw roads.
Reimplemented from freeciv::layer.
Definition at line 293 of file layer_roads.cpp.
|
private |
Initializes sprite data for RoadAllCombined.
Definition at line 94 of file layer_roads.cpp.
Referenced by initialize_extra().
|
private |
Initializes sprite data for RoadAllSeparate.
Definition at line 111 of file layer_roads.cpp.
Referenced by initialize_extra().
|
private |
Initializes "corner" sprite data.
Definition at line 73 of file layer_roads.cpp.
|
overridevirtual |
Collects all extras to be drawn.
Reimplemented from freeciv::layer.
Definition at line 39 of file layer_roads.cpp.
|
private |
Initializes sprite data for RoadAllSeparate.
Definition at line 131 of file layer_roads.cpp.
Referenced by initialize_extra().
|
overridevirtual |
Resets cached data that depends on the ruleset.
Reimplemented from freeciv::layer.
Definition at line 501 of file layer_roads.cpp.
|
private |
Definition at line 81 of file layer_roads.h.
Referenced by fill_sprite_array(), initialize_extra(), and reset_ruleset().
|
private |
Definition at line 82 of file layer_roads.h.
Referenced by fill_sprite_array(), initialize_extra(), and reset_ruleset().
|
private |
Definition at line 83 of file layer_roads.h.
Referenced by fill_sprite_array(), initialize_extra(), and reset_ruleset().