Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl3/dialogs.c Source File

Freeciv-3.3

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