Freeciv21
Develop your civilization from humble roots to a global empire
map_updates_handler.cpp
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 #include "map_updates_handler.h"
8 #include "city.h"
9 #include "options.h"
10 #include "tileset/tilespec.h"
11 
12 namespace freeciv {
13 
27 map_updates_handler::map_updates_handler(QObject *parent) : QObject(parent)
28 {
30 }
31 
36 {
37  m_full_update = false;
38  m_updates.clear();
39 }
40 
45 void map_updates_handler::update(const city *city, bool full)
46 {
47  if (!m_full_update) {
48  const auto tile = city_tile(city);
51  } else {
52  // Assumption: city sprites are as big as unit sprites
54  }
55  emit repaint_needed();
56  }
57 }
58 
62 void map_updates_handler::update(const tile *tile, bool full)
63 {
64  if (!m_full_update) {
65  if (full) {
67  } else {
69  }
70  emit repaint_needed();
71  }
72 }
73 
77 void map_updates_handler::update(const unit *unit, bool full)
78 {
79  if (!m_full_update) {
80  const auto tile = unit_tile(unit);
81  if (full && gui_options->draw_native) {
82  update_all();
83  } else if (full && unit_drawn_with_city_outline(unit, true)) {
85  emit repaint_needed();
86  } else {
88  emit repaint_needed();
89  }
90  }
91 }
92 
97 {
98  m_updates.clear();
99  m_full_update = true;
100  emit repaint_needed();
101 }
102 
108 {
109  if (!m_full_update) {
111  emit repaint_needed();
112  }
113 }
114 
119 {
120  if (!m_full_update) {
122  emit repaint_needed();
123  }
124 }
125 
126 } // namespace freeciv
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
Definition: city.cpp:1095
void update_all()
Requests an update of the whole (visible) map.
void update_tile_label(const tile *tile)
Registers a tile label for update.
std::map< const tile *, updates > m_updates
bool full() const
Returns true if the whole map should be updated.
void update_city_description(const city *city)
Registers a city label for update.
void clear()
Clears all pending updates.
map_updates_handler(QObject *parent=nullptr)
Constructor.
void update(const city *city, bool full)
Registers a city for update.
Definition: path.cpp:10
client_options * gui_options
Definition: options.cpp:74
Definition: city.h:291
bool draw_native
Definition: options.h:141
bool draw_borders
Definition: options.h:140
bool draw_map_grid
Definition: options.h:122
Definition: tile.h:42
Definition: unit.h:134
bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus)
Indicate whether a unit is to be drawn with a surrounding city outline under current conditions.
Definition: tilespec.cpp:3116
#define unit_tile(_pu)
Definition: unit.h:371