Freeciv21
Develop your civilization from humble roots to a global empire
view_map.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2023 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9  */
10 
11 /*
12  * This file contains functions to generate the GUI for the
13  * the main map view.
14  */
15 
16 #include <memory>
17 
18 // Qt
19 #include <QCommandLinkButton>
20 #include <QMouseEvent>
21 #include <QPainter>
22 
23 // utility
24 #include "log.h"
25 // client
26 #include "citybar.h"
27 #include "citydlg_g.h"
28 #include "client_main.h"
29 #include "climap.h"
30 #include "climisc.h"
31 #include "colors_common.h"
32 #include "fc_client.h"
33 #include "fonts.h"
34 #include "hudwidget.h"
35 #include "mapctrl_common.h"
36 #include "mapview_g.h"
37 #include "messagewin.h"
38 #include "minimap_panel.h"
39 #include "page_game.h"
40 #include "qtg_cxxside.h"
41 #include "renderer.h"
42 #include "text.h"
43 #include "tileset/sprite.h"
44 #include "tileset/tilespec.h"
45 #include "top_bar.h"
46 #include "views/view_map.h"
47 #include "views/view_map_common.h"
48 #include "views/view_research.h"
49 #include "widgets/decorations.h"
50 
51 static int mapview_frozen_level = 0;
52 extern void destroy_city_dialog();
53 extern QPixmap *canvas;
54 static QRegion dirty;
55 
57 extern int last_center_enemy;
58 extern int last_center_capital;
59 extern int last_center_player_city;
60 extern int last_center_enemy_city;
61 
65 void draw_calculated_trade_routes(QPainter *painter)
66 {
67  int dx, dy;
68  float w, h;
69  float x1, y1, x2, y2;
70  QPen pen;
71 
72  if (!can_client_control() || king()->trade_gen.cities.empty()) {
73  return;
74  }
75  auto color = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT);
76  // Draw calculated trade routes
78  for (auto qgilles : qAsConst(king()->trade_gen.lines)) {
79  base_map_distance_vector(&dx, &dy, TILE_XY(qgilles.t1),
80  TILE_XY(qgilles.t2));
81  map_to_gui_vector(tileset, &w, &h, dx, dy);
82 
83  tile_to_canvas_pos(&x1, &y1, qgilles.t1);
84  tile_to_canvas_pos(&x2, &y2, qgilles.t2);
85 
86  // Dont draw if route was already established
87  if (tile_city(qgilles.t1) && tile_city(qgilles.t2)
88  && have_cities_trade_route(tile_city(qgilles.t1),
89  tile_city(qgilles.t2))) {
90  continue;
91  }
92 
93  if (qgilles.autocaravan != nullptr) {
94  color = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT);
95  }
96 
97  pen.setColor(color);
98  pen.setStyle(Qt::DashLine);
99  pen.setDashOffset(4);
100  pen.setWidth(1);
101  painter->setPen(pen);
102  if (x2 - x1 == w && y2 - y1 == h) {
103  painter->drawLine(x1 + tileset_tile_width(tileset) / 2,
104  y1 + tileset_tile_height(tileset) / 2,
105  x1 + tileset_tile_width(tileset) / 2 + w,
106  y1 + tileset_tile_height(tileset) / 2 + h);
107  continue;
108  }
109  painter->drawLine(x2 + tileset_tile_width(tileset) / 2,
110  y2 + tileset_tile_height(tileset) / 2,
111  x2 + tileset_tile_width(tileset) / 2 - w,
112  y2 + tileset_tile_height(tileset) / 2 - h);
113  }
114  }
115  // Draw virtual cities
116  for (auto *pcity : qAsConst(king()->trade_gen.virtual_cities)) {
117  float canvas_x, canvas_y;
118  if (pcity->tile != nullptr
119  && tile_to_canvas_pos(&canvas_x, &canvas_y, pcity->tile)) {
120  painter->drawPixmap(static_cast<int>(canvas_x),
121  static_cast<int>(canvas_y),
123  }
124  }
125 }
126 
131  : QWidget(), m_renderer(new freeciv::renderer(this)),
132  m_origin_animation(
133  std::make_unique<QPropertyAnimation>(m_renderer, "origin")),
134  m_scale_animation(std::make_unique<QPropertyAnimation>(this, "scale"))
135 {
137  qOverload<const QRegion &>(&map_view::update));
138 
139  cursor = -1;
140  QTimer *timer = new QTimer(this);
141  setAttribute(Qt::WA_OpaquePaintEvent, true);
142  connect(timer, &QTimer::timeout, this, &map_view::timer_event);
143  timer->start(200);
144  resize(0, 0);
145  setMouseTracking(true);
146  setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
147 }
148 
153 {
154  int i;
155 
156  if (ct == CURSOR_DEFAULT) {
157  setCursor(Qt::ArrowCursor);
158  cursor = -1;
159  return;
160  }
161  cursor_frame = 0;
162  i = static_cast<int>(ct);
163  cursor = i;
164  setCursor(*(king()->fc_cursors[i][0]));
165 }
166 
171 {
172  QList<fcwidget *> fcl = this->findChildren<fcwidget *>();
173  for (auto *widget : qAsConst(fcl)) {
174  if (widget->isVisible()) {
175  widget->hide();
176  m_hidden_fcwidgets.push_back(widget);
177  }
178  }
179 }
180 
185 {
186  for (auto &widget : m_hidden_fcwidgets) {
187  if (widget) {
188  widget->show();
189  }
190  }
191  m_hidden_fcwidgets.clear();
192 }
193 
197 void map_view::center_on_tile(tile *tile, bool animate)
198 {
199  int tile_x, tile_y;
200  index_to_map_pos(&tile_x, &tile_y, tile_index(tile));
201 
202  float gui_x, gui_y;
203  map_to_gui_pos(tileset, &gui_x, &gui_y, tile_x, tile_y);
204 
205  // Put the center pixel of the tile at the exact center of the mapview.
206  gui_x -= (mapview.width - tileset_tile_width(tileset)) / 2;
207  gui_y -= (mapview.height - tileset_tile_height(tileset)) / 2;
208 
209  m_origin_animation->stop();
210  if (animate) {
212  m_origin_animation->setCurrentTime(0);
213 
214  const auto start = QPointF(mapview.gui_x0, mapview.gui_y0);
215  m_origin_animation->setStartValue(start);
216 
217  // To wrap correctly, we first find the direction in which the animation
218  // should go and then choose the end point for Qt's linear interpolation.
219  float diff_x, diff_y;
220  gui_distance_vector(tileset, &diff_x, &diff_y, mapview.gui_x0,
221  mapview.gui_y0, gui_x, gui_y);
222  m_origin_animation->setEndValue(start + QPointF(diff_x, diff_y));
223 
224  m_origin_animation->start();
225  } else {
226  m_renderer->set_origin(QPointF(gui_x, gui_y));
227  }
228 }
229 
233 void map_view::zoom_in() { set_scale(1.2 * scale()); }
234 
239 
243 void map_view::zoom_out() { set_scale(scale() / 1.2); }
244 
248 double map_view::scale() const { return m_renderer->scale(); }
249 
253 void map_view::set_scale(double scale, bool animate)
254 {
255  m_scale_animation->stop();
256  m_scale_animation->setEndValue(scale);
257  if (animate) {
259  m_scale_animation->setCurrentTime(0);
260  m_scale_animation->start();
261  } else {
263  }
264 }
265 
269 void map_view::set_scale_now(double scale)
270 {
272  emit scale_changed(scale);
273 }
274 
279 {
280  if (!m_debugger) {
281  // We never destroy it once it's created.
284  [](bool active) {
285  if (active) {
286  set_hover_state({}, HOVER_DEBUG_TILE, ACTIVITY_LAST, nullptr,
288  ORDER_LAST);
289  } else if (!active && hover_state == HOVER_DEBUG_TILE) {
291  }
292  });
293  }
294 
295  m_debugger->show();
296 }
297 
302 {
303  if (m_debugger) {
304  m_debugger->set_tile(nullptr);
305  m_debugger->close();
306  }
307 }
308 
313 {
314  if (queen()->minimap_panel->underMouse()
315  || queen()->top_bar_wdg->underMouse()) {
317  return;
318  }
319  if (cursor == -1) {
320  return;
321  }
322  cursor_frame++;
324  cursor_frame = 0;
325  }
326  setCursor(*(king()->fc_cursors[cursor][cursor_frame]));
327 }
328 
332 void map_view::focusOutEvent(QFocusEvent *event)
333 {
334  Q_UNUSED(event)
336 }
337 
342 {
343  Q_UNUSED(event);
345 }
346 
350 void map_view::paintEvent(QPaintEvent *event)
351 {
352  QPainter painter;
353 
354  painter.begin(this);
355  m_renderer->render(painter, event->region());
356  painter.scale(1 / scale(), 1 / scale());
358  painter.end();
359 }
360 
364 void map_view::resizeEvent(QResizeEvent *event)
365 {
367  event->accept();
368 }
369 
373 void map_view::wheelEvent(QWheelEvent *event)
374 {
375  auto delta = event->angleDelta();
376 
377  if (event->modifiers() == Qt::NoModifier) {
378  // Scrolling
379  m_renderer->set_origin(m_renderer->origin() - delta);
380  } else if (event->modifiers() == Qt::ShiftModifier) {
381  // Horizontal scrolling
382  std::swap(delta.rx(), delta.ry()); // FIXME Qt 6 QPoint::transposed()
383  m_renderer->set_origin(m_renderer->origin() - delta);
384  } else if (event->modifiers() == Qt::ControlModifier) {
385  // Zooming
386  if (delta.y() > 0) {
387  zoom_in();
388  } else if (delta.y() < 0) {
389  zoom_out();
390  }
391  }
392 }
393 
398 QPoint map_view::find_place(const QSize &size) const
399 {
400  // We scan all possible locations from left to right and from top to
401  // bottom. At each step we check for overlap with other widgets. We return
402  // the first point without overlap.
403  const auto step = 5;
404 
405  // This is the rectangle that would be covered by the widget.
406  auto candidate = QRect(QPoint(), size);
407 
408  const auto children = findChildren<QWidget *>();
409  while (candidate.bottom() < height()) {
410  // Check if the candidate rectangle intersects with another widget
411  if (!std::any_of(children.begin(), children.end(),
412  [candidate](const QWidget *child) {
413  return child->isVisible()
414  && candidate.intersects(child->rect());
415  })) {
416  // We found a good location
417  return candidate.topLeft();
418  }
419 
420  // Move the candidate rectangle to the next point
421  if (candidate.right() + step < width()) {
422  // Step right
423  candidate.moveTo(candidate.left() + step, candidate.top());
424  } else {
425  // Next line
426  candidate.moveTo(0, candidate.top() + step);
427  }
428  }
429 
430  // We didn't find any solution :'(
431  return QPoint();
432 }
433 
446 void update_unit_info_label(const std::vector<unit *> &unit_list)
447 {
448  if (queen()->unitinfo_wdg->isVisible()) {
450  }
451 }
452 
457 void update_mouse_cursor(enum cursor_type new_cursor_type)
458 {
459  queen()->mapview_wdg->update_cursor(new_cursor_type);
460 }
461 
468 void update_turn_done_button(bool do_restore)
469 {
471  return;
472  }
473  // queen()->minimap_panel->turn_done()->blink();
474 }
475 
480 void dirty_rect(int canvas_x, int canvas_y, int pixel_width,
481  int pixel_height)
482 {
483  if (mapview_is_frozen()) {
484  return;
485  }
486  auto scale = queen()->mapview_wdg->scale();
487  dirty |= QRect(canvas_x * scale, canvas_y * scale, pixel_width * scale,
488  pixel_height * scale);
489 }
490 
494 void dirty_all(void)
495 {
496  if (mapview_is_frozen()) {
497  return;
498  }
499  dirty |= QRect(QPoint(), queen()->mapview_wdg->size());
500 }
501 
508 {
509  if (mapview_is_frozen()) {
510  return;
511  }
512 
513  queen()->mapview_wdg->repaint(dirty);
514  dirty = QRegion();
515 }
516 
520 void pixmap_put_overlay_tile(int canvas_x, int canvas_y,
521  const QPixmap *ssprite)
522 {
523  if (!ssprite) {
524  return;
525  }
526 
527  // PORTME
528 }
529 
533 void put_cross_overlay_tile(struct tile *ptile)
534 {
535  float canvas_x, canvas_y;
536 
537  if (tile_to_canvas_pos(&canvas_x, &canvas_y, ptile)) {
538  pixmap_put_overlay_tile(canvas_x, canvas_y,
540  }
541 }
542 
546 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
547 {
548  // DON'T PORTME
549 }
550 
554 void tileset_changed(void)
555 {
556  int i;
557  science_report *sci_rep;
558  QWidget *w;
559 
560  // Refresh the tileset debugger if it exists
561  if (auto debugger = queen()->mapview_wdg->debugger();
562  debugger != nullptr) {
563  debugger->refresh(tileset);
564  }
565 
567 
570  // Update science report if open
571  if (queen()->isRepoDlgOpen(QStringLiteral("SCI"))) {
572  i = queen()->gimmeIndexOf(QStringLiteral("SCI"));
573  fc_assert(i != -1);
574  w = queen()->game_tab_widget->widget(i);
575  sci_rep = reinterpret_cast<science_report *>(w);
576  sci_rep->reset_tree();
577  sci_rep->update_report();
578  sci_rep->repaint();
579  }
580 
581  // When the tileset has an error, tell the user and give him a link to the
582  // debugger where the messages can be found.
583  if (tileset_has_error(tileset) && king() != nullptr) {
584  QMessageBox *ask = new QMessageBox(king()->central_wdg);
585  ask->setWindowTitle(_("Error loading tileset"));
586  ask->setAttribute(Qt::WA_DeleteOnClose);
587  ask->setText(
588  // TRANS: %1 is the name of the tileset
589  QString(_("There was an error loading tileset \"%1\". You can still "
590  "use it, but it might be incomplete."))
591  .arg(tileset_name_get(tileset)));
592  ask->setIcon(QMessageBox::Warning);
593  ask->setStandardButtons(QMessageBox::Close);
594 
595  auto button =
596  ask->addButton(_("Open tileset &debugger"), QMessageBox::AcceptRole);
597  QObject::connect(button, &QPushButton::clicked, queen()->mapview_wdg,
599 
600  ask->show();
601  }
602 }
603 
607 bool mapview_is_frozen() { return (0 < mapview_frozen_level); }
608 
612 info_tile::info_tile(struct tile *ptile, QWidget *parent)
613  : QLabel(parent), itile(ptile)
614 {
615  setFont(fcFont::instance()->getFont(fonts::notify_label));
616  setText(popup_info_text(itile).trimmed());
617  setWordWrap(true);
618 
619  calc_size();
620 }
621 
626 {
627  auto size = sizeHint();
628 
629  // Prevent it from getting too wide
630  QFontMetrics fm = fontMetrics();
631  const auto max_width = fm.averageCharWidth() * 70; // About 700px
632  if (size.width() > max_width) {
633  size.setWidth(max_width + 10); // Safety margin
634  size.setHeight(heightForWidth(size.width()) + 10);
635  }
636 
637  setFixedSize(size);
638 
639  float x, y;
640  if (tile_to_canvas_pos(&x, &y, itile)) {
641  x *= queen()->mapview_wdg->scale();
642  y *= queen()->mapview_wdg->scale();
643  if (y - height() > 0) {
644  y -= height();
645  } else {
647  }
648  // Make sure it's visible
649  x = std::clamp(int(x), 0, parentWidget()->width() - width());
650  move(x, y);
651  }
652 }
653 
658 {
659  delete m_instance;
660  m_instance = nullptr;
661 }
662 
666 bool info_tile::shown() { return m_instance && m_instance->isVisible(); }
667 
672 {
673  if (!m_instance && p) {
674  m_instance = new info_tile(p, queen()->mapview_wdg);
675  }
676  return m_instance;
677 }
678 
682 void popup_tile_info(struct tile *ptile)
683 {
684  struct unit *punit = nullptr;
685 
686  if (TILE_UNKNOWN != client_tile_get_known(ptile)) {
687  mapdeco_set_crosshair(ptile, true);
688  punit = find_visible_unit(ptile);
689  if (punit) {
690  mapdeco_set_gotoroute(punit);
691  if (punit->goto_tile && unit_has_orders(punit)) {
692  mapdeco_set_crosshair(punit->goto_tile, true);
693  }
694  }
695  info_tile::i(ptile)->show();
696  }
697 }
698 
703 {
706  info_tile::i()->drop();
707 }
708 
713 {
715  last_center_enemy = 0;
719 }
720 
733 void show_city_desc(QPixmap *pcanvas, int canvas_x, int canvas_y,
734  struct city *pcity, int *width, int *height)
735 {
736  if (is_any_city_dialog_open()) {
737  return;
738  }
739 
740  QPainter p;
741  p.begin(pcanvas);
742 
743  canvas_x += tileset_tile_width(tileset) / 2;
744  canvas_y += tileset_citybar_offset_y(tileset);
745 
746  auto *painter = citybar_painter::current();
747  auto rect = painter->paint(p, QPointF(canvas_x, canvas_y), pcity);
748  *width = rect.width();
749  *height = rect.height();
750 
751  p.end();
752 }
753 
758 {
759  fc_assert_ret(queen()->mapview_wdg->m_debugger);
760  queen()->mapview_wdg->m_debugger->set_tile(tile);
761 }
#define ACTION_NONE
Definition: actions.h:220
struct city * is_any_city_dialog_open()
Definition: citydlg.cpp:2315
void popdown_city_dialog()
Closes the city overlay.
Definition: citydlg.cpp:2264
static citybar_painter * current()
Returns the current painter (never null).
Definition: citybar.cpp:295
static fcFont * instance()
Returns instance of fc_font.
Definition: fonts.cpp:34
void repaint_needed(const QRegion &where)
void set_viewport_size(const QSize &size)
Instructs the renderer to draw a viewport with a different size.
Definition: renderer.cpp:60
void set_scale(double scale)
Changes the scale of the rendering (zooms in or out).
Definition: renderer.cpp:47
QPointF origin
Definition: renderer.h:22
void set_origin(const QPointF &origin)
Changes the origin of the canvas (the point at the top left of the view).
Definition: renderer.cpp:36
void render(QPainter &painter, const QRegion &region) const
Renders the specified region of the visible portion of the map on painter.
Definition: renderer.cpp:75
A dialog to perform debugging of the tileset.
void tile_picking_requested(bool active)
void update_actions()
Update possible action for given units.
Definition: hudwidget.cpp:552
static info_tile * m_instance
Definition: view_map.h:128
static void drop()
Deletes current instance.
Definition: view_map.cpp:657
void calc_size()
Calculates size of info_tile and moves it to be fully visible.
Definition: view_map.cpp:625
struct tile * itile
Definition: view_map.h:124
static info_tile * i(struct tile *p=nullptr)
Returns given instance.
Definition: view_map.cpp:671
info_tile(struct tile *ptile, QWidget *parent=0)
Constructor for info_tile.
Definition: view_map.cpp:612
static bool shown()
Check if the info tile is currently shown.
Definition: view_map.cpp:666
void paintEvent(QPaintEvent *event) override
Slot inherited from QPixamp.
Definition: view_map.cpp:350
int cursor_frame
Definition: view_map.h:101
int cursor
Definition: view_map.h:102
void scale_changed(double scale) const
void resizeEvent(QResizeEvent *event) override
The widget has been resized.
Definition: view_map.cpp:364
void set_scale_now(double scale)
Sets the map scale immediately without doing any animation.
Definition: view_map.cpp:269
std::unique_ptr< QPropertyAnimation > m_scale_animation
Definition: view_map.h:106
void timer_event()
Timer for cursor.
Definition: view_map.cpp:312
map_view()
Constructor for map.
Definition: view_map.cpp:130
void zoom_out()
Zooms out by 20%.
Definition: view_map.cpp:243
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
Definition: view_map.cpp:197
void update_cursor(enum cursor_type)
Updates cursor.
Definition: view_map.cpp:152
void zoom_reset()
Resets the zoom level.
Definition: view_map.cpp:238
std::vector< QPointer< fcwidget > > m_hidden_fcwidgets
Definition: view_map.h:109
void hide_all_fcwidgets()
Hides all fcwidgets (reports etc).
Definition: view_map.cpp:170
void focusOutEvent(QFocusEvent *event) override
Focus lost event.
Definition: view_map.cpp:332
freeciv::renderer * m_renderer
Definition: view_map.h:103
QPoint find_place(const QSize &size) const
Finds a suitable location for a widget of the given size, avoiding overlap with other widgets.
Definition: view_map.cpp:398
void show_all_fcwidgets()
Shows all fcwidgets (reports etc).
Definition: view_map.cpp:184
void leaveEvent(QEvent *event) override
Leave event.
Definition: view_map.cpp:341
void show_debugger()
Opens the tileset debugger.
Definition: view_map.cpp:278
void wheelEvent(QWheelEvent *event) override
The user wants to scroll.
Definition: view_map.cpp:373
void hide_debugger()
Closes the tileset debugger if it is open.
Definition: view_map.cpp:301
std::unique_ptr< QPropertyAnimation > m_origin_animation
Definition: view_map.h:105
void set_scale(double scale, bool animate=true)
Sets the map scale.
Definition: view_map.cpp:253
void zoom_in()
Zooms in by 20%.
Definition: view_map.cpp:233
double scale
Definition: view_map.h:48
QPointer< freeciv::tileset_debugger > m_debugger
Definition: view_map.h:108
The panel at the bottom right of the game screen, holding the minimap and the Turn Done button.
Definition: minimap_panel.h:23
int gimmeIndexOf(const QString &str)
Returns index on game tab page of given report dialog.
Definition: page_game.cpp:706
map_view * mapview_wdg
Definition: page_game.h:81
hud_units * unitinfo_wdg
Definition: page_game.h:77
fc_game_tab_widget * game_tab_widget
Definition: page_game.h:72
void update_report()
Updates all important widgets on science_report.
void reset_tree()
Recalculates research diagram again and updates science report.
bool can_client_control()
Returns TRUE iff the client can control player.
enum known_type client_tile_get_known(const struct tile *ptile)
A tile's "known" field is used by the server to store whether each player knows the tile.
Definition: climap.cpp:29
QColor get_color(const struct tileset *t, enum color_std stdcolor)
Return a pointer to the given "standard" color.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
Definition: control.cpp:169
unit * find_visible_unit(const ::tile *ptile)
Return a pointer to a visible unit, if there is one.
Definition: control.cpp:749
enum cursor_hover_state hover_state
Definition: control.cpp:82
void set_hover_state(const std::vector< unit * > &units, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Enter the given hover state.
Definition: control.cpp:272
void clear_hover_state()
Clear current hover state (go to HOVER_NONE).
Definition: control.cpp:308
@ HOVER_DEBUG_TILE
Definition: control.h:26
enum event_type event
Definition: events.cpp:68
class fc_client * king()
Return fc_client instance.
Definition: gui_main.cpp:58
#define NO_TARGET
Definition: fc_types.h:271
#define _(String)
Definition: fcintl.h:50
void show_new_turn_info()
Shows new turn information with big font.
Definition: hudwidget.cpp:1305
#define fc_assert_ret(condition)
Definition: log.h:112
#define fc_assert(condition)
Definition: log.h:89
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
Finds the difference between the two (unnormalized) positions, in cartesian (map) coordinates.
Definition: map.cpp:961
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition: map.h:164
bool get_turn_done_button_state()
Return TRUE iff the turn done button should be enabled.
const char *const notify_label
Definition: fonts.h:19
Definition: path.cpp:10
client_options * gui_options
Definition: options.cpp:74
pageGame * queen()
Return game instandce.
Definition: page_game.cpp:557
static void static sol::state * fcl
Lua virtual machine state.
Definition: script_fcdb.cpp:48
int step
Definition: specpq.h:83
size_t size
Definition: specvec.h:64
Definition: city.h:291
int smooth_center_slide_msec
Definition: options.h:82
bool draw_city_trade_routes
Definition: options.h:127
Definition: tile.h:42
Definition: unit.h:134
struct tile * goto_tile
Definition: unit.h:152
int height
float gui_x0
float gui_y0
int width
const QString popup_info_text(struct tile *ptile)
Text to popup on a middle-click in the mapview.
Definition: text.cpp:137
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
Definition: tile.cpp:72
#define tile_index(_pt_)
Definition: tile.h:70
@ TILE_UNKNOWN
Definition: tile.h:29
#define TILE_XY(ptile)
Definition: tile.h:36
const char * tileset_name_get(const struct tileset *t)
Return tileset name.
Definition: tilespec.cpp:3828
const QPixmap * get_attention_crosshair_sprite(const struct tileset *t)
Returns a sprite with the "user-attention" crosshair graphic.
Definition: tilespec.cpp:3557
int tileset_citybar_offset_y(const struct tileset *t)
Return the offset from the origin of the city tile at which to place the city bar text.
Definition: tilespec.cpp:504
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
Definition: tilespec.cpp:383
double tileset_preferred_scale(const struct tileset *t)
Returns the preferred scale (zoom level) of the tileset.
Definition: tilespec.cpp:539
bool tileset_has_error(const struct tileset *t)
Checks if the tileset had any error message (LOG_ERROR).
Definition: tilespec.cpp:3763
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
Definition: tilespec.cpp:371
#define NUM_CURSOR_FRAMES
Definition: tilespec.h:169
cursor_type
Definition: tilespec.h:154
@ CURSOR_DEFAULT
Definition: tilespec.h:166
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Check if cities have an established trade route.
bool unit_has_orders(const struct unit *punit)
Return TRUE iff the unit is following client-side orders.
Definition: unit.cpp:195
@ ORDER_LAST
Definition: unit.h:43
void update_turn_done_button(bool do_restore)
If do_restore is false it should change the turn button style (to draw the user's attention to it).
Definition: view_map.cpp:468
int last_center_capital
Definition: page_game.cpp:52
void dirty_all(void)
Mark the entire screen area as "dirty" so that we can flush it later.
Definition: view_map.cpp:494
int last_center_enemy
Definition: page_game.cpp:55
void popup_tile_info(struct tile *ptile)
Popups information label tile.
Definition: view_map.cpp:682
void tileset_changed(void)
This function is called when the tileset is changed.
Definition: view_map.cpp:554
void put_cross_overlay_tile(struct tile *ptile)
Draw a cross-hair overlay on a tile.
Definition: view_map.cpp:533
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Area Selection.
Definition: view_map.cpp:546
void dirty_rect(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Mark the rectangular region as "dirty" so that we know to flush it later.
Definition: view_map.cpp:480
bool mapview_is_frozen()
Return whether the map should be drawn or not.
Definition: view_map.cpp:607
void popdown_tile_info()
Popdowns information label tile.
Definition: view_map.cpp:702
QPixmap * canvas
void show_city_desc(QPixmap *pcanvas, int canvas_x, int canvas_y, struct city *pcity, int *width, int *height)
Draw a description for the given city.
Definition: view_map.cpp:733
int last_center_player_city
Definition: page_game.cpp:53
void debug_tile(tile *tile)
Callback to set the tile being debugged.
Definition: view_map.cpp:757
int last_center_enemy_city
Definition: page_game.cpp:54
void draw_calculated_trade_routes(QPainter *painter)
Draws calculated trade routes.
Definition: view_map.cpp:65
static int mapview_frozen_level
Definition: view_map.cpp:51
void start_turn()
New turn callback.
Definition: view_map.cpp:712
void flush_dirty()
Flush all regions that have been previously marked as dirty.
Definition: view_map.cpp:507
void update_unit_info_label(const std::vector< unit * > &unit_list)
Update the information label which gives info on the current unit and the tile under the current unit...
Definition: view_map.cpp:446
void pixmap_put_overlay_tile(int canvas_x, int canvas_y, const QPixmap *ssprite)
Put overlay tile to pixmap.
Definition: view_map.cpp:520
void update_mouse_cursor(enum cursor_type new_cursor_type)
Update the mouse cursor.
Definition: view_map.cpp:457
void destroy_city_dialog()
static QRegion dirty
Definition: view_map.cpp:54
void map_to_gui_vector(const struct tileset *t, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
Translate from a cartesian system to the GUI system.
void mapdeco_set_crosshair(const struct tile *ptile, bool crosshair)
Marks the given tile as having a "crosshair" map decoration.
struct view mapview
void mapdeco_clear_crosshairs()
Clears all previous set tile crosshair decorations.
void mapdeco_set_gotoroute(const struct unit *punit)
Set the map decorations for the given unit's goto route.
void map_to_gui_pos(const struct tileset *t, float *gui_x, float *gui_y, int map_x, int map_y)
Translate from map to gui coordinate systems.
void gui_distance_vector(const struct tileset *t, float *gui_dx, float *gui_dy, float gui_x0, float gui_y0, float gui_x1, float gui_y1)
Find the vector with minimum "real" distance between two GUI positions.
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, const tile *ptile)
Finds the canvas coordinates for a map position.
void mapdeco_clear_gotoroutes()
Clear all goto line map decorations and queues mapview updates for the affected tiles.
static void swap(struct reqtree *tree, int layer, int order1, int order2)
Swap positions of two nodes on the same layer.