Freeciv-3.1
Loading...
Searching...
No Matches
hudwidget.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 <QAction>
20#include <QApplication>
21#include <QComboBox>
22#include <QDialogButtonBox>
23#include <QGridLayout>
24#include <QGroupBox>
25#include <QHBoxLayout>
26#include <QHeaderView>
27#include <QLineEdit>
28#include <QPainter>
29#include <QPaintEvent>
30#include <QRadioButton>
31#include <QSpacerItem>
32#include <QVBoxLayout>
33
34// common
35#include "movement.h"
36#include "research.h"
37#include "tile.h"
38#include "unit.h"
39#include "unitlist.h"
40
41// client
42#include "client_main.h"
43#include "text.h"
44
45// gui-qt
46#include "fc_client.h"
47#include "fonts.h"
48#include "hudwidget.h"
49#include "sprite.h"
50
51extern "C" {
52 const char *calendar_text(void);
53 bool goto_is_active(void);
54}
55static QString popup_terrain_info(struct tile *ptile);
56
57/************************************************************************/
61{
63 if (utype_number(punit->utype) == utype) {
64 return true;
65 }
67
68 return false;
69}
70
71/************************************************************************/
74hud_message_box::hud_message_box(QWidget *parent): QMessageBox(parent)
75{
76 int size;
77 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
78 | Qt::FramelessWindowHint);
81
82 size = f_text.pointSize();
83 if (size > 0) {
84 f_text.setPointSize(size * 4 / 3);
85 f_title.setPointSize(size * 3 / 2);
86 } else {
87 size = f_text.pixelSize();
88 f_text.setPixelSize(size * 4 / 3);
89 f_title.setPointSize(size * 3 / 2);
90 }
91 f_title.setBold(true);
92 f_title.setCapitalization(QFont::SmallCaps);
93 fm_text = new QFontMetrics(f_text);
94 fm_title = new QFontMetrics(f_title);
95 top = 0;
97 hide();
98 mult = 1;
99}
100
101/************************************************************************/
105{
106 delete fm_text;
107 delete fm_title;
108}
109
110/************************************************************************/
114{
115 if (event->key() == Qt::Key_Escape) {
116 close();
117 destroy();
118 event->accept();
119 }
120 QWidget::keyPressEvent(event);
121}
122
123/************************************************************************/
126int hud_message_box::set_text_title(QString s1, QString s2, bool return_exec)
127{
128 QSpacerItem *spacer;
129 QGridLayout *layout;
130 int w, w2, h;
131 QPoint p;
132
133 if (s1.contains('\n')) {
134 int i;
135
136 i = s1.indexOf('\n');
137 cs1 = s1.left(i);
138 cs2 = s1.right(s1.length() - i);
139 mult = 2;
140 w2 = qMax(fm_text->horizontalAdvance(cs1),
141 fm_text->horizontalAdvance(cs2));
142 w = qMax(w2, fm_title->horizontalAdvance(s2));
143 } else {
144 w = qMax(fm_text->horizontalAdvance(s1),
145 fm_title->horizontalAdvance(s2));
146 }
147 w = w + 20;
148 h = mult * (fm_text->height() * 3 / 2) + 2 * fm_title->height();
149 top = 2 * fm_title->height();
150 spacer = new QSpacerItem(w, 0, QSizePolicy::Minimum,
151 QSizePolicy::Expanding);
152 layout = (QGridLayout *)this->layout();
153 layout->addItem(spacer, layout->rowCount(), 0, 1, layout->columnCount());
154 spacer = new QSpacerItem(0, h, QSizePolicy::Expanding,
155 QSizePolicy::Minimum);
156 layout->addItem(spacer, 0, 0, 1, layout->columnCount());
157
158 text = s1;
159 title = s2;
160
161 p = QPoint((parentWidget()->width() - w) / 2,
162 (parentWidget()->height() - h) / 2);
163 p = parentWidget()->mapToGlobal(p);
164 move(p);
165 if (!return_exec) {
166 show ();
167 }
168 m_timer.start();
169 startTimer(45);
170 return (return_exec) ? exec () : 0;
171}
172
173/************************************************************************/
177{
178 m_animate_step = m_timer.elapsed() / 40;
179 update();
180}
181
182/************************************************************************/
186{
187 QPainter p;
188 QRect rx, ry, rfull;
189 QLinearGradient g;
190 QColor c1;
191 QColor c2;
192 int step;
193
194 step = m_animate_step % 300;
195 if (step > 150) {
196 step = step - 150;
197 step = 150 - step;
198 }
199 step = step + 30;
200
201 rfull = QRect(2 , 2, width() - 4 , height() - 4);
202 rx = QRect(2 , 2, width() - 4 , top);
203 ry = QRect(2 , top, width() - 4, height() - top - 4);
204
205 c1 = QColor(palette().color(QPalette::Highlight));
206 c2 = QColor(palette().color(QPalette::AlternateBase));
207 step = qMax(0, step);
208 step = qMin(255, step);
209 c1.setAlpha(step);
210 c2.setAlpha(step);
211
212 g = QLinearGradient(0 , 0, width(), height());
213 g.setColorAt(0, c1);
214 g.setColorAt(1, c2);
215
216 p.begin(this);
217 p.fillRect(rx, QColor(palette().color(QPalette::Highlight)));
218 p.fillRect(ry, QColor(palette().color(QPalette::AlternateBase)));
219 p.fillRect(rfull, g);
220 p.setFont(f_title);
221 p.drawText((width() - fm_title->horizontalAdvance(title)) / 2,
222 fm_title->height() * 4 / 3, title);
223 p.setFont(f_text);
224 if (mult == 1) {
225 p.drawText((width() - fm_text->horizontalAdvance(text)) / 2,
226 2 * fm_title->height() + fm_text->height() * 4 / 3, text);
227 } else {
228 p.drawText((width() - fm_text->horizontalAdvance(cs1)) / 2,
229 2 * fm_title->height() + fm_text->height() * 4 / 3, cs1);
230 p.drawText((width() - fm_text->horizontalAdvance(cs2)) / 2,
231 2 * fm_title->height() + fm_text->height() * 8 / 3, cs2);
232 }
233 p.end();
234 event->accept();
235}
236
237/************************************************************************/
240hud_text::hud_text(QString s, int time_secs,
241 QWidget *parent) : QWidget(parent)
242{
243 int size;
244
245 text = s;
246 timeout = time_secs;
247
248 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
250 f_text.setBold(true);
251 f_text.setCapitalization(QFont::SmallCaps);
252 size = f_text.pointSize();
253 if (size > 0) {
254 f_text.setPointSize(size * 2);
255 } else {
256 size = f_text.pixelSize();
257 f_text.setPixelSize(size * 2);
258 }
259 fm_text = new QFontMetrics(f_text);
260 m_animate_step = 0;
261 m_timer.start();
262 startTimer(46);
263 setAttribute(Qt::WA_TranslucentBackground);
264 setAttribute(Qt::WA_ShowWithoutActivating);
265 setAttribute(Qt::WA_TransparentForMouseEvents);
266 setFocusPolicy(Qt::NoFocus);
267}
268
269/************************************************************************/
273{
274 show();
275 center_me();
276}
277
278/************************************************************************/
282{
283 int w;
284 QPoint p;
285
286 w = width();
287 if (!bound_rect.isEmpty()) {
288 setFixedSize(bound_rect.width(), bound_rect.height());
289 }
290 p = QPoint((parentWidget()->width() - w) / 2,
291 parentWidget()->height() / 20);
292 move(p);
293}
294
295/************************************************************************/
299{
300 delete fm_text;
301}
302
303/************************************************************************/
306void hud_text::timerEvent(QTimerEvent *event)
307{
308 m_animate_step = m_timer.elapsed() / 40;
309 if (m_timer.elapsed() > timeout * 1000) {
310 close();
311 deleteLater();
312 }
313 update();
314}
315
316/************************************************************************/
319void hud_text::paintEvent(QPaintEvent *event)
320{
321 QPainter p;
322 QRect rfull;
323 QColor c1;
324 QColor c2;
325 float opacity;
326
327 center_me();
328 if (m_timer.elapsed() < timeout * 500) {
329 opacity = static_cast<float>(m_timer.elapsed())/(timeout * 300);
330 } else {
331 opacity = static_cast<float>(5000 - m_timer.elapsed())/(timeout * 200);
332 }
333 opacity = qMin(1.0f, opacity);
334 opacity = qMax(0.0f, opacity);
335 rfull = QRect(0 , 0, width(), height());
336 c1 = QColor(Qt::white);
337 c2 = QColor(35, 35, 35, 175);
338 c1.setAlphaF(c1.alphaF() * opacity);
339 c2.setAlphaF(c2.alphaF() * opacity);
340 p.begin(this);
341 p.setBrush(c2);
342 p.setPen(QColor(0, 0, 0, 0));
343 p.drawRoundedRect(rfull, height() / 6 , height() / 6);
344 p.setFont(f_text);
345 p.setPen(c1);
346 p.drawText(rfull, Qt::AlignCenter, text, &bound_rect);
347
348 p.end();
349}
350
351/************************************************************************/
354hud_input_box::hud_input_box(QWidget *parent): QDialog(parent)
355{
356 int size;
357
358 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
359 | Qt::FramelessWindowHint);
360
363
364 size = f_text.pointSize();
365 if (size > 0) {
366 f_text.setPointSize(size * 4 / 3);
367 f_title.setPointSize(size * 3 / 2);
368 } else {
369 size = f_text.pixelSize();
370 f_text.setPixelSize(size * 4 / 3);
371 f_title.setPointSize(size * 3 / 2);
372 }
373 f_title.setBold(true);
374 f_title.setCapitalization(QFont::SmallCaps);
375 fm_text = new QFontMetrics(f_text);
376 fm_title = new QFontMetrics(f_title);
377 top = 0;
378 m_animate_step = 0;
379 hide();
380 mult = 1;
381}
382
383/************************************************************************/
387{
388 delete fm_text;
389 delete fm_title;
390}
391
392/************************************************************************/
395void hud_input_box::set_text_title_definput(QString s1, QString s2,
396 QString def_input)
397{
398 QSpacerItem *spacer;
399 QVBoxLayout *layout;
400 int w, w2, h;
401 QDialogButtonBox *button_box;
402 QPoint p;
403
404 button_box = new QDialogButtonBox(QDialogButtonBox::Ok
405 | QDialogButtonBox::Cancel,
406 Qt::Horizontal, this);
407 layout = new QVBoxLayout;
408 if (s1.contains('\n')) {
409 int i;
410
411 i = s1.indexOf('\n');
412 cs1 = s1.left(i);
413 cs2 = s1.right(s1.length() - i);
414 mult = 2;
415 w2 = qMax(fm_text->horizontalAdvance(cs1),
416 fm_text->horizontalAdvance(cs2));
417 w = qMax(w2, fm_title->horizontalAdvance(s2));
418 } else {
419 w = qMax(fm_text->horizontalAdvance(s1),
420 fm_title->horizontalAdvance(s2));
421 }
422 w = w + 20;
423 h = mult * (fm_text->height() * 3 / 2) + 2 * fm_title->height();
424 top = 2 * fm_title->height();
425
426 spacer = new QSpacerItem(w, h, QSizePolicy::Expanding,
427 QSizePolicy::Minimum);
428 layout->addItem(spacer);
429 layout->addWidget(&input_edit);
430 layout->addWidget(button_box);
431 input_edit.setFont(f_text);
432 input_edit.setText(def_input);
433 setLayout(layout);
434 QObject::connect(button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
435 QObject::connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
436
437 text = s1;
438 title = s2;
439 p = QPoint((parentWidget()->width() - w) / 2,
440 (parentWidget()->height() - h) / 2);
441 p = parentWidget()->mapToGlobal(p);
442 move(p);
443 input_edit.activateWindow();
444 input_edit.setFocus();
445 m_timer.start();
446 startTimer(41);
447 show();
448 update();
449}
450
451/************************************************************************/
455{
456 m_animate_step = m_timer.elapsed() / 40;
457 update();
458}
459
460
461/************************************************************************/
465{
466 QPainter p;
467 QRect rx, ry;
468 QLinearGradient g;
469 QColor c1;
470 QColor c2;
471 QColor c3;
472 int step;
473 float fstep;
474
475
476 step = m_animate_step % 300;
477 if (step > 150) {
478 step = step - 150;
479 step = 150 - step;
480 }
481 step = step + 10;
482 rx = QRect(2 , 2, width() - 4 , top);
483 ry = QRect(2 , top, width() - 4, height() - top - 4);
484
485 c1 = QColor(palette().color(QPalette::Highlight));
486 c2 = QColor(Qt::transparent);
487 c3 = QColor(palette().color(QPalette::Highlight)).lighter(145);
488 step = qMax(0, step);
489 step = qMin(255, step);
490 c1.setAlpha(step);
491 c2.setAlpha(step);
492 c3.setAlpha(step);
493
494 fstep = static_cast<float>(step) / 400;
495 g = QLinearGradient(0 , 0, width(), height());
496 g.setColorAt(0, c2);
497 g.setColorAt(fstep, c3);
498 g.setColorAt(1, c2);
499
500 p.begin(this);
501 p.fillRect(rx, QColor(palette().color(QPalette::Highlight)));
502 p.fillRect(ry, QColor(palette().color(QPalette::AlternateBase)));
503 p.fillRect(rx, g);
504 p.setFont(f_title);
505 p.drawText((width() - fm_title->horizontalAdvance(title)) / 2,
506 fm_title->height() * 4 / 3, title);
507 p.setFont(f_text);
508 if (mult == 1) {
509 p.drawText((width() - fm_text->horizontalAdvance(text)) / 2,
510 2 * fm_title->height() + fm_text->height() * 4 / 3, text);
511 } else {
512 p.drawText((width() - fm_text->horizontalAdvance(cs1)) / 2,
513 2 * fm_title->height() + fm_text->height() * 4 / 3, cs1);
514 p.drawText((width() - fm_text->horizontalAdvance(cs2)) / 2,
515 2 * fm_title->height() + fm_text->height() * 8 / 3, cs2);
516 }
517 p.end();
518 event->accept();
519}
520
521/************************************************************************/
524hud_units::hud_units(QWidget *parent) : QFrame(parent)
525{
526 QVBoxLayout *vbox;
527 QVBoxLayout *unit_lab;
528 QSpacerItem *sp;
529 setParent(parent);
530
531 main_layout = new QHBoxLayout;
532 sp = new QSpacerItem(50, 2);
533 vbox = new QVBoxLayout;
534 unit_lab = new QVBoxLayout;
535 unit_lab->setContentsMargins(6, 9, 0, 3);
536 vbox->setSpacing(0);
537 unit_lab->addWidget(&unit_label);
538 main_layout->addLayout(unit_lab);
539 main_layout->addWidget(&tile_label);
540 unit_icons = new unit_actions(this, nullptr);
541 vbox->addSpacerItem(sp);
542 vbox->addWidget(&text_label);
543 vbox->addWidget(unit_icons);
544 main_layout->addLayout(vbox);
545 main_layout->setSpacing(0);
546 main_layout->setSpacing(3);
547 main_layout->setContentsMargins(0, 0, 0, 0);
548 vbox->setSpacing(3);
549 vbox->setContentsMargins(0, 0, 0, 0);
550 setLayout(main_layout);
551 mw = new move_widget(this);
552 setFocusPolicy(Qt::ClickFocus);
553
554}
555
556/************************************************************************/
562
563/************************************************************************/
567{
568 gui()->qt_settings.unit_info_pos_fx = static_cast<float>(event->pos().x())
569 / gui()->mapview_wdg->width();
570 gui()->qt_settings.unit_info_pos_fy = static_cast<float>(event->pos().y())
571 / gui()->mapview_wdg->height();
572}
573
574/************************************************************************/
577void hud_units::update_actions(unit_list *punits)
578{
579 int num;
580 int wwidth;
581 int font_width;
582 int expanded_unit_width;
584 QFontMetrics *fm;
585 QImage cropped_img;
586 QImage img;
587 QPainter p;
588 QPixmap pix, pix2;
589 QRect crop, bounding_rect;
590 QString mp;
591 QString snum;
592 QString fraction1, fraction2;
593 QString text_str, move_pt_text;
594 struct canvas *tile_pixmap;
595 struct canvas *unit_pixmap;
596 struct city *pcity;
597 struct player *owner;
598 struct tileset *tmp;
599 struct unit *punit;
600
602 if (punit == nullptr) {
603 hide();
604 return;
605 }
606
607 font.setCapitalization(QFont::AllUppercase);
608 font.setBold(true);
609 setFixedHeight(parentWidget()->height() / 12);
610 text_label.setFixedHeight((height() * 2) / 10);
611
612 move(qRound(gui()->mapview_wdg->width()
613 * gui()->qt_settings.unit_info_pos_fx),
614 qRound((gui()->mapview_wdg->height()
615 * gui()->qt_settings.unit_info_pos_fy)));
616 unit_icons->setFixedHeight((height() * 8) / 10);
617
618 setUpdatesEnabled(false);
619
620 tmp = nullptr;
621 if (unscaled_tileset) {
622 tmp = tileset;
624 }
625 text_str = QString(unit_name_translation(punit));
626 owner = punit->owner;
628 if (pcity != NULL) {
629 text_str = QString(("%1(%2)"))
631 }
632 text_str = text_str + " ";
633 mp = QString(move_points_text(punit->moves_left, false));
635 mp = mp + QString("(") + QString(move_points_text((
636 unit_type_get(punit)->move_rate
637 * ((punit->fuel) - 1)
638 + punit->moves_left), false))
639 + QString(")");
640 }
641 /* TRANS: MP = Movement points */
642 mp = QString(_("MP: ")) + mp;
643 text_str = text_str + mp + " ";
644 text_str += QString(_("HP:%1/%2")).arg(
645 QString::number(punit->hp),
646 QString::number(unit_type_get(punit)->hp));
647 num = unit_list_size(punit->tile->units);
648 snum = QString::number(unit_list_size(punit->tile->units) - 1);
649 if (unit_list_size(get_units_in_focus()) > 1) {
650 int n = unit_list_size(get_units_in_focus());
651 /* TRANS: preserve leading space; always at least 2 */
652 text_str = text_str + QString(PL_(" (Selected %1 unit)",
653 " (Selected %1 units)", n))
654 .arg(n);
655 } else if (num > 1) {
656 QByteArray ut_bytes;
657
658 ut_bytes = snum.toUtf8();
659 /* TRANS: preserve leading space */
660 text_str = text_str + QString(PL_(" +%1 unit",
661 " +%1 units", num-1))
662 .arg(ut_bytes.data());
663 }
664 text_label.setTextFormat(Qt::PlainText);
665 text_label.setText(text_str);
666 font.setPixelSize((text_label.height() * 9) / 10);
667 text_label.setFont(font);
668 fm = new QFontMetrics(font);
669 text_label.setFixedWidth(fm->horizontalAdvance(text_str) + 20);
670 delete fm;
671
674 unit_pixmap->map_pixmap.fill(Qt::transparent);
675 put_unit(punit, unit_pixmap, 1, 0, 0);
676 img = unit_pixmap->map_pixmap.toImage();
677 crop = zealous_crop_rect(img);
678 cropped_img = img.copy(crop);
679 img = cropped_img.scaledToHeight(height(), Qt::SmoothTransformation);
680 expanded_unit_width = tileset_unit_width(tileset) *
681 ((height() + 0.0) / tileset_unit_height(tileset));
682 pix = QPixmap::fromImage(img);
683 /* add transparent borders if image is too slim, accounting for the
684 * scaledToHeight() we've applied */
685 if (pix.width() < expanded_unit_width) {
686 pix2 = QPixmap(expanded_unit_width, pix.height());
687 pix2.fill(Qt::transparent);
688 p.begin(&pix2);
689 p.drawPixmap(expanded_unit_width / 2 - pix.width() / 2, 0, pix);
690 p.end();
691 pix = pix2;
692 }
693
694 // Draw movement points
695 move_pt_text = move_points_text(punit->moves_left, false);
696 if (move_pt_text.contains('/')) {
697 fraction2 = move_pt_text.right(1);
698 move_pt_text.remove(move_pt_text.length() - 2, 2);
699 fraction1 = move_pt_text.right(1);
700 move_pt_text.remove(move_pt_text.length() - 1, 1);
701 }
702 crop = QRect(5, 5, pix.width() - 5, pix.height() - 5);
703 font.setCapitalization(QFont::Capitalize);
704 font.setPointSize((pix.height() * 2) / 5);
705 p.begin(&pix);
706 p.setFont(font);
707 p.setPen(Qt::white);
708 p.drawText(crop, Qt::AlignLeft | Qt::AlignBottom, move_pt_text,
709 &bounding_rect);
710
711 bounding_rect.adjust(bounding_rect.width(), 0 ,
712 bounding_rect.width() * 2, 0);
713 if (punit->fuel > 1) {
714 QString s;
715 int fuel;
716
717 font.setPointSize(pix.height() / 4);
718 p.setFont(font);
719 fuel = punit->fuel - 1;
720 fuel = fuel * punit->utype->move_rate / SINGLE_MOVE;
721 p.drawText(bounding_rect, Qt::AlignCenter,
722 QString("+") + QString::number(fuel));
723 }
724
725 if (move_pt_text.isEmpty()) {
726 move_pt_text = " ";
727 }
728 bounding_rect = p.boundingRect(crop, Qt::AlignLeft | Qt::AlignBottom,
729 move_pt_text);
730 font.setPointSize(pix.height() / 5);
731 fm = new QFontMetrics(font);
732 font_width = (fm->horizontalAdvance(move_pt_text) * 3) / 5;
733 delete fm;
734 p.setFont(font);
735 if (!fraction1.isNull()) {
736 int t = 2 * font.pointSize();
737
738 crop = QRect(bounding_rect.right() - font_width,
739 bounding_rect.top(), t, (t / 5) * 4);
740 p.drawText(crop, Qt::AlignLeft | Qt::AlignBottom, fraction1);
741 crop = QRect(bounding_rect.right() - font_width,
742 (bounding_rect.bottom() + bounding_rect.top()) / 2,
743 t, (t / 5) * 4);
744 p.drawText(crop, Qt::AlignLeft | Qt::AlignTop, fraction2);
745 crop = QRect(bounding_rect.right() - font_width,
746 (bounding_rect.bottom() + bounding_rect.top()) / 2 - t / 16,
747 (t * 2) / 5, t / 8);
748 p.fillRect(crop, Qt::white);
749 }
750 p.end();
751 wwidth = 2 * 3 + pix.width();
752 unit_label.setPixmap(pix);
756 } else {
759 }
760 tile_pixmap->map_pixmap.fill(QColor(0 , 0 , 0 , 0));
761 put_terrain(punit->tile, tile_pixmap, 1.0, 0, 0);
762 img = tile_pixmap->map_pixmap.toImage();
763 crop = zealous_crop_rect(img);
764 cropped_img = img.copy(crop);
765 img = cropped_img.scaledToHeight(height() - 5, Qt::SmoothTransformation);
766 pix = QPixmap::fromImage(img);
767 tile_label.setPixmap(pix);
768 unit_label.setToolTip(popup_info_text(punit->tile));
770 wwidth = wwidth + pix.width();
771 qtg_canvas_free(tile_pixmap);
772 qtg_canvas_free(unit_pixmap);
773
774 setFixedWidth(wwidth + qMax(unit_icons->update_actions() * (height() * 8)
775 / 10, text_label.width()));
776 mw->put_to_corner();
777 if (tmp != nullptr) {
778 tileset = tmp;
779 }
780 setUpdatesEnabled(true);
781 updateGeometry();
782 update();
783
784 show();
785}
786
787/************************************************************************/
791{
793}
794
795/************************************************************************/
799{
800 if (e->button() == Qt::LeftButton) {
801 emit left_clicked();
802 }
803}
804
805/************************************************************************/
809{
810 gui()->game_tab_widget->setCurrentIndex(0);
812}
813
814/************************************************************************/
817hud_action::hud_action(QWidget *parent) : QWidget(parent)
818{
819 connect(this, &hud_action::left_clicked, this, &hud_action::on_clicked);
820 setFocusPolicy(Qt::StrongFocus);
821 setMouseTracking(true);
822 focus = false;
823 action_pixmap = nullptr;
824}
825
826/************************************************************************/
830{
831 action_pixmap = p;
832}
833
834/************************************************************************/
838{
839 QRect rx, ry, rz;
840 QPainter p;
841
842 rx = QRect(0, 0, width(), height());
843 ry = QRect(0, 0, action_pixmap->width(), action_pixmap->height());
844 rz = QRect(0, 0, width() - 1, height() - 3);
845 p.begin(this);
846 p.setCompositionMode(QPainter::CompositionMode_Source);
847 p.setRenderHint(QPainter::SmoothPixmapTransform);
848 p.drawPixmap(rx, *action_pixmap, ry);
849 p.setPen(QColor(palette().color(QPalette::Text)));
850 p.drawRect(rz);
851 if (focus) {
852 p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
853 p.fillRect(rx, QColor(palette().color(QPalette::Highlight)));
854 }
855 p.end();
856
857}
858
859/************************************************************************/
863{
864 if (action_pixmap) {
865 delete action_pixmap;
866 }
867}
868
869/************************************************************************/
872void hud_action::mousePressEvent(QMouseEvent *e)
873{
874 if (e->button() == Qt::RightButton) {
875 emit right_clicked();
876 } else if (e->button() == Qt::LeftButton) {
877 emit left_clicked();
878 }
879}
880
881/************************************************************************/
885{
886 focus = true;
887 update();
888}
889
890/************************************************************************/
894{
895 focus = false;
896 update();
897 QWidget::leaveEvent(event);
898}
899
900/************************************************************************/
903#ifndef FC_QT5_MODE
905#else // FC_QT5_MODE
906void hud_action::enterEvent(QEvent *event)
907#endif // FC_QT5_MODE
908{
909 focus = true;
910 update();
911 QWidget::enterEvent(event);
912}
913
914/************************************************************************/
920
921/************************************************************************/
925{
926 gui()->menu_bar->execute_shortcut(action_shortcut);
927}
928
929/************************************************************************/
932unit_actions::unit_actions(QWidget *parent, unit *punit) : QWidget(parent)
933{
934 layout = new QHBoxLayout(this);
935 layout->setSpacing(3);
936 layout->setContentsMargins(0, 0, 0, 0);
938 init_layout();
939 setFocusPolicy(Qt::ClickFocus);
940}
941
942/************************************************************************/
946{
947 qDeleteAll(actions);
948 actions.clear();
949}
950
951/************************************************************************/
955{
956 QSizePolicy size_fixed_policy(QSizePolicy::MinimumExpanding,
957 QSizePolicy::Fixed,
958 QSizePolicy::Frame);
959 setSizePolicy(size_fixed_policy);
960 layout->setSpacing(0);
961 setLayout(layout);
962}
963
964/************************************************************************/
968{
969 hud_action *a;
970
972
973 if (current_unit == nullptr) {
974 clear_layout();
975 hide();
976 return 0;
977 }
978 /* HACK prevent crash with active goto when leaving widget,
979 * just skip update because with active goto actions shouldn't change */
980 if (goto_is_active() ) {
981 return actions.count();
982 }
983 hide();
984 clear_layout();
985 setUpdatesEnabled(false);
986
987
988 foreach (a, actions) {
989 delete a;
990 }
991 qDeleteAll(actions);
992 actions.clear();
993
994 /* Create possible actions */
995
997 a = new hud_action(this);
999 a->set_pixmap(fc_icons::instance()->get_pixmap("home"));
1000 actions.append(a);
1001 }
1002
1003
1004 if (can_unit_do_activity_client(current_unit, ACTIVITY_MINE)) {
1005 a = new hud_action(this);
1007 a->set_pixmap(fc_icons::instance()->get_pixmap("mine"));
1008 actions.append(a);
1009 }
1010
1011 if (can_unit_do_activity_client(current_unit, ACTIVITY_PLANT)) {
1012 a = new hud_action(this);
1014 a->set_pixmap(fc_icons::instance()->get_pixmap("plantforest"));
1015 actions.append(a);
1016 }
1017
1018 if (can_unit_do_activity_client(current_unit, ACTIVITY_IRRIGATE)) {
1019 a = new hud_action(this);
1021 a->set_pixmap(fc_icons::instance()->get_pixmap("irrigation"));
1022 actions.append(a);
1023 }
1024
1025 if (can_unit_do_activity_client(current_unit, ACTIVITY_CULTIVATE)) {
1026 a = new hud_action(this);
1028 a->set_pixmap(fc_icons::instance()->get_pixmap("chopchop"));
1029 actions.append(a);
1030 }
1031
1032 if (can_unit_do_activity_client(current_unit, ACTIVITY_TRANSFORM)) {
1033 a = new hud_action(this);
1035 a->set_pixmap(fc_icons::instance()->get_pixmap("transform"));
1036 actions.append(a);
1037 }
1038
1039 /* Road */
1040 {
1041 bool ok = false;
1042
1043 extra_type_by_cause_iterate(EC_ROAD, pextra) {
1044 struct road_type *proad = extra_road_get(pextra);
1045
1047 ok = true;
1048 }
1050 if (ok) {
1051 a = new hud_action(this);
1053 a->set_pixmap(fc_icons::instance()->get_pixmap("buildroad"));
1054 actions.append(a);
1055 }
1056 }
1057 /* Goto */
1058 a = new hud_action(this);
1060 a->set_pixmap(fc_icons::instance()->get_pixmap("goto"));
1061 actions.append(a);
1062
1063
1064 if (can_unit_do_activity_client(current_unit, ACTIVITY_FORTIFYING)) {
1065 a = new hud_action(this);
1067 a->set_pixmap(fc_icons::instance()->get_pixmap("fortify"));
1068 actions.append(a);
1069 }
1070
1071
1072 if (can_unit_do_activity_client(current_unit, ACTIVITY_SENTRY)) {
1073 a = new hud_action(this);
1075 a->set_pixmap(fc_icons::instance()->get_pixmap("sentry"));
1076 actions.append(a);
1077 }
1078
1079 // Board
1081 a = new hud_action(this);
1083 a->set_pixmap(fc_icons::instance()->get_pixmap("load"));
1084 actions.append(a);
1085 }
1086
1087 // Set homecity
1091 a = new hud_action(this);
1093 a->set_pixmap(fc_icons::instance()->get_pixmap("set_homecity"));
1094 actions.append(a);
1095 }
1096 }
1097
1098 // Upgrade
1100 a = new hud_action(this);
1102 a->set_pixmap(fc_icons::instance()->get_pixmap("upgrade"));
1103 actions.append(a);
1104 }
1105
1106 // Automate
1108 a = new hud_action(this);
1110 a->set_pixmap(fc_icons::instance()->get_pixmap("automate"));
1111 actions.append(a);
1112 }
1113
1114 // Paradrop
1116 a = new hud_action(this);
1118 a->set_pixmap(fc_icons::instance()->get_pixmap("paradrop"));
1119 actions.append(a);
1120 }
1121
1122 // Clean pollution
1123 if (can_unit_do_activity_client(current_unit, ACTIVITY_POLLUTION)) {
1124 a = new hud_action(this);
1126 a->set_pixmap(fc_icons::instance()->get_pixmap("pollution"));
1127 actions.append(a);
1128 }
1129
1130 // Deboard
1135 a = new hud_action(this);
1137 a->set_pixmap(fc_icons::instance()->get_pixmap("unload"));
1138 actions.append(a);
1139 }
1140
1141 /* Nuke */
1142 if (unit_can_do_action(current_unit, ACTION_NUKE)) {
1143 a = new hud_action(this);
1145 a->set_pixmap(fc_icons::instance()->get_pixmap("nuke"));
1146 actions.append(a);
1147 }
1148
1149 /* Wait */
1150 a = new hud_action(this);
1152 a->set_pixmap(fc_icons::instance()->get_pixmap("wait"));
1153 actions.append(a);
1154
1155 /* Done moving */
1156 a = new hud_action(this);
1158 a->set_pixmap(fc_icons::instance()->get_pixmap("done"));
1159 actions.append(a);
1160
1161
1162 foreach (a, actions) {
1163 a->setToolTip(gui()->menu_bar->shortcut_2_menustring(a->action_shortcut));
1164 a->setFixedHeight(height());
1165 a->setFixedWidth(height());
1166 layout->addWidget(a);
1167 }
1168
1169 setFixedWidth(actions.count() * height());
1170 setUpdatesEnabled(true);
1171 show();
1172 layout->update();
1173 updateGeometry();
1174 return actions.count();
1175}
1176
1177/************************************************************************/
1181{
1182 int i = actions.count();
1183 hud_action *ui;
1184 int j;
1185
1186 setUpdatesEnabled(false);
1187 for (j = 0; j < i; j++) {
1188 ui = actions[j];
1189 layout->removeWidget(ui);
1190 delete ui;
1191 }
1192 while (!actions.empty()) {
1193 actions.removeFirst();
1194 }
1195 setUpdatesEnabled(true);
1196}
1197
1198/************************************************************************/
1201hud_unit_loader::hud_unit_loader(struct unit *pcargo, struct tile *ptile)
1202{
1203 setProperty("showGrid", "false");
1204 setProperty("selectionBehavior", "SelectRows");
1205 setEditTriggers(QAbstractItemView::NoEditTriggers);
1206 setSelectionMode(QAbstractItemView::SingleSelection);
1207 verticalHeader()->setVisible(false);
1208 horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
1209 horizontalHeader()->setVisible(false);
1210 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1211 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1212 connect(selectionModel(),
1213 SIGNAL(selectionChanged(const QItemSelection &,
1214 const QItemSelection &)), this,
1215 SLOT(selection_changed(const QItemSelection &,
1216 const QItemSelection &)));
1217 cargo = pcargo;
1218 qtile = ptile;
1219
1220}
1221
1222/************************************************************************/
1228
1229/************************************************************************/
1234{
1235 QTableWidgetItem *new_item;
1236 int max_size = 0;
1237 int i, j;
1238 int w,h;
1239 sprite *spite;
1240
1241 unit_list_iterate(qtile->units, ptransport) {
1242 if (can_unit_transport(ptransport, cargo)
1243 && get_transporter_occupancy(ptransport)
1244 < get_transporter_capacity(ptransport)) {
1245 transports.append(ptransport);
1246 max_size = qMax(max_size, get_transporter_occupancy(ptransport));
1247 }
1249
1250 setRowCount(transports.count());
1251 setColumnCount(max_size + 1);
1252 for (i = 0 ; i < transports.count(); i++) {
1253 QString str;
1254 spite = get_unittype_sprite(tileset, transports.at(i)->utype,
1255 direction8_invalid());
1256 str = utype_rule_name(transports.at(i)->utype);
1257 /* TRANS: MP - just movement points */
1258 str = str + " ("
1259 + QString(move_points_text(transports.at(i)->moves_left, false))
1260 + _("MP") + ")";
1261 new_item = new QTableWidgetItem(QIcon(*spite->pm), str);
1262 setItem(i, 0, new_item);
1263 j = 1;
1264 unit_list_iterate(transports.at(i)->transporting, tunit) {
1265 spite = get_unittype_sprite(tileset, tunit->utype,
1266 direction8_invalid());
1267 new_item = new QTableWidgetItem(QIcon(*spite->pm), "");
1268 setItem(i, j, new_item);
1269 j++;
1271 }
1272
1273 w = verticalHeader()->width() + 4;
1274 for (i = 0; i < columnCount(); i++) {
1275 w += columnWidth(i);
1276 }
1277 h = horizontalHeader()->height() + 4;
1278 for (i = 0; i < rowCount(); i++) {
1279 h += rowHeight(i);
1280 }
1281
1282 resize(w, h);
1283 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
1284 | Qt::FramelessWindowHint);
1285 show();
1286}
1287
1288/************************************************************************/
1291void hud_unit_loader::selection_changed(const QItemSelection& s1,
1292 const QItemSelection& s2)
1293{
1294 int curr_row;
1295
1296 curr_row = s1.indexes().at(0).row();
1297 request_unit_load(cargo, transports.at(curr_row), qtile);
1298 close();
1299}
1300
1301/************************************************************************/
1304unit_hud_selector::unit_hud_selector(QWidget *parent) : QFrame(parent)
1305{
1306 QHBoxLayout *hbox, *hibox;
1307 Unit_type_id utype_id;
1308 QGroupBox *no_name;
1309 QVBoxLayout *groupbox_layout;
1310
1311 hide();
1312 struct unit *punit = head_of_units_in_focus();
1313
1314 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
1315 | Qt::FramelessWindowHint);
1316 main_layout = new QVBoxLayout(this);
1317
1318 unit_sel_type = new QComboBox();
1319
1320 unit_type_iterate(utype) {
1321 utype_id = utype_index(utype);
1322 if (has_player_unit_type(utype_id)) {
1323 unit_sel_type->addItem(utype_name_translation(utype), utype_id);
1324 }
1325 }
1327
1328 if (punit) {
1329 int i;
1331 unit_sel_type->setCurrentIndex(i);
1332 }
1333 no_name = new QGroupBox();
1334 no_name->setTitle(_("Unit type"));
1335 this_type = new QRadioButton(_("Selected type"), no_name);
1336 this_type->setChecked(true);
1337 any_type = new QRadioButton(_("All types"), no_name);
1338 connect(unit_sel_type, SIGNAL(currentIndexChanged(int)), this,
1339 SLOT(select_units(int)));
1340 connect(this_type, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1341 connect(any_type, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1342 groupbox_layout = new QVBoxLayout;
1343 groupbox_layout->addWidget(unit_sel_type);
1344 groupbox_layout->addWidget(this_type);
1345 groupbox_layout->addWidget(any_type);
1346 no_name->setLayout(groupbox_layout);
1347 hibox = new QHBoxLayout;
1348 hibox->addWidget(no_name);
1349
1350 no_name = new QGroupBox();
1351 no_name->setTitle(_("Unit activity"));
1352 any_activity = new QRadioButton(_("Any activity"), no_name);
1353 any_activity->setChecked(true);
1354 fortified = new QRadioButton(_("Fortified"), no_name);
1355 idle = new QRadioButton(_("Idle"), no_name);
1356 sentried = new QRadioButton(_("Sentried"), no_name);
1357 connect(any_activity, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1358 connect(idle, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1359 connect(fortified, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1360 connect(sentried, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1361 groupbox_layout = new QVBoxLayout;
1362 groupbox_layout->addWidget(any_activity);
1363 groupbox_layout->addWidget(idle);
1364 groupbox_layout->addWidget(fortified);
1365 groupbox_layout->addWidget(sentried);
1366 no_name->setLayout(groupbox_layout);
1367 hibox->addWidget(no_name);
1368 main_layout->addLayout(hibox);
1369
1370 no_name = new QGroupBox();
1371 no_name->setTitle(_("Unit HP and MP"));
1372 any = new QRadioButton(_("Any unit"), no_name);
1373 full_hp = new QRadioButton(_("Full HP"), no_name);
1374 full_mp = new QRadioButton(_("Full MP"), no_name);
1375 full_hp_mp = new QRadioButton(_("Full HP and MP"), no_name);
1376 full_hp_mp->setChecked(true);
1377 connect(any, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1378 connect(full_hp, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1379 connect(full_mp, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1380 connect(full_hp_mp, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1381 groupbox_layout = new QVBoxLayout;
1382 groupbox_layout->addWidget(any);
1383 groupbox_layout->addWidget(full_hp);
1384 groupbox_layout->addWidget(full_mp);
1385 groupbox_layout->addWidget(full_hp_mp);
1386 no_name->setLayout(groupbox_layout);
1387 hibox = new QHBoxLayout;
1388 hibox->addWidget(no_name);
1389
1390 no_name = new QGroupBox();
1391 no_name->setTitle(_("Location"));
1392 anywhere = new QRadioButton(_("Anywhere"), no_name);
1393 this_tile = new QRadioButton(_("Current tile"), no_name);
1394 this_continent = new QRadioButton(_("Current continent"), no_name);
1395 main_continent = new QRadioButton(_("Main continent"), no_name);
1396 groupbox_layout = new QVBoxLayout;
1397
1398 if (punit) {
1399 this_tile->setChecked(true);
1400 } else {
1401 this_tile->setDisabled(true);
1402 this_continent->setDisabled(true);
1403 main_continent->setChecked(true);
1404 }
1405
1406 groupbox_layout->addWidget(this_tile);
1407 groupbox_layout->addWidget(this_continent);
1408 groupbox_layout->addWidget(main_continent);
1409 groupbox_layout->addWidget(anywhere);
1410
1411 no_name->setLayout(groupbox_layout);
1412 hibox->addWidget(no_name);
1413 main_layout->addLayout(hibox);
1414
1415 select = new QPushButton(_("Select"));
1416 cancel = new QPushButton(_("Cancel"));
1417 connect(anywhere, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1418 connect(this_tile, SIGNAL(toggled(bool)), this, SLOT(select_units(bool)));
1419 connect(this_continent, SIGNAL(toggled(bool)), this,
1420 SLOT(select_units(bool)));
1421 connect(main_continent, SIGNAL(toggled(bool)), this,
1422 SLOT(select_units(bool)));
1423 connect(select, &QAbstractButton::clicked, this, &unit_hud_selector::uhs_select);
1424 connect(cancel, &QAbstractButton::clicked, this, &unit_hud_selector::uhs_cancel);
1425 hbox = new QHBoxLayout;
1426 hbox->addWidget(cancel);
1427 hbox->addWidget(select);
1428
1429 result_label.setAlignment(Qt::AlignCenter);
1430 main_layout->addWidget(&result_label, Qt::AlignHCenter);
1431 main_layout->addLayout(hbox);
1432 setLayout(main_layout);
1433
1434}
1435
1436/************************************************************************/
1440{
1441 QPoint p;
1442
1443 p = QPoint((parentWidget()->width() - sizeHint().width()) / 2,
1444 (parentWidget()->height() - sizeHint().height()) / 2);
1445 p = parentWidget()->mapToGlobal(p);
1446 move(p);
1447 setVisible(true);
1448 show();
1449 select_units();
1450}
1451
1452/************************************************************************/
1458
1459/************************************************************************/
1463{
1464 const struct player *pplayer;
1465
1466 pplayer = client_player();
1467
1468 unit_list_iterate(pplayer->units, punit) {
1472 }
1474 close();
1475}
1476
1477/************************************************************************/
1481{
1482 close();
1483}
1484
1485/************************************************************************/
1489{
1490 int num = 0;
1491 const struct player *pplayer;
1492
1493 pplayer = client_player();
1494
1495 unit_list_iterate(pplayer->units, punit) {
1498 num++;
1499 }
1501 result_label.setText(QString(PL_("%1 unit", "%1 units", num)).arg(num));
1502}
1503
1504/************************************************************************/
1508{
1509 select_units(0);
1510}
1511
1512/************************************************************************/
1516{
1517 if ((event->key() == Qt::Key_Return)
1518 || (event->key() == Qt::Key_Enter)) {
1519 uhs_select();
1520 }
1521 if (event->key() == Qt::Key_Escape) {
1522 close();
1523 event->accept();
1524 }
1525 QWidget::keyPressEvent(event);
1526}
1527
1528/************************************************************************/
1532{
1533 if ((punit->activity == ACTIVITY_FORTIFIED && fortified->isChecked())
1534 || (punit->activity == ACTIVITY_SENTRY && sentried->isChecked())
1535 || (punit->activity == ACTIVITY_IDLE && idle->isChecked())
1536 || any_activity->isChecked()) {
1537 return true;
1538 }
1539 return false;
1540}
1541
1542/************************************************************************/
1546{
1547 if ((any->isChecked()
1548 || (full_mp->isChecked()
1550 || (full_hp->isChecked() && punit->hp >= punit->utype->hp)
1551 || (full_hp_mp->isChecked() && punit->hp >= punit->utype->hp
1552 && punit->moves_left >= punit->utype->move_rate))) {
1553 return true;
1554 }
1555 return false;
1556}
1557
1558/************************************************************************/
1562{
1563 int island = -1;
1564 struct unit *cunit = head_of_units_in_focus();
1565
1566 if (this_tile->isChecked() && cunit) {
1567 if (punit->tile == cunit->tile) {
1568 return true;
1569 }
1570 }
1571
1572 if (main_continent->isChecked()
1575 } else if (this_continent->isChecked() && cunit) {
1576 island = cunit->tile->continent;
1577 }
1578
1579 if (island > -1) {
1580 if (punit->tile->continent == island) {
1581 return true;
1582 }
1583 }
1584
1585 if (anywhere->isChecked()) {
1586 return true;
1587 }
1588 return false;
1589}
1590
1591/************************************************************************/
1595{
1596 QVariant qvar;
1597 Unit_type_id utype_id;
1598
1599 if (this_type->isChecked()) {
1600 qvar = unit_sel_type->currentData();
1601 utype_id = qvar.toInt();
1602 if (utype_id == utype_index(punit->utype)) {
1603 return true;
1604 } else {
1605 return false;
1606 }
1607 }
1608 if (any_type->isChecked()) {
1609 return true;
1610 }
1611 return false;
1612}
1613
1614/************************************************************************/
1617QString popup_terrain_info(struct tile *ptile)
1618{
1619 int movement_cost;
1620 struct terrain *terr;
1621 QString ret, t, move_text;
1622 bool has_road = false;
1623
1624 terr = ptile->terrain;
1625 ret = QString(_("Terrain: %1\n")).arg(tile_get_info_text(ptile, TRUE, 0));
1626 ret = ret + QString(_("Food/Prod/Trade: %1\n"))
1627 .arg(get_tile_output_text(ptile));
1628 t = get_infrastructure_text(ptile->extras);
1629 if (t != "") {
1630 ret = ret + QString(_("Infrastructure: %1\n")).arg(t);
1631 }
1632 ret = ret + QString(_("Defense bonus: %1%\n")).arg(terr->defense_bonus);
1634
1635 extra_type_by_cause_iterate(EC_ROAD, pextra) {
1636 struct road_type *proad = extra_road_get(pextra);
1637
1638 if (tile_has_road(ptile, proad)) {
1639 if (proad->move_cost <= movement_cost) {
1640 has_road = true;
1641 move_text = move_points_text(proad->move_cost, TRUE);
1642 movement_cost = proad->move_cost;
1643 }
1644 }
1646
1647 if (has_road) {
1648 ret = ret + QString(_("Movement cost: %1")).arg(move_text);
1649 } else {
1650 ret = ret + QString(_("Movement cost: %1")).arg(movement_cost);
1651 }
1652
1653 return ret;
1654}
1655
1656/************************************************************************/
1660{
1661 QString s;
1662 hud_text *ht;
1663 QList<hud_text *> close_list;
1664 struct research *research;
1665 int i;
1666 char buf[25];
1667
1668 if (!client_has_player()
1669 || !gui()->qt_settings.show_new_turn_text) {
1670 return;
1671 }
1672 close_list = gui()->mapview_wdg->findChildren<hud_text *>();
1673 for (i = 0; i < close_list.size(); ++i) {
1674 close_list.at(i)->close();
1675 close_list.at(i)->deleteLater();
1676 }
1678 s = QString(_("Year: %1 (Turn: %2)"))
1679 .arg(calendar_text()).arg(game.info.turn) + "\n";
1680 s += QString(nation_plural_for_player(client_player()));
1681 if (client_is_observer()) {
1682 s += QString(_(" (observer)"));
1683 }
1684 s += " - " + QString(_("Population: %1"))
1688 && research->researching != A_NONE) {
1689 s = s + "\n" + QString(research_advance_name_translation(research,
1691 " (" + QString::number(research->bulbs_researched) + "/"
1692 + QString::number(research->client.researching_cost) + ")";
1693 }
1694 s = s + "\n" + science_dialog_text() + "\n";
1695
1696 /* Can't use QString().sprintf() as msys libintl.h defines sprintf() as a macro */
1697 fc_snprintf(buf, sizeof(buf), "%+d", player_get_expected_income(client.conn.playing));
1698
1699 /* TRANS: current gold, then loss/gain per turn */
1700 s = s + QString(_("Gold: %1 (%2)"))
1702 .arg(buf);
1703 ht = new hud_text(s, 5, gui()->mapview_wdg);
1704 ht->show_me();
1705}
1706
1707/************************************************************************/
1710hud_unit_combat::hud_unit_combat(int attacker_unit_id, int defender_unit_id,
1711 int attacker_hp, int defender_hp,
1712 bool make_att_veteran, bool make_def_veteran,
1713 float scale, QWidget *parent) : QWidget(parent)
1714{
1715 hud_scale = scale;
1716 att_hp = attacker_hp;
1717 def_hp = defender_hp;
1718
1719 attacker = game_unit_by_number(attacker_unit_id);
1720 defender = game_unit_by_number(defender_unit_id);
1723 att_veteran = make_att_veteran;
1724 def_veteran = make_def_veteran;
1727 if (defender_hp <= 0) {
1729 } else {
1731 }
1732 init_images();
1733}
1734
1735/************************************************************************/
1739{
1740 QImage crdimg, acrimg, at, dt;
1741 QRect dr, ar;
1742 QPainter p;
1743 struct canvas *defender_pixmap;
1744 struct canvas *attacker_pixmap;
1745 int w;
1746
1747 focus = false;
1748 w = 3 * hud_scale * tileset_unit_height(tileset) / 2;
1749 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
1750 setFixedSize(2 * w, w);
1751 defender_pixmap = qtg_canvas_create(tileset_unit_width(tileset),
1753 defender_pixmap->map_pixmap.fill(Qt::transparent);
1754 if (defender != nullptr) {
1755 if (!redraw) {
1756 put_unit(defender, defender_pixmap, 1.0, 0, 0);
1757 } else {
1758 put_unittype(type_defender, defender_pixmap, 1.0, 0, 0);
1759 }
1760 dimg = defender_pixmap->map_pixmap.toImage();
1761 dr = zealous_crop_rect(dimg);
1762 crdimg = dimg.copy(dr);
1763 dimg = crdimg.scaledToHeight(w, Qt::SmoothTransformation);
1764 }
1765 if (dimg.width() < w) {
1766 dt = QImage(w, dimg.height(), QImage::Format_ARGB32_Premultiplied);
1767 dt.fill(Qt::transparent);
1768 p.begin(&dt);
1769 p.drawImage(w / 2 - dimg.width() / 2, 0, dimg);
1770 p.end();
1771 dimg = dt;
1772 }
1773 dimg = dimg.scaled(w, w, Qt::IgnoreAspectRatio,
1774 Qt::SmoothTransformation);
1775 attacker_pixmap = qtg_canvas_create(tileset_unit_width(tileset),
1777 attacker_pixmap->map_pixmap.fill(Qt::transparent);
1778 if (attacker != nullptr) {
1779 if (!redraw) {
1780 put_unit(attacker, attacker_pixmap, 1, 0, 0);
1781 } else {
1782 put_unittype(type_attacker, attacker_pixmap, 1, 0, 0);
1783 }
1784 aimg = attacker_pixmap->map_pixmap.toImage();
1785 ar = zealous_crop_rect(aimg);
1786 acrimg = aimg.copy(ar);
1787 aimg = acrimg.scaledToHeight(w, Qt::SmoothTransformation);
1788 }
1789 if (aimg.width() < w) {
1790 at = QImage(w, dimg.height(), QImage::Format_ARGB32_Premultiplied);
1791 at.fill(Qt::transparent);
1792 p.begin(&at);
1793 p.drawImage(w / 2 - aimg.width() / 2, 0, aimg);
1794 p.end();
1795 aimg = at;
1796 }
1797 aimg = aimg.scaled(w, w, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1798 delete defender_pixmap;
1799 delete attacker_pixmap;
1800}
1801
1802/************************************************************************/
1806{
1807 hud_scale = scale;
1808 init_images(true);
1809}
1810
1811/************************************************************************/
1817
1818/************************************************************************/
1822{
1823 fading = fade;
1824 update();
1825}
1826
1827/************************************************************************/
1831{
1832 return focus;
1833}
1834
1835/************************************************************************/
1839{
1840 QPainter p;
1841 QRect left, right;
1842 QColor c1, c2;
1843 QPen pen;
1845 QString ahploss, dhploss;
1846
1847 if (att_hp_loss > 0) {
1848 ahploss = "-" + QString::number(att_hp_loss);
1849 } else {
1850 ahploss = "0";
1851 }
1852 if (def_hp_loss > 0) {
1853 dhploss = "-" + QString::number(def_hp_loss);
1854 } else {
1855 dhploss = "0";
1856 }
1857 f.setBold(true);
1858
1859 if (def_hp == 0) {
1860 c1 = QColor(25, 125, 25, 175);
1861 c2 = QColor(125, 25, 25, 175);
1862 } else {
1863 c1 = QColor(125, 25, 25, 175);
1864 c2 = QColor(25, 125, 25, 175);
1865 }
1866 int w = 3 * tileset_unit_height(tileset) / 2 * hud_scale;
1867
1868 left = QRect(0 , 0, w , w);
1869 right = QRect(w, 0, w , w);
1870 pen = QPen(QColor(palette().color(QPalette::AlternateBase)), 2.0);
1871 p.begin(this);
1872 if (fading < 1.0) {
1873 p.setOpacity(fading);
1874 }
1875 if (focus) {
1876 p.fillRect(left, QColor(palette().color(QPalette::Highlight)));
1877 p.fillRect(right, QColor(palette().color(QPalette::Highlight)));
1878 c1.setAlpha(110);
1879 c2.setAlpha(110);
1880 }
1881 p.fillRect(left, c1);
1882 p.fillRect(right, c2);
1883 p.setPen(pen);
1884 p.drawRect(1, 1, width() - 2 , height() - 2);
1885 p.drawImage(left, aimg);
1886 p.setFont(f);
1887 p.setPen(QColor(Qt::white));
1888 if (def_veteran) {
1889 p.drawText(right, Qt::AlignHCenter | Qt::AlignJustify
1890 | Qt::AlignAbsolute, "*");
1891 }
1892 if (att_veteran) {
1893 p.drawText(left, Qt::AlignHCenter | Qt::AlignJustify
1894 | Qt::AlignAbsolute, "*");
1895 }
1896 p.drawText(left, Qt::AlignHorizontal_Mask, ahploss);
1897 p.drawImage(right, dimg);
1898 p.drawText(right, Qt::AlignHorizontal_Mask, dhploss);
1899 p.end();
1900}
1901
1902/************************************************************************/
1909
1910/************************************************************************/
1914{
1915 focus = false;
1916 update();
1917}
1918
1919/************************************************************************/
1922#ifndef FC_QT5_MODE
1924#else // FC_QT5_MODE
1926#endif // FC_QT5_MODE
1927{
1928 focus = true;
1929 update();
1930}
1931
1932
1933/************************************************************************/
1936scale_widget::scale_widget(QRubberBand::Shape s,
1937 QWidget* p) : QRubberBand(s, p)
1938{
1939 QPixmap *pix;
1940
1941 size = 12;
1942 pix = fc_icons::instance()->get_pixmap("plus");
1943 plus = pix->scaledToWidth(size);
1944 delete pix;
1945 pix = fc_icons::instance()->get_pixmap("minus");
1946 minus = plus = pix->scaledToWidth(size);
1947 delete pix;
1948 setFixedSize(2 * size, size);
1949 scale = 1.0f;
1950 setAttribute(Qt::WA_TransparentForMouseEvents, false);
1951}
1952
1953/************************************************************************/
1957{
1958 QRubberBand::paintEvent(event);
1959 QPainter p;
1960
1961 p.begin(this);
1962 p.drawPixmap(0, 0, minus);
1963 p.drawPixmap(size, 0, plus);
1964 p.end();
1965}
1966
1967/************************************************************************/
1971{
1972 if (event->button() == Qt::LeftButton) {
1973#ifndef FC_QT5_MODE
1974 if (event->position().x() <= size) {
1975#else /* FC_QT5_MODE */
1976 if (event->localPos().x() <= size) {
1977#endif /* FC_QT5_MODE */
1978 scale = scale / 1.2;
1979 } else {
1980 scale = scale * 1.2;
1981 }
1982 parentWidget()->update();
1983 }
1984}
1985
1986/************************************************************************/
1989hud_battle_log::hud_battle_log(QWidget *parent) : QWidget(parent)
1990{
1991 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
1992 main_layout = new QVBoxLayout(this);
1993 mw = new move_widget(this);
1994 setContentsMargins(0, 0, 0, 0);
1995 main_layout->setContentsMargins(0, 0, 0, 0);
1996 sw = new scale_widget(QRubberBand::Rectangle, this);
1997 sw->show();
1998}
1999
2000/************************************************************************/
2004{
2005 delete sw;
2006 delete mw;
2007}
2008
2009/************************************************************************/
2013{
2014 hud_unit_combat *hudc;
2015 int w = 3 * tileset_unit_height(tileset) / 2 * scale;
2016
2017 gui()->qt_settings.battlelog_scale = scale;
2018 delete layout();
2019 main_layout = new QVBoxLayout;
2020 foreach (hudc, lhuc) {
2021 hudc->set_scale(scale);
2022 main_layout->addWidget(hudc);
2023 hudc->set_fading(1.0);
2024 }
2025 setFixedSize(2 * w + 10, lhuc.count() * w + 10);
2026 setLayout(main_layout);
2027
2028 update();
2029 show();
2030 m_timer.restart();
2031 startTimer(50);
2032}
2033
2034/************************************************************************/
2038{
2039 scale = s;
2040 sw->scale = s;
2041}
2042
2043/************************************************************************/
2047{
2048 hud_unit_combat *hudc;
2049 int w = 3 * tileset_unit_height(tileset) / 2 * scale;
2050
2051 delete layout();
2052 main_layout = new QVBoxLayout;
2053 lhuc.prepend(huc);
2054 while (lhuc.count() > 5) {
2055 hudc = lhuc.takeLast();
2056 delete hudc;
2057 }
2058 foreach (hudc, lhuc) {
2059 main_layout->addWidget(hudc);
2060 hudc->set_fading(1.0);
2061 }
2062 setFixedSize(2 * w + 10, lhuc.count() * w + 10);
2063 setLayout(main_layout);
2064
2065 update();
2066 show();
2067 m_timer.restart();
2068 startTimer(50);
2069}
2070
2071/************************************************************************/
2075{
2076 if (scale != sw->scale) {
2077 scale = sw->scale;
2078 update_size();
2079 }
2080 mw->put_to_corner();
2081 sw->move(width() - sw->width(), 0);
2082}
2083
2084/************************************************************************/
2088{
2089 QPoint p;
2090
2091 p = pos();
2092 gui()->qt_settings.battlelog_x = static_cast<float>(p.x()) / mapview.width;
2093 gui()->qt_settings.battlelog_y = static_cast<float>(p.y())
2094 / mapview.height;
2095 m_timer.restart();
2096}
2097
2098/************************************************************************/
2104{
2105 hud_unit_combat *hupdate;
2106
2107 foreach (hupdate, lhuc) {
2108 hupdate->set_fading(1.0);
2109 }
2110}
2111
2112/************************************************************************/
2116{
2117 hud_unit_combat *hudc;
2118
2119 if (m_timer.elapsed() > 4000 && m_timer.elapsed() < 5000) {
2120 foreach (hudc, lhuc) {
2121 if (hudc->get_focus()) {
2122 m_timer.restart();
2123 te_inner();
2124 return;
2125 }
2126 hudc->set_fading((5000.0 - m_timer.elapsed()) / 1000);
2127 }
2128 }
2129 if (m_timer.elapsed() >= 5000) {
2130 hide();
2131 }
2132}
2133
2134/************************************************************************/
2138{
2139 hud_unit_combat *hupdate;
2140
2141 foreach (hupdate, lhuc) {
2142 hupdate->set_fading(1.0);
2143 }
2144 m_timer.restart();
2145 setVisible(true);
2146}
#define str
Definition astring.c:76
#define n
Definition astring.c:77
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:399
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:47
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:35
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
void left_clicked()
void mousePressEvent(QMouseEvent *e)
void on_clicked()
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 paintEvent(QPaintEvent *event)
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void on_clicked()
void mouseMoveEvent(QMouseEvent *event)
void right_clicked()
QPixmap * action_pixmap
Definition hudwidget.h:159
hud_action(QWidget *parent)
void on_right_clicked()
void enterEvent(QEnterEvent *event)
shortcut_id action_shortcut
Definition hudwidget.h:165
void left_clicked()
void set_pixmap(QPixmap *p)
move_widget * mw
Definition hudwidget.h:377
QList< hud_unit_combat * > lhuc
Definition hudwidget.h:360
QElapsedTimer m_timer
Definition hudwidget.h:378
void add_combat_info(hud_unit_combat *huc)
hud_battle_log(QWidget *parent)
QVBoxLayout * main_layout
Definition hudwidget.h:359
void moveEvent(QMoveEvent *event)
void timerEvent(QTimerEvent *event)
scale_widget * sw
Definition hudwidget.h:376
void paintEvent(QPaintEvent *event)
void set_scale(float s)
void showEvent(QShowEvent *event)
QString cs1
Definition hudwidget.h:131
void set_text_title_definput(QString s1, QString s2, QString def_input)
void paintEvent(QPaintEvent *event)
QElapsedTimer m_timer
Definition hudwidget.h:113
QString cs2
Definition hudwidget.h:131
void timerEvent(QTimerEvent *event)
QFontMetrics * fm_text
Definition hudwidget.h:128
hud_input_box(QWidget *parent)
QLineEdit input_edit
Definition hudwidget.h:119
QFontMetrics * fm_title
Definition hudwidget.h:129
QString text
Definition hudwidget.h:126
QString title
Definition hudwidget.h:127
QFontMetrics * fm_text
Definition hudwidget.h:73
QString title
Definition hudwidget.h:72
QElapsedTimer m_timer
Definition hudwidget.h:58
void timerEvent(QTimerEvent *event)
void paintEvent(QPaintEvent *event)
int set_text_title(QString s1, QString s2, bool return_exec=false)
hud_message_box(QWidget *parent)
Definition hudwidget.cpp:74
void keyPressEvent(QKeyEvent *event)
QFontMetrics * fm_title
Definition hudwidget.h:74
QElapsedTimer m_timer
Definition hudwidget.h:101
QString text
Definition hudwidget.h:100
void timerEvent(QTimerEvent *event)
QFont f_text
Definition hudwidget.h:103
int timeout
Definition hudwidget.h:98
void center_me()
hud_text(QString s, int time_secs, QWidget *parent)
QRect bound_rect
Definition hudwidget.h:97
void show_me()
void paintEvent(QPaintEvent *event)
QFontMetrics * fm_text
Definition hudwidget.h:102
int m_animate_step
Definition hudwidget.h:99
void set_fading(float fade)
hud_unit_combat(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran, float scale, QWidget *parent)
struct unit * defender
Definition hudwidget.h:324
void leaveEvent(QEvent *event)
void mousePressEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *event)
void init_images(bool redraw=false)
struct unit * attacker
Definition hudwidget.h:323
const struct unit_type * type_attacker
Definition hudwidget.h:325
void set_scale(float scale)
struct tile * center_tile
Definition hudwidget.h:327
const struct unit_type * type_defender
Definition hudwidget.h:326
void enterEvent(QEnterEvent *event)
hud_unit_loader(struct unit *pcargo, struct tile *ptile)
struct tile * qtile
Definition hudwidget.h:241
struct unit * cargo
Definition hudwidget.h:240
void selection_changed(const QItemSelection &, const QItemSelection &)
QList< unit * > transports
Definition hudwidget.h:231
QLabel text_label
Definition hudwidget.h:210
void update_actions(unit_list *punits)
hud_units(QWidget *parent)
void moveEvent(QMoveEvent *event)
click_label unit_label
Definition hudwidget.h:208
click_label tile_label
Definition hudwidget.h:209
move_widget * mw
Definition hudwidget.h:221
QHBoxLayout * main_layout
Definition hudwidget.h:212
unit_actions * unit_icons
Definition hudwidget.h:213
void put_to_corner()
Definition mapview.cpp:401
void paintEvent(QPaintEvent *event)
void mousePressEvent(QMouseEvent *event)
QPixmap minus
Definition hudwidget.h:349
QPixmap plus
Definition hudwidget.h:348
scale_widget(Shape s, QWidget *p=0)
unit_actions(QWidget *parent, unit *punit)
void clear_layout()
QList< hud_action * > actions
Definition hudwidget.h:197
void init_layout()
unit * current_unit
Definition hudwidget.h:199
int update_actions()
QHBoxLayout * layout
Definition hudwidget.h:196
QRadioButton * this_continent
Definition hudwidget.h:282
QComboBox * unit_sel_type
Definition hudwidget.h:251
QRadioButton * sentried
Definition hudwidget.h:274
void keyPressEvent(QKeyEvent *event)
QVBoxLayout * main_layout
Definition hudwidget.h:250
QRadioButton * anywhere
Definition hudwidget.h:284
QRadioButton * main_continent
Definition hudwidget.h:283
QRadioButton * full_hp_mp
Definition hudwidget.h:279
QPushButton * cancel
Definition hudwidget.h:253
bool island_filter(struct unit *punit)
bool type_filter(struct unit *punit)
unit_hud_selector(QWidget *parent)
QRadioButton * full_mp
Definition hudwidget.h:277
void select_units(int x=0)
QRadioButton * fortified
Definition hudwidget.h:272
QRadioButton * this_tile
Definition hudwidget.h:281
QRadioButton * any_type
Definition hudwidget.h:287
QRadioButton * any_activity
Definition hudwidget.h:271
QPushButton * select
Definition hudwidget.h:252
QRadioButton * any
Definition hudwidget.h:276
bool activity_filter(struct unit *punit)
bool hp_filter(struct unit *punit)
QRadioButton * full_hp
Definition hudwidget.h:278
QRadioButton * this_type
Definition hudwidget.h:286
QRadioButton * idle
Definition hudwidget.h:273
bool client_is_observer(void)
struct civclient client
bool client_has_player(void)
#define client_player()
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2083
void unit_focus_add(struct unit *punit)
Definition control.c:562
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_center_focus_unit(void)
Definition control.c:2637
struct unit * head_of_units_in_focus(void)
Definition control.c:411
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
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 * punit
Definition dialogs_g.h:73
enum event_type event
Definition events.c:81
#define extra_road_get(_e_)
Definition extras.h:185
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
int Unit_type_id
Definition fc_types.h:352
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const char * population_to_text(int thousand_citizen)
Definition game.c:714
struct civ_game game
Definition game.c:57
struct world wld
Definition game.c:58
struct unit * game_unit_by_number(int id)
Definition game.c:111
int civ_population(const struct player *pplayer)
Definition game.c:69
bool goto_is_active(void)
Definition goto.c:1056
static PangoLayout * layout
Definition canvas.c:331
struct city * owner
Definition citydlg.c:219
static struct tile * pos
Definition finddlg.c:53
static QString popup_terrain_info(struct tile *ptile)
const char * calendar_text(void)
Definition calendar.c:141
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
bool goto_is_active(void)
Definition goto.c:1056
void show_new_turn_info()
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
struct view mapview
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:304
bool unit_can_load(const struct unit *punit)
Definition movement.c:841
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:813
#define SINGLE_MOVE
Definition movement.h:24
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const default_font
Definition fonts.h:27
const char *const notify_label
Definition fonts.h:28
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
const char * science_dialog_text(void)
Definition text.c:774
int player_get_expected_income(const struct player *pplayer)
Definition player.c:1262
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1179
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1313
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
struct research * research_get(const struct player *pplayer)
Definition research.c:126
bool can_build_road(const struct civ_map *nmap, struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Definition road.c:295
@ SC_PARADROP
Definition shortcuts.h:82
@ SC_UPGRADE_UNIT
Definition shortcuts.h:63
@ SC_BUILDIRRIGATION
Definition shortcuts.h:67
@ SC_BUILDCITY
Definition shortcuts.h:70
@ SC_DONE_MOVING
Definition shortcuts.h:57
@ SC_BUILDROAD
Definition shortcuts.h:69
@ SC_CULTIVATE
Definition shortcuts.h:68
@ SC_SENTRY
Definition shortcuts.h:71
@ SC_NUKE
Definition shortcuts.h:76
@ SC_SETHOME
Definition shortcuts.h:64
@ SC_PLANT
Definition shortcuts.h:66
@ SC_BUILDMINE
Definition shortcuts.h:65
@ SC_TRANSFORM
Definition shortcuts.h:75
@ SC_FORTIFY
Definition shortcuts.h:72
@ SC_GOTO
Definition shortcuts.h:73
@ SC_WAIT
Definition shortcuts.h:74
@ SC_DEBOARD
Definition shortcuts.h:78
@ SC_AUTOMATE
Definition shortcuts.h:81
@ SC_BOARD
Definition shortcuts.h:77
int step
Definition specpq.h:92
size_t size
Definition specvec.h:72
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:309
struct tile * tile
Definition city.h:311
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:20
struct player * playing
Definition connection.h:156
Definition mapimg.c:367
struct unit_list * units
Definition player.h:282
struct player_economic economic
Definition player.h:284
Tech_type_id researching
Definition research.h:52
struct research::@75::@77 client
int researching_cost
Definition research.h:98
int bulbs_researched
Definition research.h:53
int move_cost
Definition road.h:78
QPixmap * pm
Definition sprite.h:25
int defense_bonus
Definition terrain.h:193
int movement_cost
Definition terrain.h:192
Definition tile.h:49
bv_extras extras
Definition tile.h:54
struct unit_list * units
Definition tile.h:57
struct terrain * terrain
Definition tile.h:56
Continent_id continent
Definition tile.h:53
int move_rate
Definition unittype.h:497
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
int hp
Definition unit.h:151
int fuel
Definition unit.h:153
struct tile * tile
Definition unit.h:140
int homecity
Definition unit.h:146
const struct unit_type * utype
Definition unit.h:139
struct player * owner
Definition unit.h:143
int height
int width
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
#define A_UNKNOWN
Definition tech.h:49
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:496
const char * popup_info_text(struct tile *ptile)
Definition text.c:146
const char * get_tile_output_text(const struct tile *ptile)
Definition text.c:62
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Definition tile.c:829
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Definition tile.c:756
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:760
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:768
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6516
struct tileset * unscaled_tileset
Definition tilespec.c:545
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1767
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:444
bool unit_can_add_or_build_city(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:427
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2425
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:583
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:328
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:299
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:826
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1972
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2409
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:771
#define unit_tile(_pu)
Definition unit.h:395
@ UU_OK
Definition unit.h:61
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
#define utype_fuel(ptype)
Definition unittype.h:825
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848
#define show(id)
Definition widget.h:235
#define hide(id)
Definition widget.h:238