Freeciv-3.4
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 struct player *owner = unit_owner(punit);
1161
1162 if (owner != nullptr) {
1163 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1165 (vetname != NULL ? vetname : ""),
1167 punittype->attack_strength,
1168 punittype->defense_strength,
1169 move_points_text(punittype->move_rate, FALSE),
1170 punittype->firepower,
1171 (punit->hp * 100 / punittype->hp + 9) / 10);
1172 } else {
1173 fc_snprintf(cbuf , sizeof(cbuf), _("%s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
1174 (vetname != NULL ? vetname : ""),
1176 punittype->attack_strength,
1177 punittype->defense_strength,
1178 move_points_text(punittype->move_rate, FALSE),
1179 punittype->firepower,
1180 (punit->hp * 100 / punittype->hp + 9) / 10);
1181 }
1182
1183 /* Calculate chance to win */
1185 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1186 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1188 }
1189 }
1190
1191 create_active_iconlabel(buf, pwindow->dst, pstr, cbuf,
1193
1195
1196 area.w = MAX(area.w, buf->size.w);
1197 area.h += buf->size.h;
1200 }
1201
1202 if (i > NUM_SEEN - 1) {
1204 }
1205 }
1206
1211
1212 area.w += adj_size(2);
1213 if (n > NUM_SEEN) {
1215 area.w += n;
1216
1217 /* ------- window ------- */
1218 area.h = NUM_SEEN * pwindow->prev->prev->size.h;
1219 }
1220
1221 resize_window(pwindow, NULL, NULL,
1222 (pwindow->size.w - pwindow->area.w) + area.w,
1223 (pwindow->size.h - pwindow->area.h) + area.h);
1224
1225 area = pwindow->area;
1226
1227 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
1228 ptile);
1229
1230 w = area.w;
1231
1232 if (unit_select_dlg->scroll) {
1233 w -= n;
1234 }
1235
1236 /* Exit button */
1237 buf = pwindow->prev;
1238 buf->size.x = area.x + area.w - buf->size.w - 1;
1239 buf->size.y = pwindow->size.y + adj_size(2);
1240 buf = buf->prev;
1241
1242 setup_vertical_widgets_position(1, area.x + 1, area.y, w, 0,
1244 buf);
1245
1246 if (unit_select_dlg->scroll) {
1248 area.x + area.w, area.y,
1249 area.h, TRUE);
1250 }
1251
1252 /* ==================================================== */
1253 /* Redraw */
1255
1256 widget_flush(pwindow);
1257}
1258
1259/**********************************************************************/
1263{
1264 /* PORTME */
1265}
1266
1267/* ====================================================================== */
1268/* ============================ TERRAIN INFO ============================ */
1269/* ====================================================================== */
1271
1272
1273/**********************************************************************/
1276static int terrain_info_window_dlg_callback(struct widget *pwindow)
1277{
1280 }
1281
1282 return -1;
1283}
1284
1285/**********************************************************************/
1297
1298/**********************************************************************/
1302{
1305 }
1306
1307 return -1;
1308}
1309
1310/**********************************************************************/
1314const char *sdl_get_tile_defense_info_text(struct tile *ptile)
1315{
1316 static char buffer[64];
1317 int bonus = (tile_terrain(ptile)->defense_bonus - 10) * 10;
1318
1319 extra_type_iterate(pextra) {
1320 if (tile_has_extra(ptile, pextra)
1321 && pextra->category == ECAT_NATURAL) {
1322 bonus += pextra->defense_bonus;
1323 }
1325
1326 fc_snprintf(buffer, sizeof(buffer), _("Terrain Defense Bonus: +%d%% "), bonus);
1327
1328 return buffer;
1329}
1330
1331/**********************************************************************/
1335{
1336 SDL_Surface *surf;
1337 struct widget *buf, *pwindow;
1338 utf8_str *pstr;
1339 char cbuf[256];
1340 SDL_Rect area;
1341
1342 if (terrain_info_dlg) {
1343 flush_dirty();
1344 return;
1345 }
1346
1347 surf = get_terrain_surface(ptile);
1348 terrain_info_dlg = fc_calloc(1, sizeof(struct small_dialog));
1349
1350 /* ----------- */
1351 fc_snprintf(cbuf, sizeof(cbuf), "%s [%d,%d]", _("Terrain Info"),
1352 TILE_XY(ptile));
1353
1354 pwindow
1357 0);
1358 pwindow->string_utf8->style |= TTF_STYLE_BOLD;
1359
1361 set_wstate(pwindow, FC_WS_NORMAL);
1362
1365
1366 area = pwindow->area;
1367
1368 /* ---------- */
1371 pstr->style |= SF_CENTER;
1372 buf = create_iconlabel(surf, pwindow->dst, pstr, 0);
1373
1374 buf->size.h += tileset_tile_height(tileset) / 2;
1375
1377
1378 /* ------ window ---------- */
1379 area.w = MAX(area.w, buf->size.w + adj_size(20));
1380 area.h = MAX(area.h, buf->size.h);
1381
1383 (pwindow->size.w - pwindow->area.w) + area.w,
1384 (pwindow->size.h - pwindow->area.h) + area.h);
1385
1386 area = pwindow->area;
1387
1388 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, ptile);
1389
1390 /* ------------------------ */
1391
1392 buf->size.x = area.x + adj_size(10);
1393 buf->size.y = area.y;
1394
1395 /* Exit icon */
1396 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1398 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1400 buf->size.x = area.x + area.w - buf->size.w - 1;
1401 buf->size.y = pwindow->size.y + adj_size(2);
1404 buf->key = SDLK_ESCAPE;
1405
1407
1409 /* --------------------------------- */
1410 /* redraw */
1412 widget_mark_dirty(pwindow);
1413 flush_dirty();
1414}
1415
1416/* ====================================================================== */
1417/* ========================= ADVANCED_TERRAIN_MENU ====================== */
1418/* ====================================================================== */
1420
1421/**********************************************************************/
1436
1437/**********************************************************************/
1441{
1444 }
1445
1446 return -1;
1447}
1448
1449/**********************************************************************/
1453{
1456 flush_dirty();
1457 }
1458
1459 return -1;
1460}
1461
1462/**********************************************************************/
1465static int terrain_info_callback(struct widget *pwidget)
1466{
1468 int x = pwidget->data.cont->id0;
1469 int y = pwidget->data.cont->id1;
1470
1472
1474 }
1475
1476 return -1;
1477}
1478
1479/**********************************************************************/
1482static int zoom_to_city_callback(struct widget *pwidget)
1483{
1485 struct city *pcity = pwidget->data.city;
1486
1488
1490 }
1491
1492 return -1;
1493}
1494
1495/**********************************************************************/
1498static int change_production_callback(struct widget *pwidget)
1499{
1501 struct city *pcity = pwidget->data.city;
1502
1505 }
1506
1507 return -1;
1508}
1509
1510/**********************************************************************/
1513static int hurry_production_callback(struct widget *pwidget)
1514{
1516 struct city *pcity = pwidget->data.city;
1517
1519
1521 }
1522
1523 return -1;
1524}
1525
1526/**********************************************************************/
1529static int cma_callback(struct widget *pwidget)
1530{
1532 struct city *pcity = pwidget->data.city;
1533
1536 }
1537
1538 return -1;
1539}
1540
1541/**********************************************************************/
1544static int adv_unit_select_callback(struct widget *pwidget)
1545{
1547 struct unit *punit = pwidget->data.unit;
1548
1550
1551 if (punit) {
1554 }
1555 }
1556
1557 return -1;
1558}
1559
1560/**********************************************************************/
1563static int adv_unit_select_all_callback(struct widget *pwidget)
1564{
1566 struct unit *punit = pwidget->data.unit;
1567
1569
1570 if (punit) {
1572 }
1573 }
1574
1575 return -1;
1576}
1577
1578/**********************************************************************/
1581static int adv_unit_sentry_idle_callback(struct widget *pwidget)
1582{
1584 struct unit *punit = pwidget->data.unit;
1585
1587
1588 if (punit) {
1589 struct tile *ptile = unit_tile(punit);
1590
1593 && ACTIVITY_IDLE == other_unit->activity
1594 && other_unit->ssa_controller == SSA_NONE
1597 }
1599 }
1600 }
1601
1602 return -1;
1603}
1604
1605/**********************************************************************/
1608static int goto_here_callback(struct widget *pwidget)
1609{
1611 int x = pwidget->data.cont->id0;
1612 int y = pwidget->data.cont->id1;
1613
1615
1616 /* may not work */
1618 map_pos_to_tile(&(wld.map), x, y));
1619 }
1620
1621 return -1;
1622}
1623
1624/**********************************************************************/
1627static int patrol_here_callback(struct widget *pwidget)
1628{
1630 int x = pwidget->data.cont->id0;
1631 int y = pwidget->data.cont->id1;
1632 struct tile *ptile;
1633
1634 ptile = map_pos_to_tile(&(wld.map), x, y);
1635
1636 if (ptile != NULL) {
1637 struct unit_list *punits = get_units_in_focus();
1638
1643 do_unit_patrol_to(ptile);
1645 }
1646
1648 }
1649
1650 return -1;
1651}
1652
1653/**********************************************************************/
1656static int paradrop_here_callback(struct widget *pwidget)
1657{
1659 int x = pwidget->data.cont->id0;
1660 int y = pwidget->data.cont->id1;
1661 struct tile *ptile;
1662
1663 ptile = map_pos_to_tile(&(wld.map), x, y);
1664
1665 if (ptile != NULL) {
1666 struct unit_list *punits = get_units_in_focus();
1667
1671
1673 do_unit_paradrop_to(punit, ptile);
1675
1678 }
1679
1681 }
1682
1683 return -1;
1684}
1685
1686/**********************************************************************/
1689static int unit_help_callback(struct widget *pwidget)
1690{
1692 Unit_type_id unit_id = MAX_ID - pwidget->id;
1693
1695 popup_unit_info(unit_id);
1696 }
1697
1698 return -1;
1699}
1700
1701/**********************************************************************/
1706 Uint16 pos_x, Uint16 pos_y)
1707{
1708 struct widget *pwindow = NULL, *buf = NULL;
1709 struct city *pcity;
1710 struct unit *focus_unit;
1711 utf8_str *pstr;
1713 struct container *cont;
1714 char cbuf[255];
1715 int n, w = 0, h, units_h = 0;
1716 SDL_Rect area;
1717
1719 return;
1720 }
1721
1722 pcity = tile_city(ptile);
1723 n = unit_list_size(ptile->units);
1725
1726 if (!n && !pcity && !focus_unit) {
1728
1729 return;
1730 }
1731
1732 area.h = adj_size(2);
1734
1735 advanced_terrain_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1736
1737 cont = fc_calloc(1, sizeof(struct container));
1738 cont->id0 = index_to_map_pos_x(tile_index(ptile));
1739 cont->id1 = index_to_map_pos_y(tile_index(ptile));
1740
1742 pstr->style |= TTF_STYLE_BOLD;
1743
1744 pwindow = create_window_skeleton(NULL, pstr, 0);
1745
1747 set_wstate(pwindow , FC_WS_NORMAL);
1748
1751
1752 area = pwindow->area;
1753
1754 /* ---------- */
1755 /* Exit button */
1756 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
1758 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
1760 area.w += buf->size.w + adj_size(10);
1763 buf->key = SDLK_ESCAPE;
1764
1766 /* ---------- */
1767
1768 pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT);
1769 pstr->style |= TTF_STYLE_BOLD;
1770
1771 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1773
1774 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
1775
1776 buf->data.cont = cont;
1777
1778 buf->action = terrain_info_callback;
1780
1782
1783 area.w = MAX(area.w, buf->size.w);
1784 area.h += buf->size.h;
1785
1786 /* ---------- */
1787 if (pcity && city_owner(pcity) == client.conn.playing) {
1788 /* Separator */
1790
1792 area.h += buf->next->size.h;
1793 /* ------------------ */
1794
1795 fc_snprintf(cbuf, sizeof(cbuf), _("Zoom to : %s"), city_name_get(pcity));
1796
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 _("Change Production"), change_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 _("Hurry production"), hurry_production_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
1833 _("Change City Governor settings"), cma_callback);
1834
1835 buf->data.city = pcity;
1837
1839
1840 area.w = MAX(area.w, buf->size.w);
1841 area.h += buf->size.h;
1842 }
1843 /* ---------- */
1844
1845 if (focus_unit
1846 && (tile_index(unit_tile(focus_unit)) != tile_index(ptile))) {
1847 /* Separator */
1849
1851 area.h += buf->next->size.h;
1852 /* ------------------ */
1853
1854 create_active_iconlabel(buf, pwindow->dst, pstr, _("Goto here"),
1856 buf->data.cont = cont;
1858
1859 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1860
1861 area.w = MAX(area.w, buf->size.w);
1862 area.h += buf->size.h;
1863 /* ----------- */
1864
1865 create_active_iconlabel(buf, pwindow->dst, pstr, _("Patrol here"),
1867 buf->data.cont = cont;
1869
1870 add_to_gui_list(MAX_ID - 1000 - focus_unit->id, buf);
1871
1872 area.w = MAX(area.w, buf->size.w);
1873 area.h += buf->size.h;
1874 /* ----------- */
1875
1876#if 0 /* FIXME: Specific connect buttons */
1878 create_active_iconlabel(buf, pwindow->dst->surface, pstr, _("Connect here"),
1880 buf->data.cont = cont;
1882
1884
1885 area.w = MAX(area.w, buf->size.w);
1886 area.h += buf->size.h;
1887 }
1888#endif /* 0 */
1889
1890 /* FIXME: This logic seems to try to mirror do_paradrop() why? */
1894 && (unit_type_get(focus_unit)->paratroopers_range >=
1896
1897 create_active_iconlabel(buf, pwindow->dst, pstr, _("Paradrop here"),
1899 buf->data.cont = cont;
1901
1903
1904 area.w = MAX(area.w, buf->size.w);
1905 area.h += buf->size.h;
1906 }
1907
1908 }
1910
1911 /* ---------- */
1912 if (n) {
1913 int i;
1914 struct unit *punit;
1915 const struct unit_type *punittype = NULL;
1916
1917 units_h = 0;
1918
1919 /* Separator */
1921
1923 area.h += buf->next->size.h;
1924 /* ---------- */
1925 if (n > 1) {
1926 struct unit *defender, *attacker;
1927 struct widget *last = buf;
1928 bool reset = FALSE;
1929 int my_units = 0;
1930 const char *vetname;
1931
1932 #define ADV_NUM_SEEN 15
1933
1934 defender = (focus_unit ? get_defender(&(wld.map), focus_unit, ptile, NULL)
1935 : NULL);
1936 attacker = (focus_unit ? get_attacker(&(wld.map), focus_unit, ptile)
1937 : NULL);
1938 for (i = 0; i < n; i++) {
1939 punit = unit_list_get(ptile->units, i);
1940 if (punit == focus_unit) {
1941 continue;
1942 }
1945
1947 struct astring addition = ASTRING_INIT;
1948
1950 fc_snprintf(cbuf, sizeof(cbuf),
1951 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
1952 (vetname != NULL ? vetname : ""),
1953 punit->hp, punittype->hp,
1955 punittype->attack_strength,
1956 punittype->defense_strength,
1957 move_points_text(punittype->move_rate, FALSE),
1958 astr_str(&addition));
1960
1963 buf->data.unit = punit;
1966 my_units++;
1967 } else {
1969
1970 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
1972 (vetname != NULL ? vetname : ""),
1974 punittype->attack_strength,
1975 punittype->defense_strength,
1976 move_points_text(punittype->move_rate, FALSE),
1977 punittype->firepower,
1978 ((punit->hp * 100) / punittype->hp));
1979
1980 /* Calculate chance to win */
1982 focus_unit)) {
1983 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
1984 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
1986 }
1987
1988 if (attacker && attacker == punit) {
1990 reset = TRUE;
1991 } else {
1992 if (defender && defender == punit) {
1994 reset = TRUE;
1995 }
1996 }
1997
1999
2000 if (reset) {
2002 reset = FALSE;
2003 }
2004
2006 }
2007
2008 area.w = MAX(area.w, buf->size.w);
2009 units_h += buf->size.h;
2010
2011 if (i > ADV_NUM_SEEN - 1) {
2013 }
2014 }
2015
2020
2021 if (n > ADV_NUM_SEEN) {
2024 1, ADV_NUM_SEEN, TRUE, TRUE);
2025 area.w += n;
2026 }
2027
2028 if (my_units > 1) {
2029 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Ready all"), my_units);
2034 buf->id = ID_LABEL;
2035 widget_add_as_prev(buf, last);
2036 area.h += buf->size.h;
2037
2038 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d)", _("Sentry idle"), my_units);
2043 buf->id = ID_LABEL;
2044 widget_add_as_prev(buf, last->prev);
2045 area.h += buf->size.h;
2046
2047 /* Separator */
2049 buf->id = ID_SEPARATOR;
2051 area.h += buf->next->size.h;
2052 }
2053#undef ADV_NUM_SEEN
2054 } else { /* n == 1 */
2055 /* One unit - give orders */
2056 punit = unit_list_get(ptile->units, 0);
2058 if (punit != focus_unit) {
2059 const char *vetname;
2060
2063 || (unit_owner(punit) == client.conn.playing)) {
2064 struct astring addition = ASTRING_INIT;
2065
2067 fc_snprintf(cbuf, sizeof(cbuf),
2068 _("Activate %s (%d / %d) %s (%d,%d,%s) %s"),
2069 (vetname != NULL ? vetname : ""),
2070 punit->hp, punittype->hp,
2072 punittype->attack_strength,
2073 punittype->defense_strength,
2074 move_points_text(punittype->move_rate, FALSE),
2075 astr_str(&addition));
2077
2080 buf->data.unit = punit;
2082
2084
2085 area.w = MAX(area.w, buf->size.w);
2086 units_h += buf->size.h;
2087 /* ---------------- */
2088 /* Separator */
2090
2092 area.h += buf->next->size.h;
2093 } else {
2095
2096 fc_snprintf(cbuf, sizeof(cbuf), _("%s %s %s (A:%d D:%d M:%s FP:%d) HP:%d%%"),
2098 (vetname != NULL ? vetname : ""),
2100 punittype->attack_strength,
2101 punittype->defense_strength,
2102 move_points_text(punittype->move_rate, FALSE),
2103 punittype->firepower,
2104 ((punit->hp * 100) / punittype->hp));
2105
2106 /* Calculate chance to win */
2108 focus_unit)) {
2109 /* TRANS: "CtW" = "Chance to Win"; preserve leading space */
2110 cat_snprintf(cbuf, sizeof(cbuf), _(" CtW: Att:%d%% Def:%d%%"),
2112 }
2115 area.w = MAX(area.w, buf->size.w);
2116 units_h += buf->size.h;
2117 /* ---------------- */
2118
2119 /* Separator */
2121
2123 area.h += buf->next->size.h;
2124 }
2125 }
2126
2127 /* ---------------- */
2128 fc_snprintf(cbuf, sizeof(cbuf),
2129 _("Look up \"%s\" in the Help Browser"),
2135
2136 area.w = MAX(area.w, buf->size.w);
2137 units_h += buf->size.h;
2138 /* ---------------- */
2140 }
2141
2142 }
2143 /* ---------- */
2144
2145 area.w += adj_size(2);
2146 area.h += units_h;
2147
2148 resize_window(pwindow, NULL, NULL,
2149 (pwindow->size.w - pwindow->area.w) + area.w,
2150 (pwindow->size.h - pwindow->area.h) + area.h);
2151
2152 area = pwindow->area;
2153
2154 widget_set_position(pwindow, pos_x, pos_y);
2155
2156 w = area.w - adj_size(2);
2157
2159 units_h = n;
2160 } else {
2161 units_h = 0;
2162 }
2163
2164 /* Exit button */
2165 buf = pwindow->prev;
2166
2167 buf->size.x = area.x + area.w - buf->size.w - 1;
2168 buf->size.y = pwindow->size.y + adj_size(2);
2169
2170 /* Terrain info */
2171 buf = buf->prev;
2172
2173 buf->size.x = area.x + 1;
2174 buf->size.y = area.y + 1;
2175 buf->size.w = w;
2176 h = buf->size.h;
2177
2178 area2.x = adj_size(10);
2179 area2.h = adj_size(2);
2180
2181 buf = buf->prev;
2182 while (buf != NULL) {
2184 w -= units_h;
2185 }
2186
2187 buf->size.w = w;
2188 buf->size.x = buf->next->size.x;
2189 buf->size.y = buf->next->size.y + buf->next->size.h;
2190
2191 if (buf->id == ID_SEPARATOR) {
2192 FREESURFACE(buf->theme);
2193 buf->size.h = h;
2194 buf->theme = create_surf(w, h);
2195
2196 area2.y = buf->size.h / 2 - 1;
2197 area2.w = buf->size.w - adj_size(20);
2198
2199 SDL_FillSurfaceRect(buf->theme, &area2,
2200 map_rgba(buf->theme->format,
2202 }
2203
2206 break;
2207 }
2208 buf = buf->prev;
2209 }
2210
2213 area.x + area.w,
2215 area.y - advanced_terrain_dlg->end_active_widget_list->size.y + area.h,
2216 TRUE);
2217 }
2218
2219 /* -------------------- */
2220 /* Redraw */
2222
2223 widget_flush(pwindow);
2224}
2225
2226/* ====================================================================== */
2227/* ============================ PILLAGE DIALOG ========================== */
2228/* ====================================================================== */
2230
2231/**********************************************************************/
2234static int pillage_window_callback(struct widget *pwindow)
2235{
2238 }
2239
2240 return -1;
2241}
2242
2243/**********************************************************************/
2246static int pillage_callback(struct widget *pwidget)
2247{
2249 struct unit *punit = pwidget->data.unit;
2250 int what = MAX_ID - pwidget->id;
2251
2253
2254 if (punit) {
2255 struct extra_type *target = extra_by_number(what);
2256
2258 }
2259 }
2260
2261 return -1;
2262}
2263
2264/**********************************************************************/
2267static int exit_pillage_dlg_callback(struct widget *pwidget)
2268{
2271 }
2272
2273 return -1;
2274}
2275
2276/**********************************************************************/
2290
2291/**********************************************************************/
2296{
2297 struct widget *pwindow = NULL, *buf = NULL;
2298 utf8_str *pstr;
2299 SDL_Rect area;
2300 struct extra_type *tgt;
2301
2302 if (pillage_dlg) {
2303 return;
2304 }
2305
2307 pillage_dlg = fc_calloc(1, sizeof(struct small_dialog));
2308
2309 /* Window */
2310 pstr = create_utf8_from_char_fonto(_("What To Pillage"), FONTO_ATTENTION);
2311 pstr->style |= TTF_STYLE_BOLD;
2312
2313 pwindow = create_window_skeleton(NULL, pstr, 0);
2314
2316 set_wstate(pwindow, FC_WS_NORMAL);
2317
2319 pillage_dlg->end_widget_list = pwindow;
2320
2321 area = pwindow->area;
2322
2323 area.h = MAX(area.h, adj_size(2));
2324
2325 /* ---------- */
2326 /* Exit button */
2327 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2329 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2331 area.w += buf->size.w + adj_size(10);
2334 buf->key = SDLK_ESCAPE;
2335
2337 /* ---------- */
2338
2339 while ((tgt = get_preferred_pillage(extras))) {
2340 const char *name = NULL;
2341 int what;
2342
2343 BV_CLR(extras, extra_index(tgt));
2345 what = extra_index(tgt);
2346
2347 fc_assert(name != NULL);
2348
2350 (char *) name, pillage_callback);
2351
2352 buf->data.unit = punit;
2354
2356
2357 area.w = MAX(area.w, buf->size.w);
2358 area.h += buf->size.h;
2359 }
2361
2362 /* setup window size and start position */
2363
2364 resize_window(pwindow, NULL, NULL,
2365 (pwindow->size.w - pwindow->area.w) + area.w,
2366 (pwindow->size.h - pwindow->area.h) + area.h);
2367
2368 area = pwindow->area;
2369
2370 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h,
2371 unit_tile(punit));
2372
2373 /* Setup widget size and start position */
2374
2375 /* Exit button */
2376 buf = pwindow->prev;
2377 buf->size.x = area.x + area.w - buf->size.w - 1;
2378 buf->size.y = pwindow->size.y + adj_size(2);
2379
2380 /* First special to pillage */
2381 buf = buf->prev;
2383 area.x, area.y + 1, area.w, 0,
2385
2386 /* --------------------- */
2387 /* Redraw */
2389
2390 widget_flush(pwindow);
2391}
2392
2393/* ======================================================================= */
2394/* =========================== CONNECT DIALOG ============================ */
2395/* ======================================================================= */
2397
2398/**********************************************************************/
2411
2412/* ==================== Public ========================= */
2413
2414/**************************************************************************
2415 Select Government Type
2416**************************************************************************/
2417static struct small_dialog *gov_dlg = NULL;
2418
2419/**********************************************************************/
2431
2432/**********************************************************************/
2436{
2439
2441 }
2442
2443 return -1;
2444}
2445
2446/**********************************************************************/
2449static int move_government_dlg_callback(struct widget *pwindow)
2450{
2453 }
2454
2455 return -1;
2456}
2457
2458/**********************************************************************/
2462{
2463 struct utf8_str *pstr;
2464 struct widget *gov_button = NULL;
2465 struct widget *pwindow;
2466 int j;
2467 Uint16 max_w = 0, max_h = 0;
2468 SDL_Rect area;
2469
2470 if (gov_dlg != NULL) {
2471 return;
2472 }
2473
2474 gov_dlg = fc_calloc(1, sizeof(struct small_dialog));
2475
2476 /* Create window */
2477 pstr = create_utf8_from_char_fonto(_("Choose Your New Government"),
2479 pstr->style |= TTF_STYLE_BOLD;
2480 /* This win. size is temp. */
2481 pwindow = create_window_skeleton(NULL, pstr, 0);
2484
2485 gov_dlg->end_widget_list = pwindow;
2486
2487 area = pwindow->area;
2488
2489 /* Create gov. buttons */
2490 j = 0;
2491 governments_iterate(gov) {
2493 continue;
2494 }
2495
2500 = create_icon_button(get_government_surface(gov), pwindow->dst, pstr, 0);
2502
2503 max_w = MAX(max_w, gov_button->size.w);
2504 max_h = MAX(max_h, gov_button->size.h);
2505
2506 /* Ugly hack */
2508 j++;
2509
2510 }
2512
2513 if (gov_button == NULL) {
2514 /* No governments to switch to.
2515 * TODO: Provide close button for the dialog. */
2517 } else {
2519
2521
2522 max_w += adj_size(10);
2523 max_h += adj_size(4);
2524
2525 area.w = MAX(area.w, max_w + adj_size(20));
2526 area.h = MAX(area.h, j * (max_h + adj_size(10)) + adj_size(5));
2527
2528 /* Create window background */
2530 if (resize_window(pwindow, logo, NULL,
2531 (pwindow->size.w - pwindow->area.w) + area.w,
2532 (pwindow->size.h - pwindow->area.h) + area.h)) {
2534 }
2535
2536 area = pwindow->area;
2537
2538 /* Set window start positions */
2539 widget_set_position(pwindow,
2540 (main_window_width() - pwindow->size.w) / 2,
2541 (main_window_height() - pwindow->size.h) / 2);
2542
2543 /* Set buttons start positions and size */
2544 j = 1;
2545 while (gov_button != gov_dlg->end_widget_list) {
2546 gov_button->size.w = max_w;
2547 gov_button->size.h = max_h;
2548 gov_button->size.x = area.x + adj_size(10);
2549 gov_button->size.y = area.y + area.h - (j++) * (max_h + adj_size(10));
2551
2552 gov_button = gov_button->next;
2553 }
2554 }
2555
2556 set_wstate(pwindow, FC_WS_NORMAL);
2557
2558 /* Redraw */
2560
2561 widget_flush(pwindow);
2562}
2563
2564/**************************************************************************
2565 Nation Wizard
2566**************************************************************************/
2568static struct small_dialog *help_dlg = NULL;
2569
2570struct nation_info {
2571 unsigned char nation_style; /* selected style */
2572 unsigned char selected_leader; /* if not unique -> selected leader */
2573 Nation_type_id nation; /* selected nation */
2574 bool leader_sex; /* selected leader sex */
2575 struct nation_set *set;
2576 struct widget *change_sex;
2577 struct widget *name_edit;
2578 struct widget *name_next;
2579 struct widget *name_prev;
2580 struct widget *pset_name;
2581 struct widget *pset_next;
2582 struct widget *pset_prev;
2583};
2584
2585static int next_set_callback(struct widget *next_button);
2586static int prev_set_callback(struct widget *prev_button);
2587static int nations_dialog_callback(struct widget *pwindow);
2588static int nation_button_callback(struct widget *pnation);
2589static int races_dialog_ok_callback(struct widget *start_button);
2590static int races_dialog_cancel_callback(struct widget *button);
2591static int next_name_callback(struct widget *next_button);
2592static int prev_name_callback(struct widget *prev_button);
2593static int change_sex_callback(struct widget *sex);
2594static void select_random_leader(Nation_type_id nation);
2595static void change_nation_label(void);
2596
2597/**********************************************************************/
2600static int nations_dialog_callback(struct widget *pwindow)
2601{
2604 widget_flush(pwindow);
2605 }
2606 }
2607
2608 return -1;
2609}
2610
2611/**********************************************************************/
2614static int races_dialog_ok_callback(struct widget *start_button)
2615{
2617 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2618 char *pstr = setup->name_edit->string_utf8->text;
2619
2620 /* perform a minimum of sanity test on the name */
2621 if (strlen(pstr) == 0) {
2622 output_window_append(ftc_client, _("You must type a legal name."));
2623 selected_widget = start_button;
2624 set_wstate(start_button, FC_WS_SELECTED);
2625 widget_redraw(start_button);
2626 widget_flush(start_button);
2627
2628 return -1;
2629 }
2630
2632 setup->nation,
2633 setup->leader_sex, pstr,
2634 setup->nation_style);
2635
2637 flush_dirty();
2638 }
2639
2640 return -1;
2641}
2642
2643/**********************************************************************/
2646static int change_sex_callback(struct widget *sex)
2647{
2649 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2650
2651 if (setup->leader_sex) {
2654 } else {
2657 }
2658 setup->leader_sex = !setup->leader_sex;
2659
2660 if (sex) {
2663
2666 }
2667 }
2668
2669 return -1;
2670}
2671
2672/**********************************************************************/
2675static int next_name_callback(struct widget *next)
2676{
2678 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2679 const struct nation_leader_list *leaders =
2681 const struct nation_leader *pleader;
2682
2683 setup->selected_leader++;
2685
2686 /* change leader sex */
2687 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2689 }
2690
2691 /* change leader name */
2694
2697
2698 if (nation_leader_list_size(leaders) - 1 == setup->selected_leader) {
2700 }
2701
2702 if (get_wstate(setup->name_prev) == FC_WS_DISABLED) {
2704 }
2705
2706 if (!(get_wstate(setup->name_next) == FC_WS_DISABLED)) {
2707 selected_widget = setup->name_next;
2709 }
2710
2711 widget_redraw(setup->name_edit);
2712 widget_redraw(setup->name_prev);
2713 widget_redraw(setup->name_next);
2717
2718 widget_redraw(setup->change_sex);
2720
2721 flush_dirty();
2722 }
2723
2724 return -1;
2725}
2726
2727/**********************************************************************/
2730static int prev_name_callback(struct widget *prev)
2731{
2733 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2734 const struct nation_leader_list *leaders =
2736 const struct nation_leader *pleader;
2737
2738 setup->selected_leader--;
2740
2741 /* change leader sex */
2742 if (setup->leader_sex != nation_leader_is_male(pleader)) {
2744 }
2745
2746 /* change leader name */
2749
2752
2753 if (!setup->selected_leader) {
2755 }
2756
2757 if (get_wstate(setup->name_next) == FC_WS_DISABLED) {
2759 }
2760
2761 if (!(get_wstate(setup->name_prev) == FC_WS_DISABLED)) {
2762 selected_widget = setup->name_prev;
2764 }
2765
2766 widget_redraw(setup->name_edit);
2767 widget_redraw(setup->name_prev);
2768 widget_redraw(setup->name_next);
2772
2773 widget_redraw(setup->change_sex);
2775
2776 flush_dirty();
2777 }
2778
2779 return -1;
2780}
2781
2782/**********************************************************************/
2785static int next_set_callback(struct widget *next_button)
2786{
2788 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2789 struct option *poption = optset_option_by_name(server_optset, "nationset");
2790
2791 fc_assert(setup->set != NULL
2792 && nation_set_index(setup->set) < nation_set_count() - 1);
2793
2794 setup->set = nation_set_by_number(nation_set_index(setup->set) + 1);
2795
2797 }
2798
2799 return -1;
2800}
2801
2802/**********************************************************************/
2806{
2808 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2809 struct option *poption = optset_option_by_name(server_optset, "nationset");
2810
2811 fc_assert(setup->set != NULL && nation_set_index(setup->set) > 0);
2812
2813 setup->set = nation_set_by_number(nation_set_index(setup->set) - 1);
2814
2816 }
2817
2818 return -1;
2819}
2820
2821/**********************************************************************/
2824static int races_dialog_cancel_callback(struct widget *button)
2825{
2828 flush_dirty();
2829 }
2830
2831 return -1;
2832}
2833
2834/**********************************************************************/
2837static int style_callback(struct widget *pwidget)
2838{
2840 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2842 setup->nation_style);
2843
2847
2848 set_wstate(pwidget, FC_WS_DISABLED);
2849 widget_redraw(pwidget);
2850 widget_mark_dirty(pwidget);
2851
2852 setup->nation_style = MAX_ID - 1000 - pwidget->id;
2853
2854 flush_dirty();
2856 }
2857
2858 return -1;
2859}
2860
2861/**********************************************************************/
2864static int help_dlg_callback(struct widget *pwindow)
2865{
2866 return -1;
2867}
2868
2869/**********************************************************************/
2872static int cancel_help_dlg_callback(struct widget *pwidget)
2873{
2875 if (help_dlg) {
2879 if (pwidget) {
2880 flush_dirty();
2881 }
2882 }
2883 }
2884
2885 return -1;
2886}
2887
2888/**********************************************************************/
2892{
2895
2897 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
2898
2899 if (setup->nation == MAX_ID - nation_button->id) {
2902
2903 return -1;
2904 }
2905
2906 setup->nation = MAX_ID - nation_button->id;
2907
2909
2910 enable(MAX_ID - 1000 - setup->nation_style);
2912 disable(MAX_ID - 1000 - setup->nation_style);
2913
2915
2918 } else {
2919 /* Pop up nation description */
2920 struct widget *pwindow, *ok_button;
2921 utf8_str *pstr;
2922 SDL_Surface *text;
2924 struct nation_type *pnation = nation_by_number(MAX_ID - nation_button->id);
2925
2928
2929 if (!help_dlg) {
2930 help_dlg = fc_calloc(1, sizeof(struct small_dialog));
2931
2934 pstr->style |= TTF_STYLE_BOLD;
2935
2936 pwindow = create_window_skeleton(NULL, pstr, 0);
2937 pwindow->action = help_dlg_callback;
2938
2939 set_wstate(pwindow, FC_WS_NORMAL);
2940
2941 help_dlg->end_widget_list = pwindow;
2942 add_to_gui_list(ID_WINDOW, pwindow);
2943
2944 ok_button
2946 pwindow->dst, _("OK"),
2947 FONTO_HEADING, 0);
2948 ok_button->action = cancel_help_dlg_callback;
2949 set_wstate(ok_button, FC_WS_NORMAL);
2950 ok_button->key = SDLK_ESCAPE;
2951 add_to_gui_list(ID_BUTTON, ok_button);
2952 help_dlg->begin_widget_list = ok_button;
2953 } else {
2954 pwindow = help_dlg->end_widget_list;
2955 ok_button = help_dlg->begin_widget_list;
2956
2957 /* Undraw window */
2958 widget_undraw(pwindow);
2959 widget_mark_dirty(pwindow);
2960 }
2961
2962 area = pwindow->area;
2963
2964 {
2965 char info[4096];
2966
2967 helptext_nation(info, sizeof(info), pnation, NULL);
2969 }
2970
2973
2975
2976 /* create window background */
2977 area.w = MAX(area.w, text->w + adj_size(20));
2978 area.w = MAX(area.w, ok_button->size.w + adj_size(20));
2979 area.h = MAX(area.h, adj_size(9) + text->h
2980 + adj_size(10) + ok_button->size.h + adj_size(10));
2981
2983 (pwindow->size.w - pwindow->area.w) + area.w,
2984 (pwindow->size.h - pwindow->area.h) + area.h);
2985
2986 widget_set_position(pwindow,
2987 (main_window_width() - pwindow->size.w) / 2,
2988 (main_window_height() - pwindow->size.h) / 2);
2989
2990 area2.x = area.x + adj_size(7);
2991 area2.y = area.y + adj_size(6);
2992 alphablit(text, NULL, pwindow->theme, &area2, 255);
2993 FREESURFACE(text);
2994
2995 ok_button->size.x = area.x + (area.w - ok_button->size.w) / 2;
2996 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
2997
2998 /* redraw */
2999 redraw_group(ok_button, pwindow, 0);
3000
3001 widget_mark_dirty(pwindow);
3002
3003 flush_dirty();
3004
3005 }
3006
3007 return -1;
3008}
3009
3010/**********************************************************************/
3013static int leader_name_edit_callback(struct widget *pedit)
3014{
3016 if (pedit->string_utf8->text != NULL) {
3017 /* empty input -> restore previous content */
3019 widget_redraw(pedit);
3020 widget_mark_dirty(pedit);
3021 flush_dirty();
3022 }
3023 }
3024
3025 return -1;
3026}
3027
3028/* =========================================================== */
3029
3030/**********************************************************************/
3033static void change_nation_label(void)
3034{
3036 struct widget *pwindow = nation_dlg->end_widget_list;
3037 struct nation_info *setup = (struct nation_info *)(pwindow->data.ptr);
3038 struct widget *label = setup->name_edit->next;
3039 struct nation_type *pnation = nation_by_number(setup->nation);
3040
3043
3044 FREESURFACE(label->theme);
3045 label->theme = tmp_surf_zoomed;
3046
3048
3049 remake_label_size(label);
3050
3051 label->size.x = pwindow->size.x + pwindow->size.w / 2 +
3052 (pwindow->size.w / 2 - label->size.w) / 2;
3053
3054}
3055
3056/**********************************************************************/
3061{
3062 struct nation_info *setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3063 const struct nation_leader_list *leaders =
3065 const struct nation_leader *pleader;
3066
3071
3074
3075 /* initialize leader sex */
3077
3078 if (setup->leader_sex) {
3081 } else {
3084 }
3085
3086 /* disable navigation buttons */
3089
3090 if (1 < nation_leader_list_size(leaders)) {
3091 /* if selected leader is not the first leader, enable "previous leader" button */
3092 if (setup->selected_leader > 0) {
3094 }
3095
3096 /* if selected leader is not the last leader, enable "next leader" button */
3097 if (setup->selected_leader < (nation_leader_list_size(leaders) - 1)) {
3099 }
3100 }
3101}
3102
3103/**********************************************************************/
3107{
3108 int playable_nation_count = 0;
3109
3110 nations_iterate(pnation) {
3111 if (pnation->is_playable && !pnation->player
3112 && is_nation_pickable(pnation))
3115
3116 return playable_nation_count;
3117}
3118
3119/**********************************************************************/
3122void popup_races_dialog(struct player *pplayer)
3123{
3124 SDL_Color bg_color = {255,255,255,128};
3125
3126 struct widget *pwindow, *pwidget = NULL, *buf, *last_City_Style;
3127 utf8_str *pstr;
3128 int len = 0;
3129 int w = adj_size(10), h = adj_size(10);
3132 SDL_Rect dst;
3133 float zoom;
3134 struct nation_info *setup;
3135 SDL_Rect area;
3136 int i;
3137 struct nation_type *pnat;
3138 struct widget *nationsets = NULL;
3139 int natinfo_y, natinfo_h;
3140
3141#define TARGETS_ROW 5
3142#define TARGETS_COL 1
3143
3144 if (nation_dlg) {
3145 return;
3146 }
3147
3148 races_player = pplayer;
3149
3150 nation_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3151
3152 /* Create window widget */
3153 pstr = create_utf8_from_char_fonto(_("What nation will you be?"),
3155 pstr->style |= TTF_STYLE_BOLD;
3156
3157 pwindow = create_window(NULL, pstr, w, h, WF_FREE_DATA);
3159 set_wstate(pwindow, FC_WS_NORMAL);
3160 setup = fc_calloc(1, sizeof(struct nation_info));
3161 pwindow->data.ptr = (void *)setup;
3162
3163 nation_dlg->end_widget_list = pwindow;
3165 /* --------------------------------------------------------- */
3166 /* Create nations list */
3167
3168 /* Create Imprv Background Icon */
3169 main_bg = create_surf(adj_size(96*2), adj_size(64));
3170
3172 map_rgba(main_bg->format, bg_color));
3173
3175 0, 0, main_bg->w - 1, main_bg->h - 1,
3177
3179 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
3180 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
3181
3182 /* Fill list */
3183
3184 nations_iterate(pnation) {
3185 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
3186 continue;
3187 }
3188
3190
3192
3195 text_name
3197
3198 dst.x = (tmp_surf->w - tmp_surf_zoomed->w) / 2;
3199 len = tmp_surf_zoomed->h +
3200 adj_size(10) + text_name->h;
3201 dst.y = (tmp_surf->h - len) / 2;
3203 dst.y += (tmp_surf_zoomed->h + adj_size(10));
3205
3206 dst.x = (tmp_surf->w - text_name->w) / 2;
3208 dst.y += text_name->h;
3210
3211 pwidget = create_icon2(tmp_surf, pwindow->dst,
3213
3214 set_wstate(pwidget, FC_WS_NORMAL);
3215
3216 pwidget->action = nation_button_callback;
3217
3218 w = MAX(w, pwidget->size.w);
3219 h = MAX(h, pwidget->size.h);
3220
3221 add_to_gui_list(MAX_ID - nation_index(pnation), pwidget);
3222
3223 if (nation_index(pnation) > (TARGETS_ROW * TARGETS_COL - 1)) {
3224 set_wflag(pwidget, WF_HIDDEN);
3225 }
3226
3228
3230
3232 nation_dlg->begin_widget_list = pwidget;
3234
3239 }
3240
3241 /* ----------------------------------------------------------------- */
3242
3243 /* Nation set selection */
3244 if (nation_set_count() > 1) {
3246 struct option *poption;
3247
3253
3254 /* Create nation set name label */
3257
3262
3263 pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0);
3264
3265 add_to_gui_list(ID_LABEL, pwidget);
3266 setup->pset_name = pwidget;
3267
3268 /* Create next nationset button */
3269 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3270 pwindow->dst, NULL, 0);
3271 pwidget->action = next_set_callback;
3272 if (nation_set_index(setup->set) < nation_set_count() - 1) {
3273 set_wstate(pwidget, FC_WS_NORMAL);
3274 }
3276 pwidget->size.h = pwidget->next->size.h;
3277 setup->pset_next = pwidget;
3278
3279 /* Create prev nationset button */
3280 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3281 pwindow->dst, NULL, 0);
3282 pwidget->action = prev_set_callback;
3283 if (nation_set_index(setup->set) > 0) {
3284 set_wstate(pwidget, FC_WS_NORMAL);
3285 }
3287 pwidget->size.h = pwidget->next->size.h;
3288 setup->pset_prev = pwidget;
3289 }
3290
3291 /* Nation name */
3293 pnat = nation_by_number(setup->nation);
3295
3298 pstr->render = 2;
3300
3302
3303 pwidget = create_iconlabel(tmp_surf_zoomed, pwindow->dst, pstr,
3305 if (nationsets == NULL) {
3306 buf = pwidget;
3307 } else {
3308 buf = nationsets;
3309 }
3310
3311 add_to_gui_list(ID_LABEL, pwidget);
3312
3313 /* Create leader name edit */
3314 pwidget = create_edit_from_chars_fonto(NULL, pwindow->dst,
3315 NULL, FONTO_BIG,
3316 adj_size(200), 0);
3317 pwidget->size.h = adj_size(24);
3318
3319 set_wstate(pwidget, FC_WS_NORMAL);
3322 setup->name_edit = pwidget;
3323
3324 /* Create next leader name button */
3325 pwidget = create_themeicon_button(current_theme->r_arrow_icon,
3326 pwindow->dst, NULL, 0);
3327 pwidget->action = next_name_callback;
3329 pwidget->size.h = pwidget->next->size.h;
3330 setup->name_next = pwidget;
3331
3332 /* Create prev leader name button */
3333 pwidget = create_themeicon_button(current_theme->l_arrow_icon,
3334 pwindow->dst, NULL, 0);
3335 pwidget->action = prev_name_callback;
3337 pwidget->size.h = pwidget->next->size.h;
3338 setup->name_prev = pwidget;
3339
3340 /* Change sex button */
3341 pwidget = create_icon_button_from_chars_fonto(NULL, pwindow->dst,
3343 FONTO_HEADING, 0);
3344 pwidget->action = change_sex_callback;
3345 pwidget->size.w = adj_size(100);
3346 pwidget->size.h = adj_size(22);
3347 set_wstate(pwidget, FC_WS_NORMAL);
3348 setup->change_sex = pwidget;
3349
3350 /* Add to main widget list */
3352
3353 /* ---------------------------------------------------------- */
3354 zoom = DEFAULT_ZOOM * 1.0;
3355
3356 len = 0;
3359
3361
3362 if (tmp_surf->w > 48) {
3363 zoom = DEFAULT_ZOOM * (48.0 / tmp_surf->w);
3364 }
3365
3367
3368 pwidget = create_icon2(tmp_surf_zoomed, pwindow->dst,
3370 pwidget->action = style_callback;
3371 if (sn != setup->nation_style) {
3372 set_wstate(pwidget, FC_WS_NORMAL);
3373 }
3374 len += pwidget->size.w;
3375 add_to_gui_list(MAX_ID - 1000 - sn, pwidget);
3377
3378 last_City_Style = pwidget;
3379 /* ---------------------------------------------------------- */
3380
3381 /* Create Cancel button */
3382 pwidget
3384 pwindow->dst, _("Cancel"),
3385 FONTO_ATTENTION, 0);
3387 set_wstate(pwidget, FC_WS_NORMAL);
3388
3390
3391 /* Create OK button */
3392 pwidget
3394 pwindow->dst,
3395 _("OK"), FONTO_ATTENTION, 0);
3397
3398 set_wstate(pwidget, FC_WS_NORMAL);
3400 pwidget->size.w = MAX(pwidget->size.w, pwidget->next->size.w);
3401 pwidget->next->size.w = pwidget->size.w;
3402
3403 nation_dlg->begin_widget_list = pwidget;
3404 /* ---------------------------------------------------------- */
3405
3407 if (resize_window(pwindow, main_bg, NULL, adj_size(640), adj_size(480))) {
3409 }
3410
3411 area = pwindow->area;
3412
3413 widget_set_position(pwindow,
3414 (main_window_width() - pwindow->size.w) / 2,
3415 (main_window_height() - pwindow->size.h) / 2);
3416
3417 /* Nations */
3418
3420 i = (area.h - adj_size(43) - h) / 2;
3422 area.x + adj_size(10),
3423 area.y + i - adj_size(4),
3426
3427 if (nation_dlg->scroll) {
3429
3432 area.x + w + adj_size(12),
3433 area.y + i - adj_size(4), h, FALSE);
3434
3435 area2.x = area.x + w + adj_size(11);
3436 area2.y = area.y + i - adj_size(4);
3438 area2.h = h;
3439 fill_rect_alpha(pwindow->theme, &area2, &bg_color);
3440
3441 create_frame(pwindow->theme,
3442 area2.x, area2.y - 1, area2.w, area2.h + 1,
3444 }
3445
3446 if (nationsets != NULL) {
3447 /* Nationsets header */
3448 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3449 buf->size.y = area.y + adj_size(46);
3450
3451 natinfo_y = buf->size.y;
3452 natinfo_h = area.h -= buf->size.y;
3453
3454 /* Nationset name */
3455 buf = buf->prev;
3456 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3457 buf->size.y = natinfo_y + adj_size(46);
3458
3459 natinfo_y += adj_size(46);
3460 natinfo_h -= adj_size(46);
3461
3462 /* Next Nationset Button */
3463 buf = buf->prev;
3464 buf->size.x = buf->next->size.x + buf->next->size.w;
3465 buf->size.y = buf->next->size.y;
3466
3467 /* Prev Nationset Button */
3468 buf = buf->prev;
3469 buf->size.x = buf->next->next->size.x - buf->size.w;
3470 buf->size.y = buf->next->size.y;
3471
3472 buf = buf->prev;
3473 } else {
3474 natinfo_y = area.y;
3475 natinfo_h = area.h;
3476 }
3477
3478 /* Selected Nation Name */
3479 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3480 buf->size.y = natinfo_y + adj_size(46);
3481
3482 /* Leader Name Edit */
3483 buf = buf->prev;
3484 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3485 buf->size.y = natinfo_y + (natinfo_h - buf->size.h) / 2 - adj_size(30);
3486
3487 /* Next Leader Name Button */
3488 buf = buf->prev;
3489 buf->size.x = buf->next->size.x + buf->next->size.w;
3490 buf->size.y = buf->next->size.y;
3491
3492 /* Prev Leader Name Button */
3493 buf = buf->prev;
3494 buf->size.x = buf->next->next->size.x - buf->size.w;
3495 buf->size.y = buf->next->size.y;
3496
3497 /* Change Leader Sex Button */
3498 buf = buf->prev;
3499 buf->size.x = area.x + area.w / 2 + (area.w / 2 - buf->size.w) / 2;
3500 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3501
3502 /* First Style Button */
3503 buf = buf->prev;
3504 buf->size.x = area.x + area.w / 2 + (area.w / 2 - len) / 2 - adj_size(20);
3505 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(20);
3506
3507 /* Rest Style Buttons */
3508 while (buf != last_City_Style) {
3509 buf = buf->prev;
3510 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(3);
3511 buf->size.y = buf->next->size.y;
3512 }
3513
3514 create_line(pwindow->theme,
3515 area.x,
3516 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3517 area.w - 1,
3518 natinfo_y + natinfo_h - adj_size(7) - buf->prev->size.h - adj_size(10),
3520
3521 /* Disconnect Button */
3522 buf = buf->prev;
3523 buf->size.x = area.x + adj_size(10);
3524 buf->size.y = natinfo_y + natinfo_h - adj_size(7) - buf->size.h;
3525
3526 /* Start Button */
3527 buf = buf->prev;
3528 buf->size.x = area.w - adj_size(10) - buf->size.w;
3529 buf->size.y = buf->next->size.y;
3530
3531 /* -------------------------------------------------------------------- */
3532
3534
3536
3537 widget_flush(pwindow);
3538}
3539
3540/**********************************************************************/
3558
3559/**********************************************************************/
3562void races_update_pickable(bool nationset_change)
3563{
3564 /* If this is because of nationset change, update will take
3565 * place later when the new option value is received */
3566 if (nation_dlg != NULL && !nationset_change) {
3569 }
3570}
3571
3572/**********************************************************************/
3576{
3577 if (nation_dlg != NULL) {
3580 }
3581}
3582
3583/**********************************************************************/
3588{
3589 struct nation_info *setup;
3590 bool change = FALSE;
3591 struct widget *nat;
3592
3593 if (!nation_dlg) {
3594 return;
3595 }
3596
3597 setup = (struct nation_info *)(nation_dlg->end_widget_list->data.ptr);
3598
3600 if (!is_nation_pickable(nation) || nation->player) {
3601 log_debug(" [%d]: %d = %s", nation_index(nation),
3602 (!is_nation_pickable(nation) || nation->player),
3604
3607
3608 if (nation_index(nation) == setup->nation) {
3609 change = TRUE;
3610 }
3611 }
3613
3614 if (change) {
3615 do {
3618 } while (get_wstate(nat) == FC_WS_DISABLED);
3619
3620 if (get_wstate(setup->name_edit) == FC_WS_PRESSED) {
3623 }
3625 enable(MAX_ID - 1000 - setup->nation_style);
3627 disable(MAX_ID - 1000 - setup->nation_style);
3629 }
3632}
3633
3634/**********************************************************************/
3639{
3640}
3641
3642/**********************************************************************/
3649
3650/**********************************************************************/
3657
3658/**********************************************************************/
3663{
3664 /* Don't load */
3665 return FALSE;
3666}
3667
3668/**********************************************************************/
3672{
3673 /* PORTME */
3674}
3675
3676/**********************************************************************/
3679void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
3680{
3681 /* PORTME */
3682}
3683
3684/**********************************************************************/
3689{
3690 /* Just tell the client common code to handle this. */
3691 return FALSE;
3692}
3693
3694/**********************************************************************/
3698{
3699 /* PORTME */
3700}
3701
3702/**********************************************************************/
3705bool request_transport(struct unit *pcargo, struct tile *ptile)
3706{
3707 return FALSE; /* Unit was not handled here. */
3708}
3709
3710/**********************************************************************/
3714void popup_combat_info(int attacker_unit_id, int defender_unit_id,
3715 int attacker_hp, int defender_hp,
3716 bool make_att_veteran, bool make_def_veteran)
3717{
3718}
3719
3720/**********************************************************************/
3724 struct act_confirmation_data *data)
3725{
3726 /* TODO: Implement. Currently just pass everything as confirmed */
3728}
3729
3731
3732/**********************************************************************/
3735static int image_popup_window_callback(struct widget *pwindow)
3736{
3739 }
3740
3741 return -1;
3742}
3743
3744/**********************************************************************/
3761
3762/**********************************************************************/
3765void popup_image(const char *tag)
3766{
3767 if (advanced_image_popup == NULL) {
3768 struct sprite *spr = load_popup_sprite(tag);
3769
3770 if (spr != NULL) {
3771 struct widget *win = create_window_skeleton(NULL, NULL, 0);
3772 struct widget *buf;
3774 SDL_Rect dst;
3775 SDL_Rect area;
3776 int width, height;
3777
3779 advanced_image_popup = fc_calloc(1, sizeof(struct advanced_dialog));
3780
3783
3786
3787 /* Create exit button */
3788 buf = create_themeicon(current_theme->small_cancel_icon, win->dst,
3790 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3794 buf->key = SDLK_ESCAPE;
3795
3798
3800 win->size.w - win->area.w + width,
3801 win->size.h - win->area.h + buf->area.h + height);
3802
3804 (main_window_width() - win->size.w) / 2,
3805 (main_window_height() - win->size.h) / 2);
3806
3807 area = win->area;
3808 dst.x = area.x;
3809 dst.y = area.y + buf->size.y;
3810 alphablit(surf, NULL, win->theme, &dst, 255);
3811
3812 /* Redraw */
3814 widget_flush(win);
3815
3817 } else {
3818 log_error(_("No image for tag \"%s\", requested by the server."), tag);
3819 }
3820 }
3821}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
#define ACTION_NONE
Definition actions.h:59
void astr_free(struct astring *astr)
Definition astring.c:148
#define str
Definition astring.c:76
#define n
Definition astring.c:77
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_CLR(bv, bit)
Definition bitvector.h:94
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_name_get(const struct city *pcity)
Definition city.c:1141
#define city_owner(_pcity_)
Definition city.h:564
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:63
char * incite_cost
Definition comments.c:77
void clear_hover_state(void)
Definition control.c:328
void unit_focus_set(struct unit *punit)
Definition control.c:518
void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
Definition control.c:3197
struct unit_list * get_units_in_focus(void)
Definition control.c:177
void request_unit_disband(struct unit *punit)
Definition control.c:2087
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1950
void set_hover_state(struct unit_list *punits, enum cursor_hover_state state, enum unit_activity activity, struct extra_type *tgt, int last_tgt, int last_sub_tgt, action_id action, enum unit_orders order)
Definition control.c:290
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1778
void do_unit_patrol_to(struct tile *ptile)
Definition control.c:3237
struct unit * head_of_units_in_focus(void)
Definition control.c:410
void request_unit_upgrade(struct unit *punit)
Definition control.c:2118
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1941
@ HOVER_PARADROP
Definition control.h:29
@ HOVER_PATROL
Definition control.h:31
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction const char * expl
Definition dialogs_g.h:94
const char * caption
Definition dialogs_g.h:37
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city const struct action *paction request_action_confirmation
Definition dialogs_g.h:94
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define extra_index(_e_)
Definition extras.h:183
QString current_theme
Definition fc_client.cpp:59
#define NO_TARGET
Definition fc_types.h:215
int Tech_type_id
Definition fc_types.h:238
int Nation_type_id
Definition fc_types.h:241
int Unit_type_id
Definition fc_types.h:243
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
void exit_goto_state(void)
Definition goto.c: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:145
struct government * government_by_number(const Government_type_id gov)
Definition government.c:105
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Definition government.c:172
Government_type_id government_number(const struct government *pgovern)
Definition government.c:93
#define governments_iterate(NAME_pgov)
Definition government.h:127
#define governments_iterate_end
Definition government.h:130
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
struct city * owner
Definition citydlg.c:226
void city_report_dialog_popdown(void)
Definition cityrep.c:312
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:313
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
void popdown_races_dialog(void)
Definition dialogs.c:1230
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:386
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
Definition dialogs.c:1540
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.c:1583
struct player * races_player
Definition dialogs.c:74
void popup_image(const char *tag)
Definition dialogs.c:1636
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
void popdown_help_dialog(void)
Definition helpdlg.c:186
void flush_dirty(void)
Definition mapview.c:468
void update_unit_info_label(struct unit_list *punits)
Definition mapview.c:275
void meswin_dialog_popdown(void)
Definition messagewin.c:432
static GtkWidget * nation_button
Definition pages.c:1460
void popdown_players_dialog(void)
Definition plrdlg.c:105
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
void unit_select_dialog_popdown(void)
Definition unitselect.c:207
void enable_city_dlg_widgets(void)
Definition citydlg.c:1535
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
void free_city_units_lists(void)
Definition citydlg.c:819
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:109
static int adv_unit_sentry_idle_callback(struct widget *pwidget)
Definition dialogs.c:1585
static struct small_dialog * terrain_info_dlg
Definition dialogs.c:1274
void popup_government_dialog(void)
Definition dialogs.c:2464
static struct notify_goto_data * notify_goto_data_new(const char *headline, const char *lines, struct tile *ptile)
Definition dialogs.c:238
static int adv_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1548
static struct small_dialog * unit_disband_dlg
Definition dialogs.c:827
static void popdown_unit_upgrade_dlg(void)
Definition dialogs.c:815
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:878
static void popdown_unit_disband_dlg(void)
Definition dialogs.c:1015
static void notify_goto_data_destroy(struct notify_goto_data *pdata)
Definition dialogs.c:254
static int cma_callback(struct widget *pwidget)
Definition dialogs.c:1533
static struct small_dialog * connect_dlg
Definition dialogs.c:2399
bool is_unit_move_blocked
Definition gui_main.c:108
static int hurry_production_callback(struct widget *pwidget)
Definition dialogs.c:1517
static void select_random_leader(Nation_type_id nation)
Definition dialogs.c:3063
static int next_set_callback(struct widget *next_button)
Definition dialogs.c:2788
static int exit_unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1044
void popdown_advanced_terrain_dialog(void)
Definition dialogs.c:1429
void popup_musicset_suggestion_dialog(void)
Definition dialogs.c:3656
#define ADV_NUM_SEEN
static void popdown_pillage_dialog(void)
Definition dialogs.c:2283
static struct advanced_dialog * unit_select_dlg
Definition dialogs.c:1027
static int notify_goto_dialog_callback(struct widget *widget)
Definition dialogs.c:263
int exit_advanced_terrain_dlg_callback(struct widget *pwidget)
Definition dialogs.c:1456
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:650
static int prev_set_callback(struct widget *prev_button)
Definition dialogs.c:2808
static int prev_name_callback(struct widget *prev_button)
Definition dialogs.c:2733
static int exit_image_popup_callback(struct widget *pwidget)
Definition dialogs.c:3749
static int terrain_info_callback(struct widget *pwidget)
Definition dialogs.c:1469
void popup_soundset_suggestion_dialog(void)
Definition dialogs.c:3648
static int style_callback(struct widget *pwidget)
Definition dialogs.c:2840
static int unit_help_callback(struct widget *pwidget)
Definition dialogs.c:1693
static int move_government_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2452
static void popdown_government_dialog(void)
Definition dialogs.c:2425
static struct advanced_dialog * nation_dlg
Definition dialogs.c:2570
static int change_sex_callback(struct widget *sex)
Definition dialogs.c:2649
static int cancel_help_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2875
static int next_name_callback(struct widget *next_button)
Definition dialogs.c:2678
void popup_tileset_suggestion_dialog(void)
Definition dialogs.c:3640
#define TARGETS_ROW
static void popup_terrain_info_dialog(SDL_Surface *pdest, struct tile *ptile)
Definition dialogs.c:1338
static int get_playable_nation_count(void)
Definition dialogs.c:3109
static struct small_dialog * help_dlg
Definition dialogs.c:2571
struct advanced_dialog * advanced_terrain_dlg
Definition dialogs.c:1423
static void popdown_terrain_info_dialog(void)
Definition dialogs.c:1292
static int adv_unit_select_all_callback(struct widget *pwidget)
Definition dialogs.c:1567
static void notify_goto_dialog_advance(struct notify_goto_dialog *pdialog)
Definition dialogs.c:422
static int unit_select_callback(struct widget *pwidget)
Definition dialogs.c:1057
static int exit_notify_dialog_callback(struct widget *pwidget)
Definition dialogs.c:493
void popdown_notify_goto_dialog(void)
Definition dialogs.c:459
int advanced_terrain_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1444
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition dialogs.c:635
static int nation_button_callback(struct widget *pnation)
Definition dialogs.c:2894
static int races_dialog_cancel_callback(struct widget *button)
Definition dialogs.c:2827
static int notify_goto_dialog_close_callback(struct widget *widget)
Definition dialogs.c:278
static int image_popup_window_callback(struct widget *pwindow)
Definition dialogs.c:3737
static int leader_name_edit_callback(struct widget *pedit)
Definition dialogs.c:3016
static int patrol_here_callback(struct widget *pwidget)
Definition dialogs.c:1631
static int pillage_window_callback(struct widget *pwindow)
Definition dialogs.c:2237
static int help_dlg_callback(struct widget *pwindow)
Definition dialogs.c:2867
bool popup_theme_suggestion_dialog(const char *theme_name)
Definition dialogs.c:3664
static int disband_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:832
static int nations_dialog_callback(struct widget *pwindow)
Definition dialogs.c:2603
static void notify_goto_dialog_update(struct notify_goto_dialog *pdialog)
Definition dialogs.c:376
void popdown_diplomat_dialog(void)
void real_multipliers_dialog_update(void *unused)
Definition dialogs.c:3699
static int goto_here_callback(struct widget *pwidget)
Definition dialogs.c:1612
static struct small_dialog * gov_dlg
Definition dialogs.c:2420
static int notify_goto_dialog_goto_callback(struct widget *widget)
Definition dialogs.c:293
bool request_transport(struct unit *pcargo, struct tile *ptile)
Definition dialogs.c:3707
static void change_nation_label(void)
Definition dialogs.c:3036
#define NUM_SEEN
static struct small_dialog * pillage_dlg
Definition dialogs.c:2232
void nationset_changed(void)
Definition dialogs.c:3577
void popdown_incite_dialog(void)
static int races_dialog_ok_callback(struct widget *start_button)
Definition dialogs.c:2617
void popdown_bribe_dialog(void)
static void notify_goto_dialog_destroy(struct notify_goto_dialog *pdialog)
Definition dialogs.c:357
static int cancel_disband_unit_callback(struct widget *pwidget)
Definition dialogs.c:844
#define TARGETS_COL
static int change_production_callback(struct widget *pwidget)
Definition dialogs.c:1502
static int exit_pillage_dlg_callback(struct widget *pwidget)
Definition dialogs.c:2270
static int terrain_info_window_dlg_callback(struct widget *pwindow)
Definition dialogs.c:1280
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
static int zoom_to_city_callback(struct widget *pwidget)
Definition dialogs.c:1486
static bool sdl_get_chance_to_win(int *att_chance, int *def_chance, struct unit *enemy_unit, struct unit *my_unit)
Definition dialogs.c:192
struct advanced_dialog * advanced_image_popup
Definition dialogs.c:3732
static int government_dlg_callback(struct widget *gov_button)
Definition dialogs.c:2438
const char * sdl_get_tile_defense_info_text(struct tile *ptile)
Definition dialogs.c:1318
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition dialogs.c:623
static int notify_dialog_window_callback(struct widget *pwindow)
Definition dialogs.c:481
static int unit_select_window_callback(struct widget *pwindow)
Definition dialogs.c:1032
static struct small_dialog * unit_upgrade_dlg
Definition dialogs.c:618
static int exit_terrain_info_dialog_callback(struct widget *button)
Definition dialogs.c:1305
static int paradrop_here_callback(struct widget *pwidget)
Definition dialogs.c:1660
static int ok_disband_unit_window_callback(struct widget *pwidget)
Definition dialogs.c:859
void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_y)
Definition dialogs.c:1709
static struct notify_goto_dialog * notify_goto_dialog_new(void)
Definition dialogs.c:318
static void popdown_connect_dialog(void)
Definition dialogs.c:2405
static char * leader_name
Definition dialogs.c:97
struct advanced_dialog * notify_dlg
Definition dialogs.c:476
void popdown_find_dialog(void)
Definition finddlg.c:110
void popdown_goto_airlift_dialog(void)
Definition gotodlg.c:424
int main_window_width(void)
Definition graphics.c:683
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:146
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:863
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1363
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1307
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:234
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:197
struct sdl2_data main_data
Definition graphics.c:55
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:349
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:398
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1332
int main_window_height(void)
Definition graphics.c:691
#define DEFAULT_ZOOM
Definition graphics.h:198
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_TERRAIN_ADV_DLG_WINDOW
Definition gui_id.h:201
@ ID_NATION_WIZARD_WINDOW
Definition gui_id.h:60
@ ID_UNIT_SELECT_DLG_WINDOW
Definition gui_id.h:194
@ ID_NATION_WIZARD_START_BUTTON
Definition gui_id.h:61
@ ID_NATION_WIZARD_NEXT_LEADER_NAME_BUTTON
Definition gui_id.h:66
@ ID_UNIT_SELECT_DLG_EXIT_BUTTON
Definition gui_id.h:197
@ ID_NATION_WIZARD_CHANGE_SEX_BUTTON
Definition gui_id.h:68
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
@ ID_BUTTON
Definition gui_id.h:29
@ ID_TERRAIN_INFO_DLG_WINDOW
Definition gui_id.h:199
@ ID_TERRAIN_INFO_DLG_EXIT_BUTTON
Definition gui_id.h:200
@ ID_NATION_PREV_NATIONSET_BUTTON
Definition gui_id.h:70
@ ID_NATION_NEXT_NATIONSET_BUTTON
Definition gui_id.h:69
@ ID_NATION_WIZARD_DISCONNECT_BUTTON
Definition gui_id.h:64
@ ID_SEPARATOR
Definition gui_id.h:28
@ ID_LABEL
Definition gui_id.h:27
@ ID_WINDOW
Definition gui_id.h:30
@ ID_PILLAGE_DLG_EXIT_BUTTON
Definition gui_id.h:204
@ ID_NATION_WIZARD_PREV_LEADER_NAME_BUTTON
Definition gui_id.h:67
@ ID_PILLAGE_DLG_WINDOW
Definition gui_id.h:203
@ ID_NATION_WIZARD_LEADER_NAME_EDIT
Definition gui_id.h:65
@ ID_GOVERNMENT_DLG_WINDOW
Definition gui_id.h:144
void force_exit_from_event_loop(void)
Definition gui_main.c:569
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:145
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_BIG
Definition gui_string.h:70
@ FONTO_ATTENTION
Definition gui_string.h:67
@ FONTO_MAX
Definition gui_string.h:71
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
static SDL_Surface * get_government_surface(const struct government *gov)
static SDL_Surface * get_nation_flag_surface(const struct nation_type *pnation)
static SDL_Surface * get_sample_city_surface(int city_style)
void popup_unit_info(Unit_type_id type_id)
Definition helpdlg.c:630
void popdown_intel_dialogs(void)
Definition inteldlg.c:215
void popdown_newcity_dialog(void)
Definition mapctrl.c:2897
void enable_and_redraw_revolution_button(void)
Definition mapctrl.c:2245
SDL_Surface * get_terrain_surface(struct tile *ptile)
Definition mapview.c:1217
void flush_all(void)
Definition mapview.c:201
void undraw_order_widgets(void)
Definition menu.c:961
void popdown_optiondlg(bool leave_game)
Definition optiondlg.c:1451
void popdown_players_nations_dialog(void)
Definition plrdlg.c:877
void science_report_dialogs_popdown_all(void)
Definition repodlgs.c:3479
#define GET_SURF(m_sprite)
Definition sprite.h:29
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_NATIONDLG
@ BACKGROUND_CHOOSEGOVERNMENTDLG
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:24
@ COLOR_THEME_ADVANCEDTERRAINDLG_TEXT
Definition themecolors.h:46
@ COLOR_THEME_UNITUPGRADE_TEXT
@ COLOR_THEME_NATIONDLG_LEGEND
@ COLOR_THEME_UNITDISBAND_TEXT
@ COLOR_THEME_NATIONDLG_TEXT
@ COLOR_THEME_NATIONDLG_FRAME
struct theme * active_theme
Definition themespec.c:154
void del_widget_pointer_from_gui_list(struct widget *gui)
Definition widget.c:622
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:602
void add_to_gui_list(widget_id id, struct widget *gui)
Definition widget.c:586
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_PRESSED
Definition widget.h:98
@ FC_WS_SELECTED
Definition widget.h:97
#define disable(id)
Definition widget.h:229
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_FREE_GFX
Definition widget.h:70
@ WF_ICON_CENTER
Definition widget.h:83
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_ICON_ABOVE_TEXT
Definition widget.h:81
@ WF_FREE_DATA
Definition widget.h:78
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define enable(id)
Definition widget.h:223
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
struct widget * create_icon_button(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_icon_button_from_chars_fonto(icon, pdest, char_string, fonto, flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
void remake_label_size(struct widget *label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
#define create_active_iconlabel(buf, pdest, pstr, pstring, cb)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1061
void popdown_worklist_editor(void)
Definition wldlg.c:1870
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5134
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
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)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:434
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:675
static int index_to_map_pos_y(int mindex)
Definition map.h:772
static int index_to_map_pos_x(int mindex)
Definition map.h:759
void center_tile_mapcanvas(const struct tile *ptile)
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, float zoom, const struct tile *ptile)
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
#define fc_malloc(sz)
Definition mem.h:34
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1066
static mpgui * gui
Definition mpgui_qt.cpp:53
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:295
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:472
int nation_set_index(const struct nation_set *pset)
Definition nation.c:698
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:231
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:815
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:201
int nation_set_count(void)
Definition nation.c:690
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:853
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:495
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:287
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:670
#define nations_iterate_end
Definition nation.h:364
#define nations_iterate(NAME_pnation)
Definition nation.h:361
const struct option_set * server_optset
Definition options.c:4369
bool option_str_set(struct option *poption, const char *str)
Definition options.c:977
const char * option_str_get(const struct option *poption)
Definition options.c:944
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:482
void set_government_choice(struct government *government)
Definition packhand.c:2395
char * lines
Definition packhand.c:132
int len
Definition packhand.c:128
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1217
int player_number(const struct player *pplayer)
Definition player.c:826
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:1451
#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:318
struct government * government_during_revolution
Definition game.h:94
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
int id1
Definition widget.h:104
int id0
Definition widget.h:103
SDL_Surface * surface
Definition graphics.h:229
unsigned char selected_leader
Definition dialogs.c:2575
struct widget * pset_prev
Definition dialogs.c:2585
struct widget * name_next
Definition dialogs.c:2581
struct widget * name_edit
Definition dialogs.c:2580
bool leader_sex
Definition dialogs.c:2577
struct nation_set * set
Definition dialogs.c:2578
struct widget * change_sex
Definition dialogs.c:2579
unsigned char nation_style
Definition dialogs.c:2574
struct widget * pset_next
Definition dialogs.c:2584
Nation_type_id nation
Definition dialogs.c:2576
struct widget * name_prev
Definition dialogs.c:2582
struct widget * pset_name
Definition dialogs.c:2583
char * headline
Definition dialogs.c:215
struct tile * ptile
Definition dialogs.c:217
struct widget * close_button
Definition dialogs.c:226
struct widget * label
Definition dialogs.c:227
struct widget * window
Definition dialogs.c:225
struct notify_goto_list * datas
Definition dialogs.c:228
struct widget * up_left_button
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h:140
int id
Definition unit.h:147
int hp
Definition unit.h:153
int veteran
Definition unit.h:154
Uint8 style
Definition gui_string.h:53
char * text
Definition gui_string.h:60
void * ptr
Definition widget.h:133
widget_id id
Definition widget.h:155
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
struct widget * prev
Definition widget.h:114
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
union widget::@220 data
struct widget * next
Definition widget.h:113
utf8_str * info_label
Definition widget.h:122
SDL_Rect size
Definition widget.h:145
struct civ_map map
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:204
#define styles_iterate(_p)
Definition style.h:48
#define styles_iterate_end
Definition style.h:54
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:553
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1376
const char * popup_info_text(struct tile *ptile)
Definition text.c:147
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_index(_pt_)
Definition tile.h:89
#define tile_terrain(_tile)
Definition tile.h:115
#define TILE_XY(ptile)
Definition tile.h:43
#define tile_has_extra(ptile, pextra)
Definition tile.h:152
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7841
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:791
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7849
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:2115
bool can_unit_paradrop(const struct civ_map *nmap, const struct unit *punit)
Definition unit.c:865
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1211
#define unit_tile(_pu)
Definition unit.h:407
static bool is_non_attack_unit_tile(const struct tile *ptile, const struct player *pplayer)
Definition unit.h:469
@ ORDER_LAST
Definition unit.h:50
#define unit_owner(_pu)
Definition unit.h:406
unit_upgrade_result
Definition unit.h:61
@ UU_OK
Definition unit.h:62
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2642
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Definition unittype.c:215
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:102
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1586
float map_zoom
Definition zoom.c:25