Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl2/cityrep.c Source File

Freeciv-3.2

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
53 static struct advanced_dialog *city_rep = NULL;
54
55static void real_info_city_report_dialog_update(void);
56
57/* ==================================================================== */
58
59/**********************************************************************/
62 void city_report_dialog_popdown(void)
63{
64 if (city_rep) {
65 popdown_window_group_dialog(city_rep->begin_widget_list,
66 city_rep->end_widget_list);
67 FC_FREE(city_rep->scroll);
68 FC_FREE(city_rep);
69
70 enable_and_redraw_find_city_button();
71 flush_dirty();
72 }
73}
74
75/**********************************************************************/
78 static int city_report_windows_callback(struct widget *pwindow)
79{
80 if (PRESSED_EVENT(main_data.event)) {
81 move_window_group(city_rep->begin_widget_list, pwindow);
82 }
83
84 return -1;
85}
86
87/**********************************************************************/
90 static int exit_city_report_callback(struct widget *pwidget)
91{
92 if (PRESSED_EVENT(main_data.event)) {
93 city_report_dialog_popdown();
94 }
95
96 return -1;
97}
98
99/**********************************************************************/
102 static int popup_citydlg_from_city_report_callback(struct widget *pwidget)
103{
104 if (PRESSED_EVENT(main_data.event)) {
105 popup_city_dialog(pwidget->data.city);
106 }
107
108 return -1;
109}
110
111/**********************************************************************/
114 static int popup_worklist_from_city_report_callback(struct widget *pwidget)
115{
116 if (PRESSED_EVENT(main_data.event)) {
117 popup_worklist_editor(pwidget->data.city, NULL);
118 }
119
120 return -1;
121}
122
123/**********************************************************************/
126 static int popup_buy_production_from_city_report_callback(struct widget *pwidget)
127{
128 if (PRESSED_EVENT(main_data.event)) {
129 popup_hurry_production_dialog(pwidget->data.city, NULL);
130 }
131
132 return -1;
133}
134
135/**********************************************************************/
138 static int popup_cma_from_city_report_callback(struct widget *pwidget)
139{
140 if (PRESSED_EVENT(main_data.event)) {
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)) {
145 cma_release_city(pcity);
146 city_report_dialog_update_city(pcity);
147 } else {
148 popup_city_cma_dialog(pcity);
149 }
150 }
151
152 return -1;
153}
154
155#if 0
156/**********************************************************************/
159static int info_city_report_callback(struct widget *pwidget)
160{
161 if (PRESSED_EVENT(main_data.event)) {
162 set_wstate(pwidget, FC_WS_NORMAL);
163 selected_widget = NULL;
164 widget_redraw(pwidget);
165 widget_mark_dirty(pwidget);
166 real_info_city_report_dialog_update();
167 }
168
169 return -1;
170}
171#endif /* 0 */
172
173#define COL 17
174
175/**********************************************************************/
178 static void real_info_city_report_dialog_update(void)
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;
186 SDL_Surface *logo;
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;
190 SDL_Rect dst;
191 SDL_Rect area;
192
193 if (city_rep) {
194 popdown_window_group_dialog(city_rep->begin_widget_list,
195 city_rep->end_widget_list);
196 } else {
197 city_rep = fc_calloc(1, sizeof(struct advanced_dialog));
198 }
199
200 fc_snprintf(cbuf, sizeof(cbuf), _("size"));
201 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
202 pstr->style |= SF_CENTER;
203 text1 = create_text_surf_from_utf8(pstr);
204
205 fc_snprintf(cbuf, sizeof(cbuf), _("time\nto grow"));
206 copy_chars_to_utf8_str(pstr, cbuf);
207 text2 = create_text_surf_from_utf8(pstr);
208
209 fc_snprintf(cbuf, sizeof(cbuf), _("City Name"));
210 copy_chars_to_utf8_str(pstr, cbuf);
211 text3 = create_text_surf_from_utf8(pstr);
212 name_w = text3->w + adj_size(6);
213
214 fc_snprintf(cbuf, sizeof(cbuf), _("Production"));
215 copy_chars_to_utf8_str(pstr, cbuf);
216 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT);
217 text4 = create_text_surf_from_utf8(pstr);
218 prod_w = text4->w;
219 FREEUTF8STR(pstr);
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 /* --------------- */
225 pstr = create_utf8_from_char_fonto(_("Cities Report"), FONTO_ATTENTION);
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);
231 pwindow->action = city_report_windows_callback;
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,
240 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
241 pbuf->info_label = create_utf8_from_char_fonto(_("Close Dialog"),
242 FONTO_ATTENTION);
243 pbuf->action = exit_city_report_callback;
244 set_wstate(pbuf, FC_WS_NORMAL);
245 pbuf->key = SDLK_ESCAPE;
246
247 add_to_gui_list(ID_BUTTON, pbuf);
248
249/* FIXME: Not implemented yet */
250#if 0
251 /* ------------------------- */
252 pbuf = create_themeicon(current_theme->info_icon, pwindow->dst,
253 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
254 pbuf->info_label = create_utf8_from_char_fonto(_("Information Report"),
255 FONTO_ATTENTION);
256/*
257 pbuf->action = info_city_report_callback;
258 set_wstate(pbuf, FC_WS_NORMAL);
259*/
260 add_to_gui_list(ID_BUTTON, pbuf);
261 /* -------- */
262 pbuf = create_themeicon(current_theme->happy_icon, pwindow->dst,
263 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
264 pbuf->info_label = create_utf8_from_char_fonto(_("Happiness Report"),
265 FONTO_ATTENTION);
266/*
267 pbuf->action = happy_city_report_callback;
268 set_wstate(pbuf, FC_WS_NORMAL);
269*/
270 add_to_gui_list(ID_BUTTON, pbuf);
271 /* -------- */
272 pbuf = create_themeicon(current_theme->army_icon, pwindow->dst,
273 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
274
275 pbuf->info_label = create_utf8_from_char_fonto(_("Garrison Report"),
276 FONTO_ATTENTION);
277/*
278 pbuf->action = army_city_dlg_callback;
279 set_wstate(pbuf, FC_WS_NORMAL);
280*/
281 add_to_gui_list(ID_BUTTON, pbuf);
282 /* -------- */
283 pbuf = create_themeicon(current_theme->support_icon, pwindow->dst,
284 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
285 pbuf->info_label = create_utf8_from_char_fonto(_("Maintenance Report"),
286 FONTO_ATTENTION);
287/*
288 pbuf->action = supported_unit_city_dlg_callback;
289 set_wstate(pbuf, FC_WS_NORMAL);
290*/
291 add_to_gui_list(ID_BUTTON, pbuf);
292 /* ------------------------ */
293#endif /* 0 */
294
295 last = pbuf;
296 count = 0;
297 city_list_iterate(client.conn.playing->cities, pcity) {
298 pstr = create_utf8_from_char_fonto(city_name_get(pcity), FONTO_ATTENTION);
299 pstr->style |= TTF_STYLE_BOLD;
300 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
301 (WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR));
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
315 pbuf->action = popup_citydlg_from_city_report_callback;
316 set_wstate(pbuf, FC_WS_NORMAL);
317 pbuf->data.city = pcity;
318 if (count > 13 * COL) {
319 set_wflag(pbuf , WF_HIDDEN);
320 }
321 hh = pbuf->size.h;
322 name_w = MAX(pbuf->size.w, name_w);
323 add_to_gui_list(MAX_ID - pcity->id, pbuf);
324
325 /* ----------- */
326 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
327 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
328 pstr->style |= SF_CENTER;
329 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
330 WF_RESTORE_BACKGROUND);
331 if (count > 13 * COL) {
332 set_wflag(pbuf, WF_HIDDEN);
333 }
334 hh = MAX(hh, pbuf->size.h);
335 pbuf->size.w = text1->w + adj_size(8);
336 add_to_gui_list(MAX_ID - pcity->id, pbuf);
337
338 /* ----------- */
339 pbuf = create_checkbox(pwindow->dst,
340 cma_is_city_under_agent(pcity, NULL),
341 WF_RESTORE_BACKGROUND);
342 if (count > 13 * COL) {
343 set_wflag(pbuf, WF_HIDDEN);
344 }
345 hh = MAX(hh, pbuf->size.h);
346 fc_assert(MAX_ID > pcity->id);
347 add_to_gui_list(MAX_ID - pcity->id, pbuf);
348 set_wstate(pbuf, FC_WS_NORMAL);
349 pbuf->action = popup_cma_from_city_report_callback;
350
351 /* ----------- */
352 fc_snprintf(cbuf, sizeof(cbuf), "%d",
353 pcity->prod[O_FOOD] - pcity->surplus[O_FOOD]);
354 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
355 pstr->style |= SF_CENTER;
356 pstr->fgcol = *get_game_color(COLOR_OVERVIEW_LAND);
357 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
358 WF_RESTORE_BACKGROUND);
359 if (count > 13 * COL) {
360 set_wflag(pbuf, WF_HIDDEN);
361 }
362 hh = MAX(hh, pbuf->size.h);
363 pbuf->size.w = icons->big_food->w + adj_size(6);
364 add_to_gui_list(MAX_ID - pcity->id, pbuf);
365
366 /* ----------- */
367 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
368 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
369 pstr->style |= SF_CENTER;
370 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_FOOD_SURPLUS);
371 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
372 WF_RESTORE_BACKGROUND);
373 if (count > 13 * COL) {
374 set_wflag(pbuf, WF_HIDDEN);
375 }
376 hh = MAX(hh, pbuf->size.h);
377 pbuf->size.w = icons->big_food_corr->w + adj_size(6);
378 add_to_gui_list(MAX_ID - pcity->id, pbuf);
379
380 /* ----------- */
381 togrow = city_turns_to_grow(pcity);
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
394 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
395 pstr->style |= SF_CENTER;
396 if (togrow < 0) {
397 pstr->fgcol.r = 255;
398 }
399 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
400 WF_RESTORE_BACKGROUND);
401 if (count > 13 * COL) {
402 set_wflag(pbuf, WF_HIDDEN);
403 }
404 hh = MAX(hh, pbuf->size.h);
405 pbuf->size.w = text2->w + adj_size(6);
406 add_to_gui_list(MAX_ID - pcity->id, pbuf);
407
408 /* ----------- */
409 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_TRADE]);
410 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
411 pstr->style |= SF_CENTER;
412 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
413 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
414 WF_RESTORE_BACKGROUND);
415 if (count > 13 * COL) {
416 set_wflag(pbuf, WF_HIDDEN);
417 }
418 hh = MAX(hh, pbuf->size.h);
419 pbuf->size.w = icons->big_trade->w + adj_size(6);
420 add_to_gui_list(MAX_ID - pcity->id, pbuf);
421
422 /* ----------- */
423 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
424 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
425 pstr->style |= SF_CENTER;
426 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
427 WF_RESTORE_BACKGROUND);
428 if (count > 13 * COL) {
429 set_wflag(pbuf, WF_HIDDEN);
430 }
431 hh = MAX(hh, pbuf->size.h);
432 pbuf->size.w = icons->big_trade_corr->w + adj_size(6);
433 add_to_gui_list(MAX_ID - pcity->id, pbuf);
434
435 /* ----------- */
436 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
437 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
438 pstr->style |= SF_CENTER;
439 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_GOLD);
440 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
441 WF_RESTORE_BACKGROUND);
442 if (count > 13 * COL) {
443 set_wflag(pbuf, WF_HIDDEN);
444 }
445 hh = MAX(hh, pbuf->size.h);
446 pbuf->size.w = icons->big_coin->w + adj_size(6);
447 add_to_gui_list(MAX_ID - pcity->id, pbuf);
448
449 /* ----------- */
450 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
451 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
452 pstr->style |= SF_CENTER;
453 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SCIENCE);
454 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
455 WF_RESTORE_BACKGROUND);
456 if (count > 13 * COL) {
457 set_wflag(pbuf, WF_HIDDEN);
458 }
459 hh = MAX(hh, pbuf->size.h);
460 pbuf->size.w = icons->big_colb->w + adj_size(6);
461 add_to_gui_list(MAX_ID - pcity->id, pbuf);
462
463 /* ----------- */
464 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
465 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
466 pstr->style |= SF_CENTER;
467 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_LUX);
468 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
469 WF_RESTORE_BACKGROUND);
470 if (count > 13 * COL) {
471 set_wflag(pbuf, WF_HIDDEN);
472 }
473 hh = MAX(hh, pbuf->size.h);
474 pbuf->size.w = icons->big_luxury->w + adj_size(6);
475 add_to_gui_list(MAX_ID - pcity->id, pbuf);
476
477 /* ----------- */
478 fc_snprintf(cbuf, sizeof(cbuf), "%d",
479 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
480 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
481 pstr->style |= SF_CENTER;
482 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PROD);
483 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
484 WF_RESTORE_BACKGROUND);
485 if (count > 13 * COL) {
486 set_wflag(pbuf, WF_HIDDEN);
487 }
488 hh = MAX(hh, pbuf->size.h);
489 pbuf->size.w = icons->big_shield->w + adj_size(6);
490 add_to_gui_list(MAX_ID - pcity->id, pbuf);
491
492 /* ----------- */
493 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
494 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
495 pstr->style |= SF_CENTER;
496 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
497 WF_RESTORE_BACKGROUND);
498 if (count > 13 * COL) {
499 set_wflag(pbuf, WF_HIDDEN);
500 }
501 hh = MAX(hh, pbuf->size.h);
502 pbuf->size.w = icons->big_shield_corr->w + adj_size(6);
503 add_to_gui_list(MAX_ID - pcity->id, pbuf);
504
505 /* ----------- */
506 fc_snprintf(cbuf, sizeof(cbuf), "%d",
507 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD] - pcity->surplus[O_SHIELD]);
508 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
509 pstr->style |= SF_CENTER;
510 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SUPPORT);
511 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
512 WF_RESTORE_BACKGROUND);
513 if (count > 13 * COL) {
514 set_wflag(pbuf, WF_HIDDEN);
515 }
516 hh = MAX(hh, pbuf->size.h);
517 pbuf->size.w = units_icon->w + adj_size(6);
518 add_to_gui_list(MAX_ID - pcity->id, pbuf);
519
520 /* ----------- */
521 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
522 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
523 pstr->style |= SF_CENTER;
524 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
525 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
526 WF_RESTORE_BACKGROUND);
527 if (count > 13 * COL) {
528 set_wflag(pbuf, WF_HIDDEN);
529 }
530 hh = MAX(hh, pbuf->size.h);
531 pbuf->size.w = icons->big_shield_surplus->w + adj_size(6);
532 add_to_gui_list(MAX_ID - pcity->id, pbuf);
533
534 /* ----------- */
535 if (VUT_UTYPE == pcity->production.kind) {
536 const struct unit_type *punittype = pcity->production.value.utype;
537
538 logo = resize_surface_box(get_unittype_surface(punittype,
539 direction8_invalid()),
540 adj_size(36), adj_size(24), 1,
541 TRUE, TRUE);
542 togrow = utype_build_shield_cost(pcity, NULL, punittype);
543 name = utype_name_translation(punittype);
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);
550 togrow = impr_build_shield_cost(pcity, pimprove);
551 name = improvement_name_translation(pimprove);
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 */
567 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
568 pstr->style |= SF_CENTER;
569
570 togrow = city_production_turns_to_build(pcity, TRUE);
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,
579 WF_WIDGET_HAS_INFO_LABEL |WF_RESTORE_BACKGROUND
580 | WF_FREE_THEME);
581 pbuf->info_label = pstr;
582 if (count > 13 * COL) {
583 set_wflag(pbuf, WF_HIDDEN);
584 }
585 hh = MAX(hh, pbuf->size.h);
586 add_to_gui_list(MAX_ID - pcity->id, pbuf);
587 set_wstate(pbuf, FC_WS_NORMAL);
588 pbuf->action = popup_worklist_from_city_report_callback;
589 pbuf->data.city = pcity;
590
591 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
592 pstr->style |= SF_CENTER;
593 pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT);
594 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
595 (WF_SELECT_WITHOUT_BAR | WF_RESTORE_BACKGROUND));
596 if (count > 13 * COL) {
597 set_wflag(pbuf, WF_HIDDEN);
598 }
599 hh = MAX(hh, pbuf->size.h);
600 prod_w = MAX(prod_w, pbuf->size.w);
601 add_to_gui_list(MAX_ID - pcity->id, pbuf);
602 pbuf->data.city = pcity;
603 pbuf->action = popup_buy_production_from_city_report_callback;
604 if (city_can_buy(pcity)) {
605 set_wstate(pbuf, FC_WS_NORMAL);
606 }
607
608 count += COL;
609 } city_list_iterate_end;
610
611 h = hh;
612 city_rep->begin_widget_list = pbuf;
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) {
620 city_rep->end_active_widget_list = last->prev;
621 city_rep->begin_active_widget_list = city_rep->begin_widget_list;
622 if (count > 14 * COL) {
623 city_rep->active_widget_list = city_rep->end_active_widget_list;
624 if (city_rep->scroll) {
625 city_rep->scroll->count = count;
626 }
627 ww = create_vertical_scrollbar(city_rep, COL, 14, TRUE, TRUE);
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
638 logo = theme_get_background(active_theme, BACKGROUND_CITYREP);
639 resize_window(pwindow, logo, NULL,
640 (pwindow->size.w - pwindow->area.w) + area.w,
641 (pwindow->size.h - pwindow->area.h) + area.h);
642 FREESURFACE(logo);
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,
694 get_theme_color(COLOR_THEME_CITYREP_FRAME));
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);
699 FREESURFACE(text3);
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;
705 FREESURFACE(text1);
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,
724 get_theme_color(COLOR_THEME_CITYREP_FOODSTOCK));
725
726 create_frame(pwindow->theme,
727 dst.x, dst.y, dst.w, dst.h - 1,
728 get_theme_color(COLOR_THEME_CITYREP_FRAME));
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;
746 FREESURFACE(text2);
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,
761 get_theme_color(COLOR_THEME_CITYREP_TRADE));
762
763 create_frame(pwindow->theme,
764 dst.x , dst.y, dst.w, dst.h - 1,
765 get_theme_color(COLOR_THEME_CITYREP_FRAME));
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) +
796 (icons->big_shield_surplus->w + adj_size(6)) + adj_size(4);
797 dst.h = area.h - adj_size(2);
798
799 fill_rect_alpha(pwindow->theme, &dst,
800 get_theme_color(COLOR_THEME_CITYREP_PROD));
801
802 create_frame(pwindow->theme,
803 dst.x , dst.y, dst.w, dst.h - 1,
804 get_theme_color(COLOR_THEME_CITYREP_FRAME));
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,
833 get_theme_color(COLOR_THEME_CITYREP_PROD));
834
835 create_frame(pwindow->theme,
836 dst.x , dst.y, dst.w, dst.h - 1,
837 get_theme_color(COLOR_THEME_CITYREP_FRAME));
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);
842 FREESURFACE(text4);
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;
941 if (pbuf == city_rep->begin_active_widget_list) {
942 break;
943 }
944 pbuf = pbuf->prev;
945 }
946
947 if (city_rep->scroll) {
948 setup_vertical_scrollbar_area(city_rep->scroll,
949 area.x + area.w, area.y,
950 area.h, TRUE);
951 }
952
953 }
954
955 /* ----------------------------------- */
956 redraw_group(city_rep->begin_widget_list, pwindow, 0);
957 widget_mark_dirty(pwindow);
958 flush_dirty();
959}
960
961/**********************************************************************/
964 static 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;
970 SDL_Surface *logo;
971 SDL_Rect dst;
972
973 /* city name status */
974 if (city_unhappy(pcity)) {
975 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE);
976 } else {
977 if (city_celebrating(pcity)) {
978 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_CELEB);
979 } else {
980 if (city_happy(pcity)) {
981 pwidget->string_utf8->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_HAPPY);
982 }
983 }
984 }
985
986 /* city size */
987 pwidget = pwidget->prev;
988 fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pcity));
989 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
990
991 /* cma check box */
992 pwidget = pwidget->prev;
993 if (cma_is_city_under_agent(pcity, NULL) != get_checkbox_state(pwidget)) {
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]);
1001 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1002
1003 /* food surplus */
1004 pwidget = pwidget->prev;
1005 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_FOOD]);
1006 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1007
1008 /* time to grow */
1009 pwidget = pwidget->prev;
1010 togrow = city_turns_to_grow(pcity);
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 }
1022 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
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]);
1033 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1034
1035 /* corruptions */
1036 pwidget = pwidget->prev;
1037 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_TRADE]);
1038 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1039
1040 /* gold surplus */
1041 pwidget = pwidget->prev;
1042 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_GOLD]);
1043 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1044
1045 /* science income */
1046 pwidget = pwidget->prev;
1047 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_SCIENCE]);
1048 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1049
1050 /* lugury income */
1051 pwidget = pwidget->prev;
1052 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->prod[O_LUXURY]);
1053 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1054
1055 /* total production */
1056 pwidget = pwidget->prev;
1057 fc_snprintf(cbuf, sizeof(cbuf), "%d",
1058 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD]);
1059 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1060
1061 /* waste */
1062 pwidget = pwidget->prev;
1063 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->waste[O_SHIELD]);
1064 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
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]);
1070 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1071
1072 /* production income */
1073 pwidget = pwidget->prev;
1074 fc_snprintf(cbuf, sizeof(cbuf), "%d", pcity->surplus[O_SHIELD]);
1075 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1076
1077 /* change production */
1078 if (VUT_UTYPE == pcity->production.kind) {
1079 const struct unit_type *punittype = pcity->production.value.utype;
1080
1081 logo = resize_surface(get_unittype_surface(punittype, direction8_invalid()),
1082 adj_size(36), adj_size(24), 1);
1083 togrow = utype_build_shield_cost(pcity, NULL, punittype);
1084 name = utype_name_translation(punittype);
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);
1091 name = improvement_name_translation(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;
1106 copy_chars_to_utf8_str(pwidget->info_label, cbuf);
1107 FREESURFACE(pwidget->theme);
1108 pwidget->theme = logo;
1109
1110 /* hurry productions */
1111 pwidget = pwidget->prev;
1112 togrow = city_production_turns_to_build(pcity, TRUE);
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
1120 copy_chars_to_utf8_str(pwidget->string_utf8, cbuf);
1121
1122 return pwidget->prev;
1123}
1124
1125/* ======================================================================== */
1126
1127/**********************************************************************/
1130 bool is_city_report_open(void)
1131{
1132 return (city_rep != NULL);
1133}
1134
1135/**********************************************************************/
1139 void city_report_dialog_popup(bool make_modal)
1140{
1141 if (!city_rep) {
1142 real_info_city_report_dialog_update();
1143 }
1144}
1145
1146/**********************************************************************/
1149 void real_city_report_dialog_update(void *unused)
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 */
1157 city_list_iterate(client.conn.playing->cities, pcity) {
1158 if (pcity->id == MAX_ID - pwidget->id) {
1159 count = COL;
1160
1161 while (count) {
1162 count--;
1163 pwidget = pwidget->prev;
1164 }
1165 } else {
1166 real_info_city_report_dialog_update();
1167
1168 return;
1169 }
1170 } city_list_iterate_end;
1171
1172 /* check it there are some city widgets left on list */
1173 if (pwidget && pwidget->next != city_rep->begin_active_widget_list) {
1174 real_info_city_report_dialog_update();
1175 return;
1176 }
1177
1178 /* update widget city list (widget list is the same that city list) */
1179 pwidget = city_rep->end_active_widget_list;
1180 city_list_iterate(client.conn.playing->cities, pcity) {
1181 pwidget = real_city_report_dialog_update_city(pwidget, pcity);
1182 } city_list_iterate_end;
1183
1184 /* -------------------------------------- */
1185 redraw_group(city_rep->begin_widget_list, city_rep->end_widget_list, 0);
1186 widget_mark_dirty(city_rep->end_widget_list);
1187
1188 flush_dirty();
1189 }
1190}
1191
1192/**********************************************************************/
1195 void real_city_report_update_city(struct city *pcity)
1196{
1197 if (city_rep && pcity) {
1198 struct widget *buf = city_rep->end_active_widget_list;
1199
1200 while (pcity->id != MAX_ID - buf->id
1201 && buf != city_rep->begin_active_widget_list) {
1202 buf = buf->prev;
1203 }
1204
1205 if (buf == city_rep->begin_active_widget_list) {
1206 real_info_city_report_dialog_update();
1207 return;
1208 }
1209 real_city_report_dialog_update_city(buf, pcity);
1210
1211 /* -------------------------------------- */
1212 redraw_group(city_rep->begin_widget_list, city_rep->end_widget_list, 0);
1213 widget_mark_dirty(city_rep->end_widget_list);
1214
1215 flush_dirty();
1216 }
1217}
1218
1219/**********************************************************************/
1224 void hilite_cities_from_canvas(void)
1225{
1226 log_debug("hilite_cities_from_canvas : PORT ME");
1227}
1228
1229/**********************************************************************/
1232 void toggle_city_hilite(struct city *pcity, bool on_off)
1233{
1234 log_debug("toggle_city_hilite : PORT ME");
1235}
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1128
city_production_turns_to_build
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:819
city_unhappy
bool city_unhappy(const struct city *pcity)
Definition city.c:1618
city_celebrating
bool city_celebrating(const struct city *pcity)
Definition city.c:1637
city_happy
bool city_happy(const struct city *pcity)
Definition city.c:1606
city_turns_to_grow
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1988
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:1521
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:150
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:65
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:107
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:1348
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:47
COLOR_THEME_CITYREP_FRAME
@ COLOR_THEME_CITYREP_FRAME
Definition themecolors.h:70
COLOR_THEME_CITYDLG_LUX
@ COLOR_THEME_CITYDLG_LUX
Definition themecolors.h:59
COLOR_THEME_CITYDLG_TRADE
@ COLOR_THEME_CITYDLG_TRADE
Definition themecolors.h:67
COLOR_THEME_CITYDLG_PROD
@ COLOR_THEME_CITYDLG_PROD
Definition themecolors.h:61
COLOR_THEME_CITYDLG_SUPPORT
@ COLOR_THEME_CITYDLG_SUPPORT
Definition themecolors.h:66
COLOR_THEME_CITYREP_FOODSTOCK
@ COLOR_THEME_CITYREP_FOODSTOCK
Definition themecolors.h:69
COLOR_THEME_CITYREP_TEXT
@ COLOR_THEME_CITYREP_TEXT
Definition themecolors.h:72
COLOR_THEME_CITYDLG_HAPPY
@ COLOR_THEME_CITYDLG_HAPPY
Definition themecolors.h:56
COLOR_THEME_CITYDLG_SCIENCE
@ COLOR_THEME_CITYDLG_SCIENCE
Definition themecolors.h:62
COLOR_THEME_CITYREP_TRADE
@ COLOR_THEME_CITYREP_TRADE
Definition themecolors.h:73
COLOR_THEME_CITYDLG_GOLD
@ COLOR_THEME_CITYDLG_GOLD
Definition themecolors.h:53
COLOR_THEME_CITYREP_PROD
@ COLOR_THEME_CITYREP_PROD
Definition themecolors.h:71
COLOR_THEME_CITYDLG_FOOD_SURPLUS
@ COLOR_THEME_CITYDLG_FOOD_SURPLUS
Definition themecolors.h:51
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:279
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:500
universal::kind
enum universals_n kind
Definition fc_types.h:903
universal::value
universals_u value
Definition fc_types.h:902
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::data
union widget::@192 data
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
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
TRUE
#define TRUE
Definition support.h:46
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:724
universals_u::building
const struct impr_type * building
Definition fc_types.h:717
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