13 #include <QApplication>
16 #include <QHeaderView>
17 #include <QMouseEvent>
20 #include <QScrollArea>
22 #include <QSpacerItem>
24 #include <QVBoxLayout>
25 #include <QWidgetAction>
64 extern QString
split_text(
const QString &text,
bool cut);
73 setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
75 setMovement(QListView::Static);
77 connect(
this, &QListWidget::itemDoubleClicked,
this,
87 return QSize(1, 5555);
91 for (
int i = 0; i < count(); ++i) {
92 hint = hint.expandedTo(sizeHintForIndex(indexFromItem(
item(i))));
94 hint.setWidth(hint.width() * count());
103 setUpdatesEnabled(
false);
107 for (
const auto *punit :
sorted(units)) {
108 auto *
item =
new QListWidgetItem();
110 item->setData(Qt::UserRole, punit->id);
113 icon_size = icon_size.expandedTo(pixmap.size());
114 item->setIcon(QIcon(pixmap));
118 setGridSize(icon_size);
119 setIconSize(icon_size);
121 setUpdatesEnabled(
true);
134 auto units = std::vector<unit *>();
135 for (
const auto item : selectedItems()) {
136 auto id =
item->data(Qt::UserRole).toInt();
139 units.push_back(
unit);
155 auto menu =
new QMenu;
156 menu->setAttribute(Qt::WA_DeleteOnClose);
158 menu->popup(
event->globalPos());
171 for (
const auto unit : selection) {
175 if (!selection.empty()) {
194 double isosize = 0.6;
199 auto unit_pixmap = QPixmap();
209 unit_pixmap.fill(Qt::transparent);
210 put_unit(punit, &unit_pixmap, QPoint());
215 punit->
upkeep, happy_cost);
219 auto img = unit_pixmap.toImage();
221 img =
img.copy(crop_rect);
224 return QPixmap::fromImage(
226 Qt::SmoothTransformation));
228 return QPixmap::fromImage(
img.scaledToHeight(
266 const QPixmap *sprite;
272 if (VUT_UTYPE == target->
kind) {
274 direction8_invalid());
279 if (sprite ==
nullptr) {
283 img = sprite->toImage();
285 cropped_img =
img.copy(crop);
286 tpix = QPixmap::fromImage(cropped_img);
287 pix =
new QPixmap(tpix.width(), tpix.height());
288 pix->fill(Qt::transparent);
297 const QPixmap *sprite =
nullptr;
302 if (sprite ==
nullptr) {
306 pix =
new QPixmap(sprite->width(), sprite->height());
307 pix->fill(Qt::transparent);
308 pixmap_copy(
pix, sprite, 0, 0, 0, 0, sprite->width(), sprite->height());
321 QLinearGradient g, gx;
327 int point_size =
sfont->pointSize();
328 int pixel_size =
sfont->pixelSize();
330 if (
pix !=
nullptr) {
331 pix_width = height() - 4;
333 if (point_size < 0) {
341 rx.setWidth(width());
342 rx.setHeight(height());
344 p.drawLine(rx.topLeft(), rx.topRight());
345 p.drawLine(rx.bottomLeft(), rx.bottomRight());
353 r = QRect(0, 0, width() * value() / max, height());
355 gx = QLinearGradient(0, 0, 0, height());
356 c = QColor(palette().color(QPalette::Highlight));
358 gx.setColorAt(0.5, QColor(40, 40, 40));
360 p.fillRect(r, QBrush(gx));
361 p.setClipRegion(
reg);
363 g = QLinearGradient(0, 0, width(), height());
368 p.fillRect(r, QBrush(g));
370 p.setClipping(
false);
371 r2 = QRect(width() * value() / max, 0, width(), height());
372 c = palette().color(QPalette::Window);
376 if (
pix !=
nullptr) {
377 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
379 2, 2, pix_width *
static_cast<float>(
pix->width()) /
pix->height(),
380 pix_width, *
pix, 0, 0,
pix->width(),
pix->height());
384 c = palette().color(QPalette::Text);
386 sfont->setCapitalization(QFont::AllUppercase);
387 sfont->setBold(
true);
390 if (text().contains(
'\n')) {
394 i = text().indexOf(
'\n');
396 s2 = text().right(text().count() - i);
398 if (2 * f_size >= 2 * height() / 3) {
399 if (point_size < 0) {
400 sfont->setPixelSize(height() / 4);
402 sfont->setPointSize(height() / 4);
406 j = height() - 2 * f_size;
408 QFontMetrics fm(*
sfont);
409 if (fm.horizontalAdvance(s1) > rx.width()) {
410 s1 = fm.elidedText(s1, Qt::ElideRight, rx.width());
413 i = rx.width() - fm.horizontalAdvance(s1) + pix_width;
415 p.drawText(i / 2, j / 3 + f_size, s1);
417 if (fm.horizontalAdvance(s2) > rx.width()) {
418 s2 = fm.elidedText(s2, Qt::ElideRight, rx.width());
421 i = rx.width() - fm.horizontalAdvance(s2) + pix_width;
424 p.drawText(i / 2, height() - j / 3, s2);
429 j = height() - f_size;
431 QFontMetrics fm(*
sfont);
432 if (fm.horizontalAdvance(s) > rx.width()) {
433 s = fm.elidedText(s, Qt::ElideRight, rx.width());
436 i = rx.width() - fm.horizontalAdvance(s) + pix_width;
438 p.drawText(i / 2, j / 2 + f_size, s);
449 QRect r(-50, 0, width() + 50, height());
450 int chunk_width = 16;
451 int size = width() + 50;
454 for (offset = 0; offset < (
size * 2); offset += (chunk_width * 2)) {
457 a.setPoints(4, r.x(), r.y() + offset, r.x() + r.width(),
458 (r.y() + offset) -
size, r.x() + r.width(),
459 (r.y() + offset + chunk_width) -
size, r.x(),
460 r.y() + offset + chunk_width);
470 QPen pen(QColor(0, 0, 0));
475 p.setRenderHint(QPainter::Antialiasing);
477 p.drawLine(0, 0, pix->width(), pix->height());
478 p.drawLine(pix->width(), 0, 0, pix->height());
497 QHBoxLayout *l =
new QHBoxLayout();
500 l->addWidget(&
labs[0]);
501 l->addWidget(&
labs[1]);
505 l->addWidget(&
labs[2]);
506 l->addWidget(&
labs[3]);
510 l->addWidget(&
labs[4]);
511 l->addWidget(&
labs[5]);
515 l->addWidget(&
labs[6]);
516 l->addWidget(&
labs[7]);
520 l->addWidget(&
labs[8]);
521 l->addWidget(&
labs[9]);
525 l->addWidget(&
labs[10]);
526 l->addWidget(&
labs[11]);
561 grow_time = QStringLiteral(
"∞");
563 labs[11].setText(grow_time);
602 int horizontal_spacing =
606 int citizen_x = (
event->x() - horizontal_spacing) / sprite_width;
607 int citizen_y =
event->y() / sprite_height;
613 if (citizen_index < 0 || citizen_index > num_citizens - 1) {
622 auto pix = this->pixmap(Qt::ReturnByValue);
641 QGridLayout *info_grid_layout =
new QGridLayout();
642 info_grid_layout->setHorizontalSpacing(6);
643 info_grid_layout->setVerticalSpacing(0);
644 info_grid_layout->setContentsMargins(0, 0, 0, 0);
645 info_grid_layout->setColumnStretch(1, 100);
646 setLayout(info_grid_layout);
653 const auto create_labels = [&](
const char *title) {
654 auto label =
new QLabel(title,
this);
655 label->setFont(small_font);
657 info_grid_layout->addWidget(label, info_grid_layout->rowCount(), 0);
659 auto value =
new QLabel(
this);
660 value->setFont(small_font);
662 info_grid_layout->addWidget(value, info_grid_layout->rowCount() - 1, 1);
663 return std::make_pair(label, value);
667 std::tie(dummy,
m_food) = create_labels(
_(
"<b>Food:</b>"));
668 std::tie(dummy,
m_granary) = create_labels(
_(
"Granary:"));
669 std::tie(dummy,
m_size) = create_labels(
_(
"Citizens:"));
670 std::tie(dummy,
m_growth) = create_labels(
_(
"Change in:"));
672 info_grid_layout->addItem(
new QSpacerItem(0, 9),
673 info_grid_layout->rowCount(), 0);
675 std::tie(dummy,
m_production) = create_labels(
_(
"<b>Production:</b>"));
676 std::tie(dummy,
m_waste) = create_labels(
_(
"Waste:"));
678 info_grid_layout->addItem(
new QSpacerItem(0, 9),
679 info_grid_layout->rowCount(), 0);
681 std::tie(dummy,
m_trade) = create_labels(
_(
"<b>Trade:</b>"));
682 std::tie(dummy,
m_corruption) = create_labels(
_(
"Corruption:"));
683 std::tie(dummy,
m_gold) = create_labels(
_(
"Gold:"));
684 std::tie(dummy,
m_science) = create_labels(
_(
"Science:"));
685 std::tie(dummy,
m_luxury) = create_labels(
_(
"Luxury:"));
687 info_grid_layout->addItem(
new QSpacerItem(0, 9),
688 info_grid_layout->rowCount(), 0);
690 std::tie(dummy,
m_culture) = create_labels(
_(
"Culture:"));
691 std::tie(dummy,
m_pollution) = create_labels(
_(
"Pollution:"));
693 std::tie(dummy,
m_stolen) = create_labels(
_(
"Tech Stolen:"));
694 std::tie(dummy,
m_airlift) = create_labels(
_(
"Airlift:"));
700 QString::asprintf(
"%3d (%s)", pcity->
size,
705 m_food->setText(QString::asprintf(
706 "<b style=\"white-space:pre;\">%3d (<b "
707 "style=\"color:red;\">%+4d</b>)</b>",
711 m_growth->setStyleSheet(
"QLabel { color:red; }");
713 m_food->setText(QString::asprintf(
714 "<b style=\"white-space:pre;\">%3d (%+4d)</b>",
718 m_growth->setStyleSheet(
"QLabel { white-space:pre; }");
723 QString::asprintf(
"<b style=\"white-space:pre\">%3d (<b "
724 "style=\"color:red;\">%+4d</b>)</b>",
730 QString::asprintf(
"<b style=\"white-space:pre\">%3d (%+4d)</b>",
738 QString::asprintf(
"<b style=\"white-space:pre\">%3d (<b "
739 "style=\"color:red;\">%+4d</b>)</b>",
745 QString::asprintf(
"<b style=\"white-space:pre\">%3d (%+4d)</b>",
752 m_gold->setText(QString::asprintf(
753 "<span style=\"white-space:pre\">%3d (<b "
754 "style=\"color:red;\">%+4d</b>)</span>",
758 m_gold->setText(QString::asprintf(
759 "<span style=\"white-space:pre\">%3d (%+4d)</span>",
766 QString::asprintf(
"<span style=\"white-space:pre\">%3d (<b "
767 "style=\"color:red;\">%+4d</b>)</span>",
772 m_luxury->setText(QString::asprintf(
773 "<span style=\"white-space:pre\">%3d (%+4d)</span>",
781 QString::asprintf(
"<span style=\"white-space:pre\">%3d (<b "
782 "style=\"color:red;\">%+4d</b>)</span>",
788 "<span style=\"white-space:pre\">%3d (%+4d)</span>",
795 QString::asprintf(
"%3d/%-4d", pcity->
food_stock,
813 QString::asprintf(
"%3.1f%%",
static_cast<float>(illness) / 10.0));
819 if (pcity->
steal > 0) {
820 m_stolen->setText(QString::asprintf(
836 QFont f = QApplication::font();
840 int h = 2 * fm.height() + 2;
845 for (
auto child : findChildren<QWidget *>()) {
846 child->setAttribute(Qt::WA_NoMousePropagation);
849 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
850 setMouseTracking(
true);
855 ui.lcity_name->setToolTip(
_(
"Click to change city name"));
856 ui.buy_button->setIcon(
859 connect(
ui.lcity_name, &QAbstractButton::clicked,
this,
864 ui.bclose->setToolTip(
_(
"Close city dialog"));
865 connect(
ui.bclose, &QAbstractButton::clicked,
this, &QWidget::hide);
866 ui.next_city_but->setIcon(
868 ui.next_city_but->setToolTip(
_(
"Show next city"));
869 connect(
ui.next_city_but, &QAbstractButton::clicked,
this,
871 connect(
ui.prev_city_but, &QAbstractButton::clicked,
this,
873 ui.prev_city_but->setIcon(
875 ui.prev_city_but->setToolTip(
_(
"Show previous city"));
876 ui.work_next_but->setIcon(
878 ui.work_prev_but->setIcon(
880 ui.work_add_but->setIcon(
882 ui.work_rem_but->setIcon(
883 style()->standardIcon(QStyle::SP_DialogDiscardButton));
884 ui.production_combo_p->setToolTip(
_(
"Click to change current production"));
885 ui.production_combo_p->setFixedHeight(h);
886 ui.p_table_p->setMinimumWidth(160);
887 ui.p_table_p->setContextMenuPolicy(Qt::CustomContextMenu);
888 header =
ui.p_table_p->horizontalHeader();
889 header->setStretchLastSection(
true);
890 connect(
ui.p_table_p, &QWidget::customContextMenuRequested,
this,
894 connect(
ui.work_add_but, &QAbstractButton::clicked,
this,
896 connect(
ui.work_prev_but, &QAbstractButton::clicked,
this,
898 connect(
ui.work_next_but, &QAbstractButton::clicked,
this,
900 connect(
ui.work_rem_but, &QAbstractButton::clicked,
this,
902 connect(
ui.p_table_p, &QTableWidget::itemDoubleClicked,
this,
904 connect(
ui.p_table_p->selectionModel(),
905 &QItemSelectionModel::selectionChanged,
this,
907 connect(
ui.present_units_exp_col_but, &QAbstractButton::clicked,
this,
911 ui.qgbox->setTitle(
_(
"Presets:"));
913 ui.cma_table->horizontalHeader()->setSectionResizeMode(
914 QHeaderView::Stretch);
916 connect(
ui.cma_table->selectionModel(),
917 &QItemSelectionModel::selectionChanged,
this,
919 connect(
ui.cma_table, &QWidget::customContextMenuRequested,
this,
921 connect(
ui.cma_table, &QTableWidget::cellDoubleClicked,
this,
924 ui.cma_enable_but->setFocusPolicy(Qt::TabFocus);
925 connect(
ui.cma_enable_but, &QAbstractButton::pressed,
this,
928 ui.bsavecma->setText(
_(
"Save"));
929 ui.bsavecma->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
930 connect(
ui.bsavecma, &QAbstractButton::pressed,
this,
933 ui.nationality_group->setTitle(
_(
"Nationality"));
934 ui.happiness_group->setTitle(
_(
"Happiness"));
935 ui.label1->setText(
_(
"Cities:"));
936 ui.label2->setText(
_(
"Luxuries:"));
937 ui.label3->setText(
_(
"Buildings:"));
938 ui.label4->setText(
_(
"Nationality:"));
939 ui.label5->setText(
_(
"Units:"));
940 ui.label6->setText(
_(
"Wonders:"));
941 ui.label1->setFont(small_font);
942 ui.label2->setFont(small_font);
943 ui.label4->setFont(small_font);
944 ui.label3->setFont(small_font);
945 ui.label5->setFont(small_font);
946 ui.label6->setFont(small_font);
953 for (
int x = 0; x < 6; x++) {
957 ui.tabs_right->setTabText(0,
_(
"General"));
958 ui.tabs_right->setTabText(1,
_(
"Citizens"));
959 ui.tabs_right->setTabText(2,
_(
"Governor"));
964 ui.present_units_list->set_oneliner(
true);
966 installEventFilter(
this);
976 int item, targets_used;
977 QList<cid> prod_list;
993 for (i = 0; i < prod_list.size(); i++) {
994 if (prod_list.at(i) == cprod) {
1002 if (pos == prod_list.size()) {
1006 pos = prod_list.size() - 1;
1017 const auto can_edit =
1019 ui.prev_city_but->setEnabled(can_edit);
1020 ui.next_city_but->setEnabled(can_edit);
1021 ui.buy_button->setEnabled(can_edit);
1022 ui.cma_enable_but->setEnabled(can_edit);
1023 ui.production_combo_p->setEnabled(can_edit);
1032 ui.work_next_but->setEnabled(
false);
1033 ui.work_prev_but->setEnabled(
false);
1034 ui.work_add_but->setEnabled(
false);
1035 ui.work_rem_but->setEnabled(
false);
1039 ui.work_add_but->setEnabled(
true);
1041 if (
selected_row_p >= 0 && selected_row_p < ui.p_table_p->rowCount()) {
1042 ui.work_rem_but->setEnabled(
true);
1046 && selected_row_p < ui.p_table_p->rowCount() - 1) {
1047 ui.work_next_but->setEnabled(
true);
1050 if (
selected_row_p > 0 && selected_row_p < ui.p_table_p->rowCount()) {
1051 ui.work_prev_but->setEnabled(
true);
1062 removeEventFilter(
this);
1070 if (
event->spontaneous()) {
1090 if (
event->spontaneous()) {
1108 if (
event->type() == QEvent::ShortcutOverride) {
1109 QKeyEvent *key_event =
static_cast<QKeyEvent *
>(
event);
1110 if (key_event->key() == Qt::Key_Up) {
1112 event->setAccepted(
true);
1115 if (key_event->key() == Qt::Key_Down) {
1117 event->setAccepted(
true);
1122 return QObject::eventFilter(obj,
event);
1131 const int city_id =
pcity->
id;
1140 ask->setAttribute(Qt::WA_DeleteOnClose);
1141 connect(ask, &hud_message_box::accepted,
this, [=]() {
1143 QByteArray ask_bytes;
1149 ask_bytes = ask->
input_edit.text().toLocal8Bit();
1163 _(
"Name new preset"),
_(
"new preset"));
1164 ask->setAttribute(Qt::WA_DeleteOnClose);
1165 connect(ask, &hud_message_box::accepted,
this, [=]() {
1167 if (!
name.isEmpty()) {
1168 const auto params = ui.governor->parameters();
1169 cmafec_preset_add(qUtf8Printable(name), ¶ms);
1195 const auto params =
ui.governor->parameters();
1222 const QItemSelection &ds)
1227 QModelIndexList indexes = sl.indexes();
1229 if (indexes.isEmpty() ||
ui.cma_table->signalsBlocked()) {
1233 index = indexes.at(0);
1234 int ind = index.row();
1259 QTableWidgetItem *
item;
1263 ui.cma_table->clear();
1264 ui.cma_table->setRowCount(0);
1267 item =
new QTableWidgetItem;
1269 ui.cma_table->insertRow(i);
1270 ui.cma_table->setItem(i, 0,
item);
1274 ui.cma_table->insertRow(0);
1275 item =
new QTableWidgetItem;
1276 item->setText(
_(
"No governor defined"));
1277 ui.cma_table->setItem(0, 0,
item);
1283 auto icon = style()->standardIcon(QStyle::SP_DialogApplyButton);
1284 ui.cma_result_pix->setPixmap(icon.pixmap(32));
1286 ui.cma_result->setText(QString(
_(
"<h3>Governor Enabled<br>(%1)</h3>"))
1287 .arg(s.toHtmlEscaped()));
1289 auto icon = style()->standardIcon(QStyle::SP_DialogCancelButton);
1290 ui.cma_result_pix->setPixmap(icon.pixmap(32));
1291 ui.cma_result->setText(QString(
_(
"<h3>Governor Disabled</h3>")));
1293 ui.cma_result->setAlignment(Qt::AlignCenter);
1299 if (i >= 0 && i < ui.cma_table->rowCount()) {
1300 ui.cma_table->blockSignals(
true);
1301 ui.cma_table->setCurrentCell(i, 0);
1302 ui.cma_table->blockSignals(
false);
1305 ui.cma_enable_but->setText(
_(
"Disable"));
1307 ui.cma_enable_but->setText(
_(
"Enable"));
1320 i =
ui.cma_table->currentRow();
1328 ask->setStandardButtons(QMessageBox::No | QMessageBox::Yes);
1329 ask->setDefaultButton(QMessageBox::No);
1330 ask->setAttribute(Qt::WA_DeleteOnClose);
1331 connect(ask, &hud_message_box::accepted,
this, [=]() {
1343 bv_city_options new_options;
1347 if (allow_disband) {
1348 BV_SET(new_options, CITYO_DISBAND);
1350 BV_CLR(new_options, CITYO_DISBAND);
1363 QMenu *cma_menu =
new QMenu(
this);
1364 QAction *cma_del_item;
1366 cma_menu->setAttribute(Qt::WA_DeleteOnClose);
1367 cma_del_item = cma_menu->addAction(
_(
"Remove Governor"));
1368 connect(cma_menu, &QMenu::triggered,
this, [=](QAction *act) {
1369 if (act == cma_del_item) {
1374 cma_menu->popup(QCursor::pos());
1382 QAction *
action, *disband, *wl_save, *wl_clear, *wl_empty,
1383 *submenu_buildings, *submenu_futures, *submenu_units, *submenu_wonders;
1389 QMenu *options_menu;
1395 list_menu =
new QMenu(
this);
1396 change_menu = list_menu->addMenu(
_(
"Change worklist"));
1397 insert_menu = list_menu->addMenu(
_(
"Insert worklist"));
1398 wl_clear = list_menu->addAction(
_(
"Clear"));
1408 if (list.count() == 0) {
1409 wl_empty = change_menu->addAction(
_(
"(no worklists defined)"));
1410 insert_menu->addAction(wl_empty);
1413 map_iter = list.constBegin();
1415 while (map_iter != list.constEnd()) {
1416 action = change_menu->addAction(map_iter.key());
1417 action->setData(map_iter.value());
1419 action = insert_menu->addAction(map_iter.key());
1420 action->setData(map_iter.value());
1425 wl_save = list_menu->addAction(
_(
"Save worklist"));
1427 options_menu = list_menu->addMenu(
_(
"Options"));
1428 submenu_units = options_menu->addAction(
_(
"Show units"));
1429 submenu_buildings = options_menu->addAction(
_(
"Show buildings"));
1430 submenu_wonders = options_menu->addAction(
_(
"Show wonders"));
1431 submenu_futures = options_menu->addAction(
_(
"Show future targets"));
1432 submenu_futures->setCheckable(
true);
1433 submenu_wonders->setCheckable(
true);
1434 submenu_buildings->setCheckable(
true);
1435 submenu_units->setCheckable(
true);
1437 connect(submenu_futures, &QAction::triggered,
this,
1440 connect(submenu_units, &QAction::triggered,
this,
1443 connect(submenu_buildings, &QAction::triggered,
this,
1446 connect(submenu_wonders, &QAction::triggered,
this,
1448 disband = options_menu->addAction(
_(
"Allow disbanding city"));
1449 disband->setCheckable(
true);
1451 connect(disband, &QAction::triggered,
this,
1454 connect(change_menu, &QMenu::triggered,
this, [=](QAction *act) {
1455 QVariant
id = act->data();
1468 connect(insert_menu, &QMenu::triggered,
this, [=](QAction *act) {
1469 QVariant
id = act->data();
1482 list_menu->popup(QCursor::pos());
1493 ui.buy_button->setEnabled(
false);
1497 str = QString(
PL_(
"Buy (%1 gold)",
"Buy (%1 gold)", value))
1498 .arg(QString::number(value));
1501 ui.buy_button->setEnabled(
true);
1504 str = QString(
_(
"Buy"));
1507 ui.buy_button->setText(str);
1520 QRect sprite_rectangle(0, 0, sprite_width, sprite_height);
1521 QRect painting_area(0, 0, sprite_width, sprite_height);
1523 pixmap->fill(Qt::transparent);
1524 for (
int i = 0; i < num_citizens; i++) {
1529 painter->drawPixmap(painting_area, *pix, sprite_rectangle);
1554 int canvas_height = sprite_height * num_rows;
1567 ui.citizens_label->set_city(
pcity);
1569 ui.citizens_label->updateGeometry();
1599 setUpdatesEnabled(
false);
1600 ui.production_combo_p->blockSignals(
true);
1617 ui.icon->set_city(-1);
1618 ui.upkeep->set_city(-1);
1621 ui.production_combo_p->blockSignals(
false);
1622 setUpdatesEnabled(
true);
1627 QSizePolicy::Expanding,
1628 QSizePolicy::Expanding);
1644 ui.governor->set_parameters(params);
1652 QFont f = QApplication::font();
1655 QStringList info_list;
1656 QTableWidgetItem *
item;
1662 h = fm.height() + 6;
1663 ui.nationality_table->clear();
1664 ui.nationality_table->setRowCount(0);
1666 info_list <<
_(
"#") <<
_(
"Flag") <<
_(
"Nation");
1667 ui.nationality_table->setHorizontalHeaderLabels(info_list);
1671 ui.nationality_table->insertRow(i);
1673 for (
int j = 0; j <
ui.nationality_table->columnCount(); j++) {
1674 item =
new QTableWidgetItem;
1680 if (nationality_i == 0) {
1681 str = QStringLiteral(
"-");
1683 fc_snprintf(buf,
sizeof(buf),
"%d", nationality_i);
1694 if (sprite !=
nullptr) {
1695 item->setData(Qt::DecorationRole, sprite->scaledToHeight(h));
1697 item->setText(QStringLiteral(
"FLAG MISSING"));
1709 ui.nationality_table->setItem(i, j,
item);
1714 ui.nationality_table->horizontalHeader()->setStretchLastSection(
false);
1715 ui.nationality_table->resizeColumnsToContents();
1716 ui.nationality_table->resizeRowsToContents();
1717 ui.nationality_table->horizontalHeader()->setStretchLastSection(
true);
1725 ui.info_wdg->update_labels(
pcity);
1726 ui.info_icon_label->setCity(
pcity);
1727 ui.info_icon_label->updateText();
1735 if (
pcity != qcity) {
1745 ui.production_combo_p->blockSignals(
true);
1747 ui.production_combo_p->blockSignals(
false);
1772 struct unit_list *units;
1783 n = unit_list_size(units);
1784 fc_snprintf(buf,
sizeof(buf),
_(
"Supported units: %d"), n);
1785 ui.supp_units->setText(QString(buf));
1796 ui.present_units_exp_col_but->setArrowType(Qt::DownArrow);
1798 ui.present_units_exp_col_but->setArrowType(Qt::UpArrow);
1801 n = unit_list_size(units);
1802 ui.present_units_list->setLayoutDirection(Qt::LeftToRight);
1803 ui.present_units_list->set_units(units);
1804 ui.present_units_list->setVisible(n >= 0);
1805 fc_snprintf(buf,
sizeof(buf),
_(
"Present units: %d"), n);
1806 ui.present_units_label->setText(QString(buf));
1815 ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
1816 QSizePolicy::Minimum);
1817 ui.present_units_exp_col_but->setArrowType(Qt::UpArrow);
1818 ui.present_units_exp_col_but->setToolTip(
1819 _(
"Click to expand the present units list"));
1822 ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
1823 QSizePolicy::Expanding);
1824 ui.present_units_exp_col_but->setArrowType(Qt::DownArrow);
1825 ui.present_units_exp_col_but->setToolTip(
1826 _(
"Click to collapse the present units list"));
1835 const QItemSelection &ds)
1839 QModelIndexList indexes = sl.indexes();
1841 if (indexes.isEmpty()) {
1845 index = indexes.at(0);
1853 struct city *other_pcity =
nullptr;
1865 for (i = 0; i <
size; i++) {
1871 for (j = 1; j <
size; j++) {
1872 int k = next ? j : -j;
1900 ui.production_combo_p->setRange(0, cost);
1903 ui.production_combo_p->setValue(cost);
1907 ui.production_combo_p->setAlignment(Qt::AlignCenter);
1909 str = str.simplified();
1911 ui.production_combo_p->setFormat(
1912 QStringLiteral(
"(%p%) %2\n%1")
1915 ui.production_combo_p->updateGeometry();
1923 char buf[1024], buf2[1024];
1935 PL_(
"Treasury contains %d gold.",
"Treasury contains %d gold.",
1939 PL_(
"Buy %s for %d gold?",
"Buy %s for %d gold?", value),
name,
1942 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Yes);
1943 ask->setDefaultButton(QMessageBox::Cancel);
1944 ask->button(QMessageBox::Yes)->setText(
_(
"Yes Buy"));
1945 ask->setAttribute(Qt::WA_DeleteOnClose);
1946 connect(ask, &hud_message_box::accepted,
this, [=]() {
1963 QFont f = QApplication::font();
1965 QString str, tooltip;
1966 QTableWidgetItem *qitem;
1967 const QPixmap *sprite =
nullptr;
1968 int h, cost,
item, targets_used, col, upkeep;
1976 h = fm.height() + 6;
1992 tooltip = QLatin1String(
"");
1994 if (VUT_UTYPE == target.
kind) {
1999 direction8_invalid());
2000 }
else if (target.
kind == VUT_IMPROVEMENT) {
2013 for (col = 0; col < 3; col++) {
2014 qitem =
new QTableWidgetItem();
2015 qitem->setToolTip(tooltip);
2020 qitem->setData(Qt::DecorationRole, sprite->scaledToHeight(h));
2025 if (str.contains(
'[') && str.contains(
']')) {
2028 ii = str.lastIndexOf(
'[');
2029 ij = str.lastIndexOf(
']');
2031 str = str.remove(ii, ij - ii + 1);
2034 qitem->setText(str);
2038 qitem->setTextAlignment(Qt::AlignRight);
2039 qitem->setText(QString::number(cost));
2042 ui.p_table_p->setItem(i, col, qitem);
2046 ui.p_table_p->horizontalHeader()->setStretchLastSection(
false);
2047 ui.p_table_p->resizeColumnsToContents();
2048 ui.p_table_p->resizeRowsToContents();
2049 ui.p_table_p->horizontalHeader()->setStretchLastSection(
true);
2051 ui.upkeep->refresh();
2053 ui.curr_impr->setText(QString(
_(
"Improvements: upkeep %1")).arg(upkeep));
2108 if (selected_row_p < 1 || selected_row_p >=
ui.p_table_p->rowCount()) {
2119 ui.p_table_p->setCurrentIndex(index);
2128 QTableWidgetItem *
item;
2130 if (selected_row_p < 0 || selected_row_p >=
ui.p_table_p->rowCount()) {
2148 if (selected_row_p < 0 || selected_row_p >=
ui.p_table_p->rowCount() - 1) {
2159 ui.p_table_p->setCurrentIndex(index);
2172 _(
"Save current worklist"),
2174 ask->setAttribute(Qt::WA_DeleteOnClose);
2175 connect(ask, &hud_message_box::accepted, [=]() {
2178 QByteArray ask_bytes;
2182 ask_bytes = ask->
input_edit.text().toLocal8Bit();
2183 text = ask_bytes.data();
2184 if (!text.isEmpty()) {
2185 ask_bytes = text.toLocal8Bit();
2214 ui.lcity_name->setText(
2216 .replace(QLatin1String(
"&"), QLatin1String(
"&&")));
2220 buf = QString(
_(
"%1 - %2 citizens - DISORDER"))
2225 buf = QString(
_(
"%1 - %2 citizens - celebrating"))
2230 buf = QString(
_(
"%1 - %2 citizens - happy"))
2235 buf = QString(
_(
"%1 - %2 citizens"))
2240 setWindowTitle(buf);
2250 if (!
queen()->city_overlay->isVisible()) {
2256 widget->setup_ui(pcity);
2258 widget->resize(
queen()->mapview_wdg->size());
2292 for (
auto i : qAsConst(l)) {
2306 struct city *pcity_sup, *pcity_pre;
2318 if (!
queen()->city_overlay->isVisible()) {
2350 : QItemDelegate(parent), pd(sh)
2360 const QStyleOptionViewItem &
option,
2361 const QModelIndex &index)
const
2369 const QPixmap *sprite;
2370 QPixmap *free_sprite =
nullptr;
2371 bool useless =
false;
2372 bool is_coinage =
false;
2373 bool is_neutral =
false;
2374 bool is_sea =
false;
2375 bool is_flying =
false;
2376 bool is_unit =
true;
2377 QPixmap pix_dec(
option.rect.width(),
option.rect.height());
2378 QStyleOptionViewItem opt;
2379 QIcon icon = qApp->style()->standardIcon(QStyle::SP_DialogCancelButton);
2382 if (!
option.rect.isValid()) {
2386 qvar = index.data();
2388 if (!qvar.isValid()) {
2392 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
2394 if (target ==
nullptr) {
2395 free_sprite =
new QPixmap;
2396 *free_sprite = icon.pixmap(100, 100);
2397 sprite = free_sprite;
2400 }
else if (VUT_UTYPE == target->
kind) {
2428 direction8_invalid());
2437 if (sprite !=
nullptr) {
2439 sprite->scaledToHeight(
item_height - 2, Qt::SmoothTransformation);
2446 opt = QItemDelegate::setOptions(index,
option);
2448 opt.displayAlignment = Qt::AlignLeft;
2449 opt.textElideMode = Qt::ElideMiddle;
2450 QItemDelegate::drawBackground(painter, opt, index);
2452 rect1.setWidth(pix_scaled.width() + 4);
2454 rect2.setLeft(
option.rect.left() + rect1.width());
2455 rect2.setTop(rect2.top()
2456 + (rect2.height() - painter->fontMetrics().height()) / 2);
2457 QItemDelegate::drawDisplay(painter, opt, rect2,
name);
2461 pix_dec.fill(QColor(0, 0, 255, 80));
2462 }
else if (is_flying) {
2463 pix_dec.fill(QColor(220, 0, 0, 80));
2464 }
else if (is_neutral) {
2465 pix_dec.fill(QColor(0, 120, 0, 40));
2467 pix_dec.fill(QColor(0, 0, 150, 40));
2470 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix_dec);
2474 pix_dec.fill(QColor(255, 255, 0, 70));
2475 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix_dec);
2478 if (!pix_scaled.isNull()) {
2479 QItemDelegate::drawDecoration(painter, opt, rect1, pix_scaled);
2491 const QStyleOptionViewItem &
option,
2492 const QRect &rect)
const
2494 QPixmap pix(
option.rect.width(),
option.rect.height());
2496 if ((
option.state & QStyle::State_MouseOver) == 0 || !rect.isValid()) {
2500 pix.fill(QColor(50, 50, 50, 50));
2501 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix);
2508 const QModelIndex &index)
const
2515 s.setHeight(
pd.y());
2543 return QVariant::fromValue((
void *)
target);
2550 bool su,
bool sw,
bool sb,
2552 : QAbstractListModel(parent)
2577 if (!index.isValid()) {
2581 if (index.row() >= 0 && index.row() <
rowCount() && index.column() >= 0
2584 int r, c, t, new_index;
2588 new_index = t / 3 +
rowCount() * c;
2591 new_index = t / 3 +
rowCount() * c - 1;
2593 if (role == Qt::ToolTipRole) {
2612 int item, targets_used;
2617 sh.setY(fm.height() * 2);
2632 if (VUT_UTYPE == renegade->
kind) {
2634 sh.setX(qMax(
sh.x(), fm.horizontalAdvance(str)));
2642 sh.setX(qMax(
sh.x(), fm.horizontalAdvance(str)));
2659 sh.setX(2 *
sh.y() +
sh.x());
2660 sh.setX(qMin(
sh.x(), 250));
2672 bool future,
int when,
int curr,
2673 bool show_units,
bool buy,
2674 bool show_wonders,
bool show_buildings)
2679 auto temp = QGuiApplication::screens();
2680 int desk_width = temp[0]->availableGeometry().width();
2681 int desk_height = temp[0]->availableGeometry().height();
2683 setAttribute(Qt::WA_DeleteOnClose);
2684 setWindowFlags(Qt::Popup);
2685 verticalHeader()->setVisible(
false);
2686 horizontalHeader()->setVisible(
false);
2687 setProperty(
"showGrid",
false);
2693 show_wonders, show_buildings,
this);
2696 setItemDelegate(
c_p_d);
2698 viewport()->installEventFilter(
fc_tt);
2699 installEventFilter(
this);
2700 connect(selectionModel(), &QItemSelectionModel::selectionChanged,
this,
2702 resizeRowsToContents();
2703 resizeColumnsToContents();
2704 setFixedWidth(3 * sh.x() + 6);
2707 if (width() > desk_width) {
2708 setFixedWidth(desk_width);
2709 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
2711 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2714 if (height() > desk_height) {
2715 setFixedHeight(desk_height);
2716 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
2718 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2721 pos = QCursor::pos();
2723 if (pos.x() + width() > desk_width) {
2724 pos.setX(desk_width - width());
2725 }
else if (pos.x() - width() < 0) {
2729 if (pos.y() + height() > desk_height) {
2730 pos.setY(desk_height - height());
2731 }
else if (pos.y() - height() < 0) {
2736 setMouseTracking(
true);
2745 if (
event->button() == Qt::RightButton) {
2750 QAbstractItemView::mousePressEvent(
event);
2765 if (ev->type() == QEvent::MouseButtonPress) {
2766 pw_rect.setTopLeft(pos());
2767 br.setX(pos().x() + width());
2768 br.setY(pos().y() + height());
2769 pw_rect.setBottomRight(br);
2771 if (!pw_rect.contains(QCursor::pos())) {
2775 }
else if (ev->type() == QEvent::KeyRelease) {
2776 auto key_event =
dynamic_cast<QKeyEvent *
>(ev);
2777 if (key_event && key_event->key() == Qt::Key_Escape) {
2790 const QItemSelection &ds)
2794 QModelIndexList indexes = selectionModel()->selectedIndexes();
2803 index = indexes.at(0);
2804 qvar = index.data(Qt::UserRole);
2805 if (!qvar.isValid()) {
2808 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
2809 if (target !=
nullptr) {
2868 viewport()->removeEventFilter(
fc_tt);
2869 removeEventFilter(
this);
QRect zealous_crop_rect(QImage &p)
Return rectangle containing pure image (crops transparency)
void pixmap_copy(QPixmap *dest, const QPixmap *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
/ \ *********** / _ \ | / \ | Copyright (c) 1996-2023 Freeciv21 and || || _______ Freeciv contributor...
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
#define citizens_iterate_end
#define citizens_iterate(_pcity, _pslot, _nationality)
int city_production_build_shield_cost(const struct city *pcity)
Return the number of shields it takes to build current city production.
int city_granary_size(int city_size)
Generalized formula used to calculate granary size.
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Returns whether city can immediately build given target, unit or improvement.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Return the upkeep (gold) needed each turn to upkeep the given improvement in the given city.
bool is_city_option_set(const struct city *pcity, enum city_options option)
Returns TRUE iff the city has set the given option.
int city_population(const struct city *pcity)
Returns how many thousand citizen live in this city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
bool city_celebrating(const struct city *pcity)
cities celebrate only after consecutive happy turns
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Return the extended name of the building.
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Calculate city's illness in tenth of percent:
int city_unit_unhappiness(const unit *punit, int *free_unhappy)
Query unhappiness caused by a given unit.
bool city_happy(const struct city *pcity)
Return TRUE iff the city is happy.
int city_turns_to_grow(const struct city *pcity)
Calculates the turns which are needed for the city to grow.
citizens city_size_get(const struct city *pcity)
Get the city size.
const char * city_production_name_translation(const struct city *pcity)
Return the extended name of the current production.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void real_city_dialog_popup(struct city *pcity)
Pop up (or bring to the front) a dialog for the given city.
QString cut_helptext(const QString &text)
Remove some text from given text(help text) to show as tooltip.
struct city * is_any_city_dialog_open()
bool city_dialog_is_open(struct city *pcity)
Return whether the dialog for the given city is open.
void real_city_dialog_refresh(struct city *pcity)
Refresh (update) all data for the given city's dialog.
void city_font_update()
Updates city font.
void refresh_unit_city_dialogs(struct unit *punit)
Update city dialogs when the given unit's status changes.
QString split_text(const QString &text, bool cut)
Splits long text to 80 characters.
void popdown_city_dialog()
Closes the city overlay.
static void pixmap_put_x(QPixmap *pix)
Draws X on pixmap pointing its useless.
QString get_city_dialog_airlift_value(const struct city *pcity)
Return airlift capacity.
QString get_city_dialog_status_text(const struct city *pcity)
Return text describing the city's status: disorder/celebrating/...
int get_citydlg_canvas_height()
Return the height of the city dialog canvas.
QString get_city_dialog_culture_text(const struct city *pcity)
Return text describing the culture output.
QString get_city_dialog_output_text(const struct city *pcity, Output_type_id otype)
Return text describing the production output.
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
Find the city dialog city production text for the given city, and place it into the buffer.
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Set the worklist for a given city.
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
Provide a list of all citizens in the city, in order.
int city_buy_production(struct city *pcity)
Buy the current production item in a given city.
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
Insert an item into the city's queue.
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
Insert the worklist into the city's queue at the given position.
QString get_city_dialog_growth_value(const struct city *pcity)
Return time until next growth.
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
Set the city current production and the worklist, like it should be.
QString get_city_dialog_size_text(const struct city *pcity)
Return text describing the city's citizens.
QString get_city_dialog_pollution_text(const struct city *pcity)
Return text describing the pollution output.
int city_change_production(struct city *pcity, struct universal *target)
Change the production of a given city.
void city_rotate_specialist(struct city *pcity, int citizen_index)
Rotate the given specialist citizen to the next type of citizen.
QString get_city_dialog_airlift_text(const struct city *pcity)
Return text describing airlift capacity.
int get_citydlg_canvas_width()
Return the width of the city dialog canvas.
void city_get_queue(struct city *pcity, struct worklist *pqueue)
Get the city current production and the worklist, like it should be.
QString get_city_dialog_illness_text(const struct city *pcity)
Return text describing the chance for a plague.
bool city_can_buy(const struct city *pcity)
Return TRUE iff the city can buy.
cityIconInfoLabel(QWidget *parent=0)
void setCity(struct city *pcity)
void setup_ui(struct city *qcity)
Setups whole city dialog, public function.
void worklist_up()
Move current item on worklist up.
void update_nation_table()
Updates nationality table in happiness tab.
void next_city()
Changes city_dialog to next city after pushing next city button.
void cma_double_clicked(int row, int column)
Double click on some row ( column is unused )
void update_disabled()
Updates buttons/widgets which should be enabled/disabled.
void update_buy_button()
Enables/disables buy buttons depending on gold.
void update_building()
Updates building improvement/unit.
void save_worklist()
Save worklist.
void worklist_del()
Remove current item on worklist.
void clear_worklist()
Clears worklist in production page.
city_label * lab_table[6]
void showEvent(QShowEvent *event) override
Show event.
void update_info_label()
Updates information label ( food, prod ...
bool eventFilter(QObject *obj, QEvent *event) override
Event filter for catching keybaord events.
city_dialog(QWidget *parent=0)
Constructor for city_dialog, sets layouts, policies ...
void disband_state_changed(bool allow_disband)
Received signal about changed qcheckbox - allow disbanding city.
void update_citizens()
Redraws citizens for city_label (citizens_label)
void cma_context_menu(const QPoint p)
Context menu on governor tab in city worklist.
void worklist_down()
Move current item on worklist down.
void update_title()
Puts city name and people count on title.
void present_units_exp_col()
Slot to expand or collapse the present units list.
void dbl_click_p(QTableWidgetItem *item)
Double clicked item in worklist table in production tab.
void cma_remove()
Removes selected CMA.
void prev_city()
Changes city_dialog to previous city after pushing prev city button.
void city_rename()
City rename dialog input.
void refresh()
Various refresh after getting new info/reply from server.
void update_cma_tab()
Updates cma tab.
void display_worklist_menu(const QPoint)
Context menu on production tab in city worklist.
void show_targets()
Shows customized table widget with available items to produce Shows default targets in overview city ...
void cma_check_agent(const cm_parameter ¶ms)
Triggers a governor update if the parameters changed.
void fill_citizens_pixmap(QPixmap *pixmap, QPainter *painter, const citizen_category *categories, int num_citizens)
Fill a pixmap with citizen sprites.
void cma_enable()
Enables cma slot, triggered by clicked button or changed cma.
void update_improvements()
Updates list of improvements.
~city_dialog() override
City dialog destructor.
void change_production(bool next)
Changes production to next one or previous.
void cma_selected(const QItemSelection &sl, const QItemSelection &ds)
CMA has been selected from list.
void hideEvent(QHideEvent *event) override
Hide event.
void item_selected(const QItemSelection &sl, const QItemSelection &ds)
Selection changed in production tab, in worklist tab.
void show_targets_worklist()
Shows customized table widget with available items to produce Shows customized targets in city produc...
void cma_changed()
Sliders moved and cma has been changed.
void update_units()
Updates layouts for supported and present units in city.
void save_cma()
Save cma dialog input.
void update_prod_buttons()
Update sensitivity of buttons in production tab.
void update_labels(struct city *ci_city)
city_info(QWidget *parent=0)
QSize sizeHint() const override
city_label(QWidget *parent=0)
city_label is used only for showing citizens icons and was created only to catch mouse events
void set_city(struct city *pcity)
Just sets target city for city_label.
void mousePressEvent(QMouseEvent *event) override
Mouse handler for city_label.
QSize minimumSizeHint() const override
QSize get_pixmap_size() const
city_production_delegate(QPoint sh, QObject *parent, struct city *city)
City item delegate constructor.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
City item delgate paint event.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Size hint for city item delegate.
void drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const override
Draws focus for given item.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
city_production_model(struct city *pcity, bool f, bool su, bool sw, bool sb, QObject *parent=0)
Constructor for city production model.
QList< production_item * > city_target_list
int rowCount(const QModelIndex &index=QModelIndex()) const override
void populate()
Fills model with data.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data from model.
~city_production_model() override
Destructor for city production model.
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.
void set_text_title(const QString &s1, const QString &s2)
Sets text and title and shows message box.
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
void hide_all_fcwidgets()
Hides all fcwidgets (reports etc).
void show_all_fcwidgets()
Shows all fcwidgets (reports etc).
city_dialog * city_overlay
struct universal * target
~production_item() override
Production item destructor.
QVariant data() const
Returns stored data.
production_item(struct universal *ptarget, QObject *parent)
Production item constructor.
progress_bar(QWidget *parent)
Custom progressbar constructor.
void set_pixmap(struct universal *target)
Sets pixmap from given universal for custom progressbar.
~progress_bar() override
Custom progressbar destructor.
void create_region()
Creates region with diagonal lines.
void resizeEvent(QResizeEvent *event) override
Custom progressbar resize event.
void paintEvent(QPaintEvent *event) override
Paint event for custom progress bar.
std::vector< unit * > sorted(const unit_list *units)
Returns a version of units sorted in the way the user would like to see them.
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
bool can_client_issue_orders()
Returns TRUE iff the client can issue orders (such as giving unit commands).
bool client_is_observer()
Returns whether client is observer.
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Collect the cids of all targets which can be build by this city or in general.
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Takes an array of compound ids (cids).
cid cid_encode(struct universal target)
Encode a CID for the target production.
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Collect the cids of all improvements which are built in the given city.
struct universal cid_decode(cid id)
Decode the CID into a city_production structure.
#define MAX_NUM_PRODUCTION_TARGETS
void unit_focus_update()
If there is no unit currently in focus, or if the current unit in focus should not be in focus,...
void unit_focus_add(struct unit *punit)
Adds this unit to the list of units in focus.
void unit_focus_set(struct unit *punit)
Sets the focus unit directly.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
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.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
struct global_worklist * global_worklist_by_id(int id)
Returns the global worklist corresponding to this id.
bool global_worklist_set(struct global_worklist *pgwl, const struct worklist *pwl)
Sets the worklist.
int global_worklist_id(const struct global_worklist *pgwl)
Returns the id of the global worklist.
struct global_worklist * global_worklist_new(const char *name)
Creates a new global worklist form a normal worklist.
const char * global_worklist_name(const struct global_worklist *pgwl)
Return the name of the global worklist.
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
Returns the worklist of this global worklist or nullptr if it's not valid.
#define global_worklists_iterate(pgwl)
#define global_worklists_iterate_end
const char * cmafec_get_short_descr_of_city(const struct city *pcity)
Return short description of city governor preset.
int cmafec_preset_num()
Returns the total number of presets.
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Returns the indexed preset's parameter.
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Check whether city is under governor control, and fill parameter if it is.
char * cmafec_preset_get_descr(int idx)
Returns the indexed preset's description.
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Put city under governor control.
int cmafec_preset_get_index_of_parameter(const struct cm_parameter *const parameter)
Returns the index of the preset which matches the given parameter.
void cmafec_preset_remove(int idx)
Removes a preset.
void cma_release_city(struct city *pcity)
Release city from governor control.
void cmafec_get_fe_parameter(struct city *pcity, struct cm_parameter *dest)
Return the front-end parameter for the given city.
bool is_special_improvement(const struct impr_type *pimprove)
Returns TRUE if this is a "special" improvement.
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Returns TRUE if an improvement in a city is redundant, that is, the city wouldn't lose anything by lo...
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Returns the number of shields it takes to build this improvement.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Return TRUE if the impr has this flag otherwise FALSE.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define fc_assert_ret(condition)
#define fc_assert_action(condition, action)
const char *const default_font
const char *const notify_label
void add_quick_unit_actions(QMenu *menu, const std::vector< unit * > &units)
Adds a small set of common unit actions to a menu.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
pageGame * queen()
Return game instandce.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
struct city::@15::@18 client
struct universal production
struct unit_list * units_supported
struct packet_game_info info
The base class for options.
struct city_list * cities
struct player_economic economic
struct universal entries[MAX_LEN_WORKLIST]
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
struct advance * valid_advance_by_number(const Tech_type_id id)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
QString text_happiness_wonders(const struct city *pcity)
Describing wonders that affect happiness.
const QString unit_description(const unit *punit)
Returns the unit description.
QString text_happiness_luxuries(const struct city *pcity)
Describing luxuries that affect happiness.
QString text_happiness_cities(const struct city *pcity)
Describing city factors that affect happiness.
QString text_happiness_buildings(const struct city *pcity)
Describe buildings that affect happiness (or rather, anything with a Make_Content effect).
QString text_happiness_nationality(const struct city *pcity)
Describing nationality effects that affect happiness.
QString text_happiness_units(const struct city *pcity)
Describe units that affect happiness.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
int tileset_hex_width(const struct tileset *t)
Return the hex_width of the current tileset.
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.
const QPixmap * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Return a sprite for the given citizen.
int tileset_small_sprite_width(const struct tileset *t)
Return the small sprite width of the current tileset.
const QPixmap * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the sprite for the nation.
int tileset_unit_layout_offset_y(const struct tileset *t)
Offset to layout extra unit sprites, such as upkeep.
const QPixmap * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Return the sprite for the technology/advance.
bool tileset_is_isometric(const struct tileset *t)
Return whether the current tileset is isometric.
int tileset_small_sprite_height(const struct tileset *t)
Return the small sprite height of the current tileset.
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).
struct tileset * get_tileset()
Returns the tileset.
int tileset_unit_with_upkeep_height(const struct tileset *t)
Suitable canvas height for a unit icon that includes upkeep sprites.
int tileset_hex_height(const struct tileset *t)
Return the hex_height of the current tileset.
const QPixmap * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Return the sprite for the building/improvement.
void top_bar_show_map()
Callback to show map.
const struct unit_type * utype
const struct impr_type * building
const char * utype_values_translation(const struct unit_type *punittype)
Return string with translated unit name and list of its values.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Returns TRUE iff performing an action with the specified action result will consume an actor unit of ...
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
Return TRUE iff units of the given type can do any enabler controlled action with the specified actio...
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile, bool full_refresh)
Refreshes a single city on the map canvas.
void put_unit_city_overlays(const unit *punit, QPixmap *pcanvas, int canvas_x, int canvas_y, const int *upkeep_cost, int happy_cost)
Draw food, gold, and shield upkeep values on the unit.
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().
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.
void worklist_init(struct worklist *pwl)
Initialize a worklist to be empty.
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
Fill in the id and is_unit values for the ith element in the worklist.
bool worklist_insert(struct worklist *pwl, const struct universal *prod, int idx)
Inserts the production at the location idx in the worklist, thus moving all subsequent entries down.
void worklist_remove(struct worklist *pwl, int idx)
Remove element from position idx.
int worklist_length(const struct worklist *pwl)
Returns the number of entries in the worklist.