25 :
freeciv::
layer(ts, LAYER_DARKNESS), m_style(style), m_sprites{}
32 case freeciv::DARKNESS_NONE:
35 case freeciv::DARKNESS_ISORECT: {
37 QPixmap *darkness =
load_sprite({QStringLiteral(
"tx.darkness")});
41 {ntw / 2, 0}, {0, nth / 2}, {ntw / 2, nth / 2}, {0, 0}};
46 for (
int i = 0; i < 4; i++) {
47 const auto sprite = std::unique_ptr<QPixmap>(
48 crop_sprite(darkness, offsets[i][0], offsets[i][1], ntw / 2,
49 nth / 2,
nullptr, 0, 0));
53 case freeciv::DARKNESS_CARD_SINGLE:
65 _(
"Sprite for tag '%s' missing."),
66 qUtf8Printable(buffer));
70 case freeciv::DARKNESS_CARD_FULL:
72 auto buffer = QStringLiteral(
"tx.darkness_%1")
80 _(
"Sprite for tag '%s' missing."),
81 qUtf8Printable(buffer));
85 case freeciv::DARKNESS_CORNER:
91 std::vector<drawn_sprite>
94 const unit *punit)
const
108 auto sprites = std::vector<drawn_sprite>();
111 struct tile *adjc_tile;
113 const auto is_unknown = [&](direction8 dir) {
121 case DARKNESS_ISORECT:
122 for (i = 0; i < 4; i++) {
125 int offsets[4][2] = {{W / 2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}};
133 case DARKNESS_CARD_SINGLE:
140 case DARKNESS_CARD_FULL:
157 case DARKNESS_CORNER:
QPixmap crop_sprite(const QPixmap *sprite)
Helper function to crop a sprite.
std::array< QPixmap, MAX_INDEX_CARDINAL > m_sprites
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 list of sprites drawn by this layer somewhere on the map.
void set_sprite(std::size_t index, const QPixmap &p)
Sets one of the sprites used to draw the darkness.
layer_darkness(struct tileset *ts, darkness_style style)
void load_sprites() override
Loads all the sprites needed to draw the darkness.
A layer when drawing the map.
QPixmap * load_sprite(const QStringList &possible_names, bool required=false, bool verbose=true) const
Shortcut to load a sprite from the tileset.
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.
struct tileset * tileset() const
enum known_type client_tile_get_known(const struct tile *ptile)
A tile's "known" field is used by the server to store whether each player knows the tile.
struct tile * mapstep(const struct civ_map *nmap, const struct tile *ptile, enum direction8 dir)
Step from the given tile in the given direction.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
int tileset_num_cardinal_dirs(const struct tileset *t)
Returns the number of cardinal directions used by the tileset.
std::array< direction8, 8 > tileset_cardinal_dirs(const struct tileset *t)
Returns the cardinal directions used by the tileset.
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
void tileset_error(struct tileset *t, QtMsgType level, const char *format,...)
Called when ever there's problem in ruleset/tileset compatibility.
QString cardinal_index_str(const struct tileset *t, int idx)
Return a directional string for the cardinal directions.
int tileset_num_index_cardinals(const struct tileset *t)
Returns the number of cardinal indices used by the tileset.
QString dir_get_tileset_name(enum direction8 dir)
Return the tileset name of the direction.
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
constexpr direction8 DIR4_TO_DIR8[4]