Freeciv-3.2
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/* ===================================================================== */
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));
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;
102 int num_units;
103
104 /* Account for build slots in city */
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];
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 */
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) {
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
1097}
1098
1099/**************************************************************************
1100 Popdown the units report.
1101**************************************************************************/
1116
1117/* ===================================================================== */
1118/* ======================== Economy Report ============================= */
1119/* ===================================================================== */
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
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;
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;
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);
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 */
1386 gui_event_loop((void *)(&motion), NULL, NULL, NULL, NULL, NULL, NULL,
1387 NULL, NULL,
1390 /* Turn off Filter mouse motion events */
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);
1763 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1765
1766 /* Icome */
1767 pbuf = pbuf->prev->prev;
1768 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax);
1769 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1771
1772 /* Cost */
1773 pbuf = pbuf->prev;
1774 fc_snprintf(cbuf, sizeof(cbuf), "%d", total);
1775 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1777
1778 /* Netto */
1779 pbuf = pbuf->prev;
1780 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax - total);
1781 copy_chars_to_utf8_str(pbuf->string_utf8, cbuf);
1783 if (tax - total < 0) {
1785 } else {
1786 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_ECONOMYDLG_TEXT);
1787 }
1788
1789 /* ---------------- */
1792 }
1793}
1794
1795/**********************************************************************/
1815
1816#define TARGETS_ROW 2
1817#define TARGETS_COL 4
1818
1819/**********************************************************************/
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;
1848
1849 if (economy_dlg) {
1850 return;
1851 }
1852
1853 /* disable "Economy" button */
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;
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: "));
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
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: "));
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
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: "));
1939
1940 /* "Total Cost" value label */
1941 fc_snprintf(cbuf, sizeof(cbuf), "%d", total);
1943 pstr->style |= TTF_STYLE_BOLD;
1944
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: "));
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
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%%"),
1980
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,
1995 current_theme->unlock_icon);
1996 buf->info_label = pstr;
1997 buf->action = toggle_block_callback;
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
2008 buf->action = horiz_taxrate_callback;
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
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
2043 current_theme->unlock_icon);
2044
2045 buf->info_label = pstr;
2046 buf->action = toggle_block_callback;
2048
2050
2051 /* Science rate slider */
2052 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
2054
2055 buf->action = horiz_taxrate_callback;
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);
2080 buf->action = apply_taxrates_callback;
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
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
2127 pstr->style |= TTF_STYLE_BOLD;
2129
2130 fc_snprintf(cbuf, sizeof(cbuf), "%s %d\n%s %d",
2131 _("Built"), p->count, _("U Total"),p->total_cost);
2133 pstr->style &= ~TTF_STYLE_BOLD;
2134
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;
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
2171
2172 dst.x = (surf->w - zoomed->w) / 2;
2173 alphablit(zoomed, NULL, surf, &dst, 255);
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);
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;
2192 buf->action = popup_sell_impr_callback;
2193
2195
2196 if (i > (TARGETS_ROW * TARGETS_COL - 1)) {
2198 }
2199 }
2200
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;
2304
2305 /* Tax Rate */
2306 alphablit(tax_rate_text, NULL, pwindow->theme, &dst, 255);
2307 dst.y += tax_rate_text->h;
2309
2310 /* Total Income */
2311 alphablit(total_income_text, NULL, pwindow->theme, &dst, 255);
2312 dst.y += total_income_text->h;
2314
2315 /* Total Cost */
2316 alphablit(total_cost_text, NULL, pwindow->theme, &dst, 255);
2317 dst.y += total_cost_text->h;
2319
2320 /* Net Income */
2321 alphablit(net_income_text, NULL, pwindow->theme, &dst, 255);
2322 dst.y += net_income_text->h;
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);
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/* ===================================================================== */
2417
2419
2420/**********************************************************************/
2424 enum tech_info_mode mode)
2425{
2426 SDL_Surface *surf, *text, *tmp, *tmp2;
2428 SDL_Rect dst;
2430 int w, h;
2431
2432 color = *get_tech_color(tech_id);
2433 switch (mode) {
2434 case TIM_SMALL_MODE:
2435 h = adj_size(40);
2436 w = adj_size(135);
2437 break;
2438 case TIM_MED_MODE:
2440 fc__fallthrough; /* No break, continue to setting default h & w */
2441 default:
2442 h = adj_size(200);
2443 w = adj_size(100);
2444 break;
2445 }
2446
2448
2449 /* create label surface */
2450 surf = create_surf(w, h, SDL_SWSURFACE);
2451
2452 if (tech_id == research_get(client_player())->researching) {
2453 color.a = 180;
2454 } else {
2455 color.a = 128;
2456 }
2457
2458 SDL_FillRect(surf, NULL, map_rgba(surf->format, color));
2459
2460 create_frame(surf,
2461 0,0, surf->w - 1, surf->h - 1,
2463
2464 tmp = get_tech_icon(tech_id);
2465
2466 if (mode == TIM_SMALL_MODE) {
2467 /* draw name tech text */
2468 dst.x = adj_size(35) + (surf->w - text->w - adj_size(35)) / 2;
2469 dst.y = (surf->h - text->h) / 2;
2470 alphablit(text, NULL, surf, &dst, 255);
2471 FREESURFACE(text);
2472
2473 /* draw tech icon */
2474 text = resize_surface(tmp, adj_size(25), adj_size(25), 1);
2475 dst.x = (adj_size(35) - text->w) / 2;
2476 dst.y = (surf->h - text->h) / 2;
2477 alphablit(text, NULL, surf, &dst, 255);
2478 FREESURFACE(text);
2479
2480 } else {
2481
2482 /* draw name tech text */
2483 dst.x = (surf->w - text->w) / 2;
2484 dst.y = adj_size(20);
2485 alphablit(text, NULL, surf, &dst, 255);
2486 dst.y += text->h + adj_size(10);
2487 FREESURFACE(text);
2488
2489 /* draw tech icon */
2490 dst.x = (surf->w - tmp->w) / 2;
2491 alphablit(tmp, NULL, surf, &dst, 255);
2492 dst.y += tmp->w + adj_size(10);
2493
2494 /* fill array with iprvm. icons */
2495 w = 0;
2496 improvement_iterate(pimprove) {
2497 requirement_vector_iterate(&pimprove->reqs, preq) {
2498 if (VUT_ADVANCE == preq->source.kind
2499 && advance_number(preq->source.value.advance) == tech_id) {
2500 tmp2 = get_building_surface(pimprove);
2501 surf_array[w++] = zoomSurface(tmp2, DEFAULT_ZOOM * ((float)36 / tmp2->w),
2502 DEFAULT_ZOOM * ((float)36 / tmp2->w), 1);
2503 }
2506
2507 if (w) {
2508 if (w >= 2) {
2509 dst.x = (surf->w - 2 * surf_array[0]->w) / 2;
2510 } else {
2511 dst.x = (surf->w - surf_array[0]->w) / 2;
2512 }
2513
2514 /* draw iprvm. icons */
2516 h = 0;
2517 while (w) {
2518 alphablit(*buf_array, NULL, surf, &dst, 255);
2519 dst.x += (*buf_array)->w;
2520 w--;
2521 h++;
2522 if (!(h % 2)) {
2523 if (w >= 2) {
2524 dst.x = (surf->w - 2 * (*buf_array)->w) / 2;
2525 } else {
2526 dst.x = (surf->w - (*buf_array)->w) / 2;
2527 }
2528 dst.y += (*buf_array)->h;
2529 h = 0;
2530 } /* h == 2 */
2531 buf_array++;
2532 } /* while */
2533 dst.y += surf_array[0]->h + adj_size(5);
2534 } /* if (w) */
2535 /* -------------------------------------------------------- */
2536 w = 0;
2540 }
2542
2543 if (w) {
2544 if (w < 2) {
2545 /* w == 1 */
2546 if (surf_array[0]->w > 64) {
2547 float zoom = DEFAULT_ZOOM * (64.0 / surf_array[0]->w);
2548 SDL_Surface *zoomed = zoomSurface(surf_array[0], zoom, zoom, 1);
2549
2550 dst.x = (surf->w - zoomed->w) / 2;
2551 alphablit(zoomed, NULL, surf, &dst, 255);
2553 } else {
2554 dst.x = (surf->w - surf_array[0]->w) / 2;
2555 alphablit(surf_array[0], NULL, surf, &dst, 255);
2556 }
2558 } else {
2559 float zoom;
2560
2561 if (w > 2) {
2562 zoom = DEFAULT_ZOOM * (38.0 / surf_array[0]->w);
2563 } else {
2564 zoom = DEFAULT_ZOOM * (45.0 / surf_array[0]->w);
2565 }
2566 dst.x = (surf->w - (surf_array[0]->w * 2) * zoom - 2) / 2;
2568 h = 0;
2569 while (w) {
2570 SDL_Surface *zoomed = zoomSurface((*buf_array), zoom, zoom, 1);
2571
2573 alphablit(zoomed, NULL, surf, &dst, 255);
2574 dst.x += zoomed->w + 2;
2575 w--;
2576 h++;
2577 if (!(h % 2)) {
2578 if (w >= 2) {
2579 dst.x = (surf->w - 2 * zoomed->w - 2 ) / 2;
2580 } else {
2581 dst.x = (surf->w - zoomed->w) / 2;
2582 }
2583 dst.y += zoomed->h + 2;
2584 h = 0;
2585 } /* h == 2 */
2586 buf_array++;
2588 } /* while */
2589 } /* w > 1 */
2590 } /* if (w) */
2591 }
2592
2594
2595 return surf;
2596}
2597
2598/**********************************************************************/
2606
2607/**********************************************************************/
2615
2616/**********************************************************************/
2620{
2621 SDL_Color bg_color = {255, 255, 255, 136};
2622
2623 if (science_dlg) {
2624 const struct research *presearch = research_get(client_player());
2625 char cbuf[128];
2626 utf8_str *str;
2629 int step, i, cost;
2630 SDL_Rect dest;
2633 SDL_Rect area;
2634 struct widget *pwindow = science_dlg->end_widget_list;
2635
2636 area = pwindow->area;
2637 change_research_button = pwindow->prev;
2639
2640 if (A_UNSET != presearch->researching) {
2641 cost = presearch->client.researching_cost;
2642 } else {
2643 cost = 0;
2644 }
2645
2646 /* Update current research icons */
2648 change_research_button->theme = get_tech_icon(presearch->researching);
2651
2652 /* Redraw Window */
2653 widget_redraw(pwindow);
2654
2655 /* ------------------------------------- */
2656
2657 /* Research progress text */
2659 str->style |= SF_CENTER;
2661
2663
2664 dest.x = area.x + (area.w - msurf->w) / 2;
2665 dest.y = area.y + adj_size(2);
2666 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2667
2668 dest.y += msurf->h + adj_size(4);
2669
2671
2672 dest.x = area.x + adj_size(16);
2673
2674 /* separator */
2675 create_line(pwindow->dst->surface,
2676 dest.x, dest.y, (area.x + area.w - adj_size(16)), dest.y,
2678
2679 dest.y += adj_size(6);
2680
2682
2683 /* current research text */
2684 fc_snprintf(cbuf, sizeof(cbuf), "%s: %s",
2686 presearch->researching),
2688
2690
2692
2693 dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
2694
2695 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2696
2697 dest.y += msurf->h + adj_size(4);
2698
2700
2701 /* progress bar */
2702 if (cost > 0) {
2703 int cost_div_safe = cost - 1;
2704
2706 dest.w = cost * colb_surface->w;
2707 step = colb_surface->w;
2708 if (dest.w > (area.w - dest.x - adj_size(16))) {
2709 dest.w = (area.w - dest.x - adj_size(16));
2710 step = ((area.w - dest.x - adj_size(16)) - colb_surface->w) / cost_div_safe;
2711
2712 if (step == 0) {
2713 step = 1;
2714 }
2715 }
2716
2717 dest.h = colb_surface->h + adj_size(4);
2718 fill_rect_alpha(pwindow->dst->surface, &dest, &bg_color);
2719
2720 create_frame(pwindow->dst->surface,
2721 dest.x - 1, dest.y - 1, dest.w, dest.h,
2723
2724 if (cost > adj_size(286)) {
2725 cost = adj_size(286) * ((float) presearch->bulbs_researched / cost);
2726 } else {
2727 cost = (float) cost * ((float) presearch->bulbs_researched / cost);
2728 }
2729
2730 dest.y += adj_size(2);
2731 for (i = 0; i < cost; i++) {
2732 alphablit(colb_surface, NULL, pwindow->dst->surface, &dest, 255);
2733 dest.x += step;
2734 }
2735 }
2736
2737 /* improvement icons */
2738
2739 dest.y += dest.h + adj_size(4);
2740 dest.x = change_research_button->size.x + change_research_button->size.w + adj_size(10);
2741
2742 /* buildings */
2743 improvement_iterate(pimprove) {
2744 requirement_vector_iterate(&pimprove->reqs, preq) {
2745 if (VUT_ADVANCE == preq->source.kind
2746 && (advance_number(preq->source.value.advance)
2747 == presearch->researching)) {
2748 msurf = adj_surf(get_building_surface(pimprove));
2749 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2750 dest.x += msurf->w + 1;
2751 }
2754
2755 dest.x += adj_size(5);
2756
2757 /* Units */
2761 int w = usurf->w;
2762
2763 if (w > 64) {
2764 float zoom = DEFAULT_ZOOM * (64.0 / w);
2765
2766 msurf = zoomSurface(usurf, zoom, zoom, 1);
2767 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2768 dest.x += msurf->w + adj_size(2);
2770 } else {
2771 msurf = adj_surf(usurf);
2772 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2773 dest.x += msurf->w + adj_size(2);
2774 }
2775 }
2777
2778 /* -------------------------------- */
2779 /* draw separator line */
2780 dest.x = area.x + adj_size(16);
2781 dest.y += adj_size(48) + adj_size(6);
2782
2783 create_line(pwindow->dst->surface,
2784 dest.x, dest.y, (area.x + area.w - adj_size(16)), dest.y,
2786
2787 dest.x = change_research_button->size.x;
2788 dest.y += adj_size(6);
2789
2791
2792 /* -------------------------------- */
2793
2794 /* Goals */
2795 if (A_UNSET != presearch->tech_goal) {
2796 /* current goal text */
2798 (presearch, presearch->tech_goal));
2800
2801 dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
2802 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2803
2804 dest.y += msurf->h;
2805
2807
2809 (presearch->tech_goal));
2811
2812 dest.x = change_research_goal_button->size.x + change_research_goal_button->size.w + adj_size(10);
2813 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2814
2815 dest.y += msurf->h + adj_size(6);
2816
2818
2819 /* buildings */
2820 improvement_iterate(pimprove) {
2821 requirement_vector_iterate(&pimprove->reqs, preq) {
2822 if (VUT_ADVANCE == preq->source.kind
2823 && (advance_number(preq->source.value.advance)
2824 == presearch->tech_goal)) {
2825 msurf = adj_surf(get_building_surface(pimprove));
2826 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2827 dest.x += msurf->w + 1;
2828 }
2831
2832 dest.x += adj_size(6);
2833
2834 /* units */
2838 int w = usurf->w;
2839
2840 if (w > 64) {
2841 float zoom = DEFAULT_ZOOM * (64.0 / w);
2842
2843 msurf = zoomSurface(usurf, zoom, zoom, 1);
2844 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2845 dest.x += msurf->w + adj_size(2);
2847 } else {
2848 msurf = adj_surf(usurf);
2849 alphablit(msurf, NULL, pwindow->dst->surface, &dest, 255);
2850 dest.x += msurf->w + adj_size(2);
2851 }
2852 }
2854 }
2855
2856 /* -------------------------------- */
2857 widget_mark_dirty(pwindow);
2859 flush_dirty();
2860
2862 }
2863}
2864
2865/**********************************************************************/
2880
2881/**********************************************************************/
2884static int exit_change_tech_dlg_callback(struct widget *pwidget)
2885{
2887 if (change_tech_dlg) {
2893 if (pwidget) {
2894 flush_dirty();
2895 }
2896 }
2897 }
2898
2899 return -1;
2900}
2901
2902/**********************************************************************/
2905static int change_research_callback(struct widget *pwidget)
2906{
2910 } else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
2911 popup_tech_info((MAX_ID - pwidget->id));
2912 }
2913
2914 return -1;
2915}
2916
2917/**********************************************************************/
2921{
2924 widget_flush(pwindow);
2925 }
2926 }
2927
2928 return -1;
2929}
2930
2931/**********************************************************************/
2935{
2936 const struct research *presearch = research_get(client_player());
2937 struct widget *buf = NULL;
2938 struct widget *pwindow;
2939 utf8_str *pstr;
2940 SDL_Surface *surf;
2941 int max_col, max_row, col, i, count = 0, h;
2942 SDL_Rect area;
2944
2945 if (is_future_tech(presearch->researching)) {
2946 return;
2947 }
2948
2949 ac = advance_count();
2952 continue;
2953 }
2954 count++;
2956
2957 if (count < 2) {
2958 return;
2959 }
2960
2961 change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
2962
2963 pstr = create_utf8_from_char_fonto(_("What should we focus on now?"),
2965 pstr->style |= TTF_STYLE_BOLD;
2966
2967 pwindow = create_window_skeleton(NULL, pstr, 0);
2969 set_wstate(pwindow, FC_WS_NORMAL);
2971
2973
2974 area = pwindow->area;
2975
2976 /* ------------------------- */
2977 /* Exit button */
2978 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2980 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2982 area.w += buf->size.w + adj_size(10);
2985 buf->key = SDLK_ESCAPE;
2986
2988
2989 /* ------------------------- */
2990 /* max col - 104 is select tech widget width */
2991 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
2992 /* max row - 204 is select tech widget height */
2993 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h) - adj_size(2)) / adj_size(204);
2994
2995 /* make space on screen for scrollbar */
2996 if (max_col * max_row < count) {
2997 max_col--;
2998 }
2999
3000 if (count < max_col + 1) {
3001 col = count;
3002 } else {
3003 if (count < max_col + 3) {
3004 col = max_col - 2;
3005 } else {
3006 if (count < max_col + 5) {
3007 col = max_col - 1;
3008 } else {
3009 col = max_col;
3010 }
3011 }
3012 }
3013
3015 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
3016
3017 count = 0;
3018 h = col * max_row;
3021 continue;
3022 }
3023
3024 count++;
3025
3028 buf = create_icon2(surf, pwindow->dst,
3030
3032 buf->action = change_research_callback;
3033
3035
3036 if (count > h) {
3038 }
3040
3042
3046
3047 /* -------------------------------------------------------------- */
3048
3049 i = 0;
3050 if (count > col) {
3051 count = (count + (col - 1)) / col;
3052 if (count > max_row) {
3054 count = max_row;
3056 }
3057 } else {
3058 count = 1;
3059 }
3060
3062
3063 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + i));
3064 area.h = MAX(area.h, count * buf->size.h + adj_size(2));
3065
3066 /* alloca window theme and win background buffer */
3068 resize_window(pwindow, surf, NULL,
3069 (pwindow->size.w - pwindow->area.w) + area.w,
3070 (pwindow->size.h - pwindow->area.h) + area.h);
3071 FREESURFACE(surf);
3072
3073 area = pwindow->area;
3074
3075 widget_set_position(pwindow,
3076 (main_window_width() - pwindow->size.w) / 2,
3077 (main_window_height() - pwindow->size.h) / 2);
3078
3079 /* exit button */
3080 buf = pwindow->prev;
3081 buf->size.x = area.x + area.w - buf->size.w - 1;
3082 buf->size.y = pwindow->size.y + adj_size(2);
3083
3085 area.y, 0, 0,
3088
3089 if (change_tech_dlg->scroll) {
3091 area.x + area.w, area.y,
3092 area.h, TRUE);
3093 }
3094
3096
3097 widget_flush(pwindow);
3098}
3099
3100/**********************************************************************/
3103static int change_research_goal_callback(struct widget *pwidget)
3104{
3107
3109
3110 /* Following is to make the menu go back to the current goal;
3111 * there may be a better way to do this? --dwp */
3113 } else if (main_data.event.button.button == SDL_BUTTON_MIDDLE) {
3114 popup_tech_info((MAX_ID - pwidget->id));
3115 }
3116
3117 return -1;
3118}
3119
3120/**********************************************************************/
3124{
3125 const struct research *presearch = research_get(client_player());
3126 struct widget *buf = NULL;
3127 struct widget *pwindow;
3128 utf8_str *pstr;
3129 SDL_Surface *surf;
3130 char cbuf[128];
3131 int max_col, max_row, col, i, count = 0, h , num;
3132 SDL_Rect area;
3134
3135 /* Collect all techs which are reachable in under 11 steps
3136 * hist will hold afterwards the techid of the current choice
3137 */
3142 || aidx == presearch->tech_goal)) {
3143 count++;
3144 }
3146
3147 if (count < 1) {
3148 return;
3149 }
3150
3151 change_tech_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
3152
3153 pstr = create_utf8_from_char_fonto(_("Select target :"), FONTO_ATTENTION);
3154 pstr->style |= TTF_STYLE_BOLD;
3155
3156 pwindow = create_window_skeleton(NULL, pstr, 0);
3158 set_wstate(pwindow, FC_WS_NORMAL);
3160
3162
3163 area = pwindow->area;
3164
3165 /* ------------------------- */
3166 /* Exit button */
3167 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3169 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3171 area.w += buf->size.w + adj_size(10);
3174 buf->key = SDLK_ESCAPE;
3175
3177
3178 /* ------------------------- */
3179 /* max col - 104 is goal tech widget width */
3180 max_col = (main_window_width() - (pwindow->size.w - pwindow->area.w) - adj_size(2)) / adj_size(104);
3181
3182 /* max row - 204 is goal tech widget height */
3183 max_row = (main_window_height() - (pwindow->size.h - pwindow->area.h) - adj_size(2)) / adj_size(204);
3184
3185 /* make space on screen for scrollbar */
3186 if (max_col * max_row < count) {
3187 max_col--;
3188 }
3189
3190 if (count < max_col + 1) {
3191 col = count;
3192 } else {
3193 if (count < max_col + 3) {
3194 col = max_col - 2;
3195 } else {
3196 if (count < max_col + 5) {
3197 col = max_col - 1;
3198 } else {
3199 col = max_col;
3200 }
3201 }
3202 }
3203
3205 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
3206
3207 /* Collect all techs which are reachable in under 11 steps
3208 * hist will hold afterwards the techid of the current choice
3209 */
3210 count = 0;
3211 h = col * max_row;
3215 && (11 > (num = research_goal_unknown_techs(presearch, aidx))
3216 || aidx == presearch->tech_goal)) {
3217
3218 count++;
3219 fc_snprintf(cbuf, sizeof(cbuf), "%s\n%d %s",
3221 num,
3222 PL_("step", "steps", num));
3225 buf = create_icon2(surf, pwindow->dst,
3227
3230
3232
3233 if (count > h) {
3235 }
3236 }
3238
3240
3244
3245 /* -------------------------------------------------------------- */
3246
3247 i = 0;
3248 if (count > col) {
3249 count = (count + (col-1)) / col;
3250 if (count > max_row) {
3252 count = max_row;
3254 }
3255 } else {
3256 count = 1;
3257 }
3258
3260
3261 area.w = MAX(area.w, (col * buf->size.w + adj_size(2) + i));
3262 area.h = MAX(area.h, count * buf->size.h + adj_size(2));
3263
3264 /* Alloca window theme and win background buffer */
3266 resize_window(pwindow, surf, NULL,
3267 (pwindow->size.w - pwindow->area.w) + area.w,
3268 (pwindow->size.h - pwindow->area.h) + area.h);
3269 FREESURFACE(surf);
3270
3271 area = pwindow->area;
3272
3273 widget_set_position(pwindow,
3274 (main_window_width() - pwindow->size.w) / 2,
3275 (main_window_height() - pwindow->size.h) / 2);
3276
3277 /* Exit button */
3278 buf = pwindow->prev;
3279 buf->size.x = area.x + area.w - buf->size.w - 1;
3280 buf->size.y = pwindow->size.y + adj_size(2);
3281
3283 area.y, 0, 0,
3286
3287 if (change_tech_dlg->scroll) {
3289 area.x + area.w, area.y,
3290 area.h, TRUE);
3291 }
3292
3294
3295 widget_flush(pwindow);
3296}
3297
3298/**********************************************************************/
3301static int science_dialog_callback(struct widget *pwindow)
3302{
3304 if (!change_tech_dlg) {
3306 widget_flush(pwindow);
3307 }
3310 }
3311 }
3312 }
3313
3314 return -1;
3315}
3316
3317/**********************************************************************/
3321{
3323 set_wstate(pwidget, FC_WS_NORMAL);
3325 widget_redraw(pwidget);
3326 widget_flush(pwidget);
3327
3329 }
3330
3331 return -1;
3332}
3333
3334/**********************************************************************/
3338{
3340 set_wstate(pwidget, FC_WS_NORMAL);
3342 widget_redraw(pwidget);
3343 widget_flush(pwidget);
3344
3346 }
3347
3348 return -1;
3349}
3350
3351/**********************************************************************/
3354static int popdown_science_dialog_callback(struct widget *pwidget)
3355{
3358 }
3359
3360 return -1;
3361}
3362
3363/**********************************************************************/
3367{
3368 const struct research *presearch;
3369 struct widget *pwidget, *pwindow;
3372 struct widget *exit_button;
3373 utf8_str *pstr;
3374 SDL_Surface *background, *tech_icon;
3375 int count;
3376 SDL_Rect area;
3377
3378 if (science_dlg) {
3379 return;
3380 }
3381
3383
3384 /* Disable research button */
3385 pwidget = get_research_widget();
3386 set_wstate(pwidget, FC_WS_DISABLED);
3387 widget_redraw(pwidget);
3388 widget_mark_dirty(pwidget);
3389
3390 science_dlg = fc_calloc(1, sizeof(struct small_dialog));
3391
3392 /* TRANS: Research report title */
3394 pstr->style |= TTF_STYLE_BOLD;
3395
3396#ifdef SMALL_SCREEN
3397 pwindow = create_window(NULL, pstr, 200, 132, 0);
3398#else /* SMALL_SCREEN */
3399 pwindow = create_window(NULL, pstr, adj_size(400), adj_size(246), 0);
3400#endif /* SMALL_SCREEN */
3401 set_wstate(pwindow, FC_WS_NORMAL);
3403
3404 science_dlg->end_widget_list = pwindow;
3405
3407 FREESURFACE(pwindow->theme);
3408 pwindow->theme = resize_surface(background, pwindow->size.w,
3409 pwindow->size.h, 1);
3410 FREESURFACE(background);
3411
3412 area = pwindow->area;
3413
3414 widget_set_position(pwindow,
3415 (main_window_width() - pwindow->size.w) / 2,
3416 (main_window_height() - pwindow->size.h) / 2);
3417
3419
3420 /* count number of researchable techs */
3421 count = 0;
3425 count++;
3426 }
3428
3429 /* current research icon */
3430 tech_icon = get_tech_icon(presearch->researching);
3433
3435 if (count > 0) {
3437 }
3438
3440
3441 /* current research goal icon */
3442 tech_icon = get_tech_icon(presearch->tech_goal);
3445
3447 if (count > 0) {
3449 }
3450
3452
3453 /* ------ */
3454 /* Exit button */
3455 exit_button = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3458 exit_button->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3462 exit_button->key = SDLK_ESCAPE;
3463
3465
3467 area.x + area.w - exit_button->size.w - adj_size(1),
3468 pwindow->size.y + adj_size(2));
3469
3470 /* ======================== */
3472
3474}
3475
3476/**********************************************************************/
3496
3497/**********************************************************************/
3501{
3502 /* No requirement tree yet. */
3503}
3504
3505/* ===================================================================== */
3506/* ======================== Endgame Report ============================= */
3507/* ===================================================================== */
3508
3509static char eg_buffer[150 * MAX_NUM_PLAYERS];
3510static int eg_player_count = 0;
3511static int eg_players_received = 0;
3512
3513/**********************************************************************/
3518{
3519 eg_buffer[0] = '\0';
3520 eg_player_count = packet->player_num;
3522}
3523
3524/**********************************************************************/
3528{
3529 const struct player *pplayer = player_by_number(packet->player_id);
3530
3532
3534 PL_("%2d: The %s ruler %s scored %d point\n",
3535 "%2d: The %s ruler %s scored %d points\n",
3536 packet->score),
3538 player_name(pplayer), packet->score);
3539
3541 popup_notify_dialog(_("Final Report:"),
3542 _("The Greatest Civilizations in the world."),
3543 eg_buffer);
3544 }
3545}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
int entries_used
Definition agents.c:77
struct @126::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:1240
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:820
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:747
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define output_type_iterate(output)
Definition city.h:845
#define city_list_iterate_end
Definition city.h:510
#define output_type_iterate_end
Definition city.h:851
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
char * incite_cost
Definition comments.c:75
popup_notify_dialog
Definition dialogs_g.h:37
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:74
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:74
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
QString current_theme
Definition fc_client.cpp:65
int Tech_type_id
Definition fc_types.h:377
#define MAX_NUM_PLAYERS
Definition fc_types.h:36
int Unit_type_id
Definition fc_types.h:382
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
@ O_LAST
Definition fc_types.h:101
#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:143
struct government * government_of_player(const struct player *pplayer)
Definition government.c:114
void flush_dirty(void)
Definition mapview.c:468
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
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:1983
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
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:47
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
int main_window_width(void)
Definition graphics.c:685
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
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:1348
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
@ ID_SCIENCE_CANCEL_DLG_BUTTON
Definition gui_id.h:186
@ ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR
Definition gui_id.h:175
@ ID_UNITS_DIALOG_WINDOW
Definition gui_id.h:135
@ ID_SCIENCE_DLG_CHANGE_GOAL_CANCEL_BUTTON
Definition gui_id.h:193
@ ID_SCIENCE_DLG_CHANGE_GOAL_WINDOW
Definition gui_id.h:190
@ ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX
Definition gui_id.h:180
@ ID_ECONOMY_DIALOG_WINDOW
Definition gui_id.h:134
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
@ ID_ERROR
Definition gui_id.h:26
@ ID_SCIENCE_DLG_CHANGE_REASARCH_WINDOW
Definition gui_id.h:188
@ ID_BUTTON
Definition gui_id.h:29
@ ID_CHANGE_TAXRATE_DLG_SCI_LABEL
Definition gui_id.h:178
@ ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR
Definition gui_id.h:174
@ ID_CHANGE_TAXRATE_DLG_OK_BUTTON
Definition gui_id.h:183
@ ID_SCROLLBAR
Definition gui_id.h:32
@ ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON
Definition gui_id.h:187
@ ID_LABEL
Definition gui_id.h:27
@ ID_CHANGE_TAXRATE_DLG_LUX_LABEL
Definition gui_id.h:177
@ ID_SCIENCE_DLG_WINDOW
Definition gui_id.h:185
@ ID_WINDOW
Definition gui_id.h:30
@ ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX
Definition gui_id.h:181
@ ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON
Definition gui_id.h:189
@ ID_CHANGE_TAXRATE_DLG_CANCEL_BUTTON
Definition gui_id.h:184
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:581
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)(const 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:602
int MOVE_STEP_Y
Definition gui_main.c:105
Uint32 sdl2_client_flags
Definition gui_main.c:101
#define CF_CHANGE_TAXRATE_SCI_BLOCK
Definition gui_main.h:56
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define DEFAULT_MOVE_STEP
Definition gui_main.h:113
#define PRESSED_EVENT(event)
Definition gui_main.h:71
#define CF_CHANGE_TAXRATE_LUX_BLOCK
Definition gui_main.h:55
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:103
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_DEFAULT_PLUS
Definition gui_string.h:66
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
struct city_icon * icons
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)
void popup_tech_info(Tech_type_id tech)
Definition helpdlg.c:1936
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:3354
static void popup_change_research_goal_dialog(void)
Definition repodlgs.c:3123
static int sell_impr_window_callback(struct widget *pwindow)
Definition repodlgs.c:1561
static int eg_player_count
Definition repodlgs.c:3510
static int eg_players_received
Definition repodlgs.c:3511
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:3479
static struct small_dialog * science_dlg
Definition repodlgs.c:2416
static int change_research_goal_callback(struct widget *pwidget)
Definition repodlgs.c:3103
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:3337
static char eg_buffer[150 *MAX_NUM_PLAYERS]
Definition repodlgs.c:3509
static void popup_change_research_dialog(void)
Definition repodlgs.c:2934
#define TARGETS_COL
Definition repodlgs.c:1817
static int change_research_goal_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:2920
static int exit_change_tech_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:2884
static int exit_units_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:333
static void disable_science_dialog(void)
Definition repodlgs.c:2610
static void enable_science_dialog(void)
Definition repodlgs.c:2601
static int popup_change_research_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3320
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:3301
static int change_research_callback(struct widget *pwidget)
Definition repodlgs.c:2905
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
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
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:898
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:863
bool move_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:1016
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
void unselect_widget_action(void)
Definition widget.c:418
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_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)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
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:169
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:741
struct player * player_by_number(const int player_id)
Definition player.c:849
const char * player_name(const struct player *pplayer)
Definition player.c:895
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:750
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
#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 sprite int x
Definition sprite_g.h:31
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
SDL_Surface * big_shield
SDL_Surface * big_luxury
SDL_Surface * big_colb
SDL_Surface * big_food
SDL_Surface * big_coin
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
int id1
Definition widget.h:104
int id0
Definition widget.h:103
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:279
struct unit_list * units
Definition player.h:280
struct player_economic economic
Definition player.h:282
int * dst_rate
Definition repodlgs.c:1125
struct widget * label_dst
Definition repodlgs.c:1127
struct widget * label_src
Definition repodlgs.c:1127
struct widget * horiz_src
Definition repodlgs.c:1126
struct widget * horiz_dst
Definition repodlgs.c:1126
int * src_rate
Definition repodlgs.c:1125
struct widget * up_left_button
struct widget * down_right_button
struct widget * pscroll_bar
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
struct unit::@81::@83 client
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
SDL_Color fgcol
Definition gui_string.h:57
void * ptr
Definition widget.h:133
union widget::@194 data
SDL_Surface * theme
Definition widget.h:118
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
struct container * cont
Definition widget.h:127
Uint16 mod
Definition widget.h:154
utf8_str * string_utf8
Definition widget.h:121
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
struct widget * next
Definition widget.h:113
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:974
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:119
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_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_end
Definition tech.h:248
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#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:820
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:776
#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
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
Definition unittype.c:2724
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
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:1560
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862