Freeciv-3.3
Loading...
Searching...
No Matches
connectdlg.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/***********************************************************************
15 connectdlg.c - description
16 -------------------
17 begin : Mon Jul 1 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26#include <stdlib.h>
27
28/* SDL2 */
29#ifdef SDL2_PLAIN_INCLUDE
30#include <SDL.h>
31#else /* SDL2_PLAIN_INCLUDE */
32#include <SDL2/SDL.h>
33#endif /* SDL2_PLAIN_INCLUDE */
34
35/* utility */
36#include "fcintl.h"
37#include "log.h"
38
39/* client */
40#include "client_main.h"
41#include "clinet.h" /* connect_to_server() */
42#include "packhand.h"
43#include "servers.h"
44#include "update_queue.h"
45
46/* gui-sdl2 */
47#include "chatline.h"
48#include "colors.h"
49#include "graphics.h"
50#include "gui_id.h"
51#include "gui_main.h"
52#include "gui_tilespec.h"
53#include "mapview.h"
54#include "messagewin.h"
55#include "optiondlg.h"
56#include "themespec.h"
57#include "widget.h"
58
59#include "connectdlg.h"
60
61static struct server_list *server_list = NULL;
62static struct server_scan *server_scan = NULL;
63
65static struct small_dialog *connect_dlg = NULL;
66
67static int connect_callback(struct widget *pwidget);
68static int convert_portnr_callback(struct widget *pwidget);
69static int convert_playername_callback(struct widget *pwidget);
70static int convert_servername_callback(struct widget *pwidget);
71static void popup_new_user_passwd_dialog(const char *message);
72
73/*
74 THESE FUNCTIONS ARE ONE BIG TMP SOLUTION AND SHOULD BE FULLY REWRITTEN !!
75*/
76
77/**********************************************************************/
80void handle_game_load(bool load_successful, const char *filename)
81{
82 /* PORTME */
83}
84
85/**********************************************************************/
88static int connect_callback(struct widget *pwidget)
89{
91 char errbuf[512];
92
94 errbuf, sizeof(errbuf)) != -1) {
95 } else {
97
98 /* button up */
100 set_wstate(pwidget, FC_WS_SELECTED);
101 selected_widget = pwidget;
102 widget_redraw(pwidget);
103 widget_flush(pwidget);
104 }
105 }
106
107 return -1;
108}
109/* ======================================================== */
110
111
112/**********************************************************************/
115static int meta_server_window_callback(struct widget *pwindow)
116{
117 return -1;
118}
119
120/**********************************************************************/
123static int exit_meta_server_dlg_callback(struct widget *pwidget)
124{
126 queue_flush();
127
131
134 }
135
136 return -1;
137}
138
139/**********************************************************************/
142static int select_meta_servers_callback(struct widget *pwidget)
143{
145 struct server *server = (struct server *)pwidget->data.ptr;
146
149
151 }
152
153 return -1;
154}
155
156/**********************************************************************/
159static void server_scan_error(struct server_scan *scan,
160 const char *message)
161{
163 log_normal("%s", message);
164
165 switch (server_scan_get_type(scan)) {
170 break;
175 break;
176 case SERVER_SCAN_LAST:
177 break;
178 }
179}
180
181/**********************************************************************/
188{
189 struct srv_list *list = NULL;
190 int i;
191
192 if (lan) {
194 } else {
196 }
197
198 if (!server_scan) {
199 return NULL;
200 }
201
202 SDL_Delay(5000);
203
204 for (i = 0; i < 100; i++) {
207 if (list) {
208 break;
209 }
210 SDL_Delay(100);
211 }
212
213 return list;
214}
215
216/**********************************************************************/
220{
221 SDL_Color bg_color = {255, 255, 255, 128};
222 char cbuf[512];
223 int w = 0, h = 0, count = 0, meta_h;
224 struct widget *new_widget, *pwindow, *label_window;
225 utf8_str *pstr;
228 struct srv_list *srvrs;
229
230 queue_flush();
233
234 /* Text Label */
237
238 area = label_window->area;
239
240 fc_snprintf(cbuf, sizeof(cbuf), _("Creating Server List..."));
242 pstr->style = TTF_STYLE_BOLD;
243 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
247
248 area.w = MAX(area.w, new_widget->size.w + (adj_size(60) -
249 (label_window->size.w - label_window->area.w)));
250 area.h += new_widget->size.h + (adj_size(30) -
251 (label_window->size.w - label_window->area.w));
252
254 (label_window->size.w - label_window->area.w) + area.w,
255 (label_window->size.h - label_window->area.h) + area.h);
256
257 area = label_window->area;
258
260 (main_window_width() - label_window->size.w) / 2,
261 (main_window_height() - label_window->size.h) / 2);
262
265 area.x + (area.w - new_widget->size.w) / 2,
266 area.y + (area.h - new_widget->size.h) / 2);
267
269 flush_dirty();
270
271 /* Create server list */
273
274 /* Copy list */
276 fc_mutex_allocate(&srvrs->mutex);
280 fc_mutex_release(&srvrs->mutex);
281
282 /* Clear label */
284
286
287 if (!server_list) {
288 if (lan_scan) {
289 output_window_append(ftc_client, _("No LAN servers found"));
290 } else {
291 output_window_append(ftc_client, _("No public servers found"));
292 }
294 return;
295 }
296
297 /* Server list window */
298 meta_server = fc_calloc(1, sizeof(struct advanced_dialog));
299
300 pwindow = create_window_skeleton(NULL, NULL, 0);
302 set_wstate(pwindow, FC_WS_NORMAL);
304 if (lan_scan) {
306 } else {
308 }
309 meta_server->end_widget_list = pwindow;
310
311 /* Cancel button */
314 pwindow->dst, _("Cancel"),
315 FONTO_HEADING, 0);
319
320 /* Servers */
322
323 /* TRANS: "host.example.com Port 5556 Ver: 3.1.0 Running Players 3\n
324 * [server message]" */
325 fc_snprintf(cbuf, sizeof(cbuf), _("%s Port %d Ver: %s %s %s %d\n%s"),
327 Q_("?header:Players"), server->nplayers, server->message);
328
332
333 new_widget->string_utf8->style |= SF_CENTER;
334 new_widget->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
335
338 new_widget->data.ptr = (void *)server;
339
341
342 w = MAX(w, new_widget->size.w);
343 h = MAX(h, new_widget->size.h);
344 count++;
345
346 if (count > 10) {
348 }
349
351
352 if (!count) {
353 if (lan_scan) {
354 output_window_append(ftc_client, _("No LAN servers found"));
355 } else {
356 output_window_append(ftc_client, _("No public servers found"));
357 }
359 return;
360 }
361
366
367 if (count > 10) {
368 meta_h = 10 * h;
369
371 w += count;
372 } else {
373 meta_h = count * h;
374 }
375
376 w += adj_size(20);
377 area2.h = meta_h;
378
380
382 if (resize_window(pwindow, logo, NULL, w, meta_h)) {
384 }
385
386 area = pwindow->area;
387
388 widget_set_position(pwindow,
389 (main_window_width() - w) / 2,
390 (main_window_height() - meta_h) / 2);
391
392 w -= adj_size(20);
393
394 area2.w = w + 1;
395
396 if (meta_server->scroll) {
397 w -= count;
398 }
399
400 /* Exit button */
401 new_widget = pwindow->prev;
402 new_widget->size.x = area.x + area.w - new_widget->size.w - adj_size(10);
403 new_widget->size.y = area.y + area.h - new_widget->size.h - adj_size(10);
404
405 /* Meta labels */
406 new_widget = new_widget->prev;
407
408 new_widget->size.x = area.x + adj_size(10);
409 new_widget->size.y = area.y + adj_size(10);
410 new_widget->size.w = w;
411 new_widget->size.h = h;
413
414 new_widget = new_widget->prev;
415
416 while (new_widget != NULL) {
417 new_widget->size.w = w;
418 new_widget->size.h = h;
419 new_widget->size.x = new_widget->next->size.x;
420 new_widget->size.y = new_widget->next->size.y + new_widget->next->size.h;
422
424 break;
425 }
426 new_widget = new_widget->prev;
427 }
428
429 if (meta_server->scroll) {
431 area.x + area.w - adj_size(6),
433 area.h - adj_size(24) - pwindow->prev->size.h, TRUE);
434 }
435
436 /* -------------------- */
437 /* Redraw */
438
439 widget_redraw(pwindow);
440
443
445
446 create_frame(pwindow->dst->surface,
447 area2.x - 1, area2.y - 1, area2.w, area2.h,
449
451
452 create_frame(pwindow->dst->surface,
453 pwindow->size.x, pwindow->size.y,
454 area.w - 1, area.h - 1,
456
457 widget_flush(pwindow);
458}
459
460/**********************************************************************/
463static int convert_playername_callback(struct widget *pwidget)
464{
466 if (pwidget->string_utf8->text != NULL) {
468 } else {
469 /* empty input -> restore previous content */
471 widget_redraw(pwidget);
472 widget_mark_dirty(pwidget);
473 flush_dirty();
474 }
475 }
476
477 return -1;
478}
479
480/**********************************************************************/
483static int convert_servername_callback(struct widget *pwidget)
484{
486 if (pwidget->string_utf8->text != NULL) {
488 } else {
489 /* empty input -> restore previous content */
491 widget_redraw(pwidget);
492 widget_mark_dirty(pwidget);
493 flush_dirty();
494 }
495 }
496
497 return -1;
498}
499
500/**********************************************************************/
503static int convert_portnr_callback(struct widget *pwidget)
504{
506 char port_str[6];
507
508 if (pwidget->string_utf8->text != NULL) {
509 sscanf(pwidget->string_utf8->text, "%d", &server_port);
510 } else {
511 /* empty input -> restore previous content */
512 fc_snprintf(port_str, sizeof(port_str), "%d", server_port);
514 widget_redraw(pwidget);
515 widget_mark_dirty(pwidget);
516 flush_dirty();
517 }
518 }
519
520 return -1;
521}
522
523/**********************************************************************/
526static int cancel_connect_dlg_callback(struct widget *pwidget)
527{
531 }
532
533 return -1;
534}
535
536/**********************************************************************/
540{
541 char port_str[6];
542 struct widget *buf, *pwindow;
548 int start_x;
549 int pos_y;
550 int dialog_w, dialog_h;
551
552 queue_flush();
554
555 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
556
557 /* Window */
558 pwindow = create_window_skeleton(NULL, NULL, 0);
559 add_to_gui_list(ID_WINDOW, pwindow);
560 connect_dlg->end_widget_list = pwindow;
561
562 area = pwindow->area;
563
564 /* Player name label */
567 buf = create_iconlabel(NULL, pwindow->dst, plrname,
570 area.h += buf->size.h + adj_size(20);
571
572 /* Player name edit */
575 adj_size(210),
580 area.h += buf->size.h + adj_size(5);
581
582 /* Server name label */
583 srvname = create_utf8_from_char_fonto(_("Freeciv Server :"), FONTO_DEFAULT);
585 buf = create_iconlabel(NULL, pwindow->dst, srvname,
588 area.h += buf->size.h + adj_size(5);
589
590 /* Server name edit */
594
598 area.h += buf->size.h + adj_size(5);
599
600 /* Port label */
603 buf = create_iconlabel(NULL, pwindow->dst, port_nr,
606 area.h += buf->size.h + adj_size(5);
607
608 /* Port edit */
609 fc_snprintf(port_str, sizeof(port_str), "%d", server_port);
610
613 adj_size(210),
615
619 area.h += buf->size.h + adj_size(20);
620
621 /* Connect button */
623 pwindow->dst,
624 _("Connect"),
625 FONTO_HEADING, 0);
626 buf->action = connect_callback;
628 buf->key = SDLK_RETURN;
630
631 /* Cancel button */
633 pwindow->dst, _("Cancel"),
634 FONTO_HEADING, 0);
637 buf->key = SDLK_ESCAPE;
639 buf->size.w = MAX(buf->size.w, buf->next->size.w);
640 buf->next->size.w = buf->size.w;
641 area.h += buf->size.h + adj_size(10);
642 /* ------------------------------ */
643
645
646 dialog_w = MAX(adj_size(40) + buf->size.w * 2, adj_size(210)) + adj_size(80);
647
648#ifdef GUI_SDL2_SMALL_SCREEN
649 dialog_h = area.h + (pwindow->size.h - pwindow->area.h);
650#else
651 dialog_h = area.h + (pwindow->size.h - pwindow->area.h);
652#endif
653
655 if (resize_window(pwindow, logo, NULL, dialog_w, dialog_h)) {
657 }
658
659 area = pwindow->area;
660
661 widget_set_position(pwindow,
662 (main_window_width() - pwindow->size.w) / 2,
663 (main_window_height() - pwindow->size.h) / 2 + adj_size(40));
664
665 /* player name label */
667
668 start_x = area.x + (area.w - buf->prev->size.w) / 2;
669 pos_y = area.y + adj_size(20);
670
671 buf->size.x = start_x + adj_size(5);
672 buf->size.y = pos_y;
673
674 pos_y += buf->size.h;
675
676 buf = buf->prev;
677 buf->size.x = start_x;
678 buf->size.y = pos_y;
679
680 pos_y += buf->size.h + adj_size(5);
681
682 /* server name label */
683 buf = buf->prev;
684 buf->size.x = start_x + adj_size(5);
685 buf->size.y = pos_y;
686
687 pos_y += buf->size.h;
688
689 /* server name edit */
690 buf = buf->prev;
691 buf->size.x = start_x;
692 buf->size.y = pos_y;
693
694 pos_y += buf->size.h + adj_size(5);
695
696 /* port label */
697 buf = buf->prev;
698 buf->size.x = start_x + adj_size(5);
699 buf->size.y = pos_y;
700
701 pos_y += buf->size.h;
702
703 /* port edit */
704 buf = buf->prev;
705 buf->size.x = start_x;
706 buf->size.y = pos_y;
707
708 pos_y += buf->size.h + adj_size(20);
709
710 /* connect button */
711 buf = buf->prev;
712 buf->size.x = area.x + (dialog_w - (adj_size(40) + buf->size.w * 2)) / 2;
713 buf->size.y = pos_y;
714
715 /* cancel button */
716 buf = buf->prev;
717 buf->size.x = buf->next->size.x + buf->size.w + adj_size(40);
718 buf->size.y = pos_y;
719
721 FALSE);
722
723 flush_all();
724}
725
726/**********************************************************************/
729static int convert_passwd_callback(struct widget *pwidget)
730{
732 if (pwidget->string_utf8->text != NULL) {
734 }
735 }
736
737 return -1;
738}
739
740/**********************************************************************/
743static int send_passwd_callback(struct widget *pwidget)
744{
747
748 sz_strlcpy(reply.password, fc_password);
749
751 fc_password[0] = '\0';
752
753 set_wstate(pwidget, FC_WS_DISABLED);
754
755 widget_redraw(pwidget);
756
757 widget_mark_dirty(pwidget);
758
759 flush_dirty();
760
762 }
763
764 return -1;
765}
766
767/**********************************************************************/
770static int cancel_passwd_callback(struct widget *pwidget)
771{
773 fc_password[0] = '\0';
775
776 return cancel_connect_dlg_callback(pwidget);
777}
778
779/**********************************************************************/
782static void popup_user_passwd_dialog(const char *message)
783{
784 struct widget *buf, *pwindow;
786 SDL_Surface *background;
787 int start_x, start_y;
788 int start_button_y;
790
791 queue_flush();
793
794 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
795
796 pwindow = create_window_skeleton(NULL, NULL, 0);
797 add_to_gui_list(ID_WINDOW, pwindow);
798 connect_dlg->end_widget_list = pwindow;
799
800 area = pwindow->area;
801
802 /* Text label */
808 area.h += adj_size(10) + buf->size.h + adj_size(5);
809
810 /* Password edit */
811 buf = create_edit(NULL, pwindow->dst,
813 adj_size(210),
818 area.h += buf->size.h + adj_size(10);
819
820 /* Next button */
822 pwindow->dst,
823 _("Next"),
824 FONTO_HEADING, 0);
825 buf->action = send_passwd_callback;
827 buf->key = SDLK_RETURN;
829
830 /* Cancel button */
832 pwindow->dst,
833 _("Cancel"),
834 FONTO_HEADING, 0);
835 buf->action = cancel_passwd_callback;
837 buf->key = SDLK_ESCAPE;
839 buf->size.w = MAX(buf->size.w, buf->next->size.w);
840 buf->next->size.w = buf->size.w;
841 area.h += buf->size.h + adj_size(10);
842
843 /* ------------------------------ */
844
846
847 area.w = MAX(area.w, buf->size.w * 2 + adj_size(40));
848 area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
849 area.w = MAX(area.w, pwindow->prev->size.w);
850 area.w += adj_size(80);
851
853 if (resize_window(pwindow, background, NULL,
854 (pwindow->size.w - pwindow->area.w) + area.w,
855 (pwindow->size.h - pwindow->area.h) + area.h)) {
856 FREESURFACE(background);
857 }
858
859 area = pwindow->area;
860
861 widget_set_position(pwindow,
862 (main_window_width() - pwindow->size.w) / 2,
863 (main_window_height() - pwindow->size.h) / 2);
864
865 /* Text label */
867
868 start_x = area.x + (area.w - buf->size.w) / 2;
869 start_y = area.y + adj_size(10);
870
873
874 start_y += buf->size.h + adj_size(5);
875
876 /* Password edit */
877 buf = buf->prev;
878 start_x = area.x + (area.w - buf->size.w) / 2;
879
882
883 /* --------------------------------- */
884 start_button_y = buf->size.y + buf->size.h + adj_size(10);
885
886 /* connect button */
887 buf = buf->prev;
890 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
892
893 /* cancel button */
894 buf = buf->prev;
897 buf->next->size.x + buf->size.w + adj_size(40),
899
901 FALSE);
902
903 flush_all();
904}
905
906/**********************************************************************/
909static int convert_first_passwd_callback(struct widget *pwidget)
910{
912 if (pwidget->string_utf8->text != NULL) {
914 set_wstate(pwidget->prev, FC_WS_NORMAL);
915 widget_redraw(pwidget->prev);
916 widget_flush(pwidget->prev);
917 }
918 }
919
920 return -1;
921}
922
923/**********************************************************************/
926static int convert_second_passwd_callback(struct widget *pwidget)
927{
929 if (pwidget->string_utf8->text != NULL
930 && !fc_strncmp(fc_password, pwidget->string_utf8->text,
931 MAX_LEN_NAME)) {
932 set_wstate(pwidget->prev, FC_WS_NORMAL); /* Next button */
933 widget_redraw(pwidget->prev);
934 widget_flush(pwidget->prev);
935 } else {
937 fc_password[0] = '\0';
938
939 FC_FREE(pwidget->next->string_utf8->text);/* First edit */
940 FC_FREE(pwidget->string_utf8->text); /* Second edit */
941
942 popup_new_user_passwd_dialog(_("Passwords don't match, enter password."));
943 }
944 }
945
946 return -1;
947}
948
949/**********************************************************************/
952static void popup_new_user_passwd_dialog(const char *message)
953{
954 struct widget *buf, *pwindow;
956 SDL_Surface *background;
957 int start_x, start_y;
958 int start_button_y;
960
961 queue_flush();
963
964 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
965
966 pwindow = create_window_skeleton(NULL, NULL, 0);
967 add_to_gui_list(ID_WINDOW, pwindow);
968 connect_dlg->end_widget_list = pwindow;
969
970 area = pwindow->area;
971
972 /* Text label */
978 area.h += adj_size(10) + buf->size.h + adj_size(5);
979
980 /* Password edit */
981 buf = create_edit(NULL, pwindow->dst,
983 adj_size(210),
988 area.h += buf->size.h + adj_size(5);
989
990 /* Second password edit */
991 buf = create_edit(NULL, pwindow->dst,
993 adj_size(210),
997 area.h += buf->size.h + adj_size(10);
998
999 /* Next button */
1001 pwindow->dst,
1002 _("Next"),
1003 FONTO_HEADING, 0);
1004 buf->action = send_passwd_callback;
1005 buf->key = SDLK_RETURN;
1007
1008 /* Cancel button */
1010 pwindow->dst, _("Cancel"),
1011 FONTO_HEADING, 0);
1012 buf->action = cancel_passwd_callback;
1014 buf->key = SDLK_ESCAPE;
1016 buf->size.w = MAX(buf->size.w, buf->next->size.w);
1017 buf->next->size.w = buf->size.w;
1018 area.h += buf->size.h + adj_size(10);
1019
1020 /* ------------------------------ */
1021
1023
1024 area.w = buf->size.w * 2 + adj_size(40);
1025 area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
1026 area.w = MAX(area.w, pwindow->prev->size.w);
1027 area.w += adj_size(80);
1028
1030 if (resize_window(pwindow, background, NULL,
1031 (pwindow->size.w - pwindow->area.w) + area.w,
1032 (pwindow->size.h - pwindow->area.h) + area.h)) {
1033 FREESURFACE(background);
1034 }
1035
1036 area = pwindow->area;
1037
1038 widget_set_position(pwindow,
1039 (main_window_width() - pwindow->size.w) / 2,
1040 (main_window_height() - pwindow->size.h) / 2);
1041
1042 /* text label */
1044
1045 start_x = area.x + (area.w - buf->size.w) / 2;
1046 start_y = area.y + adj_size(10);
1047
1049 widget_set_position(buf, start_x, start_y);
1050
1051 start_y += buf->size.h + adj_size(5);
1052
1053 /* passwd edit */
1054 buf = buf->prev;
1055 start_x = area.x + (area.w - buf->size.w) / 2;
1056
1058 widget_set_position(buf, start_x, start_y);
1059
1060 start_y += buf->size.h + adj_size(5);
1061
1062 /* retype passwd */
1063 buf = buf->prev;
1065 widget_set_position(buf, start_x, start_y);
1066
1067 start_button_y = buf->size.y + buf->size.h + adj_size(10);
1068
1069 /* connect button */
1070 buf = buf->prev;
1073 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
1075
1076 /* cancel button */
1077 buf = buf->prev;
1080 buf->next->size.x + buf->size.w + adj_size(40),
1082
1084 FALSE);
1085
1086 flush_all();
1087}
1088
1089/* ======================================================================== */
1090
1091/**********************************************************************/
1114
1115/**********************************************************************/
1120 const char *message)
1121{
1122 switch (type) {
1123 case AUTH_NEWUSER_FIRST:
1124 case AUTH_NEWUSER_RETRY:
1126 return;
1127 case AUTH_LOGIN_FIRST:
1128 /* if we magically have a password already present in 'fc_password'
1129 * then, use that and skip the password entry dialog */
1130 if (fc_password[0] != '\0') {
1132
1133 sz_strlcpy(reply.password, fc_password);
1135
1136 return;
1137 } else {
1139 }
1140
1141 return;
1142 case AUTH_LOGIN_RETRY:
1144
1145 return;
1146 }
1147
1148 log_error("Not supported authentication type %d: %s.", type, message);
1149}
1150
1151/**********************************************************************/
1156{
1157}
void output_window_append(const struct ft_color color, const char *featured_text)
char user_name[512]
char server_host[512]
struct civclient client
char fc_password[MAX_LEN_PASSWORD]
int server_port
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:76
authentication_type
Definition conn_types.h:41
@ AUTH_NEWUSER_RETRY
Definition conn_types.h:45
@ AUTH_NEWUSER_FIRST
Definition conn_types.h:43
@ AUTH_LOGIN_RETRY
Definition conn_types.h:44
@ AUTH_LOGIN_FIRST
Definition conn_types.h:42
QString current_theme
Definition fc_client.cpp:64
#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
const struct ft_color ftc_any
void server_connect(void)
Definition connectdlg.c:60
void close_connection_dialog(void)
Definition connectdlg.c:52
void flush_dirty(void)
Definition mapview.c:468
void meswin_dialog_popdown(void)
Definition messagewin.c:432
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
static struct server_scan_timer_data lan_scan
Definition pages.c:87
GType type
Definition repodlgs.c:1313
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
static int convert_first_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:909
void handle_game_load(bool load_successful, const char *filename)
Definition connectdlg.c:80
static int cancel_connect_dlg_callback(struct widget *pwidget)
Definition connectdlg.c:526
static struct small_dialog * connect_dlg
Definition connectdlg.c:65
static int convert_playername_callback(struct widget *pwidget)
Definition connectdlg.c:463
static int exit_meta_server_dlg_callback(struct widget *pwidget)
Definition connectdlg.c:123
static int send_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:743
static void popup_new_user_passwd_dialog(const char *message)
Definition connectdlg.c:952
static void server_scan_error(struct server_scan *scan, const char *message)
Definition connectdlg.c:159
static int meta_server_window_callback(struct widget *pwindow)
Definition connectdlg.c:115
static int connect_callback(struct widget *pwidget)
Definition connectdlg.c:88
static int select_meta_servers_callback(struct widget *pwidget)
Definition connectdlg.c:142
void popup_join_game_dialog(void)
Definition connectdlg.c:539
static void popup_user_passwd_dialog(const char *message)
Definition connectdlg.c:782
static struct srv_list * sdl_create_server_list(bool lan)
Definition connectdlg.c:187
static int convert_second_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:926
void handle_authentication_req(enum authentication_type type, const char *message)
void popup_connection_dialog(bool lan_scan)
Definition connectdlg.c:219
static int convert_servername_callback(struct widget *pwidget)
Definition connectdlg.c:483
static int cancel_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:770
static struct server_list * server_list
Definition connectdlg.c:61
static struct advanced_dialog * meta_server
Definition connectdlg.c:64
static int convert_portnr_callback(struct widget *pwidget)
Definition connectdlg.c:503
static int convert_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:729
int main_window_width(void)
Definition graphics.c:685
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
struct sdl2_data main_data
Definition graphics.c:57
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1350
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
@ ID_CANCEL_BUTTON
Definition gui_id.h:53
@ ID_LAN_SERVERS_WINDOW
Definition gui_id.h:52
@ ID_PORT_EDIT
Definition gui_id.h:48
@ ID_BUTTON
Definition gui_id.h:29
@ ID_PLAYER_NAME_EDIT
Definition gui_id.h:46
@ ID_EDIT
Definition gui_id.h:34
@ ID_SERVER_NAME_EDIT
Definition gui_id.h:47
@ ID_CONNECT_BUTTON
Definition gui_id.h:49
@ ID_LABEL
Definition gui_id.h:27
@ ID_META_SERVERS_WINDOW
Definition gui_id.h:51
@ ID_WINDOW
Definition gui_id.h:30
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_BIG
Definition gui_string.h:70
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
void queue_flush(void)
Definition mapview.c:152
void flush_all(void)
Definition mapview.c:201
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_CONNECTDLG
@ BACKGROUND_JOINGAMEDLG
@ BACKGROUND_USERPASSWDDLG
@ COLOR_THEME_CONNECTDLG_INNERFRAME
Definition themecolors.h:78
@ COLOR_THEME_JOINGAMEDLG_TEXT
Definition themecolors.h:93
@ COLOR_THEME_CONNECTDLG_FRAME
Definition themecolors.h:77
@ COLOR_THEME_USERPASSWDDLG_TEXT
struct theme * active_theme
Definition themespec.c:154
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
void unselect_widget_action(void)
Definition widget.c:418
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_SELECTED
Definition widget.h:97
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
@ WF_PASSWD_EDIT
Definition widget.h:90
@ WF_DRAW_FRAME_AROUND_WIDGET
Definition widget.h:86
@ WF_FREE_DATA
Definition widget.h:78
@ WF_FREE_STRING
Definition widget.h:76
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * convert_iconlabel_to_themeiconlabel2(struct widget *icon_label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
#define log_normal(message,...)
Definition log.h:108
#define log_error(message,...)
Definition log.h:104
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
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
#define server_list_iterate(serverlist, pserver)
Definition servers.h:55
@ SERVER_SCAN_LOCAL
Definition servers.h:68
@ SERVER_SCAN_LAST
Definition servers.h:70
@ SERVER_SCAN_GLOBAL
Definition servers.h:69
#define MAX(x, y)
Definition shared.h:54
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
struct connection conn
Definition client_main.h:96
SDL_Surface * surface
Definition graphics.h:229
SDL_Event event
Definition graphics.h:217
char * host
Definition servers.h:30
char * version
Definition servers.h:34
char * message
Definition servers.h:37
char * state
Definition servers.h:35
int port
Definition servers.h:31
int nplayers
Definition servers.h:47
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
fc_mutex mutex
Definition servers.h:64
struct server_list * servers
Definition servers.h:63
char * text
Definition gui_string.h:60
void * ptr
Definition widget.h:133
union widget::@223 data
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
struct widget * next
Definition widget.h:113
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:160
void set_client_page(enum client_pages page)