Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl2/connectdlg.c Source File

Freeciv-3.2

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
45/* gui-sdl2 */
46#include "chatline.h"
47#include "colors.h"
48#include "graphics.h"
49#include "gui_id.h"
50#include "gui_main.h"
51#include "gui_tilespec.h"
52#include "mapview.h"
53#include "messagewin.h"
54#include "optiondlg.h"
55#include "pages.h"
56#include "themespec.h"
57#include "widget.h"
58
59#include "connectdlg.h"
60
61 static struct server_list *server_list = NULL;
62 static struct server_scan *server_scan = NULL;
63
64 static struct advanced_dialog *meta_server = NULL;
65 static 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/**********************************************************************/
80 void handle_game_load(bool load_successful, const char *filename)
81{
82 /* PORTME */
83}
84
85/**********************************************************************/
88 static int connect_callback(struct widget *pwidget)
89{
90 if (PRESSED_EVENT(main_data.event)) {
91 char errbuf[512];
92
93 if (connect_to_server(user_name, server_host, server_port,
94 errbuf, sizeof(errbuf)) != -1) {
95 } else {
96 output_window_append(ftc_any, errbuf);
97
98 /* button up */
99 unselect_widget_action();
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/**********************************************************************/
115 static int meta_server_window_callback(struct widget *pwindow)
116{
117 return -1;
118}
119
120/**********************************************************************/
123 static int exit_meta_server_dlg_callback(struct widget *pwidget)
124{
125 if (PRESSED_EVENT(main_data.event)) {
126 queue_flush();
127
128 server_scan_finish(server_scan);
129 server_scan = NULL;
130 server_list = NULL;
131
132 set_client_page(PAGE_NETWORK);
133 meswin_dialog_popup(TRUE);
134 }
135
136 return -1;
137}
138
139/**********************************************************************/
142 static int select_meta_servers_callback(struct widget *pwidget)
143{
144 if (PRESSED_EVENT(main_data.event)) {
145 struct server *server = (struct server *)pwidget->data.ptr;
146
147 sz_strlcpy(server_host, server->host);
148 server_port = server->port;
149
150 exit_meta_server_dlg_callback(NULL);
151 }
152
153 return -1;
154}
155
156/**********************************************************************/
159 static void server_scan_error(struct server_scan *scan,
160 const char *message)
161{
162 output_window_append(ftc_client, message);
163 log_normal("%s", message);
164
165 switch (server_scan_get_type(scan)) {
166 case SERVER_SCAN_LOCAL:
167 server_scan_finish(server_scan);
168 server_scan = NULL;
169 server_list = NULL;
170 break;
171 case SERVER_SCAN_GLOBAL:
172 server_scan_finish(server_scan);
173 server_scan = NULL;
174 server_list = NULL;
175 break;
176 case SERVER_SCAN_LAST:
177 break;
178 }
179}
180
181/**********************************************************************/
187 static struct srv_list *sdl_create_server_list(bool lan)
188{
189 struct srv_list *list = NULL;
190 int i;
191
192 if (lan) {
193 server_scan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);
194 } else {
195 server_scan = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);
196 }
197
198 if (!server_scan) {
199 return NULL;
200 }
201
202 SDL_Delay(5000);
203
204 for (i = 0; i < 100; i++) {
205 server_scan_poll(server_scan);
206 list = server_scan_get_list(server_scan);
207 if (list) {
208 break;
209 }
210 SDL_Delay(100);
211 }
212
213 return list;
214}
215
216/**********************************************************************/
219 void popup_connection_dialog(bool lan_scan)
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;
226 SDL_Surface *logo;
227 SDL_Rect area, area2;
228 struct srv_list *srvrs;
229
230 queue_flush();
231 close_connection_dialog();
232 meswin_dialog_popdown();
233
234 /* Text Label */
235 label_window = create_window_skeleton(NULL, NULL, 0);
236 add_to_gui_list(ID_WINDOW, label_window);
237
238 area = label_window->area;
239
240 fc_snprintf(cbuf, sizeof(cbuf), _("Creating Server List..."));
241 pstr = create_utf8_from_char_fonto(cbuf, FONTO_BIG);
242 pstr->style = TTF_STYLE_BOLD;
243 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
244 new_widget = create_iconlabel(NULL, label_window->dst, pstr,
245 (WF_RESTORE_BACKGROUND | WF_DRAW_TEXT_LABEL_WITH_SPACE));
246 add_to_gui_list(ID_LABEL, new_widget);
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
253 resize_window(label_window, NULL, &bg_color,
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
259 widget_set_position(label_window,
260 (main_window_width() - label_window->size.w) / 2,
261 (main_window_height() - label_window->size.h) / 2);
262
263 widget_set_area(new_widget, area);
264 widget_set_position(new_widget,
265 area.x + (area.w - new_widget->size.w) / 2,
266 area.y + (area.h - new_widget->size.h) / 2);
267
268 redraw_group(new_widget, label_window, TRUE);
269 flush_dirty();
270
271 /* Create server list */
272 srvrs = sdl_create_server_list(lan_scan);
273
274 /* Copy list */
275 server_list = server_list_new();
276 fc_mutex_allocate(&srvrs->mutex);
277 server_list_iterate(srvrs->servers, pserver) {
278 server_list_append(server_list, pserver);
279 } server_list_iterate_end;
280 fc_mutex_release(&srvrs->mutex);
281
282 /* Clear label */
283 popdown_window_group_dialog(new_widget, label_window);
284
285 meswin_dialog_popup(TRUE);
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 }
293 set_client_page(PAGE_NETWORK);
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);
301 pwindow->action = meta_server_window_callback;
302 set_wstate(pwindow, FC_WS_NORMAL);
303 clear_wflag(pwindow, WF_DRAW_FRAME_AROUND_WIDGET);
304 if (lan_scan) {
305 add_to_gui_list(ID_LAN_SERVERS_WINDOW, pwindow);
306 } else {
307 add_to_gui_list(ID_META_SERVERS_WINDOW, pwindow);
308 }
309 meta_server->end_widget_list = pwindow;
310
311 /* Cancel button */
312 new_widget
313 = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
314 pwindow->dst, _("Cancel"),
315 FONTO_HEADING, 0);
316 new_widget->action = exit_meta_server_dlg_callback;
317 set_wstate(new_widget, FC_WS_NORMAL);
318 add_to_gui_list(ID_BUTTON, new_widget);
319
320 /* Servers */
321 server_list_iterate(server_list, server) {
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"),
326 server->host, server->port, server->version, _(server->state),
327 Q_("?header:Players"), server->nplayers, server->message);
328
329 new_widget = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf,
330 FONTO_DEFAULT,
331 WF_FREE_STRING|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_RESTORE_BACKGROUND);
332
333 new_widget->string_utf8->style |= SF_CENTER;
334 new_widget->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
335
336 new_widget->action = select_meta_servers_callback;
337 set_wstate(new_widget, FC_WS_NORMAL);
338 new_widget->data.ptr = (void *)server;
339
340 add_to_gui_list(ID_BUTTON, new_widget);
341
342 w = MAX(w, new_widget->size.w);
343 h = MAX(h, new_widget->size.h);
344 count++;
345
346 if (count > 10) {
347 set_wflag(new_widget, WF_HIDDEN);
348 }
349
350 } server_list_iterate_end;
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 }
358 set_client_page(PAGE_NETWORK);
359 return;
360 }
361
362 meta_server->begin_widget_list = new_widget;
363 meta_server->begin_active_widget_list = meta_server->begin_widget_list;
364 meta_server->end_active_widget_list = meta_server->end_widget_list->prev->prev;
365 meta_server->active_widget_list = meta_server->end_active_widget_list;
366
367 if (count > 10) {
368 meta_h = 10 * h;
369
370 count = create_vertical_scrollbar(meta_server, 1, 10, TRUE, TRUE);
371 w += count;
372 } else {
373 meta_h = count * h;
374 }
375
376 w += adj_size(20);
377 area2.h = meta_h;
378
379 meta_h += meta_server->end_widget_list->prev->size.h + adj_size(10) + adj_size(20);
380
381 logo = theme_get_background(active_theme, BACKGROUND_CONNECTDLG);
382 if (resize_window(pwindow, logo, NULL, w, meta_h)) {
383 FREESURFACE(logo);
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;
412 new_widget = convert_iconlabel_to_themeiconlabel2(new_widget);
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;
421 new_widget = convert_iconlabel_to_themeiconlabel2(new_widget);
422
423 if (new_widget == meta_server->begin_active_widget_list) {
424 break;
425 }
426 new_widget = new_widget->prev;
427 }
428
429 if (meta_server->scroll) {
430 setup_vertical_scrollbar_area(meta_server->scroll,
431 area.x + area.w - adj_size(6),
432 meta_server->end_active_widget_list->size.y,
433 area.h - adj_size(24) - pwindow->prev->size.h, TRUE);
434 }
435
436 /* -------------------- */
437 /* Redraw */
438
439 widget_redraw(pwindow);
440
441 area2.x = meta_server->end_active_widget_list->size.x;
442 area2.y = meta_server->end_active_widget_list->size.y;
443
444 fill_rect_alpha(pwindow->dst->surface, &area2, &bg_color);
445
446 create_frame(pwindow->dst->surface,
447 area2.x - 1, area2.y - 1, area2.w, area2.h,
448 get_theme_color(COLOR_THEME_CONNECTDLG_INNERFRAME));
449
450 redraw_group(meta_server->begin_widget_list, pwindow->prev, 0);
451
452 create_frame(pwindow->dst->surface,
453 pwindow->size.x, pwindow->size.y,
454 area.w - 1, area.h - 1,
455 get_theme_color(COLOR_THEME_CONNECTDLG_FRAME));
456
457 widget_flush(pwindow);
458}
459
460/**********************************************************************/
463 static int convert_playername_callback(struct widget *pwidget)
464{
465 if (PRESSED_EVENT(main_data.event)) {
466 if (pwidget->string_utf8->text != NULL) {
467 sz_strlcpy(user_name, pwidget->string_utf8->text);
468 } else {
469 /* empty input -> restore previous content */
470 copy_chars_to_utf8_str(pwidget->string_utf8, user_name);
471 widget_redraw(pwidget);
472 widget_mark_dirty(pwidget);
473 flush_dirty();
474 }
475 }
476
477 return -1;
478}
479
480/**********************************************************************/
483 static int convert_servername_callback(struct widget *pwidget)
484{
485 if (PRESSED_EVENT(main_data.event)) {
486 if (pwidget->string_utf8->text != NULL) {
487 sz_strlcpy(server_host, pwidget->string_utf8->text);
488 } else {
489 /* empty input -> restore previous content */
490 copy_chars_to_utf8_str(pwidget->string_utf8, server_host);
491 widget_redraw(pwidget);
492 widget_mark_dirty(pwidget);
493 flush_dirty();
494 }
495 }
496
497 return -1;
498}
499
500/**********************************************************************/
503 static int convert_portnr_callback(struct widget *pwidget)
504{
505 if (PRESSED_EVENT(main_data.event)) {
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);
513 copy_chars_to_utf8_str(pwidget->string_utf8, port_str);
514 widget_redraw(pwidget);
515 widget_mark_dirty(pwidget);
516 flush_dirty();
517 }
518 }
519
520 return -1;
521}
522
523/**********************************************************************/
526 static int cancel_connect_dlg_callback(struct widget *pwidget)
527{
528 if (PRESSED_EVENT(main_data.event)) {
529 close_connection_dialog();
530 set_client_page(PAGE_MAIN);
531 }
532
533 return -1;
534}
535
536/**********************************************************************/
539 void popup_join_game_dialog(void)
540{
541 char port_str[6];
542 struct widget *buf, *pwindow;
543 utf8_str *plrname = NULL;
544 utf8_str *srvname = NULL;
545 utf8_str *port_nr = NULL;
546 SDL_Surface *logo;
547 SDL_Rect area;
548 int start_x;
549 int pos_y;
550 int dialog_w, dialog_h;
551
552 queue_flush();
553 close_connection_dialog();
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 */
565 plrname = create_utf8_from_char_fonto(_("Player Name :"), FONTO_DEFAULT);
566 plrname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
567 buf = create_iconlabel(NULL, pwindow->dst, plrname,
568 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
569 add_to_gui_list(ID_LABEL, buf);
570 area.h += buf->size.h + adj_size(20);
571
572 /* Player name edit */
573 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, user_name,
574 FONTO_HEADING,
575 adj_size(210),
576 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
577 buf->action = convert_playername_callback;
578 set_wstate(buf, FC_WS_NORMAL);
579 add_to_gui_list(ID_PLAYER_NAME_EDIT, buf);
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);
584 srvname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
585 buf = create_iconlabel(NULL, pwindow->dst, srvname,
586 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
587 add_to_gui_list(ID_LABEL, buf);
588 area.h += buf->size.h + adj_size(5);
589
590 /* Server name edit */
591 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, server_host,
592 FONTO_HEADING,
593 adj_size(210), WF_RESTORE_BACKGROUND);
594
595 buf->action = convert_servername_callback;
596 set_wstate(buf, FC_WS_NORMAL);
597 add_to_gui_list(ID_SERVER_NAME_EDIT, buf);
598 area.h += buf->size.h + adj_size(5);
599
600 /* Port label */
601 port_nr = create_utf8_from_char_fonto(_("Port :"), FONTO_DEFAULT);
602 port_nr->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
603 buf = create_iconlabel(NULL, pwindow->dst, port_nr,
604 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
605 add_to_gui_list(ID_LABEL, buf);
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
611 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, port_str,
612 FONTO_HEADING,
613 adj_size(210),
614 WF_RESTORE_BACKGROUND);
615
616 buf->action = convert_portnr_callback;
617 set_wstate(buf, FC_WS_NORMAL);
618 add_to_gui_list(ID_PORT_EDIT, buf);
619 area.h += buf->size.h + adj_size(20);
620
621 /* Connect button */
622 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
623 pwindow->dst,
624 _("Connect"),
625 FONTO_HEADING, 0);
626 buf->action = connect_callback;
627 set_wstate(buf, FC_WS_NORMAL);
628 buf->key = SDLK_RETURN;
629 add_to_gui_list(ID_CONNECT_BUTTON, buf);
630
631 /* Cancel button */
632 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
633 pwindow->dst, _("Cancel"),
634 FONTO_HEADING, 0);
635 buf->action = cancel_connect_dlg_callback;
636 set_wstate(buf, FC_WS_NORMAL);
637 buf->key = SDLK_ESCAPE;
638 add_to_gui_list(ID_CANCEL_BUTTON, buf);
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
644 connect_dlg->begin_widget_list = buf;
645
646 dialog_w = MAX(adj_size(40) + buf->size.w * 2, adj_size(210)) + adj_size(80);
647
648#ifdef 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
654 logo = theme_get_background(active_theme, BACKGROUND_JOINGAMEDLG);
655 if (resize_window(pwindow, logo, NULL, dialog_w, dialog_h)) {
656 FREESURFACE(logo);
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 */
666 buf = connect_dlg->end_widget_list->prev;
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
720 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
721 FALSE);
722
723 flush_all();
724}
725
726/**********************************************************************/
729 static int convert_passwd_callback(struct widget *pwidget)
730{
731 if (PRESSED_EVENT(main_data.event)) {
732 if (pwidget->string_utf8->text != NULL) {
733 fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
734 }
735 }
736
737 return -1;
738}
739
740/**********************************************************************/
743 static int send_passwd_callback(struct widget *pwidget)
744{
745 if (PRESSED_EVENT(main_data.event)) {
746 struct packet_authentication_reply reply;
747
748 sz_strlcpy(reply.password, fc_password);
749
750 memset(fc_password, 0, MAX_LEN_NAME);
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
761 send_packet_authentication_reply(&client.conn, &reply);
762 }
763
764 return -1;
765}
766
767/**********************************************************************/
770 static int cancel_passwd_callback(struct widget *pwidget)
771{
772 memset(fc_password, 0, MAX_LEN_NAME);
773 fc_password[0] = '\0';
774 disconnect_from_server(TRUE);
775
776 return cancel_connect_dlg_callback(pwidget);
777}
778
779/**********************************************************************/
782 static void popup_user_passwd_dialog(const char *message)
783{
784 struct widget *buf, *pwindow;
785 utf8_str *label_str = NULL;
786 SDL_Surface *background;
787 int start_x, start_y;
788 int start_button_y;
789 SDL_Rect area;
790
791 queue_flush();
792 close_connection_dialog();
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 */
803 label_str = create_utf8_from_char_fonto(message, FONTO_ATTENTION);
804 label_str->fgcol = *get_theme_color(COLOR_THEME_USERPASSWDDLG_TEXT);
805 buf = create_iconlabel(NULL, pwindow->dst, label_str,
806 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
807 add_to_gui_list(ID_LABEL, buf);
808 area.h += adj_size(10) + buf->size.h + adj_size(5);
809
810 /* Password edit */
811 buf = create_edit(NULL, pwindow->dst,
812 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
813 adj_size(210),
814 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
815 buf->action = convert_passwd_callback;
816 set_wstate(buf, FC_WS_NORMAL);
817 add_to_gui_list(ID_EDIT, buf);
818 area.h += buf->size.h + adj_size(10);
819
820 /* Next button */
821 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
822 pwindow->dst,
823 _("Next"),
824 FONTO_HEADING, 0);
825 buf->action = send_passwd_callback;
826 set_wstate(buf, FC_WS_NORMAL);
827 buf->key = SDLK_RETURN;
828 add_to_gui_list(ID_BUTTON, buf);
829
830 /* Cancel button */
831 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
832 pwindow->dst,
833 _("Cancel"),
834 FONTO_HEADING, 0);
835 buf->action = cancel_passwd_callback;
836 set_wstate(buf, FC_WS_NORMAL);
837 buf->key = SDLK_ESCAPE;
838 add_to_gui_list(ID_CANCEL_BUTTON, buf);
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
845 connect_dlg->begin_widget_list = buf;
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
852 background = theme_get_background(active_theme, BACKGROUND_USERPASSWDDLG);
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 */
866 buf = connect_dlg->end_widget_list->prev;
867
868 start_x = area.x + (area.w - buf->size.w) / 2;
869 start_y = area.y + adj_size(10);
870
871 widget_set_area(buf, area);
872 widget_set_position(buf, start_x, start_y);
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
880 widget_set_area(buf, area);
881 widget_set_position(buf, start_x, start_y);
882
883 /* --------------------------------- */
884 start_button_y = buf->size.y + buf->size.h + adj_size(10);
885
886 /* connect button */
887 buf = buf->prev;
888 widget_set_area(buf, area);
889 widget_set_position(buf,
890 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
891 start_button_y);
892
893 /* cancel button */
894 buf = buf->prev;
895 widget_set_area(buf, area);
896 widget_set_position(buf,
897 buf->next->size.x + buf->size.w + adj_size(40),
898 start_button_y);
899
900 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
901 FALSE);
902
903 flush_all();
904}
905
906/**********************************************************************/
909 static int convert_first_passwd_callback(struct widget *pwidget)
910{
911 if (PRESSED_EVENT(main_data.event)) {
912 if (pwidget->string_utf8->text != NULL) {
913 fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
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/**********************************************************************/
926 static int convert_second_passwd_callback(struct widget *pwidget)
927{
928 if (PRESSED_EVENT(main_data.event)) {
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 {
936 memset(fc_password, 0, MAX_LEN_NAME);
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/**********************************************************************/
952 static void popup_new_user_passwd_dialog(const char *message)
953{
954 struct widget *buf, *pwindow;
955 utf8_str *label_str = NULL;
956 SDL_Surface *background;
957 int start_x, start_y;
958 int start_button_y;
959 SDL_Rect area;
960
961 queue_flush();
962 close_connection_dialog();
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 */
973 label_str = create_utf8_from_char_fonto(message, FONTO_ATTENTION);
974 label_str->fgcol = *get_theme_color(COLOR_THEME_USERPASSWDDLG_TEXT);
975 buf = create_iconlabel(NULL, pwindow->dst, label_str,
976 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
977 add_to_gui_list(ID_LABEL, buf);
978 area.h += adj_size(10) + buf->size.h + adj_size(5);
979
980 /* Password edit */
981 buf = create_edit(NULL, pwindow->dst,
982 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
983 adj_size(210),
984 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
985 buf->action = convert_first_passwd_callback;
986 set_wstate(buf, FC_WS_NORMAL);
987 add_to_gui_list(ID_EDIT, buf);
988 area.h += buf->size.h + adj_size(5);
989
990 /* Second password edit */
991 buf = create_edit(NULL, pwindow->dst,
992 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
993 adj_size(210),
994 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
995 buf->action = convert_second_passwd_callback;
996 add_to_gui_list(ID_EDIT, buf);
997 area.h += buf->size.h + adj_size(10);
998
999 /* Next button */
1000 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
1001 pwindow->dst,
1002 _("Next"),
1003 FONTO_HEADING, 0);
1004 buf->action = send_passwd_callback;
1005 buf->key = SDLK_RETURN;
1006 add_to_gui_list(ID_BUTTON, buf);
1007
1008 /* Cancel button */
1009 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
1010 pwindow->dst, _("Cancel"),
1011 FONTO_HEADING, 0);
1012 buf->action = cancel_passwd_callback;
1013 set_wstate(buf, FC_WS_NORMAL);
1014 buf->key = SDLK_ESCAPE;
1015 add_to_gui_list(ID_CANCEL_BUTTON, buf);
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
1022 connect_dlg->begin_widget_list = buf;
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
1029 background = theme_get_background(active_theme, BACKGROUND_USERPASSWDDLG);
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 */
1043 buf = connect_dlg->end_widget_list->prev;
1044
1045 start_x = area.x + (area.w - buf->size.w) / 2;
1046 start_y = area.y + adj_size(10);
1047
1048 widget_set_area(buf, area);
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
1057 widget_set_area(buf, area);
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;
1064 widget_set_area(buf, area);
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;
1071 widget_set_area(buf, area);
1072 widget_set_position(buf,
1073 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
1074 start_button_y);
1075
1076 /* cancel button */
1077 buf = buf->prev;
1078 widget_set_area(buf, area);
1079 widget_set_position(buf,
1080 buf->next->size.x + buf->size.w + adj_size(40),
1081 start_button_y);
1082
1083 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
1084 FALSE);
1085
1086 flush_all();
1087}
1088
1089/* ======================================================================== */
1090
1091/**********************************************************************/
1094 void close_connection_dialog(void)
1095{
1096 if (connect_dlg) {
1097 popdown_window_group_dialog(connect_dlg->begin_widget_list,
1098 connect_dlg->end_widget_list);
1099 FC_FREE(connect_dlg);
1100 }
1101 if (meta_server) {
1102 popdown_window_group_dialog(meta_server->begin_widget_list,
1103 meta_server->end_widget_list);
1104 FC_FREE(meta_server->scroll);
1105 FC_FREE(meta_server);
1106
1107 if (server_list) {
1108 server_scan_finish(server_scan);
1109 server_scan = NULL;
1110 server_list = NULL;
1111 }
1112 }
1113}
1114
1115/**********************************************************************/
1119 void handle_authentication_req(enum authentication_type type,
1120 const char *message)
1121{
1122 switch (type) {
1123 case AUTH_NEWUSER_FIRST:
1124 case AUTH_NEWUSER_RETRY:
1125 popup_new_user_passwd_dialog(message);
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') {
1131 struct packet_authentication_reply reply;
1132
1133 sz_strlcpy(reply.password, fc_password);
1134 send_packet_authentication_reply(&client.conn, &reply);
1135
1136 return;
1137 } else {
1138 popup_user_passwd_dialog(message);
1139 }
1140
1141 return;
1142 case AUTH_LOGIN_RETRY:
1143 popup_user_passwd_dialog(message);
1144
1145 return;
1146 }
1147
1148 log_error("Not supported authentication type %d: %s.", type, message);
1149}
1150
1151/**********************************************************************/
1155 void server_connect(void)
1156{
1157}
output_window_append
void output_window_append(const struct ft_color color, const char *featured_text)
Definition chatline_common.c:104
user_name
char user_name[512]
Definition client_main.c:142
server_host
char server_host[512]
Definition client_main.c:141
client
struct civclient client
Definition client_main.c:150
fc_password
char fc_password[MAX_LEN_PASSWORD]
Definition client_main.c:143
server_port
int server_port
Definition client_main.c:145
client_main.h
list
static struct fc_sockaddr_list * list
Definition clinet.c:102
connect_to_server
int connect_to_server(const char *username, const char *hostname, int port, char *errbuf, int errbufsize)
Definition clinet.c:249
disconnect_from_server
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
clinet.h
incite_cost
char * incite_cost
Definition comments.c:74
authentication_type
authentication_type
Definition conn_types.h:41
AUTH_NEWUSER_RETRY
@ AUTH_NEWUSER_RETRY
Definition conn_types.h:45
AUTH_NEWUSER_FIRST
@ AUTH_NEWUSER_FIRST
Definition conn_types.h:43
AUTH_LOGIN_RETRY
@ AUTH_LOGIN_RETRY
Definition conn_types.h:44
AUTH_LOGIN_FIRST
@ AUTH_LOGIN_FIRST
Definition conn_types.h:42
current_theme
QString current_theme
Definition fc_client.cpp:65
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
_
#define _(String)
Definition fcintl.h:67
fc_mutex_allocate
void fc_mutex_allocate(fc_mutex *mutex)
fc_mutex_release
void fc_mutex_release(fc_mutex *mutex)
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
ftc_any
const struct ft_color ftc_any
Definition featured_text.c:73
server_connect
void server_connect(void)
Definition connectdlg.c:60
close_connection_dialog
void close_connection_dialog(void)
Definition connectdlg.c:52
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
meswin_dialog_popdown
void meswin_dialog_popdown(void)
Definition messagewin.c:432
meswin_dialog_popup
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
lan_scan
static struct server_scan_timer_data lan_scan
Definition pages.c:87
type
GType type
Definition repodlgs.c:1313
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
convert_first_passwd_callback
static int convert_first_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:909
handle_game_load
void handle_game_load(bool load_successful, const char *filename)
Definition connectdlg.c:80
cancel_connect_dlg_callback
static int cancel_connect_dlg_callback(struct widget *pwidget)
Definition connectdlg.c:526
connect_dlg
static struct small_dialog * connect_dlg
Definition connectdlg.c:65
convert_playername_callback
static int convert_playername_callback(struct widget *pwidget)
Definition connectdlg.c:463
exit_meta_server_dlg_callback
static int exit_meta_server_dlg_callback(struct widget *pwidget)
Definition connectdlg.c:123
send_passwd_callback
static int send_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:743
popup_new_user_passwd_dialog
static void popup_new_user_passwd_dialog(const char *message)
Definition connectdlg.c:952
server_scan_error
static void server_scan_error(struct server_scan *scan, const char *message)
Definition connectdlg.c:159
meta_server_window_callback
static int meta_server_window_callback(struct widget *pwindow)
Definition connectdlg.c:115
connect_callback
static int connect_callback(struct widget *pwidget)
Definition connectdlg.c:88
select_meta_servers_callback
static int select_meta_servers_callback(struct widget *pwidget)
Definition connectdlg.c:142
popup_join_game_dialog
void popup_join_game_dialog(void)
Definition connectdlg.c:539
popup_user_passwd_dialog
static void popup_user_passwd_dialog(const char *message)
Definition connectdlg.c:782
sdl_create_server_list
static struct srv_list * sdl_create_server_list(bool lan)
Definition connectdlg.c:187
convert_second_passwd_callback
static int convert_second_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:926
handle_authentication_req
void handle_authentication_req(enum authentication_type type, const char *message)
Definition connectdlg.c:1119
popup_connection_dialog
void popup_connection_dialog(bool lan_scan)
Definition connectdlg.c:219
convert_servername_callback
static int convert_servername_callback(struct widget *pwidget)
Definition connectdlg.c:483
cancel_passwd_callback
static int cancel_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:770
server_list
static struct server_list * server_list
Definition connectdlg.c:61
meta_server
static struct advanced_dialog * meta_server
Definition connectdlg.c:64
convert_portnr_callback
static int convert_portnr_callback(struct widget *pwidget)
Definition connectdlg.c:503
convert_passwd_callback
static int convert_passwd_callback(struct widget *pwidget)
Definition connectdlg.c:729
main_window_width
int main_window_width(void)
Definition graphics.c:685
fill_rect_alpha
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
main_data
struct sdl2_data main_data
Definition graphics.c:57
create_frame
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
main_window_height
int main_window_height(void)
Definition graphics.c:693
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
ID_CANCEL_BUTTON
@ ID_CANCEL_BUTTON
Definition gui_id.h:53
ID_LAN_SERVERS_WINDOW
@ ID_LAN_SERVERS_WINDOW
Definition gui_id.h:52
ID_PORT_EDIT
@ ID_PORT_EDIT
Definition gui_id.h:48
ID_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_PLAYER_NAME_EDIT
@ ID_PLAYER_NAME_EDIT
Definition gui_id.h:46
ID_EDIT
@ ID_EDIT
Definition gui_id.h:34
ID_SERVER_NAME_EDIT
@ ID_SERVER_NAME_EDIT
Definition gui_id.h:47
ID_CONNECT_BUTTON
@ ID_CONNECT_BUTTON
Definition gui_id.h:49
ID_LABEL
@ ID_LABEL
Definition gui_id.h:27
ID_META_SERVERS_WINDOW
@ ID_META_SERVERS_WINDOW
Definition gui_id.h:51
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
selected_widget
struct widget * selected_widget
Definition widget.c:48
adj_size
#define adj_size(size)
Definition gui_main.h:141
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:71
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_utf8_str_fonto
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_HEADING
@ FONTO_HEADING
Definition gui_string.h:69
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:65
FONTO_BIG
@ FONTO_BIG
Definition gui_string.h:70
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:67
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
queue_flush
void queue_flush(void)
Definition mapview.c:152
flush_all
void flush_all(void)
Definition mapview.c:201
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_CONNECTDLG
@ BACKGROUND_CONNECTDLG
Definition themebackgrounds.h:33
BACKGROUND_JOINGAMEDLG
@ BACKGROUND_JOINGAMEDLG
Definition themebackgrounds.h:37
BACKGROUND_USERPASSWDDLG
@ BACKGROUND_USERPASSWDDLG
Definition themebackgrounds.h:49
COLOR_THEME_CONNECTDLG_INNERFRAME
@ COLOR_THEME_CONNECTDLG_INNERFRAME
Definition themecolors.h:77
COLOR_THEME_JOINGAMEDLG_TEXT
@ COLOR_THEME_JOINGAMEDLG_TEXT
Definition themecolors.h:92
COLOR_THEME_CONNECTDLG_FRAME
@ COLOR_THEME_CONNECTDLG_FRAME
Definition themecolors.h:76
COLOR_THEME_USERPASSWDDLG_TEXT
@ COLOR_THEME_USERPASSWDDLG_TEXT
Definition themecolors.h:125
active_theme
struct theme * active_theme
Definition themespec.c:154
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
unselect_widget_action
void unselect_widget_action(void)
Definition widget.c:418
redraw_group
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
popdown_window_group_dialog
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
FC_WS_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
FC_WS_SELECTED
@ FC_WS_SELECTED
Definition widget.h:97
clear_wflag
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
widget_flush
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
WF_PASSWD_EDIT
@ WF_PASSWD_EDIT
Definition widget.h:90
WF_DRAW_FRAME_AROUND_WIDGET
@ WF_DRAW_FRAME_AROUND_WIDGET
Definition widget.h:86
WF_FREE_DATA
@ WF_FREE_DATA
Definition widget.h:78
WF_FREE_STRING
@ WF_FREE_STRING
Definition widget.h:76
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
WF_DRAW_TEXT_LABEL_WITH_SPACE
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
widget_set_area
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
set_wflag
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
create_themeicon_button_from_chars_fonto
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
Definition widget_button.h:36
create_edit
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
Definition widget_edit.c:350
create_edit_from_chars_fonto
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
convert_iconlabel_to_themeiconlabel2
struct widget * convert_iconlabel_to_themeiconlabel2(struct widget *icon_label)
Definition widget_label.c:321
create_iconlabel
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_label.c:215
create_iconlabel_from_chars_fonto
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
Definition widget_label.h:20
setup_vertical_scrollbar_area
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Definition widget_scrollbar.c:567
create_vertical_scrollbar
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
Definition widget_scrollbar.c:486
resize_window
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
Definition widget_window.c:255
create_window_skeleton
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
Definition widget_window.c:180
gui_id.h
gui_tilespec.h
themespec.h
widget.h
chatline.h
colors.h
connectdlg.h
graphics.h
gui_main.h
mapview.h
messagewin.h
optiondlg.h
pages.h
log.h
log_normal
#define log_normal(message,...)
Definition log.h:107
log_error
#define log_error(message,...)
Definition log.h:103
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
send_packet_authentication_reply
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
Definition packets_gen.c:2267
packhand.h
set_client_page
void set_client_page(enum client_pages page)
Definition update_queue.c:496
server_scan_get_list
struct srv_list * server_scan_get_list(struct server_scan *scan)
Definition servers.c:866
server_scan_finish
void server_scan_finish(struct server_scan *scan)
Definition servers.c:879
server_scan_begin
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
Definition servers.c:755
server_scan_get_type
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
Definition servers.c:809
server_scan_poll
enum server_scan_status server_scan_poll(struct server_scan *scan)
Definition servers.c:832
servers.h
server_list_iterate_end
#define server_list_iterate_end
Definition servers.h:57
server_list_iterate
#define server_list_iterate(serverlist, pserver)
Definition servers.h:55
SERVER_SCAN_LOCAL
@ SERVER_SCAN_LOCAL
Definition servers.h:68
SERVER_SCAN_LAST
@ SERVER_SCAN_LAST
Definition servers.h:70
SERVER_SCAN_GLOBAL
@ SERVER_SCAN_GLOBAL
Definition servers.h:69
MAX
#define MAX(x, y)
Definition shared.h:54
advanced_dialog
Definition widget.h:180
advanced_dialog::begin_active_widget_list
struct widget * begin_active_widget_list
Definition widget.h:184
advanced_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:182
advanced_dialog::end_active_widget_list
struct widget * end_active_widget_list
Definition widget.h:185
advanced_dialog::active_widget_list
struct widget * active_widget_list
Definition widget.h:186
advanced_dialog::scroll
struct scroll_bar * scroll
Definition widget.h:187
advanced_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:181
civclient::conn
struct connection conn
Definition client_main.h:96
gui_layer::surface
SDL_Surface * surface
Definition graphics.h:229
message
Definition messagewin_common.h:29
packet_authentication_reply
Definition packets_gen.h:64
sdl2_data::event
SDL_Event event
Definition graphics.h:217
server_scan
Definition servers.c:84
server
Definition servers.h:29
server::host
char * host
Definition servers.h:30
server::version
char * version
Definition servers.h:34
server::message
char * message
Definition servers.h:37
server::state
char * state
Definition servers.h:35
server::port
int port
Definition servers.h:31
server::nplayers
int nplayers
Definition servers.h:47
small_dialog
Definition widget.h:174
small_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:175
small_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:176
srv_list
Definition servers.h:62
srv_list::mutex
fc_mutex mutex
Definition servers.h:64
srv_list::servers
struct server_list * servers
Definition servers.h:63
utf8_str
Definition gui_string.h:52
utf8_str::text
char * text
Definition gui_string.h:60
widget
Definition widget.h:112
widget::ptr
void * ptr
Definition widget.h:133
widget::data
union widget::@192 data
widget::prev
struct widget * prev
Definition widget.h:114
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::area
SDL_Rect area
Definition widget.h:149
widget::next
struct widget * next
Definition widget.h:113
widget::size
SDL_Rect size
Definition widget.h:145
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
fc_strncmp
#define fc_strncmp(_s1_, _s2_, _len_)
Definition support.h:154