Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/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/* SDL3 */
29#include <SDL3/SDL.h>
30
31/* utility */
32#include "fcintl.h"
33#include "log.h"
34
35/* client */
36#include "client_main.h"
37#include "clinet.h" /* connect_to_server() */
38#include "packhand.h"
39#include "servers.h"
40
41/* gui-sdl3 */
42#include "chatline.h"
43#include "colors.h"
44#include "graphics.h"
45#include "gui_id.h"
46#include "gui_main.h"
47#include "gui_tilespec.h"
48#include "mapview.h"
49#include "messagewin.h"
50#include "optiondlg.h"
51#include "pages.h"
52#include "themespec.h"
53#include "widget.h"
54
55#include "connectdlg.h"
56
57 static struct server_list *server_list = NULL;
58 static struct server_scan *server_scan = NULL;
59
60 static struct advanced_dialog *meta_server = NULL;
61 static struct small_dialog *connect_dlg = NULL;
62
63static int connect_callback(struct widget *pwidget);
64static int convert_portnr_callback(struct widget *pwidget);
65static int convert_playername_callback(struct widget *pwidget);
66static int convert_servername_callback(struct widget *pwidget);
67static void popup_new_user_passwd_dialog(const char *message);
68
69/*
70 THESE FUNCTIONS ARE ONE BIG TMP SOLUTION AND SHOULD BE FULLY REWRITTEN !!
71*/
72
73/**********************************************************************/
76 void handle_game_load(bool load_successful, const char *filename)
77{
78 /* PORTME */
79}
80
81/**********************************************************************/
84 static int connect_callback(struct widget *pwidget)
85{
86 if (PRESSED_EVENT(main_data.event)) {
87 char errbuf[512];
88
89 if (connect_to_server(user_name, server_host, server_port,
90 errbuf, sizeof(errbuf)) != -1) {
91 } else {
92 output_window_append(ftc_any, errbuf);
93
94 /* button up */
95 unselect_widget_action();
96 set_wstate(pwidget, FC_WS_SELECTED);
97 selected_widget = pwidget;
98 widget_redraw(pwidget);
99 widget_flush(pwidget);
100 }
101 }
102
103 return -1;
104}
105/* ======================================================== */
106
107
108/**********************************************************************/
111 static int meta_server_window_callback(struct widget *pwindow)
112{
113 return -1;
114}
115
116/**********************************************************************/
119 static int exit_meta_server_dlg_callback(struct widget *pwidget)
120{
121 if (PRESSED_EVENT(main_data.event)) {
122 queue_flush();
123
124 server_scan_finish(server_scan);
125 server_scan = NULL;
126 server_list = NULL;
127
128 set_client_page(PAGE_NETWORK);
129 meswin_dialog_popup(TRUE);
130 }
131
132 return -1;
133}
134
135/**********************************************************************/
138 static int select_meta_servers_callback(struct widget *pwidget)
139{
140 if (PRESSED_EVENT(main_data.event)) {
141 struct server *server = (struct server *)pwidget->data.ptr;
142
143 sz_strlcpy(server_host, server->host);
144 server_port = server->port;
145
146 exit_meta_server_dlg_callback(NULL);
147 }
148
149 return -1;
150}
151
152/**********************************************************************/
155 static void server_scan_error(struct server_scan *scan,
156 const char *message)
157{
158 output_window_append(ftc_client, message);
159 log_normal("%s", message);
160
161 switch (server_scan_get_type(scan)) {
162 case SERVER_SCAN_LOCAL:
163 server_scan_finish(server_scan);
164 server_scan = NULL;
165 server_list = NULL;
166 break;
167 case SERVER_SCAN_GLOBAL:
168 server_scan_finish(server_scan);
169 server_scan = NULL;
170 server_list = NULL;
171 break;
172 case SERVER_SCAN_LAST:
173 break;
174 }
175}
176
177/**********************************************************************/
183 static struct srv_list *sdl_create_server_list(bool lan)
184{
185 struct srv_list *list = NULL;
186 int i;
187
188 if (lan) {
189 server_scan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);
190 } else {
191 server_scan = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);
192 }
193
194 if (!server_scan) {
195 return NULL;
196 }
197
198 SDL_Delay(5000);
199
200 for (i = 0; i < 100; i++) {
201 server_scan_poll(server_scan);
202 list = server_scan_get_list(server_scan);
203 if (list) {
204 break;
205 }
206 SDL_Delay(100);
207 }
208
209 return list;
210}
211
212/**********************************************************************/
215 void popup_connection_dialog(bool lan_scan)
216{
217 SDL_Color bg_color = {255, 255, 255, 128};
218 char cbuf[512];
219 int w = 0, h = 0, count = 0, meta_h;
220 struct widget *new_widget, *pwindow, *label_window;
221 utf8_str *pstr;
222 SDL_Surface *logo;
223 SDL_Rect area, area2;
224 struct srv_list *srvrs;
225
226 queue_flush();
227 close_connection_dialog();
228 meswin_dialog_popdown();
229
230 /* Text Label */
231 label_window = create_window_skeleton(NULL, NULL, 0);
232 add_to_gui_list(ID_WINDOW, label_window);
233
234 area = label_window->area;
235
236 fc_snprintf(cbuf, sizeof(cbuf), _("Creating Server List..."));
237 pstr = create_utf8_from_char_fonto(cbuf, FONTO_BIG);
238 pstr->style = TTF_STYLE_BOLD;
239 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
240 new_widget = create_iconlabel(NULL, label_window->dst, pstr,
241 (WF_RESTORE_BACKGROUND | WF_DRAW_TEXT_LABEL_WITH_SPACE));
242 add_to_gui_list(ID_LABEL, new_widget);
243
244 area.w = MAX(area.w, new_widget->size.w + (adj_size(60) -
245 (label_window->size.w - label_window->area.w)));
246 area.h += new_widget->size.h + (adj_size(30) -
247 (label_window->size.w - label_window->area.w));
248
249 resize_window(label_window, NULL, &bg_color,
250 (label_window->size.w - label_window->area.w) + area.w,
251 (label_window->size.h - label_window->area.h) + area.h);
252
253 area = label_window->area;
254
255 widget_set_position(label_window,
256 (main_window_width() - label_window->size.w) / 2,
257 (main_window_height() - label_window->size.h) / 2);
258
259 widget_set_area(new_widget, area);
260 widget_set_position(new_widget,
261 area.x + (area.w - new_widget->size.w) / 2,
262 area.y + (area.h - new_widget->size.h) / 2);
263
264 redraw_group(new_widget, label_window, TRUE);
265 flush_dirty();
266
267 /* Create server list */
268 srvrs = sdl_create_server_list(lan_scan);
269
270 /* Copy list */
271 server_list = server_list_new();
272 fc_mutex_allocate(&srvrs->mutex);
273 server_list_iterate(srvrs->servers, pserver) {
274 server_list_append(server_list, pserver);
275 } server_list_iterate_end;
276 fc_mutex_release(&srvrs->mutex);
277
278 /* Clear label */
279 popdown_window_group_dialog(new_widget, label_window);
280
281 meswin_dialog_popup(TRUE);
282
283 if (!server_list) {
284 if (lan_scan) {
285 output_window_append(ftc_client, _("No LAN servers found"));
286 } else {
287 output_window_append(ftc_client, _("No public servers found"));
288 }
289 set_client_page(PAGE_NETWORK);
290 return;
291 }
292
293 /* Server list window */
294 meta_server = fc_calloc(1, sizeof(struct advanced_dialog));
295
296 pwindow = create_window_skeleton(NULL, NULL, 0);
297 pwindow->action = meta_server_window_callback;
298 set_wstate(pwindow, FC_WS_NORMAL);
299 clear_wflag(pwindow, WF_DRAW_FRAME_AROUND_WIDGET);
300 if (lan_scan) {
301 add_to_gui_list(ID_LAN_SERVERS_WINDOW, pwindow);
302 } else {
303 add_to_gui_list(ID_META_SERVERS_WINDOW, pwindow);
304 }
305 meta_server->end_widget_list = pwindow;
306
307 /* Cancel button */
308 new_widget
309 = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
310 pwindow->dst, _("Cancel"),
311 FONTO_HEADING, 0);
312 new_widget->action = exit_meta_server_dlg_callback;
313 set_wstate(new_widget, FC_WS_NORMAL);
314 add_to_gui_list(ID_BUTTON, new_widget);
315
316 /* Servers */
317 server_list_iterate(server_list, server) {
318
319 /* TRANS: "host.example.com Port 5556 Ver: 3.1.0 Running Players 3\n
320 * [server message]" */
321 fc_snprintf(cbuf, sizeof(cbuf), _("%s Port %d Ver: %s %s %s %d\n%s"),
322 server->host, server->port, server->version, _(server->state),
323 Q_("?header:Players"), server->nplayers, server->message);
324
325 new_widget = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf,
326 FONTO_DEFAULT,
327 WF_FREE_STRING|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_RESTORE_BACKGROUND);
328
329 new_widget->string_utf8->style |= SF_CENTER;
330 new_widget->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
331
332 new_widget->action = select_meta_servers_callback;
333 set_wstate(new_widget, FC_WS_NORMAL);
334 new_widget->data.ptr = (void *)server;
335
336 add_to_gui_list(ID_BUTTON, new_widget);
337
338 w = MAX(w, new_widget->size.w);
339 h = MAX(h, new_widget->size.h);
340 count++;
341
342 if (count > 10) {
343 set_wflag(new_widget, WF_HIDDEN);
344 }
345
346 } server_list_iterate_end;
347
348 if (!count) {
349 if (lan_scan) {
350 output_window_append(ftc_client, _("No LAN servers found"));
351 } else {
352 output_window_append(ftc_client, _("No public servers found"));
353 }
354 set_client_page(PAGE_NETWORK);
355 return;
356 }
357
358 meta_server->begin_widget_list = new_widget;
359 meta_server->begin_active_widget_list = meta_server->begin_widget_list;
360 meta_server->end_active_widget_list = meta_server->end_widget_list->prev->prev;
361 meta_server->active_widget_list = meta_server->end_active_widget_list;
362
363 if (count > 10) {
364 meta_h = 10 * h;
365
366 count = create_vertical_scrollbar(meta_server, 1, 10, TRUE, TRUE);
367 w += count;
368 } else {
369 meta_h = count * h;
370 }
371
372 w += adj_size(20);
373 area2.h = meta_h;
374
375 meta_h += meta_server->end_widget_list->prev->size.h + adj_size(10) + adj_size(20);
376
377 logo = theme_get_background(active_theme, BACKGROUND_CONNECTDLG);
378 if (resize_window(pwindow, logo, NULL, w, meta_h)) {
379 FREESURFACE(logo);
380 }
381
382 area = pwindow->area;
383
384 widget_set_position(pwindow,
385 (main_window_width() - w) / 2,
386 (main_window_height() - meta_h) / 2);
387
388 w -= adj_size(20);
389
390 area2.w = w + 1;
391
392 if (meta_server->scroll) {
393 w -= count;
394 }
395
396 /* Exit button */
397 new_widget = pwindow->prev;
398 new_widget->size.x = area.x + area.w - new_widget->size.w - adj_size(10);
399 new_widget->size.y = area.y + area.h - new_widget->size.h - adj_size(10);
400
401 /* Meta labels */
402 new_widget = new_widget->prev;
403
404 new_widget->size.x = area.x + adj_size(10);
405 new_widget->size.y = area.y + adj_size(10);
406 new_widget->size.w = w;
407 new_widget->size.h = h;
408 new_widget = convert_iconlabel_to_themeiconlabel2(new_widget);
409
410 new_widget = new_widget->prev;
411
412 while (new_widget != NULL) {
413 new_widget->size.w = w;
414 new_widget->size.h = h;
415 new_widget->size.x = new_widget->next->size.x;
416 new_widget->size.y = new_widget->next->size.y + new_widget->next->size.h;
417 new_widget = convert_iconlabel_to_themeiconlabel2(new_widget);
418
419 if (new_widget == meta_server->begin_active_widget_list) {
420 break;
421 }
422 new_widget = new_widget->prev;
423 }
424
425 if (meta_server->scroll) {
426 setup_vertical_scrollbar_area(meta_server->scroll,
427 area.x + area.w - adj_size(6),
428 meta_server->end_active_widget_list->size.y,
429 area.h - adj_size(24) - pwindow->prev->size.h, TRUE);
430 }
431
432 /* -------------------- */
433 /* Redraw */
434
435 widget_redraw(pwindow);
436
437 area2.x = meta_server->end_active_widget_list->size.x;
438 area2.y = meta_server->end_active_widget_list->size.y;
439
440 fill_rect_alpha(pwindow->dst->surface, &area2, &bg_color);
441
442 create_frame(pwindow->dst->surface,
443 area2.x - 1, area2.y - 1, area2.w, area2.h,
444 get_theme_color(COLOR_THEME_CONNECTDLG_INNERFRAME));
445
446 redraw_group(meta_server->begin_widget_list, pwindow->prev, 0);
447
448 create_frame(pwindow->dst->surface,
449 pwindow->size.x, pwindow->size.y,
450 area.w - 1, area.h - 1,
451 get_theme_color(COLOR_THEME_CONNECTDLG_FRAME));
452
453 widget_flush(pwindow);
454}
455
456/**********************************************************************/
459 static int convert_playername_callback(struct widget *pwidget)
460{
461 if (PRESSED_EVENT(main_data.event)) {
462 if (pwidget->string_utf8->text != NULL) {
463 sz_strlcpy(user_name, pwidget->string_utf8->text);
464 } else {
465 /* empty input -> restore previous content */
466 copy_chars_to_utf8_str(pwidget->string_utf8, user_name);
467 widget_redraw(pwidget);
468 widget_mark_dirty(pwidget);
469 flush_dirty();
470 }
471 }
472
473 return -1;
474}
475
476/**********************************************************************/
479 static int convert_servername_callback(struct widget *pwidget)
480{
481 if (PRESSED_EVENT(main_data.event)) {
482 if (pwidget->string_utf8->text != NULL) {
483 sz_strlcpy(server_host, pwidget->string_utf8->text);
484 } else {
485 /* empty input -> restore previous content */
486 copy_chars_to_utf8_str(pwidget->string_utf8, server_host);
487 widget_redraw(pwidget);
488 widget_mark_dirty(pwidget);
489 flush_dirty();
490 }
491 }
492
493 return -1;
494}
495
496/**********************************************************************/
499 static int convert_portnr_callback(struct widget *pwidget)
500{
501 if (PRESSED_EVENT(main_data.event)) {
502 char port_str[6];
503
504 if (pwidget->string_utf8->text != NULL) {
505 sscanf(pwidget->string_utf8->text, "%d", &server_port);
506 } else {
507 /* empty input -> restore previous content */
508 fc_snprintf(port_str, sizeof(port_str), "%d", server_port);
509 copy_chars_to_utf8_str(pwidget->string_utf8, port_str);
510 widget_redraw(pwidget);
511 widget_mark_dirty(pwidget);
512 flush_dirty();
513 }
514 }
515
516 return -1;
517}
518
519/**********************************************************************/
522 static int cancel_connect_dlg_callback(struct widget *pwidget)
523{
524 if (PRESSED_EVENT(main_data.event)) {
525 close_connection_dialog();
526 set_client_page(PAGE_MAIN);
527 }
528
529 return -1;
530}
531
532/**********************************************************************/
535 void popup_join_game_dialog(void)
536{
537 char port_str[6];
538 struct widget *buf, *pwindow;
539 utf8_str *plrname = NULL;
540 utf8_str *srvname = NULL;
541 utf8_str *port_nr = NULL;
542 SDL_Surface *logo;
543 SDL_Rect area;
544 int start_x;
545 int pos_y;
546 int dialog_w, dialog_h;
547
548 queue_flush();
549 close_connection_dialog();
550
551 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
552
553 /* Window */
554 pwindow = create_window_skeleton(NULL, NULL, 0);
555 add_to_gui_list(ID_WINDOW, pwindow);
556 connect_dlg->end_widget_list = pwindow;
557
558 area = pwindow->area;
559
560 /* Player name label */
561 plrname = create_utf8_from_char_fonto(_("Player Name :"), FONTO_DEFAULT);
562 plrname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
563 buf = create_iconlabel(NULL, pwindow->dst, plrname,
564 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
565 add_to_gui_list(ID_LABEL, buf);
566 area.h += buf->size.h + adj_size(20);
567
568 /* Player name edit */
569 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, user_name,
570 FONTO_HEADING,
571 adj_size(210),
572 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
573 buf->action = convert_playername_callback;
574 set_wstate(buf, FC_WS_NORMAL);
575 add_to_gui_list(ID_PLAYER_NAME_EDIT, buf);
576 area.h += buf->size.h + adj_size(5);
577
578 /* Server name label */
579 srvname = create_utf8_from_char_fonto(_("Freeciv Server :"), FONTO_DEFAULT);
580 srvname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
581 buf = create_iconlabel(NULL, pwindow->dst, srvname,
582 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
583 add_to_gui_list(ID_LABEL, buf);
584 area.h += buf->size.h + adj_size(5);
585
586 /* Server name edit */
587 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, server_host,
588 FONTO_HEADING,
589 adj_size(210), WF_RESTORE_BACKGROUND);
590
591 buf->action = convert_servername_callback;
592 set_wstate(buf, FC_WS_NORMAL);
593 add_to_gui_list(ID_SERVER_NAME_EDIT, buf);
594 area.h += buf->size.h + adj_size(5);
595
596 /* Port label */
597 port_nr = create_utf8_from_char_fonto(_("Port :"), FONTO_DEFAULT);
598 port_nr->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT);
599 buf = create_iconlabel(NULL, pwindow->dst, port_nr,
600 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
601 add_to_gui_list(ID_LABEL, buf);
602 area.h += buf->size.h + adj_size(5);
603
604 /* Port edit */
605 fc_snprintf(port_str, sizeof(port_str), "%d", server_port);
606
607 buf = create_edit_from_chars_fonto(NULL, pwindow->dst, port_str,
608 FONTO_HEADING,
609 adj_size(210),
610 WF_RESTORE_BACKGROUND);
611
612 buf->action = convert_portnr_callback;
613 set_wstate(buf, FC_WS_NORMAL);
614 add_to_gui_list(ID_PORT_EDIT, buf);
615 area.h += buf->size.h + adj_size(20);
616
617 /* Connect button */
618 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
619 pwindow->dst,
620 _("Connect"),
621 FONTO_HEADING, 0);
622 buf->action = connect_callback;
623 set_wstate(buf, FC_WS_NORMAL);
624 buf->key = SDLK_RETURN;
625 add_to_gui_list(ID_CONNECT_BUTTON, buf);
626
627 /* Cancel button */
628 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
629 pwindow->dst, _("Cancel"),
630 FONTO_HEADING, 0);
631 buf->action = cancel_connect_dlg_callback;
632 set_wstate(buf, FC_WS_NORMAL);
633 buf->key = SDLK_ESCAPE;
634 add_to_gui_list(ID_CANCEL_BUTTON, buf);
635 buf->size.w = MAX(buf->size.w, buf->next->size.w);
636 buf->next->size.w = buf->size.w;
637 area.h += buf->size.h + adj_size(10);
638 /* ------------------------------ */
639
640 connect_dlg->begin_widget_list = buf;
641
642 dialog_w = MAX(adj_size(40) + buf->size.w * 2, adj_size(210)) + adj_size(80);
643
644#ifdef SMALL_SCREEN
645 dialog_h = area.h + (pwindow->size.h - pwindow->area.h);
646#else
647 dialog_h = area.h + (pwindow->size.h - pwindow->area.h);
648#endif
649
650 logo = theme_get_background(active_theme, BACKGROUND_JOINGAMEDLG);
651 if (resize_window(pwindow, logo, NULL, dialog_w, dialog_h)) {
652 FREESURFACE(logo);
653 }
654
655 area = pwindow->area;
656
657 widget_set_position(pwindow,
658 (main_window_width() - pwindow->size.w) / 2,
659 (main_window_height() - pwindow->size.h) / 2 + adj_size(40));
660
661 /* player name label */
662 buf = connect_dlg->end_widget_list->prev;
663
664 start_x = area.x + (area.w - buf->prev->size.w) / 2;
665 pos_y = area.y + adj_size(20);
666
667 buf->size.x = start_x + adj_size(5);
668 buf->size.y = pos_y;
669
670 pos_y += buf->size.h;
671
672 buf = buf->prev;
673 buf->size.x = start_x;
674 buf->size.y = pos_y;
675
676 pos_y += buf->size.h + adj_size(5);
677
678 /* server name label */
679 buf = buf->prev;
680 buf->size.x = start_x + adj_size(5);
681 buf->size.y = pos_y;
682
683 pos_y += buf->size.h;
684
685 /* server name edit */
686 buf = buf->prev;
687 buf->size.x = start_x;
688 buf->size.y = pos_y;
689
690 pos_y += buf->size.h + adj_size(5);
691
692 /* port label */
693 buf = buf->prev;
694 buf->size.x = start_x + adj_size(5);
695 buf->size.y = pos_y;
696
697 pos_y += buf->size.h;
698
699 /* port edit */
700 buf = buf->prev;
701 buf->size.x = start_x;
702 buf->size.y = pos_y;
703
704 pos_y += buf->size.h + adj_size(20);
705
706 /* connect button */
707 buf = buf->prev;
708 buf->size.x = area.x + (dialog_w - (adj_size(40) + buf->size.w * 2)) / 2;
709 buf->size.y = pos_y;
710
711 /* cancel button */
712 buf = buf->prev;
713 buf->size.x = buf->next->size.x + buf->size.w + adj_size(40);
714 buf->size.y = pos_y;
715
716 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
717 FALSE);
718
719 flush_all();
720}
721
722/**********************************************************************/
725 static int convert_passwd_callback(struct widget *pwidget)
726{
727 if (PRESSED_EVENT(main_data.event)) {
728 if (pwidget->string_utf8->text != NULL) {
729 fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
730 }
731 }
732
733 return -1;
734}
735
736/**********************************************************************/
739 static int send_passwd_callback(struct widget *pwidget)
740{
741 if (PRESSED_EVENT(main_data.event)) {
742 struct packet_authentication_reply reply;
743
744 sz_strlcpy(reply.password, fc_password);
745
746 memset(fc_password, 0, MAX_LEN_NAME);
747 fc_password[0] = '\0';
748
749 set_wstate(pwidget, FC_WS_DISABLED);
750
751 widget_redraw(pwidget);
752
753 widget_mark_dirty(pwidget);
754
755 flush_dirty();
756
757 send_packet_authentication_reply(&client.conn, &reply);
758 }
759
760 return -1;
761}
762
763/**********************************************************************/
766 static int cancel_passwd_callback(struct widget *pwidget)
767{
768 memset(fc_password, 0, MAX_LEN_NAME);
769 fc_password[0] = '\0';
770 disconnect_from_server(TRUE);
771
772 return cancel_connect_dlg_callback(pwidget);
773}
774
775/**********************************************************************/
778 static void popup_user_passwd_dialog(const char *message)
779{
780 struct widget *buf, *pwindow;
781 utf8_str *label_str = NULL;
782 SDL_Surface *background;
783 int start_x, start_y;
784 int start_button_y;
785 SDL_Rect area;
786
787 queue_flush();
788 close_connection_dialog();
789
790 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
791
792 pwindow = create_window_skeleton(NULL, NULL, 0);
793 add_to_gui_list(ID_WINDOW, pwindow);
794 connect_dlg->end_widget_list = pwindow;
795
796 area = pwindow->area;
797
798 /* Text label */
799 label_str = create_utf8_from_char_fonto(message, FONTO_ATTENTION);
800 label_str->fgcol = *get_theme_color(COLOR_THEME_USERPASSWDDLG_TEXT);
801 buf = create_iconlabel(NULL, pwindow->dst, label_str,
802 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
803 add_to_gui_list(ID_LABEL, buf);
804 area.h += adj_size(10) + buf->size.h + adj_size(5);
805
806 /* Password edit */
807 buf = create_edit(NULL, pwindow->dst,
808 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
809 adj_size(210),
810 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
811 buf->action = convert_passwd_callback;
812 set_wstate(buf, FC_WS_NORMAL);
813 add_to_gui_list(ID_EDIT, buf);
814 area.h += buf->size.h + adj_size(10);
815
816 /* Next button */
817 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
818 pwindow->dst,
819 _("Next"),
820 FONTO_HEADING, 0);
821 buf->action = send_passwd_callback;
822 set_wstate(buf, FC_WS_NORMAL);
823 buf->key = SDLK_RETURN;
824 add_to_gui_list(ID_BUTTON, buf);
825
826 /* Cancel button */
827 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
828 pwindow->dst,
829 _("Cancel"),
830 FONTO_HEADING, 0);
831 buf->action = cancel_passwd_callback;
832 set_wstate(buf, FC_WS_NORMAL);
833 buf->key = SDLK_ESCAPE;
834 add_to_gui_list(ID_CANCEL_BUTTON, buf);
835 buf->size.w = MAX(buf->size.w, buf->next->size.w);
836 buf->next->size.w = buf->size.w;
837 area.h += buf->size.h + adj_size(10);
838
839 /* ------------------------------ */
840
841 connect_dlg->begin_widget_list = buf;
842
843 area.w = MAX(area.w, buf->size.w * 2 + adj_size(40));
844 area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
845 area.w = MAX(area.w, pwindow->prev->size.w);
846 area.w += adj_size(80);
847
848 background = theme_get_background(active_theme, BACKGROUND_USERPASSWDDLG);
849 if (resize_window(pwindow, background, NULL,
850 (pwindow->size.w - pwindow->area.w) + area.w,
851 (pwindow->size.h - pwindow->area.h) + area.h)) {
852 FREESURFACE(background);
853 }
854
855 area = pwindow->area;
856
857 widget_set_position(pwindow,
858 (main_window_width() - pwindow->size.w) / 2,
859 (main_window_height() - pwindow->size.h) / 2);
860
861 /* Text label */
862 buf = connect_dlg->end_widget_list->prev;
863
864 start_x = area.x + (area.w - buf->size.w) / 2;
865 start_y = area.y + adj_size(10);
866
867 widget_set_area(buf, area);
868 widget_set_position(buf, start_x, start_y);
869
870 start_y += buf->size.h + adj_size(5);
871
872 /* Password edit */
873 buf = buf->prev;
874 start_x = area.x + (area.w - buf->size.w) / 2;
875
876 widget_set_area(buf, area);
877 widget_set_position(buf, start_x, start_y);
878
879 /* --------------------------------- */
880 start_button_y = buf->size.y + buf->size.h + adj_size(10);
881
882 /* connect button */
883 buf = buf->prev;
884 widget_set_area(buf, area);
885 widget_set_position(buf,
886 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
887 start_button_y);
888
889 /* cancel button */
890 buf = buf->prev;
891 widget_set_area(buf, area);
892 widget_set_position(buf,
893 buf->next->size.x + buf->size.w + adj_size(40),
894 start_button_y);
895
896 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
897 FALSE);
898
899 flush_all();
900}
901
902/**********************************************************************/
905 static int convert_first_passwd_callback(struct widget *pwidget)
906{
907 if (PRESSED_EVENT(main_data.event)) {
908 if (pwidget->string_utf8->text != NULL) {
909 fc_snprintf(fc_password, MAX_LEN_NAME, "%s", pwidget->string_utf8->text);
910 set_wstate(pwidget->prev, FC_WS_NORMAL);
911 widget_redraw(pwidget->prev);
912 widget_flush(pwidget->prev);
913 }
914 }
915
916 return -1;
917}
918
919/**********************************************************************/
922 static int convert_second_passwd_callback(struct widget *pwidget)
923{
924 if (PRESSED_EVENT(main_data.event)) {
925 if (pwidget->string_utf8->text != NULL
926 && !fc_strncmp(fc_password, pwidget->string_utf8->text,
927 MAX_LEN_NAME)) {
928 set_wstate(pwidget->prev, FC_WS_NORMAL); /* Next button */
929 widget_redraw(pwidget->prev);
930 widget_flush(pwidget->prev);
931 } else {
932 memset(fc_password, 0, MAX_LEN_NAME);
933 fc_password[0] = '\0';
934
935 FC_FREE(pwidget->next->string_utf8->text);/* First edit */
936 FC_FREE(pwidget->string_utf8->text); /* Second edit */
937
938 popup_new_user_passwd_dialog(_("Passwords don't match, enter password."));
939 }
940 }
941
942 return -1;
943}
944
945/**********************************************************************/
948 static void popup_new_user_passwd_dialog(const char *message)
949{
950 struct widget *buf, *pwindow;
951 utf8_str *label_str = NULL;
952 SDL_Surface *background;
953 int start_x, start_y;
954 int start_button_y;
955 SDL_Rect area;
956
957 queue_flush();
958 close_connection_dialog();
959
960 connect_dlg = fc_calloc(1, sizeof(struct small_dialog));
961
962 pwindow = create_window_skeleton(NULL, NULL, 0);
963 add_to_gui_list(ID_WINDOW, pwindow);
964 connect_dlg->end_widget_list = pwindow;
965
966 area = pwindow->area;
967
968 /* Text label */
969 label_str = create_utf8_from_char_fonto(message, FONTO_ATTENTION);
970 label_str->fgcol = *get_theme_color(COLOR_THEME_USERPASSWDDLG_TEXT);
971 buf = create_iconlabel(NULL, pwindow->dst, label_str,
972 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
973 add_to_gui_list(ID_LABEL, buf);
974 area.h += adj_size(10) + buf->size.h + adj_size(5);
975
976 /* Password edit */
977 buf = create_edit(NULL, pwindow->dst,
978 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
979 adj_size(210),
980 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
981 buf->action = convert_first_passwd_callback;
982 set_wstate(buf, FC_WS_NORMAL);
983 add_to_gui_list(ID_EDIT, buf);
984 area.h += buf->size.h + adj_size(5);
985
986 /* Second password edit */
987 buf = create_edit(NULL, pwindow->dst,
988 create_utf8_str_fonto(NULL, 0, FONTO_BIG),
989 adj_size(210),
990 (WF_PASSWD_EDIT|WF_RESTORE_BACKGROUND|WF_FREE_DATA));
991 buf->action = convert_second_passwd_callback;
992 add_to_gui_list(ID_EDIT, buf);
993 area.h += buf->size.h + adj_size(10);
994
995 /* Next button */
996 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
997 pwindow->dst,
998 _("Next"),
999 FONTO_HEADING, 0);
1000 buf->action = send_passwd_callback;
1001 buf->key = SDLK_RETURN;
1002 add_to_gui_list(ID_BUTTON, buf);
1003
1004 /* Cancel button */
1005 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
1006 pwindow->dst, _("Cancel"),
1007 FONTO_HEADING, 0);
1008 buf->action = cancel_passwd_callback;
1009 set_wstate(buf, FC_WS_NORMAL);
1010 buf->key = SDLK_ESCAPE;
1011 add_to_gui_list(ID_CANCEL_BUTTON, buf);
1012 buf->size.w = MAX(buf->size.w, buf->next->size.w);
1013 buf->next->size.w = buf->size.w;
1014 area.h += buf->size.h + adj_size(10);
1015
1016 /* ------------------------------ */
1017
1018 connect_dlg->begin_widget_list = buf;
1019
1020 area.w = buf->size.w * 2 + adj_size(40);
1021 area.w = MAX(area.w, adj_size(210) - (pwindow->size.w - pwindow->area.w));
1022 area.w = MAX(area.w, pwindow->prev->size.w);
1023 area.w += adj_size(80);
1024
1025 background = theme_get_background(active_theme, BACKGROUND_USERPASSWDDLG);
1026 if (resize_window(pwindow, background, NULL,
1027 (pwindow->size.w - pwindow->area.w) + area.w,
1028 (pwindow->size.h - pwindow->area.h) + area.h)) {
1029 FREESURFACE(background);
1030 }
1031
1032 area = pwindow->area;
1033
1034 widget_set_position(pwindow,
1035 (main_window_width() - pwindow->size.w) / 2,
1036 (main_window_height() - pwindow->size.h) / 2);
1037
1038 /* text label */
1039 buf = connect_dlg->end_widget_list->prev;
1040
1041 start_x = area.x + (area.w - buf->size.w) / 2;
1042 start_y = area.y + adj_size(10);
1043
1044 widget_set_area(buf, area);
1045 widget_set_position(buf, start_x, start_y);
1046
1047 start_y += buf->size.h + adj_size(5);
1048
1049 /* passwd edit */
1050 buf = buf->prev;
1051 start_x = area.x + (area.w - buf->size.w) / 2;
1052
1053 widget_set_area(buf, area);
1054 widget_set_position(buf, start_x, start_y);
1055
1056 start_y += buf->size.h + adj_size(5);
1057
1058 /* retype passwd */
1059 buf = buf->prev;
1060 widget_set_area(buf, area);
1061 widget_set_position(buf, start_x, start_y);
1062
1063 start_button_y = buf->size.y + buf->size.h + adj_size(10);
1064
1065 /* connect button */
1066 buf = buf->prev;
1067 widget_set_area(buf, area);
1068 widget_set_position(buf,
1069 area.x + (area.w - (adj_size(40) + buf->size.w * 2)) / 2,
1070 start_button_y);
1071
1072 /* cancel button */
1073 buf = buf->prev;
1074 widget_set_area(buf, area);
1075 widget_set_position(buf,
1076 buf->next->size.x + buf->size.w + adj_size(40),
1077 start_button_y);
1078
1079 redraw_group(connect_dlg->begin_widget_list, connect_dlg->end_widget_list,
1080 FALSE);
1081
1082 flush_all();
1083}
1084
1085/* ======================================================================== */
1086
1087/**********************************************************************/
1090 void close_connection_dialog(void)
1091{
1092 if (connect_dlg) {
1093 popdown_window_group_dialog(connect_dlg->begin_widget_list,
1094 connect_dlg->end_widget_list);
1095 FC_FREE(connect_dlg);
1096 }
1097 if (meta_server) {
1098 popdown_window_group_dialog(meta_server->begin_widget_list,
1099 meta_server->end_widget_list);
1100 FC_FREE(meta_server->scroll);
1101 FC_FREE(meta_server);
1102
1103 if (server_list) {
1104 server_scan_finish(server_scan);
1105 server_scan = NULL;
1106 server_list = NULL;
1107 }
1108 }
1109}
1110
1111/**********************************************************************/
1115 void handle_authentication_req(enum authentication_type type,
1116 const char *message)
1117{
1118 switch (type) {
1119 case AUTH_NEWUSER_FIRST:
1120 case AUTH_NEWUSER_RETRY:
1121 popup_new_user_passwd_dialog(message);
1122 return;
1123 case AUTH_LOGIN_FIRST:
1124 /* if we magically have a password already present in 'fc_password'
1125 * then, use that and skip the password entry dialog */
1126 if (fc_password[0] != '\0') {
1127 struct packet_authentication_reply reply;
1128
1129 sz_strlcpy(reply.password, fc_password);
1130 send_packet_authentication_reply(&client.conn, &reply);
1131
1132 return;
1133 } else {
1134 popup_user_passwd_dialog(message);
1135 }
1136
1137 return;
1138 case AUTH_LOGIN_RETRY:
1139 popup_user_passwd_dialog(message);
1140
1141 return;
1142 }
1143
1144 log_error("Not supported authentication type %d: %s.", type, message);
1145}
1146
1147/**********************************************************************/
1151 void server_connect(void)
1152{
1153}
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