Freeciv21
Develop your civilization from humble roots to a global empire
layer_units.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2022-2023 Louis Moureaux <m_louis30@yahoo.com>
3  *
4  * SPDX-License-Identifier: GPLv3-or-later
5  */
6 
7 #pragma once
8 
9 #include "fc_types.h"
11 #include "unit.h"
12 
13 #include <QPoint>
14 
15 namespace freeciv {
16 
18 public:
19  explicit layer_units(struct tileset *ts, mapview_layer layer,
20  const QPoint &activity_offset,
21  const QPoint &select_offset,
22  const QPoint &unit_offset,
23  const QPoint &unit_flag_offset);
24  virtual ~layer_units() = default;
25 
26  void load_sprites() override;
27 
28  std::vector<drawn_sprite>
29  fill_sprite_array(const tile *ptile, const tile_edge *pedge,
30  const tile_corner *pcorner,
31  const unit *punit) const override;
32 
33  // What follows is a bit hacky, but we can't do better until we have more
34  // general animation support.
35 
39  auto focus_unit_state_count() const { return m_select.size(); }
40 
44  int focus_unit_state() const { return m_focus_unit_state; }
45 
50 
51 private:
52  void add_automated_sprite(std::vector<drawn_sprite> &sprs,
53  const unit *punit,
54  const QPoint &full_offset) const;
55  void add_orders_sprite(std::vector<drawn_sprite> &sprs, const unit *punit,
56  const QPoint &full_offset) const;
57 
59 
63  std::vector<QPixmap *> m_hp_bar, m_select;
64  std::array<QPixmap *, MAX_NUM_BATTLEGROUPS> m_battlegroup = {nullptr};
65  std::array<QPixmap *, MAX_VET_LEVELS> m_veteran_level = {nullptr};
66 
69 };
70 
71 } // namespace freeciv
An abstract class for layers that need sprites for unit activities.
Draws units on the map.
Definition: layer_units.h:17
QPixmap * m_action_decision_want
Definition: layer_units.h:62
std::array< QPixmap *, MAX_VET_LEVELS > m_veteran_level
Definition: layer_units.h:65
std::vector< QPixmap * > m_select
Definition: layer_units.h:63
int & focus_unit_state()
Returns the current state of the focused unit animation.
Definition: layer_units.h:49
virtual ~layer_units()=default
QPixmap * m_auto_explore
Definition: layer_units.h:60
QPixmap * m_auto_settler
Definition: layer_units.h:60
int m_focus_unit_state
State of the focused unit animation.
Definition: layer_units.h:58
layer_units(struct tileset *ts, mapview_layer layer, const QPoint &activity_offset, const QPoint &select_offset, const QPoint &unit_offset, const QPoint &unit_flag_offset)
Constructor.
Definition: layer_units.cpp:25
QPixmap * m_auto_attack
Definition: layer_units.h:60
int focus_unit_state() const
Returns the current state of the focused unit animation.
Definition: layer_units.h:44
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.
Definition: layer_units.cpp:93
void add_automated_sprite(std::vector< drawn_sprite > &sprs, const unit *punit, const QPoint &full_offset) const
Adds the sprite used to represent an automated unit on the map to sprs.
std::array< QPixmap *, MAX_NUM_BATTLEGROUPS > m_battlegroup
Definition: layer_units.h:64
void load_sprites() override
Loads all static sprites needed by this layer (activities etc).
Definition: layer_units.cpp:39
std::vector< QPixmap * > m_hp_bar
Definition: layer_units.h:63
void add_orders_sprite(std::vector< drawn_sprite > &sprs, const unit *punit, const QPoint &full_offset) const
Adds the sprite used to represent unit orders to sprs.
auto focus_unit_state_count() const
Returns the number of steps in the focused unit animation.
Definition: layer_units.h:39
A layer when drawing the map.
Definition: layer.h:153
Definition: path.cpp:10
Definition: tile.h:42
Definition: unit.h:134