Freeciv-3.1
Loading...
Searching...
No Matches
repodlgs.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 repodlgs.c - description
16 -------------------
17 begin : Nov 15 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29
30/* common */
31#include "game.h"
32#include "government.h"
33#include "research.h"
34#include "unitlist.h"
35
36/* client */
37#include "client_main.h"
38#include "text.h"
39
40/* gui-sdl2 */
41#include "cityrep.h"
42#include "colors.h"
43#include "dialogs.h"
44#include "graphics.h"
45#include "gui_id.h"
46#include "gui_main.h"
47#include "gui_tilespec.h"
48#include "helpdlg.h"
49#include "mapctrl.h"
50#include "mapview.h"
51#include "sprite.h"
52#include "themespec.h"
53#include "widget.h"
54
55#include "repodlgs.h"
56
57
58/* ===================================================================== */
59/* ======================== Active Units Report ======================== */
60/* ===================================================================== */
61static struct advanced_dialog *units_dlg = NULL;
62static struct small_dialog *units_upg_dlg = NULL;
63
70
71/**********************************************************************/
75 struct units_entry *total)
76{
77 int time_to_build;
78
79 memset(entries, '\0', U_LAST * sizeof(struct units_entry));
80 memset(total, '\0', sizeof(struct units_entry));
81 for (time_to_build = 0; time_to_build < U_LAST; time_to_build++) {
82 entries[time_to_build].soonest_completions = FC_INFINITY;
83 }
84
87
88 (entries[uti].active_count)++;
89 (total->active_count)++;
90 if (punit->homecity) {
92 entries[uti].upkeep[o] += punit->upkeep[o];
93 total->upkeep[o] += punit->upkeep[o];
95 }
97
99 if (VUT_UTYPE == pcity->production.kind) {
100 const struct unit_type *punittype = pcity->production.value.utype;
101 Unit_type_id uti = utype_index(punittype);
102 int num_units;
103
104 /* Account for build slots in city */
105 (void) city_production_build_units(pcity, TRUE, &num_units);
106 /* Unit is in progress even if it won't be done this turn */
107 num_units = MAX(num_units, 1);
108 (entries[uti].building_count) += num_units;
109 (total->building_count) += num_units;
110 entries[uti].soonest_completions =
111 MIN(entries[uti].soonest_completions,
113 }
115}
116
117/**********************************************************************/
120static int units_dialog_callback(struct widget *pwindow)
121{
124 }
125
126 return -1;
127}
128
129/* --------------------------------------------------------------- */
130
131/**********************************************************************/
134static int ok_upgrade_unit_window_callback(struct widget *pwidget)
135{
137 int ut1 = MAX_ID - pwidget->id;
138
139 /* popdown upgrade dlg */
143
145 }
146
147 return -1;
148}
149
150/**********************************************************************/
153static int upgrade_unit_window_callback(struct widget *pwindow)
154{
157 }
158
159 return -1;
160}
161
162/**********************************************************************/
165static int cancel_upgrade_unit_callback(struct widget *pwidget)
166{
168 if (units_upg_dlg) {
172 flush_dirty();
173 }
174 }
175
176 return -1;
177}
178
179/**********************************************************************/
182static int popup_upgrade_unit_callback(struct widget *pwidget)
183{
185 struct unit_type *ut1;
186 const struct unit_type *ut2;
187 int value;
188 char tBuf[128], cbuf[128];
189 struct widget *buf = NULL, *pwindow;
190 utf8_str *pstr;
191 SDL_Surface *text;
194
195 ut1 = utype_by_number(MAX_ID - pwidget->id);
196
197 if (units_upg_dlg) {
198 return 1;
199 }
200
201 set_wstate(pwidget, FC_WS_NORMAL);
203 widget_redraw(pwidget);
204 widget_mark_dirty(pwidget);
205
206 units_upg_dlg = fc_calloc(1, sizeof(struct small_dialog));
207
210
211 fc_snprintf(tBuf, ARRAY_SIZE(tBuf), PL_("Treasury contains %d gold.",
212 "Treasury contains %d gold.",
213 client_player()->economic.gold),
214 client_player()->economic.gold);
215
216 fc_snprintf(cbuf, sizeof(cbuf),
217 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
218 PL_("Upgrade as many %s to %s as possible for %d gold each?\n%s",
219 "Upgrade as many %s to %s as possible for %d gold each?\n%s",
220 value),
223 value, tBuf);
224
225 pstr = create_utf8_from_char_fonto(_("Upgrade Obsolete Units"),
227 pstr->style |= TTF_STYLE_BOLD;
228
229 pwindow = create_window_skeleton(NULL, pstr, 0);
230
231 pwindow->action = upgrade_unit_window_callback;
232 set_wstate(pwindow, FC_WS_NORMAL);
233
234 add_to_gui_list(ID_WINDOW, pwindow);
235
237
238 area = pwindow->area;
239
240 /* ============================================================= */
241
242 /* Create text label */
244 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
246
249
250 area.h += (text->h + adj_size(10));
251 area.w = MAX(area.w, text->w + adj_size(20));
252
253 /* Cancel button */
255 pwindow->dst, _("No"),
256 FONTO_ATTENTION, 0);
257
260
261 area.h += (buf->size.h + adj_size(20));
262
264
265 if (value <= client.conn.playing->economic.gold) {
267 pwindow->dst,
268 _("Yes"),
269 FONTO_ATTENTION, 0);
270
273
274 add_to_gui_list(pwidget->id, buf);
275 buf->size.w = MAX(buf->size.w, buf->next->size.w);
276 buf->next->size.w = buf->size.w;
277 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
278 } else {
279 area.w = MAX(area.w, buf->size.w + adj_size(20));
280 }
281 /* ============================================ */
282
284
286 (pwindow->size.w - pwindow->area.w) + area.w,
287 (pwindow->size.h - pwindow->area.h) + area.h);
288
289 widget_set_position(pwindow,
291 (units_dlg->end_widget_list->size.w - pwindow->size.w) / 2,
293 (units_dlg->end_widget_list->size.h - pwindow->size.h) / 2);
294
295 /* setup rest of widgets */
296 /* label */
297 dst.x = area.x + (area.w - text->w) / 2;
298 dst.y = area.y + adj_size(10);
299 alphablit(text, NULL, pwindow->theme, &dst, 255);
300 FREESURFACE(text);
301
302 /* cancel button */
303 buf = pwindow->prev;
304 buf->size.y = area.y + area.h - buf->size.h - adj_size(10);
305
306 if (value <= client.conn.playing->economic.gold) {
307 /* sell button */
308 buf = buf->prev;
309 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
310 buf->size.y = buf->next->size.y;
311
312 /* cancel button */
313 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
314 } else {
315 /* x position of cancel button */
316 buf->size.x = area.x + area.w - buf->size.w - adj_size(10);
317 }
318
319 /* ================================================== */
320 /* redraw */
322
323 widget_mark_dirty(pwindow);
324 flush_dirty();
325 }
326
327 return -1;
328}
329
330/**********************************************************************/
352
353/**********************************************************************/
357 struct units_entry *total)
358{
359 SDL_Color bg_color = {255, 255, 255, 136};
360 struct widget *buf = NULL;
361 struct widget *pwindow, *last;
362 utf8_str *pstr;
364 int w = 0 , count, ww, hh = 0, name_w = 0;
365 char cbuf[64];
367 bool upgrade = FALSE;
369
370 if (units_dlg) {
373 } else {
374 units_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
375 }
376
377 fc_snprintf(cbuf, sizeof(cbuf), _("active"));
379 pstr->style |= SF_CENTER;
381
382 fc_snprintf(cbuf, sizeof(cbuf), _("under\nconstruction"));
385
386 fc_snprintf(cbuf, sizeof(cbuf), _("soonest\ncompletion"));
389
390 fc_snprintf(cbuf, sizeof(cbuf), _("Total"));
393
394 fc_snprintf(cbuf, sizeof(cbuf), _("Units"));
397 name_w = text4->w;
399
400 /* --------------- */
402 pstr->style |= TTF_STYLE_BOLD;
403
404 pwindow = create_window_skeleton(NULL, pstr, 0);
405 set_wstate(pwindow, FC_WS_NORMAL);
406 pwindow->action = units_dialog_callback;
407
409
410 units_dlg->end_widget_list = pwindow;
411
412 area = pwindow->area;
413
414 /* ------------------------- */
415 /* Exit button */
416 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
418 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
422 buf->key = SDLK_ESCAPE;
423
425 /* ------------------------- */
426 /* Totals */
427 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->active_count);
428
430 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
431
432 buf = create_iconlabel(NULL, pwindow->dst, pstr,
434
435 area.h += buf->size.h;
436 buf->size.w = text1->w + adj_size(6);
438 /* ---------------------------------------------- */
439 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_SHIELD]);
440
442 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
443
445
446 buf->size.w = text1->w;
448 /* ---------------------------------------------- */
449 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_FOOD]);
450
452 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
453
455
456 buf->size.w = text1->w;
458 /* ---------------------------------------------- */
459 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_GOLD]);
460
462 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
463
465
466 buf->size.w = text1->w;
468 /* ---------------------------------------------- */
469 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->building_count);
470
472 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
473
474 buf = create_iconlabel(NULL, pwindow->dst, pstr,
476
477 buf->size.w = text2->w + adj_size(6);
479
480 /* ------------------------- */
481 last = buf;
482 count = 0;
484 if ((units[utype_index(i)].active_count > 0)
485 || (units[utype_index(i)].building_count > 0)) {
486 upgrade = (can_upgrade_unittype(client.conn.playing, i) != NULL);
487
488 /* Unit type icon */
490 pwindow->dst, NULL,
492 if (count > adj_size(72)) {
494 }
495 hh = buf->size.h;
497
498 /* Unit type name */
501 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
502 buf = create_iconlabel(NULL, pwindow->dst, pstr,
504 if (upgrade) {
505 buf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
508 } else {
509 buf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_UNITSREP_TEXT);
510 }
511 buf->string_utf8->style &= ~SF_CENTER;
512 if (count > adj_size(72)) {
514 }
515 hh = MAX(hh, buf->size.h);
516 name_w = MAX(buf->size.w, name_w);
518
519 /* Active */
520 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].active_count);
522 pstr->style |= SF_CENTER;
523 buf = create_iconlabel(NULL, pwindow->dst, pstr,
525 if (count > adj_size(72)) {
527 }
528 hh = MAX(hh, buf->size.h);
529 buf->size.w = text1->w + adj_size(6);
531
532 /* Shield upkeep */
533 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_SHIELD]);
535 pstr->style |= SF_CENTER;
536 buf = create_iconlabel(NULL, pwindow->dst, pstr,
538 if (count > adj_size(72)) {
540 }
541 hh = MAX(hh, buf->size.h);
542 buf->size.w = text1->w;
544
545 /* Food upkeep */
546 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_FOOD]);
548 pstr->style |= SF_CENTER;
549 buf = create_iconlabel(NULL, pwindow->dst, pstr,
551 if (count > adj_size(72)) {
553 }
554
555 hh = MAX(hh, buf->size.h);
556 buf->size.w = text1->w;
558
559 /* Gold upkeep */
560 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_GOLD]);
562 pstr->style |= SF_CENTER;
563 buf = create_iconlabel(NULL, pwindow->dst, pstr,
565 if (count > adj_size(72)) {
567 }
568
569 hh = MAX(hh, buf->size.h);
570 buf->size.w = text1->w;
572
573 /* Building */
574 if (units[utype_index(i)].building_count > 0) {
575 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].building_count);
576 } else {
577 fc_snprintf(cbuf, sizeof(cbuf), "--");
578 }
580 pstr->style |= SF_CENTER;
581 buf = create_iconlabel(NULL, pwindow->dst, pstr,
583 if (count > adj_size(72)) {
585 }
586 hh = MAX(hh, buf->size.h);
587 buf->size.w = text2->w + adj_size(6);
589
590 /* Soonest completion */
591 if (units[utype_index(i)].building_count > 0) {
592 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
593 units[utype_index(i)].soonest_completions,
594 PL_("turn", "turns", units[utype_index(i)].soonest_completions));
595 } else {
596 fc_snprintf(cbuf, sizeof(cbuf), "--");
597 }
598
600 pstr->style |= SF_CENTER;
601 buf = create_iconlabel(NULL, pwindow->dst, pstr,
603
604 if (count > adj_size(72)) {
606 }
607 hh = MAX(hh, buf->size.h);
608 buf->size.w = text5->w + adj_size(6);
610
611 count += adj_size(8);
612 area.h += (hh / 2);
613 }
615
618 + (adj_size(4) * text1->w + adj_size(46)) + (text2->w + adj_size(16))
619 + (text5->w + adj_size(6)) + adj_size(2));
620 if (count > 0) {
623 if (count > adj_size(80)) {
625 if (units_dlg->scroll) {
626 units_dlg->scroll->count = count;
627 }
629 area.w += ww;
630 area.h = (hh + 9 * (hh/2) + adj_size(10));
631 } else {
632 area.h += hh/2;
633 }
634 } else {
635 area.h = adj_size(50);
636 }
637
638 area.h += text1->h + adj_size(10);
639 area.w += adj_size(2);
640
642 resize_window(pwindow, logo, NULL,
643 (pwindow->size.w - pwindow->area.w) + area.w,
644 (pwindow->size.h - pwindow->area.h) + area.h);
646
647#if 0
648 logo = SDL_DisplayFormat(pwindow->theme);
649 FREESURFACE(pwindow->theme);
650 pwindow->theme = logo;
651 logo = NULL;
652#endif /* 0 */
653
654 area = pwindow->area;
655
656 widget_set_position(pwindow,
657 (main_window_width() - pwindow->size.w) / 2,
658 (main_window_height() - pwindow->size.h) / 2);
659
660 /* exit button */
661 buf = pwindow->prev;
662 buf->size.x = area.x + area.w - buf->size.w - 1;
663 buf->size.y = pwindow->size.y + adj_size(2);
664
665 /* totals background and label */
666 dst.x = area.x + adj_size(2);
667 dst.y = area.y + area.h - (text3->h + adj_size(2)) - adj_size(2);
669 dst.h = text3->h + adj_size(2);
670 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
671
672 create_frame(pwindow->theme,
673 dst.x, dst.y, dst.w, dst.h - 1,
675
676 dst.y += 1;
677 dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5)) - text3->w) / 2;
678 alphablit(text3, NULL, pwindow->theme, &dst, 255);
680
681 /* total active widget */
682 buf = buf->prev;
683 buf->size.x = area.x + name_w
685 buf->size.y = dst.y;
686
687 /* total shields cost widget */
688 buf = buf->prev;
689 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
690 buf->size.y = dst.y;
691
692 /* total food cost widget */
693 buf = buf->prev;
694 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
695 buf->size.y = dst.y;
696
697 /* total gold cost widget */
698 buf = buf->prev;
699 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
700 buf->size.y = dst.y;
701
702 /* total building count widget */
703 buf = buf->prev;
704 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
705 buf->size.y = dst.y;
706
707 /* units background and labels */
708 dst.x = area.x + adj_size(2);
709 dst.y = area.y + 1;
711 dst.h = text4->h + adj_size(2);
712 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
713
714 create_frame(pwindow->theme,
715 dst.x, dst.y, dst.w, dst.h - 1,
717
718 dst.y += 1;
719 dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5))- text4->w) / 2;
720 alphablit(text4, NULL, pwindow->theme, &dst, 255);
722
723 /* active count background and label */
725 dst.y = area.y + 1;
726 dst.w = text1->w + adj_size(6);
727 dst.h = area.h - adj_size(3);
728 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
729
730 create_frame(pwindow->theme,
731 dst.x, dst.y, dst.w, dst.h - 1,
733
734 dst.x += adj_size(3);
735 alphablit(text1, NULL, pwindow->theme, &dst, 255);
736 ww = text1->w;
737 hh = text1->h;
739
740 /* shields cost background and label */
741 dst.x += (ww + adj_size(13));
742 w = dst.x;
743 dst.w = ww;
744 dst.h = area.h - adj_size(3);
745 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
746
747 create_frame(pwindow->theme,
748 dst.x, dst.y, dst.w, dst.h - 1,
750
751 dst.y = area.y + adj_size(3);
752 dst.x += ((ww - icons->big_shield->w) / 2);
753 alphablit(icons->big_shield, NULL, pwindow->theme, &dst, 255);
754
755 /* food cost background and label */
756 dst.x = w + ww + adj_size(10);
757 w = dst.x;
758 dst.y = area.y + 1;
759 dst.w = ww;
760 dst.h = area.h - adj_size(3);
761 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
762
763 create_frame(pwindow->theme,
764 dst.x, dst.y, dst.w, dst.h - 1,
766
767 dst.y = area.y + adj_size(3);
768 dst.x += ((ww - icons->big_food->w) / 2);
769 alphablit(icons->big_food, NULL, pwindow->theme, &dst, 255);
770
771 /* gold cost background and label */
772 dst.x = w + ww + adj_size(10);
773 w = dst.x;
774 dst.y = area.y + 1;
775 dst.w = ww;
776 dst.h = area.h - adj_size(3);
777 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
778
779 create_frame(pwindow->theme,
780 dst.x, dst.y, dst.w, dst.h - 1,
782
783 dst.y = area.y + adj_size(3);
784 dst.x += ((ww - icons->big_coin->w) / 2);
785 alphablit(icons->big_coin, NULL, pwindow->theme, &dst, 255);
786
787 /* building count background and label */
788 dst.x = w + ww + adj_size(10);
789 dst.y = area.y + 1;
790 dst.w = text2->w + adj_size(6);
791 ww = text2->w + adj_size(6);
792 w = dst.x;
793 dst.h = area.h - adj_size(3);
794 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
795
796 create_frame(pwindow->theme,
797 dst.x, dst.y, dst.w, dst.h - 1,
799
800 dst.x += adj_size(3);
801 alphablit(text2, NULL, pwindow->theme, &dst, 255);
803
804 /* building count background and label */
805 dst.x = w + ww + adj_size(10);
806 dst.y = area.y + 1;
807 dst.w = text5->w + adj_size(6);
808 dst.h = area.h - adj_size(3);
809 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
810
811 create_frame(pwindow->theme,
812 dst.x, dst.y, dst.w, dst.h - 1,
814
815 dst.x += adj_size(3);
816 alphablit(text5, NULL, pwindow->theme, &dst, 255);
818
819 if (count) {
820 int start_x = area.x + adj_size(2);
821 int start_y = area.y + hh + adj_size(3);
822 int mod = 0;
823
824 buf = buf->prev;
825 while (TRUE) {
826 /* Unit type icon */
827 buf->size.x = start_x + (mod ? tileset_full_tile_width(tileset) : 0);
828 buf->size.y = start_y;
829 hh = buf->size.h;
830 mod ^= 1;
831
832 /* Unit type name */
833 buf = buf->prev;
834 buf->size.w = name_w;
835 buf->size.x = start_x + tileset_full_tile_width(tileset) * 2 + adj_size(5);
836 buf->size.y = start_y + (hh - buf->size.h) / 2;
837
838 /* Number active */
839 buf = buf->prev;
840 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
841 buf->size.y = start_y + (hh - buf->size.h) / 2;
842
843 /* Shield upkeep */
844 buf = buf->prev;
845 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
846 buf->size.y = start_y + (hh - buf->size.h) / 2;
847
848 /* Food upkeep */
849 buf = buf->prev;
850 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
851 buf->size.y = start_y + (hh - buf->size.h) / 2;
852
853 /* Gold upkeep */
854 buf = buf->prev;
855 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
856 buf->size.y = start_y + (hh - buf->size.h) / 2;
857
858 /* Number under construction */
859 buf = buf->prev;
860 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
861 buf->size.y = start_y + (hh - buf->size.h) / 2;
862
863 /* Soonest completion */
864 buf = buf->prev;
865 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(10);
866 buf->size.y = start_y + (hh - buf->size.h) / 2;
867
868 start_y += (hh >> 1);
870 break;
871 }
872 buf = buf->prev;
873 }
874
875 if (units_dlg->scroll) {
877 area.x + area.w, area.y,
878 area.h, TRUE);
879 }
880
881 }
882 /* ----------------------------------- */
884 widget_mark_dirty(pwindow);
885
886 flush_dirty();
887}
888
889/**********************************************************************/
893{
894 if (units_dlg) {
895 struct units_entry units[U_LAST];
896 struct units_entry units_total;
897 struct widget *pwidget, *pbuf;
898 bool is_in_list = FALSE;
899 char cbuf[32];
900 bool upgrade;
901 bool search_finished;
902
904
905 /* Find if there are new units entry (if not then rebuild all) */
906 pwidget = units_dlg->end_active_widget_list; /* Icon of first list entry */
908 if ((units[utype_index(i)].active_count > 0)
909 || (units[utype_index(i)].building_count > 0)) {
911
912 pbuf = pwidget; /* Unit type icon */
913 while (pbuf != NULL) {
914 if ((MAX_ID - pbuf->id) == utype_number(i)) {
916 pwidget = pbuf;
917 break;
918 }
919 if (pbuf->prev->prev->prev->prev->prev->prev->prev ==
921 break;
922 }
923
924 /* First widget of next list entry */
925 pbuf = pbuf->prev->prev->prev->prev->prev->prev->prev->prev;
926 }
927
928 if (!is_in_list) {
930 return;
931 }
932 }
934
935 /* Update list */
937 if (pwidget != NULL) {
939 pbuf = pwidget; /* First widget (icon) of the first list entry */
940
941 if ((units[utype_index(i)].active_count > 0)
942 || (units[utype_index(i)].building_count > 0)) {
943 /* The player has at least one unit of this type */
944
946 while (!search_finished) {
947 if ((MAX_ID - pbuf->id) == utype_number(i)) {
948 /* List entry for this unit type found */
949
950 upgrade = (can_upgrade_unittype(client.conn.playing, i) != NULL);
951
952 pbuf = pbuf->prev; /* Unit type name */
953 if (upgrade) {
954 pbuf->string_utf8->fgcol
958 }
959
960 pbuf = pbuf->prev; /* Active */
961 fc_snprintf(cbuf, sizeof(cbuf), "%d",
962 units[utype_index(i)].active_count);
963 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
964
965 pbuf = pbuf->prev; /* Shield upkeep */
966 fc_snprintf(cbuf, sizeof(cbuf), "%d",
967 units[utype_index(i)].upkeep[O_SHIELD]);
968 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
969
970 pbuf = pbuf->prev; /* Food upkeep */
971 fc_snprintf(cbuf, sizeof(cbuf), "%d",
972 units[utype_index(i)].upkeep[O_FOOD]);
973 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
974
975 pbuf = pbuf->prev; /* Gold upkeep */
976 fc_snprintf(cbuf, sizeof(cbuf), "%d",
977 units[utype_index(i)].upkeep[O_GOLD]);
978 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
979
980 pbuf = pbuf->prev; /* Building */
981 if (units[utype_index(i)].building_count > 0) {
982 fc_snprintf(cbuf, sizeof(cbuf), "%d",
983 units[utype_index(i)].building_count);
984 } else {
985 fc_snprintf(cbuf, sizeof(cbuf), "--");
986 }
987 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
988
989 pbuf = pbuf->prev; /* Soonest completion */
990 if (units[utype_index(i)].building_count > 0) {
991 fc_snprintf(cbuf, sizeof(cbuf), "%d %s",
992 units[utype_index(i)].soonest_completions,
993 PL_("turn", "turns",
994 units[utype_index(i)].soonest_completions));
995 } else {
996 fc_snprintf(cbuf, sizeof(cbuf), "--");
997 }
998 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
999
1000 pwidget = pbuf->prev; /* Icon of next unit type */
1001
1003
1004 } else { /* List entry for this unit type not found yet */
1005
1006 /* Search it */
1007 pbuf = pwidget->next;
1008 do {
1010 pbuf->prev);
1011 } while (((MAX_ID - pbuf->prev->id) != utype_number(i))
1012 && (pbuf->prev != units_dlg->begin_active_widget_list));
1013
1014 if (pbuf->prev == units_dlg->begin_active_widget_list) {
1015 /* List entry not found - can this really happen? */
1017 pbuf->prev);
1018 pwidget = pbuf->prev; /* units_dlg->begin_active_widget_list */
1020 } else {
1021 /* Found it */
1022 pbuf = pbuf->prev; /* First widget (icon) of list entry */
1023 }
1024 }
1025 }
1026 } else { /* Player has no unit of this type */
1027 if (pbuf->next != units_dlg->begin_active_widget_list) {
1028 if (utype_number(i) < (MAX_ID - pbuf->id)) {
1029 continue;
1030 } else {
1031 pbuf = pbuf->next;
1032 do {
1034 pbuf->prev);
1035 } while (((MAX_ID - pbuf->prev->id) == utype_number(i))
1036 && (pbuf->prev != units_dlg->begin_active_widget_list));
1037 if (pbuf->prev == units_dlg->begin_active_widget_list) {
1039 pbuf->prev);
1040 }
1041 pwidget = pbuf->prev;
1042 }
1043 }
1044 }
1046 }
1047
1048 /* -------------------------------------- */
1049
1050 /* Total active */
1052 fc_snprintf(cbuf, sizeof(cbuf), "%d", units_total.active_count);
1053 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1054
1055 /* Total shields cost */
1056 pbuf = pbuf->prev;
1057 fc_snprintf(cbuf, sizeof(cbuf), "%d", units_total.upkeep[O_SHIELD]);
1058 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1059
1060 /* Total food cost widget */
1061 pbuf = pbuf->prev;
1062 fc_snprintf(cbuf, sizeof(cbuf), "%d", units_total.upkeep[O_FOOD]);
1063 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1064
1065 /* Total gold cost widget */
1066 pbuf = pbuf->prev;
1067 fc_snprintf(cbuf, sizeof(cbuf), "%d", units_total.upkeep[O_GOLD]);
1068 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1069
1070 /* Total building count */
1071 pbuf = pbuf->prev;
1072 fc_snprintf(cbuf, sizeof(cbuf), "%d", units_total.building_count);
1073 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1074
1075 /* -------------------------------------- */
1078
1079 flush_dirty();
1080 }
1081}
1082
1083/**********************************************************************/
1087{
1088 struct units_entry units[U_LAST];
1089 struct units_entry units_total;
1090
1091 if (units_dlg) {
1092 return;
1093 }
1094
1095 get_units_report_data(units, &units_total);
1096 real_activeunits_report_dialog_update(units, &units_total);
1097}
1098
1099/**************************************************************************
1100 Popdown the units report.
1101**************************************************************************/
1116
1117/* ===================================================================== */
1118/* ======================== Economy Report ============================= */
1119/* ===================================================================== */
1120static struct advanced_dialog *economy_dlg = NULL;
1121static struct small_dialog *economy_sell_dlg = NULL;
1122
1129
1130/**********************************************************************/
1133static int economy_dialog_callback(struct widget *pwindow)
1134{
1137 }
1138
1139 return -1;
1140}
1141
1142/**********************************************************************/
1167
1168/**********************************************************************/
1172{
1174 switch (pcheckbox->id) {
1177 return -1;
1178
1181 return -1;
1182
1183 default:
1184 return -1;
1185 }
1186 }
1187
1188 return -1;
1189}
1190
1191/**********************************************************************/
1199
1200/**********************************************************************/
1204 void *data)
1205{
1206 struct rates_move *motion = (struct rates_move *)data;
1208 struct widget *pbuf = NULL;
1209 char cbuf[8];
1210 int dir, inc, x, *buf_rate = NULL;
1211
1212 motion_event->x -= motion->horiz_src->dst->dest_rect.x;
1213
1214 if ((abs(motion_event->x - motion->x) > 7)
1215 && (motion_event->x >= motion->min)
1216 && (motion_event->x <= motion->max)) {
1217
1218 /* set up directions */
1219 if (motion_event->xrel > 0) {
1220 dir = 15;
1221 inc = 10;
1222 } else {
1223 dir = -15;
1224 inc = -10;
1225 }
1226
1227 /* make checks */
1228 x = motion->horiz_src->size.x;
1229 if (((x + dir) <= motion->max) && ((x + dir) >= motion->min)) {
1230 /* src in range */
1231 if (motion->horiz_dst) {
1232 x = motion->horiz_dst->size.x;
1233 if (((x + (-1 * dir)) > motion->max) || ((x + (-1 * dir)) < motion->min)) {
1234 /* dst out of range */
1235 if (motion->tax + (-1 * inc) <= motion->gov_max
1236 && motion->tax + (-1 * inc) >= 0) {
1237 /* tax in range */
1238 pbuf = motion->horiz_dst;
1239 motion->horiz_dst = NULL;
1240 buf_rate = motion->dst_rate;
1241 motion->dst_rate = &motion->tax;
1242 motion->label_dst = tax_label;
1243 } else {
1244 motion->x = motion->horiz_src->size.x;
1245 return ID_ERROR;
1246 }
1247 }
1248 } else {
1249 if (motion->tax + (-1 * inc) > motion->gov_max
1250 || motion->tax + (-1 * inc) < 0) {
1251 motion->x = motion->horiz_src->size.x;
1252 return ID_ERROR;
1253 }
1254 }
1255
1256 /* undraw scrollbars */
1257 widget_undraw(motion->horiz_src);
1258 widget_mark_dirty(motion->horiz_src);
1259
1260 if (motion->horiz_dst) {
1261 widget_undraw(motion->horiz_dst);
1262 widget_mark_dirty(motion->horiz_dst);
1263 }
1264
1265 motion->horiz_src->size.x += dir;
1266 if (motion->horiz_dst) {
1267 motion->horiz_dst->size.x -= dir;
1268 }
1269
1270 *motion->src_rate += inc;
1271 *motion->dst_rate -= inc;
1272
1273 fc_snprintf(cbuf, sizeof(cbuf), "%d%%", *motion->src_rate);
1274 copy_chars_to_utf8_str(motion->label_src->string_utf8, cbuf);
1275 fc_snprintf(cbuf, sizeof(cbuf), "%d%%", *motion->dst_rate);
1276 copy_chars_to_utf8_str(motion->label_dst->string_utf8, cbuf);
1277
1278 /* redraw label */
1279 widget_redraw(motion->label_src);
1280 widget_mark_dirty(motion->label_src);
1281
1282 widget_redraw(motion->label_dst);
1283 widget_mark_dirty(motion->label_dst);
1284
1285 /* redraw scrollbar */
1286 if (get_wflags(motion->horiz_src) & WF_RESTORE_BACKGROUND) {
1288 }
1289 widget_redraw(motion->horiz_src);
1290 widget_mark_dirty(motion->horiz_src);
1291
1292 if (motion->horiz_dst) {
1293 if (get_wflags(motion->horiz_dst) & WF_RESTORE_BACKGROUND) {
1295 }
1296 widget_redraw(motion->horiz_dst);
1297 widget_mark_dirty(motion->horiz_dst);
1298 }
1299
1300 flush_dirty();
1301
1302 if (pbuf != NULL) {
1303 motion->horiz_dst = pbuf;
1304 motion->label_dst = motion->horiz_dst->prev;
1305 motion->dst_rate = buf_rate;
1306 pbuf = NULL;
1307 }
1308
1309 motion->x = motion->horiz_src->size.x;
1310 }
1311 } /* if */
1312
1313 return ID_ERROR;
1314}
1315
1316/**********************************************************************/
1319static int horiz_taxrate_callback(struct widget *horiz_src)
1320{
1322 struct rates_move motion;
1323
1324 motion.horiz_src = horiz_src;
1325 motion.label_src = horiz_src->prev;
1326
1327 switch (horiz_src->id) {
1330 goto END;
1331 }
1332 motion.src_rate = (int *)horiz_src->data.ptr;
1333 motion.horiz_dst = horiz_src->prev->prev->prev; /* sci */
1334 motion.dst_rate = (int *)motion.horiz_dst->data.ptr;
1335 motion.tax = 100 - *motion.src_rate - *motion.dst_rate;
1337 if (motion.tax <= get_player_bonus(client.conn.playing, EFT_MAX_RATES)) {
1338 motion.horiz_dst = NULL; /* tax */
1339 motion.dst_rate = &motion.tax;
1340 } else {
1341 goto END; /* all blocked */
1342 }
1343 }
1344
1345 break;
1346
1349 goto END;
1350 }
1351 motion.src_rate = (int *)horiz_src->data.ptr;
1352 motion.horiz_dst = horiz_src->next->next->next; /* lux */
1353 motion.dst_rate = (int *)motion.horiz_dst->data.ptr;
1354 motion.tax = 100 - *motion.src_rate - *motion.dst_rate;
1356 if (motion.tax <= get_player_bonus(client.conn.playing, EFT_MAX_RATES)) {
1357 /* tax */
1358 motion.horiz_dst = NULL;
1359 motion.dst_rate = &motion.tax;
1360 } else {
1361 goto END; /* all blocked */
1362 }
1363 }
1364
1365 break;
1366
1367 default:
1368 return -1;
1369 }
1370
1371 if (motion.horiz_dst) {
1372 motion.label_dst = motion.horiz_dst->prev;
1373 } else {
1374 /* tax label */
1376 }
1377
1378 motion.min = horiz_src->next->size.x + horiz_src->next->size.w + adj_size(2);
1379 motion.gov_max = get_player_bonus(client.conn.playing, EFT_MAX_RATES);
1380 motion.max = motion.min + motion.gov_max * 1.5;
1381 motion.x = horiz_src->size.x;
1382
1383 MOVE_STEP_Y = 0;
1384 /* Filter mouse motion events */
1385 SDL_SetEventFilter(FilterMouseMotionEvents, NULL);
1386 gui_event_loop((void *)(&motion), NULL, NULL, NULL, NULL, NULL, NULL,
1387 NULL, NULL,
1390 /* Turn off Filter mouse motion events */
1391 SDL_SetEventFilter(NULL, NULL);
1393
1394END:
1400 }
1401
1402 return -1;
1403}
1404
1405/**********************************************************************/
1408static int apply_taxrates_callback(struct widget *button)
1409{
1411 struct widget *buf;
1412 int science, luxury, tax;
1413
1414 if (C_S_RUNNING != client_state()) {
1415 return -1;
1416 }
1417
1418 /* Science Scrollbar */
1419 buf = button->next->next;
1420 science = *(int *)buf->data.ptr;
1421
1422 /* Luxuries Scrollbar */
1423 buf = buf->next->next->next;
1424 luxury = *(int *)buf->data.ptr;
1425
1426 /* Tax */
1427 tax = 100 - luxury - science;
1428
1429 if (tax != client.conn.playing->economic.tax
1430 || science != client.conn.playing->economic.science
1431 || luxury != client.conn.playing->economic.luxury) {
1432 dsend_packet_player_rates(&client.conn, tax, luxury, science);
1433 }
1434
1435 widget_redraw(button);
1436 widget_flush(button);
1437 }
1438
1439 return -1;
1440}
1441
1442/**********************************************************************/
1445static void enable_economy_dlg(void)
1446{
1447 /* lux lock */
1449
1451
1452 /* lux scrollbar */
1453 buf = buf->prev;
1455
1456 /* sci lock */
1457 buf = buf->prev->prev;
1459
1460 /* sci scrollbar */
1461 buf = buf->prev;
1463
1464 /* update button */
1465 buf = buf->prev->prev;
1467
1468 /* cancel button */
1469 buf = buf->prev;
1471
1478 }
1479}
1480
1481/**********************************************************************/
1484static void disable_economy_dlg(void)
1485{
1486 /* lux lock */
1488
1490
1491 /* lux scrollbar */
1492 buf = buf->prev;
1494
1495 /* sci lock */
1496 buf = buf->prev->prev;
1498
1499 /* sci scrollbar */
1500 buf = buf->prev;
1502
1503 /* update button */
1504 buf = buf->prev->prev;
1506
1507 /* cancel button */
1508 buf = buf->prev;
1510
1517 }
1518}
1519
1520/* --------------------------------------------------------------- */
1521
1522/**********************************************************************/
1525static int ok_sell_impr_callback(struct widget *pwidget)
1526{
1528 int imp, total_count, count = 0;
1529 struct widget *impr = (struct widget *)pwidget->data.ptr;
1530
1531 imp = impr->data.cont->id0;
1532 total_count = impr->data.cont->id1;
1533
1534 /* popdown sell dlg */
1539
1540 /* send sell */
1542 if (!pcity->did_sell
1544 count++;
1545
1546 city_sell_improvement(pcity, imp);
1547 }
1549
1550 if (count == total_count) {
1552 }
1553 }
1554
1555 return -1;
1556}
1557
1558/**********************************************************************/
1561static int sell_impr_window_callback(struct widget *pwindow)
1562{
1565 }
1566
1567 return -1;
1568}
1569
1570/**********************************************************************/
1573static int cancel_sell_impr_callback(struct widget *pwidget)
1574{
1576 if (economy_sell_dlg) {
1581 flush_dirty();
1582 }
1583 }
1584
1585 return -1;
1586}
1587
1588/**********************************************************************/
1591static int popup_sell_impr_callback(struct widget *pwidget)
1592{
1594 int imp, total_count ,count = 0, gold = 0;
1595 int value;
1596 char cbuf[128];
1597 struct widget *buf = NULL, *pwindow;
1598 utf8_str *pstr;
1599 SDL_Surface *text;
1600 SDL_Rect dst;
1601 SDL_Rect area;
1602
1603 if (economy_sell_dlg) {
1604 return 1;
1605 }
1606
1607 set_wstate(pwidget, FC_WS_NORMAL);
1609 widget_redraw(pwidget);
1610 widget_mark_dirty(pwidget);
1611
1612 economy_sell_dlg = fc_calloc(1, sizeof(struct small_dialog));
1613
1614 imp = pwidget->data.cont->id0;
1615 total_count = pwidget->data.cont->id1;
1617
1619 if (!pcity->did_sell
1621 count++;
1622 gold += value;
1623 }
1625
1626 if (count > 0) {
1627 fc_snprintf(cbuf, sizeof(cbuf),
1628 _("We have %d of %s\n(total value is : %d)\n"
1629 "We can sell %d of them for %d gold."),
1632 total_count * value, count, gold);
1633 } else {
1634 fc_snprintf(cbuf, sizeof(cbuf),
1635 _("We can't sell any %s in this turn."),
1637 }
1638
1640 pstr->style |= TTF_STYLE_BOLD;
1641
1642 pwindow = create_window_skeleton(NULL, pstr, 0);
1643
1644 pwindow->action = sell_impr_window_callback;
1645 set_wstate(pwindow, FC_WS_NORMAL);
1646
1648
1649 add_to_gui_list(ID_WINDOW, pwindow);
1650
1651 area = pwindow->area;
1652
1653 /* ============================================================= */
1654
1655 /* Create text label */
1657 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1659
1662
1663 area.w = MAX(area.w, text->w + adj_size(20));
1664 area.h += (text->h + adj_size(10));
1665
1666 /* Cancel button */
1668 pwindow->dst, _("No"),
1669 FONTO_ATTENTION, 0);
1670
1673
1674 area.h += (buf->size.h + adj_size(20));
1675
1677
1678 if (count > 0) {
1680 pwindow->dst,
1681 _("Sell"),
1682 FONTO_ATTENTION, 0);
1683
1684 buf->action = ok_sell_impr_callback;
1686 buf->data.ptr = (void *)pwidget;
1687
1689 buf->size.w = MAX(buf->size.w, buf->next->size.w);
1690 buf->next->size.w = buf->size.w;
1691 area.w = MAX(area.w, adj_size(30) + buf->size.w * 2);
1692 } else {
1693 area.w = MAX(area.w, buf->size.w + adj_size(20));
1694 }
1695 /* ============================================ */
1696
1698
1700 (pwindow->size.w - pwindow->area.w) + area.w,
1701 (pwindow->size.h - pwindow->area.h) + area.h);
1702
1703 area = pwindow->area;
1704
1705 widget_set_position(pwindow,
1707 (economy_dlg->end_widget_list->size.w - pwindow->size.w) / 2,
1709 (economy_dlg->end_widget_list->size.h - pwindow->size.h) / 2);
1710
1711 /* setup rest of widgets */
1712 /* label */
1713 dst.x = area.x + (area.w - text->w) / 2;
1714 dst.y = area.y + adj_size(10);
1715 alphablit(text, NULL, pwindow->theme, &dst, 255);
1716 FREESURFACE(text);
1717
1718 /* cancel button */
1719 buf = pwindow->prev;
1720 buf->size.y = area.y + area.h - buf->size.h - adj_size(10);
1721
1722 if (count > 0) {
1723 /* sell button */
1724 buf = buf->prev;
1725 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(10))) / 2;
1726 buf->size.y = buf->next->size.y;
1727
1728 /* cancel button */
1729 buf->next->size.x = buf->size.x + buf->size.w + adj_size(10);
1730 } else {
1731 /* x position of cancel button */
1732 buf->size.x = area.x + area.w - adj_size(10) - buf->size.w;
1733 }
1734
1735 /* ================================================== */
1736 /* redraw */
1739
1740 widget_mark_dirty(pwindow);
1741 flush_dirty();
1742 }
1743
1744 return -1;
1745}
1746
1747/**********************************************************************/
1751{
1752 if (economy_dlg) {
1754 int tax, total, entries_used = 0;
1755 char cbuf[128];
1757
1759
1760 /* tresure */
1761 pbuf = pbuf->prev;
1762 fc_snprintf(cbuf, sizeof(cbuf), "%d", client.conn.playing->economic.gold);
1764 remake_label_size(pbuf);
1765
1766 /* Icome */
1767 pbuf = pbuf->prev->prev;
1768 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax);
1770 remake_label_size(pbuf);
1771
1772 /* Cost */
1773 pbuf = pbuf->prev;
1774 fc_snprintf(cbuf, sizeof(cbuf), "%d", total);
1776 remake_label_size(pbuf);
1777
1778 /* Netto */
1779 pbuf = pbuf->prev;
1780 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax - total);
1782 remake_label_size(pbuf);
1783 if (tax - total < 0) {
1785 } else {
1787 }
1788
1789 /* ---------------- */
1792 }
1793}
1794
1795/**********************************************************************/
1815
1816#define TARGETS_ROW 2
1817#define TARGETS_COL 4
1818
1819/**********************************************************************/
1822void economy_report_dialog_popup(bool make_modal)
1823{
1824 SDL_Color bg_color = {255,255,255,128};
1825 SDL_Color bg_color2 = {255,255,255,136};
1826 SDL_Color bg_color3 = {255,255,255,64};
1827 struct widget *buf;
1828 struct widget *pwindow , *last;
1829 utf8_str *pstr, *pstr2;
1830 SDL_Surface *surf, *text_name, *text, *zoomed;
1831 SDL_Surface *background;
1832 int i, count , h = 0;
1833 int w = 0; /* left column values */
1834 int w2 = 0; /* right column: lock + scrollbar + ... */
1835 int w3 = 0; /* left column text without values */
1836 int tax, total, entries_used = 0;
1837 char cbuf[128];
1839 SDL_Rect dst;
1840 SDL_Rect area;
1842 SDL_Surface *treasury_text;
1843 SDL_Surface *tax_rate_text;
1844 SDL_Surface *total_income_text;
1845 SDL_Surface *total_cost_text;
1846 SDL_Surface *net_income_text;
1847 SDL_Surface *max_rate_text;
1848
1849 if (economy_dlg) {
1850 return;
1851 }
1852
1853 /* disable "Economy" button */
1854 buf = get_tax_rates_widget();
1856 widget_redraw(buf);
1857 widget_mark_dirty(buf);
1858
1859 economy_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1860
1862
1863 /* --------------- */
1864 pstr = create_utf8_from_char_fonto(_("Economy Report"), FONTO_ATTENTION);
1865 pstr->style |= TTF_STYLE_BOLD;
1866
1867 pwindow = create_window_skeleton(NULL, pstr, 0);
1868 economy_dlg->end_widget_list = pwindow;
1869 set_wstate(pwindow, FC_WS_NORMAL);
1871
1873
1874 area = pwindow->area;
1875
1876 /* ------------------------- */
1877
1878 /* "Treasury" text surface */
1879 fc_snprintf(cbuf, sizeof(cbuf), _("Treasury: "));
1881 pstr2->style |= TTF_STYLE_BOLD;
1882 treasury_text = create_text_surf_from_utf8(pstr2);
1883 w3 = MAX(w3, treasury_text->w);
1884
1885 /* "Treasury" value label */
1886 fc_snprintf(cbuf, sizeof(cbuf), "%d", client.conn.playing->economic.gold);
1888 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1889
1890 buf = create_iconlabel(icons->big_coin, pwindow->dst, pstr,
1892
1894
1895 w = MAX(w, buf->size.w);
1896 h += buf->size.h;
1897
1898 /* "Tax Rate" text surface */
1899 fc_snprintf(cbuf, sizeof(cbuf), _("Tax Rate: "));
1900 copy_chars_to_utf8_str(pstr2, cbuf);
1901 tax_rate_text = create_text_surf_from_utf8(pstr2);
1902 w3 = MAX(w3, tax_rate_text->w);
1903
1904 /* "Tax Rate" value label */
1905 /* It is important to leave 1 space at ending of this string. */
1906 fc_snprintf(cbuf, sizeof(cbuf), "%d%% ", client.conn.playing->economic.tax);
1908 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1909
1910 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1911
1913
1914 w = MAX(w, buf->size.w + buf->next->size.w);
1915 h += buf->size.h;
1916
1917 /* "Total Income" text surface */
1918 fc_snprintf(cbuf, sizeof(cbuf), _("Total Income: "));
1919 copy_chars_to_utf8_str(pstr2, cbuf);
1920 total_income_text = create_text_surf_from_utf8(pstr2);
1921 w3 = MAX(w3, total_income_text->w);
1922
1923 /* "Total Icome" value label */
1924 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax);
1926 pstr->style |= TTF_STYLE_BOLD;
1927
1928 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1929
1931
1932 w = MAX(w, buf->size.w);
1933 h += buf->size.h;
1934
1935 /* "Total Cost" text surface */
1936 fc_snprintf(cbuf, sizeof(cbuf), _("Total Cost: "));
1937 copy_chars_to_utf8_str(pstr2, cbuf);
1938 total_cost_text = create_text_surf_from_utf8(pstr2);
1939
1940 /* "Total Cost" value label */
1941 fc_snprintf(cbuf, sizeof(cbuf), "%d", total);
1943 pstr->style |= TTF_STYLE_BOLD;
1944
1945 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1946
1948
1949 w = MAX(w, buf->size.w);
1950 h += buf->size.h;
1951
1952 /* "Net Income" text surface */
1953 fc_snprintf(cbuf, sizeof(cbuf), _("Net Income: "));
1954 copy_chars_to_utf8_str(pstr2, cbuf);
1955 net_income_text = create_text_surf_from_utf8(pstr2);
1956 w3 = MAX(w3, net_income_text->w);
1957
1958 /* "Net Icome" value label */
1959 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax - total);
1961 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1962
1963 if (tax - total < 0) {
1965 }
1966
1967 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1968
1970
1971 w = MAX(w, buf->size.w);
1972 h += buf->size.h;
1973
1974 /* gov and taxrate */
1975 fc_snprintf(cbuf, sizeof(cbuf), _("%s max rate : %d%%"),
1977 get_player_bonus(client.conn.playing, EFT_MAX_RATES));
1978 copy_chars_to_utf8_str(pstr2, cbuf);
1979 max_rate_text = create_text_surf_from_utf8(pstr2);
1980
1981 FREEUTF8STR(pstr2);
1982
1983 /* ------------------------- */
1984 /* Lux rate */
1985
1986 /* Lux rate lock */
1987 fc_snprintf(cbuf, sizeof(cbuf), _("Lock"));
1989 pstr->style |= TTF_STYLE_BOLD;
1990
1991 buf = create_checkbox(pwindow->dst,
1994 set_new_checkbox_theme(buf, current_theme->lock_icon,
1995 current_theme->unlock_icon);
1996 buf->info_label = pstr;
1999
2001
2002 w2 = adj_size(10) + buf->size.w;
2003
2004 /* Lux rate slider */
2005 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
2007
2009 buf->data.ptr = fc_calloc(1, sizeof(int));
2010 *(int *)buf->data.ptr = client.conn.playing->economic.luxury;
2012
2014
2015 w2 += adj_size(184);
2016
2017 /* Lux rate iconlabel */
2018
2019 /* It is important to leave 1 space at the end of this string. */
2020 fc_snprintf(cbuf, sizeof(cbuf), "%d%% ", client.conn.playing->economic.luxury);
2022 pstr->style |= TTF_STYLE_BOLD;
2023
2024 buf = create_iconlabel(icons->big_luxury, pwindow->dst, pstr,
2027
2028 w2 += (adj_size(5) + buf->size.w + adj_size(10));
2029
2030 /* ------------------------- */
2031 /* Science rate */
2032
2033 /* Science rate lock */
2034 fc_snprintf(cbuf, sizeof(cbuf), _("Lock"));
2036 pstr->style |= TTF_STYLE_BOLD;
2037
2038 buf = create_checkbox(pwindow->dst,
2041
2042 set_new_checkbox_theme(buf, current_theme->lock_icon,
2043 current_theme->unlock_icon);
2044
2045 buf->info_label = pstr;
2048
2050
2051 /* Science rate slider */
2052 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
2054
2056 buf->data.ptr = fc_calloc(1, sizeof(int));
2057 *(int *)buf->data.ptr = client.conn.playing->economic.science;
2058
2060
2062
2063 /* Science rate iconlabel */
2064 /* It is important to leave 1 space at the end of this string */
2065 fc_snprintf(cbuf, sizeof(cbuf), "%d%% ", client.conn.playing->economic.science);
2067 pstr->style |= TTF_STYLE_BOLD;
2068
2069 buf = create_iconlabel(icons->big_colb, pwindow->dst, pstr,
2071
2073
2074 /* ---- */
2075
2076 fc_snprintf(cbuf, sizeof(cbuf), _("Update"));
2078 buf = create_themeicon_button(current_theme->small_ok_icon, pwindow->dst,
2079 pstr, 0);
2082
2084
2085 /* ---- */
2086
2087 fc_snprintf(cbuf, sizeof(cbuf), _("Close Dialog (Esc)"));
2089 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2091 buf->info_label = pstr;
2094 buf->key = SDLK_ESCAPE;
2095
2097
2098 h += adj_size(5);
2099
2100 /* ------------------------- */
2101 last = buf;
2102 if (entries_used > 0) {
2103
2104 /* Create Imprv Background Icon */
2105 background = create_surf(adj_size(116), adj_size(116), SDL_SWSURFACE);
2106
2107 SDL_FillRect(background, NULL, map_rgba(background->format, bg_color));
2108
2109 create_frame(background,
2110 0, 0, background->w - 1, background->h - 1,
2112
2113 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
2114 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
2115 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
2116
2117 for (i = 0; i < entries_used; i++) {
2118 struct improvement_entry *p = &entries[i];
2119 struct impr_type *pimprove = p->type;
2120
2121 surf = crop_rect_from_surface(background, NULL);
2122
2123 fc_snprintf(cbuf, sizeof(cbuf), "%s",
2125
2126 copy_chars_to_utf8_str(pstr, cbuf);
2127 pstr->style |= TTF_STYLE_BOLD;
2128 text_name = create_text_surf_smaller_than_w(pstr, surf->w - adj_size(4));
2129
2130 fc_snprintf(cbuf, sizeof(cbuf), "%s %d\n%s %d",
2131 _("Built"), p->count, _("U Total"),p->total_cost);
2132 copy_chars_to_utf8_str(pstr, cbuf);
2133 pstr->style &= ~TTF_STYLE_BOLD;
2134
2135 text = create_text_surf_from_utf8(pstr);
2136
2137 /*-----------------*/
2138
2139 zoomed = get_building_surface(pimprove);
2140 zoomed = zoomSurface(zoomed, DEFAULT_ZOOM * ((float)54 / zoomed->w),
2141 DEFAULT_ZOOM * ((float)54 / zoomed->w), 1);
2142
2143 dst.x = (surf->w - zoomed->w) / 2;
2144 dst.y = (surf->h / 2 - zoomed->h) / 2;
2145 alphablit(zoomed, NULL, surf, &dst, 255);
2146 dst.y += zoomed->h;
2147 FREESURFACE(zoomed);
2148
2149 dst.x = (surf->w - text_name->w)/2;
2150 dst.y += ((surf->h - dst.y) -
2151 (text_name->h + (icons->big_coin->h + 2) + text->h)) / 2;
2152 alphablit(text_name, NULL, surf, &dst, 255);
2153
2154 dst.y += text_name->h;
2155 if (p->cost) {
2156 dst.x = (surf->w - p->cost * (icons->big_coin->w + 1))/2;
2157 for (count = 0; count < p->cost; count++) {
2158 alphablit(icons->big_coin, NULL, surf, &dst, 255);
2159 dst.x += icons->big_coin->w + 1;
2160 }
2161 } else {
2162
2163 if (!is_wonder(pimprove)) {
2164 copy_chars_to_utf8_str(pstr, _("Nation"));
2165 } else {
2166 copy_chars_to_utf8_str(pstr, _("Wonder"));
2167 }
2168 /* pstr->style &= ~TTF_STYLE_BOLD; */
2169
2170 zoomed = create_text_surf_from_utf8(pstr);
2171
2172 dst.x = (surf->w - zoomed->w) / 2;
2173 alphablit(zoomed, NULL, surf, &dst, 255);
2174 FREESURFACE(zoomed);
2175 }
2176
2177 dst.y += (icons->big_coin->h + adj_size(2));
2178 dst.x = (surf->w - text->w) / 2;
2179 alphablit(text, NULL, surf, &dst, 255);
2180
2181 FREESURFACE(text);
2182 FREESURFACE(text_name);
2183
2184 buf = create_icon2(surf, pwindow->dst,
2186
2188
2189 buf->data.cont = fc_calloc(1, sizeof(struct container));
2190 buf->data.cont->id0 = improvement_number(p->type);
2191 buf->data.cont->id1 = p->count;
2193
2194 add_to_gui_list(MAX_ID - i, buf);
2195
2196 if (i > (TARGETS_ROW * TARGETS_COL - 1)) {
2197 set_wflag(buf, WF_HIDDEN);
2198 }
2199 }
2200
2201 FREEUTF8STR(pstr);
2202 FREESURFACE(background);
2203
2207
2212 h += (TARGETS_ROW * buf->size.h + adj_size(10));
2213 } else {
2214 count = 0;
2215 if (entries_used > TARGETS_COL) {
2216 h += buf->size.h;
2217 }
2218 h += (adj_size(10) + buf->size.h);
2219 }
2220 count = TARGETS_COL * buf->size.w + count;
2221 } else {
2223 h += adj_size(10);
2224 count = 0;
2225 }
2226
2227 area.w = MAX(area.w, MAX(adj_size(10) + w3 + w + w2, count));
2228 area.h = h;
2229
2231 if (resize_window(pwindow, background, NULL,
2232 (pwindow->size.w - pwindow->area.w) + area.w,
2233 (pwindow->size.h - pwindow->area.h) + area.h)) {
2234 FREESURFACE(background);
2235 }
2236
2237 area = pwindow->area;
2238
2239 widget_set_position(pwindow,
2240 (main_window_width() - pwindow->size.w) / 2,
2241 (main_window_height() - pwindow->size.h) / 2);
2242
2243 /* "Treasury" value label */
2244 buf = pwindow->prev;
2245 buf->size.x = area.x + adj_size(10) + treasury_text->w;
2246 buf->size.y = area.y + adj_size(5);
2247
2248 w = treasury_text->w + buf->size.w;
2249 h = buf->size.h;
2250
2251 /* "Tax Rate" value label */
2252 buf = buf->prev;
2253 buf->size.x = area.x + adj_size(10) + tax_rate_text->w;
2254 buf->size.y = buf->next->size.y + buf->next->size.h;
2255
2256 w = MAX(w, tax_rate_text->w + buf->size.w);
2257 h += buf->size.h;
2258
2259 /* "Total Income" value label */
2260 buf = buf->prev;
2261 buf->size.x = area.x + adj_size(10) + total_income_text->w;
2262 buf->size.y = buf->next->size.y + buf->next->size.h;
2263
2264 w = MAX(w, total_income_text->w + buf->size.w);
2265 h += buf->size.h;
2266
2267 /* "Total Cost" value label */
2268 buf = buf->prev;
2269 buf->size.x = area.x + adj_size(10) + total_cost_text->w;
2270 buf->size.y = buf->next->size.y + buf->next->size.h;
2271
2272 w = MAX(w, total_cost_text->w + buf->size.w);
2273 h += buf->size.h;
2274
2275 /* "Net Income" value label */
2276 buf = buf->prev;
2277 buf->size.x = area.x + adj_size(10) + net_income_text->w;
2278 buf->size.y = buf->next->size.y + buf->next->size.h;
2279
2280 w = MAX(w, net_income_text->w + buf->size.w);
2281 h += buf->size.h;
2282
2283 /* Backgrounds */
2284 dst.x = area.x;
2285 dst.y = area.y;
2286 dst.w = area.w;
2287 dst.h = h + adj_size(15);
2288 h = dst.h;
2289
2290 fill_rect_alpha(pwindow->theme, &dst, &bg_color2);
2291
2292 create_frame(pwindow->theme,
2293 dst.x, dst.y, dst.w - 1, dst.h - 1,
2295
2296 /* draw statical strings */
2297 dst.x = area.x + adj_size(10);
2298 dst.y = area.y + adj_size(5);
2299
2300 /* "Treasury */
2301 alphablit(treasury_text, NULL, pwindow->theme, &dst, 255);
2302 dst.y += treasury_text->h;
2303 FREESURFACE(treasury_text);
2304
2305 /* Tax Rate */
2306 alphablit(tax_rate_text, NULL, pwindow->theme, &dst, 255);
2307 dst.y += tax_rate_text->h;
2308 FREESURFACE(tax_rate_text);
2309
2310 /* Total Income */
2311 alphablit(total_income_text, NULL, pwindow->theme, &dst, 255);
2312 dst.y += total_income_text->h;
2313 FREESURFACE(total_income_text);
2314
2315 /* Total Cost */
2316 alphablit(total_cost_text, NULL, pwindow->theme, &dst, 255);
2317 dst.y += total_cost_text->h;
2318 FREESURFACE(total_cost_text);
2319
2320 /* Net Income */
2321 alphablit(net_income_text, NULL, pwindow->theme, &dst, 255);
2322 dst.y += net_income_text->h;
2323 FREESURFACE(net_income_text);
2324
2325 /* gov and taxrate */
2326 dst.x = area.x + adj_size(10) + w + ((area.w - (w + adj_size(10)) - max_rate_text->w) / 2);
2327 dst.y = area.y + adj_size(5);
2328
2329 alphablit(max_rate_text, NULL, pwindow->theme, &dst, 255);
2330 dst.y += (max_rate_text->h + 1);
2331 FREESURFACE(max_rate_text);
2332
2333 /* Luxuries Horizontal Scrollbar Background */
2334 dst.x = area.x + adj_size(10) + w + (area.w - (w + adj_size(10)) - adj_size(184)) / 2;
2335 dst.w = adj_size(184);
2336 dst.h = current_theme->horiz->h - adj_size(2);
2337
2338 fill_rect_alpha(pwindow->theme, &dst, &bg_color3);
2339
2340 create_frame(pwindow->theme,
2341 dst.x, dst.y, dst.w - 1, dst.h - 1,
2343
2344 /* lock icon */
2345 buf = buf->prev;
2346 buf->size.x = dst.x - buf->size.w;
2347 buf->size.y = dst.y - adj_size(2);
2348
2349 /* lux scrollbar */
2350 buf = buf->prev;
2351 buf->size.x = dst.x + adj_size(2) + (client.conn.playing->economic.luxury * 3) / 2;
2352 buf->size.y = dst.y -1;
2353
2354 /* lux rate */
2355 buf = buf->prev;
2356 buf->size.x = dst.x + dst.w + adj_size(5);
2357 buf->size.y = dst.y + 1;
2358
2359 /* Science Horizontal Scrollbar Background */
2360 dst.y += current_theme->horiz->h + 1;
2361 fill_rect_alpha(pwindow->theme, &dst, &bg_color3);
2362
2363 create_frame(pwindow->theme,
2364 dst.x, dst.y, dst.w - 1, dst.h - 1,
2366
2367 /* science lock icon */
2368 buf = buf->prev;
2369 buf->size.x = dst.x - buf->size.w;
2370 buf->size.y = dst.y - adj_size(2);
2371
2372 /* science scrollbar */
2373 buf = buf->prev;
2374 buf->size.x = dst.x + adj_size(2) + (client.conn.playing->economic.science * 3) / 2;
2375 buf->size.y = dst.y -1;
2376
2377 /* science rate */
2378 buf = buf->prev;
2379 buf->size.x = dst.x + dst.w + adj_size(5);
2380 buf->size.y = dst.y + 1;
2381
2382 /* update */
2383 buf = buf->prev;
2384 buf->size.x = dst.x + (dst.w - buf->size.w) / 2;
2385 buf->size.y = dst.y + dst.h + adj_size(3);
2386
2387 /* cancel */
2388 buf = buf->prev;
2389 buf->size.x = area.x + area.w - buf->size.w - 1;
2390 buf->size.y = pwindow->size.y + adj_size(2);
2391 /* ------------------------------- */
2392
2393 if (entries_used > 0) {
2395 area.x,
2396 area.y + h,
2399 if (economy_dlg->scroll) {
2401 area.x + area.w - 1,
2402 area.y + h,
2403 area.h - h - 1, TRUE);
2404 }
2405 }
2406
2407 /* ------------------------ */
2409 widget_mark_dirty(pwindow);
2410 flush_dirty();
2411}
2412
2413/* ===================================================================== */
2414/* ======================== Science Report ============================= */
2415/* ===================================================================== */
2416static struct small_dialog *science_dlg = NULL;
2417
2418static struct advanced_dialog *change_tech_dlg = NULL;
2419
2420/**********************************************************************/
2424 enum tech_info_mode mode)
2425{
2426 struct unit_type *punit = NULL;
2427 SDL_Surface *surf, *text, *tmp, *tmp2;
2428 SDL_Surface *surf_array[10], **buf_array;
2429 SDL_Rect dst;
2430 SDL_Color color;
2431 int w, h;
2432
2433 color = *get_tech_color(tech_id);
2434 switch (mode) {
2435 case TIM_SMALL_MODE:
2436 h = adj_size(40);
2437 w = adj_size(135);
2438 break;
2439 case TIM_MED_MODE:
2441 fc__fallthrough; /* No break, continue to setting default h & w */
2442 default:
2443 h = adj_size(200);
2444 w = adj_size(100);
2445 break;
2446 }
2447
2448 text = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
2449
2450 /* create label surface */
2451 surf = create_surf(w, h, SDL_SWSURFACE);
2452
2453 if (tech_id == research_get(client_player())->researching) {
2454 color.a = 180;
2455 } else {
2456 color.a = 128;
2457 }
2458
2459 SDL_FillRect(surf, NULL, map_rgba(surf->format, color));
2460
2461 create_frame(surf,
2462 0,0, surf->w - 1, surf->h - 1,
2464
2465 tmp = get_tech_icon(tech_id);
2466
2467 if (mode == TIM_SMALL_MODE) {
2468 /* draw name tech text */
2469 dst.x = adj_size(35) + (surf->w - text->w - adj_size(35)) / 2;
2470 dst.y = (surf->h - text->h) / 2;
2471 alphablit(text, NULL, surf, &dst, 255);
2472 FREESURFACE(text);
2473
2474 /* draw tech icon */
2475 text = resize_surface(tmp, adj_size(25), adj_size(25), 1);
2476 dst.x = (adj_size(35) - text->w) / 2;
2477 dst.y = (surf->h - text->h) / 2;
2478 alphablit(text, NULL, surf, &dst, 255);
2479 FREESURFACE(text);
2480
2481 } else {
2482
2483 /* draw name tech text */
2484 dst.x = (surf->w - text->w) / 2;
2485 dst.y = adj_size(20);
2486 alphablit(text, NULL, surf, &dst, 255);
2487 dst.y += text->h + adj_size(10);
2488 FREESURFACE(text);
2489
2490 /* draw tech icon */
2491 dst.x = (surf->w - tmp->w) / 2;
2492 alphablit(tmp, NULL, surf, &dst, 255);
2493 dst.y += tmp->w + adj_size(10);
2494
2495 /* fill array with iprvm. icons */
2496 w = 0;
2497 improvement_iterate(pimprove) {
2498 requirement_vector_iterate(&pimprove->reqs, preq) {
2499 if (VUT_ADVANCE == preq->source.kind
2500 && advance_number(preq->source.value.advance) == tech_id) {
2501 tmp2 = get_building_surface(pimprove);
2502 surf_array[w++] = zoomSurface(tmp2, DEFAULT_ZOOM * ((float)36 / tmp2->w),
2503 DEFAULT_ZOOM * ((float)36 / tmp2->w), 1);
2504 }
2507
2508 if (w) {
2509 if (w >= 2) {
2510 dst.x = (surf->w - 2 * surf_array[0]->w) / 2;
2511 } else {
2512 dst.x = (surf->w - surf_array[0]->w) / 2;
2513 }
2514
2515 /* draw iprvm. icons */
2516 buf_array = surf_array;
2517 h = 0;
2518 while (w) {
2519 alphablit(*buf_array, NULL, surf, &dst, 255);
2520 dst.x += (*buf_array)->w;
2521 w--;
2522 h++;
2523 if (!(h % 2)) {
2524 if (w >= 2) {
2525 dst.x = (surf->w - 2 * (*buf_array)->w) / 2;
2526 } else {
2527 dst.x = (surf->w - (*buf_array)->w) / 2;
2528 }
2529 dst.y += (*buf_array)->h;
2530 h = 0;
2531 } /* h == 2 */
2532 buf_array++;
2533 } /* while */
2534 dst.y += surf_array[0]->h + adj_size(5);
2535 } /* if (w) */
2536 /* -------------------------------------------------------- */
2537 w = 0;
2538 unit_type_iterate(un) {
2539 punit = un;
2540 if (advance_number(punit->require_advance) == tech_id) {
2541 surf_array[w++] = adj_surf(get_unittype_surface(un, direction8_invalid()));
2542 }
2544
2545 if (w) {
2546 if (w < 2) {
2547 /* w == 1 */
2548 if (surf_array[0]->w > 64) {
2549 float zoom = DEFAULT_ZOOM * (64.0 / surf_array[0]->w);
2550 SDL_Surface *zoomed = zoomSurface(surf_array[0], zoom, zoom, 1);
2551
2552 dst.x = (surf->w - zoomed->w) / 2;
2553 alphablit(zoomed, NULL, surf, &dst, 255);
2554 FREESURFACE(zoomed);
2555 } else {
2556 dst.x = (surf->w - surf_array[0]->w) / 2;
2557 alphablit(surf_array[0], NULL, surf, &dst, 255);
2558 }
2559 FREESURFACE(surf_array[0]);
2560 } else {
2561 float zoom;
2562
2563 if (w > 2) {
2564 zoom = DEFAULT_ZOOM * (38.0 / surf_array[0]->w);
2565 } else {
2566 zoom = DEFAULT_ZOOM * (45.0 / surf_array[0]->w);
2567 }
2568 dst.x = (surf->w - (surf_array[0]->w * 2) * zoom - 2) / 2;
2569 buf_array = surf_array;
2570 h = 0;
2571 while (w) {
2572 SDL_Surface *zoomed = zoomSurface((*buf_array), zoom, zoom, 1);
2573
2574 FREESURFACE(*buf_array);
2575 alphablit(zoomed, NULL, surf, &dst, 255);
2576 dst.x += zoomed->w + 2;
2577 w--;
2578 h++;
2579 if (!(h % 2)) {
2580 if (w >= 2) {
2581 dst.x = (surf->w - 2 * zoomed->w - 2 ) / 2;
2582 } else {
2583 dst.x = (surf->w - zoomed->w) / 2;
2584 }
2585 dst.y += zoomed->h + 2;
2586 h = 0;
2587 } /* h == 2 */
2588 buf_array++;
2589 FREESURFACE(zoomed);
2590 } /* while */
2591 } /* w > 1 */
2592 } /* if (w) */
2593 }
2594
2595 FREESURFACE(tmp);
2596
2597 return surf;
2598}
2599
2600/**********************************************************************/
2608
2609/**********************************************************************/
2617
2618/**********************************************************************/
2622{
2623 SDL_Color bg_color = {255, 255, 255, 136};
2624
2625 if (science_dlg) {
2626 const struct research *presearch = research_get(client_player());
2627 char cbuf[128];
2628 utf8_str *str;
2629 SDL_Surface *msurf;
2630 SDL_Surface *colb_surface = icons->big_colb;
2631 int step, i, cost;
2632 SDL_Rect dest;
2633 struct unit_type *punit;
2636 SDL_Rect area;
2637 struct widget *pwindow = science_dlg->end_widget_list;
2638
2639 area = pwindow->area;
2640 change_research_button = pwindow->prev;
2642
2643 if (A_UNSET != presearch->researching) {
2644 cost = presearch->client.researching_cost;
2645 } else {
2646 cost = 0;
2647 }
2648
2649 /* Update current research icons */
2651 change_research_button->theme = get_tech_icon(presearch->researching);
2654
2655 /* Redraw Window */
2656 widget_redraw(pwindow);
2657
2658 /* ------------------------------------- */
2659
2660 /* Research progress text */
2662 str->style |= SF_CENTER;
2664
2666
2667 dest.x = area.x + (area.w - msurf->w) / 2;
2668 dest.y = area.y + adj_size(2);
2669 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2670
2671 dest.y += msurf->h + adj_size(4);
2672
2674
2675 dest.x = area.x + adj_size(16);
2676
2677 /* separator */
2678 create_line(pwindow->dst->surface,
2679 dest.x, dest.y, (area.x + area.w - adj_size(16)), dest.y,
2681
2682 dest.y += adj_size(6);
2683
2685
2686 /* current research text */
2687 fc_snprintf(cbuf, sizeof(cbuf), "%s: %s",
2689 presearch->researching),
2691
2693
2695
2696 dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
2697
2698 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2699
2700 dest.y += msurf->h + adj_size(4);
2701
2703
2704 /* progress bar */
2705 if (cost > 0) {
2706 int cost_div_safe = cost - 1;
2707
2709 dest.w = cost * colb_surface->w;
2710 step = colb_surface->w;
2711 if (dest.w > (area.w - dest.x - adj_size(16))) {
2712 dest.w = (area.w - dest.x - adj_size(16));
2713 step = ((area.w - dest.x - adj_size(16)) - colb_surface->w) / cost_div_safe;
2714
2715 if (step == 0) {
2716 step = 1;
2717 }
2718 }
2719
2720 dest.h = colb_surface->h + adj_size(4);
2721 fill_rect_alpha(pwindow->dst->surface, &dest, &bg_color);
2722
2723 create_frame(pwindow->dst->surface,
2724 dest.x - 1, dest.y - 1, dest.w, dest.h,
2726
2727 if (cost > adj_size(286)) {
2728 cost = adj_size(286) * ((float) presearch->bulbs_researched / cost);
2729 } else {
2730 cost = (float) cost * ((float) presearch->bulbs_researched / cost);
2731 }
2732
2733 dest.y += adj_size(2);
2734 for (i = 0; i < cost; i++) {
2735 alphablit(colb_surface, NULL, pwindow->dst->surface, &dest, 255);
2736 dest.x += step;
2737 }
2738 }
2739
2740 /* improvement icons */
2741
2742 dest.y += dest.h + adj_size(4);
2743 dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
2744
2745 /* buildings */
2746 improvement_iterate(pimprove) {
2747 requirement_vector_iterate(&pimprove->reqs, preq) {
2748 if (VUT_ADVANCE == preq->source.kind
2749 && (advance_number(preq->source.value.advance)
2750 == presearch->researching)) {
2751 msurf = adj_surf(get_building_surface(pimprove));
2752 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2753 dest.x += msurf->w + 1;
2754 }
2757
2758 dest.x += adj_size(5);
2759
2760 /* units */
2762 punit = un;
2763 if (advance_number(punit->require_advance) == presearch->researching) {
2765 int w = usurf->w;
2766
2767 if (w > 64) {
2768 float zoom = DEFAULT_ZOOM * (64.0 / w);
2769
2770 msurf = zoomSurface(usurf, zoom, zoom, 1);
2771 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2772 dest.x += msurf->w + adj_size(2);
2774 } else {
2775 msurf = adj_surf(usurf);
2776 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2777 dest.x += msurf->w + adj_size(2);
2778 }
2779 }
2781
2782 /* -------------------------------- */
2783 /* draw separator line */
2784 dest.x = area.x + adj_size(16);
2785 dest.y += adj_size(48) + adj_size(6);
2786
2787 create_line(pwindow->dst->surface,
2788 dest.x, dest.y, (area.x + area.w - adj_size(16)), dest.y,
2790
2791 dest.x = change_research_button->size.x;
2792 dest.y += adj_size(6);
2793
2795
2796 /* -------------------------------- */
2797
2798 /* Goals */
2799 if (A_UNSET != presearch->tech_goal) {
2800 /* current goal text */
2802 (presearch, presearch->tech_goal));
2804
2805 dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
2806 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2807
2808 dest.y += msurf->h;
2809
2811
2813 (presearch->tech_goal));
2815
2816 dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
2817 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2818
2819 dest.y += msurf->h + adj_size(6);
2820
2822
2823 /* buildings */
2824 improvement_iterate(pimprove) {
2825 requirement_vector_iterate(&pimprove->reqs, preq) {
2826 if (VUT_ADVANCE == preq->source.kind
2827 && (advance_number(preq->source.value.advance)
2828 == presearch->tech_goal)) {
2829 msurf = adj_surf(get_building_surface(pimprove));
2830 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2831 dest.x += msurf->w + 1;
2832 }
2835
2836 dest.x += adj_size(6);
2837
2838 /* units */
2840 punit = un;
2841 if (advance_number(punit->require_advance) == presearch->tech_goal) {
2843 int w = usurf->w;
2844
2845 if (w > 64) {
2846 float zoom = DEFAULT_ZOOM * (64.0 / w);
2847
2848 msurf = zoomSurface(usurf, zoom, zoom, 1);
2849 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2850 dest.x += msurf->w + adj_size(2);
2852 } else {
2853 msurf = adj_surf(usurf);
2854 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2855 dest.x += msurf->w + adj_size(2);
2856 }
2857 }
2859 }
2860
2861 /* -------------------------------- */
2862 widget_mark_dirty(pwindow);
2864 flush_dirty();
2865
2867 }
2868}
2869
2870/**********************************************************************/
2885
2886/**********************************************************************/
2889static int exit_change_tech_dlg_callback(struct widget *pwidget)
2890{
2892 if (change_tech_dlg) {
2898 if (pwidget) {
2899 flush_dirty();
2900 }
2901 }
2902 }
2903
2904 return -1;
2905}
2906
2907/**********************************************************************/
2910static int change_research_callback(struct widget *pwidget)
2911{
2915 } else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
2916 popup_tech_info((MAX_ID - pwidget->id));
2917 }
2918
2919 return -1;
2920}
2921
2922/**********************************************************************/
2926{
2929 widget_flush(pwindow);
2930 }
2931 }
2932
2933 return -1;
2934}
2935
2936/**********************************************************************/
2940{
2941 const struct research *presearch = research_get(client_player());
2942 struct widget *buf = NULL;
2943 struct widget *pwindow;
2944 utf8_str *pstr;
2945 SDL_Surface *surf;
2946 int max_col, max_row, col, i, count = 0, h;
2947 SDL_Rect area;
2948
2949 if (is_future_tech(presearch->researching)) {
2950 return;
2951 }
2952
2955 continue;
2956 }
2957 count++;
2959
2960 if (count < 2) {
2961 return;
2962 }
2963
2964 change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
2965
2966 pstr = create_utf8_from_char_fonto(_("What should we focus on now?"),
2968 pstr->style |= TTF_STYLE_BOLD;
2969
2970 pwindow = create_window_skeleton(NULL, pstr, 0);
2972 set_wstate(pwindow, FC_WS_NORMAL);
2974
2976
2977 area = pwindow->area;
2978
2979 /* ------------------------- */
2980 /* Exit button */
2981 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2983 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2985 area.w += buf->size.w + adj_size(10);
2988 buf->key = SDLK_ESCAPE;
2989
2991
2992 /* ------------------------- */
2993 /* max col - 104 is select tech widget width */
2994 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
2995 /* max row - 204 is select tech widget height */
2996 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h) - adj_size(2)) / adj_size(204);
2997
2998 /* make space on screen for scrollbar */
2999 if (max_col * max_row < count) {
3000 max_col--;
3001 }
3002
3003 if (count < max_col + 1) {
3004 col = count;
3005 } else {
3006 if (count < max_col + 3) {
3007 col = max_col - 2;
3008 } else {
3009 if (count < max_col + 5) {
3010 col = max_col - 1;
3011 } else {
3012 col = max_col;
3013 }
3014 }
3015 }
3016
3018 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
3019
3020 count = 0;
3021 h = col * max_row;
3024 continue;
3025 }
3026
3027 count++;
3028
3031 buf = create_icon2(surf, pwindow->dst,
3033
3035 buf->action = change_research_callback;
3036
3038
3039 if (count > h) {
3041 }
3043
3045
3049
3050 /* -------------------------------------------------------------- */
3051
3052 i = 0;
3053 if (count > col) {
3054 count = (count + (col - 1)) / col;
3055 if (count > max_row) {
3057 count = max_row;
3059 }
3060 } else {
3061 count = 1;
3062 }
3063
3065
3066 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + i));
3067 area.h = MAX(area.h, count * buf->size.h + adj_size(2));
3068
3069 /* alloca window theme and win background buffer */
3071 resize_window(pwindow, surf, NULL,
3072 (pwindow->size.w - pwindow->area.w) + area.w,
3073 (pwindow->size.h - pwindow->area.h) + area.h);
3074 FREESURFACE(surf);
3075
3076 area = pwindow->area;
3077
3078 widget_set_position(pwindow,
3079 (main_window_width() - pwindow->size.w) / 2,
3080 (main_window_height() - pwindow->size.h) / 2);
3081
3082 /* exit button */
3083 buf = pwindow->prev;
3084 buf->size.x = area.x + area.w - buf->size.w - 1;
3085 buf->size.y = pwindow->size.y + adj_size(2);
3086
3088 area.y, 0, 0,
3091
3092 if (change_tech_dlg->scroll) {
3094 area.x + area.w, area.y,
3095 area.h, TRUE);
3096 }
3097
3099
3100 widget_flush(pwindow);
3101}
3102
3103/**********************************************************************/
3106static int change_research_goal_callback(struct widget *pwidget)
3107{
3110
3112
3113 /* Following is to make the menu go back to the current goal;
3114 * there may be a better way to do this? --dwp */
3116 } else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
3117 popup_tech_info((MAX_ID - pwidget->id));
3118 }
3119
3120 return -1;
3121}
3122
3123/**********************************************************************/
3127{
3128 const struct research *presearch = research_get(client_player());
3129 struct widget *buf = NULL;
3130 struct widget *pwindow;
3131 utf8_str *pstr;
3132 SDL_Surface *surf;
3133 char cbuf[128];
3134 int max_col, max_row, col, i, count = 0, h , num;
3135 SDL_Rect area;
3136
3137 /* Collect all techs which are reachable in under 11 steps
3138 * hist will hold afterwards the techid of the current choice
3139 */
3144 || aidx == presearch->tech_goal)) {
3145 count++;
3146 }
3148
3149 if (count < 1) {
3150 return;
3151 }
3152
3153 change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3154
3155 pstr = create_utf8_from_char_fonto(_("Select target :"), FONTO_ATTENTION);
3156 pstr->style |= TTF_STYLE_BOLD;
3157
3158 pwindow = create_window_skeleton(NULL, pstr, 0);
3160 set_wstate(pwindow, FC_WS_NORMAL);
3162
3164
3165 area = pwindow->area;
3166
3167 /* ------------------------- */
3168 /* Exit button */
3169 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3171 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3173 area.w += buf->size.w + adj_size(10);
3176 buf->key = SDLK_ESCAPE;
3177
3179
3180 /* ------------------------- */
3181 /* max col - 104 is goal tech widget width */
3182 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
3183
3184 /* max row - 204 is goal tech widget height */
3185 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h) - adj_size(2)) / adj_size(204);
3186
3187 /* make space on screen for scrollbar */
3188 if (max_col * max_row < count) {
3189 max_col--;
3190 }
3191
3192 if (count < max_col + 1) {
3193 col = count;
3194 } else {
3195 if (count < max_col + 3) {
3196 col = max_col - 2;
3197 } else {
3198 if (count < max_col + 5) {
3199 col = max_col - 1;
3200 } else {
3201 col = max_col;
3202 }
3203 }
3204 }
3205
3207 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
3208
3209 /* Collect all techs which are reachable in under 11 steps
3210 * hist will hold afterwards the techid of the current choice
3211 */
3212 count = 0;
3213 h = col * max_row;
3217 && (11 > (num = research_goal_unknown_techs(presearch, aidx))
3218 || aidx == presearch->tech_goal)) {
3219
3220 count++;
3221 fc_snprintf(cbuf, sizeof(cbuf), "%s\n%d %s",
3223 num,
3224 PL_("step", "steps", num));
3227 buf = create_icon2(surf, pwindow->dst,
3229
3232
3234
3235 if (count > h) {
3237 }
3238 }
3240
3242
3246
3247 /* -------------------------------------------------------------- */
3248
3249 i = 0;
3250 if (count > col) {
3251 count = (count + (col-1)) / col;
3252 if (count > max_row) {
3254 count = max_row;
3256 }
3257 } else {
3258 count = 1;
3259 }
3260
3262
3263 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + i));
3264 area.h = MAX(area.h, count * buf->size.h + adj_size(2));
3265
3266 /* Alloca window theme and win background buffer */
3268 resize_window(pwindow, surf, NULL,
3269 (pwindow->size.w - pwindow->area.w) + area.w,
3270 (pwindow->size.h - pwindow->area.h) + area.h);
3271 FREESURFACE(surf);
3272
3273 area = pwindow->area;
3274
3275 widget_set_position(pwindow,
3276 (main_window_width() - pwindow->size.w) / 2,
3277 (main_window_height() - pwindow->size.h) / 2);
3278
3279 /* Exit button */
3280 buf = pwindow->prev;
3281 buf->size.x = area.x + area.w - buf->size.w - 1;
3282 buf->size.y = pwindow->size.y + adj_size(2);
3283
3285 area.y, 0, 0,
3288
3289 if (change_tech_dlg->scroll) {
3291 area.x + area.w, area.y,
3292 area.h, TRUE);
3293 }
3294
3296
3297 widget_flush(pwindow);
3298}
3299
3300/**********************************************************************/
3303static int science_dialog_callback(struct widget *pwindow)
3304{
3306 if (!change_tech_dlg) {
3308 widget_flush(pwindow);
3309 }
3312 }
3313 }
3314 }
3315
3316 return -1;
3317}
3318
3319/**********************************************************************/
3323{
3325 set_wstate(pwidget, FC_WS_NORMAL);
3327 widget_redraw(pwidget);
3328 widget_flush(pwidget);
3329
3331 }
3332
3333 return -1;
3334}
3335
3336/**********************************************************************/
3340{
3342 set_wstate(pwidget, FC_WS_NORMAL);
3344 widget_redraw(pwidget);
3345 widget_flush(pwidget);
3346
3348 }
3349
3350 return -1;
3351}
3352
3353/**********************************************************************/
3356static int popdown_science_dialog_callback(struct widget *pwidget)
3357{
3360 }
3361
3362 return -1;
3363}
3364
3365/**********************************************************************/
3369{
3370 const struct research *presearch;
3371 struct widget *pwidget, *pwindow;
3374 struct widget *exit_button;
3375 utf8_str *pstr;
3376 SDL_Surface *background, *tech_icon;
3377 int count;
3378 SDL_Rect area;
3379
3380 if (science_dlg) {
3381 return;
3382 }
3383
3385
3386 /* Disable research button */
3387 pwidget = get_research_widget();
3388 set_wstate(pwidget, FC_WS_DISABLED);
3389 widget_redraw(pwidget);
3390 widget_mark_dirty(pwidget);
3391
3392 science_dlg = fc_calloc(1, sizeof(struct small_dialog));
3393
3394 /* TRANS: Research report title */
3396 pstr->style |= TTF_STYLE_BOLD;
3397
3398#ifdef SMALL_SCREEN
3399 pwindow = create_window(NULL, pstr, 200, 132, 0);
3400#else /* SMALL_SCREEN */
3401 pwindow = create_window(NULL, pstr, adj_size(400), adj_size(246), 0);
3402#endif /* SMALL_SCREEN */
3403 set_wstate(pwindow, FC_WS_NORMAL);
3405
3406 science_dlg->end_widget_list = pwindow;
3407
3409 FREESURFACE(pwindow->theme);
3410 pwindow->theme = resize_surface(background, pwindow->size.w,
3411 pwindow->size.h, 1);
3412 FREESURFACE(background);
3413
3414 area = pwindow->area;
3415
3416 widget_set_position(pwindow,
3417 (main_window_width() - pwindow->size.w) / 2,
3418 (main_window_height() - pwindow->size.h) / 2);
3419
3421
3422 /* count number of researchable techs */
3423 count = 0;
3427 count++;
3428 }
3430
3431 /* current research icon */
3432 tech_icon = get_tech_icon(presearch->researching);
3435
3437 if (count > 0) {
3439 }
3440
3442
3443 /* current research goal icon */
3444 tech_icon = get_tech_icon(presearch->tech_goal);
3447
3449 if (count > 0) {
3451 }
3452
3454
3455 /* ------ */
3456 /* Exit button */
3457 exit_button = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3460 exit_button->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3464 exit_button->key = SDLK_ESCAPE;
3465
3467
3469 area.x + area.w - exit_button->size.w - adj_size(1),
3470 pwindow->size.y + adj_size(2));
3471
3472 /* ======================== */
3474
3476}
3477
3478/**********************************************************************/
3498
3499/**********************************************************************/
3503{
3504 /* No requirement tree yet. */
3505}
3506
3507/* ===================================================================== */
3508/* ======================== Endgame Report ============================= */
3509/* ===================================================================== */
3510
3511static char eg_buffer[150 * MAX_NUM_PLAYERS];
3512static int eg_player_count = 0;
3513static int eg_players_received = 0;
3514
3515/**********************************************************************/
3520{
3521 eg_buffer[0] = '\0';
3522 eg_player_count = packet->player_num;
3524}
3525
3526/**********************************************************************/
3530{
3531 const struct player *pplayer = player_by_number(packet->player_id);
3532
3534
3536 PL_("%2d: The %s ruler %s scored %d point\n",
3537 "%2d: The %s ruler %s scored %d points\n",
3538 packet->score),
3540 player_name(pplayer), packet->score);
3541
3543 popup_notify_dialog(_("Final Report:"),
3544 _("The Greatest Civilizations in the world."),
3545 eg_buffer);
3546 }
3547}
int entries_used
Definition agents.c:74
struct @124::my_agent entries[MAX_AGENTS]
#define str
Definition astring.c:76
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1216
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:805
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:732
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define output_type_iterate(output)
Definition city.h:821
#define city_list_iterate_end
Definition city.h:490
#define output_type_iterate_end
Definition city.h:827
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
struct civclient client
enum client_states client_state(void)
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
popup_notify_dialog
Definition dialogs_g.h:36
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:73
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:771
QString current_theme
Definition fc_client.cpp:65
int Tech_type_id
Definition fc_types.h:347
#define MAX_NUM_PLAYERS
Definition fc_types.h:36
int Unit_type_id
Definition fc_types.h:352
@ O_SHIELD
Definition fc_types.h:91
@ O_FOOD
Definition fc_types.h:91
@ O_GOLD
Definition fc_types.h:91
@ O_LAST
Definition fc_types.h:91
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
struct government * government_of_player(const struct player *pplayer)
Definition government.c:113
void flush_dirty(void)
Definition mapview.c:450
void units_report_dialog_popdown(void)
Definition repodlgs.c:1780
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1980
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1791
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1267
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1257
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1242
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1765
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1236
int main_window_width(void)
Definition graphics.c:685
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1378
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1347
int main_window_height(void)
Definition graphics.c:693
#define DEFAULT_ZOOM
Definition graphics.h:198
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_surf(surf)
Definition graphics.h:200
#define map_rgba(format, color)
Definition graphics.h:315
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:572
int MOVE_STEP_Y
Definition gui_main.c:101
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:593
Uint32 sdl2_client_flags
Definition gui_main.c:97
#define CF_CHANGE_TAXRATE_SCI_BLOCK
Definition gui_main.h:53
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:138
#define DEFAULT_MOVE_STEP
Definition gui_main.h:110
#define PRESSED_EVENT(event)
Definition gui_main.h:68
#define CF_CHANGE_TAXRATE_LUX_BLOCK
Definition gui_main.h:52
void popup_tech_info(Tech_type_id tech)
Definition helpdlg.c:1930
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
static int popdown_science_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3356
static void popup_change_research_goal_dialog(void)
Definition repodlgs.c:3126
static int sell_impr_window_callback(struct widget *pwindow)
Definition repodlgs.c:1561
static int eg_player_count
Definition repodlgs.c:3512
static int eg_players_received
Definition repodlgs.c:3513
static struct advanced_dialog * units_dlg
Definition repodlgs.c:61
static int exit_economy_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:1145
static int ok_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1525
static int cancel_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1573
static int horiz_taxrate_callback(struct widget *horiz_src)
Definition repodlgs.c:1319
SDL_Surface * create_select_tech_icon(utf8_str *pstr, Tech_type_id tech_id, enum tech_info_mode mode)
Definition repodlgs.c:2423
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition repodlgs.c:134
void science_report_dialogs_popdown_all(void)
Definition repodlgs.c:3481
static struct small_dialog * science_dlg
Definition repodlgs.c:2416
static int change_research_goal_callback(struct widget *pwidget)
Definition repodlgs.c:3106
static int economy_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:1133
#define TARGETS_ROW
Definition repodlgs.c:1816
static struct advanced_dialog * change_tech_dlg
Definition repodlgs.c:2418
static int apply_taxrates_callback(struct widget *button)
Definition repodlgs.c:1408
static int toggle_block_callback(struct widget *pcheckbox)
Definition repodlgs.c:1171
static void real_activeunits_report_dialog_update(struct units_entry *units, struct units_entry *total)
Definition repodlgs.c:356
static void enable_economy_dlg(void)
Definition repodlgs.c:1445
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition repodlgs.c:165
static struct small_dialog * economy_sell_dlg
Definition repodlgs.c:1121
static int popup_change_research_goal_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3339
static char eg_buffer[150 *MAX_NUM_PLAYERS]
Definition repodlgs.c:3511
static void popup_change_research_dialog(void)
Definition repodlgs.c:2939
#define TARGETS_COL
Definition repodlgs.c:1817
static int change_research_goal_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:2925
static int exit_change_tech_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:2889
static int exit_units_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:333
static void disable_science_dialog(void)
Definition repodlgs.c:2612
static void enable_science_dialog(void)
Definition repodlgs.c:2603
static int popup_change_research_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3322
static void get_units_report_data(struct units_entry *entries, struct units_entry *total)
Definition repodlgs.c:74
static struct advanced_dialog * economy_dlg
Definition repodlgs.c:1120
static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event, void *data)
Definition repodlgs.c:1194
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition repodlgs.c:153
static int units_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:120
static int popup_upgrade_unit_callback(struct widget *pwidget)
Definition repodlgs.c:182
static int popup_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1591
static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition repodlgs.c:1203
static int science_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:3303
static int change_research_callback(struct widget *pwidget)
Definition repodlgs.c:2910
static struct small_dialog * units_upg_dlg
Definition repodlgs.c:62
static void disable_economy_dlg(void)
Definition repodlgs.c:1484
tech_info_mode
Definition repodlgs.h:29
@ TIM_SMALL_MODE
Definition repodlgs.h:32
@ TIM_MED_MODE
Definition repodlgs.h:31
@ TIM_FULL_MODE
Definition repodlgs.h:30
@ ID_SCIENCE_CANCEL_DLG_BUTTON
Definition gui_id.h:187
@ ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR
Definition gui_id.h:176
@ ID_UNITS_DIALOG_WINDOW
Definition gui_id.h:136
@ ID_SCIENCE_DLG_CHANGE_GOAL_CANCEL_BUTTON
Definition gui_id.h:194
@ ID_SCIENCE_DLG_CHANGE_GOAL_WINDOW
Definition gui_id.h:191
@ ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX
Definition gui_id.h:181
@ ID_ECONOMY_DIALOG_WINDOW
Definition gui_id.h:135
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:203
@ ID_ERROR
Definition gui_id.h:26
@ ID_SCIENCE_DLG_CHANGE_REASARCH_WINDOW
Definition gui_id.h:189
@ ID_BUTTON
Definition gui_id.h:29
@ ID_CHANGE_TAXRATE_DLG_SCI_LABEL
Definition gui_id.h:179
@ ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR
Definition gui_id.h:175
@ ID_CHANGE_TAXRATE_DLG_OK_BUTTON
Definition gui_id.h:184
@ ID_SCROLLBAR
Definition gui_id.h:32
@ ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON
Definition gui_id.h:188
@ ID_LABEL
Definition gui_id.h:27
@ ID_CHANGE_TAXRATE_DLG_LUX_LABEL
Definition gui_id.h:178
@ ID_SCIENCE_DLG_WINDOW
Definition gui_id.h:186
@ ID_WINDOW
Definition gui_id.h:30
@ ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX
Definition gui_id.h:182
@ ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON
Definition gui_id.h:190
@ ID_CHANGE_TAXRATE_DLG_CANCEL_BUTTON
Definition gui_id.h:185
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
#define create_utf8_from_char(string_in, ptsize)
Definition gui_string.h:102
#define FREEUTF8STR(pstr)
Definition gui_string.h:92
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:64
@ FONTO_SLIGHTLY_BIGGER
Definition gui_string.h:65
@ FONTO_ATTENTION
Definition gui_string.h:66
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
struct city_icon * icons
SDL_Color * get_tech_color(Tech_type_id tech_id)
SDL_Surface * get_tech_icon(Tech_type_id tech)
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
struct impr_type * improvement_by_number(const Impr_type_id id)
int impr_sell_gold(const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:168
int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:774
struct player * player_by_number(const int player_id)
Definition player.c:840
const char * player_name(const struct player *pplayer)
Definition player.c:886
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
endgame_report_dialog_player
Definition repodlgs_g.h:33
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:747
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:665
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
int step
Definition specpq.h:92
struct widget * active_widget_list
Definition widget.h:186
struct widget * end_widget_list
Definition widget.h:182
struct widget * begin_widget_list
Definition widget.h:181
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_active_widget_list
Definition widget.h:185
struct scroll_bar * scroll
Definition widget.h:187
SDL_Surface * big_colb
SDL_Surface * big_coin
SDL_Surface * big_luxury
SDL_Surface * big_shield
SDL_Surface * big_food
struct connection conn
Definition client_main.h:96
Definition colors.h:20
struct player * playing
Definition connection.h:156
int id1
Definition widget.h:104
int id0
Definition widget.h:103
int value
Definition widget.h:105
SDL_Surface * surface
Definition graphics.h:229
int cost
struct impr_type * type
int total_cost
int count
struct city_list * cities
Definition player.h:281
struct unit_list * units
Definition player.h:282
struct player_economic economic
Definition player.h:284
int * dst_rate
Definition repodlgs.c:1125
struct widget * label_dst
Definition repodlgs.c:1127
struct widget * horiz_src
Definition repodlgs.c:1126
int * src_rate
Definition repodlgs.c:1125
struct widget * label_src
Definition repodlgs.c:1127
struct widget * horiz_dst
Definition repodlgs.c:1126
struct widget * up_left_button
struct widget * pscroll_bar
struct widget * down_right_button
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
int upkeep[O_LAST]
Definition unit.h:148
int homecity
Definition unit.h:146
Definition repodlgs.c:64
int soonest_completions
Definition repodlgs.c:68
int upkeep[O_LAST]
Definition repodlgs.c:66
int building_count
Definition repodlgs.c:67
int active_count
Definition repodlgs.c:65
Uint8 style
Definition gui_string.h:53
SDL_Color bgcol
Definition gui_string.h:58
SDL_Color fgcol
Definition gui_string.h:57
struct widget * next
Definition widget.h:113
void * ptr
Definition widget.h:133
utf8_str * info_label
Definition widget.h:122
SDL_Keycode key
Definition widget.h:153
union widget::@214 data
struct gui_layer * dst
Definition widget.h:116
struct widget * prev
Definition widget.h:114
int(* action)(struct widget *)
Definition widget.h:157
struct container * cont
Definition widget.h:127
Uint16 mod
Definition widget.h:154
SDL_Surface * theme
Definition widget.h:118
utf8_str * string_utf8
Definition widget.h:121
SDL_Rect area
Definition widget.h:149
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:109
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_index_iterate_end
Definition tech.h:248
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:244
const char * get_science_target_text(double *percent)
Definition text.c:853
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:899
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_SCIENCEDLG
@ BACKGROUND_CHANGERESEARCHDLG
@ BACKGROUND_UNITSREP
@ BACKGROUND_ECONOMYDLG
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
@ COLOR_THEME_ECONOMYDLG_TEXT
Definition themecolors.h:85
@ COLOR_THEME_SCIENCEDLG_MED_TECHICON_BG
@ COLOR_THEME_UNITUPGRADE_TEXT
@ COLOR_THEME_UNITSREP_FRAME
@ COLOR_THEME_ECONOMYDLG_FRAME
Definition themecolors.h:83
@ COLOR_THEME_SELLIMPR_TEXT
@ COLOR_THEME_UNITSREP_TEXT
@ COLOR_THEME_ECONOMYDLG_NEG_TEXT
Definition themecolors.h:84
@ COLOR_THEME_SCIENCEDLG_FRAME
@ COLOR_THEME_SCIENCEDLG_TEXT
struct theme * active_theme
Definition themespec.c:154
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1783
#define unit_type_iterate(_p)
Definition unittype.h:841
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:848
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:897
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:585
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:862
bool move_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:1015
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1150
void unselect_widget_action(void)
Definition widget.c:417
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:997
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:1050
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:982
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1038
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_SELECTED
Definition widget.h:97
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *pwidget) fc__attribute((nonnull(2)))
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_FREE_DATA
Definition widget.h:78
@ WF_ICON_CENTER_RIGHT
Definition widget.h:84
@ WF_SELECT_WITHOUT_BAR
Definition widget.h:89
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
int set_new_checkbox_theme(struct widget *cbox, SDL_Surface *true_surf, SDL_Surface *false_surf)
struct widget * create_checkbox(struct gui_layer *pdest, bool state, Uint32 flags)
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
void remake_label_size(struct widget *label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
struct widget * create_horizontal(SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
int resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)