Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-qt/mapview.cpp Source File

Freeciv-3.2

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();
55 static int mapview_frozen_level = 0;
56extern void destroy_city_dialog();
57extern struct canvas *canvas;
58
59#define MAX_DIRTY_RECTS 20
60 static int num_dirty_rects = 0;
61 static QRect dirty_rects[MAX_DIRTY_RECTS];
62
63extern int last_center_enemy;
64extern int last_center_capital;
65extern int last_center_player_city;
66extern int last_center_enemy_city;
67
68/**********************************************************************/
71 bool 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/**********************************************************************/
82 void draw_calculated_trade_routes(QPainter *painter)
83{
84 int dx, dy;
85 float w, h;
86 float x1, y1, x2, y2;
87 qtiles qgilles;
88 struct city *pcity;
89 struct color *pcolor;
90 QPen pen;
91
92 if (!can_client_control()
93 || gui()->trade_gen.cities.empty()) {
94 return;
95 }
96 pcolor = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT);
97 // Draw calculated trade routes
98 if (gui_options.draw_city_trade_routes) {
99
100 foreach (qgilles, gui()->trade_gen.lines) {
101 base_map_distance_vector(&dx, &dy, TILE_XY(qgilles.t1),
102 TILE_XY(qgilles.t2));
103 map_to_gui_vector(tileset, 1.0, &w, &h, dx, dy);
104
105 tile_to_canvas_pos(&x1, &y1, map_zoom, qgilles.t1);
106 tile_to_canvas_pos(&x2, &y2, map_zoom, qgilles.t2);
107
108 // Dont draw if route was already established
109 if (tile_city(qgilles.t1) && tile_city(qgilles.t2)
110 && have_cities_trade_route(tile_city(qgilles.t1),
111 tile_city(qgilles.t2))) {
112 continue;
113 }
114
115 if (qgilles.autocaravan != nullptr) {
116 pcolor = get_color(tileset, COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT);
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,
126 y1 + tileset_tile_height(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,
132 y2 + tileset_tile_height(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
141 && tile_to_canvas_pos(&canvas_x, &canvas_y, map_zoom, pcity->tile)) {
142 painter->drawPixmap(static_cast<int>(canvas_x),
143 static_cast<int>(canvas_y),
144 *get_attention_crosshair_sprite(tileset)->pm);
145 }
146 }
147}
148
149/**********************************************************************/
152mr_idle::mr_idle()
153{
154 connect(&timer, &QTimer::timeout, this, &mr_idle::idling);
155 timer.start(5);
156}
157
158/**********************************************************************/
161mr_idle::~mr_idle()
162{
163 call_me_back *cb;
164
165 while (!callback_list.isEmpty()) {
166 cb = callback_list.dequeue();
167 delete cb;
168 }
169}
170
171/**********************************************************************/
174 void mr_idle::idling()
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/**********************************************************************/
188 void mr_idle::add_callback(call_me_back *cb)
189{
190 callback_list.enqueue(cb);
191}
192
193/**********************************************************************/
196map_view::map_view() : QWidget()
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);
206 stored_autocenter = gui_options.auto_center_on_unit;
207 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
208}
209
210/**********************************************************************/
213 void map_view::update_cursor(enum cursor_type ct)
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/**********************************************************************/
231 void map_view::timer_event()
232{
233 if (gui()->infotab->underMouse()
234 || gui()->minimapview_wdg->underMouse()
235 || gui()->sidebar_wdg->underMouse()) {
236 update_cursor(CURSOR_DEFAULT);
237 return;
238 }
239 if (cursor == -1) {
240 return;
241 }
242 cursor_frame++;
243 if (cursor_frame == NUM_CURSOR_FRAMES) {
244 cursor_frame = 0;
245 }
246 setCursor(*(gui()->fc_cursors[cursor][cursor_frame]));
247}
248
249/**********************************************************************/
252 void map_view::update_font(const QString &name, const QFont &font)
253{
254 if (name == fonts::city_names
255 || name == fonts::city_productions) {
256 update_map_canvas_visible();
257 }
258}
259
260/**********************************************************************/
263 void map_view::focusOutEvent(QFocusEvent *event)
264{
265 update_cursor(CURSOR_DEFAULT);
266}
267
268/**********************************************************************/
271 void map_view::leaveEvent(QEvent *event)
272{
273 update_cursor(CURSOR_DEFAULT);
274}
275
276/**********************************************************************/
279 void map_view::paintEvent(QPaintEvent *event)
280{
281 QPainter painter;
282
283 painter.begin(this);
284 paint(&painter, event);
285 painter.end();
286}
287
288/**********************************************************************/
291 void map_view::paint(QPainter *painter, QPaintEvent *event)
292{
293 painter->drawPixmap(event->rect(), mapview.store->map_pixmap,
294 event->rect());
295 draw_calculated_trade_routes(painter);
296}
297
298/**********************************************************************/
301 void 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 }
319 find_place(new_pos_x, new_pos_y, w, h, wdth, hght, recursive_nr);
320}
321
322/**********************************************************************/
328 void 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;
333 QList <fcwidget *>widgets = this->findChildren <fcwidget *>();
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/**********************************************************************/
384move_widget::move_widget(QWidget *parent) : QLabel()
385{
386 QPixmap *pix;
387
388 setParent(parent);
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/**********************************************************************/
399 void move_widget::put_to_corner()
400{
401 move(0, 0);
402}
403
404/**********************************************************************/
407 void move_widget::mouseMoveEvent(QMouseEvent *event)
408{
409 if (!gui()->interface_locked) {
410 parentWidget()->move(mevent_gpos(event) - point);
411 }
412}
413
414/**********************************************************************/
417 void move_widget::mousePressEvent(QMouseEvent *event)
418{
419 if (!gui()->interface_locked) {
420 point = mevent_gpos(event) - parentWidget()->geometry().topLeft();
421 }
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
460 qp = mevent_gpos(event);
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/**********************************************************************/
471 void resize_widget::mousePressEvent(QMouseEvent *event)
472{
473 QPoint qp;
474
475 if (gui()->interface_locked) {
476 return;
477 }
478
479 qp = mevent_gpos(event);
480 point.setX(qp.x() - parentWidget()->width());
481 point.setY(qp.y() - parentWidget()->height());
482 update();
483}
484
485/**********************************************************************/
488close_widget::close_widget(QWidget *parent) : QLabel()
489{
490 QPixmap *pix;
491
492 setParent(parent);
493 setCursor(Qt::ArrowCursor);
494 pix = fc_icons::instance()->get_pixmap("close");
495 setPixmap(*pix);
496 delete pix;
497}
498
499/**********************************************************************/
502 void close_widget::put_to_corner()
503{
504 move(parentWidget()->width()-width(), 0);
505}
506
507/**********************************************************************/
510 void close_widget::mousePressEvent(QMouseEvent* event)
511{
512 if (gui()->interface_locked) {
513 return;
514 }
515 if (event->button() == Qt::LeftButton) {
516 parentWidget()->hide();
517 notify_parent();
518 }
519}
520
521/**********************************************************************/
524 void close_widget::notify_parent()
525{
526 fcwidget *fcw;
527
528 fcw = reinterpret_cast< fcwidget *>(parentWidget());
529 fcw->update_menu();
530}
531
532/**********************************************************************/
535minimap_view::minimap_view(QWidget *parent) : fcwidget()
536{
537 setParent(parent);
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;
549 connect(&thread, &minimap_thread::rendered_image,
550 this, &minimap_view::update_pixmap);
551}
552
553/**********************************************************************/
556minimap_view::~minimap_view()
557{
558 if (pix) {
559 delete pix;
560 }
561}
562
563/**********************************************************************/
566 void minimap_view::paintEvent(QPaintEvent *event)
567{
568 QPainter painter;
569
570 painter.begin(this);
571 paint(&painter, event);
572 painter.end();
573}
574
575/**********************************************************************/
578 void 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/**********************************************************************/
590 static 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
598 if (tileset_is_isometric(tileset)) {
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) {
607 ntl_y = map_x + map_y - wld.map.xsize;
608 ntl_x = 2 * map_x - ntl_y;
609 } else {
610 ntl_x = map_x;
611 ntl_y = map_y;
612 }
613
614 *ovr_x = floor((ntl_x - (double)gui_options.overview.map_x0)
615 * OVERVIEW_TILE_SIZE);
616 *ovr_y = floor((ntl_y - (double)gui_options.overview.map_y0)
617 * OVERVIEW_TILE_SIZE);
618
619 if (current_wrap_has_flag(WRAP_X)) {
620 *ovr_x = FC_WRAP(*ovr_x, NATURAL_WIDTH * OVERVIEW_TILE_SIZE);
621 } else {
622 if (MAP_IS_ISOMETRIC) {
623 *ovr_x -= OVERVIEW_TILE_SIZE;
624 }
625 }
626 if (current_wrap_has_flag(WRAP_Y)) {
627 *ovr_y = FC_WRAP(*ovr_y, NATURAL_HEIGHT * OVERVIEW_TILE_SIZE);
628 }
629}
630
631/**********************************************************************/
634 void minimap_view::update_menu()
635{
636 ::gui()->menu_bar->minimap_status->setChecked(false);
637}
638
639/**********************************************************************/
642 void minimap_view::moveEvent(QMoveEvent* event)
643{
644 position = event->pos();
645}
646
647/**********************************************************************/
650 void minimap_view::showEvent(QShowEvent* event)
651{
652 move(position);
653 event->setAccepted(true);
654}
655
656/**********************************************************************/
659 void minimap_view::draw_viewport(QPainter *painter)
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
668 gui_to_overview(&x[0], &y[0], mapview.gui_x0, mapview.gui_y0);
669 gui_to_overview(&x[1], &y[1], mapview.gui_x0 + mapview.width,
670 mapview.gui_y0);
671 gui_to_overview(&x[2], &y[2], mapview.gui_x0 + mapview.width,
672 mapview.gui_y0 + mapview.height);
673 gui_to_overview(&x[3], &y[3], mapview.gui_x0,
674 mapview.gui_y0 + mapview.height);
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/**********************************************************************/
695 void minimap_view::scale_point(int &x, int &y)
696{
697 int ax, bx;
698 int dx, dy;
699
700 gui_to_overview(&ax, &bx, mapview.gui_x0 + mapview.width / 2,
701 mapview.gui_y0 + mapview.height / 2);
702 x = qRound(x * scale_factor);
703 y = qRound(y * scale_factor);
704 dx = qRound(ax * scale_factor - gui_options.overview.width / 2);
705 dy = qRound(bx * scale_factor - gui_options.overview.height / 2);
706 x = x - dx;
707 y = y - dy;
708}
709
710/**********************************************************************/
713 void unscale_point(double scale_factor, int &x, int &y)
714{
715 int ax, bx;
716 int dx, dy;
717
718 gui_to_overview(&ax, &bx, mapview.gui_x0 + mapview.width / 2,
719 mapview.gui_y0 + mapview.height / 2);
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/**********************************************************************/
731 void minimap_view::reset()
732{
733 scale_factor = 1;
734}
735
736/**********************************************************************/
739 void minimap_view::update_pixmap(const QImage &image)
740{
741 *pix = QPixmap::fromImage(image);
742 update();
743}
744
745/**********************************************************************/
748minimap_thread::minimap_thread(QObject *parent) : QThread(parent)
749{
750}
751
752/**********************************************************************/
755minimap_thread::~minimap_thread()
756{
757 wait();
758}
759
760/**********************************************************************/
763 void minimap_thread::render(double scale_factor, int width, int height)
764{
765 QMutexLocker locker(&mutex);
766 mini_width = width;
767 mini_height = height;
768 scale = scale_factor;
769 start(LowPriority);
770}
771
772/**********************************************************************/
775 void minimap_thread::run()
776{
777 QImage tpix;
778 QImage gpix;
779 QImage image(QSize(mini_width, mini_height), QImage::Format_RGB32);
780 QImage bigger_pix(gui_options.overview.width * 2,
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 */
792 src = &gui_options.overview.map->map_pixmap;
793 dst = &gui_options.overview.window->map_pixmap;
794 x = gui_options.overview.map_x0;
795 y = gui_options.overview.map_y0;
796 ix = gui_options.overview.width - x;
797 iy = gui_options.overview.height - y;
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);
802 tpix = gui_options.overview.window->map_pixmap.toImage();
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;
807 unscale_point(scale, x, y);
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,
812 gui_options.overview.width, gui_options.overview.height);
813 gpix = bigger_pix.copy(delta_x + x, delta_y + y, wf, hf);
814 image = gpix.scaled(mini_width, mini_height,
815 Qt::IgnoreAspectRatio, Qt::FastTransformation);
816 } else {
817 tpix = gui_options.overview.map->map_pixmap.toImage();
818 image = tpix.scaled(mini_width, mini_height,
819 Qt::IgnoreAspectRatio, Qt::FastTransformation);
820 }
821 }
822 emit rendered_image(image);
823 mutex.unlock();
824}
825
826/**********************************************************************/
829 void minimap_view::update_image()
830{
831 if (isHidden()) {
832 return;
833 }
834 thread.render(scale_factor, width(), height());
835}
836
837/**********************************************************************/
840 void minimap_view::paint(QPainter * painter, QPaintEvent * event)
841{
842 int x, y, ix, iy;
843
844 x = gui_options.overview.map_x0 * w_ratio;
845 y = gui_options.overview.map_y0 * h_ratio;
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);
859 draw_viewport(painter);
860 rw->put_to_corner();
861}
862
863/**********************************************************************/
866 void minimap_view::resizeEvent(QResizeEvent* event)
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/**********************************************************************/
886 void minimap_view::wheelEvent(QWheelEvent *event)
887{
888 if (event->angleDelta().y() > 0) {
889 zoom_in();
890 } else {
891 zoom_out();
892 }
893 event->accept();
894}
895
896/**********************************************************************/
899 void minimap_view::zoom_in()
900{
901 if (scale_factor < gui_options.overview.width / 8) {
902 scale(1.2);
903 }
904}
905
906/**********************************************************************/
909 void minimap_view::zoom_out()
910{
911 scale(0.833);
912}
913
914/**********************************************************************/
920 void minimap_view::mousePressEvent(QMouseEvent *event)
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) {
939 unscale_point(scale_factor, fx, fy);
940 }
941 fx = qMax(fx, 1);
942 fy = qMax(fy, 1);
943 fx = qMin(fx, gui_options.overview.width - 1);
944 fy = qMin(fy, gui_options.overview.height - 1);
945 overview_to_map_pos(&x, &y, fx, fy);
946 center_tile_mapcanvas(map_pos_to_tile(&(wld.map), x, y));
947 update_image();
948 }
949
950 event->setAccepted(true);
951}
952
953/**********************************************************************/
956 void minimap_view::mouseMoveEvent(QMouseEvent *event)
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;
968 move(mevent_gpos(event) - cursor);
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/**********************************************************************/
979 void minimap_view::mouseReleaseEvent(QMouseEvent* event)
980{
981 setCursor(Qt::CrossCursor);
982}
983
984
985/**********************************************************************/
990 void update_info_label(void)
991{
992 gui()->update_info_label();
993}
994
995
996/**********************************************************************/
999 void fc_client::update_info_label(void)
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,
1010 this, &fc_client::update_info_label);
1011 update_info_timer->start(300);
1012 return;
1013 }
1014
1015 if (update_info_timer->remainingTime() > 0) {
1016 return;
1017 }
1018 update_sidebar_tooltips();
1019 if (head_of_units_in_focus() != nullptr) {
1020 real_menus_update();
1021 }
1022 /* TRANS: T is shortcut from Turn */
1023 s = QString(_("%1 \nT:%2")).arg(calendar_text(),
1024 QString::number(game.info.turn));
1025
1026 sw_map->set_custom_labels(s);
1027 sw_map->update_final_pixmap();
1028
1029 set_indicator_icons(client_research_sprite(),
1030 client_warming_sprite(),
1031 client_cooling_sprite(), client_government_sprite());
1032
1033 if (client.conn.playing != NULL) {
1034 if (player_get_expected_income(client.conn.playing) > 0) {
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 }
1043 sw_economy->set_custom_labels(eco_info);
1044 } else {
1045 sw_economy->set_custom_labels("");
1046 }
1047 sw_tax->update_final_pixmap();
1048 sw_economy->update_final_pixmap();
1049 delete update_info_timer;
1050 update_info_timer = nullptr;
1051}
1052
1053
1054/**********************************************************************/
1066 void 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/**********************************************************************/
1077 void update_mouse_cursor(enum cursor_type new_cursor_type)
1078{
1079 gui()->mapview_wdg->update_cursor(new_cursor_type);
1080}
1081
1082/**********************************************************************/
1086 void qtg_update_timeout_label(void)
1087{
1088 gui()->sw_endturn->set_custom_labels(QString(get_timeout_label_text()));
1089 gui()->sw_endturn->update_final_pixmap();
1090}
1091
1092/**********************************************************************/
1098 void update_turn_done_button(bool do_restore)
1099{
1100 if (!get_turn_done_button_state()) {
1101 return;
1102 }
1103 side_blink_endturn(do_restore);
1104}
1105
1106
1107/**********************************************************************/
1112 void set_indicator_icons(struct sprite *bulb, struct sprite *sol,
1113 struct sprite *flake, struct sprite *gov)
1114{
1115 gui()->sw_indicators->update_final_pixmap();
1116}
1117
1118/**********************************************************************/
1121 struct canvas *get_overview_window(void)
1122{
1123 gui()->minimapview_wdg->update_image();
1124 return NULL;
1125}
1126
1127/**********************************************************************/
1131 static 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/**********************************************************************/
1141 void dirty_rect(int canvas_x, int canvas_y,
1142 int pixel_width, int pixel_height)
1143{
1144 if (mapview_is_frozen()) {
1145 return;
1146 }
1147 if (num_dirty_rects < MAX_DIRTY_RECTS) {
1148 dirty_rects[num_dirty_rects].setX(canvas_x);
1149 dirty_rects[num_dirty_rects].setY(canvas_y);
1150 dirty_rects[num_dirty_rects].setWidth(pixel_width);
1151 dirty_rects[num_dirty_rects].setHeight(pixel_height);
1152 num_dirty_rects++;
1153 }
1154}
1155
1156/**********************************************************************/
1159 void dirty_all(void)
1160{
1161 if (mapview_is_frozen()) {
1162 return;
1163 }
1164 num_dirty_rects = MAX_DIRTY_RECTS;
1165}
1166
1167/**********************************************************************/
1172 void flush_dirty(void)
1173{
1174 if (mapview_is_frozen()) {
1175 return;
1176 }
1177 if (num_dirty_rects == MAX_DIRTY_RECTS) {
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++) {
1184 flush_mapcanvas(dirty_rects[i].x(), dirty_rects[i].y(),
1185 dirty_rects[i].width(), dirty_rects[i].height());
1186 }
1187 }
1188 num_dirty_rects = 0;
1189}
1190
1191/**********************************************************************/
1196 void gui_flush(void)
1197{
1198 gui()->mapview_wdg->update();
1199}
1200
1201/**********************************************************************/
1205 void update_map_canvas_scrollbars(void)
1206{
1207 gui()->mapview_wdg->update();
1208}
1209
1210/**********************************************************************/
1213 void update_map_canvas_scrollbars_size(void)
1214{
1215 // PORTME
1216}
1217
1218/**********************************************************************/
1221 void update_city_descriptions(void)
1222{
1223 update_map_canvas_visible();
1224}
1225
1226/**********************************************************************/
1229 void pixmap_put_overlay_tile(int canvas_x, int canvas_y,
1230 struct sprite *ssprite)
1231{
1232 if (!ssprite) {
1233 return;
1234 }
1235
1236 // PORTME
1237}
1238
1239/**********************************************************************/
1242 void 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)) {
1247 pixmap_put_overlay_tile(canvas_x, canvas_y,
1248 get_attention_crosshair_sprite(tileset));
1249 }
1250
1251}
1252
1253/**********************************************************************/
1256 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
1257{
1258 // PORTME
1259}
1260
1261/**********************************************************************/
1264 void tileset_changed(void)
1265{
1266 int i;
1267 science_report *sci_rep;
1268 QWidget *w;
1269
1270 update_unit_info_label(get_units_in_focus());
1271 destroy_city_dialog();
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);
1278 sci_rep->reset_tree();
1279 sci_rep->update_report();
1280 sci_rep->repaint();
1281 }
1282}
1283
1284/**********************************************************************/
1288 void get_overview_area_dimensions(int *width, int *height)
1289{
1290 *width = 0;
1291 *height = 0;
1292}
1293
1294/**********************************************************************/
1302 void overview_size_changed(void)
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/**********************************************************************/
1318 void update_overview_scroll_window_pos(int x, int y)
1319{
1320 // TODO: PORTME.
1321}
1322
1323/**********************************************************************/
1326 bool mapview_is_frozen(void)
1327{
1328 return (0 < mapview_frozen_level);
1329}
1330
1331/**********************************************************************/
1334 void mapview_freeze(void)
1335{
1336 mapview_frozen_level++;
1337}
1338
1339/**********************************************************************/
1342 void mapview_thaw(void)
1343{
1344 if (1 < mapview_frozen_level) {
1345 mapview_frozen_level--;
1346 } else {
1347 fc_assert(0 < mapview_frozen_level);
1348 mapview_frozen_level = 0;
1349 dirty_all();
1350 }
1351}
1352
1353/**********************************************************************/
1356info_tile::info_tile(struct tile *ptile, QWidget *parent): QLabel(parent)
1357{
1358 setParent(parent);
1359 info_font = *fc_font::instance()->get_font(fonts::notify_label);
1360 itile = ptile;
1361 calc_size();
1362}
1363
1364/**********************************************************************/
1367 void info_tile::calc_size()
1368{
1369 QFontMetrics fm(info_font);
1370 QString str;
1371 float x, y;
1372 int w = 0;
1373
1374 str = popup_info_text(itile);
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 {
1394 fin_y = y + tileset_tile_height(tileset);
1395 }
1396 if (x + ww > pw) {
1397 fin_x = pw - ww;
1398 }
1399 move(fin_x, fin_y);
1400 }
1401}
1402
1403/**********************************************************************/
1406 void info_tile::paint(QPainter *painter, QPaintEvent *event)
1407{
1408 QFontMetrics fm(info_font);
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/**********************************************************************/
1423 void info_tile::paintEvent(QPaintEvent *event)
1424{
1425 QPainter painter;
1426
1427 painter.begin(this);
1428 paint(&painter, event);
1429 painter.end();
1430}
1431
1432/**********************************************************************/
1435 void 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/**********************************************************************/
1447 void qtg_start_turn()
1448{
1449 show_new_turn_info();
1450 last_center_enemy = 0;
1451 last_center_capital = 0;
1452 last_center_player_city = 0;
1453 last_center_enemy_city = 0;
1454}
1455
1456/**********************************************************************/
1459 void qtg_map_canvas_size_refresh(void)
1460{
1461 /* Needed only with full screen zoom mode.
1462 * Not needed, nor implemented, in this client. */
1463 fc_assert(false);
1464}
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:120
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:101
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
pcolor
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
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:502
close_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:510
close_widget::close_widget
close_widget(QWidget *parent)
Definition mapview.cpp:488
close_widget::notify_parent
void notify_parent()
Definition mapview.cpp:524
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:2115
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:999
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:1435
info_tile::calc_size
void calc_size()
Definition mapview.cpp:1367
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:1356
info_tile::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:1423
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:1406
map_view::leaveEvent
void leaveEvent(QEvent *event)
Definition mapview.cpp:271
map_view::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:279
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:328
map_view::timer_event
void timer_event()
Definition mapview.cpp:231
map_view::map_view
map_view()
Definition mapview.cpp:196
map_view::update_cursor
void update_cursor(enum cursor_type)
Definition mapview.cpp:213
map_view::update_font
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:252
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:301
map_view::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:291
map_view::focusOutEvent
void focusOutEvent(QFocusEvent *event)
Definition mapview.cpp:263
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:748
minimap_thread::~minimap_thread
~minimap_thread()
Definition mapview.cpp:755
minimap_thread::render
void render(double scale_factor, int width, int height)
Definition mapview.cpp:763
minimap_thread::scale
double scale
Definition mapview.h:211
minimap_thread::run
void run() Q_DECL_OVERRIDE
Definition mapview.cpp:775
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:739
minimap_view::paintEvent
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:566
minimap_view::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:956
minimap_view::w_ratio
float w_ratio
Definition mapview.h:249
minimap_view::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:840
minimap_view::showEvent
void showEvent(QShowEvent *event)
Definition mapview.cpp:650
minimap_view::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition mapview.cpp:979
minimap_view::h_ratio
float h_ratio
Definition mapview.h:249
minimap_view::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition mapview.cpp:866
minimap_view::minimap_view
minimap_view(QWidget *parent)
Definition mapview.cpp:535
minimap_view::~minimap_view
~minimap_view()
Definition mapview.cpp:556
minimap_view::scale_factor
double scale_factor
Definition mapview.h:248
minimap_view::zoom_out
void zoom_out()
Definition mapview.cpp:909
minimap_view::pix
QPixmap * pix
Definition mapview.h:252
minimap_view::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:920
minimap_view::zoom_in
void zoom_in()
Definition mapview.cpp:899
minimap_view::rw
resize_widget * rw
Definition mapview.h:255
minimap_view::scale_point
void scale_point(int &x, int &y)
Definition mapview.cpp:695
minimap_view::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition mapview.cpp:886
minimap_view::update_menu
virtual void update_menu()
Definition mapview.cpp:634
minimap_view::moveEvent
void moveEvent(QMoveEvent *event)
Definition mapview.cpp:642
minimap_view::background
QBrush background
Definition mapview.h:251
minimap_view::reset
void reset()
Definition mapview.cpp:731
minimap_view::thread
minimap_thread thread
Definition mapview.h:250
minimap_view::draw_viewport
void draw_viewport(QPainter *painter)
Definition mapview.cpp:659
minimap_view::update_image
void update_image()
Definition mapview.cpp:829
minimap_view::scale
void scale(double factor)
Definition mapview.cpp:578
move_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:399
move_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:417
move_widget::point
QPoint point
Definition mapview.h:164
move_widget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:407
move_widget::move_widget
move_widget(QWidget *parent)
Definition mapview.cpp:384
mr_idle::idling
void idling()
Definition mapview.cpp:174
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:188
mr_idle::~mr_idle
~mr_idle()
Definition mapview.cpp:161
mr_idle::mr_idle
mr_idle()
Definition mapview.cpp:152
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:471
can_client_control
bool can_client_control(void)
Definition client_main.c:1253
client
struct civclient client
Definition client_main.c:150
client_state
enum client_states client_state(void)
Definition client_main.c:1026
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
client_warming_sprite
struct sprite * client_warming_sprite(void)
Definition climisc.c:377
client_cooling_sprite
struct sprite * client_cooling_sprite(void)
Definition climisc.c:394
client_research_sprite
struct sprite * client_research_sprite(void)
Definition climisc.c:354
client_government_sprite
struct sprite * client_government_sprite(void)
Definition climisc.c:412
climisc.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
incite_cost
char * incite_cost
Definition comments.c:74
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:405
event
enum event_type event
Definition events.c:81
get_turn_done_button_state
bool get_turn_done_button_state()
Definition mapctrl_common.c:523
fc_client.h
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:62
wld
struct world wld
Definition game.c:63
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:302
real_menus_update
void real_menus_update(void)
Definition menu.c:2349
mevent_gpos
#define mevent_gpos(__ev__)
Definition gui_main.h:23
unscale_point
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:713
is_point_in_area
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:71
draw_calculated_trade_routes
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:82
colors.h
gui_main.h
mapview.h
menu.h
repodlgs.h
sprite.h
show_new_turn_info
void show_new_turn_info()
Definition hudwidget.cpp:1661
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:419
base_map_distance_vector
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
Definition map.c:1024
map.h
NATURAL_HEIGHT
#define NATURAL_HEIGHT
Definition map.h:227
MAP_IS_ISOMETRIC
#define MAP_IS_ISOMETRIC
Definition map.h:42
current_wrap_has_flag
#define current_wrap_has_flag(flag)
Definition map.h:51
NATURAL_WIDTH
#define NATURAL_WIDTH
Definition map.h:226
mapctrl_common.h
flush_dirty
void flush_dirty(void)
Definition mapview.cpp:1172
update_info_label
void update_info_label(void)
Definition mapview.cpp:990
update_turn_done_button
void update_turn_done_button(bool do_restore)
Definition mapview.cpp:1098
last_center_capital
int last_center_capital
Definition pages.cpp:67
dirty_all
void dirty_all(void)
Definition mapview.cpp:1159
last_center_enemy
int last_center_enemy
Definition pages.cpp:80
tileset_changed
void tileset_changed(void)
Definition mapview.cpp:1264
put_cross_overlay_tile
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.cpp:1242
draw_selection_rectangle
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.cpp:1256
flush_mapcanvas
static void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height)
Definition mapview.cpp:1131
update_map_canvas_scrollbars_size
void update_map_canvas_scrollbars_size(void)
Definition mapview.cpp:1213
get_overview_area_dimensions
void get_overview_area_dimensions(int *width, int *height)
Definition mapview.cpp:1288
mapview_freeze
void mapview_freeze(void)
Definition mapview.cpp:1334
MAX_DIRTY_RECTS
#define MAX_DIRTY_RECTS
Definition mapview.cpp:59
last_center_player_city
int last_center_player_city
Definition pages.cpp:68
canvas
struct canvas * canvas
update_overview_scroll_window_pos
void update_overview_scroll_window_pos(int x, int y)
Definition mapview.cpp:1318
update_city_descriptions
void update_city_descriptions(void)
Definition mapview.cpp:1221
unscale_point
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:713
pixmap_put_overlay_tile
void pixmap_put_overlay_tile(int canvas_x, int canvas_y, struct sprite *ssprite)
Definition mapview.cpp:1229
gui_flush
void gui_flush(void)
Definition mapview.cpp:1196
qtg_update_timeout_label
void qtg_update_timeout_label(void)
Definition mapview.cpp:1086
update_map_canvas_scrollbars
void update_map_canvas_scrollbars(void)
Definition mapview.cpp:1205
mapview_is_frozen
bool mapview_is_frozen(void)
Definition mapview.cpp:1326
last_center_enemy_city
int last_center_enemy_city
Definition pages.cpp:69
overview_size_changed
void overview_size_changed(void)
Definition mapview.cpp:1302
qtg_start_turn
void qtg_start_turn()
Definition mapview.cpp:1447
qtg_map_canvas_size_refresh
void qtg_map_canvas_size_refresh(void)
Definition mapview.cpp:1459
is_point_in_area
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:71
draw_calculated_trade_routes
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:82
update_unit_info_label
void update_unit_info_label(struct unit_list *punitlist)
Definition mapview.cpp:1066
mapview_frozen_level
static int mapview_frozen_level
Definition mapview.cpp:55
mapview_thaw
void mapview_thaw(void)
Definition mapview.cpp:1342
get_overview_window
struct canvas * get_overview_window(void)
Definition mapview.cpp:1121
num_dirty_rects
static int num_dirty_rects
Definition mapview.cpp:60
get_timeout_label_text
const char * get_timeout_label_text()
Definition text.c:1557
dirty_rects
static QRect dirty_rects[MAX_DIRTY_RECTS]
Definition mapview.cpp:61
update_mouse_cursor
void update_mouse_cursor(enum cursor_type new_cursor_type)
Definition mapview.cpp:1077
set_indicator_icons
void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
Definition mapview.cpp:1112
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:590
update_map_canvas_visible
void update_map_canvas_visible(void)
Definition mapview_common.c:1860
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:563
mapview
struct view mapview
Definition mapview_common.c:75
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
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:706
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:357
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:1286
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:689
sidebar.h
size
size_t size
Definition specvec.h:72
y
struct sprite int int y
Definition sprite_g.h:31
scale
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
x
struct sprite int x
Definition sprite_g.h:31
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:22
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:320
city::tile
struct tile * tile
Definition city.h:322
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_map::xsize
int xsize
Definition map_types.h:78
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::draw_city_trade_routes
bool draw_city_trade_routes
Definition options.h:200
client_options::overview
struct overview overview
Definition options.h:426
client_options::auto_center_on_unit
bool auto_center_on_unit
Definition options.h:155
color
Definition colors.h:21
connection::playing
struct player * playing
Definition connection.h:151
move
Definition widget_window.c:39
overview::map_y0
double map_y0
Definition options.h:93
overview::map_x0
double map_x0
Definition options.h:93
overview::map
struct canvas * map
Definition options.h:97
overview::width
int width
Definition options.h:94
overview::window
struct canvas * window
Definition options.h:100
overview::height
int height
Definition options.h:94
packet_game_info::turn
int turn
Definition packets_gen.h:241
player_economic::gold
int gold
Definition player.h:61
player::economic
struct player_economic economic
Definition player.h:282
qtiles
Definition menu.h:160
science_report
Definition repodlgs.c:69
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:952
sprite
Definition sprite.h:22
tile
Definition tile.h:50
tileset
Definition tilespec.c:481
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:147
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:43
get_attention_crosshair_sprite
struct sprite * get_attention_crosshair_sprite(const struct tileset *t)
Definition tilespec.c:6994
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:712
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
NUM_CURSOR_FRAMES
#define NUM_CURSOR_FRAMES
Definition tilespec.h:303
cursor_type
cursor_type
Definition tilespec.h:287
CURSOR_DEFAULT
@ CURSOR_DEFAULT
Definition tilespec.h:300
have_cities_trade_route
bool have_cities_trade_route(const struct city *pc1, const struct city *pc2)
Definition traderoutes.c:534
map_zoom
float map_zoom
Definition zoom.c:25
zoom.h