14 #include <QDialogButtonBox>
16 #include <QHeaderView>
19 #include <QRadioButton>
20 #include <QVBoxLayout>
69 setWindowFlag(Qt::FramelessWindowHint);
84 f_title.setCapitalization(QFont::SmallCaps);
106 if (
event->key() == Qt::Key_Escape) {
111 QWidget::keyPressEvent(
event);
123 if (s1.contains(
'\n')) {
125 i = s1.indexOf(
'\n');
127 cs2 = s1.right(s1.count() - i);
131 w = qMax(w2,
fm_title->horizontalAdvance(s2));
133 w = qMax(
fm_text->horizontalAdvance(s1),
140 new QSpacerItem(w, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
141 layout = (QGridLayout *) this->layout();
142 layout->addItem(spacer, layout->rowCount(), 0, 1, layout->columnCount());
144 new QSpacerItem(0, h, QSizePolicy::Expanding, QSizePolicy::Minimum);
145 layout->addItem(spacer, 0, 0, 1, layout->columnCount());
182 rfull = QRect(2, 2, width() - 4, height() - 4);
183 rx = QRect(2, 2, width() - 4,
top);
184 ry = QRect(2,
top, width() - 4, height() -
top - 4);
186 c1 = QColor(palette().color(QPalette::Highlight));
187 c2 = QColor(palette().color(QPalette::AlternateBase));
193 g = QLinearGradient(0, 0, width(), height());
198 p.fillRect(rx, QColor(palette().color(QPalette::Highlight)));
199 p.fillRect(ry, QColor(palette().color(QPalette::AlternateBase)));
200 p.fillRect(rfull, g);
202 p.drawText((width() -
fm_title->horizontalAdvance(
title)) / 2,
206 p.drawText((width() -
fm_text->horizontalAdvance(
text)) / 2,
209 p.drawText((width() -
fm_text->horizontalAdvance(
cs1)) / 2,
211 p.drawText((width() -
fm_text->horizontalAdvance(
cs2)) / 2,
222 : QWidget(parent), text(s)
228 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
231 f_text.setCapitalization(QFont::SmallCaps);
243 setAttribute(Qt::WA_TranslucentBackground);
244 setAttribute(Qt::WA_ShowWithoutActivating);
245 setAttribute(Qt::WA_TransparentForMouseEvents);
246 setFocusPolicy(Qt::NoFocus);
270 p = QPoint((parentWidget()->width() - w) / 2,
271 parentWidget()->height() / 20);
306 opacity =
static_cast<float>(
m_timer.elapsed()) / (
timeout * 300);
308 opacity =
static_cast<float>(5000 -
m_timer.elapsed()) / (
timeout * 200);
310 opacity = qMin(1.0f, opacity);
311 opacity = qMax(0.0f, opacity);
312 rfull = QRect(0, 0, width(), height());
313 c1 = QColor(Qt::white);
314 c2 = QColor(35, 35, 35, 175);
315 c1.setAlphaF(c1.alphaF() * opacity);
316 c2.setAlphaF(c2.alphaF() * opacity);
319 p.setPen(QColor(0, 0, 0, 0));
320 p.drawRoundedRect(rfull, height() / 6, height() / 6);
335 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
336 | Qt::FramelessWindowHint);
351 f_title.setCapitalization(QFont::SmallCaps);
374 const QString &def_input)
379 QDialogButtonBox *button_box;
382 button_box =
new QDialogButtonBox(
383 QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal,
this);
384 layout =
new QVBoxLayout;
385 if (s1.contains(
'\n')) {
387 i = s1.indexOf(
'\n');
389 cs2 = s1.right(s1.count() - i);
393 w = qMax(w2,
fm_title->horizontalAdvance(s2));
395 w = qMax(
fm_text->horizontalAdvance(s1),
403 new QSpacerItem(w, h, QSizePolicy::Expanding, QSizePolicy::Minimum);
404 layout->addItem(spacer);
406 layout->addWidget(button_box);
410 QObject::connect(button_box, &QDialogButtonBox::accepted,
this,
412 QObject::connect(button_box, &QDialogButtonBox::rejected,
this,
417 p = QPoint((parentWidget()->width() - w) / 2,
418 (parentWidget()->height() - h) / 2);
419 p = parentWidget()->mapToGlobal(p);
458 rx = QRect(2, 2, width() - 4,
top);
459 ry = QRect(2,
top, width() - 4, height() -
top - 4);
461 c1 = QColor(palette().color(QPalette::Highlight));
462 c2 = QColor(Qt::transparent);
463 c3 = QColor(palette().color(QPalette::Highlight)).lighter(145);
470 fstep =
static_cast<float>(
step) / 400;
471 g = QLinearGradient(0, 0, width(), height());
473 g.setColorAt(fstep, c3);
477 p.fillRect(rx, QColor(palette().color(QPalette::Highlight)));
478 p.fillRect(ry, QColor(palette().color(QPalette::AlternateBase)));
481 p.drawText((width() -
fm_title->horizontalAdvance(
title)) / 2,
485 p.drawText((width() -
fm_text->horizontalAdvance(
text)) / 2,
488 p.drawText((width() -
fm_text->horizontalAdvance(
cs1)) / 2,
490 p.drawText((width() -
fm_text->horizontalAdvance(
cs2)) / 2,
501 : QFrame(parent), ufont(nullptr), ul_units(nullptr),
502 current_tile(nullptr)
505 QVBoxLayout *unit_lab;
510 sp =
new QSpacerItem(50, 2);
511 vbox =
new QVBoxLayout;
512 unit_lab =
new QVBoxLayout;
513 unit_lab->setContentsMargins(6, 9, 0, 3);
519 vbox->addSpacerItem(sp);
527 vbox->setContentsMargins(0, 0, 0, 0);
530 setFocusPolicy(Qt::ClickFocus);
557 int expanded_unit_width;
564 QRect crop, bounding_rect;
567 QString fraction1, fraction2;
568 QString text_str, move_pt_text;
569 QPixmap *tile_pixmap;
570 QPixmap *unit_pixmap;
576 if (punit ==
nullptr) {
581 font.setCapitalization(QFont::AllUppercase);
583 setFixedHeight(parentWidget()->height() / 12);
584 text_label.setFixedHeight((height() * 2) / 10);
586 move(qRound(
queen()->mapview_wdg->width()
587 *
king()->qt_settings.unit_info_pos_fx),
588 qRound((
queen()->mapview_wdg->height()
589 *
king()->qt_settings.unit_info_pos_fy)));
590 unit_icons->setFixedHeight((height() * 8) / 10);
592 setUpdatesEnabled(
false);
596 if (punit->
name.isEmpty()) {
597 if (pcity ==
nullptr) {
599 text_str = QString(
_(
"%1 #%2"))
604 text_str = QString(
_(
"%1 #%2 (%3)"))
610 if (pcity ==
nullptr) {
612 text_str = QString(
_(
"%1 #%2 \"%3\""))
618 text_str = QString(
_(
"%1 #%2 \"%3\" (%4)"))
625 text_str = text_str +
" ";
629 mp +=
" " + QString(
_(
"(%1T)")).arg(punit->
fuel - 1);
632 mp = QString(
_(
"MP: ")) + mp;
633 text_str = text_str + mp +
" ";
634 text_str += QString(
_(
"HP:%1/%2"))
635 .arg(QString::number(punit->
hp),
637 num = unit_list_size(punit->
tile->
units);
638 snum = QString::number(unit_list_size(punit->
tile->
units) - 1);
643 + QString(
PL_(
" (Selected %1 unit)",
" (Selected %1 units)", n))
645 }
else if (num > 1) {
648 ut_bytes = snum.toLocal8Bit();
651 + QString(
PL_(
" +%1 unit",
" +%1 units", num - 1))
652 .arg(ut_bytes.data());
656 font.setPixelSize((
text_label.height() * 9) / 10);
658 fm =
new QFontMetrics(font);
659 text_label.setFixedWidth(fm->horizontalAdvance(text_str) + 20);
664 unit_pixmap->fill(Qt::transparent);
665 put_unit(punit, unit_pixmap, QPoint());
666 img = unit_pixmap->toImage();
668 cropped_img =
img.copy(crop);
669 img = cropped_img.scaledToHeight(height(), Qt::SmoothTransformation);
672 pix = QPixmap::fromImage(
img);
675 if (pix.width() < expanded_unit_width) {
676 pix2 = QPixmap(expanded_unit_width, pix.height());
677 pix2.fill(Qt::transparent);
679 p.drawPixmap(expanded_unit_width / 2 - pix.width() / 2, 0, pix);
685 if (move_pt_text.contains(
'/')) {
686 fraction2 = move_pt_text.right(1);
687 move_pt_text.remove(move_pt_text.count() - 2, 2);
688 fraction1 = move_pt_text.right(1);
689 move_pt_text.remove(move_pt_text.count() - 1, 1);
691 crop = QRect(5, 5, pix.width() - 5, pix.height() - 5);
692 font.setCapitalization(QFont::Capitalize);
693 font.setPointSize((pix.height() * 2) / 5);
697 p.drawText(crop, Qt::AlignLeft | Qt::AlignBottom, move_pt_text,
700 bounding_rect.adjust(bounding_rect.width(), 0, bounding_rect.width() * 2,
702 if (punit->
fuel > 1) {
705 font.setPointSize(pix.height() / 4);
709 p.drawText(bounding_rect, Qt::AlignCenter,
710 QStringLiteral(
"+") + QString::number(
fuel));
713 if (move_pt_text.isEmpty()) {
714 move_pt_text = QStringLiteral(
" ");
717 p.boundingRect(crop, Qt::AlignLeft | Qt::AlignBottom, move_pt_text);
718 font.setPointSize(pix.height() / 5);
719 fm =
new QFontMetrics(font);
720 font_width = (fm->horizontalAdvance(move_pt_text) * 3) / 5;
723 if (!fraction1.isNull()) {
724 int t = 2 * font.pointSize();
726 crop = QRect(bounding_rect.right() - font_width, bounding_rect.top(), t,
728 p.drawText(crop, Qt::AlignLeft | Qt::AlignBottom, fraction1);
729 crop = QRect(bounding_rect.right() - font_width,
730 (bounding_rect.bottom() + bounding_rect.top()) / 2, t,
732 p.drawText(crop, Qt::AlignLeft | Qt::AlignTop, fraction2);
733 crop = QRect(bounding_rect.right() - font_width,
734 (bounding_rect.bottom() + bounding_rect.top()) / 2 - t / 16,
736 p.fillRect(crop, Qt::white);
739 wwidth = 2 * 3 + pix.width();
748 tile_pixmap->fill(QColor(0, 0, 0, 0));
750 img = tile_pixmap->toImage();
752 cropped_img =
img.copy(crop);
753 img = cropped_img.scaledToHeight(height() - 5, Qt::SmoothTransformation);
754 pix = QPixmap::fromImage(
img);
758 wwidth = wwidth + pix.width();
766 setUpdatesEnabled(
true);
787 if (e->button() == Qt::LeftButton) {
806 : QWidget(parent), icon(icon), action_shortcut(shortcut)
809 setFocusPolicy(Qt::StrongFocus);
810 setMouseTracking(
true);
822 p.setRenderHint(QPainter::SmoothPixmapTransform);
824 p.fillRect(rect(), QColor(palette().color(QPalette::Highlight)));
826 icon.paint(&p, rect());
840 if (e->button() == Qt::RightButton) {
842 }
else if (e->button() == Qt::LeftButton) {
863 QWidget::leaveEvent(
event);
873 QWidget::enterEvent(
event);
895 layout =
new QHBoxLayout(
this);
897 layout->setContentsMargins(0, 0, 0, 0);
900 setFocusPolicy(Qt::ClickFocus);
917 QSizePolicy size_fixed_policy(QSizePolicy::MinimumExpanding,
918 QSizePolicy::Fixed, QSizePolicy::Frame);
919 setSizePolicy(size_fixed_policy);
943 setUpdatesEnabled(
false);
945 for (
auto *a : qAsConst(
actions)) {
1107 for (
auto *a : qAsConst(
actions)) {
1108 const auto shortcut =
1110 if (shortcut.is_valid()) {
1113 QString(
_(
"%1 (%2)")).arg(shortcut.str).arg(shortcut.to_string()));
1115 a->setToolTip(shortcut.str);
1118 a->setFixedHeight(height());
1119 a->setFixedWidth(height());
1123 setFixedWidth(
actions.count() * height());
1124 setUpdatesEnabled(
true);
1140 setUpdatesEnabled(
false);
1141 for (j = 0; j < i; j++) {
1143 layout->removeWidget(ui);
1149 setUpdatesEnabled(
true);
1158 setSelectionBehavior(QAbstractItemView::SelectRows);
1159 setEditTriggers(QAbstractItemView::NoEditTriggers);
1160 setSelectionMode(QAbstractItemView::SingleSelection);
1161 verticalHeader()->setVisible(
false);
1162 horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
1163 horizontalHeader()->setVisible(
false);
1164 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1165 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1167 connect(selectionModel(), &QItemSelectionModel::selectionChanged,
this,
1184 QTableWidgetItem *new_item;
1201 setColumnCount(max_size + 1);
1204 direction8_invalid());
1210 new_item =
new QTableWidgetItem(QIcon(*sprite), str);
1211 setItem(i, 0, new_item);
1217 new_item =
new QTableWidgetItem(QIcon(*sprite), QLatin1String(
""));
1218 setItem(i, j, new_item);
1226 new QTableWidgetItem(QIcon::fromTheme(
"dialog-cancel"),
_(
"Cancel"));
1229 w = verticalHeader()->width() + 4;
1230 for (i = 0; i < columnCount(); i++) {
1231 w += columnWidth(i);
1233 h = horizontalHeader()->height() + 4;
1234 for (i = 0; i < rowCount(); i++) {
1239 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
1240 | Qt::FramelessWindowHint);
1248 const QItemSelection &s2)
1250 auto curr_row = s1.indexes().at(0).row();
1251 if (curr_row >= 0 && curr_row <
transports.size()) {
1264 QString ret, t, move_text;
1265 bool has_road =
false;
1273 if (t != QLatin1String(
"")) {
1274 ret = ret + QString(
_(
"Infrastructure: %1\n")).arg(t);
1276 ret = ret + QString(
_(
"Defense bonus: %1%\n")).arg(terr->
defense_bonus);
1284 if (proad->
move_cost <= movement_cost) {
1294 ret = ret + QString(
_(
"Movement cost: %1")).arg(move_text);
1296 ret = ret + QString(
_(
"Movement cost: %1")).arg(movement_cost);
1309 QList<hud_text *> close_list;
1318 for (i = 0; i < close_list.size(); ++i) {
1319 close_list.at(i)->close();
1320 close_list.at(i)->deleteLater();
1323 s = QString(
_(
"Year: %1 (Turn: %2)"))
1329 + QString(
_(
"Population: %1"))
1348 + QString(
_(
"Gold: %1 (%2)"))
1359 int attacker_hp,
int defender_hp,
1360 bool make_att_veteran,
1361 bool make_def_veteran,
float scale,
1380 if (defender_hp <= 0) {
1395 QImage crdimg, acrimg, at, dt;
1402 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
1403 setFixedSize(2 * w, w);
1406 defender_pixmap.fill(Qt::transparent);
1414 dimg = defender_pixmap.toImage();
1416 crdimg =
dimg.copy(dr);
1417 dimg = crdimg.scaledToHeight(w, Qt::SmoothTransformation);
1419 if (
dimg.width() < w) {
1420 dt = QImage(w,
dimg.height(), QImage::Format_ARGB32_Premultiplied);
1421 dt.fill(Qt::transparent);
1423 p.drawImage(w / 2 -
dimg.width() / 2, 0,
dimg);
1427 dimg =
dimg.scaled(w, w, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1430 attacker_pixmap.fill(Qt::transparent);
1438 aimg = attacker_pixmap.toImage();
1440 acrimg =
aimg.copy(ar);
1441 aimg = acrimg.scaledToHeight(w, Qt::SmoothTransformation);
1443 if (
aimg.width() < w) {
1444 at = QImage(w,
dimg.height(), QImage::Format_ARGB32_Premultiplied);
1445 at.fill(Qt::transparent);
1447 p.drawImage(w / 2 -
aimg.width() / 2, 0,
aimg);
1451 aimg =
aimg.scaled(w, w, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1492 QString ahploss, dhploss;
1501 c1 = QColor(25, 125, 25, 175);
1502 c2 = QColor(125, 25, 25, 175);
1504 c1 = QColor(125, 25, 25, 175);
1505 c2 = QColor(25, 125, 25, 175);
1509 left = QRect(0, 0, w, w);
1510 right = QRect(w, 0, w, w);
1511 pen = QPen(QColor(palette().color(QPalette::AlternateBase)), 2.0);
1517 p.fillRect(left, QColor(palette().color(QPalette::Highlight)));
1518 p.fillRect(right, QColor(palette().color(QPalette::Highlight)));
1522 p.fillRect(left, c1);
1523 p.fillRect(right, c2);
1525 p.drawRect(1, 1, width() - 2, height() - 2);
1526 p.drawImage(left,
aimg);
1528 p.setPen(QColor(Qt::white));
1531 p.setPen(QColor(255, 215, 0, 255));
1532 p.drawText(right, Qt::AlignRight | Qt::AlignBottom | Qt::AlignAbsolute,
1534 p.setPen(QColor(Qt::white));
1538 p.setPen(QColor(255, 215, 0, 255));
1539 p.drawText(left, Qt::AlignRight | Qt::AlignBottom | Qt::AlignAbsolute,
1541 p.setPen(QColor(Qt::white));
1543 p.drawText(left, Qt::AlignHorizontal_Mask, ahploss);
1544 p.drawImage(right,
dimg);
1545 p.drawText(right, Qt::AlignHorizontal_Mask, dhploss);
1547 p.drawText(right, Qt::AlignBottom | Qt::AlignLeft | Qt::AlignAbsolute,
1551 p.drawText(left, Qt::AlignBottom | Qt::AlignLeft | Qt::AlignAbsolute,
1592 clw->setFixedSize(12, 12);
1594 setContentsMargins(4, 4, 0, 0);
1620 for (
auto *hudc : qAsConst(
lhuc)) {
1621 hudc->set_scale(
scale);
1623 hudc->set_fading(1.0);
1625 setFixedSize(2 * w + 15,
lhuc.count() * w + 15);
1654 while (
lhuc.count() > 5) {
1655 hudc =
lhuc.takeLast();
1658 for (
auto *hudc : qAsConst(
lhuc)) {
1662 setFixedSize(2 * w + 15,
lhuc.count() * w + 15);
1683 sw->move(width() -
sw->width() - 12, 0);
1707 for (
auto *hudc : qAsConst(
lhuc)) {
1708 if (hudc->get_focus()) {
1710 for (
auto *hupdate : qAsConst(
lhuc)) {
1711 hupdate->set_fading(1.0);
1715 hudc->set_fading((20000.0 -
m_timer.elapsed()) / 1000);
1718 if (
m_timer.elapsed() >= 20000) {
1728 for (
auto *hupdate : qAsConst(
lhuc)) {
1729 hupdate->set_fading(1.0);
const char * calendar_text()
Produce a statically allocated textual representation of the current calendar time.
QRect zealous_crop_rect(QImage &p)
Return rectangle containing pure image (crops transparency)
const char * city_name_get(const struct city *pcity)
Return the name of the city.
void mousePressEvent(QMouseEvent *e) override
Mouse event for click_label.
void mouse_clicked()
Centers on current unit.
click_label()
Custom label with extra mouse events.
QFont getFont(const QString &name, double zoom=1.0) const
Returns desired font.
static fcFont * instance()
Returns instance of fc_font.
static fcIcons * instance()
Returns instance of fc_icons.
fc_shortcut get_shortcut(shortcut_id id) const
Returns shortcut for given id.
static fc_shortcuts * sc()
Returns given instance.
void invoke(shortcut_id id, map_view *mapview)
Invokes the action for a shortcut.
~hud_action() override
Hud action destructor.
void leaveEvent(QEvent *event) override
Leave event for hud_action, used to get status of pixmap higlight.
hud_action(QWidget *parent, const QIcon &icon, shortcut_id shortcut)
Hud action constructor, used to show one action.
void mousePressEvent(QMouseEvent *e) override
Mouse press event for hud_action.
void paintEvent(QPaintEvent *event) override
Custom painting for hud_action.
void enterEvent(QEvent *event) override
Enter event for hud_action, used to get status of pixmap higlight.
void mouseMoveEvent(QMouseEvent *event) override
Mouse move event for hud_action, draw focus.
shortcut_id action_shortcut
void mouse_right_clicked()
Right click event for hud_action.
void mouse_clicked()
Left click event for hud_action.
void update_size()
Updates size when scale has changed.
void moveEvent(QMoveEvent *event) override
Move event, saves current position.
void timerEvent(QTimerEvent *event) override
Timer event.
void add_combat_info(hud_unit_combat *huc)
Adds combat information to battle log.
~hud_battle_log() override
Hud battle log destructor.
hud_battle_log(QWidget *parent)
Hud battle log contructor.
QVBoxLayout * main_layout
void paintEvent(QPaintEvent *event) override
Paint event for hud battle log.
QList< hud_unit_combat * > lhuc
void set_scale(float s)
Set scale.
void showEvent(QShowEvent *event) override
Show event, restart fading timer.
void set_text_title(const QString &s1, const QString &s2)
Sets text and title and shows message box.
hud_message_box(QWidget *parent)
Custom message box constructor.
void timerEvent(QTimerEvent *event) override
Timer event used to animate message box.
void keyPressEvent(QKeyEvent *event) override
Key press event for hud message box.
~hud_message_box() override
Custom message box destructor.
void paintEvent(QPaintEvent *event) override
Paint event for custom message box.
void paintEvent(QPaintEvent *event) override
Paint event for custom hud_text.
void timerEvent(QTimerEvent *event) override
Timer event, closes widget after timeout.
void center_me()
Moves to top center parent widget and sets size new size.
~hud_text() override
Destructor for hud text.
void show_me()
Shows hud text.
hud_text(const QString &s, int time_secs, QWidget *parent)
Hud text constructor takes text to display and time.
void set_fading(float fade)
Sets widget fading.
void mousePressEvent(QMouseEvent *e) override
Mouse press event, centers on highlighted 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)
Hud unit combat contructor, prepares images to show as result.
void paintEvent(QPaintEvent *event) override
Paint event for hud_unit combat.
void init_images(bool redraw=false)
Draws images of units to pixmaps for later use.
bool get_focus()
Returns true if widget has focus (used to prevent hiding parent)
const struct unit_type * type_attacker
void set_scale(float scale)
Sets scale for images.
struct tile * center_tile
void enterEvent(QEvent *event) override
Leave event for hud unit combat.
~hud_unit_combat() override
Hud unit combat destructor.
const struct unit_type * type_defender
void leaveEvent(QEvent *event) override
Leave event for hud unit combat.
hud_unit_loader(struct unit *pcargo, struct tile *ptile)
Constructor for widget allowing loading units on transports.
~hud_unit_loader() override
Destructor for units loader.
QList< unit * > transports
void selection_changed(const QItemSelection &, const QItemSelection &)
Selects given tranport and closes widget.
void show_me()
Shows unit loader, adds possible tranportsand units to table Calculates table size.
hud_units(QWidget *parent)
Constructor for hud_units (holds layout for whole uunits info)
~hud_units() override
Hud_units destructor.
void update_actions()
Update possible action for given units.
QHBoxLayout * main_layout
unit_actions * unit_icons
void moveEvent(QMoveEvent *event) override
Move Event for hud_units, used to save position.
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
unit_actions(QWidget *parent, unit *punit)
Units action contructor, holds possible hud_actions.
void clear_layout()
Cleans layout - run it before layout initialization.
QList< hud_action * > actions
void init_layout()
Initiazlizes layout ( layout needs to be changed after adding units )
~unit_actions() override
Destructor for unit_actions.
int update_actions()
Updates avaialable actions, returns actions count.
bool client_has_player()
Either controlling or observing.
struct player * client_player()
Either controlling or observing.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Send a request to the server that the cargo be loaded into the transporter.
void request_center_focus_unit()
Center to focus unit.
struct unit * head_of_units_in_focus()
Return head of focus units list.
class fc_client * king()
Return fc_client instance.
#define PL_(String1, String2, n)
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
const char * population_to_text(int thousand_citizen)
Return a prettily formatted string containing the population text.
int civ_population(const struct player *pplayer)
Count the # of thousand citizen in a civilisation.
bool goto_is_active()
Is goto state active?
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
bool unit_can_load(const struct unit *punit)
Return whether we can find a suitable transporter for given unit at current location.
bool can_unit_transport(const struct unit *transporter, const struct unit *transported)
Return true iff transporter has ability to transport transported.
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
const char *const default_font
const char *const notify_label
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
pageGame * queen()
Return game instandce.
int player_get_expected_income(const struct player *pplayer)
Return the expected net income of the player this turn.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
QString research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
bool can_build_road(struct road_type *proad, const struct unit *punit, const struct tile *ptile)
Tells if unit can build road on tile.
struct packet_game_info info
struct player_economic economic
struct research::@71::@73 client
const struct unit_type * utype
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
const char * get_infrastructure_text(bv_extras extras)
Return a (static) string with extra(s) name(s): eg: "Mine" eg: "Road/Farmland" This only includes "in...
const QString science_dialog_text()
Returns the text to display in the science dialog.
const QString popup_info_text(struct tile *ptile)
Text to popup on a middle-click in the mapview.
const QString get_tile_output_text(const struct tile *ptile)
Return a (static) string with a tile's food/prod/trade.
const char * tile_get_info_text(const struct tile *ptile, bool include_nuisances, int linebreaks)
Return a (static) string with tile name describing terrain and extras of some categories.
bool tile_has_road(const struct tile *ptile, const struct road_type *proad)
Returns TRUE if the given tile has a road of given type on it.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
int tileset_unit_width(const struct tileset *t)
Return the unit tile width of the current tileset.
int tileset_unit_height(const struct tileset *t)
Return the unit tile height of the current tileset.
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
const QPixmap * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing, const QColor &replace)
Return the sprite for the unit type (the base "unit" sprite).
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
int tileset_full_tile_width(const struct tileset *t)
Return the full tile width of the current tileset.
void top_bar_show_map()
Callback to show map.
int get_transporter_occupancy(const struct unit *ptrans)
Return how many units are in the transport.
enum unit_upgrade_result unit_upgrade_test(const struct unit *punit, bool is_free)
Tests if the unit could be updated.
bool can_unit_paradrop(const struct unit *punit)
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airb...
bool unit_can_add_or_build_city(const struct unit *punit)
Return TRUE iff this unit can add to a current city or build a new city at its current location.
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Return TRUE iff the unit can change homecity to the given city.
struct unit * unit_transport_get(const struct unit *pcargo)
Returns the transporter of the unit or nullptr if it is not transported.
bool can_unit_do_autosettlers(const struct unit *punit)
Return whether the unit can be put in auto-settler mode.
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
int get_transporter_capacity(const struct unit *punit)
Return the number of units the transporter can hold (or 0).
bool can_unit_do_activity(const struct unit *punit, enum unit_activity activity)
Return TRUE iff the unit can do the given untargeted activity at its current location.
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Return TRUE iff the given unit can be unloaded from its current transporter.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
#define utype_fuel(ptype)
void put_terrain(struct tile *ptile, QPixmap *pcanvas, const QPoint &canvas_loc)
Draw the given tile terrain onto the canvas store at the given location.
void put_unit(const struct unit *punit, QPixmap *pcanvas, const QPoint &canvas_loc)
Draw the given unit onto the canvas store at the given location.