Freeciv-3.3
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 "ratesdlg_g.h"
55#include "text.h"
56#include "zoom.h"
57
58/* gui-sdl2 */
59#include "chatline.h"
60#include "citydlg.h"
61#include "cityrep.h"
62#include "cma_fe.h"
63#include "colors.h"
64#include "finddlg.h"
65#include "gotodlg.h"
66#include "graphics.h"
67#include "gui_id.h"
68#include "gui_main.h"
69#include "gui_tilespec.h"
70#include "helpdlg.h"
71#include "inteldlg.h"
72#include "mapctrl.h"
73#include "mapview.h"
74#include "menu.h"
75#include "messagewin.h"
76#include "optiondlg.h"
77#include "plrdlg.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))) {
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 struct player *owner = unit_owner(punit);
1165
1166 if (owner != nullptr) {
1167 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1169 (vetname != NULL ? vetname : ""),
1171 punittype->attack_strength,
1172 punittype->defense_strength,
1173 move_points_text(punittype->move_rate, FALSE),
1174 punittype->firepower,
1175 (punit->hp * 100 / punittype->hp + 9) / 10);
1176 } else {
1177 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1178 (vetname != NULL ? vetname : ""),
1180 punittype->attack_strength,
1181 punittype->defense_strength,
1182 move_points_text(punittype->move_rate, FALSE),
1183 punittype->firepower,
1184 (punit->hp * 100 / punittype->hp + 9) / 10);
1185 }
1186
1187 /* Calculate chance to win */
1189 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1190 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1192 }
1193 }
1194
1195 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf,
1197
1199
1200 area.w = MAX(area.w, buf->size.w);
1201 area.h += buf->size.h;
1204 }
1205
1206 if (i > NUM_SEEN - 1) {
1208 }
1209 }
1210
1215
1216 area.w += adj_size(2);
1217 if (n > NUM_SEEN) {
1219 area.w += n;
1220
1221 /* ------- window ------- */
1222 area.h = NUM_SEEN * pwindow->prev->prev->size.h;
1223 }
1224
1225 resize_window(pwindow, NULL, NULL,
1226 (pwindow->size.w - pwindow->area.w) + area.w,
1227 (pwindow->size.h - pwindow->area.h) + area.h);
1228
1229 area = pwindow->area;
1230
1231 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1232 ptile);
1233
1234 w = area.w;
1235
1236 if (unit_select_dlg->scroll) {
1237 w -= n;
1238 }
1239
1240 /* Exit button */
1241 buf = pwindow->prev;
1242 buf->size.x = area.x + area.w - buf->size.w - 1;
1243 buf->size.y = pwindow->size.y + adj_size(2);
1244 buf = buf->prev;
1245
1246 setup_vertical_widgets_position(1, area.x + 1, area.y, w, 0,
1248 buf);
1249
1250 if (unit_select_dlg->scroll) {
1252 area.x + area.w, area.y,
1253 area.h, TRUE);
1254 }
1255
1256 /* ==================================================== */
1257 /* Redraw */
1259
1260 widget_flush(pwindow);
1261}
1262
1263/**********************************************************************/
1267{
1268 /* PORTME */
1269}
1270
1271/* ====================================================================== */
1272/* ============================ TERRAIN INFO ============================ */
1273/* ====================================================================== */
1275
1276
1277/**********************************************************************/
1280static int terrain_info_window_dlg_callback(struct widget *pwindow)
1281{
1284 }
1285
1286 return -1;
1287}
1288
1289/**********************************************************************/
1301
1302/**********************************************************************/
1306{
1309 }
1310
1311 return -1;
1312}
1313
1314/**********************************************************************/
1318const char *sdl_get_tile_defense_info_text(struct tile *ptile)
1319{
1320 static char buffer[64];
1321 int bonus = (tile_terrain(ptile)->defense_bonus - 10) * 10;
1322
1323 extra_type_iterate(pextra) {
1324 if (tile_has_extra(ptile, pextra)
1325 && pextra->category == ECAT_NATURAL) {
1326 bonus += pextra->defense_bonus;
1327 }
1329
1330 fc_snprintf(buffer, sizeof(buffer), _("Terrain Defense Bonus: +%d%% "), bonus);
1331
1332 return buffer;
1333}
1334
1335/**********************************************************************/
1339{
1340 SDL_Surface *surf;
1341 struct widget *buf, *pwindow;
1342 utf8_str *pstr;
1343 char cbuf[256];
1344 SDL_Rect area;
1345
1346 if (terrain_info_dlg) {
1347 flush_dirty();
1348 return;
1349 }
1350
1351 surf = get_terrain_surface(ptile);
1352 terrain_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1353
1354 /* ----------- */
1355 fc_snprintf(cbuf, sizeof(cbuf), "%s [%d,%d]", _("Terrain Info"),
1356 TILE_XY(ptile));
1357
1358 pwindow
1361 0);
1362 pwindow->string_utf8->style |= TTF_STYLE_BOLD;
1363
1365 set_wstate(pwindow, FC_WS_NORMAL);
1366
1369
1370 area = pwindow->area;
1371
1372 /* ---------- */
1375 pstr->style |= SF_CENTER;
1376 buf = create_iconlabel(surf, pwindow->dst, pstr, 0);
1377
1378 buf->size.h += tileset_tile_height(tileset) / 2;
1379
1381
1382 /* ------ window ---------- */
1383 area.w = MAX(area.w, buf->size.w + adj_size(20));
1384 area.h = MAX(area.h, buf->size.h);
1385
1387 (pwindow->size.w - pwindow->area.w) + area.w,
1388 (pwindow->size.h - pwindow->area.h) + area.h);
1389
1390 area = pwindow->area;
1391
1392 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, ptile);
1393
1394 /* ------------------------ */
1395
1396 buf->size.x = area.x + adj_size(10);
1397 buf->size.y = area.y;
1398
1399 /* Exit icon */
1400 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1402 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1404 buf->size.x = area.x + area.w - buf->size.w - 1;
1405 buf->size.y = pwindow->size.y + adj_size(2);
1408 buf->key = SDLK_ESCAPE;
1409
1411
1413 /* --------------------------------- */
1414 /* redraw */
1416 widget_mark_dirty(pwindow);
1417 flush_dirty();
1418}
1419
1420/* ====================================================================== */
1421/* ========================= ADVANCED_TERRAIN_MENU ====================== */
1422/* ====================================================================== */
1424
1425/**********************************************************************/
1440
1441/**********************************************************************/
1445{
1448 }
1449
1450 return -1;
1451}
1452
1453/**********************************************************************/
1457{
1460 flush_dirty();
1461 }
1462
1463 return -1;
1464}
1465
1466/**********************************************************************/
1469static int terrain_info_callback(struct widget *pwidget)
1470{
1472 int x = pwidget->data.cont->id0;
1473 int y = pwidget->data.cont->id1;
1474
1476
1478 }
1479
1480 return -1;
1481}
1482
1483/**********************************************************************/
1486static int zoom_to_city_callback(struct widget *pwidget)
1487{
1489 struct city *pcity = pwidget->data.city;
1490
1492
1494 }
1495
1496 return -1;
1497}
1498
1499/**********************************************************************/
1502static int change_production_callback(struct widget *pwidget)
1503{
1505 struct city *pcity = pwidget->data.city;
1506
1509 }
1510
1511 return -1;
1512}
1513
1514/**********************************************************************/
1517static int hurry_production_callback(struct widget *pwidget)
1518{
1520 struct city *pcity = pwidget->data.city;
1521
1523
1525 }
1526
1527 return -1;
1528}
1529
1530/**********************************************************************/
1533static int cma_callback(struct widget *pwidget)
1534{
1536 struct city *pcity = pwidget->data.city;
1537
1540 }
1541
1542 return -1;
1543}
1544
1545/**********************************************************************/
1548static int adv_unit_select_callback(struct widget *pwidget)
1549{
1551 struct unit *punit = pwidget->data.unit;
1552
1554
1555 if (punit) {
1558 }
1559 }
1560
1561 return -1;
1562}
1563
1564/**********************************************************************/
1567static int adv_unit_select_all_callback(struct widget *pwidget)
1568{
1570 struct unit *punit = pwidget->data.unit;
1571
1573
1574 if (punit) {
1576 }
1577 }
1578
1579 return -1;
1580}
1581
1582/**********************************************************************/
1585static int adv_unit_sentry_idle_callback(struct widget *pwidget)
1586{
1588 struct unit *punit = pwidget->data.unit;
1589
1591
1592 if (punit) {
1593 struct tile *ptile = unit_tile(punit);
1594
1597 && ACTIVITY_IDLE == other_unit->activity
1598 && other_unit->ssa_controller == SSA_NONE
1601 }
1603 }
1604 }
1605
1606 return -1;
1607}
1608
1609/**********************************************************************/
1612static int goto_here_callback(struct widget *pwidget)
1613{
1615 int x = pwidget->data.cont->id0;
1616 int y = pwidget->data.cont->id1;
1617
1619
1620 /* may not work */
1622 map_pos_to_tile(&(wld.map), x, y));
1623 }
1624
1625 return -1;
1626}
1627
1628/**********************************************************************/
1631static int patrol_here_callback(struct widget *pwidget)
1632{
1634 int x = pwidget->data.cont->id0;
1635 int y = pwidget->data.cont->id1;
1636 struct tile *ptile;
1637
1638 ptile = map_pos_to_tile(&(wld.map), x, y);
1639
1640 if (ptile != NULL) {
1641 struct unit_list *punits = get_units_in_focus();
1642
1647 do_unit_patrol_to(ptile);
1649 }
1650
1652 }
1653
1654 return -1;
1655}
1656
1657/**********************************************************************/
1660static int paradrop_here_callback(struct widget *pwidget)
1661{
1663 int x = pwidget->data.cont->id0;
1664 int y = pwidget->data.cont->id1;
1665 struct tile *ptile;
1666
1667 ptile = map_pos_to_tile(&(wld.map), x, y);
1668
1669 if (ptile != NULL) {
1670 struct unit_list *punits = get_units_in_focus();
1671
1675
1677 do_unit_paradrop_to(punit, ptile);
1679
1682 }
1683
1685 }
1686
1687 return -1;
1688}
1689
1690/**********************************************************************/
1693static int unit_help_callback(struct widget *pwidget)
1694{
1696 Unit_type_id unit_id = MAX_ID - pwidget->id;
1697
1699 popup_unit_info(unit_id);
1700 }
1701
1702 return -1;
1703}
1704
1705/**********************************************************************/
1710 Uint16 pos_x, Uint16 pos_y)
1711{
1712 struct widget *pwindow = NULL, *buf = NULL;
1713 struct city *pcity;
1714 struct unit *focus_unit;
1715 utf8_str *pstr;
1717 struct container *cont;
1718 char cbuf[255];
1719 int n, w = 0, h, units_h = 0;
1720 SDL_Rect area;
1721
1723 return;
1724 }
1725
1726 pcity = tile_city(ptile);
1727 n = unit_list_size(ptile->units);
1729
1730 if (!n && !pcity && !focus_unit) {
1732
1733 return;
1734 }
1735
1736 area.h = adj_size(2);
1738
1739 advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1740
1741 cont = fc_calloc(1, sizeof(struct container));
1742 cont->id0 = index_to_map_pos_x(tile_index(ptile));
1743 cont->id1 = index_to_map_pos_y(tile_index(ptile));
1744
1746 pstr->style |= TTF_STYLE_BOLD;
1747
1748 pwindow = create_window_skeleton(NULL, pstr, 0);
1749
1751 set_wstate(pwindow , FC_WS_NORMAL);
1752
1755
1756 area = pwindow->area;
1757
1758 /* ---------- */
1759 /* Exit button */
1760 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1762 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1764 area.w += buf->size.w + adj_size(10);
1767 buf->key = SDLK_ESCAPE;
1768
1770 /* ---------- */
1771
1772 pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT);
1773 pstr->style |= TTF_STYLE_BOLD;
1774
1775 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1777
1778 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
1779
1780 buf->data.cont = cont;
1781
1782 buf->action = terrain_info_callback;
1784
1786
1787 area.w = MAX(area.w, buf->size.w);
1788 area.h += buf->size.h;
1789
1790 /* ---------- */
1791 if (pcity && city_owner(pcity) == client.conn.playing) {
1792 /* Separator */
1794
1796 area.h += buf->next->size.h;
1797 /* ------------------ */
1798
1799 fc_snprintf(cbuf, sizeof(cbuf), _("Zoom to : %s"), city_name_get(pcity));
1800
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 _("Change Production"), change_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 _("Hurry production"), hurry_production_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
1837 _("Change City Governor settings"), cma_callback);
1838
1839 buf->data.city = pcity;
1841
1843
1844 area.w = MAX(area.w, buf->size.w);
1845 area.h += buf->size.h;
1846 }
1847 /* ---------- */
1848
1849 if (focus_unit
1850 && (tile_index(unit_tile(focus_unit)) != tile_index(ptile))) {
1851 /* Separator */
1853
1855 area.h += buf->next->size.h;
1856 /* ------------------ */
1857
1858 create_active_iconlabel(buf, pwindow->dst, pstr, _("Goto here"),
1860 buf->data.cont = cont;
1862
1863 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1864
1865 area.w = MAX(area.w, buf->size.w);
1866 area.h += buf->size.h;
1867 /* ----------- */
1868
1869 create_active_iconlabel(buf, pwindow->dst, pstr, _("Patrol here"),
1871 buf->data.cont = cont;
1873
1874 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1875
1876 area.w = MAX(area.w, buf->size.w);
1877 area.h += buf->size.h;
1878 /* ----------- */
1879
1880#if 0 /* FIXME: specific connect buttons */
1882 create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
1884 buf->data.cont = cont;
1886
1888
1889 area.w = MAX(area.w, buf->size.w);
1890 area.h += buf->size.h;
1891 }
1892#endif /* 0 */
1893
1894 /* FIXME: This logic seems to try to mirror do_paradrop() why? */
1898 && (unit_type_get(focus_unit)->paratroopers_range >=
1900
1901 create_active_iconlabel(buf, pwindow->dst, pstr, _("Paradrop here"),
1903 buf->data.cont = cont;
1905
1907
1908 area.w = MAX(area.w, buf->size.w);
1909 area.h += buf->size.h;
1910 }
1911
1912 }
1914
1915 /* ---------- */
1916 if (n) {
1917 int i;
1918 struct unit *punit;
1919 const struct unit_type *punittype = NULL;
1920
1921 units_h = 0;
1922
1923 /* Separator */
1925
1927 area.h += buf->next->size.h;
1928 /* ---------- */
1929 if (n > 1) {
1930 struct unit *defender, *attacker;
1931 struct widget *last = buf;
1932 bool reset = FALSE;
1933 int my_units = 0;
1934 const char *vetname;
1935
1936 #define ADV_NUM_SEEN 15
1937
1938 defender = (focus_unit ? get_defender(&(wld.map), focus_unit, ptile, NULL)
1939 : NULL);
1940 attacker = (focus_unit ? get_attacker(&(wld.map), focus_unit, ptile)
1941 : NULL);
1942 for (i = 0; i < n; i++) {
1943 punit = unit_list_get(ptile->units, i);
1944 if (punit == focus_unit) {
1945 continue;
1946 }
1949
1951 struct astring addition = ASTRING_INIT;
1952
1954 fc_snprintf(cbuf, sizeof(cbuf),
1955 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
1956 (vetname != NULL ? vetname : ""),
1957 punit->hp, punittype->hp,
1959 punittype->attack_strength,
1960 punittype->defense_strength,
1961 move_points_text(punittype->move_rate, FALSE),
1962 astr_str(&addition));
1964
1967 buf->data.unit = punit;
1970 my_units++;
1971 } else {
1973
1974 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
1976 (vetname != NULL ? vetname : ""),
1978 punittype->attack_strength,
1979 punittype->defense_strength,
1980 move_points_text(punittype->move_rate, FALSE),
1981 punittype->firepower,
1982 ((punit->hp * 100) / punittype->hp));
1983
1984 /* Calculate chance to win */
1986 focus_unit)) {
1987 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1988 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1990 }
1991
1992 if (attacker && attacker == punit) {
1994 reset = TRUE;
1995 } else {
1996 if (defender && defender == punit) {
1998 reset = TRUE;
1999 }
2000 }
2001
2003
2004 if (reset) {
2006 reset = FALSE;
2007 }
2008
2010 }
2011
2012 area.w = MAX(area.w, buf->size.w);
2013 units_h += buf->size.h;
2014
2015 if (i > ADV_NUM_SEEN - 1) {
2017 }
2018 }
2019
2024
2025 if (n > ADV_NUM_SEEN) {
2028 1, ADV_NUM_SEEN, TRUE, TRUE);
2029 area.w += n;
2030 }
2031
2032 if (my_units > 1) {
2033 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Ready all"), my_units);
2038 buf->id = ID_LABEL;
2039 widget_add_as_prev(buf, last);
2040 area.h += buf->size.h;
2041
2042 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Sentry idle"), my_units);
2047 buf->id = ID_LABEL;
2048 widget_add_as_prev(buf, last->prev);
2049 area.h += buf->size.h;
2050
2051 /* separator */
2053 buf->id = ID_SEPARATOR;
2055 area.h += buf->next->size.h;
2056 }
2057#undef ADV_NUM_SEEN
2058 } else { /* n == 1 */
2059 /* one unit - give orders */
2060 punit = unit_list_get(ptile->units, 0);
2062 if (punit != focus_unit) {
2063 const char *vetname;
2064
2067 || (unit_owner(punit) == client.conn.playing)) {
2068 struct astring addition = ASTRING_INIT;
2069
2071 fc_snprintf(cbuf, sizeof(cbuf),
2072 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
2073 (vetname != NULL ? vetname : ""),
2074 punit->hp, punittype->hp,
2076 punittype->attack_strength,
2077 punittype->defense_strength,
2078 move_points_text(punittype->move_rate, FALSE),
2079 astr_str(&addition));
2081
2084 buf->data.unit = punit;
2086
2088
2089 area.w = MAX(area.w, buf->size.w);
2090 units_h += buf->size.h;
2091 /* ---------------- */
2092 /* Separator */
2094
2096 area.h += buf->next->size.h;
2097 } else {
2099
2100 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
2102 (vetname != NULL ? vetname : ""),
2104 punittype->attack_strength,
2105 punittype->defense_strength,
2106 move_points_text(punittype->move_rate, FALSE),
2107 punittype->firepower,
2108 ((punit->hp * 100) / punittype->hp));
2109
2110 /* Calculate chance to win */
2112 focus_unit)) {
2113 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
2114 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
2116 }
2119 area.w = MAX(area.w, buf->size.w);
2120 units_h += buf->size.h;
2121 /* ---------------- */
2122
2123 /* Separator */
2125
2127 area.h += buf->next->size.h;
2128 }
2129 }
2130
2131 /* ---------------- */
2132 fc_snprintf(cbuf, sizeof(cbuf),
2133 _("Look up \"%s\" in the Help Browser"),
2139
2140 area.w = MAX(area.w, buf->size.w);
2141 units_h += buf->size.h;
2142 /* ---------------- */
2144 }
2145
2146 }
2147 /* ---------- */
2148
2149 area.w += adj_size(2);
2150 area.h += units_h;
2151
2152 resize_window(pwindow, NULL, NULL,
2153 (pwindow->size.w - pwindow->area.w) + area.w,
2154 (pwindow->size.h - pwindow->area.h) + area.h);
2155
2156 area = pwindow->area;
2157
2158 widget_set_position(pwindow, pos_x, pos_y);
2159
2160 w = area.w - adj_size(2);
2161
2163 units_h = n;
2164 } else {
2165 units_h = 0;
2166 }
2167
2168 /* Exit button */
2169 buf = pwindow->prev;
2170
2171 buf->size.x = area.x + area.w - buf->size.w - 1;
2172 buf->size.y = pwindow->size.y + adj_size(2);
2173
2174 /* Terrain info */
2175 buf = buf->prev;
2176
2177 buf->size.x = area.x + 1;
2178 buf->size.y = area.y + 1;
2179 buf->size.w = w;
2180 h = buf->size.h;
2181
2182 area2.x = adj_size(10);
2183 area2.h = adj_size(2);
2184
2185 buf = buf->prev;
2186 while (buf) {
2188 w -= units_h;
2189 }
2190
2191 buf->size.w = w;
2192 buf->size.x = buf->next->size.x;
2193 buf->size.y = buf->next->size.y + buf->next->size.h;
2194
2195 if (buf->id == ID_SEPARATOR) {
2196 FREESURFACE(buf->theme);
2197 buf->size.h = h;
2198 buf->theme = create_surf(w, h, SDL_SWSURFACE);
2199
2200 area2.y = buf->size.h / 2 - 1;
2201 area2.w = buf->size.w - adj_size(20);
2202
2203 SDL_FillRect(buf->theme, &area2, map_rgba(buf->theme->format,
2205 }
2206
2209 break;
2210 }
2211 buf = buf->prev;
2212 }
2213
2216 area.x + area.w,
2218 area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
2219 TRUE);
2220 }
2221
2222 /* -------------------- */
2223 /* Redraw */
2225
2226 widget_flush(pwindow);
2227}
2228
2229/* ====================================================================== */
2230/* ============================ PILLAGE DIALOG ========================== */
2231/* ====================================================================== */
2233
2234/**********************************************************************/
2237static int pillage_window_callback(struct widget *pwindow)
2238{
2241 }
2242
2243 return -1;
2244}
2245
2246/**********************************************************************/
2249static int pillage_callback(struct widget *pwidget)
2250{
2252 struct unit *punit = pwidget->data.unit;
2253 int what = MAX_ID - pwidget->id;
2254
2256
2257 if (punit) {
2258 struct extra_type *target = extra_by_number(what);
2259
2261 }
2262 }
2263
2264 return -1;
2265}
2266
2267/**********************************************************************/
2270static int exit_pillage_dlg_callback(struct widget *pwidget)
2271{
2274 }
2275
2276 return -1;
2277}
2278
2279/**********************************************************************/
2293
2294/**********************************************************************/
2299{
2300 struct widget *pwindow = NULL, *buf = NULL;
2301 utf8_str *pstr;
2302 SDL_Rect area;
2303 struct extra_type *tgt;
2304
2305 if (pillage_dlg) {
2306 return;
2307 }
2308
2310 pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
2311
2312 /* Window */
2313 pstr = create_utf8_from_char_fonto(_("What To Pillage"), FONTO_ATTENTION);
2314 pstr->style |= TTF_STYLE_BOLD;
2315
2316 pwindow = create_window_skeleton(NULL, pstr, 0);
2317
2319 set_wstate(pwindow, FC_WS_NORMAL);
2320
2322 pillage_dlg->end_widget_list = pwindow;
2323
2324 area = pwindow->area;
2325
2326 area.h = MAX(area.h, adj_size(2));
2327
2328 /* ---------- */
2329 /* Exit button */
2330 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2332 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2334 area.w += buf->size.w + adj_size(10);
2337 buf->key = SDLK_ESCAPE;
2338
2340 /* ---------- */
2341
2342 while ((tgt = get_preferred_pillage(extras))) {
2343 const char *name = NULL;
2344 int what;
2345
2346 BV_CLR(extras, extra_index(tgt));
2348 what = extra_index(tgt);
2349
2350 fc_assert(name != NULL);
2351
2353 (char *) name, pillage_callback);
2354
2355 buf->data.unit = punit;
2357
2359
2360 area.w = MAX(area.w, buf->size.w);
2361 area.h += buf->size.h;
2362 }
2364
2365 /* setup window size and start position */
2366
2367 resize_window(pwindow, NULL, NULL,
2368 (pwindow->size.w - pwindow->area.w) + area.w,
2369 (pwindow->size.h - pwindow->area.h) + area.h);
2370
2371 area = pwindow->area;
2372
2373 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2374 unit_tile(punit));
2375
2376 /* Setup widget size and start position */
2377
2378 /* Exit button */
2379 buf = pwindow->prev;
2380 buf->size.x = area.x + area.w - buf->size.w - 1;
2381 buf->size.y = pwindow->size.y + adj_size(2);
2382
2383 /* First special to pillage */
2384 buf = buf->prev;
2386 area.x, area.y + 1, area.w, 0,
2388
2389 /* --------------------- */
2390 /* Redraw */
2392
2393 widget_flush(pwindow);
2394}
2395
2396/* ======================================================================= */
2397/* =========================== CONNECT DIALOG ============================ */
2398/* ======================================================================= */
2400
2401/**********************************************************************/
2414
2415/* ==================== Public ========================= */
2416
2417/**************************************************************************
2418 Select Government Type
2419**************************************************************************/
2420static struct small_dialog *gov_dlg = NULL;
2421
2422/**********************************************************************/
2434
2435/**********************************************************************/
2439{
2442
2444 }
2445
2446 return -1;
2447}
2448
2449/**********************************************************************/
2452static int move_government_dlg_callback(struct widget *pwindow)
2453{
2456 }
2457
2458 return -1;
2459}
2460
2461/**********************************************************************/
2465{
2466 struct utf8_str *pstr;
2467 struct widget *gov_button = NULL;
2468 struct widget *pwindow;
2469 int j;
2470 Uint16 max_w = 0, max_h = 0;
2471 SDL_Rect area;
2472
2473 if (gov_dlg != NULL) {
2474 return;
2475 }
2476
2477 gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
2478
2479 /* Create window */
2480 pstr = create_utf8_from_char_fonto(_("Choose Your New Government"),
2482 pstr->style |= TTF_STYLE_BOLD;
2483 /* This win. size is temp. */
2484 pwindow = create_window_skeleton(NULL, pstr, 0);
2487
2488 gov_dlg->end_widget_list = pwindow;
2489
2490 area = pwindow->area;
2491
2492 /* Create gov. buttons */
2493 j = 0;
2494 governments_iterate(gov) {
2496 continue;
2497 }
2498
2503 = create_icon_button(get_government_surface(gov), pwindow->dst, pstr, 0);
2505
2506 max_w = MAX(max_w, gov_button->size.w);
2507 max_h = MAX(max_h, gov_button->size.h);
2508
2509 /* Ugly hack */
2511 j++;
2512
2513 }
2515
2516 if (gov_button == NULL) {
2517 /* No governments to switch to.
2518 * TODO: Provide close button for the dialog. */
2520 } else {
2522
2524
2525 max_w += adj_size(10);
2526 max_h += adj_size(4);
2527
2528 area.w = MAX(area.w, max_w + adj_size(20));
2529 area.h = MAX(area.h, j * (max_h + adj_size(10)) + adj_size(5));
2530
2531 /* Create window background */
2533 if (resize_window(pwindow, logo, NULL,
2534 (pwindow->size.w - pwindow->area.w) + area.w,
2535 (pwindow->size.h - pwindow->area.h) + area.h)) {
2537 }
2538
2539 area = pwindow->area;
2540
2541 /* Set window start positions */
2542 widget_set_position(pwindow,
2543 (main_window_width() - pwindow->size.w) / 2,
2544 (main_window_height() - pwindow->size.h) / 2);
2545
2546 /* Set buttons start positions and size */
2547 j = 1;
2548 while (gov_button != gov_dlg->end_widget_list) {
2549 gov_button->size.w = max_w;
2550 gov_button->size.h = max_h;
2551 gov_button->size.x = area.x + adj_size(10);
2552 gov_button->size.y = area.y + area.h - (j++) * (max_h + adj_size(10));
2554
2555 gov_button = gov_button->next;
2556 }
2557 }
2558
2559 set_wstate(pwindow, FC_WS_NORMAL);
2560
2561 /* Redraw */
2563
2564 widget_flush(pwindow);
2565}
2566
2567/**************************************************************************
2568 Nation Wizard
2569**************************************************************************/
2571static struct small_dialog *help_dlg = NULL;
2572
2574 unsigned char nation_style; /* selected style */
2575 unsigned char selected_leader; /* if not unique -> selected leader */
2576 Nation_type_id nation; /* selected nation */
2577 bool leader_sex; /* selected leader sex */
2586};
2587
2588static int next_set_callback(struct widget *next_button);
2589static int prev_set_callback(struct widget *prev_button);
2590static int nations_dialog_callback(struct widget *pwindow);
2591static int nation_button_callback(struct widget *pnation);
2592static int races_dialog_ok_callback(struct widget *start_button);
2593static int races_dialog_cancel_callback(struct widget *button);
2594static int next_name_callback(struct widget *next_button);
2595static int prev_name_callback(struct widget *prev_button);
2596static int change_sex_callback(struct widget *sex);
2597static void select_random_leader(Nation_type_id nation);
2598static void change_nation_label(void);
2599
2600/**********************************************************************/
2603static int nations_dialog_callback(struct widget *pwindow)
2604{
2607 widget_flush(pwindow);
2608 }
2609 }
2610
2611 return -1;
2612}
2613
2614/**********************************************************************/
2617static int races_dialog_ok_callback(struct widget *start_button)
2618{
2620 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2621 char *pstr = setup->name_edit->string_utf8->text;
2622
2623 /* perform a minimum of sanity test on the name */
2624 if (strlen(pstr) == 0) {
2625 output_window_append(ftc_client, _("You must type a legal name."));
2626 selected_widget = start_button;
2627 set_wstate(start_button, FC_WS_SELECTED);
2628 widget_redraw(start_button);
2629 widget_flush(start_button);
2630
2631 return -1;
2632 }
2633
2635 setup->nation,
2636 setup->leader_sex, pstr,
2637 setup->nation_style);
2638
2640 flush_dirty();
2641 }
2642
2643 return -1;
2644}
2645
2646/**********************************************************************/
2649static int change_sex_callback(struct widget *sex)
2650{
2652 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2653
2654 if (setup->leader_sex) {
2657 } else {
2660 }
2661 setup->leader_sex = !setup->leader_sex;
2662
2663 if (sex) {
2666
2669 }
2670 }
2671
2672 return -1;
2673}
2674
2675/**********************************************************************/
2678static int next_name_callback(struct widget *next)
2679{
2681 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2682 const struct nation_leader_list *leaders =
2684 const struct nation_leader *pleader;
2685
2686 setup->selected_leader++;
2688
2689 /* change leader sex */
2690 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2692 }
2693
2694 /* change leader name */
2697
2700
2701 if (nation_leader_list_size(leaders) - 1 == setup->selected_leader) {
2703 }
2704
2705 if (get_wstate(setup->name_prev) == FC_WS_DISABLED) {
2707 }
2708
2709 if (!(get_wstate(setup->name_next) == FC_WS_DISABLED)) {
2710 selected_widget = setup->name_next;
2712 }
2713
2714 widget_redraw(setup->name_edit);
2715 widget_redraw(setup->name_prev);
2716 widget_redraw(setup->name_next);
2720
2721 widget_redraw(setup->change_sex);
2723
2724 flush_dirty();
2725 }
2726
2727 return -1;
2728}
2729
2730/**********************************************************************/
2733static int prev_name_callback(struct widget *prev)
2734{
2736 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2737 const struct nation_leader_list *leaders =
2739 const struct nation_leader *pleader;
2740
2741 setup->selected_leader--;
2743
2744 /* change leader sex */
2745 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2747 }
2748
2749 /* change leader name */
2752
2755
2756 if (!setup->selected_leader) {
2758 }
2759
2760 if (get_wstate(setup->name_next) == FC_WS_DISABLED) {
2762 }
2763
2764 if (!(get_wstate(setup->name_prev) == FC_WS_DISABLED)) {
2765 selected_widget = setup->name_prev;
2767 }
2768
2769 widget_redraw(setup->name_edit);
2770 widget_redraw(setup->name_prev);
2771 widget_redraw(setup->name_next);
2775
2776 widget_redraw(setup->change_sex);
2778
2779 flush_dirty();
2780 }
2781
2782 return -1;
2783}
2784
2785/**********************************************************************/
2788static int next_set_callback(struct widget *next_button)
2789{
2791 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2792 struct option *poption = optset_option_by_name(server_optset, "nationset");
2793
2794 fc_assert(setup->set != NULL
2795 && nation_set_index(setup->set) < nation_set_count() - 1);
2796
2797 setup->set = nation_set_by_number(nation_set_index(setup->set) + 1);
2798
2800 }
2801
2802 return -1;
2803}
2804
2805/**********************************************************************/
2809{
2811 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2812 struct option *poption = optset_option_by_name(server_optset, "nationset");
2813
2814 fc_assert(setup->set != NULL && nation_set_index(setup->set) > 0);
2815
2816 setup->set = nation_set_by_number(nation_set_index(setup->set) - 1);
2817
2819 }
2820
2821 return -1;
2822}
2823
2824/**********************************************************************/
2827static int races_dialog_cancel_callback(struct widget *button)
2828{
2831 flush_dirty();
2832 }
2833
2834 return -1;
2835}
2836
2837/**********************************************************************/
2840static int style_callback(struct widget *pwidget)
2841{
2843 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2845 setup->nation_style);
2846
2850
2851 set_wstate(pwidget, FC_WS_DISABLED);
2852 widget_redraw(pwidget);
2853 widget_mark_dirty(pwidget);
2854
2855 setup->nation_style = MAX_ID - 1000 - pwidget->id;
2856
2857 flush_dirty();
2859 }
2860
2861 return -1;
2862}
2863
2864/**********************************************************************/
2867static int help_dlg_callback(struct widget *pwindow)
2868{
2869 return -1;
2870}
2871
2872/**********************************************************************/
2875static int cancel_help_dlg_callback(struct widget *pwidget)
2876{
2878 if (help_dlg) {
2882 if (pwidget) {
2883 flush_dirty();
2884 }
2885 }
2886 }
2887
2888 return -1;
2889}
2890
2891/**********************************************************************/
2895{
2898
2900 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2901
2902 if (setup->nation == MAX_ID - nation_button->id) {
2905
2906 return -1;
2907 }
2908
2909 setup->nation = MAX_ID - nation_button->id;
2910
2912
2913 enable(MAX_ID - 1000 - setup->nation_style);
2915 disable(MAX_ID - 1000 - setup->nation_style);
2916
2918
2921 } else {
2922 /* Pop up nation description */
2923 struct widget *pwindow, *ok_button;
2924 utf8_str *pstr;
2925 SDL_Surface *text;
2927 struct nation_type *pnation = nation_by_number(MAX_ID - nation_button->id);
2928
2931
2932 if (!help_dlg) {
2933 help_dlg = fc_calloc(1, sizeof(struct small_dialog));
2934
2937 pstr->style |= TTF_STYLE_BOLD;
2938
2939 pwindow = create_window_skeleton(NULL, pstr, 0);
2940 pwindow->action = help_dlg_callback;
2941
2942 set_wstate(pwindow, FC_WS_NORMAL);
2943
2944 help_dlg->end_widget_list = pwindow;
2945 add_to_gui_list(ID_WINDOW, pwindow);
2946
2947 ok_button
2949 pwindow->dst, _("OK"),
2950 FONTO_HEADING, 0);
2951 ok_button->action = cancel_help_dlg_callback;
2952 set_wstate(ok_button, FC_WS_NORMAL);
2953 ok_button->key = SDLK_ESCAPE;
2954 add_to_gui_list(ID_BUTTON, ok_button);
2955 help_dlg->begin_widget_list = ok_button;
2956 } else {
2957 pwindow = help_dlg->end_widget_list;
2958 ok_button = help_dlg->begin_widget_list;
2959
2960 /* Undraw window */
2961 widget_undraw(pwindow);
2962 widget_mark_dirty(pwindow);
2963 }
2964
2965 area = pwindow->area;
2966
2967 {
2968 char info[4096];
2969
2970 helptext_nation(info, sizeof(info), pnation, NULL);
2972 }
2973
2976
2978
2979 /* create window background */
2980 area.w = MAX(area.w, text->w + adj_size(20));
2981 area.w = MAX(area.w, ok_button->size.w + adj_size(20));
2982 area.h = MAX(area.h, adj_size(9) + text->h
2983 + adj_size(10) + ok_button->size.h + adj_size(10));
2984
2986 (pwindow->size.w - pwindow->area.w) + area.w,
2987 (pwindow->size.h - pwindow->area.h) + area.h);
2988
2989 widget_set_position(pwindow,
2990 (main_window_width() - pwindow->size.w) / 2,
2991 (main_window_height() - pwindow->size.h) / 2);
2992
2993 area2.x = area.x + adj_size(7);
2994 area2.y = area.y + adj_size(6);
2995 alphablit(text, NULL, pwindow->theme, &area2, 255);
2996 FREESURFACE(text);
2997
2998 ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
2999 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
3000
3001 /* redraw */
3002 redraw_group(ok_button, pwindow, 0);
3003
3004 widget_mark_dirty(pwindow);
3005
3006 flush_dirty();
3007
3008 }
3009
3010 return -1;
3011}
3012
3013/**********************************************************************/
3016static int leader_name_edit_callback(struct widget *pedit)
3017{
3019 if (pedit->string_utf8->text != NULL) {
3020 /* empty input -> restore previous content */
3022 widget_redraw(pedit);
3023 widget_mark_dirty(pedit);
3024 flush_dirty();
3025 }
3026 }
3027
3028 return -1;
3029}
3030
3031/* =========================================================== */
3032
3033/**********************************************************************/
3036static void change_nation_label(void)
3037{
3039 struct widget *pwindow = nation_dlg->end_widget_list;
3040 struct nation_info *setup = (struct nation_info *)(pwindow->data.ptr);
3041 struct widget *label = setup->name_edit->next;
3042 struct nation_type *pnation = nation_by_number(setup->nation);
3043
3046
3047 FREESURFACE(label->theme);
3048 label->theme = tmp_surf_zoomed;
3049
3051
3052 remake_label_size(label);
3053
3054 label->size.x = pwindow->size.x + pwindow->size.w / 2 +
3055 (pwindow->size.w / 2 - label->size.w) / 2;
3056
3057}
3058
3059/**********************************************************************/
3064{
3065 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3066 const struct nation_leader_list *leaders =
3068 const struct nation_leader *pleader;
3069
3074
3077
3078 /* initialize leader sex */
3080
3081 if (setup->leader_sex) {
3084 } else {
3087 }
3088
3089 /* disable navigation buttons */
3092
3093 if (1 < nation_leader_list_size(leaders)) {
3094 /* if selected leader is not the first leader, enable "previous leader" button */
3095 if (setup->selected_leader > 0) {
3097 }
3098
3099 /* if selected leader is not the last leader, enable "next leader" button */
3100 if (setup->selected_leader < (nation_leader_list_size(leaders) - 1)) {
3102 }
3103 }
3104}
3105
3106/**********************************************************************/
3110{
3111 int playable_nation_count = 0;
3112
3113 nations_iterate(pnation) {
3114 if (pnation->is_playable && !pnation->player
3115 && is_nation_pickable(pnation))
3118
3119 return playable_nation_count;
3120}
3121
3122/**********************************************************************/
3125void popup_races_dialog(struct player *pplayer)
3126{
3127 SDL_Color bg_color = {255,255,255,128};
3128
3129 struct widget *pwindow, *pwidget = NULL, *buf, *last_City_Style;
3130 utf8_str *pstr;
3131 int len = 0;
3132 int w = adj_size(10), h = adj_size(10);
3135 SDL_Rect dst;
3136 float zoom;
3137 struct nation_info *setup;
3138 SDL_Rect area;
3139 int i;
3140 struct nation_type *pnat;
3141 struct widget *nationsets = NULL;
3142 int natinfo_y, natinfo_h;
3143
3144#define TARGETS_ROW 5
3145#define TARGETS_COL 1
3146
3147 if (nation_dlg) {
3148 return;
3149 }
3150
3151 races_player = pplayer;
3152
3153 nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3154
3155 /* Create window widget */
3156 pstr = create_utf8_from_char_fonto(_("What nation will you be?"),
3158 pstr->style |= TTF_STYLE_BOLD;
3159
3160 pwindow = create_window(NULL, pstr, w, h, WF_FREE_DATA);
3162 set_wstate(pwindow, FC_WS_NORMAL);
3163 setup = fc_calloc(1, sizeof(struct nation_info));
3164 pwindow->data.ptr = (void *)setup;
3165
3166 nation_dlg->end_widget_list = pwindow;
3168 /* --------------------------------------------------------- */
3169 /* Create nations list */
3170
3171 /* Create Imprv Background Icon */
3173
3175
3177 0, 0, main_bg->w - 1, main_bg->h - 1,
3179
3181 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
3182 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
3183
3184 /* Fill list */
3185
3186 nations_iterate(pnation) {
3187 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
3188 continue;
3189 }
3190
3192
3194
3197 text_name
3199
3200 dst.x = (tmp_surf->w - tmp_surf_zoomed->w) / 2;
3201 len = tmp_surf_zoomed->h +
3202 adj_size(10) + text_name->h;
3203 dst.y = (tmp_surf->h - len) / 2;
3205 dst.y += (tmp_surf_zoomed->h + adj_size(10));
3207
3208 dst.x = (tmp_surf->w - text_name->w) / 2;
3210 dst.y += text_name->h;
3212
3213 pwidget = create_icon2(tmp_surf, pwindow->dst,
3215
3216 set_wstate(pwidget, FC_WS_NORMAL);
3217
3218 pwidget->action = nation_button_callback;
3219
3220 w = MAX(w, pwidget->size.w);
3221 h = MAX(h, pwidget->size.h);
3222
3223 add_to_gui_list(MAX_ID - nation_index(pnation), pwidget);
3224
3225 if (nation_index(pnation) > (TARGETS_ROW * TARGETS_COL - 1)) {
3226 set_wflag(pwidget, WF_HIDDEN);
3227 }
3228
3230
3232
3234 nation_dlg->begin_widget_list = pwidget;
3236
3241 }
3242
3243 /* ----------------------------------------------------------------- */
3244
3245 /* Nation set selection */
3246 if (nation_set_count() > 1) {
3248 struct option *poption;
3249
3255
3256 /* Create nation set name label */
3259
3264
3265 pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3266
3267 add_to_gui_list(ID_LABEL, pwidget);
3268 setup->pset_name = pwidget;
3269
3270 /* Create next nationset button */
3271 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3272 pwindow->dst, NULL, 0);
3273 pwidget->action = next_set_callback;
3274 if (nation_set_index(setup->set) < nation_set_count() - 1) {
3275 set_wstate(pwidget, FC_WS_NORMAL);
3276 }
3278 pwidget->size.h = pwidget->next->size.h;
3279 setup->pset_next = pwidget;
3280
3281 /* Create prev nationset button */
3282 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3283 pwindow->dst, NULL, 0);
3284 pwidget->action = prev_set_callback;
3285 if (nation_set_index(setup->set) > 0) {
3286 set_wstate(pwidget, FC_WS_NORMAL);
3287 }
3289 pwidget->size.h = pwidget->next->size.h;
3290 setup->pset_prev = pwidget;
3291 }
3292
3293 /* Nation name */
3295 pnat = nation_by_number(setup->nation);
3297
3300 pstr->render = 2;
3302
3304
3305 pwidget = create_iconlabel(tmp_surf_zoomed, pwindow->dst, pstr,
3307 if (nationsets == NULL) {
3308 buf = pwidget;
3309 } else {
3310 buf = nationsets;
3311 }
3312
3313 add_to_gui_list(ID_LABEL, pwidget);
3314
3315 /* Create leader name edit */
3316 pwidget = create_edit_from_chars_fonto(NULL, pwindow->dst,
3317 NULL, FONTO_BIG,
3318 adj_size(200), 0);
3319 pwidget->size.h = adj_size(24);
3320
3321 set_wstate(pwidget, FC_WS_NORMAL);
3324 setup->name_edit = pwidget;
3325
3326 /* Create next leader name button */
3327 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3328 pwindow->dst, NULL, 0);
3329 pwidget->action = next_name_callback;
3331 pwidget->size.h = pwidget->next->size.h;
3332 setup->name_next = pwidget;
3333
3334 /* Create prev leader name button */
3335 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3336 pwindow->dst, NULL, 0);
3337 pwidget->action = prev_name_callback;
3339 pwidget->size.h = pwidget->next->size.h;
3340 setup->name_prev = pwidget;
3341
3342 /* Change sex button */
3343 pwidget = create_icon_button_from_chars_fonto(NULL, pwindow->dst,
3345 FONTO_HEADING, 0);
3346 pwidget->action = change_sex_callback;
3347 pwidget->size.w = adj_size(100);
3348 pwidget->size.h = adj_size(22);
3349 set_wstate(pwidget, FC_WS_NORMAL);
3350 setup->change_sex = pwidget;
3351
3352 /* Add to main widget list */
3354
3355 /* ---------------------------------------------------------- */
3356 zoom = DEFAULT_ZOOM * 1.0;
3357
3358 len = 0;
3361
3363
3364 if (tmp_surf->w > 48) {
3365 zoom = DEFAULT_ZOOM * (48.0 / tmp_surf->w);
3366 }
3367
3369
3370 pwidget = create_icon2(tmp_surf_zoomed, pwindow->dst,
3372 pwidget->action = style_callback;
3373 if (sn != setup->nation_style) {
3374 set_wstate(pwidget, FC_WS_NORMAL);
3375 }
3376 len += pwidget->size.w;
3377 add_to_gui_list(MAX_ID - 1000 - sn, pwidget);
3379
3380 last_City_Style = pwidget;
3381 /* ---------------------------------------------------------- */
3382
3383 /* Create Cancel button */
3384 pwidget
3386 pwindow->dst, _("Cancel"),
3387 FONTO_ATTENTION, 0);
3389 set_wstate(pwidget, FC_WS_NORMAL);
3390
3392
3393 /* Create OK button */
3394 pwidget
3396 pwindow->dst,
3397 _("OK"), FONTO_ATTENTION, 0);
3399
3400 set_wstate(pwidget, FC_WS_NORMAL);
3402 pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
3403 pwidget->next->size.w = pwidget->size.w;
3404
3405 nation_dlg->begin_widget_list = pwidget;
3406 /* ---------------------------------------------------------- */
3407
3409 if (resize_window(pwindow, main_bg, NULL, adj_size(640), adj_size(480))) {
3411 }
3412
3413 area = pwindow->area;
3414
3415 widget_set_position(pwindow,
3416 (main_window_width() - pwindow->size.w) / 2,
3417 (main_window_height() - pwindow->size.h) / 2);
3418
3419 /* Nations */
3420
3422 i = (area.h - adj_size(43) - h) / 2;
3424 area.x + adj_size(10),
3425 area.y + i - adj_size(4),
3428
3429 if (nation_dlg->scroll) {
3431
3434 area.x + w + adj_size(12),
3435 area.y + i - adj_size(4), h, FALSE);
3436
3437 area2.x = area.x + w + adj_size(11);
3438 area2.y = area.y + i - adj_size(4);
3440 area2.h = h;
3441 fill_rect_alpha(pwindow->theme, &area2, &bg_color);
3442
3443 create_frame(pwindow->theme,
3444 area2.x, area2.y - 1, area2.w, area2.h + 1,
3446 }
3447
3448 if (nationsets != NULL) {
3449 /* Nationsets header */
3450 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3451 buf->size.y = area.y + adj_size(46);
3452
3453 natinfo_y = buf->size.y;
3454 natinfo_h = area.h -= buf->size.y;
3455
3456 /* Nationset name */
3457 buf = buf->prev;
3458 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3459 buf->size.y = natinfo_y + adj_size(46);
3460
3461 natinfo_y += adj_size(46);
3462 natinfo_h -= adj_size(46);
3463
3464 /* Next Nationset Button */
3465 buf = buf->prev;
3466 buf->size.x = buf->next->size.x + buf->next->size.w;
3467 buf->size.y = buf->next->size.y;
3468
3469 /* Prev Nationset Button */
3470 buf = buf->prev;
3471 buf->size.x = buf->next->next->size.x - buf->size.w;
3472 buf->size.y = buf->next->size.y;
3473
3474 buf = buf->prev;
3475 } else {
3476 natinfo_y = area.y;
3477 natinfo_h = area.h;
3478 }
3479
3480 /* Selected Nation Name */
3481 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3482 buf->size.y = natinfo_y + adj_size(46);
3483
3484 /* Leader Name Edit */
3485 buf = buf->prev;
3486 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3487 buf->size.y = natinfo_y + (natinfo_h - buf->size.h) / 2 - adj_size(30);
3488
3489 /* Next Leader Name Button */
3490 buf = buf->prev;
3491 buf->size.x = buf->next->size.x + buf->next->size.w;
3492 buf->size.y = buf->next->size.y;
3493
3494 /* Prev Leader Name Button */
3495 buf = buf->prev;
3496 buf->size.x = buf->next->next->size.x - buf->size.w;
3497 buf->size.y = buf->next->size.y;
3498
3499 /* Change Leader Sex Button */
3500 buf = buf->prev;
3501 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3502 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3503
3504 /* First Style Button */
3505 buf = buf->prev;
3506 buf->size.x = area.x + area.w / 2 + (area.w / 2 - len) / 2 - adj_size(20);
3507 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3508
3509 /* Rest Style Buttons */
3510 while (buf != last_City_Style) {
3511 buf = buf->prev;
3512 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(3);
3513 buf->size.y = buf->next->size.y;
3514 }
3515
3516 create_line(pwindow->theme,
3517 area.x,
3518 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3519 area.w - 1,
3520 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3522
3523 /* Disconnect Button */
3524 buf = buf->prev;
3525 buf->size.x = area.x + adj_size(10);
3526 buf->size.y = natinfo_y + natinfo_h - adj_size(7) - buf->size.h;
3527
3528 /* Start Button */
3529 buf = buf->prev;
3530 buf->size.x = area.w - adj_size(10) - buf->size.w;
3531 buf->size.y = buf->next->size.y;
3532
3533 /* -------------------------------------------------------------------- */
3534
3536
3538
3539 widget_flush(pwindow);
3540}
3541
3542/**********************************************************************/
3560
3561/**********************************************************************/
3564void races_update_pickable(bool nationset_change)
3565{
3566 /* If this is because of nationset change, update will take
3567 * place later when the new option value is received */
3568 if (nation_dlg != NULL && !nationset_change) {
3571 }
3572}
3573
3574/**********************************************************************/
3578{
3579 if (nation_dlg != NULL) {
3582 }
3583}
3584
3585/**********************************************************************/
3590{
3591 struct nation_info *setup;
3592 bool change = FALSE;
3593 struct widget *nat;
3594
3595 if (!nation_dlg) {
3596 return;
3597 }
3598
3599 setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3600
3602 if (!is_nation_pickable(nation) || nation->player) {
3603 log_debug(" [%d]: %d = %s", nation_index(nation),
3604 (!is_nation_pickable(nation) || nation->player),
3606
3609
3610 if (nation_index(nation) == setup->nation) {
3611 change = TRUE;
3612 }
3613 }
3615
3616 if (change) {
3617 do {
3620 } while (get_wstate(nat) == FC_WS_DISABLED);
3621
3622 if (get_wstate(setup->name_edit) == FC_WS_PRESSED) {
3625 }
3627 enable(MAX_ID - 1000 - setup->nation_style);
3629 disable(MAX_ID - 1000 - setup->nation_style);
3631 }
3634}
3635
3636/**********************************************************************/
3641{
3642}
3643
3644/**********************************************************************/
3651
3652/**********************************************************************/
3659
3660/**********************************************************************/
3665{
3666 /* Don't load */
3667 return FALSE;
3668}
3669
3670/**********************************************************************/
3674{
3675 /* PORTME */
3676}
3677
3678/**********************************************************************/
3681void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
3682{
3683 /* PORTME */
3684}
3685
3686/**********************************************************************/
3691{
3692 /* Just tell the client common code to handle this. */
3693 return FALSE;
3694}
3695
3696/**********************************************************************/
3700{
3701 /* PORTME */
3702}
3703
3704/**********************************************************************/
3707bool request_transport(struct unit *pcargo, struct tile *ptile)
3708{
3709 return FALSE; /* Unit was not handled here. */
3710}
3711
3712/**********************************************************************/
3716void popup_combat_info(int attacker_unit_id, int defender_unit_id,
3717 int attacker_hp, int defender_hp,
3718 bool make_att_veteran, bool make_def_veteran)
3719{
3720}
3721
3722/**********************************************************************/
3726 struct act_confirmation_data *data)
3727{
3728 /* TODO: Implement. Currently just pass everything as confirmed */
3730}
3731
3733
3734/**********************************************************************/
3737static int image_popup_window_callback(struct widget *pwindow)
3738{
3741 }
3742
3743 return -1;
3744}
3745
3746/**********************************************************************/
3763
3764/**********************************************************************/
3767void popup_image(const char *tag)
3768{
3769 if (advanced_image_popup == NULL) {
3770 struct sprite *spr = load_popup_sprite(tag);
3771
3772 if (spr != NULL) {
3773 struct widget *win = create_window_skeleton(NULL, NULL, 0);
3774 struct widget *buf;
3776 SDL_Rect dst;
3777 SDL_Rect area;
3778 int width, height;
3779
3781 advanced_image_popup = fc_calloc(1, sizeof(struct advanced_dialog));
3782
3785
3788
3789 /* Create exit button */
3790 buf = create_themeicon(current_theme->small_cancel_icon, win->dst,
3792 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3796 buf->key = SDLK_ESCAPE;
3797
3800
3802 win->size.w - win->area.w + width,
3803 win->size.h - win->area.h + buf->area.h + height);
3804
3806 (main_window_width() - win->size.w) / 2,
3807 (main_window_height() - win->size.h) / 2);
3808
3809 area = win->area;
3810 dst.x = area.x;
3811 dst.y = area.y + buf->size.y;
3812 alphablit(surf, NULL, win->theme, &dst, 255);
3813
3814 /* Redraw */
3816 widget_flush(win);
3817
3819 } else {
3820 log_error(_("No image for tag \"%s\", requested by the server."), tag);
3821 }
3822 }
3823}
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:59
void astr_free(struct astring *astr)
Definition astring.c:148
#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:94
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:560
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:480
struct unit * get_attacker(const struct civ_map *nmap, const struct unit *defender, const struct tile *ptile)
Definition combat.c:911
struct unit * get_defender(const struct civ_map *nmap, const struct unit *attacker, const struct tile *ptile, const struct action *paction)
Definition combat.c:841
char * nationsets
Definition comments.c:61
char * incite_cost
Definition comments.c:76
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:518
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3197
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
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:1778
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3237
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1941
@ 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 struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:94
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 * 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 struct unit struct city * pcity
Definition dialogs_g.h:78
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 struct unit struct city const struct action *paction request_action_confirmation
Definition dialogs_g.h:94
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:64
#define NO_TARGET
Definition fc_types.h:214
int Tech_type_id
Definition fc_types.h:237
int Nation_type_id
Definition fc_types.h:240
int Unit_type_id
Definition fc_types.h:242
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
void exit_goto_state(void)
Definition goto.c:1033
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Definition goto.c:1569
void enter_goto_state(struct unit_list *punits)
Definition goto.c:1011
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:170
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
struct city * owner
Definition citydlg.c:226
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 show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.c:1540
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 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:207
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:1585
static struct small_dialog * terrain_info_dlg
Definition dialogs.c:1274
void popup_government_dialog(void)
Definition dialogs.c:2464
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:1548
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:1533
static struct small_dialog * connect_dlg
Definition dialogs.c:2399
bool is_unit_move_blocked
Definition gui_main.c:108
static int hurry_production_callback(struct widget *pwidget)
Definition dialogs.c:1517
static void select_random_leader(Nation_type_id nation)
Definition dialogs.c:3063
static int next_set_callback(struct widget *next_button)
Definition dialogs.c:2788
static int exit_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1044
void popdown_advanced_terrain_dialog(void)
Definition dialogs.c:1429
void popup_musicset_suggestion_dialog(void)
Definition dialogs.c:3656
#define ADV_NUM_SEEN
static void popdown_pillage_dialog(void)
Definition dialogs.c:2283
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:1456
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:2808
static int prev_name_callback(struct widget *prev_button)
Definition dialogs.c:2733
static int exit_image_popup_callback(struct widget *pwidget)
Definition dialogs.c:3749
static int terrain_info_callback(struct widget *pwidget)
Definition dialogs.c:1469
void popup_soundset_suggestion_dialog(void)
Definition dialogs.c:3648
static int style_callback(struct widget *pwidget)
Definition dialogs.c:2840
static int unit_help_callback(struct widget *pwidget)
Definition dialogs.c:1693
static int move_government_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2452
static void popdown_government_dialog(void)
Definition dialogs.c:2425
static struct advanced_dialog * nation_dlg
Definition dialogs.c:2570
static int change_sex_callback(struct widget *sex)
Definition dialogs.c:2649
static int cancel_help_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2875
static int next_name_callback(struct widget *next_button)
Definition dialogs.c:2678
void popup_tileset_suggestion_dialog(void)
Definition dialogs.c:3640
#define TARGETS_ROW
static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
Definition dialogs.c:1338
static int get_playable_nation_count(void)
Definition dialogs.c:3109
static struct small_dialog * help_dlg
Definition dialogs.c:2571
struct advanced_dialog * advanced_terrain_dlg
Definition dialogs.c:1423
static void popdown_terrain_info_dialog(void)
Definition dialogs.c:1292
static int adv_unit_select_all_callback(struct widget *pwidget)
Definition dialogs.c:1567
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:1444
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition dialogs.c:635
static int nation_button_callback(struct widget *pnation)
Definition dialogs.c:2894
static int races_dialog_cancel_callback(struct widget *button)
Definition dialogs.c:2827
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:3737
static int leader_name_edit_callback(struct widget *pedit)
Definition dialogs.c:3016
static int patrol_here_callback(struct widget *pwidget)
Definition dialogs.c:1631
static int pillage_window_callback(struct widget *pwindow)
Definition dialogs.c:2237
static int help_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2867
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.c:3664
static int disband_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:832
static int nations_dialog_callback(struct widget *pwindow)
Definition dialogs.c:2603
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:3699
static int goto_here_callback(struct widget *pwidget)
Definition dialogs.c:1612
static struct small_dialog * gov_dlg
Definition dialogs.c:2420
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:3707
static void change_nation_label(void)
Definition dialogs.c:3036
#define NUM_SEEN
static struct small_dialog * pillage_dlg
Definition dialogs.c:2232
void nationset_changed(void)
Definition dialogs.c:3577
void popdown_incite_dialog(void)
static int races_dialog_ok_callback(struct widget *start_button)
Definition dialogs.c:2617
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:1502
static int exit_pillage_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2270
static int terrain_info_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1280
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:1486
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:3732
static int government_dlg_callback(struct widget *gov_button)
Definition dialogs.c:2438
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1318
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:1305
static int paradrop_here_callback(struct widget *pwidget)
Definition dialogs.c:1660
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:1709
static struct notify_goto_dialog * notify_goto_dialog_new(void)
Definition dialogs.c:318
static void popdown_connect_dialog(void)
Definition dialogs.c:2405
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:683
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:146
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:863
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1363
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1307
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:234
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:197
struct sdl2_data main_data
Definition graphics.c:55
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:349
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:398
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1332
int main_window_height(void)
Definition graphics.c:691
#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:569
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:145
#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:630
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:24
@ COLOR_THEME_ADVANCEDTERRAINDLG_TEXT
Definition themecolors.h:46
@ 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
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
void add_to_gui_list(widget_id id, struct widget *gui)
Definition widget.c:586
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:1061
void popdown_worklist_editor(void)
Definition wldlg.c:1870
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5086
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert(condition)
Definition log.h:177
#define log_debug(message,...)
Definition log.h:116
#define log_error(message,...)
Definition log.h:104
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:434
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:675
static int index_to_map_pos_y(int mindex)
Definition map.h:772
static int index_to_map_pos_x(int mindex)
Definition map.h:759
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:1066
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:4077
bool option_str_set(struct option *poption, const char *str)
Definition options.c:937
const char * option_str_get(const struct option *poption)
Definition options.c:904
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:442
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:2392
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:1463
#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:317
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:2575
struct widget * pset_prev
Definition dialogs.c:2585
struct widget * name_next
Definition dialogs.c:2581
struct widget * name_edit
Definition dialogs.c:2580
bool leader_sex
Definition dialogs.c:2577
struct nation_set * set
Definition dialogs.c:2578
struct widget * change_sex
Definition dialogs.c:2579
unsigned char nation_style
Definition dialogs.c:2574
struct widget * pset_next
Definition dialogs.c:2584
Nation_type_id nation
Definition dialogs.c:2576
struct widget * name_prev
Definition dialogs.c:2582
struct widget * pset_name
Definition dialogs.c:2583
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:140
int id
Definition unit.h:147
int hp
Definition unit.h:153
int veteran
Definition unit.h:154
Uint8 style
Definition gui_string.h:53
char * text
Definition gui_string.h:60
void * ptr
Definition widget.h:133
widget_id id
Definition widget.h:155
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
struct widget * prev
Definition widget.h:114
union widget::@196 data
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
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:960
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:986
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:549
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1376
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:89
#define tile_terrain(_tile)
Definition tile.h:115
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:152
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7834
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:791
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7842
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
enum unit_upgrade_result unit_upgrade_info(const struct civ_map *nmap, const struct unit *punit, char *buf, size_t bufsz)
Definition unit.c:2114
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:864
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1210
#define unit_tile(_pu)
Definition unit.h:407
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:469
@ ORDER_LAST
Definition unit.h:50
#define unit_owner(_pu)
Definition unit.h:406
unit_upgrade_result
Definition unit.h:61
@ UU_OK
Definition unit.h:62
#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:2614
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:194
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:1564
float map_zoom
Definition zoom.c:25