Freeciv-3.2
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 "sex.h"
46#include "unitlist.h"
47
48/* client */
49#include "client_main.h"
50#include "climap.h" /* for client_tile_get_known() */
51#include "goto.h"
52#include "helpdata.h" /* for helptext_nation() */
53#include "packhand.h"
54#include "text.h"
55#include "zoom.h"
56
57/* gui-sdl2 */
58#include "chatline.h"
59#include "citydlg.h"
60#include "cityrep.h"
61#include "cma_fe.h"
62#include "colors.h"
63#include "finddlg.h"
64#include "gotodlg.h"
65#include "graphics.h"
66#include "gui_id.h"
67#include "gui_main.h"
68#include "gui_tilespec.h"
69#include "helpdlg.h"
70#include "inteldlg.h"
71#include "mapctrl.h"
72#include "mapview.h"
73#include "menu.h"
74#include "messagewin.h"
75#include "optiondlg.h"
76#include "plrdlg.h"
77#include "ratesdlg.h"
78#include "repodlgs.h"
79#include "sprite.h"
80#include "themespec.h"
81#include "widget.h"
82#include "wldlg.h"
83
84#include "dialogs.h"
85
87
88extern bool is_unit_move_blocked;
89extern void popdown_diplomat_dialog(void);
90extern void popdown_incite_dialog(void);
91extern void popdown_bribe_dialog(void);
92
96
97static char *leader_name = NULL;
98
99static void unit_select_dialog_popdown(void);
100static void popdown_terrain_info_dialog(void);
101static void popdown_pillage_dialog(void);
102static void popdown_connect_dialog(void);
103static void popdown_unit_upgrade_dlg(void);
104static void popdown_unit_disband_dlg(void);
105
106/**********************************************************************/
109void put_window_near_map_tile(struct widget *pwindow,
111 struct tile *ptile)
112{
113 float canvas_x, canvas_y;
114 int window_x = 0, window_y = 0;
115
118 if (canvas_x - window_width < 0) {
120 } else {
122 }
123 } else {
125 }
126
130 } else {
131 if (canvas_y < 0) {
132 window_y = 0;
133 } else {
135 }
136 }
137 } else {
140 }
141
143}
144
145/**********************************************************************/
184
185/* ======================================================================= */
186
187/**********************************************************************/
193 struct unit *enemy_unit,
194 struct unit *my_unit)
195{
196 if (!my_unit || !enemy_unit) {
197 return FALSE;
198 }
199
200 /* Chance to win when active unit is attacking the selected unit */
202 enemy_unit, NULL) * 100;
203
204 /* Chance to win when selected unit is attacking the active unit */
206 my_unit, NULL)) * 100;
207
208 return TRUE;
209}
210
211/**************************************************************************
212 Notify goto dialog.
213**************************************************************************/
215 char *headline;
216 char *lines;
217 struct tile *ptile;
218};
219
220#define SPECLIST_TAG notify_goto
221#define SPECLIST_TYPE struct notify_goto_data
222#include "speclist.h"
223
230
232
233static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog);
234
235/**********************************************************************/
239 const char *lines,
240 struct tile *ptile)
241{
242 struct notify_goto_data *pdata = fc_malloc(sizeof(*pdata));
243
244 pdata->headline = fc_strdup(headline);
245 pdata->lines = fc_strdup(lines);
246 pdata->ptile = ptile;
247
248 return pdata;
249}
250
251/**********************************************************************/
255{
256 free(pdata->headline);
257 free(pdata->lines);
258}
259
260/**********************************************************************/
264{
265 struct notify_goto_dialog *pdialog =
266 (struct notify_goto_dialog *) widget->data.ptr;
267
269 move_window_group(pdialog->label, pdialog->window);
270 }
271
272 return -1;
273}
274
275/**********************************************************************/
279{
280 struct notify_goto_dialog *pdialog =
281 (struct notify_goto_dialog *) widget->data.ptr;
282
285 }
286
287 return -1;
288}
289
290/**********************************************************************/
294{
295 struct notify_goto_dialog *pdialog =
296 (struct notify_goto_dialog *) widget->data.ptr;
297 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
298 0);
299
301 if (NULL != pdata->ptile) {
303 }
304 } else if (main_data.event.button.button == SDL_BUTTON_RIGHT) {
305 struct city *pcity;
306
307 if (NULL != pdata->ptile && (pcity = tile_city(pdata->ptile))) {
308 popup_city_dialog(pcity);
309 }
310 }
311
312 return -1;
313}
314
315/**********************************************************************/
319{
320 struct notify_goto_dialog *pdialog = fc_malloc(sizeof(*pdialog));
321 utf8_str *str;
322
323 /* Window. */
325 str->style |= TTF_STYLE_BOLD;
326
327 pdialog->window = create_window_skeleton(NULL, str, 0);
329 pdialog->window->data.ptr = pdialog;
330 set_wstate(pdialog->window, FC_WS_NORMAL);
332
333 /* Close button. */
334 pdialog->close_button = create_themeicon(current_theme->small_cancel_icon,
335 pdialog->window->dst,
338 pdialog->close_button->info_label
339 = create_utf8_from_char_fonto(_("Close Dialog (Esc)"), FONTO_ATTENTION);
341 pdialog->close_button->data.ptr = pdialog;
343 pdialog->close_button->key = SDLK_ESCAPE;
345
346 pdialog->label = NULL;
347
348 /* Data list. */
350
351 return pdialog;
352}
353
354/**********************************************************************/
358{
359 widget_undraw(pdialog->window);
360 widget_mark_dirty(pdialog->window);
361 remove_gui_layer(pdialog->window->dst);
362
365 if (NULL != pdialog->label) {
367 }
368
370 free(pdialog);
371}
372
373/**********************************************************************/
377{
378 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
379 0);
380
381 if (NULL == pdata) {
382 return;
383 }
384
385 widget_undraw(pdialog->window);
386 widget_mark_dirty(pdialog->window);
387
388 copy_chars_to_utf8_str(pdialog->window->string_utf8, pdata->headline);
389 if (NULL != pdialog->label) {
391 }
393 pdata->lines,
397 pdialog->label->data.ptr = pdialog;
398 set_wstate(pdialog->label, FC_WS_NORMAL);
399 add_to_gui_list(ID_LABEL, pdialog->label);
400
401 resize_window(pdialog->window, NULL, NULL,
402 adj_size(pdialog->label->size.w + 40),
403 adj_size(pdialog->label->size.h + 60));
405 (main_window_width() - pdialog->window->size.w) / 2,
406 (main_window_height() - pdialog->window->size.h) / 2);
407 widget_set_position(pdialog->close_button, pdialog->window->size.w
408 - pdialog->close_button->size.w - 1,
409 pdialog->window->size.y + adj_size(2));
410 widget_set_position(pdialog->label, adj_size(20), adj_size(40));
411
412 widget_redraw(pdialog->window);
413 widget_redraw(pdialog->close_button);
414 widget_redraw(pdialog->label);
415 widget_mark_dirty(pdialog->window);
416 flush_all();
417}
418
419/**********************************************************************/
423{
424 if (1 < notify_goto_list_size(pdialog->datas)) {
426 notify_goto_list_get(pdialog->datas, 0));
428 } else {
430 if (pdialog == notify_goto_dialog) {
432 }
433 }
434}
435
436/**********************************************************************/
455
456/**********************************************************************/
466
467/**********************************************************************/
470void popup_connect_msg(const char *headline, const char *message)
471{
472 log_error("popup_connect_msg() PORT ME");
473}
474
475/* ----------------------------------------------------------------------- */
477
478/**********************************************************************/
481static int notify_dialog_window_callback(struct widget *pwindow)
482{
485 }
486
487 return -1;
488}
489
490/**********************************************************************/
493static int exit_notify_dialog_callback(struct widget *pwidget)
494{
496 if (notify_dlg) {
501 flush_dirty();
502 }
503 }
504
505 return -1;
506}
507
508/**********************************************************************/
511void popup_notify_dialog(const char *caption, const char *headline,
512 const char *lines)
513{
514 struct widget *buf, *pwindow;
515 utf8_str *pstr;
519
520 if (notify_dlg) {
521 return;
522 }
523
524 notify_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
525
527 pstr->style |= TTF_STYLE_BOLD;
528
529 pwindow = create_window_skeleton(NULL, pstr, 0);
530
532 set_wstate(pwindow, FC_WS_NORMAL);
533
534 add_to_gui_list(ID_WINDOW, pwindow);
535 notify_dlg->end_widget_list = pwindow;
536
537 area = pwindow->area;
538
539 /* ---------- */
540 /* Create exit button */
541 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
543 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
547 buf->key = SDLK_ESCAPE;
548 area.w += (buf->size.w + adj_size(10));
549
552
554 pstr->style |= TTF_STYLE_BOLD;
555
557
558 if (lines && *lines != '\0') {
560 pstr->style &= ~TTF_STYLE_BOLD;
563 } else {
565 }
566
568
569 area.w = MAX(area.w, headline_surf->w);
570 if (lines_surf) {
571 area.w = MAX(area.w, lines_surf->w);
572 }
573 area.w += adj_size(60);
574 area.h = MAX(area.h, adj_size(10) + headline_surf->h + adj_size(10));
575 if (lines_surf) {
576 area.h += lines_surf->h + adj_size(10);
577 }
578
580 (pwindow->size.w - pwindow->area.w) + area.w,
581 (pwindow->size.h - pwindow->area.h) + area.h);
582
583 area = pwindow->area;
584
585 widget_set_position(pwindow,
586 (main_window_width() - pwindow->size.w) / 2,
587 (main_window_height() - pwindow->size.h) / 2);
588
589 dst.x = area.x + (area.w - headline_surf->w) / 2;
590 dst.y = area.y + adj_size(10);
591
592 alphablit(headline_surf, NULL, pwindow->theme, &dst, 255);
593 if (lines_surf) {
594 dst.y += headline_surf->h + adj_size(10);
595 if (headline_surf->w < lines_surf->w) {
596 dst.x = area.x + (area.w - lines_surf->w) / 2;
597 }
598
599 alphablit(lines_surf, NULL, pwindow->theme, &dst, 255);
600 }
601
604
605 /* exit button */
606 buf = pwindow->prev;
607 buf->size.x = area.x + area.w - buf->size.w - 1;
608 buf->size.y = pwindow->size.y + adj_size(2);
609
610 /* redraw */
612 widget_flush(pwindow);
613}
614
615/* =======================================================================*/
616/* ========================= UNIT UPGRADE DIALOG =========================*/
617/* =======================================================================*/
619
620/**********************************************************************/
623static int upgrade_unit_window_callback(struct widget *pwindow)
624{
627 }
628
629 return -1;
630}
631
632/**********************************************************************/
635static int cancel_upgrade_unit_callback(struct widget *pwidget)
636{
639 /* enable city dlg */
641 flush_dirty();
642 }
643
644 return -1;
645}
646
647/**********************************************************************/
650static int ok_upgrade_unit_window_callback(struct widget *pwidget)
651{
653 struct unit *punit = pwidget->data.unit;
654
656 /* enable city dlg */
660 flush_dirty();
661 }
662
663 return -1;
664}
665
666/***********************************************************************/
669void popup_upgrade_dialog(struct unit_list *punits)
670{
671 /* PORTME: is support for more than one unit in punits required? */
672
673 /* Assume only one unit for now. */
675 "SDL2 popup_upgrade_dialog() handles max 1 unit.");
676
678}
679
680/**********************************************************************/
684{
685 char cbuf[128];
686 struct widget *buf = NULL, *pwindow;
687 utf8_str *pstr;
688 SDL_Surface *text;
690 int window_x = 0, window_y = 0;
693
694 if (unit_upgrade_dlg) {
695 /* just in case */
696 flush_dirty();
697 return;
698 }
699
700 unit_upgrade_dlg = fc_calloc(1, sizeof(struct small_dialog));
701
703
704 pstr = create_utf8_from_char_fonto(_("Upgrade Obsolete Units"),
706 pstr->style |= TTF_STYLE_BOLD;
707
708 pwindow = create_window_skeleton(NULL, pstr, 0);
709
710 pwindow->action = upgrade_unit_window_callback;
711 set_wstate(pwindow, FC_WS_NORMAL);
712
714
715 add_to_gui_list(ID_WINDOW, pwindow);
716
717 area = pwindow->area;
718
719 /* ============================================================= */
720
721 /* Create text label */
723 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
725
728
729 area.w = MAX(area.w, text->w + adj_size(20));
730 area.h += (text->h + adj_size(10));
731
732 /* Cancel button */
734 pwindow->dst, _("Cancel"),
735 FONTO_ATTENTION, 0);
736
739
740 area.h += (buf->size.h + adj_size(20));
741
743
744 if (UU_OK == unit_upgrade_result) {
746 pwindow->dst,
747 _("Upgrade"),
748 FONTO_ATTENTION, 0);
749
752 buf->data.unit = punit;
754 buf->size.w = MAX(buf->size.w, buf->next->size.w);
755 buf->next->size.w = buf->size.w;
756 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
757 } else {
758 area.w = MAX(area.w, buf->size.w + adj_size(20));
759 }
760 /* ============================================ */
761
763
765 (pwindow->size.w - pwindow->area.w) + area.w,
766 (pwindow->size.h - pwindow->area.h) + area.h);
767
768 area = pwindow->area;
769
770 if (city) {
771 window_x = main_data.event.motion.x;
772 window_y = main_data.event.motion.y;
773 } else {
774 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
776 }
777
779
780 /* setup rest of widgets */
781 /* label */
782 dst.x = area.x + (area.w - text->w) / 2;
783 dst.y = area.y + adj_size(10);
784 alphablit(text, NULL, pwindow->theme, &dst, 255);
785 FREESURFACE(text);
786
787 /* cancel button */
788 buf = pwindow->prev;
789 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
790
791 if (UU_OK == unit_upgrade_result) {
792 /* upgrade button */
793 buf = buf->prev;
794 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
795 buf->size.y = buf->next->size.y;
796
797 /* cancel button */
798 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
799 } else {
800 /* x position of cancel button */
801 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
802 }
803
804 /* ================================================== */
805 /* redraw */
807
808 widget_mark_dirty(pwindow);
809 flush_dirty();
810}
811
812/**********************************************************************/
823
824/* =======================================================================*/
825/* ========================= UNIT DISBAND DIALOG =========================*/
826/* =======================================================================*/
828
829/**********************************************************************/
832static int disband_unit_window_callback(struct widget *pwindow)
833{
836 }
837
838 return -1;
839}
840
841/**********************************************************************/
844static int cancel_disband_unit_callback(struct widget *pwidget)
845{
848 /* enable city dlg */
850 flush_dirty();
851 }
852
853 return -1;
854}
855
856/**********************************************************************/
859static int ok_disband_unit_window_callback(struct widget *pwidget)
860{
862 struct unit *punit = pwidget->data.unit;
863
865 /* enable city dlg */
869 flush_dirty();
870 }
871
872 return -1;
873}
874
875/**********************************************************************/
879{
880 char cbuf[128];
881 struct widget *buf = NULL, *pwindow;
882 utf8_str *pstr;
883 SDL_Surface *text;
885 int window_x = 0, window_y = 0;
888
889 if (unit_disband_dlg) {
890 /* just in case */
891 flush_dirty();
892 return;
893 }
894
895 unit_disband_dlg = fc_calloc(1, sizeof(struct small_dialog));
896
897 {
898 struct unit_list *punits = unit_list_new();
899
903 }
904
906 pstr->style |= TTF_STYLE_BOLD;
907
908 pwindow = create_window_skeleton(NULL, pstr, 0);
909
910 pwindow->action = disband_unit_window_callback;
911 set_wstate(pwindow, FC_WS_NORMAL);
912
914
915 add_to_gui_list(ID_WINDOW, pwindow);
916
917 area = pwindow->area;
918
919 /* ============================================================= */
920
921 /* Create text label */
923 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
925
928
929 area.w = MAX(area.w, text->w + adj_size(20));
930 area.h += (text->h + adj_size(10));
931
932 /* Cancel button */
934 pwindow->dst, _("Cancel"),
935 FONTO_ATTENTION, 0);
936
939
940 area.h += (buf->size.h + adj_size(20));
941
943
946 pwindow->dst,
947 _("Disband"),
948 FONTO_ATTENTION, 0);
949
952 buf->data.unit = punit;
954 buf->size.w = MAX(buf->size.w, buf->next->size.w);
955 buf->next->size.w = buf->size.w;
956 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
957 } else {
958 area.w = MAX(area.w, buf->size.w + adj_size(20));
959 }
960 /* ============================================ */
961
963
965 (pwindow->size.w - pwindow->area.w) + area.w,
966 (pwindow->size.h - pwindow->area.h) + area.h);
967
968 area = pwindow->area;
969
970 if (city) {
971 window_x = main_data.event.motion.x;
972 window_y = main_data.event.motion.y;
973 } else {
974 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
976 }
977
979
980 /* setup rest of widgets */
981 /* label */
982 dst.x = area.x + (area.w - text->w) / 2;
983 dst.y = area.y + adj_size(10);
984 alphablit(text, NULL, pwindow->theme, &dst, 255);
985 FREESURFACE(text);
986
987 /* cancel button */
988 buf = pwindow->prev;
989 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
990
992 /* disband button */
993 buf = buf->prev;
994 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
995 buf->size.y = buf->next->size.y;
996
997 /* cancel button */
998 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
999 } else {
1000 /* x position of cancel button */
1001 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
1002 }
1003
1004 /* ================================================== */
1005 /* redraw */
1007
1008 widget_mark_dirty(pwindow);
1009 flush_dirty();
1010}
1011
1012/**********************************************************************/
1023
1024/* =======================================================================*/
1025/* ======================== UNIT SELECTION DIALOG ========================*/
1026/* =======================================================================*/
1028
1029/**********************************************************************/
1032static int unit_select_window_callback(struct widget *pwindow)
1033{
1036 }
1037
1038 return -1;
1039}
1040
1041/**********************************************************************/
1044static int exit_unit_select_callback(struct widget *pwidget)
1045{
1049 }
1050
1051 return -1;
1052}
1053
1054/**********************************************************************/
1057static int unit_select_callback(struct widget *pwidget)
1058{
1060 struct unit *punit =
1062
1064 if (punit) {
1067 }
1068 }
1069
1070 return -1;
1071}
1072
1073/**********************************************************************/
1088
1089/**********************************************************************/
1093{
1094 struct widget *buf = NULL, *pwindow;
1095 utf8_str *pstr;
1096 struct unit *punit = NULL, *focus = head_of_units_in_focus();
1097 const struct unit_type *punittype;
1098 char cbuf[255];
1099 int i, w = 0, n;
1100 SDL_Rect area;
1101
1102#define NUM_SEEN 20
1103
1104 n = unit_list_size(ptile->units);
1105
1106 if (n == 0 || unit_select_dlg) {
1107 return;
1108 }
1109
1111 unit_select_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1112
1113 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Unit selection"), n);
1115 pstr->style |= TTF_STYLE_BOLD;
1116
1117 pwindow = create_window_skeleton(NULL, pstr, 0);
1118
1119 pwindow->action = unit_select_window_callback;
1120 set_wstate(pwindow, FC_WS_NORMAL);
1121
1124
1125 area = pwindow->area;
1126
1127 /* ---------- */
1128 /* Create exit button */
1129 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1131 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1135 buf->key = SDLK_ESCAPE;
1136 area.w += (buf->size.w + adj_size(10));
1137
1139
1140 /* ---------- */
1141
1142 for (i = 0; i < n; i++) {
1143 const char *vetname;
1144
1145 punit = unit_list_get(ptile->units, i);
1148
1150 struct astring addition = ASTRING_INIT;
1151
1153 fc_snprintf(cbuf , sizeof(cbuf), _("Contact %s (%d / %d) %s(%d,%d,%s) %s"),
1154 (vetname != NULL ? vetname : ""),
1155 punit->hp, punittype->hp,
1157 punittype->attack_strength,
1158 punittype->defense_strength,
1159 move_points_text(punittype->move_rate, FALSE),
1160 astr_str(&addition));
1162 } else {
1164
1165 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1167 (vetname != NULL ? vetname : ""),
1169 punittype->attack_strength,
1170 punittype->defense_strength,
1171 move_points_text(punittype->move_rate, FALSE),
1172 punittype->firepower,
1173 (punit->hp * 100 / punittype->hp + 9) / 10);
1174
1175 /* Calculate chance to win */
1177 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1178 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1180 }
1181 }
1182
1183 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf,
1185
1187
1188 area.w = MAX(area.w, buf->size.w);
1189 area.h += buf->size.h;
1192 }
1193
1194 if (i > NUM_SEEN - 1) {
1196 }
1197 }
1198
1203
1204 area.w += adj_size(2);
1205 if (n > NUM_SEEN) {
1207 area.w += n;
1208
1209 /* ------- window ------- */
1210 area.h = NUM_SEEN * pwindow->prev->prev->size.h;
1211 }
1212
1213 resize_window(pwindow, NULL, NULL,
1214 (pwindow->size.w - pwindow->area.w) + area.w,
1215 (pwindow->size.h - pwindow->area.h) + area.h);
1216
1217 area = pwindow->area;
1218
1219 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1220 ptile);
1221
1222 w = area.w;
1223
1224 if (unit_select_dlg->scroll) {
1225 w -= n;
1226 }
1227
1228 /* exit button */
1229 buf = pwindow->prev;
1230 buf->size.x = area.x + area.w - buf->size.w - 1;
1231 buf->size.y = pwindow->size.y + adj_size(2);
1232 buf = buf->prev;
1233
1234 setup_vertical_widgets_position(1, area.x + 1, area.y, w, 0,
1236 buf);
1237
1238 if (unit_select_dlg->scroll) {
1240 area.x + area.w, area.y,
1241 area.h, TRUE);
1242 }
1243
1244 /* ==================================================== */
1245 /* redraw */
1247
1248 widget_flush(pwindow);
1249}
1250
1251/**********************************************************************/
1255{
1256 /* PORTME */
1257}
1258
1259/* ====================================================================== */
1260/* ============================ TERRAIN INFO ============================ */
1261/* ====================================================================== */
1263
1264
1265/**********************************************************************/
1268static int terrain_info_window_dlg_callback(struct widget *pwindow)
1269{
1272 }
1273
1274 return -1;
1275}
1276
1277/**********************************************************************/
1289
1290/**********************************************************************/
1294{
1297 }
1298
1299 return -1;
1300}
1301
1302/**********************************************************************/
1306const char *sdl_get_tile_defense_info_text(struct tile *ptile)
1307{
1308 static char buffer[64];
1309 int bonus = (tile_terrain(ptile)->defense_bonus - 10) * 10;
1310
1311 extra_type_iterate(pextra) {
1312 if (tile_has_extra(ptile, pextra)
1313 && pextra->category == ECAT_NATURAL) {
1314 bonus += pextra->defense_bonus;
1315 }
1317
1318 fc_snprintf(buffer, sizeof(buffer), _("Terrain Defense Bonus: +%d%% "), bonus);
1319
1320 return buffer;
1321}
1322
1323/**********************************************************************/
1327{
1328 SDL_Surface *surf;
1329 struct widget *buf, *pwindow;
1330 utf8_str *pstr;
1331 char cbuf[256];
1332 SDL_Rect area;
1333
1334 if (terrain_info_dlg) {
1335 flush_dirty();
1336 return;
1337 }
1338
1339 surf = get_terrain_surface(ptile);
1340 terrain_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1341
1342 /* ----------- */
1343 fc_snprintf(cbuf, sizeof(cbuf), "%s [%d,%d]", _("Terrain Info"),
1344 TILE_XY(ptile));
1345
1346 pwindow
1349 0);
1350 pwindow->string_utf8->style |= TTF_STYLE_BOLD;
1351
1353 set_wstate(pwindow, FC_WS_NORMAL);
1354
1357
1358 area = pwindow->area;
1359
1360 /* ---------- */
1363 pstr->style |= SF_CENTER;
1364 buf = create_iconlabel(surf, pwindow->dst, pstr, 0);
1365
1366 buf->size.h += tileset_tile_height(tileset) / 2;
1367
1369
1370 /* ------ window ---------- */
1371 area.w = MAX(area.w, buf->size.w + adj_size(20));
1372 area.h = MAX(area.h, buf->size.h);
1373
1375 (pwindow->size.w - pwindow->area.w) + area.w,
1376 (pwindow->size.h - pwindow->area.h) + area.h);
1377
1378 area = pwindow->area;
1379
1380 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, ptile);
1381
1382 /* ------------------------ */
1383
1384 buf->size.x = area.x + adj_size(10);
1385 buf->size.y = area.y;
1386
1387 /* Exit icon */
1388 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1390 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1392 buf->size.x = area.x + area.w - buf->size.w - 1;
1393 buf->size.y = pwindow->size.y + adj_size(2);
1396 buf->key = SDLK_ESCAPE;
1397
1399
1401 /* --------------------------------- */
1402 /* redraw */
1404 widget_mark_dirty(pwindow);
1405 flush_dirty();
1406}
1407
1408/* ====================================================================== */
1409/* ========================= ADVANCED_TERRAIN_MENU ====================== */
1410/* ====================================================================== */
1412
1413/**********************************************************************/
1428
1429/**********************************************************************/
1433{
1436 }
1437
1438 return -1;
1439}
1440
1441/**********************************************************************/
1445{
1448 flush_dirty();
1449 }
1450
1451 return -1;
1452}
1453
1454/**********************************************************************/
1457static int terrain_info_callback(struct widget *pwidget)
1458{
1460 int x = pwidget->data.cont->id0;
1461 int y = pwidget->data.cont->id1;
1462
1464
1466 }
1467
1468 return -1;
1469}
1470
1471/**********************************************************************/
1474static int zoom_to_city_callback(struct widget *pwidget)
1475{
1477 struct city *pcity = pwidget->data.city;
1478
1480
1481 popup_city_dialog(pcity);
1482 }
1483
1484 return -1;
1485}
1486
1487/**********************************************************************/
1490static int change_production_callback(struct widget *pwidget)
1491{
1493 struct city *pcity = pwidget->data.city;
1494
1497 }
1498
1499 return -1;
1500}
1501
1502/**********************************************************************/
1505static int hurry_production_callback(struct widget *pwidget)
1506{
1508 struct city *pcity = pwidget->data.city;
1509
1511
1513 }
1514
1515 return -1;
1516}
1517
1518/**********************************************************************/
1521static int cma_callback(struct widget *pwidget)
1522{
1524 struct city *pcity = pwidget->data.city;
1525
1527 popup_city_cma_dialog(pcity);
1528 }
1529
1530 return -1;
1531}
1532
1533/**********************************************************************/
1536static int adv_unit_select_callback(struct widget *pwidget)
1537{
1539 struct unit *punit = pwidget->data.unit;
1540
1542
1543 if (punit) {
1546 }
1547 }
1548
1549 return -1;
1550}
1551
1552/**********************************************************************/
1555static int adv_unit_select_all_callback(struct widget *pwidget)
1556{
1558 struct unit *punit = pwidget->data.unit;
1559
1561
1562 if (punit) {
1564 }
1565 }
1566
1567 return -1;
1568}
1569
1570/**********************************************************************/
1573static int adv_unit_sentry_idle_callback(struct widget *pwidget)
1574{
1576 struct unit *punit = pwidget->data.unit;
1577
1579
1580 if (punit) {
1581 struct tile *ptile = unit_tile(punit);
1582
1585 && ACTIVITY_IDLE == other_unit->activity
1586 && other_unit->ssa_controller == SSA_NONE
1589 }
1591 }
1592 }
1593
1594 return -1;
1595}
1596
1597/**********************************************************************/
1600static int goto_here_callback(struct widget *pwidget)
1601{
1603 int x = pwidget->data.cont->id0;
1604 int y = pwidget->data.cont->id1;
1605
1607
1608 /* may not work */
1610 map_pos_to_tile(&(wld.map), x, y));
1611 }
1612
1613 return -1;
1614}
1615
1616/**********************************************************************/
1619static int patrol_here_callback(struct widget *pwidget)
1620{
1622 int x = pwidget->data.cont->id0;
1623 int y = pwidget->data.cont->id1;
1624 struct tile *ptile;
1625
1626 ptile = map_pos_to_tile(&(wld.map), x, y);
1627
1628 if (ptile != NULL) {
1629 struct unit_list *punits = get_units_in_focus();
1630
1635 do_unit_patrol_to(ptile);
1637 }
1638
1640 }
1641
1642 return -1;
1643}
1644
1645/**********************************************************************/
1648static int paradrop_here_callback(struct widget *pwidget)
1649{
1651 int x = pwidget->data.cont->id0;
1652 int y = pwidget->data.cont->id1;
1653 struct tile *ptile;
1654
1655 ptile = map_pos_to_tile(&(wld.map), x, y);
1656
1657 if (ptile != NULL) {
1658 struct unit_list *punits = get_units_in_focus();
1659
1663
1665 do_unit_paradrop_to(punit, ptile);
1667
1670 }
1671
1673 }
1674
1675 return -1;
1676}
1677
1678/**********************************************************************/
1681static int unit_help_callback(struct widget *pwidget)
1682{
1684 Unit_type_id unit_id = MAX_ID - pwidget->id;
1685
1687 popup_unit_info(unit_id);
1688 }
1689
1690 return -1;
1691}
1692
1693/**********************************************************************/
1698 Uint16 pos_x, Uint16 pos_y)
1699{
1700 struct widget *pwindow = NULL, *buf = NULL;
1701 struct city *pcity;
1702 struct unit *focus_unit;
1703 utf8_str *pstr;
1705 struct container *cont;
1706 char cbuf[255];
1707 int n, w = 0, h, units_h = 0;
1708 SDL_Rect area;
1709
1711 return;
1712 }
1713
1714 pcity = tile_city(ptile);
1715 n = unit_list_size(ptile->units);
1717
1718 if (!n && !pcity && !focus_unit) {
1720
1721 return;
1722 }
1723
1724 area.h = adj_size(2);
1726
1727 advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1728
1729 cont = fc_calloc(1, sizeof(struct container));
1730 cont->id0 = index_to_map_pos_x(tile_index(ptile));
1731 cont->id1 = index_to_map_pos_y(tile_index(ptile));
1732
1734 pstr->style |= TTF_STYLE_BOLD;
1735
1736 pwindow = create_window_skeleton(NULL, pstr, 0);
1737
1739 set_wstate(pwindow , FC_WS_NORMAL);
1740
1743
1744 area = pwindow->area;
1745
1746 /* ---------- */
1747 /* Exit button */
1748 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1750 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1752 area.w += buf->size.w + adj_size(10);
1755 buf->key = SDLK_ESCAPE;
1756
1758 /* ---------- */
1759
1760 pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT);
1761 pstr->style |= TTF_STYLE_BOLD;
1762
1763 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1765
1766 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
1767
1768 buf->data.cont = cont;
1769
1770 buf->action = terrain_info_callback;
1772
1774
1775 area.w = MAX(area.w, buf->size.w);
1776 area.h += buf->size.h;
1777
1778 /* ---------- */
1779 if (pcity && city_owner(pcity) == client.conn.playing) {
1780 /* Separator */
1782
1784 area.h += buf->next->size.h;
1785 /* ------------------ */
1786
1787 fc_snprintf(cbuf, sizeof(cbuf), _("Zoom to : %s"), city_name_get(pcity));
1788
1791 buf->data.city = pcity;
1793
1795
1796 area.w = MAX(area.w, buf->size.w);
1797 area.h += buf->size.h;
1798 /* ----------- */
1799
1801 _("Change Production"), change_production_callback);
1802
1803 buf->data.city = pcity;
1805
1807
1808 area.w = MAX(area.w, buf->size.w);
1809 area.h += buf->size.h;
1810 /* -------------- */
1811
1813 _("Hurry production"), hurry_production_callback);
1814
1815 buf->data.city = pcity;
1817
1819
1820 area.w = MAX(area.w, buf->size.w);
1821 area.h += buf->size.h;
1822 /* ----------- */
1823
1825 _("Change City Governor settings"), cma_callback);
1826
1827 buf->data.city = pcity;
1829
1831
1832 area.w = MAX(area.w, buf->size.w);
1833 area.h += buf->size.h;
1834 }
1835 /* ---------- */
1836
1837 if (focus_unit
1838 && (tile_index(unit_tile(focus_unit)) != tile_index(ptile))) {
1839 /* Separator */
1841
1843 area.h += buf->next->size.h;
1844 /* ------------------ */
1845
1846 create_active_iconlabel(buf, pwindow->dst, pstr, _("Goto here"),
1848 buf->data.cont = cont;
1850
1851 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1852
1853 area.w = MAX(area.w, buf->size.w);
1854 area.h += buf->size.h;
1855 /* ----------- */
1856
1857 create_active_iconlabel(buf, pwindow->dst, pstr, _("Patrol here"),
1859 buf->data.cont = cont;
1861
1862 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1863
1864 area.w = MAX(area.w, buf->size.w);
1865 area.h += buf->size.h;
1866 /* ----------- */
1867
1868#if 0 /* FIXME: specific connect buttons */
1870 create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
1872 buf->data.cont = cont;
1874
1876
1877 area.w = MAX(area.w, buf->size.w);
1878 area.h += buf->size.h;
1879 }
1880#endif /* 0 */
1881
1882 /* FIXME: This logic seems to try to mirror do_paradrop() why? */
1884 && !(((pcity && pplayers_non_attack(client.conn.playing, city_owner(pcity)))
1886 && (unit_type_get(focus_unit)->paratroopers_range >=
1888
1889 create_active_iconlabel(buf, pwindow->dst, pstr, _("Paradrop here"),
1891 buf->data.cont = cont;
1893
1895
1896 area.w = MAX(area.w, buf->size.w);
1897 area.h += buf->size.h;
1898 }
1899
1900 }
1902
1903 /* ---------- */
1904 if (n) {
1905 int i;
1906 struct unit *punit;
1907 const struct unit_type *punittype = NULL;
1908
1909 units_h = 0;
1910
1911 /* Separator */
1913
1915 area.h += buf->next->size.h;
1916 /* ---------- */
1917 if (n > 1) {
1918 struct unit *defender, *attacker;
1919 struct widget *last = buf;
1920 bool reset = FALSE;
1921 int my_units = 0;
1922 const char *vetname;
1923
1924 #define ADV_NUM_SEEN 15
1925
1926 defender = (focus_unit ? get_defender(&(wld.map), focus_unit, ptile, NULL)
1927 : NULL);
1928 attacker = (focus_unit ? get_attacker(&(wld.map), focus_unit, ptile)
1929 : NULL);
1930 for (i = 0; i < n; i++) {
1931 punit = unit_list_get(ptile->units, i);
1932 if (punit == focus_unit) {
1933 continue;
1934 }
1937
1939 struct astring addition = ASTRING_INIT;
1940
1942 fc_snprintf(cbuf, sizeof(cbuf),
1943 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
1944 (vetname != NULL ? vetname : ""),
1945 punit->hp, punittype->hp,
1947 punittype->attack_strength,
1948 punittype->defense_strength,
1949 move_points_text(punittype->move_rate, FALSE),
1950 astr_str(&addition));
1952
1955 buf->data.unit = punit;
1958 my_units++;
1959 } else {
1961
1962 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
1964 (vetname != NULL ? vetname : ""),
1966 punittype->attack_strength,
1967 punittype->defense_strength,
1968 move_points_text(punittype->move_rate, FALSE),
1969 punittype->firepower,
1970 ((punit->hp * 100) / punittype->hp));
1971
1972 /* Calculate chance to win */
1974 focus_unit)) {
1975 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1976 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1978 }
1979
1980 if (attacker && attacker == punit) {
1982 reset = TRUE;
1983 } else {
1984 if (defender && defender == punit) {
1986 reset = TRUE;
1987 }
1988 }
1989
1991
1992 if (reset) {
1994 reset = FALSE;
1995 }
1996
1998 }
1999
2000 area.w = MAX(area.w, buf->size.w);
2001 units_h += buf->size.h;
2002
2003 if (i > ADV_NUM_SEEN - 1) {
2005 }
2006 }
2007
2012
2013 if (n > ADV_NUM_SEEN) {
2016 1, ADV_NUM_SEEN, TRUE, TRUE);
2017 area.w += n;
2018 }
2019
2020 if (my_units > 1) {
2021 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Ready all"), my_units);
2026 buf->id = ID_LABEL;
2027 widget_add_as_prev(buf, last);
2028 area.h += buf->size.h;
2029
2030 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Sentry idle"), my_units);
2035 buf->id = ID_LABEL;
2036 widget_add_as_prev(buf, last->prev);
2037 area.h += buf->size.h;
2038
2039 /* separator */
2041 buf->id = ID_SEPARATOR;
2043 area.h += buf->next->size.h;
2044 }
2045#undef ADV_NUM_SEEN
2046 } else { /* n == 1 */
2047 /* one unit - give orders */
2048 punit = unit_list_get(ptile->units, 0);
2050 if (punit != focus_unit) {
2051 const char *vetname;
2052
2054 if ((pcity && city_owner(pcity) == client.conn.playing)
2055 || (unit_owner(punit) == client.conn.playing)) {
2056 struct astring addition = ASTRING_INIT;
2057
2059 fc_snprintf(cbuf, sizeof(cbuf),
2060 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
2061 (vetname != NULL ? vetname : ""),
2062 punit->hp, punittype->hp,
2064 punittype->attack_strength,
2065 punittype->defense_strength,
2066 move_points_text(punittype->move_rate, FALSE),
2067 astr_str(&addition));
2069
2072 buf->data.unit = punit;
2074
2076
2077 area.w = MAX(area.w, buf->size.w);
2078 units_h += buf->size.h;
2079 /* ---------------- */
2080 /* Separator */
2082
2084 area.h += buf->next->size.h;
2085 } else {
2087
2088 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
2090 (vetname != NULL ? vetname : ""),
2092 punittype->attack_strength,
2093 punittype->defense_strength,
2094 move_points_text(punittype->move_rate, FALSE),
2095 punittype->firepower,
2096 ((punit->hp * 100) / punittype->hp));
2097
2098 /* Calculate chance to win */
2100 focus_unit)) {
2101 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
2102 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
2104 }
2107 area.w = MAX(area.w, buf->size.w);
2108 units_h += buf->size.h;
2109 /* ---------------- */
2110
2111 /* Separator */
2113
2115 area.h += buf->next->size.h;
2116 }
2117 }
2118
2119 /* ---------------- */
2120 fc_snprintf(cbuf, sizeof(cbuf),
2121 _("Look up \"%s\" in the Help Browser"),
2127
2128 area.w = MAX(area.w, buf->size.w);
2129 units_h += buf->size.h;
2130 /* ---------------- */
2132 }
2133
2134 }
2135 /* ---------- */
2136
2137 area.w += adj_size(2);
2138 area.h += units_h;
2139
2140 resize_window(pwindow, NULL, NULL,
2141 (pwindow->size.w - pwindow->area.w) + area.w,
2142 (pwindow->size.h - pwindow->area.h) + area.h);
2143
2144 area = pwindow->area;
2145
2146 widget_set_position(pwindow, pos_x, pos_y);
2147
2148 w = area.w - adj_size(2);
2149
2151 units_h = n;
2152 } else {
2153 units_h = 0;
2154 }
2155
2156 /* exit button */
2157 buf = pwindow->prev;
2158
2159 buf->size.x = area.x + area.w - buf->size.w - 1;
2160 buf->size.y = pwindow->size.y + adj_size(2);
2161
2162 /* terrain info */
2163 buf = buf->prev;
2164
2165 buf->size.x = area.x + 1;
2166 buf->size.y = area.y + 1;
2167 buf->size.w = w;
2168 h = buf->size.h;
2169
2170 area2.x = adj_size(10);
2171 area2.h = adj_size(2);
2172
2173 buf = buf->prev;
2174 while (buf) {
2176 w -= units_h;
2177 }
2178
2179 buf->size.w = w;
2180 buf->size.x = buf->next->size.x;
2181 buf->size.y = buf->next->size.y + buf->next->size.h;
2182
2183 if (buf->id == ID_SEPARATOR) {
2184 FREESURFACE(buf->theme);
2185 buf->size.h = h;
2186 buf->theme = create_surf(w, h, SDL_SWSURFACE);
2187
2188 area2.y = buf->size.h / 2 - 1;
2189 area2.w = buf->size.w - adj_size(20);
2190
2191 SDL_FillRect(buf->theme, &area2, map_rgba(buf->theme->format,
2193 }
2194
2197 break;
2198 }
2199 buf = buf->prev;
2200 }
2201
2204 area.x + area.w,
2206 area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
2207 TRUE);
2208 }
2209
2210 /* -------------------- */
2211 /* redraw */
2213
2214 widget_flush(pwindow);
2215}
2216
2217/* ====================================================================== */
2218/* ============================ PILLAGE DIALOG ========================== */
2219/* ====================================================================== */
2221
2222/**********************************************************************/
2225static int pillage_window_callback(struct widget *pwindow)
2226{
2229 }
2230
2231 return -1;
2232}
2233
2234/**********************************************************************/
2237static int pillage_callback(struct widget *pwidget)
2238{
2240 struct unit *punit = pwidget->data.unit;
2241 int what = MAX_ID - pwidget->id;
2242
2244
2245 if (punit) {
2246 struct extra_type *target = extra_by_number(what);
2247
2249 }
2250 }
2251
2252 return -1;
2253}
2254
2255/**********************************************************************/
2258static int exit_pillage_dlg_callback(struct widget *pwidget)
2259{
2262 }
2263
2264 return -1;
2265}
2266
2267/**********************************************************************/
2281
2282/**********************************************************************/
2287{
2288 struct widget *pwindow = NULL, *buf = NULL;
2289 utf8_str *pstr;
2290 SDL_Rect area;
2291 struct extra_type *tgt;
2292
2293 if (pillage_dlg) {
2294 return;
2295 }
2296
2298 pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
2299
2300 /* Window */
2301 pstr = create_utf8_from_char_fonto(_("What To Pillage"), FONTO_ATTENTION);
2302 pstr->style |= TTF_STYLE_BOLD;
2303
2304 pwindow = create_window_skeleton(NULL, pstr, 0);
2305
2307 set_wstate(pwindow, FC_WS_NORMAL);
2308
2310 pillage_dlg->end_widget_list = pwindow;
2311
2312 area = pwindow->area;
2313
2314 area.h = MAX(area.h, adj_size(2));
2315
2316 /* ---------- */
2317 /* Exit button */
2318 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2320 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2322 area.w += buf->size.w + adj_size(10);
2325 buf->key = SDLK_ESCAPE;
2326
2328 /* ---------- */
2329
2330 while ((tgt = get_preferred_pillage(extras))) {
2331 const char *name = NULL;
2332 int what;
2333
2334 BV_CLR(extras, extra_index(tgt));
2336 what = extra_index(tgt);
2337
2338 fc_assert(name != NULL);
2339
2341 (char *) name, pillage_callback);
2342
2343 buf->data.unit = punit;
2345
2347
2348 area.w = MAX(area.w, buf->size.w);
2349 area.h += buf->size.h;
2350 }
2352
2353 /* setup window size and start position */
2354
2355 resize_window(pwindow, NULL, NULL,
2356 (pwindow->size.w - pwindow->area.w) + area.w,
2357 (pwindow->size.h - pwindow->area.h) + area.h);
2358
2359 area = pwindow->area;
2360
2361 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2362 unit_tile(punit));
2363
2364 /* setup widget size and start position */
2365
2366 /* exit button */
2367 buf = pwindow->prev;
2368 buf->size.x = area.x + area.w - buf->size.w - 1;
2369 buf->size.y = pwindow->size.y + adj_size(2);
2370
2371 /* first special to pillage */
2372 buf = buf->prev;
2374 area.x, area.y + 1, area.w, 0,
2376
2377 /* --------------------- */
2378 /* redraw */
2380
2381 widget_flush(pwindow);
2382}
2383
2384/* ======================================================================= */
2385/* =========================== CONNECT DIALOG ============================ */
2386/* ======================================================================= */
2388
2389/**********************************************************************/
2402
2403/* ==================== Public ========================= */
2404
2405/**************************************************************************
2406 Select Government Type
2407**************************************************************************/
2408static struct small_dialog *gov_dlg = NULL;
2409
2410/**********************************************************************/
2422
2423/**********************************************************************/
2427{
2430
2432 }
2433
2434 return -1;
2435}
2436
2437/**********************************************************************/
2440static int move_government_dlg_callback(struct widget *pwindow)
2441{
2444 }
2445
2446 return -1;
2447}
2448
2449/**********************************************************************/
2453{
2454 struct utf8_str *pstr;
2455 struct widget *gov_button = NULL;
2456 struct widget *pwindow;
2457 int j;
2458 Uint16 max_w = 0, max_h = 0;
2459 SDL_Rect area;
2460
2461 if (gov_dlg != NULL) {
2462 return;
2463 }
2464
2465 gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
2466
2467 /* Create window */
2468 pstr = create_utf8_from_char_fonto(_("Choose Your New Government"),
2470 pstr->style |= TTF_STYLE_BOLD;
2471 /* This win. size is temp. */
2472 pwindow = create_window_skeleton(NULL, pstr, 0);
2475
2476 gov_dlg->end_widget_list = pwindow;
2477
2478 area = pwindow->area;
2479
2480 /* Create gov. buttons */
2481 j = 0;
2482 governments_iterate(gov) {
2484 continue;
2485 }
2486
2491 = create_icon_button(get_government_surface(gov), pwindow->dst, pstr, 0);
2493
2494 max_w = MAX(max_w, gov_button->size.w);
2495 max_h = MAX(max_h, gov_button->size.h);
2496
2497 /* Ugly hack */
2499 j++;
2500
2501 }
2503
2504 if (gov_button == NULL) {
2505 /* No governments to switch to.
2506 * TODO: Provide close button for the dialog. */
2508 } else {
2510
2512
2513 max_w += adj_size(10);
2514 max_h += adj_size(4);
2515
2516 area.w = MAX(area.w, max_w + adj_size(20));
2517 area.h = MAX(area.h, j * (max_h + adj_size(10)) + adj_size(5));
2518
2519 /* Create window background */
2521 if (resize_window(pwindow, logo, NULL,
2522 (pwindow->size.w - pwindow->area.w) + area.w,
2523 (pwindow->size.h - pwindow->area.h) + area.h)) {
2525 }
2526
2527 area = pwindow->area;
2528
2529 /* Set window start positions */
2530 widget_set_position(pwindow,
2531 (main_window_width() - pwindow->size.w) / 2,
2532 (main_window_height() - pwindow->size.h) / 2);
2533
2534 /* Set buttons start positions and size */
2535 j = 1;
2536 while (gov_button != gov_dlg->end_widget_list) {
2537 gov_button->size.w = max_w;
2538 gov_button->size.h = max_h;
2539 gov_button->size.x = area.x + adj_size(10);
2540 gov_button->size.y = area.y + area.h - (j++) * (max_h + adj_size(10));
2542
2543 gov_button = gov_button->next;
2544 }
2545 }
2546
2547 set_wstate(pwindow, FC_WS_NORMAL);
2548
2549 /* Redraw */
2551
2552 widget_flush(pwindow);
2553}
2554
2555/**************************************************************************
2556 Nation Wizard
2557**************************************************************************/
2559static struct small_dialog *help_dlg = NULL;
2560
2562 unsigned char nation_style; /* selected style */
2563 unsigned char selected_leader; /* if not unique -> selected leader */
2564 Nation_type_id nation; /* selected nation */
2565 bool leader_sex; /* selected leader sex */
2574};
2575
2576static int next_set_callback(struct widget *next_button);
2577static int prev_set_callback(struct widget *prev_button);
2578static int nations_dialog_callback(struct widget *pwindow);
2579static int nation_button_callback(struct widget *pnation);
2580static int races_dialog_ok_callback(struct widget *start_button);
2581static int races_dialog_cancel_callback(struct widget *button);
2582static int next_name_callback(struct widget *next_button);
2583static int prev_name_callback(struct widget *prev_button);
2584static int change_sex_callback(struct widget *sex);
2585static void select_random_leader(Nation_type_id nation);
2586static void change_nation_label(void);
2587
2588/**********************************************************************/
2591static int nations_dialog_callback(struct widget *pwindow)
2592{
2595 widget_flush(pwindow);
2596 }
2597 }
2598
2599 return -1;
2600}
2601
2602/**********************************************************************/
2605static int races_dialog_ok_callback(struct widget *start_button)
2606{
2608 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2609 char *pstr = setup->name_edit->string_utf8->text;
2610
2611 /* perform a minimum of sanity test on the name */
2612 if (strlen(pstr) == 0) {
2613 output_window_append(ftc_client, _("You must type a legal name."));
2614 selected_widget = start_button;
2615 set_wstate(start_button, FC_WS_SELECTED);
2616 widget_redraw(start_button);
2617 widget_flush(start_button);
2618
2619 return -1;
2620 }
2621
2623 setup->nation,
2624 setup->leader_sex, pstr,
2625 setup->nation_style);
2626
2628 flush_dirty();
2629 }
2630
2631 return -1;
2632}
2633
2634/**********************************************************************/
2637static int change_sex_callback(struct widget *sex)
2638{
2640 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2641
2642 if (setup->leader_sex) {
2645 } else {
2648 }
2649 setup->leader_sex = !setup->leader_sex;
2650
2651 if (sex) {
2654
2657 }
2658 }
2659
2660 return -1;
2661}
2662
2663/**********************************************************************/
2666static int next_name_callback(struct widget *next)
2667{
2669 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2670 const struct nation_leader_list *leaders =
2672 const struct nation_leader *pleader;
2673
2674 setup->selected_leader++;
2676
2677 /* change leader sex */
2678 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2680 }
2681
2682 /* change leader name */
2685
2688
2689 if (nation_leader_list_size(leaders) - 1 == setup->selected_leader) {
2691 }
2692
2693 if (get_wstate(setup->name_prev) == FC_WS_DISABLED) {
2695 }
2696
2697 if (!(get_wstate(setup->name_next) == FC_WS_DISABLED)) {
2698 selected_widget = setup->name_next;
2700 }
2701
2702 widget_redraw(setup->name_edit);
2703 widget_redraw(setup->name_prev);
2704 widget_redraw(setup->name_next);
2708
2709 widget_redraw(setup->change_sex);
2711
2712 flush_dirty();
2713 }
2714
2715 return -1;
2716}
2717
2718/**********************************************************************/
2721static int prev_name_callback(struct widget *prev)
2722{
2724 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2725 const struct nation_leader_list *leaders =
2727 const struct nation_leader *pleader;
2728
2729 setup->selected_leader--;
2731
2732 /* change leader sex */
2733 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2735 }
2736
2737 /* change leader name */
2740
2743
2744 if (!setup->selected_leader) {
2746 }
2747
2748 if (get_wstate(setup->name_next) == FC_WS_DISABLED) {
2750 }
2751
2752 if (!(get_wstate(setup->name_prev) == FC_WS_DISABLED)) {
2753 selected_widget = setup->name_prev;
2755 }
2756
2757 widget_redraw(setup->name_edit);
2758 widget_redraw(setup->name_prev);
2759 widget_redraw(setup->name_next);
2763
2764 widget_redraw(setup->change_sex);
2766
2767 flush_dirty();
2768 }
2769
2770 return -1;
2771}
2772
2773/**********************************************************************/
2776static int next_set_callback(struct widget *next_button)
2777{
2779 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2780 struct option *poption = optset_option_by_name(server_optset, "nationset");
2781
2782 fc_assert(setup->set != NULL
2783 && nation_set_index(setup->set) < nation_set_count() - 1);
2784
2785 setup->set = nation_set_by_number(nation_set_index(setup->set) + 1);
2786
2788 }
2789
2790 return -1;
2791}
2792
2793/**********************************************************************/
2797{
2799 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2800 struct option *poption = optset_option_by_name(server_optset, "nationset");
2801
2802 fc_assert(setup->set != NULL && nation_set_index(setup->set) > 0);
2803
2804 setup->set = nation_set_by_number(nation_set_index(setup->set) - 1);
2805
2807 }
2808
2809 return -1;
2810}
2811
2812/**********************************************************************/
2815static int races_dialog_cancel_callback(struct widget *button)
2816{
2819 flush_dirty();
2820 }
2821
2822 return -1;
2823}
2824
2825/**********************************************************************/
2828static int style_callback(struct widget *pwidget)
2829{
2831 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2833 setup->nation_style);
2834
2838
2839 set_wstate(pwidget, FC_WS_DISABLED);
2840 widget_redraw(pwidget);
2841 widget_mark_dirty(pwidget);
2842
2843 setup->nation_style = MAX_ID - 1000 - pwidget->id;
2844
2845 flush_dirty();
2847 }
2848
2849 return -1;
2850}
2851
2852/**********************************************************************/
2855static int help_dlg_callback(struct widget *pwindow)
2856{
2857 return -1;
2858}
2859
2860/**********************************************************************/
2863static int cancel_help_dlg_callback(struct widget *pwidget)
2864{
2866 if (help_dlg) {
2870 if (pwidget) {
2871 flush_dirty();
2872 }
2873 }
2874 }
2875
2876 return -1;
2877}
2878
2879/**********************************************************************/
2883{
2886
2888 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2889
2890 if (setup->nation == MAX_ID - nation_button->id) {
2893
2894 return -1;
2895 }
2896
2897 setup->nation = MAX_ID - nation_button->id;
2898
2900
2901 enable(MAX_ID - 1000 - setup->nation_style);
2903 disable(MAX_ID - 1000 - setup->nation_style);
2904
2906
2909 } else {
2910 /* Pop up nation description */
2911 struct widget *pwindow, *ok_button;
2912 utf8_str *pstr;
2913 SDL_Surface *text;
2915 struct nation_type *pnation = nation_by_number(MAX_ID - nation_button->id);
2916
2919
2920 if (!help_dlg) {
2921 help_dlg = fc_calloc(1, sizeof(struct small_dialog));
2922
2925 pstr->style |= TTF_STYLE_BOLD;
2926
2927 pwindow = create_window_skeleton(NULL, pstr, 0);
2928 pwindow->action = help_dlg_callback;
2929
2930 set_wstate(pwindow, FC_WS_NORMAL);
2931
2932 help_dlg->end_widget_list = pwindow;
2933 add_to_gui_list(ID_WINDOW, pwindow);
2934
2935 ok_button
2937 pwindow->dst, _("OK"),
2938 FONTO_HEADING, 0);
2939 ok_button->action = cancel_help_dlg_callback;
2940 set_wstate(ok_button, FC_WS_NORMAL);
2941 ok_button->key = SDLK_ESCAPE;
2942 add_to_gui_list(ID_BUTTON, ok_button);
2943 help_dlg->begin_widget_list = ok_button;
2944 } else {
2945 pwindow = help_dlg->end_widget_list;
2946 ok_button = help_dlg->begin_widget_list;
2947
2948 /* Undraw window */
2949 widget_undraw(pwindow);
2950 widget_mark_dirty(pwindow);
2951 }
2952
2953 area = pwindow->area;
2954
2955 {
2956 char info[4096];
2957
2958 helptext_nation(info, sizeof(info), pnation, NULL);
2960 }
2961
2964
2966
2967 /* create window background */
2968 area.w = MAX(area.w, text->w + adj_size(20));
2969 area.w = MAX(area.w, ok_button->size.w + adj_size(20));
2970 area.h = MAX(area.h, adj_size(9) + text->h
2971 + adj_size(10) + ok_button->size.h + adj_size(10));
2972
2974 (pwindow->size.w - pwindow->area.w) + area.w,
2975 (pwindow->size.h - pwindow->area.h) + area.h);
2976
2977 widget_set_position(pwindow,
2978 (main_window_width() - pwindow->size.w) / 2,
2979 (main_window_height() - pwindow->size.h) / 2);
2980
2981 area2.x = area.x + adj_size(7);
2982 area2.y = area.y + adj_size(6);
2983 alphablit(text, NULL, pwindow->theme, &area2, 255);
2984 FREESURFACE(text);
2985
2986 ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
2987 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2988
2989 /* redraw */
2990 redraw_group(ok_button, pwindow, 0);
2991
2992 widget_mark_dirty(pwindow);
2993
2994 flush_dirty();
2995
2996 }
2997
2998 return -1;
2999}
3000
3001/**********************************************************************/
3004static int leader_name_edit_callback(struct widget *pedit)
3005{
3007 if (pedit->string_utf8->text != NULL) {
3008 /* empty input -> restore previous content */
3010 widget_redraw(pedit);
3011 widget_mark_dirty(pedit);
3012 flush_dirty();
3013 }
3014 }
3015
3016 return -1;
3017}
3018
3019/* =========================================================== */
3020
3021/**********************************************************************/
3024static void change_nation_label(void)
3025{
3027 struct widget *pwindow = nation_dlg->end_widget_list;
3028 struct nation_info *setup = (struct nation_info *)(pwindow->data.ptr);
3029 struct widget *label = setup->name_edit->next;
3030 struct nation_type *pnation = nation_by_number(setup->nation);
3031
3034
3035 FREESURFACE(label->theme);
3036 label->theme = tmp_surf_zoomed;
3037
3039
3040 remake_label_size(label);
3041
3042 label->size.x = pwindow->size.x + pwindow->size.w / 2 +
3043 (pwindow->size.w / 2 - label->size.w) / 2;
3044
3045}
3046
3047/**********************************************************************/
3052{
3053 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3054 const struct nation_leader_list *leaders =
3056 const struct nation_leader *pleader;
3057
3062
3065
3066 /* initialize leader sex */
3068
3069 if (setup->leader_sex) {
3072 } else {
3075 }
3076
3077 /* disable navigation buttons */
3080
3081 if (1 < nation_leader_list_size(leaders)) {
3082 /* if selected leader is not the first leader, enable "previous leader" button */
3083 if (setup->selected_leader > 0) {
3085 }
3086
3087 /* if selected leader is not the last leader, enable "next leader" button */
3088 if (setup->selected_leader < (nation_leader_list_size(leaders) - 1)) {
3090 }
3091 }
3092}
3093
3094/**********************************************************************/
3098{
3099 int playable_nation_count = 0;
3100
3101 nations_iterate(pnation) {
3102 if (pnation->is_playable && !pnation->player
3103 && is_nation_pickable(pnation))
3106
3107 return playable_nation_count;
3108}
3109
3110/**********************************************************************/
3113void popup_races_dialog(struct player *pplayer)
3114{
3115 SDL_Color bg_color = {255,255,255,128};
3116
3117 struct widget *pwindow, *pwidget = NULL, *buf, *last_City_Style;
3118 utf8_str *pstr;
3119 int len = 0;
3120 int w = adj_size(10), h = adj_size(10);
3123 SDL_Rect dst;
3124 float zoom;
3125 struct nation_info *setup;
3126 SDL_Rect area;
3127 int i;
3128 struct nation_type *pnat;
3129 struct widget *nationsets = NULL;
3130 int natinfo_y, natinfo_h;
3131
3132#define TARGETS_ROW 5
3133#define TARGETS_COL 1
3134
3135 if (nation_dlg) {
3136 return;
3137 }
3138
3139 races_player = pplayer;
3140
3141 nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3142
3143 /* Create window widget */
3144 pstr = create_utf8_from_char_fonto(_("What nation will you be?"),
3146 pstr->style |= TTF_STYLE_BOLD;
3147
3148 pwindow = create_window(NULL, pstr, w, h, WF_FREE_DATA);
3150 set_wstate(pwindow, FC_WS_NORMAL);
3151 setup = fc_calloc(1, sizeof(struct nation_info));
3152 pwindow->data.ptr = (void *)setup;
3153
3154 nation_dlg->end_widget_list = pwindow;
3156 /* --------------------------------------------------------- */
3157 /* Create nations list */
3158
3159 /* Create Imprv Background Icon */
3161
3163
3165 0, 0, main_bg->w - 1, main_bg->h - 1,
3167
3169 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
3170 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
3171
3172 /* Fill list */
3173
3174 nations_iterate(pnation) {
3175 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
3176 continue;
3177 }
3178
3180
3182
3185 text_name
3187
3188 dst.x = (tmp_surf->w - tmp_surf_zoomed->w) / 2;
3189 len = tmp_surf_zoomed->h +
3190 adj_size(10) + text_name->h;
3191 dst.y = (tmp_surf->h - len) / 2;
3193 dst.y += (tmp_surf_zoomed->h + adj_size(10));
3195
3196 dst.x = (tmp_surf->w - text_name->w) / 2;
3198 dst.y += text_name->h;
3200
3201 pwidget = create_icon2(tmp_surf, pwindow->dst,
3203
3204 set_wstate(pwidget, FC_WS_NORMAL);
3205
3206 pwidget->action = nation_button_callback;
3207
3208 w = MAX(w, pwidget->size.w);
3209 h = MAX(h, pwidget->size.h);
3210
3211 add_to_gui_list(MAX_ID - nation_index(pnation), pwidget);
3212
3213 if (nation_index(pnation) > (TARGETS_ROW * TARGETS_COL - 1)) {
3214 set_wflag(pwidget, WF_HIDDEN);
3215 }
3216
3218
3220
3222 nation_dlg->begin_widget_list = pwidget;
3224
3229 }
3230
3231 /* ----------------------------------------------------------------- */
3232
3233 /* Nation set selection */
3234 if (nation_set_count() > 1) {
3236 struct option *poption;
3237
3243
3244 /* Create nation set name label */
3247
3252
3253 pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3254
3255 add_to_gui_list(ID_LABEL, pwidget);
3256 setup->pset_name = pwidget;
3257
3258 /* Create next nationset button */
3259 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3260 pwindow->dst, NULL, 0);
3261 pwidget->action = next_set_callback;
3262 if (nation_set_index(setup->set) < nation_set_count() - 1) {
3263 set_wstate(pwidget, FC_WS_NORMAL);
3264 }
3266 pwidget->size.h = pwidget->next->size.h;
3267 setup->pset_next = pwidget;
3268
3269 /* Create prev nationset button */
3270 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3271 pwindow->dst, NULL, 0);
3272 pwidget->action = prev_set_callback;
3273 if (nation_set_index(setup->set) > 0) {
3274 set_wstate(pwidget, FC_WS_NORMAL);
3275 }
3277 pwidget->size.h = pwidget->next->size.h;
3278 setup->pset_prev = pwidget;
3279 }
3280
3281 /* Nation name */
3283 pnat = nation_by_number(setup->nation);
3285
3288 pstr->render = 2;
3290
3292
3293 pwidget = create_iconlabel(tmp_surf_zoomed, pwindow->dst, pstr,
3295 if (nationsets == NULL) {
3296 buf = pwidget;
3297 } else {
3298 buf = nationsets;
3299 }
3300
3301 add_to_gui_list(ID_LABEL, pwidget);
3302
3303 /* Create leader name edit */
3304 pwidget = create_edit_from_chars_fonto(NULL, pwindow->dst,
3305 NULL, FONTO_BIG,
3306 adj_size(200), 0);
3307 pwidget->size.h = adj_size(24);
3308
3309 set_wstate(pwidget, FC_WS_NORMAL);
3312 setup->name_edit = pwidget;
3313
3314 /* Create next leader name button */
3315 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3316 pwindow->dst, NULL, 0);
3317 pwidget->action = next_name_callback;
3319 pwidget->size.h = pwidget->next->size.h;
3320 setup->name_next = pwidget;
3321
3322 /* Create prev leader name button */
3323 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3324 pwindow->dst, NULL, 0);
3325 pwidget->action = prev_name_callback;
3327 pwidget->size.h = pwidget->next->size.h;
3328 setup->name_prev = pwidget;
3329
3330 /* Change sex button */
3331 pwidget = create_icon_button_from_chars_fonto(NULL, pwindow->dst,
3333 FONTO_HEADING, 0);
3334 pwidget->action = change_sex_callback;
3335 pwidget->size.w = adj_size(100);
3336 pwidget->size.h = adj_size(22);
3337 set_wstate(pwidget, FC_WS_NORMAL);
3338 setup->change_sex = pwidget;
3339
3340 /* Add to main widget list */
3342
3343 /* ---------------------------------------------------------- */
3344 zoom = DEFAULT_ZOOM * 1.0;
3345
3346 len = 0;
3349
3351
3352 if (tmp_surf->w > 48) {
3353 zoom = DEFAULT_ZOOM * (48.0 / tmp_surf->w);
3354 }
3355
3357
3358 pwidget = create_icon2(tmp_surf_zoomed, pwindow->dst,
3360 pwidget->action = style_callback;
3361 if (sn != setup->nation_style) {
3362 set_wstate(pwidget, FC_WS_NORMAL);
3363 }
3364 len += pwidget->size.w;
3365 add_to_gui_list(MAX_ID - 1000 - sn, pwidget);
3367
3368 last_City_Style = pwidget;
3369 /* ---------------------------------------------------------- */
3370
3371 /* Create Cancel button */
3372 pwidget
3374 pwindow->dst, _("Cancel"),
3375 FONTO_ATTENTION, 0);
3377 set_wstate(pwidget, FC_WS_NORMAL);
3378
3380
3381 /* Create OK button */
3382 pwidget
3384 pwindow->dst,
3385 _("OK"), FONTO_ATTENTION, 0);
3387
3388 set_wstate(pwidget, FC_WS_NORMAL);
3390 pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
3391 pwidget->next->size.w = pwidget->size.w;
3392
3393 nation_dlg->begin_widget_list = pwidget;
3394 /* ---------------------------------------------------------- */
3395
3397 if (resize_window(pwindow, main_bg, NULL, adj_size(640), adj_size(480))) {
3399 }
3400
3401 area = pwindow->area;
3402
3403 widget_set_position(pwindow,
3404 (main_window_width() - pwindow->size.w) / 2,
3405 (main_window_height() - pwindow->size.h) / 2);
3406
3407 /* Nations */
3408
3410 i = (area.h - adj_size(43) - h) / 2;
3412 area.x + adj_size(10),
3413 area.y + i - adj_size(4),
3416
3417 if (nation_dlg->scroll) {
3419
3422 area.x + w + adj_size(12),
3423 area.y + i - adj_size(4), h, FALSE);
3424
3425 area2.x = area.x + w + adj_size(11);
3426 area2.y = area.y + i - adj_size(4);
3428 area2.h = h;
3429 fill_rect_alpha(pwindow->theme, &area2, &bg_color);
3430
3431 create_frame(pwindow->theme,
3432 area2.x, area2.y - 1, area2.w, area2.h + 1,
3434 }
3435
3436 if (nationsets != NULL) {
3437 /* Nationsets header */
3438 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3439 buf->size.y = area.y + adj_size(46);
3440
3441 natinfo_y = buf->size.y;
3442 natinfo_h = area.h -= buf->size.y;
3443
3444 /* Nationset name */
3445 buf = buf->prev;
3446 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3447 buf->size.y = natinfo_y + adj_size(46);
3448
3449 natinfo_y += adj_size(46);
3450 natinfo_h -= adj_size(46);
3451
3452 /* Next Nationset Button */
3453 buf = buf->prev;
3454 buf->size.x = buf->next->size.x + buf->next->size.w;
3455 buf->size.y = buf->next->size.y;
3456
3457 /* Prev Nationset Button */
3458 buf = buf->prev;
3459 buf->size.x = buf->next->next->size.x - buf->size.w;
3460 buf->size.y = buf->next->size.y;
3461
3462 buf = buf->prev;
3463 } else {
3464 natinfo_y = area.y;
3465 natinfo_h = area.h;
3466 }
3467
3468 /* Selected Nation Name */
3469 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3470 buf->size.y = natinfo_y + adj_size(46);
3471
3472 /* Leader Name Edit */
3473 buf = buf->prev;
3474 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3475 buf->size.y = natinfo_y + (natinfo_h - buf->size.h) / 2 - adj_size(30);
3476
3477 /* Next Leader Name Button */
3478 buf = buf->prev;
3479 buf->size.x = buf->next->size.x + buf->next->size.w;
3480 buf->size.y = buf->next->size.y;
3481
3482 /* Prev Leader Name Button */
3483 buf = buf->prev;
3484 buf->size.x = buf->next->next->size.x - buf->size.w;
3485 buf->size.y = buf->next->size.y;
3486
3487 /* Change Leader Sex Button */
3488 buf = buf->prev;
3489 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3490 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3491
3492 /* First Style Button */
3493 buf = buf->prev;
3494 buf->size.x = area.x + area.w / 2 + (area.w / 2 - len) / 2 - adj_size(20);
3495 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3496
3497 /* Rest Style Buttons */
3498 while (buf != last_City_Style) {
3499 buf = buf->prev;
3500 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(3);
3501 buf->size.y = buf->next->size.y;
3502 }
3503
3504 create_line(pwindow->theme,
3505 area.x,
3506 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3507 area.w - 1,
3508 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3510
3511 /* Disconnect Button */
3512 buf = buf->prev;
3513 buf->size.x = area.x + adj_size(10);
3514 buf->size.y = natinfo_y + natinfo_h - adj_size(7) - buf->size.h;
3515
3516 /* Start Button */
3517 buf = buf->prev;
3518 buf->size.x = area.w - adj_size(10) - buf->size.w;
3519 buf->size.y = buf->next->size.y;
3520
3521 /* -------------------------------------------------------------------- */
3522
3524
3526
3527 widget_flush(pwindow);
3528}
3529
3530/**********************************************************************/
3548
3549/**********************************************************************/
3552void races_update_pickable(bool nationset_change)
3553{
3554 /* If this is because of nationset change, update will take
3555 * place later when the new option value is received */
3556 if (nation_dlg != NULL && !nationset_change) {
3559 }
3560}
3561
3562/**********************************************************************/
3566{
3567 if (nation_dlg != NULL) {
3570 }
3571}
3572
3573/**********************************************************************/
3578{
3579 struct nation_info *setup;
3580 bool change = FALSE;
3581 struct widget *nat;
3582
3583 if (!nation_dlg) {
3584 return;
3585 }
3586
3587 setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3588
3590 if (!is_nation_pickable(nation) || nation->player) {
3591 log_debug(" [%d]: %d = %s", nation_index(nation),
3592 (!is_nation_pickable(nation) || nation->player),
3594
3597
3598 if (nation_index(nation) == setup->nation) {
3599 change = TRUE;
3600 }
3601 }
3603
3604 if (change) {
3605 do {
3608 } while (get_wstate(nat) == FC_WS_DISABLED);
3609
3610 if (get_wstate(setup->name_edit) == FC_WS_PRESSED) {
3613 }
3615 enable(MAX_ID - 1000 - setup->nation_style);
3617 disable(MAX_ID - 1000 - setup->nation_style);
3619 }
3622}
3623
3624/**********************************************************************/
3629{
3630}
3631
3632/**********************************************************************/
3639
3640/**********************************************************************/
3647
3648/**********************************************************************/
3653{
3654 /* Don't load */
3655 return FALSE;
3656}
3657
3658/**********************************************************************/
3662{
3663 /* PORTME */
3664}
3665
3666/**********************************************************************/
3669void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
3670{
3671 /* PORTME */
3672}
3673
3674/**********************************************************************/
3679{
3680 /* Just tell the client common code to handle this. */
3681 return FALSE;
3682}
3683
3684/**********************************************************************/
3688{
3689 /* PORTME */
3690}
3691
3692/**********************************************************************/
3695bool request_transport(struct unit *pcargo, struct tile *ptile)
3696{
3697 return FALSE; /* Unit was not handled here. */
3698}
3699
3700/**********************************************************************/
3704void popup_combat_info(int attacker_unit_id, int defender_unit_id,
3705 int attacker_hp, int defender_hp,
3706 bool make_att_veteran, bool make_def_veteran)
3707{
3708}
3709
3710/**********************************************************************/
3713void request_action_confirmation(const char *expl,
3714 struct act_confirmation_data *data)
3715{
3716 /* TODO: Implement. Currently just pass everything as confirmed */
3718}
3719
3721
3722/**********************************************************************/
3725static int image_popup_window_callback(struct widget *pwindow)
3726{
3729 }
3730
3731 return -1;
3732}
3733
3734/**********************************************************************/
3751
3752/**********************************************************************/
3755void popup_image(const char *tag)
3756{
3757 if (advanced_image_popup == NULL) {
3758 struct sprite *spr = load_popup_sprite(tag);
3759
3760 if (spr != NULL) {
3761 struct widget *win = create_window_skeleton(NULL, NULL, 0);
3762 struct widget *buf;
3764 SDL_Rect dst;
3765 SDL_Rect area;
3766 int width, height;
3767
3769 advanced_image_popup = fc_calloc(1, sizeof(struct advanced_dialog));
3770
3773
3776
3777 /* Create exit button */
3778 buf = create_themeicon(current_theme->small_cancel_icon, win->dst,
3780 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3784 buf->key = SDLK_ESCAPE;
3785
3788
3790 win->size.w - win->area.w + width,
3791 win->size.h - win->area.h + buf->area.h + height);
3792
3794 (main_window_width() - win->size.w) / 2,
3795 (main_window_height() - win->size.h) / 2);
3796
3797 area = win->area;
3798 dst.x = area.x;
3799 dst.y = area.y + buf->size.y;
3800 alphablit(surf, NULL, win->theme, &dst, 255);
3801
3802 /* Redraw */
3804 widget_flush(win);
3805
3807 } else {
3808 log_error(_("No image for tag \"%s\", requested by the server."), tag);
3809 }
3810 }
3811}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
#define ACTION_NONE
Definition actions.h:311
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 struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
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:1137
#define city_owner(_pcity_)
Definition city.h:563
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
double unit_win_chance(const struct civ_map *nmap, const struct unit *attacker, const struct unit *defender, const struct action *paction)
Definition combat.c:478
struct unit * get_attacker(const struct civ_map *nmap, const struct unit *defender, const struct tile *ptile)
Definition combat.c:906
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile, const struct action *paction)
Definition combat.c:836
char * nationsets
Definition comments.c:60
char * incite_cost
Definition comments.c:75
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:506
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3185
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
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 action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3225
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_PATROL
Definition control.h:31
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
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:85
const char * caption
Definition dialogs_g.h:37
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
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:86
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:74
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:86
struct extra_type * extra_by_number(int id)
Definition extras.c:183
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:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define extra_index(_e_)
Definition extras.h:183
QString current_theme
Definition fc_client.cpp:65
#define NO_TARGET
Definition fc_types.h:354
int Tech_type_id
Definition fc_types.h:377
int Nation_type_id
Definition fc_types.h:380
int Unit_type_id
Definition fc_types.h:382
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
void exit_goto_state(void)
Definition goto.c:1022
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:1001
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
struct government * government_by_number(const Government_type_id gov)
Definition government.c:103
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Definition government.c:166
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define governments_iterate(NAME_pgov)
Definition government.h:124
#define governments_iterate_end
Definition government.h:127
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void city_report_dialog_popdown(void)
Definition cityrep.c:312
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:313
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:386
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
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:1583
struct player * races_player
Definition dialogs.c:74
void request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.c:1607
void popup_image(const char *tag)
Definition dialogs.c:1636
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
void popdown_help_dialog(void)
Definition helpdlg.c:186
void flush_dirty(void)
Definition mapview.c:468
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void meswin_dialog_popdown(void)
Definition messagewin.c:432
static GtkWidget * nation_button
Definition pages.c:1460
void popdown_players_dialog(void)
Definition plrdlg.c:105
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
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:47
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:109
static int adv_unit_sentry_idle_callback(struct widget *pwidget)
Definition dialogs.c:1573
static struct small_dialog * terrain_info_dlg
Definition dialogs.c:1262
void popup_government_dialog(void)
Definition dialogs.c:2452
static struct notify_goto_data * notify_goto_data_new(const char *headline, const char *lines, struct tile *ptile)
Definition dialogs.c:238
static int adv_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1536
static struct small_dialog * unit_disband_dlg
Definition dialogs.c:827
static void popdown_unit_upgrade_dlg(void)
Definition dialogs.c:815
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:878
static void popdown_unit_disband_dlg(void)
Definition dialogs.c:1015
static void notify_goto_data_destroy(struct notify_goto_data *pdata)
Definition dialogs.c:254
static int cma_callback(struct widget *pwidget)
Definition dialogs.c:1521
static struct small_dialog * connect_dlg
Definition dialogs.c:2387
bool is_unit_move_blocked
Definition gui_main.c:107
static int hurry_production_callback(struct widget *pwidget)
Definition dialogs.c:1505
static void select_random_leader(Nation_type_id nation)
Definition dialogs.c:3051
static int next_set_callback(struct widget *next_button)
Definition dialogs.c:2776
static int exit_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1044
void popdown_advanced_terrain_dialog(void)
Definition dialogs.c:1417
void popup_musicset_suggestion_dialog(void)
Definition dialogs.c:3644
#define ADV_NUM_SEEN
static void popdown_pillage_dialog(void)
Definition dialogs.c:2271
static struct advanced_dialog * unit_select_dlg
Definition dialogs.c:1027
static int notify_goto_dialog_callback(struct widget *widget)
Definition dialogs.c:263
int exit_advanced_terrain_dlg_callback(struct widget *pwidget)
Definition dialogs.c:1444
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:650
static int prev_set_callback(struct widget *prev_button)
Definition dialogs.c:2796
static int prev_name_callback(struct widget *prev_button)
Definition dialogs.c:2721
static int exit_image_popup_callback(struct widget *pwidget)
Definition dialogs.c:3737
static int terrain_info_callback(struct widget *pwidget)
Definition dialogs.c:1457
void popup_soundset_suggestion_dialog(void)
Definition dialogs.c:3636
static int style_callback(struct widget *pwidget)
Definition dialogs.c:2828
static int unit_help_callback(struct widget *pwidget)
Definition dialogs.c:1681
static int move_government_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2440
static void popdown_government_dialog(void)
Definition dialogs.c:2413
static struct advanced_dialog * nation_dlg
Definition dialogs.c:2558
static int change_sex_callback(struct widget *sex)
Definition dialogs.c:2637
static int cancel_help_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2863
static int next_name_callback(struct widget *next_button)
Definition dialogs.c:2666
void popup_tileset_suggestion_dialog(void)
Definition dialogs.c:3628
#define TARGETS_ROW
static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
Definition dialogs.c:1326
static int get_playable_nation_count(void)
Definition dialogs.c:3097
static struct small_dialog * help_dlg
Definition dialogs.c:2559
struct advanced_dialog * advanced_terrain_dlg
Definition dialogs.c:1411
static void popdown_terrain_info_dialog(void)
Definition dialogs.c:1280
static int adv_unit_select_all_callback(struct widget *pwidget)
Definition dialogs.c:1555
static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog)
Definition dialogs.c:422
static int unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1057
static int exit_notify_dialog_callback(struct widget *pwidget)
Definition dialogs.c:493
void popdown_notify_goto_dialog(void)
Definition dialogs.c:459
int advanced_terrain_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1432
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition dialogs.c:635
static int nation_button_callback(struct widget *pnation)
Definition dialogs.c:2882
static int races_dialog_cancel_callback(struct widget *button)
Definition dialogs.c:2815
static int notify_goto_dialog_close_callback(struct widget *widget)
Definition dialogs.c:278
static int image_popup_window_callback(struct widget *pwindow)
Definition dialogs.c:3725
static int leader_name_edit_callback(struct widget *pedit)
Definition dialogs.c:3004
static int patrol_here_callback(struct widget *pwidget)
Definition dialogs.c:1619
static int pillage_window_callback(struct widget *pwindow)
Definition dialogs.c:2225
static int help_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2855
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.c:3652
static int disband_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:832
static int nations_dialog_callback(struct widget *pwindow)
Definition dialogs.c:2591
static void notify_goto_dialog_update(struct notify_goto_dialog *pdialog)
Definition dialogs.c:376
void popdown_diplomat_dialog(void)
void real_multipliers_dialog_update(void *unused)
Definition dialogs.c:3687
static int goto_here_callback(struct widget *pwidget)
Definition dialogs.c:1600
static struct small_dialog * gov_dlg
Definition dialogs.c:2408
static int notify_goto_dialog_goto_callback(struct widget *widget)
Definition dialogs.c:293
bool request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.c:3695
static void change_nation_label(void)
Definition dialogs.c:3024
#define NUM_SEEN
static struct small_dialog * pillage_dlg
Definition dialogs.c:2220
void nationset_changed(void)
Definition dialogs.c:3565
void popdown_incite_dialog(void)
static int races_dialog_ok_callback(struct widget *start_button)
Definition dialogs.c:2605
void popdown_bribe_dialog(void)
static void notify_goto_dialog_destroy(struct notify_goto_dialog *pdialog)
Definition dialogs.c:357
static int cancel_disband_unit_callback(struct widget *pwidget)
Definition dialogs.c:844
#define TARGETS_COL
static int change_production_callback(struct widget *pwidget)
Definition dialogs.c:1490
static int exit_pillage_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2258
static int terrain_info_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1268
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
static int zoom_to_city_callback(struct widget *pwidget)
Definition dialogs.c:1474
static bool sdl_get_chance_to_win(int *att_chance, int *def_chance, struct unit *enemy_unit, struct unit *my_unit)
Definition dialogs.c:192
struct advanced_dialog * advanced_image_popup
Definition dialogs.c:3720
static int government_dlg_callback(struct widget *gov_button)
Definition dialogs.c:2426
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1306
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:623
static int notify_dialog_window_callback(struct widget *pwindow)
Definition dialogs.c:481
static int unit_select_window_callback(struct widget *pwindow)
Definition dialogs.c:1032
static struct small_dialog * unit_upgrade_dlg
Definition dialogs.c:618
static int exit_terrain_info_dialog_callback(struct widget *button)
Definition dialogs.c:1293
static int paradrop_here_callback(struct widget *pwidget)
Definition dialogs.c:1648
static int ok_disband_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:859
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1697
static struct notify_goto_dialog * notify_goto_dialog_new(void)
Definition dialogs.c:318
static void popdown_connect_dialog(void)
Definition dialogs.c:2393
static char * leader_name
Definition dialogs.c:97
struct advanced_dialog * notify_dlg
Definition dialogs.c:476
void popdown_find_dialog(void)
Definition finddlg.c:110
void popdown_goto_airlift_dialog(void)
Definition gotodlg.c:424
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:1379
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1309
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:1348
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
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:201
@ ID_NATION_WIZARD_WINDOW
Definition gui_id.h:60
@ ID_UNIT_SELECT_DLG_WINDOW
Definition gui_id.h:194
@ 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:197
@ ID_NATION_WIZARD_CHANGE_SEX_BUTTON
Definition gui_id.h:68
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
@ ID_BUTTON
Definition gui_id.h:29
@ ID_TERRAIN_INFO_DLG_WINDOW
Definition gui_id.h:199
@ ID_TERRAIN_INFO_DLG_EXIT_BUTTON
Definition gui_id.h:200
@ 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:204
@ ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON
Definition gui_id.h:67
@ ID_PILLAGE_DLG_WINDOW
Definition gui_id.h:203
@ ID_NATION_WIZARD_LEADER_NAME_EDIT
Definition gui_id.h:65
@ ID_GOVERNMENT_DLG_WINDOW
Definition gui_id.h:144
void force_exit_from_event_loop(void)
Definition gui_main.c:565
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
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:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_BIG
Definition gui_string.h:70
@ FONTO_ATTENTION
Definition gui_string.h:67
@ FONTO_MAX
Definition gui_string.h:71
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
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 popup_unit_info(Unit_type_id type_id)
Definition helpdlg.c:632
void popdown_intel_dialogs(void)
Definition inteldlg.c:215
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:961
void popdown_optiondlg(bool leave_game)
Definition optiondlg.c:1451
void popdown_players_nations_dialog(void)
Definition plrdlg.c:877
void science_report_dialogs_popdown_all(void)
Definition repodlgs.c:3479
#define GET_SURF(m_sprite)
Definition sprite.h:29
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
void del_widget_pointer_from_gui_list(struct widget *gui)
Definition widget.c:622
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:602
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
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:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
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)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
void popdown_worklist_editor(void)
Definition wldlg.c:1853
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5039
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:419
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:630
static int index_to_map_pos_y(int mindex)
Definition map.h:724
static int index_to_map_pos_x(int mindex)
Definition map.h:715
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:1015
static mpgui * gui
Definition mpgui_qt.cpp:52
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:138
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
int nation_set_count(void)
Definition nation.c:691
struct nation_set * nation_set_by_number(int id)
Definition nation.c:762
const char * nation_plural_translation(const struct nation_type *pnation)
Definition nation.c:159
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:498
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
const struct option_set * server_optset
Definition options.c:4016
bool option_str_set(struct option *poption, const char *str)
Definition options.c:926
const char * option_str_get(const struct option *poption)
Definition options.c:893
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
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:2363
char * lines
Definition packhand.c:131
int len
Definition packhand.c:127
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
int player_number(const struct player *pplayer)
Definition player.c:837
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1459
#define fc_rand(_size)
Definition rand.h:56
const char * sex_name_translation(sex_t kind)
Definition sex.c:60
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
#define MAX(x, y)
Definition shared.h:54
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
Definition city.h:320
struct government * government_during_revolution
Definition game.h:94
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
int id1
Definition widget.h:104
int id0
Definition widget.h:103
SDL_Surface * surface
Definition graphics.h:229
unsigned char selected_leader
Definition dialogs.c:2563
struct widget * pset_prev
Definition dialogs.c:2573
struct widget * name_next
Definition dialogs.c:2569
struct widget * name_edit
Definition dialogs.c:2568
bool leader_sex
Definition dialogs.c:2565
struct nation_set * set
Definition dialogs.c:2566
struct widget * change_sex
Definition dialogs.c:2567
unsigned char nation_style
Definition dialogs.c:2562
struct widget * pset_next
Definition dialogs.c:2572
Nation_type_id nation
Definition dialogs.c:2564
struct widget * name_prev
Definition dialogs.c:2570
struct widget * pset_name
Definition dialogs.c:2571
char * headline
Definition dialogs.c:215
struct tile * ptile
Definition dialogs.c:217
struct widget * close_button
Definition dialogs.c:226
struct widget * label
Definition dialogs.c:227
struct widget * window
Definition dialogs.c:225
struct notify_goto_list * datas
Definition dialogs.c:228
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:50
struct unit_list * units
Definition tile.h:58
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
char * text
Definition gui_string.h:60
void * ptr
Definition widget.h:133
union widget::@194 data
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
struct widget * prev
Definition widget.h:114
struct unit * unit
Definition widget.h:129
struct gui_layer * dst
Definition widget.h:116
struct city * city
Definition widget.h:128
struct container * cont
Definition widget.h:127
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
struct widget * next
Definition widget.h:113
utf8_str * info_label
Definition widget.h:122
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:974
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1323
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:88
#define tile_terrain(_tile)
Definition tile.h:110
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:147
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7578
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7586
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2051
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:822
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
#define unit_tile(_pu)
Definition unit.h:397
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:457
@ ORDER_LAST
Definition unit.h:49
#define unit_owner(_pu)
Definition unit.h:396
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:2610
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:190
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:1560
float map_zoom
Definition zoom.c:25