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/* SDL3 */
27#include <SDL3/SDL.h>
28
29/* utility */
30#include "astring.h"
31#include "bitvector.h"
32#include "fcintl.h"
33#include "log.h"
34
35/* common */
36#include "game.h"
37#include "movement.h"
38#include "specialist.h"
39#include "unitlist.h"
40
41/* client */
42#include "client_main.h"
43#include "climisc.h"
44#include "control.h"
45#include "text.h"
46
47/* gui-sdl3 */
48#include "cityrep.h"
49#include "cma_fe.h"
50#include "colors.h"
51#include "dialogs.h"
52#include "graphics.h"
53#include "gui_id.h"
54#include "gui_main.h"
55#include "gui_tilespec.h"
56#include "mapview.h"
57#include "menu.h"
58#include "sprite.h"
59#include "themespec.h"
60#include "widget.h"
61#include "wldlg.h"
62
63#include "citydlg.h"
64
65/* ============================================================= */
66
67static struct city_dialog {
68 struct city *pcity;
69
70 enum {
71 INFO_PAGE = 0,
77
78 /* main window group list */
81
82 /* Imprvm. vscrollbar */
83 struct advanced_dialog *imprv;
84
85 /* Penel group list */
86 struct advanced_dialog *panel;
87
88 /* Menu imprv. dlg. */
91
92 /* shortcuts */
93 struct widget *add_point;
94 struct widget *buy_button;
95 struct widget *resource_map;
96 struct widget *city_name_edit;
97
98 int citizen_step;
99
101
102 bool lock;
104
108
109static float city_map_zoom = 1;
110
112
113static void popdown_hurry_production_dialog(void);
114static void disable_city_dlg_widgets(void);
115static void redraw_city_dialog(struct city *pcity);
116static void rebuild_imprm_list(struct city *pcity);
117static void rebuild_citydlg_title_str(struct widget *pwindow, struct city *pcity);
118
119/* ======================================================================= */
120
121/**********************************************************************/
128struct impr_type *get_building_for_effect(enum effect_type effect_type)
129{
130 improvement_iterate(pimprove) {
131 if (building_has_effect(pimprove, effect_type)) {
132 return pimprove;
133 }
135
136 return NULL;
137}
138
139/**********************************************************************/
154
155/**********************************************************************/
190
191/**********************************************************************/
195static int city_dlg_callback(struct widget *pwindow)
196{
200
201 if (is_in_rect_area(main_data.event.motion.x, main_data.event.motion.y,
202 &(pcity_dlg->spec_area))) {
204 (main_data.event.motion.x - pcity_dlg->spec_area.x)
206
207 return -1;
208 }
209 }
210
211 if (!pcity_dlg->lock) {
212 if (pcity_dlg->panel) {
216 widget_flush(pwindow);
217 } else {
219 widget_flush(pwindow);
220 }
221 }
222 }
223 }
224
225 return -1;
226}
227
228/* ===================================================================== */
229/* ========================== Units Orders Menu ======================== */
230/* ===================================================================== */
231
232/**********************************************************************/
249
250/**********************************************************************/
254{
256 struct unit *punit = button->data.unit;
257
259 if (punit) {
261 }
262 }
263
264 return -1;
265}
266
267/**********************************************************************/
289
290/**********************************************************************/
294{
296 struct unit *punit = button->data.unit;
297
299 if (punit) {
301 }
302 }
303
304 return -1;
305}
306
307/**********************************************************************/
311{
313 struct unit *punit = button->data.unit;
314
316 if (punit) {
318 }
319 }
320
321 return -1;
322}
323
324/**********************************************************************/
328{
330 struct unit *punit = button->data.unit;
331
334 }
335
336 return -1;
337}
338
339/**********************************************************************/
343{
345 struct unit *punit = button->data.unit;
346
348 if (punit) {
350 }
351 }
352
353 return -1;
354}
355
356/**********************************************************************/
360{
362 struct unit *punit = button->data.unit;
363
366 }
367
368 return -1;
369}
370
371/**********************************************************************/
374static int units_orders_dlg_callback(struct widget *button)
375{
376 return -1;
377}
378
379/**********************************************************************/
382static int units_orders_city_dlg_callback(struct widget *button)
383{
385 && main_data.event.button.button == SDL_BUTTON_RIGHT);
386
388 utf8_str *pstr;
389 char cbuf[80];
390 struct widget *buf, *pwindow;
391 struct unit *punit;
392 const struct unit_type *putype;
393 Uint16 i = 0, hh = 0;
394 SDL_Rect area;
395
397
398 if (punit == NULL || !can_client_issue_orders()) {
399 return -1;
400 }
401
402 if (right_button) {
406
407 return -1;
408 }
409
410 /* Disable city dlg */
413
415
416 /* Window */
417 fc_snprintf(cbuf, sizeof(cbuf), "%s:", _("Unit commands"));
419 pstr->style |= TTF_STYLE_BOLD;
420 pwindow = create_window_skeleton(NULL, pstr, 0);
421
423 set_wstate(pwindow, FC_WS_NORMAL);
426
427 area = pwindow->area;
428
429 /* Unit description */
430 fc_snprintf(cbuf, sizeof(cbuf), "%s", unit_description(punit));
432 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
434 pwindow->dst, pstr, WF_FREE_THEME);
435 area.w = MAX(area.w, buf->size.w);
437
438 /* Activate unit */
440 _("Activate unit"),
441 FONTO_ATTENTION, 0);
442 i++;
443 area.w = MAX(area.w, buf->size.w);
444 hh = MAX(hh, buf->size.h);
446 buf->data = button->data;
448 add_to_gui_list(button->id, buf);
449
450 /* Activate unit, close dlg. */
452 _("Activate unit, close dialog"),
453 FONTO_ATTENTION, 0);
454 i++;
455 area.w = MAX(area.w, buf->size.w);
456 hh = MAX(hh, buf->size.h);
458 buf->data = button->data;
460 add_to_gui_list(button->id, buf);
461 /* ----- */
462
463 if (pcity_dlg->page == ARMY_PAGE) {
464 /* Sentry unit */
466 _("Sentry unit"),
467 FONTO_ATTENTION, 0);
468 i++;
469 area.w = MAX(area.w, buf->size.w);
470 hh = MAX(hh, buf->size.h);
471 buf->data = button->data;
476 }
477 add_to_gui_list(button->id, buf);
478 /* ----- */
479
480 /* Fortify unit */
482 _("Fortify unit"),
483 FONTO_ATTENTION, 0);
484 i++;
485 area.w = MAX(area.w, buf->size.w);
486 hh = MAX(hh, buf->size.h);
487 buf->data = button->data;
492 }
493 add_to_gui_list(button->id, buf);
494 }
495 /* ----- */
496
497 /* Disband unit */
499 _("Disband unit"),
500 FONTO_ATTENTION, 0);
501 i++;
502 area.w = MAX(area.w, buf->size.w);
503 hh = MAX(hh, buf->size.h);
504 buf->data = button->data;
507 add_to_gui_list(button->id, buf);
508 /* ----- */
509
510 if (pcity_dlg->page == ARMY_PAGE) {
511 if (punit->homecity != pcity_dlg->pcity->id) {
512 /* Make new Homecity */
515 FONTO_ATTENTION, 0);
516 i++;
517 area.w = MAX(area.w, buf->size.w);
518 hh = MAX(hh, buf->size.h);
519 buf->data = button->data;
522 add_to_gui_list(button->id, buf);
523 }
524 /* ----- */
525
527 /* Upgrade unit */
529 _("Upgrade unit"),
530 FONTO_ATTENTION, 0);
531 i++;
532 area.w = MAX(area.w, buf->size.w);
533 hh = MAX(hh, buf->size.h);
534 buf->data = button->data;
537 add_to_gui_list(button->id, buf);
538 }
539 }
540
541 /* ----- */
542 /* Cancel */
544 _("Cancel"),
545 FONTO_ATTENTION, 0);
546 i++;
547 area.w = MAX(area.w, buf->size.w);
548 hh = MAX(hh, buf->size.h);
549 buf->key = SDLK_ESCAPE;
552 add_to_gui_list(button->id, buf);
554
555 /* ================================================== */
557 /* ================================================== */
558
559 area.w += adj_size(10);
560 hh += adj_size(4);
561
562 /* Create window background */
564 (pwindow->size.w - pwindow->area.w) + area.w,
565 (pwindow->size.h - pwindow->area.h) + pwindow->prev->size.h +
566 (i * hh) + adj_size(5));
567
568 area = pwindow->area;
569
570 widget_set_position(pwindow,
571 button->size.x + adj_size(2),
572 pwindow->area.y + button->size.y + 1);
573
574 /* Label */
575 buf = pwindow->prev;
576 buf->size.w = area.w;
577 buf->size.x = area.x;
578 buf->size.y = area.y + 1;
579 buf = buf->prev;
580
581 /* First button */
582 buf->size.w = area.w;
583 buf->size.h = hh;
584 buf->size.x = area.x;
585 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
586 buf = buf->prev;
587
588 while (buf != NULL) {
589 buf->size.w = area.w;
590 buf->size.h = hh;
591 buf->size.x = buf->next->size.x;
592 buf->size.y = buf->next->size.y + buf->next->size.h;
594 break;
595 }
596 buf = buf->prev;
597 }
598
599 /* ================================================== */
600 /* Redraw */
602 widget_flush(pwindow);
603 }
604
605 return -1;
606}
607
608/* ======================================================================= */
609/* ======================= City Dlg. Panels ============================== */
610/* ======================================================================= */
611
612/**********************************************************************/
615static SDL_Surface *create_unit_surface(struct unit *punit, bool support,
616 int w, int h)
617{
620 struct canvas *destcanvas;
621 const struct civ_map *nmap = &(wld.map);
622
625
626 put_unit(punit, destcanvas, 1.0, 0, 0);
627
628 /* Get unit sprite width, and crop top. Bottom might get restored in 'support'
629 * case below. */
631
632 if (support) {
633 int i, step;
634 int free_unhappy;
635 int happy_cost;
636 SDL_Rect dest;
638
639 /* Support also layouts placing support icons higher than unit. */
640 src_rect.y = MIN(src_rect.y, offset);
641 /* Restore bottom space when needed for support icons. */
642 src_rect.h = destcanvas->surf->h - src_rect.y;
643
646
648 punit->upkeep[O_GOLD] + happy_cost;
649
650 if (i * icons->food->w > src_rect.w / 2) {
651 step = (src_rect.w / 2 - icons->food->w) / (i - 1);
652 } else {
653 step = icons->food->w;
654 }
655
657 dest.x = src_rect.x + src_rect.w / 8;
658
659 for (i = 0; i < punit->upkeep[O_SHIELD]; i++) {
660 alphablit(icons->shield, NULL, destcanvas->surf, &dest, 255);
661 dest.x += step;
662 }
663
664 for (i = 0; i < punit->upkeep[O_FOOD]; i++) {
665 alphablit(icons->food, NULL, destcanvas->surf, &dest, 255);
666 dest.x += step;
667 }
668
669 for (i = 0; i < punit->upkeep[O_GOLD]; i++) {
670 alphablit(icons->coint, NULL, destcanvas->surf, &dest, 255);
671 dest.x += step;
672 }
673
674 for (i = 0; i < happy_cost; i++) {
675 alphablit(icons->face, NULL, destcanvas->surf, &dest, 255);
676 dest.x += step;
677 }
678
679 }
680
682 alphablit(destcanvas->surf, &src_rect, psurf, NULL, 255);
683
685
686 if (w != src_rect.w || h != src_rect.h) {
688
691 psurf = pzoomed;
692 }
693
694 return psurf;
695}
696
697/**********************************************************************/
702static void create_present_supported_units_widget_list(struct unit_list *units)
703{
704 int i;
705 struct widget *buf = NULL;
706 struct widget *end = NULL;
707 struct widget *pwindow = pcity_dlg->end_city_widget_list;
708 struct city *home_city;
709 const struct unit_type *putype;
710 SDL_Surface *surf;
711 utf8_str *pstr;
712 char cbuf[256];
713 int num_x, num_y, w, h;
714
715 i = 0;
716
718 if (num_x < 4) {
719 num_x = 4;
720 w = adj_size(160 - 4*4) / 4;
721 } else {
723 }
724
726 if (num_y < 4) {
727 num_y = 4;
728 h = adj_size(151 - 4*4) / 4;
729 } else {
731 }
732
733 unit_list_iterate(units, punit) {
734 const char *vetname;
736
741 fc_snprintf(cbuf, sizeof(cbuf), "%s (%d,%d,%s)%s%s\n%s\n(%d/%d)\n%s",
743 putype->attack_strength,
744 putype->defense_strength,
745 move_points_text(putype->move_rate, FALSE),
746 (vetname != NULL ? "\n" : ""),
747 (vetname != NULL ? vetname : ""),
749 punit->hp, putype->hp,
750 home_city ? home_city->name : Q_("?homecity:None"));
752
753 if (pcity_dlg->page == SUPPORTED_UNITS_PAGE) {
754 int city_near_dist;
756
757 sz_strlcat(cbuf, "\n");
759 surf = adj_surf(create_unit_surface(punit, TRUE, w, h));
760 } else {
761 surf = adj_surf(create_unit_surface(punit, FALSE, w, h));
762 }
763
765 pstr->style |= SF_CENTER;
766
767 buf = create_icon2(surf, pwindow->dst, WF_FREE_THEME
769 buf->info_label = pstr;
770 buf->data.unit = punit;
772
773 if (!end) {
774 end = buf;
775 }
776
777 if (++i > num_x * num_y) {
779 }
780
783 }
784
787
788 pcity_dlg->panel = fc_calloc(1, sizeof(struct advanced_dialog));
794
796 pwindow->area.x + adj_size(5),
797 pwindow->area.y + adj_size(44),
800
801 if (i > num_x * num_y) {
803 num_x, num_y, TRUE, TRUE);
804
806 pwindow->area.x + adj_size(185),
807 pwindow->area.y + adj_size(45),
808 adj_size(150), TRUE);
809 }
810}
811
812/**********************************************************************/
824
825/**********************************************************************/
828static int army_city_dlg_callback(struct widget *button)
829{
831 if (pcity_dlg->page != ARMY_PAGE) {
833 pcity_dlg->page = ARMY_PAGE;
835 flush_dirty();
836 } else {
837 widget_redraw(button);
838 widget_flush(button);
839 }
840 }
841
842 return -1;
843}
844
845/**********************************************************************/
848static int supported_unit_city_dlg_callback(struct widget *button)
849{
851 if (pcity_dlg->page != SUPPORTED_UNITS_PAGE) {
853 pcity_dlg->page = SUPPORTED_UNITS_PAGE;
855 flush_dirty();
856 } else {
857 widget_redraw(button);
858 widget_flush(button);
859 }
860 }
861
862 return -1;
863}
864
865/* ---------------------- */
866
867/**********************************************************************/
870static int info_city_dlg_callback(struct widget *button)
871{
873 if (pcity_dlg->page != INFO_PAGE) {
875 pcity_dlg->page = INFO_PAGE;
877 flush_dirty();
878 } else {
879 widget_redraw(button);
880 widget_flush(button);
881 }
882 }
883
884 return -1;
885}
886
887/* ---------------------- */
888/**********************************************************************/
891static int happy_city_dlg_callback(struct widget *button)
892{
894 if (pcity_dlg->page != HAPPINESS_PAGE) {
898 flush_dirty();
899 } else {
900 widget_redraw(button);
901 widget_flush(button);
902 }
903 }
904
905 return -1;
906}
907
908/**********************************************************************/
911static int misc_panel_city_dlg_callback(struct widget *pwidget)
912{
915
916 switch (MAX_ID - pwidget->id) {
917 case 0x10:
920 } else {
922 }
923 break;
924 case 0x20:
927 } else {
929 }
932 } else {
934 }
935
936 pwidget->theme2 = get_tax_surface(O_GOLD);
937 pwidget->id = MAX_ID - 0x40;
938 widget_redraw(pwidget);
939 widget_flush(pwidget);
940 break;
941 case 0x40:
944 pwidget->theme2 = get_tax_surface(O_LUXURY);
945 pwidget->id = MAX_ID - 0x60;
946 widget_redraw(pwidget);
947 widget_flush(pwidget);
948 break;
949 case 0x60:
952 } else {
954 }
955
956 pwidget->theme2 = get_tax_surface(O_SCIENCE);
957 pwidget->id = MAX_ID - 0x20;
958 widget_redraw(pwidget);
959 widget_flush(pwidget);
960 break;
961 }
962
965 }
966
967 return -1;
968}
969
970/**********************************************************************/
973static void create_city_options_widget_list(struct city *pcity)
974{
975 struct widget *buf, *pwindow = pcity_dlg->end_city_widget_list;
976 SDL_Surface *surf;
977 utf8_str *pstr;
978 char cbuf[80];
979
980 fc_snprintf(cbuf, sizeof(cbuf),
981 _("Allow unit production\nto disband city"));
983 pstr->style |= TTF_STYLE_BOLD;
985
986 buf =
987 create_textcheckbox(pwindow->dst,
992 add_to_gui_list(MAX_ID - 0x10, buf);
993 buf->size.x = pwindow->area.x + adj_size(7);
994 buf->size.y = pwindow->area.y + adj_size(45);
995
996 /* ----- */
997
998 pcity_dlg->panel = fc_calloc(1, sizeof(struct advanced_dialog));
1000
1001 /* ----- */
1002
1003 fc_snprintf(cbuf, sizeof(cbuf), "%s:", _("New citizens produce"));
1005 pstr->style |= SF_CENTER;
1006
1008 surf = get_tax_surface(O_SCIENCE);
1009 buf = create_icon_button(surf, pwindow->dst, pstr,
1011 add_to_gui_list(MAX_ID - 0x20, buf);
1012 } else {
1014 surf = get_tax_surface(O_GOLD);
1015 buf = create_icon_button(surf, pwindow->dst,
1017 add_to_gui_list(MAX_ID - 0x40, buf);
1018 } else {
1019 surf = get_tax_surface(O_LUXURY);
1020 buf = create_icon_button(surf, pwindow->dst,
1022 add_to_gui_list(MAX_ID - 0x60, buf);
1023 }
1024 }
1025
1026 buf->size.w = adj_size(177);
1029
1030 buf->size.x = buf->next->size.x;
1031 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
1033}
1034
1035/**********************************************************************/
1038static int options_city_dlg_callback(struct widget *button)
1039{
1041 if (pcity_dlg->page != MISC_PAGE) {
1043 pcity_dlg->page = MISC_PAGE;
1045 flush_dirty();
1046 } else {
1047 widget_redraw(button);
1048 widget_flush(button);
1049 }
1050 }
1051
1052 return -1;
1053}
1054
1055/* ======================================================================= */
1056
1057/**********************************************************************/
1060static int cma_city_dlg_callback(struct widget *button)
1061{
1065 }
1066
1067 return -1;
1068}
1069
1070/**********************************************************************/
1073static int exit_city_dlg_callback(struct widget *button)
1074{
1077 }
1078
1079 return -1;
1080}
1081
1082/* ======================================================================= */
1083/* ======================== Buy Production Dlg. ========================== */
1084/* ======================================================================= */
1085
1086/**********************************************************************/
1090{
1093
1094 if (pcity_dlg) {
1095 /* enable city dlg */
1097 }
1098 }
1099
1100 return -1;
1101}
1102
1103/**********************************************************************/
1106static int ok_buy_prod_city_dlg_callback(struct widget *button)
1107{
1109 struct city *pcity = button->data.city; /* Save it. */
1110
1112 city_buy_production(pcity);
1113
1114 if (pcity_dlg) {
1115 /* enable city dlg */
1117
1118 /* disable buy button */
1122 flush_dirty();
1123 }
1124 }
1125
1126 return -1;
1127}
1128
1129/**********************************************************************/
1132static int buy_prod_city_dlg_callback(struct widget *button)
1133{
1135 widget_redraw(button);
1136 widget_flush(button);
1139 }
1140
1141 return -1;
1142}
1143
1144/**********************************************************************/
1156
1157/**********************************************************************/
1160static int hurry_production_window_callback(struct widget *pwindow)
1161{
1164 }
1165
1166 return -1;
1167}
1168
1169/**********************************************************************/
1173{
1174 char tbuf[512], cbuf[512];
1175 struct widget *buf = NULL, *pwindow;
1176 utf8_str *pstr;
1177 SDL_Surface *text;
1178 SDL_Rect dst;
1179 int window_x = 0, window_y = 0;
1180 SDL_Rect area;
1181 const char *name = city_production_name_translation(pcity);
1182 int value = pcity->client.buy_cost;
1183
1184 if (hurry_prog_dlg) {
1185 return;
1186 }
1187
1188 fc_snprintf(tbuf, ARRAY_SIZE(tbuf), PL_("Treasury contains %d gold.",
1189 "Treasury contains %d gold.",
1190 client_player()->economic.gold),
1191 client_player()->economic.gold);
1192
1193 hurry_prog_dlg = fc_calloc(1, sizeof(struct small_dialog));
1194
1195 if (city_can_buy(pcity)) {
1196 if (value <= client_player()->economic.gold) {
1197 fc_snprintf(cbuf, sizeof(cbuf),
1198 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
1199 PL_("Buy %s for %d gold?\n%s",
1200 "Buy %s for %d gold?\n%s", value),
1201 name, value, tbuf);
1202 } else {
1203 fc_snprintf(cbuf, sizeof(cbuf),
1204 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
1205 PL_("%s costs %d gold.\n%s",
1206 "%s costs %d gold.\n%s", value),
1207 name, value, tbuf);
1208 }
1209 } else {
1210 if (pcity->did_buy) {
1211 fc_snprintf(cbuf, sizeof(cbuf),
1212 _("Sorry, you have already bought here in this turn."));
1213 } else {
1214 fc_snprintf(cbuf, sizeof(cbuf),
1215 _("Sorry, you can't buy here in this turn."));
1216 }
1217 }
1218
1220 pstr->style |= TTF_STYLE_BOLD;
1221 pwindow = create_window_skeleton(NULL, pstr, 0);
1222 pwindow->action = hurry_production_window_callback;
1223 set_wstate(pwindow, FC_WS_NORMAL);
1224 add_to_gui_list(ID_WINDOW, pwindow);
1225
1227
1228 area = pwindow->area;
1229
1230 area.h += 1;
1231
1232 /* ============================================================= */
1233
1234 /* Label */
1236 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1238
1241 area.w = MAX(area.w , text->w);
1242 area.h += text->h + adj_size(5);
1243
1245 pwindow->dst, _("No"),
1246 FONTO_ATTENTION, 0);
1247
1250 buf->key = SDLK_ESCAPE;
1251 area.h += buf->size.h;
1252
1254
1255 if (city_can_buy(pcity) && (value <= client.conn.playing->economic.gold)) {
1257 pwindow->dst,
1258 _("Yes"),
1259 FONTO_ATTENTION, 0);
1260
1263 buf->data.city = pcity;
1264 buf->key = SDLK_RETURN;
1266 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1267 buf->next->size.w = buf->size.w;
1268 area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
1269 }
1270
1272
1273 /* Setup window size and start position */
1274 area.w += adj_size(10);
1275 area.h += adj_size(5);
1276
1278 (pwindow->size.w - pwindow->area.w) + area.w,
1279 (pwindow->size.h - pwindow->area.h) + area.h);
1280
1281 area = pwindow->area;
1282
1283 if (city_dialog_is_open(pcity)) {
1284 window_x = pcity_dlg->buy_button->size.x;
1285 window_y = pcity_dlg->buy_button->size.y - pwindow->size.h;
1286 } else if (is_city_report_open()) {
1288
1290 + pwindow->size.w > main_window_width()) {
1291 window_x = selected_widget->size.x - pwindow->size.w;
1292 } else {
1294 }
1295
1297 + (selected_widget->size.h - pwindow->size.h) / 2;
1298
1299 if (window_y + pwindow->size.h > main_window_height()) {
1300 window_y = main_window_height() - pwindow->size.h - 1;
1301 } else if (window_y < 0) {
1302 window_y = 0;
1303 }
1304 } else {
1305 put_window_near_map_tile(pwindow, pwindow->size.w, pwindow->size.h, pcity->tile);
1306 }
1307
1309
1310 /* Setup rest of widgets */
1311 /* Label */
1312 dst.x = area.x + (area.w - text->w) / 2;
1313 dst.y = area.y + 1;
1314 alphablit(text, NULL, pwindow->theme, &dst, 255);
1315 dst.y += text->h + adj_size(5);
1316 FREESURFACE(text);
1317
1318 /* No */
1319 buf = pwindow->prev;
1320 buf->size.y = dst.y;
1321
1322 if (city_can_buy(pcity) && value <= client.conn.playing->economic.gold) {
1323 /* Yes */
1324 buf = buf->prev;
1325 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
1326 buf->size.y = dst.y;
1327
1328 /* No */
1329 buf->next->size.x = buf->size.x + buf->size.w + adj_size(20);
1330 } else {
1331 /* No */
1332 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
1333 }
1334
1335 /* ================================================== */
1336 /* Redraw */
1338 widget_mark_dirty(pwindow);
1339 flush_dirty();
1340}
1341
1342/* =======================================================================*/
1343/* ========================== CHANGE PRODUCTION ==========================*/
1344/* =======================================================================*/
1345
1346/**********************************************************************/
1349static int change_prod_dlg_callback(struct widget *button)
1350{
1352 widget_redraw(button);
1353 widget_flush(button);
1354
1357 }
1358
1359 return -1;
1360}
1361
1362/* =======================================================================*/
1363/* ========================== SELL IMPROVEMENTS ==========================*/
1364/* =======================================================================*/
1365
1366/**********************************************************************/
1382
1383/**********************************************************************/
1386static int sell_imprvm_dlg_ok_callback(struct widget *ok_button)
1387{
1389 struct widget *tmp = (struct widget *)ok_button->data.ptr;
1390
1392
1393 /* popdown, we don't redraw and flush because this is made by redraw city dlg.
1394 when response from server comes */
1397
1399
1400 /* del imprv from widget list */
1402
1404
1408 }
1409
1411 flush_dirty();
1412 }
1413
1414 return -1;
1415}
1416
1417/**********************************************************************/
1420static int sell_imprvm_dlg_callback(struct widget *impr)
1421{
1423 utf8_str *pstr = NULL;
1424 struct widget *label = NULL;
1425 struct widget *pwindow = NULL;
1426 struct widget *cancel_button = NULL;
1427 struct widget *ok_button = NULL;
1428 char cbuf[80];
1429 int id;
1430 SDL_Rect area;
1431 int price;
1432
1435
1437 pstr->style |= TTF_STYLE_BOLD;
1438 pwindow = create_window_skeleton(NULL, pstr, 0);
1439 /*pwindow->action = move_sell_imprvm_dlg_callback; */
1440 /*set_wstate(pwindow, FC_WS_NORMAL); */
1441 add_to_gui_list(ID_WINDOW, pwindow);
1443
1444 area = pwindow->area;
1445
1446 /* Create text label */
1447 id = MAX_ID - 3000 - impr->id;
1448
1450 fc_snprintf(cbuf, sizeof(cbuf), PL_("Sell %s for %d gold?",
1451 "Sell %s for %d gold?", price),
1454 price);
1456 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1458 label = create_iconlabel(NULL, pwindow->dst, pstr, 0);
1459 add_to_gui_list(ID_LABEL, label);
1460
1461 /* Create cancel button */
1462 cancel_button =
1464 pwindow->dst, _("Cancel"),
1465 FONTO_DEFAULT, 0);
1466 cancel_button->action = sell_imprvm_dlg_cancel_callback;
1467 cancel_button->key = SDLK_ESCAPE;
1468 set_wstate(cancel_button, FC_WS_NORMAL);
1469 add_to_gui_list(ID_BUTTON, cancel_button);
1470
1471 /* create ok button */
1473 pwindow->dst, _("Sell"),
1474 FONTO_DEFAULT, 0);
1475 ok_button->data.ptr = (void *)impr;
1476 ok_button->size.w = cancel_button->size.w;
1478 ok_button->key = SDLK_RETURN;
1479 set_wstate(ok_button, FC_WS_NORMAL);
1480 add_to_gui_list(ID_BUTTON, ok_button);
1481
1483
1484 /* correct sizes */
1485 if ((ok_button->size.w + cancel_button->size.w + adj_size(30)) >
1486 label->size.w + adj_size(20)) {
1487 area.w = MAX(area.w, ok_button->size.w + cancel_button->size.w + adj_size(30));
1488 } else {
1489 area.w = MAX(area.w, label->size.w + adj_size(20));
1490 }
1491
1492 area.h = MAX(area.h, ok_button->size.h + label->size.h + adj_size(25));
1493
1494 /* create window background */
1496 (pwindow->size.w - pwindow->area.w) + area.w,
1497 (pwindow->size.h - pwindow->area.h) + area.h);
1498
1499 area = pwindow->area;
1500
1501 /* set start positions */
1502 widget_set_position(pwindow,
1503 (main_window_width() - pwindow->size.w) / 2,
1504 (main_window_height() - pwindow->size.h) / 2 + adj_size(10));
1505
1506 ok_button->size.x = area.x + adj_size(10);
1507 ok_button->size.y = area.y + area.h - ok_button->size.h - adj_size(10);
1508
1509 cancel_button->size.y = ok_button->size.y;
1510 cancel_button->size.x = area.x + area.w - cancel_button->size.w - adj_size(10);
1511
1512 label->size.x = area.x;
1513 label->size.y = area.y + adj_size(4);
1514 label->size.w = area.w;
1515
1516 /* redraw */
1519
1520 widget_mark_dirty(pwindow);
1521 flush_dirty();
1522 }
1523
1524 return -1;
1525}
1526/* ====================================================================== */
1527
1528/**********************************************************************/
1532{
1533 if (pcity_dlg) {
1536
1538 if (pcity_dlg->imprv->scroll) {
1542 }
1543
1544 /* There is common function test_player_sell_building_now(),
1545 * but we are not using it here, since we want to use set_group_state()
1546 * when possible */
1551 } else {
1553
1554 while (TRUE) {
1555 struct impr_type *pimpr = improvement_by_number(MAX_ID - 3000 -
1556 tmp_widget->id);
1557
1560 } else {
1562 }
1563
1565 break;
1566 }
1567
1568 tmp_widget = tmp_widget->prev;
1569
1570 } /* while */
1571 }
1572 }
1573
1576 }
1577
1578 if (pcity_dlg->panel) {
1581 }
1582
1585 }
1586
1587 pcity_dlg->lock = FALSE;
1588 }
1589}
1590
1591/**********************************************************************/
1610
1611/* ======================================================================== */
1612
1613/**********************************************************************/
1617{
1619
1620 city_map_zoom = ((buf->w * 159 > buf->h * 249) ?
1621 (float)adj_size(249) / buf->w
1622 : (float)adj_size(159) / buf->h);
1623
1625}
1626
1627/**********************************************************************/
1631{
1633 int col, row;
1634
1635 if (canvas_to_city_pos(&col, &row,
1637 1 / city_map_zoom * (main_data.event.motion.x - map->dst->dest_rect.x
1638 - map->size.x),
1639 1 / city_map_zoom * (main_data.event.motion.y - map->dst->dest_rect.y
1640 - map->size.y))) {
1641
1643 }
1644 }
1645
1646 return -1;
1647}
1648
1649/* ====================================================================== */
1650
1651/**********************************************************************/
1654static int city_comp_by_turn_founded(const void *a, const void *b)
1655{
1656 struct city *pcity1 = *((struct city **) a);
1657 struct city *pcity2 = *((struct city **) b);
1658
1659 return pcity1->turn_founded - pcity2->turn_founded;
1660}
1661
1662/**********************************************************************/
1665static int next_prev_city_dlg_callback(struct widget *button)
1666{
1668 struct city **array;
1669 int i, dir, non_open_size;
1671
1672 fc_assert_ret_val(size >= 1, -1);
1674 == client.conn.playing, -1);
1675
1676 if (size == 1) {
1677 return -1;
1678 }
1679
1680 /* dir = 1 will advance to the city, dir = -1 will get previous */
1681 if (button->id == ID_CITY_DLG_NEXT_BUTTON) {
1682 dir = 1;
1683 } else {
1684 if (button->id == ID_CITY_DLG_PREV_BUTTON) {
1685 dir = -1;
1686 } else {
1687 /* Always fails. */
1689 || button->id != ID_CITY_DLG_PREV_BUTTON, -1);
1690 dir = 1;
1691 }
1692 }
1693
1694 array = fc_calloc(1, size * sizeof(struct city *));
1695
1696 non_open_size = 0;
1697 for (i = 0; i < size; i++) {
1699 }
1700
1702
1703 if (non_open_size <= 1) {
1704 FC_FREE(array);
1705 return -1;
1706 }
1707
1708 qsort(array, non_open_size, sizeof(struct city *),
1710
1711 for (i = 0; i < non_open_size; i++) {
1712 if (pcity_dlg->pcity == array[i]) {
1713 break;
1714 }
1715 }
1716
1718 pcity_dlg->pcity = array[(i + dir + non_open_size) % non_open_size];
1719 FC_FREE(array);
1720
1721 /* free panel widgets */
1723 /* refresh resource map */
1727
1728 /* redraw */
1730 flush_dirty();
1731 }
1732
1733 return -1;
1734}
1735
1736/**********************************************************************/
1739static int new_name_city_dlg_callback(struct widget *pedit)
1740{
1741 if (pedit->string_utf8->text != NULL) {
1745 }
1746 } else {
1747 /* Empty input -> restore previous content */
1749 widget_redraw(pedit);
1750 widget_mark_dirty(pedit);
1751 flush_dirty();
1752 }
1753
1754 return -1;
1755}
1756
1757/* ======================================================================= */
1758/* ======================== Redrawing City Dlg. ========================== */
1759/* ======================================================================= */
1760
1761/**********************************************************************/
1779
1780/**********************************************************************/
1785 struct city *pcity)
1786{
1787 char cbuf[60];
1788 utf8_str *pstr;
1789 SDL_Surface *surf;
1790 SDL_Rect dest;
1791
1792 fc_snprintf(cbuf, sizeof(cbuf), _("City options"));
1793
1796 pstr->style |= TTF_STYLE_BOLD;
1797
1799
1800 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1801 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1802
1803 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1804
1805 FREESURFACE(surf);
1807
1808 if (!pcity_dlg->panel) {
1810 }
1813}
1814
1815/**********************************************************************/
1820 struct city *pcity)
1821{
1822 char cbuf[60];
1823 utf8_str *pstr;
1824 SDL_Surface *surf;
1825 SDL_Rect dest;
1826 struct unit_list *units;
1827 int size;
1828
1831 } else {
1832 units = (pcity_dlg->pcity->units_supported);
1833 }
1834
1835 size = unit_list_size(units);
1836
1837 fc_snprintf(cbuf, sizeof(cbuf), _("Supported units: %d"), size);
1838
1841 pstr->style |= TTF_STYLE_BOLD;
1842
1844
1845 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1846 dest.y = city_window->area.y + + adj_size(4) + current_theme->info_icon->h;
1847
1848 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1849
1850 FREESURFACE(surf);
1852
1853 if (pcity_dlg->panel) {
1854 if (size > 0) {
1857 } else {
1862 }
1863 } else {
1864 if (size > 0) {
1868 }
1869 }
1870}
1871
1872/**********************************************************************/
1877 struct city *pcity)
1878{
1879 char cbuf[60];
1880 utf8_str *pstr;
1881 SDL_Surface *surf;
1882 SDL_Rect dest;
1883 struct unit_list *units;
1884 int size;
1885
1888 } else {
1889 units = pcity_dlg->pcity->tile->units;
1890 }
1891
1892 size = unit_list_size(units);
1893
1894 fc_snprintf(cbuf, sizeof(cbuf), _("Present units: %d"), size);
1895
1898 pstr->style |= TTF_STYLE_BOLD;
1899
1901
1902 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1903 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1904
1905 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1906
1907 FREESURFACE(surf);
1909
1910 if (pcity_dlg->panel) {
1911 if (size) {
1914 } else {
1919 }
1920 } else {
1921 if (size) {
1925 }
1926 }
1927}
1928
1929/**********************************************************************/
1934 struct city *pcity)
1935{
1936 char cbuf[30];
1937 struct city *trade_city = NULL;
1938 int step, i, xx;
1939 utf8_str *pstr = NULL;
1940 SDL_Surface *surf = NULL;
1941 SDL_Rect dest;
1942
1943 fc_snprintf(cbuf, sizeof(cbuf), _("City info"));
1946 pstr->style |= TTF_STYLE_BOLD;
1947
1949
1950 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
1951 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
1952
1953 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1954
1955 dest.x = city_window->size.x + adj_size(10);
1956 dest.y += surf->h + 1;
1957
1958 FREESURFACE(surf);
1959
1962
1963 if (pcity->pollution) {
1964 fc_snprintf(cbuf, sizeof(cbuf), _("Pollution: %d"),
1965 pcity->pollution);
1966
1968
1970
1971 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1972
1973 dest.y += surf->h + adj_size(3);
1974
1975 FREESURFACE(surf);
1976
1977 if (((icons->pollution->w + 1) * pcity->pollution) > adj_size(187)) {
1978 step = (adj_size(187) - icons->pollution->w) / (pcity->pollution - 1);
1979 } else {
1980 step = icons->pollution->w + 1;
1981 }
1982
1983 for (i = 0; i < pcity->pollution; i++) {
1984 alphablit(icons->pollution, NULL, city_window->dst->surface, &dest, 255);
1985 dest.x += step;
1986 }
1987
1988 dest.x = city_window->size.x + adj_size(10);
1989 dest.y += icons->pollution->h + adj_size(3);
1990
1991 } else {
1992 fc_snprintf(cbuf, sizeof(cbuf), _("Pollution: none"));
1993
1995
1997
1998 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
1999
2000 dest.y += surf->h + adj_size(3);
2001
2002 FREESURFACE(surf);
2003 }
2004
2005 if (game.info.illness_on) {
2006 int risk_pml = city_illness_calc(pcity, NULL, NULL, NULL, NULL);
2007
2008 fc_snprintf(cbuf, sizeof(cbuf), _("Plague risk: %.1f%%"),
2009 (double)risk_pml / 10.0);
2010 } else {
2011 fc_snprintf(cbuf, sizeof(cbuf), _("Plague risk: none"));
2012 }
2013
2016 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2017 dest.y += surf->h + adj_size(3);
2018 FREESURFACE(surf);
2019
2020 fc_snprintf(cbuf, sizeof(cbuf), _("Trade routes: "));
2021
2023
2025
2026 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2027
2028 xx = dest.x + surf->w;
2029 dest.y += surf->h + adj_size(3);
2030
2031 FREESURFACE(surf);
2032
2033 step = 0;
2034 dest.x = city_window->size.x + adj_size(10);
2035
2037 step += proute->value;
2038
2039 if ((trade_city = game_city_by_number(proute->partner))) {
2040 fc_snprintf(cbuf, sizeof(cbuf), "%s: +%d", city_name_get(trade_city),
2041 proute->value);
2042 } else {
2043 fc_snprintf(cbuf, sizeof(cbuf), "%s: +%d", _("Unknown"),
2044 proute->value);
2045 }
2046
2048
2050
2051 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2052
2053 /* Blit trade icon */
2054 dest.x += surf->w + adj_size(3);
2055 dest.y += adj_size(4);
2056 alphablit(icons->trade, NULL, city_window->dst->surface, &dest, 255);
2057 dest.x = city_window->size.x + adj_size(10);
2058 dest.y -= adj_size(4);
2059
2060 dest.y += surf->h;
2061
2062 FREESURFACE(surf);
2064
2065 if (step > 0) {
2066 fc_snprintf(cbuf, sizeof(cbuf), _("Trade: +%d"), step);
2067
2070 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2071
2072 dest.x += surf->w + adj_size(3);
2073 dest.y += adj_size(4);
2074 alphablit(icons->trade, NULL, city_window->dst->surface, &dest, 255);
2075
2076 FREESURFACE(surf);
2077 } else {
2078 fc_snprintf(cbuf, sizeof(cbuf), Q_("?trade:None"));
2079
2081
2083
2084 dest.x = xx;
2085 dest.y -= surf->h + adj_size(3);
2086 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2087
2088 FREESURFACE(surf);
2089 }
2090
2092}
2093
2094/**********************************************************************/
2100 struct city *pcity)
2101{
2102 char cbuf[30];
2103 int step, i, j, count;
2105 utf8_str *pstr = NULL;
2106 SDL_Surface *surf = NULL;
2107 SDL_Rect dest = {0, 0, 0, 0};
2109
2110 fc_snprintf(cbuf, sizeof(cbuf), _("Happiness"));
2111
2114 pstr->style |= TTF_STYLE_BOLD;
2115
2117
2118 dest.x = city_window->area.x + adj_size(2) + (adj_size(192) - surf->w) / 2;
2119 dest.y = city_window->area.y + adj_size(4) + current_theme->info_icon->h;
2120 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2121
2122 dest.x = city_window->size.x + adj_size(10);
2123 dest.y += surf->h + 1;
2124
2125 FREESURFACE(surf);
2127
2130 + city_specialists(pcity));
2131
2132 if (count * icons->male_happy->w > adj_size(166)) {
2133 step = (adj_size(166) - icons->male_happy->w) / (count - 1);
2134 } else {
2135 step = icons->male_happy->w;
2136 }
2137
2138 for (j = 0; j < FEELING_LAST; j++) {
2139 if (j == 0 || pcity->feel[CITIZEN_HAPPY][j - 1] != pcity->feel[CITIZEN_HAPPY][j]
2140 || pcity->feel[CITIZEN_CONTENT][j - 1] != pcity->feel[CITIZEN_CONTENT][j]
2141 || pcity->feel[CITIZEN_UNHAPPY][j - 1] != pcity->feel[CITIZEN_UNHAPPY][j]
2142 || pcity->feel[CITIZEN_ANGRY][j - 1] != pcity->feel[CITIZEN_ANGRY][j]) {
2143 int spe, spe_max;
2144
2145 if (j != 0) {
2146 create_line(city_window->dst->surface,
2147 dest.x, dest.y, dest.x + adj_size(176), dest.y,
2149 dest.y += adj_size(5);
2150 }
2151
2152 if (pcity->feel[CITIZEN_HAPPY][j]) {
2153 surf = icons->male_happy;
2154 for (i = 0; i < pcity->feel[CITIZEN_HAPPY][j]; i++) {
2155 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2156 dest.x += step;
2157 if (surf == icons->male_happy) {
2158 surf = icons->female_happy;
2159 } else {
2160 surf = icons->male_happy;
2161 }
2162 }
2163 }
2164
2165 if (pcity->feel[CITIZEN_CONTENT][j]) {
2166 surf = icons->male_content;
2167 for (i = 0; i < pcity->feel[CITIZEN_CONTENT][j]; i++) {
2168 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2169 dest.x += step;
2170 if (surf == icons->male_content) {
2171 surf = icons->female_content;
2172 } else {
2173 surf = icons->male_content;
2174 }
2175 }
2176 }
2177
2178 if (pcity->feel[CITIZEN_UNHAPPY][j]) {
2179 surf = icons->male_unhappy;
2180 for (i = 0; i < pcity->feel[CITIZEN_UNHAPPY][j]; i++) {
2181 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2182 dest.x += step;
2183 if (surf == icons->male_unhappy) {
2184 surf = icons->female_unhappy;
2185 } else {
2186 surf = icons->male_unhappy;
2187 }
2188 }
2189 }
2190
2191 if (pcity->feel[CITIZEN_ANGRY][j]) {
2192 surf = icons->male_angry;
2193 for (i = 0; i < pcity->feel[CITIZEN_ANGRY][j]; i++) {
2194 alphablit(surf, NULL, city_window->dst->surface, &dest, 255);
2195 dest.x += step;
2196 if (surf == icons->male_angry) {
2197 surf = icons->female_angry;
2198 } else {
2199 surf = icons->male_angry;
2200 }
2201 }
2202 }
2203
2205 for (spe = 0 ; spe < spe_max; spe++) {
2206 if (pcity->specialists[spe]) {
2207 for (i = 0; i < pcity->specialists[spe]; i++) {
2208 alphablit(icons->specialists[spe], NULL, city_window->dst->surface,
2209 &dest, 255);
2210 dest.x += step;
2211 }
2212 }
2213 }
2214
2215 if (j == 1) { /* Luxury effect */
2216 dest.x =
2217 city_window->size.x + adj_size(187) - icons->big_luxury->w - adj_size(2);
2218 count = dest.y;
2219 dest.y += (icons->male_happy->h -
2220 icons->big_luxury->h) / 2;
2221 alphablit(icons->big_luxury, NULL, city_window->dst->surface, &dest, 255);
2222 dest.y = count;
2223 }
2224
2225 if (j == 2) { /* Improvements effects */
2226 int w = -1;
2227 count = 0;
2228
2230
2233 if (preq->source.kind == VUT_IMPROVEMENT) {
2234 tmp = get_building_surface(preq->source.value.building);
2235 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2236 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2237
2238 count += (tmp->h + 1);
2239
2240 if (w < 0) {
2241 w = tmp->w;
2242 }
2243
2245 }
2248
2249 if (w >= 0) {
2250 dest.x = city_window->size.x + adj_size(187) - w - adj_size(2);
2251 i = dest.y;
2252 dest.y += (icons->male_happy->h - count) / 2;
2253
2256 if (preq->source.kind == VUT_IMPROVEMENT) {
2257 tmp = get_building_surface(preq->source.value.building);
2258 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2259 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2260
2261 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2262 dest.y += (tmp->h + 1);
2263
2265 }
2268
2269 dest.y = i;
2270 }
2271
2273 }
2274
2275 if (j == 3) { /* police effect */
2276 dest.x = city_window->size.x + adj_size(187) - icons->police->w - adj_size(5);
2277 i = dest.y;
2278 dest.y +=
2279 (icons->male_happy->h - icons->police->h) / 2;
2280 alphablit(icons->police, NULL, city_window->dst->surface, &dest, 255);
2281 dest.y = i;
2282 }
2283
2284 if (j == 4) { /* Wonders effect */
2285 int w = -1;
2286 count = 0;
2287
2291 if (preq->source.kind == VUT_IMPROVEMENT) {
2292 tmp = get_building_surface(preq->source.value.building);
2293 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2294 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2295
2296 count += (tmp->h + 1);
2297
2298 if (w < 0) {
2299 w = tmp->w;
2300 }
2301
2303 }
2306
2308
2310
2313 if (preq->source.kind == VUT_IMPROVEMENT) {
2314 tmp = get_building_surface(preq->source.value.building);
2315 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2316 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2317 count += (tmp->h + 1);
2318
2319 if (w < 0) {
2320 w = tmp->w;
2321 }
2322
2324 }
2327
2329
2331
2334 if (preq->source.kind == VUT_IMPROVEMENT) {
2335 tmp = get_building_surface(preq->source.value.building);
2336 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2337 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2338
2339 count += (tmp->h + 1);
2340
2341 if (w < 0) {
2342 w = tmp->w;
2343 }
2344
2346 }
2349
2351
2352 if (w >= 0) {
2353 dest.x = city_window->size.x + adj_size(187) - surf->w - adj_size(2);
2354 i = dest.y;
2355 dest.y += (icons->male_happy->h - count) / 2;
2356
2358
2361 if (preq->source.kind == VUT_IMPROVEMENT) {
2362 tmp = get_building_surface(preq->source.value.building);
2363 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2364 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2365
2366 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2367 dest.y += (tmp->h + 1);
2368
2370 }
2373
2375
2377
2380 if (preq->source.kind == VUT_IMPROVEMENT) {
2381 tmp = get_building_surface(preq->source.value.building);
2382 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2383 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2384
2385 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2386 dest.y += (tmp->h + 1);
2387
2389 }
2392
2394
2396
2399 if (preq->source.kind == VUT_IMPROVEMENT) {
2400 tmp = get_building_surface(preq->source.value.building);
2401 tmp = zoomSurface(tmp, DEFAULT_ZOOM * ((float)18 / tmp->w),
2402 DEFAULT_ZOOM * ((float)18 / tmp->w), 1);
2403
2404 alphablit(tmp, NULL, city_window->dst->surface, &dest, 255);
2405 dest.y += (tmp->h + 1);
2406
2408 }
2411
2413
2414 dest.y = i;
2415 }
2416 }
2417
2418 dest.x = city_window->size.x + adj_size(10);
2419 dest.y += icons->male_happy->h + adj_size(5);
2420
2421 }
2422 }
2423
2425}
2426
2427/**********************************************************************/
2430static void redraw_city_dialog(struct city *pcity)
2431{
2432 char cbuf[40];
2433 int i, step, count, limit;
2434 int cost = 0;
2435 SDL_Rect dest;
2436 struct widget *pwindow = pcity_dlg->end_city_widget_list;
2437 SDL_Surface *buf = NULL, *buf2 = NULL;
2438 utf8_str *pstr = NULL;
2439 int spe, spe_max;
2440
2441 refresh_city_names(pcity);
2442
2443 if ((city_unhappy(pcity) || city_celebrating(pcity) || city_happy(pcity)
2444 || cma_is_city_under_agent(pcity, NULL))
2446 /* City status was changed : NORMAL <-> DISORDER, HAPPY, CELEBR. */
2447
2449
2450#if 0
2451 /* Upd. resource map */
2454#endif
2455
2456 /* Upd. window title */
2458 }
2459
2460 /* Update resource map */
2463
2464 /* Redraw city dlg */
2467
2468 /* ================================================================= */
2469 fc_snprintf(cbuf, sizeof(cbuf), _("City map"));
2470
2473 pstr->style |= TTF_STYLE_BOLD;
2474
2476
2477 dest.x = pwindow->size.x + adj_size(196) + (adj_size(132) - buf->w) / 2;
2478 dest.y = pwindow->size.y + adj_size(49) + (adj_size(13) - buf->h) / 2;
2479
2480 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2481
2483
2484 fc_snprintf(cbuf, sizeof(cbuf), _("Citizens"));
2485
2488
2490
2491 dest.x = pwindow->size.x + adj_size(344) + (adj_size(146) - buf->w) / 2;
2492 dest.y = pwindow->size.y + adj_size(47) + (adj_size(13) - buf->h) / 2;
2493
2494 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2495
2497
2498 fc_snprintf(cbuf, sizeof(cbuf), _("City improvements"));
2499
2502
2504
2505 dest.x = pwindow->size.x + adj_size(504) + (adj_size(132) - buf->w) / 2;
2506 dest.y = pwindow->size.y + adj_size(49) + (adj_size(13) - buf->h) / 2;
2507
2508 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2509
2511
2512 /* ================================================================= */
2513 /* Food label */
2514 fc_snprintf(cbuf, sizeof(cbuf), _("Food: %d per turn"),
2515 pcity->prod[O_FOOD]);
2516
2518
2520
2522
2523 dest.x = pwindow->size.x + adj_size(200);
2524 dest.y = pwindow->size.y + adj_size(228) + (adj_size(16) - buf->h) / 2;
2525
2526 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2527
2529
2530 /* Draw food income */
2531 dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - icons->big_food->h) / 2;
2532 dest.x = pwindow->size.x + adj_size(203);
2533
2534 if (pcity->surplus[O_FOOD] >= 0) {
2535 count = pcity->prod[O_FOOD] - pcity->surplus[O_FOOD];
2536 } else {
2537 count = pcity->prod[O_FOOD];
2538 }
2539
2540 if (((icons->big_food->w + 1) * count) > adj_size(200)) {
2541 step = (adj_size(200) - icons->big_food->w) / (count - 1);
2542 } else {
2543 step = icons->big_food->w + 1;
2544 }
2545
2546 for (i = 0; i < count; i++) {
2547 alphablit(icons->big_food, NULL, pwindow->dst->surface, &dest, 255);
2548 dest.x += step;
2549 }
2550
2551 fc_snprintf(cbuf, sizeof(cbuf), Q_("?food:Surplus: %d"),
2552 pcity->surplus[O_FOOD]);
2553
2556
2558
2559 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2560 dest.y = pwindow->size.y + adj_size(228) + (adj_size(16) - buf->h) / 2;
2561
2562 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2563
2565
2566 /* Draw surplus of food */
2567 if (pcity->surplus[O_FOOD]) {
2568 if (pcity->surplus[O_FOOD] > 0) {
2569 count = pcity->surplus[O_FOOD];
2570 buf = icons->big_food;
2571 } else {
2572 count = -1 * pcity->surplus[O_FOOD];
2574 }
2575
2576 dest.x = pwindow->size.x + adj_size(423);
2577 dest.y = pwindow->size.y + adj_size(246) + (adj_size(16) - buf->h) / 2;
2578
2579 if (count > 2) {
2580 if (count < 18) {
2581 step = (adj_size(30) - buf->w) / (count - 1);
2582 } else {
2583 step = 1;
2584 count = 17;
2585 }
2586 } else {
2587 step = buf->w + 1;
2588 }
2589
2590 for (i = 0; i < count; i++) {
2591 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2592 dest.x -= step;
2593 }
2594 }
2595
2596 /* ================================================================= */
2597 /* Productions label */
2598 fc_snprintf(cbuf, sizeof(cbuf), _("Production: %d (%d) per turn"),
2599 pcity->surplus[O_SHIELD],
2600 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
2601
2604
2606
2607 dest.x = pwindow->size.x + adj_size(200);
2608 dest.y = pwindow->size.y + adj_size(263) + (adj_size(15) - buf->h) / 2;
2609
2610 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2611
2613
2614 /* Draw productions shields */
2615 if (pcity->surplus[O_SHIELD]) {
2616
2617 if (pcity->surplus[O_SHIELD] > 0) {
2618 count = pcity->surplus[O_SHIELD] + pcity->waste[O_SHIELD];
2619 buf = icons->big_shield;
2620 } else {
2621 count = -1 * pcity->surplus[O_SHIELD];
2623 }
2624
2625 dest.y = pwindow->size.y + adj_size(281) + (adj_size(16) - buf->h) / 2;
2626 dest.x = pwindow->size.x + adj_size(203);
2627
2628 if ((buf->w * count) > adj_size(200)) {
2629 step = (adj_size(200) - buf->w) / (count - 1);
2630 } else {
2631 step = buf->w;
2632 }
2633
2634 for (i = 0; i < count; i++) {
2635 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2636 dest.x += step;
2637 if (i > pcity->surplus[O_SHIELD]) {
2639 }
2640 }
2641 }
2642
2643 /* Support shields label */
2644 fc_snprintf(cbuf, sizeof(cbuf), Q_("?production:Support: %d"),
2645 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD] -
2646 pcity->surplus[O_SHIELD]);
2647
2650
2652
2653 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2654 dest.y = pwindow->size.y + adj_size(263) + (adj_size(15) - buf->h) / 2;
2655
2656 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2657
2659
2660 /* Draw support shields */
2661 if (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]) {
2662 dest.x = pwindow->size.x + adj_size(423);
2663 dest.y =
2664 pwindow->size.y + adj_size(281) + (adj_size(16) - icons->big_shield->h) / 2;
2665
2666 if ((icons->big_shield->w + 1) * (pcity->prod[O_SHIELD] -
2667 pcity->surplus[O_SHIELD]) > adj_size(30)) {
2668 step =
2669 (adj_size(30) - icons->big_food->w) / (pcity->prod[O_SHIELD] -
2670 pcity->surplus[O_SHIELD] - 1);
2671 } else {
2672 step = icons->big_shield->w + 1;
2673 }
2674
2675 for (i = 0; i < (pcity->prod[O_SHIELD] - pcity->surplus[O_SHIELD]); i++) {
2676 alphablit(icons->big_shield, NULL, pwindow->dst->surface, &dest, 255);
2677 dest.x -= step;
2678 }
2679 }
2680
2681 /* ================================================================= */
2682 /* Trade label */
2683 fc_snprintf(cbuf, sizeof(cbuf), _("Trade: %d per turn"),
2684 pcity->surplus[O_TRADE]);
2685
2688
2690
2691 dest.x = pwindow->size.x + adj_size(200);
2692 dest.y = pwindow->size.y + adj_size(298) + (adj_size(15) - buf->h) / 2;
2693
2694 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2695
2697
2698 /* Draw total (trade - corruption) */
2699 if (pcity->surplus[O_TRADE]) {
2700 dest.y =
2701 pwindow->size.y + adj_size(316) + (adj_size(16) - icons->big_trade->h) / 2;
2702 dest.x = pwindow->size.x + adj_size(203);
2703
2704 if (((icons->big_trade->w + 1) * pcity->surplus[O_TRADE]) > adj_size(200)) {
2705 step = (adj_size(200) - icons->big_trade->w) / (pcity->surplus[O_TRADE] - 1);
2706 } else {
2707 step = icons->big_trade->w + 1;
2708 }
2709
2710 for (i = 0; i < pcity->surplus[O_TRADE]; i++) {
2711 alphablit(icons->big_trade, NULL, pwindow->dst->surface, &dest, 255);
2712 dest.x += step;
2713 }
2714 }
2715
2716 /* Corruption label */
2717 fc_snprintf(cbuf, sizeof(cbuf), _("Corruption: %d"),
2718 pcity->waste[O_TRADE]);
2719
2722
2724
2725 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2726 dest.y = pwindow->size.y + adj_size(298) + (adj_size(15) - buf->h) / 2;
2727
2728 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2729
2731
2732 /* Draw corruption */
2733 if (pcity->waste[O_TRADE] > 0) {
2734 dest.x = pwindow->size.x + adj_size(423);
2735 dest.y =
2736 pwindow->size.y + adj_size(316) + (adj_size(16) - icons->big_trade->h) / 2;
2737
2738 if (((icons->big_trade_corr->w + 1) * pcity->waste[O_TRADE]) > adj_size(30)) {
2739 step =
2740 (adj_size(30) - icons->big_trade_corr->w) / (pcity->waste[O_TRADE] - 1);
2741 } else {
2742 step = icons->big_trade_corr->w + 1;
2743 }
2744
2745 for (i = 0; i < pcity->waste[O_TRADE]; i++) {
2747 &dest, 255);
2748 dest.x -= step;
2749 }
2750 }
2751
2752 /* ================================================================= */
2753 /* Gold label */
2754 fc_snprintf(cbuf, sizeof(cbuf), _("Gold: %d (%d) per turn"),
2755 pcity->surplus[O_GOLD], pcity->prod[O_GOLD]);
2756
2759
2761
2762 dest.x = pwindow->size.x + adj_size(200);
2763 dest.y = pwindow->size.y + adj_size(342) + (adj_size(15) - buf->h) / 2;
2764
2765 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2766
2768
2769 /* Draw coins */
2770 count = pcity->surplus[O_GOLD];
2771 if (count) {
2772
2773 if (count > 0) {
2774 buf = icons->big_coin;
2775 } else {
2776 count *= -1;
2778 }
2779
2780 dest.y = pwindow->size.y + adj_size(359) + (adj_size(16) - buf->h) / 2;
2781 dest.x = pwindow->size.x + adj_size(203);
2782
2783 if ((buf->w * count) > adj_size(110)) {
2784 step = (adj_size(110) - buf->w) / (count - 1);
2785 if (!step) {
2786 step = 1;
2787 count = 97;
2788 }
2789 } else {
2790 step = buf->w;
2791 }
2792
2793 for (i = 0; i < count; i++) {
2794 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2795 dest.x += step;
2796 }
2797
2798 }
2799
2800 /* Upkeep label */
2801 fc_snprintf(cbuf, sizeof(cbuf), _("Upkeep: %d"),
2802 pcity->prod[O_GOLD] - pcity->surplus[O_GOLD]);
2803
2806
2808
2809 dest.x = pwindow->size.x + adj_size(440) - buf->w;
2810 dest.y = pwindow->size.y + adj_size(342) + (adj_size(15) - buf->h) / 2;
2811
2812 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2813
2815
2816 /* Draw upkeep */
2817 count = pcity->surplus[O_GOLD];
2818 if (pcity->prod[O_GOLD] - count) {
2819
2820 dest.x = pwindow->size.x + adj_size(423);
2821 dest.y = pwindow->size.y + adj_size(359)
2822 + (adj_size(16) - icons->big_coin_upkeep->h) / 2;
2823
2824 if (((icons->big_coin_upkeep->w + 1) *
2825 (pcity->prod[O_GOLD] - count)) > adj_size(110)) {
2826 step = (adj_size(110) - icons->big_coin_upkeep->w) /
2827 (pcity->prod[O_GOLD] - count - 1);
2828 } else {
2829 step = icons->big_coin_upkeep->w + 1;
2830 }
2831
2832 for (i = 0; i < (pcity->prod[O_GOLD] - count); i++) {
2834 &dest, 255);
2835 dest.x -= step;
2836 }
2837 }
2838
2839 /* ================================================================= */
2840 /* Science label */
2841 fc_snprintf(cbuf, sizeof(cbuf), _("Science: %d per turn"),
2842 pcity->prod[O_SCIENCE]);
2843
2846
2848
2849 dest.x = pwindow->size.x + adj_size(200);
2850 dest.y = pwindow->size.y + adj_size(376) + (adj_size(15) - buf->h) / 2;
2851
2852 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2853
2855
2856 /* Draw colb */
2857 count = pcity->prod[O_SCIENCE];
2858 if (count) {
2859
2860 dest.y =
2861 pwindow->size.y + adj_size(394) + (adj_size(16) - icons->big_colb->h) / 2;
2862 dest.x = pwindow->size.x + adj_size(203);
2863
2864 if ((icons->big_colb->w * count) > adj_size(235)) {
2865 step = (adj_size(235) - icons->big_colb->w) / (count - 1);
2866 if (!step) {
2867 step = 1;
2868 count = 222;
2869 }
2870 } else {
2871 step = icons->big_colb->w;
2872 }
2873
2874 for (i = 0; i < count; i++) {
2875 alphablit(icons->big_colb, NULL, pwindow->dst->surface, &dest, 255);
2876 dest.x += step;
2877 }
2878 }
2879
2880 /* ================================================================= */
2881 /* Luxury label */
2882 fc_snprintf(cbuf, sizeof(cbuf), _("Luxury: %d per turn"),
2883 pcity->prod[O_LUXURY]);
2884
2887
2889
2890 dest.x = pwindow->size.x + adj_size(200);
2891 dest.y = pwindow->size.y + adj_size(412) + (adj_size(15) - buf->h) / 2;
2892
2893 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2894
2896
2897 /* Draw luxury */
2898 if (pcity->prod[O_LUXURY]) {
2899
2900 dest.y =
2901 pwindow->size.y + adj_size(429) + (adj_size(16) - icons->big_luxury->h) / 2;
2902 dest.x = pwindow->size.x + adj_size(203);
2903
2904 if ((icons->big_luxury->w * pcity->prod[O_LUXURY]) > adj_size(235)) {
2905 step =
2906 (adj_size(235) - icons->big_luxury->w) / (pcity->prod[O_LUXURY] - 1);
2907 } else {
2908 step = icons->big_luxury->w;
2909 }
2910
2911 for (i = 0; i < pcity->prod[O_LUXURY]; i++) {
2912 alphablit(icons->big_luxury, NULL, pwindow->dst->surface, &dest, 255);
2913 dest.x += step;
2914 }
2915 }
2916
2917 /* ================================================================= */
2918 /* Turns to grow label */
2919 count = city_turns_to_grow(pcity);
2920 if (count == 0) {
2921 fc_snprintf(cbuf, sizeof(cbuf), _("City growth: blocked"));
2922 } else if (count == FC_INFINITY) {
2923 fc_snprintf(cbuf, sizeof(cbuf), _("City growth: never"));
2924 } else if (count < 0) {
2925 /* Turns until famine */
2926 fc_snprintf(cbuf, sizeof(cbuf),
2927 _("City shrinks: %d %s"), abs(count),
2928 PL_("turn", "turns", abs(count)));
2929 } else {
2930 fc_snprintf(cbuf, sizeof(cbuf),
2931 _("City growth: %d %s"), count,
2932 PL_("turn", "turns", count));
2933 }
2934
2936
2938
2940
2941 dest.x = pwindow->size.x + adj_size(445) + (adj_size(192) - buf->w) / 2;
2942 dest.y = pwindow->size.y + adj_size(227);
2943
2944 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2945
2947
2948 count = (city_granary_size(city_size_get(pcity))) / 10;
2949
2950 if (count > 12) {
2951 step = (adj_size(168) - icons->big_food->h) / adj_size((11 + count - 12));
2952 i = (count - 1) * step + 14;
2953 } else {
2954 step = icons->big_food->h;
2955 i = count * step;
2956 }
2957
2958 /* Food stock */
2959 if (get_city_bonus(pcity, EFT_GROWTH_FOOD) > 0) {
2960 /* With granary */
2961 /* Stocks label */
2962 copy_chars_to_utf8_str(pstr, _("Stock"));
2964
2965 dest.x = pwindow->size.x + adj_size(461) + (adj_size(76) - buf->w) / 2;
2966 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
2967
2968 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2969
2971
2972 /* Granary label */
2973 copy_chars_to_utf8_str(pstr, _("Granary"));
2975
2976 dest.x = pwindow->size.x + adj_size(549) + (adj_size(76) - buf->w) / 2;
2977 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
2978
2979 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
2980
2982
2983 /* Draw bcgd granary */
2984 dest.x = pwindow->size.x + adj_size(462);
2985 dest.y = pwindow->size.y + adj_size(260);
2986 dest.w = 70 + 4;
2987 dest.h = i + 4;
2988
2989 fill_rect_alpha(pwindow->dst->surface, &dest,
2991
2992 create_frame(pwindow->dst->surface,
2993 dest.x - 1, dest.y - 1, dest.w, dest.h,
2995
2996 /* Draw bcgd stocks*/
2997 dest.x = pwindow->size.x + adj_size(550);
2998 dest.y = pwindow->size.y + adj_size(260);
2999
3000 fill_rect_alpha(pwindow->dst->surface, &dest,
3002
3003 create_frame(pwindow->dst->surface,
3004 dest.x - 1, dest.y - 1, dest.w, dest.h,
3006
3007 /* Draw stocks icons */
3009 if (pcity->food_stock + pcity->surplus[O_FOOD] > cost) {
3010 count = cost;
3011 } else {
3012 if (pcity->surplus[O_FOOD] < 0) {
3013 count = pcity->food_stock;
3014 } else {
3015 count = pcity->food_stock + pcity->surplus[O_FOOD];
3016 }
3017 }
3018 cost /= 2;
3019
3020 if (pcity->surplus[O_FOOD] < 0) {
3021 limit = pcity->food_stock + pcity->surplus[O_FOOD];
3022 if (limit < 0) {
3023 limit = 0;
3024 }
3025 } else {
3026 limit = 0xffff;
3027 }
3028
3029 dest.x += 2;
3030 dest.y += 2;
3031 i = 0;
3032 buf = icons->big_food;
3033 while (count && cost) {
3034 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3035 dest.x += buf->w;
3036 count--;
3037 cost--;
3038 i++;
3039 if (dest.x > pwindow->size.x + adj_size(620)) {
3040 dest.x = pwindow->size.x + adj_size(552);
3041 dest.y += step;
3042 }
3043 if (i > limit - 1) {
3045 } else {
3046 if (i > pcity->food_stock - 1) {
3048 }
3049 }
3050 }
3051 /* Draw granary icons */
3052 dest.x = pwindow->size.x + adj_size(462) + adj_size(2);
3053 dest.y = pwindow->size.y + adj_size(260) + adj_size(2);
3054
3055 while (count) {
3056 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3057 dest.x += buf->w;
3058 count--;
3059 i++;
3060
3061 if (dest.x > pwindow->size.x + adj_size(532)) {
3062 dest.x = pwindow->size.x + adj_size(464);
3063 dest.y += step;
3064 }
3065
3066 if (i > limit - 1) {
3068 } else if (i > pcity->food_stock - 1) {
3070 }
3071 }
3072
3073 } else {
3074 /* Without granary */
3075 /* Stocks label */
3076 copy_chars_to_utf8_str(pstr, _("Stock"));
3078
3079 dest.x = pwindow->size.x + adj_size(461) + (adj_size(144) - buf->w) / 2;
3080 dest.y = pwindow->size.y + adj_size(258) - buf->h - 1;
3081
3082 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3084
3085 /* Food stock */
3086
3087 /* Draw bcgd */
3088 dest.x = pwindow->size.x + adj_size(462);
3089 dest.y = pwindow->size.y + adj_size(260);
3090 dest.w = adj_size(144);
3091 dest.h = i + adj_size(4);
3092
3093 fill_rect_alpha(pwindow->dst->surface, &dest,
3095
3096 create_frame(pwindow->dst->surface,
3097 dest.x - 1, dest.y - 1, dest.w, dest.h,
3099
3100 /* Draw icons */
3102 if (pcity->food_stock + pcity->surplus[O_FOOD] > cost) {
3103 count = cost;
3104 } else {
3105 if (pcity->surplus[O_FOOD] < 0) {
3106 count = pcity->food_stock;
3107 } else {
3108 count = pcity->food_stock + pcity->surplus[O_FOOD];
3109 }
3110 }
3111
3112 if (pcity->surplus[O_FOOD] < 0) {
3113 limit = pcity->food_stock + pcity->surplus[O_FOOD];
3114 if (limit < 0) {
3115 limit = 0;
3116 }
3117 } else {
3118 limit = 0xffff;
3119 }
3120
3121 dest.x += adj_size(2);
3122 dest.y += adj_size(2);
3123 i = 0;
3124 buf = icons->big_food;
3125 while (count) {
3126 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3127 dest.x += buf->w;
3128 count--;
3129 i++;
3130
3131 if (dest.x > pwindow->size.x + adj_size(602)) {
3132 dest.x = pwindow->size.x + adj_size(464);
3133 dest.y += step;
3134 }
3135 if (i > limit - 1) {
3137 } else {
3138 if (i > pcity->food_stock - 1) {
3140 }
3141 }
3142 }
3143 }
3144 /* ================================================================= */
3145
3146 /* draw productions shields progress */
3147 if (VUT_UTYPE == pcity->production.kind) {
3148 const struct unit_type *punittype = pcity->production.value.utype;
3149
3151 count = cost / 10;
3152
3155
3157 buf2 = zoomSurface(buf2, DEFAULT_ZOOM * ((float)32 / buf2->h),
3158 DEFAULT_ZOOM * ((float)32 / buf2->h), 1);
3159
3160 /* blit unit icon */
3161 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - (buf->w + buf2->w + adj_size(5))) / 2;
3162 dest.y = pwindow->size.y + adj_size(233);
3163
3164 alphablit(buf2, NULL, pwindow->dst->surface, &dest, 255);
3165
3166 dest.y += (buf2->h - buf->h) / 2;
3167 dest.x += buf2->w + adj_size(5);
3168
3169 } else {
3170 const struct impr_type *pimprove = pcity->production.value.building;
3171
3172 if (is_convert_improvement(pimprove)) {
3173
3178 }
3179
3180 /* You can't see capitalization progress */
3181 count = 0;
3182
3183 } else {
3184
3185 if (city_can_buy(pcity) && pcity_dlg->buy_button
3189 }
3190
3191 cost = impr_build_shield_cost(pcity, pimprove);
3192 count = cost / 10;
3193 }
3194
3197
3199 buf2 = zoomSurface(buf2, DEFAULT_ZOOM * ((float)32 / buf2->h),
3200 DEFAULT_ZOOM * ((float)32 / buf2->h), 1);
3201
3202 /* blit impr icon */
3203 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - (buf->w + buf2->w + adj_size(5))) / 2;
3204 dest.y = pwindow->size.y + adj_size(233);
3205
3206 alphablit(buf2, NULL, pwindow->dst->surface, &dest, 255);
3207
3208 dest.y += (buf2->h - buf->h) / 2;
3209 dest.x += buf2->w + adj_size(5);
3210 }
3211
3212 /* blit unit/impr name */
3213 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3214
3217
3218 if (count) {
3219 if (count > 11) {
3220 step = (adj_size(154) - icons->big_shield->h) / adj_size((10 + count - 11));
3221
3222 if (!step) {
3223 step = 1;
3224 }
3225
3226 i = (step * (count - 1)) + icons->big_shield->h;
3227 } else {
3228 step = icons->big_shield->h;
3229 i = count * step;
3230 }
3231
3232 /* draw shield stock background */
3233 dest.x = pwindow->size.x + adj_size(28);
3234 dest.y = pwindow->size.y + adj_size(270);
3235 dest.w = adj_size(144);
3236 dest.h = i + adj_size(4);
3237
3238 fill_rect_alpha(pwindow->dst->surface, &dest,
3240
3241 create_frame(pwindow->dst->surface,
3242 dest.x - 1, dest.y - 1, dest.w, dest.h,
3244
3245 /* draw production progress text */
3246 dest.y = pwindow->size.y + adj_size(270) + dest.h + 1;
3247
3248 if (pcity->shield_stock < cost) {
3249 count = city_production_turns_to_build(pcity, TRUE);
3250 if (count == 999) {
3251 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %s!",
3252 pcity->shield_stock, cost, _("blocked"));
3253 } else {
3254 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %d %s",
3255 pcity->shield_stock, cost, count, PL_("turn", "turns", count));
3256 }
3257 } else {
3258 fc_snprintf(cbuf, sizeof(cbuf), "(%d/%d) %s!",
3259 pcity->shield_stock, cost, _("finished"));
3260 }
3261
3264
3266
3267 dest.x = pwindow->size.x + adj_size(6) + (adj_size(185) - buf->w) / 2;
3268
3269 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3270
3273
3274 /* draw shield stock */
3275 if (pcity->shield_stock + pcity->surplus[O_SHIELD] <= cost) {
3276 count = pcity->shield_stock + pcity->surplus[O_SHIELD];
3277 } else {
3278 count = cost;
3279 }
3280 dest.x = pwindow->size.x + adj_size(29) + adj_size(2);
3281 dest.y = pwindow->size.y + adj_size(270) + adj_size(2);
3282 i = 0;
3283
3284 buf = icons->big_shield;
3285 while (count > 0) {
3286 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3287 dest.x += buf->w;
3288 count--;
3289 if (dest.x > pwindow->size.x + adj_size(170)) {
3290 dest.x = pwindow->size.x + adj_size(31);
3291 dest.y += step;
3292 }
3293 i++;
3294 if (i > pcity->shield_stock - 1) {
3296 }
3297 }
3298 }
3299
3300 /* count != 0 */
3301 /* ==================================================== */
3302 /* Draw Citizens */
3305 + city_specialists(pcity));
3306
3308
3309 if (count > 13) {
3310 step = (adj_size(440) - buf->w) / (adj_size(12 + count - 13));
3311 } else {
3312 step = buf->w;
3313 }
3314
3316
3317 dest.x = pwindow->size.x + adj_size(198);
3318 dest.y = pwindow->size.y + pwindow->area.y + adj_size(1) + (adj_size(22) - buf->h) / 2;
3319 pcity_dlg->spec_area.x = pwindow->dst->dest_rect.x + dest.x;
3320 pcity_dlg->spec_area.y = pwindow->dst->dest_rect.y + dest.y;
3321 pcity_dlg->spec_area.w = count * step;
3322 pcity_dlg->spec_area.h = buf->h;
3323
3324 if (pcity->feel[CITIZEN_HAPPY][FEELING_FINAL]) {
3325 for (i = 0; i < pcity->feel[CITIZEN_HAPPY][FEELING_FINAL]; i++) {
3327
3328 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3329 dest.x += step;
3331 }
3332 }
3333
3334 if (pcity->feel[CITIZEN_CONTENT][FEELING_FINAL]) {
3335 for (i = 0; i < pcity->feel[CITIZEN_CONTENT][FEELING_FINAL]; i++) {
3337
3338 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3339 dest.x += step;
3341 }
3342 }
3343
3344 if (pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL]) {
3345 for (i = 0; i < pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL]; i++) {
3347
3348 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3349 dest.x += step;
3351 }
3352 }
3353
3354 if (pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]) {
3355 for (i = 0; i < pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]; i++) {
3357
3358 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3359 dest.x += step;
3361 }
3362 }
3363
3365 for (spe = 0; spe < spe_max; spe++) {
3366 if (pcity->specialists[spe] > 0) {
3368
3369 for (i = 0; i < pcity->specialists[spe]; i++) {
3370 alphablit(buf, NULL, pwindow->dst->surface, &dest, 255);
3371 dest.x += step;
3372 }
3374 }
3375 }
3376
3377 /* ==================================================== */
3378
3379
3380 switch (pcity_dlg->page) {
3381 case INFO_PAGE:
3382 redraw_info_city_dialog(pwindow, pcity);
3383 break;
3384
3385 case HAPPINESS_PAGE:
3386 redraw_happiness_city_dialog(pwindow, pcity);
3387 break;
3388
3389 case ARMY_PAGE:
3390 redraw_army_city_dialog(pwindow, pcity);
3391 break;
3392
3393 case SUPPORTED_UNITS_PAGE:
3394 redraw_supported_units_city_dialog(pwindow, pcity);
3395 break;
3396
3397 case MISC_PAGE:
3398 redraw_misc_city_dialog(pwindow, pcity);
3399 break;
3400
3401 default:
3402 break;
3403
3404 }
3405
3406 /* redraw "sell improvement" dialog */
3409
3410 widget_mark_dirty(pwindow);
3411}
3412
3413/* ============================================================== */
3414
3415/**********************************************************************/
3418static void rebuild_imprm_list(struct city *pcity)
3419{
3420 int count = 0;
3421 struct widget *pwindow = pcity_dlg->end_city_widget_list;
3422 struct widget *add_dock, *buf, *last;
3424 utf8_str *pstr = NULL;
3425 struct player *owner = city_owner(pcity);
3426 int prev_y = 0;
3427
3428 if (!pcity_dlg->imprv) {
3429 pcity_dlg->imprv = fc_calloc(1, sizeof(struct advanced_dialog));
3430 }
3431
3432 /* free old list */
3442 }
3443
3445 buf = last = add_dock;
3446
3447 /* Alloc new */
3448 city_built_iterate(pcity, pimprove) {
3450 city_improvement_name_translation(pcity, pimprove),
3453
3454 pstr->style |= TTF_STYLE_BOLD;
3455
3456 logo = get_building_surface(pimprove);
3458
3459 buf = create_iconlabel(logo, pwindow->dst, pstr,
3461
3462 buf->size.x = pwindow->size.x + adj_size(450);
3463 buf->size.y = pwindow->size.y + adj_size(66) + prev_y;
3464
3465 prev_y += buf->size.h;
3466
3467 buf->size.w = adj_size(165);
3468 buf->action = sell_imprvm_dlg_callback;
3469
3470 if (!pcity_dlg->pcity->did_sell
3471 && !is_wonder(pimprove) && (owner == client.conn.playing)) {
3473 }
3474
3475 buf->id = MAX_ID - improvement_number(pimprove) - 3000;
3477 add_dock = buf;
3478
3479 count++;
3480
3481 if (count > 7) {
3483 }
3484
3486
3487 if (count) {
3492
3493 if (count > 7) {
3495
3497
3499 pwindow->size.x + adj_size(635),
3500 pwindow->size.y + adj_size(66),
3501 adj_size(155), TRUE);
3502 }
3503 }
3504}
3505
3506/**********************************************************************/
3509static void rebuild_citydlg_title_str(struct widget *pwindow,
3510 struct city *pcity)
3511{
3512 char cbuf[512];
3513
3514 fc_snprintf(cbuf, sizeof(cbuf),
3515 _("City of %s (Population %s citizens)"),
3516 city_name_get(pcity),
3518
3519 if (city_unhappy(pcity)) {
3520 /* TRANS: preserve leading space */
3521 fc_strlcat(cbuf, _(" - DISORDER"), sizeof(cbuf));
3522 } else {
3523 if (city_celebrating(pcity)) {
3524 /* TRANS: preserve leading space */
3525 fc_strlcat(cbuf, _(" - celebrating"), sizeof(cbuf));
3526 } else {
3527 if (city_happy(pcity)) {
3528 /* TRANS: preserve leading space */
3529 fc_strlcat(cbuf, _(" - happy"), sizeof(cbuf));
3530 }
3531 }
3532 }
3533
3534 if (cma_is_city_under_agent(pcity, NULL)) {
3535 /* TRANS: preserve leading space */
3536 fc_strlcat(cbuf, _(" - under Citizen Governor control."), sizeof(cbuf));
3537 }
3538
3540}
3541
3542
3543/* ========================= Public ================================== */
3544
3545/**********************************************************************/
3549void real_city_dialog_popup(struct city *pcity)
3550{
3551 struct widget *pwindow = NULL, *buf = NULL;
3553 utf8_str *pstr = NULL;
3554 int cs;
3555 struct player *owner = city_owner(pcity);
3556 SDL_Rect area;
3557
3558 if (pcity_dlg) {
3559 return;
3560 }
3561
3562 menus_update();
3563
3564 pcity_dlg = fc_calloc(1, sizeof(struct city_dialog));
3565 pcity_dlg->pcity = pcity;
3566 pcity_dlg->page = ARMY_PAGE;
3567
3569 pstr->style |= TTF_STYLE_BOLD;
3570 pwindow = create_window(NULL, pstr, adj_size(640), adj_size(480), 0);
3571
3572 rebuild_citydlg_title_str(pwindow, pcity);
3573
3574 pwindow->action = city_dlg_callback;
3575 set_wstate(pwindow, FC_WS_NORMAL);
3576
3578
3580
3581 /* create window background */
3583 if (resize_window(pwindow, logo, NULL, adj_size(640), adj_size(480))) {
3585 }
3586
3587 logo = get_city_gfx();
3588 alphablit(logo, NULL, pwindow->theme, NULL, 255);
3589
3590 area = pwindow->area;
3591
3592 widget_set_position(pwindow,
3593 (main_window_width() - pwindow->size.w) / 2,
3594 (main_window_height() - pwindow->size.h) / 2);
3595
3596 /* ============================================================= */
3597
3598 /* Close dialog button */
3599 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3601 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3603 buf->action = exit_city_dlg_callback;
3604 buf->size.x = area.x + area.w - buf->size.w;
3605 buf->size.y = pwindow->size.y + adj_size(2);
3606 buf->key = SDLK_ESCAPE;
3609
3610 /* -------- */
3611
3612 buf = create_themeicon(current_theme->army_icon, pwindow->dst,
3614 buf->info_label = create_utf8_from_char_fonto(_("Present units"),
3616 buf->action = army_city_dlg_callback;
3617 buf->size.x = area.x + adj_size(2) + ((adj_size(183) - 5 * buf->size.w) / 6);
3618 buf->size.y = area.y + adj_size(2);
3621 /* -------- */
3622
3623 buf = create_themeicon(current_theme->support_icon, pwindow->dst,
3625 buf->info_label = create_utf8_from_char_fonto(_("Supported units"),
3628 buf->size.x =
3629 area.x + adj_size(2) + 2 * ((adj_size(183) - 5 * buf->size.w) / 6) + buf->size.w;
3630 buf->size.y = area.y + adj_size(2);
3631
3634 /* -------- */
3635
3636 buf = create_themeicon(current_theme->happy_icon, pwindow->dst,
3638 buf->info_label = create_utf8_from_char_fonto(_("Happiness"),
3640 buf->action = happy_city_dlg_callback;
3641 buf->size.x
3642 = area.x + adj_size(2) + 3 * ((adj_size(183) - 5 * buf->size.w) / 6) + 2 * buf->size.w;
3643 buf->size.y = area.y + adj_size(2);
3646 /* -------- */
3647
3648 buf = create_themeicon(current_theme->info_icon, pwindow->dst,
3650 buf->info_label = create_utf8_from_char_fonto(_("City info"),
3652 buf->action = info_city_dlg_callback;
3653 buf->size.x
3654 = area.x + adj_size(4) + 4 * ((adj_size(183) - 5 * buf->size.w) / 6) + 3 * buf->size.w;
3655 buf->size.y = area.y + adj_size(2);
3658
3661 /* ===================================================== */
3662 rebuild_imprm_list(pcity);
3663 /* ===================================================== */
3664
3665 logo = get_scaled_city_map(pcity);
3666
3667 buf = create_themelabel(logo, pwindow->dst, NULL,
3669
3671
3673 if (!cma_is_city_under_agent(pcity, NULL) && (owner == client.conn.playing)) {
3675 }
3676 buf->size.x = area.x + adj_size(193) + (adj_size(249) - buf->size.w) / 2;
3677 buf->size.y = area.y + adj_size(41) + (adj_size(158) - buf->size.h) / 2;
3679 /* -------- */
3680
3681 buf = create_themeicon(current_theme->options_icon, pwindow->dst,
3683 buf->info_label = create_utf8_from_char_fonto(_("City options"),
3686 buf->size.x
3687 = area.x + adj_size(4) + 5 * ((adj_size(183) - 5 * buf->size.w) / 6) + 4 * buf->size.w;
3688 buf->size.y = area.y + adj_size(2);
3689 if (owner == client.conn.playing) {
3691 }
3693 /* -------- */
3694
3695 buf = create_themeicon(current_theme->prod_icon, pwindow->dst,
3697 buf->info_label = create_utf8_from_char_fonto(_("Change production"),
3699 buf->action = change_prod_dlg_callback;
3700 buf->size.x = area.x + adj_size(7);
3701 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3702 if (owner == client.conn.playing) {
3704 }
3705 buf->key = SDLK_C;
3707 /* -------- */
3708
3709 buf = create_themeicon(current_theme->buy_prod_icon, pwindow->dst,
3711 buf->info_label = create_utf8_from_char_fonto(_("Hurry production"),
3714 buf->size.x = area.x + adj_size(7) + (buf->size.w + adj_size(2));
3715 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3717 buf->key = SDLK_H;
3718 if (city_can_buy(pcity)) {
3720 }
3722 /* -------- */
3723
3724 buf = create_themeicon(current_theme->cma_icon, pwindow->dst,
3726 buf->info_label = create_utf8_from_char_fonto(_("Citizen Governor"),
3728 buf->action = cma_city_dlg_callback;
3729 buf->key = SDLK_A;
3730 buf->size.x = area.x + adj_size(7) + (buf->size.w + adj_size(2)) * 2;
3731 buf->size.y = area.y + area.h - buf->size.h - adj_size(5);
3732 if (owner == client.conn.playing) {
3734 }
3736
3737
3738 /* -------- */
3739 buf = create_themeicon(current_theme->l_arrow_icon, pwindow->dst,
3741 buf->info_label = create_utf8_from_char_fonto(_("Previous city"),
3744 buf->size.x = area.x + adj_size(220) - buf->size.w - adj_size(8);
3745 buf->size.y = area.y + area.h - buf->size.h;
3746 if (owner == client.conn.playing) {
3748 }
3749 buf->key = SDLK_LEFT;
3750 buf->mod = SDL_KMOD_LSHIFT;
3752 /* -------- */
3753
3754 buf = create_themeicon(current_theme->r_arrow_icon, pwindow->dst,
3756 buf->info_label = create_utf8_from_char_fonto(_("Next city"),
3759 buf->size.x = area.x + adj_size(420) + adj_size(2);
3760 buf->size.y = area.y + area.h - buf->size.h;
3761 if (owner == client.conn.playing) {
3763 }
3764 buf->key = SDLK_RIGHT;
3765 buf->mod = SDL_KMOD_LSHIFT;
3767 /* -------- */
3768
3770 FONTO_DEFAULT, adj_size(200),
3773 buf->size.x = area.x + (area.w - buf->size.w) / 2;
3774 buf->size.y = area.y + area.h - buf->size.h - adj_size(2);
3775 if (owner == client.conn.playing) {
3777 }
3778
3781
3783
3784 /* check if Citizen Icons style was loaded */
3785 cs = style_of_city(pcity);
3786
3787 if (cs != icons->style) {
3789 }
3790
3791 /* ===================================================== */
3792 if ((city_unhappy(pcity) || city_celebrating(pcity)
3793 || city_happy(pcity))) {
3795 }
3796 /* ===================================================== */
3797
3798 redraw_city_dialog(pcity);
3799 flush_dirty();
3800}
3801
3802/**********************************************************************/
3805void popdown_city_dialog(struct city *pcity)
3806{
3807 if (city_dialog_is_open(pcity)) {
3809
3810 flush_dirty();
3811
3813 menus_update();
3814 }
3815}
3816
3817/**********************************************************************/
3821{
3822 if (pcity_dlg) {
3824 }
3825}
3826
3827/**********************************************************************/
3831{
3832 if (city_dialog_is_open(pcity)) {
3834 flush_dirty();
3835 }
3836}
3837
3838/**********************************************************************/
3844{
3847
3848 if (pcity_dlg && ((pcity_dlg->pcity == city_sup)
3849 || (pcity_dlg->pcity == city_pre))) {
3852 flush_dirty();
3853 }
3854}
3855
3856/**********************************************************************/
3859bool city_dialog_is_open(struct city *pcity)
3860{
3861 return (pcity_dlg && (pcity_dlg->pcity == pcity));
3862}
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
#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
Uint32 sdl3_client_flags
Definition gui_main.c:97
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 * 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