Freeciv-3.2
Loading...
Searching...
No Matches
citydlg.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 citydlg.c - description
16 -------------------
17 begin : Wed Sep 04 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "astring.h"
35#include "bitvector.h"
36#include "fcintl.h"
37#include "log.h"
38
39/* common */
40#include "game.h"
41#include "movement.h"
42#include "specialist.h"
43#include "unitlist.h"
44
45/* client */
46#include "client_main.h"
47#include "climisc.h"
48#include "control.h"
49#include "text.h"
50
51/* gui-sdl2 */
52#include "cityrep.h"
53#include "cma_fe.h"
54#include "colors.h"
55#include "dialogs.h"
56#include "graphics.h"
57#include "gui_id.h"
58#include "gui_main.h"
59#include "gui_tilespec.h"
60#include "mapview.h"
61#include "menu.h"
62#include "sprite.h"
63#include "themespec.h"
64#include "widget.h"
65#include "wldlg.h"
66
67#include "citydlg.h"
68
69/* ============================================================= */
70
71static struct city_dialog {
72 struct city *pcity;
73
74 enum {
81
82 /* main window group list */
85
86 /* Imprvm. vscrollbar */
88
89 /* Penel group list */
91
92 /* Menu imprv. dlg. */
95
96 /* shortcuts */
101
103
105
106 bool lock;
108
112
113static float city_map_zoom = 1;
114
116
117static void popdown_hurry_production_dialog(void);
118static void disable_city_dlg_widgets(void);
119static void redraw_city_dialog(struct city *pcity);
120static void rebuild_imprm_list(struct city *pcity);
121static void rebuild_citydlg_title_str(struct widget *pwindow, struct city *pcity);
122
123/* ======================================================================= */
124
125/**********************************************************************/
132struct impr_type *get_building_for_effect(enum effect_type effect_type)
133{
134 improvement_iterate(pimprove) {
135 if (building_has_effect(pimprove, effect_type)) {
136 return pimprove;
137 }
139
140 return NULL;
141}
142
143/**********************************************************************/
158
159/**********************************************************************/
194
195/**********************************************************************/
199static int city_dlg_callback(struct widget *pwindow)
200{
204
205 if (is_in_rect_area(main_data.event.motion.x, main_data.event.motion.y,
206 &(pcity_dlg->spec_area))) {
208 (main_data.event.motion.x - pcity_dlg->spec_area.x)
210
211 return -1;
212 }
213 }
214
215 if (!pcity_dlg->lock) {
216 if (pcity_dlg->panel) {
220 widget_flush(pwindow);
221 } else {
223 widget_flush(pwindow);
224 }
225 }
226 }
227 }
228
229 return -1;
230}
231
232/* ===================================================================== */
233/* ========================== Units Orders Menu ======================== */
234/* ===================================================================== */
235
236/**********************************************************************/
253
254/**********************************************************************/
258{
260 struct unit *punit = button->data.unit;
261
263 if (punit) {
265 }
266 }
267
268 return -1;
269}
270
271/**********************************************************************/
293
294/**********************************************************************/
298{
300 struct unit *punit = button->data.unit;
301
303 if (punit) {
305 }
306 }
307
308 return -1;
309}
310
311/**********************************************************************/
315{
317 struct unit *punit = button->data.unit;
318
320 if (punit) {
322 }
323 }
324
325 return -1;
326}
327
328/**********************************************************************/
332{
334 struct unit *punit = button->data.unit;
335
338 }
339
340 return -1;
341}
342
343/**********************************************************************/
347{
349 struct unit *punit = button->data.unit;
350
352 if (punit) {
354 }
355 }
356
357 return -1;
358}
359
360/**********************************************************************/
364{
366 struct unit *punit = button->data.unit;
367
370 }
371
372 return -1;
373}
374
375/**********************************************************************/
378static int units_orders_dlg_callback(struct widget *button)
379{
380 return -1;
381}
382
383/**********************************************************************/
386static int units_orders_city_dlg_callback(struct widget *button)
387{
389 && main_data.event.button.button == SDL_BUTTON_RIGHT);
390
392 utf8_str *pstr;
393 char cbuf[80];
394 struct widget *buf, *pwindow;
395 struct unit *punit;
396 const struct unit_type *putype;
397 Uint16 i = 0, hh = 0;
398 SDL_Rect area;
399
401
402 if (punit == NULL || !can_client_issue_orders()) {
403 return -1;
404 }
405
406 if (right_button) {
410
411 return -1;
412 }
413
414 /* Disable city dlg */
417
419
420 /* Window */
421 fc_snprintf(cbuf, sizeof(cbuf), "%s:", _("Unit commands"));
423 pstr->style |= TTF_STYLE_BOLD;
424 pwindow = create_window_skeleton(NULL, pstr, 0);
425
427 set_wstate(pwindow, FC_WS_NORMAL);
430
431 area = pwindow->area;
432
433 /* Unit description */
434 fc_snprintf(cbuf, sizeof(cbuf), "%s", unit_description(punit));
436 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
438 pwindow->dst, pstr, WF_FREE_THEME);
439 area.w = MAX(area.w, buf->size.w);
441
442 /* Activate unit */
444 _("Activate unit"),
445 FONTO_ATTENTION, 0);
446 i++;
447 area.w = MAX(area.w, buf->size.w);
448 hh = MAX(hh, buf->size.h);
450 buf->data = button->data;
452 add_to_gui_list(button->id, buf);
453
454 /* Activate unit, close dlg. */
456 _("Activate unit, close dialog"),
457 FONTO_ATTENTION, 0);
458 i++;
459 area.w = MAX(area.w, buf->size.w);
460 hh = MAX(hh, buf->size.h);
462 buf->data = button->data;
464 add_to_gui_list(button->id, buf);
465 /* ----- */
466
467 if (pcity_dlg->page == ARMY_PAGE) {
468 /* Sentry unit */
470 _("Sentry unit"),
471 FONTO_ATTENTION, 0);
472 i++;
473 area.w = MAX(area.w, buf->size.w);
474 hh = MAX(hh, buf->size.h);
475 buf->data = button->data;
480 }
481 add_to_gui_list(button->id, buf);
482 /* ----- */
483
484 /* Fortify unit */
486 _("Fortify unit"),
487 FONTO_ATTENTION, 0);
488 i++;
489 area.w = MAX(area.w, buf->size.w);
490 hh = MAX(hh, buf->size.h);
491 buf->data = button->data;
496 }
497 add_to_gui_list(button->id, buf);
498 }
499 /* ----- */
500
501 /* Disband unit */
503 _("Disband unit"),
504 FONTO_ATTENTION, 0);
505 i++;
506 area.w = MAX(area.w, buf->size.w);
507 hh = MAX(hh, buf->size.h);
508 buf->data = button->data;
511 add_to_gui_list(button->id, buf);
512 /* ----- */
513
514 if (pcity_dlg->page == ARMY_PAGE) {
515 if (punit->homecity != pcity_dlg->pcity->id) {
516 /* Make new Homecity */
519 FONTO_ATTENTION, 0);
520 i++;
521 area.w = MAX(area.w, buf->size.w);
522 hh = MAX(hh, buf->size.h);
523 buf->data = button->data;
526 add_to_gui_list(button->id, buf);
527 }
528 /* ----- */
529
531 /* Upgrade unit */
533 _("Upgrade unit"),
534 FONTO_ATTENTION, 0);
535 i++;
536 area.w = MAX(area.w, buf->size.w);
537 hh = MAX(hh, buf->size.h);
538 buf->data = button->data;
541 add_to_gui_list(button->id, buf);
542 }
543 }
544
545 /* ----- */
546 /* Cancel */
548 _("Cancel"),
549 FONTO_ATTENTION, 0);
550 i++;
551 area.w = MAX(area.w, buf->size.w);
552 hh = MAX(hh, buf->size.h);
553 buf->key = SDLK_ESCAPE;
556 add_to_gui_list(button->id, buf);
558
559 /* ================================================== */
561 /* ================================================== */
562
563 area.w += adj_size(10);
564 hh += adj_size(4);
565
566 /* Create window background */
568 (pwindow->size.w - pwindow->area.w) + area.w,
569 (pwindow->size.h - pwindow->area.h) + pwindow->prev->size.h +
570 (i * hh) + adj_size(5));
571
572 area = pwindow->area;
573
574 widget_set_position(pwindow,
575 button->size.x + adj_size(2),
576 pwindow->area.y + button->size.y + 1);
577
578 /* Label */
579 buf = pwindow->prev;
580 buf->size.w = area.w;
581 buf->size.x = area.x;
582 buf->size.y = area.y + 1;
583 buf = buf->prev;
584
585 /* First button */
586 buf->size.w = area.w;
587 buf->size.h = hh;
588 buf->size.x = area.x;
589 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
590 buf = buf->prev;
591
592 while (buf != NULL) {
593 buf->size.w = area.w;
594 buf->size.h = hh;
595 buf->size.x = buf->next->size.x;
596 buf->size.y = buf->next->size.y + buf->next->size.h;
598 break;
599 }
600 buf = buf->prev;
601 }
602
603 /* ================================================== */
604 /* Redraw */
606 widget_flush(pwindow);
607 }
608
609 return -1;
610}
611
612/* ======================================================================= */
613/* ======================= City Dlg. Panels ============================== */
614/* ======================================================================= */
615
616/**********************************************************************/
619static SDL_Surface *create_unit_surface(struct unit *punit, bool support,
620 int w, int h)
621{
624 struct canvas *destcanvas;
625 const struct civ_map *nmap = &(wld.map);
626
629
630 put_unit(punit, destcanvas, 1.0, 0, 0);
631
632 /* Get unit sprite width, and crop top. Bottom might get restored in 'support'
633 * case below. */
635
636 if (support) {
637 int i, step;
638 int free_unhappy;
639 int happy_cost;
640 SDL_Rect dest;
642
643 /* Support also layouts placing support icons higher than unit. */
644 src_rect.y = MIN(src_rect.y, offset);
645 /* Restore bottom space when needed for support icons. */
646 src_rect.h = destcanvas->surf->h - src_rect.y;
647
650
652 punit->upkeep[O_GOLD] + happy_cost;
653
654 if (i * icons->food->w > src_rect.w / 2) {
655 step = (src_rect.w / 2 - icons->food->w) / (i - 1);
656 } else {
657 step = icons->food->w;
658 }
659
661 dest.x = src_rect.x + src_rect.w / 8;
662
663 for (i = 0; i < punit->upkeep[O_SHIELD]; i++) {
664 alphablit(icons->shield, NULL, destcanvas->surf, &dest, 255);
665 dest.x += step;
666 }
667
668 for (i = 0; i < punit->upkeep[O_FOOD]; i++) {
669 alphablit(icons->food, NULL, destcanvas->surf, &dest, 255);
670 dest.x += step;
671 }
672
673 for (i = 0; i < punit->upkeep[O_GOLD]; i++) {
674 alphablit(icons->coint, NULL, destcanvas->surf, &dest, 255);
675 dest.x += step;
676 }
677
678 for (i = 0; i < happy_cost; i++) {
679 alphablit(icons->face, NULL, destcanvas->surf, &dest, 255);
680 dest.x += step;
681 }
682
683 }
684
686 alphablit(destcanvas->surf, &src_rect, psurf, NULL, 255);
687
689
690 if (w != src_rect.w || h != src_rect.h) {
692
695 psurf = pzoomed;
696 }
697
698 return psurf;
699}
700
701/**********************************************************************/
706static void create_present_supported_units_widget_list(struct unit_list *units)
707{
708 int i;
709 struct widget *buf = NULL;
710 struct widget *end = NULL;
711 struct widget *pwindow = pcity_dlg->end_city_widget_list;
712 struct city *home_city;
713 const struct unit_type *putype;
714 SDL_Surface *surf;
715 utf8_str *pstr;
716 char cbuf[256];
717 int num_x, num_y, w, h;
718
719 i = 0;
720
722 if (num_x < 4) {
723 num_x = 4;
724 w = adj_size(160 - 4*4) / 4;
725 } else {
727 }
728
730 if (num_y < 4) {
731 num_y = 4;
732 h = adj_size(151 - 4*4) / 4;
733 } else {
735 }
736
737 unit_list_iterate(units, punit) {
738 const char *vetname;
740
745 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d,%d,%s)%s%s\n%s\n(%d/%d)\n%s",
747 putype->attack_strength,
748 putype->defense_strength,
749 move_points_text(putype->move_rate, FALSE),
750 (vetname != NULL ? "\n" : ""),
751 (vetname != NULL ? vetname : ""),
753 punit->hp, putype->hp,
754 home_city ? home_city->name : Q_("?homecity:None"));
756
757 if (pcity_dlg->page == SUPPORTED_UNITS_PAGE) {
758 int city_near_dist;
760
761 sz_strlcat(cbuf, "\n");
763 surf = adj_surf(create_unit_surface(punit, TRUE, w, h));
764 } else {
765 surf = adj_surf(create_unit_surface(punit, FALSE, w, h));
766 }
767
769 pstr->style |= SF_CENTER;
770
771 buf = create_icon2(surf, pwindow->dst, WF_FREE_THEME
773 buf->info_label = pstr;
774 buf->data.unit = punit;
776
777 if (!end) {
778 end = buf;
779 }
780
781 if (++i > num_x * num_y) {
783 }
784
787 }
788
791
792 pcity_dlg->panel = fc_calloc(1, sizeof(struct advanced_dialog));
798
800 pwindow->area.x + adj_size(5),
801 pwindow->area.y + adj_size(44),
804
805 if (i > num_x * num_y) {
807 num_x, num_y, TRUE, TRUE);
808
810 pwindow->area.x + adj_size(185),
811 pwindow->area.y + adj_size(45),
812 adj_size(150), TRUE);
813 }
814}
815
816/**********************************************************************/
828
829/**********************************************************************/
832static int army_city_dlg_callback(struct widget *button)
833{
835 if (pcity_dlg->page != ARMY_PAGE) {
837 pcity_dlg->page = ARMY_PAGE;
839 flush_dirty();
840 } else {
841 widget_redraw(button);
842 widget_flush(button);
843 }
844 }
845
846 return -1;
847}
848
849/**********************************************************************/
852static int supported_unit_city_dlg_callback(struct widget *button)
853{
855 if (pcity_dlg->page != SUPPORTED_UNITS_PAGE) {
857 pcity_dlg->page = SUPPORTED_UNITS_PAGE;
859 flush_dirty();
860 } else {
861 widget_redraw(button);
862 widget_flush(button);
863 }
864 }
865
866 return -1;
867}
868
869/* ---------------------- */
870
871/**********************************************************************/
874static int info_city_dlg_callback(struct widget *button)
875{
877 if (pcity_dlg->page != INFO_PAGE) {
879 pcity_dlg->page = INFO_PAGE;
881 flush_dirty();
882 } else {
883 widget_redraw(button);
884 widget_flush(button);
885 }
886 }
887
888 return -1;
889}
890
891/* ---------------------- */
892/**********************************************************************/
895static int happy_city_dlg_callback(struct widget *button)
896{
898 if (pcity_dlg->page != HAPPINESS_PAGE) {
902 flush_dirty();
903 } else {
904 widget_redraw(button);
905 widget_flush(button);
906 }
907 }
908
909 return -1;
910}
911
912/**********************************************************************/
915static int misc_panel_city_dlg_callback(struct widget *pwidget)
916{
919
920 switch (MAX_ID - pwidget->id) {
921 case 0x10:
924 } else {
926 }
927 break;
928 case 0x20:
931 } else {
933 }
936 } else {
938 }
939
940 pwidget->theme2 = get_tax_surface(O_GOLD);
941 pwidget->id = MAX_ID - 0x40;
942 widget_redraw(pwidget);
943 widget_flush(pwidget);
944 break;
945 case 0x40:
948 pwidget->theme2 = get_tax_surface(O_LUXURY);
949 pwidget->id = MAX_ID - 0x60;
950 widget_redraw(pwidget);
951 widget_flush(pwidget);
952 break;
953 case 0x60:
956 } else {
958 }
959
960 pwidget->theme2 = get_tax_surface(O_SCIENCE);
961 pwidget->id = MAX_ID - 0x20;
962 widget_redraw(pwidget);
963 widget_flush(pwidget);
964 break;
965 }
966
969 }
970
971 return -1;
972}
973
974/**********************************************************************/
977static void create_city_options_widget_list(struct city *pcity)
978{
979 struct widget *buf, *pwindow = pcity_dlg->end_city_widget_list;
980 SDL_Surface *surf;
981 utf8_str *pstr;
982 char cbuf[80];
983
984 fc_snprintf(cbuf, sizeof(cbuf),
985 _("Allow unit production\nto disband city"));
987 pstr->style |= TTF_STYLE_BOLD;
989
990 buf =
991 create_textcheckbox(pwindow->dst,
996 add_to_gui_list(MAX_ID - 0x10, buf);
997 buf->size.x = pwindow->area.x + adj_size(7);
998 buf->size.y = pwindow->area.y + adj_size(45);
999
1000 /* ----- */
1001
1002 pcity_dlg->panel = fc_calloc(1, sizeof(struct advanced_dialog));
1004
1005 /* ----- */
1006
1007 fc_snprintf(cbuf, sizeof(cbuf), "%s:", _("New citizens produce"));
1009 pstr->style |= SF_CENTER;
1010
1012 surf = get_tax_surface(O_SCIENCE);
1013 buf = create_icon_button(surf, pwindow->dst, pstr,
1015 add_to_gui_list(MAX_ID - 0x20, buf);
1016 } else {
1018 surf = get_tax_surface(O_GOLD);
1019 buf = create_icon_button(surf, pwindow->dst,
1021 add_to_gui_list(MAX_ID - 0x40, buf);
1022 } else {
1023 surf = get_tax_surface(O_LUXURY);
1024 buf = create_icon_button(surf, pwindow->dst,
1026 add_to_gui_list(MAX_ID - 0x60, buf);
1027 }
1028 }
1029
1030 buf->size.w = adj_size(177);
1033
1034 buf->size.x = buf->next->size.x;
1035 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
1037}
1038
1039/**********************************************************************/
1042static int options_city_dlg_callback(struct widget *button)
1043{
1045 if (pcity_dlg->page != MISC_PAGE) {
1047 pcity_dlg->page = MISC_PAGE;
1049 flush_dirty();
1050 } else {
1051 widget_redraw(button);
1052 widget_flush(button);
1053 }
1054 }
1055
1056 return -1;
1057}
1058
1059/* ======================================================================= */
1060
1061/**********************************************************************/
1064static int cma_city_dlg_callback(struct widget *button)
1065{
1069 }
1070
1071 return -1;
1072}
1073
1074/**********************************************************************/
1077static int exit_city_dlg_callback(struct widget *button)
1078{
1081 }
1082
1083 return -1;
1084}
1085
1086/* ======================================================================= */
1087/* ======================== Buy Production Dlg. ========================== */
1088/* ======================================================================= */
1089
1090/**********************************************************************/
1094{
1097
1098 if (pcity_dlg) {
1099 /* enable city dlg */
1101 }
1102 }
1103
1104 return -1;
1105}
1106
1107/**********************************************************************/
1110static int ok_buy_prod_city_dlg_callback(struct widget *button)
1111{
1113 struct city *pcity = button->data.city; /* Save it. */
1114
1116 city_buy_production(pcity);
1117
1118 if (pcity_dlg) {
1119 /* enable city dlg */
1121
1122 /* disable buy button */
1126 flush_dirty();
1127 }
1128 }
1129
1130 return -1;
1131}
1132
1133/**********************************************************************/
1136static int buy_prod_city_dlg_callback(struct widget *button)
1137{
1139 widget_redraw(button);
1140 widget_flush(button);
1143 }
1144
1145 return -1;
1146}
1147
1148/**********************************************************************/
1160
1161/**********************************************************************/
1164static int hurry_production_window_callback(struct widget *pwindow)
1165{
1168 }
1169
1170 return -1;
1171}
1172
1173/**********************************************************************/
1177{
1178 char tbuf[512], cbuf[512];
1179 struct widget *buf = NULL, *pwindow;
1180 utf8_str *pstr;
1181 SDL_Surface *text;
1182 SDL_Rect dst;
1183 int window_x = 0, window_y = 0;
1184 SDL_Rect area;
1185 const char *name = city_production_name_translation(pcity);
1186 int value = pcity->client.buy_cost;
1187
1188 if (hurry_prog_dlg) {
1189 return;
1190 }
1191
1192 fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
1193 "Treasury contains %d gold.",
1194 client_player()->economic.gold),
1195 client_player()->economic.gold);
1196
1197 hurry_prog_dlg = fc_calloc(1, sizeof(struct small_dialog));
1198
1199 if (city_can_buy(pcity)) {
1200 if (value <= client_player()->economic.gold) {
1201 fc_snprintf(cbuf, sizeof(cbuf),
1202 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
1203 PL_("Buy %s for %d gold?\n%s",
1204 "Buy %s for %d gold?\n%s", value),
1205 name, value, tbuf);
1206 } else {
1207 fc_snprintf(cbuf, sizeof(cbuf),
1208 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
1209 PL_("%s costs %d gold.\n%s",
1210 "%s costs %d gold.\n%s", value),
1211 name, value, tbuf);
1212 }
1213 } else {
1214 if (pcity->did_buy) {
1215 fc_snprintf(cbuf, sizeof(cbuf),
1216 _("Sorry, you have already bought here in this turn."));
1217 } else {
1218 fc_snprintf(cbuf, sizeof(cbuf),
1219 _("Sorry, you can't buy here in this turn."));
1220 }
1221 }
1222
1224 pstr->style |= TTF_STYLE_BOLD;
1225 pwindow = create_window_skeleton(NULL, pstr, 0);
1226 pwindow->action = hurry_production_window_callback;
1227 set_wstate(pwindow, FC_WS_NORMAL);
1228 add_to_gui_list(ID_WINDOW, pwindow);
1229
1231
1232 area = pwindow->area;
1233
1234 area.h += 1;
1235
1236 /* ============================================================= */
1237
1238 /* Label */
1240 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1242
1245 area.w = MAX(area.w , text->w);
1246 area.h += text->h + adj_size(5);
1247
1249 pwindow->dst, _("No"),
1250 FONTO_ATTENTION, 0);
1251
1254 buf->key = SDLK_ESCAPE;
1255 area.h += buf->size.h;
1256
1258
1259 if (city_can_buy(pcity) && (value <= client.conn.playing->economic.gold)) {
1261 pwindow->dst,
1262 _("Yes"),
1263 FONTO_ATTENTION, 0);
1264
1267 buf->data.city = pcity;
1268 buf->key = SDLK_RETURN;
1270 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1271 buf->next->size.w = buf->size.w;
1272 area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
1273 }
1274
1276
1277 /* Setup window size and start position */
1278 area.w += adj_size(10);
1279 area.h += adj_size(5);
1280
1282 (pwindow->size.w - pwindow->area.w) + area.w,
1283 (pwindow->size.h - pwindow->area.h) + area.h);
1284
1285 area = pwindow->area;
1286
1287 if (city_dialog_is_open(pcity)) {
1288 window_x = pcity_dlg->buy_button->size.x;
1289 window_y = pcity_dlg->buy_button->size.y - pwindow->size.h;
1290 } else if (is_city_report_open()) {
1292
1294 + pwindow->size.w > main_window_width()) {
1295 window_x = selected_widget->size.x - pwindow->size.w;
1296 } else {
1298 }
1299
1301 + (selected_widget->size.h - pwindow->size.h) / 2;
1302
1303 if (window_y + pwindow->size.h > main_window_height()) {
1304 window_y = main_window_height() - pwindow->size.h - 1;
1305 } else if (window_y < 0) {
1306 window_y = 0;
1307 }
1308 } else {
1309 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, pcity->tile);
1310 }
1311
1313
1314 /* Setup rest of widgets */
1315 /* Label */
1316 dst.x = area.x + (area.w - text->w) / 2;
1317 dst.y = area.y + 1;
1318 alphablit(text, NULL, pwindow->theme, &dst, 255);
1319 dst.y += text->h + adj_size(5);
1320 FREESURFACE(text);
1321
1322 /* No */
1323 buf = pwindow->prev;
1324 buf->size.y = dst.y;
1325
1326 if (city_can_buy(pcity) && value <= client.conn.playing->economic.gold) {
1327 /* Yes */
1328 buf = buf->prev;
1329 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
1330 buf->size.y = dst.y;
1331
1332 /* No */
1333 buf->next->size.x = buf->size.x + buf->size.w + adj_size(20);
1334 } else {
1335 /* No */
1336 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
1337 }
1338
1339 /* ================================================== */
1340 /* Redraw */
1342 widget_mark_dirty(pwindow);
1343 flush_dirty();
1344}
1345
1346/* =======================================================================*/
1347/* ========================== CHANGE PRODUCTION ==========================*/
1348/* =======================================================================*/
1349
1350/**********************************************************************/
1353static int change_prod_dlg_callback(struct widget *button)
1354{
1356 widget_redraw(button);
1357 widget_flush(button);
1358
1361 }
1362
1363 return -1;
1364}
1365
1366/* =======================================================================*/
1367/* ========================== SELL IMPROVEMENTS ==========================*/
1368/* =======================================================================*/
1369
1370/**********************************************************************/
1386
1387/**********************************************************************/
1390static int sell_imprvm_dlg_ok_callback(struct widget *ok_button)
1391{
1393 struct widget *tmp = (struct widget *)ok_button->data.ptr;
1394
1396
1397 /* popdown, we don't redraw and flush because this is made by redraw city dlg.
1398 when response from server comes */
1401
1403
1404 /* del imprv from widget list */
1406
1408
1412 }
1413
1415 flush_dirty();
1416 }
1417
1418 return -1;
1419}
1420
1421/**********************************************************************/
1424static int sell_imprvm_dlg_callback(struct widget *impr)
1425{
1427 utf8_str *pstr = NULL;
1428 struct widget *label = NULL;
1429 struct widget *pwindow = NULL;
1430 struct widget *cancel_button = NULL;
1431 struct widget *ok_button = NULL;
1432 char cbuf[80];
1433 int id;
1434 SDL_Rect area;
1435 int price;
1436
1439
1441 pstr->style |= TTF_STYLE_BOLD;
1442 pwindow = create_window_skeleton(NULL, pstr, 0);
1443 /*pwindow->action = move_sell_imprvm_dlg_callback; */
1444 /*set_wstate(pwindow, FC_WS_NORMAL); */
1445 add_to_gui_list(ID_WINDOW, pwindow);
1447
1448 area = pwindow->area;
1449
1450 /* Create text label */
1451 id = MAX_ID - 3000 - impr->id;
1452
1454 fc_snprintf(cbuf, sizeof(cbuf), PL_("Sell %s for %d gold?",
1455 "Sell %s for %d gold?", price),
1458 price);
1460 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1462 label = create_iconlabel(NULL, pwindow->dst, pstr, 0);
1463 add_to_gui_list(ID_LABEL, label);
1464
1465 /* Create cancel button */
1466 cancel_button =
1468 pwindow->dst, _("Cancel"),
1469 FONTO_DEFAULT, 0);
1470 cancel_button->action = sell_imprvm_dlg_cancel_callback;
1471 cancel_button->key = SDLK_ESCAPE;
1472 set_wstate(cancel_button, FC_WS_NORMAL);
1473 add_to_gui_list(ID_BUTTON, cancel_button);
1474
1475 /* create ok button */
1477 pwindow->dst, _("Sell"),
1478 FONTO_DEFAULT, 0);
1479 ok_button->data.ptr = (void *)impr;
1480 ok_button->size.w = cancel_button->size.w;
1482 ok_button->key = SDLK_RETURN;
1483 set_wstate(ok_button, FC_WS_NORMAL);
1484 add_to_gui_list(ID_BUTTON, ok_button);
1485
1487
1488 /* correct sizes */
1489 if ((ok_button->size.w + cancel_button->size.w + adj_size(30)) >
1490 label->size.w + adj_size(20)) {
1491 area.w = MAX(area.w, ok_button->size.w + cancel_button->size.w + adj_size(30));
1492 } else {
1493 area.w = MAX(area.w, label->size.w + adj_size(20));
1494 }
1495
1496 area.h = MAX(area.h, ok_button->size.h + label->size.h + adj_size(25));
1497
1498 /* create window background */
1500 (pwindow->size.w - pwindow->area.w) + area.w,
1501 (pwindow->size.h - pwindow->area.h) + area.h);
1502
1503 area = pwindow->area;
1504
1505 /* set start positions */
1506 widget_set_position(pwindow,
1507 (main_window_width() - pwindow->size.w) / 2,
1508 (main_window_height() - pwindow->size.h) / 2 + adj_size(10));
1509
1510 ok_button->size.x = area.x + adj_size(10);
1511 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
1512
1513 cancel_button->size.y = ok_button->size.y;
1514 cancel_button->size.x = area.x + area.w - cancel_button->size.w - adj_size(10);
1515
1516 label->size.x = area.x;
1517 label->size.y = area.y + adj_size(4);
1518 label->size.w = area.w;
1519
1520 /* redraw */
1523
1524 widget_mark_dirty(pwindow);
1525 flush_dirty();
1526 }
1527
1528 return -1;
1529}
1530/* ====================================================================== */
1531
1532/**********************************************************************/
1536{
1537 if (pcity_dlg) {
1540
1542 if (pcity_dlg->imprv->scroll) {
1546 }
1547
1548 /* There is common function test_player_sell_building_now(),
1549 * but we are not using it here, since we want to use set_group_state()
1550 * when possible */
1555 } else {
1557
1558 while (TRUE) {
1559 struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 -
1560 tmp_widget->id);
1561
1564 } else {
1566 }
1567
1569 break;
1570 }
1571
1572 tmp_widget = tmp_widget->prev;
1573
1574 } /* while */
1575 }
1576 }
1577
1580 }
1581
1582 if (pcity_dlg->panel) {
1585 }
1586
1589 }
1590
1591 pcity_dlg->lock = FALSE;
1592 }
1593}
1594
1595/**********************************************************************/
1614
1615/* ======================================================================== */
1616
1617/**********************************************************************/
1621{
1623
1624 city_map_zoom = ((buf->w * 159 > buf->h * 249) ?
1625 (float)adj_size(249) / buf->w
1626 : (float)adj_size(159) / buf->h);
1627
1629}
1630
1631/**********************************************************************/
1635{
1637 int col, row;
1638
1639 if (canvas_to_city_pos(&col, &row,
1641 1 / city_map_zoom * (main_data.event.motion.x - map->dst->dest_rect.x
1642 - map->size.x),
1643 1 / city_map_zoom * (main_data.event.motion.y - map->dst->dest_rect.y
1644 - map->size.y))) {
1645
1647 }
1648 }
1649
1650 return -1;
1651}
1652
1653/* ====================================================================== */
1654
1655/**********************************************************************/
1658static int city_comp_by_turn_founded(const void *a, const void *b)
1659{
1660 struct city *pcity1 = *((struct city **) a);
1661 struct city *pcity2 = *((struct city **) b);
1662
1663 return pcity1->turn_founded - pcity2->turn_founded;
1664}
1665
1666/**********************************************************************/
1669static int next_prev_city_dlg_callback(struct widget *button)
1670{
1672 struct city **array;
1673 int i, dir, non_open_size;
1675
1676 fc_assert_ret_val(size >= 1, -1);
1678 == client.conn.playing, -1);
1679
1680 if (size == 1) {
1681 return -1;
1682 }
1683
1684 /* dir = 1 will advance to the city, dir = -1 will get previous */
1685 if (button->id == ID_CITY_DLG_NEXT_BUTTON) {
1686 dir = 1;
1687 } else {
1688 if (button->id == ID_CITY_DLG_PREV_BUTTON) {
1689 dir = -1;
1690 } else {
1691 /* Always fails. */
1693 || button->id != ID_CITY_DLG_PREV_BUTTON, -1);
1694 dir = 1;
1695 }
1696 }
1697
1698 array = fc_calloc(1, size * sizeof(struct city *));
1699
1700 non_open_size = 0;
1701 for (i = 0; i < size; i++) {
1703 }
1704
1706
1707 if (non_open_size <= 1) {
1708 FC_FREE(array);
1709 return -1;
1710 }
1711
1712 qsort(array, non_open_size, sizeof(struct city *),
1714
1715 for (i = 0; i < non_open_size; i++) {
1716 if (pcity_dlg->pcity == array[i]) {
1717 break;
1718 }
1719 }
1720
1722 pcity_dlg->pcity = array[(i + dir + non_open_size) % non_open_size];
1723 FC_FREE(array);
1724
1725 /* free panel widgets */
1727 /* refresh resource map */
1731
1732 /* redraw */
1734 flush_dirty();
1735 }
1736
1737 return -1;
1738}
1739
1740/**********************************************************************/
1743static int new_name_city_dlg_callback(struct widget *pedit)
1744{
1745 if (pedit->string_utf8->text != NULL) {
1749 }
1750 } else {
1751 /* Empty input -> restore previous content */
1753 widget_redraw(pedit);
1754 widget_mark_dirty(pedit);
1755 flush_dirty();
1756 }
1757
1758 return -1;
1759}
1760
1761/* ======================================================================= */
1762/* ======================== Redrawing City Dlg. ========================== */
1763/* ======================================================================= */
1764
1765/**********************************************************************/
1783
1784/**********************************************************************/
1789 struct city *pcity)
1790{
1791 char cbuf[60];
1792 utf8_str *pstr;
1793 SDL_Surface *surf;
1794 SDL_Rect dest;
1795
1796 fc_snprintf(cbuf, sizeof(cbuf), _("City options"));
1797
1800 pstr->style |= TTF_STYLE_BOLD;
1801
1803
1804 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1805 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1806
1807 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1808
1809 FREESURFACE(surf);
1811
1812 if (!pcity_dlg->panel) {
1814 }
1817}
1818
1819/**********************************************************************/
1824 struct city *pcity)
1825{
1826 char cbuf[60];
1827 utf8_str *pstr;
1828 SDL_Surface *surf;
1829 SDL_Rect dest;
1830 struct unit_list *units;
1831 int size;
1832
1835 } else {
1836 units = (pcity_dlg->pcity->units_supported);
1837 }
1838
1839 size = unit_list_size(units);
1840
1841 fc_snprintf(cbuf, sizeof(cbuf), _("Supported units: %d"), size);
1842
1845 pstr->style |= TTF_STYLE_BOLD;
1846
1848
1849 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1850 dest.y = city_window->area.y + + adj_size(4) + current_theme->info_icon->h;
1851
1852 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1853
1854 FREESURFACE(surf);
1856
1857 if (pcity_dlg->panel) {
1858 if (size > 0) {
1861 } else {
1866 }
1867 } else {
1868 if (size > 0) {
1872 }
1873 }
1874}
1875
1876/**********************************************************************/
1881 struct city *pcity)
1882{
1883 char cbuf[60];
1884 utf8_str *pstr;
1885 SDL_Surface *surf;
1886 SDL_Rect dest;
1887 struct unit_list *units;
1888 int size;
1889
1892 } else {
1893 units = pcity_dlg->pcity->tile->units;
1894 }
1895
1896 size = unit_list_size(units);
1897
1898 fc_snprintf(cbuf, sizeof(cbuf), _("Present units: %d"), size);
1899
1902 pstr->style |= TTF_STYLE_BOLD;
1903
1905
1906 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1907 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1908
1909 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1910
1911 FREESURFACE(surf);
1913
1914 if (pcity_dlg->panel) {
1915 if (size) {
1918 } else {
1923 }
1924 } else {
1925 if (size) {
1929 }
1930 }
1931}
1932
1933/**********************************************************************/
1938 struct city *pcity)
1939{
1940 char cbuf[30];
1941 struct city *trade_city = NULL;
1942 int step, i, xx;
1943 utf8_str *pstr = NULL;
1944 SDL_Surface *surf = NULL;
1945 SDL_Rect dest;
1946
1947 fc_snprintf(cbuf, sizeof(cbuf), _("City info"));
1950 pstr->style |= TTF_STYLE_BOLD;
1951
1953
1954 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1955 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1956
1957 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1958
1959 dest.x = city_window->size.x + adj_size(10);
1960 dest.y += surf->h + 1;
1961
1962 FREESURFACE(surf);
1963
1966
1967 if (pcity->pollution) {
1968 fc_snprintf(cbuf, sizeof(cbuf), _("Pollution: %d"),
1969 pcity->pollution);
1970
1972
1974
1975 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1976
1977 dest.y += surf->h + adj_size(3);
1978
1979 FREESURFACE(surf);
1980
1981 if (((icons->pollution->w + 1) * pcity->pollution) > adj_size(187)) {
1982 step = (adj_size(187) - icons->pollution->w) / (pcity->pollution - 1);
1983 } else {
1984 step = icons->pollution->w + 1;
1985 }
1986
1987 for (i = 0; i < pcity->pollution; i++) {
1988 alphablit(icons->pollution, NULL, city_window->dst->surface, &dest, 255);
1989 dest.x += step;
1990 }
1991
1992 dest.x = city_window->size.x + adj_size(10);
1993 dest.y += icons->pollution->h + adj_size(3);
1994
1995 } else {
1996 fc_snprintf(cbuf, sizeof(cbuf), _("Pollution: none"));
1997
1999
2001
2002 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2003
2004 dest.y += surf->h + adj_size(3);
2005
2006 FREESURFACE(surf);
2007 }
2008
2009 if (game.info.illness_on) {
2010 int risk_pml = city_illness_calc(pcity, NULL, NULL, NULL, NULL);
2011
2012 fc_snprintf(cbuf, sizeof(cbuf), _("Plague risk: %.1f%%"),
2013 (double)risk_pml / 10.0);
2014 } else {
2015 fc_snprintf(cbuf, sizeof(cbuf), _("Plague risk: none"));
2016 }
2017
2020 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2021 dest.y += surf->h + adj_size(3);
2022 FREESURFACE(surf);
2023
2024 fc_snprintf(cbuf, sizeof(cbuf), _("Trade routes: "));
2025
2027
2029
2030 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2031
2032 xx = dest.x + surf->w;
2033 dest.y += surf->h + adj_size(3);
2034
2035 FREESURFACE(surf);
2036
2037 step = 0;
2038 dest.x = city_window->size.x + adj_size(10);
2039
2041 step += proute->value;
2042
2043 if ((trade_city = game_city_by_number(proute->partner))) {
2044 fc_snprintf(cbuf, sizeof(cbuf), "%s: +%d", city_name_get(trade_city),
2045 proute->value);
2046 } else {
2047 fc_snprintf(cbuf, sizeof(cbuf), "%s: +%d", _("Unknown"),
2048 proute->value);
2049 }
2050
2052
2054
2055 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2056
2057 /* Blit trade icon */
2058 dest.x += surf->w + adj_size(3);
2059 dest.y += adj_size(4);
2060 alphablit(icons->trade, NULL, city_window->dst->surface, &dest, 255);
2061 dest.x = city_window->size.x + adj_size(10);
2062 dest.y -= adj_size(4);
2063
2064 dest.y += surf->h;
2065
2066 FREESURFACE(surf);
2068
2069 if (step > 0) {
2070 fc_snprintf(cbuf, sizeof(cbuf), _("Trade: +%d"), step);
2071
2074 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2075
2076 dest.x += surf->w + adj_size(3);
2077 dest.y += adj_size(4);
2078 alphablit(icons->trade, NULL, city_window->dst->surface, &dest, 255);
2079
2080 FREESURFACE(surf);
2081 } else {
2082 fc_snprintf(cbuf, sizeof(cbuf), Q_("?trade:None"));
2083
2085
2087
2088 dest.x = xx;
2089 dest.y -= surf->h + adj_size(3);
2090 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2091
2092 FREESURFACE(surf);
2093 }
2094
2096}
2097
2098/**********************************************************************/
2104 struct city *pcity)
2105{
2106 char cbuf[30];
2107 int step, i, j, count;
2109 utf8_str *pstr = NULL;
2110 SDL_Surface *surf = NULL;
2111 SDL_Rect dest = {0, 0, 0, 0};
2113
2114 fc_snprintf(cbuf, sizeof(cbuf), _("Happiness"));
2115
2118 pstr->style |= TTF_STYLE_BOLD;
2119
2121
2122 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
2123 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
2124 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2125
2126 dest.x = city_window->size.x + adj_size(10);
2127 dest.y += surf->h + 1;
2128
2129 FREESURFACE(surf);
2131
2134 + city_specialists(pcity));
2135
2136 if (count * icons->male_happy->w > adj_size(166)) {
2137 step = (adj_size(166) - icons->male_happy->w) / (count - 1);
2138 } else {
2139 step = icons->male_happy->w;
2140 }
2141
2142 for (j = 0; j < FEELING_LAST; j++) {
2143 if (j == 0 || pcity->feel[CITIZEN_HAPPY][j - 1] != pcity->feel[CITIZEN_HAPPY][j]
2144 || pcity->feel[CITIZEN_CONTENT][j - 1] != pcity->feel[CITIZEN_CONTENT][j]
2145 || pcity->feel[CITIZEN_UNHAPPY][j - 1] != pcity->feel[CITIZEN_UNHAPPY][j]
2146 || pcity->feel[CITIZEN_ANGRY][j - 1] != pcity->feel[CITIZEN_ANGRY][j]) {
2147 int spe, spe_max;
2148
2149 if (j != 0) {
2150 create_line(city_window->dst->surface,
2151 dest.x, dest.y, dest.x + adj_size(176), dest.y,
2153 dest.y += adj_size(5);
2154 }
2155
2156 if (pcity->feel[CITIZEN_HAPPY][j]) {
2157 surf = icons->male_happy;
2158 for (i = 0; i < pcity->feel[CITIZEN_HAPPY][j]; i++) {
2159 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2160 dest.x += step;
2161 if (surf == icons->male_happy) {
2162 surf = icons->female_happy;
2163 } else {
2164 surf = icons->male_happy;
2165 }
2166 }
2167 }
2168
2169 if (pcity->feel[CITIZEN_CONTENT][j]) {
2170 surf = icons->male_content;
2171 for (i = 0; i < pcity->feel[CITIZEN_CONTENT][j]; i++) {
2172 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2173 dest.x += step;
2174 if (surf == icons->male_content) {
2175 surf = icons->female_content;
2176 } else {
2177 surf = icons->male_content;
2178 }
2179 }
2180 }
2181
2182 if (pcity->feel[CITIZEN_UNHAPPY][j]) {
2183 surf = icons->male_unhappy;
2184 for (i = 0; i < pcity->feel[CITIZEN_UNHAPPY][j]; i++) {
2185 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2186 dest.x += step;
2187 if (surf == icons->male_unhappy) {
2188 surf = icons->female_unhappy;
2189 } else {
2190 surf = icons->male_unhappy;
2191 }
2192 }
2193 }
2194
2195 if (pcity->feel[CITIZEN_ANGRY][j]) {
2196 surf = icons->male_angry;
2197 for (i = 0; i < pcity->feel[CITIZEN_ANGRY][j]; i++) {
2198 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2199 dest.x += step;
2200 if (surf == icons->male_angry) {
2201 surf = icons->female_angry;
2202 } else {
2203 surf = icons->male_angry;
2204 }
2205 }
2206 }
2207
2209 for (spe = 0 ; spe < spe_max; spe++) {
2210 if (pcity->specialists[spe]) {
2211 for (i = 0; i < pcity->specialists[spe]; i++) {
2212 alphablit(icons->specialists[spe], NULL, city_window->dst->surface,
2213 &dest, 255);
2214 dest.x += step;
2215 }
2216 }
2217 }
2218
2219 if (j == 1) { /* Luxury effect */
2220 dest.x =
2221 city_window->size.x + adj_size(187) - icons->big_luxury->w - adj_size(2);
2222 count = dest.y;
2223 dest.y += (icons->male_happy->h -
2224 icons->big_luxury->h) / 2;
2225 alphablit(icons->big_luxury, NULL, city_window->dst->surface, &dest, 255);
2226 dest.y = count;
2227 }
2228
2229 if (j == 2) { /* Improvements effects */
2230 int w = -1;
2231 count = 0;
2232
2234
2237 if (preq->source.kind == VUT_IMPROVEMENT) {
2238 tmp = get_building_surface(preq->source.value.building);
2239 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2240 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2241
2242 count += (tmp->h + 1);
2243
2244 if (w < 0) {
2245 w = tmp->w;
2246 }
2247
2249 }
2252
2253 if (w >= 0) {
2254 dest.x = city_window->size.x + adj_size(187) - w - adj_size(2);
2255 i = dest.y;
2256 dest.y += (icons->male_happy->h - count) / 2;
2257
2260 if (preq->source.kind == VUT_IMPROVEMENT) {
2261 tmp = get_building_surface(preq->source.value.building);
2262 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2263 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2264
2265 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2266 dest.y += (tmp->h + 1);
2267
2269 }
2272
2273 dest.y = i;
2274 }
2275
2277 }
2278
2279 if (j == 3) { /* police effect */
2280 dest.x = city_window->size.x + adj_size(187) - icons->police->w - adj_size(5);
2281 i = dest.y;
2282 dest.y +=
2283 (icons->male_happy->h - icons->police->h) / 2;
2284 alphablit(icons->police, NULL, city_window->dst->surface, &dest, 255);
2285 dest.y = i;
2286 }
2287
2288 if (j == 4) { /* Wonders effect */
2289 int w = -1;
2290 count = 0;
2291
2295 if (preq->source.kind == VUT_IMPROVEMENT) {
2296 tmp = get_building_surface(preq->source.value.building);
2297 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2298 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2299
2300 count += (tmp->h + 1);
2301
2302 if (w < 0) {
2303 w = tmp->w;
2304 }
2305
2307 }
2310
2312
2314
2317 if (preq->source.kind == VUT_IMPROVEMENT) {
2318 tmp = get_building_surface(preq->source.value.building);
2319 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2320 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2321 count += (tmp->h + 1);
2322
2323 if (w < 0) {
2324 w = tmp->w;
2325 }
2326
2328 }
2331
2333
2335
2338 if (preq->source.kind == VUT_IMPROVEMENT) {
2339 tmp = get_building_surface(preq->source.value.building);
2340 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2341 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2342
2343 count += (tmp->h + 1);
2344
2345 if (w < 0) {
2346 w = tmp->w;
2347 }
2348
2350 }
2353
2355
2356 if (w >= 0) {
2357 dest.x = city_window->size.x + adj_size(187) - surf->w - adj_size(2);
2358 i = dest.y;
2359 dest.y += (icons->male_happy->h - count) / 2;
2360
2362
2365 if (preq->source.kind == VUT_IMPROVEMENT) {
2366 tmp = get_building_surface(preq->source.value.building);
2367 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2368 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2369
2370 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2371 dest.y += (tmp->h + 1);
2372
2374 }
2377
2379
2381
2384 if (preq->source.kind == VUT_IMPROVEMENT) {
2385 tmp = get_building_surface(preq->source.value.building);
2386 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2387 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2388
2389 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2390 dest.y += (tmp->h + 1);
2391
2393 }
2396
2398
2400
2403 if (preq->source.kind == VUT_IMPROVEMENT) {
2404 tmp = get_building_surface(preq->source.value.building);
2405 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2406 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2407
2408 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2409 dest.y += (tmp->h + 1);
2410
2412 }
2415
2417
2418 dest.y = i;
2419 }
2420 }
2421
2422 dest.x = city_window->size.x + adj_size(10);
2423 dest.y += icons->male_happy->h + adj_size(5);
2424
2425 }
2426 }
2427
2429}
2430
2431/**********************************************************************/
2434static void redraw_city_dialog(struct city *pcity)
2435{
2436 char cbuf[40];
2437 int i, step, count, limit;
2438 int cost = 0;
2439 SDL_Rect dest;
2440 struct widget *pwindow = pcity_dlg->end_city_widget_list;
2441 SDL_Surface *buf = NULL, *buf2 = NULL;
2442 utf8_str *pstr = NULL;
2443 int spe, spe_max;
2444
2445 refresh_city_names(pcity);
2446
2447 if ((city_unhappy(pcity) || city_celebrating(pcity) || city_happy(pcity)
2448 || cma_is_city_under_agent(pcity, NULL))
2450 /* City status was changed : NORMAL <-> DISORDER, HAPPY, CELEBR. */
2451
2453
2454#if 0
2455 /* Upd. resource map */
2458#endif
2459
2460 /* Upd. window title */
2462 }
2463
2464 /* Update resource map */
2467
2468 /* Redraw city dlg */
2471
2472 /* ================================================================= */
2473 fc_snprintf(cbuf, sizeof(cbuf), _("City map"));
2474
2477 pstr->style |= TTF_STYLE_BOLD;
2478
2480
2481 dest.x = pwindow->size.x + adj_size(196) + (adj_size(132) - buf->w) / 2;
2482 dest.y = pwindow->size.y + adj_size(49) + (adj_size(13) - buf->h) / 2;
2483
2484 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2485
2487
2488 fc_snprintf(cbuf, sizeof(cbuf), _("Citizens"));
2489
2492
2494
2495 dest.x = pwindow->size.x + adj_size(344) + (adj_size(146) - buf->w) / 2;
2496 dest.y = pwindow->size.y + adj_size(47) + (adj_size(13) - buf->h) / 2;
2497
2498 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2499
2501
2502 fc_snprintf(cbuf, sizeof(cbuf), _("City improvements"));
2503
2506
2508
2509 dest.x = pwindow->size.x + adj_size(504) + (adj_size(132) - buf->w) / 2;
2510 dest.y = pwindow->size.y + adj_size(49) + (adj_size(13) - buf->h) / 2;
2511
2512 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2513
2515
2516 /* ================================================================= */
2517 /* Food label */
2518 fc_snprintf(cbuf, sizeof(cbuf), _("Food: %d per turn"),
2519 pcity->prod[O_FOOD]);
2520
2522
2524
2526
2527 dest.x = pwindow->size.x + adj_size(200);
2528 dest.y = pwindow->size.y + adj_size(228) + (adj_size(16) - buf->h) / 2;
2529
2530 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2531
2533
2534 /* Draw food income */
2535 dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - icons->big_food->h) / 2;
2536 dest.x = pwindow->size.x + adj_size(203);
2537
2538 if (pcity->surplus[O_FOOD] >= 0) {
2539 count = pcity->prod[O_FOOD] - pcity->surplus[O_FOOD];
2540 } else {
2541 count = pcity->prod[O_FOOD];
2542 }
2543
2544 if (((icons->big_food->w + 1) * count) > adj_size(200)) {
2545 step = (adj_size(200) - icons->big_food->w) / (count - 1);
2546 } else {
2547 step = icons->big_food->w + 1;
2548 }
2549
2550 for (i = 0; i < count; i++) {
2551 alphablit(icons->big_food, NULL, pwindow->dst->surface, &dest, 255);
2552 dest.x += step;
2553 }
2554
2555 fc_snprintf(cbuf, sizeof(cbuf), Q_("?food:Surplus: %d"),
2556 pcity->surplus[O_FOOD]);
2557
2560
2562
2563 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2564 dest.y = pwindow->size.y + adj_size(228) + (adj_size(16) - buf->h) / 2;
2565
2566 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2567
2569
2570 /* Draw surplus of food */
2571 if (pcity->surplus[O_FOOD]) {
2572 if (pcity->surplus[O_FOOD] > 0) {
2573 count = pcity->surplus[O_FOOD];
2574 buf = icons->big_food;
2575 } else {
2576 count = -1 * pcity->surplus[O_FOOD];
2578 }
2579
2580 dest.x = pwindow->size.x + adj_size(423);
2581 dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - buf->h) / 2;
2582
2583 if (count > 2) {
2584 if (count < 18) {
2585 step = (adj_size(30) - buf->w) / (count - 1);
2586 } else {
2587 step = 1;
2588 count = 17;
2589 }
2590 } else {
2591 step = buf->w + 1;
2592 }
2593
2594 for (i = 0; i < count; i++) {
2595 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2596 dest.x -= step;
2597 }
2598 }
2599
2600 /* ================================================================= */
2601 /* Productions label */
2602 fc_snprintf(cbuf, sizeof(cbuf), _("Production: %d (%d) per turn"),
2603 pcity->surplus[O_SHIELD],
2604 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
2605
2608
2610
2611 dest.x = pwindow->size.x + adj_size(200);
2612 dest.y = pwindow->size.y + adj_size(263) + (adj_size(15) - buf->h) / 2;
2613
2614 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2615
2617
2618 /* Draw productions shields */
2619 if (pcity->surplus[O_SHIELD]) {
2620
2621 if (pcity->surplus[O_SHIELD] > 0) {
2622 count = pcity->surplus[O_SHIELD] + pcity->waste[O_SHIELD];
2623 buf = icons->big_shield;
2624 } else {
2625 count = -1 * pcity->surplus[O_SHIELD];
2627 }
2628
2629 dest.y = pwindow->size.y + adj_size(281) + (adj_size(16) - buf->h) / 2;
2630 dest.x = pwindow->size.x + adj_size(203);
2631
2632 if ((buf->w * count) > adj_size(200)) {
2633 step = (adj_size(200) - buf->w) / (count - 1);
2634 } else {
2635 step = buf->w;
2636 }
2637
2638 for (i = 0; i < count; i++) {
2639 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2640 dest.x += step;
2641 if (i > pcity->surplus[O_SHIELD]) {
2643 }
2644 }
2645 }
2646
2647 /* Support shields label */
2648 fc_snprintf(cbuf, sizeof(cbuf), Q_("?production:Support: %d"),
2649 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD] -
2650 pcity->surplus[O_SHIELD]);
2651
2654
2656
2657 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2658 dest.y = pwindow->size.y + adj_size(263) + (adj_size(15) - buf->h) / 2;
2659
2660 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2661
2663
2664 /* Draw support shields */
2665 if (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]) {
2666 dest.x = pwindow->size.x + adj_size(423);
2667 dest.y =
2668 pwindow->size.y + adj_size(281) + (adj_size(16) - icons->big_shield->h) / 2;
2669
2670 if ((icons->big_shield->w + 1) * (pcity->prod[O_SHIELD] -
2671 pcity->surplus[O_SHIELD]) > adj_size(30)) {
2672 step =
2673 (adj_size(30) - icons->big_food->w) / (pcity->prod[O_SHIELD] -
2674 pcity->surplus[O_SHIELD] - 1);
2675 } else {
2676 step = icons->big_shield->w + 1;
2677 }
2678
2679 for (i = 0; i < (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]); i++) {
2680 alphablit(icons->big_shield, NULL, pwindow->dst->surface, &dest, 255);
2681 dest.x -= step;
2682 }
2683 }
2684
2685 /* ================================================================= */
2686 /* Trade label */
2687 fc_snprintf(cbuf, sizeof(cbuf), _("Trade: %d per turn"),
2688 pcity->surplus[O_TRADE]);
2689
2692
2694
2695 dest.x = pwindow->size.x + adj_size(200);
2696 dest.y = pwindow->size.y + adj_size(298) + (adj_size(15) - buf->h) / 2;
2697
2698 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2699
2701
2702 /* Draw total (trade - corruption) */
2703 if (pcity->surplus[O_TRADE]) {
2704 dest.y =
2705 pwindow->size.y + adj_size(316) + (adj_size(16) - icons->big_trade->h) / 2;
2706 dest.x = pwindow->size.x + adj_size(203);
2707
2708 if (((icons->big_trade->w + 1) * pcity->surplus[O_TRADE]) > adj_size(200)) {
2709 step = (adj_size(200) - icons->big_trade->w) / (pcity->surplus[O_TRADE] - 1);
2710 } else {
2711 step = icons->big_trade->w + 1;
2712 }
2713
2714 for (i = 0; i < pcity->surplus[O_TRADE]; i++) {
2715 alphablit(icons->big_trade, NULL, pwindow->dst->surface, &dest, 255);
2716 dest.x += step;
2717 }
2718 }
2719
2720 /* Corruption label */
2721 fc_snprintf(cbuf, sizeof(cbuf), _("Corruption: %d"),
2722 pcity->waste[O_TRADE]);
2723
2726
2728
2729 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2730 dest.y = pwindow->size.y + adj_size(298) + (adj_size(15) - buf->h) / 2;
2731
2732 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2733
2735
2736 /* Draw corruption */
2737 if (pcity->waste[O_TRADE] > 0) {
2738 dest.x = pwindow->size.x + adj_size(423);
2739 dest.y =
2740 pwindow->size.y + adj_size(316) + (adj_size(16) - icons->big_trade->h) / 2;
2741
2742 if (((icons->big_trade_corr->w + 1) * pcity->waste[O_TRADE]) > adj_size(30)) {
2743 step =
2744 (adj_size(30) - icons->big_trade_corr->w) / (pcity->waste[O_TRADE] - 1);
2745 } else {
2746 step = icons->big_trade_corr->w + 1;
2747 }
2748
2749 for (i = 0; i < pcity->waste[O_TRADE]; i++) {
2751 &dest, 255);
2752 dest.x -= step;
2753 }
2754 }
2755
2756 /* ================================================================= */
2757 /* Gold label */
2758 fc_snprintf(cbuf, sizeof(cbuf), _("Gold: %d (%d) per turn"),
2759 pcity->surplus[O_GOLD], pcity->prod[O_GOLD]);
2760
2763
2765
2766 dest.x = pwindow->size.x + adj_size(200);
2767 dest.y = pwindow->size.y + adj_size(342) + (adj_size(15) - buf->h) / 2;
2768
2769 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2770
2772
2773 /* Draw coins */
2774 count = pcity->surplus[O_GOLD];
2775 if (count) {
2776
2777 if (count > 0) {
2778 buf = icons->big_coin;
2779 } else {
2780 count *= -1;
2782 }
2783
2784 dest.y = pwindow->size.y + adj_size(359) + (adj_size(16) - buf->h) / 2;
2785 dest.x = pwindow->size.x + adj_size(203);
2786
2787 if ((buf->w * count) > adj_size(110)) {
2788 step = (adj_size(110) - buf->w) / (count - 1);
2789 if (!step) {
2790 step = 1;
2791 count = 97;
2792 }
2793 } else {
2794 step = buf->w;
2795 }
2796
2797 for (i = 0; i < count; i++) {
2798 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2799 dest.x += step;
2800 }
2801
2802 }
2803
2804 /* Upkeep label */
2805 fc_snprintf(cbuf, sizeof(cbuf), _("Upkeep: %d"),
2806 pcity->prod[O_GOLD] - pcity->surplus[O_GOLD]);
2807
2810
2812
2813 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2814 dest.y = pwindow->size.y + adj_size(342) + (adj_size(15) - buf->h) / 2;
2815
2816 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2817
2819
2820 /* Draw upkeep */
2821 count = pcity->surplus[O_GOLD];
2822 if (pcity->prod[O_GOLD] - count) {
2823
2824 dest.x = pwindow->size.x + adj_size(423);
2825 dest.y = pwindow->size.y + adj_size(359)
2826 + (adj_size(16) - icons->big_coin_upkeep->h) / 2;
2827
2828 if (((icons->big_coin_upkeep->w + 1) *
2829 (pcity->prod[O_GOLD] - count)) > adj_size(110)) {
2830 step = (adj_size(110) - icons->big_coin_upkeep->w) /
2831 (pcity->prod[O_GOLD] - count - 1);
2832 } else {
2833 step = icons->big_coin_upkeep->w + 1;
2834 }
2835
2836 for (i = 0; i < (pcity->prod[O_GOLD] - count); i++) {
2838 &dest, 255);
2839 dest.x -= step;
2840 }
2841 }
2842
2843 /* ================================================================= */
2844 /* Science label */
2845 fc_snprintf(cbuf, sizeof(cbuf), _("Science: %d per turn"),
2846 pcity->prod[O_SCIENCE]);
2847
2850
2852
2853 dest.x = pwindow->size.x + adj_size(200);
2854 dest.y = pwindow->size.y + adj_size(376) + (adj_size(15) - buf->h) / 2;
2855
2856 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2857
2859
2860 /* Draw colb */
2861 count = pcity->prod[O_SCIENCE];
2862 if (count) {
2863
2864 dest.y =
2865 pwindow->size.y + adj_size(394) + (adj_size(16) - icons->big_colb->h) / 2;
2866 dest.x = pwindow->size.x + adj_size(203);
2867
2868 if ((icons->big_colb->w * count) > adj_size(235)) {
2869 step = (adj_size(235) - icons->big_colb->w) / (count - 1);
2870 if (!step) {
2871 step = 1;
2872 count = 222;
2873 }
2874 } else {
2875 step = icons->big_colb->w;
2876 }
2877
2878 for (i = 0; i < count; i++) {
2879 alphablit(icons->big_colb, NULL, pwindow->dst->surface, &dest, 255);
2880 dest.x += step;
2881 }
2882 }
2883
2884 /* ================================================================= */
2885 /* Luxury label */
2886 fc_snprintf(cbuf, sizeof(cbuf), _("Luxury: %d per turn"),
2887 pcity->prod[O_LUXURY]);
2888
2891
2893
2894 dest.x = pwindow->size.x + adj_size(200);
2895 dest.y = pwindow->size.y + adj_size(412) + (adj_size(15) - buf->h) / 2;
2896
2897 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2898
2900
2901 /* Draw luxury */
2902 if (pcity->prod[O_LUXURY]) {
2903
2904 dest.y =
2905 pwindow->size.y + adj_size(429) + (adj_size(16) - icons->big_luxury->h) / 2;
2906 dest.x = pwindow->size.x + adj_size(203);
2907
2908 if ((icons->big_luxury->w * pcity->prod[O_LUXURY]) > adj_size(235)) {
2909 step =
2910 (adj_size(235) - icons->big_luxury->w) / (pcity->prod[O_LUXURY] - 1);
2911 } else {
2912 step = icons->big_luxury->w;
2913 }
2914
2915 for (i = 0; i < pcity->prod[O_LUXURY]; i++) {
2916 alphablit(icons->big_luxury, NULL, pwindow->dst->surface, &dest, 255);
2917 dest.x += step;
2918 }
2919 }
2920
2921 /* ================================================================= */
2922 /* Turns to grow label */
2923 count = city_turns_to_grow(pcity);
2924 if (count == 0) {
2925 fc_snprintf(cbuf, sizeof(cbuf), _("City growth: blocked"));
2926 } else if (count == FC_INFINITY) {
2927 fc_snprintf(cbuf, sizeof(cbuf), _("City growth: never"));
2928 } else if (count < 0) {
2929 /* Turns until famine */
2930 fc_snprintf(cbuf, sizeof(cbuf),
2931 _("City shrinks: %d %s"), abs(count),
2932 PL_("turn", "turns", abs(count)));
2933 } else {
2934 fc_snprintf(cbuf, sizeof(cbuf),
2935 _("City growth: %d %s"), count,
2936 PL_("turn", "turns", count));
2937 }
2938
2940
2942
2944
2945 dest.x = pwindow->size.x + adj_size(445) + (adj_size(192) - buf->w) / 2;
2946 dest.y = pwindow->size.y + adj_size(227);
2947
2948 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2949
2951
2952 count = (city_granary_size(city_size_get(pcity))) / 10;
2953
2954 if (count > 12) {
2955 step = (adj_size(168) - icons->big_food->h) / adj_size((11 + count - 12));
2956 i = (count - 1) * step + 14;
2957 } else {
2958 step = icons->big_food->h;
2959 i = count * step;
2960 }
2961
2962 /* Food stock */
2963 if (get_city_bonus(pcity, EFT_GROWTH_FOOD) > 0) {
2964 /* With granary */
2965 /* Stocks label */
2966 copy_chars_to_utf8_str(pstr, _("Stock"));
2968
2969 dest.x = pwindow->size.x + adj_size(461) + (adj_size(76) - buf->w) / 2;
2970 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
2971
2972 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2973
2975
2976 /* Granary label */
2977 copy_chars_to_utf8_str(pstr, _("Granary"));
2979
2980 dest.x = pwindow->size.x + adj_size(549) + (adj_size(76) - buf->w) / 2;
2981 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
2982
2983 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2984
2986
2987 /* Draw bcgd granary */
2988 dest.x = pwindow->size.x + adj_size(462);
2989 dest.y = pwindow->size.y + adj_size(260);
2990 dest.w = 70 + 4;
2991 dest.h = i + 4;
2992
2993 fill_rect_alpha(pwindow->dst->surface, &dest,
2995
2996 create_frame(pwindow->dst->surface,
2997 dest.x - 1, dest.y - 1, dest.w, dest.h,
2999
3000 /* Draw bcgd stocks*/
3001 dest.x = pwindow->size.x + adj_size(550);
3002 dest.y = pwindow->size.y + adj_size(260);
3003
3004 fill_rect_alpha(pwindow->dst->surface, &dest,
3006
3007 create_frame(pwindow->dst->surface,
3008 dest.x - 1, dest.y - 1, dest.w, dest.h,
3010
3011 /* Draw stocks icons */
3013 if (pcity->food_stock + pcity->surplus[O_FOOD] > cost) {
3014 count = cost;
3015 } else {
3016 if (pcity->surplus[O_FOOD] < 0) {
3017 count = pcity->food_stock;
3018 } else {
3019 count = pcity->food_stock + pcity->surplus[O_FOOD];
3020 }
3021 }
3022 cost /= 2;
3023
3024 if (pcity->surplus[O_FOOD] < 0) {
3025 limit = pcity->food_stock + pcity->surplus[O_FOOD];
3026 if (limit < 0) {
3027 limit = 0;
3028 }
3029 } else {
3030 limit = 0xffff;
3031 }
3032
3033 dest.x += 2;
3034 dest.y += 2;
3035 i = 0;
3036 buf = icons->big_food;
3037 while (count && cost) {
3038 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3039 dest.x += buf->w;
3040 count--;
3041 cost--;
3042 i++;
3043 if (dest.x > pwindow->size.x + adj_size(620)) {
3044 dest.x = pwindow->size.x + adj_size(552);
3045 dest.y += step;
3046 }
3047 if (i > limit - 1) {
3049 } else {
3050 if (i > pcity->food_stock - 1) {
3052 }
3053 }
3054 }
3055 /* Draw granary icons */
3056 dest.x = pwindow->size.x + adj_size(462) + adj_size(2);
3057 dest.y = pwindow->size.y + adj_size(260) + adj_size(2);
3058
3059 while (count) {
3060 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3061 dest.x += buf->w;
3062 count--;
3063 i++;
3064
3065 if (dest.x > pwindow->size.x + adj_size(532)) {
3066 dest.x = pwindow->size.x + adj_size(464);
3067 dest.y += step;
3068 }
3069
3070 if (i > limit - 1) {
3072 } else if (i > pcity->food_stock - 1) {
3074 }
3075 }
3076
3077 } else {
3078 /* Without granary */
3079 /* Stocks label */
3080 copy_chars_to_utf8_str(pstr, _("Stock"));
3082
3083 dest.x = pwindow->size.x + adj_size(461) + (adj_size(144) - buf->w) / 2;
3084 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
3085
3086 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3088
3089 /* Food stock */
3090
3091 /* Draw bcgd */
3092 dest.x = pwindow->size.x + adj_size(462);
3093 dest.y = pwindow->size.y + adj_size(260);
3094 dest.w = adj_size(144);
3095 dest.h = i + adj_size(4);
3096
3097 fill_rect_alpha(pwindow->dst->surface, &dest,
3099
3100 create_frame(pwindow->dst->surface,
3101 dest.x - 1, dest.y - 1, dest.w, dest.h,
3103
3104 /* Draw icons */
3106 if (pcity->food_stock + pcity->surplus[O_FOOD] > cost) {
3107 count = cost;
3108 } else {
3109 if (pcity->surplus[O_FOOD] < 0) {
3110 count = pcity->food_stock;
3111 } else {
3112 count = pcity->food_stock + pcity->surplus[O_FOOD];
3113 }
3114 }
3115
3116 if (pcity->surplus[O_FOOD] < 0) {
3117 limit = pcity->food_stock + pcity->surplus[O_FOOD];
3118 if (limit < 0) {
3119 limit = 0;
3120 }
3121 } else {
3122 limit = 0xffff;
3123 }
3124
3125 dest.x += adj_size(2);
3126 dest.y += adj_size(2);
3127 i = 0;
3128 buf = icons->big_food;
3129 while (count) {
3130 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3131 dest.x += buf->w;
3132 count--;
3133 i++;
3134
3135 if (dest.x > pwindow->size.x + adj_size(602)) {
3136 dest.x = pwindow->size.x + adj_size(464);
3137 dest.y += step;
3138 }
3139 if (i > limit - 1) {
3141 } else {
3142 if (i > pcity->food_stock - 1) {
3144 }
3145 }
3146 }
3147 }
3148 /* ================================================================= */
3149
3150 /* draw productions shields progress */
3151 if (VUT_UTYPE == pcity->production.kind) {
3152 const struct unit_type *punittype = pcity->production.value.utype;
3153
3155 count = cost / 10;
3156
3159
3161 buf2 = zoomSurface(buf2, DEFAULT_ZOOM * ((float)32 / buf2->h),
3162 DEFAULT_ZOOM * ((float)32 / buf2->h), 1);
3163
3164 /* blit unit icon */
3165 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - (buf->w + buf2->w + adj_size(5))) / 2;
3166 dest.y = pwindow->size.y + adj_size(233);
3167
3168 alphablit(buf2, NULL, pwindow->dst->surface, &dest, 255);
3169
3170 dest.y += (buf2->h - buf->h) / 2;
3171 dest.x += buf2->w + adj_size(5);
3172
3173 } else {
3174 const struct impr_type *pimprove = pcity->production.value.building;
3175
3176 if (is_convert_improvement(pimprove)) {
3177
3182 }
3183
3184 /* You can't see capitalization progress */
3185 count = 0;
3186
3187 } else {
3188
3189 if (city_can_buy(pcity) && pcity_dlg->buy_button
3193 }
3194
3195 cost = impr_build_shield_cost(pcity, pimprove);
3196 count = cost / 10;
3197 }
3198
3201
3203 buf2 = zoomSurface(buf2, DEFAULT_ZOOM * ((float)32 / buf2->h),
3204 DEFAULT_ZOOM * ((float)32 / buf2->h), 1);
3205
3206 /* blit impr icon */
3207 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - (buf->w + buf2->w + adj_size(5))) / 2;
3208 dest.y = pwindow->size.y + adj_size(233);
3209
3210 alphablit(buf2, NULL, pwindow->dst->surface, &dest, 255);
3211
3212 dest.y += (buf2->h - buf->h) / 2;
3213 dest.x += buf2->w + adj_size(5);
3214 }
3215
3216 /* blit unit/impr name */
3217 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3218
3221
3222 if (count) {
3223 if (count > 11) {
3224 step = (adj_size(154) - icons->big_shield->h) / adj_size((10 + count - 11));
3225
3226 if (!step) {
3227 step = 1;
3228 }
3229
3230 i = (step * (count - 1)) + icons->big_shield->h;
3231 } else {
3232 step = icons->big_shield->h;
3233 i = count * step;
3234 }
3235
3236 /* draw shield stock background */
3237 dest.x = pwindow->size.x + adj_size(28);
3238 dest.y = pwindow->size.y + adj_size(270);
3239 dest.w = adj_size(144);
3240 dest.h = i + adj_size(4);
3241
3242 fill_rect_alpha(pwindow->dst->surface, &dest,
3244
3245 create_frame(pwindow->dst->surface,
3246 dest.x - 1, dest.y - 1, dest.w, dest.h,
3248
3249 /* draw production progress text */
3250 dest.y = pwindow->size.y + adj_size(270) + dest.h + 1;
3251
3252 if (pcity->shield_stock < cost) {
3253 count = city_production_turns_to_build(pcity, TRUE);
3254 if (count == 999) {
3255 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %s!",
3256 pcity->shield_stock, cost, _("blocked"));
3257 } else {
3258 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %d %s",
3259 pcity->shield_stock, cost, count, PL_("turn", "turns", count));
3260 }
3261 } else {
3262 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %s!",
3263 pcity->shield_stock, cost, _("finished"));
3264 }
3265
3268
3270
3271 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - buf->w) / 2;
3272
3273 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3274
3277
3278 /* draw shield stock */
3279 if (pcity->shield_stock + pcity->surplus[O_SHIELD] <= cost) {
3280 count = pcity->shield_stock + pcity->surplus[O_SHIELD];
3281 } else {
3282 count = cost;
3283 }
3284 dest.x = pwindow->size.x + adj_size(29) + adj_size(2);
3285 dest.y = pwindow->size.y + adj_size(270) + adj_size(2);
3286 i = 0;
3287
3288 buf = icons->big_shield;
3289 while (count > 0) {
3290 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3291 dest.x += buf->w;
3292 count--;
3293 if (dest.x > pwindow->size.x + adj_size(170)) {
3294 dest.x = pwindow->size.x + adj_size(31);
3295 dest.y += step;
3296 }
3297 i++;
3298 if (i > pcity->shield_stock - 1) {
3300 }
3301 }
3302 }
3303
3304 /* count != 0 */
3305 /* ==================================================== */
3306 /* Draw Citizens */
3309 + city_specialists(pcity));
3310
3312
3313 if (count > 13) {
3314 step = (adj_size(440) - buf->w) / (adj_size(12 + count - 13));
3315 } else {
3316 step = buf->w;
3317 }
3318
3320
3321 dest.x = pwindow->size.x + adj_size(198);
3322 dest.y = pwindow->size.y + pwindow->area.y + adj_size(1) + (adj_size(22) - buf->h) / 2;
3323 pcity_dlg->spec_area.x = pwindow->dst->dest_rect.x + dest.x;
3324 pcity_dlg->spec_area.y = pwindow->dst->dest_rect.y + dest.y;
3325 pcity_dlg->spec_area.w = count * step;
3326 pcity_dlg->spec_area.h = buf->h;
3327
3328 if (pcity->feel[CITIZEN_HAPPY][FEELING_FINAL]) {
3329 for (i = 0; i < pcity->feel[CITIZEN_HAPPY][FEELING_FINAL]; i++) {
3331
3332 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3333 dest.x += step;
3335 }
3336 }
3337
3338 if (pcity->feel[CITIZEN_CONTENT][FEELING_FINAL]) {
3339 for (i = 0; i < pcity->feel[CITIZEN_CONTENT][FEELING_FINAL]; i++) {
3341
3342 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3343 dest.x += step;
3345 }
3346 }
3347
3348 if (pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL]) {
3349 for (i = 0; i < pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL]; i++) {
3351
3352 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3353 dest.x += step;
3355 }
3356 }
3357
3358 if (pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]) {
3359 for (i = 0; i < pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]; i++) {
3361
3362 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3363 dest.x += step;
3365 }
3366 }
3367
3369 for (spe = 0; spe < spe_max; spe++) {
3370 if (pcity->specialists[spe] > 0) {
3372
3373 for (i = 0; i < pcity->specialists[spe]; i++) {
3374 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3375 dest.x += step;
3376 }
3378 }
3379 }
3380
3381 /* ==================================================== */
3382
3383
3384 switch (pcity_dlg->page) {
3385 case INFO_PAGE:
3386 redraw_info_city_dialog(pwindow, pcity);
3387 break;
3388
3389 case HAPPINESS_PAGE:
3390 redraw_happiness_city_dialog(pwindow, pcity);
3391 break;
3392
3393 case ARMY_PAGE:
3394 redraw_army_city_dialog(pwindow, pcity);
3395 break;
3396
3397 case SUPPORTED_UNITS_PAGE:
3398 redraw_supported_units_city_dialog(pwindow, pcity);
3399 break;
3400
3401 case MISC_PAGE:
3402 redraw_misc_city_dialog(pwindow, pcity);
3403 break;
3404
3405 default:
3406 break;
3407
3408 }
3409
3410 /* redraw "sell improvement" dialog */
3413
3414 widget_mark_dirty(pwindow);
3415}
3416
3417/* ============================================================== */
3418
3419/**********************************************************************/
3422static void rebuild_imprm_list(struct city *pcity)
3423{
3424 int count = 0;
3425 struct widget *pwindow = pcity_dlg->end_city_widget_list;
3426 struct widget *add_dock, *buf, *last;
3428 utf8_str *pstr = NULL;
3429 struct player *owner = city_owner(pcity);
3430 int prev_y = 0;
3431
3432 if (!pcity_dlg->imprv) {
3433 pcity_dlg->imprv = fc_calloc(1, sizeof(struct advanced_dialog));
3434 }
3435
3436 /* free old list */
3446 }
3447
3449 buf = last = add_dock;
3450
3451 /* Alloc new */
3452 city_built_iterate(pcity, pimprove) {
3454 city_improvement_name_translation(pcity, pimprove),
3457
3458 pstr->style |= TTF_STYLE_BOLD;
3459
3460 logo = get_building_surface(pimprove);
3462
3463 buf = create_iconlabel(logo, pwindow->dst, pstr,
3465
3466 buf->size.x = pwindow->size.x + adj_size(450);
3467 buf->size.y = pwindow->size.y + adj_size(66) + prev_y;
3468
3469 prev_y += buf->size.h;
3470
3471 buf->size.w = adj_size(165);
3472 buf->action = sell_imprvm_dlg_callback;
3473
3474 if (!pcity_dlg->pcity->did_sell
3475 && !is_wonder(pimprove) && (owner == client.conn.playing)) {
3477 }
3478
3479 buf->id = MAX_ID - improvement_number(pimprove) - 3000;
3481 add_dock = buf;
3482
3483 count++;
3484
3485 if (count > 7) {
3487 }
3488
3490
3491 if (count) {
3496
3497 if (count > 7) {
3499
3501
3503 pwindow->size.x + adj_size(635),
3504 pwindow->size.y + adj_size(66),
3505 adj_size(155), TRUE);
3506 }
3507 }
3508}
3509
3510/**********************************************************************/
3513static void rebuild_citydlg_title_str(struct widget *pwindow,
3514 struct city *pcity)
3515{
3516 char cbuf[512];
3517
3518 fc_snprintf(cbuf, sizeof(cbuf),
3519 _("City of %s (Population %s citizens)"),
3520 city_name_get(pcity),
3522
3523 if (city_unhappy(pcity)) {
3524 /* TRANS: preserve leading space */
3525 fc_strlcat(cbuf, _(" - DISORDER"), sizeof(cbuf));
3526 } else {
3527 if (city_celebrating(pcity)) {
3528 /* TRANS: preserve leading space */
3529 fc_strlcat(cbuf, _(" - celebrating"), sizeof(cbuf));
3530 } else {
3531 if (city_happy(pcity)) {
3532 /* TRANS: preserve leading space */
3533 fc_strlcat(cbuf, _(" - happy"), sizeof(cbuf));
3534 }
3535 }
3536 }
3537
3538 if (cma_is_city_under_agent(pcity, NULL)) {
3539 /* TRANS: preserve leading space */
3540 fc_strlcat(cbuf, _(" - under Citizen Governor control."), sizeof(cbuf));
3541 }
3542
3544}
3545
3546
3547/* ========================= Public ================================== */
3548
3549/**********************************************************************/
3553void real_city_dialog_popup(struct city *pcity)
3554{
3555 struct widget *pwindow = NULL, *buf = NULL;
3557 utf8_str *pstr = NULL;
3558 int cs;
3559 struct player *owner = city_owner(pcity);
3560 SDL_Rect area;
3561
3562 if (pcity_dlg) {
3563 return;
3564 }
3565
3566 menus_update();
3567
3568 pcity_dlg = fc_calloc(1, sizeof(struct city_dialog));
3569 pcity_dlg->pcity = pcity;
3570 pcity_dlg->page = ARMY_PAGE;
3571
3573 pstr->style |= TTF_STYLE_BOLD;
3574 pwindow = create_window(NULL, pstr, adj_size(640), adj_size(480), 0);
3575
3576 rebuild_citydlg_title_str(pwindow, pcity);
3577
3578 pwindow->action = city_dlg_callback;
3579 set_wstate(pwindow, FC_WS_NORMAL);
3580
3582
3584
3585 /* create window background */
3587 if (resize_window(pwindow, logo, NULL, adj_size(640), adj_size(480))) {
3589 }
3590
3591 logo = get_city_gfx();
3592 alphablit(logo, NULL, pwindow->theme, NULL, 255);
3593
3594 area = pwindow->area;
3595
3596 widget_set_position(pwindow,
3597 (main_window_width() - pwindow->size.w) / 2,
3598 (main_window_height() - pwindow->size.h) / 2);
3599
3600 /* ============================================================= */
3601
3602 /* Close dialog button */
3603 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3605 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3607 buf->action = exit_city_dlg_callback;
3608 buf->size.x = area.x + area.w - buf->size.w;
3609 buf->size.y = pwindow->size.y + adj_size(2);
3610 buf->key = SDLK_ESCAPE;
3613
3614 /* -------- */
3615
3616 buf = create_themeicon(current_theme->army_icon, pwindow->dst,
3618 buf->info_label = create_utf8_from_char_fonto(_("Present units"),
3620 buf->action = army_city_dlg_callback;
3621 buf->size.x = area.x + adj_size(2) + ((adj_size(183) - 5 * buf->size.w) / 6);
3622 buf->size.y = area.y + adj_size(2);
3625 /* -------- */
3626
3627 buf = create_themeicon(current_theme->support_icon, pwindow->dst,
3629 buf->info_label = create_utf8_from_char_fonto(_("Supported units"),
3632 buf->size.x =
3633 area.x + adj_size(2) + 2 * ((adj_size(183) - 5 * buf->size.w) / 6) + buf->size.w;
3634 buf->size.y = area.y + adj_size(2);
3635
3638 /* -------- */
3639
3640 buf = create_themeicon(current_theme->happy_icon, pwindow->dst,
3642 buf->info_label = create_utf8_from_char_fonto(_("Happiness"),
3644 buf->action = happy_city_dlg_callback;
3645 buf->size.x
3646 = area.x + adj_size(2) + 3 * ((adj_size(183) - 5 * buf->size.w) / 6) + 2 * buf->size.w;
3647 buf->size.y = area.y + adj_size(2);
3650 /* -------- */
3651
3652 buf = create_themeicon(current_theme->info_icon, pwindow->dst,
3654 buf->info_label = create_utf8_from_char_fonto(_("City info"),
3656 buf->action = info_city_dlg_callback;
3657 buf->size.x
3658 = area.x + adj_size(4) + 4 * ((adj_size(183) - 5 * buf->size.w) / 6) + 3 * buf->size.w;
3659 buf->size.y = area.y + adj_size(2);
3662
3665 /* ===================================================== */
3666 rebuild_imprm_list(pcity);
3667 /* ===================================================== */
3668
3669 logo = get_scaled_city_map(pcity);
3670
3671 buf = create_themelabel(logo, pwindow->dst, NULL,
3673
3675
3677 if (!cma_is_city_under_agent(pcity, NULL) && (owner == client.conn.playing)) {
3679 }
3680 buf->size.x = area.x + adj_size(193) + (adj_size(249) - buf->size.w) / 2;
3681 buf->size.y = area.y + adj_size(41) + (adj_size(158) - buf->size.h) / 2;
3683 /* -------- */
3684
3685 buf = create_themeicon(current_theme->options_icon, pwindow->dst,
3687 buf->info_label = create_utf8_from_char_fonto(_("City options"),
3690 buf->size.x
3691 = area.x + adj_size(4) + 5 * ((adj_size(183) - 5 * buf->size.w) / 6) + 4 * buf->size.w;
3692 buf->size.y = area.y + adj_size(2);
3693 if (owner == client.conn.playing) {
3695 }
3697 /* -------- */
3698
3699 buf = create_themeicon(current_theme->prod_icon, pwindow->dst,
3701 buf->info_label = create_utf8_from_char_fonto(_("Change production"),
3703 buf->action = change_prod_dlg_callback;
3704 buf->size.x = area.x + adj_size(7);
3705 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3706 if (owner == client.conn.playing) {
3708 }
3709 buf->key = SDLK_c;
3711 /* -------- */
3712
3713 buf = create_themeicon(current_theme->buy_prod_icon, pwindow->dst,
3715 buf->info_label = create_utf8_from_char_fonto(_("Hurry production"),
3718 buf->size.x = area.x + adj_size(7) + (buf->size.w + adj_size(2));
3719 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3721 buf->key = SDLK_h;
3722 if (city_can_buy(pcity)) {
3724 }
3726 /* -------- */
3727
3728 buf = create_themeicon(current_theme->cma_icon, pwindow->dst,
3730 buf->info_label = create_utf8_from_char_fonto(_("Citizen Governor"),
3732 buf->action = cma_city_dlg_callback;
3733 buf->key = SDLK_a;
3734 buf->size.x = area.x + adj_size(7) + (buf->size.w + adj_size(2)) * 2;
3735 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3736 if (owner == client.conn.playing) {
3738 }
3740
3741
3742 /* -------- */
3743 buf = create_themeicon(current_theme->l_arrow_icon, pwindow->dst,
3745 buf->info_label = create_utf8_from_char_fonto(_("Previous city"),
3748 buf->size.x = area.x + adj_size(220) - buf->size.w - adj_size(8);
3749 buf->size.y = area.y + area.h - buf->size.h;
3750 if (owner == client.conn.playing) {
3752 }
3753 buf->key = SDLK_LEFT;
3754 buf->mod = KMOD_LSHIFT;
3756 /* -------- */
3757
3758 buf = create_themeicon(current_theme->r_arrow_icon, pwindow->dst,
3760 buf->info_label = create_utf8_from_char_fonto(_("Next city"),
3763 buf->size.x = area.x + adj_size(420) + adj_size(2);
3764 buf->size.y = area.y + area.h - buf->size.h;
3765 if (owner == client.conn.playing) {
3767 }
3768 buf->key = SDLK_RIGHT;
3769 buf->mod = KMOD_LSHIFT;
3771 /* -------- */
3772
3774 FONTO_DEFAULT, adj_size(200),
3777 buf->size.x = area.x + (area.w - buf->size.w) / 2;
3778 buf->size.y = area.y + area.h - buf->size.h - adj_size(2);
3779 if (owner == client.conn.playing) {
3781 }
3782
3785
3787
3788 /* check if Citizen Icons style was loaded */
3789 cs = style_of_city(pcity);
3790
3791 if (cs != icons->style) {
3793 }
3794
3795 /* ===================================================== */
3796 if ((city_unhappy(pcity) || city_celebrating(pcity)
3797 || city_happy(pcity))) {
3799 }
3800 /* ===================================================== */
3801
3802 redraw_city_dialog(pcity);
3803 flush_dirty();
3804}
3805
3806/**********************************************************************/
3809void popdown_city_dialog(struct city *pcity)
3810{
3811 if (city_dialog_is_open(pcity)) {
3813
3814 flush_dirty();
3815
3817 menus_update();
3818 }
3819}
3820
3821/**********************************************************************/
3825{
3826 if (pcity_dlg) {
3828 }
3829}
3830
3831/**********************************************************************/
3835{
3836 if (city_dialog_is_open(pcity)) {
3838 flush_dirty();
3839 }
3840}
3841
3842/**********************************************************************/
3848{
3851
3852 if (pcity_dlg && ((pcity_dlg->pcity == city_sup)
3853 || (pcity_dlg->pcity == city_pre))) {
3856 flush_dirty();
3857 }
3858}
3859
3860/**********************************************************************/
3863bool city_dialog_is_open(struct city *pcity)
3864{
3865 return (pcity_dlg && (pcity_dlg->pcity == pcity));
3866}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
void astr_free(struct astring *astr)
Definition astring.c:153
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
#define BV_CLR(bv, bit)
Definition bitvector.h:86
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
int city_granary_size(int city_size)
Definition city.c:2132
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_population(const struct city *pcity)
Definition city.c:1191
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
Definition city.c:3049
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:820
bool city_unhappy(const struct city *pcity)
Definition city.c:1626
bool city_celebrating(const struct city *pcity)
Definition city.c:1645
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2870
bool city_happy(const struct city *pcity)
Definition city.c:1614
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
citizens city_specialists(const struct city *pcity)
Definition city.c:3317
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1996
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:700
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
@ CITIZEN_SPECIALIST
Definition city.h:273
@ CITIZEN_ANGRY
Definition city.h:271
@ CITIZEN_HAPPY
Definition city.h:268
@ CITIZEN_CONTENT
Definition city.h:269
@ CITIZEN_UNHAPPY
Definition city.h:270
#define city_owner(_pcity_)
Definition city.h:563
@ FEELING_FINAL
Definition city.h:284
@ FEELING_LAST
Definition city.h:285
#define city_built_iterate(_pcity, _p)
Definition city.h:834
#define city_built_iterate_end
Definition city.h:840
int city_rename(struct city *pcity, const char *name)
int city_buy_production(struct city *pcity)
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
void city_rotate_specialist(struct city *pcity, int citizen_index)
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
bool city_can_buy(const struct city *pcity)
struct civclient client
bool can_client_issue_orders(void)
#define client_player()
struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Definition climisc.c:1118
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:552
char * incite_cost
Definition comments.c:75
void request_unit_fortify(struct unit *punit)
Definition control.c:2353
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2094
void request_unit_sentry(struct unit *punit)
Definition control.c:2342
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:846
int get_city_bonus_effects(struct effect_list *plist, const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:1153
bool building_has_effect(const struct impr_type *pimprove, enum effect_type effect_type)
Definition effects.c:644
#define effect_list_iterate_end
Definition effects.h:406
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:404
QString current_theme
Definition fc_client.cpp:65
#define MAX_LEN_NAME
Definition fc_types.h:66
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_LUXURY
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const char * population_to_text(int thousand_citizen)
Definition game.c:734
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct city * game_city_by_number(int id)
Definition game.c:107
void canvas_free(struct canvas *store)
Definition canvas.c:44
struct canvas * canvas_create(int width, int height)
Definition canvas.c:28
@ HAPPINESS_PAGE
Definition citydlg.c:112
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
struct city * owner
Definition citydlg.c:226
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:595
void flush_dirty(void)
Definition mapview.c:468
static int units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:386
static void redraw_supported_units_city_dialog(struct widget *city_window, struct city *pcity)
Definition citydlg.c:1823
static int activate_and_exit_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:274
static int cancel_buy_prod_city_dlg_callback(struct widget *button)
Definition citydlg.c:1093
static int units_orders_dlg_callback(struct widget *button)
Definition citydlg.c:378
static int options_city_dlg_callback(struct widget *button)
Definition citydlg.c:1042
static void redraw_city_dialog(struct city *pcity)
Definition citydlg.c:2434
static int army_city_dlg_callback(struct widget *button)
Definition citydlg.c:832
static void rebuild_imprm_list(struct city *pcity)
Definition citydlg.c:3422
static void redraw_happiness_city_dialog(const struct widget *city_window, struct city *pcity)
Definition citydlg.c:2103
static void redraw_misc_city_dialog(struct widget *city_window, struct city *pcity)
Definition citydlg.c:1788
static void redraw_info_city_dialog(struct widget *city_window, struct city *pcity)
Definition citydlg.c:1937
static int new_name_city_dlg_callback(struct widget *pedit)
Definition citydlg.c:1743
static int sell_imprvm_dlg_cancel_callback(struct widget *cancel_button)
Definition citydlg.c:1373
static int next_prev_city_dlg_callback(struct widget *button)
Definition citydlg.c:1669
static void disable_city_dlg_widgets(void)
Definition citydlg.c:1598
static int sell_imprvm_dlg_ok_callback(struct widget *ok_button)
Definition citydlg.c:1390
static SDL_Surface * create_unit_surface(struct unit *punit, bool support, int w, int h)
Definition citydlg.c:619
static int resource_map_city_dlg_callback(struct widget *map)
Definition citydlg.c:1634
static void refresh_city_names(struct city *pcity)
Definition citydlg.c:1768
void enable_city_dlg_widgets(void)
Definition citydlg.c:1535
static int buy_prod_city_dlg_callback(struct widget *button)
Definition citydlg.c:1136
static int upgrade_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:363
static int fortify_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:314
static void redraw_army_city_dialog(struct widget *city_window, struct city *pcity)
Definition citydlg.c:1880
static void popdown_hurry_production_dialog(void)
Definition citydlg.c:1151
static int change_prod_dlg_callback(struct widget *button)
Definition citydlg.c:1353
specialist_type
Definition citydlg.c:109
@ SP_SCIENTIST
Definition citydlg.c:110
@ SP_LAST
Definition citydlg.c:110
@ SP_ELVIS
Definition citydlg.c:110
@ SP_TAXMAN
Definition citydlg.c:110
struct impr_type * get_building_for_effect(enum effect_type effect_type)
Definition citydlg.c:132
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
static void create_city_options_widget_list(struct city *pcity)
Definition citydlg.c:977
static int supported_unit_city_dlg_callback(struct widget *button)
Definition citydlg.c:852
static int city_comp_by_turn_founded(const void *a, const void *b)
Definition citydlg.c:1658
static int activate_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:257
static void popdown_city_menu_dlg(bool enable_city_dialog_widgets)
Definition citydlg.c:146
static struct small_dialog * hurry_prog_dlg
Definition citydlg.c:115
static int hurry_production_window_callback(struct widget *pwindow)
Definition citydlg.c:1164
static void del_city_dialog(void)
Definition citydlg.c:162
static int ok_buy_prod_city_dlg_callback(struct widget *button)
Definition citydlg.c:1110
static int cancel_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:239
static void rebuild_citydlg_title_str(struct widget *pwindow, struct city *pcity)
Definition citydlg.c:3513
static int cma_city_dlg_callback(struct widget *button)
Definition citydlg.c:1064
static int homecity_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:346
static int sentry_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:297
static struct city_dialog * pcity_dlg
static int exit_city_dlg_callback(struct widget *button)
Definition citydlg.c:1077
static int sell_imprvm_dlg_callback(struct widget *impr)
Definition citydlg.c:1424
static int info_city_dlg_callback(struct widget *button)
Definition citydlg.c:874
static int disband_units_orders_city_dlg_callback(struct widget *button)
Definition citydlg.c:331
static int happy_city_dlg_callback(struct widget *button)
Definition citydlg.c:895
static int city_dlg_callback(struct widget *pwindow)
Definition citydlg.c:199
static float city_map_zoom
Definition citydlg.c:113
SDL_Surface * get_scaled_city_map(struct city *pcity)
Definition citydlg.c:1620
static int misc_panel_city_dlg_callback(struct widget *pwidget)
Definition citydlg.c:915
void free_city_units_lists(void)
Definition citydlg.c:819
static void create_present_supported_units_widget_list(struct unit_list *units)
Definition citydlg.c:706
bool is_city_report_open(void)
Definition cityrep.c:1130
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
void put_window_near_map_tile(struct widget *pwindow, int window_width, int window_height, struct tile *ptile)
Definition dialogs.c:109
void popup_unit_disband_dlg(struct unit *punit, bool city)
Definition dialogs.c:878
void popup_unit_upgrade_dlg(struct unit *punit, bool city)
Definition dialogs.c:683
int main_window_width(void)
Definition graphics.c:685
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:925
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
Definition graphics.c:936
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
int main_window_height(void)
Definition graphics.c:693
SDL_Surface * resize_surface_box(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
Definition graphics.c:1257
#define DEFAULT_ZOOM
Definition graphics.h:198
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
@ ID_CITY_DLG_HAPPY_BUTTON
Definition gui_id.h:150
@ ID_CITY_DLG_CHANGE_PROD_BUTTON
Definition gui_id.h:159
@ ID_CITY_DLG_PROD_BUY_BUTTON
Definition gui_id.h:161
@ ID_CITY_DLG_WINDOW
Definition gui_id.h:145
@ ID_CITY_DLG_RESOURCE_MAP
Definition gui_id.h:158
@ ID_CITY_DLG_CMA_BUTTON
Definition gui_id.h:162
@ ID_CITY_DLG_NEXT_BUTTON
Definition gui_id.h:164
@ ID_BUTTON
Definition gui_id.h:29
@ ID_CITY_DLG_OPTIONS_BUTTON
Definition gui_id.h:166
@ ID_CITY_DLG_NAME_EDIT
Definition gui_id.h:165
@ ID_CITY_DLG_SUPPORT_BUTTON
Definition gui_id.h:152
@ ID_LABEL
Definition gui_id.h:27
@ ID_CITY_DLG_ARMY_BUTTON
Definition gui_id.h:151
@ ID_WINDOW
Definition gui_id.h:30
@ ID_REVOLUTION_DLG_WINDOW
Definition gui_id.h:140
@ ID_CITY_DLG_EXIT_BUTTON
Definition gui_id.h:146
@ ID_CITY_DLG_INFO_BUTTON
Definition gui_id.h:149
@ ID_CITY_DLG_PREV_BUTTON
Definition gui_id.h:163
Uint32 sdl2_client_flags
Definition gui_main.c:101
#define CF_CHANGED_CITY_NAME
Definition gui_main.h:53
struct widget * selected_widget
Definition widget.c:48
#define CF_CITY_STATUS_SPECIAL
Definition gui_main.h:54
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
void change_fonto_utf8(utf8_str *pstr, enum font_origin origin)
Definition gui_string.c:584
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_DEFAULT_PLUS
Definition gui_string.h:66
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
struct city_icon * icons
void reload_citizens_icons(int style)
SDL_Surface * get_city_gfx(void)
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
static SDL_Surface * get_citizen_surface(enum citizen_category type, int citizen_index)
static SDL_Surface * get_tax_surface(Output_type_id otype)
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
SDL_Surface * create_city_map(struct city *pcity)
Definition mapview.c:1201
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_CITYDLG
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
@ COLOR_THEME_CITYDLG_INFOPANEL
Definition themecolors.h:58
@ COLOR_THEME_CITYDLG_SELL
Definition themecolors.h:63
@ COLOR_THEME_CITYDLG_FOODPERTURN
Definition themecolors.h:49
@ COLOR_THEME_CITYDLG_IMPR
Definition themecolors.h:57
@ COLOR_THEME_CITYDLG_BUY
Definition themecolors.h:46
@ COLOR_THEME_CITYDLG_SHIELDSTOCK
Definition themecolors.h:64
@ COLOR_THEME_CITYDLG_LUX
Definition themecolors.h:59
@ COLOR_THEME_CITYDLG_TRADE
Definition themecolors.h:67
@ COLOR_THEME_CITYDLG_PROD
Definition themecolors.h:61
@ COLOR_THEME_CITYDLG_GROWTH
Definition themecolors.h:55
@ COLOR_THEME_CITYDLG_SUPPORT
Definition themecolors.h:66
@ COLOR_THEME_CITYDLG_GRANARY
Definition themecolors.h:54
@ COLOR_THEME_CITYDLG_SCIENCE
Definition themecolors.h:62
@ COLOR_THEME_CITYDLG_CORRUPTION
Definition themecolors.h:48
@ COLOR_THEME_CITYDLG_FOODSTOCK
Definition themecolors.h:50
@ COLOR_THEME_CITYDLG_GOLD
Definition themecolors.h:53
@ COLOR_THEME_CITYDLG_STOCKS
Definition themecolors.h:65
@ COLOR_THEME_CITYDLG_UPKEEP
Definition themecolors.h:68
@ COLOR_THEME_CITYDLG_FRAME
Definition themecolors.h:52
@ COLOR_THEME_CITYDLG_FOOD_SURPLUS
Definition themecolors.h:51
@ COLOR_THEME_CITYDLG_PANEL
Definition themecolors.h:60
@ COLOR_THEME_CHECKBOX_LABEL_TEXT
Definition themecolors.h:24
struct theme * active_theme
Definition themespec.c:154
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:898
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:863
void unselect_widget_action(void)
Definition widget.c:418
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:602
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *pwidget) fc__attribute((nonnull(2)))
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_ICON_CENTER_RIGHT
Definition widget.h:84
@ WF_FREE_THEME2
Definition widget.h:74
@ WF_SELECT_WITHOUT_BAR
Definition widget.h:89
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_icon_button(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_icon_button_from_chars_fonto(icon, pdest, char_string, fonto, flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
struct widget * create_textcheckbox(struct gui_layer *pdest, bool state, utf8_str *pstr, Uint32 flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
struct widget * create_themelabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint16 w, Uint16 h, Uint32 flags)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
struct impr_type * improvement_by_number(const Impr_type_id id)
int impr_sell_gold(const struct impr_type *pimprove)
bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_convert_improvement(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
void menus_update(void)
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1015
int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options, enum city_wl_cancel_behavior wl_cb)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
Specialist_type_id specialist_count(void)
Definition specialist.c:71
int step
Definition specpq.h:92
size_t size
Definition specvec.h:72
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
struct widget * resource_map
Definition citydlg.c:99
int citizen_step
Definition citydlg.c:102
struct advanced_dialog * imprv
Definition citydlg.c:87
bool lock
Definition citydlg.c:106
struct widget * begin_city_menu_widget_list
Definition citydlg.c:93
struct widget * end_city_widget_list
Definition citydlg.c:84
struct city * pcity
Definition citydlg.c:138
@ SUPPORTED_UNITS_PAGE
Definition citydlg.c:78
@ HAPPINESS_PAGE
Definition citydlg.c:76
SDL_Rect spec_area
Definition citydlg.c:104
enum city_dialog::@191 page
struct widget * begin_city_widget_list
Definition citydlg.c:83
struct widget * buy_button
Definition citydlg.c:98
struct widget * city_name_edit
Definition citydlg.c:100
struct widget * end_city_menu_widget_list
Definition citydlg.c:94
QPushButton * buy_button
Definition citydlg.h:483
struct widget * add_point
Definition citydlg.c:97
struct advanced_dialog * panel
Definition citydlg.c:90
SDL_Surface * pollution
SDL_Surface * shield
SDL_Surface * coint
SDL_Surface * big_trade_corr
SDL_Surface * trade
SDL_Surface * big_shield_corr
SDL_Surface * big_trade
SDL_Surface * face
SDL_Surface * food
SDL_Surface * female_angry
SDL_Surface * big_shield
SDL_Surface * specialists[SP_MAX]
SDL_Surface * female_happy
SDL_Surface * big_luxury
SDL_Surface * female_content
SDL_Surface * police
SDL_Surface * big_colb
SDL_Surface * big_coin_upkeep
SDL_Surface * female_unhappy
SDL_Surface * male_unhappy
SDL_Surface * male_content
SDL_Surface * big_food
SDL_Surface * big_coin_corr
SDL_Surface * male_happy
SDL_Surface * big_coin
SDL_Surface * big_food_corr
SDL_Surface * male_angry
SDL_Surface * big_food_surplus
SDL_Surface * big_shield_surplus
Definition city.h:320
int surplus[O_LAST]
Definition city.h:355
enum city_wl_cancel_behavior wlcb
Definition city.h:404
int food_stock
Definition city.h:367
int pollution
Definition city.h:369
bool did_sell
Definition city.h:380
int id
Definition city.h:326
int waste[O_LAST]
Definition city.h:356
struct unit_list * info_units_present
Definition city.h:474
bv_city_options city_options
Definition city.h:403
struct player * owner
Definition city.h:323
int turn_founded
Definition city.h:386
bool did_buy
Definition city.h:379
struct unit_list * info_units_supported
Definition city.h:473
struct universal production
Definition city.h:396
int buy_cost
Definition city.h:466
citizens feel[CITIZEN_LAST][FEELING_LAST]
Definition city.h:333
citizens specialists[SP_MAX]
Definition city.h:336
struct tile * tile
Definition city.h:322
int shield_stock
Definition city.h:368
int prod[O_LAST]
Definition city.h:358
struct unit_list * units_supported
Definition city.h:406
struct city::@17::@20 client
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
SDL_Surface * surface
Definition graphics.h:229
SDL_Rect dest_rect
Definition graphics.h:228
struct city_list * cities
Definition player.h:279
struct widget * up_left_button
struct widget * down_right_button
struct widget * pscroll_bar
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
struct unit_list * units
Definition tile.h:58
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int id
Definition unit.h:145
int hp
Definition unit.h:151
enum direction8 facing
Definition unit.h:142
int homecity
Definition unit.h:146
int veteran
Definition unit.h:152
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
char * text
Definition gui_string.h:60
void * ptr
Definition widget.h:133
union widget::@194 data
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
SDL_Surface * theme2
Definition widget.h:119
struct widget * prev
Definition widget.h:114
struct unit * unit
Definition widget.h:129
struct gui_layer * dst
Definition widget.h:116
struct city * city
Definition widget.h:128
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
struct civ_map map
int style_of_city(const struct city *pcity)
Definition style.c:202
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:836
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define sz_strlcat(dest, src)
Definition support.h:196
const char * get_nearest_city_text(struct city *pcity, int sq_dist)
Definition text.c:441
const char * unit_description(struct unit *punit)
Definition text.c:475
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:789
int tileset_unit_with_small_upkeep_height(const struct tileset *t)
Definition tilespec.c:871
int tileset_unit_layout_small_offset_y(const struct tileset *t)
Definition tilespec.c:891
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:776
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
#define trade_routes_iterate_end
#define trade_routes_iterate(c, proute)
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
void unit_activity_astr(const struct unit *punit, struct astring *astr)
Definition unit.c:1155
#define unit_tile(_pu)
Definition unit.h:397
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const char * utype_veteran_name_translation(const struct unit_type *punittype, int level)
Definition unittype.c:2610
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1438
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560