Freeciv-3.3
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 "gui_main.h"
50#include "mapview.h"
51#include "qtg_cxxside.h"
52#include "sidebar.h"
53
54const char *get_timeout_label_text();
55static int mapview_frozen_level = 0;
56extern void destroy_city_dialog();
57extern struct canvas *canvas;
58
59#define MAX_DIRTY_RECTS 20
60static int num_dirty_rects = 0;
62
63extern int last_center_enemy;
64extern int last_center_capital;
66extern int last_center_enemy_city;
67
68/**********************************************************************/
71bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
72{
73 if (x >= px && y >= py && x <= pxe && y <= pye) {
74 return true;
75 }
76 return false;
77}
78
79/**********************************************************************/
83{
84 int dx, dy;
85 float w, h;
86 float x1, y1, x2, y2;
88 struct city *pcity;
89 struct color *pcolor;
90 QPen pen;
91
93 || gui()->trade_gen.cities.empty()) {
94 return;
95 }
97 // Draw calculated trade routes
99
100 foreach (qgilles, gui()->trade_gen.lines) {
102 TILE_XY(qgilles.t2));
103 map_to_gui_vector(tileset, 1.0, &w, &h, dx, dy);
104
107
108 // Dont draw if route was already established
109 if (tile_city(qgilles.t1) && tile_city(qgilles.t2)
111 tile_city(qgilles.t2))) {
112 continue;
113 }
114
115 if (qgilles.autocaravan != nullptr) {
117 }
118
119 pen.setColor(pcolor->qcolor);
120 pen.setStyle(Qt::DashLine);
121 pen.setDashOffset(4);
122 pen.setWidth(1);
123 painter->setPen(pen);
124 if (x2 - x1 == w && y2 - y1 == h) {
125 painter->drawLine(x1 + tileset_tile_width(tileset) / 2,
127 x1 + tileset_tile_width(tileset) / 2 + w,
128 y1 + tileset_tile_height(tileset) / 2 + h);
129 continue;
130 }
131 painter->drawLine(x2 + tileset_tile_width(tileset) / 2,
133 x2 + tileset_tile_width(tileset) / 2 - w,
134 y2 + tileset_tile_height(tileset) / 2 - h);
135 }
136 }
137 // Draw virtual cities
138 foreach (pcity, gui()->trade_gen.virtual_cities) {
139 float canvas_x, canvas_y;
140 if (pcity->tile != nullptr
142 painter->drawPixmap(static_cast<int>(canvas_x),
143 static_cast<int>(canvas_y),
145 }
146 }
147}
148
149/**********************************************************************/
153{
154 connect(&timer, &QTimer::timeout, this, &mr_idle::idling);
155 timer.start(5);
156}
157
158/**********************************************************************/
162{
163 call_me_back *cb;
164
165 while (!callback_list.isEmpty()) {
166 cb = callback_list.dequeue();
167 delete cb;
168 }
169}
170
171/**********************************************************************/
175{
176 call_me_back *cb;
177
178 while (!callback_list.isEmpty()) {
179 cb = callback_list.dequeue();
180 (cb->callback) (cb->data);
181 delete cb;
182 }
183}
184
185/**********************************************************************/
189{
190 callback_list.enqueue(cb);
191}
192
193/**********************************************************************/
197{
198 menu_click = false;
199 cursor = -1;
200 QTimer *timer = new QTimer(this);
201 setAttribute(Qt::WA_OpaquePaintEvent, true);
202 connect(timer, &QTimer::timeout, this, &map_view::timer_event);
203 timer->start(200);
204 resize(0, 0);
205 setMouseTracking(true);
207 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
208}
209
210/**********************************************************************/
214{
215 int i;
216
217 if (ct == CURSOR_DEFAULT) {
218 setCursor(Qt::ArrowCursor);
219 cursor = -1;
220 return;
221 }
222 cursor_frame = 0;
223 i = static_cast<int>(ct);
224 cursor = i;
225 setCursor(*(gui()->fc_cursors[i][0]));
226}
227
228/**********************************************************************/
232{
233 if (gui()->infotab->underMouse()
234 || gui()->minimapview_wdg->underMouse()
235 || gui()->sidebar_wdg->underMouse()) {
237 return;
238 }
239 if (cursor == -1) {
240 return;
241 }
242 cursor_frame++;
244 cursor_frame = 0;
245 }
247}
248
249/**********************************************************************/
252void map_view::update_font(const QString &name, const QFont &font)
253{
257 }
258}
259
260/**********************************************************************/
267
268/**********************************************************************/
275
276/**********************************************************************/
280{
282
283 painter.begin(this);
285 painter.end();
286}
287
288/**********************************************************************/
297
298/**********************************************************************/
301void map_view::resume_searching(int pos_x, int pos_y, int &w, int &h,
302 int wdth, int hght, int recursive_nr)
303{
304 int new_pos_x, new_pos_y;
305
306 recursive_nr++;
307 new_pos_x = pos_x;
308 new_pos_y = pos_y;
309
310 if (pos_y + hght + 4 < height() && pos_x > width() / 2) {
311 new_pos_y = pos_y + 5;
312 } else if (pos_x > 0 && pos_y > 10) {
313 new_pos_x = pos_x - 5;
314 } else if (pos_y > 0) {
315 new_pos_y = pos_y - 5;
316 } else if (pos_x + wdth + 4 < this->width()) {
317 new_pos_x = pos_x + 5;
318 }
320}
321
322/**********************************************************************/
328void map_view::find_place(int pos_x, int pos_y, int &w, int &h, int wdth,
329 int hght, int recursive_nr)
330{
331 int i;
332 int x, y, xe, ye;
334 bool cont_searching = false;
335
336 if (recursive_nr >= 1000) {
337 // Give up searching position
338 return;
339 }
345 for (i = 0; i < widgets.count(); i++) {
346 if (!widgets[i]->isVisible()) {
347 continue;
348 }
349 x = widgets[i]->pos().x();
350 y = widgets[i]->pos().y();
351
352 if (x == 0 && y ==0) {
353 continue;
354 }
355 xe = widgets[i]->pos().x() + widgets[i]->width();
356 ye = widgets[i]->pos().y() + widgets[i]->height();
357
358 if (is_point_in_area(pos_x, pos_y, x, y, xe, ye)) {
359 cont_searching = true;
360 }
361 if (is_point_in_area(pos_x + wdth, pos_y, x, y, xe, ye)) {
362 cont_searching = true;
363 }
364 if (is_point_in_area(pos_x + wdth, pos_y + hght, x, y, xe, ye)) {
365 cont_searching = true;
366 }
367 if (is_point_in_area(pos_x, pos_y + hght, x, y, xe, ye)) {
368 cont_searching = true;
369 }
370 if (is_point_in_area(pos_x + wdth / 2, pos_y + hght / 2, x, y, xe, ye)) {
371 cont_searching = true;
372 }
373 }
374 w = pos_x;
375 h = pos_y;
376 if (cont_searching) {
377 resume_searching(pos_x, pos_y, w, h, wdth, hght, recursive_nr);
378 }
379}
380
381/**********************************************************************/
385{
386 QPixmap *pix;
387
389 setCursor(Qt::SizeAllCursor);
390 pix = fc_icons::instance()->get_pixmap("move");
391 setPixmap(*pix);
392 delete pix;
393 setFixedSize(16, 16);
394}
395
396/**********************************************************************/
400{
401 move(0, 0);
402}
403
404/**********************************************************************/
408{
409 if (!gui()->interface_locked) {
411 }
412}
413
414/**********************************************************************/
418{
419 if (!gui()->interface_locked) {
420 point = mevent_gpos(event) - parentWidget()->geometry().topLeft();
421 }
422
423 update();
424}
425
426/**********************************************************************/
430{
431 QPixmap *pix;
432
434 setCursor(Qt::SizeFDiagCursor);
435 pix = fc_icons::instance()->get_pixmap("resize");
436 setPixmap(*pix);
437 delete pix;
438}
439
440/**********************************************************************/
448
449/**********************************************************************/
453{
454 QPoint qp, np;
455
456 if (gui()->interface_locked) {
457 return;
458 }
459
461 np.setX(qp.x() - point.x());
462 np.setY(qp.y() - point.y());
463 np.setX(qMax(np.x(), 32));
464 np.setY(qMax(np.y(), 32));
465 parentWidget()->resize(np.x(), np.y());
466}
467
468/**********************************************************************/
472{
473 QPoint qp;
474
475 if (gui()->interface_locked) {
476 return;
477 }
478
480 point.setX(qp.x() - parentWidget()->width());
481 point.setY(qp.y() - parentWidget()->height());
482 update();
483}
484
485/**********************************************************************/
489{
490 QPixmap *pix;
491
493 setCursor(Qt::ArrowCursor);
494 pix = fc_icons::instance()->get_pixmap("close");
495 setPixmap(*pix);
496 delete pix;
497}
498
499/**********************************************************************/
503{
504 move(parentWidget()->width()-width(), 0);
505}
506
507/**********************************************************************/
511{
512 if (gui()->interface_locked) {
513 return;
514 }
515 if (event->button() == Qt::LeftButton) {
516 parentWidget()->hide();
518 }
519}
520
521/**********************************************************************/
525{
526 fcwidget *fcw;
527
528 fcw = reinterpret_cast<fcwidget *>(parentWidget());
529 fcw->update_menu();
530}
531
532/**********************************************************************/
536{
538 setAttribute(Qt::WA_OpaquePaintEvent, true);
539 w_ratio = 0.0;
540 h_ratio = 0.0;
541 // Dark magic: This call is required for the widget to work.
542 resize(0, 0);
543 background = QBrush(QColor (0, 0, 0));
544 setCursor(Qt::CrossCursor);
545 rw = new resize_widget(this);
546 rw->put_to_corner();
547 pix = new QPixmap;
548 scale_factor = 1.0;
551}
552
553/**********************************************************************/
557{
558 if (pix) {
559 delete pix;
560 }
561}
562
563/**********************************************************************/
567{
569
570 painter.begin(this);
572 painter.end();
573}
574
575/**********************************************************************/
578void minimap_view::scale(double factor)
579{
580 scale_factor *= factor;
581 if (scale_factor < 1) {
582 scale_factor = 1.0;
583 };
584 update_image();
585}
586
587/**********************************************************************/
590static void gui_to_overview(int *ovr_x, int *ovr_y, int gui_x, int gui_y)
591{
592 double ntl_x, ntl_y;
593 const double gui_xd = gui_x, gui_yd = gui_y;
594 const double W = tileset_tile_width(tileset);
595 const double H = tileset_tile_height(tileset);
596 double map_x, map_y;
597
599 map_x = (gui_xd * H + gui_yd * W) / (W * H);
600 map_y = (gui_yd * W - gui_xd * H) / (W * H);
601 } else {
602 map_x = gui_xd / W;
603 map_y = gui_yd / H;
604 }
605
606 if (MAP_IS_ISOMETRIC) {
608 ntl_x = 2 * map_x - ntl_y;
609 } else {
610 ntl_x = map_x;
611 ntl_y = map_y;
612 }
613
618
621 } else {
622 if (MAP_IS_ISOMETRIC) {
624 }
625 }
628 }
629}
630
631/**********************************************************************/
635{
636 ::gui()->menu_bar->minimap_status->setChecked(false);
637}
638
639/**********************************************************************/
643{
644 position = event->pos();
645}
646
647/**********************************************************************/
651{
652 move(position);
653 event->setAccepted(true);
654}
655
656/**********************************************************************/
660{
661 int i, x[4], y[4];
662 int src_x, src_y, dst_x, dst_y;
663
664 if (!gui_options.overview.map) {
665 return;
666 }
667
673 gui_to_overview(&x[3], &y[3], mapview.gui_x0,
675 painter->setPen(QColor(Qt::white));
676
677 if (scale_factor > 1) {
678 for (i = 0; i < 4; i++) {
679 scale_point(x[i], y[i]);
680 }
681 }
682
683 for (i = 0; i < 4; i++) {
684 src_x = x[i] * w_ratio;
685 src_y = y[i] * h_ratio;
686 dst_x = x[(i + 1) % 4] * w_ratio;
687 dst_y = y[(i + 1) % 4] * h_ratio;
688 painter->drawLine(src_x, src_y, dst_x, dst_y);
689 }
690}
691
692/**********************************************************************/
696{
697 int ax, bx;
698 int dx, dy;
699
702 x = qRound(x * scale_factor);
703 y = qRound(y * scale_factor);
706 x = x - dx;
707 y = y - dy;
708}
709
710/**********************************************************************/
713void unscale_point(double scale_factor, int &x, int &y)
714{
715 int ax, bx;
716 int dx, dy;
717
720 dx = qRound(ax * scale_factor - gui_options.overview.width / 2);
721 dy = qRound(bx * scale_factor - gui_options.overview.height / 2);
722 x = x + dx;
723 y = y + dy;
724 x = qRound(x / scale_factor);
725 y = qRound(y / scale_factor);
726}
727
728/**********************************************************************/
732{
733 scale_factor = 1;
734}
735
736/**********************************************************************/
740{
741 *pix = QPixmap::fromImage(image);
742 update();
743}
744
745/**********************************************************************/
749{
750}
751
752/**********************************************************************/
756{
757 wait();
758}
759
760/**********************************************************************/
763void minimap_thread::render(double scale_factor, int width, int height)
764{
768 scale = scale_factor;
769 start(LowPriority);
770}
771
772/**********************************************************************/
776{
777 QImage tpix;
778 QImage gpix;
779 QImage image(QSize(mini_width, mini_height), QImage::Format_RGB32);
781 gui_options.overview.height * 2, QImage::Format_RGB32);
782 int delta_x, delta_y;
783 int x, y, ix, iy;
784 float wf, hf;
785 QPixmap *src, *dst;
786
787 mutex.lock();
788 if (gui_options.overview.map != nullptr) {
789 if (scale > 1) {
790 /* move minimap now,
791 scale later and draw without looking for origin */
798 pixmap_copy(dst, src, 0, 0, ix, iy, x, y);
799 pixmap_copy(dst, src, 0, y, ix, 0, x, iy);
800 pixmap_copy(dst, src, x, 0, 0, iy, ix, y);
801 pixmap_copy(dst, src, x, y, 0, 0, ix, iy);
803 wf = static_cast <float>(gui_options.overview.width) / scale;
804 hf = static_cast <float>(gui_options.overview.height) / scale;
805 x = 0;
806 y = 0;
808 bigger_pix.fill(Qt::black);
809 delta_x = gui_options.overview.width / 2;
810 delta_y = gui_options.overview.height / 2;
811 image_copy(&bigger_pix, &tpix, 0, 0, delta_x, delta_y,
813 gpix = bigger_pix.copy(delta_x + x, delta_y + y, wf, hf);
815 Qt::IgnoreAspectRatio, Qt::FastTransformation);
816 } else {
819 Qt::IgnoreAspectRatio, Qt::FastTransformation);
820 }
821 }
823 mutex.unlock();
824}
825
826/**********************************************************************/
830{
831 if (isHidden()) {
832 return;
833 }
835}
836
837/**********************************************************************/
841{
842 int x, y, ix, iy;
843
846 ix = pix->width() - x;
847 iy = pix->height() - y;
848
849 if (scale_factor > 1) {
850 painter->drawPixmap(0, 0, *pix, 0, 0, pix->width(), pix->height());
851 } else {
852 painter->drawPixmap(ix, iy, *pix, 0, 0, x, y);
853 painter->drawPixmap(ix, 0, *pix, 0, y, x, iy);
854 painter->drawPixmap(0, iy, *pix, x, 0, ix, y);
855 painter->drawPixmap(0, 0, *pix, x, y, ix, iy);
856 }
857 painter->setPen(QColor(palette().color(QPalette::Highlight)));
858 painter->drawRect(0, 0, width() - 1, height() - 1);
860 rw->put_to_corner();
861}
862
863/**********************************************************************/
867{
868 QSize size;
869 size = event->size();
870
871 if (C_S_RUNNING <= client_state() && size.width() > 0
872 && size.height() > 0) {
873 w_ratio = static_cast<float>(width()) / gui_options.overview.width;
874 h_ratio = static_cast<float>(height()) / gui_options.overview.height;
875 gui()->qt_settings.minimap_width = static_cast<float>(size.width())
876 / mapview.width;
877 gui()->qt_settings.minimap_height = static_cast<float>(size.height())
878 / mapview.height;
879 }
880 update_image();
881}
882
883/**********************************************************************/
887{
888 if (event->angleDelta().y() > 0) {
889 zoom_in();
890 } else {
891 zoom_out();
892 }
893 event->accept();
894}
895
896/**********************************************************************/
900{
902 scale(1.2);
903 }
904}
905
906/**********************************************************************/
910{
911 scale(0.833);
912}
913
914/**********************************************************************/
921{
922 int fx, fy;
923 int x, y;
924
925 if (event->button() == Qt::LeftButton) {
926 if (gui()->interface_locked) {
927 return;
928 }
929 cursor = mevent_gpos(event) - geometry().topLeft();
930 }
931
932 if (event->button() == Qt::RightButton) {
933 cursor = event->pos();
934 fx = event->pos().x();
935 fy = event->pos().y();
936 fx = qRound(fx / w_ratio);
937 fy = qRound(fy / h_ratio);
938 if (scale_factor > 1) {
940 }
941 fx = qMax(fx, 1);
942 fy = qMax(fy, 1);
947 update_image();
948 }
949
950 event->setAccepted(true);
951}
952
953/**********************************************************************/
957{
958 if (gui()->interface_locked) {
959 return;
960 }
961
962 if (event->buttons() & Qt::LeftButton) {
963 QPoint p, r;
964
965 p = event->pos();
966 r = mapTo(gui()->mapview_wdg, p);
967 p = r - p;
969 setCursor(Qt::SizeAllCursor);
970 gui()->qt_settings.minimap_x = static_cast<float>(p.x()) / mapview.width;
971 gui()->qt_settings.minimap_y = static_cast<float>(p.y())
972 / mapview.height;
973 }
974}
975
976/**********************************************************************/
980{
981 setCursor(Qt::CrossCursor);
982}
983
984
985/**********************************************************************/
991{
992 gui()->update_info_label();
993}
994
995
996/**********************************************************************/
1000{
1001 QString s, eco_info;
1002
1003 if (current_page() != PAGE_GAME) {
1004 return;
1005 }
1006 if (update_info_timer == nullptr) {
1007 update_info_timer = new QTimer();
1008 update_info_timer->setSingleShot(true);
1009 connect(update_info_timer, &QTimer::timeout,
1011 update_info_timer->start(300);
1012 return;
1013 }
1014
1015 if (update_info_timer->remainingTime() > 0) {
1016 return;
1017 }
1019 if (head_of_units_in_focus() != nullptr) {
1021 }
1022 /* TRANS: T is shortcut from Turn */
1023 s = QString(_("%1 \nT:%2")).arg(calendar_text(),
1024 QString::number(game.info.turn));
1025
1028
1032
1033 if (client.conn.playing != nullptr) {
1035 eco_info = QString(_("%1 (+%2)"))
1036 .arg(QString::number(client.conn.playing->economic.gold),
1037 QString::number(player_get_expected_income(client.conn.playing)));
1038 } else {
1039 eco_info = QString(_("%1 (%2)"))
1040 .arg(QString::number(client.conn.playing->economic.gold),
1041 QString::number(player_get_expected_income(client.conn.playing)));
1042 }
1044 } else {
1046 }
1049 delete update_info_timer;
1050 update_info_timer = nullptr;
1051}
1052
1053
1054/**********************************************************************/
1066void update_unit_info_label(struct unit_list *punitlist)
1067{
1068 if (gui()->unitinfo_wdg->isVisible()) {
1069 gui()->unitinfo_wdg->update_actions(nullptr);
1070 }
1071}
1072
1073/**********************************************************************/
1078{
1079 gui()->mapview_wdg->update_cursor(new_cursor_type);
1080}
1081
1082/**********************************************************************/
1087{
1088 gui()->sw_endturn->set_custom_labels(QString(get_timeout_label_text()));
1089 gui()->sw_endturn->update_final_pixmap();
1090}
1091
1092/**********************************************************************/
1099{
1101 return;
1102 }
1104}
1105
1106
1107/**********************************************************************/
1113 struct sprite *flake, struct sprite *gov)
1114{
1115 gui()->sw_indicators->update_final_pixmap();
1116}
1117
1118/**********************************************************************/
1122{
1123 gui()->minimapview_wdg->update_image();
1124 return nullptr;
1125}
1126
1127/**********************************************************************/
1131static void flush_mapcanvas(int canvas_x, int canvas_y,
1132 int pixel_width, int pixel_height)
1133{
1134 gui()->mapview_wdg->repaint(canvas_x, canvas_y, pixel_width, pixel_height);
1135}
1136
1137/**********************************************************************/
1142 int pixel_width, int pixel_height)
1143{
1144 if (mapview_is_frozen()) {
1145 return;
1146 }
1153 }
1154}
1155
1156/**********************************************************************/
1159void dirty_all(void)
1160{
1161 if (mapview_is_frozen()) {
1162 return;
1163 }
1165}
1166
1167/**********************************************************************/
1172void flush_dirty(void)
1173{
1174 if (mapview_is_frozen()) {
1175 return;
1176 }
1178 flush_mapcanvas(0, 0, gui()->mapview_wdg->width(),
1179 gui()->mapview_wdg->height());
1180 } else {
1181 int i;
1182
1183 for (i = 0; i < num_dirty_rects; i++) {
1186 }
1187 }
1188 num_dirty_rects = 0;
1189}
1190
1191/**********************************************************************/
1196void gui_flush(void)
1197{
1198 gui()->mapview_wdg->update();
1199}
1200
1201/**********************************************************************/
1206{
1207 gui()->mapview_wdg->update();
1208}
1209
1210/**********************************************************************/
1214{
1215 // PORTME
1216}
1217
1218/**********************************************************************/
1225
1226/**********************************************************************/
1230 struct sprite *ssprite)
1231{
1232 if (!ssprite) {
1233 return;
1234 }
1235
1236 // PORTME
1237}
1238
1239/**********************************************************************/
1242void put_cross_overlay_tile(struct tile *ptile)
1243{
1244 float canvas_x, canvas_y;
1245
1246 if (tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, ptile)) {
1249 }
1250
1251}
1252
1253/**********************************************************************/
1256void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
1257{
1258 // PORTME
1259}
1260
1261/**********************************************************************/
1265{
1266 int i;
1268 QWidget *w;
1269
1272 // Update science report if open
1273 if (gui()->is_repo_dlg_open("SCI")) {
1274 i = gui()->gimme_index_of("SCI");
1275 fc_assert(i != -1);
1276 w = gui()->game_tab_widget->widget(i);
1277 sci_rep = reinterpret_cast<science_report*>(w);
1279 sci_rep->update_report();
1280 sci_rep->repaint();
1281 }
1282}
1283
1284/**********************************************************************/
1289{
1290 *width = 0;
1291 *height = 0;
1292}
1293
1294/**********************************************************************/
1303{
1304 gui()->minimapview_wdg->resize(0, 0);
1305 gui()->minimapview_wdg->move(gui()->qt_settings.minimap_x
1306 * mapview.width,
1307 gui()->qt_settings.minimap_y
1308 * mapview.height);
1309 gui()->minimapview_wdg->resize(gui()->qt_settings.minimap_width
1310 * mapview.width,
1311 gui()->qt_settings.minimap_height
1312 * mapview.height);
1313}
1314
1315/**********************************************************************/
1319{
1320 // TODO: PORTME.
1321}
1322
1323/**********************************************************************/
1327{
1328 return (0 < mapview_frozen_level);
1329}
1330
1331/**********************************************************************/
1335{
1337}
1338
1339/**********************************************************************/
1343{
1344 if (1 < mapview_frozen_level) {
1346 } else {
1349 dirty_all();
1350 }
1351}
1352
1353/**********************************************************************/
1356info_tile::info_tile(struct tile *ptile, QWidget *parent): QLabel(parent)
1357{
1360 itile = ptile;
1361 calc_size();
1362}
1363
1364/**********************************************************************/
1368{
1370 QString str;
1371 float x, y;
1372 int w = 0;
1373
1375 str_list = str.split("\n");
1376
1377 foreach(str, str_list) {
1378 w = qMax(w, fm.horizontalAdvance(str));
1379 }
1380 setFixedHeight(str_list.count() * (fm.height() + 5));
1381 setFixedWidth(w + 10);
1382
1383 if (tile_to_canvas_pos(&x, &y, map_zoom, itile)) {
1384 int fin_x;
1385 int fin_y;
1386 int wh = height();
1387 int ww = width();
1388 int pw = parentWidget()->width();
1389
1390 fin_x = x;
1391 if (y - wh > 0) {
1392 fin_y = y - wh;
1393 } else {
1395 }
1396 if (x + ww > pw) {
1397 fin_x = pw - ww;
1398 }
1399 move(fin_x, fin_y);
1400 }
1401}
1402
1403/**********************************************************************/
1407{
1409 int pos, h;
1410
1411 h = fm.height();
1412 pos = h;
1413 painter->setFont(info_font);
1414 for (int i = 0; i < str_list.count(); i++) {
1415 painter->drawText(5, pos, str_list.at(i));
1416 pos = pos + 5 + h;
1417 }
1418}
1419
1420/**********************************************************************/
1424{
1426
1427 painter.begin(this);
1428 paint(&painter, event);
1429 painter.end();
1430}
1431
1432/**********************************************************************/
1435void info_tile::update_font(const QString &name, const QFont &font)
1436{
1437 if (name == fonts::notify_label) {
1438 info_font = font;
1439 calc_size();
1440 update();
1441 }
1442}
1443
1444/**********************************************************************/
1455
1456/**********************************************************************/
1460{
1461 /* Needed only with full screen zoom mode.
1462 * Not needed, nor implemented, in this client. */
1463 fc_assert(false);
1464}
#define str
Definition astring.c:76
const char * calendar_text(void)
Definition calendar.c:142
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:120
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:101
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void put_to_corner()
Definition mapview.cpp:502
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:510
close_widget(QWidget *parent)
Definition mapview.cpp:488
void notify_parent()
Definition mapview.cpp:524
fc_sidewidget * sw_tax
Definition fc_client.h:222
void update_sidebar_tooltips()
Definition pages.cpp:2160
fc_sidewidget * sw_economy
Definition fc_client.h:223
enum client_pages current_page()
void update_info_label()
Definition mapview.cpp:999
QTimer * update_info_timer
Definition fc_client.h:214
fc_sidewidget * sw_map
Definition fc_client.h:220
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
void set_custom_labels(QString l)
Definition sidebar.cpp:152
void update_final_pixmap()
Definition sidebar.cpp:393
virtual void update_menu()=0
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:1435
void calc_size()
Definition mapview.cpp:1367
struct tile * itile
Definition mapview.h:122
info_tile(struct tile *ptile, QWidget *parent=0)
Definition mapview.cpp:1356
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:1423
QStringList str_list
Definition mapview.h:127
QFont info_font
Definition mapview.h:119
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:1406
void leaveEvent(QEvent *event)
Definition mapview.cpp:271
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:279
bool menu_click
Definition mapview.h:92
bool stored_autocenter
Definition mapview.h:107
int cursor_frame
Definition mapview.h:108
int cursor
Definition mapview.h:109
void find_place(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:328
void timer_event()
Definition mapview.cpp:231
void update_cursor(enum cursor_type)
Definition mapview.cpp:213
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:252
void resume_searching(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:301
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:291
void focusOutEvent(QFocusEvent *event)
Definition mapview.cpp:263
void rendered_image(const QImage &image)
minimap_thread(QObject *parent=0)
Definition mapview.cpp:748
void render(double scale_factor, int width, int height)
Definition mapview.cpp:763
double scale
Definition mapview.h:211
void run() Q_DECL_OVERRIDE
Definition mapview.cpp:775
QMutex mutex
Definition mapview.h:212
QPoint position
Definition mapview.h:254
QPoint cursor
Definition mapview.h:253
void update_pixmap(const QImage &image)
Definition mapview.cpp:739
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:566
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:956
float w_ratio
Definition mapview.h:249
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:840
void showEvent(QShowEvent *event)
Definition mapview.cpp:650
void mouseReleaseEvent(QMouseEvent *event)
Definition mapview.cpp:979
float h_ratio
Definition mapview.h:249
void resizeEvent(QResizeEvent *event)
Definition mapview.cpp:866
minimap_view(QWidget *parent)
Definition mapview.cpp:535
double scale_factor
Definition mapview.h:248
void zoom_out()
Definition mapview.cpp:909
QPixmap * pix
Definition mapview.h:252
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:920
void zoom_in()
Definition mapview.cpp:899
resize_widget * rw
Definition mapview.h:255
void scale_point(int &x, int &y)
Definition mapview.cpp:695
void wheelEvent(QWheelEvent *event)
Definition mapview.cpp:886
virtual void update_menu()
Definition mapview.cpp:634
void moveEvent(QMoveEvent *event)
Definition mapview.cpp:642
QBrush background
Definition mapview.h:251
void reset()
Definition mapview.cpp:731
minimap_thread thread
Definition mapview.h:250
void draw_viewport(QPainter *painter)
Definition mapview.cpp:659
void update_image()
Definition mapview.cpp:829
void scale(double factor)
Definition mapview.cpp:578
void put_to_corner()
Definition mapview.cpp:399
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:417
QPoint point
Definition mapview.h:164
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:407
move_widget(QWidget *parent)
Definition mapview.cpp:384
void idling()
Definition mapview.cpp:174
QQueue< call_me_back * > callback_list
Definition mapview.h:72
void add_callback(call_me_back *cb)
Definition mapview.cpp:188
void put_to_corner()
Definition mapview.cpp:443
resize_widget(QWidget *parent)
Definition mapview.cpp:429
QPoint point
Definition mapview.h:146
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:452
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:471
bool can_client_control(void)
struct civclient client
enum client_states client_state(void)
@ C_S_RUNNING
Definition client_main.h:47
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
struct sprite * client_research_sprite(void)
Definition climisc.c:354
struct sprite * client_government_sprite(void)
Definition climisc.c:412
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
char * incite_cost
Definition comments.c:76
struct unit_list * get_units_in_focus(void)
Definition control.c:177
struct unit * head_of_units_in_focus(void)
Definition control.c:410
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
enum event_type event
Definition events.c:81
bool get_turn_done_button_state()
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
static struct tile * pos
Definition finddlg.c:53
GdkCursor * fc_cursors[CURSOR_LAST][NUM_CURSOR_FRAMES]
Definition graphics.c:48
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.c:302
void real_menus_update(void)
Definition menu.c:2353
#define mevent_gpos(__ev__)
Definition gui_main.h:23
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:713
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:71
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:82
void show_new_turn_info()
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:177
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:434
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
Definition map.c:1162
#define current_wrap_has_flag(flag)
Definition map.h:46
void flush_dirty(void)
Definition mapview.cpp:1172
void update_info_label(void)
Definition mapview.cpp:990
void update_turn_done_button(bool do_restore)
Definition mapview.cpp:1098
int last_center_capital
Definition pages.cpp:68
void dirty_all(void)
Definition mapview.cpp:1159
int last_center_enemy
Definition pages.cpp:81
void tileset_changed(void)
Definition mapview.cpp:1264
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.cpp:1242
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.cpp:1256
static void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Definition mapview.cpp:1131
void update_map_canvas_scrollbars_size(void)
Definition mapview.cpp:1213
void get_overview_area_dimensions(int *width, int *height)
Definition mapview.cpp:1288
void mapview_freeze(void)
Definition mapview.cpp:1334
#define MAX_DIRTY_RECTS
Definition mapview.cpp:59
int last_center_player_city
Definition pages.cpp:69
struct canvas * canvas
void update_overview_scroll_window_pos(int x, int y)
Definition mapview.cpp:1318
void update_city_descriptions(void)
Definition mapview.cpp:1221
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:713
void pixmap_put_overlay_tile(int canvas_x, int canvas_y, struct sprite *ssprite)
Definition mapview.cpp:1229
void gui_flush(void)
Definition mapview.cpp:1196
void qtg_update_timeout_label(void)
Definition mapview.cpp:1086
void update_map_canvas_scrollbars(void)
Definition mapview.cpp:1205
bool mapview_is_frozen(void)
Definition mapview.cpp:1326
int last_center_enemy_city
Definition pages.cpp:70
void overview_size_changed(void)
Definition mapview.cpp:1302
void qtg_start_turn()
Definition mapview.cpp:1447
void qtg_map_canvas_size_refresh(void)
Definition mapview.cpp:1459
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:71
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:82
void update_unit_info_label(struct unit_list *punitlist)
Definition mapview.cpp:1066
static int mapview_frozen_level
Definition mapview.cpp:55
void mapview_thaw(void)
Definition mapview.cpp:1342
struct canvas * get_overview_window(void)
Definition mapview.cpp:1121
static int num_dirty_rects
Definition mapview.cpp:60
const char * get_timeout_label_text()
Definition text.c:1604
static QRect dirty_rects[MAX_DIRTY_RECTS]
Definition mapview.cpp:61
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.cpp:1077
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.cpp:1112
void destroy_city_dialog()
Definition citydlg.cpp:3839
static void gui_to_overview(int *ovr_x, int *ovr_y, int gui_x, int gui_y)
Definition mapview.cpp:590
void update_map_canvas_visible(void)
void map_to_gui_vector(const struct tileset *t, float zoom, float *gui_dx, float *gui_dy, int map_dx, int map_dy)
struct view mapview
void center_tile_mapcanvas(const struct tile *ptile)
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
dirty_rect
Definition mapview_g.h:47
int int int pixel_width
Definition mapview_g.h:48
#define H(x, y, z)
Definition md5.c:92
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const city_productions
Definition fonts.h:33
const char *const notify_label
Definition fonts.h:28
const char *const city_names
Definition fonts.h:32
struct client_options gui_options
Definition options.c:71
void overview_to_map_pos(int *map_x, int *map_y, int overview_x, int overview_y)
int OVERVIEW_TILE_SIZE
int player_get_expected_income(const struct player *pplayer)
Definition player.c:1286
#define FC_WRAP(value, range)
Definition shared.h:65
void side_blink_endturn(bool do_restore)
Definition sidebar.cpp:689
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
struct sprite int x
Definition sprite_g.h:31
void(* callback)(void *data)
Definition mapview.h:54
void * data
Definition mapview.h:55
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
bool draw_city_trade_routes
Definition options.h:201
struct overview overview
Definition options.h:462
bool auto_center_on_unit
Definition options.h:156
Definition colors.h:21
struct player * playing
Definition connection.h:151
double map_y0
Definition options.h:93
double map_x0
Definition options.h:93
struct canvas * map
Definition options.h:97
int width
Definition options.h:94
struct canvas * window
Definition options.h:100
int height
Definition options.h:94
struct player_economic economic
Definition player.h:284
Definition menu.h:160
void reset_tree()
Definition repodlgs.cpp:954
Definition tile.h:50
Definition timing.c:81
union timer::@11 start
struct tile * tile
Definition unit.h:142
int height
float gui_x0
struct canvas * store
float gui_y0
int width
struct civ_map map
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define TILE_XY(ptile)
Definition tile.h:43
struct sprite * get_attention_crosshair_sprite(const struct tileset *t)
Definition tilespec.c:7214
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:738
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:791
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
#define NUM_CURSOR_FRAMES
Definition tilespec.h:305
cursor_type
Definition tilespec.h:289
@ CURSOR_DEFAULT
Definition tilespec.h:302
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
#define MAP_NATIVE_WIDTH
#define MAP_IS_ISOMETRIC
#define MAP_NATURAL_HEIGHT
#define MAP_NATURAL_WIDTH
float map_zoom
Definition zoom.c:25