Freeciv-3.3
Loading...
Searching...
No Matches
cityrep.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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* SDL2 */
19#ifdef SDL2_PLAIN_INCLUDE
20#include <SDL.h>
21#else /* SDL2_PLAIN_INCLUDE */
22#include <SDL2/SDL.h>
23#endif /* SDL2_PLAIN_INCLUDE */
24
25/* utility */
26#include "fcintl.h"
27#include "log.h"
28
29/* common */
30#include "game.h"
31
32/* client */
33#include "client_main.h"
34
35/* gui-sdl2 */
36#include "citydlg.h"
37#include "cma_fe.h"
38#include "colors.h"
39#include "graphics.h"
40#include "gui_id.h"
41#include "gui_main.h"
42#include "gui_tilespec.h"
43#include "mapctrl.h"
44#include "mapview.h"
45#include "repodlgs.h"
46#include "sprite.h"
47#include "themespec.h"
48#include "widget.h"
49#include "wldlg.h"
50
51#include "cityrep.h"
52
53static struct advanced_dialog *city_rep = NULL;
54
56
57/* ==================================================================== */
58
59/**********************************************************************/
74
75/**********************************************************************/
78static int city_report_windows_callback(struct widget *pwindow)
79{
82 }
83
84 return -1;
85}
86
87/**********************************************************************/
90static int exit_city_report_callback(struct widget *pwidget)
91{
94 }
95
96 return -1;
97}
98
99/**********************************************************************/
103{
105 popup_city_dialog(pwidget->data.city);
106 }
107
108 return -1;
109}
110
111/**********************************************************************/
115{
118 }
119
120 return -1;
121}
122
123/**********************************************************************/
127{
130 }
131
132 return -1;
133}
134
135/**********************************************************************/
139{
141 struct city *pcity = game_city_by_number(MAX_ID - pwidget->id);
142
143 /* state is changed before enter this function */
144 if (!get_checkbox_state(pwidget)) {
147 } else {
149 }
150 }
151
152 return -1;
153}
154
155#if 0
156/**********************************************************************/
159static int info_city_report_callback(struct widget *pwidget)
160{
162 set_wstate(pwidget, FC_WS_NORMAL);
164 widget_redraw(pwidget);
165 widget_mark_dirty(pwidget);
167 }
168
169 return -1;
170}
171#endif /* 0 */
172
173#define COL 17
174
175/**********************************************************************/
179{
180 SDL_Color bg_color = {255, 255, 255, 136};
181
182 struct widget *pbuf = NULL;
183 struct widget *pwindow, *last;
184 utf8_str *pstr;
185 SDL_Surface *text1, *text2, *text3, *units_icon, *cma_icon, *text4;
187 int togrow, w = 0 , count, ww = 0, hh = 0, name_w = 0, prod_w = 0, h;
188 char cbuf[128];
189 const char *name;
192
193 if (city_rep) {
196 } else {
197 city_rep = fc_calloc(1, sizeof(struct advanced_dialog));
198 }
199
200 fc_snprintf(cbuf, sizeof(cbuf), _("size"));
202 pstr->style |= SF_CENTER;
204
205 fc_snprintf(cbuf, sizeof(cbuf), _("time\nto grow"));
208
209 fc_snprintf(cbuf, sizeof(cbuf), _("City Name"));
212 name_w = text3->w + adj_size(6);
213
214 fc_snprintf(cbuf, sizeof(cbuf), _("Production"));
218 prod_w = text4->w;
220
221 units_icon = create_icon_from_theme(current_theme->units_icon, 0);
222 cma_icon = create_icon_from_theme(current_theme->cma_icon, 0);
223
224 /* --------------- */
226 pstr->style |= TTF_STYLE_BOLD;
227
228 pwindow = create_window_skeleton(NULL, pstr, 0);
229 city_rep->end_widget_list = pwindow;
230 set_wstate(pwindow, FC_WS_NORMAL);
232
233 add_to_gui_list(ID_WINDOW, pwindow);
234
235 area = pwindow->area;
236
237 /* ------------------------- */
238 /* Exit button */
239 pbuf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
241 pbuf->info_label = create_utf8_from_char_fonto(_("Close Dialog"),
245 pbuf->key = SDLK_ESCAPE;
246
248
249/* FIXME: Not implemented yet */
250#if 0
251 /* ------------------------- */
252 pbuf = create_themeicon(current_theme->info_icon, pwindow->dst,
254 pbuf->info_label = create_utf8_from_char_fonto(_("Information Report"),
256/*
257 pbuf->action = info_city_report_callback;
258 set_wstate(pbuf, FC_WS_NORMAL);
259*/
261 /* -------- */
262 pbuf = create_themeicon(current_theme->happy_icon, pwindow->dst,
264 pbuf->info_label = create_utf8_from_char_fonto(_("Happiness Report"),
266/*
267 pbuf->action = happy_city_report_callback;
268 set_wstate(pbuf, FC_WS_NORMAL);
269*/
271 /* -------- */
272 pbuf = create_themeicon(current_theme->army_icon, pwindow->dst,
274
275 pbuf->info_label = create_utf8_from_char_fonto(_("Garrison Report"),
277/*
278 pbuf->action = army_city_dlg_callback;
279 set_wstate(pbuf, FC_WS_NORMAL);
280*/
282 /* -------- */
283 pbuf = create_themeicon(current_theme->support_icon, pwindow->dst,
285 pbuf->info_label = create_utf8_from_char_fonto(_("Maintenance Report"),
287/*
288 pbuf->action = supported_unit_city_dlg_callback;
289 set_wstate(pbuf, FC_WS_NORMAL);
290*/
292 /* ------------------------ */
293#endif /* 0 */
294
295 last = pbuf;
296 count = 0;
299 pstr->style |= TTF_STYLE_BOLD;
300 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
302
303 if (city_unhappy(pcity)) {
304 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
305 } else {
306 if (city_celebrating(pcity)) {
307 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
308 } else {
309 if (city_happy(pcity)) {
310 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
311 }
312 }
313 }
314
317 pbuf->data.city = pcity;
318 if (count > 13 * COL) {
320 }
321 hh = pbuf->size.h;
322 name_w = MAX(pbuf->size.w, name_w);
324
325 /* ----------- */
326 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
328 pstr->style |= SF_CENTER;
329 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
331 if (count > 13 * COL) {
333 }
334 hh = MAX(hh, pbuf->size.h);
335 pbuf->size.w = text1->w + adj_size(8);
337
338 /* ----------- */
339 pbuf = create_checkbox(pwindow->dst,
342 if (count > 13 * COL) {
344 }
345 hh = MAX(hh, pbuf->size.h);
350
351 /* ----------- */
352 fc_snprintf(cbuf, sizeof(cbuf), "%d",
353 pcity->prod[O_FOOD] - pcity->surplus[O_FOOD]);
355 pstr->style |= SF_CENTER;
357 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
359 if (count > 13 * COL) {
361 }
362 hh = MAX(hh, pbuf->size.h);
363 pbuf->size.w = icons->big_food->w + adj_size(6);
365
366 /* ----------- */
367 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
369 pstr->style |= SF_CENTER;
371 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
373 if (count > 13 * COL) {
375 }
376 hh = MAX(hh, pbuf->size.h);
377 pbuf->size.w = icons->big_food_corr->w + adj_size(6);
379
380 /* ----------- */
382 switch (togrow) {
383 case 0:
384 fc_snprintf(cbuf, sizeof(cbuf), "#");
385 break;
386 case FC_INFINITY:
387 fc_snprintf(cbuf, sizeof(cbuf), "--");
388 break;
389 default:
390 fc_snprintf(cbuf, sizeof(cbuf), "%d", togrow);
391 break;
392 }
393
395 pstr->style |= SF_CENTER;
396 if (togrow < 0) {
397 pstr->fgcol.r = 255;
398 }
399 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
401 if (count > 13 * COL) {
403 }
404 hh = MAX(hh, pbuf->size.h);
405 pbuf->size.w = text2->w + adj_size(6);
407
408 /* ----------- */
409 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_TRADE]);
411 pstr->style |= SF_CENTER;
413 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
415 if (count > 13 * COL) {
417 }
418 hh = MAX(hh, pbuf->size.h);
419 pbuf->size.w = icons->big_trade->w + adj_size(6);
421
422 /* ----------- */
423 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
425 pstr->style |= SF_CENTER;
426 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
428 if (count > 13 * COL) {
430 }
431 hh = MAX(hh, pbuf->size.h);
432 pbuf->size.w = icons->big_trade_corr->w + adj_size(6);
434
435 /* ----------- */
436 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
438 pstr->style |= SF_CENTER;
440 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
442 if (count > 13 * COL) {
444 }
445 hh = MAX(hh, pbuf->size.h);
446 pbuf->size.w = icons->big_coin->w + adj_size(6);
448
449 /* ----------- */
450 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
452 pstr->style |= SF_CENTER;
454 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
456 if (count > 13 * COL) {
458 }
459 hh = MAX(hh, pbuf->size.h);
460 pbuf->size.w = icons->big_colb->w + adj_size(6);
462
463 /* ----------- */
464 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
466 pstr->style |= SF_CENTER;
468 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
470 if (count > 13 * COL) {
472 }
473 hh = MAX(hh, pbuf->size.h);
474 pbuf->size.w = icons->big_luxury->w + adj_size(6);
476
477 /* ----------- */
478 fc_snprintf(cbuf, sizeof(cbuf), "%d",
479 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
481 pstr->style |= SF_CENTER;
483 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
485 if (count > 13 * COL) {
487 }
488 hh = MAX(hh, pbuf->size.h);
489 pbuf->size.w = icons->big_shield->w + adj_size(6);
491
492 /* ----------- */
493 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
495 pstr->style |= SF_CENTER;
496 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
498 if (count > 13 * COL) {
500 }
501 hh = MAX(hh, pbuf->size.h);
502 pbuf->size.w = icons->big_shield_corr->w + adj_size(6);
504
505 /* ----------- */
506 fc_snprintf(cbuf, sizeof(cbuf), "%d",
507 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD] - pcity->surplus[O_SHIELD]);
509 pstr->style |= SF_CENTER;
511 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
513 if (count > 13 * COL) {
515 }
516 hh = MAX(hh, pbuf->size.h);
517 pbuf->size.w = units_icon->w + adj_size(6);
519
520 /* ----------- */
521 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
523 pstr->style |= SF_CENTER;
525 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
527 if (count > 13 * COL) {
529 }
530 hh = MAX(hh, pbuf->size.h);
531 pbuf->size.w = icons->big_shield_surplus->w + adj_size(6);
533
534 /* ----------- */
535 if (VUT_UTYPE == pcity->production.kind) {
536 const struct unit_type *punittype = pcity->production.value.utype;
537
540 adj_size(36), adj_size(24), 1,
541 TRUE, TRUE);
544 } else {
545 const struct impr_type *pimprove = pcity->production.value.building;
546
547 logo = resize_surface_box(get_building_surface(pcity->production.value.building),
548 adj_size(36), adj_size(24), 1,
549 TRUE, TRUE);
552 }
553
554 if (!worklist_is_empty(&(pcity->worklist))) {
555 dst.x = logo->w - icons->worklist->w;
556 dst.y = 0;
557 alphablit(icons->worklist, NULL, logo, &dst, 255);
558 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
559 name, pcity->shield_stock, togrow, _("worklist"));
560 } else {
561 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)%s",
562 name, pcity->shield_stock, togrow,
563 pcity->shield_stock > togrow ? _("\nfinished"): "" );
564 }
565
566 /* Info string */
568 pstr->style |= SF_CENTER;
569
571 if (togrow == 999) {
572 fc_snprintf(cbuf, sizeof(cbuf), "%s", _("never"));
573 } else {
574 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
575 togrow, PL_("turn", "turns", togrow));
576 }
577
578 pbuf = create_icon2(logo, pwindow->dst,
580 | WF_FREE_THEME);
581 pbuf->info_label = pstr;
582 if (count > 13 * COL) {
584 }
585 hh = MAX(hh, pbuf->size.h);
589 pbuf->data.city = pcity;
590
592 pstr->style |= SF_CENTER;
594 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
596 if (count > 13 * COL) {
598 }
599 hh = MAX(hh, pbuf->size.h);
600 prod_w = MAX(prod_w, pbuf->size.w);
602 pbuf->data.city = pcity;
604 if (city_can_buy(pcity)) {
606 }
607
608 count += COL;
610
611 h = hh;
613
614 /* Setup window width */
615 area.w = name_w + adj_size(6) + text1->w + adj_size(8) + cma_icon->w
616 + (icons->big_food->w + adj_size(6)) * 10 + text2->w + adj_size(6)
617 + units_icon->w + adj_size(6) + prod_w + adj_size(170);
618
619 if (count) {
622 if (count > 14 * COL) {
624 if (city_rep->scroll) {
625 city_rep->scroll->count = count;
626 }
628 area.w += ww;
629 area.h = 14 * (hh + adj_size(2));
630 } else {
631 area.h = (count / COL) * (hh + adj_size(2));
632 }
633 }
634
635 area.h += text2->h + adj_size(6);
636 area.w += adj_size(2);
637
639 resize_window(pwindow, logo, NULL,
640 (pwindow->size.w - pwindow->area.w) + area.w,
641 (pwindow->size.h - pwindow->area.h) + area.h);
643
644#if 0
645 logo = SDL_DisplayFormat(pwindow->theme);
646 FREESURFACE(pwindow->theme);
647 pwindow->theme = logo;
648 logo = NULL;
649#endif /* 0 */
650
651 area = pwindow->area;
652
653 widget_set_position(pwindow,
654 (main_window_width() - pwindow->size.w) / 2,
655 (main_window_height() - pwindow->size.h) / 2);
656
657 /* Exit button */
658 pbuf = pwindow->prev;
659 pbuf->size.x = area.x + area.w - pbuf->size.w - 1;
660 pbuf->size.y = pwindow->size.y + adj_size(2);
661
662/* FIXME: not implemented yet */
663#if 0
664 /* Info button */
665 pbuf = pbuf->prev;
666 pbuf->size.x = area.x + area.w - pbuf->size.w - adj_size(5);
667 pbuf->size.y = area.y + area.h - pbuf->size.h - adj_size(5);
668
669 /* Happy button */
670 pbuf = pbuf->prev;
671 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
672 pbuf->size.y = pbuf->next->size.y;
673
674 /* Army button */
675 pbuf = pbuf->prev;
676 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
677 pbuf->size.y = pbuf->next->size.y;
678
679 /* Supported button */
680 pbuf = pbuf->prev;
681 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
682 pbuf->size.y = pbuf->next->size.y;
683#endif /* 0 */
684
685 /* Cities background and labels */
686 dst.x = area.x + adj_size(2);
687 dst.y = area.y + 1;
688 dst.w = (name_w + adj_size(6)) + (text1->w + adj_size(8)) + adj_size(5);
689 dst.h = area.h - adj_size(2);
690 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
691
692 create_frame(pwindow->theme,
693 dst.x , dst.y, dst.w, dst.h - 1,
695
696 dst.y += (text2->h - text3->h) / 2;
697 dst.x += ((name_w + adj_size(6)) - text3->w) / 2;
698 alphablit(text3, NULL, pwindow->theme, &dst, 255);
700
701 /* City size background and label */
702 dst.x = area.x + adj_size(5) + name_w + adj_size(5 + 4);
703 alphablit(text1, NULL, pwindow->theme, &dst, 255);
704 ww = text1->w;
706
707 /* CMA icon */
708 dst.x += (ww + adj_size(9));
709 dst.y = area.y + 1 + (text2->h - cma_icon->h) / 2;
710 alphablit(cma_icon, NULL, pwindow->theme, &dst, 255);
711 ww = cma_icon->w;
712 FREESURFACE(cma_icon);
713
714 /* -------------- */
715 /* Populations food upkeep background and label */
716 dst.x += (ww + 1);
717 dst.y = area.y + 1;
718 w = dst.x + adj_size(2);
719 dst.w = (icons->big_food->w + adj_size(6)) + adj_size(10)
720 + (icons->big_food_surplus->w + adj_size(6)) + adj_size(10)
721 + text2->w + adj_size(6 + 2);
722 dst.h = area.h - adj_size(2);
723 fill_rect_alpha(pwindow->theme, &dst,
725
726 create_frame(pwindow->theme,
727 dst.x, dst.y, dst.w, dst.h - 1,
729
730 dst.y = area.y + 1 + (text2->h - icons->big_food->h) / 2;
731 dst.x += adj_size(5);
732 alphablit(icons->big_food, NULL, pwindow->theme, &dst, 255);
733
734 /* Food surplus icon */
735 w += (icons->big_food->w + adj_size(6)) + adj_size(10);
736 dst.x = w + adj_size(3);
737 alphablit(icons->big_food_surplus, NULL, pwindow->theme, &dst, 255);
738
739 /* To grow label */
740 w += (icons->big_food_surplus->w + adj_size(6)) + adj_size(10);
741 dst.x = w + adj_size(3);
742 dst.y = area.y + 1;
743 alphablit(text2, NULL, pwindow->theme, &dst, 255);
744 hh = text2->h;
745 ww = text2->w;
747 /* -------------- */
748
749 /* Trade, corruptions, gold, science, luxury income background and label */
750 dst.x = w + (ww + adj_size(8));
751 dst.y = area.y + 1;
752 w = dst.x + adj_size(2);
753 dst.w = (icons->big_trade->w + adj_size(6)) + adj_size(10) +
754 (icons->big_trade_corr->w + adj_size(6)) + adj_size(10) +
755 (icons->big_coin->w + adj_size(6)) + adj_size(10) +
756 (icons->big_colb->w + adj_size(6)) + adj_size(10) +
757 (icons->big_luxury->w + adj_size(6)) + adj_size(4);
758 dst.h = area.h - adj_size(2);
759
760 fill_rect_alpha(pwindow->theme, &dst,
762
763 create_frame(pwindow->theme,
764 dst.x , dst.y, dst.w, dst.h - 1,
766
767 dst.y = area.y + 1 + (hh - icons->big_trade->h) / 2;
768 dst.x += adj_size(5);
769 alphablit(icons->big_trade, NULL, pwindow->theme, &dst, 255);
770
771 w += (icons->big_trade->w + adj_size(6)) + adj_size(10);
772 dst.x = w + adj_size(3);
773 alphablit(icons->big_trade_corr, NULL, pwindow->theme, &dst, 255);
774
775 w += (icons->big_food_corr->w + adj_size(6)) + adj_size(10);
776 dst.x = w + adj_size(3);
777 alphablit(icons->big_coin, NULL, pwindow->theme, &dst, 255);
778
779 w += (icons->big_coin->w + adj_size(6)) + adj_size(10);
780 dst.x = w + adj_size(3);
781 alphablit(icons->big_colb, NULL, pwindow->theme, &dst, 255);
782
783 w += (icons->big_colb->w + adj_size(6)) + adj_size(10);
784 dst.x = w + adj_size(3);
785 alphablit(icons->big_luxury, NULL, pwindow->theme, &dst, 255);
786 /* --------------------- */
787
788 /* Total productions, waste, support, shields surplus background and label */
789 w += (icons->big_luxury->w + adj_size(6)) + adj_size(4);
790 dst.x = w;
791 w += adj_size(2);
792 dst.y = area.y + 1;
793 dst.w = (icons->big_shield->w + adj_size(6)) + adj_size(10) +
794 (icons->big_shield_corr->w + adj_size(6)) + adj_size(10) +
795 (units_icon->w + adj_size(6)) + adj_size(10) +
797 dst.h = area.h - adj_size(2);
798
799 fill_rect_alpha(pwindow->theme, &dst,
801
802 create_frame(pwindow->theme,
803 dst.x , dst.y, dst.w, dst.h - 1,
805
806 dst.y = area.y + 1 + (hh - icons->big_shield->h) / 2;
807 dst.x += adj_size(5);
808 alphablit(icons->big_shield, NULL, pwindow->theme, &dst, 255);
809
810 w += (icons->big_shield->w + adj_size(6)) + adj_size(10);
811 dst.x = w + adj_size(3);
812 alphablit(icons->big_shield_corr, NULL, pwindow->theme, &dst, 255);
813
814 w += (icons->big_shield_corr->w + adj_size(6)) + adj_size(10);
815 dst.x = w + adj_size(3);
816 dst.y = area.y + 1 + (hh - units_icon->h) / 2;
817 alphablit(units_icon, NULL, pwindow->theme, &dst, 255);
818
819 w += (units_icon->w + adj_size(6)) + adj_size(10);
820 FREESURFACE(units_icon);
821 dst.x = w + adj_size(3);
822 dst.y = area.y + 1 + (hh - icons->big_shield_surplus->h) / 2;
823 alphablit(icons->big_shield_surplus, NULL, pwindow->theme, &dst, 255);
824 /* ------------------------------- */
825
826 w += (icons->big_shield_surplus->w + adj_size(6)) + adj_size(10);
827 dst.x = w;
828 dst.y = area.y + 1;
829 dst.w = adj_size(36) + adj_size(5) + prod_w;
830 dst.h = hh + adj_size(2);
831
832 fill_rect_alpha(pwindow->theme, &dst,
834
835 create_frame(pwindow->theme,
836 dst.x , dst.y, dst.w, dst.h - 1,
838
839 dst.y = area.y + 1 + (hh - text4->h) / 2;
840 dst.x += (dst.w - text4->w) / 2;
841 alphablit(text4, NULL, pwindow->theme, &dst, 255);
843
844 if (count) {
845 int start_x = area.x + adj_size(5);
846 int start_y = area.y + hh + adj_size(3);
847
848 h += adj_size(2);
849 pbuf = pbuf->prev;
850
851 while (TRUE) {
852
853 /* City name */
854 pbuf->size.x = start_x;
855 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
856 pbuf->size.w = name_w;
857
858 /* City size */
859 pbuf = pbuf->prev;
860 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
861 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
862
863 /* CMA */
864 pbuf = pbuf->prev;
865 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
866 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
867
868 /* Food cons. */
869 pbuf = pbuf->prev;
870 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
871 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
872
873 /* Food surplus */
874 pbuf = pbuf->prev;
875 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
876 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
877
878 /* Time to grow */
879 pbuf = pbuf->prev;
880 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
881 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
882
883 /* Trade */
884 pbuf = pbuf->prev;
885 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
886 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
887
888 /* Trade corruptions */
889 pbuf = pbuf->prev;
890 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
891 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
892
893 /* Net gold income */
894 pbuf = pbuf->prev;
895 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
896 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
897
898 /* Science income */
899 pbuf = pbuf->prev;
900 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
901 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
902
903 /* Luxuries income */
904 pbuf = pbuf->prev;
905 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
906 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
907
908 /* Total production */
909 pbuf = pbuf->prev;
910 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
911 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
912
913 /* Waste */
914 pbuf = pbuf->prev;
915 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
916 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
917
918 /* Units support */
919 pbuf = pbuf->prev;
920 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
921 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
922
923 /* Production surplus */
924 pbuf = pbuf->prev;
925 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
926 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
927
928 /* Currently build */
929 /* Icon */
930 pbuf = pbuf->prev;
931 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
932 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
933
934 /* Label */
935 pbuf = pbuf->prev;
936 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
937 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
938 pbuf->size.w = prod_w;
939
940 start_y += h;
942 break;
943 }
944 pbuf = pbuf->prev;
945 }
946
947 if (city_rep->scroll) {
949 area.x + area.w, area.y,
950 area.h, TRUE);
951 }
952
953 }
954
955 /* ----------------------------------- */
957 widget_mark_dirty(pwindow);
958 flush_dirty();
959}
960
961/**********************************************************************/
964static struct widget *real_city_report_dialog_update_city(struct widget *pwidget,
965 struct city *pcity)
966{
967 char cbuf[64];
968 const char *name;
969 int togrow;
972
973 /* city name status */
974 if (city_unhappy(pcity)) {
976 } else {
977 if (city_celebrating(pcity)) {
979 } else {
980 if (city_happy(pcity)) {
982 }
983 }
984 }
985
986 /* city size */
987 pwidget = pwidget->prev;
988 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
990
991 /* cma check box */
992 pwidget = pwidget->prev;
994 toggle_checkbox(pwidget);
995 }
996
997 /* food consumptions */
998 pwidget = pwidget->prev;
999 fc_snprintf(cbuf, sizeof(cbuf), "%d",
1000 pcity->prod[O_FOOD] - pcity->surplus[O_FOOD]);
1002
1003 /* food surplus */
1004 pwidget = pwidget->prev;
1005 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
1007
1008 /* time to grow */
1009 pwidget = pwidget->prev;
1011 switch (togrow) {
1012 case 0:
1013 fc_snprintf(cbuf, sizeof(cbuf), "#");
1014 break;
1015 case FC_INFINITY:
1016 fc_snprintf(cbuf, sizeof(cbuf), "--");
1017 break;
1018 default:
1019 fc_snprintf(cbuf, sizeof(cbuf), "%d", togrow);
1020 break;
1021 }
1023
1024 if (togrow < 0) {
1025 pwidget->string_utf8->fgcol.r = 255;
1026 } else {
1027 pwidget->string_utf8->fgcol.r = 0;
1028 }
1029
1030 /* trade production */
1031 pwidget = pwidget->prev;
1032 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_TRADE]);
1034
1035 /* corruptions */
1036 pwidget = pwidget->prev;
1037 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
1039
1040 /* gold surplus */
1041 pwidget = pwidget->prev;
1042 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
1044
1045 /* science income */
1046 pwidget = pwidget->prev;
1047 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
1049
1050 /* lugury income */
1051 pwidget = pwidget->prev;
1052 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
1054
1055 /* total production */
1056 pwidget = pwidget->prev;
1057 fc_snprintf(cbuf, sizeof(cbuf), "%d",
1058 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
1060
1061 /* waste */
1062 pwidget = pwidget->prev;
1063 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
1065
1066 /* units support */
1067 pwidget = pwidget->prev;
1068 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SHIELD] +
1069 pcity->waste[O_SHIELD] - pcity->surplus[O_SHIELD]);
1071
1072 /* production income */
1073 pwidget = pwidget->prev;
1074 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
1076
1077 /* change production */
1078 if (VUT_UTYPE == pcity->production.kind) {
1079 const struct unit_type *punittype = pcity->production.value.utype;
1080
1082 adj_size(36), adj_size(24), 1);
1085 } else {
1086 const struct impr_type *pimprove = pcity->production.value.building;
1087
1088 logo = resize_surface(get_building_surface(pcity->production.value.building),
1089 adj_size(36), adj_size(24), 1);
1090 togrow = impr_build_shield_cost(pcity, pimprove);
1092 }
1093
1094 if (!worklist_is_empty(&(pcity->worklist))) {
1095 dst.x = logo->w - icons->worklist->w;
1096 dst.y = 0;
1097 alphablit(icons->worklist, NULL, logo, &dst, 255);
1098 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
1099 name, pcity->shield_stock, togrow, _("worklist"));
1100 } else {
1101 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)",
1102 name, pcity->shield_stock, togrow);
1103 }
1104
1105 pwidget = pwidget->prev;
1107 FREESURFACE(pwidget->theme);
1108 pwidget->theme = logo;
1109
1110 /* hurry productions */
1111 pwidget = pwidget->prev;
1113 if (togrow == 999) {
1114 fc_snprintf(cbuf, sizeof(cbuf), "%s", _("never"));
1115 } else {
1116 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
1117 togrow, PL_("turn", "turns", togrow));
1118 }
1119
1121
1122 return pwidget->prev;
1123}
1124
1125/* ======================================================================== */
1126
1127/**********************************************************************/
1131{
1132 return (city_rep != NULL);
1133}
1134
1135/**********************************************************************/
1140{
1141 if (!city_rep) {
1143 }
1144}
1145
1146/**********************************************************************/
1150{
1151 if (city_rep) {
1152 struct widget *pwidget;
1153 int count;
1154
1155 /* find if the lists are identical (if not then rebuild all) */
1156 pwidget = city_rep->end_active_widget_list; /* name of first city */
1158 if (pcity->id == MAX_ID - pwidget->id) {
1159 count = COL;
1160
1161 while (count) {
1162 count--;
1163 pwidget = pwidget->prev;
1164 }
1165 } else {
1167
1168 return;
1169 }
1171
1172 /* check it there are some city widgets left on list */
1173 if (pwidget && pwidget->next != city_rep->begin_active_widget_list) {
1175 return;
1176 }
1177
1178 /* update widget city list (widget list is the same that city list) */
1181 pwidget = real_city_report_dialog_update_city(pwidget, pcity);
1183
1184 /* -------------------------------------- */
1187
1188 flush_dirty();
1189 }
1190}
1191
1192/**********************************************************************/
1196{
1197 if (city_rep && pcity) {
1199
1200 while (pcity->id != MAX_ID - buf->id
1202 buf = buf->prev;
1203 }
1204
1207 return;
1208 }
1210
1211 /* -------------------------------------- */
1214
1215 flush_dirty();
1216 }
1217}
1218
1219/**********************************************************************/
1225{
1226 log_debug("hilite_cities_from_canvas : PORT ME");
1227}
1228
1229/**********************************************************************/
1233{
1234 log_debug("toggle_city_hilite : PORT ME");
1235}
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
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
bool city_happy(const struct city *pcity)
Definition city.c:1614
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1996
#define city_list_iterate(citylist, pcity)
Definition city.h:505
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
#define city_list_iterate_end
Definition city.h:507
bool city_can_buy(const struct city *pcity)
void popup_city_dialog(struct city *pcity)
void city_report_dialog_update_city(struct city *pcity)
struct civclient client
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:552
void cma_release_city(struct city *pcity)
Definition cma_core.c:542
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
QString current_theme
Definition fc_client.cpp:64
@ 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 PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct city * game_city_by_number(int id)
Definition game.c:106
void real_city_report_dialog_update(void *unused)
Definition cityrep.c:1458
void real_city_report_update_city(struct city *pcity)
Definition cityrep.c:1493
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2093
void hilite_cities_from_canvas(void)
Definition cityrep.c:2070
void city_report_dialog_popdown(void)
Definition cityrep.c:312
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
void flush_dirty(void)
Definition mapview.c:468
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1176
static int exit_city_report_callback(struct widget *pwidget)
Definition cityrep.c:90
static int popup_worklist_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:114
static int popup_citydlg_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:102
static int city_report_windows_callback(struct widget *pwindow)
Definition cityrep.c:78
static struct advanced_dialog * city_rep
Definition cityrep.c:53
static struct widget * real_city_report_dialog_update_city(struct widget *pwidget, struct city *pcity)
Definition cityrep.c:964
static int popup_cma_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:138
static int popup_buy_production_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:126
#define COL
Definition cityrep.c:173
static void real_info_city_report_dialog_update(void)
Definition cityrep.c:178
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
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
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
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1350
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 FREESURFACE(ptr)
Definition graphics.h:322
@ ID_BUTTON
Definition gui_id.h:29
@ ID_WINDOW
Definition gui_id.h:30
struct widget * selected_widget
Definition widget.c:48
#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
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
@ 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
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
void enable_and_redraw_find_city_button(void)
Definition mapctrl.c:2235
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_CITYREP
@ COLOR_THEME_CITYDLG_CELEB
Definition themecolors.h:48
@ COLOR_THEME_CITYREP_FRAME
Definition themecolors.h:71
@ COLOR_THEME_CITYDLG_LUX
Definition themecolors.h:60
@ COLOR_THEME_CITYDLG_TRADE
Definition themecolors.h:68
@ COLOR_THEME_CITYDLG_PROD
Definition themecolors.h:62
@ COLOR_THEME_CITYDLG_SUPPORT
Definition themecolors.h:67
@ COLOR_THEME_CITYREP_FOODSTOCK
Definition themecolors.h:70
@ COLOR_THEME_CITYREP_TEXT
Definition themecolors.h:73
@ COLOR_THEME_CITYDLG_HAPPY
Definition themecolors.h:57
@ COLOR_THEME_CITYDLG_SCIENCE
Definition themecolors.h:63
@ COLOR_THEME_CITYREP_TRADE
Definition themecolors.h:74
@ COLOR_THEME_CITYDLG_GOLD
Definition themecolors.h:54
@ COLOR_THEME_CITYREP_PROD
Definition themecolors.h:72
@ COLOR_THEME_CITYDLG_FOOD_SURPLUS
Definition themecolors.h:52
struct theme * active_theme
Definition themespec.c:154
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
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_NORMAL
Definition widget.h:96
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ 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
void toggle_checkbox(struct widget *cbox)
bool get_checkbox_state(struct widget *cbox)
struct widget * create_checkbox(struct gui_layer *pdest, bool state, Uint32 flags)
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)
SDL_Surface * create_icon_from_theme(SDL_Surface *icon_theme, Uint8 state)
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)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1061
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:177
#define log_debug(message,...)
Definition log.h:116
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
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
SDL_Surface * big_trade_corr
SDL_Surface * big_shield_corr
SDL_Surface * big_trade
SDL_Surface * big_shield
SDL_Surface * big_luxury
SDL_Surface * big_colb
SDL_Surface * big_food
SDL_Surface * big_coin
SDL_Surface * big_food_corr
SDL_Surface * big_food_surplus
SDL_Surface * worklist
SDL_Surface * big_shield_surplus
Definition city.h:317
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
struct city_list * cities
Definition player.h:281
SDL_Event event
Definition graphics.h:217
int id
Definition unit.h:147
enum gen_action action
Definition unit.h:160
const struct unit_type * utype
Definition unit.h:141
SDL_Color fgcol
Definition gui_string.h:57
SDL_Surface * theme
Definition widget.h:118
union widget::@223 data
struct widget * prev
Definition widget.h:114
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
struct widget * next
Definition widget.h:113
utf8_str * info_label
Definition widget.h:122
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1444
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1566
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66