20#include <QApplication>
29#include <QStackedWidget>
30#include <QTableWidget>
91 if (pterrain->identifier_load == ch) {
104 gui()->switch_page(page);
114 gui()->pr_options->set_rulesets(num_rulesets, rulesets);
122 return gui()->current_page();
130 gui()->update_start_page();
139 QLabel* free_main_pic =
new QLabel;
140 QPainter painter(&main_graphics);
141 QStringList buttons_names;
145 QFont f = QApplication::font();
148#if IS_BETA_VERSION || IS_DEVEL_VERSION
155 painter.setPen(Qt::white);
159 if (rev_ver == NULL) {
162 fc_snprintf(msgbuf,
sizeof(msgbuf),
_(
"%s%s, Qt5 client"),
165 fc_snprintf(msgbuf,
sizeof(msgbuf),
_(
"%s%s, Qt6 client"),
172 main_graphics.height() - fm.descent() - fm.height() * 2,
176 fc_snprintf(msgbuf,
sizeof(msgbuf),
_(
"commit: %s"), rev_ver);
178 main_graphics.height() - fm.descent() - fm.height(),
182 strncpy(msgbuf,
_(
"Qt5 client"),
sizeof(msgbuf) - 1);
184 strncpy(msgbuf,
_(
"Qt6 client"),
sizeof(msgbuf) - 1);
188 painter.drawText(main_graphics.width() - fm.horizontalAdvance (msgbuf)
189 -10, main_graphics.height() - fm.descent(), msgbuf);
190 free_main_pic->setPixmap(main_graphics);
192 row++, 0, 1, 2, Qt::AlignCenter);
194#if IS_BETA_VERSION || IS_DEVEL_VERSION
195 warn_color.setColor(QPalette::WindowText, Qt::red);
196 unstable_label->setPalette(warn_color);
197 unstable_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
198 unstable_label->setAlignment(Qt::AlignCenter);
200 row++, 0, 1, 2, Qt::AlignHCenter);
203 buttons_names <<
_(
"Start new game") <<
_(
"Start scenario game")
204 <<
_(
"Load saved game") <<
_(
"Connect to network game")
205 <<
_(
"Options") <<
_(
"Quit");
207 buttons_nr = buttons_names.count();
209 for (
int iter = 0; iter < buttons_nr; iter++) {
210 button =
new QPushButton(buttons_names[iter]);
216 _(
"Launches local server, and connects to it for a single-player game."));
222 _(
"Loads one of the scenarios for a single-player game. "
223 "Tutorial is one of the scenarios."));
224 QObject::connect(
button, &QPushButton::clicked, [
this]() {
231 _(
"Continues previously saved single-player game."));
232 QObject::connect(
button, &QPushButton::clicked, [
this]() {
239 _(
"Connects to outside server. "
240 "Sometimes you want to launch a separate server even for local games."));
241 QObject::connect(
button, &QPushButton::clicked, [
this]() {
247 button->setToolTip(
_(
"Adjusting client-side options."));
252 button->setToolTip(
_(
"Gives you a break from playing freeciv."));
306 QPushButton *network_button;
309 QVBoxLayout *page_network_layout =
new QVBoxLayout;
310 QGridLayout *page_network_grid_layout =
new QGridLayout;
311 QHBoxLayout *page_network_lan_layout =
new QHBoxLayout;
312 QHBoxLayout *page_network_wan_layout =
new QHBoxLayout;
331 QStringList servers_list;
332 servers_list <<
_(
"Server Name") <<
_(
"Port") <<
_(
"Version")
333 <<
_(
"Status") <<
Q_(
"?count:Players") <<
_(
"Comment");
334 QStringList server_info;
335 server_info <<
_(
"Name") <<
_(
"Type") <<
_(
"Host") <<
_(
"Nation");
338 lan_widget->setColumnCount(servers_list.count());
339 lan_widget->verticalHeader()->setVisible(
false);
343 wan_widget->setColumnCount(servers_list.count());
344 wan_widget->verticalHeader()->setVisible(
false);
351 lan_widget->setHorizontalHeaderLabels(servers_list);
353 lan_widget->setProperty(
"selectionBehavior",
"SelectRows");
354 lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
355 lan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
357 wan_widget->setHorizontalHeaderLabels(servers_list);
359 wan_widget->setProperty(
"selectionBehavior",
"SelectRows");
360 wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
361 wan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
364 &QItemSelectionModel::selectionChanged,
this,
368 &QItemSelectionModel::selectionChanged,
this,
370 connect(
wan_widget, &QTableWidget::itemDoubleClicked,
this,
372 connect(
lan_widget, &QTableWidget::itemDoubleClicked,
this,
375 info_widget->setHorizontalHeaderLabels(server_info);
376 info_widget->setProperty(
"selectionBehavior",
"SelectRows");
377 info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
378 info_widget->setSelectionMode(QAbstractItemView::SingleSelection);
383 header->setSectionResizeMode(0, QHeaderView::Stretch);
384 header->setStretchLastSection(
true);
386 header->setSectionResizeMode(0, QHeaderView::Stretch);
387 header->setStretchLastSection(
true);
389 header->setSectionResizeMode(0, QHeaderView::Stretch);
390 header->setStretchLastSection(
true);
392 QStringList label_names;
393 label_names <<
_(
"Connect") <<
_(
"Port") <<
_(
"Login")
394 <<
_(
"Password") <<
_(
"Confirm Password");
396 for (
int i = 0; i < label_names.count(); i++) {
397 connect_msg =
new QLabel;
398 connect_msg->setText(label_names[i]);
399 page_network_grid_layout->addWidget(connect_msg, i, 0, Qt::AlignHCenter);
407 page_network_grid_layout->addWidget(
info_widget, 0, 2, 5, 4);
409 network_button =
new QPushButton(
_(
"Refresh"));
410 QObject::connect(network_button, &QAbstractButton::clicked,
this,
412 page_network_grid_layout->addWidget(network_button, 5, 0);
414 network_button =
new QPushButton(
_(
"Cancel"));
415 QObject::connect(network_button, &QPushButton::clicked, [
this]() {
418 page_network_grid_layout->addWidget(network_button, 5, 2, 1, 1);
420 network_button =
new QPushButton(
_(
"Connect"));
421 page_network_grid_layout->addWidget(network_button, 5, 5, 1, 1);
432 page_network_lan_layout->addWidget(
lan_widget, 0);
433 page_network_wan_layout->addWidget(
wan_widget, 1);
434 lan_label =
new QLabel(
_(
"Internet servers:"));
435 page_network_layout->addWidget(lan_label, 1);
436 page_network_layout->addWidget(
wan_widget, 10);
437 lan_label =
new QLabel(
_(
"Local servers:"));
438 page_network_layout->addWidget(lan_label, 1);
439 page_network_layout->addWidget(
lan_widget, 1);
440 page_network_grid_layout->setColumnStretch(3, 4);
441 pages_layout[PAGE_NETWORK]->addLayout(page_network_layout, 1, 1);
442 pages_layout[PAGE_NETWORK]->addLayout(page_network_grid_layout, 2, 1);
483 QLabel *label =
new QLabel(
_(
"Loading..."));
486 pages_layout[PAGE_GAME + 1]->addWidget(label, 0, 0, 1, 1,
498 QLabel *lbl_show_preview;
504 hbox =
new QHBoxLayout;
506 lbl_show_preview =
new QLabel(
_(
"Show preview"));
507 sav <<
_(
"Choose Saved Game to Load") <<
_(
"Date");
509 load_pix->setProperty(
"themed_border",
true);
521 hbox->addWidget(lbl_show_preview, Qt::AlignLeft);
522 wdg->setLayout(hbox);
525 saves_load->setProperty(
"selectionBehavior",
"SelectRows");
526 saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
527 saves_load->setSelectionMode(QAbstractItemView::SingleSelection);
528 saves_load->verticalHeader()->setVisible(
false);
531 header->setSectionResizeMode(0, QHeaderView::Stretch);
532 header->setStretchLastSection(
true);
536 &QItemSelectionModel::selectionChanged,
this,
544 but =
new QPushButton;
545 but->setText(
_(
"Browse..."));
546 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
550 but =
new QPushButton;
551 but->setText(
_(
"Cancel"));
552 but->setIcon(QApplication::style()->standardIcon(
553 QStyle::SP_DialogCancelButton));
557 but =
new QPushButton;
558 but->setText(
_(
"Load"));
559 but->setIcon(QApplication::style()->standardIcon(
560 QStyle::SP_DialogOkButton));
586 sav <<
_(
"Choose a Scenario");
592 scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
593 scenarios_load->setSelectionMode(QAbstractItemView::SingleSelection);
605 header->setSectionResizeMode(0, QHeaderView::Stretch);
606 header->setStretchLastSection(
true);
608 &QItemSelectionModel::selectionChanged,
this,
611 but =
new QPushButton;
612 but->setText(
_(
"Browse..."));
613 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
617 but =
new QPushButton;
618 but->setText(
_(
"Cancel"));
619 but->setIcon(QApplication::style()->standardIcon(
620 QStyle::SP_DialogCancelButton));
628 but =
new QPushButton;
629 but->setText(
_(
"Load Scenario"));
630 but->setIcon(QApplication::style()->standardIcon(
631 QStyle::SP_DialogOkButton));
643 QGridLayout *up_layout;
644 QGridLayout *down_layout;
646 QWidget *down_widget;
649 QStringList player_widget_list;
651 up_layout =
new QGridLayout;
652 down_layout =
new QGridLayout;
656 chat_line->setProperty(
"doomchat",
true);
663 player_widget_list <<
_(
"Name") <<
_(
"Ready") <<
Q_(
"?player:Leader")
664 <<
_(
"Flag") <<
_(
"Border") <<
_(
"Nation") <<
_(
"Team")
675 SIGNAL(customContextMenuRequested(
const QPoint&)),
680 but =
new QPushButton;
681 but->setText(
_(
"Disconnect"));
682 but->setIcon(style()->standardPixmap(QStyle::SP_DialogCancelButton));
684 down_layout->addWidget(but, 5, 4);
689 QObject::connect(
nation_button, &QAbstractButton::clicked,
this,
696 QObject::connect(
obs_button, &QAbstractButton::clicked,
this,
700 start_button->setIcon(style()->standardPixmap(QStyle::SP_DialogOkButton));
702 QObject::connect(
start_button, &QAbstractButton::clicked,
this,
706 down_layout->addWidget(
pre_vote, 4, 0, 1, 4);
707 down_layout->addWidget(
chat_line, 5, 0, 1, 4);
709 splitter =
new QSplitter;
710 up_widget =
new QWidget();
711 down_widget =
new QWidget();
712 up_widget->setLayout(up_layout);
713 down_widget->setLayout(down_layout);
714 splitter->addWidget(up_widget);
715 splitter->addWidget(down_widget);
716 splitter->setOrientation(Qt::Vertical);
725 QGridLayout *game_layout;
729 game_layout =
new QGridLayout;
730 game_layout->setContentsMargins(0, 0, 0, 0);
731 game_layout->setSpacing(0);
755 _(
"Research"),
"SCI",
802 pages_layout[PAGE_GAME]->setContentsMargins(0, 0, 0, 0);
832 str = QString(
_(
"Save Files"))
833 + QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
836 QDir::homePath(),
str);
847 QItemSelection slctn;
854 slctn =
saves_load->selectionModel()->selection();
855 saves_load->selectionModel()->clearSelection();
856 saves_load->selectionModel()->select(slctn, QItemSelectionModel::Rows
857 | QItemSelectionModel::SelectCurrent);
867 str = QString(
_(
"Scenarios Files"))
868 + QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
870 _(
"Open Scenario File"),
871 QDir::homePath(),
str);
883 QTableWidget* sel = NULL;
884 QString host, portstr;
910 port = portstr.toInt();
911 old_row_count = sel->rowCount();
912 sel->clearContents();
919 if (old_row_count <= row) {
923 if (pserver->humans >= 0) {
924 fc_snprintf(buf,
sizeof(buf),
"%d", pserver->humans);
926 strncpy(buf,
_(
"Unknown"),
sizeof(buf) - 1);
927 buf[
sizeof(buf) - 1] =
'\0';
931 tstring = QString::number(tmp);
933 for (
int col = 0; col < 6; col++) {
934 QTableWidgetItem *
item;
936 item =
new QTableWidgetItem();
940 item->setText(pserver->host);
943 item->setText(tstring);
946 item->setText(pserver->version);
949 item->setText(
_(pserver->state));
955 item->setText(pserver->message);
960 sel->setItem(row, col,
item);
963 if (host == pserver->host && port == pserver->port) {
971 while (old_row_count - row > 0) {
972 sel->removeRow(old_row_count - 1);
1149 const QItemSelection &deselected)
1151 QModelIndexList indexes = selected.indexes();
1154 QTableWidgetItem *
item;
1155 QItemSelectionModel *tw;
1160 const char *terr_name;
1161 const struct server *pserver = NULL;
1166 QByteArray fn_bytes;
1168 if (indexes.isEmpty()) {
1174 index = indexes.at(0);
1176 index = indexes.at(1);
1179 tw = qobject_cast<QItemSelectionModel *>(sender());
1192 pserver = server_list_get(srvrs->
servers, index.row());
1197 if (!pserver || !pserver->
players) {
1203 for (k = 0; k <
n; k++) {
1205 for (col = 0; col < 4; col++) {
1206 item =
new QTableWidgetItem();
1228 index = indexes.at(0);
1229 qvar = index.data(Qt::UserRole);
1230 sl = qvar.toStringList();
1232 if (sl.count() > 1) {
1238 index = indexes.at(0);
1239 qvar = index.data(Qt::UserRole);
1242 load_pix->setPixmap(*(
new QPixmap));
1252 QString pl_str =
nullptr;
1253 int num_players = 0;
1254 int curr_player = 0;
1255 QByteArray pl_bytes;
1259 final_str = QString(
"<b>") +
_(
"Turn") +
":</b> "
1260 + QString::number(integer).toHtmlEscaped() +
"<br>";
1263 "players",
TRUE))) {
1266 final_str = final_str +
"<b>" +
_(
"Players") +
":</b>" +
" "
1267 + QString::number(integer).toHtmlEscaped() +
"<br>";
1269 num_players = integer;
1271 for (
int i = 0; i < num_players; i++) {
1272 pl_str = QString(
"player") + QString::number(i);
1273 pl_bytes = pl_str.toUtf8();
1275 pl_bytes.data(),
true))) {
1277 "player%d.unassigned_user",
1285 if (pl_str ==
nullptr) {
1291 pl_bytes = pl_str.toUtf8();
1293 pl_bytes.data(),
true))) {
1297 final_str = final_str +
"<b>" +
_(
"Nation") +
":</b> "
1298 + QString(sname).toHtmlEscaped() +
"<br>";
1303 final_str = final_str +
"<b>" +
_(
"Cities") +
":</b> "
1304 + QString::number(integer).toHtmlEscaped() +
"<br>";
1309 final_str = final_str +
"<b>" +
_(
"Units") +
":</b> "
1310 + QString::number(integer).toHtmlEscaped() +
"<br>";
1315 final_str = final_str +
"<b>" +
_(
"Gold") +
":</b> "
1316 + QString::number(integer).toHtmlEscaped() +
"<br>";
1322 "player%d.map_t%04d",
1323 curr_player,
nat_y++);
1324 if (line ==
nullptr) {
1327 nat_x = strlen(line);
1328 str_pixmap = str_pixmap + line;
1333 pterr->identifier_load =
'\0';
1340 "savefile.terrident%d.name", ii)) != NULL) {
1342 if (pterr != NULL) {
1344 "savefile.terrident%d.identifier", ii);
1351 QImage
img(
nat_x,
nat_y, QImage::Format_ARGB32_Premultiplied);
1353 img.fill(Qt::black);
1354 for (
int a = 0 ; a <
nat_x; a++) {
1355 for (
int b = 0; b <
nat_y; b++) {
1360 if (tr !=
nullptr) {
1364 color.setRgb(rgb->
r, rgb->
g, rgb->
b);
1369 if (
img.width() > 1) {
1370 load_pix->setPixmap(QPixmap::fromImage(
img).scaledToHeight(200));
1372 load_pix->setPixmap(*(
new QPixmap));
1388 "research",
TRUE))) {
1390 "research.r%d.now_name",
1393 final_str = final_str +
"<b>" +
_(
"Researching") +
":</b> "
1394 + QString(sname).toHtmlEscaped();
1412 struct fileinfo_list *files;
1421 QTableWidgetItem *
item;
1424 item =
new QTableWidgetItem();
1425 item->setData(Qt::UserRole, QString(pfile->fullname));
1427 item->setText(pfile->name);
1429 item =
new QTableWidgetItem();
1430 dt = QDateTime::fromSecsSinceEpoch(pfile->mtime);
1431 item->setText(dt.toString(Qt::TextDate));
1435 fileinfo_list_destroy(files);
1443 struct fileinfo_list *files;
1458 const char *sname, *sdescription, *sauthors;
1459 QTableWidgetItem *
item;
1464 int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000;
1465 int current_dev = current_ver;
1467 if (PATCH_VERSION >= 90) {
1469 current_dev += PATCH_VERSION * 100;
1473 if (fcver < 30000) {
1479 if (fcver % 10000 >= 9000) {
1480 fcdev = fcver - (fcver % 100);
1482 fcdev = fcver - (fcver % 10000);
1486 "scenario.description");
1488 "scenario.authors");
1490 if (fcdev <= current_dev) {
1492 bool add_item =
true;
1503 maj = fcver / 1000000;
1505 min = fcver / 10000;
1507 if (fcver >= 9000) {
1509 version = QString(
"%1.%2+").arg(maj).arg(min);
1511 version = QString(
"%1.%2").arg(maj).arg(min);
1515 version = QString(
_(
"pre-2.6"));
1519 for (i = 0; i < rows; ++i) {
1529 sl =
item->data(Qt::UserRole).toStringList();
1530 found_ver = sl.at(3).toInt();
1531 if (found_ver < fcver) {
1537 item =
new QTableWidgetItem();
1540 item->setText(QString(pfile->name));
1541 format = QString(
"<br>") + QString(
_(
"Format:")) +
" "
1542 + version.toHtmlEscaped();
1544 st = QString(
"\n") + QString(
"<b>") +
_(
"Authors: ")
1545 + QString(
"</b>") + QString(sauthors).toHtmlEscaped();
1550 + QString(sname && strlen(sname) ?
Q_(sname) : pfile->name)
1553 << QString(pfile->fullname).toHtmlEscaped()
1554 << QString(NULL != sdescription &&
'\0' != sdescription[0]
1555 ?
Q_(sdescription) :
"").toHtmlEscaped() + st + format
1556 << QString::number(fcver).toHtmlEscaped();
1557 sl.replaceInStrings(
"\n",
"<br>");
1558 item->setData(Qt::UserRole, sl);
1569 fileinfo_list_destroy(files);
1621 QByteArray ba_bytes;
1632 errbuf,
sizeof(errbuf)) != -1) {
1677 QVariant qvar, qvar2;
1679 QString host, nation, leader,
team,
str;
1683 QTreeWidgetItem *
item;
1684 QTreeWidgetItem *item_r;
1685 QList <QTreeWidgetItem*> items;
1686 QList <QTreeWidgetItem*> recursed_items;
1687 QTreeWidgetItem *player_item;
1688 QTreeWidgetItem *global_item;
1689 QTreeWidgetItem *detach_item;
1693 if (conn_num == 0) {
1700 player_item =
new QTreeWidgetItem();
1701 player_item->setText(0,
Q_(
"?header:Players"));
1702 player_item->setData(0, Qt::UserRole, qvar2);
1718 if (pconn->playing == pplayer && !pconn->observer) {
1719 conn_id = pconn->id;
1727 if (
is_ai(pplayer)) {
1730 is_ready = pplayer->is_ready;
1734 nation =
_(
"Random");
1736 if (pplayer->was_created) {
1746 if (pplayer->team) {
1752 item =
new QTreeWidgetItem();
1753 for (
int col = 0; col < 8; col++) {
1756 str = pplayer->username;
1758 if (
is_ai(pplayer)) {
1759 str =
str +
" <" + (ai_level_translated_name(pplayer->ai_common.skill_level))
1767 qvar = QVariant::fromValue((
void *) pplayer);
1769 item->setData(0, Qt::UserRole, qvar2);
1770 item->setData(1, Qt::UserRole, qvar);
1774 item->setText(col,
_(
"Yes"));
1776 item->setText(col,
_(
"No"));
1780 item->setText(col, leader);
1783 if (!pplayer->nation) {
1788 item->setData(col, Qt::DecorationRole, *pixmap);
1794 pixmap =
new QPixmap(
1796 pixmap->fill(Qt::transparent);
1798 p.fillRect(pixmap->width() / 2 - 8, 0, 16, 16, Qt::black);
1799 p.fillRect(pixmap->width() / 2 - 7, 1, 14, 14,
1802 item->setData(col, Qt::DecorationRole, *pixmap);
1806 item->setText(col, nation);
1812 item->setText(col, host);
1822 recursed_items.clear();
1824 if (pconn->id == conn_id) {
1827 item_r =
new QTreeWidgetItem();
1828 item_r->setText(0, pconn->username);
1829 item_r->setText(5,
_(
"Observer"));
1830 item_r->setText(7, pconn->addr);
1831 recursed_items.append(item_r);
1832 item->addChildren(recursed_items);
1838 player_item->addChildren(items);
1845 global_item =
new QTreeWidgetItem();
1846 global_item->setText(0,
_(
"Global observers"));
1848 global_item->setData(0, Qt::UserRole, qvar2);
1851 if (NULL != pconn->playing || !pconn->observer) {
1854 item =
new QTreeWidgetItem();
1855 for (
int col = 0; col < 8; col++) {
1858 item->setText(col, pconn->username);
1861 item->setText(col,
_(
"Observer"));
1864 item->setText(col, pconn->addr);
1873 global_item->addChildren(items);
1880 detach_item =
new QTreeWidgetItem();
1881 detach_item->setText(0,
_(
"Detached"));
1883 detach_item->setData(0, Qt::UserRole, qvar2);
1886 if (NULL != pconn->playing || pconn->observer) {
1889 item =
new QTreeWidgetItem();
1890 item->setText(0, pconn->username);
1891 item->setText(7, pconn->addr);
1895 detach_item->addChildren(items);
1921 text =
_(
"Not ready");
1923 int num_unready = 0;
1926 if (
is_human(pplayer) && !pplayer->is_ready) {
1931 if (num_unready > 1) {
1976 QString me, splayer,
str, sp;
1977 bool need_empty_team;
1978 const char *level_cmd, *level_name;
1980 QVariant qvar, qvar2;
1985 if (
item ==
nullptr) {
1989 qvar =
item->data(0, Qt::UserRole);
1990 qvar2 =
item->data(1, Qt::UserRole);
2000 if (pplayer !=
nullptr) {
2001 QMenu *page_menu =
new QMenu(
this);
2006 splayer = QString(pplayer->
name);
2007 sp =
"\"" + splayer +
"\"";
2008 if (me != splayer) {
2009 str = QString(
_(
"Observe"));
2011 str =
"/observe " + sp;
2012 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2015 page_menu->addAction(
action);
2018 str = QString(
_(
"Remove player"));
2020 str =
"/remove " + sp;
2021 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2024 page_menu->addAction(
action);
2026 str = QString(
_(
"Take this player"));
2028 str =
"/take " + sp;
2029 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2032 page_menu->addAction(
action);
2036 str = QString(
_(
"Pick nation"));
2039 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2042 page_menu->addAction(
action);
2045 if (
is_ai(pplayer)) {
2055 level_name = ai_level_translated_name(
static_cast < ai_level
> (
level));
2058 str =
"/" + QString(level_cmd) +
" " + sp;
2059 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2075 count = pplayer->
team ?
2077 need_empty_team = (count != 1);
2080 if (!need_empty_team) {
2083 need_empty_team =
false;
2089 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2097 str = QString(
_(
"Aitoggle player"));
2099 str =
"/aitoggle " + sp;
2100 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2103 page_menu->addAction(
action);
2106 page_menu->popup(global_pos);
2162 str = QString(
_(
"Tax: %1% Science: %2% Luxury: %3%\n"))
2167 str += QString(
_(
"%1 - max rate: %2%")).
2169 QString::number(max));
2173 &building_total, &tax);
2174 fc_snprintf(buf,
sizeof(buf),
_(
"Income: %d Total Costs: %d"),
2175 tax, building_total + unit_total);
2195 bool center_next =
false;
2196 bool first_tile =
false;
2198 struct tile *ptile =
nullptr;
2205 ptile = pcity->tile;
2206 first_id = pcity->id;
2220 if (ptile !=
nullptr) {
2231 bool center_next =
false;
2232 bool first_tile =
false;
2234 struct tile *ptile =
nullptr;
2241 ptile = pcity->tile;
2242 first_id = pcity->id;
2256 if (ptile !=
nullptr) {
2268 bool center_next =
false;
2269 bool first_tile =
false;
2271 struct tile *ptile =
nullptr;
2276 if (capital ==
nullptr) {
2281 ptile = capital->
tile;
2282 first_id = capital->
id;
2296 if (ptile !=
nullptr) {
2322 bool center_next =
false;
2323 bool first_tile =
false;
2325 struct tile *ptile =
nullptr;
2347 if (ptile !=
nullptr) {
struct canvas int int struct sprite * psprite
void qtg_version_message(const char *vertext)
int send_chat_printf(const char *format,...)
int send_chat(const char *message)
void output_window_append(const struct ft_color color, const char *featured_text)
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
fc_game_tab_widget * game_tab_widget
QStringList status_bar_queue
void handle_authentication_req(enum authentication_type type, const char *message)
QLineEdit * connect_host_edit
QTextEdit * output_window
void update_sidebar_tooltips()
fc_sidewidget * sw_economy
hud_battle_log * battlelog_wdg
QPushButton * start_button
int add_game_tab(QWidget *widget)
fc_sidewidget * sw_science
QTableWidget * lan_widget
QWidget * connect_metaserver
QWidget * game_main_widget
QLineEdit * connect_confirm_password_edit
QPushButton * nation_button
QTableWidget * saves_load
void set_status_bar(QString str, int timeout=2000)
enum client_pages current_page()
bool check_server_scan(server_scan *scan_data)
QLineEdit * connect_password_edit
minimap_view * minimapview_wdg
void reload_sidebar_icons()
QTableWidget * wan_widget
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
fc_sidewidget * sw_indicators
fc_sidewidget * sw_endturn
void slot_pregame_observe()
QTableWidget * info_widget
void set_connection_state(enum connection_state state)
QLabel * status_bar_label
QGridLayout * pages_layout[PAGE_GAME+2]
QLineEdit * connect_login_edit
QTextEdit * scenarios_view
void destroy_server_scans(void)
void update_sidebar_position()
QMenu * page_submenu_team
void create_network_page()
QTreeWidget * start_players_tree
QLineEdit * connect_port_edit
void create_loading_page()
void start_page_menu(QPoint)
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
void update_network_lists()
void slot_pregame_start()
fc_sidewidget * sw_cities
void popup_client_options()
void update_load_page(void)
pregame_options * pr_options
QTableWidget * scenarios_load
void rm_game_tab(int index)
void send_fake_chat_message(const QString &message)
void create_scenario_page()
void update_scenarios_page(void)
QIcon get_icon(const QString &id)
static fc_icons * instance()
void set_aifill(int aifill)
bool can_client_control(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
char fc_password[MAX_LEN_PASSWORD]
static struct fc_sockaddr_list * list
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
bool player_has_color(const struct player *pplayer)
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void key_center_capital(void)
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
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
void fc_allocate_mutex(fc_mutex *mutex)
void fc_release_mutex(fc_mutex *mutex)
const struct ft_color ftc_client
const char * government_name_for_player(const struct player *pplayer)
void city_report_dialog_popup(bool raise)
void popup_races_dialog(struct player *pplayer)
void put_cross_overlay_tile(struct tile *ptile)
static struct server_scan_timer_data meta_scan
static enum connection_state connection_status
static struct server_scan_timer_data lan_scan
static void server_scan_error(struct server_scan *scan, const char *message)
static bool holding_srv_list_mutex
void popup_players_dialog(bool raise)
void economy_report_dialog_popup(bool raise)
static struct server_list * server_list
#define log_error(message,...)
void center_tile_mapcanvas(const struct tile *ptile)
const char * nation_adjective_for_player(const struct player *pplayer)
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
#define NO_NATION_SELECTED
struct client_options gui_options
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
const char * get_government_tooltip(void)
const char * text_happiness_cities(const struct city *pcity)
void qtg_real_set_client_page(enum client_pages page)
static void center_next_enemy_city()
enum client_pages qtg_get_current_client_page()
static void center_next_player_city()
void popup_shortcuts_dialog()
static enum connection_state connection_status
static struct server_scan * meta_scan
void qtg_set_rulesets(int num_rulesets, char **rulesets)
int last_center_player_city
const char * get_info_label_text_popup(void)
void toggle_units_report(bool)
static bool holding_srv_list_mutex
const char * science_dialog_text(void)
static void cycle_enemy_units()
static struct terrain * char2terrain(char ch)
int last_center_enemy_city
const char * get_nuclear_winter_tooltip(void)
void server_scan_error(struct server_scan *scan, const char *message)
const char * get_bulb_tooltip(void)
const char * get_info_label_text(bool)
const char * get_global_warming_tooltip(void)
void update_start_page(void)
static struct server_scan * lan_scan
static void center_next_player_capital()
bool is_settable_ai_level(enum ai_level level)
const char * player_name(const struct player *pplayer)
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
struct city * player_primary_capital(const struct player *pplayer)
#define ai_level_cmd(_level_)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void secfile_destroy(struct section_file *secfile)
struct section_file * secfile_load_section(const char *filename, const char *section, bool allow_duplicates)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
static struct terrain * char2terrain(char ch)
struct srv_list * server_scan_get_list(struct server_scan *scan)
void server_scan_finish(struct server_scan *scan)
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
enum server_scan_status server_scan_poll(struct server_scan *scan)
#define server_list_iterate_end
#define server_list_iterate(serverlist, pserver)
struct setting_list * level[OLEVELS_NUM]
const struct strvec * get_scenario_dirs(void)
const struct strvec * get_save_dirs(void)
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
#define fileinfo_list_iterate(list, pnode)
#define fileinfo_list_iterate_end
enum capital_type capital
struct conn_list * est_connections
struct packet_game_info info
struct conn_list * all_connections
enum cmdlevel access_level
char username[MAX_LEN_NAME]
char password[MAX_LEN_PASSWORD]
struct player_economic economic
struct server::players * players
struct server_list * servers
int fc_snprintf(char *str, size_t n, const char *format,...)
#define sz_strlcpy(dest, src)
const char * team_name_translation(const struct team *pteam)
const char * team_slot_name_translation(const struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool team_slot_is_used(const struct team_slot *tslot)
const char * team_slot_rule_name(const struct team_slot *tslot)
#define team_slots_iterate_end
#define team_slots_iterate(_tslot)
struct terrain * terrain_by_rule_name(const char *name)
#define terrain_type_iterate(_p)
#define TERRAIN_UNKNOWN_IDENTIFIER
#define terrain_type_iterate_end
const char * tileset_main_intro_filename(const struct tileset *t)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * fc_git_revision(void)
const char * unstable_message(void)
const char * word_version(void)