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/* SDL3 */
27#include <SDL3/SDL.h>
28
29/* utility */
30#include "astring.h"
31#include "bitvector.h"
32#include "fcintl.h"
33#include "log.h"
34#include "rand.h"
35
36/* common */
37#include "combat.h"
38#include "game.h"
39#include "government.h"
40#include "movement.h"
41#include "sex.h"
42#include "unitlist.h"
43
44/* client */
45#include "client_main.h"
46#include "climap.h" /* For client_tile_get_known() */
47#include "goto.h"
48#include "helpdata.h" /* For helptext_nation() */
49#include "packhand.h"
50#include "ratesdlg_g.h"
51#include "text.h"
52#include "zoom.h"
53
54/* gui-sdl3 */
55#include "chatline.h"
56#include "citydlg.h"
57#include "cityrep.h"
58#include "cma_fe.h"
59#include "colors.h"
60#include "finddlg.h"
61#include "gotodlg.h"
62#include "graphics.h"
63#include "gui_id.h"
64#include "gui_main.h"
65#include "gui_tilespec.h"
66#include "helpdlg.h"
67#include "inteldlg.h"
68#include "mapctrl.h"
69#include "mapview.h"
70#include "menu.h"
71#include "messagewin.h"
72#include "optiondlg.h"
73#include "plrdlg.h"
74#include "repodlgs.h"
75#include "sprite.h"
76#include "themespec.h"
77#include "widget.h"
78#include "wldlg.h"
79
80#include "dialogs.h"
81
83
84extern bool is_unit_move_blocked;
85extern void popdown_diplomat_dialog(void);
86extern void popdown_incite_dialog(void);
87extern void popdown_bribe_dialog(void);
88
92
93static char *leader_name = NULL;
94
95static void unit_select_dialog_popdown(void);
96static void popdown_terrain_info_dialog(void);
97static void popdown_pillage_dialog(void);
98static void popdown_connect_dialog(void);
99static void popdown_unit_upgrade_dlg(void);
100static void popdown_unit_disband_dlg(void);
101
102/**********************************************************************/
105void put_window_near_map_tile(struct widget *pwindow,
107 struct tile *ptile)
108{
109 float canvas_x, canvas_y;
110 int window_x = 0, window_y = 0;
111
114 if (canvas_x - window_width < 0) {
116 } else {
118 }
119 } else {
121 }
122
126 } else {
127 if (canvas_y < 0) {
128 window_y = 0;
129 } else {
131 }
132 }
133 } else {
136 }
137
139}
140
141/**********************************************************************/
180
181/* ======================================================================= */
182
183/**********************************************************************/
189 struct unit *enemy_unit,
190 struct unit *my_unit)
191{
192 if (!my_unit || !enemy_unit) {
193 return FALSE;
194 }
195
196 /* Chance to win when active unit is attacking the selected unit */
198 enemy_unit, NULL) * 100;
199
200 /* Chance to win when selected unit is attacking the active unit */
202 my_unit, NULL)) * 100;
203
204 return TRUE;
205}
206
207/**************************************************************************
208 Notify goto dialog.
209**************************************************************************/
210struct notify_goto_data {
211 char *headline;
212 char *lines;
213 struct tile *ptile;
214};
215
216#define SPECLIST_TAG notify_goto
217#define SPECLIST_TYPE struct notify_goto_data
218#include "speclist.h"
219
220struct notify_goto_dialog {
221 struct widget *window;
222 struct widget *close_button;
223 struct widget *label;
224 struct notify_goto_list *datas;
225};
226
228
229static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog);
230
231/**********************************************************************/
235 const char *lines,
236 struct tile *ptile)
237{
238 struct notify_goto_data *pdata = fc_malloc(sizeof(*pdata));
239
240 pdata->headline = fc_strdup(headline);
241 pdata->lines = fc_strdup(lines);
242 pdata->ptile = ptile;
243
244 return pdata;
245}
246
247/**********************************************************************/
251{
252 free(pdata->headline);
253 free(pdata->lines);
254}
255
256/**********************************************************************/
260{
261 struct notify_goto_dialog *pdialog =
262 (struct notify_goto_dialog *) widget->data.ptr;
263
265 move_window_group(pdialog->label, pdialog->window);
266 }
267
268 return -1;
269}
270
271/**********************************************************************/
275{
276 struct notify_goto_dialog *pdialog =
277 (struct notify_goto_dialog *) widget->data.ptr;
278
281 }
282
283 return -1;
284}
285
286/**********************************************************************/
290{
291 struct notify_goto_dialog *pdialog =
292 (struct notify_goto_dialog *) widget->data.ptr;
293 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
294 0);
295
297 if (NULL != pdata->ptile) {
299 }
300 } else if (main_data.event.button.button == SDL_BUTTON_RIGHT) {
301 struct city *pcity;
302
303 if (NULL != pdata->ptile && (pcity = tile_city(pdata->ptile))) {
305 }
306 }
307
308 return -1;
309}
310
311/**********************************************************************/
315{
316 struct notify_goto_dialog *pdialog = fc_malloc(sizeof(*pdialog));
317 utf8_str *str;
318
319 /* Window. */
321 str->style |= TTF_STYLE_BOLD;
322
323 pdialog->window = create_window_skeleton(NULL, str, 0);
325 pdialog->window->data.ptr = pdialog;
326 set_wstate(pdialog->window, FC_WS_NORMAL);
328
329 /* Close button. */
330 pdialog->close_button = create_themeicon(current_theme->small_cancel_icon,
331 pdialog->window->dst,
334 pdialog->close_button->info_label
335 = create_utf8_from_char_fonto(_("Close Dialog (Esc)"), FONTO_ATTENTION);
337 pdialog->close_button->data.ptr = pdialog;
339 pdialog->close_button->key = SDLK_ESCAPE;
341
342 pdialog->label = NULL;
343
344 /* Data list. */
346
347 return pdialog;
348}
349
350/**********************************************************************/
354{
355 widget_undraw(pdialog->window);
356 widget_mark_dirty(pdialog->window);
357 remove_gui_layer(pdialog->window->dst);
358
361 if (NULL != pdialog->label) {
363 }
364
366 free(pdialog);
367}
368
369/**********************************************************************/
373{
374 const struct notify_goto_data *pdata = notify_goto_list_get(pdialog->datas,
375 0);
376
377 if (NULL == pdata) {
378 return;
379 }
380
381 widget_undraw(pdialog->window);
382 widget_mark_dirty(pdialog->window);
383
384 copy_chars_to_utf8_str(pdialog->window->string_utf8, pdata->headline);
385 if (NULL != pdialog->label) {
387 }
389 pdata->lines,
393 pdialog->label->data.ptr = pdialog;
394 set_wstate(pdialog->label, FC_WS_NORMAL);
395 add_to_gui_list(ID_LABEL, pdialog->label);
396
397 resize_window(pdialog->window, NULL, NULL,
398 adj_size(pdialog->label->size.w + 40),
399 adj_size(pdialog->label->size.h + 60));
401 (main_window_width() - pdialog->window->size.w) / 2,
402 (main_window_height() - pdialog->window->size.h) / 2);
403 widget_set_position(pdialog->close_button, pdialog->window->size.w
404 - pdialog->close_button->size.w - 1,
405 pdialog->window->size.y + adj_size(2));
406 widget_set_position(pdialog->label, adj_size(20), adj_size(40));
407
408 widget_redraw(pdialog->window);
409 widget_redraw(pdialog->close_button);
410 widget_redraw(pdialog->label);
411 widget_mark_dirty(pdialog->window);
412 flush_all();
413}
414
415/**********************************************************************/
419{
420 if (1 < notify_goto_list_size(pdialog->datas)) {
422 notify_goto_list_get(pdialog->datas, 0));
424 } else {
426 if (pdialog == notify_goto_dialog) {
428 }
429 }
430}
431
432/**********************************************************************/
451
452/**********************************************************************/
462
463/**********************************************************************/
466void popup_connect_msg(const char *headline, const char *message)
467{
468 log_error("popup_connect_msg() PORT ME");
469}
470
471/* ----------------------------------------------------------------------- */
473
474/**********************************************************************/
477static int notify_dialog_window_callback(struct widget *pwindow)
478{
481 }
482
483 return -1;
484}
485
486/**********************************************************************/
489static int exit_notify_dialog_callback(struct widget *pwidget)
490{
492 if (notify_dlg) {
497 flush_dirty();
498 }
499 }
500
501 return -1;
502}
503
504/**********************************************************************/
507void popup_notify_dialog(const char *caption, const char *headline,
508 const char *lines)
509{
510 struct widget *buf, *pwindow;
511 utf8_str *pstr;
515
516 if (notify_dlg) {
517 return;
518 }
519
520 notify_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
521
523 pstr->style |= TTF_STYLE_BOLD;
524
525 pwindow = create_window_skeleton(NULL, pstr, 0);
526
528 set_wstate(pwindow, FC_WS_NORMAL);
529
530 add_to_gui_list(ID_WINDOW, pwindow);
531 notify_dlg->end_widget_list = pwindow;
532
533 area = pwindow->area;
534
535 /* ---------- */
536 /* Create exit button */
537 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
539 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
543 buf->key = SDLK_ESCAPE;
544 area.w += (buf->size.w + adj_size(10));
545
548
550 pstr->style |= TTF_STYLE_BOLD;
551
553
554 if (lines && *lines != '\0') {
556 pstr->style &= ~TTF_STYLE_BOLD;
559 } else {
561 }
562
564
565 area.w = MAX(area.w, headline_surf->w);
566 if (lines_surf) {
567 area.w = MAX(area.w, lines_surf->w);
568 }
569 area.w += adj_size(60);
570 area.h = MAX(area.h, adj_size(10) + headline_surf->h + adj_size(10));
571 if (lines_surf) {
572 area.h += lines_surf->h + adj_size(10);
573 }
574
576 (pwindow->size.w - pwindow->area.w) + area.w,
577 (pwindow->size.h - pwindow->area.h) + area.h);
578
579 area = pwindow->area;
580
581 widget_set_position(pwindow,
582 (main_window_width() - pwindow->size.w) / 2,
583 (main_window_height() - pwindow->size.h) / 2);
584
585 dst.x = area.x + (area.w - headline_surf->w) / 2;
586 dst.y = area.y + adj_size(10);
587
588 alphablit(headline_surf, NULL, pwindow->theme, &dst, 255);
589 if (lines_surf) {
590 dst.y += headline_surf->h + adj_size(10);
591 if (headline_surf->w < lines_surf->w) {
592 dst.x = area.x + (area.w - lines_surf->w) / 2;
593 }
594
595 alphablit(lines_surf, NULL, pwindow->theme, &dst, 255);
596 }
597
600
601 /* Exit button */
602 buf = pwindow->prev;
603 buf->size.x = area.x + area.w - buf->size.w - 1;
604 buf->size.y = pwindow->size.y + adj_size(2);
605
606 /* Redraw */
608 widget_flush(pwindow);
609}
610
611/* =======================================================================*/
612/* ========================= UNIT UPGRADE DIALOG =========================*/
613/* =======================================================================*/
615
616/**********************************************************************/
619static int upgrade_unit_window_callback(struct widget *pwindow)
620{
623 }
624
625 return -1;
626}
627
628/**********************************************************************/
631static int cancel_upgrade_unit_callback(struct widget *pwidget)
632{
635 /* enable city dlg */
637 flush_dirty();
638 }
639
640 return -1;
641}
642
643/**********************************************************************/
646static int ok_upgrade_unit_window_callback(struct widget *pwidget)
647{
649 struct unit *punit = pwidget->data.unit;
650
652 /* enable city dlg */
656 flush_dirty();
657 }
658
659 return -1;
660}
661
662/***********************************************************************/
665void popup_upgrade_dialog(struct unit_list *punits)
666{
667 /* PORTME: is support for more than one unit in punits required? */
668
669 /* Assume only one unit for now. */
671 "SDL3 popup_upgrade_dialog() handles max 1 unit.");
672
674}
675
676/**********************************************************************/
680{
681 char cbuf[128];
682 struct widget *buf = NULL, *pwindow;
683 utf8_str *pstr;
684 SDL_Surface *text;
686 int window_x = 0, window_y = 0;
689
690 if (unit_upgrade_dlg) {
691 /* just in case */
692 flush_dirty();
693 return;
694 }
695
696 unit_upgrade_dlg = fc_calloc(1, sizeof(struct small_dialog));
697
699
700 pstr = create_utf8_from_char_fonto(_("Upgrade Obsolete Units"),
702 pstr->style |= TTF_STYLE_BOLD;
703
704 pwindow = create_window_skeleton(NULL, pstr, 0);
705
706 pwindow->action = upgrade_unit_window_callback;
707 set_wstate(pwindow, FC_WS_NORMAL);
708
710
711 add_to_gui_list(ID_WINDOW, pwindow);
712
713 area = pwindow->area;
714
715 /* ============================================================= */
716
717 /* Create text label */
719 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
721
724
725 area.w = MAX(area.w, text->w + adj_size(20));
726 area.h += (text->h + adj_size(10));
727
728 /* Cancel button */
730 pwindow->dst, _("Cancel"),
731 FONTO_ATTENTION, 0);
732
735
736 area.h += (buf->size.h + adj_size(20));
737
739
740 if (UU_OK == unit_upgrade_result) {
742 pwindow->dst,
743 _("Upgrade"),
744 FONTO_ATTENTION, 0);
745
748 buf->data.unit = punit;
750 buf->size.w = MAX(buf->size.w, buf->next->size.w);
751 buf->next->size.w = buf->size.w;
752 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
753 } else {
754 area.w = MAX(area.w, buf->size.w + adj_size(20));
755 }
756 /* ============================================ */
757
759
761 (pwindow->size.w - pwindow->area.w) + area.w,
762 (pwindow->size.h - pwindow->area.h) + area.h);
763
764 area = pwindow->area;
765
766 if (city) {
767 window_x = main_data.event.motion.x;
768 window_y = main_data.event.motion.y;
769 } else {
770 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
772 }
773
775
776 /* setup rest of widgets */
777 /* label */
778 dst.x = area.x + (area.w - text->w) / 2;
779 dst.y = area.y + adj_size(10);
780 alphablit(text, NULL, pwindow->theme, &dst, 255);
781 FREESURFACE(text);
782
783 /* cancel button */
784 buf = pwindow->prev;
785 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
786
787 if (UU_OK == unit_upgrade_result) {
788 /* upgrade button */
789 buf = buf->prev;
790 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
791 buf->size.y = buf->next->size.y;
792
793 /* cancel button */
794 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
795 } else {
796 /* x position of cancel button */
797 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
798 }
799
800 /* ================================================== */
801 /* redraw */
803
804 widget_mark_dirty(pwindow);
805 flush_dirty();
806}
807
808/**********************************************************************/
819
820/* =======================================================================*/
821/* ========================= UNIT DISBAND DIALOG =========================*/
822/* =======================================================================*/
824
825/**********************************************************************/
828static int disband_unit_window_callback(struct widget *pwindow)
829{
832 }
833
834 return -1;
835}
836
837/**********************************************************************/
840static int cancel_disband_unit_callback(struct widget *pwidget)
841{
844 /* enable city dlg */
846 flush_dirty();
847 }
848
849 return -1;
850}
851
852/**********************************************************************/
855static int ok_disband_unit_window_callback(struct widget *pwidget)
856{
858 struct unit *punit = pwidget->data.unit;
859
861 /* enable city dlg */
865 flush_dirty();
866 }
867
868 return -1;
869}
870
871/**********************************************************************/
875{
876 char cbuf[128];
877 struct widget *buf = NULL, *pwindow;
878 utf8_str *pstr;
879 SDL_Surface *text;
881 int window_x = 0, window_y = 0;
884
885 if (unit_disband_dlg) {
886 /* just in case */
887 flush_dirty();
888 return;
889 }
890
891 unit_disband_dlg = fc_calloc(1, sizeof(struct small_dialog));
892
893 {
894 struct unit_list *punits = unit_list_new();
895
899 }
900
902 pstr->style |= TTF_STYLE_BOLD;
903
904 pwindow = create_window_skeleton(NULL, pstr, 0);
905
906 pwindow->action = disband_unit_window_callback;
907 set_wstate(pwindow, FC_WS_NORMAL);
908
910
911 add_to_gui_list(ID_WINDOW, pwindow);
912
913 area = pwindow->area;
914
915 /* ============================================================= */
916
917 /* Create text label */
919 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
921
924
925 area.w = MAX(area.w, text->w + adj_size(20));
926 area.h += (text->h + adj_size(10));
927
928 /* Cancel button */
930 pwindow->dst, _("Cancel"),
931 FONTO_ATTENTION, 0);
932
935
936 area.h += (buf->size.h + adj_size(20));
937
939
942 pwindow->dst,
943 _("Disband"),
944 FONTO_ATTENTION, 0);
945
948 buf->data.unit = punit;
950 buf->size.w = MAX(buf->size.w, buf->next->size.w);
951 buf->next->size.w = buf->size.w;
952 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
953 } else {
954 area.w = MAX(area.w, buf->size.w + adj_size(20));
955 }
956 /* ============================================ */
957
959
961 (pwindow->size.w - pwindow->area.w) + area.w,
962 (pwindow->size.h - pwindow->area.h) + area.h);
963
964 area = pwindow->area;
965
966 if (city) {
967 window_x = main_data.event.motion.x;
968 window_y = main_data.event.motion.y;
969 } else {
970 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
972 }
973
975
976 /* setup rest of widgets */
977 /* label */
978 dst.x = area.x + (area.w - text->w) / 2;
979 dst.y = area.y + adj_size(10);
980 alphablit(text, NULL, pwindow->theme, &dst, 255);
981 FREESURFACE(text);
982
983 /* cancel button */
984 buf = pwindow->prev;
985 buf->size.y = area.y + area.h - buf->size.h - adj_size(7);
986
988 /* disband button */
989 buf = buf->prev;
990 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
991 buf->size.y = buf->next->size.y;
992
993 /* cancel button */
994 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
995 } else {
996 /* x position of cancel button */
997 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
998 }
999
1000 /* ================================================== */
1001 /* redraw */
1003
1004 widget_mark_dirty(pwindow);
1005 flush_dirty();
1006}
1007
1008/**********************************************************************/
1019
1020/* =======================================================================*/
1021/* ======================== UNIT SELECTION DIALOG ========================*/
1022/* =======================================================================*/
1024
1025/**********************************************************************/
1028static int unit_select_window_callback(struct widget *pwindow)
1029{
1032 }
1033
1034 return -1;
1035}
1036
1037/**********************************************************************/
1040static int exit_unit_select_callback(struct widget *pwidget)
1041{
1045 }
1046
1047 return -1;
1048}
1049
1050/**********************************************************************/
1053static int unit_select_callback(struct widget *pwidget)
1054{
1056 struct unit *punit =
1058
1060 if (punit) {
1063 }
1064 }
1065
1066 return -1;
1067}
1068
1069/**********************************************************************/
1084
1085/**********************************************************************/
1089{
1090 struct widget *buf = NULL, *pwindow;
1091 utf8_str *pstr;
1092 struct unit *punit = NULL, *focus = head_of_units_in_focus();
1093 const struct unit_type *punittype;
1094 char cbuf[255];
1095 int i, w = 0, n;
1096 SDL_Rect area;
1097
1098#define NUM_SEEN 20
1099
1100 n = unit_list_size(ptile->units);
1101
1102 if (n == 0 || unit_select_dlg) {
1103 return;
1104 }
1105
1107 unit_select_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1108
1109 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Unit selection"), n);
1111 pstr->style |= TTF_STYLE_BOLD;
1112
1113 pwindow = create_window_skeleton(NULL, pstr, 0);
1114
1115 pwindow->action = unit_select_window_callback;
1116 set_wstate(pwindow, FC_WS_NORMAL);
1117
1120
1121 area = pwindow->area;
1122
1123 /* ---------- */
1124 /* Create exit button */
1125 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1127 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1131 buf->key = SDLK_ESCAPE;
1132 area.w += (buf->size.w + adj_size(10));
1133
1135
1136 /* ---------- */
1137
1138 for (i = 0; i < n; i++) {
1139 const char *vetname;
1140
1141 punit = unit_list_get(ptile->units, i);
1144
1146 struct astring addition = ASTRING_INIT;
1147
1149 fc_snprintf(cbuf , sizeof(cbuf), _("Contact %s (%d / %d) %s(%d,%d,%s) %s"),
1150 (vetname != NULL ? vetname : ""),
1151 punit->hp, punittype->hp,
1153 punittype->attack_strength,
1154 punittype->defense_strength,
1155 move_points_text(punittype->move_rate, FALSE),
1156 astr_str(&addition));
1158 } else {
1160
1161 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1163 (vetname != NULL ? vetname : ""),
1165 punittype->attack_strength,
1166 punittype->defense_strength,
1167 move_points_text(punittype->move_rate, FALSE),
1168 punittype->firepower,
1169 (punit->hp * 100 / punittype->hp + 9) / 10);
1170
1171 /* Calculate chance to win */
1173 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1174 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1176 }
1177 }
1178
1179 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf,
1181
1183
1184 area.w = MAX(area.w, buf->size.w);
1185 area.h += buf->size.h;
1188 }
1189
1190 if (i > NUM_SEEN - 1) {
1192 }
1193 }
1194
1199
1200 area.w += adj_size(2);
1201 if (n > NUM_SEEN) {
1203 area.w += n;
1204
1205 /* ------- window ------- */
1206 area.h = NUM_SEEN * pwindow->prev->prev->size.h;
1207 }
1208
1209 resize_window(pwindow, NULL, NULL,
1210 (pwindow->size.w - pwindow->area.w) + area.w,
1211 (pwindow->size.h - pwindow->area.h) + area.h);
1212
1213 area = pwindow->area;
1214
1215 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1216 ptile);
1217
1218 w = area.w;
1219
1220 if (unit_select_dlg->scroll) {
1221 w -= n;
1222 }
1223
1224 /* Exit button */
1225 buf = pwindow->prev;
1226 buf->size.x = area.x + area.w - buf->size.w - 1;
1227 buf->size.y = pwindow->size.y + adj_size(2);
1228 buf = buf->prev;
1229
1230 setup_vertical_widgets_position(1, area.x + 1, area.y, w, 0,
1232 buf);
1233
1234 if (unit_select_dlg->scroll) {
1236 area.x + area.w, area.y,
1237 area.h, TRUE);
1238 }
1239
1240 /* ==================================================== */
1241 /* Redraw */
1243
1244 widget_flush(pwindow);
1245}
1246
1247/**********************************************************************/
1251{
1252 /* PORTME */
1253}
1254
1255/* ====================================================================== */
1256/* ============================ TERRAIN INFO ============================ */
1257/* ====================================================================== */
1259
1260
1261/**********************************************************************/
1264static int terrain_info_window_dlg_callback(struct widget *pwindow)
1265{
1268 }
1269
1270 return -1;
1271}
1272
1273/**********************************************************************/
1285
1286/**********************************************************************/
1290{
1293 }
1294
1295 return -1;
1296}
1297
1298/**********************************************************************/
1302const char *sdl_get_tile_defense_info_text(struct tile *ptile)
1303{
1304 static char buffer[64];
1305 int bonus = (tile_terrain(ptile)->defense_bonus - 10) * 10;
1306
1307 extra_type_iterate(pextra) {
1308 if (tile_has_extra(ptile, pextra)
1309 && pextra->category == ECAT_NATURAL) {
1310 bonus += pextra->defense_bonus;
1311 }
1313
1314 fc_snprintf(buffer, sizeof(buffer), _("Terrain Defense Bonus: +%d%% "), bonus);
1315
1316 return buffer;
1317}
1318
1319/**********************************************************************/
1323{
1324 SDL_Surface *surf;
1325 struct widget *buf, *pwindow;
1326 utf8_str *pstr;
1327 char cbuf[256];
1328 SDL_Rect area;
1329
1330 if (terrain_info_dlg) {
1331 flush_dirty();
1332 return;
1333 }
1334
1335 surf = get_terrain_surface(ptile);
1336 terrain_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1337
1338 /* ----------- */
1339 fc_snprintf(cbuf, sizeof(cbuf), "%s [%d,%d]", _("Terrain Info"),
1340 TILE_XY(ptile));
1341
1342 pwindow
1345 0);
1346 pwindow->string_utf8->style |= TTF_STYLE_BOLD;
1347
1349 set_wstate(pwindow, FC_WS_NORMAL);
1350
1353
1354 area = pwindow->area;
1355
1356 /* ---------- */
1359 pstr->style |= SF_CENTER;
1360 buf = create_iconlabel(surf, pwindow->dst, pstr, 0);
1361
1362 buf->size.h += tileset_tile_height(tileset) / 2;
1363
1365
1366 /* ------ window ---------- */
1367 area.w = MAX(area.w, buf->size.w + adj_size(20));
1368 area.h = MAX(area.h, buf->size.h);
1369
1371 (pwindow->size.w - pwindow->area.w) + area.w,
1372 (pwindow->size.h - pwindow->area.h) + area.h);
1373
1374 area = pwindow->area;
1375
1376 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, ptile);
1377
1378 /* ------------------------ */
1379
1380 buf->size.x = area.x + adj_size(10);
1381 buf->size.y = area.y;
1382
1383 /* Exit icon */
1384 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1386 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1388 buf->size.x = area.x + area.w - buf->size.w - 1;
1389 buf->size.y = pwindow->size.y + adj_size(2);
1392 buf->key = SDLK_ESCAPE;
1393
1395
1397 /* --------------------------------- */
1398 /* redraw */
1400 widget_mark_dirty(pwindow);
1401 flush_dirty();
1402}
1403
1404/* ====================================================================== */
1405/* ========================= ADVANCED_TERRAIN_MENU ====================== */
1406/* ====================================================================== */
1408
1409/**********************************************************************/
1424
1425/**********************************************************************/
1429{
1432 }
1433
1434 return -1;
1435}
1436
1437/**********************************************************************/
1441{
1444 flush_dirty();
1445 }
1446
1447 return -1;
1448}
1449
1450/**********************************************************************/
1453static int terrain_info_callback(struct widget *pwidget)
1454{
1456 int x = pwidget->data.cont->id0;
1457 int y = pwidget->data.cont->id1;
1458
1460
1462 }
1463
1464 return -1;
1465}
1466
1467/**********************************************************************/
1470static int zoom_to_city_callback(struct widget *pwidget)
1471{
1473 struct city *pcity = pwidget->data.city;
1474
1476
1478 }
1479
1480 return -1;
1481}
1482
1483/**********************************************************************/
1486static int change_production_callback(struct widget *pwidget)
1487{
1489 struct city *pcity = pwidget->data.city;
1490
1493 }
1494
1495 return -1;
1496}
1497
1498/**********************************************************************/
1501static int hurry_production_callback(struct widget *pwidget)
1502{
1504 struct city *pcity = pwidget->data.city;
1505
1507
1509 }
1510
1511 return -1;
1512}
1513
1514/**********************************************************************/
1517static int cma_callback(struct widget *pwidget)
1518{
1520 struct city *pcity = pwidget->data.city;
1521
1524 }
1525
1526 return -1;
1527}
1528
1529/**********************************************************************/
1532static int adv_unit_select_callback(struct widget *pwidget)
1533{
1535 struct unit *punit = pwidget->data.unit;
1536
1538
1539 if (punit) {
1542 }
1543 }
1544
1545 return -1;
1546}
1547
1548/**********************************************************************/
1551static int adv_unit_select_all_callback(struct widget *pwidget)
1552{
1554 struct unit *punit = pwidget->data.unit;
1555
1557
1558 if (punit) {
1560 }
1561 }
1562
1563 return -1;
1564}
1565
1566/**********************************************************************/
1569static int adv_unit_sentry_idle_callback(struct widget *pwidget)
1570{
1572 struct unit *punit = pwidget->data.unit;
1573
1575
1576 if (punit) {
1577 struct tile *ptile = unit_tile(punit);
1578
1581 && ACTIVITY_IDLE == other_unit->activity
1582 && other_unit->ssa_controller == SSA_NONE
1585 }
1587 }
1588 }
1589
1590 return -1;
1591}
1592
1593/**********************************************************************/
1596static int goto_here_callback(struct widget *pwidget)
1597{
1599 int x = pwidget->data.cont->id0;
1600 int y = pwidget->data.cont->id1;
1601
1603
1604 /* may not work */
1606 map_pos_to_tile(&(wld.map), x, y));
1607 }
1608
1609 return -1;
1610}
1611
1612/**********************************************************************/
1615static int patrol_here_callback(struct widget *pwidget)
1616{
1618 int x = pwidget->data.cont->id0;
1619 int y = pwidget->data.cont->id1;
1620 struct tile *ptile;
1621
1622 ptile = map_pos_to_tile(&(wld.map), x, y);
1623
1624 if (ptile != NULL) {
1625 struct unit_list *punits = get_units_in_focus();
1626
1631 do_unit_patrol_to(ptile);
1633 }
1634
1636 }
1637
1638 return -1;
1639}
1640
1641/**********************************************************************/
1644static int paradrop_here_callback(struct widget *pwidget)
1645{
1647 int x = pwidget->data.cont->id0;
1648 int y = pwidget->data.cont->id1;
1649 struct tile *ptile;
1650
1651 ptile = map_pos_to_tile(&(wld.map), x, y);
1652
1653 if (ptile != NULL) {
1654 struct unit_list *punits = get_units_in_focus();
1655
1659
1661 do_unit_paradrop_to(punit, ptile);
1663
1666 }
1667
1669 }
1670
1671 return -1;
1672}
1673
1674/**********************************************************************/
1677static int unit_help_callback(struct widget *pwidget)
1678{
1680 Unit_type_id unit_id = MAX_ID - pwidget->id;
1681
1683 popup_unit_info(unit_id);
1684 }
1685
1686 return -1;
1687}
1688
1689/**********************************************************************/
1694 Uint16 pos_x, Uint16 pos_y)
1695{
1696 struct widget *pwindow = NULL, *buf = NULL;
1697 struct city *pcity;
1698 struct unit *focus_unit;
1699 utf8_str *pstr;
1701 struct container *cont;
1702 char cbuf[255];
1703 int n, w = 0, h, units_h = 0;
1704 SDL_Rect area;
1705
1707 return;
1708 }
1709
1710 pcity = tile_city(ptile);
1711 n = unit_list_size(ptile->units);
1713
1714 if (!n && !pcity && !focus_unit) {
1716
1717 return;
1718 }
1719
1720 area.h = adj_size(2);
1722
1723 advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1724
1725 cont = fc_calloc(1, sizeof(struct container));
1726 cont->id0 = index_to_map_pos_x(tile_index(ptile));
1727 cont->id1 = index_to_map_pos_y(tile_index(ptile));
1728
1730 pstr->style |= TTF_STYLE_BOLD;
1731
1732 pwindow = create_window_skeleton(NULL, pstr, 0);
1733
1735 set_wstate(pwindow , FC_WS_NORMAL);
1736
1739
1740 area = pwindow->area;
1741
1742 /* ---------- */
1743 /* Exit button */
1744 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1746 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1748 area.w += buf->size.w + adj_size(10);
1751 buf->key = SDLK_ESCAPE;
1752
1754 /* ---------- */
1755
1756 pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT);
1757 pstr->style |= TTF_STYLE_BOLD;
1758
1759 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1761
1762 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
1763
1764 buf->data.cont = cont;
1765
1766 buf->action = terrain_info_callback;
1768
1770
1771 area.w = MAX(area.w, buf->size.w);
1772 area.h += buf->size.h;
1773
1774 /* ---------- */
1775 if (pcity && city_owner(pcity) == client.conn.playing) {
1776 /* Separator */
1778
1780 area.h += buf->next->size.h;
1781 /* ------------------ */
1782
1783 fc_snprintf(cbuf, sizeof(cbuf), _("Zoom to : %s"), city_name_get(pcity));
1784
1787 buf->data.city = pcity;
1789
1791
1792 area.w = MAX(area.w, buf->size.w);
1793 area.h += buf->size.h;
1794 /* ----------- */
1795
1797 _("Change Production"), change_production_callback);
1798
1799 buf->data.city = pcity;
1801
1803
1804 area.w = MAX(area.w, buf->size.w);
1805 area.h += buf->size.h;
1806 /* -------------- */
1807
1809 _("Hurry production"), hurry_production_callback);
1810
1811 buf->data.city = pcity;
1813
1815
1816 area.w = MAX(area.w, buf->size.w);
1817 area.h += buf->size.h;
1818 /* ----------- */
1819
1821 _("Change City Governor settings"), cma_callback);
1822
1823 buf->data.city = pcity;
1825
1827
1828 area.w = MAX(area.w, buf->size.w);
1829 area.h += buf->size.h;
1830 }
1831 /* ---------- */
1832
1833 if (focus_unit
1834 && (tile_index(unit_tile(focus_unit)) != tile_index(ptile))) {
1835 /* Separator */
1837
1839 area.h += buf->next->size.h;
1840 /* ------------------ */
1841
1842 create_active_iconlabel(buf, pwindow->dst, pstr, _("Goto here"),
1844 buf->data.cont = cont;
1846
1847 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1848
1849 area.w = MAX(area.w, buf->size.w);
1850 area.h += buf->size.h;
1851 /* ----------- */
1852
1853 create_active_iconlabel(buf, pwindow->dst, pstr, _("Patrol here"),
1855 buf->data.cont = cont;
1857
1858 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1859
1860 area.w = MAX(area.w, buf->size.w);
1861 area.h += buf->size.h;
1862 /* ----------- */
1863
1864#if 0 /* FIXME: Specific connect buttons */
1866 create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
1868 buf->data.cont = cont;
1870
1872
1873 area.w = MAX(area.w, buf->size.w);
1874 area.h += buf->size.h;
1875 }
1876#endif /* 0 */
1877
1878 /* FIXME: This logic seems to try to mirror do_paradrop() why? */
1882 && (unit_type_get(focus_unit)->paratroopers_range >=
1884
1885 create_active_iconlabel(buf, pwindow->dst, pstr, _("Paradrop here"),
1887 buf->data.cont = cont;
1889
1891
1892 area.w = MAX(area.w, buf->size.w);
1893 area.h += buf->size.h;
1894 }
1895
1896 }
1898
1899 /* ---------- */
1900 if (n) {
1901 int i;
1902 struct unit *punit;
1903 const struct unit_type *punittype = NULL;
1904
1905 units_h = 0;
1906
1907 /* Separator */
1909
1911 area.h += buf->next->size.h;
1912 /* ---------- */
1913 if (n > 1) {
1914 struct unit *defender, *attacker;
1915 struct widget *last = buf;
1916 bool reset = FALSE;
1917 int my_units = 0;
1918 const char *vetname;
1919
1920 #define ADV_NUM_SEEN 15
1921
1922 defender = (focus_unit ? get_defender(&(wld.map), focus_unit, ptile, NULL)
1923 : NULL);
1924 attacker = (focus_unit ? get_attacker(&(wld.map), focus_unit, ptile)
1925 : NULL);
1926 for (i = 0; i < n; i++) {
1927 punit = unit_list_get(ptile->units, i);
1928 if (punit == focus_unit) {
1929 continue;
1930 }
1933
1935 struct astring addition = ASTRING_INIT;
1936
1938 fc_snprintf(cbuf, sizeof(cbuf),
1939 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
1940 (vetname != NULL ? vetname : ""),
1941 punit->hp, punittype->hp,
1943 punittype->attack_strength,
1944 punittype->defense_strength,
1945 move_points_text(punittype->move_rate, FALSE),
1946 astr_str(&addition));
1948
1951 buf->data.unit = punit;
1954 my_units++;
1955 } else {
1957
1958 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
1960 (vetname != NULL ? vetname : ""),
1962 punittype->attack_strength,
1963 punittype->defense_strength,
1964 move_points_text(punittype->move_rate, FALSE),
1965 punittype->firepower,
1966 ((punit->hp * 100) / punittype->hp));
1967
1968 /* Calculate chance to win */
1970 focus_unit)) {
1971 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1972 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1974 }
1975
1976 if (attacker && attacker == punit) {
1978 reset = TRUE;
1979 } else {
1980 if (defender && defender == punit) {
1982 reset = TRUE;
1983 }
1984 }
1985
1987
1988 if (reset) {
1990 reset = FALSE;
1991 }
1992
1994 }
1995
1996 area.w = MAX(area.w, buf->size.w);
1997 units_h += buf->size.h;
1998
1999 if (i > ADV_NUM_SEEN - 1) {
2001 }
2002 }
2003
2008
2009 if (n > ADV_NUM_SEEN) {
2012 1, ADV_NUM_SEEN, TRUE, TRUE);
2013 area.w += n;
2014 }
2015
2016 if (my_units > 1) {
2017 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Ready all"), my_units);
2022 buf->id = ID_LABEL;
2023 widget_add_as_prev(buf, last);
2024 area.h += buf->size.h;
2025
2026 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Sentry idle"), my_units);
2031 buf->id = ID_LABEL;
2032 widget_add_as_prev(buf, last->prev);
2033 area.h += buf->size.h;
2034
2035 /* Separator */
2037 buf->id = ID_SEPARATOR;
2039 area.h += buf->next->size.h;
2040 }
2041#undef ADV_NUM_SEEN
2042 } else { /* n == 1 */
2043 /* One unit - give orders */
2044 punit = unit_list_get(ptile->units, 0);
2046 if (punit != focus_unit) {
2047 const char *vetname;
2048
2051 || (unit_owner(punit) == client.conn.playing)) {
2052 struct astring addition = ASTRING_INIT;
2053
2055 fc_snprintf(cbuf, sizeof(cbuf),
2056 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
2057 (vetname != NULL ? vetname : ""),
2058 punit->hp, punittype->hp,
2060 punittype->attack_strength,
2061 punittype->defense_strength,
2062 move_points_text(punittype->move_rate, FALSE),
2063 astr_str(&addition));
2065
2068 buf->data.unit = punit;
2070
2072
2073 area.w = MAX(area.w, buf->size.w);
2074 units_h += buf->size.h;
2075 /* ---------------- */
2076 /* Separator */
2078
2080 area.h += buf->next->size.h;
2081 } else {
2083
2084 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
2086 (vetname != NULL ? vetname : ""),
2088 punittype->attack_strength,
2089 punittype->defense_strength,
2090 move_points_text(punittype->move_rate, FALSE),
2091 punittype->firepower,
2092 ((punit->hp * 100) / punittype->hp));
2093
2094 /* Calculate chance to win */
2096 focus_unit)) {
2097 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
2098 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
2100 }
2103 area.w = MAX(area.w, buf->size.w);
2104 units_h += buf->size.h;
2105 /* ---------------- */
2106
2107 /* Separator */
2109
2111 area.h += buf->next->size.h;
2112 }
2113 }
2114
2115 /* ---------------- */
2116 fc_snprintf(cbuf, sizeof(cbuf),
2117 _("Look up \"%s\" in the Help Browser"),
2123
2124 area.w = MAX(area.w, buf->size.w);
2125 units_h += buf->size.h;
2126 /* ---------------- */
2128 }
2129
2130 }
2131 /* ---------- */
2132
2133 area.w += adj_size(2);
2134 area.h += units_h;
2135
2136 resize_window(pwindow, NULL, NULL,
2137 (pwindow->size.w - pwindow->area.w) + area.w,
2138 (pwindow->size.h - pwindow->area.h) + area.h);
2139
2140 area = pwindow->area;
2141
2142 widget_set_position(pwindow, pos_x, pos_y);
2143
2144 w = area.w - adj_size(2);
2145
2147 units_h = n;
2148 } else {
2149 units_h = 0;
2150 }
2151
2152 /* Exit button */
2153 buf = pwindow->prev;
2154
2155 buf->size.x = area.x + area.w - buf->size.w - 1;
2156 buf->size.y = pwindow->size.y + adj_size(2);
2157
2158 /* Terrain info */
2159 buf = buf->prev;
2160
2161 buf->size.x = area.x + 1;
2162 buf->size.y = area.y + 1;
2163 buf->size.w = w;
2164 h = buf->size.h;
2165
2166 area2.x = adj_size(10);
2167 area2.h = adj_size(2);
2168
2169 buf = buf->prev;
2170 while (buf != NULL) {
2172 w -= units_h;
2173 }
2174
2175 buf->size.w = w;
2176 buf->size.x = buf->next->size.x;
2177 buf->size.y = buf->next->size.y + buf->next->size.h;
2178
2179 if (buf->id == ID_SEPARATOR) {
2180 FREESURFACE(buf->theme);
2181 buf->size.h = h;
2182 buf->theme = create_surf(w, h);
2183
2184 area2.y = buf->size.h / 2 - 1;
2185 area2.w = buf->size.w - adj_size(20);
2186
2187 SDL_FillSurfaceRect(buf->theme, &area2,
2188 map_rgba(buf->theme->format,
2190 }
2191
2194 break;
2195 }
2196 buf = buf->prev;
2197 }
2198
2201 area.x + area.w,
2203 area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
2204 TRUE);
2205 }
2206
2207 /* -------------------- */
2208 /* Redraw */
2210
2211 widget_flush(pwindow);
2212}
2213
2214/* ====================================================================== */
2215/* ============================ PILLAGE DIALOG ========================== */
2216/* ====================================================================== */
2218
2219/**********************************************************************/
2222static int pillage_window_callback(struct widget *pwindow)
2223{
2226 }
2227
2228 return -1;
2229}
2230
2231/**********************************************************************/
2234static int pillage_callback(struct widget *pwidget)
2235{
2237 struct unit *punit = pwidget->data.unit;
2238 int what = MAX_ID - pwidget->id;
2239
2241
2242 if (punit) {
2243 struct extra_type *target = extra_by_number(what);
2244
2246 }
2247 }
2248
2249 return -1;
2250}
2251
2252/**********************************************************************/
2255static int exit_pillage_dlg_callback(struct widget *pwidget)
2256{
2259 }
2260
2261 return -1;
2262}
2263
2264/**********************************************************************/
2278
2279/**********************************************************************/
2284{
2285 struct widget *pwindow = NULL, *buf = NULL;
2286 utf8_str *pstr;
2287 SDL_Rect area;
2288 struct extra_type *tgt;
2289
2290 if (pillage_dlg) {
2291 return;
2292 }
2293
2295 pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
2296
2297 /* Window */
2298 pstr = create_utf8_from_char_fonto(_("What To Pillage"), FONTO_ATTENTION);
2299 pstr->style |= TTF_STYLE_BOLD;
2300
2301 pwindow = create_window_skeleton(NULL, pstr, 0);
2302
2304 set_wstate(pwindow, FC_WS_NORMAL);
2305
2307 pillage_dlg->end_widget_list = pwindow;
2308
2309 area = pwindow->area;
2310
2311 area.h = MAX(area.h, adj_size(2));
2312
2313 /* ---------- */
2314 /* Exit button */
2315 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2317 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2319 area.w += buf->size.w + adj_size(10);
2322 buf->key = SDLK_ESCAPE;
2323
2325 /* ---------- */
2326
2327 while ((tgt = get_preferred_pillage(extras))) {
2328 const char *name = NULL;
2329 int what;
2330
2331 BV_CLR(extras, extra_index(tgt));
2333 what = extra_index(tgt);
2334
2335 fc_assert(name != NULL);
2336
2338 (char *) name, pillage_callback);
2339
2340 buf->data.unit = punit;
2342
2344
2345 area.w = MAX(area.w, buf->size.w);
2346 area.h += buf->size.h;
2347 }
2349
2350 /* setup window size and start position */
2351
2352 resize_window(pwindow, NULL, NULL,
2353 (pwindow->size.w - pwindow->area.w) + area.w,
2354 (pwindow->size.h - pwindow->area.h) + area.h);
2355
2356 area = pwindow->area;
2357
2358 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2359 unit_tile(punit));
2360
2361 /* Setup widget size and start position */
2362
2363 /* Exit button */
2364 buf = pwindow->prev;
2365 buf->size.x = area.x + area.w - buf->size.w - 1;
2366 buf->size.y = pwindow->size.y + adj_size(2);
2367
2368 /* First special to pillage */
2369 buf = buf->prev;
2371 area.x, area.y + 1, area.w, 0,
2373
2374 /* --------------------- */
2375 /* Redraw */
2377
2378 widget_flush(pwindow);
2379}
2380
2381/* ======================================================================= */
2382/* =========================== CONNECT DIALOG ============================ */
2383/* ======================================================================= */
2385
2386/**********************************************************************/
2399
2400/* ==================== Public ========================= */
2401
2402/**************************************************************************
2403 Select Government Type
2404**************************************************************************/
2405static struct small_dialog *gov_dlg = NULL;
2406
2407/**********************************************************************/
2419
2420/**********************************************************************/
2424{
2427
2429 }
2430
2431 return -1;
2432}
2433
2434/**********************************************************************/
2437static int move_government_dlg_callback(struct widget *pwindow)
2438{
2441 }
2442
2443 return -1;
2444}
2445
2446/**********************************************************************/
2450{
2451 struct utf8_str *pstr;
2452 struct widget *gov_button = NULL;
2453 struct widget *pwindow;
2454 int j;
2455 Uint16 max_w = 0, max_h = 0;
2456 SDL_Rect area;
2457
2458 if (gov_dlg != NULL) {
2459 return;
2460 }
2461
2462 gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
2463
2464 /* Create window */
2465 pstr = create_utf8_from_char_fonto(_("Choose Your New Government"),
2467 pstr->style |= TTF_STYLE_BOLD;
2468 /* This win. size is temp. */
2469 pwindow = create_window_skeleton(NULL, pstr, 0);
2472
2473 gov_dlg->end_widget_list = pwindow;
2474
2475 area = pwindow->area;
2476
2477 /* Create gov. buttons */
2478 j = 0;
2479 governments_iterate(gov) {
2481 continue;
2482 }
2483
2488 = create_icon_button(get_government_surface(gov), pwindow->dst, pstr, 0);
2490
2491 max_w = MAX(max_w, gov_button->size.w);
2492 max_h = MAX(max_h, gov_button->size.h);
2493
2494 /* Ugly hack */
2496 j++;
2497
2498 }
2500
2501 if (gov_button == NULL) {
2502 /* No governments to switch to.
2503 * TODO: Provide close button for the dialog. */
2505 } else {
2507
2509
2510 max_w += adj_size(10);
2511 max_h += adj_size(4);
2512
2513 area.w = MAX(area.w, max_w + adj_size(20));
2514 area.h = MAX(area.h, j * (max_h + adj_size(10)) + adj_size(5));
2515
2516 /* Create window background */
2518 if (resize_window(pwindow, logo, NULL,
2519 (pwindow->size.w - pwindow->area.w) + area.w,
2520 (pwindow->size.h - pwindow->area.h) + area.h)) {
2522 }
2523
2524 area = pwindow->area;
2525
2526 /* Set window start positions */
2527 widget_set_position(pwindow,
2528 (main_window_width() - pwindow->size.w) / 2,
2529 (main_window_height() - pwindow->size.h) / 2);
2530
2531 /* Set buttons start positions and size */
2532 j = 1;
2533 while (gov_button != gov_dlg->end_widget_list) {
2534 gov_button->size.w = max_w;
2535 gov_button->size.h = max_h;
2536 gov_button->size.x = area.x + adj_size(10);
2537 gov_button->size.y = area.y + area.h - (j++) * (max_h + adj_size(10));
2539
2540 gov_button = gov_button->next;
2541 }
2542 }
2543
2544 set_wstate(pwindow, FC_WS_NORMAL);
2545
2546 /* Redraw */
2548
2549 widget_flush(pwindow);
2550}
2551
2552/**************************************************************************
2553 Nation Wizard
2554**************************************************************************/
2556static struct small_dialog *help_dlg = NULL;
2557
2558struct nation_info {
2559 unsigned char nation_style; /* selected style */
2560 unsigned char selected_leader; /* if not unique -> selected leader */
2561 Nation_type_id nation; /* selected nation */
2562 bool leader_sex; /* selected leader sex */
2563 struct nation_set *set;
2564 struct widget *change_sex;
2565 struct widget *name_edit;
2566 struct widget *name_next;
2567 struct widget *name_prev;
2568 struct widget *pset_name;
2569 struct widget *pset_next;
2570 struct widget *pset_prev;
2571};
2572
2573static int next_set_callback(struct widget *next_button);
2574static int prev_set_callback(struct widget *prev_button);
2575static int nations_dialog_callback(struct widget *pwindow);
2576static int nation_button_callback(struct widget *pnation);
2577static int races_dialog_ok_callback(struct widget *start_button);
2578static int races_dialog_cancel_callback(struct widget *button);
2579static int next_name_callback(struct widget *next_button);
2580static int prev_name_callback(struct widget *prev_button);
2581static int change_sex_callback(struct widget *sex);
2582static void select_random_leader(Nation_type_id nation);
2583static void change_nation_label(void);
2584
2585/**********************************************************************/
2588static int nations_dialog_callback(struct widget *pwindow)
2589{
2592 widget_flush(pwindow);
2593 }
2594 }
2595
2596 return -1;
2597}
2598
2599/**********************************************************************/
2602static int races_dialog_ok_callback(struct widget *start_button)
2603{
2605 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2606 char *pstr = setup->name_edit->string_utf8->text;
2607
2608 /* perform a minimum of sanity test on the name */
2609 if (strlen(pstr) == 0) {
2610 output_window_append(ftc_client, _("You must type a legal name."));
2611 selected_widget = start_button;
2612 set_wstate(start_button, FC_WS_SELECTED);
2613 widget_redraw(start_button);
2614 widget_flush(start_button);
2615
2616 return -1;
2617 }
2618
2620 setup->nation,
2621 setup->leader_sex, pstr,
2622 setup->nation_style);
2623
2625 flush_dirty();
2626 }
2627
2628 return -1;
2629}
2630
2631/**********************************************************************/
2634static int change_sex_callback(struct widget *sex)
2635{
2637 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2638
2639 if (setup->leader_sex) {
2642 } else {
2645 }
2646 setup->leader_sex = !setup->leader_sex;
2647
2648 if (sex) {
2651
2654 }
2655 }
2656
2657 return -1;
2658}
2659
2660/**********************************************************************/
2663static int next_name_callback(struct widget *next)
2664{
2666 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2667 const struct nation_leader_list *leaders =
2669 const struct nation_leader *pleader;
2670
2671 setup->selected_leader++;
2673
2674 /* change leader sex */
2675 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2677 }
2678
2679 /* change leader name */
2682
2685
2686 if (nation_leader_list_size(leaders) - 1 == setup->selected_leader) {
2688 }
2689
2690 if (get_wstate(setup->name_prev) == FC_WS_DISABLED) {
2692 }
2693
2694 if (!(get_wstate(setup->name_next) == FC_WS_DISABLED)) {
2695 selected_widget = setup->name_next;
2697 }
2698
2699 widget_redraw(setup->name_edit);
2700 widget_redraw(setup->name_prev);
2701 widget_redraw(setup->name_next);
2705
2706 widget_redraw(setup->change_sex);
2708
2709 flush_dirty();
2710 }
2711
2712 return -1;
2713}
2714
2715/**********************************************************************/
2718static int prev_name_callback(struct widget *prev)
2719{
2721 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2722 const struct nation_leader_list *leaders =
2724 const struct nation_leader *pleader;
2725
2726 setup->selected_leader--;
2728
2729 /* change leader sex */
2730 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2732 }
2733
2734 /* change leader name */
2737
2740
2741 if (!setup->selected_leader) {
2743 }
2744
2745 if (get_wstate(setup->name_next) == FC_WS_DISABLED) {
2747 }
2748
2749 if (!(get_wstate(setup->name_prev) == FC_WS_DISABLED)) {
2750 selected_widget = setup->name_prev;
2752 }
2753
2754 widget_redraw(setup->name_edit);
2755 widget_redraw(setup->name_prev);
2756 widget_redraw(setup->name_next);
2760
2761 widget_redraw(setup->change_sex);
2763
2764 flush_dirty();
2765 }
2766
2767 return -1;
2768}
2769
2770/**********************************************************************/
2773static int next_set_callback(struct widget *next_button)
2774{
2776 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2777 struct option *poption = optset_option_by_name(server_optset, "nationset");
2778
2779 fc_assert(setup->set != NULL
2780 && nation_set_index(setup->set) < nation_set_count() - 1);
2781
2782 setup->set = nation_set_by_number(nation_set_index(setup->set) + 1);
2783
2785 }
2786
2787 return -1;
2788}
2789
2790/**********************************************************************/
2794{
2796 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2797 struct option *poption = optset_option_by_name(server_optset, "nationset");
2798
2799 fc_assert(setup->set != NULL && nation_set_index(setup->set) > 0);
2800
2801 setup->set = nation_set_by_number(nation_set_index(setup->set) - 1);
2802
2804 }
2805
2806 return -1;
2807}
2808
2809/**********************************************************************/
2812static int races_dialog_cancel_callback(struct widget *button)
2813{
2816 flush_dirty();
2817 }
2818
2819 return -1;
2820}
2821
2822/**********************************************************************/
2825static int style_callback(struct widget *pwidget)
2826{
2828 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2830 setup->nation_style);
2831
2835
2836 set_wstate(pwidget, FC_WS_DISABLED);
2837 widget_redraw(pwidget);
2838 widget_mark_dirty(pwidget);
2839
2840 setup->nation_style = MAX_ID - 1000 - pwidget->id;
2841
2842 flush_dirty();
2844 }
2845
2846 return -1;
2847}
2848
2849/**********************************************************************/
2852static int help_dlg_callback(struct widget *pwindow)
2853{
2854 return -1;
2855}
2856
2857/**********************************************************************/
2860static int cancel_help_dlg_callback(struct widget *pwidget)
2861{
2863 if (help_dlg) {
2867 if (pwidget) {
2868 flush_dirty();
2869 }
2870 }
2871 }
2872
2873 return -1;
2874}
2875
2876/**********************************************************************/
2880{
2883
2885 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2886
2887 if (setup->nation == MAX_ID - nation_button->id) {
2890
2891 return -1;
2892 }
2893
2894 setup->nation = MAX_ID - nation_button->id;
2895
2897
2898 enable(MAX_ID - 1000 - setup->nation_style);
2900 disable(MAX_ID - 1000 - setup->nation_style);
2901
2903
2906 } else {
2907 /* Pop up nation description */
2908 struct widget *pwindow, *ok_button;
2909 utf8_str *pstr;
2910 SDL_Surface *text;
2912 struct nation_type *pnation = nation_by_number(MAX_ID - nation_button->id);
2913
2916
2917 if (!help_dlg) {
2918 help_dlg = fc_calloc(1, sizeof(struct small_dialog));
2919
2922 pstr->style |= TTF_STYLE_BOLD;
2923
2924 pwindow = create_window_skeleton(NULL, pstr, 0);
2925 pwindow->action = help_dlg_callback;
2926
2927 set_wstate(pwindow, FC_WS_NORMAL);
2928
2929 help_dlg->end_widget_list = pwindow;
2930 add_to_gui_list(ID_WINDOW, pwindow);
2931
2932 ok_button
2934 pwindow->dst, _("OK"),
2935 FONTO_HEADING, 0);
2936 ok_button->action = cancel_help_dlg_callback;
2937 set_wstate(ok_button, FC_WS_NORMAL);
2938 ok_button->key = SDLK_ESCAPE;
2939 add_to_gui_list(ID_BUTTON, ok_button);
2940 help_dlg->begin_widget_list = ok_button;
2941 } else {
2942 pwindow = help_dlg->end_widget_list;
2943 ok_button = help_dlg->begin_widget_list;
2944
2945 /* Undraw window */
2946 widget_undraw(pwindow);
2947 widget_mark_dirty(pwindow);
2948 }
2949
2950 area = pwindow->area;
2951
2952 {
2953 char info[4096];
2954
2955 helptext_nation(info, sizeof(info), pnation, NULL);
2957 }
2958
2961
2963
2964 /* create window background */
2965 area.w = MAX(area.w, text->w + adj_size(20));
2966 area.w = MAX(area.w, ok_button->size.w + adj_size(20));
2967 area.h = MAX(area.h, adj_size(9) + text->h
2968 + adj_size(10) + ok_button->size.h + adj_size(10));
2969
2971 (pwindow->size.w - pwindow->area.w) + area.w,
2972 (pwindow->size.h - pwindow->area.h) + area.h);
2973
2974 widget_set_position(pwindow,
2975 (main_window_width() - pwindow->size.w) / 2,
2976 (main_window_height() - pwindow->size.h) / 2);
2977
2978 area2.x = area.x + adj_size(7);
2979 area2.y = area.y + adj_size(6);
2980 alphablit(text, NULL, pwindow->theme, &area2, 255);
2981 FREESURFACE(text);
2982
2983 ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
2984 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2985
2986 /* redraw */
2987 redraw_group(ok_button, pwindow, 0);
2988
2989 widget_mark_dirty(pwindow);
2990
2991 flush_dirty();
2992
2993 }
2994
2995 return -1;
2996}
2997
2998/**********************************************************************/
3001static int leader_name_edit_callback(struct widget *pedit)
3002{
3004 if (pedit->string_utf8->text != NULL) {
3005 /* empty input -> restore previous content */
3007 widget_redraw(pedit);
3008 widget_mark_dirty(pedit);
3009 flush_dirty();
3010 }
3011 }
3012
3013 return -1;
3014}
3015
3016/* =========================================================== */
3017
3018/**********************************************************************/
3021static void change_nation_label(void)
3022{
3024 struct widget *pwindow = nation_dlg->end_widget_list;
3025 struct nation_info *setup = (struct nation_info *)(pwindow->data.ptr);
3026 struct widget *label = setup->name_edit->next;
3027 struct nation_type *pnation = nation_by_number(setup->nation);
3028
3031
3032 FREESURFACE(label->theme);
3033 label->theme = tmp_surf_zoomed;
3034
3036
3037 remake_label_size(label);
3038
3039 label->size.x = pwindow->size.x + pwindow->size.w / 2 +
3040 (pwindow->size.w / 2 - label->size.w) / 2;
3041
3042}
3043
3044/**********************************************************************/
3049{
3050 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3051 const struct nation_leader_list *leaders =
3053 const struct nation_leader *pleader;
3054
3059
3062
3063 /* initialize leader sex */
3065
3066 if (setup->leader_sex) {
3069 } else {
3072 }
3073
3074 /* disable navigation buttons */
3077
3078 if (1 < nation_leader_list_size(leaders)) {
3079 /* if selected leader is not the first leader, enable "previous leader" button */
3080 if (setup->selected_leader > 0) {
3082 }
3083
3084 /* if selected leader is not the last leader, enable "next leader" button */
3085 if (setup->selected_leader < (nation_leader_list_size(leaders) - 1)) {
3087 }
3088 }
3089}
3090
3091/**********************************************************************/
3095{
3096 int playable_nation_count = 0;
3097
3098 nations_iterate(pnation) {
3099 if (pnation->is_playable && !pnation->player
3100 && is_nation_pickable(pnation))
3103
3104 return playable_nation_count;
3105}
3106
3107/**********************************************************************/
3110void popup_races_dialog(struct player *pplayer)
3111{
3112 SDL_Color bg_color = {255,255,255,128};
3113
3114 struct widget *pwindow, *pwidget = NULL, *buf, *last_City_Style;
3115 utf8_str *pstr;
3116 int len = 0;
3117 int w = adj_size(10), h = adj_size(10);
3120 SDL_Rect dst;
3121 float zoom;
3122 struct nation_info *setup;
3123 SDL_Rect area;
3124 int i;
3125 struct nation_type *pnat;
3126 struct widget *nationsets = NULL;
3127 int natinfo_y, natinfo_h;
3128
3129#define TARGETS_ROW 5
3130#define TARGETS_COL 1
3131
3132 if (nation_dlg) {
3133 return;
3134 }
3135
3136 races_player = pplayer;
3137
3138 nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3139
3140 /* Create window widget */
3141 pstr = create_utf8_from_char_fonto(_("What nation will you be?"),
3143 pstr->style |= TTF_STYLE_BOLD;
3144
3145 pwindow = create_window(NULL, pstr, w, h, WF_FREE_DATA);
3147 set_wstate(pwindow, FC_WS_NORMAL);
3148 setup = fc_calloc(1, sizeof(struct nation_info));
3149 pwindow->data.ptr = (void *)setup;
3150
3151 nation_dlg->end_widget_list = pwindow;
3153 /* --------------------------------------------------------- */
3154 /* Create nations list */
3155
3156 /* Create Imprv Background Icon */
3157 main_bg = create_surf(adj_size(96*2), adj_size(64));
3158
3160 map_rgba(main_bg->format, bg_color));
3161
3163 0, 0, main_bg->w - 1, main_bg->h - 1,
3165
3167 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
3168 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
3169
3170 /* Fill list */
3171
3172 nations_iterate(pnation) {
3173 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
3174 continue;
3175 }
3176
3178
3180
3183 text_name
3185
3186 dst.x = (tmp_surf->w - tmp_surf_zoomed->w) / 2;
3187 len = tmp_surf_zoomed->h +
3188 adj_size(10) + text_name->h;
3189 dst.y = (tmp_surf->h - len) / 2;
3191 dst.y += (tmp_surf_zoomed->h + adj_size(10));
3193
3194 dst.x = (tmp_surf->w - text_name->w) / 2;
3196 dst.y += text_name->h;
3198
3199 pwidget = create_icon2(tmp_surf, pwindow->dst,
3201
3202 set_wstate(pwidget, FC_WS_NORMAL);
3203
3204 pwidget->action = nation_button_callback;
3205
3206 w = MAX(w, pwidget->size.w);
3207 h = MAX(h, pwidget->size.h);
3208
3209 add_to_gui_list(MAX_ID - nation_index(pnation), pwidget);
3210
3211 if (nation_index(pnation) > (TARGETS_ROW * TARGETS_COL - 1)) {
3212 set_wflag(pwidget, WF_HIDDEN);
3213 }
3214
3216
3218
3220 nation_dlg->begin_widget_list = pwidget;
3222
3227 }
3228
3229 /* ----------------------------------------------------------------- */
3230
3231 /* Nation set selection */
3232 if (nation_set_count() > 1) {
3234 struct option *poption;
3235
3241
3242 /* Create nation set name label */
3245
3250
3251 pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3252
3253 add_to_gui_list(ID_LABEL, pwidget);
3254 setup->pset_name = pwidget;
3255
3256 /* Create next nationset button */
3257 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3258 pwindow->dst, NULL, 0);
3259 pwidget->action = next_set_callback;
3260 if (nation_set_index(setup->set) < nation_set_count() - 1) {
3261 set_wstate(pwidget, FC_WS_NORMAL);
3262 }
3264 pwidget->size.h = pwidget->next->size.h;
3265 setup->pset_next = pwidget;
3266
3267 /* Create prev nationset button */
3268 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3269 pwindow->dst, NULL, 0);
3270 pwidget->action = prev_set_callback;
3271 if (nation_set_index(setup->set) > 0) {
3272 set_wstate(pwidget, FC_WS_NORMAL);
3273 }
3275 pwidget->size.h = pwidget->next->size.h;
3276 setup->pset_prev = pwidget;
3277 }
3278
3279 /* Nation name */
3281 pnat = nation_by_number(setup->nation);
3283
3286 pstr->render = 2;
3288
3290
3291 pwidget = create_iconlabel(tmp_surf_zoomed, pwindow->dst, pstr,
3293 if (nationsets == NULL) {
3294 buf = pwidget;
3295 } else {
3296 buf = nationsets;
3297 }
3298
3299 add_to_gui_list(ID_LABEL, pwidget);
3300
3301 /* Create leader name edit */
3302 pwidget = create_edit_from_chars_fonto(NULL, pwindow->dst,
3303 NULL, FONTO_BIG,
3304 adj_size(200), 0);
3305 pwidget->size.h = adj_size(24);
3306
3307 set_wstate(pwidget, FC_WS_NORMAL);
3310 setup->name_edit = pwidget;
3311
3312 /* Create next leader name button */
3313 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3314 pwindow->dst, NULL, 0);
3315 pwidget->action = next_name_callback;
3317 pwidget->size.h = pwidget->next->size.h;
3318 setup->name_next = pwidget;
3319
3320 /* Create prev leader name button */
3321 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3322 pwindow->dst, NULL, 0);
3323 pwidget->action = prev_name_callback;
3325 pwidget->size.h = pwidget->next->size.h;
3326 setup->name_prev = pwidget;
3327
3328 /* Change sex button */
3329 pwidget = create_icon_button_from_chars_fonto(NULL, pwindow->dst,
3331 FONTO_HEADING, 0);
3332 pwidget->action = change_sex_callback;
3333 pwidget->size.w = adj_size(100);
3334 pwidget->size.h = adj_size(22);
3335 set_wstate(pwidget, FC_WS_NORMAL);
3336 setup->change_sex = pwidget;
3337
3338 /* Add to main widget list */
3340
3341 /* ---------------------------------------------------------- */
3342 zoom = DEFAULT_ZOOM * 1.0;
3343
3344 len = 0;
3347
3349
3350 if (tmp_surf->w > 48) {
3351 zoom = DEFAULT_ZOOM * (48.0 / tmp_surf->w);
3352 }
3353
3355
3356 pwidget = create_icon2(tmp_surf_zoomed, pwindow->dst,
3358 pwidget->action = style_callback;
3359 if (sn != setup->nation_style) {
3360 set_wstate(pwidget, FC_WS_NORMAL);
3361 }
3362 len += pwidget->size.w;
3363 add_to_gui_list(MAX_ID - 1000 - sn, pwidget);
3365
3366 last_City_Style = pwidget;
3367 /* ---------------------------------------------------------- */
3368
3369 /* Create Cancel button */
3370 pwidget
3372 pwindow->dst, _("Cancel"),
3373 FONTO_ATTENTION, 0);
3375 set_wstate(pwidget, FC_WS_NORMAL);
3376
3378
3379 /* Create OK button */
3380 pwidget
3382 pwindow->dst,
3383 _("OK"), FONTO_ATTENTION, 0);
3385
3386 set_wstate(pwidget, FC_WS_NORMAL);
3388 pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
3389 pwidget->next->size.w = pwidget->size.w;
3390
3391 nation_dlg->begin_widget_list = pwidget;
3392 /* ---------------------------------------------------------- */
3393
3395 if (resize_window(pwindow, main_bg, NULL, adj_size(640), adj_size(480))) {
3397 }
3398
3399 area = pwindow->area;
3400
3401 widget_set_position(pwindow,
3402 (main_window_width() - pwindow->size.w) / 2,
3403 (main_window_height() - pwindow->size.h) / 2);
3404
3405 /* Nations */
3406
3408 i = (area.h - adj_size(43) - h) / 2;
3410 area.x + adj_size(10),
3411 area.y + i - adj_size(4),
3414
3415 if (nation_dlg->scroll) {
3417
3420 area.x + w + adj_size(12),
3421 area.y + i - adj_size(4), h, FALSE);
3422
3423 area2.x = area.x + w + adj_size(11);
3424 area2.y = area.y + i - adj_size(4);
3426 area2.h = h;
3427 fill_rect_alpha(pwindow->theme, &area2, &bg_color);
3428
3429 create_frame(pwindow->theme,
3430 area2.x, area2.y - 1, area2.w, area2.h + 1,
3432 }
3433
3434 if (nationsets != NULL) {
3435 /* Nationsets header */
3436 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3437 buf->size.y = area.y + adj_size(46);
3438
3439 natinfo_y = buf->size.y;
3440 natinfo_h = area.h -= buf->size.y;
3441
3442 /* Nationset name */
3443 buf = buf->prev;
3444 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3445 buf->size.y = natinfo_y + adj_size(46);
3446
3447 natinfo_y += adj_size(46);
3448 natinfo_h -= adj_size(46);
3449
3450 /* Next Nationset Button */
3451 buf = buf->prev;
3452 buf->size.x = buf->next->size.x + buf->next->size.w;
3453 buf->size.y = buf->next->size.y;
3454
3455 /* Prev Nationset Button */
3456 buf = buf->prev;
3457 buf->size.x = buf->next->next->size.x - buf->size.w;
3458 buf->size.y = buf->next->size.y;
3459
3460 buf = buf->prev;
3461 } else {
3462 natinfo_y = area.y;
3463 natinfo_h = area.h;
3464 }
3465
3466 /* Selected Nation Name */
3467 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3468 buf->size.y = natinfo_y + adj_size(46);
3469
3470 /* Leader Name Edit */
3471 buf = buf->prev;
3472 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3473 buf->size.y = natinfo_y + (natinfo_h - buf->size.h) / 2 - adj_size(30);
3474
3475 /* Next Leader Name Button */
3476 buf = buf->prev;
3477 buf->size.x = buf->next->size.x + buf->next->size.w;
3478 buf->size.y = buf->next->size.y;
3479
3480 /* Prev Leader Name Button */
3481 buf = buf->prev;
3482 buf->size.x = buf->next->next->size.x - buf->size.w;
3483 buf->size.y = buf->next->size.y;
3484
3485 /* Change Leader Sex Button */
3486 buf = buf->prev;
3487 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3488 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3489
3490 /* First Style Button */
3491 buf = buf->prev;
3492 buf->size.x = area.x + area.w / 2 + (area.w / 2 - len) / 2 - adj_size(20);
3493 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3494
3495 /* Rest Style Buttons */
3496 while (buf != last_City_Style) {
3497 buf = buf->prev;
3498 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(3);
3499 buf->size.y = buf->next->size.y;
3500 }
3501
3502 create_line(pwindow->theme,
3503 area.x,
3504 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3505 area.w - 1,
3506 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3508
3509 /* Disconnect Button */
3510 buf = buf->prev;
3511 buf->size.x = area.x + adj_size(10);
3512 buf->size.y = natinfo_y + natinfo_h - adj_size(7) - buf->size.h;
3513
3514 /* Start Button */
3515 buf = buf->prev;
3516 buf->size.x = area.w - adj_size(10) - buf->size.w;
3517 buf->size.y = buf->next->size.y;
3518
3519 /* -------------------------------------------------------------------- */
3520
3522
3524
3525 widget_flush(pwindow);
3526}
3527
3528/**********************************************************************/
3546
3547/**********************************************************************/
3550void races_update_pickable(bool nationset_change)
3551{
3552 /* If this is because of nationset change, update will take
3553 * place later when the new option value is received */
3554 if (nation_dlg != NULL && !nationset_change) {
3557 }
3558}
3559
3560/**********************************************************************/
3564{
3565 if (nation_dlg != NULL) {
3568 }
3569}
3570
3571/**********************************************************************/
3576{
3577 struct nation_info *setup;
3578 bool change = FALSE;
3579 struct widget *nat;
3580
3581 if (!nation_dlg) {
3582 return;
3583 }
3584
3585 setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3586
3588 if (!is_nation_pickable(nation) || nation->player) {
3589 log_debug(" [%d]: %d = %s", nation_index(nation),
3590 (!is_nation_pickable(nation) || nation->player),
3592
3595
3596 if (nation_index(nation) == setup->nation) {
3597 change = TRUE;
3598 }
3599 }
3601
3602 if (change) {
3603 do {
3606 } while (get_wstate(nat) == FC_WS_DISABLED);
3607
3608 if (get_wstate(setup->name_edit) == FC_WS_PRESSED) {
3611 }
3613 enable(MAX_ID - 1000 - setup->nation_style);
3615 disable(MAX_ID - 1000 - setup->nation_style);
3617 }
3620}
3621
3622/**********************************************************************/
3627{
3628}
3629
3630/**********************************************************************/
3637
3638/**********************************************************************/
3645
3646/**********************************************************************/
3651{
3652 /* Don't load */
3653 return FALSE;
3654}
3655
3656/**********************************************************************/
3660{
3661 /* PORTME */
3662}
3663
3664/**********************************************************************/
3667void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
3668{
3669 /* PORTME */
3670}
3671
3672/**********************************************************************/
3677{
3678 /* Just tell the client common code to handle this. */
3679 return FALSE;
3680}
3681
3682/**********************************************************************/
3686{
3687 /* PORTME */
3688}
3689
3690/**********************************************************************/
3693bool request_transport(struct unit *pcargo, struct tile *ptile)
3694{
3695 return FALSE; /* Unit was not handled here. */
3696}
3697
3698/**********************************************************************/
3702void popup_combat_info(int attacker_unit_id, int defender_unit_id,
3703 int attacker_hp, int defender_hp,
3704 bool make_att_veteran, bool make_def_veteran)
3705{
3706}
3707
3708/**********************************************************************/
3712 struct act_confirmation_data *data)
3713{
3714 /* TODO: Implement. Currently just pass everything as confirmed */
3716}
3717
3719
3720/**********************************************************************/
3723static int image_popup_window_callback(struct widget *pwindow)
3724{
3727 }
3728
3729 return -1;
3730}
3731
3732/**********************************************************************/
3749
3750/**********************************************************************/
3753void popup_image(const char *tag)
3754{
3755 if (advanced_image_popup == NULL) {
3756 struct sprite *spr = load_popup_sprite(tag);
3757
3758 if (spr != NULL) {
3759 struct widget *win = create_window_skeleton(NULL, NULL, 0);
3760 struct widget *buf;
3762 SDL_Rect dst;
3763 SDL_Rect area;
3764 int width, height;
3765
3767 advanced_image_popup = fc_calloc(1, sizeof(struct advanced_dialog));
3768
3771
3774
3775 /* Create exit button */
3776 buf = create_themeicon(current_theme->small_cancel_icon, win->dst,
3778 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3782 buf->key = SDLK_ESCAPE;
3783
3786
3788 win->size.w - win->area.w + width,
3789 win->size.h - win->area.h + buf->area.h + height);
3790
3792 (main_window_width() - win->size.w) / 2,
3793 (main_window_height() - win->size.h) / 2);
3794
3795 area = win->area;
3796 dst.x = area.x;
3797 dst.y = area.y + buf->size.y;
3798 alphablit(surf, NULL, win->theme, &dst, 255);
3799
3800 /* Redraw */
3802 widget_flush(win);
3803
3805 } else {
3806 log_error(_("No image for tag \"%s\", requested by the server."), tag);
3807 }
3808 }
3809}
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:55
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:506
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3185
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:290
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3225
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1929
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_PATROL
Definition control.h:31
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction 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:213
int Tech_type_id
Definition fc_types.h:236
int Nation_type_id
Definition fc_types.h:239
int Unit_type_id
Definition fc_types.h:241
#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:166
Government_type_id government_number(const struct government *pgovern)
Definition government.c:91
#define governments_iterate(NAME_pgov)
Definition government.h:124
#define governments_iterate_end
Definition government.h:127
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void city_report_dialog_popdown(void)
Definition cityrep.c:312
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:313
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:386
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
void 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:214
void enable_city_dlg_widgets(void)
Definition citydlg.c:1535
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
void free_city_units_lists(void)
Definition citydlg.c:819
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:109
static int adv_unit_sentry_idle_callback(struct widget *pwidget)
Definition dialogs.c:1573
static struct small_dialog * terrain_info_dlg
Definition dialogs.c:1262
void popup_government_dialog(void)
Definition dialogs.c:2452
static struct notify_goto_data * notify_goto_data_new(const char *headline, const char *lines, struct tile *ptile)
Definition dialogs.c:238
static int adv_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1536
static struct small_dialog * unit_disband_dlg
Definition dialogs.c:827
static void popdown_unit_upgrade_dlg(void)
Definition dialogs.c:815
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:878
static void popdown_unit_disband_dlg(void)
Definition dialogs.c:1015
static void notify_goto_data_destroy(struct notify_goto_data *pdata)
Definition dialogs.c:254
static int cma_callback(struct widget *pwidget)
Definition dialogs.c:1521
static struct small_dialog * connect_dlg
Definition dialogs.c:2387
bool is_unit_move_blocked
Definition gui_main.c:108
static int hurry_production_callback(struct widget *pwidget)
Definition dialogs.c:1505
static void select_random_leader(Nation_type_id nation)
Definition dialogs.c:3051
static int next_set_callback(struct widget *next_button)
Definition dialogs.c:2776
static int exit_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1044
void popdown_advanced_terrain_dialog(void)
Definition dialogs.c:1417
void popup_musicset_suggestion_dialog(void)
Definition dialogs.c:3644
#define ADV_NUM_SEEN
static void popdown_pillage_dialog(void)
Definition dialogs.c:2271
static struct advanced_dialog * unit_select_dlg
Definition dialogs.c:1027
static int notify_goto_dialog_callback(struct widget *widget)
Definition dialogs.c:263
int exit_advanced_terrain_dlg_callback(struct widget *pwidget)
Definition dialogs.c:1444
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:650
static int prev_set_callback(struct widget *prev_button)
Definition dialogs.c:2796
static int prev_name_callback(struct widget *prev_button)
Definition dialogs.c:2721
static int exit_image_popup_callback(struct widget *pwidget)
Definition dialogs.c:3737
static int terrain_info_callback(struct widget *pwidget)
Definition dialogs.c:1457
void popup_soundset_suggestion_dialog(void)
Definition dialogs.c:3636
static int style_callback(struct widget *pwidget)
Definition dialogs.c:2828
static int unit_help_callback(struct widget *pwidget)
Definition dialogs.c:1681
static int move_government_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2440
static void popdown_government_dialog(void)
Definition dialogs.c:2413
static struct advanced_dialog * nation_dlg
Definition dialogs.c:2558
static int change_sex_callback(struct widget *sex)
Definition dialogs.c:2637
static int cancel_help_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2863
static int next_name_callback(struct widget *next_button)
Definition dialogs.c:2666
void popup_tileset_suggestion_dialog(void)
Definition dialogs.c:3628
#define TARGETS_ROW
static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
Definition dialogs.c:1326
static int get_playable_nation_count(void)
Definition dialogs.c:3097
static struct small_dialog * help_dlg
Definition dialogs.c:2559
struct advanced_dialog * advanced_terrain_dlg
Definition dialogs.c:1411
static void popdown_terrain_info_dialog(void)
Definition dialogs.c:1280
static int adv_unit_select_all_callback(struct widget *pwidget)
Definition dialogs.c:1555
static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog)
Definition dialogs.c:422
static int unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1057
static int exit_notify_dialog_callback(struct widget *pwidget)
Definition dialogs.c:493
void popdown_notify_goto_dialog(void)
Definition dialogs.c:459
int advanced_terrain_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1432
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition dialogs.c:635
static int nation_button_callback(struct widget *pnation)
Definition dialogs.c:2882
static int races_dialog_cancel_callback(struct widget *button)
Definition dialogs.c:2815
static int notify_goto_dialog_close_callback(struct widget *widget)
Definition dialogs.c:278
static int image_popup_window_callback(struct widget *pwindow)
Definition dialogs.c:3725
static int leader_name_edit_callback(struct widget *pedit)
Definition dialogs.c:3004
static int patrol_here_callback(struct widget *pwidget)
Definition dialogs.c:1619
static int pillage_window_callback(struct widget *pwindow)
Definition dialogs.c:2225
static int help_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2855
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.c:3652
static int disband_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:832
static int nations_dialog_callback(struct widget *pwindow)
Definition dialogs.c:2591
static void notify_goto_dialog_update(struct notify_goto_dialog *pdialog)
Definition dialogs.c:376
void popdown_diplomat_dialog(void)
void real_multipliers_dialog_update(void *unused)
Definition dialogs.c:3687
static int goto_here_callback(struct widget *pwidget)
Definition dialogs.c:1600
static struct small_dialog * gov_dlg
Definition dialogs.c:2408
static int notify_goto_dialog_goto_callback(struct widget *widget)
Definition dialogs.c:293
bool request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.c:3695
static void change_nation_label(void)
Definition dialogs.c:3024
#define NUM_SEEN
static struct small_dialog * pillage_dlg
Definition dialogs.c:2220
void nationset_changed(void)
Definition dialogs.c:3565
void popdown_incite_dialog(void)
static int races_dialog_ok_callback(struct widget *start_button)
Definition dialogs.c:2605
void popdown_bribe_dialog(void)
static void notify_goto_dialog_destroy(struct notify_goto_dialog *pdialog)
Definition dialogs.c:357
static int cancel_disband_unit_callback(struct widget *pwidget)
Definition dialogs.c:844
#define TARGETS_COL
static int change_production_callback(struct widget *pwidget)
Definition dialogs.c:1490
static int exit_pillage_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2258
static int terrain_info_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1268
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
static int zoom_to_city_callback(struct widget *pwidget)
Definition dialogs.c:1474
static bool sdl_get_chance_to_win(int *att_chance, int *def_chance, struct unit *enemy_unit, struct unit *my_unit)
Definition dialogs.c:192
struct advanced_dialog * advanced_image_popup
Definition dialogs.c:3720
static int government_dlg_callback(struct widget *gov_button)
Definition dialogs.c:2426
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1306
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:623
static int notify_dialog_window_callback(struct widget *pwindow)
Definition dialogs.c:481
static int unit_select_window_callback(struct widget *pwindow)
Definition dialogs.c:1032
static struct small_dialog * unit_upgrade_dlg
Definition dialogs.c:618
static int exit_terrain_info_dialog_callback(struct widget *button)
Definition dialogs.c:1293
static int paradrop_here_callback(struct widget *pwidget)
Definition dialogs.c:1648
static int ok_disband_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:859
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1697
static struct notify_goto_dialog * notify_goto_dialog_new(void)
Definition dialogs.c:318
static void popdown_connect_dialog(void)
Definition dialogs.c:2393
static char * leader_name
Definition dialogs.c:97
struct advanced_dialog * notify_dlg
Definition dialogs.c:476
void popdown_find_dialog(void)
Definition finddlg.c:110
void popdown_goto_airlift_dialog(void)
Definition gotodlg.c:424
int main_window_width(void)
Definition graphics.c:685
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:148
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1381
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1309
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1350
int main_window_height(void)
Definition graphics.c:693
#define DEFAULT_ZOOM
Definition graphics.h:198
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:201
@ ID_NATION_WIZARD_WINDOW
Definition gui_id.h:60
@ ID_UNIT_SELECT_DLG_WINDOW
Definition gui_id.h:194
@ ID_NATION_WIZARD_START_BUTTON
Definition gui_id.h:61
@ ID_NATION_WIZARD_NEXT_LEADER_NAME_BUTTON
Definition gui_id.h:66
@ ID_UNIT_SELECT_DLG_EXIT_BUTTON
Definition gui_id.h:197
@ ID_NATION_WIZARD_CHANGE_SEX_BUTTON
Definition gui_id.h:68
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
@ ID_BUTTON
Definition gui_id.h:29
@ ID_TERRAIN_INFO_DLG_WINDOW
Definition gui_id.h:199
@ ID_TERRAIN_INFO_DLG_EXIT_BUTTON
Definition gui_id.h:200
@ ID_NATION_PREV_NATIONSET_BUTTON
Definition gui_id.h:70
@ ID_NATION_NEXT_NATIONSET_BUTTON
Definition gui_id.h:69
@ ID_NATION_WIZARD_DISCONNECT_BUTTON
Definition gui_id.h:64
@ ID_SEPARATOR
Definition gui_id.h:28
@ ID_LABEL
Definition gui_id.h:27
@ ID_WINDOW
Definition gui_id.h:30
@ ID_PILLAGE_DLG_EXIT_BUTTON
Definition gui_id.h:204
@ ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON
Definition gui_id.h:67
@ ID_PILLAGE_DLG_WINDOW
Definition gui_id.h:203
@ ID_NATION_WIZARD_LEADER_NAME_EDIT
Definition gui_id.h:65
@ ID_GOVERNMENT_DLG_WINDOW
Definition gui_id.h:144
void force_exit_from_event_loop(void)
Definition gui_main.c:566
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_BIG
Definition gui_string.h:70
@ FONTO_ATTENTION
Definition gui_string.h:67
@ FONTO_MAX
Definition gui_string.h:71
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
static SDL_Surface * get_government_surface(const struct government *gov)
static SDL_Surface * get_nation_flag_surface(const struct nation_type *pnation)
static SDL_Surface * get_sample_city_surface(int city_style)
void popup_unit_info(Unit_type_id type_id)
Definition helpdlg.c: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
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:602
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_PRESSED
Definition widget.h:98
@ FC_WS_SELECTED
Definition widget.h:97
#define disable(id)
Definition widget.h:229
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_FREE_GFX
Definition widget.h:70
@ WF_ICON_CENTER
Definition widget.h:83
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_ICON_ABOVE_TEXT
Definition widget.h:81
@ WF_FREE_DATA
Definition widget.h:78
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define enable(id)
Definition widget.h:223
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
struct widget * create_icon_button(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_icon_button_from_chars_fonto(icon, pdest, char_string, fonto, flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
void remake_label_size(struct widget *label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
#define create_active_iconlabel(buf, pdest, pstr, pstring, cb)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c: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:5034
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:752
static int index_to_map_pos_x(int mindex)
Definition map.h:743
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:1016
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:4278
bool option_str_set(struct option *poption, const char *str)
Definition options.c:962
const char * option_str_get(const struct option *poption)
Definition options.c:929
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:467
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:2385
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:2563
struct widget * pset_prev
Definition dialogs.c:2573
struct widget * name_next
Definition dialogs.c:2569
struct widget * name_edit
Definition dialogs.c:2568
bool leader_sex
Definition dialogs.c:2565
struct nation_set * set
Definition dialogs.c:2566
struct widget * change_sex
Definition dialogs.c:2567
unsigned char nation_style
Definition dialogs.c:2562
struct widget * pset_next
Definition dialogs.c:2572
Nation_type_id nation
Definition dialogs.c:2564
struct widget * name_prev
Definition dialogs.c:2570
struct widget * pset_name
Definition dialogs.c:2571
char * headline
Definition dialogs.c:215
struct tile * ptile
Definition dialogs.c:217
struct widget * close_button
Definition dialogs.c:226
struct widget * label
Definition dialogs.c:227
struct widget * window
Definition dialogs.c:225
struct notify_goto_list * datas
Definition dialogs.c:228
struct widget * up_left_button
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h: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
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
union widget::@223 data
struct widget * prev
Definition widget.h:114
struct unit * unit
Definition widget.h:129
struct gui_layer * dst
Definition widget.h:116
struct city * city
Definition widget.h:128
struct container * cont
Definition widget.h:127
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
struct widget * next
Definition widget.h:113
utf8_str * info_label
Definition widget.h:122
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
struct civ_map map
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c: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:550
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1370
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:111
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7807
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:791
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7815
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:2088
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:846
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1184
#define unit_tile(_pu)
Definition unit.h:404
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:466
@ ORDER_LAST
Definition unit.h:50
#define unit_owner(_pu)
Definition unit.h:403
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:2616
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:196
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:1566
float map_zoom
Definition zoom.c:25