Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/dialogs.c Source File

Freeciv-3.1

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