Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/mapview.cpp Source File

Freeciv-3.1

Loading...
Searching...
No Matches
mapview.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QMouseEvent>
20#include <QPainter>
21#include <QPixmap>
22#include <QToolTip>
23#include <QWheelEvent>
24
25// utility
26#include "log.h"
27#include "support.h"
28
29// common
30#include "calendar.h"
31#include "game.h"
32#include "map.h"
33#include "research.h"
34
35// client
36#include "climisc.h"
37#include "mapctrl_common.h"
38#include "menu.h" // gov_menu
39#include "movement.h"
40#include "overview_common.h"
41#include "sprite.h"
42#include "repodlgs.h"
43#include "text.h"
44#include "zoom.h"
45
46// gui-qt
47#include "colors.h"
48#include "fc_client.h"
49#include "qtg_cxxside.h"
50#include "mapview.h"
51#include "sidebar.h"
52
53const char *get_timeout_label_text();
54 static int mapview_frozen_level = 0;
55extern void destroy_city_dialog();
56extern struct canvas *canvas;
57
58#define MAX_DIRTY_RECTS 20
59 static int num_dirty_rects = 0;
60 static QRect dirty_rects[MAX_DIRTY_RECTS];
61
62extern int last_center_enemy;
63extern int last_center_capital;
64extern int last_center_player_city;
65extern int last_center_enemy_city;
66
67/**********************************************************************/
70 bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
71{
72 if (x >= px && y >= py && x <= pxe && y <= pye) {
73 return true;
74 }
75 return false;
76}
77
78/**********************************************************************/
81 void draw_calculated_trade_routes(QPainter *painter)
82{
83 int dx, dy;
84 float w, h;
85 float x1, y1, x2, y2;
86 qtiles qgilles;
87 struct city *pcity;
88 struct color *pcolor;
89 QPen pen;
90
91 if (!can_client_control()
92 || gui()->trade_gen.cities.empty()) {
93 return;
94 }
95 pcolor = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT);
96 /* Draw calculated trade routes */
97 if (gui_options.draw_city_trade_routes) {
98
99 foreach (qgilles, gui()->trade_gen.lines) {
100 base_map_distance_vector(&dx, &dy, TILE_XY(qgilles.t1),
101 TILE_XY(qgilles.t2));
102 map_to_gui_vector(tileset, 1.0, &w, &h, dx, dy);
103
104 tile_to_canvas_pos(&x1, &y1, map_zoom, qgilles.t1);
105 tile_to_canvas_pos(&x2, &y2, map_zoom, qgilles.t2);
106
107 /* Dont draw if route was already established */
108 if (tile_city(qgilles.t1) && tile_city(qgilles.t2)
109 && have_cities_trade_route(tile_city(qgilles.t1),
110 tile_city(qgilles.t2))) {
111 continue;
112 }
113
114 if (qgilles.autocaravan != nullptr) {
115 pcolor = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT);
116 }
117
118 pen.setColor(pcolor->qcolor);
119 pen.setStyle(Qt::DashLine);
120 pen.setDashOffset(4);
121 pen.setWidth(1);
122 painter->setPen(pen);
123 if (x2 - x1 == w && y2 - y1 == h) {
124 painter->drawLine(x1 + tileset_tile_width(tileset) / 2,
125 y1 + tileset_tile_height(tileset) / 2,
126 x1 + tileset_tile_width(tileset) / 2 + w,
127 y1 + tileset_tile_height(tileset) / 2 + h);
128 continue;
129 }
130 painter->drawLine(x2 + tileset_tile_width(tileset) / 2,
131 y2 + tileset_tile_height(tileset) / 2,
132 x2 + tileset_tile_width(tileset) / 2 - w,
133 y2 + tileset_tile_height(tileset) / 2 - h);
134 }
135 }
136 /* Draw virtual cities */
137 foreach (pcity, gui()->trade_gen.virtual_cities) {
138 float canvas_x, canvas_y;
139 if (pcity->tile != nullptr
140 && tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, pcity->tile)) {
141 painter->drawPixmap(static_cast<int>(canvas_x),
142 static_cast<int>(canvas_y),
143 *get_attention_crosshair_sprite(tileset)->pm);
144 }
145 }
146}
147
148/**********************************************************************/
151mr_idle::mr_idle()
152{
153 connect(&timer, &QTimer::timeout, this, &mr_idle::idling);
154 timer.start(5);
155}
156
157/**********************************************************************/
160mr_idle::~mr_idle()
161{
162 call_me_back *cb;
163
164 while (!callback_list.isEmpty()) {
165 cb = callback_list.dequeue();
166 delete cb;
167 }
168}
169
170/**********************************************************************/
173 void mr_idle::idling()
174{
175 call_me_back *cb;
176
177 while (!callback_list.isEmpty()) {
178 cb = callback_list.dequeue();
179 (cb->callback) (cb->data);
180 delete cb;
181 }
182}
183
184/**********************************************************************/
187 void mr_idle::add_callback(call_me_back *cb)
188{
189 callback_list.enqueue(cb);
190}
191
192/**********************************************************************/
195map_view::map_view() : QWidget()
196{
197 menu_click = false;
198 cursor = -1;
199 QTimer *timer = new QTimer(this);
200 setAttribute(Qt::WA_OpaquePaintEvent, true);
201 connect(timer, &QTimer::timeout, this, &map_view::timer_event);
202 timer->start(200);
203 resize(0, 0);
204 setMouseTracking(true);
205 stored_autocenter = gui_options.auto_center_on_unit;
206 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
207}
208
209/**********************************************************************/
212 void map_view::update_cursor(enum cursor_type ct)
213{
214 int i;
215
216 if (ct == CURSOR_DEFAULT) {
217 setCursor(Qt::ArrowCursor);
218 cursor = -1;
219 return;
220 }
221 cursor_frame = 0;
222 i = static_cast<int>(ct);
223 cursor = i;
224 setCursor(*(gui()->fc_cursors[i][0]));
225}
226
227/**********************************************************************/
230 void map_view::timer_event()
231{
232 if (gui()->infotab->underMouse()
233 || gui()->minimapview_wdg->underMouse()
234 || gui()->sidebar_wdg->underMouse()) {
235 update_cursor(CURSOR_DEFAULT);
236 return;
237 }
238 if (cursor == -1) {
239 return;
240 }
241 cursor_frame++;
242 if (cursor_frame == NUM_CURSOR_FRAMES) {
243 cursor_frame = 0;
244 }
245 setCursor(*(gui()->fc_cursors[cursor][cursor_frame]));
246}
247
248/**********************************************************************/
251 void map_view::update_font(const QString &name, const QFont &font)
252{
253 if (name == fonts::city_names
254 || name == fonts::city_productions) {
255 update_map_canvas_visible();
256 }
257}
258
259/**********************************************************************/
262 void map_view::focusOutEvent(QFocusEvent *event)
263{
264 update_cursor(CURSOR_DEFAULT);
265}
266
267/**********************************************************************/
270 void map_view::leaveEvent(QEvent *event)
271{
272 update_cursor(CURSOR_DEFAULT);
273}
274
275/**********************************************************************/
278 void map_view::paintEvent(QPaintEvent *event)
279{
280 QPainter painter;
281
282 painter.begin(this);
283 paint(&painter, event);
284 painter.end();
285}
286
287/**********************************************************************/
290 void map_view::paint(QPainter *painter, QPaintEvent *event)
291{
292 painter->drawPixmap(event->rect(), mapview.store->map_pixmap,
293 event->rect());
294 draw_calculated_trade_routes(painter);
295}
296
297/**********************************************************************/
300 void map_view::resume_searching(int pos_x, int pos_y, int &w, int &h,
301 int wdth, int hght, int recursive_nr)
302{
303 int new_pos_x, new_pos_y;
304
305 recursive_nr++;
306 new_pos_x = pos_x;
307 new_pos_y = pos_y;
308
309 if (pos_y + hght + 4 < height() && pos_x > width() / 2) {
310 new_pos_y = pos_y + 5;
311 } else if (pos_x > 0 && pos_y > 10) {
312 new_pos_x = pos_x - 5;
313 } else if (pos_y > 0) {
314 new_pos_y = pos_y - 5;
315 } else if (pos_x + wdth + 4 < this->width()) {
316 new_pos_x = pos_x + 5;
317 }
318 find_place(new_pos_x, new_pos_y, w, h, wdth, hght, recursive_nr);
319}
320
321/**********************************************************************/
327 void map_view::find_place(int pos_x, int pos_y, int &w, int &h, int wdth,
328 int hght, int recursive_nr)
329{
330 int i;
331 int x, y, xe, ye;
332 QList <fcwidget *>widgets = this->findChildren <fcwidget *>();
333 bool cont_searching = false;
334
335 if (recursive_nr >= 1000) {
339 return;
340 }
346 for (i = 0; i < widgets.count(); i++) {
347 if (!widgets[i]->isVisible()) {
348 continue;
349 }
350 x = widgets[i]->pos().x();
351 y = widgets[i]->pos().y();
352
353 if (x == 0 && y ==0) {
354 continue;
355 }
356 xe = widgets[i]->pos().x() + widgets[i]->width();
357 ye = widgets[i]->pos().y() + widgets[i]->height();
358
359 if (is_point_in_area(pos_x, pos_y, x, y, xe, ye)) {
360 cont_searching = true;
361 }
362 if (is_point_in_area(pos_x + wdth, pos_y, x, y, xe, ye)) {
363 cont_searching = true;
364 }
365 if (is_point_in_area(pos_x + wdth, pos_y + hght, x, y, xe, ye)) {
366 cont_searching = true;
367 }
368 if (is_point_in_area(pos_x, pos_y + hght, x, y, xe, ye)) {
369 cont_searching = true;
370 }
371 if (is_point_in_area(pos_x + wdth / 2, pos_y + hght / 2, x, y, xe, ye)) {
372 cont_searching = true;
373 }
374 }
375 w = pos_x;
376 h = pos_y;
377 if (cont_searching) {
378 resume_searching(pos_x, pos_y, w, h, wdth, hght, recursive_nr);
379 }
380}
381
382/**********************************************************************/
385move_widget::move_widget(QWidget *parent) : QLabel()
386{
387 QPixmap *pix;
388
389 setParent(parent);
390 setCursor(Qt::SizeAllCursor);
391 pix = fc_icons::instance()->get_pixmap("move");
392 setPixmap(*pix);
393 delete pix;
394 setFixedSize(16, 16);
395}
396
397/**********************************************************************/
400 void move_widget::put_to_corner()
401{
402 move(0, 0);
403}
404
405/**********************************************************************/
408 void move_widget::mouseMoveEvent(QMouseEvent *event)
409{
410 if (!gui()->interface_locked) {
411 parentWidget()->move(event->globalPos() - point);
412 }
413}
414
415/**********************************************************************/
418 void move_widget::mousePressEvent(QMouseEvent* event)
419{
420 if (!gui()->interface_locked) {
421 point = event->globalPos() - parentWidget()->geometry().topLeft();
422 }
423 update();
424}
425
426/**********************************************************************/
429resize_widget::resize_widget(QWidget *parent) : QLabel()
430{
431 QPixmap *pix;
432
433 setParent(parent);
434 setCursor(Qt::SizeFDiagCursor);
435 pix = fc_icons::instance()->get_pixmap("resize");
436 setPixmap(*pix);
437 delete pix;
438}
439
440/**********************************************************************/
443 void resize_widget::put_to_corner()
444{
445 move(parentWidget()->width() - width(),
446 parentWidget()->height() - height());
447}
448
449/**********************************************************************/
452 void resize_widget::mouseMoveEvent(QMouseEvent * event)
453{
454 QPoint qp, np;
455
456 if (gui()->interface_locked) {
457 return;
458 }
459 qp = event->globalPos();
460 np.setX(qp.x() - point.x());
461 np.setY(qp.y() - point.y());
462 np.setX(qMax(np.x(), 32));
463 np.setY(qMax(np.y(), 32));
464 parentWidget()->resize(np.x(), np.y());
465}
466
467/**********************************************************************/
470 void resize_widget::mousePressEvent(QMouseEvent* event)
471{
472 QPoint qp;
473
474 if (gui()->interface_locked) {
475 return;
476 }
477 qp = event->globalPos();
478 point.setX(qp.x() - parentWidget()->width());
479 point.setY(qp.y() - parentWidget()->height());
480 update();
481}
482
483/**********************************************************************/
486close_widget::close_widget(QWidget *parent) : QLabel()
487{
488 QPixmap *pix;
489
490 setParent(parent);
491 setCursor(Qt::ArrowCursor);
492 pix = fc_icons::instance()->get_pixmap("close");
493 setPixmap(*pix);
494 delete pix;
495}
496
497/**********************************************************************/
500 void close_widget::put_to_corner()
501{
502 move(parentWidget()->width()-width(), 0);
503}
504
505/**********************************************************************/
508 void close_widget::mousePressEvent(QMouseEvent* event)
509{
510 if (gui()->interface_locked) {
511 return;
512 }
513 if (event->button() == Qt::LeftButton) {
514 parentWidget()->hide();
515 notify_parent();
516 }
517}
518
519/**********************************************************************/
522 void close_widget::notify_parent()
523{
524 fcwidget *fcw;
525
526 fcw = reinterpret_cast< fcwidget *>(parentWidget());
527 fcw->update_menu();
528}
529
530/**********************************************************************/
533minimap_view::minimap_view(QWidget *parent) : fcwidget()
534{
535 setParent(parent);
536 setAttribute(Qt::WA_OpaquePaintEvent, true);
537 w_ratio = 0.0;
538 h_ratio = 0.0;
539 // Dark magic: This call is required for the widget to work.
540 resize(0, 0);
541 background = QBrush(QColor (0, 0, 0));
542 setCursor(Qt::CrossCursor);
543 rw = new resize_widget(this);
544 rw->put_to_corner();
545 pix = new QPixmap;
546 scale_factor = 1.0;
547 connect(&thread, &minimap_thread::rendered_image,
548 this, &minimap_view::update_pixmap);
549}
550
551/**********************************************************************/
554minimap_view::~minimap_view()
555{
556 if (pix) {
557 delete pix;
558 }
559}
560
561/**********************************************************************/
564 void minimap_view::paintEvent(QPaintEvent *event)
565{
566 QPainter painter;
567
568 painter.begin(this);
569 paint(&painter, event);
570 painter.end();
571}
572
573/**********************************************************************/
576 void minimap_view::scale(double factor)
577{
578 scale_factor *= factor;
579 if (scale_factor < 1) {
580 scale_factor = 1.0;
581 };
582 update_image();
583}
584
585/**********************************************************************/
588 static void gui_to_overview(int *ovr_x, int *ovr_y, int gui_x, int gui_y)
589{
590 double ntl_x, ntl_y;
591 const double gui_xd = gui_x, gui_yd = gui_y;
592 const double W = tileset_tile_width(tileset);
593 const double H = tileset_tile_height(tileset);
594 double map_x, map_y;
595
596 if (tileset_is_isometric(tileset)) {
597 map_x = (gui_xd * H + gui_yd * W) / (W * H);
598 map_y = (gui_yd * W - gui_xd * H) / (W * H);
599 } else {
600 map_x = gui_xd / W;
601 map_y = gui_yd / H;
602 }
603
604 if (MAP_IS_ISOMETRIC) {
605 ntl_y = map_x + map_y - wld.map.xsize;
606 ntl_x = 2 * map_x - ntl_y;
607 } else {
608 ntl_x = map_x;
609 ntl_y = map_y;
610 }
611
612 *ovr_x = floor((ntl_x - (double)gui_options.overview.map_x0)
613 * OVERVIEW_TILE_SIZE);
614 *ovr_y = floor((ntl_y - (double)gui_options.overview.map_y0)
615 * OVERVIEW_TILE_SIZE);
616
617 if (current_topo_has_flag(TF_WRAPX)) {
618 *ovr_x = FC_WRAP(*ovr_x, NATURAL_WIDTH * OVERVIEW_TILE_SIZE);
619 } else {
620 if (MAP_IS_ISOMETRIC) {
621 *ovr_x -= OVERVIEW_TILE_SIZE;
622 }
623 }
624 if (current_topo_has_flag(TF_WRAPY)) {
625 *ovr_y = FC_WRAP(*ovr_y, NATURAL_HEIGHT * OVERVIEW_TILE_SIZE);
626 }
627}
628
629/**********************************************************************/
632 void minimap_view::update_menu()
633{
634 ::gui()->menu_bar->minimap_status->setChecked(false);
635}
636
637/**********************************************************************/
640 void minimap_view::moveEvent(QMoveEvent* event)
641{
642 position = event->pos();
643}
644
645/**********************************************************************/
648 void minimap_view::showEvent(QShowEvent* event)
649{
650 move(position);
651 event->setAccepted(true);
652}
653
654/**********************************************************************/
657 void minimap_view::draw_viewport(QPainter *painter)
658{
659 int i, x[4], y[4];
660 int src_x, src_y, dst_x, dst_y;
661
662 if (!gui_options.overview.map) {
663 return;
664 }
665
666 gui_to_overview(&x[0], &y[0], mapview.gui_x0, mapview.gui_y0);
667 gui_to_overview(&x[1], &y[1], mapview.gui_x0 + mapview.width,
668 mapview.gui_y0);
669 gui_to_overview(&x[2], &y[2], mapview.gui_x0 + mapview.width,
670 mapview.gui_y0 + mapview.height);
671 gui_to_overview(&x[3], &y[3], mapview.gui_x0,
672 mapview.gui_y0 + mapview.height);
673 painter->setPen(QColor(Qt::white));
674
675 if (scale_factor > 1) {
676 for (i = 0; i < 4; i++) {
677 scale_point(x[i], y[i]);
678 }
679 }
680
681 for (i = 0; i < 4; i++) {
682 src_x = x[i] * w_ratio;
683 src_y = y[i] * h_ratio;
684 dst_x = x[(i + 1) % 4] * w_ratio;
685 dst_y = y[(i + 1) % 4] * h_ratio;
686 painter->drawLine(src_x, src_y, dst_x, dst_y);
687 }
688}
689
690/**********************************************************************/
693 void minimap_view::scale_point(int &x, int &y)
694{
695 int ax, bx;
696 int dx, dy;
697
698 gui_to_overview(&ax, &bx, mapview.gui_x0 + mapview.width / 2,
699 mapview.gui_y0 + mapview.height / 2);
700 x = qRound(x * scale_factor);
701 y = qRound(y * scale_factor);
702 dx = qRound(ax * scale_factor - gui_options.overview.width / 2);
703 dy = qRound(bx * scale_factor - gui_options.overview.height / 2);
704 x = x - dx;
705 y = y - dy;
706}
707
708/**********************************************************************/
711 void unscale_point(double scale_factor, int &x, int &y)
712{
713 int ax, bx;
714 int dx, dy;
715
716 gui_to_overview(&ax, &bx, mapview.gui_x0 + mapview.width / 2,
717 mapview.gui_y0 + mapview.height / 2);
718 dx = qRound(ax * scale_factor - gui_options.overview.width / 2);
719 dy = qRound(bx * scale_factor - gui_options.overview.height / 2);
720 x = x + dx;
721 y = y + dy;
722 x = qRound(x / scale_factor);
723 y = qRound(y / scale_factor);
724}
725
726/**********************************************************************/
729 void minimap_view::reset()
730{
731 scale_factor = 1;
732}
733
734/**********************************************************************/
737 void minimap_view::update_pixmap(const QImage &image)
738{
739 *pix = QPixmap::fromImage(image);
740 update();
741}
742
743/**********************************************************************/
746minimap_thread::minimap_thread(QObject *parent) : QThread(parent)
747{
748}
749
750/**********************************************************************/
753minimap_thread::~minimap_thread()
754{
755 wait();
756}
757
758/**********************************************************************/
761 void minimap_thread::render(double scale_factor, int width, int height)
762{
763 QMutexLocker locker(&mutex);
764 mini_width = width;
765 mini_height = height;
766 scale = scale_factor;
767 start(LowPriority);
768}
769
770/**********************************************************************/
773 void minimap_thread::run()
774{
775 QImage tpix;
776 QImage gpix;
777 QImage image(QSize(mini_width, mini_height), QImage::Format_RGB32);
778 QImage bigger_pix(gui_options.overview.width * 2,
779 gui_options.overview.height * 2, QImage::Format_RGB32);
780 int delta_x, delta_y;
781 int x, y, ix, iy;
782 float wf, hf;
783 QPixmap *src, *dst;
784
785 mutex.lock();
786 if (gui_options.overview.map != nullptr) {
787 if (scale > 1) {
788 /* move minimap now,
789 scale later and draw without looking for origin */
790 src = &gui_options.overview.map->map_pixmap;
791 dst = &gui_options.overview.window->map_pixmap;
792 x = gui_options.overview.map_x0;
793 y = gui_options.overview.map_y0;
794 ix = gui_options.overview.width - x;
795 iy = gui_options.overview.height - y;
796 pixmap_copy(dst, src, 0, 0, ix, iy, x, y);
797 pixmap_copy(dst, src, 0, y, ix, 0, x, iy);
798 pixmap_copy(dst, src, x, 0, 0, iy, ix, y);
799 pixmap_copy(dst, src, x, y, 0, 0, ix, iy);
800 tpix = gui_options.overview.window->map_pixmap.toImage();
801 wf = static_cast <float>(gui_options.overview.width) / scale;
802 hf = static_cast <float>(gui_options.overview.height) / scale;
803 x = 0;
804 y = 0;
805 unscale_point(scale, x, y);
806 bigger_pix.fill(Qt::black);
807 delta_x = gui_options.overview.width / 2;
808 delta_y = gui_options.overview.height / 2;
809 image_copy(&bigger_pix, &tpix, 0, 0, delta_x, delta_y,
810 gui_options.overview.width, gui_options.overview.height);
811 gpix = bigger_pix.copy(delta_x + x, delta_y + y, wf, hf);
812 image = gpix.scaled(mini_width, mini_height,
813 Qt::IgnoreAspectRatio, Qt::FastTransformation);
814 } else {
815 tpix = gui_options.overview.map->map_pixmap.toImage();
816 image = tpix.scaled(mini_width, mini_height,
817 Qt::IgnoreAspectRatio, Qt::FastTransformation);
818 }
819 }
820 emit rendered_image(image);
821 mutex.unlock();
822}
823
824/**********************************************************************/
827 void minimap_view::update_image()
828{
829 if (isHidden()) {
830 return;
831 }
832 thread.render(scale_factor, width(), height());
833}
834
835/**********************************************************************/
838 void minimap_view::paint(QPainter * painter, QPaintEvent * event)
839{
840 int x, y, ix, iy;
841
842 x = gui_options.overview.map_x0 * w_ratio;
843 y = gui_options.overview.map_y0 * h_ratio;
844 ix = pix->width() - x;
845 iy = pix->height() - y;
846
847 if (scale_factor > 1) {
848 painter->drawPixmap(0, 0, *pix, 0, 0, pix->width(), pix->height());
849 } else {
850 painter->drawPixmap(ix, iy, *pix, 0, 0, x, y);
851 painter->drawPixmap(ix, 0, *pix, 0, y, x, iy);
852 painter->drawPixmap(0, iy, *pix, x, 0, ix, y);
853 painter->drawPixmap(0, 0, *pix, x, y, ix, iy);
854 }
855 painter->setPen(QColor(palette().color(QPalette::Highlight)));
856 painter->drawRect(0, 0, width() - 1, height() - 1);
857 draw_viewport(painter);
858 rw->put_to_corner();
859}
860
861/**********************************************************************/
864 void minimap_view::resizeEvent(QResizeEvent* event)
865{
866 QSize size;
867 size = event->size();
868
869 if (C_S_RUNNING <= client_state() && size.width() > 0
870 && size.height() > 0) {
871 w_ratio = static_cast<float>(width()) / gui_options.overview.width;
872 h_ratio = static_cast<float>(height()) / gui_options.overview.height;
873 gui()->qt_settings.minimap_width = static_cast<float>(size.width())
874 / mapview.width;
875 gui()->qt_settings.minimap_height = static_cast<float>(size.height())
876 / mapview.height;
877 }
878 update_image();
879}
880
881/**********************************************************************/
884 void minimap_view::wheelEvent(QWheelEvent *event)
885{
886 if (event->angleDelta().y() > 0) {
887 zoom_in();
888 } else {
889 zoom_out();
890 }
891 event->accept();
892}
893
894/**********************************************************************/
897 void minimap_view::zoom_in()
898{
899 if (scale_factor < gui_options.overview.width / 8) {
900 scale(1.2);
901 }
902}
903
904/**********************************************************************/
907 void minimap_view::zoom_out()
908{
909 scale(0.833);
910}
911
912/**********************************************************************/
918 void minimap_view::mousePressEvent(QMouseEvent * event)
919{
920 int fx, fy;
921 int x, y;
922
923 if (event->button() == Qt::LeftButton) {
924 if (gui()->interface_locked) {
925 return;
926 }
927 cursor = event->globalPos() - geometry().topLeft();
928 }
929 if (event->button() == Qt::RightButton) {
930 cursor = event->pos();
931 fx = event->pos().x();
932 fy = event->pos().y();
933 fx = qRound(fx / w_ratio);
934 fy = qRound(fy / h_ratio);
935 if (scale_factor > 1) {
936 unscale_point(scale_factor, fx, fy);
937 }
938 fx = qMax(fx, 1);
939 fy = qMax(fy, 1);
940 fx = qMin(fx, gui_options.overview.width - 1);
941 fy = qMin(fy, gui_options.overview.height - 1);
942 overview_to_map_pos(&x, &y, fx, fy);
943 center_tile_mapcanvas(map_pos_to_tile(&(wld.map), x, y));
944 update_image();
945 }
946 event->setAccepted(true);
947}
948
949/**********************************************************************/
952 void minimap_view::mouseMoveEvent(QMouseEvent* event)
953{
954 if (gui()->interface_locked) {
955 return;
956 }
957 if (event->buttons() & Qt::LeftButton) {
958 QPoint p, r;
959 p = event->pos();
960 r = mapTo(gui()->mapview_wdg, p);
961 p = r - p;
962 move(event->globalPos() - cursor);
963 setCursor(Qt::SizeAllCursor);
964 gui()->qt_settings.minimap_x = static_cast<float>(p.x()) / mapview.width;
965 gui()->qt_settings.minimap_y = static_cast<float>(p.y())
966 / mapview.height;
967 }
968}
969
970/**********************************************************************/
973 void minimap_view::mouseReleaseEvent(QMouseEvent* event)
974{
975 setCursor(Qt::CrossCursor);
976}
977
978
979/**********************************************************************/
984 void update_info_label(void)
985{
986 gui()->update_info_label();
987}
988
989
990/**********************************************************************/
993 void fc_client::update_info_label(void)
994{
995 QString s, eco_info;
996
997 if (current_page() != PAGE_GAME) {
998 return;
999 }
1000 if (update_info_timer == nullptr) {
1001 update_info_timer = new QTimer();
1002 update_info_timer->setSingleShot(true);
1003 connect(update_info_timer, &QTimer::timeout,
1004 this, &fc_client::update_info_label);
1005 update_info_timer->start(300);
1006 return;
1007 }
1008
1009 if (update_info_timer->remainingTime() > 0) {
1010 return;
1011 }
1012 update_sidebar_tooltips();
1013 if (head_of_units_in_focus() != nullptr) {
1014 real_menus_update();
1015 }
1016 /* TRANS: T is shortcut from Turn */
1017 s = QString(_("%1 \nT:%2")).arg(calendar_text(),
1018 QString::number(game.info.turn));
1019
1020 sw_map->set_custom_labels(s);
1021 sw_map->update_final_pixmap();
1022
1023 set_indicator_icons(client_research_sprite(),
1024 client_warming_sprite(),
1025 client_cooling_sprite(), client_government_sprite());
1026
1027 if (client.conn.playing != NULL) {
1028 if (player_get_expected_income(client.conn.playing) > 0) {
1029 eco_info = QString(_("%1 (+%2)"))
1030 .arg(QString::number(client.conn.playing->economic.gold),
1031 QString::number(player_get_expected_income(client.conn.playing)));
1032 } else {
1033 eco_info = QString(_("%1 (%2)"))
1034 .arg(QString::number(client.conn.playing->economic.gold),
1035 QString::number(player_get_expected_income(client.conn.playing)));
1036 }
1037 sw_economy->set_custom_labels(eco_info);
1038 } else {
1039 sw_economy->set_custom_labels("");
1040 }
1041 sw_tax->update_final_pixmap();
1042 sw_economy->update_final_pixmap();
1043 delete update_info_timer;
1044 update_info_timer = nullptr;
1045}
1046
1047
1048/**********************************************************************/
1060 void update_unit_info_label(struct unit_list *punitlist)
1061{
1062 if (gui()->unitinfo_wdg->isVisible()) {
1063 gui()->unitinfo_wdg->update_actions(nullptr);
1064 }
1065}
1066
1067/**********************************************************************/
1071 void update_mouse_cursor(enum cursor_type new_cursor_type)
1072{
1073 gui()->mapview_wdg->update_cursor(new_cursor_type);
1074}
1075
1076/**********************************************************************/
1080 void qtg_update_timeout_label(void)
1081{
1082 gui()->sw_endturn->set_custom_labels(QString(get_timeout_label_text()));
1083 gui()->sw_endturn->update_final_pixmap();
1084}
1085
1086/**********************************************************************/
1092 void update_turn_done_button(bool do_restore)
1093{
1094 if (!get_turn_done_button_state()) {
1095 return;
1096 }
1097 side_blink_endturn(do_restore);
1098}
1099
1100
1101/**********************************************************************/
1106 void set_indicator_icons(struct sprite *bulb, struct sprite *sol,
1107 struct sprite *flake, struct sprite *gov)
1108{
1109 gui()->sw_indicators->update_final_pixmap();
1110}
1111
1112/**********************************************************************/
1115 struct canvas *get_overview_window(void)
1116{
1117 gui()->minimapview_wdg->update_image();
1118 return NULL;
1119}
1120
1121/**********************************************************************/
1125 static void flush_mapcanvas(int canvas_x, int canvas_y,
1126 int pixel_width, int pixel_height)
1127{
1128 gui()->mapview_wdg->repaint(canvas_x, canvas_y, pixel_width, pixel_height);
1129}
1130
1131/**********************************************************************/
1135 void dirty_rect(int canvas_x, int canvas_y,
1136 int pixel_width, int pixel_height)
1137{
1138 if (mapview_is_frozen()) {
1139 return;
1140 }
1141 if (num_dirty_rects < MAX_DIRTY_RECTS) {
1142 dirty_rects[num_dirty_rects].setX(canvas_x);
1143 dirty_rects[num_dirty_rects].setY(canvas_y);
1144 dirty_rects[num_dirty_rects].setWidth(pixel_width);
1145 dirty_rects[num_dirty_rects].setHeight(pixel_height);
1146 num_dirty_rects++;
1147 }
1148}
1149
1150/**********************************************************************/
1153 void dirty_all(void)
1154{
1155 if (mapview_is_frozen()) {
1156 return;
1157 }
1158 num_dirty_rects = MAX_DIRTY_RECTS;
1159}
1160
1161/**********************************************************************/
1166 void flush_dirty(void)
1167{
1168 if (mapview_is_frozen()) {
1169 return;
1170 }
1171 if (num_dirty_rects == MAX_DIRTY_RECTS) {
1172 flush_mapcanvas(0, 0, gui()->mapview_wdg->width(),
1173 gui()->mapview_wdg->height());
1174 } else {
1175 int i;
1176
1177 for (i = 0; i < num_dirty_rects; i++) {
1178 flush_mapcanvas(dirty_rects[i].x(), dirty_rects[i].y(),
1179 dirty_rects[i].width(), dirty_rects[i].height());
1180 }
1181 }
1182 num_dirty_rects = 0;
1183}
1184
1185/**********************************************************************/
1190 void gui_flush(void)
1191{
1192 gui()->mapview_wdg->update();
1193}
1194
1195/**********************************************************************/
1199 void update_map_canvas_scrollbars(void)
1200{
1201 gui()->mapview_wdg->update();
1202}
1203
1204/**********************************************************************/
1207 void update_map_canvas_scrollbars_size(void)
1208{
1209 /* PORTME */
1210}
1211
1212/**********************************************************************/
1215 void update_city_descriptions(void)
1216{
1217 update_map_canvas_visible();
1218}
1219
1220/**********************************************************************/
1223 void pixmap_put_overlay_tile(int canvas_x, int canvas_y,
1224 struct sprite *ssprite)
1225{
1226 if (!ssprite) {
1227 return;
1228 }
1229
1230 /* PORTME */
1231}
1232
1233/**********************************************************************/
1236 void put_cross_overlay_tile(struct tile *ptile)
1237{
1238 float canvas_x, canvas_y;
1239
1240 if (tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, ptile)) {
1241 pixmap_put_overlay_tile(canvas_x, canvas_y,
1242 get_attention_crosshair_sprite(tileset));
1243 }
1244
1245}
1246
1247/**********************************************************************/
1250 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
1251{
1252 /* PORTME */
1253}
1254
1255/**********************************************************************/
1258 void tileset_changed(void)
1259{
1260 int i;
1261 science_report *sci_rep;
1262 QWidget *w;
1263
1264 update_unit_info_label(get_units_in_focus());
1265 destroy_city_dialog();
1266 /* Update science report if open */
1267 if (gui()->is_repo_dlg_open("SCI")) {
1268 i = gui()->gimme_index_of("SCI");
1269 fc_assert(i != -1);
1270 w = gui()->game_tab_widget->widget(i);
1271 sci_rep = reinterpret_cast< science_report*>(w);
1272 sci_rep->reset_tree();
1273 sci_rep->update_report();
1274 sci_rep->repaint();
1275 }
1276}
1277
1278/**********************************************************************/
1282 void get_overview_area_dimensions(int *width, int *height)
1283{
1284 *width = 0;
1285 *height = 0;
1286}
1287
1288/**********************************************************************/
1296 void overview_size_changed(void)
1297{
1298 gui()->minimapview_wdg->resize(0, 0);
1299 gui()->minimapview_wdg->move(gui()->qt_settings.minimap_x
1300 * mapview.width,
1301 gui()->qt_settings.minimap_y
1302 * mapview.height);
1303 gui()->minimapview_wdg->resize(gui()->qt_settings.minimap_width
1304 * mapview.width,
1305 gui()->qt_settings.minimap_height
1306 * mapview.height);
1307}
1308
1309/**********************************************************************/
1312 void update_overview_scroll_window_pos(int x, int y)
1313{
1314 /* TODO: PORTME. */
1315}
1316
1317/**********************************************************************/
1320 bool mapview_is_frozen(void)
1321{
1322 return (0 < mapview_frozen_level);
1323}
1324
1325/**********************************************************************/
1328 void mapview_freeze(void)
1329{
1330 mapview_frozen_level++;
1331}
1332
1333/**********************************************************************/
1336 void mapview_thaw(void)
1337{
1338 if (1 < mapview_frozen_level) {
1339 mapview_frozen_level--;
1340 } else {
1341 fc_assert(0 < mapview_frozen_level);
1342 mapview_frozen_level = 0;
1343 dirty_all();
1344 }
1345}
1346
1347/**********************************************************************/
1350info_tile::info_tile(struct tile *ptile, QWidget *parent): QLabel(parent)
1351{
1352 setParent(parent);
1353 info_font = *fc_font::instance()->get_font(fonts::notify_label);
1354 itile = ptile;
1355 calc_size();
1356}
1357
1358/**********************************************************************/
1361 void info_tile::calc_size()
1362{
1363 QFontMetrics fm(info_font);
1364 QString str;
1365 float x, y;
1366 int w = 0;
1367
1368 str = popup_info_text(itile);
1369 str_list = str.split("\n");
1370
1371 foreach(str, str_list) {
1372 w = qMax(w, fm.horizontalAdvance(str));
1373 }
1374 setFixedHeight(str_list.count() * (fm.height() + 5));
1375 setFixedWidth(w + 10);
1376
1377 if (tile_to_canvas_pos(&x, &y, map_zoom, itile)) {
1378 int fin_x;
1379 int fin_y;
1380 int wh = height();
1381 int ww = width();
1382 int pw = parentWidget()->width();
1383
1384 fin_x = x;
1385 if (y - wh > 0) {
1386 fin_y = y - wh;
1387 } else {
1388 fin_y = y + tileset_tile_height(tileset);
1389 }
1390 if (x + ww > pw) {
1391 fin_x = pw - ww;
1392 }
1393 move(fin_x, fin_y);
1394 }
1395}
1396
1397/**********************************************************************/
1400 void info_tile::paint(QPainter *painter, QPaintEvent *event)
1401{
1402 QFontMetrics fm(info_font);
1403 int pos, h;
1404
1405 h = fm.height();
1406 pos = h;
1407 painter->setFont(info_font);
1408 for (int i = 0; i < str_list.count(); i++) {
1409 painter->drawText(5, pos, str_list.at(i));
1410 pos = pos + 5 + h;
1411 }
1412}
1413
1414/**********************************************************************/
1417 void info_tile::paintEvent(QPaintEvent *event)
1418{
1419 QPainter painter;
1420
1421 painter.begin(this);
1422 paint(&painter, event);
1423 painter.end();
1424}
1425
1426/**********************************************************************/
1429 void info_tile::update_font(const QString &name, const QFont &font)
1430{
1431 if (name == fonts::notify_label) {
1432 info_font = font;
1433 calc_size();
1434 update();
1435 }
1436}
1437
1438/**********************************************************************/
1441 void qtg_start_turn()
1442{
1443 show_new_turn_info();
1444 last_center_enemy = 0;
1445 last_center_capital = 0;
1446 last_center_player_city = 0;
1447 last_center_enemy_city = 0;
1448}
1449
1450/**********************************************************************/
1453 void qtg_map_canvas_size_refresh(void)
1454{
1455 /* Needed only with full screen zoom mode.
1456 * Not needed, nor implemented, in this client. */
1457 fc_assert(false);
1458}
str
#define str
Definition astring.c:76
calendar_text
const char * calendar_text(void)
Definition calendar.c:141
calendar.h
image_copy
void image_copy(QImage *dest, QImage *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
Definition canvas.cpp:119
pixmap_copy
void pixmap_copy(QPixmap *dest, QPixmap *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
Definition canvas.cpp:100
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
pcolor
struct canvas int int struct sprite bool int int fog_y struct canvas struct sprite struct color * pcolor
Definition canvas_g.h:57
canvas_y
struct canvas int int canvas_y
Definition canvas_g.h:43
canvas_x
struct canvas int canvas_x
Definition canvas_g.h:43
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
close_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:500
close_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:508
close_widget::close_widget
close_widget(QWidget *parent)
Definition mapview.cpp:486
close_widget::notify_parent
void notify_parent()
Definition mapview.cpp:522
fc_client::sw_tax
fc_sidewidget * sw_tax
Definition fc_client.h:222
fc_client::update_sidebar_tooltips
void update_sidebar_tooltips()
Definition pages.cpp:2125
fc_client::sw_economy
fc_sidewidget * sw_economy
Definition fc_client.h:223
fc_client::current_page
enum client_pages current_page()
Definition fc_client.cpp:441
fc_client::update_info_label
void update_info_label()
Definition mapview.cpp:993
fc_client::update_info_timer
QTimer * update_info_timer
Definition fc_client.h:214
fc_client::sw_map
fc_sidewidget * sw_map
Definition fc_client.h:220
fc_font::instance
static fc_font * instance()
Definition fonts.cpp:41
fc_font::get_font
QFont * get_font(QString name)
Definition fonts.cpp:63
fc_icons::get_pixmap
QPixmap * get_pixmap(const QString &id)
Definition fc_client.cpp:1046
fc_icons::instance
static fc_icons * instance()
Definition fc_client.cpp:995
fc_sidewidget::set_custom_labels
void set_custom_labels(QString l)
Definition sidebar.cpp:152
fc_sidewidget::update_final_pixmap
void update_final_pixmap()
Definition sidebar.cpp:393
fcwidget
Definition mapview.h:172
fcwidget::update_menu
virtual void update_menu()=0
info_tile::update_font
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:1429
info_tile::calc_size
void calc_size()
Definition mapview.cpp:1361
info_tile::itile
struct tile * itile
Definition mapview.h:122
info_tile::info_tile
info_tile(struct tile *ptile, QWidget *parent=0)
Definition mapview.cpp:1350
info_tile::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:1417
info_tile::str_list
QStringList str_list
Definition mapview.h:127
info_tile::info_font
QFont info_font
Definition mapview.h:119
info_tile::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:1400
map_view::leaveEvent
void leaveEvent(QEvent *event)
Definition mapview.cpp:270
map_view::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:278
map_view::menu_click
bool menu_click
Definition mapview.h:92
map_view::stored_autocenter
bool stored_autocenter
Definition mapview.h:107
map_view::cursor_frame
int cursor_frame
Definition mapview.h:108
map_view::cursor
int cursor
Definition mapview.h:109
map_view::find_place
void find_place(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:327
map_view::timer_event
void timer_event()
Definition mapview.cpp:230
map_view::map_view
map_view()
Definition mapview.cpp:195
map_view::update_cursor
void update_cursor(enum cursor_type)
Definition mapview.cpp:212
map_view::update_font
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:251
map_view::resume_searching
void resume_searching(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:300
map_view::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:290
map_view::focusOutEvent
void focusOutEvent(QFocusEvent *event)
Definition mapview.cpp:262
minimap_thread::mini_height
int mini_height
Definition mapview.h:210
minimap_thread::mini_width
int mini_width
Definition mapview.h:210
minimap_thread::rendered_image
void rendered_image(const QImage &image)
minimap_thread::minimap_thread
minimap_thread(QObject *parent=0)
Definition mapview.cpp:746
minimap_thread::~minimap_thread
~minimap_thread()
Definition mapview.cpp:753
minimap_thread::render
void render(double scale_factor, int width, int height)
Definition mapview.cpp:761
minimap_thread::scale
double scale
Definition mapview.h:211
minimap_thread::run
void run() Q_DECL_OVERRIDE
Definition mapview.cpp:773
minimap_thread::mutex
QMutex mutex
Definition mapview.h:212
minimap_view::position
QPoint position
Definition mapview.h:254
minimap_view::cursor
QPoint cursor
Definition mapview.h:253
minimap_view::update_pixmap
void update_pixmap(const QImage &image)
Definition mapview.cpp:737
minimap_view::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:564
minimap_view::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:952
minimap_view::w_ratio
float w_ratio
Definition mapview.h:249
minimap_view::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:838
minimap_view::showEvent
void showEvent(QShowEvent *event)
Definition mapview.cpp:648
minimap_view::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition mapview.cpp:973
minimap_view::h_ratio
float h_ratio
Definition mapview.h:249
minimap_view::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition mapview.cpp:864
minimap_view::minimap_view
minimap_view(QWidget *parent)
Definition mapview.cpp:533
minimap_view::~minimap_view
~minimap_view()
Definition mapview.cpp:554
minimap_view::scale_factor
double scale_factor
Definition mapview.h:248
minimap_view::zoom_out
void zoom_out()
Definition mapview.cpp:907
minimap_view::pix
QPixmap * pix
Definition mapview.h:252
minimap_view::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:918
minimap_view::zoom_in
void zoom_in()
Definition mapview.cpp:897
minimap_view::rw
resize_widget * rw
Definition mapview.h:255
minimap_view::scale_point
void scale_point(int &x, int &y)
Definition mapview.cpp:693
minimap_view::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition mapview.cpp:884
minimap_view::update_menu
virtual void update_menu()
Definition mapview.cpp:632
minimap_view::moveEvent
void moveEvent(QMoveEvent *event)
Definition mapview.cpp:640
minimap_view::background
QBrush background
Definition mapview.h:251
minimap_view::reset
void reset()
Definition mapview.cpp:729
minimap_view::thread
minimap_thread thread
Definition mapview.h:250
minimap_view::draw_viewport
void draw_viewport(QPainter *painter)
Definition mapview.cpp:657
minimap_view::update_image
void update_image()
Definition mapview.cpp:827
minimap_view::scale
void scale(double factor)
Definition mapview.cpp:576
move_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:400
move_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:418
move_widget::point
QPoint point
Definition mapview.h:164
move_widget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:408
move_widget::move_widget
move_widget(QWidget *parent)
Definition mapview.cpp:385
mr_idle::idling
void idling()
Definition mapview.cpp:173
mr_idle::callback_list
QQueue< call_me_back * > callback_list
Definition mapview.h:72
mr_idle::add_callback
void add_callback(call_me_back *cb)
Definition mapview.cpp:187
mr_idle::~mr_idle
~mr_idle()
Definition mapview.cpp:160
mr_idle::mr_idle
mr_idle()
Definition mapview.cpp:151
resize_widget
Definition mapview.h:136
resize_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:443
resize_widget::resize_widget
resize_widget(QWidget *parent)
Definition mapview.cpp:429
resize_widget::point
QPoint point
Definition mapview.h:146
resize_widget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:452
resize_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:470
can_client_control
bool can_client_control(void)
Definition client_main.c:1254
client
struct civclient client
Definition client_main.c:149
client_state
enum client_states client_state(void)
Definition client_main.c:1029
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:371
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:388
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:348
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:406
climisc.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
event
enum event_type event
Definition events.c:81
get_turn_done_button_state
bool get_turn_done_button_state()
Definition mapctrl_common.c:519
fc_client.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game.h
pos
static struct tile * pos
Definition finddlg.c:53
fc_cursors
GdkCursor * fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES]
Definition graphics.c:48
set_indicator_icons
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.c:285
real_menus_update
void real_menus_update(void)
Definition menu.c:2317
unscale_point
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:711
is_point_in_area
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:70
draw_calculated_trade_routes
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:81
colors.h
mapview.h
menu.h
repodlgs.h
sprite.h
show_new_turn_info
void show_new_turn_info()
Definition hudwidget.cpp:1659
name
const char * name
Definition inputfile.c:127
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
map_pos_to_tile
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:417
base_map_distance_vector
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
Definition map.c:1022
map.h
current_topo_has_flag
#define current_topo_has_flag(flag)
Definition map.h:45
NATURAL_HEIGHT
#define NATURAL_HEIGHT
Definition map.h:221
MAP_IS_ISOMETRIC
#define MAP_IS_ISOMETRIC
Definition map.h:40
NATURAL_WIDTH
#define NATURAL_WIDTH
Definition map.h:220
mapctrl_common.h
flush_dirty
void flush_dirty(void)
Definition mapview.cpp:1166
update_info_label
void update_info_label(void)
Definition mapview.cpp:984
update_turn_done_button
void update_turn_done_button(bool do_restore)
Definition mapview.cpp:1092
last_center_capital
int last_center_capital
Definition pages.cpp:66
dirty_all
void dirty_all(void)
Definition mapview.cpp:1153
last_center_enemy
int last_center_enemy
Definition pages.cpp:79
tileset_changed
void tileset_changed(void)
Definition mapview.cpp:1258
put_cross_overlay_tile
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.cpp:1236
draw_selection_rectangle
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.cpp:1250
flush_mapcanvas
static void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Definition mapview.cpp:1125
update_map_canvas_scrollbars_size
void update_map_canvas_scrollbars_size(void)
Definition mapview.cpp:1207
get_overview_area_dimensions
void get_overview_area_dimensions(int *width, int *height)
Definition mapview.cpp:1282
mapview_freeze
void mapview_freeze(void)
Definition mapview.cpp:1328
MAX_DIRTY_RECTS
#define MAX_DIRTY_RECTS
Definition mapview.cpp:58
last_center_player_city
int last_center_player_city
Definition pages.cpp:67
canvas
struct canvas * canvas
update_overview_scroll_window_pos
void update_overview_scroll_window_pos(int x, int y)
Definition mapview.cpp:1312
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.cpp:1215
unscale_point
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:711
pixmap_put_overlay_tile
void pixmap_put_overlay_tile(int canvas_x, int canvas_y, struct sprite *ssprite)
Definition mapview.cpp:1223
gui_flush
void gui_flush(void)
Definition mapview.cpp:1190
qtg_update_timeout_label
void qtg_update_timeout_label(void)
Definition mapview.cpp:1080
update_map_canvas_scrollbars
void update_map_canvas_scrollbars(void)
Definition mapview.cpp:1199
mapview_is_frozen
bool mapview_is_frozen(void)
Definition mapview.cpp:1320
last_center_enemy_city
int last_center_enemy_city
Definition pages.cpp:68
overview_size_changed
void overview_size_changed(void)
Definition mapview.cpp:1296
qtg_start_turn
void qtg_start_turn()
Definition mapview.cpp:1441
qtg_map_canvas_size_refresh
void qtg_map_canvas_size_refresh(void)
Definition mapview.cpp:1453
is_point_in_area
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:70
draw_calculated_trade_routes
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:81
update_unit_info_label
void update_unit_info_label(struct unit_list *punitlist)
Definition mapview.cpp:1060
mapview_frozen_level
static int mapview_frozen_level
Definition mapview.cpp:54
mapview_thaw
void mapview_thaw(void)
Definition mapview.cpp:1336
get_overview_window
struct canvas * get_overview_window(void)
Definition mapview.cpp:1115
num_dirty_rects
static int num_dirty_rects
Definition mapview.cpp:59
get_timeout_label_text
const char * get_timeout_label_text()
Definition text.c:1590
dirty_rects
static QRect dirty_rects[MAX_DIRTY_RECTS]
Definition mapview.cpp:60
update_mouse_cursor
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.cpp:1071
set_indicator_icons
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.cpp:1106
destroy_city_dialog
void destroy_city_dialog()
Definition citydlg.cpp:3721
gui_to_overview
static void gui_to_overview(int *ovr_x, int *ovr_y, int gui_x, int gui_y)
Definition mapview.cpp:588
update_map_canvas_visible
void update_map_canvas_visible(void)
Definition mapview_common.c:1843
map_to_gui_vector
void map_to_gui_vector(const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
Definition mapview_common.c:553
mapview
struct view mapview
Definition mapview_common.c:74
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
tile_to_canvas_pos
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
Definition mapview_common.c:694
dirty_rect
dirty_rect
Definition mapview_g.h:47
pixel_width
int int int pixel_width
Definition mapview_g.h:48
H
#define H(x, y, z)
Definition md5.c:92
movement.h
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
fonts::city_productions
const char *const city_productions
Definition fonts.h:33
fonts::notify_label
const char *const notify_label
Definition fonts.h:28
fonts::city_names
const char *const city_names
Definition fonts.h:32
gui_options
struct client_options gui_options
Definition options.c:71
overview_to_map_pos
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
Definition overview_common.c:356
OVERVIEW_TILE_SIZE
int OVERVIEW_TILE_SIZE
Definition overview_common.c:33
overview_common.h
player_get_expected_income
int player_get_expected_income(const struct player *pplayer)
Definition player.c:1262
qtg_cxxside.h
research.h
FC_WRAP
#define FC_WRAP(value, range)
Definition shared.h:65
side_blink_endturn
void side_blink_endturn(bool do_restore)
Definition sidebar.cpp:690
sidebar.h
size
size_t size
Definition specvec.h:72
call_me_back
Definition mapview.h:53
call_me_back::callback
void(* callback)(void *data)
Definition mapview.h:54
call_me_back::data
void * data
Definition mapview.h:55
canvas
Definition canvas.h:21
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:309
city::tile
struct tile * tile
Definition city.h:311
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map::xsize
int xsize
Definition map_types.h:77
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::draw_city_trade_routes
bool draw_city_trade_routes
Definition options.h:192
client_options::overview
struct overview overview
Definition options.h:402
client_options::auto_center_on_unit
bool auto_center_on_unit
Definition options.h:148
color
Definition colors.h:20
connection::playing
struct player * playing
Definition connection.h:156
move
Definition widget_window.c:39
overview::map_y0
double map_y0
Definition options.h:92
overview::map_x0
double map_x0
Definition options.h:92
overview::map
struct canvas * map
Definition options.h:96
overview::width
int width
Definition options.h:93
overview::window
struct canvas * window
Definition options.h:99
overview::height
int height
Definition options.h:93
packet_game_info::turn
int turn
Definition packets_gen.h:241
player_economic::gold
int gold
Definition player.h:70
player::economic
struct player_economic economic
Definition player.h:284
qtiles
Definition menu.h:159
qtiles::t1
struct tile * t1
Definition menu.h:160
qtiles::t2
struct tile * t2
Definition menu.h:161
qtiles::autocaravan
struct unit * autocaravan
Definition menu.h:162
science_report
Definition repodlgs.c:69
science_report::update_report
void update_report()
Definition repodlgs.cpp:958
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:946
sprite
Definition sprite.h:22
tile
Definition tile.h:49
tileset
Definition tilespec.c:459
timer
Definition timing.c:81
timer::start
union timer::@11 start
view::height
int height
Definition mapview_common.h:38
view::gui_x0
float gui_x0
Definition mapview_common.h:37
view::store
struct canvas * store
Definition mapview_common.h:42
view::gui_y0
float gui_y0
Definition mapview_common.h:37
view::width
int width
Definition mapview_common.h:38
world::map
struct civ_map map
Definition world_object.h:38
support.h
popup_info_text
const char * popup_info_text(struct tile *ptile)
Definition text.c:146
text.h
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
TILE_XY
#define TILE_XY(ptile)
Definition tile.h:42
get_attention_crosshair_sprite
struct sprite * get_attention_crosshair_sprite(const struct tileset *t)
Definition tilespec.c:6689
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
NUM_CURSOR_FRAMES
#define NUM_CURSOR_FRAMES
Definition tilespec.h:300
cursor_type
cursor_type
Definition tilespec.h:285
CURSOR_DEFAULT
@ CURSOR_DEFAULT
Definition tilespec.h:297
have_cities_trade_route
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:532
map_zoom
float map_zoom
Definition zoom.c:25
zoom.h