Freeciv-3.1
Loading...
Searching...
No Matches
dialogs.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 dialogs.c - description
16 -------------------
17 begin : Wed Jul 24 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/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "astring.h"
35#include "bitvector.h"
36#include "fcintl.h"
37#include "log.h"
38#include "rand.h"
39
40/* common */
41#include "combat.h"
42#include "game.h"
43#include "government.h"
44#include "movement.h"
45#include "unitlist.h"
46
47/* client */
48#include "client_main.h"
49#include "climap.h" /* for client_tile_get_known() */
50#include "goto.h"
51#include "helpdata.h" /* for helptext_nation() */
52#include "packhand.h"
53#include "text.h"
54#include "zoom.h"
55
56/* gui-sdl2 */
57#include "chatline.h"
58#include "citydlg.h"
59#include "cityrep.h"
60#include "cma_fe.h"
61#include "colors.h"
62#include "finddlg.h"
63#include "gotodlg.h"
64#include "graphics.h"
65#include "gui_id.h"
66#include "gui_main.h"
67#include "gui_tilespec.h"
68#include "helpdlg.h"
69#include "inteldlg.h"
70#include "mapctrl.h"
71#include "mapview.h"
72#include "menu.h"
73#include "messagewin.h"
74#include "optiondlg.h"
75#include "plrdlg.h"
76#include "ratesdlg.h"
77#include "repodlgs.h"
78#include "sprite.h"
79#include "themespec.h"
80#include "widget.h"
81#include "wldlg.h"
82
83#include "dialogs.h"
84
86
87extern bool is_unit_move_blocked;
88extern void popdown_diplomat_dialog(void);
89extern void popdown_incite_dialog(void);
90extern void popdown_bribe_dialog(void);
91
95
96static char *leader_name = NULL;
97
98static void unit_select_dialog_popdown(void);
99static void popdown_terrain_info_dialog(void);
100static void popdown_pillage_dialog(void);
101static void popdown_connect_dialog(void);
102static void popdown_unit_upgrade_dlg(void);
103static void popdown_unit_disband_dlg(void);
104
105/**********************************************************************/
108void put_window_near_map_tile(struct widget *pwindow,
109 int window_width, int window_height,
110 struct tile *ptile)
111{
112 float canvas_x, canvas_y;
113 int window_x = 0, window_y = 0;
114
116 if (canvas_x + tileset_tile_width(tileset) + window_width >= main_window_width()) {
117 if (canvas_x - window_width < 0) {
118 window_x = (main_window_width() - window_width) / 2;
119 } else {
120 window_x = canvas_x - window_width;
121 }
122 } else {
123 window_x = canvas_x + tileset_tile_width(tileset);
124 }
125
126 canvas_y += (tileset_tile_height(tileset) - window_height) / 2;
127 if (canvas_y + window_height >= main_window_height()) {
128 window_y = main_window_height() - window_height - 1;
129 } else {
130 if (canvas_y < 0) {
131 window_y = 0;
132 } else {
133 window_y = canvas_y;
134 }
135 }
136 } else {
137 window_x = (main_window_width() - window_width) / 2;
138 window_y = (main_window_height() - window_height) / 2;
139 }
140
141 widget_set_position(pwindow, window_x, window_y);
142}
143
144/**********************************************************************/
183
184/* ======================================================================= */
185
186/**********************************************************************/
191static bool sdl_get_chance_to_win(int *att_chance, int *def_chance,
192 struct unit *enemy_unit,
193 struct unit *my_unit)
194{
195 if (!my_unit || !enemy_unit) {
196 return FALSE;
197 }
198
199 /* Chance to win when active unit is attacking the selected unit */
200 *att_chance = unit_win_chance(&(wld.map), my_unit, enemy_unit) * 100;
201
202 /* Chance to win when selected unit is attacking the active unit */
203 *def_chance = (1.0 - unit_win_chance(&(wld.map), enemy_unit, my_unit)) * 100;
204
205 return TRUE;
206}
207
208/**************************************************************************
209 Notify goto dialog.
210**************************************************************************/
212 char *headline;
213 char *lines;
214 struct tile *ptile;
215};
216
217#define SPECLIST_TAG notify_goto
218#define SPECLIST_TYPE struct notify_goto_data
219#include "speclist.h"
220
222 struct widget *window;
224 struct widget *label;
225 struct notify_goto_list *datas;
226};
227
229
230static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog);
231
232/**********************************************************************/
236 const char *lines,
237 struct tile *ptile)
238{
239 struct notify_goto_data *pdata = fc_malloc(sizeof(*pdata));
240
241 pdata->headline = fc_strdup(headline);
242 pdata->lines = fc_strdup(lines);
243 pdata->ptile = ptile;
244
245 return pdata;
246}
247
248/**********************************************************************/
252{
253 free(pdata->headline);
254 free(pdata->lines);
255}
256
257/**********************************************************************/
261{
262 struct notify_goto_dialog *pdialog =
263 (struct notify_goto_dialog *) widget->data.ptr;
264
266 move_window_group(pdialog->label, pdialog->window);
267 }
268
269 return -1;
270}
271
272/**********************************************************************/
276{
277 struct notify_goto_dialog *pdialog =
278 (struct notify_goto_dialog *) widget->data.ptr;
279
282 }
283
284 return -1;
285}
286
287/**********************************************************************/
291{
292 struct notify_goto_dialog *pdialog =
293 (struct notify_goto_dialog *) widget->data.ptr;
294 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
295 0);
296
298 if (NULL != pdata->ptile) {
300 }
301 } else if (main_data.event.button.button == SDL_BUTTON_RIGHT) {
302 struct city *pcity;
303
304 if (NULL != pdata->ptile && (pcity = tile_city(pdata->ptile))) {
305 popup_city_dialog(pcity);
306 }
307 }
308
309 return -1;
310}
311
312/**********************************************************************/
316{
317 struct notify_goto_dialog *pdialog = fc_malloc(sizeof(*pdialog));
318 utf8_str *str;
319
320 /* Window. */
322 str->style |= TTF_STYLE_BOLD;
323
324 pdialog->window = create_window_skeleton(NULL, str, 0);
326 pdialog->window->data.ptr = pdialog;
327 set_wstate(pdialog->window, FC_WS_NORMAL);
329
330 /* Close button. */
331 pdialog->close_button = create_themeicon(current_theme->small_cancel_icon,
332 pdialog->window->dst,
335 pdialog->close_button->info_label
336 = create_utf8_from_char_fonto(_("Close Dialog (Esc)"), FONTO_ATTENTION);
338 pdialog->close_button->data.ptr = pdialog;
340 pdialog->close_button->key = SDLK_ESCAPE;
342
343 pdialog->label = NULL;
344
345 /* Data list. */
346 pdialog->datas = notify_goto_list_new_full(notify_goto_data_destroy);
347
348 return pdialog;
349}
350
351/**********************************************************************/
355{
356 widget_undraw(pdialog->window);
357 widget_mark_dirty(pdialog->window);
358 remove_gui_layer(pdialog->window->dst);
359
362 if (NULL != pdialog->label) {
364 }
365
366 notify_goto_list_destroy(pdialog->datas);
367 free(pdialog);
368}
369
370/**********************************************************************/
374{
375 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
376 0);
377
378 if (NULL == pdata) {
379 return;
380 }
381
382 widget_undraw(pdialog->window);
383 widget_mark_dirty(pdialog->window);
384
386 if (NULL != pdialog->label) {
388 }
389 pdialog->label = create_iconlabel_from_chars_fonto(NULL, pdialog->window->dst,
390 pdata->lines,
394 pdialog->label->data.ptr = pdialog;
395 set_wstate(pdialog->label, FC_WS_NORMAL);
396 add_to_gui_list(ID_LABEL, pdialog->label);
397
398 resize_window(pdialog->window, NULL, NULL,
399 adj_size(pdialog->label->size.w + 40),
400 adj_size(pdialog->label->size.h + 60));
402 (main_window_width() - pdialog->window->size.w) / 2,
403 (main_window_height() - pdialog->window->size.h) / 2);
404 widget_set_position(pdialog->close_button, pdialog->window->size.w
405 - pdialog->close_button->size.w - 1,
406 pdialog->window->size.y + adj_size(2));
407 widget_set_position(pdialog->label, adj_size(20), adj_size(40));
408
409 widget_redraw(pdialog->window);
410 widget_redraw(pdialog->close_button);
411 widget_redraw(pdialog->label);
412 widget_mark_dirty(pdialog->window);
413 flush_all();
414}
415
416/**********************************************************************/
420{
421 if (1 < notify_goto_list_size(pdialog->datas)) {
422 notify_goto_list_remove(pdialog->datas,
423 notify_goto_list_get(pdialog->datas, 0));
425 } else {
427 if (pdialog == notify_goto_dialog) {
428 notify_goto_dialog = NULL;
429 }
430 }
431}
432
433/**********************************************************************/
438void popup_notify_goto_dialog(const char *headline, const char *lines,
439 const struct text_tag_list *tags,
440 struct tile *ptile)
441{
442 if (NULL == notify_goto_dialog) {
444 }
445
447
448 notify_goto_list_prepend(notify_goto_dialog->datas,
451}
452
453/**********************************************************************/
463
464/**********************************************************************/
467void popup_connect_msg(const char *headline, const char *message)
468{
469 log_error("popup_connect_msg() PORT ME");
470}
471
472/* ----------------------------------------------------------------------- */
474
475/**********************************************************************/
478static int notify_dialog_window_callback(struct widget *pwindow)
479{
482 }
483
484 return -1;
485}
486
487/**********************************************************************/
490static int exit_notify_dialog_callback(struct widget *pwidget)
491{
493 if (notify_dlg) {
498 flush_dirty();
499 }
500 }
501
502 return -1;
503}
504
505/**********************************************************************/
508void popup_notify_dialog(const char *caption, const char *headline,
509 const char *lines)
510{
511 struct widget *buf, *pwindow;
512 utf8_str *pstr;
516
517 if (notify_dlg) {
518 return;
519 }
520
521 notify_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
522
524 pstr->style |= TTF_STYLE_BOLD;
525
526 pwindow = create_window_skeleton(NULL, pstr, 0);
527
529 set_wstate(pwindow, FC_WS_NORMAL);
530
531 add_to_gui_list(ID_WINDOW, pwindow);
532 notify_dlg->end_widget_list = pwindow;
533
534 area = pwindow->area;
535
536 /* ---------- */
537 /* Create exit button */
538 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
540 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
544 buf->key = SDLK_ESCAPE;
545 area.w += (buf->size.w + adj_size(10));
546
549
551 pstr->style |= TTF_STYLE_BOLD;
552
554
555 if (lines && *lines != '\0') {
557 pstr->style &= ~TTF_STYLE_BOLD;
560 } else {
562 }
563
565
566 area.w = MAX(area.w, headline_surf->w);
567 if (lines_surf) {
568 area.w = MAX(area.w, lines_surf->w);
569 }
570 area.w += adj_size(60);
571 area.h = MAX(area.h, adj_size(10) + headline_surf->h + adj_size(10));
572 if (lines_surf) {
573 area.h += lines_surf->h + adj_size(10);
574 }
575
577 (pwindow->size.w - pwindow->area.w) + area.w,
578 (pwindow->size.h - pwindow->area.h) + area.h);
579
580 area = pwindow->area;
581
582 widget_set_position(pwindow,
583 (main_window_width() - pwindow->size.w) / 2,
584 (main_window_height() - pwindow->size.h) / 2);
585
586 dst.x = area.x + (area.w - headline_surf->w) / 2;
587 dst.y = area.y + adj_size(10);
588
589 alphablit(headline_surf, NULL, pwindow->theme, &dst, 255);
590 if (lines_surf) {
591 dst.y += headline_surf->h + adj_size(10);
592 if (headline_surf->w < lines_surf->w) {
593 dst.x = area.x + (area.w - lines_surf->w) / 2;
594 }
595
596 alphablit(lines_surf, NULL, pwindow->theme, &dst, 255);
597 }
598
601
602 /* exit button */
603 buf = pwindow->prev;
604 buf->size.x = area.x + area.w - buf->size.w - 1;
605 buf->size.y = pwindow->size.y + adj_size(2);
606
607 /* redraw */
609 widget_flush(pwindow);
610}
611
612/* =======================================================================*/
613/* ========================= UNIT UPGRADE DIALOG =========================*/
614/* =======================================================================*/
615static struct small_dialog *unit_upgrade_dlg = NULL;
616
617/**********************************************************************/
620static int upgrade_unit_window_callback(struct widget *pwindow)
621{
624 }
625
626 return -1;
627}
628
629/**********************************************************************/
632static int cancel_upgrade_unit_callback(struct widget *pwidget)
633{
636 /* enable city dlg */
638 flush_dirty();
639 }
640
641 return -1;
642}
643
644/**********************************************************************/
647static int ok_upgrade_unit_window_callback(struct widget *pwidget)
648{
650 struct unit *punit = pwidget->data.unit;
651
653 /* enable city dlg */
657 flush_dirty();
658 }
659
660 return -1;
661}
662
663/***********************************************************************/
666void popup_upgrade_dialog(struct unit_list *punits)
667{
668 /* PORTME: is support for more than one unit in punits required? */
669
670 /* Assume only one unit for now. */
671 fc_assert_msg(unit_list_size(punits) <= 1,
672 "SDL2 popup_upgrade_dialog() handles max 1 unit.");
673
674 popup_unit_upgrade_dlg(unit_list_get(punits, 0), FALSE);
675}
676
677/**********************************************************************/
681{
682 char cbuf[128];
683 struct widget *buf = NULL, *pwindow;
684 utf8_str *pstr;
685 SDL_Surface *text;
687 int window_x = 0, window_y = 0;
690
691 if (unit_upgrade_dlg) {
692 /* just in case */
693 flush_dirty();
694 return;
695 }
696
697 unit_upgrade_dlg = fc_calloc(1, sizeof(struct small_dialog));
698
700
701 pstr = create_utf8_from_char_fonto(_("Upgrade Obsolete Units"),
703 pstr->style |= TTF_STYLE_BOLD;
704
705 pwindow = create_window_skeleton(NULL, pstr, 0);
706
707 pwindow->action = upgrade_unit_window_callback;
708 set_wstate(pwindow, FC_WS_NORMAL);
709
711
712 add_to_gui_list(ID_WINDOW, pwindow);
713
714 area = pwindow->area;
715
716 /* ============================================================= */
717
718 /* Create text label */
720 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
722
725
726 area.w = MAX(area.w, text->w + adj_size(20));
727 area.h += (text->h + adj_size(10));
728
729 /* Cancel button */
731 pwindow->dst, _("Cancel"),
732 FONTO_ATTENTION, 0);
733
736
737 area.h += (buf->size.h + adj_size(20));
738
740
741 if (UU_OK == unit_upgrade_result) {
743 pwindow->dst,
744 _("Upgrade"),
745 FONTO_ATTENTION, 0);
746
749 buf->data.unit = punit;
751 buf->size.w = MAX(buf->size.w, buf->next->size.w);
752 buf->next->size.w = buf->size.w;
753 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
754 } else {
755 area.w = MAX(area.w, buf->size.w + adj_size(20));
756 }
757 /* ============================================ */
758
760
762 (pwindow->size.w - pwindow->area.w) + area.w,
763 (pwindow->size.h - pwindow->area.h) + area.h);
764
765 area = pwindow->area;
766
767 if (city) {
768 window_x = main_data.event.motion.x;
769 window_y = main_data.event.motion.y;
770 } else {
771 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
773 }
774
776
777 /* setup rest of widgets */
778 /* label */
779 dst.x = area.x + (area.w - text->w) / 2;
780 dst.y = area.y + adj_size(10);
781 alphablit(text, NULL, pwindow->theme, &dst, 255);
782 FREESURFACE(text);
783
784 /* cancel button */
785 buf = pwindow->prev;
786 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
787
788 if (UU_OK == unit_upgrade_result) {
789 /* upgrade button */
790 buf = buf->prev;
791 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
792 buf->size.y = buf->next->size.y;
793
794 /* cancel button */
795 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
796 } else {
797 /* x position of cancel button */
798 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
799 }
800
801 /* ================================================== */
802 /* redraw */
804
805 widget_mark_dirty(pwindow);
806 flush_dirty();
807}
808
809/**********************************************************************/
820
821/* =======================================================================*/
822/* ========================= UNIT DISBAND DIALOG =========================*/
823/* =======================================================================*/
824static struct small_dialog *unit_disband_dlg = NULL;
825
826/**********************************************************************/
829static int disband_unit_window_callback(struct widget *pwindow)
830{
833 }
834
835 return -1;
836}
837
838/**********************************************************************/
841static int cancel_disband_unit_callback(struct widget *pwidget)
842{
845 /* enable city dlg */
847 flush_dirty();
848 }
849
850 return -1;
851}
852
853/**********************************************************************/
856static int ok_disband_unit_window_callback(struct widget *pwidget)
857{
859 struct unit *punit = pwidget->data.unit;
860
862 /* enable city dlg */
866 flush_dirty();
867 }
868
869 return -1;
870}
871
872/**********************************************************************/
876{
877 char cbuf[128];
878 struct widget *buf = NULL, *pwindow;
879 utf8_str *pstr;
880 SDL_Surface *text;
882 int window_x = 0, window_y = 0;
885
886 if (unit_disband_dlg) {
887 /* just in case */
888 flush_dirty();
889 return;
890 }
891
892 unit_disband_dlg = fc_calloc(1, sizeof(struct small_dialog));
893
894 {
895 struct unit_list *punits = unit_list_new();
896
897 unit_list_append(punits, punit);
898 unit_disband_result = get_units_disband_info(cbuf, sizeof(cbuf), punits);
899 unit_list_destroy(punits);
900 }
901
902 pstr = create_utf8_from_char_fonto(_("Disband Units"), FONTO_ATTENTION);
903 pstr->style |= TTF_STYLE_BOLD;
904
905 pwindow = create_window_skeleton(NULL, pstr, 0);
906
907 pwindow->action = disband_unit_window_callback;
908 set_wstate(pwindow, FC_WS_NORMAL);
909
911
912 add_to_gui_list(ID_WINDOW, pwindow);
913
914 area = pwindow->area;
915
916 /* ============================================================= */
917
918 /* Create text label */
920 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
922
923 text = create_text_surf_from_utf8(pstr);
924 FREEUTF8STR(pstr);
925
926 area.w = MAX(area.w, text->w + adj_size(20));
927 area.h += (text->h + adj_size(10));
928
929 /* Cancel button */
931 pwindow->dst, _("Cancel"),
932 FONTO_ATTENTION, 0);
933
936
937 area.h += (buf->size.h + adj_size(20));
938
940
941 if (unit_disband_result) {
943 pwindow->dst,
944 _("Disband"),
945 FONTO_ATTENTION, 0);
946
949 buf->data.unit = punit;
951 buf->size.w = MAX(buf->size.w, buf->next->size.w);
952 buf->next->size.w = buf->size.w;
953 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
954 } else {
955 area.w = MAX(area.w, buf->size.w + adj_size(20));
956 }
957 /* ============================================ */
958
960
962 (pwindow->size.w - pwindow->area.w) + area.w,
963 (pwindow->size.h - pwindow->area.h) + area.h);
964
965 area = pwindow->area;
966
967 if (city) {
968 window_x = main_data.event.motion.x;
969 window_y = main_data.event.motion.y;
970 } else {
971 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
973 }
974
975 widget_set_position(pwindow, window_x, window_y);
976
977 /* setup rest of widgets */
978 /* label */
979 dst.x = area.x + (area.w - text->w) / 2;
980 dst.y = area.y + adj_size(10);
981 alphablit(text, NULL, pwindow->theme, &dst, 255);
982 FREESURFACE(text);
983
984 /* cancel button */
985 buf = pwindow->prev;
986 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
987
988 if (unit_disband_result) {
989 /* disband button */
990 buf = buf->prev;
991 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
992 buf->size.y = buf->next->size.y;
993
994 /* cancel button */
995 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
996 } else {
997 /* x position of cancel button */
998 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
999 }
1000
1001 /* ================================================== */
1002 /* redraw */
1004
1005 widget_mark_dirty(pwindow);
1006 flush_dirty();
1007}
1008
1009/**********************************************************************/
1020
1021/* =======================================================================*/
1022/* ======================== UNIT SELECTION DIALOG ========================*/
1023/* =======================================================================*/
1024static struct advanced_dialog *unit_select_dlg = NULL;
1025
1026/**********************************************************************/
1029static int unit_select_window_callback(struct widget *pwindow)
1030{
1033 }
1034
1035 return -1;
1036}
1037
1038/**********************************************************************/
1041static int exit_unit_select_callback(struct widget *pwidget)
1042{
1046 }
1047
1048 return -1;
1049}
1050
1051/**********************************************************************/
1054static int unit_select_callback(struct widget *pwidget)
1055{
1057 struct unit *punit =
1059
1061 if (punit) {
1062 request_new_unit_activity(punit, ACTIVITY_IDLE);
1064 }
1065 }
1066
1067 return -1;
1068}
1069
1070/**********************************************************************/
1085
1086/**********************************************************************/
1090{
1091 struct widget *buf = NULL, *pwindow;
1092 utf8_str *pstr;
1093 struct unit *punit = NULL, *focus = head_of_units_in_focus();
1094 const struct unit_type *punittype;
1095 char cbuf[255];
1096 int i, w = 0, n;
1097 SDL_Rect area;
1098
1099#define NUM_SEEN 20
1100
1101 n = unit_list_size(ptile->units);
1102
1103 if (n == 0 || unit_select_dlg) {
1104 return;
1105 }
1106
1108 unit_select_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1109
1110 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Unit selection"), n);
1112 pstr->style |= TTF_STYLE_BOLD;
1113
1114 pwindow = create_window_skeleton(NULL, pstr, 0);
1115
1116 pwindow->action = unit_select_window_callback;
1117 set_wstate(pwindow, FC_WS_NORMAL);
1118
1121
1122 area = pwindow->area;
1123
1124 /* ---------- */
1125 /* Create exit button */
1126 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1128 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1132 buf->key = SDLK_ESCAPE;
1133 area.w += (buf->size.w + adj_size(10));
1134
1136
1137 /* ---------- */
1138
1139 for (i = 0; i < n; i++) {
1140 const char *vetname;
1141
1142 punit = unit_list_get(ptile->units, i);
1143 punittype = unit_type_get(punit);
1144 vetname = utype_veteran_name_translation(punittype, punit->veteran);
1145
1147 struct astring addition = ASTRING_INIT;
1148
1149 unit_activity_astr(punit, &addition);
1150 fc_snprintf(cbuf , sizeof(cbuf), _("Contact %s (%d / %d) %s(%d,%d,%s) %s"),
1151 (vetname != NULL ? vetname : ""),
1152 punit->hp, punittype->hp,
1153 utype_name_translation(punittype),
1154 punittype->attack_strength,
1155 punittype->defense_strength,
1156 move_points_text(punittype->move_rate, FALSE),
1157 astr_str(&addition));
1158 astr_free(&addition);
1159 } else {
1160 int att_chance, def_chance;
1161
1162 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1164 (vetname != NULL ? vetname : ""),
1165 utype_name_translation(punittype),
1166 punittype->attack_strength,
1167 punittype->defense_strength,
1168 move_points_text(punittype->move_rate, FALSE),
1169 punittype->firepower,
1170 (punit->hp * 100 / punittype->hp + 9) / 10);
1171
1172 /* Calculate chance to win */
1173 if (sdl_get_chance_to_win(&att_chance, &def_chance, punit, focus)) {
1174 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1175 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1176 att_chance, def_chance);
1177 }
1178 }
1179
1180 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf,
1182
1183 add_to_gui_list(MAX_ID - punit->id , buf);
1184
1185 area.w = MAX(area.w, buf->size.w);
1186 area.h += buf->size.h;
1189 }
1190
1191 if (i > NUM_SEEN - 1) {
1192 set_wflag(buf , WF_HIDDEN);
1193 }
1194 }
1195
1200
1201 area.w += adj_size(2);
1202 if (n > NUM_SEEN) {
1204 area.w += n;
1205
1206 /* ------- window ------- */
1207 area.h = NUM_SEEN * pwindow->prev->prev->size.h;
1208 }
1209
1210 resize_window(pwindow, NULL, NULL,
1211 (pwindow->size.w - pwindow->area.w) + area.w,
1212 (pwindow->size.h - pwindow->area.h) + area.h);
1213
1214 area = pwindow->area;
1215
1216 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1217 ptile);
1218
1219 w = area.w;
1220
1221 if (unit_select_dlg->scroll) {
1222 w -= n;
1223 }
1224
1225 /* exit button */
1226 buf = pwindow->prev;
1227 buf->size.x = area.x + area.w - buf->size.w - 1;
1228 buf->size.y = pwindow->size.y + adj_size(2);
1229 buf = buf->prev;
1230
1231 setup_vertical_widgets_position(1, area.x + 1, area.y, w, 0,
1233 buf);
1234
1235 if (unit_select_dlg->scroll) {
1237 area.x + area.w, area.y,
1238 area.h, TRUE);
1239 }
1240
1241 /* ==================================================== */
1242 /* redraw */
1244
1245 widget_flush(pwindow);
1246}
1247
1248/**********************************************************************/
1252{
1253 /* PORTME */
1254}
1255
1256/* ====================================================================== */
1257/* ============================ TERRAIN INFO ============================ */
1258/* ====================================================================== */
1259static struct small_dialog *terrain_info_dlg = NULL;
1260
1261
1262/**********************************************************************/
1265static int terrain_info_window_dlg_callback(struct widget *pwindow)
1266{
1269 }
1270
1271 return -1;
1272}
1273
1274/**********************************************************************/
1286
1287/**********************************************************************/
1291{
1294 }
1295
1296 return -1;
1297}
1298
1299/**********************************************************************/
1303const char *sdl_get_tile_defense_info_text(struct tile *ptile)
1304{
1305 static char buffer[64];
1306 int bonus = (tile_terrain(ptile)->defense_bonus - 10) * 10;
1307
1308 extra_type_iterate(pextra) {
1309 if (tile_has_extra(ptile, pextra)
1310 && pextra->category == ECAT_NATURAL) {
1311 bonus += pextra->defense_bonus;
1312 }
1314
1315 fc_snprintf(buffer, sizeof(buffer), _("Terrain Defense Bonus: +%d%% "), bonus);
1316
1317 return buffer;
1318}
1319
1320/**********************************************************************/
1323static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
1324{
1325 SDL_Surface *surf;
1326 struct widget *buf, *pwindow;
1327 utf8_str *pstr;
1328 char cbuf[256];
1329 SDL_Rect area;
1330
1331 if (terrain_info_dlg) {
1332 flush_dirty();
1333 return;
1334 }
1335
1336 surf = get_terrain_surface(ptile);
1337 terrain_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1338
1339 /* ----------- */
1340 fc_snprintf(cbuf, sizeof(cbuf), "%s [%d,%d]", _("Terrain Info"),
1341 TILE_XY(ptile));
1342
1343 pwindow
1346 0);
1347 pwindow->string_utf8->style |= TTF_STYLE_BOLD;
1348
1350 set_wstate(pwindow, FC_WS_NORMAL);
1351
1354
1355 area = pwindow->area;
1356
1357 /* ---------- */
1360 pstr->style |= SF_CENTER;
1361 buf = create_iconlabel(surf, pwindow->dst, pstr, 0);
1362
1363 buf->size.h += tileset_tile_height(tileset) / 2;
1364
1366
1367 /* ------ window ---------- */
1368 area.w = MAX(area.w, buf->size.w + adj_size(20));
1369 area.h = MAX(area.h, buf->size.h);
1370
1372 (pwindow->size.w - pwindow->area.w) + area.w,
1373 (pwindow->size.h - pwindow->area.h) + area.h);
1374
1375 area = pwindow->area;
1376
1377 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, ptile);
1378
1379 /* ------------------------ */
1380
1381 buf->size.x = area.x + adj_size(10);
1382 buf->size.y = area.y;
1383
1384 /* Exit icon */
1385 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1387 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1389 buf->size.x = area.x + area.w - buf->size.w - 1;
1390 buf->size.y = pwindow->size.y + adj_size(2);
1393 buf->key = SDLK_ESCAPE;
1394
1396
1398 /* --------------------------------- */
1399 /* redraw */
1401 widget_mark_dirty(pwindow);
1402 flush_dirty();
1403}
1404
1405/* ====================================================================== */
1406/* ========================= ADVANCED_TERRAIN_MENU ====================== */
1407/* ====================================================================== */
1409
1410/**********************************************************************/
1425
1426/**********************************************************************/
1430{
1433 }
1434
1435 return -1;
1436}
1437
1438/**********************************************************************/
1442{
1445 flush_dirty();
1446 }
1447
1448 return -1;
1449}
1450
1451/**********************************************************************/
1454static int terrain_info_callback(struct widget *pwidget)
1455{
1457 int x = pwidget->data.cont->id0;
1458 int y = pwidget->data.cont->id1;
1459
1461
1463 }
1464
1465 return -1;
1466}
1467
1468/**********************************************************************/
1471static int zoom_to_city_callback(struct widget *pwidget)
1472{
1474 struct city *pcity = pwidget->data.city;
1475
1477
1478 popup_city_dialog(pcity);
1479 }
1480
1481 return -1;
1482}
1483
1484/**********************************************************************/
1487static int change_production_callback(struct widget *pwidget)
1488{
1490 struct city *pcity = pwidget->data.city;
1491
1493 popup_worklist_editor(pcity, NULL);
1494 }
1495
1496 return -1;
1497}
1498
1499/**********************************************************************/
1502static int hurry_production_callback(struct widget *pwidget)
1503{
1505 struct city *pcity = pwidget->data.city;
1506
1508
1509 popup_hurry_production_dialog(pcity, NULL);
1510 }
1511
1512 return -1;
1513}
1514
1515/**********************************************************************/
1518static int cma_callback(struct widget *pwidget)
1519{
1521 struct city *pcity = pwidget->data.city;
1522
1524 popup_city_cma_dialog(pcity);
1525 }
1526
1527 return -1;
1528}
1529
1530/**********************************************************************/
1533static int adv_unit_select_callback(struct widget *pwidget)
1534{
1536 struct unit *punit = pwidget->data.unit;
1537
1539
1540 if (punit) {
1541 request_new_unit_activity(punit, ACTIVITY_IDLE);
1543 }
1544 }
1545
1546 return -1;
1547}
1548
1549/**********************************************************************/
1552static int adv_unit_select_all_callback(struct widget *pwidget)
1553{
1555 struct unit *punit = pwidget->data.unit;
1556
1558
1559 if (punit) {
1561 }
1562 }
1563
1564 return -1;
1565}
1566
1567/**********************************************************************/
1570static int adv_unit_sentry_idle_callback(struct widget *pwidget)
1571{
1573 struct unit *punit = pwidget->data.unit;
1574
1576
1577 if (punit) {
1578 struct tile *ptile = unit_tile(punit);
1579
1580 unit_list_iterate(ptile->units, other_unit) {
1581 if (unit_owner(other_unit) == client.conn.playing
1582 && ACTIVITY_IDLE == other_unit->activity
1583 && other_unit->ssa_controller == SSA_NONE
1584 && can_unit_do_activity_client(other_unit, ACTIVITY_SENTRY)) {
1585 request_new_unit_activity(other_unit, ACTIVITY_SENTRY);
1586 }
1588 }
1589 }
1590
1591 return -1;
1592}
1593
1594/**********************************************************************/
1597static int goto_here_callback(struct widget *pwidget)
1598{
1600 int x = pwidget->data.cont->id0;
1601 int y = pwidget->data.cont->id1;
1602
1604
1605 /* may not work */
1607 map_pos_to_tile(&(wld.map), x, y));
1608 }
1609
1610 return -1;
1611}
1612
1613/**********************************************************************/
1616static int patrol_here_callback(struct widget *pwidget)
1617{
1619 int x = pwidget->data.cont->id0;
1620 int y = pwidget->data.cont->id1;
1621 struct tile *ptile;
1622
1623 ptile = map_pos_to_tile(&(wld.map), x, y);
1624
1625 if (ptile != NULL) {
1626 struct unit_list *punits = get_units_in_focus();
1627
1628 set_hover_state(punits, HOVER_PATROL, ACTIVITY_LAST, NULL,
1630 update_unit_info_label(punits);
1631 enter_goto_state(punits);
1632 do_unit_patrol_to(ptile);
1634 }
1635
1637 }
1638
1639 return -1;
1640}
1641
1642/**********************************************************************/
1645static int paradrop_here_callback(struct widget *pwidget)
1646{
1648 int x = pwidget->data.cont->id0;
1649 int y = pwidget->data.cont->id1;
1650 struct tile *ptile;
1651
1652 ptile = map_pos_to_tile(&(wld.map), x, y);
1653
1654 if (ptile != NULL) {
1655 struct unit_list *punits = get_units_in_focus();
1656
1657 set_hover_state(punits, HOVER_PARADROP, ACTIVITY_LAST, NULL,
1659 update_unit_info_label(punits);
1660
1661 unit_list_iterate(punits, punit) {
1662 do_unit_paradrop_to(punit, ptile);
1664
1667 }
1668
1670 }
1671
1672 return -1;
1673}
1674
1675/**********************************************************************/
1678static int unit_help_callback(struct widget *pwidget)
1679{
1681 Unit_type_id unit_id = MAX_ID - pwidget->id;
1682
1684 popup_unit_info(unit_id);
1685 }
1686
1687 return -1;
1688}
1689
1690/**********************************************************************/
1695 Uint16 pos_x, Uint16 pos_y)
1696{
1697 struct widget *pwindow = NULL, *buf = NULL;
1698 struct city *pcity;
1699 struct unit *focus_unit;
1700 utf8_str *pstr;
1701 SDL_Rect area2;
1702 struct container *cont;
1703 char cbuf[255];
1704 int n, w = 0, h, units_h = 0;
1705 SDL_Rect area;
1706
1708 return;
1709 }
1710
1711 pcity = tile_city(ptile);
1712 n = unit_list_size(ptile->units);
1713 focus_unit = head_of_units_in_focus();
1714
1715 if (!n && !pcity && !focus_unit) {
1716 popup_terrain_info_dialog(NULL, ptile);
1717
1718 return;
1719 }
1720
1721 area.h = adj_size(2);
1723
1724 advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1725
1726 cont = fc_calloc(1, sizeof(struct container));
1727 cont->id0 = index_to_map_pos_x(tile_index(ptile));
1728 cont->id1 = index_to_map_pos_y(tile_index(ptile));
1729
1730 pstr = create_utf8_from_char_fonto(_("Advanced Menu"), FONTO_ATTENTION);
1731 pstr->style |= TTF_STYLE_BOLD;
1732
1733 pwindow = create_window_skeleton(NULL, pstr, 0);
1734
1736 set_wstate(pwindow , FC_WS_NORMAL);
1737
1740
1741 area = pwindow->area;
1742
1743 /* ---------- */
1744 /* Exit button */
1745 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1747 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1749 area.w += buf->size.w + adj_size(10);
1752 buf->key = SDLK_ESCAPE;
1753
1755 /* ---------- */
1756
1757 pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT);
1758 pstr->style |= TTF_STYLE_BOLD;
1759
1760 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1762
1763 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
1764
1765 buf->data.cont = cont;
1766
1767 buf->action = terrain_info_callback;
1769
1771
1772 area.w = MAX(area.w, buf->size.w);
1773 area.h += buf->size.h;
1774
1775 /* ---------- */
1776 if (pcity && city_owner(pcity) == client.conn.playing) {
1777 /* Separator */
1778 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
1779
1781 area.h += buf->next->size.h;
1782 /* ------------------ */
1783
1784 fc_snprintf(cbuf, sizeof(cbuf), _("Zoom to : %s"), city_name_get(pcity));
1785
1786 create_active_iconlabel(buf, pwindow->dst,
1787 pstr, cbuf, zoom_to_city_callback);
1788 buf->data.city = pcity;
1790
1792
1793 area.w = MAX(area.w, buf->size.w);
1794 area.h += buf->size.h;
1795 /* ----------- */
1796
1797 create_active_iconlabel(buf, pwindow->dst, pstr,
1798 _("Change Production"), change_production_callback);
1799
1800 buf->data.city = pcity;
1802
1804
1805 area.w = MAX(area.w, buf->size.w);
1806 area.h += buf->size.h;
1807 /* -------------- */
1808
1809 create_active_iconlabel(buf, pwindow->dst, pstr,
1810 _("Hurry production"), hurry_production_callback);
1811
1812 buf->data.city = pcity;
1814
1816
1817 area.w = MAX(area.w, buf->size.w);
1818 area.h += buf->size.h;
1819 /* ----------- */
1820
1821 create_active_iconlabel(buf, pwindow->dst, pstr,
1822 _("Change City Governor settings"), cma_callback);
1823
1824 buf->data.city = pcity;
1826
1828
1829 area.w = MAX(area.w, buf->size.w);
1830 area.h += buf->size.h;
1831 }
1832 /* ---------- */
1833
1834 if (focus_unit
1835 && (tile_index(unit_tile(focus_unit)) != tile_index(ptile))) {
1836 /* Separator */
1837 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
1838
1840 area.h += buf->next->size.h;
1841 /* ------------------ */
1842
1843 create_active_iconlabel(buf, pwindow->dst, pstr, _("Goto here"),
1845 buf->data.cont = cont;
1847
1848 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1849
1850 area.w = MAX(area.w, buf->size.w);
1851 area.h += buf->size.h;
1852 /* ----------- */
1853
1854 create_active_iconlabel(buf, pwindow->dst, pstr, _("Patrol here"),
1856 buf->data.cont = cont;
1858
1859 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1860
1861 area.w = MAX(area.w, buf->size.w);
1862 area.h += buf->size.h;
1863 /* ----------- */
1864
1865#if 0 /* FIXME: specific connect buttons */
1866 if (unit_has_type_flag(focus_unit, UTYF_SETTLERS)) {
1867 create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
1868 connect_here_callback);
1869 buf->data.cont = cont;
1871
1873
1874 area.w = MAX(area.w, buf->size.w);
1875 area.h += buf->size.h;
1876 }
1877#endif /* 0 */
1878
1879 /* FIXME: This logic seems to try to mirror do_paradrop() why? */
1880 if (can_unit_paradrop(&(wld.map), focus_unit) && client_tile_get_known(ptile)
1881 && !(((pcity && pplayers_non_attack(client.conn.playing, city_owner(pcity)))
1883 && (unit_type_get(focus_unit)->paratroopers_range >=
1884 real_map_distance(unit_tile(focus_unit), ptile))) {
1885
1886 create_active_iconlabel(buf, pwindow->dst, pstr, _("Paradrop here"),
1888 buf->data.cont = cont;
1890
1892
1893 area.w = MAX(area.w, buf->size.w);
1894 area.h += buf->size.h;
1895 }
1896
1897 }
1899
1900 /* ---------- */
1901 if (n) {
1902 int i;
1903 struct unit *punit;
1904 const struct unit_type *punittype = NULL;
1905
1906 units_h = 0;
1907
1908 /* Separator */
1909 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
1910
1912 area.h += buf->next->size.h;
1913 /* ---------- */
1914 if (n > 1) {
1915 struct unit *defender, *attacker;
1916 struct widget *last = buf;
1917 bool reset = FALSE;
1918 int my_units = 0;
1919 const char *vetname;
1920
1921 #define ADV_NUM_SEEN 15
1922
1923 defender = (focus_unit ? get_defender(&(wld.map), focus_unit, ptile)
1924 : NULL);
1925 attacker = (focus_unit ? get_attacker(&(wld.map), focus_unit, ptile)
1926 : NULL);
1927 for (i = 0; i < n; i++) {
1928 punit = unit_list_get(ptile->units, i);
1929 if (punit == focus_unit) {
1930 continue;
1931 }
1934
1936 struct astring addition = ASTRING_INIT;
1937
1938 unit_activity_astr(punit, &addition);
1939 fc_snprintf(cbuf, sizeof(cbuf),
1940 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
1941 (vetname != NULL ? vetname : ""),
1942 punit->hp, punittype->hp,
1943 utype_name_translation(punittype),
1944 punittype->attack_strength,
1945 punittype->defense_strength,
1946 move_points_text(punittype->move_rate, FALSE),
1947 astr_str(&addition));
1948 astr_free(&addition);
1949
1950 create_active_iconlabel(buf, pwindow->dst, pstr,
1952 buf->data.unit = punit;
1955 my_units++;
1956 } else {
1957 int att_chance, def_chance;
1958
1959 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
1961 (vetname != NULL ? vetname : ""),
1962 utype_name_translation(punittype),
1963 punittype->attack_strength,
1964 punittype->defense_strength,
1965 move_points_text(punittype->move_rate, FALSE),
1966 punittype->firepower,
1967 ((punit->hp * 100) / punittype->hp));
1968
1969 /* Calculate chance to win */
1970 if (sdl_get_chance_to_win(&att_chance, &def_chance, punit,
1971 focus_unit)) {
1972 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1973 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1974 att_chance, def_chance);
1975 }
1976
1977 if (attacker && attacker == punit) {
1978 pstr->fgcol = *(get_game_color(COLOR_OVERVIEW_ENEMY_UNIT));
1979 reset = TRUE;
1980 } else {
1981 if (defender && defender == punit) {
1982 pstr->fgcol = *(get_game_color(COLOR_OVERVIEW_MY_UNIT));
1983 reset = TRUE;
1984 }
1985 }
1986
1987 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
1988
1989 if (reset) {
1991 reset = FALSE;
1992 }
1993
1995 }
1996
1997 area.w = MAX(area.w, buf->size.w);
1998 units_h += buf->size.h;
1999
2000 if (i > ADV_NUM_SEEN - 1) {
2001 set_wflag(buf, WF_HIDDEN);
2002 }
2003 }
2004
2009
2010 if (n > ADV_NUM_SEEN) {
2011 units_h = ADV_NUM_SEEN * buf->size.h;
2013 1, ADV_NUM_SEEN, TRUE, TRUE);
2014 area.w += n;
2015 }
2016
2017 if (my_units > 1) {
2018 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Ready all"), my_units);
2019 create_active_iconlabel(buf, pwindow->dst, pstr,
2023 buf->id = ID_LABEL;
2024 widget_add_as_prev(buf, last);
2025 area.h += buf->size.h;
2026
2027 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Sentry idle"), my_units);
2028 create_active_iconlabel(buf, pwindow->dst, pstr,
2032 buf->id = ID_LABEL;
2033 widget_add_as_prev(buf, last->prev);
2034 area.h += buf->size.h;
2035
2036 /* separator */
2037 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
2038 buf->id = ID_SEPARATOR;
2039 widget_add_as_prev(buf, last->prev->prev);
2040 area.h += buf->next->size.h;
2041 }
2042#undef ADV_NUM_SEEN
2043 } else { /* n == 1 */
2044 /* one unit - give orders */
2045 punit = unit_list_get(ptile->units, 0);
2046 punittype = unit_type_get(punit);
2047 if (punit != focus_unit) {
2048 const char *vetname;
2049
2050 vetname = utype_veteran_name_translation(punittype, punit->veteran);
2051 if ((pcity && city_owner(pcity) == client.conn.playing)
2052 || (unit_owner(punit) == client.conn.playing)) {
2053 struct astring addition = ASTRING_INIT;
2054
2055 unit_activity_astr(punit, &addition);
2056 fc_snprintf(cbuf, sizeof(cbuf),
2057 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
2058 (vetname != NULL ? vetname : ""),
2059 punit->hp, punittype->hp,
2060 utype_name_translation(punittype),
2061 punittype->attack_strength,
2062 punittype->defense_strength,
2063 move_points_text(punittype->move_rate, FALSE),
2064 astr_str(&addition));
2065 astr_free(&addition);
2066
2067 create_active_iconlabel(buf, pwindow->dst, pstr,
2069 buf->data.unit = punit;
2071
2073
2074 area.w = MAX(area.w, buf->size.w);
2075 units_h += buf->size.h;
2076 /* ---------------- */
2077 /* Separator */
2078 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
2079
2081 area.h += buf->next->size.h;
2082 } else {
2083 int att_chance, def_chance;
2084
2085 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
2087 (vetname != NULL ? vetname : ""),
2088 utype_name_translation(punittype),
2089 punittype->attack_strength,
2090 punittype->defense_strength,
2091 move_points_text(punittype->move_rate, FALSE),
2092 punittype->firepower,
2093 ((punit->hp * 100) / punittype->hp));
2094
2095 /* Calculate chance to win */
2096 if (sdl_get_chance_to_win(&att_chance, &def_chance, punit,
2097 focus_unit)) {
2098 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
2099 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
2100 att_chance, def_chance);
2101 }
2102 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf, NULL);
2104 area.w = MAX(area.w, buf->size.w);
2105 units_h += buf->size.h;
2106 /* ---------------- */
2107
2108 /* Separator */
2109 buf = create_iconlabel(NULL, pwindow->dst, NULL, WF_FREE_THEME);
2110
2112 area.h += buf->next->size.h;
2113 }
2114 }
2115
2116 /* ---------------- */
2117 fc_snprintf(cbuf, sizeof(cbuf),
2118 _("Look up \"%s\" in the Help Browser"),
2119 utype_name_translation(punittype));
2120 create_active_iconlabel(buf, pwindow->dst, pstr,
2121 cbuf, unit_help_callback);
2122 set_wstate(buf , FC_WS_NORMAL);
2123 add_to_gui_list(MAX_ID - utype_number(punittype), buf);
2124
2125 area.w = MAX(area.w, buf->size.w);
2126 units_h += buf->size.h;
2127 /* ---------------- */
2129 }
2130
2131 }
2132 /* ---------- */
2133
2134 area.w += adj_size(2);
2135 area.h += units_h;
2136
2137 resize_window(pwindow, NULL, NULL,
2138 (pwindow->size.w - pwindow->area.w) + area.w,
2139 (pwindow->size.h - pwindow->area.h) + area.h);
2140
2141 area = pwindow->area;
2142
2143 widget_set_position(pwindow, pos_x, pos_y);
2144
2145 w = area.w - adj_size(2);
2146
2148 units_h = n;
2149 } else {
2150 units_h = 0;
2151 }
2152
2153 /* exit button */
2154 buf = pwindow->prev;
2155
2156 buf->size.x = area.x + area.w - buf->size.w - 1;
2157 buf->size.y = pwindow->size.y + adj_size(2);
2158
2159 /* terrain info */
2160 buf = buf->prev;
2161
2162 buf->size.x = area.x + 1;
2163 buf->size.y = area.y + 1;
2164 buf->size.w = w;
2165 h = buf->size.h;
2166
2167 area2.x = adj_size(10);
2168 area2.h = adj_size(2);
2169
2170 buf = buf->prev;
2171 while (buf) {
2173 w -= units_h;
2174 }
2175
2176 buf->size.w = w;
2177 buf->size.x = buf->next->size.x;
2178 buf->size.y = buf->next->size.y + buf->next->size.h;
2179
2180 if (buf->id == ID_SEPARATOR) {
2181 FREESURFACE(buf->theme);
2182 buf->size.h = h;
2183 buf->theme = create_surf(w, h, SDL_SWSURFACE);
2184
2185 area2.y = buf->size.h / 2 - 1;
2186 area2.w = buf->size.w - adj_size(20);
2187
2188 SDL_FillRect(buf->theme, &area2, map_rgba(buf->theme->format,
2190 }
2191
2194 break;
2195 }
2196 buf = buf->prev;
2197 }
2198
2201 area.x + area.w,
2203 area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
2204 TRUE);
2205 }
2206
2207 /* -------------------- */
2208 /* redraw */
2210
2211 widget_flush(pwindow);
2212}
2213
2214/* ====================================================================== */
2215/* ============================ PILLAGE DIALOG ========================== */
2216/* ====================================================================== */
2217static struct small_dialog *pillage_dlg = NULL;
2218
2219/**********************************************************************/
2222static int pillage_window_callback(struct widget *pwindow)
2223{
2226 }
2227
2228 return -1;
2229}
2230
2231/**********************************************************************/
2234static int pillage_callback(struct widget *pwidget)
2235{
2237 struct unit *punit = pwidget->data.unit;
2238 int what = MAX_ID - pwidget->id;
2239
2241
2242 if (punit) {
2243 struct extra_type *target = extra_by_number(what);
2244
2245 request_new_unit_activity_targeted(punit, ACTIVITY_PILLAGE, target);
2246 }
2247 }
2248
2249 return -1;
2250}
2251
2252/**********************************************************************/
2255static int exit_pillage_dlg_callback(struct widget *pwidget)
2256{
2259 }
2260
2261 return -1;
2262}
2263
2264/**********************************************************************/
2278
2279/**********************************************************************/
2283void popup_pillage_dialog(struct unit *punit, bv_extras extras)
2284{
2285 struct widget *pwindow = NULL, *buf = NULL;
2286 utf8_str *pstr;
2287 SDL_Rect area;
2288 struct extra_type *tgt;
2289
2290 if (pillage_dlg) {
2291 return;
2292 }
2293
2295 pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
2296
2297 /* Window */
2298 pstr = create_utf8_from_char_fonto(_("What To Pillage"), FONTO_ATTENTION);
2299 pstr->style |= TTF_STYLE_BOLD;
2300
2301 pwindow = create_window_skeleton(NULL, pstr, 0);
2302
2304 set_wstate(pwindow, FC_WS_NORMAL);
2305
2307 pillage_dlg->end_widget_list = pwindow;
2308
2309 area = pwindow->area;
2310
2311 area.h = MAX(area.h, adj_size(2));
2312
2313 /* ---------- */
2314 /* Exit button */
2315 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2317 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2319 area.w += buf->size.w + adj_size(10);
2320 buf->action = exit_pillage_dlg_callback;
2322 buf->key = SDLK_ESCAPE;
2323
2325 /* ---------- */
2326
2327 while ((tgt = get_preferred_pillage(extras))) {
2328 const char *name = NULL;
2329 int what;
2330
2331 BV_CLR(extras, extra_index(tgt));
2333 what = extra_index(tgt);
2334
2335 fc_assert(name != NULL);
2336
2337 create_active_iconlabel(buf, pwindow->dst, pstr,
2338 (char *) name, pillage_callback);
2339
2340 buf->data.unit = punit;
2342
2343 add_to_gui_list(MAX_ID - what, buf);
2344
2345 area.w = MAX(area.w, buf->size.w);
2346 area.h += buf->size.h;
2347 }
2349
2350 /* setup window size and start position */
2351
2352 resize_window(pwindow, NULL, NULL,
2353 (pwindow->size.w - pwindow->area.w) + area.w,
2354 (pwindow->size.h - pwindow->area.h) + area.h);
2355
2356 area = pwindow->area;
2357
2358 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2359 unit_tile(punit));
2360
2361 /* setup widget size and start position */
2362
2363 /* exit button */
2364 buf = pwindow->prev;
2365 buf->size.x = area.x + area.w - buf->size.w - 1;
2366 buf->size.y = pwindow->size.y + adj_size(2);
2367
2368 /* first special to pillage */
2369 buf = buf->prev;
2371 area.x, area.y + 1, area.w, 0,
2373
2374 /* --------------------- */
2375 /* redraw */
2377
2378 widget_flush(pwindow);
2379}
2380
2381/* ======================================================================= */
2382/* =========================== CONNECT DIALOG ============================ */
2383/* ======================================================================= */
2384static struct small_dialog *connect_dlg = NULL;
2385
2386/**********************************************************************/
2399
2400/* ==================== Public ========================= */
2401
2402/**************************************************************************
2403 Select Government Type
2404**************************************************************************/
2405static struct small_dialog *gov_dlg = NULL;
2406
2407/**********************************************************************/
2419
2420/**********************************************************************/
2423static int government_dlg_callback(struct widget *gov_button)
2424{
2427
2429 }
2430
2431 return -1;
2432}
2433
2434/**********************************************************************/
2437static int move_government_dlg_callback(struct widget *pwindow)
2438{
2441 }
2442
2443 return -1;
2444}
2445
2446/**********************************************************************/
2450{
2451 struct utf8_str *pstr;
2452 struct widget *gov_button = NULL;
2453 struct widget *pwindow;
2454 int j;
2455 Uint16 max_w = 0, max_h = 0;
2456 SDL_Rect area;
2457
2458 if (gov_dlg != NULL) {
2459 return;
2460 }
2461
2462 gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
2463
2464 /* Create window */
2465 pstr = create_utf8_from_char_fonto(_("Choose Your New Government"),
2467 pstr->style |= TTF_STYLE_BOLD;
2468 /* This win. size is temp. */
2469 pwindow = create_window_skeleton(NULL, pstr, 0);
2472
2473 gov_dlg->end_widget_list = pwindow;
2474
2475 area = pwindow->area;
2476
2477 /* Create gov. buttons */
2478 j = 0;
2479 governments_iterate(gov) {
2481 continue;
2482 }
2483
2488 = create_icon_button(get_government_surface(gov), pwindow->dst, pstr, 0);
2490
2491 max_w = MAX(max_w, gov_button->size.w);
2492 max_h = MAX(max_h, gov_button->size.h);
2493
2494 /* Ugly hack */
2496 j++;
2497
2498 }
2500
2501 if (gov_button == NULL) {
2502 /* No governments to switch to.
2503 * TODO: Provide close button for the dialog. */
2505 } else {
2507
2509
2510 max_w += adj_size(10);
2511 max_h += adj_size(4);
2512
2513 area.w = MAX(area.w, max_w + adj_size(20));
2514 area.h = MAX(area.h, j * (max_h + adj_size(10)) + adj_size(5));
2515
2516 /* Create window background */
2518 if (resize_window(pwindow, logo, NULL,
2519 (pwindow->size.w - pwindow->area.w) + area.w,
2520 (pwindow->size.h - pwindow->area.h) + area.h)) {
2522 }
2523
2524 area = pwindow->area;
2525
2526 /* Set window start positions */
2527 widget_set_position(pwindow,
2528 (main_window_width() - pwindow->size.w) / 2,
2529 (main_window_height() - pwindow->size.h) / 2);
2530
2531 /* Set buttons start positions and size */
2532 j = 1;
2533 while (gov_button != gov_dlg->end_widget_list) {
2534 gov_button->size.w = max_w;
2535 gov_button->size.h = max_h;
2536 gov_button->size.x = area.x + adj_size(10);
2537 gov_button->size.y = area.y + area.h - (j++) * (max_h + adj_size(10));
2539
2540 gov_button = gov_button->next;
2541 }
2542 }
2543
2544 set_wstate(pwindow, FC_WS_NORMAL);
2545
2546 /* Redraw */
2548
2549 widget_flush(pwindow);
2550}
2551
2552/**************************************************************************
2553 Nation Wizard
2554**************************************************************************/
2555static struct advanced_dialog *nation_dlg = NULL;
2556static struct small_dialog *help_dlg = NULL;
2557
2559 unsigned char nation_style; /* selected style */
2560 unsigned char selected_leader; /* if not unique -> selected leader */
2561 Nation_type_id nation; /* selected nation */
2562 bool leader_sex; /* selected leader sex */
2571};
2572
2573static int next_set_callback(struct widget *next_button);
2574static int prev_set_callback(struct widget *prev_button);
2575static int nations_dialog_callback(struct widget *pwindow);
2576static int nation_button_callback(struct widget *pnation);
2577static int races_dialog_ok_callback(struct widget *start_button);
2578static int races_dialog_cancel_callback(struct widget *button);
2579static int next_name_callback(struct widget *next_button);
2580static int prev_name_callback(struct widget *prev_button);
2581static int change_sex_callback(struct widget *sex);
2582static void select_random_leader(Nation_type_id nation);
2583static void change_nation_label(void);
2584
2585/**********************************************************************/
2588static int nations_dialog_callback(struct widget *pwindow)
2589{
2592 widget_flush(pwindow);
2593 }
2594 }
2595
2596 return -1;
2597}
2598
2599/**********************************************************************/
2602static int races_dialog_ok_callback(struct widget *start_button)
2603{
2605 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2606 char *pstr = setup->name_edit->string_utf8->text;
2607
2608 /* perform a minimum of sanity test on the name */
2609 if (strlen(pstr) == 0) {
2610 output_window_append(ftc_client, _("You must type a legal name."));
2611 selected_widget = start_button;
2612 set_wstate(start_button, FC_WS_SELECTED);
2613 widget_redraw(start_button);
2614 widget_flush(start_button);
2615
2616 return -1;
2617 }
2618
2620 setup->nation,
2621 setup->leader_sex, pstr,
2622 setup->nation_style);
2623
2625 flush_dirty();
2626 }
2627
2628 return -1;
2629}
2630
2631/**********************************************************************/
2634static int change_sex_callback(struct widget *sex)
2635{
2637 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2638
2639 if (setup->leader_sex) {
2640 copy_chars_to_utf8_str(setup->change_sex->string_utf8, _("Female"));
2641 } else {
2643 }
2644 setup->leader_sex = !setup->leader_sex;
2645
2646 if (sex) {
2647 selected_widget = sex;
2649
2650 widget_redraw(sex);
2651 widget_flush(sex);
2652 }
2653 }
2654
2655 return -1;
2656}
2657
2658/**********************************************************************/
2661static int next_name_callback(struct widget *next)
2662{
2664 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2665 const struct nation_leader_list *leaders =
2667 const struct nation_leader *pleader;
2668
2669 setup->selected_leader++;
2670 pleader = nation_leader_list_get(leaders, setup->selected_leader);
2671
2672 /* change leader sex */
2673 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2674 change_sex_callback(NULL);
2675 }
2676
2677 /* change leader name */
2679 nation_leader_name(pleader));
2680
2683
2684 if (nation_leader_list_size(leaders) - 1 == setup->selected_leader) {
2686 }
2687
2688 if (get_wstate(setup->name_prev) == FC_WS_DISABLED) {
2690 }
2691
2692 if (!(get_wstate(setup->name_next) == FC_WS_DISABLED)) {
2693 selected_widget = setup->name_next;
2695 }
2696
2697 widget_redraw(setup->name_edit);
2698 widget_redraw(setup->name_prev);
2699 widget_redraw(setup->name_next);
2703
2704 widget_redraw(setup->change_sex);
2706
2707 flush_dirty();
2708 }
2709
2710 return -1;
2711}
2712
2713/**********************************************************************/
2716static int prev_name_callback(struct widget *prev)
2717{
2719 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2720 const struct nation_leader_list *leaders =
2722 const struct nation_leader *pleader;
2723
2724 setup->selected_leader--;
2725 pleader = nation_leader_list_get(leaders, setup->selected_leader);
2726
2727 /* change leader sex */
2728 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2729 change_sex_callback(NULL);
2730 }
2731
2732 /* change leader name */
2734 nation_leader_name(pleader));
2735
2738
2739 if (!setup->selected_leader) {
2741 }
2742
2743 if (get_wstate(setup->name_next) == FC_WS_DISABLED) {
2745 }
2746
2747 if (!(get_wstate(setup->name_prev) == FC_WS_DISABLED)) {
2748 selected_widget = setup->name_prev;
2750 }
2751
2752 widget_redraw(setup->name_edit);
2753 widget_redraw(setup->name_prev);
2754 widget_redraw(setup->name_next);
2758
2759 widget_redraw(setup->change_sex);
2761
2762 flush_dirty();
2763 }
2764
2765 return -1;
2766}
2767
2768/**********************************************************************/
2771static int next_set_callback(struct widget *next_button)
2772{
2774 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2775 struct option *poption = optset_option_by_name(server_optset, "nationset");
2776
2777 fc_assert(setup->set != NULL
2778 && nation_set_index(setup->set) < nation_set_count() - 1);
2779
2780 setup->set = nation_set_by_number(nation_set_index(setup->set) + 1);
2781
2782 option_str_set(poption, nation_set_rule_name(setup->set));
2783 }
2784
2785 return -1;
2786}
2787
2788/**********************************************************************/
2791static int prev_set_callback(struct widget *prev_button)
2792{
2794 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2795 struct option *poption = optset_option_by_name(server_optset, "nationset");
2796
2797 fc_assert(setup->set != NULL && nation_set_index(setup->set) > 0);
2798
2799 setup->set = nation_set_by_number(nation_set_index(setup->set) - 1);
2800
2801 option_str_set(poption, nation_set_rule_name(setup->set));
2802 }
2803
2804 return -1;
2805}
2806
2807/**********************************************************************/
2810static int races_dialog_cancel_callback(struct widget *button)
2811{
2814 flush_dirty();
2815 }
2816
2817 return -1;
2818}
2819
2820/**********************************************************************/
2823static int style_callback(struct widget *pwidget)
2824{
2826 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2828 setup->nation_style);
2829
2833
2834 set_wstate(pwidget, FC_WS_DISABLED);
2835 widget_redraw(pwidget);
2836 widget_mark_dirty(pwidget);
2837
2838 setup->nation_style = MAX_ID - 1000 - pwidget->id;
2839
2840 flush_dirty();
2842 }
2843
2844 return -1;
2845}
2846
2847/**********************************************************************/
2850static int help_dlg_callback(struct widget *pwindow)
2851{
2852 return -1;
2853}
2854
2855/**********************************************************************/
2858static int cancel_help_dlg_callback(struct widget *pwidget)
2859{
2861 if (help_dlg) {
2865 if (pwidget) {
2866 flush_dirty();
2867 }
2868 }
2869 }
2870
2871 return -1;
2872}
2873
2874/**********************************************************************/
2878{
2881
2883 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2884
2885 if (setup->nation == MAX_ID - nation_button->id) {
2888
2889 return -1;
2890 }
2891
2892 setup->nation = MAX_ID - nation_button->id;
2893
2895
2896 enable(MAX_ID - 1000 - setup->nation_style);
2898 disable(MAX_ID - 1000 - setup->nation_style);
2899
2901
2904 } else {
2905 /* Pop up nation description */
2906 struct widget *pwindow, *ok_button;
2907 utf8_str *pstr;
2908 SDL_Surface *text;
2910 struct nation_type *pnation = nation_by_number(MAX_ID - nation_button->id);
2911
2914
2915 if (!help_dlg) {
2916 help_dlg = fc_calloc(1, sizeof(struct small_dialog));
2917
2920 pstr->style |= TTF_STYLE_BOLD;
2921
2922 pwindow = create_window_skeleton(NULL, pstr, 0);
2923 pwindow->action = help_dlg_callback;
2924
2925 set_wstate(pwindow, FC_WS_NORMAL);
2926
2927 help_dlg->end_widget_list = pwindow;
2928 add_to_gui_list(ID_WINDOW, pwindow);
2929
2930 ok_button
2932 pwindow->dst, _("OK"),
2933 FONTO_HEADING, 0);
2934 ok_button->action = cancel_help_dlg_callback;
2935 set_wstate(ok_button, FC_WS_NORMAL);
2936 ok_button->key = SDLK_ESCAPE;
2937 add_to_gui_list(ID_BUTTON, ok_button);
2938 help_dlg->begin_widget_list = ok_button;
2939 } else {
2940 pwindow = help_dlg->end_widget_list;
2941 ok_button = help_dlg->begin_widget_list;
2942
2943 /* Undraw window */
2944 widget_undraw(pwindow);
2945 widget_mark_dirty(pwindow);
2946 }
2947
2948 area = pwindow->area;
2949
2950 {
2951 char info[4096];
2952
2953 helptext_nation(info, sizeof(info), pnation, NULL);
2955 }
2956
2959
2960 FREEUTF8STR(pstr);
2961
2962 /* create window background */
2963 area.w = MAX(area.w, text->w + adj_size(20));
2964 area.w = MAX(area.w, ok_button->size.w + adj_size(20));
2965 area.h = MAX(area.h, adj_size(9) + text->h
2966 + adj_size(10) + ok_button->size.h + adj_size(10));
2967
2969 (pwindow->size.w - pwindow->area.w) + area.w,
2970 (pwindow->size.h - pwindow->area.h) + area.h);
2971
2972 widget_set_position(pwindow,
2973 (main_window_width() - pwindow->size.w) / 2,
2974 (main_window_height() - pwindow->size.h) / 2);
2975
2976 area2.x = area.x + adj_size(7);
2977 area2.y = area.y + adj_size(6);
2978 alphablit(text, NULL, pwindow->theme, &area2, 255);
2979 FREESURFACE(text);
2980
2981 ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
2982 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2983
2984 /* redraw */
2985 redraw_group(ok_button, pwindow, 0);
2986
2987 widget_mark_dirty(pwindow);
2988
2989 flush_dirty();
2990
2991 }
2992
2993 return -1;
2994}
2995
2996/**********************************************************************/
2999static int leader_name_edit_callback(struct widget *pedit)
3000{
3002 if (pedit->string_utf8->text != NULL) {
3003 /* empty input -> restore previous content */
3005 widget_redraw(pedit);
3006 widget_mark_dirty(pedit);
3007 flush_dirty();
3008 }
3009 }
3010
3011 return -1;
3012}
3013
3014/* =========================================================== */
3015
3016/**********************************************************************/
3019static void change_nation_label(void)
3020{
3021 SDL_Surface *tmp_surf, *tmp_surf_zoomed;
3022 struct widget *pwindow = nation_dlg->end_widget_list;
3023 struct nation_info *setup = (struct nation_info *)(pwindow->data.ptr);
3024 struct widget *label = setup->name_edit->next;
3025 struct nation_type *pnation = nation_by_number(setup->nation);
3026
3027 tmp_surf = get_nation_flag_surface(pnation);
3028 tmp_surf_zoomed = zoomSurface(tmp_surf, DEFAULT_ZOOM * 1.0, DEFAULT_ZOOM * 1.0, 1);
3029
3030 FREESURFACE(label->theme);
3031 label->theme = tmp_surf_zoomed;
3032
3034
3035 remake_label_size(label);
3036
3037 label->size.x = pwindow->size.x + pwindow->size.w / 2 +
3038 (pwindow->size.w / 2 - label->size.w) / 2;
3039
3040}
3041
3042/**********************************************************************/
3047{
3048 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3049 const struct nation_leader_list *leaders =
3051 const struct nation_leader *pleader;
3052
3053 setup->selected_leader = fc_rand(nation_leader_list_size(leaders));
3054 pleader = nation_leader_list_get(leaders, setup->selected_leader);
3056 nation_leader_name(pleader));
3057
3060
3061 /* initialize leader sex */
3062 setup->leader_sex = nation_leader_is_male(pleader);
3063
3064 if (setup->leader_sex) {
3066 } else {
3067 copy_chars_to_utf8_str(setup->change_sex->string_utf8, _("Female"));
3068 }
3069
3070 /* disable navigation buttons */
3073
3074 if (1 < nation_leader_list_size(leaders)) {
3075 /* if selected leader is not the first leader, enable "previous leader" button */
3076 if (setup->selected_leader > 0) {
3078 }
3079
3080 /* if selected leader is not the last leader, enable "next leader" button */
3081 if (setup->selected_leader < (nation_leader_list_size(leaders) - 1)) {
3083 }
3084 }
3085}
3086
3087/**********************************************************************/
3091{
3092 int playable_nation_count = 0;
3093
3094 nations_iterate(pnation) {
3095 if (pnation->is_playable && !pnation->player
3096 && is_nation_pickable(pnation))
3097 playable_nation_count++;
3099
3100 return playable_nation_count;
3101}
3102
3103/**********************************************************************/
3106void popup_races_dialog(struct player *pplayer)
3107{
3108 SDL_Color bg_color = {255,255,255,128};
3109
3110 struct widget *pwindow, *pwidget = NULL, *buf, *last_City_Style;
3111 utf8_str *pstr;
3112 int len = 0;
3113 int w = adj_size(10), h = adj_size(10);
3116 SDL_Rect dst;
3117 float zoom;
3118 struct nation_info *setup;
3119 SDL_Rect area;
3120 int i;
3121 struct nation_type *pnat;
3122 struct widget *nationsets = NULL;
3123 int natinfo_y, natinfo_h;
3124
3125#define TARGETS_ROW 5
3126#define TARGETS_COL 1
3127
3128 if (nation_dlg) {
3129 return;
3130 }
3131
3132 races_player = pplayer;
3133
3134 nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3135
3136 /* Create window widget */
3137 pstr = create_utf8_from_char_fonto(_("What nation will you be?"),
3139 pstr->style |= TTF_STYLE_BOLD;
3140
3141 pwindow = create_window(NULL, pstr, w, h, WF_FREE_DATA);
3143 set_wstate(pwindow, FC_WS_NORMAL);
3144 setup = fc_calloc(1, sizeof(struct nation_info));
3145 pwindow->data.ptr = (void *)setup;
3146
3147 nation_dlg->end_widget_list = pwindow;
3149 /* --------------------------------------------------------- */
3150 /* Create nations list */
3151
3152 /* Create Imprv Background Icon */
3154
3156
3158 0, 0, main_bg->w - 1, main_bg->h - 1,
3160
3162 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
3163 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
3164
3165 /* Fill list */
3166
3167 nations_iterate(pnation) {
3168 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
3169 continue;
3170 }
3171
3173
3175
3179
3180 dst.x = (tmp_surf->w - tmp_surf_zoomed->w) / 2;
3181 len = tmp_surf_zoomed->h +
3182 adj_size(10) + text_name->h;
3183 dst.y = (tmp_surf->h - len) / 2;
3185 dst.y += (tmp_surf_zoomed->h + adj_size(10));
3187
3188 dst.x = (tmp_surf->w - text_name->w) / 2;
3190 dst.y += text_name->h;
3192
3193 pwidget = create_icon2(tmp_surf, pwindow->dst,
3195
3196 set_wstate(pwidget, FC_WS_NORMAL);
3197
3198 pwidget->action = nation_button_callback;
3199
3200 w = MAX(w, pwidget->size.w);
3201 h = MAX(h, pwidget->size.h);
3202
3203 add_to_gui_list(MAX_ID - nation_index(pnation), pwidget);
3204
3205 if (nation_index(pnation) > (TARGETS_ROW * TARGETS_COL - 1)) {
3206 set_wflag(pwidget, WF_HIDDEN);
3207 }
3208
3210
3212
3214 nation_dlg->begin_widget_list = pwidget;
3216
3221 }
3222
3223 /* ----------------------------------------------------------------- */
3224
3225 /* Nation set selection */
3226 if (nation_set_count() > 1) {
3228 struct option *poption;
3229
3230 natset_str = create_utf8_from_char_fonto(_("Nation set"),
3232 change_fonto_utf8(natset_str, FONTO_MAX);
3233 nationsets = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3235
3236 /* Create nation set name label */
3237 poption = optset_option_by_name(server_optset, "nationset");
3239
3240 natset_str
3243 change_fonto_utf8(natset_str, FONTO_MAX);
3244
3245 pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3246
3247 add_to_gui_list(ID_LABEL, pwidget);
3248 setup->pset_name = pwidget;
3249
3250 /* Create next nationset button */
3251 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3252 pwindow->dst, NULL, 0);
3253 pwidget->action = next_set_callback;
3254 if (nation_set_index(setup->set) < nation_set_count() - 1) {
3255 set_wstate(pwidget, FC_WS_NORMAL);
3256 }
3258 pwidget->size.h = pwidget->next->size.h;
3259 setup->pset_next = pwidget;
3260
3261 /* Create prev nationset button */
3262 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3263 pwindow->dst, NULL, 0);
3264 pwidget->action = prev_set_callback;
3265 if (nation_set_index(setup->set) > 0) {
3266 set_wstate(pwidget, FC_WS_NORMAL);
3267 }
3269 pwidget->size.h = pwidget->next->size.h;
3270 setup->pset_prev = pwidget;
3271 }
3272
3273 /* Nation name */
3275 pnat = nation_by_number(setup->nation);
3277
3280 pstr->render = 2;
3282
3283 tmp_surf_zoomed = adj_surf(get_nation_flag_surface(pnat));
3284
3285 pwidget = create_iconlabel(tmp_surf_zoomed, pwindow->dst, pstr,
3287 if (nationsets == NULL) {
3288 buf = pwidget;
3289 } else {
3290 buf = nationsets;
3291 }
3292
3293 add_to_gui_list(ID_LABEL, pwidget);
3294
3295 /* Create leader name edit */
3296 pwidget = create_edit_from_chars_fonto(NULL, pwindow->dst,
3297 NULL, FONTO_BIG,
3298 adj_size(200), 0);
3299 pwidget->size.h = adj_size(24);
3300
3301 set_wstate(pwidget, FC_WS_NORMAL);
3304 setup->name_edit = pwidget;
3305
3306 /* Create next leader name button */
3307 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3308 pwindow->dst, NULL, 0);
3309 pwidget->action = next_name_callback;
3311 pwidget->size.h = pwidget->next->size.h;
3312 setup->name_next = pwidget;
3313
3314 /* Create prev leader name button */
3315 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3316 pwindow->dst, NULL, 0);
3317 pwidget->action = prev_name_callback;
3319 pwidget->size.h = pwidget->next->size.h;
3320 setup->name_prev = pwidget;
3321
3322 /* Change sex button */
3323 pwidget = create_icon_button_from_chars_fonto(NULL, pwindow->dst,
3324 _("Male"),
3325 FONTO_HEADING, 0);
3326 pwidget->action = change_sex_callback;
3327 pwidget->size.w = adj_size(100);
3328 pwidget->size.h = adj_size(22);
3329 set_wstate(pwidget, FC_WS_NORMAL);
3330 setup->change_sex = pwidget;
3331
3332 /* Add to main widget list */
3334
3335 /* ---------------------------------------------------------- */
3336 zoom = DEFAULT_ZOOM * 1.0;
3337
3338 len = 0;
3339 styles_iterate(pstyle) {
3340 int sn = basic_city_style_for_style(pstyle);
3341
3342 tmp_surf = get_sample_city_surface(sn);
3343
3344 if (tmp_surf->w > 48) {
3345 zoom = DEFAULT_ZOOM * (48.0 / tmp_surf->w);
3346 }
3347
3348 tmp_surf_zoomed = zoomSurface(get_sample_city_surface(sn), zoom, zoom, 0);
3349
3350 pwidget = create_icon2(tmp_surf_zoomed, pwindow->dst, WF_RESTORE_BACKGROUND);
3351 pwidget->action = style_callback;
3352 if (sn != setup->nation_style) {
3353 set_wstate(pwidget, FC_WS_NORMAL);
3354 }
3355 len += pwidget->size.w;
3356 add_to_gui_list(MAX_ID - 1000 - sn, pwidget);
3358
3359 last_City_Style = pwidget;
3360 /* ---------------------------------------------------------- */
3361
3362 /* Create Cancel button */
3363 pwidget
3365 pwindow->dst, _("Cancel"),
3366 FONTO_ATTENTION, 0);
3368 set_wstate(pwidget, FC_WS_NORMAL);
3369
3371
3372 /* Create OK button */
3373 pwidget
3375 pwindow->dst,
3376 _("OK"), FONTO_ATTENTION, 0);
3378
3379 set_wstate(pwidget, FC_WS_NORMAL);
3381 pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
3382 pwidget->next->size.w = pwidget->size.w;
3383
3384 nation_dlg->begin_widget_list = pwidget;
3385 /* ---------------------------------------------------------- */
3386
3388 if (resize_window(pwindow, main_bg, NULL, adj_size(640), adj_size(480))) {
3389 FREESURFACE(main_bg);
3390 }
3391
3392 area = pwindow->area;
3393
3394 widget_set_position(pwindow,
3395 (main_window_width() - pwindow->size.w) / 2,
3396 (main_window_height() - pwindow->size.h) / 2);
3397
3398 /* Nations */
3399
3401 i = (area.h - adj_size(43) - h) / 2;
3403 area.x + adj_size(10),
3404 area.y + i - adj_size(4),
3407
3408 if (nation_dlg->scroll) {
3409 SDL_Rect area2;
3410
3413 area.x + w + adj_size(12),
3414 area.y + i - adj_size(4), h, FALSE);
3415
3416 area2.x = area.x + w + adj_size(11);
3417 area2.y = area.y + i - adj_size(4);
3418 area2.w = nation_dlg->scroll->up_left_button->size.w + adj_size(2);
3419 area2.h = h;
3420 fill_rect_alpha(pwindow->theme, &area2, &bg_color);
3421
3422 create_frame(pwindow->theme,
3423 area2.x, area2.y - 1, area2.w, area2.h + 1,
3425 }
3426
3427 if (nationsets != NULL) {
3428 /* Nationsets header */
3429 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3430 buf->size.y = area.y + adj_size(46);
3431
3432 natinfo_y = buf->size.y;
3433 natinfo_h = area.h -= buf->size.y;
3434
3435 /* Nationset name */
3436 buf = buf->prev;
3437 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3438 buf->size.y = natinfo_y + adj_size(46);
3439
3440 natinfo_y += adj_size(46);
3441 natinfo_h -= adj_size(46);
3442
3443 /* Next Nationset Button */
3444 buf = buf->prev;
3445 buf->size.x = buf->next->size.x + buf->next->size.w;
3446 buf->size.y = buf->next->size.y;
3447
3448 /* Prev Nationset Button */
3449 buf = buf->prev;
3450 buf->size.x = buf->next->next->size.x - buf->size.w;
3451 buf->size.y = buf->next->size.y;
3452
3453 buf = buf->prev;
3454 } else {
3455 natinfo_y = area.y;
3456 natinfo_h = area.h;
3457 }
3458
3459 /* Selected Nation Name */
3460 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3461 buf->size.y = natinfo_y + adj_size(46);
3462
3463 /* Leader Name Edit */
3464 buf = buf->prev;
3465 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3466 buf->size.y = natinfo_y + (natinfo_h - buf->size.h) / 2 - adj_size(30);
3467
3468 /* Next Leader Name Button */
3469 buf = buf->prev;
3470 buf->size.x = buf->next->size.x + buf->next->size.w;
3471 buf->size.y = buf->next->size.y;
3472
3473 /* Prev Leader Name Button */
3474 buf = buf->prev;
3475 buf->size.x = buf->next->next->size.x - buf->size.w;
3476 buf->size.y = buf->next->size.y;
3477
3478 /* Change Leader Sex Button */
3479 buf = buf->prev;
3480 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3481 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3482
3483 /* First Style Button */
3484 buf = buf->prev;
3485 buf->size.x = area.x + area.w / 2 + (area.w / 2 - len) / 2 - adj_size(20);
3486 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3487
3488 /* Rest Style Buttons */
3489 while (buf != last_City_Style) {
3490 buf = buf->prev;
3491 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(3);
3492 buf->size.y = buf->next->size.y;
3493 }
3494
3495 create_line(pwindow->theme,
3496 area.x,
3497 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3498 area.w - 1,
3499 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3501
3502 /* Disconnect Button */
3503 buf = buf->prev;
3504 buf->size.x = area.x + adj_size(10);
3505 buf->size.y = natinfo_y + natinfo_h - adj_size(7) - buf->size.h;
3506
3507 /* Start Button */
3508 buf = buf->prev;
3509 buf->size.x = area.w - adj_size(10) - buf->size.w;
3510 buf->size.y = buf->next->size.y;
3511
3512 /* -------------------------------------------------------------------- */
3513
3515
3517
3518 widget_flush(pwindow);
3519}
3520
3521/**********************************************************************/
3539
3540/**********************************************************************/
3543void races_update_pickable(bool nationset_change)
3544{
3545 /* If this is because of nationset change, update will take
3546 * place later when the new option value is received */
3547 if (nation_dlg != NULL && !nationset_change) {
3550 }
3551}
3552
3553/**********************************************************************/
3557{
3558 if (nation_dlg != NULL) {
3561 }
3562}
3563
3564/**********************************************************************/
3569{
3570 struct nation_info *setup;
3571 bool change = FALSE;
3572 struct widget *nat;
3573
3574 if (!nation_dlg) {
3575 return;
3576 }
3577
3578 setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3579
3581 if (!is_nation_pickable(nation) || nation->player) {
3582 log_debug(" [%d]: %d = %s", nation_index(nation),
3583 (!is_nation_pickable(nation) || nation->player),
3585
3588
3589 if (nation_index(nation) == setup->nation) {
3590 change = TRUE;
3591 }
3592 }
3594
3595 if (change) {
3596 do {
3599 } while (get_wstate(nat) == FC_WS_DISABLED);
3600
3601 if (get_wstate(setup->name_edit) == FC_WS_PRESSED) {
3604 }
3606 enable(MAX_ID - 1000 - setup->nation_style);
3608 disable(MAX_ID - 1000 - setup->nation_style);
3610 }
3613}
3614
3615/**********************************************************************/
3620{
3621}
3622
3623/**********************************************************************/
3630
3631/**********************************************************************/
3638
3639/**********************************************************************/
3643bool popup_theme_suggestion_dialog(const char *theme_name)
3644{
3645 /* Don't load */
3646 return FALSE;
3647}
3648
3649/**********************************************************************/
3653{
3654 /* PORTME */
3655}
3656
3657/**********************************************************************/
3660void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
3661{
3662 /* PORTME */
3663}
3664
3665/**********************************************************************/
3670{
3671 /* Just tell the client common code to handle this. */
3672 return FALSE;
3673}
3674
3675/**********************************************************************/
3679{
3680 /* PORTME */
3681}
3682
3683/**********************************************************************/
3686bool request_transport(struct unit *pcargo, struct tile *ptile)
3687{
3688 return FALSE; /* Unit was not handled here. */
3689}
3690
3691/**********************************************************************/
3695void popup_combat_info(int attacker_unit_id, int defender_unit_id,
3696 int attacker_hp, int defender_hp,
3697 bool make_att_veteran, bool make_def_veteran)
3698{
3699}
#define ACTION_NONE
Definition actions.h:293
void astr_free(struct astring *astr)
Definition astring.c:153
#define str
Definition astring.c:76
#define n
Definition astring.c:77
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_CLR(bv, bit)
Definition bitvector.h:86
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
#define city_owner(_pcity_)
Definition city.h:543
void activate_all_units(struct tile *ptile)
void popup_city_dialog(struct city *pcity)
struct civclient client
enum client_states client_state(void)
#define client_player()
@ C_S_PREPARING
Definition client_main.h:46
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
struct unit * get_attacker(const struct civ_map *nmap, const struct unit *defender, const struct tile *ptile)
Definition combat.c:851
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender)
Definition combat.c:438
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile)
Definition combat.c:783
char * nationsets
Definition comments.c:52
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:507
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3027
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_disband(struct unit *punit)
Definition control.c:2002
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1863
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:290
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3067
struct unit * head_of_units_in_focus(void)
Definition control.c:411
void request_unit_upgrade(struct unit *punit)
Definition control.c:2033
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1854
@ HOVER_PARADROP
Definition control.h:28
@ HOVER_PATROL
Definition control.h:30
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction show_tileset_error
Definition dialogs_g.h:84
const char * caption
Definition dialogs_g.h:36
const char const char * headline
Definition dialogs_g.h:37
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction bool fatal
Definition dialogs_g.h:85
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction bool const char * tset_name
Definition dialogs_g.h:85
struct extra_type * extra_by_number(int id)
Definition extras.c:175
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define extra_index(_e_)
Definition extras.h:177
QString current_theme
Definition fc_client.cpp:65
#define NO_TARGET
Definition fc_types.h:324
int Tech_type_id
Definition fc_types.h:347
int Nation_type_id
Definition fc_types.h:350
int Unit_type_id
Definition fc_types.h:352
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:57
struct world wld
Definition game.c:58
void exit_goto_state(void)
Definition goto.c:1019
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Definition goto.c:1551
void enter_goto_state(struct unit_list *punits)
Definition goto.c:998
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
struct government * government_by_number(const Government_type_id gov)
Definition government.c:102
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Definition government.c:165
Government_type_id government_number(const struct government *pgovern)
Definition government.c:90
#define governments_iterate(NAME_pgov)
Definition government.h:121
#define governments_iterate_end
Definition government.h:124
void popdown_all_city_dialogs(void)
Definition citydlg.c:599
void city_report_dialog_popdown(void)
Definition cityrep.c:312
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:382
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1444
void races_update_pickable(bool nationset_change)
Definition dialogs.c:737
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:318
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:194
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1533
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1223
void popdown_races_dialog(void)
Definition dialogs.c:1238
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:343
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:243
bool handmade_scenario_warning(void)
Definition dialogs.c:1582
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:391
void races_toggles_set_sensitive(void)
Definition dialogs.c:1253
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.c:1592
struct player * races_player
Definition dialogs.c:73
void popdown_all_game_dialogs(void)
Definition dialogs.c:1523
void popdown_help_dialog(void)
Definition helpdlg.c:185
void flush_dirty(void)
Definition mapview.c:450
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:258
void meswin_dialog_popdown(void)
Definition messagewin.c:431
static GtkWidget * nation_button
Definition pages.c:1458
void popdown_players_dialog(void)
Definition plrdlg.c:105
void units_report_dialog_popdown(void)
Definition repodlgs.c:1780
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1257
void unit_select_dialog_popdown(void)
Definition unitselect.c:214
void enable_city_dlg_widgets(void)
Definition citydlg.c:1535
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
void free_city_units_lists(void)
Definition citydlg.c:819
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:52
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:108
static int adv_unit_sentry_idle_callback(struct widget *pwidget)
Definition dialogs.c:1570
static struct small_dialog * terrain_info_dlg
Definition dialogs.c:1259
void popup_government_dialog(void)
Definition dialogs.c:2449
static struct notify_goto_data * notify_goto_data_new(const char *headline, const char *lines, struct tile *ptile)
Definition dialogs.c:235
static int adv_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1533
static struct small_dialog * unit_disband_dlg
Definition dialogs.c:824
static void popdown_unit_upgrade_dlg(void)
Definition dialogs.c:812
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:875
static void popdown_unit_disband_dlg(void)
Definition dialogs.c:1012
static void notify_goto_data_destroy(struct notify_goto_data *pdata)
Definition dialogs.c:251
static int cma_callback(struct widget *pwidget)
Definition dialogs.c:1518
static struct small_dialog * connect_dlg
Definition dialogs.c:2384
bool is_unit_move_blocked
Definition gui_main.c:103
static int hurry_production_callback(struct widget *pwidget)
Definition dialogs.c:1502
static void select_random_leader(Nation_type_id nation)
Definition dialogs.c:3046
static int next_set_callback(struct widget *next_button)
Definition dialogs.c:2771
static int exit_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1041
void popdown_advanced_terrain_dialog(void)
Definition dialogs.c:1414
void popup_musicset_suggestion_dialog(void)
Definition dialogs.c:3635
#define ADV_NUM_SEEN
static void popdown_pillage_dialog(void)
Definition dialogs.c:2268
static struct advanced_dialog * unit_select_dlg
Definition dialogs.c:1024
static int notify_goto_dialog_callback(struct widget *widget)
Definition dialogs.c:260
int exit_advanced_terrain_dlg_callback(struct widget *pwidget)
Definition dialogs.c:1441
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:647
static int prev_set_callback(struct widget *prev_button)
Definition dialogs.c:2791
static int prev_name_callback(struct widget *prev_button)
Definition dialogs.c:2716
static int terrain_info_callback(struct widget *pwidget)
Definition dialogs.c:1454
void popup_soundset_suggestion_dialog(void)
Definition dialogs.c:3627
static int style_callback(struct widget *pwidget)
Definition dialogs.c:2823
static int unit_help_callback(struct widget *pwidget)
Definition dialogs.c:1678
static int move_government_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2437
static void popdown_government_dialog(void)
Definition dialogs.c:2410
static struct advanced_dialog * nation_dlg
Definition dialogs.c:2555
static int change_sex_callback(struct widget *sex)
Definition dialogs.c:2634
static int cancel_help_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2858
static int next_name_callback(struct widget *next_button)
Definition dialogs.c:2661
void popup_tileset_suggestion_dialog(void)
Definition dialogs.c:3619
#define TARGETS_ROW
static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
Definition dialogs.c:1323
static int get_playable_nation_count(void)
Definition dialogs.c:3090
static struct small_dialog * help_dlg
Definition dialogs.c:2556
struct advanced_dialog * advanced_terrain_dlg
Definition dialogs.c:1408
static void popdown_terrain_info_dialog(void)
Definition dialogs.c:1277
static int adv_unit_select_all_callback(struct widget *pwidget)
Definition dialogs.c:1552
static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog)
Definition dialogs.c:419
static int unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1054
static int exit_notify_dialog_callback(struct widget *pwidget)
Definition dialogs.c:490
void popdown_notify_goto_dialog(void)
Definition dialogs.c:456
int advanced_terrain_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1429
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition dialogs.c:632
static int nation_button_callback(struct widget *pnation)
Definition dialogs.c:2877
static int races_dialog_cancel_callback(struct widget *button)
Definition dialogs.c:2810
static int notify_goto_dialog_close_callback(struct widget *widget)
Definition dialogs.c:275
static int leader_name_edit_callback(struct widget *pedit)
Definition dialogs.c:2999
static int patrol_here_callback(struct widget *pwidget)
Definition dialogs.c:1616
static int pillage_window_callback(struct widget *pwindow)
Definition dialogs.c:2222
static int help_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2850
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.c:3643
static int disband_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:829
static int nations_dialog_callback(struct widget *pwindow)
Definition dialogs.c:2588
static void notify_goto_dialog_update(struct notify_goto_dialog *pdialog)
Definition dialogs.c:373
void popdown_diplomat_dialog(void)
void real_multipliers_dialog_update(void *unused)
Definition dialogs.c:3678
static int goto_here_callback(struct widget *pwidget)
Definition dialogs.c:1597
static struct small_dialog * gov_dlg
Definition dialogs.c:2405
static int notify_goto_dialog_goto_callback(struct widget *widget)
Definition dialogs.c:290
bool request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.c:3686
static void change_nation_label(void)
Definition dialogs.c:3019
#define NUM_SEEN
static struct small_dialog * pillage_dlg
Definition dialogs.c:2217
void nationset_changed(void)
Definition dialogs.c:3556
void popdown_incite_dialog(void)
static int races_dialog_ok_callback(struct widget *start_button)
Definition dialogs.c:2602
void popdown_bribe_dialog(void)
static void notify_goto_dialog_destroy(struct notify_goto_dialog *pdialog)
Definition dialogs.c:354
static int cancel_disband_unit_callback(struct widget *pwidget)
Definition dialogs.c:841
#define TARGETS_COL
static int change_production_callback(struct widget *pwidget)
Definition dialogs.c:1487
static int exit_pillage_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2255
static int terrain_info_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1265
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:680
static int zoom_to_city_callback(struct widget *pwidget)
Definition dialogs.c:1471
static bool sdl_get_chance_to_win(int *att_chance, int *def_chance, struct unit *enemy_unit, struct unit *my_unit)
Definition dialogs.c:191
static int government_dlg_callback(struct widget *gov_button)
Definition dialogs.c:2423
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1303
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:620
static int notify_dialog_window_callback(struct widget *pwindow)
Definition dialogs.c:478
static int unit_select_window_callback(struct widget *pwindow)
Definition dialogs.c:1029
static struct small_dialog * unit_upgrade_dlg
Definition dialogs.c:615
static int exit_terrain_info_dialog_callback(struct widget *button)
Definition dialogs.c:1290
static int paradrop_here_callback(struct widget *pwidget)
Definition dialogs.c:1645
static int ok_disband_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:856
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1694
static struct notify_goto_dialog * notify_goto_dialog_new(void)
Definition dialogs.c:315
static void popdown_connect_dialog(void)
Definition dialogs.c:2390
static char * leader_name
Definition dialogs.c:96
struct advanced_dialog * notify_dlg
Definition dialogs.c:473
void popdown_find_dialog(void)
Definition finddlg.c:109
void popdown_goto_airlift_dialog(void)
Definition gotodlg.c:423
int main_window_width(void)
Definition graphics.c:685
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:148
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1378
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1347
int main_window_height(void)
Definition graphics.c:693
#define DEFAULT_ZOOM
Definition graphics.h:198
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
void force_exit_from_event_loop(void)
Definition gui_main.c:556
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:138
#define PRESSED_EVENT(event)
Definition gui_main.h:68
void popup_unit_info(Unit_type_id type_id)
Definition helpdlg.c:632
void popdown_intel_dialogs(void)
Definition inteldlg.c:214
void popdown_newcity_dialog(void)
Definition mapctrl.c:2897
void enable_and_redraw_revolution_button(void)
Definition mapctrl.c:2245
SDL_Surface * get_terrain_surface(struct tile *ptile)
Definition mapview.c:1217
void flush_all(void)
Definition mapview.c:201
void undraw_order_widgets(void)
Definition menu.c:979
void popdown_optiondlg(bool leave_game)
Definition optiondlg.c:1451
void popdown_players_nations_dialog(void)
Definition plrdlg.c:875
void science_report_dialogs_popdown_all(void)
Definition repodlgs.c:3481
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1050
void popdown_worklist_editor(void)
Definition wldlg.c:1836
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:202
@ ID_NATION_WIZARD_WINDOW
Definition gui_id.h:60
@ ID_UNIT_SELECT_DLG_WINDOW
Definition gui_id.h:195
@ ID_NATION_WIZARD_START_BUTTON
Definition gui_id.h:61
@ ID_NATION_WIZARD_NEXT_LEADER_NAME_BUTTON
Definition gui_id.h:66
@ ID_UNIT_SELECT_DLG_EXIT_BUTTON
Definition gui_id.h:198
@ ID_NATION_WIZARD_CHANGE_SEX_BUTTON
Definition gui_id.h:68
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:203
@ ID_BUTTON
Definition gui_id.h:29
@ ID_TERRAIN_INFO_DLG_WINDOW
Definition gui_id.h:200
@ ID_TERRAIN_INFO_DLG_EXIT_BUTTON
Definition gui_id.h:201
@ ID_NATION_PREV_NATIONSET_BUTTON
Definition gui_id.h:70
@ ID_NATION_NEXT_NATIONSET_BUTTON
Definition gui_id.h:69
@ ID_NATION_WIZARD_DISCONNECT_BUTTON
Definition gui_id.h:64
@ ID_SEPARATOR
Definition gui_id.h:28
@ ID_LABEL
Definition gui_id.h:27
@ ID_WINDOW
Definition gui_id.h:30
@ ID_PILLAGE_DLG_EXIT_BUTTON
Definition gui_id.h:205
@ ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON
Definition gui_id.h:67
@ ID_PILLAGE_DLG_WINDOW
Definition gui_id.h:204
@ ID_NATION_WIZARD_LEADER_NAME_EDIT
Definition gui_id.h:65
@ ID_GOVERNMENT_DLG_WINDOW
Definition gui_id.h:145
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
#define FREEUTF8STR(pstr)
Definition gui_string.h:92
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:68
@ FONTO_DEFAULT
Definition gui_string.h:64
@ FONTO_BIG
Definition gui_string.h:69
@ FONTO_ATTENTION
Definition gui_string.h:66
@ FONTO_MAX
Definition gui_string.h:70
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
static SDL_Surface * get_government_surface(const struct government *gov)
static SDL_Surface * get_nation_flag_surface(const struct nation_type *pnation)
static SDL_Surface * get_sample_city_surface(int city_style)
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:4871
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define log_debug(message,...)
Definition log.h:115
#define log_error(message,...)
Definition log.h:103
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:417
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:628
static int index_to_map_pos_y(int mindex)
Definition map.h:696
static int index_to_map_pos_x(int mindex)
Definition map.h:687
void center_tile_mapcanvas(const struct tile *ptile)
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
static mpgui * gui
Definition mpgui_qt.cpp:52
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:289
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:168
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:474
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:187
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:229
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:817
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:199
int nation_set_count(void)
Definition nation.c:690
struct nation_set * nation_set_by_number(int id)
Definition nation.c:761
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:158
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:858
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:497
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:280
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:671
#define nations_iterate_end
Definition nation.h:335
#define nations_iterate(NAME_pnation)
Definition nation.h:332
const struct option_set * server_optset
Definition options.c:4009
bool option_str_set(struct option *poption, const char *str)
Definition options.c:901
const char * option_str_get(const struct option *poption)
Definition options.c:868
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:406
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
void set_government_choice(struct government *government)
Definition packhand.c:2504
char * lines
Definition packhand.c:129
int len
Definition packhand.c:125
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1205
int player_number(const struct player *pplayer)
Definition player.c:828
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1435
#define fc_rand(_size)
Definition rand.h:34
#define MAX(x, y)
Definition shared.h:54
struct widget * active_widget_list
Definition widget.h:186
struct widget * end_widget_list
Definition widget.h:182
struct widget * begin_widget_list
Definition widget.h:181
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_active_widget_list
Definition widget.h:185
struct scroll_bar * scroll
Definition widget.h:187
Definition city.h:309
struct government * government_during_revolution
Definition game.h:94
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:156
int id1
Definition widget.h:104
int id0
Definition widget.h:103
SDL_Surface * surface
Definition graphics.h:229
struct widget * pset_name
Definition dialogs.c:2568
struct widget * pset_prev
Definition dialogs.c:2570
unsigned char selected_leader
Definition dialogs.c:2560
struct widget * name_edit
Definition dialogs.c:2565
struct widget * pset_next
Definition dialogs.c:2569
bool leader_sex
Definition dialogs.c:2562
struct widget * name_next
Definition dialogs.c:2566
unsigned char nation_style
Definition dialogs.c:2559
struct widget * change_sex
Definition dialogs.c:2564
Nation_type_id nation
Definition dialogs.c:2561
struct nation_set * set
Definition dialogs.c:2563
struct widget * name_prev
Definition dialogs.c:2567
struct tile * ptile
Definition dialogs.c:214
char * headline
Definition dialogs.c:212
struct widget * label
Definition dialogs.c:224
struct notify_goto_list * datas
Definition dialogs.c:225
struct widget * close_button
Definition dialogs.c:223
struct widget * window
Definition dialogs.c:222
struct widget * up_left_button
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
Definition tile.h:49
struct unit_list * units
Definition tile.h:57
int defense_strength
Definition unittype.h:496
int firepower
Definition unittype.h:506
int move_rate
Definition unittype.h:497
int attack_strength
Definition unittype.h:495
Definition unit.h:138
int id
Definition unit.h:145
int hp
Definition unit.h:151
int veteran
Definition unit.h:152
Uint8 style
Definition gui_string.h:53
SDL_Color fgcol
Definition gui_string.h:57
char * text
Definition gui_string.h:60
Uint8 render
Definition gui_string.h:54
struct widget * next
Definition widget.h:113
void * ptr
Definition widget.h:133
utf8_str * info_label
Definition widget.h:122
SDL_Keycode key
Definition widget.h:153
union widget::@214 data
struct gui_layer * dst
Definition widget.h:116
struct widget * prev
Definition widget.h:114
int(* action)(struct widget *)
Definition widget.h:157
struct unit * unit
Definition widget.h:129
struct city * city
Definition widget.h:128
struct container * cont
Definition widget.h:127
SDL_Surface * theme
Definition widget.h:118
utf8_str * string_utf8
Definition widget.h:121
SDL_Rect area
Definition widget.h:149
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
struct civ_map map
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:538
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1356
const char * popup_info_text(struct tile *ptile)
Definition text.c:146
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_NATIONDLG
@ BACKGROUND_CHOOSEGOVERNMENTDLG
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
@ COLOR_THEME_ADVANCEDTERRAINDLG_TEXT
Definition themecolors.h:45
@ COLOR_THEME_UNITUPGRADE_TEXT
@ COLOR_THEME_NATIONDLG_LEGEND
@ COLOR_THEME_UNITDISBAND_TEXT
@ COLOR_THEME_NATIONDLG_TEXT
@ COLOR_THEME_NATIONDLG_FRAME
struct theme * active_theme
Definition themespec.c:154
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:87
#define tile_terrain(_tile)
Definition tile.h:109
#define TILE_XY(ptile)
Definition tile.h:42
#define tile_has_extra(ptile, pextra)
Definition tile.h:146
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2035
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:826
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1174
#define unit_tile(_pu)
Definition unit.h:395
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:455
@ ORDER_LAST
Definition unit.h:49
#define unit_owner(_pu)
Definition unit.h:394
unit_upgrade_result
Definition unit.h:60
@ UU_OK
Definition unit.h:61
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2658
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:184
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
void del_widget_pointer_from_gui_list(struct widget *gui)
Definition widget.c:621
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:585
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:577
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:601
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:997
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1050
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:982
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1038
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_PRESSED
Definition widget.h:98
@ FC_WS_SELECTED
Definition widget.h:97
#define disable(id)
Definition widget.h:229
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_FREE_GFX
Definition widget.h:70
@ WF_ICON_CENTER
Definition widget.h:83
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_ICON_ABOVE_TEXT
Definition widget.h:81
@ WF_FREE_DATA
Definition widget.h:78
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define enable(id)
Definition widget.h:223
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
struct widget * create_icon_button(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_icon_button_from_chars_fonto(icon, pdest, char_string, fonto, flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
void remake_label_size(struct widget *label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
#define create_active_iconlabel(buf, pdest, pstr, pstring, cb)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
int resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
float map_zoom
Definition zoom.c:25