Freeciv-3.2
Loading...
Searching...
No Matches
pages.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996-2004 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QAction>
20#include <QApplication>
21#include <QCheckBox>
22#include <QDateTime>
23#include <QFileDialog>
24#include <QGridLayout>
25#include <QHeaderView>
26#include <QLineEdit>
27#include <QPainter>
28#include <QSplitter>
29#include <QStackedWidget>
30#include <QTableWidget>
31#include <QTextEdit>
32#include <QTreeWidget>
33
34// common
35#include "game.h"
36#include "rgbcolor.h"
37#include "version.h"
38
39// client
40#include "client_main.h"
41#include "connectdlg_common.h"
42#include "svgflag.h"
43
44// gui-qt
45#include "colors.h"
46#include "dialogs.h"
47#include "fc_client.h"
48#include "pages.h"
49#include "plrdlg.h"
50#include "qtg_cxxside.h"
51#include "sidebar.h"
52#include "sprite.h"
53#include "voteinfo_bar.h"
54
55extern "C" {
56#include "repodlgs_g.h"
57#include "cityrep_g.h"
58const char *science_dialog_text(void);
59const char *get_bulb_tooltip(void);
60const char *get_global_warming_tooltip(void);
61const char *get_nuclear_winter_tooltip(void);
62const char *get_government_tooltip(void);
63const char *get_info_label_text_popup(void);
64const char *get_info_label_text(bool);
65const char *text_happiness_cities(const struct city *pcity);
66}
67
71extern void toggle_units_report(bool);
72extern void popup_shortcuts_dialog();
73static void center_next_enemy_city();
74static void center_next_player_city();
75static void center_next_player_capital();
77static bool holding_srv_list_mutex = false;
79static struct terrain *char2terrain(char ch);
80static void cycle_enemy_units();
82
83/**********************************************************************/
87static struct terrain *char2terrain(char ch)
88{
90 return T_UNKNOWN;
91 }
92 terrain_type_iterate(pterrain) {
93 if (pterrain->identifier_load == ch) {
94 return pterrain;
95 }
97 return nullptr;
98}
99
100
101/**********************************************************************/
105{
106 gui()->switch_page(page);
107}
108
109/**********************************************************************/
114void qtg_set_rulesets(int num_rulesets, char **rulesets)
115{
116 gui()->pr_options->set_rulesets(num_rulesets, rulesets);
117}
118
119/**********************************************************************/
123{
124 return gui()->current_page();
125}
126
127/**********************************************************************/
131{
132 gui()->update_start_page();
133}
134
135/**********************************************************************/
139{
141 QLabel *free_main_pic = new QLabel;
144 int buttons_nr;
145 char msgbuf[128];
146 const char *rev_ver;
147 QFont f = QApplication::font();
149 int row = 0;
150#if IS_BETA_VERSION || IS_DEVEL_VERSION
152 QLabel *unstable_label = new QLabel(unstable_message());
153#endif // IS_BETA_VERSION || IS_DEVEL_VERSION
154
156
157 painter.setPen(Qt::white);
158
160
161 if (rev_ver == NULL) {
162 // TRANS: "version 3.1.0, Qt5 client"
163#ifdef FC_QT5_MODE
164 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt5 client"),
166#else // FC_QT5_MODE
167 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt6 client"),
169#endif // FC_QT5_MODE
170 } else {
171 fc_snprintf(msgbuf, sizeof(msgbuf), "%s%s",
173 painter.drawText(10,
174 main_graphics.height() - fm.descent() - fm.height() * 2,
175 msgbuf);
176
177 // TRANS: "commit: [modified] <git commit id>"
178 fc_snprintf(msgbuf, sizeof(msgbuf), _("commit: %s"), rev_ver);
179 painter.drawText(10,
180 main_graphics.height() - fm.descent() - fm.height(),
181 msgbuf);
182
183#ifdef FC_QT5_MODE
184 strncpy(msgbuf, _("Qt5 client"), sizeof(msgbuf) - 1);
185#else // FC_QT5_MODE
186 strncpy(msgbuf, _("Qt6 client"), sizeof(msgbuf) - 1);
187#endif // FC_QT5_MODE
188 }
189
190 painter.drawText(main_graphics.width() - fm.horizontalAdvance (msgbuf)
191 -10, main_graphics.height() - fm.descent(), msgbuf);
192 free_main_pic->setPixmap(main_graphics);
194 row++, 0, 1, 2, Qt::AlignCenter);
195
196#if IS_BETA_VERSION || IS_DEVEL_VERSION
197 warn_color.setColor(QPalette::WindowText, Qt::red);
198 unstable_label->setPalette(warn_color);
199 unstable_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
200 unstable_label->setAlignment(Qt::AlignCenter);
202 row++, 0, 1, 2, Qt::AlignHCenter);
203#endif // IS_BETA_VERSION || IS_DEVEL_VERSION
204
205 buttons_names << _("Start new game") << _("Start scenario game")
206 << _("Load saved game") << _("Connect to network game")
207 << _("Options") << _("Quit");
208
209 buttons_nr = buttons_names.count();
210
211 for (int iter = 0; iter < buttons_nr; iter++) {
212 button = new QPushButton(buttons_names[iter]);
213
214 switch (iter) {
215 case 0:
216 pages_layout[PAGE_MAIN]->addWidget(button, row + 1, 0);
217 button->setToolTip(
218 _("Launches local server, and connects to it for a single-player game."));
219 connect(button, &QAbstractButton::clicked, this, &fc_client::start_new_game);
220 break;
221 case 1:
222 pages_layout[PAGE_MAIN]->addWidget(button, row + 2, 0);
223 button->setToolTip(
224 _("Loads one of the scenarios for a single-player game. "
225 "Tutorial is one of the scenarios."));
226 QObject::connect(button, &QPushButton::clicked, [this]() {
228 });
229 break;
230 case 2:
231 pages_layout[PAGE_MAIN]->addWidget(button, row + 3, 0);
232 button->setToolTip(
233 _("Continues previously saved single-player game."));
234 QObject::connect(button, &QPushButton::clicked, [this]() {
236 });
237 break;
238 case 3:
239 pages_layout[PAGE_MAIN]->addWidget(button, row + 1, 1);
240 button->setToolTip(
241 _("Connects to outside server. "
242 "Sometimes you want to launch a separate server even for local games."));
243 QObject::connect(button, &QPushButton::clicked, [this]() {
245 });
246 break;
247 case 4:
248 pages_layout[PAGE_MAIN]->addWidget(button, row + 2, 1);
249 button->setToolTip(_("Adjusting client-side options."));
250 connect(button, &QAbstractButton::clicked, this, &fc_client::popup_client_options);
251 break;
252 case 5:
253 pages_layout[PAGE_MAIN]->addWidget(button, row + 3, 1);
254 button->setToolTip(_("Gives you a break from playing freeciv."));
255 QObject::connect(button, &QAbstractButton::clicked, this, &fc_client::quit);
256 break;
257 default:
258 break;
259 }
260 }
261}
262
263/**********************************************************************/
267{
268 switch (state) {
269 case LOGIN_TYPE:
270 set_status_bar("");
271 connect_password_edit->setText("");
272 connect_password_edit->setDisabled(true);
274 connect_confirm_password_edit->setDisabled(true);
275 break;
277 connect_password_edit->setText("");
279 connect_password_edit->setDisabled(false);
280 connect_confirm_password_edit->setDisabled(false);
281 connect_password_edit->setFocus(Qt::OtherFocusReason);
282 break;
284 connect_password_edit->setText("");
286 connect_password_edit->setDisabled(false);
287 connect_confirm_password_edit->setDisabled(true);
288 connect_password_edit->setFocus(Qt::OtherFocusReason);
289
290
291 break;
292 case WAITING_TYPE:
293 set_status_bar("");
294 break;
295 }
296
297 connection_status = state;
298}
299
300/**********************************************************************/
304{
305 QHeaderView *header;
306 QLabel *connect_msg;
307 QLabel *lan_label;
308 QPushButton *network_button;
309
315
316 connect_host_edit = new QLineEdit;
317 connect_port_edit = new QLineEdit;
318 connect_login_edit = new QLineEdit;
319 connect_password_edit = new QLineEdit;
320 connect_confirm_password_edit = new QLineEdit;
321
322 connect_password_edit->setEchoMode(QLineEdit::Password);
323 connect_confirm_password_edit->setEchoMode(QLineEdit::Password);
324
325 connect_password_edit->setDisabled(true);
326 connect_confirm_password_edit->setDisabled(true);
327 connect_lan = new QWidget;
328 connect_metaserver = new QWidget;
329 lan_widget = new QTableWidget;
330 wan_widget = new QTableWidget;
331 info_widget = new QTableWidget;
332
334 servers_list << _("Server Name") << _("Port") << _("Version")
335 << _("Status") << Q_("?count:Players") << _("Comment");
337 server_info << _("Name") << _("Type") << _("Host") << _("Nation");
338
339 lan_widget->setRowCount(0);
340 lan_widget->setColumnCount(servers_list.count());
341 lan_widget->verticalHeader()->setVisible(false);
342 lan_widget->setAutoScroll(false);
343
344 wan_widget->setRowCount(0);
345 wan_widget->setColumnCount(servers_list.count());
346 wan_widget->verticalHeader()->setVisible(false);
347 wan_widget->setAutoScroll(false);
348
349 info_widget->setRowCount(0);
350 info_widget->setColumnCount(server_info.count());
351 info_widget->verticalHeader()->setVisible(false);
352
353 lan_widget->setHorizontalHeaderLabels(servers_list);
354 lan_widget->setProperty("showGrid", "false");
355 lan_widget->setProperty("selectionBehavior", "SelectRows");
356 lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
357 lan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
358
359 wan_widget->setHorizontalHeaderLabels(servers_list);
360 wan_widget->setProperty("showGrid", "false");
361 wan_widget->setProperty("selectionBehavior", "SelectRows");
362 wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
363 wan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
364
365 connect(wan_widget->selectionModel(),
366 &QItemSelectionModel::selectionChanged, this,
368
369 connect(lan_widget->selectionModel(),
370 &QItemSelectionModel::selectionChanged, this,
372 connect(wan_widget, &QTableWidget::itemDoubleClicked, this,
374 connect(lan_widget, &QTableWidget::itemDoubleClicked, this,
376
377 info_widget->setHorizontalHeaderLabels(server_info);
378 info_widget->setProperty("selectionBehavior", "SelectRows");
379 info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
380 info_widget->setSelectionMode(QAbstractItemView::SingleSelection);
381 info_widget->setProperty("showGrid", "false");
382 info_widget->setAlternatingRowColors(true);
383
384 header = lan_widget->horizontalHeader();
385 header->setSectionResizeMode(0, QHeaderView::Stretch);
386 header->setStretchLastSection(true);
387 header = wan_widget->horizontalHeader();
388 header->setSectionResizeMode(0, QHeaderView::Stretch);
389 header->setStretchLastSection(true);
390 header = info_widget->horizontalHeader();
391 header->setSectionResizeMode(0, QHeaderView::Stretch);
392 header->setStretchLastSection(true);
393
395 label_names << _("Connect") << _("Port") << _("Login")
396 << _("Password") << _("Confirm Password");
397
398 for (int i = 0; i < label_names.count(); i++) {
399 connect_msg = new QLabel;
400 connect_msg->setText(label_names[i]);
401 page_network_grid_layout->addWidget(connect_msg, i, 0, Qt::AlignHCenter);
402 }
403
409 page_network_grid_layout->addWidget(info_widget, 0, 2, 5, 4);
410
411 network_button = new QPushButton(_("Refresh"));
412 QObject::connect(network_button, &QAbstractButton::clicked, this,
415
416 network_button = new QPushButton(_("Cancel"));
417 QObject::connect(network_button, &QPushButton::clicked, [this]() {
419 });
420 page_network_grid_layout->addWidget(network_button, 5, 2, 1, 1);
421
422 network_button = new QPushButton(_("Connect"));
423 page_network_grid_layout->addWidget(network_button, 5, 5, 1, 1);
424 connect(network_button, &QAbstractButton::clicked, this, &fc_client::slot_connect);
425 connect(connect_login_edit, &QLineEdit::returnPressed,
427 connect(connect_password_edit, &QLineEdit::returnPressed,
429 connect(connect_confirm_password_edit, &QLineEdit::returnPressed,
431
434 page_network_lan_layout->addWidget(lan_widget, 0);
435 page_network_wan_layout->addWidget(wan_widget, 1);
436 lan_label = new QLabel(_("Internet servers:"));
437 page_network_layout->addWidget(lan_label, 1);
438 page_network_layout->addWidget(wan_widget, 10);
439 lan_label = new QLabel(_("Local servers:"));
440 page_network_layout->addWidget(lan_label, 1);
441 page_network_layout->addWidget(lan_widget, 1);
442 page_network_grid_layout->setColumnStretch(3, 4);
445
446}
447
448/**********************************************************************/
452{
453 if (status_bar_label->text().isEmpty()) {
454 status_bar_label->setText(message);
455 QTimer::singleShot(timeout, this, SLOT(clear_status_bar()));
456 } else {
458 while (status_bar_queue.count() > 3) {
459 status_bar_queue.removeFirst();
460 }
461 }
462}
463
464/**********************************************************************/
468{
469 QString str;
470
471 if (!status_bar_queue.isEmpty()) {
472 str = status_bar_queue.takeFirst();
473 status_bar_label->setText(str);
474 QTimer::singleShot(2000, this, SLOT(clear_status_bar()));
475 } else {
476 status_bar_label->setText("");
477 }
478}
479
480/**********************************************************************/
484{
485 QLabel *label = new QLabel(_("Loading..."));
486
488 pages_layout[PAGE_GAME + 1]->addWidget(label, 0, 0, 1, 1,
489 Qt::AlignHCenter);
490}
491
492/**********************************************************************/
496{
498 QPushButton *but;
499 QHeaderView *header;
500 QLabel *lbl_show_preview;
501 QWidget *wdg;
503
504 saves_load = new QTableWidget;
505 wdg = new QWidget;
506 hbox = new QHBoxLayout;
508 lbl_show_preview = new QLabel(_("Show preview"));
509 sav << _("Choose Saved Game to Load") << _("Date");
510 load_pix = new QLabel;
511 load_pix->setProperty("themed_border", true);
512 load_pix->setFixedSize(0 ,0);
513 load_save_text = new QLabel;
514 load_save_text->setTextFormat(Qt::RichText);
515 load_save_text->setWordWrap(true);
518 saves_load->setAlternatingRowColors(true);
519 saves_load->setRowCount(0);
520 saves_load->setColumnCount(sav.count());
521 saves_load->setHorizontalHeaderLabels(sav);
522 hbox->addWidget(show_preview);
523 hbox->addWidget(lbl_show_preview, Qt::AlignLeft);
524 wdg->setLayout(hbox);
525
526 saves_load->setProperty("showGrid", "false");
527 saves_load->setProperty("selectionBehavior", "SelectRows");
528 saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
529 saves_load->setSelectionMode(QAbstractItemView::SingleSelection);
530 saves_load->verticalHeader()->setVisible(false);
531
532 header = saves_load->horizontalHeader();
533 header->setSectionResizeMode(0, QHeaderView::Stretch);
534 header->setStretchLastSection(true);
535
536 pages_layout[PAGE_LOAD]->addWidget(saves_load, 0, 0, 1, 4);
537 connect(saves_load->selectionModel(),
538 &QItemSelectionModel::selectionChanged, this,
540 connect(show_preview, &QCheckBox::stateChanged, this,
542 pages_layout[PAGE_LOAD]->addWidget(wdg, 1, 0);
543 pages_layout[PAGE_LOAD]->addWidget(load_save_text, 2, 0, 1, 2);
544 pages_layout[PAGE_LOAD]->addWidget(load_pix, 2, 2, 1, 2);
545
546 but = new QPushButton;
547 but->setText(_("Browse..."));
548 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
549 connect(but, &QAbstractButton::clicked, this, &fc_client::browse_saves);
550 pages_layout[PAGE_LOAD]->addWidget(but, 3, 0);
551
552 but = new QPushButton;
553 but->setText(_("Cancel"));
554 but->setIcon(QApplication::style()->standardIcon(
555 QStyle::SP_DialogCancelButton));
556 connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
557 pages_layout[PAGE_LOAD]->addWidget(but, 3, 2);
558
559 but = new QPushButton;
560 but->setText(_("Load"));
561 but->setIcon(QApplication::style()->standardIcon(
562 QStyle::SP_DialogOkButton));
563 connect(but, &QAbstractButton::clicked, this, &fc_client::start_from_save);
564 pages_layout[PAGE_LOAD]->addWidget(but, 3, 3);
565 pages_layout[PAGE_LOAD]->setColumnStretch(3, 10);
566 pages_layout[PAGE_LOAD]->setColumnStretch(2, 10);
567 pages_layout[PAGE_LOAD]->setColumnStretch(0, 10);
568
569}
570
571/**********************************************************************/
575{
576 QPushButton *but;
577 QHeaderView *header;
579
581 scenarios_load = new QTableWidget;
583 scenarios_text = new QLabel;
584
585 scenarios_view->setObjectName("scenarios_view");
586 scenarios_text->setTextFormat(Qt::RichText);
587 scenarios_text->setWordWrap(true);
588 sav << _("Choose a Scenario");
589 scenarios_load->setRowCount(0);
590 scenarios_load->setColumnCount(sav.count());
591 scenarios_load->setHorizontalHeaderLabels(sav);
592 scenarios_load->setProperty("showGrid", "false");
593 scenarios_load->setProperty("selectionBehavior", "SelectRows");
594 scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
595 scenarios_load->setSelectionMode(QAbstractItemView::SingleSelection);
596 scenarios_load->verticalHeader()->setVisible(false);
597 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_load, 0, 0, 3, 3,
598 Qt::AlignLeft);
599 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_view, 1, 3, 2, 3);
600 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_text, 0, 3, 1, 2,
601 Qt::AlignTop);
602 scenarios_view->setReadOnly(true);
603 scenarios_view->setWordWrapMode(QTextOption::WordWrap);
604 scenarios_text->setAlignment(Qt::AlignCenter);
605
606 header = scenarios_load->horizontalHeader();
607 header->setSectionResizeMode(0, QHeaderView::Stretch);
608 header->setStretchLastSection(true);
609 connect(scenarios_load->selectionModel(),
610 &QItemSelectionModel::selectionChanged, this,
612
613 but = new QPushButton;
614 but->setText(_("Browse..."));
615 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
616 connect(but, &QAbstractButton::clicked, this, &fc_client::browse_scenarios);
617 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 0);
618
619 but = new QPushButton;
620 but->setText(_("Cancel"));
621 but->setIcon(QApplication::style()->standardIcon(
622 QStyle::SP_DialogCancelButton));
623 connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
624 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 3);
625
626 pages_layout[PAGE_SCENARIO]->setColumnStretch(2, 10);
627 pages_layout[PAGE_SCENARIO]->setColumnStretch(4, 20);
628 pages_layout[PAGE_SCENARIO]->setColumnStretch(3, 20);
629 pages_layout[PAGE_SCENARIO]->setRowStretch(1, 5);
630 but = new QPushButton;
631 but->setText(_("Load Scenario"));
632 but->setIcon(QApplication::style()->standardIcon(
633 QStyle::SP_DialogOkButton));
634 connect(but, &QAbstractButton::clicked, this, &fc_client::start_scenario);
635 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 4);
636}
637
638/**********************************************************************/
642{
643 QPushButton *but;
644 QSplitter *splitter;
647 QWidget *up_widget;
648 QWidget *down_widget;
649 QFont f;
650
656 pr_options = new pregame_options(this);
657 chat_line = new chat_input;
658 chat_line->setProperty("doomchat", true);
660 output_window->setReadOnly(false);
661 f.setBold(true);
662 output_window->setFont(f);
663
664 pr_options->init();
665 player_widget_list << _("Name") << _("Ready") << Q_("?player:Leader")
666 << _("Flag") << _("Border") << _("Nation") << _("Team")
667 << _("Host");
668
669 start_players_tree->setColumnCount(player_widget_list.count());
670 start_players_tree->setHeaderLabels(player_widget_list);
671 start_players_tree->setContextMenuPolicy(Qt::CustomContextMenu);
672 start_players_tree->setProperty("selectionBehavior", "SelectRows");
673 start_players_tree->setEditTriggers(QAbstractItemView::NoEditTriggers);
674 start_players_tree->setRootIsDecorated(false);
675
676 connect(start_players_tree,
679
680 up_layout->addWidget(start_players_tree, 0, 0, 3, 6);
681 up_layout->addWidget(pr_options, 0, 6, 3, 2);
682 but = new QPushButton;
683 but->setText(_("Disconnect"));
684 but->setIcon(style()->standardPixmap(QStyle::SP_DialogCancelButton));
685 QObject::connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
686 down_layout->addWidget(but, 5, 4);
687 nation_button = new QPushButton;
688 nation_button->setText(_("Pick Nation"));
689 nation_button->setIcon(fc_icons::instance()->get_icon("flag"));
690 down_layout->addWidget(nation_button, 5, 5);
691 QObject::connect(nation_button, &QAbstractButton::clicked, this,
693
694 obs_button = new QPushButton;
695 obs_button->setText(_("Observe"));
696 obs_button->setIcon(fc_icons::instance()->get_icon("meeting-observer"));
697 down_layout->addWidget(obs_button, 5, 6);
698 QObject::connect(obs_button, &QAbstractButton::clicked, this,
700 start_button = new QPushButton;
701 start_button->setText(_("Start"));
702 start_button->setIcon(style()->standardPixmap(QStyle::SP_DialogOkButton));
703 down_layout->addWidget(start_button, 5, 7);
704 QObject::connect(start_button, &QAbstractButton::clicked, this,
706 pre_vote = new pregamevote;
707
708 down_layout->addWidget(pre_vote, 4, 0, 1, 4);
709 down_layout->addWidget(chat_line, 5, 0, 1, 4);
710 down_layout->addWidget(output_window, 3, 0, 1, 8);
711 splitter = new QSplitter;
712 up_widget = new QWidget();
713 down_widget = new QWidget();
714 up_widget->setLayout(up_layout);
715 down_widget->setLayout(down_layout);
716 splitter->addWidget(up_widget);
717 splitter->addWidget(down_widget);
718 splitter->setOrientation(Qt::Vertical);
719 pages_layout[PAGE_START]->addWidget(splitter);
720}
721
722/**********************************************************************/
726{
728
730 game_main_widget = new QWidget;
732 game_layout->setContentsMargins(0, 0, 0, 0);
733 game_layout->setSpacing(0);
734 mapview_wdg = new map_view();
735 mapview_wdg->setFocusPolicy(Qt::WheelFocus);
736 sidebar_wdg = new fc_sidebar();
737
738 sw_map = new fc_sidewidget(fc_icons::instance()->get_pixmap("view"),
739 Q_("?noun:View"), "MAP", side_show_map);
740 sw_tax = new fc_sidewidget(nullptr, nullptr, "", side_rates_wdg, SW_TAX);
741 sw_indicators = new fc_sidewidget(nullptr, nullptr, "", side_show_map,
744 sw_cunit = new fc_sidewidget(fc_icons::instance()->get_pixmap("units"),
745 _("Units"), "",
747 sw_cities = new fc_sidewidget(fc_icons::instance()->get_pixmap("cities"),
748 _("Cities"), "CTS",
752 sw_diplo = new fc_sidewidget(fc_icons::instance()->get_pixmap("nations"),
753 _("Nations"), "PLR", popup_players_dialog);
756 sw_science = new fc_sidewidget(fc_icons::instance()->get_pixmap("research"),
757 _("Research"), "SCI",
759 sw_economy = new fc_sidewidget(fc_icons::instance()->get_pixmap("economy"),
760 _("Economy"), "ECO",
762 sw_endturn = new fc_sidewidget(fc_icons::instance()->get_pixmap("endturn"),
763 _("Turn Done"), "", side_finish_turn);
769
779
781 minimapview_wdg->show();
784 battlelog_wdg->hide();
786 infotab->show();
787 x_vote = new xvote(mapview_wdg);
788 x_vote->hide();
790 gtd->hide();
791
792 game_layout->addWidget(mapview_wdg, 1, 0);
793 game_main_widget->setLayout(game_layout);
795 game_tab_widget->setMinimumSize(600,400);
796 game_tab_widget->setContentsMargins(0, 0, 0, 0);
799 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 0);
800 } else {
801 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 2);
802 }
803 pages_layout[PAGE_GAME]->addWidget(game_tab_widget, 1, 1);
804 pages_layout[PAGE_GAME]->setContentsMargins(0, 0, 0, 0);
805 pages_layout[PAGE_GAME]->setSpacing(0);
806}
807
808/**********************************************************************/
812{
813 int i;
814
815 i = game_tab_widget->addWidget(widget);
816 game_tab_widget->setCurrentWidget(widget);
817 return i;
818}
819
820/**********************************************************************/
824{
825 game_tab_widget->removeWidget(game_tab_widget->widget(index));
826}
827
828/**********************************************************************/
832{
833 QString str;
834 str = QString(_("Save Files"))
835 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
836 current_file = QFileDialog::getOpenFileName(gui()->central_wdg,
837 _("Open Save File"),
838 QDir::homePath(), str);
839 if (!current_file.isEmpty()) {
841 }
842}
843
844/**********************************************************************/
848{
850
851 if (show_preview->checkState() == Qt::Unchecked) {
853 } else {
855 }
856 slctn = saves_load->selectionModel()->selection();
857 saves_load->selectionModel()->clearSelection();
858 saves_load->selectionModel()->select(slctn, QItemSelectionModel::Rows
859 | QItemSelectionModel::SelectCurrent);
860}
861
862/**********************************************************************/
866{
867 QString str;
868
869 str = QString(_("Scenarios Files"))
870 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
871 current_file = QFileDialog::getOpenFileName(gui()->central_wdg,
872 _("Open Scenario File"),
873 QDir::homePath(), str);
874 if (!current_file.isEmpty()) {
876 }
877}
878
879/**********************************************************************/
883 const struct server_list *list)
884{
885 QTableWidget* sel = NULL;
886 QString host, portstr;
887 int port;
888 int row;
889 int old_row_count;
890
891 switch (sstype) {
893 sel = lan_widget;
894 break;
896 sel = wan_widget;
897 break;
898 default:
899 break;
900 }
901
902 if (!sel) {
903 return;
904 }
905
906 if (!list) {
907 return;
908 }
909
910 host = connect_host_edit->text();
911 portstr = connect_port_edit->text();
912 port = portstr.toInt();
913 old_row_count = sel->rowCount();
914 sel->clearContents();
915 row = 0;
917 char buf[35];
918 int tmp;
920
921 if (old_row_count <= row) {
922 sel->insertRow(row);
923 }
924
925 if (pserver->humans >= 0) {
926 fc_snprintf(buf, sizeof(buf), "%d", pserver->humans);
927 } else {
928 strncpy(buf, _("Unknown"), sizeof(buf) - 1);
929 buf[sizeof(buf) - 1] = '\0';
930 }
931
932 tmp = pserver->port;
933 tstring = QString::number(tmp);
934
935 for (int col = 0; col < 6; col++) {
937
938 item = new QTableWidgetItem();
939
940 switch (col) {
941 case 0:
942 item->setText(pserver->host);
943 break;
944 case 1:
945 item->setText(tstring);
946 break;
947 case 2:
948 item->setText(pserver->version);
949 break;
950 case 3:
951 item->setText(_(pserver->state));
952 break;
953 case 4:
954 item->setText(buf);
955 break;
956 case 5:
957 item->setText(pserver->message);
958 break;
959 default:
960 break;
961 }
962 sel->setItem(row, col, item);
963 }
964
965 if (host == pserver->host && port == pserver->port) {
966 sel->selectRow(row);
967 }
968
969 row++;
971
972 // Remove unneeded rows, if there are any
973 while (old_row_count - row > 0) {
974 sel->removeRow(old_row_count - 1);
976 }
977
978}
979
980/**********************************************************************/
983void server_scan_error(struct server_scan *scan, const char *message)
984{
986 log_error("%s", message);
987
988 /* Main thread will finalize the scan later (or even concurrently) -
989 * do not do anything here to cause double free or raze condition. */
990}
991
992
993/**********************************************************************/
997{
998 if (meta_scan) {
1000 meta_scan = NULL;
1001 }
1002
1003 if (meta_scan_timer != NULL) {
1004 meta_scan_timer->stop();
1005 meta_scan_timer->disconnect();
1006 delete meta_scan_timer;
1008 }
1009
1010 if (lan_scan) {
1012 lan_scan = NULL;
1013 }
1014
1015 if (lan_scan_timer != NULL) {
1016 lan_scan_timer->stop();
1017 lan_scan_timer->disconnect();
1018 delete lan_scan_timer;
1020 }
1021}
1022
1023/**********************************************************************/
1027{
1029
1030 lan_scan_timer = new QTimer(this);
1032 connect(lan_scan_timer, &QTimer::timeout, this, &fc_client::slot_lan_scan);
1033 lan_scan_timer->start(500);
1034
1035 meta_scan_timer = new QTimer(this);
1037 connect(meta_scan_timer, &QTimer::timeout, this, &fc_client::slot_meta_scan);
1038 meta_scan_timer->start(800);
1039
1040}
1041
1042/**********************************************************************/
1046{
1047 struct server_scan *scan = scan_data;
1049
1050 if (!scan) {
1051 return false;
1052 }
1053
1054 stat = server_scan_poll(scan);
1055
1056 if (stat >= SCAN_STATUS_PARTIAL) {
1058 struct srv_list *srvrs;
1059
1060 type = server_scan_get_type(scan);
1061 srvrs = server_scan_get_list(scan);
1062 fc_mutex_allocate(&srvrs->mutex);
1065 holding_srv_list_mutex = false;
1066 fc_mutex_release(&srvrs->mutex);
1067 }
1068
1070 return false;
1071 }
1072
1073 return true;
1074}
1075
1076/**********************************************************************/
1080{
1081 if (lan_scan_timer == NULL) {
1082 return;
1083 }
1085}
1086
1087/**********************************************************************/
1091{
1092 if (meta_scan_timer == NULL) {
1093 return;
1094 }
1096}
1097
1098/**********************************************************************/
1102{
1103 if (!is_server_running()) {
1105
1106 // Saved settings are sent in client/options.c
1107 // resend_desired_settable_options()
1108 }
1109}
1110
1111/**********************************************************************/
1115{
1116 if (!is_server_running()) {
1118 send_chat("/detach");
1119 }
1120 if (is_server_running() && !current_file.isEmpty()) {
1122
1123 c_bytes = current_file.toUtf8();
1124 send_chat_printf("/load %s", c_bytes.data());
1126 }
1127}
1128
1129/**********************************************************************/
1133{
1134 if (!is_server_running()) {
1136 send_chat("/detach");
1137 }
1138 if (is_server_running() && !current_file.isEmpty()) {
1140
1141 c_bytes = current_file.toUtf8();
1142 send_chat_printf("/load %s", c_bytes.data());
1144 }
1145}
1146
1147/**********************************************************************/
1152{
1153 QModelIndexList indexes = selected.indexes();
1155 QModelIndex index;
1158 QVariant qvar;
1160
1162 const char *terr_name;
1163 const struct server *pserver = NULL;
1164 int ii = 0;
1165 int k, col, n, nat_y, nat_x;
1166 struct section_file *sf;
1167 struct srv_list *srvrs;
1169
1170 if (indexes.isEmpty()) {
1171 return;
1172 }
1173
1174 switch (cpage) {
1175 case PAGE_NETWORK:
1176 index = indexes.at(0);
1177 connect_host_edit->setText(index.data().toString());
1178 index = indexes.at(1);
1179 connect_port_edit->setText(index.data().toString());
1180
1182
1183 if (tw == lan_widget->selectionModel()) {
1184 wan_widget->clearSelection();
1185 } else {
1186 lan_widget->clearSelection();
1187 }
1188
1191 fc_mutex_allocate(&srvrs->mutex);
1192 }
1193 if (srvrs->servers) {
1194 pserver = server_list_get(srvrs->servers, index.row());
1195 }
1197 fc_mutex_release(&srvrs->mutex);
1198 }
1199 if (!pserver || !pserver->players) {
1200 return;
1201 }
1202 n = pserver->nplayers;
1203 info_widget->clearContents();
1204 info_widget->setRowCount(0);
1205 for (k = 0; k < n; k++) {
1206 info_widget->insertRow(k);
1207 for (col = 0; col < 4; col++) {
1208 item = new QTableWidgetItem();
1209 switch (col) {
1210 case 0:
1211 item->setText(pserver->players[k].name);
1212 break;
1213 case 1:
1214 item->setText(pserver->players[k].type);
1215 break;
1216 case 2:
1217 item->setText(pserver->players[k].host);
1218 break;
1219 case 3:
1220 item->setText(pserver->players[k].nation);
1221 break;
1222 default:
1223 break;
1224 }
1225 info_widget->setItem(k, col, item);
1226 }
1227 }
1228 break;
1229 case PAGE_SCENARIO:
1230 index = indexes.at(0);
1231 qvar = index.data(Qt::UserRole);
1232 sl = qvar.toStringList();
1233 scenarios_text->setText(sl.at(0));
1234 if (sl.count() > 1) {
1235 scenarios_view->setText(sl.at(2));
1236 current_file = sl.at(1);
1237 }
1238 break;
1239 case PAGE_LOAD:
1240 index = indexes.at(0);
1241 qvar = index.data(Qt::UserRole);
1242 current_file = qvar.toString();
1243 if (show_preview->checkState() == Qt::Unchecked) {
1244 load_pix->setPixmap(*(new QPixmap));
1245 load_save_text->setText("");
1246 break;
1247 }
1248 fn_bytes = current_file.toUtf8();
1249 if ((sf = secfile_load_section(fn_bytes.data(),
1250 "game", TRUE))) {
1251 const char *sname;
1252 int integer;
1254 QString pl_str = nullptr;
1255 int num_players = 0;
1256 int curr_player = 0;
1258
1259 integer = secfile_lookup_int_default(sf, -1, "game.turn");
1260 if (integer >= 0) {
1261 final_str = QString("<b>") + _("Turn") + ":</b> "
1262 + QString::number(integer).toHtmlEscaped() + "<br>";
1263 }
1264 if ((sf = secfile_load_section(fn_bytes.data(),
1265 "players", TRUE))) {
1266 integer = secfile_lookup_int_default(sf, -1, "players.nplayers");
1267 if (integer >= 0) {
1268 final_str = final_str + "<b>" + _("Players") + ":</b>" + " "
1269 + QString::number(integer).toHtmlEscaped() + "<br>";
1270 }
1271 num_players = integer;
1272 }
1273 for (int i = 0; i < num_players; i++) {
1274 pl_str = QString("player") + QString::number(i);
1275 pl_bytes = pl_str.toUtf8();
1276 if ((sf = secfile_load_section(fn_bytes.data(),
1277 pl_bytes.data(), true))) {
1278 if (!secfile_lookup_bool_default(sf, true,
1279 "player%d.unassigned_user",
1280 i)) {
1281 curr_player = i;
1282 break;
1283 }
1284 }
1285 }
1286 // Break case (and return) if no human player found
1287 if (pl_str == nullptr) {
1288 load_save_text->setText(final_str);
1289 break;
1290 }
1291
1292 // Information about human player
1293 pl_bytes = pl_str.toUtf8();
1294 if ((sf = secfile_load_section(fn_bytes.data(),
1295 pl_bytes.data(), true))) {
1296 sname = secfile_lookup_str_default(sf, nullptr, "player%d.nation",
1297 curr_player);
1298 if (sname) {
1299 final_str = final_str + "<b>" + _("Nation") + ":</b> "
1300 + QString(sname).toHtmlEscaped() + "<br>";
1301 }
1302 integer = secfile_lookup_int_default(sf, -1, "player%d.ncities",
1303 curr_player);
1304 if (integer >= 0) {
1305 final_str = final_str + "<b>" + _("Cities") + ":</b> "
1306 + QString::number(integer).toHtmlEscaped() + "<br>";
1307 }
1308 integer = secfile_lookup_int_default(sf, -1, "player%d.nunits",
1309 curr_player);
1310 if (integer >= 0) {
1311 final_str = final_str + "<b>" + _("Units") + ":</b> "
1312 + QString::number(integer).toHtmlEscaped() + "<br>";
1313 }
1314 integer = secfile_lookup_int_default(sf, -1, "player%d.gold",
1315 curr_player);
1316 if (integer >= 0) {
1317 final_str = final_str + "<b>" + _("Gold") + ":</b> "
1318 + QString::number(integer).toHtmlEscaped() + "<br>";
1319 }
1320 nat_x = 0;
1321 nat_y = 0;
1322 while (true) { // Until breaks out
1323 const char *line = secfile_lookup_str_default(sf, nullptr,
1324 "player%d.map_t%04d",
1325 curr_player, nat_y++);
1326 if (line == nullptr) {
1327 break;
1328 }
1329 nat_x = strlen(line);
1331 }
1332
1333 // Reset terrain information
1335 pterr->identifier_load = '\0';
1337
1338 // Load possible terrains and their identifiers (chars)
1339 if ((sf = secfile_load_section(fn_bytes.data(),
1340 "savefile", true))) {
1342 "savefile.terrident%d.name", ii)) != NULL) {
1344
1345 if (pterr != NULL) {
1346 const char *iptr = secfile_lookup_str_default(sf, NULL,
1347 "savefile.terrident%d.identifier", ii);
1348 pterr->identifier_load = *iptr;
1349 }
1350 ii++;
1351 }
1352 }
1353
1354 // Create image
1355 QImage img(nat_x, nat_y, QImage::Format_ARGB32_Premultiplied);
1356
1357 img.fill(Qt::black);
1358 for (int a = 0 ; a < nat_x; a++) {
1359 for (int b = 0; b < nat_y; b++) {
1360 struct terrain *tr;
1361 struct rgbcolor *rgb;
1362
1363 tr = char2terrain(str_pixmap.at(b * nat_x + a).toLatin1());
1364 if (tr != nullptr) {
1365 rgb = tr->rgb;
1366 QColor color;
1367
1368 color.setRgb(rgb->r, rgb->g, rgb->b);
1369 img.setPixel(a, b, color.rgb());
1370 }
1371 }
1372 }
1373 if (img.width() > 1) {
1374 load_pix->setPixmap(QPixmap::fromImage(img).scaledToHeight(200));
1375 } else {
1376 load_pix->setPixmap(*(new QPixmap));
1377 }
1378
1379#ifndef FC_QT5_MODE
1380 // This is Qt6 implementation
1381 // Qt-5.15 could use load_pix->pixmap(Qt::ReturnByValue)
1382 QPixmap pm = load_pix->pixmap();
1383
1384 load_pix->setFixedSize(pm.width(),
1385 pm.height());
1386#else // FC_QT5_MODE
1387 load_pix->setFixedSize(load_pix->pixmap()->width(),
1388 load_pix->pixmap()->height());
1389#endif // FC_QT5_MODE
1390
1391 if ((sf = secfile_load_section(fn_bytes.data(),
1392 "research", TRUE))) {
1393 sname = secfile_lookup_str_default(sf, nullptr,
1394 "research.r%d.now_name",
1395 curr_player);
1396 if (sname) {
1397 final_str = final_str + "<b>" + _("Researching") + ":</b> "
1398 + QString(sname).toHtmlEscaped();
1399 }
1400 }
1401 }
1402 load_save_text->setText(final_str);
1403 }
1404 break;
1405 default:
1406 break;
1407 }
1408
1409}
1410
1411/**********************************************************************/
1415{
1416 struct fileinfo_list *files;
1417 int row;
1418
1419 row = 0;
1420 files = fileinfolist_infix(get_save_dirs(), ".sav", FALSE);
1421 saves_load->clearContents();
1422 saves_load->setRowCount(0);
1426 QDateTime dt;
1427
1428 item = new QTableWidgetItem();
1429 item->setData(Qt::UserRole, QString(pfile->fullname));
1430 saves_load->insertRow(row);
1431 item->setText(pfile->name);
1432 saves_load->setItem(row, 0, item);
1433 item = new QTableWidgetItem();
1434 dt = QDateTime::fromSecsSinceEpoch(pfile->mtime);
1435 item->setText(dt.toString(Qt::TextDate));
1436 saves_load->setItem(row, 1, item);
1437 row++;
1439 fileinfo_list_destroy(files);
1440}
1441
1442/**********************************************************************/
1446{
1447 struct fileinfo_list *files;
1448 int row = 0;
1449
1450 scenarios_load->clearContents();
1451 scenarios_load->setRowCount(0);
1452 scenarios_text->setText("");
1453 scenarios_view->setText("");
1454
1455 files = fileinfolist_infix(get_scenario_dirs(), ".sav", false);
1457 struct section_file *sf;
1458
1459 if ((sf = secfile_load_section(pfile->fullname, "scenario", TRUE))
1460 && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) {
1461
1462 const char *sname, *sdescription, *sauthors;
1464 QString format;
1465 QString st;
1466 int fcver;
1467 int fcdev;
1468 int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000;
1470
1471 if (PATCH_VERSION >= 90) {
1472 // Patch level matters on development versions
1473 current_dev += PATCH_VERSION * 100;
1474 }
1475
1476 fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version");
1477 if (fcver < 30000) {
1478 /* Pre-3.0 versions stored version number without emergency version
1479 * part in the end. To get comparable version number stored,
1480 * multiply by 100. */
1481 fcver *= 100;
1482 }
1483 if (fcver % 10000 >= 9000) {
1484 fcdev = fcver - (fcver % 100); // Emergency version does not count.
1485 } else {
1486 fcdev = fcver - (fcver % 10000); // Patch version does not count.
1487 }
1488 sname = secfile_lookup_str_default(sf, NULL, "scenario.name");
1490 "scenario.description");
1492 "scenario.authors");
1493 // Ignore scenarios for newer freeciv versions than we are.
1494 if (fcdev <= current_dev) {
1495 QString version;
1496 bool add_item = true;
1497 bool found = false;
1499 int rows;
1500 int found_ver;
1501 int i;
1502
1503 if (fcver > 0) {
1504 int maj;
1505 int min;
1506
1507 maj = fcver / 1000000;
1508 fcver %= 1000000;
1509 min = fcver / 10000;
1510 fcver %= 10000;
1511 if (fcver >= 9000) {
1512 // Development version, have '+'
1513 version = QString("%1.%2+").arg(maj).arg(min);
1514 } else {
1515 version = QString("%1.%2").arg(maj).arg(min);
1516 }
1517 } else {
1518 // TRANS: Unknown scenario format
1519 version = QString(_("pre-2.6"));
1520 }
1521
1522 rows = scenarios_load->rowCount();
1523 for (i = 0; i < rows; ++i) {
1524 if (scenarios_load->item(i, 0)
1525 && scenarios_load->item(i, 0)->text() == pfile->name) {
1526 found = true;
1527 item = scenarios_load->takeItem(i, 0);
1528 break;
1529 }
1530 }
1531
1532 if (found) {
1533 sl = item->data(Qt::UserRole).toStringList();
1534 found_ver = sl.at(3).toInt();
1535 if (found_ver < fcver) {
1536 continue;
1537 }
1538 add_item = false;
1539 }
1540 if (add_item) {
1541 item = new QTableWidgetItem();
1542 scenarios_load->insertRow(row);
1543 }
1544 item->setText(QString(pfile->name));
1545 format = QString("<br>") + QString(_("Format:")) + " "
1546 + version.toHtmlEscaped();
1547 if (sauthors) {
1548 st = QString("\n") + QString("<b>") + _("Authors: ")
1549 + QString("</b>") + QString(sauthors).toHtmlEscaped();
1550 } else {
1551 st = "";
1552 }
1553 sl << "<b>"
1554 + QString(sname && strlen(sname) ? Q_(sname) : pfile->name)
1555 .toHtmlEscaped()
1556 + "</b>"
1557 << QString(pfile->fullname).toHtmlEscaped()
1558 << QString(NULL != sdescription && '\0' != sdescription[0]
1559 ? Q_(sdescription) : "").toHtmlEscaped() + st + format
1560 << QString::number(fcver).toHtmlEscaped();
1561 sl.replaceInStrings("\n", "<br>");
1562 item->setData(Qt::UserRole, sl);
1563 if (add_item) {
1564 scenarios_load->setItem(row, 0, item);
1565 row++;
1566 } else {
1567 scenarios_load->setItem(i, 0, item);
1568 }
1569 }
1570 secfile_destroy(sf);
1571 }
1573 fileinfo_list_destroy(files);
1574 scenarios_load->sortItems(0);
1575 scenarios_load->update();
1576}
1577
1578/**********************************************************************/
1583 const char *message)
1584{
1585 set_status_bar(QString::fromUtf8(message));
1587
1588 switch (type) {
1589 case AUTH_NEWUSER_FIRST:
1590 case AUTH_NEWUSER_RETRY:
1592 return;
1593 case AUTH_LOGIN_FIRST:
1594 /* if we magically have a password already present in 'fc_password'
1595 * then, use that and skip the password entry dialog */
1596 if (fc_password[0] != '\0') {
1598
1599 sz_strlcpy(reply.password, fc_password);
1601 return;
1602 } else {
1604 }
1605
1606 return;
1607 case AUTH_LOGIN_RETRY:
1609 return;
1610 }
1611
1612 log_error("Unsupported authentication type %d: %s.", type, message);
1613}
1614
1615/**********************************************************************/
1621{
1622 char errbuf [512];
1625
1626 switch (connection_status) {
1627 case LOGIN_TYPE:
1628 ba_bytes = connect_login_edit->text().toUtf8();
1629 sz_strlcpy(user_name, ba_bytes.data());
1630 ba_bytes = connect_host_edit->text().toUtf8();
1632 server_port = connect_port_edit->text().toInt();
1633
1635 errbuf, sizeof(errbuf)) != -1) {
1636 } else {
1637 set_status_bar(QString::fromUtf8(errbuf));
1639 }
1640
1641 return;
1642 case NEW_PASSWORD_TYPE:
1643 ba_bytes = connect_password_edit->text().toLatin1();
1645 ba_bytes = connect_confirm_password_edit->text().toLatin1();
1646 sz_strlcpy(reply.password,
1647 ba_bytes.data());
1648
1649 if (!fc_strncmp(reply.password, fc_password, MAX_LEN_NAME)) {
1650 fc_password[0] = '\0';
1653 } else {
1654 set_status_bar(_("Passwords don't match, enter password."));
1656 }
1657
1658 return;
1660 ba_bytes = connect_password_edit->text().toLatin1();
1661 sz_strlcpy(reply.password,
1662 ba_bytes.data());
1665 return;
1666 case WAITING_TYPE:
1667 return;
1668 }
1669
1670 log_error("Unsupported connection status: %d", connection_status);
1671}
1672
1673/**********************************************************************/
1678{
1679 int conn_num, i;
1681 bool is_ready;
1682 QString host, nation, leader, team, str;
1683 QPixmap *pixmap;
1684 QPainter p;
1685 struct sprite *psprite;
1693 int conn_id;
1694 bool svg = is_svg_flag_enabled();
1695
1697
1698 if (conn_num == 0) {
1699 return;
1700 }
1701
1702 start_players_tree->clear();
1703 qvar2 = 0;
1704
1706 player_item->setText(0, Q_("?header:Players"));
1707 player_item->setData(0, Qt::UserRole, qvar2);
1708
1709 i = 0;
1710 players_iterate(pplayer) {
1711 i++;
1714 // Inserts playing players, observing custom players, and AI)
1715
1716 players_iterate(pplayer) {
1717 host = "";
1718 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1719 conn_id = -1;
1720 conn_list_iterate(pplayer->connections, pconn) {
1721 if (pconn->playing == pplayer && !pconn->observer) {
1722 conn_id = pconn->id;
1723 host = pconn->addr;
1724 break;
1725 }
1727 if (is_barbarian(pplayer)) {
1728 continue;
1729 }
1730 if (is_ai(pplayer)) {
1731 is_ready = true;
1732 } else {
1733 is_ready = pplayer->is_ready;
1734 }
1735
1736 if (pplayer->nation == NO_NATION_SELECTED) {
1737 nation = _("Random");
1738
1739 if (pplayer->was_created) {
1740 leader = player_name(pplayer);
1741 } else {
1742 leader = "";
1743 }
1744 } else {
1745 nation = nation_adjective_for_player(pplayer);
1746 leader = player_name(pplayer);
1747 }
1748
1749 if (pplayer->team) {
1750 team = team_name_translation(pplayer->team);
1751 } else {
1752 team = "";
1753 }
1754
1755 item = new QTreeWidgetItem();
1756 for (int col = 0; col < 8; col++) {
1757 switch (col) {
1758 case 0:
1759 str = pplayer->username;
1760
1761 if (is_ai(pplayer)) {
1762 str = str + " <" + (ai_level_translated_name(pplayer->ai_common.skill_level))
1763 + ">";
1764 item->setIcon(col, fc_icons::instance()->get_icon("ai"));
1765 } else {
1766 item->setIcon(col, fc_icons::instance()->get_icon("human"));
1767 }
1768
1769 item->setText(col, str);
1770 qvar = QVariant::fromValue((void *) pplayer);
1771 qvar2 = 1;
1772 item->setData(0, Qt::UserRole, qvar2);
1773 item->setData(1, Qt::UserRole, qvar);
1774 break;
1775 case 1:
1776 if (is_ready) {
1777 item->setText(col, _("Yes"));
1778 } else {
1779 item->setText(col, _("No"));
1780 }
1781 break;
1782 case 2:
1783 item->setText(col, leader);
1784 break;
1785 case 3:
1786 if (!pplayer->nation) {
1787 break;
1788 }
1789 psprite = get_nation_flag_sprite(tileset, pplayer->nation);
1790 pixmap = psprite->pm;
1791 if (svg) {
1792 item->setData(col, Qt::DecorationRole, (*pixmap).scaledToHeight(50));
1793 } else {
1794 item->setData(col, Qt::DecorationRole, *pixmap);
1795 }
1796 break;
1797 case 4:
1798 if (!player_has_color(pplayer)) {
1799 break;
1800 }
1801 pixmap = new QPixmap(
1802 start_players_tree->header()->sectionSizeHint(col), 16);
1803 pixmap->fill(Qt::transparent);
1804 p.begin(pixmap);
1805 p.fillRect(pixmap->width() / 2 - 8, 0, 16, 16, Qt::black);
1806 p.fillRect(pixmap->width() / 2 - 7, 1, 14, 14,
1807 get_player_color(tileset, pplayer)->qcolor);
1808 p.end();
1809 item->setData(col, Qt::DecorationRole, *pixmap);
1810 delete pixmap;
1811 break;
1812 case 5:
1813 item->setText(col, nation);
1814 break;
1815 case 6:
1816 item->setText(col, team);
1817 break;
1818 case 7:
1819 item->setText(col, host);
1820 break;
1821 default:
1822 break;
1823 }
1824 }
1825
1826 // Find any custom observers
1827 recursed_items.clear();
1828 conn_list_iterate(pplayer->connections, pconn) {
1829 if (pconn->id == conn_id) {
1830 continue;
1831 }
1832 item_r = new QTreeWidgetItem();
1833 item_r->setText(0, pconn->username);
1834 item_r->setText(5, _("Observer"));
1835 item_r->setText(7, pconn->addr);
1836 recursed_items.append(item_r);
1837 item->addChildren(recursed_items);
1839 items.append(item);
1840 }
1842
1843 player_item->addChildren(items);
1844 start_players_tree->insertTopLevelItem(0, player_item);
1845
1846 // Insert global observers
1847 items.clear();
1849 global_item->setText(0, _("Global observers"));
1850 qvar2 = 0;
1851 global_item->setData(0, Qt::UserRole, qvar2);
1852
1854 if (NULL != pconn->playing || !pconn->observer) {
1855 continue;
1856 }
1857 item = new QTreeWidgetItem();
1858 for (int col = 0; col < 8; col++) {
1859 switch (col) {
1860 case 0:
1861 item->setText(col, pconn->username);
1862 break;
1863 case 5:
1864 item->setText(col, _("Observer"));
1865 break;
1866 case 7:
1867 item->setText(col, pconn->addr);
1868 break;
1869 default:
1870 break;
1871 }
1872 items.append(item);
1873 }
1875
1876 global_item->addChildren(items);
1877 start_players_tree->insertTopLevelItem(1, global_item);
1878 items.clear();
1879
1880 // Insert detached
1882 detach_item->setText(0, _("Detached"));
1883 qvar2 = 0;
1884 detach_item->setData(0, Qt::UserRole, qvar2);
1885
1887 if (NULL != pconn->playing || pconn->observer) {
1888 continue;
1889 }
1890 item = new QTreeWidgetItem();
1891 item->setText(0, pconn->username);
1892 item->setText(7, pconn->addr);
1893 items.append(item);
1895
1896 detach_item->addChildren(items);
1897 start_players_tree->insertTopLevelItem(2, detach_item);
1898 start_players_tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
1899 start_players_tree->expandAll();
1901}
1902
1903/**********************************************************************/
1907{
1908 bool sensitive;
1909 QString text;
1910
1911 // Observe button
1913 obs_button->setText(_("Don't Observe"));
1914 } else {
1915 obs_button->setText(_("Observe"));
1916 }
1917
1918 // Ready button
1919 if (can_client_control()) {
1920 sensitive = client_player()->is_alive;
1921 if (client_player()->is_ready) {
1922 text = _("Not ready");
1923 } else {
1924 int num_unready = 0;
1925
1926 players_iterate_alive(pplayer) {
1927 if (is_human(pplayer) && !pplayer->is_ready) {
1928 num_unready++;
1929 }
1931
1932 if (num_unready > 1) {
1933 text = _("Ready");
1934 } else {
1935 /* We are the last unready player so clicking here will
1936 * immediately start the game. */
1937 text = _("Start");
1938 }
1939 }
1940 } else {
1941 text = _("Start");
1943 sensitive = true;
1945 if (is_human(plr)) {
1946 /* There's human controlled player(s) in game, so it's their
1947 * job to start the game. */
1948 sensitive = false;
1949 break;
1950 }
1952 } else {
1953 sensitive = false;
1954 }
1955 }
1956 start_button->setEnabled(sensitive);
1957 start_button->setText(text);
1958
1959 // Nation button
1961 nation_button->setEnabled(sensitive);
1962
1964 pr_options->setEnabled(sensitive);
1965
1968}
1969
1970/**********************************************************************/
1974{
1975 QAction *action;
1976 QPoint global_pos = start_players_tree->mapToGlobal(pos);
1977 QString me, splayer, str, sp;
1978 bool need_empty_team;
1979 const char *level_cmd, *level_name;
1980 int level, count;
1982
1985
1986 if (item == nullptr) {
1987 return;
1988 }
1989
1990 qvar = item->data(0, Qt::UserRole);
1991 qvar2 = item->data(1, Qt::UserRole);
1992
1998 if (qvar == 1) {
1999 player *pplayer = (player *) qvar2.value < void *>();
2000
2001 if (pplayer != nullptr) {
2002 QMenu *page_menu = new QMenu(this);
2003
2004 page_submenu_AI = new QMenu(this);
2005 page_submenu_team = new QMenu(this);
2006
2007 splayer = QString(pplayer->name);
2008 sp = "\"" + splayer + "\"";
2009 if (me != splayer) {
2010 str = QString(_("Observe"));
2012 str = "/observe " + sp;
2013 QObject::connect(action, &QAction::triggered, [this,str]() {
2015 });
2016 page_menu->addAction(action);
2017
2019 str = QString(_("Remove player"));
2021 str = "/remove " + sp;
2022 QObject::connect(action, &QAction::triggered, [this,str]() {
2024 });
2025 page_menu->addAction(action);
2026 }
2027 str = QString(_("Take this player"));
2029 str = "/take " + sp;
2030 QObject::connect(action, &QAction::triggered, [this,str]() {
2032 });
2033 page_menu->addAction(action);
2034 }
2035
2036 if (can_conn_edit_players_nation(&client.conn, pplayer)) {
2037 str = QString(_("Pick nation"));
2039 str = "PICK:" + QString(player_name(pplayer)); // PICK is a key
2040 QObject::connect(action, &QAction::triggered, [this,str]() {
2042 });
2043 page_menu->addAction(action);
2044 }
2045
2046 if (is_ai(pplayer)) {
2047 // Set AI difficulty submenu
2049 page_submenu_AI->setTitle(_("Set difficulty"));
2050 page_menu->addMenu(page_submenu_AI);
2051
2052 for (level = 0; level < AI_LEVEL_COUNT; level++) {
2053 if (is_settable_ai_level(static_cast < ai_level > (level))) {
2054 level_name = ai_level_translated_name(static_cast < ai_level > (level));
2055 level_cmd = ai_level_cmd(static_cast < ai_level > (level));
2057 str = "/" + QString(level_cmd) + " " + sp;
2058 QObject::connect(action, &QAction::triggered, [this,str]() {
2060 });
2061 page_submenu_AI->addAction(action);
2062 }
2063 }
2064 }
2065 }
2066
2067 // Put to Team X submenu
2068 if (game.info.is_new_game) {
2069 page_menu->addMenu(page_submenu_team);
2070 page_submenu_team->setTitle(_("Put on team"));
2071 page_menu->addMenu(page_submenu_team);
2072 count = pplayer->team ?
2073 player_list_size(team_members(pplayer->team)) : 0;
2074 need_empty_team = (count != 1);
2076 if (!team_slot_is_used(tslot)) {
2077 if (!need_empty_team) {
2078 continue;
2079 }
2080 need_empty_team = false;
2081 }
2084 str = "/team" + sp + " \"" + QString(team_slot_rule_name(tslot))
2085 + "\"";
2086 QObject::connect(action, &QAction::triggered, [this,str]() {
2088 });
2089 page_submenu_team->addAction(action);
2091 }
2092
2094 str = QString(_("Aitoggle player"));
2096 str = "/aitoggle " + sp;
2097 QObject::connect(action, &QAction::triggered, [this,str]() {
2099 });
2100 page_menu->addAction(action);
2101 }
2102
2103 page_menu->popup(global_pos);
2104 }
2105 }
2106}
2107
2108/**********************************************************************/
2115
2116/**********************************************************************/
2120{
2121 sw_map->set_pixmap(fc_icons::instance()->get_pixmap("view"));
2122 sw_cunit->set_pixmap(fc_icons::instance()->get_pixmap("units"));
2123 sw_cities->set_pixmap(fc_icons::instance()->get_pixmap("cities"));
2124 sw_diplo->set_pixmap(fc_icons::instance()->get_pixmap("nations"));
2125 sw_science->set_pixmap(fc_icons::instance()->get_pixmap("research"));
2126 sw_economy->set_pixmap(fc_icons::instance()->get_pixmap("economy"));
2127 sw_endturn->set_pixmap(fc_icons::instance()->get_pixmap("endturn"));
2128 sidebar_wdg->resize_me(game_tab_widget->height(), true);
2129}
2130
2131/**********************************************************************/
2135{
2136 QString str;
2137 int max;
2139 char buf[256];
2140
2143
2144 if (current_page() != PAGE_GAME) {
2145 return;
2146 }
2147
2148 if (NULL != client.conn.playing) {
2150 } else {
2151 max = 100;
2152 }
2153
2157 str = str + '\n' + get_info_label_text(false);
2159 str = QString(_("Tax: %1% Science: %2% Luxury: %3%\n"))
2163
2164 str += QString(_("%1 - max rate: %2%")).
2166 QString::number(max));
2167
2170 &building_total, &tax);
2171 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
2172 tax, building_total + unit_total);
2177 }
2178 } else {
2179 sw_tax->set_tooltip("");
2181 sw_map->set_tooltip("");
2183 }
2185}
2186
2187/**********************************************************************/
2191{
2192 bool center_next = false;
2193 bool first_tile = false;
2194 int first_id;
2195 struct tile *ptile = nullptr;
2196
2197 players_iterate(pplayer) {
2198 if (pplayer != client_player()) {
2199 city_list_iterate(pplayer->cities, pcity) {
2200 if (!first_tile) {
2201 first_tile = true;
2202 ptile = pcity->tile;
2203 first_id = pcity->id;
2204 }
2205 if ((last_center_enemy_city == 0) || center_next) {
2206 last_center_enemy_city = pcity->id;
2207 center_tile_mapcanvas(pcity->tile);
2208 return;
2209 }
2210 if (pcity->id == last_center_enemy_city) {
2211 center_next = true;
2212 }
2214 }
2216
2217 if (ptile != nullptr) {
2218 center_tile_mapcanvas(ptile);
2220 }
2221}
2222
2223/**********************************************************************/
2227{
2228 bool center_next = false;
2229 bool first_tile = false;
2230 int first_id;
2231 struct tile *ptile = nullptr;
2232
2233 players_iterate(pplayer) {
2234 if (pplayer == client_player()) {
2235 city_list_iterate(pplayer->cities, pcity) {
2236 if (!first_tile) {
2237 first_tile = true;
2238 ptile = pcity->tile;
2239 first_id = pcity->id;
2240 }
2241 if ((last_center_player_city == 0) || center_next) {
2242 last_center_player_city = pcity->id;
2243 center_tile_mapcanvas(pcity->tile);
2244 return;
2245 }
2246 if (pcity->id == last_center_player_city) {
2247 center_next = true;
2248 }
2250 }
2252
2253 if (ptile != nullptr) {
2254 center_tile_mapcanvas(ptile);
2256 }
2257}
2258
2259/**********************************************************************/
2263{
2264 struct city *capital;
2265 bool center_next = false;
2266 bool first_tile = false;
2267 int first_id;
2268 struct tile *ptile = nullptr;
2269
2270 players_iterate(pplayer) {
2271 if (pplayer != client_player()) {
2272 capital = player_primary_capital(pplayer);
2273 if (capital == nullptr) {
2274 continue;
2275 }
2276 if (!first_tile) {
2277 first_tile = true;
2278 ptile = capital->tile;
2279 first_id = capital->id;
2280 }
2281 if ((last_center_player_city == 0) || center_next) {
2282 last_center_player_city = capital->id;
2283 center_tile_mapcanvas(capital->tile);
2284 put_cross_overlay_tile(capital->tile);
2285 return;
2286 }
2287 if (capital->id == last_center_player_city) {
2288 center_next = true;
2289 }
2290 }
2292
2293 if (ptile != nullptr) {
2294 center_tile_mapcanvas(ptile);
2297 }
2298
2299}
2300
2301/**********************************************************************/
2305{
2306 pages_layout[PAGE_GAME]->removeWidget(gui()->sidebar_wdg);
2308 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 0);
2309 } else {
2310 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 2);
2311 }
2312}
2313
2314/**********************************************************************/
2318{
2319 bool center_next = false;
2320 bool first_tile = false;
2321 int first_id;
2322 struct tile *ptile = nullptr;
2323
2324 players_iterate(pplayer) {
2325 if (pplayer != client_player()) {
2326 unit_list_iterate(pplayer->units, punit) {
2327 if (!first_tile) {
2328 first_tile = true;
2329 ptile = punit->tile;
2330 first_id = punit->id;
2331 }
2332 if ((last_center_enemy == 0) || center_next) {
2335 return;
2336 }
2337 if (punit->id == last_center_enemy) {
2338 center_next = true;
2339 }
2341 }
2343
2344 if (ptile != nullptr) {
2345 center_tile_mapcanvas(ptile);
2347 }
2348}
int entries_used
Definition agents.c:77
#define str
Definition astring.c:76
#define n
Definition astring.c:77
void qtg_version_message(const char *vertext)
Definition chatline.cpp:806
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)
Definition city.h:508
#define city_list_iterate_end
Definition city.h:510
fc_game_tab_widget * game_tab_widget
Definition fc_client.h:259
QStringList status_bar_queue
Definition fc_client.h:351
void handle_authentication_req(enum authentication_type type, const char *message)
Definition pages.cpp:1582
QLineEdit * connect_host_edit
Definition fc_client.h:188
fc_sidewidget * sw_tax
Definition fc_client.h:222
void update_buttons()
Definition pages.cpp:1906
QTextEdit * output_window
Definition fc_client.h:181
void update_sidebar_tooltips()
Definition pages.cpp:2134
goto_dialog * gtd
Definition fc_client.h:265
fc_sidewidget * sw_economy
Definition fc_client.h:223
QTimer * meta_scan_timer
Definition fc_client.h:212
hud_battle_log * battlelog_wdg
Definition fc_client.h:272
QPushButton * start_button
Definition fc_client.h:196
void start_from_save()
Definition pages.cpp:1132
QWidget * connect_lan
Definition fc_client.h:174
int add_game_tab(QWidget *widget)
Definition pages.cpp:811
fc_sidewidget * sw_science
Definition fc_client.h:275
QTableWidget * lan_widget
Definition fc_client.h:205
void browse_saves()
Definition pages.cpp:831
QWidget * connect_metaserver
Definition fc_client.h:175
QWidget * game_main_widget
Definition fc_client.h:176
QLineEdit * connect_confirm_password_edit
Definition fc_client.h:192
chat_input * chat_line
Definition fc_client.h:203
hud_units * unitinfo_wdg
Definition fc_client.h:271
pregamevote * pre_vote
Definition fc_client.h:262
QPushButton * nation_button
Definition fc_client.h:197
QTableWidget * saves_load
Definition fc_client.h:208
void set_status_bar(QString str, int timeout=2000)
Definition pages.cpp:451
QPushButton * button
Definition fc_client.h:194
QCheckBox * show_preview
Definition fc_client.h:186
fc_sidewidget * sw_cunit
Definition fc_client.h:274
enum client_pages current_page()
bool check_server_scan(server_scan *scan_data)
Definition pages.cpp:1045
QLineEdit * connect_password_edit
Definition fc_client.h:191
void quit()
minimap_view * minimapview_wdg
Definition fc_client.h:232
void reload_sidebar_icons()
Definition pages.cpp:2119
QTableWidget * wan_widget
Definition fc_client.h:206
void slot_pick_nation()
Definition pages.cpp:2111
map_view * mapview_wdg
Definition fc_client.h:230
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
Definition pages.cpp:1150
fc_sidewidget * sw_indicators
Definition fc_client.h:277
QMenu * page_submenu_AI
Definition fc_client.h:281
info_tab * infotab
Definition fc_client.h:261
QLabel * scenarios_text
Definition fc_client.h:183
QLabel * load_save_text
Definition fc_client.h:184
void create_start_page()
Definition pages.cpp:641
void slot_disconnect()
void clear_status_bar()
Definition pages.cpp:467
fc_sidewidget * sw_endturn
Definition fc_client.h:276
void slot_pregame_observe()
void state_preview(int)
Definition pages.cpp:847
QTableWidget * info_widget
Definition fc_client.h:207
void set_connection_state(enum connection_state state)
Definition pages.cpp:266
QPushButton * obs_button
Definition fc_client.h:195
QLabel * load_pix
Definition fc_client.h:185
QLabel * status_bar_label
Definition fc_client.h:217
QGridLayout * pages_layout[PAGE_GAME+2]
Definition fc_client.h:178
QLineEdit * connect_login_edit
Definition fc_client.h:190
QTextEdit * scenarios_view
Definition fc_client.h:182
void destroy_server_scans(void)
Definition pages.cpp:996
void update_sidebar_position()
Definition pages.cpp:2304
QMenu * page_submenu_team
Definition fc_client.h:282
void switch_page(int i)
void create_network_page()
Definition pages.cpp:303
QTreeWidget * start_players_tree
Definition fc_client.h:210
void create_load_page()
Definition pages.cpp:495
QTimer * lan_scan_timer
Definition fc_client.h:213
void update_start_page()
Definition pages.cpp:1677
QLineEdit * connect_port_edit
Definition fc_client.h:189
fc_sidebar * sidebar_wdg
Definition fc_client.h:231
void create_main_page()
Definition pages.cpp:138
void create_loading_page()
Definition pages.cpp:483
void start_page_menu(QPoint)
Definition pages.cpp:1973
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
Definition pages.cpp:882
void update_network_lists()
Definition pages.cpp:1026
QWidget * central_wdg
Definition fc_client.h:256
void slot_meta_scan()
Definition pages.cpp:1090
QString current_file
Definition fc_client.h:352
void slot_lan_scan()
Definition pages.cpp:1079
xvote * x_vote
Definition fc_client.h:264
void browse_scenarios()
Definition pages.cpp:865
void slot_pregame_start()
fc_sidewidget * sw_cities
Definition fc_client.h:221
void popup_client_options()
void slot_connect()
Definition pages.cpp:1620
fc_sidewidget * sw_map
Definition fc_client.h:220
void update_load_page(void)
Definition pages.cpp:1414
void start_scenario()
Definition pages.cpp:1114
pregame_options * pr_options
Definition fc_client.h:267
QTableWidget * scenarios_load
Definition fc_client.h:209
void rm_game_tab(int index)
Definition pages.cpp:823
void send_fake_chat_message(const QString &message)
fc_sidewidget * sw_diplo
Definition fc_client.h:278
void create_scenario_page()
Definition pages.cpp:574
void start_new_game()
Definition pages.cpp:1101
void update_scenarios_page(void)
Definition pages.cpp:1445
void create_game_page()
Definition pages.cpp:725
QIcon get_icon(const QString &id)
static fc_icons * instance()
void resize_me(int height, bool force=false)
Definition sidebar.cpp:570
void add_widget(fc_sidewidget *fsw)
Definition sidebar.cpp:537
void set_wheel_down(pfcn func)
Definition sidebar.cpp:287
void set_wheel_up(pfcn func)
Definition sidebar.cpp:295
void set_pixmap(QPixmap *pm)
Definition sidebar.cpp:120
void set_right_click(pfcn func)
Definition sidebar.cpp:279
void set_tooltip(QString tooltip)
Definition sidebar.cpp:160
void set_aifill(int aifill)
bool can_client_control(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
char user_name[512]
char server_host[512]
struct civclient client
char fc_password[MAX_LEN_PASSWORD]
int server_port
#define client_player()
static struct fc_sockaddr_list * list
Definition clinet.c:102
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
Definition clinet.c:249
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
bool player_has_color(const struct player *pplayer)
char * incite_cost
Definition comments.c:75
authentication_type
Definition conn_types.h:41
@ AUTH_NEWUSER_RETRY
Definition conn_types.h:45
@ AUTH_NEWUSER_FIRST
Definition conn_types.h:43
@ AUTH_LOGIN_RETRY
Definition conn_types.h:44
@ AUTH_LOGIN_FIRST
Definition conn_types.h:42
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
void key_unit_wait(void)
Definition control.c:3542
void key_center_capital(void)
Definition control.c:3295
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
connection_state
Definition fc_client.h:55
@ LOGIN_TYPE
Definition fc_client.h:56
@ NEW_PASSWORD_TYPE
Definition fc_client.h:57
@ WAITING_TYPE
Definition fc_client.h:59
@ ENTER_PASSWORD_TYPE
Definition fc_client.h:58
class fc_client * gui()
Definition gui_main.cpp:84
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
void fc_mutex_allocate(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
const char * government_name_for_player(const struct player *pplayer)
Definition government.c:154
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
static struct tile * pos
Definition finddlg.c:53
void put_cross_overlay_tile(struct tile *ptile)
Definition mapview.c:643
static struct server_scan_timer_data meta_scan
Definition pages.c:86
static enum connection_state connection_status
Definition pages.c:859
static struct server_scan_timer_data lan_scan
Definition pages.c:87
connection_state
Definition pages.c:852
static void server_scan_error(struct server_scan *scan, const char *message)
Definition pages.c:825
static bool holding_srv_list_mutex
Definition pages.c:95
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
GType type
Definition repodlgs.c:1313
static struct server_list * server_list
Definition connectdlg.c:61
#define B_LAST
Definition improvement.h:42
#define log_error(message,...)
Definition log.h:103
#define nat_x
#define nat_y
void center_tile_mapcanvas(const struct tile *ptile)
static mpgui * gui
Definition mpgui_qt.cpp:52
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
Definition nation.c:1187
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
#define NO_NATION_SELECTED
Definition nation.h:30
struct client_options gui_options
Definition options.c:71
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
const char * get_government_tooltip(void)
Definition text.c:1478
const char * text_happiness_cities(const struct city *pcity)
Definition text.c:1900
void qtg_real_set_client_page(enum client_pages page)
Definition pages.cpp:104
int last_center_capital
Definition pages.cpp:68
int last_center_enemy
Definition pages.cpp:81
static void center_next_enemy_city()
Definition pages.cpp:2190
enum client_pages qtg_get_current_client_page()
Definition pages.cpp:122
static void center_next_player_city()
Definition pages.cpp:2226
void popup_shortcuts_dialog()
static enum connection_state connection_status
Definition pages.cpp:78
static struct server_scan * meta_scan
Definition pages.cpp:76
void qtg_set_rulesets(int num_rulesets, char **rulesets)
Definition pages.cpp:114
int last_center_player_city
Definition pages.cpp:69
const char * get_info_label_text_popup(void)
Definition text.c:969
void toggle_units_report(bool)
static bool holding_srv_list_mutex
Definition pages.cpp:77
const char * science_dialog_text(void)
Definition text.c:741
static void cycle_enemy_units()
Definition pages.cpp:2317
static struct terrain * char2terrain(char ch)
Definition pages.cpp:87
int last_center_enemy_city
Definition pages.cpp:70
const char * get_nuclear_winter_tooltip(void)
Definition text.c:1451
void server_scan_error(struct server_scan *scan, const char *message)
Definition pages.cpp:983
const char * get_bulb_tooltip(void)
Definition text.c:1367
const char * get_info_label_text(bool)
Definition text.c:917
const char * get_global_warming_tooltip(void)
Definition text.c:1424
void update_start_page(void)
Definition pages.cpp:130
static struct server_scan * lan_scan
Definition pages.cpp:76
static void center_next_player_capital()
Definition pages.cpp:2262
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1919
const char * player_name(const struct player *pplayer)
Definition player.c:895
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1990
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
#define ai_level_cmd(_level_)
Definition player.h:567
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
static bool is_barbarian(const struct player *pplayer)
Definition player.h:489
#define is_ai(plr)
Definition player.h:230
#define players_iterate_alive_end
Definition player.h:547
#define is_human(plr)
Definition player.h:229
#define players_iterate_alive(_pplayer)
Definition player.h:542
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)
Definition savegame2.c:1331
struct srv_list * server_scan_get_list(struct server_scan *scan)
Definition servers.c:866
void server_scan_finish(struct server_scan *scan)
Definition servers.c:879
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
Definition servers.c:755
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
Definition servers.c:809
enum server_scan_status server_scan_poll(struct server_scan *scan)
Definition servers.c:832
#define server_list_iterate_end
Definition servers.h:57
server_scan_status
Definition servers.h:79
@ SCAN_STATUS_PARTIAL
Definition servers.h:82
@ SCAN_STATUS_ERROR
Definition servers.h:80
@ SCAN_STATUS_DONE
Definition servers.h:83
#define server_list_iterate(serverlist, pserver)
Definition servers.h:55
server_scan_type
Definition servers.h:67
@ SERVER_SCAN_LOCAL
Definition servers.h:68
@ SERVER_SCAN_GLOBAL
Definition servers.h:69
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
const struct strvec * get_scenario_dirs(void)
Definition shared.c:978
const struct strvec * get_save_dirs(void)
Definition shared.c:941
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
Definition shared.c:1211
#define fileinfo_list_iterate(list, pnode)
Definition shared.h:176
#define fileinfo_list_iterate_end
Definition shared.h:178
void side_center_unit()
Definition sidebar.cpp:649
void side_show_map(bool nothing)
Definition sidebar.cpp:623
void side_indicators_menu()
Definition sidebar.cpp:701
void side_left_click_science(bool nothing)
Definition sidebar.cpp:809
void side_rates_wdg(bool nothing)
Definition sidebar.cpp:639
void side_finish_turn(bool nothing)
Definition sidebar.cpp:631
void side_right_click_science(void)
Definition sidebar.cpp:760
void side_right_click_diplomacy(void)
Definition sidebar.cpp:715
@ SW_TAX
Definition sidebar.h:26
@ SW_INDICATORS
Definition sidebar.h:26
Definition city.h:320
int id
Definition city.h:326
enum capital_type capital
Definition city.h:328
struct tile * tile
Definition city.h:322
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
struct conn_list * all_connections
Definition game.h:96
struct connection conn
Definition client_main.h:96
bool gui_qt_show_preview
Definition options.h:406
bool gui_qt_sidebar_left
Definition options.h:408
Definition colors.h:21
struct player * playing
Definition connection.h:151
enum cmdlevel access_level
Definition connection.h:177
bool observer
Definition connection.h:147
char username[MAX_LEN_NAME]
Definition connection.h:164
Definition mapimg.c:367
Definition climisc.h:82
struct team * team
Definition player.h:259
struct player_economic economic
Definition player.h:282
char name[MAX_LEN_NAME]
Definition player.h:249
int g
Definition rgbcolor.h:34
int b
Definition rgbcolor.h:34
int r
Definition rgbcolor.h:34
fc_mutex mutex
Definition servers.h:64
struct server_list * servers
Definition servers.h:63
Definition team.c:40
Definition tile.h:50
int id
Definition unit.h:145
struct tile * tile
Definition unit.h:140
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
#define is_svg_flag_enabled()
Definition svgflag.h:30
const char * team_name_translation(const struct team *pteam)
Definition team.c:420
const char * team_slot_name_translation(const struct team_slot *tslot)
Definition team.c:253
const struct player_list * team_members(const struct team *pteam)
Definition team.c:456
bool team_slot_is_used(const struct team_slot *tslot)
Definition team.c:162
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233
#define team_slots_iterate_end
Definition team.h:77
#define team_slots_iterate(_tslot)
Definition team.h:72
struct terrain * terrain_by_rule_name(const char *name)
Definition terrain.c:186
#define terrain_type_iterate(_p)
Definition terrain.h:373
#define T_UNKNOWN
Definition terrain.h:57
#define TERRAIN_UNKNOWN_IDENTIFIER
Definition terrain.h:195
#define terrain_type_iterate_end
Definition terrain.h:379
const char * tileset_main_intro_filename(const struct tileset *t)
Definition tilespec.c:947
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6756
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
#define U_LAST
Definition unittype.h:40
const char * fc_git_revision(void)
Definition version.c:75
const char * unstable_message(void)
Definition version.c:160
const char * word_version(void)
Definition version.c:62