Freeciv21
Develop your civilization from humble roots to a global empire
layer_workertask.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_workertask.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_WORKERTASK),
25  m_activity_offset(activity_offset)
26 {
27 }
28 
29 std::vector<drawn_sprite> layer_workertask::fill_sprite_array(
30  const tile *ptile, const tile_edge *pedge, const tile_corner *pcorner,
31  const unit *punit) const
32 {
33  Q_UNUSED(pedge);
34  Q_UNUSED(pcorner);
35 
36  // Should we draw anything in the first place?
37  const auto city = is_any_city_dialog_open();
38  if (!city || !ptile) {
39  return {};
40  }
41 
42  // Now we draw
43  std::vector<drawn_sprite> sprs;
44 
46  {
47  if (ptask->ptile == ptile) {
48  if (auto sprite = activity_sprite(ptask->act, ptask->tgt)) {
49  sprs.emplace_back(tileset(), sprite, true,
52  }
53  }
54  }
56 
57  return sprs;
58 }
59 
60 } // namespace freeciv
struct city * is_any_city_dialog_open()
Definition: citydlg.cpp:2315
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.
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.
layer_workertask(struct tileset *ts, const QPoint &activity_offset)
Constructor.
struct tileset * tileset() const
Definition: layer.h:241
Definition: path.cpp:10
Definition: city.h:291
struct worker_task_list * task_reqs
Definition: city.h:381
Definition: tile.h:42
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
#define worker_task_list_iterate(tasklist, ptask)
Definition: workertask.h:27
#define worker_task_list_iterate_end
Definition: workertask.h:29