20#include <QApplication>
29#include <QStackedWidget>
30#include <QTableWidget>
93 if (pterrain->identifier_load ==
ch) {
106 gui()->switch_page(page);
124 return gui()->current_page();
132 gui()->update_start_page();
147 QFont f = QApplication::font();
150#if IS_BETA_VERSION || IS_DEVEL_VERSION
166#elif defined(FC_QT6X_MODE)
188#elif defined(FC_QT6X_MODE)
199 row++, 0, 1, 2, Qt::AlignCenter);
201#if IS_BETA_VERSION || IS_DEVEL_VERSION
202 warn_color.setColor(QPalette::WindowText, Qt::red);
204 unstable_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
207 row++, 0, 1, 2, Qt::AlignHCenter);
211 <<
_(
"Load saved game") <<
_(
"Connect to network game")
212 <<
_(
"Options") <<
_(
"Quit");
223 _(
"Launches local server, and connects to it for a single-player game."));
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]() {
238 _(
"Continues previously saved single-player game."));
239 QObject::connect(
button, &QPushButton::clicked, [
this]() {
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]() {
254 button->setToolTip(
_(
"Adjusting client-side options."));
259 button->setToolTip(
_(
"Gives you a break from playing freeciv."));
340 <<
_(
"Status") <<
Q_(
"?count:Players") <<
_(
"Comment");
346 lan_widget->verticalHeader()->setVisible(
false);
351 wan_widget->verticalHeader()->setVisible(
false);
360 lan_widget->setProperty(
"selectionBehavior",
"SelectRows");
361 lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
362 lan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
366 wan_widget->setProperty(
"selectionBehavior",
"SelectRows");
367 wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
368 wan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
371 &QItemSelectionModel::selectionChanged,
this,
375 &QItemSelectionModel::selectionChanged,
this,
377 connect(
wan_widget, &QTableWidget::itemDoubleClicked,
this,
379 connect(
lan_widget, &QTableWidget::itemDoubleClicked,
this,
383 info_widget->setProperty(
"selectionBehavior",
"SelectRows");
384 info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
385 info_widget->setSelectionMode(QAbstractItemView::SingleSelection);
390 header->setSectionResizeMode(0, QHeaderView::Stretch);
391 header->setStretchLastSection(
true);
393 header->setSectionResizeMode(0, QHeaderView::Stretch);
394 header->setStretchLastSection(
true);
396 header->setSectionResizeMode(0, QHeaderView::Stretch);
397 header->setStretchLastSection(
true);
401 <<
_(
"Password") <<
_(
"Confirm Password");
422 QObject::connect(
network_button, &QPushButton::clicked, [
this]() {
441 lan_label =
new QLabel(
_(
"Internet servers:"));
490 QLabel *label =
new QLabel(
_(
"Loading..."));
514 sav <<
_(
"Choose Saved Game to Load") <<
_(
"Date");
516 load_pix->setProperty(
"themed_border",
true);
532 saves_load->setProperty(
"selectionBehavior",
"SelectRows");
533 saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
534 saves_load->setSelectionMode(QAbstractItemView::SingleSelection);
535 saves_load->verticalHeader()->setVisible(
false);
538 header->setSectionResizeMode(0, QHeaderView::Stretch);
539 header->setStretchLastSection(
true);
543 &QItemSelectionModel::selectionChanged,
this,
546 connect(
show_preview, &QCheckBox::checkStateChanged,
this,
556 but =
new QPushButton;
557 but->setText(
_(
"Browse..."));
562 but =
new QPushButton;
563 but->setText(
_(
"Cancel"));
565 QStyle::SP_DialogCancelButton));
569 but =
new QPushButton;
570 but->setText(
_(
"Load"));
572 QStyle::SP_DialogOkButton));
598 sav <<
_(
"Choose a Scenario");
604 scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
605 scenarios_load->setSelectionMode(QAbstractItemView::SingleSelection);
617 header->setSectionResizeMode(0, QHeaderView::Stretch);
618 header->setStretchLastSection(
true);
620 &QItemSelectionModel::selectionChanged,
this,
623 but =
new QPushButton;
624 but->setText(
_(
"Browse..."));
629 but =
new QPushButton;
630 but->setText(
_(
"Cancel"));
632 QStyle::SP_DialogCancelButton));
640 but =
new QPushButton;
641 but->setText(
_(
"Load Scenario"));
643 QStyle::SP_DialogOkButton));
668 chat_line->setProperty(
"doomchat",
true);
676 <<
_(
"Flag") <<
_(
"Border") <<
_(
"Nation") <<
_(
"Team")
692 but =
new QPushButton;
693 but->setText(
_(
"Disconnect"));
701 QObject::connect(
nation_button, &QAbstractButton::clicked,
this,
708 QObject::connect(
obs_button, &QAbstractButton::clicked,
this,
714 QObject::connect(
start_button, &QAbstractButton::clicked,
this,
728 splitter->setOrientation(Qt::Vertical);
767 _(
"Research"),
"SCI",
845 +
QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
848 QDir::homePath(),
str);
867 saves_load->selectionModel()->clearSelection();
869 | QItemSelectionModel::SelectCurrent);
886 saves_load->selectionModel()->clearSelection();
888 | QItemSelectionModel::SelectCurrent);
899 +
QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
901 _(
"Open Scenario File"),
902 QDir::homePath(),
str);
914 QTableWidget *
sel =
nullptr;
943 sel->clearContents();
958 buf[
sizeof(
buf) - 1] =
'\0';
1234 for (k = 0; k <
n; k++) {
1260 qvar = index.data(Qt::UserRole);
1261 sl =
qvar.toStringList();
1263 if (
sl.count() > 1) {
1270 qvar = index.data(Qt::UserRole);
1284 int num_players = 0;
1285 int curr_player = 0;
1291 + QString::number(integer).toHtmlEscaped() +
"<br>";
1294 "players",
TRUE))) {
1298 + QString::number(integer).toHtmlEscaped() +
"<br>";
1300 num_players = integer;
1302 for (
int i = 0;
i < num_players;
i++) {
1308 "player%d.unassigned_user",
1335 + QString::number(integer).toHtmlEscaped() +
"<br>";
1341 + QString::number(integer).toHtmlEscaped() +
"<br>";
1347 + QString::number(integer).toHtmlEscaped() +
"<br>";
1353 "player%d.map_t%04d",
1354 curr_player,
nat_y++);
1355 if (
line ==
nullptr) {
1364 pterr->identifier_load =
'\0';
1369 "savefile",
true))) {
1371 "savefile.terrident%d.name",
ii)) !=
nullptr) {
1374 if (
pterr !=
nullptr) {
1376 "savefile.terrident%d.identifier",
ii);
1386 img.fill(Qt::black);
1387 for (
int a = 0 ; a <
nat_x; a++) {
1388 for (
int b = 0; b <
nat_y; b++) {
1393 if (
tr !=
nullptr) {
1397 color.setRgb(rgb->
r, rgb->
g, rgb->
b);
1402 if (
img.width() > 1) {
1418 "research",
TRUE))) {
1420 "research.r%d.now_name",
1460 dt = QDateTime::fromSecsSinceEpoch(
pfile->mtime);
1461 item->setText(
dt.toString(Qt::TextDate));
1503 if (
fcver < 30000) {
1509 if (
fcver % 10000 >= 9000) {
1516 "scenario.description");
1518 "scenario.authors");
1522 bool add_item =
true;
1535 min =
fcver / 10000;
1537 if (
fcver >= 9000) {
1539 version =
QString(
"%1.%2+").arg(
maj).arg(min);
1541 version =
QString(
"%1.%2").arg(
maj).arg(min);
1559 sl =
item->data(Qt::UserRole).toStringList();
1572 + version.toHtmlEscaped();
1586 << QString::number(
fcver).toHtmlEscaped();
1587 sl.replaceInStrings(
"\n",
"<br>");
1588 item->setData(Qt::UserRole,
sl);
1747 if (
pconn->playing == pplayer && !
pconn->observer) {
1748 conn_id =
pconn->id;
1756 if (
is_ai(pplayer)) {
1759 is_ready = pplayer->is_ready;
1763 nation =
_(
"Random");
1765 if (pplayer->was_created) {
1775 if (pplayer->team) {
1785 str = pplayer->username;
1787 if (
is_ai(pplayer)) {
1796 qvar = QVariant::fromValue((
void *) pplayer);
1799 item->setData(1, Qt::UserRole,
qvar);
1812 if (!pplayer->nation) {
1818 item->setData(
col, Qt::DecorationRole, (*pixmap).scaledToHeight(50));
1829 pixmap->fill(Qt::transparent);
1831 p.fillRect(
pixmap->width() / 2 - 8, 0, 16, 16, Qt::black);
1832 p.fillRect(
pixmap->width() / 2 - 7, 1, 14, 14,
1855 if (
pconn->id == conn_id) {
1860 item_r->setText(5,
_(
"Observer"));
1880 if (
pconn->playing !=
nullptr || !
pconn->observer) {
1913 if (
pconn->playing !=
nullptr ||
pconn->observer) {
1948 text =
_(
"Not ready");
1953 if (
is_human(pplayer) && !pplayer->is_ready) {
2012 if (
item ==
nullptr) {
2016 qvar =
item->data(0, Qt::UserRole);
2027 if (pplayer !=
nullptr) {
2038 str =
"/observe " +
sp;
2039 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2047 str =
"/remove " +
sp;
2048 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2055 str =
"/take " +
sp;
2056 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2066 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2072 if (
is_ai(pplayer)) {
2084 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2098 count = pplayer->
team ?
2112 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2122 str =
"/aitoggle " +
sp;
2123 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2175 if (pplayer !=
nullptr) {
2186 str =
QString(
_(
"Tax: %1% Science: %2% Luxury: %3%\n"))
2193 QString::number(max));
2223 struct tile *ptile =
nullptr;
2245 if (ptile !=
nullptr) {
2259 struct tile *ptile =
nullptr;
2281 if (ptile !=
nullptr) {
2296 struct tile *ptile =
nullptr;
2301 if (capital ==
nullptr) {
2306 ptile = capital->
tile;
2321 if (ptile !=
nullptr) {
2350 struct tile *ptile =
nullptr;
2372 if (ptile !=
nullptr) {
void qtg_version_message(const char *vertext)
int send_chat_printf(const char *format,...)
int send_chat(const char *message)
void output_window_append(const struct ft_color color, const char *featured_text)
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
fc_game_tab_widget * game_tab_widget
QStringList status_bar_queue
void handle_authentication_req(enum authentication_type type, const char *message)
QLineEdit * connect_host_edit
QTextEdit * output_window
void state_preview_depr(int state)
void update_sidebar_tooltips()
fc_sidewidget * sw_economy
hud_battle_log * battlelog_wdg
QPushButton * start_button
int add_game_tab(QWidget *widget)
fc_sidewidget * sw_science
QTableWidget * lan_widget
QWidget * connect_metaserver
QWidget * game_main_widget
QLineEdit * connect_confirm_password_edit
QPushButton * nation_button
QTableWidget * saves_load
void set_status_bar(QString str, int timeout=2000)
enum client_pages current_page()
bool check_server_scan(server_scan *scan_data)
QLineEdit * connect_password_edit
minimap_view * minimapview_wdg
void reload_sidebar_icons()
QTableWidget * wan_widget
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
fc_sidewidget * sw_indicators
fc_sidewidget * sw_endturn
void slot_pregame_observe()
QTableWidget * info_widget
void set_connection_state(enum connection_state state)
QLabel * status_bar_label
QGridLayout * pages_layout[PAGE_GAME+2]
QLineEdit * connect_login_edit
QTextEdit * scenarios_view
void destroy_server_scans(void)
void update_sidebar_position()
QMenu * page_submenu_team
void create_network_page()
QTreeWidget * start_players_tree
QLineEdit * connect_port_edit
void create_loading_page()
void start_page_menu(QPoint)
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
void update_network_lists()
void slot_pregame_start()
fc_sidewidget * sw_cities
void popup_client_options()
void update_load_page(void)
pregame_options * pr_options
QTableWidget * scenarios_load
void rm_game_tab(int index)
void send_fake_chat_message(const QString &message)
void state_preview(Qt::CheckState state)
void create_scenario_page()
void update_scenarios_page(void)
QIcon get_icon(const QString &id)
static fc_icons * instance()
void set_aifill(int aifill)
bool can_client_control(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
char fc_password[MAX_LEN_PASSWORD]
static struct fc_sockaddr_list * list
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
bool player_has_color(const struct player *pplayer)
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void key_center_capital(void)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
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
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
void fc_mutex_allocate(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
const struct ft_color ftc_client
const char * government_name_for_player(const struct player *pplayer)
void city_report_dialog_popup(bool raise)
void popup_races_dialog(struct player *pplayer)
void put_cross_overlay_tile(struct tile *ptile)
static struct server_scan_timer_data meta_scan
static enum connection_state connection_status
static struct server_scan_timer_data lan_scan
static void server_scan_error(struct server_scan *scan, const char *message)
static bool holding_srv_list_mutex
void popup_players_dialog(bool raise)
void economy_report_dialog_popup(bool raise)
static struct server_list * server_list
#define log_error(message,...)
void center_tile_mapcanvas(const struct tile *ptile)
const char * nation_adjective_for_player(const struct player *pplayer)
bool can_conn_edit_players_nation(const struct connection *pconn, const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
#define NO_NATION_SELECTED
struct client_options gui_options
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
const char * get_government_tooltip(void)
const char * text_happiness_cities(const struct city *pcity)
void qtg_real_set_client_page(enum client_pages page)
static void center_next_enemy_city()
enum client_pages qtg_get_current_client_page()
static void center_next_player_city()
void popup_shortcuts_dialog()
static enum connection_state connection_status
static struct server_scan * meta_scan
void qtg_set_rulesets(int num_rulesets, char **rulesets)
int last_center_player_city
const char * get_info_label_text_popup(void)
void toggle_units_report(bool)
static bool holding_srv_list_mutex
const char * science_dialog_text(void)
static void cycle_enemy_units()
static struct terrain * char2terrain(char ch)
int last_center_enemy_city
const char * get_nuclear_winter_tooltip(void)
void server_scan_error(struct server_scan *scan, const char *message)
const char * get_bulb_tooltip(void)
const char * get_info_label_text(bool)
const char * get_global_warming_tooltip(void)
void update_start_page(void)
static struct server_scan * lan_scan
static void center_next_player_capital()
bool is_settable_ai_level(enum ai_level level)
const char * player_name(const struct player *pplayer)
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
struct city * player_primary_capital(const struct player *pplayer)
#define ai_level_cmd(_level_)
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void secfile_destroy(struct section_file *secfile)
struct section_file * secfile_load_section(const char *filename, const char *section, bool allow_duplicates)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
static struct terrain * char2terrain(char ch)
struct srv_list * server_scan_get_list(struct server_scan *scan)
void server_scan_finish(struct server_scan *scan)
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
enum server_scan_status server_scan_poll(struct server_scan *scan)
#define server_list_iterate_end
#define server_list_iterate(serverlist, pserver)
struct setting_list * level[OLEVELS_NUM]
const struct strvec * get_scenario_dirs(void)
const struct strvec * get_save_dirs(void)
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
#define fileinfo_list_iterate(list, pnode)
#define fileinfo_list_iterate_end
enum capital_type capital
struct conn_list * est_connections
struct packet_game_info info
struct conn_list * all_connections
enum cmdlevel access_level
char username[MAX_LEN_NAME]
struct player_economic economic
struct server_list * servers
int fc_snprintf(char *str, size_t n, const char *format,...)
#define sz_strlcpy(dest, src)
#define fc_strncmp(_s1_, _s2_, _len_)
#define is_svg_flag_enabled()
const char * team_name_translation(const struct team *pteam)
const char * team_slot_name_translation(const struct team_slot *tslot)
const struct player_list * team_members(const struct team *pteam)
bool team_slot_is_used(const struct team_slot *tslot)
const char * team_slot_rule_name(const struct team_slot *tslot)
#define team_slots_iterate_end
#define team_slots_iterate(_tslot)
struct terrain * terrain_by_rule_name(const char *name)
#define terrain_type_iterate(_p)
#define TERRAIN_UNKNOWN_IDENTIFIER
#define terrain_type_iterate_end
const char * tileset_main_intro_filename(const struct tileset *t)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * fc_git_revision(void)
const char * unstable_message(void)
const char * word_version(void)