Freeciv21
Develop your civilization from humble roots to a global empire
layer_infrawork.cpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPLv3-or-later
2 // SPDX-FileCopyrightText: Freeciv authors
3 // SPDX-FileCopyrightText: Freeciv21 authors
4 // SPDX-FileCopyrightText: Louis Moureaux <m_louis30@yahoo.com>
5 
6 #include "layer_infrawork.h"
7 
8 #include "citydlg_g.h"
9 #include "tilespec.h"
10 #include "workertask.h"
11 
17 namespace freeciv {
18 
23  const QPoint &activity_offset)
24  : freeciv::layer_abstract_activities(ts, LAYER_INFRAWORK),
25  m_activity_offset(activity_offset)
26 {
27 }
28 
29 std::vector<drawn_sprite>
31  const tile_corner *pcorner,
32  const unit *punit) const
33 {
34  Q_UNUSED(pedge);
35  Q_UNUSED(pcorner);
36 
37  // Should we draw anything in the first place?
38  if (!ptile || !ptile->placing) {
39  return {};
40  }
41 
42  // Now we draw
43  std::vector<drawn_sprite> sprs;
44 
45  if (auto sprite = activity_sprite(ACTIVITY_IDLE, ptile->placing)) {
46  sprs.emplace_back(tileset(), sprite, true,
49  }
50 
51  return sprs;
52 }
53 
54 } // namespace freeciv
An abstract class for layers that need sprites for unit activities.
QPixmap * activity_sprite(unit_activity id, const extra_type *extra) const
Returns the sprite used to represent a given activity on the map.
layer_infrawork(struct tileset *ts, const QPoint &activity_offset)
Constructor.
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.
struct tileset * tileset() const
Definition: layer.h:241
Definition: path.cpp:10
Definition: tile.h:42
struct extra_type * placing
Definition: tile.h:53
Definition: unit.h:134
QPoint tileset_full_tile_offset(const struct tileset *t)
Return the x and y offsets of full tiles in the tileset.
Definition: tilespec.cpp:416