Freeciv-3.3
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 "repodlgs_g.h"
52#include "sidebar.h"
53#include "sprite.h"
54#include "voteinfo_bar.h"
55
56extern "C" {
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 == nullptr) {
162 // TRANS: "version 3.1.0, Qt5 client"
163#ifdef FC_QT5_MODE
164 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt5 client"),
166#elif defined(FC_QT6X_MODE)
167 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt6x client"),
169#else // FC_QT5_MODE
170 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt6 client"),
172#endif // FC_QT5_MODE
173 } else {
174 fc_snprintf(msgbuf, sizeof(msgbuf), "%s%s",
176 painter.drawText(10,
177 main_graphics.height() - fm.descent() - fm.height() * 2,
178 msgbuf);
179
180 // TRANS: "commit: [modified] <git commit id>"
181 fc_snprintf(msgbuf, sizeof(msgbuf), _("commit: %s"), rev_ver);
182 painter.drawText(10,
183 main_graphics.height() - fm.descent() - fm.height(),
184 msgbuf);
185
186#ifdef FC_QT5_MODE
187 strncpy(msgbuf, _("Qt5 client"), sizeof(msgbuf) - 1);
188#elif defined(FC_QT6X_MODE)
189 strncpy(msgbuf, _("Qt6x client"), sizeof(msgbuf) - 1);
190#else // FC_QT5_MODE
191 strncpy(msgbuf, _("Qt6 client"), sizeof(msgbuf) - 1);
192#endif // FC_QT5_MODE
193 }
194
195 painter.drawText(main_graphics.width() - fm.horizontalAdvance (msgbuf)
196 -10, main_graphics.height() - fm.descent(), msgbuf);
197 free_main_pic->setPixmap(main_graphics);
199 row++, 0, 1, 2, Qt::AlignCenter);
200
201#if IS_BETA_VERSION || IS_DEVEL_VERSION
202 warn_color.setColor(QPalette::WindowText, Qt::red);
203 unstable_label->setPalette(warn_color);
204 unstable_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
205 unstable_label->setAlignment(Qt::AlignCenter);
207 row++, 0, 1, 2, Qt::AlignHCenter);
208#endif // IS_BETA_VERSION || IS_DEVEL_VERSION
209
210 buttons_names << _("Start new game") << _("Start scenario game")
211 << _("Load saved game") << _("Connect to network game")
212 << _("Options") << _("Quit");
213
214 buttons_nr = buttons_names.count();
215
216 for (int iter = 0; iter < buttons_nr; iter++) {
217 button = new QPushButton(buttons_names[iter]);
218
219 switch (iter) {
220 case 0:
221 pages_layout[PAGE_MAIN]->addWidget(button, row + 1, 0);
222 button->setToolTip(
223 _("Launches local server, and connects to it for a single-player game."));
224 connect(button, &QAbstractButton::clicked, this, &fc_client::start_new_game);
225 break;
226 case 1:
227 pages_layout[PAGE_MAIN]->addWidget(button, row + 2, 0);
228 button->setToolTip(
229 _("Loads one of the scenarios for a single-player game. "
230 "Tutorial is one of the scenarios."));
231 QObject::connect(button, &QPushButton::clicked, [this]() {
233 });
234 break;
235 case 2:
236 pages_layout[PAGE_MAIN]->addWidget(button, row + 3, 0);
237 button->setToolTip(
238 _("Continues previously saved single-player game."));
239 QObject::connect(button, &QPushButton::clicked, [this]() {
241 });
242 break;
243 case 3:
244 pages_layout[PAGE_MAIN]->addWidget(button, row + 1, 1);
245 button->setToolTip(
246 _("Connects to outside server. "
247 "Sometimes you want to launch a separate server even for local games."));
248 QObject::connect(button, &QPushButton::clicked, [this]() {
250 });
251 break;
252 case 4:
253 pages_layout[PAGE_MAIN]->addWidget(button, row + 2, 1);
254 button->setToolTip(_("Adjusting client-side options."));
255 connect(button, &QAbstractButton::clicked, this, &fc_client::popup_client_options);
256 break;
257 case 5:
258 pages_layout[PAGE_MAIN]->addWidget(button, row + 3, 1);
259 button->setToolTip(_("Gives you a break from playing freeciv."));
260 QObject::connect(button, &QAbstractButton::clicked, this, &fc_client::quit);
261 break;
262 default:
263 break;
264 }
265 }
266}
267
268/**********************************************************************/
272{
273 switch (state) {
274 case LOGIN_TYPE:
275 set_status_bar("");
276 connect_password_edit->setText("");
277 connect_password_edit->setDisabled(true);
279 connect_confirm_password_edit->setDisabled(true);
280 break;
282 connect_password_edit->setText("");
284 connect_password_edit->setDisabled(false);
285 connect_confirm_password_edit->setDisabled(false);
286 connect_password_edit->setFocus(Qt::OtherFocusReason);
287 break;
289 connect_password_edit->setText("");
291 connect_password_edit->setDisabled(false);
292 connect_confirm_password_edit->setDisabled(true);
293 connect_password_edit->setFocus(Qt::OtherFocusReason);
294
295
296 break;
297 case WAITING_TYPE:
298 set_status_bar("");
299 break;
300 }
301
302 connection_status = state;
303}
304
305/**********************************************************************/
309{
310 QHeaderView *header;
311 QLabel *connect_msg;
312 QLabel *lan_label;
313 QPushButton *network_button;
314
320
321 connect_host_edit = new QLineEdit;
322 connect_port_edit = new QLineEdit;
323 connect_login_edit = new QLineEdit;
324 connect_password_edit = new QLineEdit;
325 connect_confirm_password_edit = new QLineEdit;
326
327 connect_password_edit->setEchoMode(QLineEdit::Password);
328 connect_confirm_password_edit->setEchoMode(QLineEdit::Password);
329
330 connect_password_edit->setDisabled(true);
331 connect_confirm_password_edit->setDisabled(true);
332 connect_lan = new QWidget;
333 connect_metaserver = new QWidget;
334 lan_widget = new QTableWidget;
335 wan_widget = new QTableWidget;
336 info_widget = new QTableWidget;
337
339 servers_list << _("Server Name") << _("Port") << _("Version")
340 << _("Status") << Q_("?count:Players") << _("Comment");
342 server_info << _("Name") << _("Type") << _("Host") << _("Nation");
343
344 lan_widget->setRowCount(0);
345 lan_widget->setColumnCount(servers_list.count());
346 lan_widget->verticalHeader()->setVisible(false);
347 lan_widget->setAutoScroll(false);
348
349 wan_widget->setRowCount(0);
350 wan_widget->setColumnCount(servers_list.count());
351 wan_widget->verticalHeader()->setVisible(false);
352 wan_widget->setAutoScroll(false);
353
354 info_widget->setRowCount(0);
355 info_widget->setColumnCount(server_info.count());
356 info_widget->verticalHeader()->setVisible(false);
357
358 lan_widget->setHorizontalHeaderLabels(servers_list);
359 lan_widget->setProperty("showGrid", "false");
360 lan_widget->setProperty("selectionBehavior", "SelectRows");
361 lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
362 lan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
363
364 wan_widget->setHorizontalHeaderLabels(servers_list);
365 wan_widget->setProperty("showGrid", "false");
366 wan_widget->setProperty("selectionBehavior", "SelectRows");
367 wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
368 wan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
369
370 connect(wan_widget->selectionModel(),
371 &QItemSelectionModel::selectionChanged, this,
373
374 connect(lan_widget->selectionModel(),
375 &QItemSelectionModel::selectionChanged, this,
377 connect(wan_widget, &QTableWidget::itemDoubleClicked, this,
379 connect(lan_widget, &QTableWidget::itemDoubleClicked, this,
381
382 info_widget->setHorizontalHeaderLabels(server_info);
383 info_widget->setProperty("selectionBehavior", "SelectRows");
384 info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
385 info_widget->setSelectionMode(QAbstractItemView::SingleSelection);
386 info_widget->setProperty("showGrid", "false");
387 info_widget->setAlternatingRowColors(true);
388
389 header = lan_widget->horizontalHeader();
390 header->setSectionResizeMode(0, QHeaderView::Stretch);
391 header->setStretchLastSection(true);
392 header = wan_widget->horizontalHeader();
393 header->setSectionResizeMode(0, QHeaderView::Stretch);
394 header->setStretchLastSection(true);
395 header = info_widget->horizontalHeader();
396 header->setSectionResizeMode(0, QHeaderView::Stretch);
397 header->setStretchLastSection(true);
398
400 label_names << _("Connect") << _("Port") << _("Login")
401 << _("Password") << _("Confirm Password");
402
403 for (int i = 0; i < label_names.count(); i++) {
404 connect_msg = new QLabel;
405 connect_msg->setText(label_names[i]);
406 page_network_grid_layout->addWidget(connect_msg, i, 0, Qt::AlignHCenter);
407 }
408
414 page_network_grid_layout->addWidget(info_widget, 0, 2, 5, 4);
415
416 network_button = new QPushButton(_("Refresh"));
417 QObject::connect(network_button, &QAbstractButton::clicked, this,
420
421 network_button = new QPushButton(_("Cancel"));
422 QObject::connect(network_button, &QPushButton::clicked, [this]() {
424 });
425 page_network_grid_layout->addWidget(network_button, 5, 2, 1, 1);
426
427 network_button = new QPushButton(_("Connect"));
428 page_network_grid_layout->addWidget(network_button, 5, 5, 1, 1);
429 connect(network_button, &QAbstractButton::clicked, this, &fc_client::slot_connect);
430 connect(connect_login_edit, &QLineEdit::returnPressed,
432 connect(connect_password_edit, &QLineEdit::returnPressed,
434 connect(connect_confirm_password_edit, &QLineEdit::returnPressed,
436
439 page_network_lan_layout->addWidget(lan_widget, 0);
440 page_network_wan_layout->addWidget(wan_widget, 1);
441 lan_label = new QLabel(_("Internet servers:"));
442 page_network_layout->addWidget(lan_label, 1);
443 page_network_layout->addWidget(wan_widget, 10);
444 lan_label = new QLabel(_("Local servers:"));
445 page_network_layout->addWidget(lan_label, 1);
446 page_network_layout->addWidget(lan_widget, 1);
447 page_network_grid_layout->setColumnStretch(3, 4);
450
451}
452
453/**********************************************************************/
457{
458 if (status_bar_label->text().isEmpty()) {
459 status_bar_label->setText(message);
460 QTimer::singleShot(timeout, this, SLOT(clear_status_bar()));
461 } else {
463 while (status_bar_queue.count() > 3) {
464 status_bar_queue.removeFirst();
465 }
466 }
467}
468
469/**********************************************************************/
473{
474 QString str;
475
476 if (!status_bar_queue.isEmpty()) {
477 str = status_bar_queue.takeFirst();
478 status_bar_label->setText(str);
479 QTimer::singleShot(2000, this, SLOT(clear_status_bar()));
480 } else {
481 status_bar_label->setText("");
482 }
483}
484
485/**********************************************************************/
489{
490 QLabel *label = new QLabel(_("Loading..."));
491
493 pages_layout[PAGE_GAME + 1]->addWidget(label, 0, 0, 1, 1,
494 Qt::AlignHCenter);
495}
496
497/**********************************************************************/
501{
503 QPushButton *but;
504 QHeaderView *header;
505 QLabel *lbl_show_preview;
506 QWidget *wdg;
508
509 saves_load = new QTableWidget;
510 wdg = new QWidget;
511 hbox = new QHBoxLayout;
513 lbl_show_preview = new QLabel(_("Show preview"));
514 sav << _("Choose Saved Game to Load") << _("Date");
515 load_pix = new QLabel;
516 load_pix->setProperty("themed_border", true);
517 load_pix->setFixedSize(0 ,0);
518 load_save_text = new QLabel;
519 load_save_text->setTextFormat(Qt::RichText);
520 load_save_text->setWordWrap(true);
523 saves_load->setAlternatingRowColors(true);
524 saves_load->setRowCount(0);
525 saves_load->setColumnCount(sav.count());
526 saves_load->setHorizontalHeaderLabels(sav);
527 hbox->addWidget(show_preview);
528 hbox->addWidget(lbl_show_preview, Qt::AlignLeft);
529 wdg->setLayout(hbox);
530
531 saves_load->setProperty("showGrid", "false");
532 saves_load->setProperty("selectionBehavior", "SelectRows");
533 saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
534 saves_load->setSelectionMode(QAbstractItemView::SingleSelection);
535 saves_load->verticalHeader()->setVisible(false);
536
537 header = saves_load->horizontalHeader();
538 header->setSectionResizeMode(0, QHeaderView::Stretch);
539 header->setStretchLastSection(true);
540
541 pages_layout[PAGE_LOAD]->addWidget(saves_load, 0, 0, 1, 4);
542 connect(saves_load->selectionModel(),
543 &QItemSelectionModel::selectionChanged, this,
545#ifdef FC_QT6X_MODE
546 connect(show_preview, &QCheckBox::checkStateChanged, this,
548#else // FC_QT6X_MODE
549 connect(show_preview, &QCheckBox::stateChanged, this,
551#endif // FC_QT6X_MODE
552 pages_layout[PAGE_LOAD]->addWidget(wdg, 1, 0);
553 pages_layout[PAGE_LOAD]->addWidget(load_save_text, 2, 0, 1, 2);
554 pages_layout[PAGE_LOAD]->addWidget(load_pix, 2, 2, 1, 2);
555
556 but = new QPushButton;
557 but->setText(_("Browse..."));
558 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
559 connect(but, &QAbstractButton::clicked, this, &fc_client::browse_saves);
560 pages_layout[PAGE_LOAD]->addWidget(but, 3, 0);
561
562 but = new QPushButton;
563 but->setText(_("Cancel"));
564 but->setIcon(QApplication::style()->standardIcon(
565 QStyle::SP_DialogCancelButton));
566 connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
567 pages_layout[PAGE_LOAD]->addWidget(but, 3, 2);
568
569 but = new QPushButton;
570 but->setText(_("Load"));
571 but->setIcon(QApplication::style()->standardIcon(
572 QStyle::SP_DialogOkButton));
573 connect(but, &QAbstractButton::clicked, this, &fc_client::start_from_save);
574 pages_layout[PAGE_LOAD]->addWidget(but, 3, 3);
575 pages_layout[PAGE_LOAD]->setColumnStretch(3, 10);
576 pages_layout[PAGE_LOAD]->setColumnStretch(2, 10);
577 pages_layout[PAGE_LOAD]->setColumnStretch(0, 10);
578
579}
580
581/**********************************************************************/
585{
586 QPushButton *but;
587 QHeaderView *header;
589
591 scenarios_load = new QTableWidget;
593 scenarios_text = new QLabel;
594
595 scenarios_view->setObjectName("scenarios_view");
596 scenarios_text->setTextFormat(Qt::RichText);
597 scenarios_text->setWordWrap(true);
598 sav << _("Choose a Scenario");
599 scenarios_load->setRowCount(0);
600 scenarios_load->setColumnCount(sav.count());
601 scenarios_load->setHorizontalHeaderLabels(sav);
602 scenarios_load->setProperty("showGrid", "false");
603 scenarios_load->setProperty("selectionBehavior", "SelectRows");
604 scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
605 scenarios_load->setSelectionMode(QAbstractItemView::SingleSelection);
606 scenarios_load->verticalHeader()->setVisible(false);
607 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_load, 0, 0, 3, 3,
608 Qt::AlignLeft);
609 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_view, 1, 3, 2, 3);
610 pages_layout[PAGE_SCENARIO]->addWidget(scenarios_text, 0, 3, 1, 2,
611 Qt::AlignTop);
612 scenarios_view->setReadOnly(true);
613 scenarios_view->setWordWrapMode(QTextOption::WordWrap);
614 scenarios_text->setAlignment(Qt::AlignCenter);
615
616 header = scenarios_load->horizontalHeader();
617 header->setSectionResizeMode(0, QHeaderView::Stretch);
618 header->setStretchLastSection(true);
619 connect(scenarios_load->selectionModel(),
620 &QItemSelectionModel::selectionChanged, this,
622
623 but = new QPushButton;
624 but->setText(_("Browse..."));
625 but->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
626 connect(but, &QAbstractButton::clicked, this, &fc_client::browse_scenarios);
627 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 0);
628
629 but = new QPushButton;
630 but->setText(_("Cancel"));
631 but->setIcon(QApplication::style()->standardIcon(
632 QStyle::SP_DialogCancelButton));
633 connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
634 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 3);
635
636 pages_layout[PAGE_SCENARIO]->setColumnStretch(2, 10);
637 pages_layout[PAGE_SCENARIO]->setColumnStretch(4, 20);
638 pages_layout[PAGE_SCENARIO]->setColumnStretch(3, 20);
639 pages_layout[PAGE_SCENARIO]->setRowStretch(1, 5);
640 but = new QPushButton;
641 but->setText(_("Load Scenario"));
642 but->setIcon(QApplication::style()->standardIcon(
643 QStyle::SP_DialogOkButton));
644 connect(but, &QAbstractButton::clicked, this, &fc_client::start_scenario);
645 pages_layout[PAGE_SCENARIO]->addWidget(but, 4, 4);
646}
647
648/**********************************************************************/
652{
653 QPushButton *but;
654 QSplitter *splitter;
657 QWidget *up_widget;
658 QWidget *down_widget;
659 QFont f;
660
666 pr_options = new pregame_options(this);
667 chat_line = new chat_input;
668 chat_line->setProperty("doomchat", true);
670 output_window->setReadOnly(false);
671 f.setBold(true);
672 output_window->setFont(f);
673
674 pr_options->init();
675 player_widget_list << _("Name") << _("Ready") << Q_("?player:Leader")
676 << _("Flag") << _("Border") << _("Nation") << _("Team")
677 << _("Host");
678
679 start_players_tree->setColumnCount(player_widget_list.count());
680 start_players_tree->setHeaderLabels(player_widget_list);
681 start_players_tree->setContextMenuPolicy(Qt::CustomContextMenu);
682 start_players_tree->setProperty("selectionBehavior", "SelectRows");
683 start_players_tree->setEditTriggers(QAbstractItemView::NoEditTriggers);
684 start_players_tree->setRootIsDecorated(false);
685
686 connect(start_players_tree,
689
690 up_layout->addWidget(start_players_tree, 0, 0, 3, 6);
691 up_layout->addWidget(pr_options, 0, 6, 3, 2);
692 but = new QPushButton;
693 but->setText(_("Disconnect"));
694 but->setIcon(style()->standardPixmap(QStyle::SP_DialogCancelButton));
695 QObject::connect(but, &QAbstractButton::clicked, this, &fc_client::slot_disconnect);
696 down_layout->addWidget(but, 5, 4);
697 nation_button = new QPushButton;
698 nation_button->setText(_("Pick Nation"));
699 nation_button->setIcon(fc_icons::instance()->get_icon("flag"));
700 down_layout->addWidget(nation_button, 5, 5);
701 QObject::connect(nation_button, &QAbstractButton::clicked, this,
703
704 obs_button = new QPushButton;
705 obs_button->setText(_("Observe"));
706 obs_button->setIcon(fc_icons::instance()->get_icon("meeting-observer"));
707 down_layout->addWidget(obs_button, 5, 6);
708 QObject::connect(obs_button, &QAbstractButton::clicked, this,
710 start_button = new QPushButton;
711 start_button->setText(_("Start"));
712 start_button->setIcon(style()->standardPixmap(QStyle::SP_DialogOkButton));
713 down_layout->addWidget(start_button, 5, 7);
714 QObject::connect(start_button, &QAbstractButton::clicked, this,
716 pre_vote = new pregamevote;
717
718 down_layout->addWidget(pre_vote, 4, 0, 1, 4);
719 down_layout->addWidget(chat_line, 5, 0, 1, 4);
720 down_layout->addWidget(output_window, 3, 0, 1, 8);
721 splitter = new QSplitter;
722 up_widget = new QWidget();
723 down_widget = new QWidget();
724 up_widget->setLayout(up_layout);
725 down_widget->setLayout(down_layout);
726 splitter->addWidget(up_widget);
727 splitter->addWidget(down_widget);
728 splitter->setOrientation(Qt::Vertical);
729 pages_layout[PAGE_START]->addWidget(splitter);
730}
731
732/**********************************************************************/
736{
738
740 game_main_widget = new QWidget;
742 game_layout->setContentsMargins(0, 0, 0, 0);
743 game_layout->setSpacing(0);
744 mapview_wdg = new map_view();
745 mapview_wdg->setFocusPolicy(Qt::WheelFocus);
746 sidebar_wdg = new fc_sidebar();
747
748 sw_map = new fc_sidewidget(fc_icons::instance()->get_pixmap("view"),
749 Q_("?noun:View"), "MAP", side_show_map);
750 sw_tax = new fc_sidewidget(nullptr, nullptr, "", side_rates_wdg, SW_TAX);
751 sw_indicators = new fc_sidewidget(nullptr, nullptr, "", side_show_map,
754 sw_cunit = new fc_sidewidget(fc_icons::instance()->get_pixmap("units"),
755 _("Units"), "",
757 sw_cities = new fc_sidewidget(fc_icons::instance()->get_pixmap("cities"),
758 _("Cities"), "CTS",
762 sw_diplo = new fc_sidewidget(fc_icons::instance()->get_pixmap("nations"),
763 _("Nations"), "PLR", popup_players_dialog);
766 sw_science = new fc_sidewidget(fc_icons::instance()->get_pixmap("research"),
767 _("Research"), "SCI",
769 sw_economy = new fc_sidewidget(fc_icons::instance()->get_pixmap("economy"),
770 _("Economy"), "ECO",
772 sw_endturn = new fc_sidewidget(fc_icons::instance()->get_pixmap("endturn"),
773 _("Turn Done"), "", side_finish_turn);
779
789
791 minimapview_wdg->show();
794 battlelog_wdg->hide();
796 infotab->show();
797 x_vote = new xvote(mapview_wdg);
798 x_vote->hide();
800 gtd->hide();
801
802 game_layout->addWidget(mapview_wdg, 1, 0);
803 game_main_widget->setLayout(game_layout);
805 game_tab_widget->setMinimumSize(600,400);
806 game_tab_widget->setContentsMargins(0, 0, 0, 0);
809 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 0);
810 } else {
811 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 2);
812 }
813 pages_layout[PAGE_GAME]->addWidget(game_tab_widget, 1, 1);
814 pages_layout[PAGE_GAME]->setContentsMargins(0, 0, 0, 0);
815 pages_layout[PAGE_GAME]->setSpacing(0);
816}
817
818/**********************************************************************/
822{
823 int i;
824
825 i = game_tab_widget->addWidget(widget);
826 game_tab_widget->setCurrentWidget(widget);
827 return i;
828}
829
830/**********************************************************************/
834{
835 game_tab_widget->removeWidget(game_tab_widget->widget(index));
836}
837
838/**********************************************************************/
842{
843 QString str;
844 str = QString(_("Save Files"))
845 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
846 current_file = QFileDialog::getOpenFileName(gui()->central_wdg,
847 _("Open Save File"),
848 QDir::homePath(), str);
849 if (!current_file.isEmpty()) {
851 }
852}
853
854/**********************************************************************/
857void fc_client::state_preview(Qt::CheckState state)
858{
860
861 if (show_preview->checkState() == Qt::Unchecked) {
863 } else {
865 }
866 slctn = saves_load->selectionModel()->selection();
867 saves_load->selectionModel()->clearSelection();
868 saves_load->selectionModel()->select(slctn, QItemSelectionModel::Rows
869 | QItemSelectionModel::SelectCurrent);
870}
871
872/**********************************************************************/
877{
879
880 if (show_preview->checkState() == Qt::Unchecked) {
882 } else {
884 }
885 slctn = saves_load->selectionModel()->selection();
886 saves_load->selectionModel()->clearSelection();
887 saves_load->selectionModel()->select(slctn, QItemSelectionModel::Rows
888 | QItemSelectionModel::SelectCurrent);
889}
890
891/**********************************************************************/
895{
896 QString str;
897
898 str = QString(_("Scenarios Files"))
899 + QString(" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
900 current_file = QFileDialog::getOpenFileName(gui()->central_wdg,
901 _("Open Scenario File"),
902 QDir::homePath(), str);
903 if (!current_file.isEmpty()) {
905 }
906}
907
908/**********************************************************************/
912 const struct server_list *list)
913{
914 QTableWidget *sel = nullptr;
915 QString host, portstr;
916 int port;
917 int row;
918 int old_row_count;
919
920 switch (sstype) {
922 sel = lan_widget;
923 break;
925 sel = wan_widget;
926 break;
927 default:
928 break;
929 }
930
931 if (!sel) {
932 return;
933 }
934
935 if (!list) {
936 return;
937 }
938
939 host = connect_host_edit->text();
940 portstr = connect_port_edit->text();
941 port = portstr.toInt();
942 old_row_count = sel->rowCount();
943 sel->clearContents();
944 row = 0;
946 char buf[35];
947 int tmp;
949
950 if (old_row_count <= row) {
951 sel->insertRow(row);
952 }
953
954 if (pserver->humans >= 0) {
955 fc_snprintf(buf, sizeof(buf), "%d", pserver->humans);
956 } else {
957 strncpy(buf, _("Unknown"), sizeof(buf) - 1);
958 buf[sizeof(buf) - 1] = '\0';
959 }
960
961 tmp = pserver->port;
962 tstring = QString::number(tmp);
963
964 for (int col = 0; col < 6; col++) {
966
967 item = new QTableWidgetItem();
968
969 switch (col) {
970 case 0:
971 item->setText(pserver->host);
972 break;
973 case 1:
974 item->setText(tstring);
975 break;
976 case 2:
977 item->setText(pserver->version);
978 break;
979 case 3:
980 item->setText(_(pserver->state));
981 break;
982 case 4:
983 item->setText(buf);
984 break;
985 case 5:
986 item->setText(pserver->message);
987 break;
988 default:
989 break;
990 }
991 sel->setItem(row, col, item);
992 }
993
994 if (host == pserver->host && port == pserver->port) {
995 sel->selectRow(row);
996 }
997
998 row++;
1000
1001 // Remove unneeded rows, if there are any
1002 while (old_row_count - row > 0) {
1003 sel->removeRow(old_row_count - 1);
1004 old_row_count--;
1005 }
1006
1007}
1008
1009/**********************************************************************/
1012void server_scan_error(struct server_scan *scan, const char *message)
1013{
1015 log_error("%s", message);
1016
1017 /* Main thread will finalize the scan later (or even concurrently) -
1018 * do not do anything here to cause double free or raze condition. */
1019}
1020
1021
1022/**********************************************************************/
1026{
1027 if (meta_scan) {
1029 meta_scan = nullptr;
1030 }
1031
1032 if (meta_scan_timer != nullptr) {
1033 meta_scan_timer->stop();
1034 meta_scan_timer->disconnect();
1035 delete meta_scan_timer;
1036 meta_scan_timer = nullptr;
1037 }
1038
1039 if (lan_scan) {
1041 lan_scan = nullptr;
1042 }
1043
1044 if (lan_scan_timer != nullptr) {
1045 lan_scan_timer->stop();
1046 lan_scan_timer->disconnect();
1047 delete lan_scan_timer;
1048 lan_scan_timer = nullptr;
1049 }
1050}
1051
1052/**********************************************************************/
1056{
1058
1059 lan_scan_timer = new QTimer(this);
1061 connect(lan_scan_timer, &QTimer::timeout, this, &fc_client::slot_lan_scan);
1062 lan_scan_timer->start(500);
1063
1064 meta_scan_timer = new QTimer(this);
1066 connect(meta_scan_timer, &QTimer::timeout, this, &fc_client::slot_meta_scan);
1067 meta_scan_timer->start(800);
1068
1069}
1070
1071/**********************************************************************/
1075{
1076 struct server_scan *scan = scan_data;
1078
1079 if (!scan) {
1080 return false;
1081 }
1082
1083 stat = server_scan_poll(scan);
1084
1085 if (stat >= SCAN_STATUS_PARTIAL) {
1087 struct srv_list *srvrs;
1088
1089 type = server_scan_get_type(scan);
1090 srvrs = server_scan_get_list(scan);
1091 fc_mutex_allocate(&srvrs->mutex);
1094 holding_srv_list_mutex = false;
1095 fc_mutex_release(&srvrs->mutex);
1096 }
1097
1099 return false;
1100 }
1101
1102 return true;
1103}
1104
1105/**********************************************************************/
1109{
1110 if (lan_scan_timer == nullptr) {
1111 return;
1112 }
1114}
1115
1116/**********************************************************************/
1120{
1121 if (meta_scan_timer == nullptr) {
1122 return;
1123 }
1125}
1126
1127/**********************************************************************/
1131{
1132 if (!is_server_running()) {
1134
1135 // Saved settings are sent in client/options.c
1136 // resend_desired_settable_options()
1137 }
1138}
1139
1140/**********************************************************************/
1144{
1145 if (!is_server_running()) {
1147 send_chat("/detach");
1148 }
1149 if (is_server_running() && !current_file.isEmpty()) {
1151
1152 c_bytes = current_file.toUtf8();
1153 send_chat_printf("/load %s", c_bytes.data());
1155 }
1156}
1157
1158/**********************************************************************/
1162{
1163 if (!is_server_running()) {
1165 send_chat("/detach");
1166 }
1167 if (is_server_running() && !current_file.isEmpty()) {
1169
1170 c_bytes = current_file.toUtf8();
1171 send_chat_printf("/load %s", c_bytes.data());
1173 }
1174}
1175
1176/**********************************************************************/
1181{
1182 QModelIndexList indexes = selected.indexes();
1184 QModelIndex index;
1187 QVariant qvar;
1189
1191 const char *terr_name;
1192 const struct server *pserver = nullptr;
1193 int ii = 0;
1194 int k, col, n, nat_y, nat_x;
1195 struct section_file *sf;
1196 struct srv_list *srvrs;
1198
1199 if (indexes.isEmpty()) {
1200 return;
1201 }
1202
1203 switch (cpage) {
1204 case PAGE_NETWORK:
1205 index = indexes.at(0);
1206 connect_host_edit->setText(index.data().toString());
1207 index = indexes.at(1);
1208 connect_port_edit->setText(index.data().toString());
1209
1211
1212 if (tw == lan_widget->selectionModel()) {
1213 wan_widget->clearSelection();
1214 } else {
1215 lan_widget->clearSelection();
1216 }
1217
1220 fc_mutex_allocate(&srvrs->mutex);
1221 }
1222 if (srvrs->servers) {
1223 pserver = server_list_get(srvrs->servers, index.row());
1224 }
1226 fc_mutex_release(&srvrs->mutex);
1227 }
1228 if (!pserver || !pserver->players) {
1229 return;
1230 }
1231 n = pserver->nplayers;
1232 info_widget->clearContents();
1233 info_widget->setRowCount(0);
1234 for (k = 0; k < n; k++) {
1235 info_widget->insertRow(k);
1236 for (col = 0; col < 4; col++) {
1237 item = new QTableWidgetItem();
1238 switch (col) {
1239 case 0:
1240 item->setText(pserver->players[k].name);
1241 break;
1242 case 1:
1243 item->setText(pserver->players[k].type);
1244 break;
1245 case 2:
1246 item->setText(pserver->players[k].host);
1247 break;
1248 case 3:
1249 item->setText(pserver->players[k].nation);
1250 break;
1251 default:
1252 break;
1253 }
1254 info_widget->setItem(k, col, item);
1255 }
1256 }
1257 break;
1258 case PAGE_SCENARIO:
1259 index = indexes.at(0);
1260 qvar = index.data(Qt::UserRole);
1261 sl = qvar.toStringList();
1262 scenarios_text->setText(sl.at(0));
1263 if (sl.count() > 1) {
1264 scenarios_view->setText(sl.at(2));
1265 current_file = sl.at(1);
1266 }
1267 break;
1268 case PAGE_LOAD:
1269 index = indexes.at(0);
1270 qvar = index.data(Qt::UserRole);
1271 current_file = qvar.toString();
1272 if (show_preview->checkState() == Qt::Unchecked) {
1273 load_pix->setPixmap(*(new QPixmap));
1274 load_save_text->setText("");
1275 break;
1276 }
1277 fn_bytes = current_file.toUtf8();
1278 if ((sf = secfile_load_section(fn_bytes.data(),
1279 "game", TRUE))) {
1280 const char *sname;
1281 int integer;
1283 QString pl_str = nullptr;
1284 int num_players = 0;
1285 int curr_player = 0;
1287
1288 integer = secfile_lookup_int_default(sf, -1, "game.turn");
1289 if (integer >= 0) {
1290 final_str = QString("<b>") + _("Turn") + ":</b> "
1291 + QString::number(integer).toHtmlEscaped() + "<br>";
1292 }
1293 if ((sf = secfile_load_section(fn_bytes.data(),
1294 "players", TRUE))) {
1295 integer = secfile_lookup_int_default(sf, -1, "players.nplayers");
1296 if (integer >= 0) {
1297 final_str = final_str + "<b>" + _("Players") + ":</b>" + " "
1298 + QString::number(integer).toHtmlEscaped() + "<br>";
1299 }
1300 num_players = integer;
1301 }
1302 for (int i = 0; i < num_players; i++) {
1303 pl_str = QString("player") + QString::number(i);
1304 pl_bytes = pl_str.toUtf8();
1305 if ((sf = secfile_load_section(fn_bytes.data(),
1306 pl_bytes.data(), true))) {
1307 if (!secfile_lookup_bool_default(sf, true,
1308 "player%d.unassigned_user",
1309 i)) {
1310 curr_player = i;
1311 break;
1312 }
1313 }
1314 }
1315 // Break case (and return) if no human player found
1316 if (pl_str == nullptr) {
1317 load_save_text->setText(final_str);
1318 break;
1319 }
1320
1321 // Information about human player
1322 pl_bytes = pl_str.toUtf8();
1323 if ((sf = secfile_load_section(fn_bytes.data(),
1324 pl_bytes.data(), true))) {
1325 sname = secfile_lookup_str_default(sf, nullptr, "player%d.nation",
1326 curr_player);
1327 if (sname) {
1328 final_str = final_str + "<b>" + _("Nation") + ":</b> "
1329 + QString(sname).toHtmlEscaped() + "<br>";
1330 }
1331 integer = secfile_lookup_int_default(sf, -1, "player%d.ncities",
1332 curr_player);
1333 if (integer >= 0) {
1334 final_str = final_str + "<b>" + _("Cities") + ":</b> "
1335 + QString::number(integer).toHtmlEscaped() + "<br>";
1336 }
1337 integer = secfile_lookup_int_default(sf, -1, "player%d.nunits",
1338 curr_player);
1339 if (integer >= 0) {
1340 final_str = final_str + "<b>" + _("Units") + ":</b> "
1341 + QString::number(integer).toHtmlEscaped() + "<br>";
1342 }
1343 integer = secfile_lookup_int_default(sf, -1, "player%d.gold",
1344 curr_player);
1345 if (integer >= 0) {
1346 final_str = final_str + "<b>" + _("Gold") + ":</b> "
1347 + QString::number(integer).toHtmlEscaped() + "<br>";
1348 }
1349 nat_x = 0;
1350 nat_y = 0;
1351 while (true) { // Until breaks out
1352 const char *line = secfile_lookup_str_default(sf, nullptr,
1353 "player%d.map_t%04d",
1354 curr_player, nat_y++);
1355 if (line == nullptr) {
1356 break;
1357 }
1358 nat_x = strlen(line);
1360 }
1361
1362 // Reset terrain information
1364 pterr->identifier_load = '\0';
1366
1367 // Load possible terrains and their identifiers (chars)
1368 if ((sf = secfile_load_section(fn_bytes.data(),
1369 "savefile", true))) {
1370 while ((terr_name = secfile_lookup_str_default(sf, nullptr,
1371 "savefile.terrident%d.name", ii)) != nullptr) {
1373
1374 if (pterr != nullptr) {
1375 const char *iptr = secfile_lookup_str_default(sf, nullptr,
1376 "savefile.terrident%d.identifier", ii);
1377 pterr->identifier_load = *iptr;
1378 }
1379 ii++;
1380 }
1381 }
1382
1383 // Create image
1384 QImage img(nat_x, nat_y, QImage::Format_ARGB32_Premultiplied);
1385
1386 img.fill(Qt::black);
1387 for (int a = 0 ; a < nat_x; a++) {
1388 for (int b = 0; b < nat_y; b++) {
1389 struct terrain *tr;
1390 struct rgbcolor *rgb;
1391
1392 tr = char2terrain(str_pixmap.at(b * nat_x + a).toLatin1());
1393 if (tr != nullptr) {
1394 rgb = tr->rgb;
1395 QColor color;
1396
1397 color.setRgb(rgb->r, rgb->g, rgb->b);
1398 img.setPixel(a, b, color.rgb());
1399 }
1400 }
1401 }
1402 if (img.width() > 1) {
1403 load_pix->setPixmap(QPixmap::fromImage(img).scaledToHeight(200));
1404 } else {
1405 load_pix->setPixmap(*(new QPixmap));
1406 }
1407
1408#ifdef FC_QT5_MODE
1409 QPixmap pm = load_pix->pixmap(Qt::ReturnByValue);
1410#else // FC_QT5_MODE
1411 QPixmap pm = load_pix->pixmap();
1412#endif // FC_QT5_MODE
1413
1414 load_pix->setFixedSize(pm.width(),
1415 pm.height());
1416
1417 if ((sf = secfile_load_section(fn_bytes.data(),
1418 "research", TRUE))) {
1419 sname = secfile_lookup_str_default(sf, nullptr,
1420 "research.r%d.now_name",
1421 curr_player);
1422 if (sname) {
1423 final_str = final_str + "<b>" + _("Researching") + ":</b> "
1424 + QString(sname).toHtmlEscaped();
1425 }
1426 }
1427 }
1428 load_save_text->setText(final_str);
1429 }
1430 break;
1431 default:
1432 break;
1433 }
1434
1435}
1436
1437/**********************************************************************/
1441{
1442 struct fileinfo_list *files;
1443 int row;
1444
1445 row = 0;
1446 files = fileinfolist_infix(get_save_dirs(), ".sav", FALSE);
1447 saves_load->clearContents();
1448 saves_load->setRowCount(0);
1452 QDateTime dt;
1453
1454 item = new QTableWidgetItem();
1455 item->setData(Qt::UserRole, QString(pfile->fullname));
1456 saves_load->insertRow(row);
1457 item->setText(pfile->name);
1458 saves_load->setItem(row, 0, item);
1459 item = new QTableWidgetItem();
1460 dt = QDateTime::fromSecsSinceEpoch(pfile->mtime);
1461 item->setText(dt.toString(Qt::TextDate));
1462 saves_load->setItem(row, 1, item);
1463 row++;
1465 fileinfo_list_destroy(files);
1466}
1467
1468/**********************************************************************/
1472{
1473 struct fileinfo_list *files;
1474 int row = 0;
1475
1476 scenarios_load->clearContents();
1477 scenarios_load->setRowCount(0);
1478 scenarios_text->setText("");
1479 scenarios_view->setText("");
1480
1481 files = fileinfolist_infix(get_scenario_dirs(), ".sav", false);
1483 struct section_file *sf;
1484
1485 if ((sf = secfile_load_section(pfile->fullname, "scenario", TRUE))
1486 && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) {
1487
1488 const char *sname, *sdescription, *sauthors;
1490 QString format;
1491 QString st;
1492 int fcver;
1493 int fcdev;
1494 int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000;
1496
1497 if (PATCH_VERSION >= 90) {
1498 // Patch level matters on development versions
1499 current_dev += PATCH_VERSION * 100;
1500 }
1501
1502 fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version");
1503 if (fcver < 30000) {
1504 /* Pre-3.0 versions stored version number without emergency version
1505 * part in the end. To get comparable version number stored,
1506 * multiply by 100. */
1507 fcver *= 100;
1508 }
1509 if (fcver % 10000 >= 9000) {
1510 fcdev = fcver - (fcver % 100); // Emergency version does not count.
1511 } else {
1512 fcdev = fcver - (fcver % 10000); // Patch version does not count.
1513 }
1514 sname = secfile_lookup_str_default(sf, nullptr, "scenario.name");
1516 "scenario.description");
1518 "scenario.authors");
1519 // Ignore scenarios for newer freeciv versions than we are.
1520 if (fcdev <= current_dev) {
1521 QString version;
1522 bool add_item = true;
1523 bool found = false;
1525 int rows;
1526 int found_ver;
1527 int i;
1528
1529 if (fcver > 0) {
1530 int maj;
1531 int min;
1532
1533 maj = fcver / 1000000;
1534 fcver %= 1000000;
1535 min = fcver / 10000;
1536 fcver %= 10000;
1537 if (fcver >= 9000) {
1538 // Development version, have '+'
1539 version = QString("%1.%2+").arg(maj).arg(min);
1540 } else {
1541 version = QString("%1.%2").arg(maj).arg(min);
1542 }
1543 } else {
1544 // TRANS: Unknown scenario format
1545 version = QString(_("pre-2.6"));
1546 }
1547
1548 rows = scenarios_load->rowCount();
1549 for (i = 0; i < rows; ++i) {
1550 if (scenarios_load->item(i, 0)
1551 && scenarios_load->item(i, 0)->text() == pfile->name) {
1552 found = true;
1553 item = scenarios_load->takeItem(i, 0);
1554 break;
1555 }
1556 }
1557
1558 if (found) {
1559 sl = item->data(Qt::UserRole).toStringList();
1560 found_ver = sl.at(3).toInt();
1561 if (found_ver < fcver) {
1562 continue;
1563 }
1564 add_item = false;
1565 }
1566 if (add_item) {
1567 item = new QTableWidgetItem();
1568 scenarios_load->insertRow(row);
1569 }
1570 item->setText(QString(pfile->name));
1571 format = QString("<br>") + QString(_("Format:")) + " "
1572 + version.toHtmlEscaped();
1573 if (sauthors) {
1574 st = QString("\n") + QString("<b>") + _("Authors: ")
1575 + QString("</b>") + QString(sauthors).toHtmlEscaped();
1576 } else {
1577 st = "";
1578 }
1579 sl << "<b>"
1580 + QString(sname && strlen(sname) ? Q_(sname) : pfile->name)
1581 .toHtmlEscaped()
1582 + "</b>"
1583 << QString(pfile->fullname).toHtmlEscaped()
1584 << QString(sdescription != nullptr && '\0' != sdescription[0]
1585 ? Q_(sdescription) : "").toHtmlEscaped() + st + format
1586 << QString::number(fcver).toHtmlEscaped();
1587 sl.replaceInStrings("\n", "<br>");
1588 item->setData(Qt::UserRole, sl);
1589 if (add_item) {
1590 scenarios_load->setItem(row, 0, item);
1591 row++;
1592 } else {
1593 scenarios_load->setItem(i, 0, item);
1594 }
1595 }
1596 secfile_destroy(sf);
1597 }
1599 fileinfo_list_destroy(files);
1600 scenarios_load->sortItems(0);
1601 scenarios_load->update();
1602}
1603
1604/**********************************************************************/
1609 const char *message)
1610{
1611 set_status_bar(QString::fromUtf8(message));
1613
1614 switch (type) {
1615 case AUTH_NEWUSER_FIRST:
1616 case AUTH_NEWUSER_RETRY:
1618 return;
1619 case AUTH_LOGIN_FIRST:
1620 /* if we magically have a password already present in 'fc_password'
1621 * then, use that and skip the password entry dialog */
1622 if (fc_password[0] != '\0') {
1624
1625 sz_strlcpy(reply.password, fc_password);
1627 return;
1628 } else {
1630 }
1631
1632 return;
1633 case AUTH_LOGIN_RETRY:
1635 return;
1636 }
1637
1638 log_error("Unsupported authentication type %d: %s.", type, message);
1639}
1640
1641/**********************************************************************/
1647{
1648 char errbuf [512];
1651
1652 switch (connection_status) {
1653 case LOGIN_TYPE:
1654 ba_bytes = connect_login_edit->text().toUtf8();
1655 sz_strlcpy(user_name, ba_bytes.data());
1656 ba_bytes = connect_host_edit->text().toUtf8();
1658 server_port = connect_port_edit->text().toInt();
1659
1661 errbuf, sizeof(errbuf)) != -1) {
1662 } else {
1663 set_status_bar(QString::fromUtf8(errbuf));
1665 }
1666
1667 return;
1668 case NEW_PASSWORD_TYPE:
1669 ba_bytes = connect_password_edit->text().toLatin1();
1671 ba_bytes = connect_confirm_password_edit->text().toLatin1();
1672 sz_strlcpy(reply.password,
1673 ba_bytes.data());
1674
1675 if (!fc_strncmp(reply.password, fc_password, MAX_LEN_NAME)) {
1676 fc_password[0] = '\0';
1679 } else {
1680 set_status_bar(_("Passwords don't match, enter password."));
1682 }
1683
1684 return;
1686 ba_bytes = connect_password_edit->text().toLatin1();
1687 sz_strlcpy(reply.password,
1688 ba_bytes.data());
1691 return;
1692 case WAITING_TYPE:
1693 return;
1694 }
1695
1696 log_error("Unsupported connection status: %d", connection_status);
1697}
1698
1699/**********************************************************************/
1704{
1705 int conn_num, i;
1707 bool is_ready;
1708 QString host, nation, leader, team, str;
1709 QPixmap *pixmap;
1710 QPainter p;
1711 struct sprite *psprite;
1719 int conn_id;
1720 bool svg = is_svg_flag_enabled();
1721
1723
1724 if (conn_num == 0) {
1725 return;
1726 }
1727
1728 start_players_tree->clear();
1729 qvar2 = 0;
1730
1732 player_item->setText(0, Q_("?header:Players"));
1733 player_item->setData(0, Qt::UserRole, qvar2);
1734
1735 i = 0;
1736 players_iterate(pplayer) {
1737 i++;
1740 // Inserts playing players, observing custom players, and AI)
1741
1742 players_iterate(pplayer) {
1743 host = "";
1744 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
1745 conn_id = -1;
1746 conn_list_iterate(pplayer->connections, pconn) {
1747 if (pconn->playing == pplayer && !pconn->observer) {
1748 conn_id = pconn->id;
1749 host = pconn->addr;
1750 break;
1751 }
1753 if (is_barbarian(pplayer)) {
1754 continue;
1755 }
1756 if (is_ai(pplayer)) {
1757 is_ready = true;
1758 } else {
1759 is_ready = pplayer->is_ready;
1760 }
1761
1762 if (pplayer->nation == NO_NATION_SELECTED) {
1763 nation = _("Random");
1764
1765 if (pplayer->was_created) {
1766 leader = player_name(pplayer);
1767 } else {
1768 leader = "";
1769 }
1770 } else {
1771 nation = nation_adjective_for_player(pplayer);
1772 leader = player_name(pplayer);
1773 }
1774
1775 if (pplayer->team) {
1776 team = team_name_translation(pplayer->team);
1777 } else {
1778 team = "";
1779 }
1780
1781 item = new QTreeWidgetItem();
1782 for (int col = 0; col < 8; col++) {
1783 switch (col) {
1784 case 0:
1785 str = pplayer->username;
1786
1787 if (is_ai(pplayer)) {
1788 str = str + " <" + (ai_level_translated_name(pplayer->ai_common.skill_level))
1789 + ">";
1790 item->setIcon(col, fc_icons::instance()->get_icon("ai"));
1791 } else {
1792 item->setIcon(col, fc_icons::instance()->get_icon("human"));
1793 }
1794
1795 item->setText(col, str);
1796 qvar = QVariant::fromValue((void *) pplayer);
1797 qvar2 = 1;
1798 item->setData(0, Qt::UserRole, qvar2);
1799 item->setData(1, Qt::UserRole, qvar);
1800 break;
1801 case 1:
1802 if (is_ready) {
1803 item->setText(col, _("Yes"));
1804 } else {
1805 item->setText(col, _("No"));
1806 }
1807 break;
1808 case 2:
1809 item->setText(col, leader);
1810 break;
1811 case 3:
1812 if (!pplayer->nation) {
1813 break;
1814 }
1815 psprite = get_nation_flag_sprite(tileset, pplayer->nation);
1816 pixmap = psprite->pm;
1817 if (svg) {
1818 item->setData(col, Qt::DecorationRole, (*pixmap).scaledToHeight(50));
1819 } else {
1820 item->setData(col, Qt::DecorationRole, *pixmap);
1821 }
1822 break;
1823 case 4:
1824 if (!player_has_color(pplayer)) {
1825 break;
1826 }
1827 pixmap = new QPixmap(
1828 start_players_tree->header()->sectionSizeHint(col), 16);
1829 pixmap->fill(Qt::transparent);
1830 p.begin(pixmap);
1831 p.fillRect(pixmap->width() / 2 - 8, 0, 16, 16, Qt::black);
1832 p.fillRect(pixmap->width() / 2 - 7, 1, 14, 14,
1833 get_player_color(tileset, pplayer)->qcolor);
1834 p.end();
1835 item->setData(col, Qt::DecorationRole, *pixmap);
1836 delete pixmap;
1837 break;
1838 case 5:
1839 item->setText(col, nation);
1840 break;
1841 case 6:
1842 item->setText(col, team);
1843 break;
1844 case 7:
1845 item->setText(col, host);
1846 break;
1847 default:
1848 break;
1849 }
1850 }
1851
1852 // Find any custom observers
1853 recursed_items.clear();
1854 conn_list_iterate(pplayer->connections, pconn) {
1855 if (pconn->id == conn_id) {
1856 continue;
1857 }
1858 item_r = new QTreeWidgetItem();
1859 item_r->setText(0, pconn->username);
1860 item_r->setText(5, _("Observer"));
1861 item_r->setText(7, pconn->addr);
1862 recursed_items.append(item_r);
1863 item->addChildren(recursed_items);
1865 items.append(item);
1866 }
1868
1869 player_item->addChildren(items);
1870 start_players_tree->insertTopLevelItem(0, player_item);
1871
1872 // Insert global observers
1873 items.clear();
1875 global_item->setText(0, _("Global observers"));
1876 qvar2 = 0;
1877 global_item->setData(0, Qt::UserRole, qvar2);
1878
1880 if (pconn->playing != nullptr || !pconn->observer) {
1881 continue;
1882 }
1883 item = new QTreeWidgetItem();
1884 for (int col = 0; col < 8; col++) {
1885 switch (col) {
1886 case 0:
1887 item->setText(col, pconn->username);
1888 break;
1889 case 5:
1890 item->setText(col, _("Observer"));
1891 break;
1892 case 7:
1893 item->setText(col, pconn->addr);
1894 break;
1895 default:
1896 break;
1897 }
1898 items.append(item);
1899 }
1901
1902 global_item->addChildren(items);
1903 start_players_tree->insertTopLevelItem(1, global_item);
1904 items.clear();
1905
1906 // Insert detached
1908 detach_item->setText(0, _("Detached"));
1909 qvar2 = 0;
1910 detach_item->setData(0, Qt::UserRole, qvar2);
1911
1913 if (pconn->playing != nullptr || pconn->observer) {
1914 continue;
1915 }
1916 item = new QTreeWidgetItem();
1917 item->setText(0, pconn->username);
1918 item->setText(7, pconn->addr);
1919 items.append(item);
1921
1922 detach_item->addChildren(items);
1923 start_players_tree->insertTopLevelItem(2, detach_item);
1924 start_players_tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
1925 start_players_tree->expandAll();
1927}
1928
1929/**********************************************************************/
1933{
1934 bool sensitive;
1935 QString text;
1936
1937 // Observe button
1939 obs_button->setText(_("Don't Observe"));
1940 } else {
1941 obs_button->setText(_("Observe"));
1942 }
1943
1944 // Ready button
1945 if (can_client_control()) {
1946 sensitive = client_player()->is_alive;
1947 if (client_player()->is_ready) {
1948 text = _("Not ready");
1949 } else {
1950 int num_unready = 0;
1951
1952 players_iterate_alive(pplayer) {
1953 if (is_human(pplayer) && !pplayer->is_ready) {
1954 num_unready++;
1955 }
1957
1958 if (num_unready > 1) {
1959 text = _("Ready");
1960 } else {
1961 /* We are the last unready player so clicking here will
1962 * immediately start the game. */
1963 text = _("Start");
1964 }
1965 }
1966 } else {
1967 text = _("Start");
1969 sensitive = true;
1971 if (is_human(plr)) {
1972 /* There's human controlled player(s) in game, so it's their
1973 * job to start the game. */
1974 sensitive = false;
1975 break;
1976 }
1978 } else {
1979 sensitive = false;
1980 }
1981 }
1982 start_button->setEnabled(sensitive);
1983 start_button->setText(text);
1984
1985 // Nation button
1987 nation_button->setEnabled(sensitive);
1988
1990 pr_options->setEnabled(sensitive);
1991
1994}
1995
1996/**********************************************************************/
2000{
2001 QAction *action;
2002 QPoint global_pos = start_players_tree->mapToGlobal(pos);
2003 QString me, splayer, str, sp;
2004 bool need_empty_team;
2005 const char *level_cmd, *level_name;
2006 int level, count;
2008
2011
2012 if (item == nullptr) {
2013 return;
2014 }
2015
2016 qvar = item->data(0, Qt::UserRole);
2017 qvar2 = item->data(1, Qt::UserRole);
2018
2024 if (qvar == 1) {
2025 player *pplayer = (player *) qvar2.value < void *>();
2026
2027 if (pplayer != nullptr) {
2028 QMenu *page_menu = new QMenu(this);
2029
2030 page_submenu_AI = new QMenu(this);
2031 page_submenu_team = new QMenu(this);
2032
2033 splayer = QString(pplayer->name);
2034 sp = "\"" + splayer + "\"";
2035 if (me != splayer) {
2036 str = QString(_("Observe"));
2038 str = "/observe " + sp;
2039 QObject::connect(action, &QAction::triggered, [this,str]() {
2041 });
2042 page_menu->addAction(action);
2043
2045 str = QString(_("Remove player"));
2047 str = "/remove " + sp;
2048 QObject::connect(action, &QAction::triggered, [this,str]() {
2050 });
2051 page_menu->addAction(action);
2052 }
2053 str = QString(_("Take this player"));
2055 str = "/take " + sp;
2056 QObject::connect(action, &QAction::triggered, [this,str]() {
2058 });
2059 page_menu->addAction(action);
2060 }
2061
2062 if (can_conn_edit_players_nation(&client.conn, pplayer)) {
2063 str = QString(_("Pick nation"));
2065 str = "PICK:" + QString(player_name(pplayer)); // PICK is a key
2066 QObject::connect(action, &QAction::triggered, [this,str]() {
2068 });
2069 page_menu->addAction(action);
2070 }
2071
2072 if (is_ai(pplayer)) {
2073 // Set AI difficulty submenu
2075 page_submenu_AI->setTitle(_("Set difficulty"));
2076 page_menu->addMenu(page_submenu_AI);
2077
2078 for (level = 0; level < AI_LEVEL_COUNT; level++) {
2079 if (is_settable_ai_level(static_cast < ai_level > (level))) {
2080 level_name = ai_level_translated_name(static_cast < ai_level > (level));
2081 level_cmd = ai_level_cmd(static_cast < ai_level > (level));
2083 str = "/" + QString(level_cmd) + " " + sp;
2084 QObject::connect(action, &QAction::triggered, [this,str]() {
2086 });
2087 page_submenu_AI->addAction(action);
2088 }
2089 }
2090 }
2091 }
2092
2093 // Put to Team X submenu
2094 if (game.info.is_new_game) {
2095 page_menu->addMenu(page_submenu_team);
2096 page_submenu_team->setTitle(_("Put on team"));
2097 page_menu->addMenu(page_submenu_team);
2098 count = pplayer->team ?
2099 player_list_size(team_members(pplayer->team)) : 0;
2100 need_empty_team = (count != 1);
2102 if (!team_slot_is_used(tslot)) {
2103 if (!need_empty_team) {
2104 continue;
2105 }
2106 need_empty_team = false;
2107 }
2110 str = "/team" + sp + " \"" + QString(team_slot_rule_name(tslot))
2111 + "\"";
2112 QObject::connect(action, &QAction::triggered, [this,str]() {
2114 });
2115 page_submenu_team->addAction(action);
2117 }
2118
2120 str = QString(_("Aitoggle player"));
2122 str = "/aitoggle " + sp;
2123 QObject::connect(action, &QAction::triggered, [this,str]() {
2125 });
2126 page_menu->addAction(action);
2127 }
2128
2129 page_menu->popup(global_pos);
2130 }
2131 }
2132}
2133
2134/**********************************************************************/
2141
2142/**********************************************************************/
2146{
2147 sw_map->set_pixmap(fc_icons::instance()->get_pixmap("view"));
2148 sw_cunit->set_pixmap(fc_icons::instance()->get_pixmap("units"));
2149 sw_cities->set_pixmap(fc_icons::instance()->get_pixmap("cities"));
2150 sw_diplo->set_pixmap(fc_icons::instance()->get_pixmap("nations"));
2151 sw_science->set_pixmap(fc_icons::instance()->get_pixmap("research"));
2152 sw_economy->set_pixmap(fc_icons::instance()->get_pixmap("economy"));
2153 sw_endturn->set_pixmap(fc_icons::instance()->get_pixmap("endturn"));
2154 sidebar_wdg->resize_me(game_tab_widget->height(), true);
2155}
2156
2157/**********************************************************************/
2161{
2162 QString str;
2163 int max;
2165 char buf[256];
2168 struct player *pplayer;
2169
2170 if (current_page() != PAGE_GAME) {
2171 return;
2172 }
2173
2174 pplayer = client_player();
2175 if (pplayer != nullptr) {
2176 max = get_player_bonus(pplayer, EFT_MAX_RATES);
2177 } else {
2178 max = 100;
2179 }
2180
2184 str = str + '\n' + get_info_label_text(false);
2186 str = QString(_("Tax: %1% Science: %2% Luxury: %3%\n"))
2187 .arg(pplayer->economic.tax)
2188 .arg(pplayer->economic.luxury)
2189 .arg(pplayer->economic.science);
2190
2191 str += QString(_("%1 - max rate: %2%")).
2192 arg(government_name_for_player(pplayer),
2193 QString::number(max));
2194
2197 &building_total, &tax);
2198 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
2199 tax, building_total + unit_total);
2201 if (player_primary_capital(pplayer)) {
2203 player_primary_capital(pplayer)));
2204 }
2205 } else {
2206 sw_tax->set_tooltip("");
2208 sw_map->set_tooltip("");
2210 }
2211
2213}
2214
2215/**********************************************************************/
2219{
2220 bool center_next = false;
2221 bool first_tile = false;
2222 int first_id;
2223 struct tile *ptile = nullptr;
2224
2225 players_iterate(pplayer) {
2226 if (pplayer != client_player()) {
2227 city_list_iterate(pplayer->cities, pcity) {
2228 if (!first_tile) {
2229 first_tile = true;
2230 ptile = pcity->tile;
2231 first_id = pcity->id;
2232 }
2233 if ((last_center_enemy_city == 0) || center_next) {
2236 return;
2237 }
2239 center_next = true;
2240 }
2242 }
2244
2245 if (ptile != nullptr) {
2246 center_tile_mapcanvas(ptile);
2248 }
2249}
2250
2251/**********************************************************************/
2255{
2256 bool center_next = false;
2257 bool first_tile = false;
2258 int first_id;
2259 struct tile *ptile = nullptr;
2260
2261 players_iterate(pplayer) {
2262 if (pplayer == client_player()) {
2263 city_list_iterate(pplayer->cities, pcity) {
2264 if (!first_tile) {
2265 first_tile = true;
2266 ptile = pcity->tile;
2267 first_id = pcity->id;
2268 }
2269 if ((last_center_player_city == 0) || center_next) {
2272 return;
2273 }
2275 center_next = true;
2276 }
2278 }
2280
2281 if (ptile != nullptr) {
2282 center_tile_mapcanvas(ptile);
2284 }
2285}
2286
2287/**********************************************************************/
2291{
2292 struct city *capital;
2293 bool center_next = false;
2294 bool first_tile = false;
2295 int first_id;
2296 struct tile *ptile = nullptr;
2297
2298 players_iterate(pplayer) {
2299 if (pplayer != client_player()) {
2300 capital = player_primary_capital(pplayer);
2301 if (capital == nullptr) {
2302 continue;
2303 }
2304 if (!first_tile) {
2305 first_tile = true;
2306 ptile = capital->tile;
2307 first_id = capital->id;
2308 }
2309 if ((last_center_player_city == 0) || center_next) {
2310 last_center_player_city = capital->id;
2311 center_tile_mapcanvas(capital->tile);
2312 put_cross_overlay_tile(capital->tile);
2313 return;
2314 }
2315 if (capital->id == last_center_player_city) {
2316 center_next = true;
2317 }
2318 }
2320
2321 if (ptile != nullptr) {
2322 center_tile_mapcanvas(ptile);
2325 }
2326
2327}
2328
2329/**********************************************************************/
2333{
2334 pages_layout[PAGE_GAME]->removeWidget(gui()->sidebar_wdg);
2336 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 0);
2337 } else {
2338 pages_layout[PAGE_GAME]->addWidget(sidebar_wdg, 1, 2);
2339 }
2340}
2341
2342/**********************************************************************/
2346{
2347 bool center_next = false;
2348 bool first_tile = false;
2349 int first_id;
2350 struct tile *ptile = nullptr;
2351
2352 players_iterate(pplayer) {
2353 if (pplayer != client_player()) {
2354 unit_list_iterate(pplayer->units, punit) {
2355 if (!first_tile) {
2356 first_tile = true;
2357 ptile = punit->tile;
2358 first_id = punit->id;
2359 }
2360 if ((last_center_enemy == 0) || center_next) {
2363 return;
2364 }
2365 if (punit->id == last_center_enemy) {
2366 center_next = true;
2367 }
2369 }
2371
2372 if (ptile != nullptr) {
2373 center_tile_mapcanvas(ptile);
2375 }
2376}
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:833
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:505
#define city_list_iterate_end
Definition city.h:507
fc_game_tab_widget * game_tab_widget
Definition fc_client.h:259
QStringList status_bar_queue
Definition fc_client.h:352
void handle_authentication_req(enum authentication_type type, const char *message)
Definition pages.cpp:1608
QLineEdit * connect_host_edit
Definition fc_client.h:188
fc_sidewidget * sw_tax
Definition fc_client.h:222
void update_buttons()
Definition pages.cpp:1932
QTextEdit * output_window
Definition fc_client.h:181
void state_preview_depr(int state)
Definition pages.cpp:876
void update_sidebar_tooltips()
Definition pages.cpp:2160
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:1161
QWidget * connect_lan
Definition fc_client.h:174
int add_game_tab(QWidget *widget)
Definition pages.cpp:821
fc_sidewidget * sw_science
Definition fc_client.h:275
QTableWidget * lan_widget
Definition fc_client.h:205
void browse_saves()
Definition pages.cpp:841
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:456
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:1074
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:2145
QTableWidget * wan_widget
Definition fc_client.h:206
void slot_pick_nation()
Definition pages.cpp:2137
map_view * mapview_wdg
Definition fc_client.h:230
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
Definition pages.cpp:1179
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:651
void slot_disconnect()
void clear_status_bar()
Definition pages.cpp:472
fc_sidewidget * sw_endturn
Definition fc_client.h:276
void slot_pregame_observe()
QTableWidget * info_widget
Definition fc_client.h:207
void set_connection_state(enum connection_state state)
Definition pages.cpp:271
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:1025
void update_sidebar_position()
Definition pages.cpp:2332
QMenu * page_submenu_team
Definition fc_client.h:282
void switch_page(int i)
void create_network_page()
Definition pages.cpp:308
QTreeWidget * start_players_tree
Definition fc_client.h:210
void create_load_page()
Definition pages.cpp:500
QTimer * lan_scan_timer
Definition fc_client.h:213
void update_start_page()
Definition pages.cpp:1703
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:488
void start_page_menu(QPoint)
Definition pages.cpp:1999
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
Definition pages.cpp:911
void update_network_lists()
Definition pages.cpp:1055
QWidget * central_wdg
Definition fc_client.h:256
void slot_meta_scan()
Definition pages.cpp:1119
QString current_file
Definition fc_client.h:353
void slot_lan_scan()
Definition pages.cpp:1108
xvote * x_vote
Definition fc_client.h:264
void browse_scenarios()
Definition pages.cpp:894
void slot_pregame_start()
fc_sidewidget * sw_cities
Definition fc_client.h:221
void popup_client_options()
void slot_connect()
Definition pages.cpp:1646
fc_sidewidget * sw_map
Definition fc_client.h:220
void update_load_page(void)
Definition pages.cpp:1440
void start_scenario()
Definition pages.cpp:1143
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:833
void send_fake_chat_message(const QString &message)
fc_sidewidget * sw_diplo
Definition fc_client.h:278
void state_preview(Qt::CheckState state)
Definition pages.cpp:857
void create_scenario_page()
Definition pages.cpp:584
void start_new_game()
Definition pages.cpp:1130
void update_scenarios_page(void)
Definition pages.cpp:1471
void create_game_page()
Definition pages.cpp:735
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:76
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:824
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:82
#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:61
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:104
#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:1525
const char * text_happiness_cities(const struct city *pcity)
Definition text.c:1947
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:2218
enum client_pages qtg_get_current_client_page()
Definition pages.cpp:122
static void center_next_player_city()
Definition pages.cpp:2254
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:1016
void toggle_units_report(bool)
static bool holding_srv_list_mutex
Definition pages.cpp:77
const char * science_dialog_text(void)
Definition text.c:788
static void cycle_enemy_units()
Definition pages.cpp:2345
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:1498
void server_scan_error(struct server_scan *scan, const char *message)
Definition pages.cpp:1012
const char * get_bulb_tooltip(void)
Definition text.c:1414
const char * get_info_label_text(bool)
Definition text.c:964
const char * get_global_warming_tooltip(void)
Definition text.c:1471
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:2290
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1925
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:1996
struct city * player_primary_capital(const struct player *pplayer)
Definition player.c:1337
#define ai_level_cmd(_level_)
Definition player.h:572
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
static bool is_barbarian(const struct player *pplayer)
Definition player.h:491
#define is_ai(plr)
Definition player.h:232
#define players_iterate_alive_end
Definition player.h:552
#define is_human(plr)
Definition player.h:231
#define players_iterate_alive(_pplayer)
Definition player.h:547
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:1339
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:971
const struct strvec * get_save_dirs(void)
Definition shared.c:934
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
Definition shared.c:1204
#define fileinfo_list_iterate(list, pnode)
Definition shared.h:182
#define fileinfo_list_iterate_end
Definition shared.h:184
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:317
int id
Definition city.h:323
enum capital_type capital
Definition city.h:325
struct tile * tile
Definition city.h:319
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:443
bool gui_qt_sidebar_left
Definition options.h:445
Definition colors.h:21
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:261
struct player_economic economic
Definition player.h:284
char name[MAX_LEN_NAME]
Definition player.h:251
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:147
struct tile * tile
Definition unit.h:142
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#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:266
#define T_UNKNOWN
Definition terrain.h:62
#define TERRAIN_UNKNOWN_IDENTIFIER
Definition terrain.h:88
#define terrain_type_iterate_end
Definition terrain.h:272
const char * tileset_main_intro_filename(const struct tileset *t)
Definition tilespec.c:973
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6980
#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