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

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/* SDL3 */
19#include <SDL3/SDL.h>
20
21/* utility */
22#include "fcintl.h"
23#include "log.h"
24
25/* common */
26#include "game.h"
27
28/* client */
29#include "client_main.h"
30
31/* gui-sdl3 */
32#include "citydlg.h"
33#include "cma_fe.h"
34#include "colors.h"
35#include "graphics.h"
36#include "gui_id.h"
37#include "gui_main.h"
38#include "gui_tilespec.h"
39#include "mapctrl.h"
40#include "mapview.h"
41#include "repodlgs.h"
42#include "sprite.h"
43#include "themespec.h"
44#include "widget.h"
45#include "wldlg.h"
46
47#include "cityrep.h"
48
49 static struct advanced_dialog *city_rep = NULL;
50
51static void real_info_city_report_dialog_update(void);
52
53/* ==================================================================== */
54
55/**********************************************************************/
58 void city_report_dialog_popdown(void)
59{
60 if (city_rep) {
61 popdown_window_group_dialog(city_rep->begin_widget_list,
62 city_rep->end_widget_list);
63 FC_FREE(city_rep->scroll);
64 FC_FREE(city_rep);
65
66 enable_and_redraw_find_city_button();
67 flush_dirty();
68 }
69}
70
71/**********************************************************************/
74 static int city_report_windows_callback(struct widget *pwindow)
75{
76 if (PRESSED_EVENT(main_data.event)) {
77 move_window_group(city_rep->begin_widget_list, pwindow);
78 }
79
80 return -1;
81}
82
83/**********************************************************************/
86 static int exit_city_report_callback(struct widget *pwidget)
87{
88 if (PRESSED_EVENT(main_data.event)) {
89 city_report_dialog_popdown();
90 }
91
92 return -1;
93}
94
95/**********************************************************************/
98 static int popup_citydlg_from_city_report_callback(struct widget *pwidget)
99{
100 if (PRESSED_EVENT(main_data.event)) {
101 popup_city_dialog(pwidget->data.city);
102 }
103
104 return -1;
105}
106
107/**********************************************************************/
110 static int popup_worklist_from_city_report_callback(struct widget *pwidget)
111{
112 if (PRESSED_EVENT(main_data.event)) {
113 popup_worklist_editor(pwidget->data.city, NULL);
114 }
115
116 return -1;
117}
118
119/**********************************************************************/
122 static int popup_buy_production_from_city_report_callback(struct widget *pwidget)
123{
124 if (PRESSED_EVENT(main_data.event)) {
125 popup_hurry_production_dialog(pwidget->data.city, NULL);
126 }
127
128 return -1;
129}
130
131/**********************************************************************/
134 static int popup_cma_from_city_report_callback(struct widget *pwidget)
135{
136 if (PRESSED_EVENT(main_data.event)) {
137 struct city *pcity = game_city_by_number(MAX_ID - pwidget->id);
138
139 /* state is changed before enter this function */
140 if (!get_checkbox_state(pwidget)) {
141 cma_release_city(pcity);
142 city_report_dialog_update_city(pcity);
143 } else {
144 popup_city_cma_dialog(pcity);
145 }
146 }
147
148 return -1;
149}
150
151#if 0
152/**********************************************************************/
155static int info_city_report_callback(struct widget *pwidget)
156{
157 if (PRESSED_EVENT(main_data.event)) {
158 set_wstate(pwidget, FC_WS_NORMAL);
159 selected_widget = NULL;
160 widget_redraw(pwidget);
161 widget_mark_dirty(pwidget);
162 real_info_city_report_dialog_update();
163 }
164
165 return -1;
166}
167#endif /* 0 */
168
169#define COL 17
170
171/**********************************************************************/
174 static void real_info_city_report_dialog_update(void)
175{
176 SDL_Color bg_color = {255, 255, 255, 136};
177
178 struct widget *pbuf = NULL;
179 struct widget *pwindow, *last;
180 utf8_str *pstr;
181 SDL_Surface *text1, *text2, *text3, *units_icon, *cma_icon, *text4;
182 SDL_Surface *logo;
183 int togrow, w = 0 , count, ww = 0, hh = 0, name_w = 0, prod_w = 0, h;
184 char cbuf[128];
185 const char *name;
186 SDL_Rect dst;
187 SDL_Rect area;
188
189 if (city_rep) {
190 popdown_window_group_dialog(city_rep->begin_widget_list,
191 city_rep->end_widget_list);
192 } else {
193 city_rep = fc_calloc(1, sizeof(struct advanced_dialog));
194 }
195
196 fc_snprintf(cbuf, sizeof(cbuf), _("size"));
197 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
198 pstr->style |= SF_CENTER;
199 text1 = create_text_surf_from_utf8(pstr);
200
201 fc_snprintf(cbuf, sizeof(cbuf), _("time\nto grow"));
202 copy_chars_to_utf8_str(pstr, cbuf);
203 text2 = create_text_surf_from_utf8(pstr);
204
205 fc_snprintf(cbuf, sizeof(cbuf), _("City Name"));
206 copy_chars_to_utf8_str(pstr, cbuf);
207 text3 = create_text_surf_from_utf8(pstr);
208 name_w = text3->w + adj_size(6);
209
210 fc_snprintf(cbuf, sizeof(cbuf), _("Production"));
211 copy_chars_to_utf8_str(pstr, cbuf);
212 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT);
213 text4 = create_text_surf_from_utf8(pstr);
214 prod_w = text4->w;
215 FREEUTF8STR(pstr);
216
217 units_icon = create_icon_from_theme(current_theme->units_icon, 0);
218 cma_icon = create_icon_from_theme(current_theme->cma_icon, 0);
219
220 /* --------------- */
221 pstr = create_utf8_from_char_fonto(_("Cities Report"), FONTO_ATTENTION);
222 pstr->style |= TTF_STYLE_BOLD;
223
224 pwindow = create_window_skeleton(NULL, pstr, 0);
225 city_rep->end_widget_list = pwindow;
226 set_wstate(pwindow, FC_WS_NORMAL);
227 pwindow->action = city_report_windows_callback;
228
229 add_to_gui_list(ID_WINDOW, pwindow);
230
231 area = pwindow->area;
232
233 /* ------------------------- */
234 /* Exit button */
235 pbuf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
236 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
237 pbuf->info_label = create_utf8_from_char_fonto(_("Close Dialog"),
238 FONTO_ATTENTION);
239 pbuf->action = exit_city_report_callback;
240 set_wstate(pbuf, FC_WS_NORMAL);
241 pbuf->key = SDLK_ESCAPE;
242
243 add_to_gui_list(ID_BUTTON, pbuf);
244
245/* FIXME: Not implemented yet */
246#if 0
247 /* ------------------------- */
248 pbuf = create_themeicon(current_theme->info_icon, pwindow->dst,
249 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
250 pbuf->info_label = create_utf8_from_char_fonto(_("Information Report"),
251 FONTO_ATTENTION);
252/*
253 pbuf->action = info_city_report_callback;
254 set_wstate(pbuf, FC_WS_NORMAL);
255*/
256 add_to_gui_list(ID_BUTTON, pbuf);
257 /* -------- */
258 pbuf = create_themeicon(current_theme->happy_icon, pwindow->dst,
259 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
260 pbuf->info_label = create_utf8_from_char_fonto(_("Happiness Report"),
261 FONTO_ATTENTION);
262/*
263 pbuf->action = happy_city_report_callback;
264 set_wstate(pbuf, FC_WS_NORMAL);
265*/
266 add_to_gui_list(ID_BUTTON, pbuf);
267 /* -------- */
268 pbuf = create_themeicon(current_theme->army_icon, pwindow->dst,
269 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
270
271 pbuf->info_label = create_utf8_from_char_fonto(_("Garrison Report"),
272 FONTO_ATTENTION);
273/*
274 pbuf->action = army_city_dlg_callback;
275 set_wstate(pbuf, FC_WS_NORMAL);
276*/
277 add_to_gui_list(ID_BUTTON, pbuf);
278 /* -------- */
279 pbuf = create_themeicon(current_theme->support_icon, pwindow->dst,
280 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
281 pbuf->info_label = create_utf8_from_char_fonto(_("Maintenance Report"),
282 FONTO_ATTENTION);
283/*
284 pbuf->action = supported_unit_city_dlg_callback;
285 set_wstate(pbuf, FC_WS_NORMAL);
286*/
287 add_to_gui_list(ID_BUTTON, pbuf);
288 /* ------------------------ */
289#endif /* 0 */
290
291 last = pbuf;
292 count = 0;
293 city_list_iterate(client.conn.playing->cities, pcity) {
294 pstr = create_utf8_from_char_fonto(city_name_get(pcity), FONTO_ATTENTION);
295 pstr->style |= TTF_STYLE_BOLD;
296 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
297 (WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR));
298
299 if (city_unhappy(pcity)) {
300 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
301 } else {
302 if (city_celebrating(pcity)) {
303 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
304 } else {
305 if (city_happy(pcity)) {
306 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
307 }
308 }
309 }
310
311 pbuf->action = popup_citydlg_from_city_report_callback;
312 set_wstate(pbuf, FC_WS_NORMAL);
313 pbuf->data.city = pcity;
314 if (count > 13 * COL) {
315 set_wflag(pbuf , WF_HIDDEN);
316 }
317 hh = pbuf->size.h;
318 name_w = MAX(pbuf->size.w, name_w);
319 add_to_gui_list(MAX_ID - pcity->id, pbuf);
320
321 /* ----------- */
322 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
323 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
324 pstr->style |= SF_CENTER;
325 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
326 WF_RESTORE_BACKGROUND);
327 if (count > 13 * COL) {
328 set_wflag(pbuf, WF_HIDDEN);
329 }
330 hh = MAX(hh, pbuf->size.h);
331 pbuf->size.w = text1->w + adj_size(8);
332 add_to_gui_list(MAX_ID - pcity->id, pbuf);
333
334 /* ----------- */
335 pbuf = create_checkbox(pwindow->dst,
336 cma_is_city_under_agent(pcity, NULL),
337 WF_RESTORE_BACKGROUND);
338 if (count > 13 * COL) {
339 set_wflag(pbuf, WF_HIDDEN);
340 }
341 hh = MAX(hh, pbuf->size.h);
342 fc_assert(MAX_ID > pcity->id);
343 add_to_gui_list(MAX_ID - pcity->id, pbuf);
344 set_wstate(pbuf, FC_WS_NORMAL);
345 pbuf->action = popup_cma_from_city_report_callback;
346
347 /* ----------- */
348 fc_snprintf(cbuf, sizeof(cbuf), "%d",
349 pcity->prod[O_FOOD] - pcity->surplus[O_FOOD]);
350 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
351 pstr->style |= SF_CENTER;
352 pstr->fgcol = *get_game_color(COLOR_OVERVIEW_LAND);
353 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
354 WF_RESTORE_BACKGROUND);
355 if (count > 13 * COL) {
356 set_wflag(pbuf, WF_HIDDEN);
357 }
358 hh = MAX(hh, pbuf->size.h);
359 pbuf->size.w = icons->big_food->w + adj_size(6);
360 add_to_gui_list(MAX_ID - pcity->id, pbuf);
361
362 /* ----------- */
363 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
364 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
365 pstr->style |= SF_CENTER;
366 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_FOOD_SURPLUS);
367 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
368 WF_RESTORE_BACKGROUND);
369 if (count > 13 * COL) {
370 set_wflag(pbuf, WF_HIDDEN);
371 }
372 hh = MAX(hh, pbuf->size.h);
373 pbuf->size.w = icons->big_food_corr->w + adj_size(6);
374 add_to_gui_list(MAX_ID - pcity->id, pbuf);
375
376 /* ----------- */
377 togrow = city_turns_to_grow(pcity);
378 switch (togrow) {
379 case 0:
380 fc_snprintf(cbuf, sizeof(cbuf), "#");
381 break;
382 case FC_INFINITY:
383 fc_snprintf(cbuf, sizeof(cbuf), "--");
384 break;
385 default:
386 fc_snprintf(cbuf, sizeof(cbuf), "%d", togrow);
387 break;
388 }
389
390 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
391 pstr->style |= SF_CENTER;
392 if (togrow < 0) {
393 pstr->fgcol.r = 255;
394 }
395 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
396 WF_RESTORE_BACKGROUND);
397 if (count > 13 * COL) {
398 set_wflag(pbuf, WF_HIDDEN);
399 }
400 hh = MAX(hh, pbuf->size.h);
401 pbuf->size.w = text2->w + adj_size(6);
402 add_to_gui_list(MAX_ID - pcity->id, pbuf);
403
404 /* ----------- */
405 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_TRADE]);
406 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
407 pstr->style |= SF_CENTER;
408 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
409 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
410 WF_RESTORE_BACKGROUND);
411 if (count > 13 * COL) {
412 set_wflag(pbuf, WF_HIDDEN);
413 }
414 hh = MAX(hh, pbuf->size.h);
415 pbuf->size.w = icons->big_trade->w + adj_size(6);
416 add_to_gui_list(MAX_ID - pcity->id, pbuf);
417
418 /* ----------- */
419 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
420 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
421 pstr->style |= SF_CENTER;
422 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
423 WF_RESTORE_BACKGROUND);
424 if (count > 13 * COL) {
425 set_wflag(pbuf, WF_HIDDEN);
426 }
427 hh = MAX(hh, pbuf->size.h);
428 pbuf->size.w = icons->big_trade_corr->w + adj_size(6);
429 add_to_gui_list(MAX_ID - pcity->id, pbuf);
430
431 /* ----------- */
432 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
433 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
434 pstr->style |= SF_CENTER;
435 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_GOLD);
436 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
437 WF_RESTORE_BACKGROUND);
438 if (count > 13 * COL) {
439 set_wflag(pbuf, WF_HIDDEN);
440 }
441 hh = MAX(hh, pbuf->size.h);
442 pbuf->size.w = icons->big_coin->w + adj_size(6);
443 add_to_gui_list(MAX_ID - pcity->id, pbuf);
444
445 /* ----------- */
446 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
447 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
448 pstr->style |= SF_CENTER;
449 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SCIENCE);
450 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
451 WF_RESTORE_BACKGROUND);
452 if (count > 13 * COL) {
453 set_wflag(pbuf, WF_HIDDEN);
454 }
455 hh = MAX(hh, pbuf->size.h);
456 pbuf->size.w = icons->big_colb->w + adj_size(6);
457 add_to_gui_list(MAX_ID - pcity->id, pbuf);
458
459 /* ----------- */
460 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
461 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
462 pstr->style |= SF_CENTER;
463 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_LUX);
464 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
465 WF_RESTORE_BACKGROUND);
466 if (count > 13 * COL) {
467 set_wflag(pbuf, WF_HIDDEN);
468 }
469 hh = MAX(hh, pbuf->size.h);
470 pbuf->size.w = icons->big_luxury->w + adj_size(6);
471 add_to_gui_list(MAX_ID - pcity->id, pbuf);
472
473 /* ----------- */
474 fc_snprintf(cbuf, sizeof(cbuf), "%d",
475 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
476 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
477 pstr->style |= SF_CENTER;
478 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PROD);
479 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
480 WF_RESTORE_BACKGROUND);
481 if (count > 13 * COL) {
482 set_wflag(pbuf, WF_HIDDEN);
483 }
484 hh = MAX(hh, pbuf->size.h);
485 pbuf->size.w = icons->big_shield->w + adj_size(6);
486 add_to_gui_list(MAX_ID - pcity->id, pbuf);
487
488 /* ----------- */
489 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
490 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
491 pstr->style |= SF_CENTER;
492 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
493 WF_RESTORE_BACKGROUND);
494 if (count > 13 * COL) {
495 set_wflag(pbuf, WF_HIDDEN);
496 }
497 hh = MAX(hh, pbuf->size.h);
498 pbuf->size.w = icons->big_shield_corr->w + adj_size(6);
499 add_to_gui_list(MAX_ID - pcity->id, pbuf);
500
501 /* ----------- */
502 fc_snprintf(cbuf, sizeof(cbuf), "%d",
503 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD] - pcity->surplus[O_SHIELD]);
504 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
505 pstr->style |= SF_CENTER;
506 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SUPPORT);
507 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
508 WF_RESTORE_BACKGROUND);
509 if (count > 13 * COL) {
510 set_wflag(pbuf, WF_HIDDEN);
511 }
512 hh = MAX(hh, pbuf->size.h);
513 pbuf->size.w = units_icon->w + adj_size(6);
514 add_to_gui_list(MAX_ID - pcity->id, pbuf);
515
516 /* ----------- */
517 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
518 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
519 pstr->style |= SF_CENTER;
520 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
521 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
522 WF_RESTORE_BACKGROUND);
523 if (count > 13 * COL) {
524 set_wflag(pbuf, WF_HIDDEN);
525 }
526 hh = MAX(hh, pbuf->size.h);
527 pbuf->size.w = icons->big_shield_surplus->w + adj_size(6);
528 add_to_gui_list(MAX_ID - pcity->id, pbuf);
529
530 /* ----------- */
531 if (VUT_UTYPE == pcity->production.kind) {
532 const struct unit_type *punittype = pcity->production.value.utype;
533
534 logo = resize_surface_box(get_unittype_surface(punittype,
535 direction8_invalid()),
536 adj_size(36), adj_size(24), 1,
537 TRUE, TRUE);
538 togrow = utype_build_shield_cost(pcity, NULL, punittype);
539 name = utype_name_translation(punittype);
540 } else {
541 const struct impr_type *pimprove = pcity->production.value.building;
542
543 logo = resize_surface_box(get_building_surface(pcity->production.value.building),
544 adj_size(36), adj_size(24), 1,
545 TRUE, TRUE);
546 togrow = impr_build_shield_cost(pcity, pimprove);
547 name = improvement_name_translation(pimprove);
548 }
549
550 if (!worklist_is_empty(&(pcity->worklist))) {
551 dst.x = logo->w - icons->worklist->w;
552 dst.y = 0;
553 alphablit(icons->worklist, NULL, logo, &dst, 255);
554 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
555 name, pcity->shield_stock, togrow, _("worklist"));
556 } else {
557 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)%s",
558 name, pcity->shield_stock, togrow,
559 pcity->shield_stock > togrow ? _("\nfinished"): "" );
560 }
561
562 /* Info string */
563 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
564 pstr->style |= SF_CENTER;
565
566 togrow = city_production_turns_to_build(pcity, TRUE);
567 if (togrow == 999) {
568 fc_snprintf(cbuf, sizeof(cbuf), "%s", _("never"));
569 } else {
570 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
571 togrow, PL_("turn", "turns", togrow));
572 }
573
574 pbuf = create_icon2(logo, pwindow->dst,
575 WF_WIDGET_HAS_INFO_LABEL |WF_RESTORE_BACKGROUND
576 | WF_FREE_THEME);
577 pbuf->info_label = pstr;
578 if (count > 13 * COL) {
579 set_wflag(pbuf, WF_HIDDEN);
580 }
581 hh = MAX(hh, pbuf->size.h);
582 add_to_gui_list(MAX_ID - pcity->id, pbuf);
583 set_wstate(pbuf, FC_WS_NORMAL);
584 pbuf->action = popup_worklist_from_city_report_callback;
585 pbuf->data.city = pcity;
586
587 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
588 pstr->style |= SF_CENTER;
589 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT);
590 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
591 (WF_SELECT_WITHOUT_BAR | WF_RESTORE_BACKGROUND));
592 if (count > 13 * COL) {
593 set_wflag(pbuf, WF_HIDDEN);
594 }
595 hh = MAX(hh, pbuf->size.h);
596 prod_w = MAX(prod_w, pbuf->size.w);
597 add_to_gui_list(MAX_ID - pcity->id, pbuf);
598 pbuf->data.city = pcity;
599 pbuf->action = popup_buy_production_from_city_report_callback;
600 if (city_can_buy(pcity)) {
601 set_wstate(pbuf, FC_WS_NORMAL);
602 }
603
604 count += COL;
605 } city_list_iterate_end;
606
607 h = hh;
608 city_rep->begin_widget_list = pbuf;
609
610 /* Setup window width */
611 area.w = name_w + adj_size(6) + text1->w + adj_size(8) + cma_icon->w
612 + (icons->big_food->w + adj_size(6)) * 10 + text2->w + adj_size(6)
613 + units_icon->w + adj_size(6) + prod_w + adj_size(170);
614
615 if (count) {
616 city_rep->end_active_widget_list = last->prev;
617 city_rep->begin_active_widget_list = city_rep->begin_widget_list;
618 if (count > 14 * COL) {
619 city_rep->active_widget_list = city_rep->end_active_widget_list;
620 if (city_rep->scroll) {
621 city_rep->scroll->count = count;
622 }
623 ww = create_vertical_scrollbar(city_rep, COL, 14, TRUE, TRUE);
624 area.w += ww;
625 area.h = 14 * (hh + adj_size(2));
626 } else {
627 area.h = (count / COL) * (hh + adj_size(2));
628 }
629 }
630
631 area.h += text2->h + adj_size(6);
632 area.w += adj_size(2);
633
634 logo = theme_get_background(active_theme, BACKGROUND_CITYREP);
635 resize_window(pwindow, logo, NULL,
636 (pwindow->size.w - pwindow->area.w) + area.w,
637 (pwindow->size.h - pwindow->area.h) + area.h);
638 FREESURFACE(logo);
639
640#if 0
641 logo = SDL_DisplayFormat(pwindow->theme);
642 FREESURFACE(pwindow->theme);
643 pwindow->theme = logo;
644 logo = NULL;
645#endif /* 0 */
646
647 area = pwindow->area;
648
649 widget_set_position(pwindow,
650 (main_window_width() - pwindow->size.w) / 2,
651 (main_window_height() - pwindow->size.h) / 2);
652
653 /* Exit button */
654 pbuf = pwindow->prev;
655 pbuf->size.x = area.x + area.w - pbuf->size.w - 1;
656 pbuf->size.y = pwindow->size.y + adj_size(2);
657
658/* FIXME: not implemented yet */
659#if 0
660 /* Info button */
661 pbuf = pbuf->prev;
662 pbuf->size.x = area.x + area.w - pbuf->size.w - adj_size(5);
663 pbuf->size.y = area.y + area.h - pbuf->size.h - adj_size(5);
664
665 /* Happy button */
666 pbuf = pbuf->prev;
667 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
668 pbuf->size.y = pbuf->next->size.y;
669
670 /* Army button */
671 pbuf = pbuf->prev;
672 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
673 pbuf->size.y = pbuf->next->size.y;
674
675 /* Supported button */
676 pbuf = pbuf->prev;
677 pbuf->size.x = pbuf->next->size.x - adj_size(5) - pbuf->size.w;
678 pbuf->size.y = pbuf->next->size.y;
679#endif /* 0 */
680
681 /* Cities background and labels */
682 dst.x = area.x + adj_size(2);
683 dst.y = area.y + 1;
684 dst.w = (name_w + adj_size(6)) + (text1->w + adj_size(8)) + adj_size(5);
685 dst.h = area.h - adj_size(2);
686 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
687
688 create_frame(pwindow->theme,
689 dst.x , dst.y, dst.w, dst.h - 1,
690 get_theme_color(COLOR_THEME_CITYREP_FRAME));
691
692 dst.y += (text2->h - text3->h) / 2;
693 dst.x += ((name_w + adj_size(6)) - text3->w) / 2;
694 alphablit(text3, NULL, pwindow->theme, &dst, 255);
695 FREESURFACE(text3);
696
697 /* City size background and label */
698 dst.x = area.x + adj_size(5) + name_w + adj_size(5 + 4);
699 alphablit(text1, NULL, pwindow->theme, &dst, 255);
700 ww = text1->w;
701 FREESURFACE(text1);
702
703 /* CMA icon */
704 dst.x += (ww + adj_size(9));
705 dst.y = area.y + 1 + (text2->h - cma_icon->h) / 2;
706 alphablit(cma_icon, NULL, pwindow->theme, &dst, 255);
707 ww = cma_icon->w;
708 FREESURFACE(cma_icon);
709
710 /* -------------- */
711 /* Populations food upkeep background and label */
712 dst.x += (ww + 1);
713 dst.y = area.y + 1;
714 w = dst.x + adj_size(2);
715 dst.w = (icons->big_food->w + adj_size(6)) + adj_size(10)
716 + (icons->big_food_surplus->w + adj_size(6)) + adj_size(10)
717 + text2->w + adj_size(6 + 2);
718 dst.h = area.h - adj_size(2);
719 fill_rect_alpha(pwindow->theme, &dst,
720 get_theme_color(COLOR_THEME_CITYREP_FOODSTOCK));
721
722 create_frame(pwindow->theme,
723 dst.x, dst.y, dst.w, dst.h - 1,
724 get_theme_color(COLOR_THEME_CITYREP_FRAME));
725
726 dst.y = area.y + 1 + (text2->h - icons->big_food->h) / 2;
727 dst.x += adj_size(5);
728 alphablit(icons->big_food, NULL, pwindow->theme, &dst, 255);
729
730 /* Food surplus icon */
731 w += (icons->big_food->w + adj_size(6)) + adj_size(10);
732 dst.x = w + adj_size(3);
733 alphablit(icons->big_food_surplus, NULL, pwindow->theme, &dst, 255);
734
735 /* To grow label */
736 w += (icons->big_food_surplus->w + adj_size(6)) + adj_size(10);
737 dst.x = w + adj_size(3);
738 dst.y = area.y + 1;
739 alphablit(text2, NULL, pwindow->theme, &dst, 255);
740 hh = text2->h;
741 ww = text2->w;
742 FREESURFACE(text2);
743 /* -------------- */
744
745 /* Trade, corruptions, gold, science, luxury income background and label */
746 dst.x = w + (ww + adj_size(8));
747 dst.y = area.y + 1;
748 w = dst.x + adj_size(2);
749 dst.w = (icons->big_trade->w + adj_size(6)) + adj_size(10) +
750 (icons->big_trade_corr->w + adj_size(6)) + adj_size(10) +
751 (icons->big_coin->w + adj_size(6)) + adj_size(10) +
752 (icons->big_colb->w + adj_size(6)) + adj_size(10) +
753 (icons->big_luxury->w + adj_size(6)) + adj_size(4);
754 dst.h = area.h - adj_size(2);
755
756 fill_rect_alpha(pwindow->theme, &dst,
757 get_theme_color(COLOR_THEME_CITYREP_TRADE));
758
759 create_frame(pwindow->theme,
760 dst.x , dst.y, dst.w, dst.h - 1,
761 get_theme_color(COLOR_THEME_CITYREP_FRAME));
762
763 dst.y = area.y + 1 + (hh - icons->big_trade->h) / 2;
764 dst.x += adj_size(5);
765 alphablit(icons->big_trade, NULL, pwindow->theme, &dst, 255);
766
767 w += (icons->big_trade->w + adj_size(6)) + adj_size(10);
768 dst.x = w + adj_size(3);
769 alphablit(icons->big_trade_corr, NULL, pwindow->theme, &dst, 255);
770
771 w += (icons->big_food_corr->w + adj_size(6)) + adj_size(10);
772 dst.x = w + adj_size(3);
773 alphablit(icons->big_coin, NULL, pwindow->theme, &dst, 255);
774
775 w += (icons->big_coin->w + adj_size(6)) + adj_size(10);
776 dst.x = w + adj_size(3);
777 alphablit(icons->big_colb, NULL, pwindow->theme, &dst, 255);
778
779 w += (icons->big_colb->w + adj_size(6)) + adj_size(10);
780 dst.x = w + adj_size(3);
781 alphablit(icons->big_luxury, NULL, pwindow->theme, &dst, 255);
782 /* --------------------- */
783
784 /* Total productions, waste, support, shields surplus background and label */
785 w += (icons->big_luxury->w + adj_size(6)) + adj_size(4);
786 dst.x = w;
787 w += adj_size(2);
788 dst.y = area.y + 1;
789 dst.w = (icons->big_shield->w + adj_size(6)) + adj_size(10) +
790 (icons->big_shield_corr->w + adj_size(6)) + adj_size(10) +
791 (units_icon->w + adj_size(6)) + adj_size(10) +
792 (icons->big_shield_surplus->w + adj_size(6)) + adj_size(4);
793 dst.h = area.h - adj_size(2);
794
795 fill_rect_alpha(pwindow->theme, &dst,
796 get_theme_color(COLOR_THEME_CITYREP_PROD));
797
798 create_frame(pwindow->theme,
799 dst.x , dst.y, dst.w, dst.h - 1,
800 get_theme_color(COLOR_THEME_CITYREP_FRAME));
801
802 dst.y = area.y + 1 + (hh - icons->big_shield->h) / 2;
803 dst.x += adj_size(5);
804 alphablit(icons->big_shield, NULL, pwindow->theme, &dst, 255);
805
806 w += (icons->big_shield->w + adj_size(6)) + adj_size(10);
807 dst.x = w + adj_size(3);
808 alphablit(icons->big_shield_corr, NULL, pwindow->theme, &dst, 255);
809
810 w += (icons->big_shield_corr->w + adj_size(6)) + adj_size(10);
811 dst.x = w + adj_size(3);
812 dst.y = area.y + 1 + (hh - units_icon->h) / 2;
813 alphablit(units_icon, NULL, pwindow->theme, &dst, 255);
814
815 w += (units_icon->w + adj_size(6)) + adj_size(10);
816 FREESURFACE(units_icon);
817 dst.x = w + adj_size(3);
818 dst.y = area.y + 1 + (hh - icons->big_shield_surplus->h) / 2;
819 alphablit(icons->big_shield_surplus, NULL, pwindow->theme, &dst, 255);
820 /* ------------------------------- */
821
822 w += (icons->big_shield_surplus->w + adj_size(6)) + adj_size(10);
823 dst.x = w;
824 dst.y = area.y + 1;
825 dst.w = adj_size(36) + adj_size(5) + prod_w;
826 dst.h = hh + adj_size(2);
827
828 fill_rect_alpha(pwindow->theme, &dst,
829 get_theme_color(COLOR_THEME_CITYREP_PROD));
830
831 create_frame(pwindow->theme,
832 dst.x , dst.y, dst.w, dst.h - 1,
833 get_theme_color(COLOR_THEME_CITYREP_FRAME));
834
835 dst.y = area.y + 1 + (hh - text4->h) / 2;
836 dst.x += (dst.w - text4->w) / 2;
837 alphablit(text4, NULL, pwindow->theme, &dst, 255);
838 FREESURFACE(text4);
839
840 if (count) {
841 int start_x = area.x + adj_size(5);
842 int start_y = area.y + hh + adj_size(3);
843
844 h += adj_size(2);
845 pbuf = pbuf->prev;
846
847 while (TRUE) {
848
849 /* City name */
850 pbuf->size.x = start_x;
851 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
852 pbuf->size.w = name_w;
853
854 /* City size */
855 pbuf = pbuf->prev;
856 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
857 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
858
859 /* CMA */
860 pbuf = pbuf->prev;
861 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
862 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
863
864 /* Food cons. */
865 pbuf = pbuf->prev;
866 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
867 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
868
869 /* Food surplus */
870 pbuf = pbuf->prev;
871 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
872 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
873
874 /* Time to grow */
875 pbuf = pbuf->prev;
876 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
877 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
878
879 /* Trade */
880 pbuf = pbuf->prev;
881 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
882 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
883
884 /* Trade corruptions */
885 pbuf = pbuf->prev;
886 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
887 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
888
889 /* Net gold income */
890 pbuf = pbuf->prev;
891 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
892 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
893
894 /* Science income */
895 pbuf = pbuf->prev;
896 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
897 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
898
899 /* Luxuries income */
900 pbuf = pbuf->prev;
901 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
902 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
903
904 /* Total production */
905 pbuf = pbuf->prev;
906 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(6);
907 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
908
909 /* Waste */
910 pbuf = pbuf->prev;
911 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
912 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
913
914 /* Units support */
915 pbuf = pbuf->prev;
916 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
917 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
918
919 /* Production surplus */
920 pbuf = pbuf->prev;
921 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
922 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
923
924 /* Currently build */
925 /* Icon */
926 pbuf = pbuf->prev;
927 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(10);
928 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
929
930 /* Label */
931 pbuf = pbuf->prev;
932 pbuf->size.x = pbuf->next->size.x + pbuf->next->size.w + adj_size(5);
933 pbuf->size.y = start_y + (h - pbuf->size.h) / 2;
934 pbuf->size.w = prod_w;
935
936 start_y += h;
937 if (pbuf == city_rep->begin_active_widget_list) {
938 break;
939 }
940 pbuf = pbuf->prev;
941 }
942
943 if (city_rep->scroll) {
944 setup_vertical_scrollbar_area(city_rep->scroll,
945 area.x + area.w, area.y,
946 area.h, TRUE);
947 }
948
949 }
950
951 /* ----------------------------------- */
952 redraw_group(city_rep->begin_widget_list, pwindow, 0);
953 widget_mark_dirty(pwindow);
954 flush_dirty();
955}
956
957/**********************************************************************/
960 static struct widget *real_city_report_dialog_update_city(struct widget *pwidget,
961 struct city *pcity)
962{
963 char cbuf[64];
964 const char *name;
965 int togrow;
966 SDL_Surface *logo;
967 SDL_Rect dst;
968
969 /* city name status */
970 if (city_unhappy(pcity)) {
971 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
972 } else {
973 if (city_celebrating(pcity)) {
974 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
975 } else {
976 if (city_happy(pcity)) {
977 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
978 }
979 }
980 }
981
982 /* city size */
983 pwidget = pwidget->prev;
984 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
985 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
986
987 /* cma check box */
988 pwidget = pwidget->prev;
989 if (cma_is_city_under_agent(pcity, NULL) != get_checkbox_state(pwidget)) {
990 toggle_checkbox(pwidget);
991 }
992
993 /* food consumptions */
994 pwidget = pwidget->prev;
995 fc_snprintf(cbuf, sizeof(cbuf), "%d",
996 pcity->prod[O_FOOD] - pcity->surplus[O_FOOD]);
997 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
998
999 /* food surplus */
1000 pwidget = pwidget->prev;
1001 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
1002 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1003
1004 /* time to grow */
1005 pwidget = pwidget->prev;
1006 togrow = city_turns_to_grow(pcity);
1007 switch (togrow) {
1008 case 0:
1009 fc_snprintf(cbuf, sizeof(cbuf), "#");
1010 break;
1011 case FC_INFINITY:
1012 fc_snprintf(cbuf, sizeof(cbuf), "--");
1013 break;
1014 default:
1015 fc_snprintf(cbuf, sizeof(cbuf), "%d", togrow);
1016 break;
1017 }
1018 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1019
1020 if (togrow < 0) {
1021 pwidget->string_utf8->fgcol.r = 255;
1022 } else {
1023 pwidget->string_utf8->fgcol.r = 0;
1024 }
1025
1026 /* trade production */
1027 pwidget = pwidget->prev;
1028 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_TRADE]);
1029 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1030
1031 /* corruptions */
1032 pwidget = pwidget->prev;
1033 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
1034 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1035
1036 /* gold surplus */
1037 pwidget = pwidget->prev;
1038 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
1039 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1040
1041 /* science income */
1042 pwidget = pwidget->prev;
1043 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
1044 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1045
1046 /* lugury income */
1047 pwidget = pwidget->prev;
1048 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
1049 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1050
1051 /* total production */
1052 pwidget = pwidget->prev;
1053 fc_snprintf(cbuf, sizeof(cbuf), "%d",
1054 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
1055 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1056
1057 /* waste */
1058 pwidget = pwidget->prev;
1059 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
1060 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1061
1062 /* units support */
1063 pwidget = pwidget->prev;
1064 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SHIELD] +
1065 pcity->waste[O_SHIELD] - pcity->surplus[O_SHIELD]);
1066 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1067
1068 /* production income */
1069 pwidget = pwidget->prev;
1070 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
1071 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1072
1073 /* change production */
1074 if (VUT_UTYPE == pcity->production.kind) {
1075 const struct unit_type *punittype = pcity->production.value.utype;
1076
1077 logo = resize_surface(get_unittype_surface(punittype, direction8_invalid()),
1078 adj_size(36), adj_size(24), 1);
1079 togrow = utype_build_shield_cost(pcity, NULL, punittype);
1080 name = utype_name_translation(punittype);
1081 } else {
1082 const struct impr_type *pimprove = pcity->production.value.building;
1083
1084 logo = resize_surface(get_building_surface(pcity->production.value.building),
1085 adj_size(36), adj_size(24), 1);
1086 togrow = impr_build_shield_cost(pcity, pimprove);
1087 name = improvement_name_translation(pimprove);
1088 }
1089
1090 if (!worklist_is_empty(&(pcity->worklist))) {
1091 dst.x = logo->w - icons->worklist->w;
1092 dst.y = 0;
1093 alphablit(icons->worklist, NULL, logo, &dst, 255);
1094 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)\n%s",
1095 name, pcity->shield_stock, togrow, _("worklist"));
1096 } else {
1097 fc_snprintf(cbuf, sizeof(cbuf), "%s\n(%d/%d)",
1098 name, pcity->shield_stock, togrow);
1099 }
1100
1101 pwidget = pwidget->prev;
1102 copy_chars_to_utf8_str(pwidget->info_label, cbuf);
1103 FREESURFACE(pwidget->theme);
1104 pwidget->theme = logo;
1105
1106 /* hurry productions */
1107 pwidget = pwidget->prev;
1108 togrow = city_production_turns_to_build(pcity, TRUE);
1109 if (togrow == 999) {
1110 fc_snprintf(cbuf, sizeof(cbuf), "%s", _("never"));
1111 } else {
1112 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
1113 togrow, PL_("turn", "turns", togrow));
1114 }
1115
1116 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1117
1118 return pwidget->prev;
1119}
1120
1121/* ======================================================================== */
1122
1123/**********************************************************************/
1126 bool is_city_report_open(void)
1127{
1128 return (city_rep != NULL);
1129}
1130
1131/**********************************************************************/
1135 void city_report_dialog_popup(bool make_modal)
1136{
1137 if (!city_rep) {
1138 real_info_city_report_dialog_update();
1139 }
1140}
1141
1142/**********************************************************************/
1145 void real_city_report_dialog_update(void *unused)
1146{
1147 if (city_rep) {
1148 struct widget *pwidget;
1149 int count;
1150
1151 /* find if the lists are identical (if not then rebuild all) */
1152 pwidget = city_rep->end_active_widget_list; /* name of first city */
1153 city_list_iterate(client.conn.playing->cities, pcity) {
1154 if (pcity->id == MAX_ID - pwidget->id) {
1155 count = COL;
1156
1157 while (count) {
1158 count--;
1159 pwidget = pwidget->prev;
1160 }
1161 } else {
1162 real_info_city_report_dialog_update();
1163
1164 return;
1165 }
1166 } city_list_iterate_end;
1167
1168 /* check it there are some city widgets left on list */
1169 if (pwidget && pwidget->next != city_rep->begin_active_widget_list) {
1170 real_info_city_report_dialog_update();
1171 return;
1172 }
1173
1174 /* update widget city list (widget list is the same that city list) */
1175 pwidget = city_rep->end_active_widget_list;
1176 city_list_iterate(client.conn.playing->cities, pcity) {
1177 pwidget = real_city_report_dialog_update_city(pwidget, pcity);
1178 } city_list_iterate_end;
1179
1180 /* -------------------------------------- */
1181 redraw_group(city_rep->begin_widget_list, city_rep->end_widget_list, 0);
1182 widget_mark_dirty(city_rep->end_widget_list);
1183
1184 flush_dirty();
1185 }
1186}
1187
1188/**********************************************************************/
1191 void real_city_report_update_city(struct city *pcity)
1192{
1193 if (city_rep && pcity) {
1194 struct widget *buf = city_rep->end_active_widget_list;
1195
1196 while (pcity->id != MAX_ID - buf->id
1197 && buf != city_rep->begin_active_widget_list) {
1198 buf = buf->prev;
1199 }
1200
1201 if (buf == city_rep->begin_active_widget_list) {
1202 real_info_city_report_dialog_update();
1203 return;
1204 }
1205 real_city_report_dialog_update_city(buf, pcity);
1206
1207 /* -------------------------------------- */
1208 redraw_group(city_rep->begin_widget_list, city_rep->end_widget_list, 0);
1209 widget_mark_dirty(city_rep->end_widget_list);
1210
1211 flush_dirty();
1212 }
1213}
1214
1215/**********************************************************************/
1220 void hilite_cities_from_canvas(void)
1221{
1222 log_debug("hilite_cities_from_canvas : PORT ME");
1223}
1224
1225/**********************************************************************/
1228 void toggle_city_hilite(struct city *pcity, bool on_off)
1229{
1230 log_debug("toggle_city_hilite : PORT ME");
1231}
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1133
city_production_turns_to_build
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:820
city_unhappy
bool city_unhappy(const struct city *pcity)
Definition city.c:1622
city_celebrating
bool city_celebrating(const struct city *pcity)
Definition city.c:1641
city_happy
bool city_happy(const struct city *pcity)
Definition city.c:1610
city_turns_to_grow
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1992
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
city_size_get
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
city_can_buy
bool city_can_buy(const struct city *pcity)
Definition citydlg_common.c:1524
popup_city_dialog
void popup_city_dialog(struct city *pcity)
Definition update_queue.c:623
city_report_dialog_update_city
void city_report_dialog_update_city(struct city *pcity)
Definition update_queue.c:641
client
struct civclient client
Definition client_main.c:153
client_main.h
cma_is_city_under_agent
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:551
cma_release_city
void cma_release_city(struct city *pcity)
Definition cma_core.c:541
incite_cost
char * incite_cost
Definition comments.c:74
current_theme
QString current_theme
Definition fc_client.cpp:64
O_SHIELD
@ O_SHIELD
Definition fc_types.h:101
O_FOOD
@ O_FOOD
Definition fc_types.h:101
O_TRADE
@ O_TRADE
Definition fc_types.h:101
O_SCIENCE
@ O_SCIENCE
Definition fc_types.h:101
O_LUXURY
@ O_LUXURY
Definition fc_types.h:101
O_GOLD
@ O_GOLD
Definition fc_types.h:101
fcintl.h
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:106
game.h
real_city_report_dialog_update
void real_city_report_dialog_update(void *unused)
Definition cityrep.c:1454
real_city_report_update_city
void real_city_report_update_city(struct city *pcity)
Definition cityrep.c:1489
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2089
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.c:2066
city_report_dialog_popdown
void city_report_dialog_popdown(void)
Definition cityrep.c:312
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
popup_hurry_production_dialog
void popup_hurry_production_dialog(struct city *pcity, SDL_Surface *pdest)
Definition citydlg.c:1173
exit_city_report_callback
static int exit_city_report_callback(struct widget *pwidget)
Definition cityrep.c:90
popup_worklist_from_city_report_callback
static int popup_worklist_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:114
popup_citydlg_from_city_report_callback
static int popup_citydlg_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:102
city_report_windows_callback
static int city_report_windows_callback(struct widget *pwindow)
Definition cityrep.c:78
city_rep
static struct advanced_dialog * city_rep
Definition cityrep.c:53
real_city_report_dialog_update_city
static struct widget * real_city_report_dialog_update_city(struct widget *pwidget, struct city *pcity)
Definition cityrep.c:964
popup_cma_from_city_report_callback
static int popup_cma_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:138
popup_buy_production_from_city_report_callback
static int popup_buy_production_from_city_report_callback(struct widget *pwidget)
Definition cityrep.c:126
COL
#define COL
Definition cityrep.c:173
real_info_city_report_dialog_update
static void real_info_city_report_dialog_update(void)
Definition cityrep.c:178
is_city_report_open
bool is_city_report_open(void)
Definition cityrep.c:1130
popup_city_cma_dialog
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
get_game_color
SDL_Color * get_game_color(enum color_std stdcolor)
Definition colors.c:55
resize_surface
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
main_window_width
int main_window_width(void)
Definition graphics.c:685
fill_rect_alpha
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
alphablit
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
main_data
struct sdl2_data main_data
Definition graphics.c:57
create_frame
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1350
main_window_height
int main_window_height(void)
Definition graphics.c:693
resize_surface_box
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
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
ID_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
selected_widget
struct widget * selected_widget
Definition widget.c:48
adj_size
#define adj_size(size)
Definition gui_main.h:141
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:71
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_text_surf_from_utf8
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
FREEUTF8STR
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:65
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:67
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
icons
struct city_icon * icons
Definition gui_tilespec.c:55
get_building_surface
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
Definition gui_tilespec.h:251
get_unittype_surface
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
Definition gui_tilespec.h:259
enable_and_redraw_find_city_button
void enable_and_redraw_find_city_button(void)
Definition mapctrl.c:2235
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_CITYREP
@ BACKGROUND_CITYREP
Definition themebackgrounds.h:32
COLOR_THEME_CITYDLG_CELEB
@ COLOR_THEME_CITYDLG_CELEB
Definition themecolors.h:48
COLOR_THEME_CITYREP_FRAME
@ COLOR_THEME_CITYREP_FRAME
Definition themecolors.h:71
COLOR_THEME_CITYDLG_LUX
@ COLOR_THEME_CITYDLG_LUX
Definition themecolors.h:60
COLOR_THEME_CITYDLG_TRADE
@ COLOR_THEME_CITYDLG_TRADE
Definition themecolors.h:68
COLOR_THEME_CITYDLG_PROD
@ COLOR_THEME_CITYDLG_PROD
Definition themecolors.h:62
COLOR_THEME_CITYDLG_SUPPORT
@ COLOR_THEME_CITYDLG_SUPPORT
Definition themecolors.h:67
COLOR_THEME_CITYREP_FOODSTOCK
@ COLOR_THEME_CITYREP_FOODSTOCK
Definition themecolors.h:70
COLOR_THEME_CITYREP_TEXT
@ COLOR_THEME_CITYREP_TEXT
Definition themecolors.h:73
COLOR_THEME_CITYDLG_HAPPY
@ COLOR_THEME_CITYDLG_HAPPY
Definition themecolors.h:57
COLOR_THEME_CITYDLG_SCIENCE
@ COLOR_THEME_CITYDLG_SCIENCE
Definition themecolors.h:63
COLOR_THEME_CITYREP_TRADE
@ COLOR_THEME_CITYREP_TRADE
Definition themecolors.h:74
COLOR_THEME_CITYDLG_GOLD
@ COLOR_THEME_CITYDLG_GOLD
Definition themecolors.h:54
COLOR_THEME_CITYREP_PROD
@ COLOR_THEME_CITYREP_PROD
Definition themecolors.h:72
COLOR_THEME_CITYDLG_FOOD_SURPLUS
@ COLOR_THEME_CITYDLG_FOOD_SURPLUS
Definition themecolors.h:52
active_theme
struct theme * active_theme
Definition themespec.c:154
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
redraw_group
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
popdown_window_group_dialog
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
move_window_group
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
MAX_ID
#define MAX_ID
Definition widget.h:38
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
WF_WIDGET_HAS_INFO_LABEL
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
WF_SELECT_WITHOUT_BAR
@ WF_SELECT_WITHOUT_BAR
Definition widget.h:89
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
WF_FREE_THEME
@ WF_FREE_THEME
Definition widget.h:72
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
set_wflag
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
toggle_checkbox
void toggle_checkbox(struct widget *cbox)
Definition widget_checkbox.c:225
get_checkbox_state
bool get_checkbox_state(struct widget *cbox)
Definition widget_checkbox.c:239
create_checkbox
struct widget * create_checkbox(struct gui_layer *pdest, bool state, Uint32 flags)
Definition widget_checkbox.c:115
create_themeicon
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:212
create_icon2
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:337
create_icon_from_theme
SDL_Surface * create_icon_from_theme(SDL_Surface *icon_theme, Uint8 state)
Definition widget_icon.c:298
create_iconlabel
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_label.c:215
setup_vertical_scrollbar_area
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Definition widget_scrollbar.c:567
create_vertical_scrollbar
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
Definition widget_scrollbar.c:486
resize_window
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
Definition widget_window.c:255
create_window_skeleton
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
Definition widget_window.c:180
popup_worklist_editor
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
cma_fe.h
gui_id.h
gui_tilespec.h
themespec.h
widget.h
citydlg.h
cityrep.h
colors.h
graphics.h
gui_main.h
mapctrl.h
mapview.h
repodlgs.h
sprite.h
wldlg.h
impr_build_shield_cost
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:294
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
name
const char * name
Definition inputfile.c:127
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_debug
#define log_debug(message,...)
Definition log.h:115
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
advanced_dialog
Definition widget.h:180
advanced_dialog::begin_active_widget_list
struct widget * begin_active_widget_list
Definition widget.h:184
advanced_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:182
advanced_dialog::end_active_widget_list
struct widget * end_active_widget_list
Definition widget.h:185
advanced_dialog::active_widget_list
struct widget * active_widget_list
Definition widget.h:186
advanced_dialog::scroll
struct scroll_bar * scroll
Definition widget.h:187
advanced_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:181
city_icon::big_trade_corr
SDL_Surface * big_trade_corr
Definition gui_tilespec.h:153
city_icon::big_shield_corr
SDL_Surface * big_shield_corr
Definition gui_tilespec.h:152
city_icon::big_trade
SDL_Surface * big_trade
Definition gui_tilespec.h:156
city_icon::big_shield
SDL_Surface * big_shield
Definition gui_tilespec.h:155
city_icon::big_luxury
SDL_Surface * big_luxury
Definition gui_tilespec.h:157
city_icon::big_colb
SDL_Surface * big_colb
Definition gui_tilespec.h:159
city_icon::big_food
SDL_Surface * big_food
Definition gui_tilespec.h:154
city_icon::big_coin
SDL_Surface * big_coin
Definition gui_tilespec.h:158
city_icon::big_food_corr
SDL_Surface * big_food_corr
Definition gui_tilespec.h:151
city_icon::big_food_surplus
SDL_Surface * big_food_surplus
Definition gui_tilespec.h:164
city_icon::worklist
SDL_Surface * worklist
Definition gui_tilespec.h:177
city_icon::big_shield_surplus
SDL_Surface * big_shield_surplus
Definition gui_tilespec.h:163
city
Definition city.h:320
city::surplus
int surplus[O_LAST]
Definition city.h:355
city::id
int id
Definition city.h:326
city::waste
int waste[O_LAST]
Definition city.h:356
city::worklist
struct worklist worklist
Definition city.h:401
city::production
struct universal production
Definition city.h:396
city::shield_stock
int shield_stock
Definition city.h:368
city::prod
int prod[O_LAST]
Definition city.h:358
civclient::conn
struct connection conn
Definition client_main.h:96
connection::playing
struct player * playing
Definition connection.h:151
impr_type
Definition improvement.h:50
player::cities
struct city_list * cities
Definition player.h:281
scroll_bar::count
Uint16 count
Definition widget_scrollbar.h:27
sdl2_data::event
SDL_Event event
Definition graphics.h:217
unit_type
Definition unittype.h:507
universal::kind
enum universals_n kind
Definition fc_types.h:880
universal::value
universals_u value
Definition fc_types.h:879
utf8_str
Definition gui_string.h:52
utf8_str::fgcol
SDL_Color fgcol
Definition gui_string.h:57
widget
Definition widget.h:112
widget::theme
SDL_Surface * theme
Definition widget.h:118
widget::prev
struct widget * prev
Definition widget.h:114
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::city
struct city * city
Definition widget.h:128
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::area
SDL_Rect area
Definition widget.h:149
widget::next
struct widget * next
Definition widget.h:113
widget::info_label
utf8_str * info_label
Definition widget.h:122
widget::id
Uint16 id
Definition widget.h:155
widget::size
SDL_Rect size
Definition widget.h:145
widget::data
union widget::@217 data
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
TRUE
#define TRUE
Definition support.h:46
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:698
universals_u::building
const struct impr_type * building
Definition fc_types.h:691
utype_build_shield_cost
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1438
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
worklist_is_empty
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66