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

Freeciv-3.2

Loading...
Searching...
No Matches
cma_fe.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2001 - R. Falke, M. Kaufman
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
28/* common */
29#include "game.h"
30
31/* client */
32#include "client_main.h" /* can_client_issue_orders() */
33
34/* gui-sdl2 */
35#include "citydlg.h"
36#include "cityrep.h"
37#include "cma_fec.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 "mapview.h"
44#include "sprite.h"
45#include "themespec.h"
46#include "widget.h"
47
48#include "cma_fe.h"
49
50 struct hmove {
51 struct widget *pscroll_bar;
52 int min, max, base;
53};
54
55static struct cma_dialog {
56 struct city *pcity;
57 struct small_dialog *dlg;
58 struct advanced_dialog *adv;
59 struct cm_parameter edited_cm_parm;
60} *cma = NULL;
61
62 enum specialist_type {
63 SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
64};
65
66static void set_cma_hscrollbars(void);
67
68/* =================================================================== */
69
70/**********************************************************************/
73 static int cma_dlg_callback(struct widget *pwindow)
74{
75 return -1;
76}
77
78/**********************************************************************/
81 static int exit_cma_dialog_callback(struct widget *pwidget)
82{
83 if (PRESSED_EVENT(main_data.event)) {
84 popdown_city_cma_dialog();
85 flush_dirty();
86 }
87
88 return -1;
89}
90
91/**********************************************************************/
94 static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
95 void *data)
96{
97 return (Uint16)ID_SCROLLBAR;
98}
99
100/**********************************************************************/
103 static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
104 void *data)
105{
106 struct hmove *motion = (struct hmove *)data;
107 char cbuf[4];
108
109 motion_event->x -= motion->pscroll_bar->dst->dest_rect.x;
110
111 if (motion && motion_event->xrel
112 && (motion_event->x >= motion->min) && (motion_event->x <= motion->max)) {
113 /* draw bcgd */
114 widget_undraw(motion->pscroll_bar);
115 widget_mark_dirty(motion->pscroll_bar);
116
117 if ((motion->pscroll_bar->size.x + motion_event->xrel) >
118 (motion->max - motion->pscroll_bar->size.w)) {
119 motion->pscroll_bar->size.x = motion->max - motion->pscroll_bar->size.w;
120 } else {
121 if ((motion->pscroll_bar->size.x + motion_event->xrel) < motion->min) {
122 motion->pscroll_bar->size.x = motion->min;
123 } else {
124 motion->pscroll_bar->size.x += motion_event->xrel;
125 }
126 }
127
128 *(int *)motion->pscroll_bar->data.ptr =
129 motion->base + (motion->pscroll_bar->size.x - motion->min);
130
131 fc_snprintf(cbuf, sizeof(cbuf), "%d",
132 *(int *)motion->pscroll_bar->data.ptr);
133 copy_chars_to_utf8_str(motion->pscroll_bar->next->string_utf8, cbuf);
134
135 /* redraw label */
136 widget_redraw(motion->pscroll_bar->next);
137 widget_mark_dirty(motion->pscroll_bar->next);
138
139 /* redraw scrollbar */
140 if (get_wflags(motion->pscroll_bar) & WF_RESTORE_BACKGROUND) {
141 refresh_widget_background(motion->pscroll_bar);
142 }
143 widget_redraw(motion->pscroll_bar);
144 widget_mark_dirty(motion->pscroll_bar);
145
146 flush_dirty();
147 }
148
149 return ID_ERROR;
150}
151
152/**********************************************************************/
155 static int min_horiz_cma_callback(struct widget *pwidget)
156{
157 if (PRESSED_EVENT(main_data.event)) {
158 struct hmove motion;
159
160 motion.pscroll_bar = pwidget;
161 motion.min = pwidget->next->size.x + pwidget->next->size.w + 5;
162 motion.max = motion.min + 70;
163 motion.base = -20;
164
165 MOVE_STEP_X = 2;
166 MOVE_STEP_Y = 0;
167 /* Filter mouse motion events */
168 SDL_SetEventFilter(FilterMouseMotionEvents, NULL);
169 gui_event_loop((void *)(&motion), NULL, NULL, NULL, NULL, NULL, NULL,
170 NULL, NULL,
171 scroll_mouse_button_up, scroll_mouse_motion_handler);
172 /* Turn off Filter mouse motion events */
173 SDL_SetEventFilter(NULL, NULL);
174 MOVE_STEP_X = DEFAULT_MOVE_STEP;
175 MOVE_STEP_Y = DEFAULT_MOVE_STEP;
176
177 selected_widget = pwidget;
178 set_wstate(pwidget, FC_WS_SELECTED);
179 /* save the change */
180 cmafec_set_fe_parameter(cma->pcity, &cma->edited_cm_parm);
181 /* refreshes the cma */
182 if (cma_is_city_under_agent(cma->pcity, NULL)) {
183 cma_release_city(cma->pcity);
184 cma_put_city_under_agent(cma->pcity, &cma->edited_cm_parm);
185 }
186 update_city_cma_dialog();
187 }
188
189 return -1;
190}
191
192/**********************************************************************/
195 static int factor_horiz_cma_callback(struct widget *pwidget)
196{
197 if (PRESSED_EVENT(main_data.event)) {
198 struct hmove motion;
199
200 motion.pscroll_bar = pwidget;
201 motion.min = pwidget->next->size.x + pwidget->next->size.w + 5;
202 motion.max = motion.min + 54;
203 motion.base = 1;
204
205 MOVE_STEP_X = 2;
206 MOVE_STEP_Y = 0;
207 /* Filter mouse motion events */
208 SDL_SetEventFilter(FilterMouseMotionEvents, NULL);
209 gui_event_loop((void *)(&motion), NULL, NULL, NULL, NULL, NULL, NULL,
210 NULL, NULL,
211 scroll_mouse_button_up, scroll_mouse_motion_handler);
212 /* Turn off Filter mouse motion events */
213 SDL_SetEventFilter(NULL, NULL);
214 MOVE_STEP_X = DEFAULT_MOVE_STEP;
215 MOVE_STEP_Y = DEFAULT_MOVE_STEP;
216
217 selected_widget = pwidget;
218 set_wstate(pwidget, FC_WS_SELECTED);
219 /* save the change */
220 cmafec_set_fe_parameter(cma->pcity, &cma->edited_cm_parm);
221 /* refreshes the cma */
222 if (cma_is_city_under_agent(cma->pcity, NULL)) {
223 cma_release_city(cma->pcity);
224 cma_put_city_under_agent(cma->pcity, &cma->edited_cm_parm);
225 }
226 update_city_cma_dialog();
227 }
228
229 return -1;
230}
231
232/**********************************************************************/
235 static int toggle_cma_celebrating_callback(struct widget *pwidget)
236{
237 if (PRESSED_EVENT(main_data.event)) {
238 cma->edited_cm_parm.require_happy ^= TRUE;
239 /* save the change */
240 cmafec_set_fe_parameter(cma->pcity, &cma->edited_cm_parm);
241 update_city_cma_dialog();
242 }
243
244 return -1;
245}
246
247/* ============================================================= */
248
249/**********************************************************************/
252 static int save_cma_window_callback(struct widget *pwindow)
253{
254 return -1;
255}
256
257/**********************************************************************/
260 static int ok_save_cma_callback(struct widget *pwidget)
261{
262 if (PRESSED_EVENT(main_data.event)) {
263 if (pwidget && cma && cma->adv) {
264 struct widget *pedit = (struct widget *)pwidget->data.ptr;
265
266 if (pedit->string_utf8->text != NULL) {
267 cmafec_preset_add(pedit->string_utf8->text, &cma->edited_cm_parm);
268 } else {
269 cmafec_preset_add(_("new preset"), &cma->edited_cm_parm);
270 }
271
272 del_group_of_widgets_from_gui_list(cma->adv->begin_widget_list,
273 cma->adv->end_widget_list);
274 FC_FREE(cma->adv);
275
276 update_city_cma_dialog();
277 }
278 }
279
280 return -1;
281}
282
283/**********************************************************************/
286 static int cancel_sld_cma_callback(struct widget *pwidget)
287{
288 if (PRESSED_EVENT(main_data.event)) {
289 if (cma && cma->adv) {
290 popdown_window_group_dialog(cma->adv->begin_widget_list,
291 cma->adv->end_widget_list);
292 FC_FREE(cma->adv->scroll);
293 FC_FREE(cma->adv);
294 flush_dirty();
295 }
296 }
297
298 return -1;
299}
300
301/**********************************************************************/
304 static int save_cma_callback(struct widget *pwidget)
305{
306 if (PRESSED_EVENT(main_data.event)) {
307 struct widget *buf, *pwindow;
308 utf8_str *pstr;
309 SDL_Surface *text;
310 SDL_Rect dst;
311 SDL_Rect area;
312
313 if (cma->adv) {
314 return 1;
315 }
316
317 cma->adv = fc_calloc(1, sizeof(struct advanced_dialog));
318
319 pstr = create_utf8_from_char_fonto(_("Name new preset"),
320 FONTO_ATTENTION);
321 pstr->style |= TTF_STYLE_BOLD;
322
323 pwindow = create_window_skeleton(NULL, pstr, 0);
324
325 pwindow->action = save_cma_window_callback;
326 set_wstate(pwindow, FC_WS_NORMAL);
327 cma->adv->end_widget_list = pwindow;
328
329 add_to_gui_list(ID_WINDOW, pwindow);
330
331 area = pwindow->area;
332 area.h = MAX(area.h, 1);
333
334 /* ============================================================= */
335 /* Label */
336 pstr = create_utf8_from_char_fonto(_("What should we name the preset?"),
337 FONTO_DEFAULT);
338 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
339 pstr->fgcol = *get_theme_color(COLOR_THEME_CMA_TEXT);
340
341 text = create_text_surf_from_utf8(pstr);
342 FREEUTF8STR(pstr);
343 area.w = MAX(area.w, text->w);
344 area.h += text->h + adj_size(5);
345 /* ============================================================= */
346
347 buf = create_edit(NULL, pwindow->dst,
348 create_utf8_from_char_fonto(_("new preset"),
349 FONTO_ATTENTION),
350 adj_size(100),
351 (WF_RESTORE_BACKGROUND|WF_FREE_STRING));
352 set_wstate(buf, FC_WS_NORMAL);
353 area.h += buf->size.h;
354 area.w = MAX(area.w, buf->size.w);
355
356 add_to_gui_list(ID_EDIT, buf);
357 /* ============================================================= */
358
359 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
360 pwindow->dst,
361 _("Yes"),
362 FONTO_ATTENTION, 0);
363
364 buf->action = ok_save_cma_callback;
365 set_wstate(buf, FC_WS_NORMAL);
366 buf->key = SDLK_RETURN;
367 add_to_gui_list(ID_BUTTON, buf);
368 buf->data.ptr = (void *)buf->next;
369
370 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
371 pwindow->dst, _("No"),
372 FONTO_ATTENTION, 0);
373 buf->action = cancel_sld_cma_callback;
374 set_wstate(buf, FC_WS_NORMAL);
375 buf->key = SDLK_ESCAPE;
376
377 add_to_gui_list(ID_BUTTON, buf);
378
379 area.h += buf->size.h;
380 buf->size.w = MAX(buf->next->size.w, buf->size.w);
381 buf->next->size.w = buf->size.w;
382 area.w = MAX(area.w, 2 * buf->size.w + adj_size(20));
383
384 cma->adv->begin_widget_list = buf;
385
386 /* setup window size and start position */
387 area.w += adj_size(20);
388 area.h += adj_size(15);
389
390 resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
391 (pwindow->size.w - pwindow->area.w) + area.w,
392 (pwindow->size.h - pwindow->area.h) + area.h);
393
394 area = pwindow->area;
395
396 widget_set_position(pwindow,
397 pwidget->size.x - pwindow->size.w / 2,
398 pwidget->size.y - pwindow->size.h);
399
400 /* setup rest of widgets */
401 /* label */
402 dst.x = area.x + (area.w - text->w) / 2;
403 dst.y = area.y + 1;
404 alphablit(text, NULL, pwindow->theme, &dst, 255);
405 dst.y += text->h + adj_size(5);
406 FREESURFACE(text);
407
408 /* edit */
409 buf = pwindow->prev;
410 buf->size.w = area.w - adj_size(10);
411 buf->size.x = area.x + adj_size(5);
412 buf->size.y = dst.y;
413 dst.y += buf->size.h + adj_size(5);
414
415 /* yes */
416 buf = buf->prev;
417 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
418 buf->size.y = dst.y;
419
420 /* no */
421 buf = buf->prev;
422 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(20);
423 buf->size.y = buf->next->size.y;
424
425 /* ================================================== */
426 /* redraw */
427 redraw_group(cma->adv->begin_widget_list, pwindow, 0);
428 widget_mark_dirty(pwindow);
429 flush_dirty();
430 }
431
432 return -1;
433}
434
435/* ================================================== */
436
437/**********************************************************************/
440 static int ld_cma_callback(struct widget *pwidget)
441{
442 if (PRESSED_EVENT(main_data.event)) {
443 bool load = pwidget->data.ptr != NULL;
444 int index = MAX_ID - pwidget->id;
445
446 popdown_window_group_dialog(cma->adv->begin_widget_list,
447 cma->adv->end_widget_list);
448 FC_FREE(cma->adv->scroll);
449 FC_FREE(cma->adv);
450
451 if (load) {
452 cm_copy_parameter(&cma->edited_cm_parm,
453 cmafec_preset_get_parameter(index));
454 set_cma_hscrollbars();
455 /* save the change */
456 cmafec_set_fe_parameter(cma->pcity, &cma->edited_cm_parm);
457 /* stop the cma */
458 if (cma_is_city_under_agent(cma->pcity, NULL)) {
459 cma_release_city(cma->pcity);
460 }
461 } else {
462 cmafec_preset_remove(index);
463 }
464
465 update_city_cma_dialog();
466 }
467
468 return -1;
469}
470
471/**********************************************************************/
474 static void popup_load_del_presets_dialog(bool load, struct widget *button)
475{
476 int hh, count, i;
477 struct widget *buf, *pwindow;
478 utf8_str *pstr;
479 SDL_Rect area;
480
481 if (cma->adv) {
482 return;
483 }
484
485 count = cmafec_preset_num();
486
487 if (count == 1) {
488 if (load) {
489 cm_copy_parameter(&cma->edited_cm_parm, cmafec_preset_get_parameter(0));
490 set_cma_hscrollbars();
491 /* save the change */
492 cmafec_set_fe_parameter(cma->pcity, &cma->edited_cm_parm);
493 /* stop the cma */
494 if (cma_is_city_under_agent(cma->pcity, NULL)) {
495 cma_release_city(cma->pcity);
496 }
497 } else {
498 cmafec_preset_remove(0);
499 }
500 update_city_cma_dialog();
501 return;
502 }
503
504 cma->adv = fc_calloc(1, sizeof(struct advanced_dialog));
505
506 pstr = create_utf8_from_char_fonto(_("Presets"), FONTO_ATTENTION);
507 pstr->style |= TTF_STYLE_BOLD;
508
509 pwindow = create_window_skeleton(NULL, pstr, 0);
510
511 pwindow->action = save_cma_window_callback;
512 set_wstate(pwindow, FC_WS_NORMAL);
513 cma->adv->end_widget_list = pwindow;
514
515 add_to_gui_list(ID_WINDOW, pwindow);
516
517 area = pwindow->area;
518
519 /* ---------- */
520 /* Create exit button */
521 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
522 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
523 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
524 FONTO_ATTENTION);
525 buf->action = cancel_sld_cma_callback;
526 set_wstate(buf, FC_WS_NORMAL);
527 buf->key = SDLK_ESCAPE;
528 area.w += (buf->size.w + adj_size(10));
529
530 add_to_gui_list(ID_BUTTON, buf);
531 /* ---------- */
532
533 for (i = 0; i < count; i++) {
534 pstr = create_utf8_from_char_fonto(cmafec_preset_get_descr(i), FONTO_DEFAULT);
535 pstr->style |= TTF_STYLE_BOLD;
536 buf = create_iconlabel(NULL, pwindow->dst, pstr,
537 (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE));
538 buf->string_utf8->bgcol = (SDL_Color) {0, 0, 0, 0};
539 buf->action = ld_cma_callback;
540
541 area.w = MAX(area.w, buf->size.w);
542 area.h += buf->size.h;
543 set_wstate(buf , FC_WS_NORMAL);
544
545 if (load) {
546 buf->data.ptr = (void *)1;
547 } else {
548 buf->data.ptr = NULL;
549 }
550
551 add_to_gui_list(MAX_ID - i, buf);
552
553 if (i > 10) {
554 set_wflag(buf, WF_HIDDEN);
555 }
556 }
557 cma->adv->begin_widget_list = buf;
558 cma->adv->begin_active_widget_list = cma->adv->begin_widget_list;
559 cma->adv->end_active_widget_list = pwindow->prev->prev;
560 cma->adv->active_widget_list = cma->adv->end_active_widget_list;
561
562 area.w += adj_size(2);
563 area.h += 1;
564
565 if (count > 11) {
566 create_vertical_scrollbar(cma->adv, 1, 11, FALSE, TRUE);
567
568 /* ------- window ------- */
569 area.h = 11 * pwindow->prev->prev->size.h + adj_size(2)
570 + 2 * cma->adv->scroll->up_left_button->size.h;
571 cma->adv->scroll->up_left_button->size.w = area.w;
572 cma->adv->scroll->down_right_button->size.w = area.w;
573 }
574
575 /* ----------------------------------- */
576
577 resize_window(pwindow, NULL, NULL,
578 (pwindow->size.w - pwindow->area.w) + area.w,
579 (pwindow->size.h - pwindow->area.h) + area.h);
580
581 area = pwindow->area;
582
583 widget_set_position(pwindow,
584 button->size.x - (pwindow->size.w / 2),
585 button->size.y - pwindow->size.h);
586
587 /* exit button */
588 buf = pwindow->prev;
589 buf->size.x = area.x + area.w - buf->size.w - 1;
590 buf->size.y = pwindow->size.y + adj_size(2);
591
592 buf = buf->prev;
593 hh = (cma->adv->scroll ? cma->adv->scroll->up_left_button->size.h + 1 : 0);
594 setup_vertical_widgets_position(1, area.x + 1,
595 area.y + 1 + hh, area.w - 1, 0,
596 cma->adv->begin_active_widget_list, buf);
597
598 if (cma->adv->scroll) {
599 cma->adv->scroll->up_left_button->size.x = area.x;
600 cma->adv->scroll->up_left_button->size.y = area.y;
601 cma->adv->scroll->down_right_button->size.x = area.x;
602 cma->adv->scroll->down_right_button->size.y =
603 area.y + area.h - cma->adv->scroll->down_right_button->size.h;
604 }
605
606 /* ==================================================== */
607 /* redraw */
608 redraw_group(cma->adv->begin_widget_list, pwindow, 0);
609
610 widget_flush(pwindow);
611}
612
613/**********************************************************************/
616 static int load_cma_callback(struct widget *pwidget)
617{
618 if (PRESSED_EVENT(main_data.event)) {
619 popup_load_del_presets_dialog(TRUE, pwidget);
620 }
621
622 return -1;
623}
624
625/**********************************************************************/
628 static int del_cma_callback(struct widget *pwidget)
629{
630 if (PRESSED_EVENT(main_data.event)) {
631 popup_load_del_presets_dialog(FALSE, pwidget);
632 }
633
634 return -1;
635}
636
637/* ================================================== */
638
639/**********************************************************************/
643 static int run_cma_callback(struct widget *pwidget)
644{
645 if (PRESSED_EVENT(main_data.event)) {
646 cma_put_city_under_agent(cma->pcity, &cma->edited_cm_parm);
647 update_city_cma_dialog();
648 }
649
650 return -1;
651}
652
653/**********************************************************************/
656 static int run_cma_once_callback(struct widget *pwidget)
657{
658 if (PRESSED_EVENT(main_data.event)) {
659 struct cm_result *result;
660
661 update_city_cma_dialog();
662 /* fill in result label */
663 result = cm_result_new(cma->pcity);
664 cm_query_result(cma->pcity, &cma->edited_cm_parm, result, FALSE);
665 cma_apply_result(cma->pcity, result);
666 cm_result_destroy(result);
667 }
668
669 return -1;
670}
671
672/**********************************************************************/
675 static int stop_cma_callback(struct widget *pwidget)
676{
677 if (PRESSED_EVENT(main_data.event)) {
678 cma_release_city(cma->pcity);
679 update_city_cma_dialog();
680 }
681
682 return -1;
683}
684
685/* ===================================================================== */
686
687/**********************************************************************/
690 static void set_cma_hscrollbars(void)
691{
692 struct widget *pbuf;
693 char cbuf[4];
694
695 if (!cma) {
696 return;
697 }
698
699 /* exit button */
700 pbuf = cma->dlg->end_widget_list->prev;
701 output_type_iterate(i) {
702 /* min label */
703 pbuf = pbuf->prev;
704 fc_snprintf(cbuf, sizeof(cbuf), "%d", *(int *)pbuf->prev->data.ptr);
705 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
706
707 /* min scrollbar */
708 pbuf = pbuf->prev;
709 pbuf->size.x = pbuf->next->size.x
710 + pbuf->next->size.w + adj_size(5) + adj_size(20) + *(int *)pbuf->data.ptr;
711
712 /* factor label */
713 pbuf = pbuf->prev;
714 fc_snprintf(cbuf, sizeof(cbuf), "%d", *(int *)pbuf->prev->data.ptr);
715 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
716
717 /* factor scrollbar*/
718 pbuf = pbuf->prev;
719 pbuf->size.x = pbuf->next->size.x
720 + pbuf->next->size.w + adj_size(5) + *(int *)pbuf->data.ptr - 1;
721 } output_type_iterate_end;
722
723 /* happy factor label */
724 pbuf = pbuf->prev;
725 fc_snprintf(cbuf, sizeof(cbuf), "%d", *(int *)pbuf->prev->data.ptr);
726 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
727
728 /* happy factor scrollbar */
729 pbuf = pbuf->prev;
730 pbuf->size.x = pbuf->next->size.x
731 + pbuf->next->size.w + adj_size(5) + *(int *)pbuf->data.ptr - 1;
732}
733
734/**********************************************************************/
737 void update_city_cma_dialog(void)
738{
739 SDL_Color bg_color = {255, 255, 255, 136};
740 int count, step, i;
741 struct widget *buf = cma->dlg->end_widget_list; /* pwindow */
742 SDL_Surface *text;
743 utf8_str *pstr;
744 SDL_Rect dst;
745 bool cma_presets_exist = cmafec_preset_num() > 0;
746 bool client_under_control = can_client_issue_orders();
747 bool controlled = cma_is_city_under_agent(cma->pcity, NULL);
748 struct cm_result *result = cm_result_new(cma->pcity);
749
750 /* redraw window background and exit button */
751 redraw_group(buf->prev, buf, 0);
752
753 /* fill in result label */
754 cm_result_from_main_map(result, cma->pcity);
755
756 if (result->found_a_valid) {
757 /* redraw Citizens */
758 count = city_size_get(cma->pcity);
759
760 text = get_tax_surface(O_LUXURY);
761 step = (buf->size.w - adj_size(20)) / text->w;
762 if (count > step) {
763 step = (buf->size.w - adj_size(20) - text->w) / (count - 1);
764 } else {
765 step = text->w;
766 }
767
768 dst.y = buf->area.y + adj_size(4);
769 dst.x = buf->area.x + adj_size(7);
770
771 for (i = 0;
772 i < count - (result->specialists[SP_ELVIS]
773 + result->specialists[SP_SCIENTIST]
774 + result->specialists[SP_TAXMAN]); i++) {
775 text = adj_surf(get_citizen_surface(CITIZEN_CONTENT, i));
776 alphablit(text, NULL, buf->dst->surface, &dst, 255);
777 dst.x += step;
778 }
779
780 text = get_tax_surface(O_LUXURY);
781 for (i = 0; i < result->specialists[SP_ELVIS]; i++) {
782 alphablit(text, NULL, buf->dst->surface, &dst, 255);
783 dst.x += step;
784 }
785
786 text = get_tax_surface(O_GOLD);
787 for (i = 0; i < result->specialists[SP_TAXMAN]; i++) {
788 alphablit(text, NULL, buf->dst->surface, &dst, 255);
789 dst.x += step;
790 }
791
792 text = get_tax_surface(O_SCIENCE);
793 for (i = 0; i < result->specialists[SP_SCIENTIST]; i++) {
794 alphablit(text, NULL, buf->dst->surface, &dst, 255);
795 dst.x += step;
796 }
797 }
798
799 /* Create result text surface */
800 pstr = create_utf8_from_char_fonto(cmafec_get_result_descr(cma->pcity, result,
801 &cma->edited_cm_parm),
802 FONTO_ATTENTION);
803
804 text = create_text_surf_from_utf8(pstr);
805 FREEUTF8STR(pstr);
806
807 /* Fill result text background */
808 dst.x = buf->area.x + adj_size(7);
809 dst.y = buf->area.y + adj_size(186);
810 dst.w = text->w + adj_size(10);
811 dst.h = text->h + adj_size(10);
812 fill_rect_alpha(buf->dst->surface, &dst, &bg_color);
813
814 create_frame(buf->dst->surface,
815 dst.x, dst.y, dst.x + dst.w - 1, dst.y + dst.h - 1,
816 get_theme_color(COLOR_THEME_CMA_FRAME));
817
818 dst.x += adj_size(5);
819 dst.y += adj_size(5);
820 alphablit(text, NULL, buf->dst->surface, &dst, 255);
821 FREESURFACE(text);
822
823 /* Happy factor scrollbar */
824 buf = cma->dlg->begin_widget_list->next->next->next->next->next->next->next;
825 if (client_under_control && get_checkbox_state(buf->prev)) {
826 set_wstate(buf, FC_WS_NORMAL);
827 } else {
828 set_wstate(buf, FC_WS_DISABLED);
829 }
830
831 /* Save as ... */
832 buf = buf->prev->prev;
833 if (client_under_control) {
834 set_wstate(buf, FC_WS_NORMAL);
835 } else {
836 set_wstate(buf, FC_WS_DISABLED);
837 }
838
839 /* Load */
840 buf = buf->prev;
841 if (cma_presets_exist && client_under_control) {
842 set_wstate(buf, FC_WS_NORMAL);
843 } else {
844 set_wstate(buf, FC_WS_DISABLED);
845 }
846
847 /* Del */
848 buf = buf->prev;
849 if (cma_presets_exist && client_under_control) {
850 set_wstate(buf, FC_WS_NORMAL);
851 } else {
852 set_wstate(buf, FC_WS_DISABLED);
853 }
854
855 /* Run */
856 buf = buf->prev;
857 if (client_under_control && result->found_a_valid && !controlled) {
858 set_wstate(buf, FC_WS_NORMAL);
859 } else {
860 set_wstate(buf, FC_WS_DISABLED);
861 }
862
863 /* Run once */
864 buf = buf->prev;
865 if (client_under_control && result->found_a_valid && !controlled) {
866 set_wstate(buf, FC_WS_NORMAL);
867 } else {
868 set_wstate(buf, FC_WS_DISABLED);
869 }
870
871 /* Stop */
872 buf = buf->prev;
873 if (client_under_control && controlled) {
874 set_wstate(buf, FC_WS_NORMAL);
875 } else {
876 set_wstate(buf, FC_WS_DISABLED);
877 }
878
879 /* redraw rest widgets */
880 redraw_group(cma->dlg->begin_widget_list,
881 cma->dlg->end_widget_list->prev->prev, 0);
882
883 widget_flush(cma->dlg->end_widget_list);
884
885 cm_result_destroy(result);
886}
887
888/**********************************************************************/
891 void popup_city_cma_dialog(struct city *pcity)
892{
893 SDL_Color bg_color = {255, 255, 255, 136};
894
895 struct widget *pwindow, *buf;
896 SDL_Surface *logo, *text[O_LAST + 1], *minimal, *factor;
897 SDL_Surface *pcity_map;
898 utf8_str *pstr;
899 char cbuf[128];
900 int w, text_w, x, cs;
901 SDL_Rect dst, area;
902
903 if (cma) {
904 return;
905 }
906
907 cma = fc_calloc(1, sizeof(struct cma_dialog));
908 cma->pcity = pcity;
909 cma->dlg = fc_calloc(1, sizeof(struct small_dialog));
910 cma->adv = NULL;
911 pcity_map = get_scaled_city_map(pcity);
912
913 cmafec_get_fe_parameter(pcity, &cma->edited_cm_parm);
914
915 /* --------------------------- */
916
917 fc_snprintf(cbuf, sizeof(cbuf),
918 _("City of %s (Population %s citizens) : %s"),
919 city_name_get(pcity),
920 population_to_text(city_population(pcity)),
921 _("Citizen Governor"));
922
923 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
924 pstr->style |= TTF_STYLE_BOLD;
925
926 pwindow = create_window_skeleton(NULL, pstr, 0);
927
928 pwindow->action = cma_dlg_callback;
929 set_wstate(pwindow, FC_WS_NORMAL);
930 add_to_gui_list(ID_WINDOW, pwindow);
931 cma->dlg->end_widget_list = pwindow;
932
933 area = pwindow->area;
934
935 /* ---------- */
936 /* Create exit button */
937 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
938 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
939 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
940 FONTO_ATTENTION);
941 buf->action = exit_cma_dialog_callback;
942 set_wstate(buf, FC_WS_NORMAL);
943 buf->key = SDLK_ESCAPE;
944 area.w += (buf->size.w + adj_size(10));
945
946 add_to_gui_list(ID_BUTTON, buf);
947
948 pstr = create_utf8_str_fonto(NULL, 0, FONTO_ATTENTION);
949 text_w = 0;
950
951 copy_chars_to_utf8_str(pstr, _("Minimal Surplus"));
952 minimal = create_text_surf_from_utf8(pstr);
953
954 copy_chars_to_utf8_str(pstr, _("Factor"));
955 factor = create_text_surf_from_utf8(pstr);
956
957 /* ---------- */
958 output_type_iterate(i) {
959 copy_chars_to_utf8_str(pstr, get_output_name(i));
960 text[i] = create_text_surf_from_utf8(pstr);
961 text_w = MAX(text_w, text[i]->w);
962
963 /* Minimal label */
964 buf = create_iconlabel(NULL, pwindow->dst,
965 create_utf8_from_char_fonto("999", FONTO_DEFAULT),
966 (WF_FREE_STRING | WF_RESTORE_BACKGROUND));
967
968 add_to_gui_list(ID_LABEL, buf);
969
970 /* Minimal scrollbar */
971 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
972 (WF_RESTORE_BACKGROUND));
973
974 buf->action = min_horiz_cma_callback;
975 buf->data.ptr = &cma->edited_cm_parm.minimal_surplus[i];
976
977 set_wstate(buf, FC_WS_NORMAL);
978
979 add_to_gui_list(ID_SCROLLBAR, buf);
980
981 /* Factor label */
982 buf = create_iconlabel(NULL, pwindow->dst,
983 create_utf8_from_char_fonto("999", FONTO_DEFAULT),
984 (WF_FREE_STRING | WF_RESTORE_BACKGROUND));
985
986 add_to_gui_list(ID_LABEL, buf);
987
988 /* Factor scrollbar */
989 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
990 (WF_RESTORE_BACKGROUND));
991
992 buf->action = factor_horiz_cma_callback;
993 buf->data.ptr = &cma->edited_cm_parm.factor[i];
994
995 set_wstate(buf, FC_WS_NORMAL);
996
997 add_to_gui_list(ID_SCROLLBAR, buf);
998 } output_type_iterate_end;
999
1000 copy_chars_to_utf8_str(pstr, _("Celebrate"));
1001 text[O_LAST] = create_text_surf_from_utf8(pstr);
1002 FREEUTF8STR(pstr);
1003
1004 /* Happy factor label */
1005 buf = create_iconlabel(NULL, pwindow->dst,
1006 create_utf8_from_char_fonto("999", FONTO_DEFAULT),
1007 (WF_FREE_STRING | WF_RESTORE_BACKGROUND));
1008
1009 add_to_gui_list(ID_LABEL, buf);
1010
1011 /* Happy factor scrollbar */
1012 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
1013 (WF_RESTORE_BACKGROUND));
1014
1015 buf->action = factor_horiz_cma_callback;
1016 buf->data.ptr = &cma->edited_cm_parm.happy_factor;
1017
1018 set_wstate(buf, FC_WS_NORMAL);
1019
1020 add_to_gui_list(ID_SCROLLBAR, buf);
1021
1022 /* celebrating */
1023 buf = create_checkbox(pwindow->dst,
1024 cma->edited_cm_parm.require_happy,
1025 WF_RESTORE_BACKGROUND);
1026
1027 set_wstate(buf, FC_WS_NORMAL);
1028 buf->action = toggle_cma_celebrating_callback;
1029 add_to_gui_list(ID_CHECKBOX, buf);
1030
1031 /* Save as ... */
1032 buf = create_themeicon(current_theme->save_icon, pwindow->dst,
1033 WF_RESTORE_BACKGROUND |WF_WIDGET_HAS_INFO_LABEL);
1034 buf->action = save_cma_callback;
1035 buf->info_label = create_utf8_from_char_fonto(_("Save settings as..."),
1036 FONTO_DEFAULT);
1037
1038 add_to_gui_list(ID_ICON, buf);
1039
1040 /* Load settings */
1041 buf = create_themeicon(current_theme->load_icon, pwindow->dst,
1042 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1043 buf->action = load_cma_callback;
1044 buf->info_label = create_utf8_from_char_fonto(_("Load settings"),
1045 FONTO_DEFAULT);
1046
1047 add_to_gui_list(ID_ICON, buf);
1048
1049 /* Del settings */
1050 buf = create_themeicon(current_theme->delete_icon, pwindow->dst,
1051 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1052 buf->action = del_cma_callback;
1053 buf->info_label = create_utf8_from_char_fonto(_("Delete settings"),
1054 FONTO_DEFAULT);
1055
1056 add_to_gui_list(ID_ICON, buf);
1057
1058 /* Run cma */
1059 buf = create_themeicon(current_theme->qprod_icon, pwindow->dst,
1060 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1061 buf->action = run_cma_callback;
1062 buf->info_label = create_utf8_from_char_fonto(_("Control city"), FONTO_DEFAULT);
1063
1064 add_to_gui_list(ID_ICON, buf);
1065
1066 /* Run cma once */
1067 buf = create_themeicon(current_theme->find_city_icon, pwindow->dst,
1068 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1069 buf->action = run_cma_once_callback;
1070 buf->info_label = create_utf8_from_char_fonto(_("Apply once"), FONTO_DEFAULT);
1071
1072 add_to_gui_list(ID_ICON, buf);
1073
1074 /* Del settings */
1075 buf = create_themeicon(current_theme->support_icon, pwindow->dst,
1076 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1077 buf->action = stop_cma_callback;
1078 buf->info_label = create_utf8_from_char_fonto(_("Release city"), FONTO_DEFAULT);
1079
1080 add_to_gui_list(ID_ICON, buf);
1081
1082 /* -------------------------------- */
1083 cma->dlg->begin_widget_list = buf;
1084
1085#ifdef SMALL_SCREEN
1086 area.w = MAX(pcity_map->w + adj_size(220) + text_w + adj_size(10) +
1087 (pwindow->prev->prev->size.w + adj_size(5 + 70 + 5) +
1088 pwindow->prev->prev->size.w + adj_size(5 + 55 + 15)), area.w);
1089 area.h = adj_size(390) - (pwindow->size.w - pwindow->area.w);
1090#else /* SMALL_SCREEN */
1091 area.w = MAX(pcity_map->w + adj_size(150) + text_w + adj_size(10) +
1092 (pwindow->prev->prev->size.w + adj_size(5 + 70 + 5) +
1093 pwindow->prev->prev->size.w + adj_size(5 + 55 + 15)), area.w);
1094 area.h = adj_size(360) - (pwindow->size.w - pwindow->area.w);
1095#endif /* SMALL_SCREEN */
1096
1097 logo = theme_get_background(active_theme, BACKGROUND_CITYGOVDLG);
1098 if (resize_window(pwindow, logo, NULL,
1099 (pwindow->size.w - pwindow->area.w) + area.w,
1100 (pwindow->size.w - pwindow->area.w) + area.h)) {
1101 FREESURFACE(logo);
1102 }
1103
1104#if 0
1105 logo = SDL_DisplayFormat(pwindow->theme);
1106 FREESURFACE(pwindow->theme);
1107 pwindow->theme = logo;
1108#endif /* 0 */
1109
1110 area = pwindow->area;
1111
1112 widget_set_position(pwindow,
1113 (main_window_width() - pwindow->size.w) / 2,
1114 (main_window_height() - pwindow->size.h) / 2);
1115
1116 /* exit button */
1117 buf = pwindow->prev;
1118 buf->size.x = area.x + area.w - buf->size.w - 1;
1119 buf->size.y = pwindow->size.y + adj_size(2);
1120
1121 /* ---------- */
1122 dst.x = pcity_map->w + adj_size(80) +
1123 (pwindow->size.w - (pcity_map->w + adj_size(40)) -
1124 (text_w + adj_size(10) + pwindow->prev->prev->size.w + adj_size(5 + 70 + 5) +
1125 pwindow->prev->prev->size.w + adj_size(5 + 55))) / 2;
1126
1127#ifdef SMALL_SCREEN
1128 dst.x += 22;
1129#endif
1130
1131 dst.y = adj_size(75);
1132
1133 x = area.x = dst.x - adj_size(10);
1134 area.y = dst.y - adj_size(20);
1135 w = area.w = adj_size(10) + text_w + adj_size(10) + pwindow->prev->prev->size.w + adj_size(5 + 70 + 5)
1136 + pwindow->prev->prev->size.w + adj_size(5 + 55 + 10);
1137 area.h = (O_LAST + 1) * (text[0]->h + adj_size(6)) + adj_size(20);
1138 fill_rect_alpha(pwindow->theme, &area, &bg_color);
1139
1140 create_frame(pwindow->theme,
1141 area.x, area.y, area.w - 1, area.h - 1,
1142 get_theme_color(COLOR_THEME_CMA_FRAME));
1143
1144 area.x = dst.x + text_w + adj_size(10);
1145 alphablit(minimal, NULL, pwindow->theme, &area, 255);
1146 area.x += minimal->w + adj_size(10);
1147 FREESURFACE(minimal);
1148
1149 alphablit(factor, NULL, pwindow->theme, &area, 255);
1150 FREESURFACE(factor);
1151
1152 area.x = pwindow->area.x + adj_size(22);
1153 area.y = pwindow->area.y + adj_size(31);
1154 alphablit(pcity_map, NULL, pwindow->theme, &area, 255);
1155 FREESURFACE(pcity_map);
1156
1157 output_type_iterate(i) {
1158 /* min label */
1159 buf = buf->prev;
1160 buf->size.x = pwindow->size.x + dst.x + text_w + adj_size(10);
1161 buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
1162
1163 /* min sb */
1164 buf = buf->prev;
1165 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
1166 buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
1167
1168 area.x = buf->size.x - pwindow->size.x - adj_size(2);
1169 area.y = buf->size.y - pwindow->size.y;
1170 area.w = adj_size(74);
1171 area.h = buf->size.h;
1172 fill_rect_alpha(pwindow->theme, &area, &bg_color);
1173
1174 create_frame(pwindow->theme,
1175 area.x, area.y, area.w - 1, area.h - 1,
1176 get_theme_color(COLOR_THEME_CMA_FRAME));
1177
1178 /* factor label */
1179 buf = buf->prev;
1180 buf->size.x = buf->next->size.x + adj_size(75);
1181 buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
1182
1183 /* factor sb */
1184 buf = buf->prev;
1185 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
1186 buf->size.y = pwindow->size.y + dst.y + (text[i]->h - buf->size.h) / 2;
1187
1188 area.x = buf->size.x - pwindow->size.x - adj_size(2);
1189 area.y = buf->size.y - pwindow->size.y;
1190 area.w = adj_size(58);
1191 area.h = buf->size.h;
1192 fill_rect_alpha(pwindow->theme, &area, &bg_color);
1193
1194 create_frame(pwindow->theme,
1195 area.x, area.y, area.w - 1, area.h - 1,
1196 get_theme_color(COLOR_THEME_CMA_FRAME));
1197
1198 alphablit(text[i], NULL, pwindow->theme, &dst, 255);
1199 dst.y += text[i]->h + adj_size(6);
1200 FREESURFACE(text[i]);
1201 } output_type_iterate_end;
1202
1203 /* happy factor label */
1204 buf = buf->prev;
1205 buf->size.x = buf->next->next->size.x;
1206 buf->size.y = pwindow->size.y + dst.y + (text[O_LAST]->h - buf->size.h) / 2;
1207
1208 /* happy factor sb */
1209 buf = buf->prev;
1210 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(5);
1211 buf->size.y = pwindow->size.y + dst.y + (text[O_LAST]->h - buf->size.h) / 2;
1212
1213 area.x = buf->size.x - pwindow->size.x - adj_size(2);
1214 area.y = buf->size.y - pwindow->size.y;
1215 area.w = adj_size(58);
1216 area.h = buf->size.h;
1217 fill_rect_alpha(pwindow->theme, &area, &bg_color);
1218
1219 create_frame(pwindow->theme,
1220 area.x, area.y, area.w - 1, area.h - 1,
1221 get_theme_color(COLOR_THEME_CMA_FRAME));
1222
1223 /* Celebrate cbox */
1224 buf = buf->prev;
1225 buf->size.x = pwindow->size.x + dst.x + adj_size(10);
1226 buf->size.y = pwindow->size.y + dst.y;
1227
1228 /* Celebrate static text */
1229 dst.x += (adj_size(10) + buf->size.w + adj_size(5));
1230 dst.y += (buf->size.h - text[O_LAST]->h) / 2;
1231 alphablit(text[O_LAST], NULL, pwindow->theme, &dst, 255);
1232 FREESURFACE(text[O_LAST]);
1233 /* ------------------------ */
1234
1235 /* Save as */
1236 buf = buf->prev;
1237 buf->size.x = pwindow->size.x + x + (w - (buf->size.w + adj_size(6)) * 6) / 2;
1238 buf->size.y = pwindow->size.y + pwindow->size.h - buf->size.h * 2 - adj_size(10);
1239
1240 area.x = x;
1241 area.y = buf->size.y - pwindow->size.y - adj_size(5);
1242 area.w = w;
1243 area.h = buf->size.h + adj_size(10);
1244 fill_rect_alpha(pwindow->theme, &area, &bg_color);
1245
1246 create_frame(pwindow->theme,
1247 area.x, area.y, area.w - 1, area.h - 1,
1248 get_theme_color(COLOR_THEME_CMA_FRAME));
1249
1250 /* Load */
1251 buf = buf->prev;
1252 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(4);
1253 buf->size.y = buf->next->size.y;
1254
1255 /* Del */
1256 buf = buf->prev;
1257 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(4);
1258 buf->size.y = buf->next->size.y;
1259
1260 /* Run */
1261 buf = buf->prev;
1262 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(4);
1263 buf->size.y = buf->next->size.y;
1264
1265 /* Run one time */
1266 buf = buf->prev;
1267 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(4);
1268 buf->size.y = buf->next->size.y;
1269
1270 /* Del */
1271 buf = buf->prev;
1272 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(4);
1273 buf->size.y = buf->next->size.y;
1274
1275 /* ------------------------ */
1276 /* Check if Citizen Icons style was loaded */
1277 cs = style_of_city(cma->pcity);
1278
1279 if (cs != icons->style) {
1280 reload_citizens_icons(cs);
1281 }
1282
1283 set_cma_hscrollbars();
1284 update_city_cma_dialog();
1285}
1286
1287/**********************************************************************/
1290 void popdown_city_cma_dialog(void)
1291{
1292 if (cma) {
1293 popdown_window_group_dialog(cma->dlg->begin_widget_list,
1294 cma->dlg->end_widget_list);
1295 FC_FREE(cma->dlg);
1296 if (cma->adv) {
1297 del_group_of_widgets_from_gui_list(cma->adv->begin_widget_list,
1298 cma->adv->end_widget_list);
1299 FC_FREE(cma->adv->scroll);
1300 FC_FREE(cma->adv);
1301 }
1302 if (city_dialog_is_open(cma->pcity)) {
1303 /* enable city dlg */
1304 enable_city_dlg_widgets();
1305 refresh_city_dialog(cma->pcity);
1306 }
1307
1308 city_report_dialog_update();
1309 FC_FREE(cma);
1310 }
1311}
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1128
city_population
int city_population(const struct city *pcity)
Definition city.c:1182
get_output_name
const char * get_output_name(Output_type_id output)
Definition city.c:628
city_size_get
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
CITIZEN_CONTENT
@ CITIZEN_CONTENT
Definition city.h:269
output_type_iterate
#define output_type_iterate(output)
Definition city.h:833
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:839
refresh_city_dialog
void refresh_city_dialog(struct city *pcity)
Definition update_queue.c:632
city_report_dialog_update
void city_report_dialog_update(void)
Definition update_queue.c:666
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
client_main.h
cm_copy_parameter
void cm_copy_parameter(struct cm_parameter *dest, const struct cm_parameter *const src)
Definition cm.c:2171
cm_result_new
struct cm_result * cm_result_new(struct city *pcity)
Definition cm.c:345
cm_result_from_main_map
void cm_result_from_main_map(struct cm_result *result, const struct city *pcity)
Definition cm.c:2258
cm_result_destroy
void cm_result_destroy(struct cm_result *result)
Definition cm.c:368
cm_query_result
void cm_query_result(struct city *pcity, const struct cm_parameter *param, struct cm_result *result, bool negative_ok)
Definition cm.c:2120
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_put_city_under_agent
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_core.c:523
cma_release_city
void cma_release_city(struct city *pcity)
Definition cma_core.c:541
cma_apply_result
bool cma_apply_result(struct city *pcity, const struct cm_result *result)
Definition cma_core.c:509
cmafec_set_fe_parameter
void cmafec_set_fe_parameter(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_fec.c:105
cmafec_preset_get_descr
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
cmafec_get_result_descr
const char * cmafec_get_result_descr(struct city *pcity, const struct cm_result *result, const struct cm_parameter *const parameter)
Definition cma_fec.c:322
cmafec_preset_get_parameter
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
cmafec_preset_add
void cmafec_preset_add(const char *descr_name, struct cm_parameter *pparam)
Definition cma_fec.c:136
cmafec_preset_remove
void cmafec_preset_remove(int idx)
Definition cma_fec.c:153
cmafec_preset_num
int cmafec_preset_num(void)
Definition cma_fec.c:213
cmafec_get_fe_parameter
void cmafec_get_fe_parameter(struct city *pcity, struct cm_parameter *dest)
Definition cma_fec.c:115
cma_fec.h
incite_cost
char * incite_cost
Definition comments.c:74
current_theme
QString current_theme
Definition fc_client.cpp:65
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
O_LAST
@ O_LAST
Definition fc_types.h:101
fcintl.h
_
#define _(String)
Definition fcintl.h:67
population_to_text
const char * population_to_text(int thousand_citizen)
Definition game.c:732
game.h
city_dialog_is_open
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:579
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
enable_city_dlg_widgets
void enable_city_dlg_widgets(void)
Definition citydlg.c:1532
specialist_type
specialist_type
Definition citydlg.c:109
get_scaled_city_map
SDL_Surface * get_scaled_city_map(struct city *pcity)
Definition citydlg.c:1617
save_cma_callback
static int save_cma_callback(struct widget *pwidget)
Definition cma_fe.c:304
ld_cma_callback
static int ld_cma_callback(struct widget *pwidget)
Definition cma_fe.c:440
load_cma_callback
static int load_cma_callback(struct widget *pwidget)
Definition cma_fe.c:616
set_cma_hscrollbars
static void set_cma_hscrollbars(void)
Definition cma_fe.c:690
cma
static struct cma_dialog * cma
toggle_cma_celebrating_callback
static int toggle_cma_celebrating_callback(struct widget *pwidget)
Definition cma_fe.c:235
save_cma_window_callback
static int save_cma_window_callback(struct widget *pwindow)
Definition cma_fe.c:252
scroll_mouse_button_up
static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event, void *data)
Definition cma_fe.c:94
exit_cma_dialog_callback
static int exit_cma_dialog_callback(struct widget *pwidget)
Definition cma_fe.c:81
run_cma_once_callback
static int run_cma_once_callback(struct widget *pwidget)
Definition cma_fe.c:656
cma_dlg_callback
static int cma_dlg_callback(struct widget *pwindow)
Definition cma_fe.c:73
run_cma_callback
static int run_cma_callback(struct widget *pwidget)
Definition cma_fe.c:643
SP_SCIENTIST
@ SP_SCIENTIST
Definition cma_fe.c:63
SP_LAST
@ SP_LAST
Definition cma_fe.c:63
SP_ELVIS
@ SP_ELVIS
Definition cma_fe.c:63
SP_TAXMAN
@ SP_TAXMAN
Definition cma_fe.c:63
min_horiz_cma_callback
static int min_horiz_cma_callback(struct widget *pwidget)
Definition cma_fe.c:155
update_city_cma_dialog
void update_city_cma_dialog(void)
Definition cma_fe.c:737
scroll_mouse_motion_handler
static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition cma_fe.c:103
del_cma_callback
static int del_cma_callback(struct widget *pwidget)
Definition cma_fe.c:628
popup_city_cma_dialog
void popup_city_cma_dialog(struct city *pcity)
Definition cma_fe.c:891
popdown_city_cma_dialog
void popdown_city_cma_dialog(void)
Definition cma_fe.c:1290
ok_save_cma_callback
static int ok_save_cma_callback(struct widget *pwidget)
Definition cma_fe.c:260
popup_load_del_presets_dialog
static void popup_load_del_presets_dialog(bool load, struct widget *button)
Definition cma_fe.c:474
cancel_sld_cma_callback
static int cancel_sld_cma_callback(struct widget *pwidget)
Definition cma_fe.c:286
stop_cma_callback
static int stop_cma_callback(struct widget *pwidget)
Definition cma_fe.c:675
factor_horiz_cma_callback
static int factor_horiz_cma_callback(struct widget *pwidget)
Definition cma_fe.c:195
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
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
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
adj_surf
#define adj_surf(surf)
Definition graphics.h:200
ID_ERROR
@ ID_ERROR
Definition gui_id.h:26
ID_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_EDIT
@ ID_EDIT
Definition gui_id.h:34
ID_SCROLLBAR
@ ID_SCROLLBAR
Definition gui_id.h:32
ID_ICON
@ ID_ICON
Definition gui_id.h:33
ID_LABEL
@ ID_LABEL
Definition gui_id.h:27
ID_CHECKBOX
@ ID_CHECKBOX
Definition gui_id.h:35
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
FilterMouseMotionEvents
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:577
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.c:101
gui_event_loop
Uint16 gui_event_loop(void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_Keysym key, void *data), Uint16(*key_up_handler)(SDL_Keysym key, void *data), Uint16(*textinput_handler)(char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:598
MOVE_STEP_X
int MOVE_STEP_X
Definition gui_main.c:100
selected_widget
struct widget * selected_widget
Definition widget.c:48
adj_size
#define adj_size(size)
Definition gui_main.h:141
DEFAULT_MOVE_STEP
#define DEFAULT_MOVE_STEP
Definition gui_main.h:113
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
create_utf8_str_fonto
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
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
reload_citizens_icons
void reload_citizens_icons(int style)
Definition gui_tilespec.c:126
get_citizen_surface
static SDL_Surface * get_citizen_surface(enum citizen_category type, int citizen_index)
Definition gui_tilespec.h:218
get_tax_surface
static SDL_Surface * get_tax_surface(Output_type_id otype)
Definition gui_tilespec.h:269
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_CITYGOVDLG
@ BACKGROUND_CITYGOVDLG
Definition themebackgrounds.h:31
COLOR_THEME_BACKGROUND
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
COLOR_THEME_CMA_FRAME
@ COLOR_THEME_CMA_FRAME
Definition themecolors.h:74
COLOR_THEME_CMA_TEXT
@ COLOR_THEME_CMA_TEXT
Definition themecolors.h:75
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
del_group_of_widgets_from_gui_list
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:863
refresh_widget_background
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
setup_vertical_widgets_position
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
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
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_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
FC_WS_SELECTED
@ FC_WS_SELECTED
Definition widget.h:97
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
widget_flush
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
get_wflags
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
widget_undraw
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
WF_WIDGET_HAS_INFO_LABEL
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
WF_FREE_STRING
@ WF_FREE_STRING
Definition widget.h:76
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
WF_DRAW_TEXT_LABEL_WITH_SPACE
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
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
create_themeicon_button_from_chars_fonto
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
Definition widget_button.h:36
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_edit
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
Definition widget_edit.c:350
create_themeicon
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:212
create_iconlabel
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_label.c:215
create_horizontal
struct widget * create_horizontal(SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
Definition widget_scrollbar.c:296
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
cma_fe.h
gui_id.h
gui_tilespec.h
themespec.h
widget.h
citydlg.h
cityrep.h
colors.h
graphics.h
gui_main.h
mapview.h
sprite.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
MAX
#define MAX(x, y)
Definition shared.h:54
step
int step
Definition specpq.h:92
x
struct sprite int x
Definition sprite_g.h:31
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::style
int style
Definition gui_tilespec.h:149
city
Definition city.h:320
cm_parameter
Definition cm.h:40
cm_parameter::factor
int factor[O_LAST]
Definition cm.h:47
cm_parameter::require_happy
bool require_happy
Definition cm.h:43
cm_parameter::minimal_surplus
int minimal_surplus[O_LAST]
Definition cm.h:41
cm_parameter::happy_factor
int happy_factor
Definition cm.h:48
cm_result
Definition cm.h:52
cm_result::found_a_valid
bool found_a_valid
Definition cm.h:54
cm_result::specialists
citizens specialists[SP_MAX]
Definition cm.h:60
cma_dialog
Definition cma_fe.h:31
cma_dialog::dlg
struct small_dialog * dlg
Definition cma_fe.c:57
cma_dialog::adv
struct advanced_dialog * adv
Definition cma_fe.c:58
cma_dialog::edited_cm_parm
struct cm_parameter edited_cm_parm
Definition cma_fe.c:59
cma_dialog::pcity
struct city * pcity
Definition cma_fe.h:32
gui_layer::dest_rect
SDL_Rect dest_rect
Definition graphics.h:228
hmove
Definition cma_fe.c:50
hmove::base
int base
Definition cma_fe.c:52
hmove::max
int max
Definition cma_fe.c:52
hmove::min
int min
Definition cma_fe.c:52
hmove::pscroll_bar
struct widget * pscroll_bar
Definition cma_fe.c:51
scroll_bar::up_left_button
struct widget * up_left_button
Definition widget_scrollbar.h:21
scroll_bar::down_right_button
struct widget * down_right_button
Definition widget_scrollbar.h:23
sdl2_data::event
SDL_Event event
Definition graphics.h:217
small_dialog
Definition widget.h:174
small_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:175
small_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:176
utf8_str
Definition gui_string.h:52
utf8_str::text
char * text
Definition gui_string.h:60
widget
Definition widget.h:112
widget::ptr
void * ptr
Definition widget.h:133
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::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::id
Uint16 id
Definition widget.h:155
widget::size
SDL_Rect size
Definition widget.h:145
style_of_city
int style_of_city(const struct city *pcity)
Definition style.c:202
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47