Freeciv21
Develop your civilization from humble roots to a global empire
drawn_sprite.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021 Freeciv21 contributors
3  * SPDX-FileCopyrightText: 2023 Louis Moureaux <m_louis30@yahoo.com>
4  *
5  * SPDX-License-Identifier: GPLv3-or-later
6  */
7 
8 #include "drawn_sprite.h"
9 
10 #include "tilespec.h"
11 
12 #include <QPixmap>
13 #include <QRect>
14 
18 drawn_sprite::drawn_sprite(const struct tileset *ts, const QPixmap *sprite,
19  bool foggable, int offset_x, int offset_y)
20  : sprite(sprite), foggable(foggable && tileset_use_hard_coded_fog(ts)),
21  offset(offset_x, offset_y)
22 {
24 }
25 
29 drawn_sprite::drawn_sprite(const struct tileset *ts, const QPixmap *sprite,
30  bool foggable, const QPoint &offset)
31  : drawn_sprite(ts, sprite, foggable, offset.x(), offset.y())
32 {
33 }
34 
38 QRect sprite_array_bounds(const std::vector<drawn_sprite> &sprs)
39 {
40  QRect bounds;
41  for (const auto &sprite : sprs) {
42  bounds |= QRect(sprite.offset, sprite.sprite->size());
43  }
44  return bounds;
45 }
QRect sprite_array_bounds(const std::vector< drawn_sprite > &sprs)
Calculates the bounding rectangle of the given sprite array.
#define fc_assert(condition)
Definition: log.h:89
drawn_sprite(const struct tileset *ts, const QPixmap *sprite, bool foggable=true, int offset_x=0, int offset_y=0)
Instantiates a drawn sprite, ensuring that it's never null.
const QPixmap * sprite
Definition: drawn_sprite.h:30
bool tileset_use_hard_coded_fog(const struct tileset *t)
Return TRUE if the client will use the code to generate the fog.
Definition: tilespec.cpp:531