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
194 row++, 0, 1, 2, Qt::AlignCenter);
196#if IS_BETA_VERSION || IS_DEVEL_VERSION
197 warn_color.setColor(QPalette::WindowText, Qt::red);
199 unstable_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
202 row++, 0, 1, 2, Qt::AlignHCenter);
206 <<
_(
"Load saved game") <<
_(
"Connect to network game")
207 <<
_(
"Options") <<
_(
"Quit");
218 _(
"Launches local server, and connects to it for a single-player game."));
224 _(
"Loads one of the scenarios for a single-player game. "
225 "Tutorial is one of the scenarios."));
226 QObject::connect(
button, &QPushButton::clicked, [
this]() {
233 _(
"Continues previously saved single-player game."));
234 QObject::connect(
button, &QPushButton::clicked, [
this]() {
241 _(
"Connects to outside server. "
242 "Sometimes you want to launch a separate server even for local games."));
243 QObject::connect(
button, &QPushButton::clicked, [
this]() {
249 button->setToolTip(
_(
"Adjusting client-side options."));
254 button->setToolTip(
_(
"Gives you a break from playing freeciv."));
335 <<
_(
"Status") <<
Q_(
"?count:Players") <<
_(
"Comment");
341 lan_widget->verticalHeader()->setVisible(
false);
346 wan_widget->verticalHeader()->setVisible(
false);
355 lan_widget->setProperty(
"selectionBehavior",
"SelectRows");
356 lan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
357 lan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
361 wan_widget->setProperty(
"selectionBehavior",
"SelectRows");
362 wan_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
363 wan_widget->setSelectionMode(QAbstractItemView::SingleSelection);
366 &QItemSelectionModel::selectionChanged,
this,
370 &QItemSelectionModel::selectionChanged,
this,
372 connect(
wan_widget, &QTableWidget::itemDoubleClicked,
this,
374 connect(
lan_widget, &QTableWidget::itemDoubleClicked,
this,
378 info_widget->setProperty(
"selectionBehavior",
"SelectRows");
379 info_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
380 info_widget->setSelectionMode(QAbstractItemView::SingleSelection);
385 header->setSectionResizeMode(0, QHeaderView::Stretch);
386 header->setStretchLastSection(
true);
388 header->setSectionResizeMode(0, QHeaderView::Stretch);
389 header->setStretchLastSection(
true);
391 header->setSectionResizeMode(0, QHeaderView::Stretch);
392 header->setStretchLastSection(
true);
396 <<
_(
"Password") <<
_(
"Confirm Password");
417 QObject::connect(
network_button, &QPushButton::clicked, [
this]() {
436 lan_label =
new QLabel(
_(
"Internet servers:"));
485 QLabel *label =
new QLabel(
_(
"Loading..."));
509 sav <<
_(
"Choose Saved Game to Load") <<
_(
"Date");
511 load_pix->setProperty(
"themed_border",
true);
527 saves_load->setProperty(
"selectionBehavior",
"SelectRows");
528 saves_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
529 saves_load->setSelectionMode(QAbstractItemView::SingleSelection);
530 saves_load->verticalHeader()->setVisible(
false);
533 header->setSectionResizeMode(0, QHeaderView::Stretch);
534 header->setStretchLastSection(
true);
538 &QItemSelectionModel::selectionChanged,
this,
546 but =
new QPushButton;
547 but->setText(
_(
"Browse..."));
552 but =
new QPushButton;
553 but->setText(
_(
"Cancel"));
555 QStyle::SP_DialogCancelButton));
559 but =
new QPushButton;
560 but->setText(
_(
"Load"));
562 QStyle::SP_DialogOkButton));
588 sav <<
_(
"Choose a Scenario");
594 scenarios_load->setEditTriggers(QAbstractItemView::NoEditTriggers);
595 scenarios_load->setSelectionMode(QAbstractItemView::SingleSelection);
607 header->setSectionResizeMode(0, QHeaderView::Stretch);
608 header->setStretchLastSection(
true);
610 &QItemSelectionModel::selectionChanged,
this,
613 but =
new QPushButton;
614 but->setText(
_(
"Browse..."));
619 but =
new QPushButton;
620 but->setText(
_(
"Cancel"));
622 QStyle::SP_DialogCancelButton));
630 but =
new QPushButton;
631 but->setText(
_(
"Load Scenario"));
633 QStyle::SP_DialogOkButton));
658 chat_line->setProperty(
"doomchat",
true);
666 <<
_(
"Flag") <<
_(
"Border") <<
_(
"Nation") <<
_(
"Team")
682 but =
new QPushButton;
683 but->setText(
_(
"Disconnect"));
691 QObject::connect(
nation_button, &QAbstractButton::clicked,
this,
698 QObject::connect(
obs_button, &QAbstractButton::clicked,
this,
704 QObject::connect(
start_button, &QAbstractButton::clicked,
this,
718 splitter->setOrientation(Qt::Vertical);
757 _(
"Research"),
"SCI",
835 +
QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
838 QDir::homePath(),
str);
857 saves_load->selectionModel()->clearSelection();
859 | QItemSelectionModel::SelectCurrent);
870 +
QString(
" (*.sav *.sav.bz2 *.sav.gz *.sav.xz *.sav.zst)");
872 _(
"Open Scenario File"),
873 QDir::homePath(),
str);
914 sel->clearContents();
929 buf[
sizeof(
buf) - 1] =
'\0';
1205 for (k = 0; k <
n; k++) {
1231 qvar = index.data(Qt::UserRole);
1232 sl =
qvar.toStringList();
1234 if (
sl.count() > 1) {
1241 qvar = index.data(Qt::UserRole);
1255 int num_players = 0;
1256 int curr_player = 0;
1262 + QString::number(integer).toHtmlEscaped() +
"<br>";
1265 "players",
TRUE))) {
1269 + QString::number(integer).toHtmlEscaped() +
"<br>";
1271 num_players = integer;
1273 for (
int i = 0;
i < num_players;
i++) {
1279 "player%d.unassigned_user",
1306 + QString::number(integer).toHtmlEscaped() +
"<br>";
1312 + QString::number(integer).toHtmlEscaped() +
"<br>";
1318 + QString::number(integer).toHtmlEscaped() +
"<br>";
1324 "player%d.map_t%04d",
1325 curr_player,
nat_y++);
1326 if (
line ==
nullptr) {
1335 pterr->identifier_load =
'\0';
1340 "savefile",
true))) {
1342 "savefile.terrident%d.name",
ii)) !=
NULL) {
1347 "savefile.terrident%d.identifier",
ii);
1357 img.fill(Qt::black);
1358 for (
int a = 0 ; a <
nat_x; a++) {
1359 for (
int b = 0; b <
nat_y; b++) {
1364 if (
tr !=
nullptr) {
1368 color.setRgb(rgb->
r, rgb->
g, rgb->
b);
1373 if (
img.width() > 1) {
1392 "research",
TRUE))) {
1394 "research.r%d.now_name",
1434 dt = QDateTime::fromSecsSinceEpoch(
pfile->mtime);
1435 item->setText(
dt.toString(Qt::TextDate));
1477 if (
fcver < 30000) {
1483 if (
fcver % 10000 >= 9000) {
1490 "scenario.description");
1492 "scenario.authors");
1496 bool add_item =
true;
1509 min =
fcver / 10000;
1511 if (
fcver >= 9000) {
1513 version =
QString(
"%1.%2+").arg(
maj).arg(min);
1515 version =
QString(
"%1.%2").arg(
maj).arg(min);
1533 sl =
item->data(Qt::UserRole).toStringList();
1546 + version.toHtmlEscaped();
1560 << QString::number(
fcver).toHtmlEscaped();
1561 sl.replaceInStrings(
"\n",
"<br>");
1562 item->setData(Qt::UserRole,
sl);
1721 if (
pconn->playing == pplayer && !
pconn->observer) {
1722 conn_id =
pconn->id;
1730 if (
is_ai(pplayer)) {
1733 is_ready = pplayer->is_ready;
1737 nation =
_(
"Random");
1739 if (pplayer->was_created) {
1749 if (pplayer->team) {
1759 str = pplayer->username;
1761 if (
is_ai(pplayer)) {
1770 qvar = QVariant::fromValue((
void *) pplayer);
1773 item->setData(1, Qt::UserRole,
qvar);
1786 if (!pplayer->nation) {
1792 item->setData(
col, Qt::DecorationRole, (*pixmap).scaledToHeight(50));
1803 pixmap->fill(Qt::transparent);
1805 p.fillRect(
pixmap->width() / 2 - 8, 0, 16, 16, Qt::black);
1806 p.fillRect(
pixmap->width() / 2 - 7, 1, 14, 14,
1829 if (
pconn->id == conn_id) {
1834 item_r->setText(5,
_(
"Observer"));
1922 text =
_(
"Not ready");
1927 if (
is_human(pplayer) && !pplayer->is_ready) {
1986 if (
item ==
nullptr) {
1990 qvar =
item->data(0, Qt::UserRole);
2001 if (pplayer !=
nullptr) {
2012 str =
"/observe " +
sp;
2013 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2021 str =
"/remove " +
sp;
2022 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2029 str =
"/take " +
sp;
2030 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2040 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2046 if (
is_ai(pplayer)) {
2058 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2072 count = pplayer->
team ?
2086 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2096 str =
"/aitoggle " +
sp;
2097 QObject::connect(
action, &QAction::triggered, [
this,
str]() {
2159 str =
QString(
_(
"Tax: %1% Science: %2% Luxury: %3%\n"))
2166 QString::number(max));
2195 struct tile *ptile =
nullptr;
2202 ptile = pcity->tile;
2217 if (ptile !=
nullptr) {
2231 struct tile *ptile =
nullptr;
2238 ptile = pcity->tile;
2253 if (ptile !=
nullptr) {
2268 struct tile *ptile =
nullptr;
2273 if (capital ==
nullptr) {
2278 ptile = capital->
tile;
2293 if (ptile !=
nullptr) {
2322 struct tile *ptile =
nullptr;
2344 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 update_sidebar_tooltips()
fc_sidewidget * sw_economy
hud_battle_log * battlelog_wdg
QPushButton * start_button
int add_game_tab(QWidget *widget)
fc_sidewidget * sw_science
QTableWidget * lan_widget
QWidget * connect_metaserver
QWidget * game_main_widget
QLineEdit * connect_confirm_password_edit
QPushButton * nation_button
QTableWidget * saves_load
void set_status_bar(QString str, int timeout=2000)
enum client_pages current_page()
bool check_server_scan(server_scan *scan_data)
QLineEdit * connect_password_edit
minimap_view * minimapview_wdg
void reload_sidebar_icons()
QTableWidget * wan_widget
void slot_selection_changed(const QItemSelection &, const QItemSelection &)
fc_sidewidget * sw_indicators
fc_sidewidget * sw_endturn
void slot_pregame_observe()
QTableWidget * info_widget
void set_connection_state(enum connection_state state)
QLabel * status_bar_label
QGridLayout * pages_layout[PAGE_GAME+2]
QLineEdit * connect_login_edit
QTextEdit * scenarios_view
void destroy_server_scans(void)
void update_sidebar_position()
QMenu * page_submenu_team
void create_network_page()
QTreeWidget * start_players_tree
QLineEdit * connect_port_edit
void create_loading_page()
void start_page_menu(QPoint)
void update_server_list(enum server_scan_type sstype, const struct server_list *list)
void update_network_lists()
void slot_pregame_start()
fc_sidewidget * sw_cities
void popup_client_options()
void update_load_page(void)
pregame_options * pr_options
QTableWidget * scenarios_load
void rm_game_tab(int index)
void send_fake_chat_message(const QString &message)
void create_scenario_page()
void update_scenarios_page(void)
QIcon get_icon(const QString &id)
static fc_icons * instance()
void set_aifill(int aifill)
bool can_client_control(void)
bool client_is_global_observer(void)
bool client_is_observer(void)
char fc_password[MAX_LEN_PASSWORD]
static struct fc_sockaddr_list * list
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
bool player_has_color(const struct player *pplayer)
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
void key_center_capital(void)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
void fc_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)