Freeciv-3.2
Loading...
Searching...
No Matches
pages.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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#include <stdio.h>
19#include <time.h>
20
21#include <sys/stat.h>
22
23#include <gtk/gtk.h>
24
25/* utility */
26#include "fcintl.h"
27#include "log.h"
28#include "mem.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "chat.h"
34#include "dataio.h"
35#include "game.h"
36#include "mapimg.h"
37#include "version.h"
38
39/* client */
40#include "client_main.h"
41#include "climisc.h"
42#include "clinet.h"
43#include "connectdlg_common.h"
44#include "packhand.h"
45#include "servers.h"
46#include "update_queue.h"
47
48/* client/gui-gtk-4.0 */
49#include "chatline.h"
50#include "connectdlg.h"
51#include "dialogs.h"
52#include "graphics.h"
53#include "gui_main.h"
54#include "gui_stuff.h"
55#include "mapview.h"
56#include "menu.h"
57#include "optiondlg.h"
58#include "plrdlg.h" /* get_flag() */
59#include "repodlgs.h"
60#include "voteinfo_bar.h"
61
62#include "pages.h"
63
64
69
71
74
77
78/* This is the current page. Invalid value at start, to be sure that it won't
79 * be caught through a switch() statement. */
80static enum client_pages current_page = -1;
81
83{
84 struct server_scan *scan;
86};
87
88static struct server_scan_timer_data meta_scan = { NULL, 0 };
89static struct server_scan_timer_data lan_scan = { NULL, 0 };
90
94
96
98
100
101static void connection_state_reset(void);
102
103/**********************************************************************/
107{
108 if (!is_server_running()) {
110
111 /* Saved settings are sent in client/options.c
112 * resend_desired_settable_options() */
113 }
114}
115
116/**********************************************************************/
120{
121 output_window_append(ftc_client, _("Compiling scenario list."));
123}
124
125/**********************************************************************/
132
133/**********************************************************************/
141
142/**********************************************************************/
145static void open_settings(void)
146{
147 option_dialog_popup(_("Set local options"), client_optset);
148}
149
150/**********************************************************************/
153static void main_callback(GtkWidget *w, gpointer data)
154{
155 enum client_pages page = PAGE_MAIN;
156
157 if (client.conn.used) {
159 }
160 if (page != get_client_page()) {
161 set_client_page(page);
162 }
163}
164
165/**********************************************************************/
169 int width, int height, gpointer data)
170{
171 static PangoLayout *layout;
173 static int pwidth, pheight;
174 static bool left = FALSE;
176 struct sprite *intro = (struct sprite *)data;
177
178 cairo_set_source_surface(cr, intro->surface, 0, 0);
179 cairo_paint(cr);
180
181 if (!layout) {
182 char msgbuf[128];
183 const char *rev_ver;
184
186 desc = pango_font_description_from_string("Sans Bold 10");
189
191
192 if (rev_ver == NULL) {
193 /* TRANS: "version 2.6.0, gui-gtk-3.22 client" */
194 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, %s client"),
196 } else {
197 /* TRANS: "version 2.6.0
198 * commit: [modified] <git commit id>
199 * gui-gtk-3.22 client" */
200 fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s\ncommit: %s\n%s client"),
202 left = TRUE;
203 }
205
207 }
209
210 cairo_set_source_rgb(cr, 0, 0, 0);
211 cairo_move_to(cr, left ? 4 : allocation.width - pwidth - 3,
212 allocation.height - pheight - 3);
214
215 cairo_set_source_rgb(cr, 1, 1, 1);
216 cairo_move_to(cr, left ? 3 : allocation.width - pwidth - 4,
217 allocation.height - pheight - 4);
219}
220
221/**********************************************************************/
224static void intro_free(GtkWidget *w, gpointer *data)
225{
226 struct sprite *intro = (struct sprite *)data;
227
229}
230
231/**********************************************************************/
235{
236 GtkWidget *widget, *vgrid, *frame, *darea, *button, *table;
238 struct sprite *intro_in, *intro;
239 int width, height;
240 int sh;
241 int space_needed;
242 int grid_row = 0;
243
245
249 widget = vgrid;
250
251 frame = gtk_frame_new(NULL);
253 gtk_widget_set_margin_end(frame, 18);
255 gtk_widget_set_margin_top(frame, 18);
257 gtk_grid_attach(GTK_GRID(vgrid), frame, 0, grid_row++, 1, 1);
258
261 sh = screen_height();
262
263 if (sh <= 0) {
264 /* Assume some minimum height */
265 sh = 600;
266 }
267
268 space_needed = 250;
269#if IS_BETA_VERSION || IS_DEVEL_VERSION
270 /* Alpha or Beta notice takes extra space */
271 space_needed += 50;
272#endif
273
274 if (sh - height < space_needed) {
275 float scale;
276
277 if (sh < (space_needed + 0.2 * height)) {
278 /* Screen is simply too small, use minimum scale */
279 scale = 0.2;
280 } else {
281 scale = (double)(sh - space_needed) / height;
282 }
283 height *= scale;
284 width *= scale;
287 } else {
288 intro = intro_in;
289 }
290 darea = gtk_drawing_area_new();
294 g_signal_connect(widget, "destroy",
296 gtk_frame_set_child(GTK_FRAME(frame), darea);
297
298#if IS_BETA_VERSION || IS_DEVEL_VERSION
299 {
300 GtkWidget *label;
301
303 gtk_widget_set_name(label, "beta_label");
307 gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1);
308 }
309#endif /* IS_BETA_VERSION || IS_DEVEL_VERSION */
310
320
324
325 button = gtk_button_new_with_mnemonic(_("Start _New Game"));
327 gtk_grid_attach(GTK_GRID(table), button, 0, 0, 1, 1);
329 _("Launches local server, and connects to it for a single-player game."));
330 g_signal_connect(button, "clicked",
332
333 button = gtk_button_new_with_mnemonic(_("Start _Scenario Game"));
335 gtk_grid_attach(GTK_GRID(table), button, 0, 1, 1, 1);
337 _("Loads one of the scenarios for a single-player game. "
338 "Tutorial is one of the scenarios."));
339 g_signal_connect(button, "clicked",
341
342 button = gtk_button_new_with_mnemonic(_("_Load Saved Game"));
344 gtk_grid_attach(GTK_GRID(table), button, 0, 2, 1, 1);
346 _("Continues previously saved single-player game."));
347 g_signal_connect(button, "clicked",
349
350 button = gtk_button_new_with_mnemonic(_("C_onnect to Network Game"));
352 gtk_grid_attach(GTK_GRID(table), button, 1, 0, 1, 1);
354 _("Connects to outside server. "
355 "Sometimes you want to launch a separate server even for local games."));
356 g_signal_connect(button, "clicked",
358
359 button = gtk_button_new_with_mnemonic(_("Client Settings"));
361 gtk_grid_attach(GTK_GRID(table), button, 1, 1, 1, 1);
363 _("Adjusting client-side options."));
364 g_signal_connect(button, "clicked", open_settings, NULL);
365
366 button = icon_label_button_new("application-exit", _("E_xit"));
369 gtk_grid_attach(GTK_GRID(table), button, 1, 2, 1, 1);
371 _("Gives you a break from playing freeciv."));
372 g_signal_connect(button, "clicked",
374
375 return widget;
376}
377
378/****************************************************************************
379 GENERIC SAVE DIALOG
380****************************************************************************/
381typedef void (*save_dialog_action_fn_t) (const char *filename);
382typedef struct fileinfo_list * (*save_dialog_files_fn_t) (void);
383
384struct save_dialog {
390};
391
398
404
405/**********************************************************************/
409{
411 G_TYPE_STRING, /* SD_COL_PRETTY_NAME */
412 G_TYPE_STRING); /* SD_COL_FULL_PATH */
413}
414
415/**********************************************************************/
419 const struct fileinfo_list *files)
420{
422
426 gtk_list_store_set(store, &iter,
428 SD_COL_FULL_PATH, pfile->fullname,
429 -1);
431}
432
433/**********************************************************************/
436static void save_dialog_update(struct save_dialog *pdialog)
437{
438 struct fileinfo_list *files;
439
440 fc_assert_ret(NULL != pdialog);
441
442 /* Update the store. */
443 files = pdialog->files();
446 files);
448}
449
450/**********************************************************************/
454 gint response, gpointer data)
455{
456 if (response == GTK_RESPONSE_OK) {
459
460 if (file != NULL) {
461 gchar *filename = g_file_get_parse_name(file);
462
463 if (NULL != filename) {
464 action(filename);
465 g_free(filename);
466 }
467
468 g_object_unref(file);
469 }
470 }
471
473}
474
475/**********************************************************************/
478static void save_dialog_file_chooser_popup(const char *title,
481{
483
484 /* Create the chooser */
486 _("_Cancel"), GTK_RESPONSE_CANCEL,
488 _("_Save") : _("_Open"),
491
492 g_signal_connect(filechoose, "response",
494
495 /* Display that dialog */
497}
498
499/**********************************************************************/
503 gpointer data)
504{
505 struct save_dialog *pdialog = data;
506
507 switch (response) {
508 case SD_RES_BROWSE:
509 save_dialog_file_chooser_popup(_("Select Location to Save"),
511 pdialog->action);
512 break;
513 case SD_RES_DELETE:
514 {
515 GtkTreeSelection *selection;
516 GtkTreeModel *model;
518 const gchar *full_path;
519
520 selection = gtk_tree_view_get_selection(pdialog->tree_view);
521 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
522 return;
523 }
524
527 save_dialog_update(pdialog);
528 }
529 return;
530 case SD_RES_SAVE:
531 {
532 const char *text = gtk_entry_buffer_get_text(gtk_entry_get_buffer(pdialog->entry));
533 gchar *filename = g_filename_from_utf8(text, -1, NULL, NULL, NULL);
534
535 if (NULL == filename) {
536 return;
537 }
538 pdialog->action(filename);
539 g_free(filename);
540 }
541 break;
542 default:
543 break;
544 }
545
547}
548
549/**********************************************************************/
559
560/**********************************************************************/
567
568/**********************************************************************/
572 gpointer data)
573{
574 struct save_dialog *pdialog = data;
575 GtkTreeModel *model;
577 const gchar *filename;
578
579 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
581 return;
582 }
583
585 gtk_tree_model_get(model, &iter, SD_COL_PRETTY_NAME, &filename, -1);
587}
588
589/**********************************************************************/
592static GtkWidget *save_dialog_new(const char *title, const char *savelabel,
593 const char *savefilelabel,
596{
597 GtkWidget *shell, *sbox, *sw, *label, *view, *entry;
598 GtkBox *vbox;
599 GtkListStore *store;
601 GtkTreeSelection *selection;
602 struct save_dialog *pdialog;
603
606
607 /* Save dialog structure. */
608 pdialog = fc_malloc(sizeof(*pdialog));
609 pdialog->action = action;
610 pdialog->files = files;
611
612 /* Shell. */
614 _("_Browse..."), SD_RES_BROWSE,
615 _("_Delete"), SD_RES_DELETE,
616 _("_Cancel"), GTK_RESPONSE_CANCEL,
617 _("_Save"), SD_RES_SAVE,
618 NULL);
619 g_object_set_data_full(G_OBJECT(shell), "save_dialog", pdialog,
624 g_signal_connect(shell, "response",
626 pdialog->shell = GTK_DIALOG(shell);
628
629 /* Tree view. */
630 store = save_dialog_store_new();
634 g_object_unref(store);
636 g_signal_connect(view, "row-activated",
638 pdialog->tree_view = GTK_TREE_VIEW(view);
639
641 gtk_box_append(vbox, sbox);
642
644 "use-underline", TRUE,
645 "mnemonic-widget", view,
646 "label", savelabel,
647 "xalign", 0.0,
648 "yalign", 0.5,
649 NULL);
650 gtk_box_append(GTK_BOX(sbox), label);
651
660
663 g_signal_connect(selection, "changed",
665
668 -1, NULL, rend, "text",
670
671 /* Entry. */
674 g_signal_connect(entry, "activate",
676 pdialog->entry = GTK_ENTRY(entry);
677
683
685 "use-underline", TRUE,
686 "mnemonic-widget", entry,
687 "label", savefilelabel,
688 "xalign", 0.0,
689 "yalign", 0.5,
690 NULL);
691 gtk_box_append(GTK_BOX(sbox), label);
692
694 gtk_box_append(vbox, sbox);
695
696 save_dialog_update(pdialog);
699
700 return shell;
701}
702
703/****************************************************************************
704 NETWORK PAGE
705****************************************************************************/
711
712/**********************************************************************/
716 const struct server_list *list)
717{
720 GtkTreeIter it;
721 GtkListStore *store;
722 const gchar *host, *portstr;
723 int port;
724
725 switch (sstype) {
728 break;
731 break;
732 default:
733 break;
734 }
735
736 if (!sel) {
737 return;
738 }
739
743
744 if (!list) {
745 return;
746 }
747
750 port = atoi(portstr);
751
753 char buf[35];
754
755 if (pserver->humans >= 0) {
756 fc_snprintf(buf, sizeof(buf), "%d", pserver->humans);
757 } else {
758 sz_strlcpy(buf, _("Unknown"));
759 }
760 gtk_list_store_append(store, &it);
761 gtk_list_store_set(store, &it,
762 0, pserver->host,
763 1, pserver->port,
764 2, pserver->version,
765 3, _(pserver->state),
766 4, pserver->nplayers,
767 5, buf,
768 6, pserver->message,
769 -1);
770 if (strcmp(host, pserver->host) == 0 && port == pserver->port) {
772 }
774}
775
776/**********************************************************************/
780{
781 if (meta_scan.scan) {
784 }
785 if (meta_scan.timer != 0) {
787 meta_scan.timer = 0;
788 }
789 if (lan_scan.scan) {
792 }
793 if (lan_scan.timer != 0) {
795 lan_scan.timer = 0;
796 }
797}
798
799/**********************************************************************/
803{
804 struct server_scan_timer_data *scan_data = data;
805 struct server_scan *scan = scan_data->scan;
807
808 if (!scan) {
809 return FALSE;
810 }
811
812 stat = server_scan_poll(scan);
813 if (stat >= SCAN_STATUS_PARTIAL) {
815 struct srv_list *srvrs;
816
818 srvrs = server_scan_get_list(scan);
819 fc_mutex_allocate(&srvrs->mutex);
823 fc_mutex_release(&srvrs->mutex);
824 }
825
827 scan_data->timer = 0;
828 return FALSE;
829 }
830 return TRUE;
831}
832
833/**********************************************************************/
836static void server_scan_error(struct server_scan *scan,
837 const char *message)
838{
840 log_error("%s", message);
841
842 /* Main thread will finalize the scan later (or even concurrently) -
843 * do not do anything here to cause double free or raze condition. */
844}
845
846/**********************************************************************/
859
860/**************************************************************************
861 Network connection state defines.
862**************************************************************************/
869
871
872/**********************************************************************/
876{
878 char *txt;
879
882 free(txt);
883 }
884
885 return TRUE;
886}
887
888/**********************************************************************/
891static void clear_network_statusbar(void)
892{
894 char *txt;
895
897 free(txt);
898 }
900}
901
902/**********************************************************************/
905void append_network_statusbar(const char *text, bool force)
906{
908 if (force) {
911 } else {
913 }
914 }
915}
916
917/**********************************************************************/
936
937/**********************************************************************/
941{
942 switch (state) {
943 case LOGIN_TYPE:
945
947 "", -1);
949 "", -1);
950
959 break;
964 "", -1);
965
974
976 break;
981 "", -1);
982
991
993 break;
994 case WAITING_TYPE:
996
1003 break;
1004 }
1005
1006 connection_status = state;
1007}
1008
1009/**********************************************************************/
1012static void connection_state_reset(void)
1013{
1015}
1016
1017/**********************************************************************/
1022 const char *message)
1023{
1025
1026 switch (type) {
1027 case AUTH_NEWUSER_FIRST:
1028 case AUTH_NEWUSER_RETRY:
1030 return;
1031 case AUTH_LOGIN_FIRST:
1032 /* if we magically have a password already present in 'fc_password'
1033 * then, use that and skip the password entry dialog */
1034 if (fc_password[0] != '\0') {
1036
1037 sz_strlcpy(reply.password, fc_password);
1039 return;
1040 } else {
1042 }
1043 return;
1044 case AUTH_LOGIN_RETRY:
1046 return;
1047 }
1048
1049 log_error("Unsupported authentication type %d: %s.", type, message);
1050}
1051
1052/**********************************************************************/
1058{
1059 char errbuf [512];
1061
1062 switch (connection_status) {
1063 case LOGIN_TYPE:
1069
1071 errbuf, sizeof(errbuf)) != -1) {
1072 } else {
1074
1076 }
1077 return;
1078 case NEW_PASSWORD_TYPE:
1079 if (w != network_password) {
1082 sz_strlcpy(reply.password,
1084 if (!fc_strncmp(reply.password, fc_password, MAX_LEN_NAME)) {
1085 fc_password[0] = '\0';
1087
1089 } else {
1090 append_network_statusbar(_("Passwords don't match, enter password."),
1091 TRUE);
1092
1094 }
1095 }
1096 return;
1098 sz_strlcpy(reply.password,
1101
1103 return;
1104 case WAITING_TYPE:
1105 return;
1106 }
1107
1108 log_error("Unsupported connection status: %d", connection_status);
1109}
1110
1111/**********************************************************************/
1117 gpointer data)
1118{
1119 connect_callback(NULL, data);
1120}
1121
1122/**********************************************************************/
1126static void update_server_playerlist(const struct server *pserver)
1127{
1128 GtkListStore *store;
1130 int n, i;
1131
1133 fc_assert_ret(store != NULL);
1134
1135 gtk_list_store_clear(store);
1136 if (!pserver || !pserver->players) {
1137 return;
1138 }
1139
1140 n = pserver->nplayers;
1141 for (i = 0; i < n; i++) {
1142 gtk_list_store_append(store, &iter);
1143 gtk_list_store_set(store, &iter,
1144 0, pserver->players[i].name,
1145 1, pserver->players[i].type,
1146 2, pserver->players[i].host,
1147 3, pserver->players[i].nation,
1148 -1);
1149 }
1150}
1151
1152/**********************************************************************/
1156{
1157 GtkTreeModel *model;
1158 GtkTreeIter it;
1159 const char *host;
1160 int port;
1161 char portstr[32];
1162 const struct server *pserver = NULL;
1163
1164 if (!gtk_tree_selection_get_selected(select, &model, &it)) {
1165 return;
1166 }
1167
1168 if (select == meta_selection) {
1169 GtkTreePath *path;
1170 struct srv_list *srvrs;
1171
1173 path = gtk_tree_model_get_path(model, &it);
1175 /* We are not yet inside mutex protected block */
1176 fc_mutex_allocate(&srvrs->mutex);
1177 }
1178 if (srvrs->servers && path) {
1180
1182 }
1184 /* We are not yet inside mutex protected block */
1185 fc_mutex_release(&srvrs->mutex);
1186 }
1187 gtk_tree_path_free(path);
1188 }
1190
1191 gtk_tree_model_get(model, &it, 0, &host, 1, &port, -1);
1192
1194 fc_snprintf(portstr, sizeof(portstr), "%d", port);
1196}
1197
1198/**********************************************************************/
1213
1214/**********************************************************************/
1218{
1219 GtkWidget *box, *sbox, *bbox, *hbox, *notebook;
1220 GtkWidget *button, *label, *view, *sw, *table;
1221 GtkTreeSelection *selection;
1222 GtkListStore *store;
1224
1230
1231 notebook = gtk_notebook_new();
1232 gtk_box_append(GTK_BOX(box), notebook);
1233
1234 /* LAN pane. */
1236 G_TYPE_INT, /* port */
1237 G_TYPE_STRING, /* version */
1238 G_TYPE_STRING, /* state */
1239 G_TYPE_INT, /* nplayers */
1240 G_TYPE_STRING, /* humans */
1241 G_TYPE_STRING); /* message */
1242
1248
1250 lan_selection = selection;
1252
1257
1258 g_signal_connect(view, "row-activated",
1260 g_signal_connect(selection, "changed",
1262
1263 add_treeview_column(view, _("Server Name"), G_TYPE_STRING, 0);
1264 add_treeview_column(view, _("Port"), G_TYPE_INT, 1);
1265 add_treeview_column(view, _("Version"), G_TYPE_STRING, 2);
1266 add_treeview_column(view, _("Status"), G_TYPE_STRING, 3);
1267 add_treeview_column(view, _("Players"), G_TYPE_INT, 4);
1268 add_treeview_column(view, _("Humans"), G_TYPE_STRING, 5);
1269 add_treeview_column(view, _("Comment"), G_TYPE_STRING, 6);
1270
1271 label = gtk_label_new_with_mnemonic(_("Local _Area Network"));
1272
1282 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label);
1283
1284
1285 /* Metaserver pane. */
1287 G_TYPE_INT, /* port */
1288 G_TYPE_STRING, /* version */
1289 G_TYPE_STRING, /* state */
1290 G_TYPE_INT, /* nplayers */
1291 G_TYPE_STRING, /* humans */
1292 G_TYPE_STRING); /* message */
1293
1299
1301 meta_selection = selection;
1303
1308
1309 g_signal_connect(view, "row-activated",
1311 g_signal_connect(selection, "changed",
1313
1314 add_treeview_column(view, _("Server Name"), G_TYPE_STRING, 0);
1315 add_treeview_column(view, _("Port"), G_TYPE_INT, 1);
1316 add_treeview_column(view, _("Version"), G_TYPE_STRING, 2);
1317 add_treeview_column(view, _("Status"), G_TYPE_STRING, 3);
1318 add_treeview_column(view, _("Players"), G_TYPE_INT, 4);
1319 add_treeview_column(view, _("Humans"), G_TYPE_STRING, 5);
1320 add_treeview_column(view, _("Comment"), G_TYPE_STRING, 6);
1321
1322 label = gtk_label_new_with_mnemonic(_("Internet _Metaserver"));
1323
1334 gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), sw, label);
1335 } else {
1336 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label);
1337 }
1338
1339 /* Bottom part of the page, outside the inner notebook. */
1342
1349
1350 table = gtk_grid_new();
1354
1356 g_signal_connect(network_host, "activate",
1359
1361 "use-underline", TRUE,
1362 "mnemonic-widget", network_host,
1363 "label", _("_Host:"),
1364 "xalign", 0.0,
1365 "yalign", 0.5,
1366 NULL);
1367 network_host_label = label;
1368 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
1369
1371 g_signal_connect(network_port, "activate",
1374
1376 "use-underline", TRUE,
1377 "mnemonic-widget", network_port,
1378 "label", _("_Port:"),
1379 "xalign", 0.0,
1380 "yalign", 0.5,
1381 NULL);
1382 network_port_label = label;
1383 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
1384
1387 g_signal_connect(network_login, "activate",
1390
1392 "use-underline", TRUE,
1393 "mnemonic-widget", network_login,
1394 "label", _("_Login:"),
1395 "xalign", 0.0,
1396 "yalign", 0.5,
1397 NULL);
1398 gtk_widget_set_margin_top(label, 10);
1399 network_login_label = label;
1400 gtk_grid_attach(GTK_GRID(table), label, 0, 3, 1, 1);
1401
1407
1409 "use-underline", TRUE,
1410 "mnemonic-widget", network_password,
1411 "label", _("Pass_word:"),
1412 "xalign", 0.0,
1413 "yalign", 0.5,
1414 NULL);
1415 network_password_label = label;
1416 gtk_grid_attach(GTK_GRID(table), label, 0, 4, 1, 1);
1417
1423
1425 "use-underline", TRUE,
1426 "mnemonic-widget", network_confirm_password,
1427 "label", _("Conf_irm Password:"),
1428 "xalign", 0.0,
1429 "yalign", 0.5,
1430 NULL);
1432 gtk_grid_attach(GTK_GRID(table), label, 0, 5, 1, 1);
1433
1434 /* Server player list. */
1440
1446 add_treeview_column(view, _("Nation"), G_TYPE_STRING, 3);
1448
1455
1463
1464 button = gtk_button_new_from_icon_name("view-refresh");
1465 gtk_box_append(GTK_BOX(bbox), button);
1466 g_signal_connect(button, "clicked",
1468
1469 button = gtk_button_new_with_mnemonic(_("_Cancel"));
1470 gtk_box_append(GTK_BOX(bbox), button);
1471 g_signal_connect(button, "clicked",
1473
1474 button = gtk_button_new_with_mnemonic(_("C_onnect"));
1475 gtk_box_append(GTK_BOX(bbox), button);
1476 g_signal_connect(button, "clicked",
1478
1479 return box;
1480}
1481
1482/****************************************************************************
1483 START PAGE
1484****************************************************************************/
1486
1493
1494
1495/* NB: Must match creation arguments in connection_list_store_new(). */
1512
1513/**********************************************************************/
1517{
1519 G_TYPE_INT, /* CL_COL_PLAYER_NUMBER */
1520 G_TYPE_STRING, /* CL_COL_USER_NAME */
1521 G_TYPE_BOOLEAN, /* CL_COL_READY_STATE */
1522 G_TYPE_STRING, /* CL_COL_PLAYER_NAME */
1523 GDK_TYPE_PIXBUF, /* CL_COL_FLAG */
1524 GDK_TYPE_PIXBUF, /* CL_COL_COLOR */
1525 G_TYPE_STRING, /* CL_COL_NATION */
1526 G_TYPE_STRING, /* CL_COL_TEAM */
1527 G_TYPE_INT, /* CL_COL_CONN_ID */
1528 G_TYPE_INT, /* CL_COL_STYLE */
1529 G_TYPE_INT, /* CL_COL_WEIGHT */
1530 G_TYPE_BOOLEAN); /* CL_COL_COLLAPSED */
1531}
1532
1533/**********************************************************************/
1537static void client_aitoggle_player(void *data)
1538{
1539 struct player *pplayer = player_by_number(FC_PTR_TO_INT(data));
1540
1541 if (NULL != pplayer
1542 && pplayer == client_player()
1543 && !is_human(pplayer)) {
1544 send_chat("/away");
1545 }
1546}
1547
1548/**********************************************************************/
1551static void client_take_player(struct player *pplayer)
1552{
1553 int request_id = send_chat_printf("/take \"%s\"", player_name(pplayer));
1554 void *data = FC_INT_TO_PTR(player_number(pplayer));
1555
1558}
1559
1560/**********************************************************************/
1563static void object_put(GObject *object, struct player *pplayer,
1564 struct connection *pconn)
1565{
1566 /* Note that passing -1 to GINT_TO_POINTER() is buggy with some versions
1567 * of gcc. player_slot_count() is not a valid player number. 0 is not
1568 * a valid connection id (see comment in server/sernet.c:
1569 * makeup_connection_name()). */
1570 g_object_set_data(object, "player_id",
1571 GINT_TO_POINTER(NULL != pplayer
1572 ? player_number(pplayer)
1573 : player_slot_count()));
1574 g_object_set_data(object, "connection_id",
1575 GINT_TO_POINTER(NULL != pconn ? pconn->id : 0));
1576}
1577
1578/**********************************************************************/
1582static bool object_extract(GObject *object, struct player **ppplayer,
1583 struct connection **ppconn)
1584{
1585 bool ret = FALSE;
1586 int id;
1587
1588 if (NULL != ppplayer) {
1589 id = GPOINTER_TO_INT(g_object_get_data(object, "player_id"));
1591 if (NULL != *ppplayer) {
1592 ret = TRUE;
1593 }
1594 }
1595 if (NULL != ppconn) {
1596 id = GPOINTER_TO_INT(g_object_get_data(object, "connection_id"));
1597 *ppconn = conn_by_number(id);
1598 if (NULL != *ppconn) {
1599 ret = TRUE;
1600 }
1601 }
1602
1603 return ret;
1604}
1605
1606/**********************************************************************/
1610{
1611 option_dialog_popup(_("Game Settings"), server_optset);
1612}
1613
1614/**********************************************************************/
1618{
1619 enum ai_level *levels = (enum ai_level *)data;
1620 const char *name;
1621 int i;
1622
1624
1625 if (i != -1) {
1626 enum ai_level level = levels[i];
1627
1628 /* Suppress changes provoked by server rather than local user */
1629 if (server_ai_level() != level) {
1631 send_chat_printf("/%s", name);
1632 }
1633 }
1634}
1635
1636/* HACK: sometimes when creating the ruleset combo the value is set without
1637 * the user's control. In this case we don't want to do a /read. */
1639
1640/**********************************************************************/
1643static void ruleset_selected(const char *name)
1644{
1645 if (name && name[0] != '\0' && !no_ruleset_callback) {
1647 }
1648}
1649
1650/**********************************************************************/
1656{
1657 const char *name = NULL;
1658
1660
1661 if (name != NULL) {
1663 }
1664}
1665
1666/**********************************************************************/
1677
1678/**********************************************************************/
1682{
1683 if (start_aifill_spin) {
1684 bool old = send_new_aifill_to_server;
1685 /* Suppress callback from this change to avoid a loop. */
1687 /* HACK: this GUI control doesn't have quite the same semantics as the
1688 * server 'aifill' option, in that it claims to represent the minimum
1689 * number of players _including humans_. The GUI control has a minimum
1690 * value of 1, so aifill == 0 will not be represented correctly.
1691 * But there's generally exactly one human player because the control
1692 * only shows up for a locally spawned server, so we more or less
1693 * get away with this. */
1696 }
1697}
1698
1699/**********************************************************************/
1703{
1705}
1706
1707/**********************************************************************/
1711{
1712 if (conn_popover != NULL){
1715
1717 }
1718}
1719
1720/**********************************************************************/
1724 gpointer data)
1725{
1726 struct player *pplayer;
1727 struct team_slot *tslot = g_object_get_data(G_OBJECT(action), "slot");
1728 GMenu *menu = data;
1729
1730 if (object_extract(G_OBJECT(menu), &pplayer, NULL)
1731 && NULL != tslot
1732 && team_slot_index(tslot) != team_number(pplayer->team)) {
1733 send_chat_printf("/team \"%s\" \"%s\"",
1734 player_name(pplayer),
1736 }
1737
1739}
1740
1741/**********************************************************************/
1745 gpointer data)
1746{
1747 struct player *pplayer;
1748 GMenu *menu = data;
1749
1750 if (object_extract(G_OBJECT(menu), &pplayer, NULL)) {
1752 player_number(pplayer), !pplayer->is_ready);
1753 }
1754
1756}
1757
1758/**********************************************************************/
1762 gpointer data)
1763{
1764 struct player *pplayer;
1765 GMenu *menu = data;
1766
1767 if (object_extract(G_OBJECT(menu), &pplayer, NULL)) {
1768 popup_races_dialog(pplayer);
1769 }
1770
1772}
1773
1774/**********************************************************************/
1779 gpointer data)
1780{
1781 struct player *pplayer;
1782 GMenu *menu = data;
1783
1784 if (object_extract(G_OBJECT(menu), &pplayer, NULL)) {
1785 send_chat_printf("/%s \"%s\"",
1786 (char *) g_object_get_data(G_OBJECT(action), "command"),
1787 player_name(pplayer));
1788 }
1789
1791}
1792
1793/**********************************************************************/
1797 gpointer data)
1798{
1799 struct player *pplayer;
1800 GMenu *menu = data;
1801
1802 if (object_extract(G_OBJECT(menu), &pplayer, NULL)) {
1803 client_take_player(pplayer);
1804 }
1805
1807}
1808
1809/**********************************************************************/
1814 GVariant *parameter, gpointer data)
1815{
1816 struct connection *pconn;
1817 GMenu *menu = data;
1818
1819 if (object_extract(G_OBJECT(menu), NULL, &pconn)) {
1821 (char *) g_object_get_data(G_OBJECT(action), "command"),
1822 pconn->username);
1823 }
1824
1826}
1827
1828/**********************************************************************/
1831static void show_conn_popup(struct player *pplayer, struct connection *pconn)
1832{
1834 char buf[4096] = "";
1835
1836 if (pconn) {
1837 cat_snprintf(buf, sizeof(buf), _("Connection name: %s"),
1838 pconn->username);
1839 } else {
1840 cat_snprintf(buf, sizeof(buf), _("Player name: %s"),
1841 player_name(pplayer));
1842 }
1843 cat_snprintf(buf, sizeof(buf), "\n");
1844 if (pconn) {
1845 cat_snprintf(buf, sizeof(buf), _("Host: %s"), pconn->addr);
1846 }
1847 cat_snprintf(buf, sizeof(buf), "\n");
1848
1849 /* Show popup. */
1852 "%s", buf);
1853 gtk_window_set_title(GTK_WINDOW(popup), _("Player/conn info"));
1857}
1858
1859/**********************************************************************/
1863 gpointer data)
1864{
1865 struct player *pplayer;
1866 struct connection *pconn;
1867 GMenu *menu = data;
1868
1869 if (object_extract(G_OBJECT(menu), &pplayer, &pconn)) {
1870 show_conn_popup(pplayer, pconn);
1871 }
1872
1874}
1875
1876/**********************************************************************/
1880static GtkWidget *create_conn_menu(struct player *pplayer,
1881 struct connection *pconn)
1882{
1883 GMenu *menu;
1884 gchar *buf;
1885 GSimpleAction *act;
1886 GActionGroup *group;
1887
1889
1890 menu = g_menu_new();
1891
1892 object_put(G_OBJECT(menu), pplayer, pconn);
1893
1894 buf = g_strdup_printf(_("%s info"),
1895 pconn ? pconn->username : player_name(pplayer));
1896
1897 act = g_simple_action_new("info", NULL);
1899 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_info_chosen), menu);
1900 menu_item_append_unref(menu, g_menu_item_new(buf, "win.info"));
1901
1902 if (NULL != pplayer) {
1903 act = g_simple_action_new("toggle_ready", NULL);
1905 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_ready_chosen), menu);
1907 menu_item_append_unref(menu, g_menu_item_new(_("Toggle player ready"),
1908 "win.toggle_ready"));
1909
1910 act = g_simple_action_new("pick_nation", NULL);
1912 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_nation_chosen), menu);
1915 pplayer));
1916 menu_item_append_unref(menu, g_menu_item_new(_("Pick nation"), "win.pick_nation"));
1917
1918 act = g_simple_action_new("observe", NULL);
1919 g_object_set_data_full(G_OBJECT(act), "command", g_strdup("observe"),
1922 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_player_command), menu);
1923 menu_item_append_unref(menu, g_menu_item_new(_("Observe this player"),
1924 "win.observe"));
1925
1926 act = g_simple_action_new("take_plr", NULL);
1928 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_player_take), menu);
1929 menu_item_append_unref(menu, g_menu_item_new(_("Take this player"),
1930 "win.take_plr"));
1931 }
1932
1934 && pconn->id != client.conn.id) {
1935 act = g_simple_action_new("cut_conn", NULL);
1936 g_object_set_data_full(G_OBJECT(act), "command", g_strdup("cut"),
1940 menu_item_append_unref(menu, g_menu_item_new(_("Cut connection"), "win.cut_conn"));
1941 }
1942
1943 if (ALLOW_CTRL <= client.conn.access_level && NULL != pplayer) {
1944 act = g_simple_action_new("aitoggle", NULL);
1945 g_object_set_data_full(G_OBJECT(act), "command", g_strdup("aitoggle"),
1949 menu_item_append_unref(menu, g_menu_item_new(_("Aitoggle player"), "win.aitoggle"));
1950
1951 if (pplayer != client.conn.playing && game.info.is_new_game) {
1952 act = g_simple_action_new("remove", NULL);
1953 g_object_set_data_full(G_OBJECT(act), "command", g_strdup("remove"),
1957 menu_item_append_unref(menu, g_menu_item_new(_("Remove player"), "win.remove"));
1958 }
1959 }
1960
1962 && pconn->id != client.conn.id) {
1963 enum cmdlevel level;
1964
1965 /* No item for hack access; that would be a serious security hole. */
1967 char actbuf[128];
1968
1969 buf = g_strdup_printf(_("Give %s access"), cmdlevel_name(level));
1970 fc_snprintf(actbuf, sizeof(actbuf), "cmdlevel_%d", level);
1971
1973 g_object_set_data_full(G_OBJECT(act), "command",
1974 g_strdup_printf("cmdlevel %s",
1979 fc_snprintf(actbuf, sizeof(actbuf), "win.cmdlevel_%d", level);
1981 g_free(buf);
1982 }
1983 }
1984
1986 && NULL != pplayer && is_ai(pplayer)) {
1987 enum ai_level level;
1988
1989 for (level = 0; level < AI_LEVEL_COUNT; level++) {
1991 char actbuf[128];
1992
1993 buf = g_strdup_printf(_("Difficulty: %s"), ai_level_translated_name(level));
1994 fc_snprintf(actbuf, sizeof(actbuf), "ailevel_%d", level);
1995
1997 g_object_set_data_full(G_OBJECT(act), "command",
2001 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_player_command), menu);
2002 fc_snprintf(actbuf, sizeof(actbuf), "win.ailevel_%d", level);
2004 g_free(buf);
2005 }
2006 }
2007 }
2008
2009 if (pplayer != NULL /* && game.info.is_new_game */) {
2010 const int count = pplayer->team
2011 ? player_list_size(team_members(pplayer->team)) : 0;
2012 bool need_empty_team = (count != 1);
2013
2014 /* Can't use team_iterate here since it skips empty teams. */
2016 char actbuf[128];
2017 int id;
2018
2019 if (!team_slot_is_used(tslot)) {
2020 if (!need_empty_team) {
2021 continue;
2022 }
2024 }
2025
2027
2028 /* TRANS: e.g., "Put on Team 5" */
2029 buf = g_strdup_printf(_("Put on %s"),
2031 fc_snprintf(actbuf, sizeof(actbuf), "team_%d", id);
2032
2034 g_object_set_data(G_OBJECT(act), "slot", tslot);
2036 g_signal_connect(act, "activate", G_CALLBACK(conn_menu_team_chosen), menu);
2037 fc_snprintf(actbuf, sizeof(actbuf), "win.team_%d", id);
2039 g_free(buf);
2041 }
2042
2047
2048 return conn_popover;
2049}
2050
2051/**********************************************************************/
2055{
2056 if (NULL != connection_list_view) {
2057 GtkTreeSelection *selection =
2059 GtkTreePath *path = data;
2060
2061 gtk_tree_selection_unselect_path(selection, path);
2062 gtk_tree_path_free(path);
2063 }
2064 return FALSE;
2065}
2066
2067/**********************************************************************/
2071 int n_press,
2072 double x, double y, gpointer data)
2073{
2076 GtkTreePath *path = NULL;
2078
2080 x, y,
2081 &path, NULL, NULL, NULL)) {
2082 return FALSE;
2083 }
2084
2085 if (gtk_tree_selection_path_is_selected(selection, path)) {
2086 /* Need to delay to avoid problem with the expander. */
2088 return FALSE; /* Return now, don't free the path. */
2089 }
2090
2091 gtk_tree_path_free(path);
2092
2093 return FALSE;
2094}
2095
2096/**********************************************************************/
2100 int n_press,
2101 double x, double y, gpointer data)
2102{
2105 GtkWidget *parent = data;
2106 GtkTreePath *path = NULL;
2107 GtkWidget *menu;
2108 GtkTreeSelection *selection;
2109 GtkTreeModel *model;
2111 int player_no, conn_id;
2112 struct player *pplayer;
2113 struct connection *pconn;
2114 int bx, by;
2115 GdkRectangle rect = { .x = x, .y = y, .width = 1, .height = 1};
2116
2118
2120 &path, NULL, NULL, NULL)) {
2121 return FALSE;
2122 }
2123
2126
2127 if (!gtk_tree_selection_path_is_selected(selection, path)) {
2128 gtk_tree_selection_select_path(selection, path);
2129 }
2130 gtk_tree_model_get_iter(model, &iter, path);
2131
2132 gtk_tree_model_get(model, &iter, CL_COL_PLAYER_NUMBER, &player_no, -1);
2133 pplayer = player_by_number(player_no);
2134
2135 gtk_tree_model_get(model, &iter, CL_COL_CONN_ID, &conn_id, -1);
2136 pconn = conn_by_number(conn_id);
2137
2138 menu = create_conn_menu(pplayer, pconn);
2139 gtk_widget_set_parent(menu, parent); /* Gtk bug prevents tree view parenting */
2141
2143
2144 gtk_tree_path_free(path);
2145
2146 return TRUE;
2147}
2148
2149/**********************************************************************/
2154 GtkTreePath *path,
2155 gpointer data)
2156{
2158
2159 gtk_tree_store_set(store, iter,
2161}
2162
2163/**********************************************************************/
2168 struct connection **ppconn)
2169{
2170 if (NULL != connection_list_view) {
2172 GtkTreeModel *model;
2173 GtkTreeSelection *selection =
2175
2176 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
2177 int id;
2178
2179 if (NULL != ppplayer) {
2180 gtk_tree_model_get(model, &iter, CL_COL_PLAYER_NUMBER, &id, -1);
2182 }
2183 if (NULL != ppconn) {
2184 gtk_tree_model_get(model, &iter, CL_COL_CONN_ID, &id, -1);
2185 *ppconn = conn_by_number(id);
2186 }
2187 return TRUE;
2188 }
2189 }
2190
2191 if (NULL != ppplayer) {
2192 *ppplayer = NULL;
2193 }
2194 if (NULL != ppconn) {
2195 *ppconn = NULL;
2196 }
2197 return FALSE;
2198}
2199
2200/**********************************************************************/
2204{
2205 GtkTreeModel *model;
2206 GtkTreeIter parent, child, *iter = NULL;
2207 GtkTreeSelection *selection;
2208 gboolean valid;
2209 const int search_id = pconn->id;
2210 int id;
2211
2212 if (NULL == connection_list_view) {
2213 return;
2214 }
2215
2218
2219 /* Main iteration. */
2220 valid = gtk_tree_model_get_iter_first(model, &parent);
2221 while (valid && NULL == iter) {
2222 gtk_tree_model_get(model, &parent, CL_COL_CONN_ID, &id, -1);
2223 if (search_id == id) {
2224 iter = &parent;
2225 break;
2226 }
2227
2228 /* Node children iteration. */
2229 valid = gtk_tree_model_iter_children(model, &child, &parent);
2230 while (valid && NULL == iter) {
2231 gtk_tree_model_get(model, &child, CL_COL_CONN_ID, &id, -1);
2232 if (search_id == id) {
2233 iter = &child;
2234 break;
2235 }
2236 valid = gtk_tree_model_iter_next(model, &child);
2237 }
2238
2239 valid = gtk_tree_model_iter_next(model, &parent);
2240 }
2241
2242 /* Select iterator. */
2243 if (NULL != iter) {
2245 } else {
2246 log_error("%s(): connection %s not found.",
2248 }
2249}
2250
2251/**********************************************************************/
2255{
2256 if (can_client_control()) {
2259 !client_player()->is_ready);
2260 } else {
2262 }
2263}
2264
2265/**********************************************************************/
2269{
2270 struct player *selected_plr;
2271 bool row_selected = conn_list_selection(&selected_plr, NULL);
2272
2273 if (row_selected && NULL != selected_plr) {
2274 /* "Take <player_name>" */
2276 } else if (can_client_control()) {
2277 /* "Pick Nation" */
2279 } else {
2280 /* "Take a Player" */
2281 send_chat("/take -");
2282 }
2283}
2284
2285/**********************************************************************/
2289{
2290 struct player *selected_plr;
2291 bool row_selected = conn_list_selection(&selected_plr, NULL);
2292
2293 if (row_selected && NULL != selected_plr) {
2294 /* "Observe <player_name>" */
2295 send_chat_printf("/observe \"%s\"", player_name(selected_plr));
2296 } else if (!client_is_global_observer()) {
2297 /* "Observe" */
2298 send_chat("/observe");
2299 } else {
2300 /* "Do not observe" */
2301 send_chat("/detach");
2302 }
2303}
2304
2305/**********************************************************************/
2309{
2310 char buf[2 * MAX_LEN_NAME];
2311 const char *text;
2312 struct player *selected_plr;
2313 bool row_selected = conn_list_selection(&selected_plr, NULL);
2314 bool sensitive;
2315
2316 /*** Ready button. ***/
2317 if (can_client_control()) {
2318 sensitive = client_player()->is_alive;
2319 if (client_player()->is_ready) {
2320 text = _("Not _ready");
2321 } else {
2322 int num_unready = 0;
2323
2324 players_iterate_alive(pplayer) {
2325 if (is_human(pplayer) && !pplayer->is_ready) {
2326 num_unready++;
2327 }
2329
2330 if (num_unready > 1) {
2331 text = _("_Ready");
2332 } else {
2333 /* We are the last unready player so clicking here will
2334 * immediately start the game. */
2335 text = _("_Start");
2336 }
2337 }
2338 } else {
2339 text = _("_Start");
2340 if (can_client_access_hack()) {
2341 sensitive = TRUE;
2343 if (is_human(plr)) {
2344 /* There's human controlled player(s) in game, so it's their
2345 * job to start the game. */
2346 sensitive = FALSE;
2347 break;
2348 }
2350 } else {
2351 sensitive = FALSE;
2352 }
2353 }
2356
2357 /*** Nation button. ***/
2358 if (row_selected && NULL != selected_plr) {
2359 fc_snprintf(buf, sizeof(buf), _("_Take %s"), player_name(selected_plr));
2360 text = buf;
2362 } else if (can_client_control()) {
2363 text = _("Pick _Nation");
2365 } else {
2366 text = _("_Take a Player");
2368 }
2371
2372 /*** Observe button. ***/
2373 if (row_selected && NULL != selected_plr) {
2374 fc_snprintf(buf, sizeof(buf), _("_Observe %s"),
2376 text = buf;
2378 } else if (!client_is_global_observer()) {
2379 text = _("_Observe");
2380 sensitive = TRUE;
2381 } else {
2382 text = _("Do not _observe");
2383 sensitive = TRUE;
2384 }
2387}
2388
2389/**********************************************************************/
2395 GtkTreeIter *start,
2396 const struct player *pplayer)
2397{
2398 const int search_id = player_number(pplayer);
2399 int id;
2400
2401 if (NULL != start) {
2402 *iter = *start;
2403 if (!gtk_tree_model_iter_next(model, iter)) {
2404 return FALSE;
2405 }
2406 } else if (!gtk_tree_model_get_iter_first(model, iter)) {
2407 return FALSE;
2408 }
2409
2410 do {
2412 if (id == search_id) {
2413 return TRUE;
2414 }
2415 } while (gtk_tree_model_iter_next(model, iter));
2416
2417 return FALSE;
2418}
2419
2420/**********************************************************************/
2426 const struct connection *pconn)
2427{
2428 const int search_id = pconn->id;
2429 int id;
2430
2431 if (NULL != start) {
2432 *iter = *start;
2433 if (!gtk_tree_model_iter_next(model, iter)) {
2434 return FALSE;
2435 }
2436 } else if (!gtk_tree_model_iter_children(model, iter, parent)) {
2437 return FALSE;
2438 }
2439
2440 do {
2441 gtk_tree_model_get(model, iter, CL_COL_CONN_ID, &id, -1);
2442 if (id == search_id) {
2443 return TRUE;
2444 }
2445 } while (gtk_tree_model_iter_next(model, iter));
2446
2447 return FALSE;
2448}
2449
2450/**********************************************************************/
2454{
2459 GtkTreeModel *model = GTK_TREE_MODEL(store);
2460 GtkTreePath *path;
2463 GdkPixbuf *flag, *color;
2465 struct player *pselected_player;
2466 struct connection *pselected_conn;
2467 bool is_ready;
2468 const char *nation, *plr_name, *team;
2469 char name[MAX_LEN_NAME + 8];
2471 int conn_id;
2472
2473 /* Refresh the AI skill level control */
2474 if (ai_lvl_combobox) {
2475 enum ai_level new_level = server_ai_level(), level;
2476 int i = 0;
2477
2478 for (level = 0; level < AI_LEVEL_COUNT; level++) {
2480 if (level == new_level) {
2482 break;
2483 }
2484 i++;
2485 }
2486 }
2487 if (level == AI_LEVEL_COUNT) {
2488 /* Probably ai_level_invalid() */
2490 }
2491 }
2492
2493 /* Save the selected connection. */
2495
2496 /* Insert players into the connection list. */
2497 players_iterate(pplayer) {
2498 if (!player_has_flag(pplayer, PLRF_SCENARIO_RESERVED)) {
2499 conn_id = -1;
2501 flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
2502 color = create_player_icon(pplayer);
2503
2504 conn_list_iterate(pplayer->connections, pconn) {
2505 if (pconn->playing == pplayer && !pconn->observer) {
2506 conn_id = pconn->id;
2507 access_level = pconn->access_level;
2508 break;
2509 }
2511
2512 if (is_ai(pplayer) && !pplayer->was_created
2513 && !pplayer->is_connected) {
2514 /* TRANS: "<Novice AI>" */
2515 fc_snprintf(name, sizeof(name), _("<%s AI>"),
2516 ai_level_translated_name(pplayer->ai_common.skill_level));
2517 } else {
2518 sz_strlcpy(name, pplayer->username);
2519 if (access_level > ALLOW_BASIC) {
2520 sz_strlcat(name, "*");
2521 }
2522 }
2523
2524 is_ready = !is_human(pplayer) ? TRUE : pplayer->is_ready;
2525
2526 if (pplayer->nation == NO_NATION_SELECTED) {
2527 nation = _("Random");
2528 if (pplayer->was_created) {
2529 plr_name = player_name(pplayer);
2530 } else {
2531 plr_name = "";
2532 }
2533 } else {
2534 nation = nation_adjective_for_player(pplayer);
2535 plr_name = player_name(pplayer);
2536 }
2537
2538 team = pplayer->team ? team_name_translation(pplayer->team) : "";
2539
2540 if (model_get_player_iter(model, &parent, pprev_parent, pplayer)) {
2542 } else {
2544 }
2545
2546 gtk_tree_store_set(store, &parent,
2549 CL_COL_READY_STATE, is_ready,
2551 CL_COL_FLAG, flag,
2553 CL_COL_NATION, nation,
2555 CL_COL_CONN_ID, conn_id,
2558 -1);
2559
2560 /* Insert observers of this player as child nodes. */
2561 pprev_child = NULL;
2562 conn_list_iterate(pplayer->connections, pconn) {
2563 if (pconn->id == conn_id) {
2564 continue;
2565 }
2566 if (model_get_conn_iter(model, &child, &parent,
2567 pprev_child, pconn)) {
2568 gtk_tree_store_move_after(store, &child, pprev_child);
2569 } else {
2571 }
2572
2573 gtk_tree_store_set(store, &child,
2575 CL_COL_USER_NAME, pconn->username,
2576 CL_COL_TEAM, _("Observer"),
2577 CL_COL_CONN_ID, pconn->id,
2580 -1);
2581
2582 prev_child = child;
2585
2586 /* Expand node? */
2587 if (NULL != pprev_child) {
2589 if (!collapsed) {
2590 path = gtk_tree_model_get_path(model, &parent);
2592 path, FALSE);
2593 gtk_tree_path_free(path);
2594 }
2595 }
2596
2597 /* Remove trailing rows. */
2598 if (NULL != pprev_child) {
2599 child = prev_child;
2600 if (gtk_tree_model_iter_next(model, &child)) {
2601 while (gtk_tree_store_remove(store, &child)) {
2602 /* Do nothing more. */
2603 }
2604 }
2605 } else if (gtk_tree_model_iter_children(model, &child, &parent)) {
2606 while (gtk_tree_store_remove(store, &child)) {
2607 /* Do nothing more. */
2608 }
2609 }
2610
2613 if (flag) {
2614 g_object_unref(flag);
2615 }
2616 if (color) {
2618 }
2619 }
2621
2622 /* Finally, insert global observers... */
2624 if (NULL != pconn->playing || !pconn->observer) {
2625 continue;
2626 }
2627
2630 } else {
2632 }
2633
2634 gtk_tree_store_set(store, &parent,
2636 CL_COL_USER_NAME, pconn->username,
2637 CL_COL_TEAM, _("Observer"),
2638 CL_COL_CONN_ID, pconn->id,
2641 -1);
2642
2646
2647 /* ...and detached connections. */
2649 if (NULL != pconn->playing || pconn->observer) {
2650 continue;
2651 }
2652
2655 } else {
2657 }
2658
2659 gtk_tree_store_set(store, &parent,
2661 CL_COL_USER_NAME, pconn->username,
2662 CL_COL_TEAM, _("Detached"),
2663 CL_COL_CONN_ID, pconn->id,
2666 -1);
2667
2671
2672 /* Remove trailing rows. */
2673 if (NULL != pprev_parent) {
2675 if (gtk_tree_model_iter_next(model, &parent)) {
2676 while (gtk_tree_store_remove(store, &parent)) {
2677 /* Do nothing more. */
2678 }
2679 }
2680 } else {
2681 gtk_tree_store_clear(store);
2682 }
2683
2684 /* If we were selecting a single connection, let's try to reselect it. */
2687 }
2688 }
2689
2691}
2692
2693/**********************************************************************/
2699 const char *title, int colnum, const char *key)
2700{
2703
2704 if (gtype == G_TYPE_BOOLEAN) {
2707 "active", colnum, NULL);
2708 } else if (gtype == GDK_TYPE_PIXBUF) {
2711 "pixbuf", colnum, NULL);
2712 } else {
2715 "text", colnum,
2716 "style", CL_COL_STYLE,
2717 "weight", CL_COL_WEIGHT,
2718 NULL);
2719 }
2720
2723
2724 if (key != NULL) {
2726 }
2727}
2728
2729/**********************************************************************/
2733{
2734 GtkWidget *box, *sbox, *table, *vgrid;
2735 GtkWidget *view, *sw, *text, *toolkit_view, *button, *spin;
2736 GtkWidget *label;
2737 GtkTreeSelection *selection;
2738 enum ai_level level;
2739 /* There's less than AI_LEVEL_COUNT entries as not all levels have
2740 entries (that's the whole point of this array: index != value),
2741 but this is set safely to the max */
2742 static enum ai_level levels[AI_LEVEL_COUNT];
2743 int i = 0;
2744 int box_row = 0;
2745 int sbox_col = 0;
2746 int grid_row = 0;
2749
2750 box = gtk_grid_new();
2758
2759 sbox = gtk_grid_new();
2761 gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1);
2762
2763 vgrid = gtk_grid_new();
2774
2775 table = gtk_grid_new();
2780
2786 if (server_optset != NULL) {
2788 if (paifill) {
2791 } /* else it'll be updated later */
2792 }
2793 g_signal_connect_after(spin, "value_changed",
2795
2796 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
2797
2799 "use-underline", TRUE,
2800 "mnemonic-widget", spin,
2801 /* TRANS: Keep individual lines short */
2802 "label", _("Number of _Players\n(including AI):"),
2803 "xalign", 0.0,
2804 "yalign", 0.5,
2805 NULL);
2806 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
2807
2809
2810 for (level = 0; level < AI_LEVEL_COUNT; level++) {
2813
2815 levels[i] = level;
2816 i++;
2817 }
2818 }
2821 G_CALLBACK(ai_skill_callback), levels);
2822
2824
2826 "use-underline", TRUE,
2827 "mnemonic-widget", ai_lvl_combobox,
2828 "label", _("AI Skill _Level:"),
2829 "xalign", 0.0,
2830 "yalign", 0.5,
2831 NULL);
2832 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
2833
2837
2839
2841 "use-underline", TRUE,
2842 "mnemonic-widget", GTK_COMBO_BOX_TEXT(ruleset_combo),
2843 "label", _("Ruleset:"),
2844 "xalign", 0.0,
2845 "yalign", 0.5,
2846 NULL);
2847 gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
2848
2849 button = icon_label_button_new("preferences-system",
2850 _("_More Game Options..."));
2852 gtk_widget_set_margin_end(button, 8);
2853 gtk_widget_set_margin_start(button, 8);
2854 gtk_widget_set_margin_top(button, 8);
2857 g_signal_connect(button, "clicked",
2859 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
2860
2867
2870 g_signal_connect(selection, "changed",
2872
2873 add_tree_col(view, G_TYPE_STRING, _("Name"),
2875 add_tree_col(view, G_TYPE_BOOLEAN, _("Ready"),
2877 add_tree_col(view, G_TYPE_STRING, Q_("?player:Leader"),
2880 CL_COL_FLAG, NULL);
2881 add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
2883 add_tree_col(view, G_TYPE_STRING, _("Nation"),
2885 add_tree_col(view, G_TYPE_STRING, _("Team"),
2886 CL_COL_TEAM, NULL);
2887
2889 g_signal_connect(controller, "pressed",
2892
2893 g_signal_connect(view, "row-collapsed",
2896 g_signal_connect(view, "row-expanded",
2899
2907
2908 /* This is for a workaround against gtk bug that we can't parent
2909 * popup to the tree view - we have to parent it all the way to sw */
2913 g_signal_connect(controller, "pressed",
2916
2917 gtk_grid_attach(GTK_GRID(sbox), sw, sbox_col++, 0, 1, 1);
2918
2924 gtk_grid_attach(GTK_GRID(box), sw, 0, box_row++, 1, 1);
2925
2929 start_message_area = text;
2930 gtk_widget_set_name(text, "chatline");
2935
2936
2937 /* Vote widgets. */
2938 if (pregame_votebar == NULL) {
2940 }
2942
2944 gtk_grid_attach(GTK_GRID(box), toolkit_view, 0, box_row++, 1, 1);
2945
2946 button = gtk_button_new_with_mnemonic(_("_Cancel"));
2948 g_signal_connect(button, "clicked", G_CALLBACK(main_callback), NULL);
2949
2950 nation_button = icon_label_button_new("document-properties",
2951 _("Pick _Nation"));
2955
2956 observe_button = icon_label_button_new("zoom-in", _("_Observe"));
2960
2961 ready_button = icon_label_button_new("system-run", _("_Ready"));
2963 g_signal_connect(ready_button, "clicked",
2965
2966 return box;
2967}
2968
2969
2970/**********************************************************************/
2973void handle_game_load(bool load_successful, const char *filename)
2974{
2975 if (load_successful) {
2977
2978 if (game.info.is_new_game) {
2979 /* It's pregame. Create a player and connect to it */
2980 send_chat("/take -");
2981 }
2982 }
2983}
2984
2985/**********************************************************************/
2988static void load_filename(const char *filename)
2989{
2990 send_chat_printf("/load %s", filename);
2991}
2992
2993/**********************************************************************/
2996static void load_callback(void)
2997{
2998 GtkTreeIter it;
2999 const gchar *filename;
3000
3002 return;
3003 }
3004
3006 SD_COL_FULL_PATH, &filename, -1);
3007 load_filename(filename);
3008}
3009
3010/**********************************************************************/
3014{
3015 save_dialog_file_chooser_popup(_("Choose Saved Game to Load"),
3018}
3019
3020/**********************************************************************/
3023static void update_load_page(void)
3024{
3025 /* Search for user saved games. */
3027 ".sav", FALSE);
3028
3030 fileinfo_list_destroy(files);
3031}
3032
3033/**********************************************************************/
3037{
3038 GtkWidget *box, *sbox, *bbox;
3039
3040 GtkWidget *button, *label, *view, *sw;
3042 int box_row = 0;
3043 int sbox_row = 0;
3044
3045 box = gtk_grid_new();
3053
3058
3061 -1, NULL, rend, "text", 0, NULL);
3062
3065
3067
3068 g_signal_connect(view, "row-activated",
3070
3071 sbox = gtk_grid_new();
3076 gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1);
3077
3079 "use-underline", TRUE,
3080 "mnemonic-widget", view,
3081 "label", _("Choose Saved Game to _Load:"),
3082 "xalign", 0.0,
3083 "yalign", 0.5,
3084 NULL);
3085 gtk_grid_attach(GTK_GRID(sbox), label, 0, sbox_row++, 1, 1);
3086
3093 gtk_grid_attach(GTK_GRID(sbox), sw, 0, sbox_row++, 1, 1);
3094
3098 gtk_grid_attach(GTK_GRID(box), bbox, 0, box_row++, 1, 1);
3099
3100 button = gtk_button_new_with_mnemonic(_("_Browse..."));
3101 gtk_box_append(GTK_BOX(bbox), button);
3102 g_signal_connect(button, "clicked",
3104
3105 button = gtk_button_new_with_mnemonic(_("_Cancel"));
3106 gtk_box_append(GTK_BOX(bbox), button);
3107 g_signal_connect(button, "clicked",
3109
3110 button = gtk_button_new_with_mnemonic(_("_OK"));
3111 gtk_box_append(GTK_BOX(bbox), button);
3112 g_signal_connect(button, "clicked",
3114
3115 return box;
3116}
3117
3118/**********************************************************************/
3121static void scenario_list_callback(void)
3122{
3123 GtkTreeIter it;
3124 GtkTextBuffer *buffer;
3125 char *description;
3126 char *authors;
3127 char *filename;
3128 int ver;
3129 char vername[50];
3130
3133 2, &description, -1);
3135 3, &authors, -1);
3137 1, &filename, -1);
3139 4, &ver, -1);
3140 filename = skip_to_basename(filename);
3141 if (ver > 0) {
3142 int maj;
3143 int min;
3144
3145 maj = ver / 1000000;
3146 ver %= 1000000;
3147 min = ver / 10000;
3148 ver %= 10000;
3149 if (ver >= 9000) {
3150 /* Development version, have '+' */
3151 fc_snprintf(vername, sizeof(vername), "%d.%d+", maj, min);
3152 } else {
3153 fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min);
3154 }
3155 } else {
3156 /* TRANS: Old scenario format version */
3157 fc_snprintf(vername, sizeof(vername), _("pre-2.6"));
3158 }
3159 } else {
3160 description = "";
3161 authors = "";
3162 filename = "";
3163 vername[0] = '\0';
3164 }
3165
3167 gtk_text_buffer_set_text(buffer, description, -1);
3169 gtk_text_buffer_set_text(buffer, authors, -1);
3172}
3173
3174/**********************************************************************/
3177static void scenario_callback(void)
3178{
3179 GtkTreeIter it;
3180 char *filename;
3181
3183 return;
3184 }
3185
3186 gtk_tree_model_get(GTK_TREE_MODEL(scenario_store), &it, 1, &filename, -1);
3187 load_filename(filename);
3188}
3189
3190/**********************************************************************/
3194{
3195 save_dialog_file_chooser_popup(_("Choose a Scenario"),
3198}
3199
3200/**********************************************************************/
3203static void update_scenario_page(void)
3204{
3205 struct fileinfo_list *files;
3206
3208
3209 /* search for scenario files. */
3210 files = fileinfolist_infix(get_scenario_dirs(), ".sav", TRUE);
3212 struct section_file *sf;
3213
3214 if ((sf = secfile_load_section(pfile->fullname, "scenario", TRUE))
3215 && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) {
3216 const char *sname, *sdescription, *sauthors;
3217 int fcver;
3218 int fcdev;
3219 int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000;
3220 int current_dev;
3221
3223 if (PATCH_VERSION >= 90) {
3224 /* Patch level matters on development versions */
3225 current_dev += PATCH_VERSION * 100;
3226 }
3227
3228 fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version");
3229 if (fcver < 30000) {
3230 /* Pre-3.0 versions stored version number without emergency version
3231 * part in the end. To get comparable version number stored,
3232 * multiply by 100. */
3233 fcver *= 100;
3234 }
3235 if (fcver % 10000 >= 9000) {
3236 fcdev = fcver - (fcver % 100); /* Emergency version does not count. */
3237 } else {
3238 fcdev = fcver - (fcver % 10000); /* Patch version does not count. */
3239 }
3240 sname = secfile_lookup_str_default(sf, NULL, "scenario.name");
3242 "scenario.description");
3243 sauthors = secfile_lookup_str_default(sf, NULL, "scenario.authors");
3244 log_debug("scenario file: %s from %s", sname, pfile->fullname);
3245
3246 /* Ignore scenarios for newer freeciv versions than we are. */
3247 if (fcdev <= current_dev) {
3248 bool add_new = TRUE;
3249
3250 if (sname != NULL) {
3251 GtkTreeIter it;
3252 bool valid;
3253
3255 while (valid) {
3256 char *oname;
3257
3259 0, &oname, -1);
3260
3261 if (!strcmp(sname, oname)) {
3262 /* Already listed scenario has the same name as the one we just found */
3263 int existing;
3264
3266 4, &existing, -1);
3267 log_debug("Duplicate %s (%d vs %d)", sname, existing, fcver);
3268
3269 if (existing > fcver) {
3270 /* Already listed one has higher version number */
3271 add_new = FALSE;
3272 } else if (existing < fcver) {
3273 /* New one has higher version number */
3274 add_new = FALSE;
3275
3277 0, sname && strlen(sname) ? Q_(sname) : pfile->name,
3278 1, pfile->fullname,
3279 2, (NULL != sdescription && '\0' != sdescription[0]
3280 ? Q_(sdescription) : ""),
3281 3, (NULL != sauthors && sauthors[0] != '\0'
3282 ? Q_(sauthors) : ""),
3283 4, fcver,
3284 -1);
3285 } else {
3286 /* Same version number -> list both */
3287 }
3288 }
3290 }
3291 }
3292
3293 if (add_new) {
3294 GtkTreeIter it;
3295
3298 0, sname && strlen(sname) ? Q_(sname) : pfile->name,
3299 1, pfile->fullname,
3300 2, (NULL != sdescription && '\0' != sdescription[0]
3301 ? Q_(sdescription) : ""),
3302 3, (NULL != sauthors && sauthors[0] != '\0'
3303 ? Q_(sauthors) : ""),
3304 4, fcver,
3305 -1);
3306 }
3307 }
3308
3309 secfile_destroy(sf);
3310 }
3312
3313 fileinfo_list_destroy(files);
3314}
3315
3316/**********************************************************************/
3320{
3323 GtkWidget *button, *label, *view, *sw, *swa, *text;
3325 int grid_row = 0;
3326 int filenamecol = 0;
3327 int vercol = 0;
3328 int descrow = 0;
3329
3330 vgrid = gtk_grid_new();
3338
3343 G_TYPE_INT);
3348
3351 -1, NULL, rend, "text", 0, NULL);
3352
3357
3359
3360 g_signal_connect(view, "row-activated",
3362
3364 "use-underline", TRUE,
3365 "mnemonic-widget", view,
3366 "label", _("Choose a _Scenario:"),
3367 "xalign", 0.0,
3368 "yalign", 0.5,
3369 NULL);
3370 gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1);
3371
3372 sbox = gtk_grid_new();
3379
3380 hbox = gtk_grid_new();
3383
3389 gtk_grid_attach(GTK_GRID(sbox), sw, 0, 0, 1, 2);
3390
3391 text = gtk_text_view_new();
3397 scenario_description = text;
3398
3404
3405 text = gtk_text_view_new();
3411 scenario_authors = text;
3412
3418
3419 text = gtk_label_new(_("Filename:"));
3424
3431
3432 gtk_grid_attach(GTK_GRID(filenamebox), text, filenamecol++, 0, 1, 1);
3434 filenamecol++, 0, 1, 1);
3435
3436 /* TRANS: Scenario format version */
3437 vertext = gtk_label_new(_("Format:"));
3442
3449
3452 vercol++, 0, 1, 1);
3453
3458 gtk_grid_attach(GTK_GRID(descbox), sw, 0, descrow++, 1, 1);
3461 0, descrow++, 1, 1);
3463 0, descrow++, 1, 1);
3464 gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 2);
3465
3469
3470 button = gtk_button_new_with_mnemonic(_("_Browse..."));
3471 gtk_box_append(GTK_BOX(bbox), button);
3472 g_signal_connect(button, "clicked",
3474
3475 button = gtk_button_new_with_mnemonic(_("_Cancel"));
3476 gtk_box_append(GTK_BOX(bbox), button);
3477 g_signal_connect(button, "clicked",
3479
3480 button = gtk_button_new_with_mnemonic(_("_OK"));
3481 gtk_box_append(GTK_BOX(bbox), button);
3482 g_signal_connect(button, "clicked",
3484
3485 return vgrid;
3486}
3487
3488/**********************************************************************/
3492{
3493 return current_page;
3494}
3495
3496/**********************************************************************/
3500{
3501 /* Don't use current_page directly here because maybe it could be modified
3502 * before we reach the end of this function. */
3504
3505 /* If the page remains the same, don't do anything. */
3506 if (old_page == new_page) {
3507 return;
3508 }
3509
3510 log_debug("Switching client page from %s to %s.",
3511 -1 == old_page ? "(no page)" : client_pages_name(old_page),
3513
3515
3516 switch (old_page) {
3517 case PAGE_SCENARIO:
3518 case PAGE_LOAD:
3519 break;
3520 case PAGE_GAME:
3521 {
3523
3525 if (vmode == NULL) {
3527 }
3528 }
3529 break;
3530 default:
3531 break;
3532 }
3533
3534 switch (new_page) {
3535 case PAGE_MAIN:
3536 case PAGE_START:
3537 if (is_server_running()) {
3540 } else {
3542 }
3546 break;
3547 case PAGE_GAME:
3548 {
3550
3553 if (vmode == NULL) {
3555 }
3558 }
3559 break;
3560 case PAGE_LOAD:
3562 break;
3563 case PAGE_SCENARIO:
3565 break;
3566 case PAGE_NETWORK:
3568 break;
3569 }
3570
3571 /* Hide/show statusbar. */
3572 if (new_page == PAGE_START || new_page == PAGE_GAME) {
3575 } else {
3577 }
3578
3580
3581 /* Update the GUI. */
3582 while (g_main_context_pending(NULL)) {
3584 }
3585
3586 switch (new_page) {
3587 case PAGE_MAIN:
3588 break;
3589 case PAGE_START:
3592 break;
3593 case PAGE_LOAD:
3595 break;
3596 case PAGE_SCENARIO:
3598 break;
3599 case PAGE_GAME:
3603 mapview_thaw();
3606 break;
3607 case PAGE_NETWORK:
3612 break;
3613 }
3614}
3615
3616/****************************************************************************
3617 SAVE GAME DIALOGs
3618****************************************************************************/
3619
3620/**********************************************************************/
3624{
3625 return fileinfolist_infix(get_save_dirs(), ".sav", FALSE);
3626}
3627
3628/**********************************************************************/
3632{
3633 static GtkWidget *shell = NULL;
3634
3635 if (NULL != shell) {
3636 return;
3637 }
3638
3639 shell = save_dialog_new(_("Save Game"), _("Saved _Games:"),
3640 _("Save _Filename:"), send_save_game,
3643 &shell);
3645}
3646
3647/**********************************************************************/
3650static void save_dialog_save_scenario(const char *filename)
3651{
3653}
3654
3655/**********************************************************************/
3659{
3660 return fileinfolist_infix(get_scenario_dirs(), ".sav", FALSE);
3661}
3662
3663/**********************************************************************/
3667{
3668 static GtkWidget *shell = NULL;
3669
3670 if (NULL != shell) {
3671 return;
3672 }
3673
3674 shell = save_dialog_new(_("Save Scenario"), _("Saved Sce_narios:"),
3675 _("Save Sc_enario:"), save_dialog_save_scenario,
3678 &shell);
3680}
3681
3682/**********************************************************************/
3688{
3689 return fileinfolist_infix(get_save_dirs(), ".map", FALSE);
3690}
3691
3692/**********************************************************************/
3696{
3697 static GtkWidget *shell = NULL;
3698
3699 if (NULL != shell) {
3700 return;
3701 }
3702
3703 shell = save_dialog_new(_("Save Map Image"), _("Saved Map _Images:"),
3704 _("Save _Map Images:"), mapimg_client_save,
3707 &shell);
3709}
3710
3711/**********************************************************************/
3714void mapimg_client_save(const char *filename)
3715{
3716 if (!mapimg_client_createmap(filename)) {
3717 char msg[512];
3718
3719 fc_snprintf(msg, sizeof(msg), "(%s)", mapimg_error());
3720 popup_notify_dialog(_("Error"),
3721 _("Error Creating the Map Image!"), msg);
3722 }
3723}
3724
3725/**********************************************************************/
3730void set_rulesets(int num_rulesets, char **rulesets)
3731{
3732 int i;
3733 int def_idx = -1;
3734
3736 for (i = 0; i < num_rulesets; i++) {
3737
3739 if (!strcmp("default", rulesets[i])) {
3740 def_idx = i;
3741 }
3742 }
3743
3745
3746 /* HACK: server should tell us the current ruleset. */
3748
3750}
#define n
Definition astring.c:77
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
#define SERVER_COMMAND_PREFIX_STR
Definition chat.h:29
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)
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
enum client_states client_state(void)
char fc_password[MAX_LEN_PASSWORD]
int server_port
#define client_player()
@ C_S_PREPARING
Definition client_main.h:46
enum ai_level server_ai_level(void)
Definition climisc.c:1518
bool mapimg_client_createmap(const char *filename)
Definition climisc.c:1465
void center_on_something(void)
Definition climisc.c:430
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
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
char * incite_cost
Definition comments.c:75
authentication_type
Definition conn_types.h:41
@ AUTH_NEWUSER_RETRY
Definition conn_types.h:45
@ AUTH_NEWUSER_FIRST
Definition conn_types.h:43
@ AUTH_LOGIN_RETRY
Definition conn_types.h:44
@ AUTH_LOGIN_FIRST
Definition conn_types.h:42
void send_save_game(const char *filename)
void set_ruleset(const char *ruleset)
bool is_server_running(void)
bool client_start_server(void)
bool can_client_access_hack(void)
const char * conn_description(const struct connection *pconn)
Definition connection.c:474
struct connection * conn_by_number(int id)
Definition connection.c:421
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
popup_notify_dialog
Definition dialogs_g.h:37
int int id
Definition editgui_g.h:28
#define MAX_NUM_PLAYERS
Definition fc_types.h:36
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
void fc_mutex_allocate(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
static PangoLayout * layout
Definition canvas.c:325
void inputline_toolkit_view_append_button(GtkWidget *toolkit_view, GtkWidget *button)
Definition chatline.c:1292
GtkWidget * inputline_toolkit_view_new(void)
Definition chatline.c:1270
void inputline_grab_focus(void)
Definition chatline.c:79
void chatline_scroll_to_bottom(bool delayed)
Definition chatline.c:1006
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
static struct tile * pos
Definition finddlg.c:53
const char * client_string
Definition gui_main.c:105
GtkTextBuffer * message_buffer
Definition gui_main.c:178
struct video_mode * resolution_request_get(void)
Definition gui_main.c:2611
void enable_menus(bool enable)
Definition gui_main.c:1052
void refresh_chat_buttons(void)
Definition gui_main.c:2509
void add_idle_callback(void(callback)(void *), void *data)
Definition gui_main.c:2405
void reset_unit_table(void)
Definition gui_main.c:1023
GtkWidget * toplevel
Definition gui_main.c:125
void quit_gtk_main(void)
Definition gui_main.c:2337
static struct video_mode vmode
Definition gui_main.c:191
GtkWidget * toplevel_tabs
Definition gui_main.c:127
int screen_height(void)
Definition gui_main.c:2593
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
void gtk_stockbutton_set_label(GtkWidget *button, const gchar *label_text)
Definition gui_stuff.c:96
GtkWidget * icon_label_button_new(const gchar *icon_name, const gchar *label_text)
Definition gui_stuff.c:76
GtkTreeViewColumn * add_treeview_column(GtkWidget *view, const char *title, GType gtype, int model_index)
Definition gui_stuff.c:1123
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void mapview_freeze(void)
Definition mapview.c:373
void overview_size_changed(void)
Definition mapview.c:326
void mapview_thaw(void)
Definition mapview.c:381
static struct gui_dialog * shell
Definition messagedlg.c:39
void option_dialog_popup(const char *name, const struct option_set *poptset)
Definition optiondlg.c:972
static GtkListStore * load_store
Definition pages.c:68
static void update_network_page(void)
Definition pages.c:1185
void handle_game_load(bool load_successful, const char *filename)
Definition pages.c:2841
GtkWidget * create_start_page(void)
Definition pages.c:2623
GtkWidget * create_network_page(void)
Definition pages.c:1201
static void client_aitoggle_player(void *data)
Definition pages.c:1509
static GtkWidget * nation_button
Definition pages.c:1460
static void update_server_list(enum server_scan_type sstype, const struct server_list *list)
Definition pages.c:704
static void start_scenario_callback(GtkWidget *w, gpointer data)
Definition pages.c:115
static GtkTreeSelection * scenario_selection
Definition pages.c:73
static void update_start_page_buttons(void)
Definition pages.c:2199
static void save_dialog_response_callback(GtkWidget *w, gint response, gpointer data)
Definition pages.c:489
GtkWidget * create_scenario_page(void)
Definition pages.c:3185
static void show_conn_popup(struct player *pplayer, struct connection *pconn)
Definition pages.c:1767
static GtkWidget * network_confirm_password_label
Definition pages.c:699
void save_mapimg_dialog_popup(void)
Definition pages.c:3551
static void ruleset_selected(const char *name)
Definition pages.c:1615
static void ready_button_callback(GtkWidget *w, gpointer data)
Definition pages.c:2145
static bool conn_list_selection(struct player **ppplayer, struct connection **ppconn)
Definition pages.c:2058
static struct server_scan_timer_data meta_scan
Definition pages.c:86
static void update_network_lists(void)
Definition pages.c:838
static GtkWidget * statusbar
Definition pages.c:89
static GtkWidget * server_playerlist_view
Definition pages.c:71
static GtkListStore * save_dialog_store_new(void)
Definition pages.c:399
void append_network_statusbar(const char *text, bool force)
Definition pages.c:894
static gboolean update_network_statusbar(gpointer data)
Definition pages.c:864
void set_rulesets(int num_rulesets, char **rulesets)
Definition pages.c:3586
void mapimg_client_save(const char *filename)
Definition pages.c:3570
static void conn_menu_player_command(GObject *object, gpointer data)
Definition pages.c:1726
static void load_filename(const char *filename)
Definition pages.c:2856
static void conn_menu_nation_chosen(GObject *object, gpointer data)
Definition pages.c:1713
static GtkWidget * scenario_description
Definition pages.c:63
void save_game_dialog_popup(void)
Definition pages.c:3487
enum client_pages get_current_client_page(void)
Definition pages.c:3345
static GtkListStore * lan_store
Definition pages.c:68
static enum connection_state connection_status
Definition pages.c:859
save_dialog_columns
Definition pages.c:383
@ SD_COL_NUM
Definition pages.c:387
@ SD_COL_FULL_PATH
Definition pages.c:385
@ SD_COL_PRETTY_NAME
Definition pages.c:384
static struct server_scan_timer_data lan_scan
Definition pages.c:87
static void save_dialog_list_callback(GtkTreeSelection *selection, gpointer data)
Definition pages.c:557
static void connect_network_game_callback(GtkWidget *w, gpointer data)
Definition pages.c:132
static GtkTreeView * connection_list_view
Definition pages.c:1462
static GtkWidget * network_login
Definition pages.c:695
static GtkWidget * network_login_label
Definition pages.c:695
connection_state
Definition pages.c:852
@ LOGIN_TYPE
Definition pages.c:853
@ NEW_PASSWORD_TYPE
Definition pages.c:854
@ WAITING_TYPE
Definition pages.c:856
@ ENTER_PASSWORD_TYPE
Definition pages.c:855
static void connect_callback(GtkWidget *w, gpointer data)
Definition pages.c:1043
static void scenario_browse_callback(GtkWidget *w, gpointer data)
Definition pages.c:3059
static GtkListStore * meta_store
Definition pages.c:68
connection_list_columns
Definition pages.c:1468
@ CL_COL_STYLE
Definition pages.c:1478
@ CL_COL_USER_NAME
Definition pages.c:1470
@ CL_COL_READY_STATE
Definition pages.c:1471
@ CL_COL_WEIGHT
Definition pages.c:1479
@ CL_COL_PLAYER_NAME
Definition pages.c:1472
@ CL_COL_NATION
Definition pages.c:1475
@ CL_COL_CONN_ID
Definition pages.c:1477
@ CL_COL_PLAYER_NUMBER
Definition pages.c:1469
@ CL_NUM_COLUMNS
Definition pages.c:1482
@ CL_COL_TEAM
Definition pages.c:1476
@ CL_COL_COLOR
Definition pages.c:1474
@ CL_COL_COLLAPSED
Definition pages.c:1480
@ CL_COL_FLAG
Definition pages.c:1473
static void update_load_page(void)
Definition pages.c:2891
static void save_dialog_update(struct save_dialog *pdialog)
Definition pages.c:427
static GtkWidget * scenario_authors
Definition pages.c:64
static GtkWidget * start_aifill_spin
Definition pages.c:1463
static void ruleset_entry_changed(GtkWidget *w, gpointer data)
Definition pages.c:1627
void(* save_dialog_action_fn_t)(const char *filename)
Definition pages.c:372
static void open_settings(void)
Definition pages.c:141
static void set_connection_state(enum connection_state state)
Definition pages.c:930
static GtkWidget * ruleset_combo
Definition pages.c:93
static void observe_button_callback(GtkWidget *w, gpointer data)
Definition pages.c:2179
static void conn_menu_ready_chosen(GObject *object, gpointer data)
Definition pages.c:1700
static void server_scan_error(struct server_scan *scan, const char *message)
Definition pages.c:825
static void load_callback(void)
Definition pages.c:2864
static void save_dialog_file_chooser_callback(GtkWidget *widget, gint response, gpointer data)
Definition pages.c:444
static void network_list_callback(GtkTreeSelection *select, gpointer data)
Definition pages.c:1139
static GtkListStore * server_playerlist_store
Definition pages.c:70
static void nation_button_callback(GtkWidget *w, gpointer data)
Definition pages.c:2159
void real_set_client_page(enum client_pages new_page)
Definition pages.c:3353
static void conn_menu_connection_command(GObject *object, gpointer data)
Definition pages.c:1753
static void scenario_list_callback(void)
Definition pages.c:2987
static gboolean intro_expose(GtkWidget *w, cairo_t *cr, gpointer *data)
Definition pages.c:164
static void load_browse_callback(GtkWidget *w, gpointer data)
Definition pages.c:2881
static void network_activate_callback(GtkTreeView *view, GtkTreePath *arg1, GtkTreeViewColumn *arg2, gpointer data)
Definition pages.c:1098
static struct fileinfo_list * save_dialog_scenario_list(void)
Definition pages.c:3514
static void connection_state_reset(void)
Definition pages.c:998
void real_conn_list_dialog_update(void *unused)
Definition pages.c:2344
static bool holding_srv_list_mutex
Definition pages.c:95
static GtkTreeStore * connection_list_store
Definition pages.c:1461
static struct fileinfo_list * save_dialog_savegame_list(void)
Definition pages.c:3479
static void start_new_game_callback(GtkWidget *w, gpointer data)
Definition pages.c:102
void destroy_server_scans(void)
Definition pages.c:768
void save_scenario_dialog_popup(void)
Definition pages.c:3522
static GtkTreeSelection * lan_selection
Definition pages.c:74
static void save_dialog_save_scenario(const char *filename)
Definition pages.c:3506
struct fileinfo_list *(* save_dialog_files_fn_t)(void)
Definition pages.c:373
static gboolean check_server_scan(gpointer data)
Definition pages.c:791
static void save_dialog_store_update(GtkListStore *store, const struct fileinfo_list *files)
Definition pages.c:409
static void ai_fill_changed_by_user(GtkWidget *w, gpointer data)
Definition pages.c:1642
static gboolean delayed_unselect_path(gpointer data)
Definition pages.c:1973
static void conn_menu_player_take(GObject *object, gpointer data)
Definition pages.c:1740
static void conn_menu_info_chosen(GObject *object, gpointer data)
Definition pages.c:1798
static bool model_get_player_iter(GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *start, const struct player *pplayer)
Definition pages.c:2284
static GtkTreeSelection * load_selection
Definition pages.c:73
static void ai_skill_callback(GtkWidget *w, gpointer data)
Definition pages.c:1589
static enum client_pages current_page
Definition pages.c:78
static GtkWidget * statusbar_frame
Definition pages.c:89
static GtkWidget * network_confirm_password
Definition pages.c:699
static void client_take_player(struct player *pplayer)
Definition pages.c:1523
static void clear_network_statusbar(void)
Definition pages.c:880
static GtkTreeSelection * meta_selection
Definition pages.c:74
static void save_dialog_row_callback(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
Definition pages.c:538
static void connection_list_row_callback(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
Definition pages.c:2043
save_dialog_response
Definition pages.c:390
@ SD_RES_DELETE
Definition pages.c:392
@ SD_RES_SAVE
Definition pages.c:393
@ SD_RES_BROWSE
Definition pages.c:391
GtkWidget * create_load_page(void)
Definition pages.c:2904
static GtkWidget * ai_lvl_combobox
Definition pages.c:1464
static GtkWidget * network_password_label
Definition pages.c:698
static GtkWidget * save_dialog_new(const char *title, const char *savelabel, const char *savefilelabel, save_dialog_action_fn_t action, save_dialog_files_fn_t files)
Definition pages.c:578
static void intro_free(GtkWidget *w, gpointer *data)
Definition pages.c:221
static GtkWidget * network_password
Definition pages.c:698
static GtkWidget * network_host
Definition pages.c:696
void handle_authentication_req(enum authentication_type type, const char *message)
Definition pages.c:1007
static GtkTreeStore * connection_list_store_new(void)
Definition pages.c:1488
static bool send_new_aifill_to_server
Definition pages.c:1641
static void save_dialog_file_chooser_popup(const char *title, GtkFileChooserAction action, save_dialog_action_fn_t cb)
Definition pages.c:464
static GtkWidget * network_port
Definition pages.c:697
static void add_tree_col(GtkWidget *treeview, GType gtype, const char *title, int colnum, const char *key)
Definition pages.c:2589
static void save_dialog_entry_callback(GtkEntry *entry, gpointer data)
Definition pages.c:549
static void main_callback(GtkWidget *w, gpointer data)
Definition pages.c:149
void update_start_page(void)
Definition pages.c:1675
static void scenario_callback(void)
Definition pages.c:3043
static GtkWidget * start_options_table
Definition pages.c:1459
static bool no_ruleset_callback
Definition pages.c:1610
void ai_fill_changed_by_server(int aifill)
Definition pages.c:1653
static void update_server_playerlist(const struct server *pserver)
Definition pages.c:1110
static GtkWidget * observe_button
Definition pages.c:1460
static GtkWidget * scenario_version
Definition pages.c:66
GtkWidget * create_statusbar(void)
Definition pages.c:909
static void game_options_callback(GtkWidget *w, gpointer data)
Definition pages.c:1581
static GtkListStore * scenario_store
Definition pages.c:68
static GtkWidget * network_host_label
Definition pages.c:696
static bool model_get_conn_iter(GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *parent, GtkTreeIter *start, const struct connection *pconn)
Definition pages.c:2315
static GQueue * statusbar_queue
Definition pages.c:90
GtkWidget * start_message_area
Definition pages.c:1457
static GtkWidget * network_port_label
Definition pages.c:697
static void update_scenario_page(void)
Definition pages.c:3069
static GtkWidget * scenario_filename
Definition pages.c:65
static void conn_menu_team_chosen(GObject *object, gpointer data)
Definition pages.c:1683
static GtkWidget * create_conn_menu(struct player *pplayer, struct connection *pconn)
Definition pages.c:1812
static void load_saved_game_callback(GtkWidget *w, gpointer data)
Definition pages.c:124
static guint statusbar_timer
Definition pages.c:91
static bool object_extract(GObject *object, struct player **ppplayer, struct connection **ppconn)
Definition pages.c:1554
static void object_put(GObject *object, struct player *pplayer, struct connection *pconn)
Definition pages.c:1535
static struct fileinfo_list * save_dialog_mapimg_list(void)
Definition pages.c:3543
GtkWidget * create_main_page(void)
Definition pages.c:231
static void conn_list_select_conn(struct connection *pconn)
Definition pages.c:2094
static GtkWidget * ready_button
Definition pages.c:1460
GdkPixbuf * create_player_icon(const struct player *plr)
Definition plrdlg.c:117
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
const char * title
Definition repodlgs.c:1314
GType type
Definition repodlgs.c:1313
void free_sprite(struct sprite *s)
Definition sprite.c:278
struct sprite * sprite_scale(struct sprite *src, int new_w, int new_h)
Definition sprite.c:291
struct sprite * load_gfxfile(const char *filename, bool svgflag)
Definition sprite.c:170
void voteinfo_gui_update(void)
GtkWidget * voteinfo_bar_new(bool split_bar)
GtkWidget * pregame_votebar
gboolean terminate_signal_processing(GtkEventControllerFocus *controller, gpointer data)
Definition gui_main.c:1042
void animation_idle_cb(void *data)
Definition gui_main.c:2428
void main_message_area_resize(void *data)
Definition gui_main.c:359
void widget_destroyed(GtkWidget *wdg, void *data)
Definition gui_stuff.c:1154
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
static gboolean connect_list_right_button(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition pages.c:2099
void(* save_dialog_action_fn_t)(const char *filename)
Definition pages.c:381
struct fileinfo_list *(* save_dialog_files_fn_t)(void)
Definition pages.c:382
static void close_conn_menu_popover(void)
Definition pages.c:1710
static gboolean connect_list_left_button(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition pages.c:2070
static GtkWidget * conn_popover
Definition pages.c:97
static struct server_list * server_list
Definition connectdlg.c:61
static enum client_pages old_page
Definition pages.c:46
void conn_list_dialog_update(void)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_debug(message,...)
Definition log.h:115
#define log_error(message,...)
Definition log.h:103
const char * mapimg_error(void)
Definition mapimg.c:759
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
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
#define NO_NATION_SELECTED
Definition nation.h:30
const struct option_set * server_optset
Definition options.c:4016
const struct option_set * client_optset
Definition options.c:1280
int option_int_get(const struct option *poption)
Definition options.c:834
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
bool option_int_set(struct option *poption, int val)
Definition options.c:878
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
int dsend_packet_save_scenario(struct connection *pc, const char *name)
int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
void client_start_server_and_set_page(enum client_pages page)
void set_client_page(enum client_pages page)
enum client_pages get_client_page(void)
bool is_settable_ai_level(enum ai_level level)
Definition player.c:1919
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_slot_count(void)
Definition player.c:418
int player_number(const struct player *pplayer)
Definition player.c:837
const char * player_name(const struct player *pplayer)
Definition player.c:895
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Definition player.c:1990
#define ai_level_cmd(_level_)
Definition player.h:567
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
#define is_ai(plr)
Definition player.h:230
#define players_iterate_alive_end
Definition player.h:547
#define is_human(plr)
Definition player.h:229
#define players_iterate_alive(_pplayer)
Definition player.h:542
void secfile_destroy(struct section_file *secfile)
struct section_file * secfile_load_section(const char *filename, const char *section, bool allow_duplicates)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
struct srv_list * server_scan_get_list(struct server_scan *scan)
Definition servers.c:866
void server_scan_finish(struct server_scan *scan)
Definition servers.c:879
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
Definition servers.c:755
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
Definition servers.c:809
enum server_scan_status server_scan_poll(struct server_scan *scan)
Definition servers.c:832
#define server_list_iterate_end
Definition servers.h:57
server_scan_status
Definition servers.h:79
@ SCAN_STATUS_PARTIAL
Definition servers.h:82
@ SCAN_STATUS_ERROR
Definition servers.h:80
@ SCAN_STATUS_DONE
Definition servers.h:83
#define server_list_iterate(serverlist, pserver)
Definition servers.h:55
server_scan_type
Definition servers.h:67
@ SERVER_SCAN_LOCAL
Definition servers.h:68
@ SERVER_SCAN_GLOBAL
Definition servers.h:69
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
const struct strvec * get_scenario_dirs(void)
Definition shared.c:978
const struct strvec * get_save_dirs(void)
Definition shared.c:941
char * skip_to_basename(char *filepath)
Definition shared.c:1760
struct fileinfo_list * fileinfolist_infix(const struct strvec *dirs, const char *infix, bool nodups)
Definition shared.c:1211
#define fileinfo_list_iterate(list, pnode)
Definition shared.h:176
#define FC_PTR_TO_INT(p)
Definition shared.h:95
#define fileinfo_list_iterate_end
Definition shared.h:178
#define FC_INT_TO_PTR(i)
Definition shared.h:94
size_t size
Definition specvec.h:72
struct sprite int int y
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
const char * aifill(int amount)
Definition srv_main.c:2465
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
enum cmdlevel access_level
Definition connection.h:177
struct team * team
Definition player.h:259
bool is_ready
Definition player.h:260
save_dialog_action_fn_t action
Definition pages.c:379
GtkEntry * entry
Definition pages.c:378
GtkTreeView * tree_view
Definition pages.c:377
GtkDialog * shell
Definition pages.c:376
save_dialog_files_fn_t files
Definition pages.c:380
struct server_scan * scan
Definition pages.c:82
fc_mutex mutex
Definition servers.h:64
struct server_list * servers
Definition servers.h:63
Definition team.c:40
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
int fc_remove(const char *filename)
Definition support.c:557
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define sz_strlcat(dest, src)
Definition support.h:196
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
const char * team_name_translation(const struct team *pteam)
Definition team.c:420
struct team * team_slot_get_team(const struct team_slot *tslot)
Definition team.c:150
const char * team_slot_name_translation(const struct team_slot *tslot)
Definition team.c:253
int team_number(const struct team *pteam)
Definition team.c:391
int team_slot_index(const struct team_slot *tslot)
Definition team.c:138
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
const char * tileset_main_intro_filename(const struct tileset *t)
Definition tilespec.c:947
void update_queue_connect_processing_finished(int request_id, uq_callback_t callback, void *data)
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