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

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/************************************************************************/
60 bool has_player_unit_type(Unit_type_id utype)
61{
62 unit_list_iterate(client.conn.playing->units, punit) {
63 if (utype_number(punit->utype) == utype) {
64 return true;
65 }
66 } unit_list_iterate_end;
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);
79 f_text = *fc_font::instance()->get_font(fonts::default_font);
80 f_title = *fc_font::instance()->get_font(fonts::default_font);
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;
96 m_animate_step = 0;
97 hide();
98 mult = 1;
99}
100
101/************************************************************************/
104hud_message_box::~hud_message_box()
105{
106 delete fm_text;
107 delete fm_title;
108}
109
110/************************************************************************/
113 void hud_message_box::keyPressEvent(QKeyEvent *event)
114{
115 if (event->key() == Qt::Key_Escape) {
116 close();
117 destroy();
118 event->accept();
119 }
120 QWidget::keyPressEvent(event);
121}
122
123/************************************************************************/
126 int 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/************************************************************************/
176 void hud_message_box::timerEvent(QTimerEvent *event)
177{
178 m_animate_step = m_timer.elapsed() / 40;
179 update();
180}
181
182/************************************************************************/
185 void hud_message_box::paintEvent(QPaintEvent *event)
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);
249 f_text = *fc_font::instance()->get_font(fonts::default_font);
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/************************************************************************/
272 void hud_text::show_me()
273{
274 show();
275 center_me();
276}
277
278/************************************************************************/
281 void hud_text::center_me()
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/************************************************************************/
298hud_text::~hud_text()
299{
300 delete fm_text;
301}
302
303/************************************************************************/
306 void 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/************************************************************************/
319 void 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
361 f_text = *fc_font::instance()->get_font(fonts::default_font);
362 f_title = *fc_font::instance()->get_font(fonts::default_font);
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/************************************************************************/
386hud_input_box::~hud_input_box()
387{
388 delete fm_text;
389 delete fm_title;
390}
391
392/************************************************************************/
395 void 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/************************************************************************/
454 void hud_input_box::timerEvent(QTimerEvent *event)
455{
456 m_animate_step = m_timer.elapsed() / 40;
457 update();
458}
459
460
461/************************************************************************/
464 void hud_input_box::paintEvent(QPaintEvent *event)
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/************************************************************************/
559hud_units::~hud_units()
560{
561}
562
563/************************************************************************/
566 void hud_units::moveEvent(QMoveEvent *event)
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/************************************************************************/
577 void hud_units::update_actions(unit_list *punits)
578{
579 int num;
580 int wwidth;
581 int font_width;
582 int expanded_unit_width;
583 QFont font = *fc_font::instance()->get_font(fonts::notify_label);
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
601 punit = head_of_units_in_focus();
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;
623 tileset = unscaled_tileset;
624 }
625 text_str = QString(unit_name_translation(punit));
626 owner = punit->owner;
627 pcity = player_city_by_number(owner, punit->homecity);
628 if (pcity != NULL) {
629 text_str = QString(("%1(%2)"))
630 .arg(unit_name_translation(punit), city_name_get(pcity));
631 }
632 text_str = text_str + " ";
633 mp = QString(move_points_text(punit->moves_left, false));
634 if (utype_fuel(unit_type_get(punit))) {
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
672 unit_pixmap = qtg_canvas_create(tileset_unit_width(tileset),
673 tileset_unit_height(tileset));
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);
753 if (tileset_is_isometric(tileset)) {
754 tile_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
755 tileset_tile_height(tileset) * 2);
756 } else {
757 tile_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
758 tileset_tile_height(tileset));
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));
769 tile_label.setToolTip(popup_terrain_info(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/************************************************************************/
790click_label::click_label() : QLabel()
791{
792 connect(this, &click_label::left_clicked, this, &click_label::on_clicked);
793}
794
795/************************************************************************/
798 void click_label::mousePressEvent(QMouseEvent *e)
799{
800 if (e->button() == Qt::LeftButton) {
801 emit left_clicked();
802 }
803}
804
805/************************************************************************/
808 void click_label::on_clicked()
809{
810 gui()->game_tab_widget->setCurrentIndex(0);
811 request_center_focus_unit();
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/************************************************************************/
829 void hud_action::set_pixmap(QPixmap *p)
830{
831 action_pixmap = p;
832}
833
834/************************************************************************/
837 void hud_action::paintEvent(QPaintEvent *event)
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/************************************************************************/
862hud_action::~hud_action()
863{
864 if (action_pixmap) {
865 delete action_pixmap;
866 }
867}
868
869/************************************************************************/
872 void 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/************************************************************************/
884 void hud_action::mouseMoveEvent(QMouseEvent *event)
885{
886 focus = true;
887 update();
888}
889
890/************************************************************************/
893 void hud_action::leaveEvent(QEvent *event)
894{
895 focus = false;
896 update();
897 QWidget::leaveEvent(event);
898}
899
900/************************************************************************/
903#ifndef FC_QT5_MODE
904 void hud_action::enterEvent(QEnterEvent *event)
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/************************************************************************/
917 void hud_action::on_right_clicked()
918{
919}
920
921/************************************************************************/
924 void hud_action::on_clicked()
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);
937 current_unit = punit;
938 init_layout();
939 setFocusPolicy(Qt::ClickFocus);
940}
941
942/************************************************************************/
945unit_actions::~unit_actions()
946{
947 qDeleteAll(actions);
948 actions.clear();
949}
950
951/************************************************************************/
954 void unit_actions::init_layout()
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/************************************************************************/
967 int unit_actions::update_actions()
968{
969 hud_action *a;
970
971 current_unit = head_of_units_in_focus();
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
996 if (unit_can_add_or_build_city(current_unit)) {
997 a = new hud_action(this);
998 a->action_shortcut = SC_BUILDCITY;
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);
1006 a->action_shortcut = SC_BUILDMINE;
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);
1013 a->action_shortcut = SC_PLANT;
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);
1020 a->action_shortcut = SC_BUILDIRRIGATION;
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);
1027 a->action_shortcut = SC_CULTIVATE;
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);
1034 a->action_shortcut = SC_TRANSFORM;
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
1046 if (can_build_road(&(wld.map), proad, current_unit, unit_tile(current_unit))) {
1047 ok = true;
1048 }
1049 } extra_type_by_cause_iterate_end;
1050 if (ok) {
1051 a = new hud_action(this);
1052 a->action_shortcut = SC_BUILDROAD;
1053 a->set_pixmap(fc_icons::instance()->get_pixmap("buildroad"));
1054 actions.append(a);
1055 }
1056 }
1057 /* Goto */
1058 a = new hud_action(this);
1059 a->action_shortcut = SC_GOTO;
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);
1066 a->action_shortcut = SC_FORTIFY;
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);
1074 a->action_shortcut = SC_SENTRY;
1075 a->set_pixmap(fc_icons::instance()->get_pixmap("sentry"));
1076 actions.append(a);
1077 }
1078
1079 // Board
1080 if (unit_can_load(current_unit)) {
1081 a = new hud_action(this);
1082 a->action_shortcut = SC_BOARD;
1083 a->set_pixmap(fc_icons::instance()->get_pixmap("load"));
1084 actions.append(a);
1085 }
1086
1087 // Set homecity
1088 if (tile_city(unit_tile(current_unit))) {
1089 if (can_unit_change_homecity_to(current_unit,
1090 tile_city(unit_tile(current_unit)))) {
1091 a = new hud_action(this);
1092 a->action_shortcut = SC_SETHOME;
1093 a->set_pixmap(fc_icons::instance()->get_pixmap("set_homecity"));
1094 actions.append(a);
1095 }
1096 }
1097
1098 // Upgrade
1099 if (UU_OK == unit_upgrade_test(&(wld.map), current_unit, FALSE)) {
1100 a = new hud_action(this);
1101 a->action_shortcut = SC_UPGRADE_UNIT;
1102 a->set_pixmap(fc_icons::instance()->get_pixmap("upgrade"));
1103 actions.append(a);
1104 }
1105
1106 // Automate
1107 if (can_unit_do_autosettlers(current_unit)) {
1108 a = new hud_action(this);
1109 a->action_shortcut = SC_AUTOMATE;
1110 a->set_pixmap(fc_icons::instance()->get_pixmap("automate"));
1111 actions.append(a);
1112 }
1113
1114 // Paradrop
1115 if (can_unit_paradrop(&(wld.map), current_unit)) {
1116 a = new hud_action(this);
1117 a->action_shortcut = SC_PARADROP;
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);
1125 a->action_shortcut = SC_PARADROP;
1126 a->set_pixmap(fc_icons::instance()->get_pixmap("pollution"));
1127 actions.append(a);
1128 }
1129
1130 // Deboard
1131 if (unit_transported(current_unit)
1132 && can_unit_unload(current_unit, unit_transport_get(current_unit))
1133 && can_unit_exist_at_tile(&(wld.map), current_unit,
1134 unit_tile(current_unit))) {
1135 a = new hud_action(this);
1136 a->action_shortcut = SC_DEBOARD;
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);
1144 a->action_shortcut = SC_NUKE;
1145 a->set_pixmap(fc_icons::instance()->get_pixmap("nuke"));
1146 actions.append(a);
1147 }
1148
1149 /* Wait */
1150 a = new hud_action(this);
1151 a->action_shortcut = SC_WAIT;
1152 a->set_pixmap(fc_icons::instance()->get_pixmap("wait"));
1153 actions.append(a);
1154
1155 /* Done moving */
1156 a = new hud_action(this);
1157 a->action_shortcut = SC_DONE_MOVING;
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/************************************************************************/
1180 void unit_actions::clear_layout()
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/************************************************************************/
1225hud_unit_loader::~hud_unit_loader()
1226{
1227}
1228
1229/************************************************************************/
1233 void hud_unit_loader::show_me()
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 }
1248 } unit_list_iterate_end;
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++;
1270 } unit_list_iterate_end;
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/************************************************************************/
1291 void 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 }
1326 unit_type_iterate_end;
1327
1328 if (punit) {
1329 int i;
1330 i = unit_sel_type->findText(utype_name_translation(punit->utype));
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/************************************************************************/
1439 void unit_hud_selector::show_me()
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/************************************************************************/
1455unit_hud_selector::~unit_hud_selector()
1456{
1457}
1458
1459/************************************************************************/
1462 void unit_hud_selector::uhs_select()
1463{
1464 const struct player *pplayer;
1465
1466 pplayer = client_player();
1467
1468 unit_list_iterate(pplayer->units, punit) {
1469 if (activity_filter(punit) && hp_filter(punit)
1470 && island_filter(punit) && type_filter(punit)) {
1471 unit_focus_add(punit);
1472 }
1473 } unit_list_iterate_end;
1474 close();
1475}
1476
1477/************************************************************************/
1480 void unit_hud_selector::uhs_cancel()
1481{
1482 close();
1483}
1484
1485/************************************************************************/
1488 void unit_hud_selector::select_units(int x)
1489{
1490 int num = 0;
1491 const struct player *pplayer;
1492
1493 pplayer = client_player();
1494
1495 unit_list_iterate(pplayer->units, punit) {
1496 if (activity_filter(punit) && hp_filter(punit)
1497 && island_filter(punit) && type_filter(punit)) {
1498 num++;
1499 }
1500 } unit_list_iterate_end;
1501 result_label.setText(QString(PL_("%1 unit", "%1 units", num)).arg(num));
1502}
1503
1504/************************************************************************/
1507 void unit_hud_selector::select_units(bool x)
1508{
1509 select_units(0);
1510}
1511
1512/************************************************************************/
1515 void unit_hud_selector::keyPressEvent(QKeyEvent *event)
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/************************************************************************/
1531 bool unit_hud_selector::activity_filter(struct unit *punit)
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/************************************************************************/
1545 bool unit_hud_selector::hp_filter(struct unit *punit)
1546{
1547 if ((any->isChecked()
1548 || (full_mp->isChecked()
1549 && punit->moves_left >= punit->utype->move_rate)
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/************************************************************************/
1561 bool unit_hud_selector::island_filter(struct unit *punit)
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()
1573 && player_primary_capital(client_player())) {
1574 island = player_primary_capital(client_player())->tile->continent;
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/************************************************************************/
1594 bool unit_hud_selector::type_filter(struct unit *punit)
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);
1633 movement_cost = terr->movement_cost;
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 }
1645 } extra_type_by_cause_iterate_end;
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/************************************************************************/
1659 void show_new_turn_info()
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 }
1677 research = research_get(client_player());
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"))
1685 .arg(population_to_text(civ_population(client.conn.playing)));
1686 if (research->researching != A_UNKNOWN
1687 && research->researching != A_UNSET
1688 && research->researching != A_NONE) {
1689 s = s + "\n" + QString(research_advance_name_translation(research,
1690 research->researching)) +
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)"))
1701 .arg(client.conn.playing->economic.gold)
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);
1721 type_attacker = attacker->utype;
1722 type_defender = defender->utype;
1723 att_veteran = make_att_veteran;
1724 def_veteran = make_def_veteran;
1725 att_hp_loss = attacker->hp - att_hp;
1726 def_hp_loss = defender->hp - def_hp;
1727 if (defender_hp <= 0) {
1728 center_tile = attacker->tile;
1729 } else {
1730 center_tile = defender->tile;
1731 }
1732 init_images();
1733}
1734
1735/************************************************************************/
1738 void hud_unit_combat::init_images(bool redraw)
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),
1752 tileset_unit_height(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),
1776 tileset_unit_height(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/************************************************************************/
1805 void hud_unit_combat::set_scale(float scale)
1806{
1807 hud_scale = scale;
1808 init_images(true);
1809}
1810
1811/************************************************************************/
1814hud_unit_combat::~hud_unit_combat()
1815{
1816}
1817
1818/************************************************************************/
1821 void hud_unit_combat::set_fading(float fade)
1822{
1823 fading = fade;
1824 update();
1825}
1826
1827/************************************************************************/
1830 bool hud_unit_combat::get_focus()
1831{
1832 return focus;
1833}
1834
1835/************************************************************************/
1838 void hud_unit_combat::paintEvent(QPaintEvent *event)
1839{
1840 QPainter p;
1841 QRect left, right;
1842 QColor c1, c2;
1843 QPen pen;
1844 QFont f = *fc_font::instance()->get_font(fonts::default_font);
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/************************************************************************/
1905 void hud_unit_combat::mousePressEvent(QMouseEvent *e)
1906{
1907 center_tile_mapcanvas(center_tile);
1908}
1909
1910/************************************************************************/
1913 void hud_unit_combat::leaveEvent(QEvent *event)
1914{
1915 focus = false;
1916 update();
1917}
1918
1919/************************************************************************/
1922#ifndef FC_QT5_MODE
1923 void hud_unit_combat::enterEvent(QEnterEvent *event)
1924#else // FC_QT5_MODE
1925void hud_unit_combat::enterEvent(QEvent *event)
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/************************************************************************/
1956 void scale_widget::paintEvent(QPaintEvent *event)
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/************************************************************************/
1970 void scale_widget::mousePressEvent(QMouseEvent *event)
1971{
1972 if (event->button() == Qt::LeftButton) {
1973 if (event->localPos().x() <= size) {
1974 scale = scale / 1.2;
1975 } else {
1976 scale = scale * 1.2;
1977 }
1978 parentWidget()->update();
1979 }
1980}
1981
1982
1983/************************************************************************/
1986hud_battle_log::hud_battle_log(QWidget *parent) : QWidget(parent)
1987{
1988 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
1989 main_layout = new QVBoxLayout(this);
1990 mw = new move_widget(this);
1991 setContentsMargins(0, 0, 0, 0);
1992 main_layout->setContentsMargins(0, 0, 0, 0);
1993 sw = new scale_widget(QRubberBand::Rectangle, this);
1994 sw->show();
1995}
1996
1997/************************************************************************/
2000hud_battle_log::~hud_battle_log()
2001{
2002 delete sw;
2003 delete mw;
2004}
2005
2006/************************************************************************/
2009 void hud_battle_log::update_size()
2010{
2011 hud_unit_combat *hudc;
2012 int w = 3 * tileset_unit_height(tileset) / 2 * scale;
2013
2014 gui()->qt_settings.battlelog_scale = scale;
2015 delete layout();
2016 main_layout = new QVBoxLayout;
2017 foreach (hudc, lhuc) {
2018 hudc->set_scale(scale);
2019 main_layout->addWidget(hudc);
2020 hudc->set_fading(1.0);
2021 }
2022 setFixedSize(2 * w + 10, lhuc.count() * w + 10);
2023 setLayout(main_layout);
2024
2025 update();
2026 show();
2027 m_timer.restart();
2028 startTimer(50);
2029}
2030
2031/************************************************************************/
2034 void hud_battle_log::set_scale(float s)
2035{
2036 scale = s;
2037 sw->scale = s;
2038}
2039
2040/************************************************************************/
2043 void hud_battle_log::add_combat_info(hud_unit_combat *huc)
2044{
2045 hud_unit_combat *hudc;
2046 int w = 3 * tileset_unit_height(tileset) / 2 * scale;
2047
2048 delete layout();
2049 main_layout = new QVBoxLayout;
2050 lhuc.prepend(huc);
2051 while (lhuc.count() > 5) {
2052 hudc = lhuc.takeLast();
2053 delete hudc;
2054 }
2055 foreach (hudc, lhuc) {
2056 main_layout->addWidget(hudc);
2057 hudc->set_fading(1.0);
2058 }
2059 setFixedSize(2 * w + 10, lhuc.count() * w + 10);
2060 setLayout(main_layout);
2061
2062 update();
2063 show();
2064 m_timer.restart();
2065 startTimer(50);
2066}
2067
2068/************************************************************************/
2071 void hud_battle_log::paintEvent(QPaintEvent *event)
2072{
2073 if (scale != sw->scale) {
2074 scale = sw->scale;
2075 update_size();
2076 }
2077 mw->put_to_corner();
2078 sw->move(width() - sw->width(), 0);
2079}
2080
2081/************************************************************************/
2084 void hud_battle_log::moveEvent(QMoveEvent *event)
2085{
2086 QPoint p;
2087
2088 p = pos();
2089 gui()->qt_settings.battlelog_x = static_cast<float>(p.x()) / mapview.width;
2090 gui()->qt_settings.battlelog_y = static_cast<float>(p.y())
2091 / mapview.height;
2092 m_timer.restart();
2093}
2094
2095/************************************************************************/
2100 void hud_battle_log::te_inner()
2101{
2102 hud_unit_combat *hupdate;
2103
2104 foreach (hupdate, lhuc) {
2105 hupdate->set_fading(1.0);
2106 }
2107}
2108
2109/************************************************************************/
2112 void hud_battle_log::timerEvent(QTimerEvent *event)
2113{
2114 hud_unit_combat *hudc;
2115
2116 if (m_timer.elapsed() > 4000 && m_timer.elapsed() < 5000) {
2117 foreach (hudc, lhuc) {
2118 if (hudc->get_focus()) {
2119 m_timer.restart();
2120 te_inner();
2121 return;
2122 }
2123 hudc->set_fading((5000.0 - m_timer.elapsed()) / 1000);
2124 }
2125 }
2126 if (m_timer.elapsed() >= 5000) {
2127 hide();
2128 }
2129}
2130
2131/************************************************************************/
2134 void hud_battle_log::showEvent(QShowEvent *event)
2135{
2136 hud_unit_combat *hupdate;
2137
2138 foreach (hupdate, lhuc) {
2139 hupdate->set_fading(1.0);
2140 }
2141 m_timer.restart();
2142 setVisible(true);
2143}
str
#define str
Definition astring.c:76
n
#define n
Definition astring.c:77
zealous_crop_rect
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:399
qtg_canvas_free
void qtg_canvas_free(struct canvas *store)
Definition canvas.cpp:47
qtg_canvas_create
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:35
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1106
click_label::left_clicked
void left_clicked()
click_label::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Definition hudwidget.cpp:798
click_label::on_clicked
void on_clicked()
Definition hudwidget.cpp:808
click_label::click_label
click_label()
Definition hudwidget.cpp:790
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
hud_action
Definition hudwidget.h:157
hud_action::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:837
hud_action::leaveEvent
void leaveEvent(QEvent *event)
Definition hudwidget.cpp:893
hud_action::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Definition hudwidget.cpp:872
hud_action::on_clicked
void on_clicked()
Definition hudwidget.cpp:924
hud_action::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition hudwidget.cpp:884
hud_action::right_clicked
void right_clicked()
hud_action::focus
bool focus
Definition hudwidget.h:160
hud_action::action_pixmap
QPixmap * action_pixmap
Definition hudwidget.h:159
hud_action::hud_action
hud_action(QWidget *parent)
Definition hudwidget.cpp:817
hud_action::on_right_clicked
void on_right_clicked()
Definition hudwidget.cpp:917
hud_action::enterEvent
void enterEvent(QEnterEvent *event)
Definition hudwidget.cpp:904
hud_action::action_shortcut
shortcut_id action_shortcut
Definition hudwidget.h:165
hud_action::left_clicked
void left_clicked()
hud_action::~hud_action
~hud_action()
Definition hudwidget.cpp:862
hud_action::set_pixmap
void set_pixmap(QPixmap *p)
Definition hudwidget.cpp:829
hud_battle_log::update_size
void update_size()
Definition hudwidget.cpp:2009
hud_battle_log::mw
move_widget * mw
Definition hudwidget.h:377
hud_battle_log::lhuc
QList< hud_unit_combat * > lhuc
Definition hudwidget.h:360
hud_battle_log::m_timer
QElapsedTimer m_timer
Definition hudwidget.h:378
hud_battle_log::add_combat_info
void add_combat_info(hud_unit_combat *huc)
Definition hudwidget.cpp:2043
hud_battle_log::te_inner
void te_inner()
Definition hudwidget.cpp:2100
hud_battle_log::hud_battle_log
hud_battle_log(QWidget *parent)
Definition hudwidget.cpp:1986
hud_battle_log::main_layout
QVBoxLayout * main_layout
Definition hudwidget.h:359
hud_battle_log::~hud_battle_log
~hud_battle_log()
Definition hudwidget.cpp:2000
hud_battle_log::moveEvent
void moveEvent(QMoveEvent *event)
Definition hudwidget.cpp:2084
hud_battle_log::timerEvent
void timerEvent(QTimerEvent *event)
Definition hudwidget.cpp:2112
hud_battle_log::sw
scale_widget * sw
Definition hudwidget.h:376
hud_battle_log::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:2071
hud_battle_log::set_scale
void set_scale(float s)
Definition hudwidget.cpp:2034
hud_battle_log::showEvent
void showEvent(QShowEvent *event)
Definition hudwidget.cpp:2134
hud_battle_log::scale
float scale
Definition hudwidget.h:366
hud_input_box::top
int top
Definition hudwidget.h:133
hud_input_box::cs1
QString cs1
Definition hudwidget.h:131
hud_input_box::set_text_title_definput
void set_text_title_definput(QString s1, QString s2, QString def_input)
Definition hudwidget.cpp:395
hud_input_box::m_animate_step
int m_animate_step
Definition hudwidget.h:125
hud_input_box::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:464
hud_input_box::f_title
QFont f_title
Definition hudwidget.h:132
hud_input_box::m_timer
QElapsedTimer m_timer
Definition hudwidget.h:113
hud_input_box::cs2
QString cs2
Definition hudwidget.h:131
hud_input_box::timerEvent
void timerEvent(QTimerEvent *event)
Definition hudwidget.cpp:454
hud_input_box::~hud_input_box
~hud_input_box()
Definition hudwidget.cpp:386
hud_input_box::fm_text
QFontMetrics * fm_text
Definition hudwidget.h:128
hud_input_box::f_text
QFont f_text
Definition hudwidget.h:130
hud_input_box::hud_input_box
hud_input_box(QWidget *parent)
Definition hudwidget.cpp:354
hud_input_box::mult
int mult
Definition hudwidget.h:134
hud_input_box::input_edit
QLineEdit input_edit
Definition hudwidget.h:119
hud_input_box::fm_title
QFontMetrics * fm_title
Definition hudwidget.h:129
hud_input_box::text
QString text
Definition hudwidget.h:126
hud_input_box::title
QString title
Definition hudwidget.h:127
hud_message_box::mult
int mult
Definition hudwidget.h:79
hud_message_box::fm_text
QFontMetrics * fm_text
Definition hudwidget.h:73
hud_message_box::title
QString title
Definition hudwidget.h:72
hud_message_box::f_text
QFont f_text
Definition hudwidget.h:75
hud_message_box::text
QString text
Definition hudwidget.h:71
hud_message_box::m_timer
QElapsedTimer m_timer
Definition hudwidget.h:58
hud_message_box::cs1
QString cs1
Definition hudwidget.h:76
hud_message_box::top
int top
Definition hudwidget.h:78
hud_message_box::~hud_message_box
~hud_message_box()
Definition hudwidget.cpp:104
hud_message_box::timerEvent
void timerEvent(QTimerEvent *event)
Definition hudwidget.cpp:176
hud_message_box::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:185
hud_message_box::f_title
QFont f_title
Definition hudwidget.h:77
hud_message_box::set_text_title
int set_text_title(QString s1, QString s2, bool return_exec=false)
Definition hudwidget.cpp:126
hud_message_box::hud_message_box
hud_message_box(QWidget *parent)
Definition hudwidget.cpp:74
hud_message_box::m_animate_step
int m_animate_step
Definition hudwidget.h:70
hud_message_box::keyPressEvent
void keyPressEvent(QKeyEvent *event)
Definition hudwidget.cpp:113
hud_message_box::fm_title
QFontMetrics * fm_title
Definition hudwidget.h:74
hud_message_box::cs2
QString cs2
Definition hudwidget.h:76
hud_text
Definition hudwidget.h:86
hud_text::m_timer
QElapsedTimer m_timer
Definition hudwidget.h:101
hud_text::~hud_text
~hud_text()
Definition hudwidget.cpp:298
hud_text::text
QString text
Definition hudwidget.h:100
hud_text::timerEvent
void timerEvent(QTimerEvent *event)
Definition hudwidget.cpp:306
hud_text::f_text
QFont f_text
Definition hudwidget.h:103
hud_text::timeout
int timeout
Definition hudwidget.h:98
hud_text::center_me
void center_me()
Definition hudwidget.cpp:281
hud_text::hud_text
hud_text(QString s, int time_secs, QWidget *parent)
Definition hudwidget.cpp:240
hud_text::bound_rect
QRect bound_rect
Definition hudwidget.h:97
hud_text::show_me
void show_me()
Definition hudwidget.cpp:272
hud_text::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:319
hud_text::fm_text
QFontMetrics * fm_text
Definition hudwidget.h:102
hud_text::m_animate_step
int m_animate_step
Definition hudwidget.h:99
hud_unit_combat
Definition hudwidget.h:295
hud_unit_combat::att_hp_loss
int att_hp_loss
Definition hudwidget.h:319
hud_unit_combat::set_fading
void set_fading(float fade)
Definition hudwidget.cpp:1821
hud_unit_combat::hud_unit_combat
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)
Definition hudwidget.cpp:1710
hud_unit_combat::defender
struct unit * defender
Definition hudwidget.h:324
hud_unit_combat::leaveEvent
void leaveEvent(QEvent *event)
Definition hudwidget.cpp:1913
hud_unit_combat::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Definition hudwidget.cpp:1905
hud_unit_combat::aimg
QImage aimg
Definition hudwidget.h:331
hud_unit_combat::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:1838
hud_unit_combat::init_images
void init_images(bool redraw=false)
Definition hudwidget.cpp:1738
hud_unit_combat::attacker
struct unit * attacker
Definition hudwidget.h:323
hud_unit_combat::get_focus
bool get_focus()
Definition hudwidget.cpp:1830
hud_unit_combat::fading
float fading
Definition hudwidget.h:329
hud_unit_combat::type_attacker
const struct unit_type * type_attacker
Definition hudwidget.h:325
hud_unit_combat::def_hp
int def_hp
Definition hudwidget.h:318
hud_unit_combat::att_veteran
bool att_veteran
Definition hudwidget.h:321
hud_unit_combat::dimg
QImage dimg
Definition hudwidget.h:331
hud_unit_combat::def_veteran
bool def_veteran
Definition hudwidget.h:322
hud_unit_combat::set_scale
void set_scale(float scale)
Definition hudwidget.cpp:1805
hud_unit_combat::att_hp
int att_hp
Definition hudwidget.h:317
hud_unit_combat::center_tile
struct tile * center_tile
Definition hudwidget.h:327
hud_unit_combat::~hud_unit_combat
~hud_unit_combat()
Definition hudwidget.cpp:1814
hud_unit_combat::type_defender
const struct unit_type * type_defender
Definition hudwidget.h:326
hud_unit_combat::focus
bool focus
Definition hudwidget.h:328
hud_unit_combat::enterEvent
void enterEvent(QEnterEvent *event)
Definition hudwidget.cpp:1923
hud_unit_combat::hud_scale
float hud_scale
Definition hudwidget.h:330
hud_unit_combat::def_hp_loss
int def_hp_loss
Definition hudwidget.h:320
hud_unit_loader::~hud_unit_loader
~hud_unit_loader()
Definition hudwidget.cpp:1225
hud_unit_loader::hud_unit_loader
hud_unit_loader(struct unit *pcargo, struct tile *ptile)
Definition hudwidget.cpp:1201
hud_unit_loader::qtile
struct tile * qtile
Definition hudwidget.h:241
hud_unit_loader::cargo
struct unit * cargo
Definition hudwidget.h:240
hud_unit_loader::selection_changed
void selection_changed(const QItemSelection &, const QItemSelection &)
Definition hudwidget.cpp:1291
hud_unit_loader::transports
QList< unit * > transports
Definition hudwidget.h:231
hud_unit_loader::show_me
void show_me()
Definition hudwidget.cpp:1233
hud_units::text_label
QLabel text_label
Definition hudwidget.h:210
hud_units::update_actions
void update_actions(unit_list *punits)
Definition hudwidget.cpp:577
hud_units::hud_units
hud_units(QWidget *parent)
Definition hudwidget.cpp:524
hud_units::moveEvent
void moveEvent(QMoveEvent *event)
Definition hudwidget.cpp:566
hud_units::unit_label
click_label unit_label
Definition hudwidget.h:208
hud_units::~hud_units
~hud_units()
Definition hudwidget.cpp:559
hud_units::tile_label
click_label tile_label
Definition hudwidget.h:209
hud_units::mw
move_widget * mw
Definition hudwidget.h:221
hud_units::main_layout
QHBoxLayout * main_layout
Definition hudwidget.h:212
hud_units::unit_icons
unit_actions * unit_icons
Definition hudwidget.h:213
move_widget
Definition mapview.h:154
move_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:400
scale_widget
Definition hudwidget.h:338
scale_widget::paintEvent
void paintEvent(QPaintEvent *event)
Definition hudwidget.cpp:1956
scale_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition hudwidget.cpp:1970
scale_widget::minus
QPixmap minus
Definition hudwidget.h:349
scale_widget::plus
QPixmap plus
Definition hudwidget.h:348
scale_widget::scale_widget
scale_widget(Shape s, QWidget *p=0)
Definition hudwidget.cpp:1936
scale_widget::scale
float scale
Definition hudwidget.h:342
scale_widget::size
int size
Definition hudwidget.h:347
unit_actions
Definition hudwidget.h:188
unit_actions::unit_actions
unit_actions(QWidget *parent, unit *punit)
Definition hudwidget.cpp:932
unit_actions::clear_layout
void clear_layout()
Definition hudwidget.cpp:1180
unit_actions::actions
QList< hud_action * > actions
Definition hudwidget.h:197
unit_actions::init_layout
void init_layout()
Definition hudwidget.cpp:954
unit_actions::current_unit
unit * current_unit
Definition hudwidget.h:199
unit_actions::update_actions
int update_actions()
Definition hudwidget.cpp:967
unit_actions::~unit_actions
~unit_actions()
Definition hudwidget.cpp:945
unit_actions::layout
QHBoxLayout * layout
Definition hudwidget.h:196
unit_hud_selector::this_continent
QRadioButton * this_continent
Definition hudwidget.h:282
unit_hud_selector::unit_sel_type
QComboBox * unit_sel_type
Definition hudwidget.h:251
unit_hud_selector::sentried
QRadioButton * sentried
Definition hudwidget.h:274
unit_hud_selector::keyPressEvent
void keyPressEvent(QKeyEvent *event)
Definition hudwidget.cpp:1515
unit_hud_selector::main_layout
QVBoxLayout * main_layout
Definition hudwidget.h:250
unit_hud_selector::anywhere
QRadioButton * anywhere
Definition hudwidget.h:284
unit_hud_selector::main_continent
QRadioButton * main_continent
Definition hudwidget.h:283
unit_hud_selector::full_hp_mp
QRadioButton * full_hp_mp
Definition hudwidget.h:279
unit_hud_selector::cancel
QPushButton * cancel
Definition hudwidget.h:253
unit_hud_selector::island_filter
bool island_filter(struct unit *punit)
Definition hudwidget.cpp:1561
unit_hud_selector::result_label
QLabel result_label
Definition hudwidget.h:288
unit_hud_selector::type_filter
bool type_filter(struct unit *punit)
Definition hudwidget.cpp:1594
unit_hud_selector::unit_hud_selector
unit_hud_selector(QWidget *parent)
Definition hudwidget.cpp:1304
unit_hud_selector::uhs_select
void uhs_select()
Definition hudwidget.cpp:1462
unit_hud_selector::full_mp
QRadioButton * full_mp
Definition hudwidget.h:277
unit_hud_selector::select_units
void select_units(int x=0)
Definition hudwidget.cpp:1488
unit_hud_selector::fortified
QRadioButton * fortified
Definition hudwidget.h:272
unit_hud_selector::this_tile
QRadioButton * this_tile
Definition hudwidget.h:281
unit_hud_selector::any_type
QRadioButton * any_type
Definition hudwidget.h:287
unit_hud_selector::any_activity
QRadioButton * any_activity
Definition hudwidget.h:271
unit_hud_selector::~unit_hud_selector
~unit_hud_selector()
Definition hudwidget.cpp:1455
unit_hud_selector::select
QPushButton * select
Definition hudwidget.h:252
unit_hud_selector::any
QRadioButton * any
Definition hudwidget.h:276
unit_hud_selector::activity_filter
bool activity_filter(struct unit *punit)
Definition hudwidget.cpp:1531
unit_hud_selector::hp_filter
bool hp_filter(struct unit *punit)
Definition hudwidget.cpp:1545
unit_hud_selector::full_hp
QRadioButton * full_hp
Definition hudwidget.h:278
unit_hud_selector::this_type
QRadioButton * this_type
Definition hudwidget.h:286
unit_hud_selector::show_me
void show_me()
Definition hudwidget.cpp:1439
unit_hud_selector::uhs_cancel
void uhs_cancel()
Definition hudwidget.cpp:1480
unit_hud_selector::idle
QRadioButton * idle
Definition hudwidget.h:273
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
client
struct civclient client
Definition client_main.c:149
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
client_main.h
client_player
#define client_player()
Definition client_main.h:106
request_unit_load
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2054
unit_focus_add
void unit_focus_add(struct unit *punit)
Definition control.c:557
get_units_in_focus
struct unit_list * get_units_in_focus(void)
Definition control.c:177
request_center_focus_unit
void request_center_focus_unit(void)
Definition control.c:2608
head_of_units_in_focus
struct unit * head_of_units_in_focus(void)
Definition control.c:406
can_unit_do_activity_client
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
punit
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
event
enum event_type event
Definition events.c:81
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:185
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
fc_client.h
Unit_type_id
int Unit_type_id
Definition fc_types.h:352
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
fonts.h
population_to_text
const char * population_to_text(int thousand_citizen)
Definition game.c:714
game
struct civ_game game
Definition game.c:57
wld
struct world wld
Definition game.c:58
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:111
civ_population
int civ_population(const struct player *pplayer)
Definition game.c:69
goto_is_active
bool goto_is_active(void)
Definition goto.c:1056
layout
static PangoLayout * layout
Definition canvas.c:331
owner
struct city * owner
Definition citydlg.c:219
pos
static struct tile * pos
Definition finddlg.c:53
sprite.h
popup_terrain_info
static QString popup_terrain_info(struct tile *ptile)
Definition hudwidget.cpp:1617
calendar_text
const char * calendar_text(void)
Definition calendar.c:141
has_player_unit_type
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
goto_is_active
bool goto_is_active(void)
Definition goto.c:1056
show_new_turn_info
void show_new_turn_info()
Definition hudwidget.cpp:1659
hudwidget.h
has_player_unit_type
bool has_player_unit_type(Unit_type_id utype)
Definition hudwidget.cpp:60
put_terrain
void put_terrain(struct tile *ptile, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
Definition mapview_common.c:1420
mapview
struct view mapview
Definition mapview_common.c:74
put_unit
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
Definition mapview_common.c:1374
put_unittype
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
Definition mapview_common.c:1388
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
move_points_text
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
can_unit_exist_at_tile
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:304
unit_can_load
bool unit_can_load(const struct unit *punit)
Definition movement.c:841
can_unit_transport
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Definition movement.c:813
movement.h
SINGLE_MOVE
#define SINGLE_MOVE
Definition movement.h:24
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
fonts::default_font
const char *const default_font
Definition fonts.h:27
fonts::notify_label
const char *const notify_label
Definition fonts.h:28
nation_plural_for_player
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:774
player_get_expected_income
int player_get_expected_income(const struct player *pplayer)
Definition player.c:1262
player_city_by_number
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1179
player_primary_capital
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1313
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research.h
can_build_road
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
@ SC_PARADROP
Definition shortcuts.h:82
SC_UPGRADE_UNIT
@ SC_UPGRADE_UNIT
Definition shortcuts.h:63
SC_BUILDIRRIGATION
@ SC_BUILDIRRIGATION
Definition shortcuts.h:67
SC_BUILDCITY
@ SC_BUILDCITY
Definition shortcuts.h:70
SC_DONE_MOVING
@ SC_DONE_MOVING
Definition shortcuts.h:57
SC_BUILDROAD
@ SC_BUILDROAD
Definition shortcuts.h:69
SC_CULTIVATE
@ SC_CULTIVATE
Definition shortcuts.h:68
SC_SENTRY
@ SC_SENTRY
Definition shortcuts.h:71
SC_NUKE
@ SC_NUKE
Definition shortcuts.h:76
SC_SETHOME
@ SC_SETHOME
Definition shortcuts.h:64
SC_PLANT
@ SC_PLANT
Definition shortcuts.h:66
SC_BUILDMINE
@ SC_BUILDMINE
Definition shortcuts.h:65
SC_TRANSFORM
@ SC_TRANSFORM
Definition shortcuts.h:75
SC_FORTIFY
@ SC_FORTIFY
Definition shortcuts.h:72
SC_GOTO
@ SC_GOTO
Definition shortcuts.h:73
SC_WAIT
@ SC_WAIT
Definition shortcuts.h:74
SC_DEBOARD
@ SC_DEBOARD
Definition shortcuts.h:78
SC_AUTOMATE
@ SC_AUTOMATE
Definition shortcuts.h:81
SC_BOARD
@ SC_BOARD
Definition shortcuts.h:77
step
int step
Definition specpq.h:92
size
size_t size
Definition specvec.h:72
canvas
Definition canvas.h:21
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:309
city::tile
struct tile * tile
Definition city.h:311
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
color
Definition colors.h:20
connection::playing
struct player * playing
Definition connection.h:156
img
Definition mapimg.c:367
move
Definition widget_window.c:39
packet_game_info::turn
int turn
Definition packets_gen.h:241
player_economic::gold
int gold
Definition player.h:70
player
Definition player.h:249
player::units
struct unit_list * units
Definition player.h:282
player::economic
struct player_economic economic
Definition player.h:284
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
research::client
struct research::@75::@77 client
research::researching_cost
int researching_cost
Definition research.h:98
research::bulbs_researched
int bulbs_researched
Definition research.h:53
road_type
Definition road.h:75
road_type::move_cost
int move_cost
Definition road.h:78
sprite
Definition sprite.h:22
sprite::pm
QPixmap * pm
Definition sprite.h:25
terrain
Definition terrain.h:176
terrain::defense_bonus
int defense_bonus
Definition terrain.h:193
terrain::movement_cost
int movement_cost
Definition terrain.h:192
tile
Definition tile.h:49
tile::extras
bv_extras extras
Definition tile.h:54
tile::units
struct unit_list * units
Definition tile.h:57
tile::terrain
struct terrain * terrain
Definition tile.h:56
tile::continent
Continent_id continent
Definition tile.h:53
tileset
Definition tilespec.c:459
unit_type::move_rate
int move_rate
Definition unittype.h:497
unit_type::hp
int hp
Definition unittype.h:505
unit
Definition unit.h:138
unit::activity
enum unit_activity activity
Definition unit.h:157
unit::moves_left
int moves_left
Definition unit.h:150
unit::hp
int hp
Definition unit.h:151
unit::fuel
int fuel
Definition unit.h:153
unit::tile
struct tile * tile
Definition unit.h:140
unit::homecity
int homecity
Definition unit.h:146
unit::utype
const struct unit_type * utype
Definition unit.h:139
unit::owner
struct player * owner
Definition unit.h:143
view::height
int height
Definition mapview_common.h:38
view::width
int width
Definition mapview_common.h:38
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
A_NONE
#define A_NONE
Definition tech.h:43
A_UNSET
#define A_UNSET
Definition tech.h:48
A_UNKNOWN
#define A_UNKNOWN
Definition tech.h:49
get_infrastructure_text
const char * get_infrastructure_text(bv_extras extras)
Definition terrain.c:496
popup_info_text
const char * popup_info_text(struct tile *ptile)
Definition text.c:146
get_tile_output_text
const char * get_tile_output_text(const struct tile *ptile)
Definition text.c:62
text.h
tile_has_road
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Definition tile.c:829
tile_get_info_text
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Definition tile.c:756
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
tile.h
tileset_unit_width
int tileset_unit_width(const struct tileset *t)
Definition tilespec.c:760
tileset_unit_height
int tileset_unit_height(const struct tileset *t)
Definition tilespec.c:768
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6520
unscaled_tileset
struct tileset * unscaled_tileset
Definition tilespec.c:545
tileset_is_isometric
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:675
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
tileset_full_tile_width
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
get_transporter_occupancy
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1763
unit_can_add_or_build_city
bool unit_can_add_or_build_city(const struct unit *punit)
Definition unit.c:429
can_unit_change_homecity_to
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:445
unit_transport_get
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2421
can_unit_do_autosettlers
bool can_unit_do_autosettlers(const struct unit *punit)
Definition unit.c:579
unit_can_do_action
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:330
get_transporter_capacity
int get_transporter_capacity(const struct unit *punit)
Definition unit.c:301
can_unit_paradrop
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:823
unit_upgrade_test
enum unit_upgrade_result unit_upgrade_test(const struct civ_map *nmap, const struct unit *punit, bool is_free)
Definition unit.c:1968
unit_transported
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2405
can_unit_unload
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:767
unit.h
unit_tile
#define unit_tile(_pu)
Definition unit.h:388
UU_OK
@ UU_OK
Definition unit.h:61
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
unit_name_translation
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
utype_rule_name
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
utype_fuel
#define utype_fuel(ptype)
Definition unittype.h:822
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
show
#define show(id)
Definition widget.h:235
hide
#define hide(id)
Definition widget.h:238