Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/repodlgs.c Source File

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-sdl3 */
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/* ===================================================================== */
61 static struct advanced_dialog *units_dlg = NULL;
62 static struct small_dialog *units_upg_dlg = NULL;
63
64struct units_entry {
65 int active_count;
66 int upkeep[O_LAST];
67 int building_count;
68 int soonest_completions;
69};
70
71/**********************************************************************/
74 static void get_units_report_data(struct units_entry *entries,
75 struct units_entry *total)
76{
77 int time_to_build;
78
79 memset(entries, '\0', U_LAST * sizeof(struct units_entry));
80 memset(total, '\0', sizeof(struct units_entry));
81 for (time_to_build = 0; time_to_build < U_LAST; time_to_build++) {
82 entries[time_to_build].soonest_completions = FC_INFINITY;
83 }
84
85 unit_list_iterate(client.conn.playing->units, punit) {
86 Unit_type_id uti = utype_index(unit_type_get(punit));
87
88 (entries[uti].active_count)++;
89 (total->active_count)++;
90 if (punit->homecity) {
91 output_type_iterate(o) {
92 entries[uti].upkeep[o] += punit->upkeep[o];
93 total->upkeep[o] += punit->upkeep[o];
94 } output_type_iterate_end;
95 }
96 } unit_list_iterate_end;
97
98 city_list_iterate(client.conn.playing->cities, pcity) {
99 if (VUT_UTYPE == pcity->production.kind) {
100 const struct unit_type *punittype = pcity->production.value.utype;
101 Unit_type_id uti = utype_index(punittype);
102 int num_units;
103
104 /* Account for build slots in city */
105 (void) city_production_build_units(pcity, TRUE, &num_units);
106 /* Unit is in progress even if it won't be done this turn */
107 num_units = MAX(num_units, 1);
108 (entries[uti].building_count) += num_units;
109 (total->building_count) += num_units;
110 entries[uti].soonest_completions =
111 MIN(entries[uti].soonest_completions,
112 city_production_turns_to_build(pcity, TRUE));
113 }
114 } city_list_iterate_end;
115}
116
117/**********************************************************************/
120 static int units_dialog_callback(struct widget *pwindow)
121{
122 if (PRESSED_EVENT(main_data.event)) {
123 move_window_group(units_dlg->begin_widget_list, pwindow);
124 }
125
126 return -1;
127}
128
129/* --------------------------------------------------------------- */
130
131/**********************************************************************/
134 static int ok_upgrade_unit_window_callback(struct widget *pwidget)
135{
136 if (PRESSED_EVENT(main_data.event)) {
137 int ut1 = MAX_ID - pwidget->id;
138
139 /* popdown upgrade dlg */
140 popdown_window_group_dialog(units_upg_dlg->begin_widget_list,
141 units_upg_dlg->end_widget_list);
142 FC_FREE(units_upg_dlg);
143
144 dsend_packet_unit_type_upgrade(&client.conn, ut1);
145 }
146
147 return -1;
148}
149
150/**********************************************************************/
153 static int upgrade_unit_window_callback(struct widget *pwindow)
154{
155 if (PRESSED_EVENT(main_data.event)) {
156 move_window_group(units_upg_dlg->begin_widget_list, pwindow);
157 }
158
159 return -1;
160}
161
162/**********************************************************************/
165 static int cancel_upgrade_unit_callback(struct widget *pwidget)
166{
167 if (PRESSED_EVENT(main_data.event)) {
168 if (units_upg_dlg) {
169 popdown_window_group_dialog(units_upg_dlg->begin_widget_list,
170 units_upg_dlg->end_widget_list);
171 FC_FREE(units_upg_dlg);
172 flush_dirty();
173 }
174 }
175
176 return -1;
177}
178
179/**********************************************************************/
182 static int popup_upgrade_unit_callback(struct widget *pwidget)
183{
184 if (PRESSED_EVENT(main_data.event)) {
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;
192 SDL_Rect dst;
193 SDL_Rect area;
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);
202 selected_widget = NULL;
203 widget_redraw(pwidget);
204 widget_mark_dirty(pwidget);
205
206 units_upg_dlg = fc_calloc(1, sizeof(struct small_dialog));
207
208 ut2 = can_upgrade_unittype(client.conn.playing, ut1);
209 value = unit_upgrade_price(client.conn.playing, ut1, ut2);
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),
221 utype_name_translation(ut1),
222 utype_name_translation(ut2),
223 value, tBuf);
224
225 pstr = create_utf8_from_char_fonto(_("Upgrade Obsolete Units"),
226 FONTO_ATTENTION);
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
236 units_upg_dlg->end_widget_list = pwindow;
237
238 area = pwindow->area;
239
240 /* ============================================================= */
241
242 /* Create text label */
243 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
244 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
245 pstr->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
246
247 text = create_text_surf_from_utf8(pstr);
248 FREEUTF8STR(pstr);
249
250 area.h += (text->h + adj_size(10));
251 area.w = MAX(area.w, text->w + adj_size(20));
252
253 /* Cancel button */
254 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
255 pwindow->dst, _("No"),
256 FONTO_ATTENTION, 0);
257
258 buf->action = cancel_upgrade_unit_callback;
259 set_wstate(buf, FC_WS_NORMAL);
260
261 area.h += (buf->size.h + adj_size(20));
262
263 add_to_gui_list(ID_BUTTON, buf);
264
265 if (value <= client.conn.playing->economic.gold) {
266 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
267 pwindow->dst,
268 _("Yes"),
269 FONTO_ATTENTION, 0);
270
271 buf->action = ok_upgrade_unit_window_callback;
272 set_wstate(buf, FC_WS_NORMAL);
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
283 units_upg_dlg->begin_widget_list = buf;
284
285 resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
286 (pwindow->size.w - pwindow->area.w) + area.w,
287 (pwindow->size.h - pwindow->area.h) + area.h);
288
289 widget_set_position(pwindow,
290 units_dlg->end_widget_list->size.x +
291 (units_dlg->end_widget_list->size.w - pwindow->size.w) / 2,
292 units_dlg->end_widget_list->size.y +
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 */
321 redraw_group(units_upg_dlg->begin_widget_list, pwindow, 0);
322
323 widget_mark_dirty(pwindow);
324 flush_dirty();
325 }
326
327 return -1;
328}
329
330/**********************************************************************/
333 static int exit_units_dlg_callback(struct widget *pwidget)
334{
335 if (PRESSED_EVENT(main_data.event)) {
336 if (units_dlg) {
337 if (units_upg_dlg) {
338 del_group_of_widgets_from_gui_list(units_upg_dlg->begin_widget_list,
339 units_upg_dlg->end_widget_list);
340 FC_FREE(units_upg_dlg);
341 }
342 popdown_window_group_dialog(units_dlg->begin_widget_list,
343 units_dlg->end_widget_list);
344 FC_FREE(units_dlg->scroll);
345 FC_FREE(units_dlg);
346 flush_dirty();
347 }
348 }
349
350 return -1;
351}
352
353/**********************************************************************/
356 static void real_activeunits_report_dialog_update(struct units_entry *units,
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;
363 SDL_Surface *text1, *text2, *text3 , *text4, *text5, *logo;
364 int w = 0 , count, ww, hh = 0, name_w = 0;
365 char cbuf[64];
366 SDL_Rect dst;
367 bool upgrade = FALSE;
368 SDL_Rect area;
369
370 if (units_dlg) {
371 popdown_window_group_dialog(units_dlg->begin_widget_list,
372 units_dlg->end_widget_list);
373 } else {
374 units_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
375 }
376
377 fc_snprintf(cbuf, sizeof(cbuf), _("active"));
378 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
379 pstr->style |= SF_CENTER;
380 text1 = create_text_surf_from_utf8(pstr);
381
382 fc_snprintf(cbuf, sizeof(cbuf), _("under\nconstruction"));
383 copy_chars_to_utf8_str(pstr, cbuf);
384 text2 = create_text_surf_from_utf8(pstr);
385
386 fc_snprintf(cbuf, sizeof(cbuf), _("soonest\ncompletion"));
387 copy_chars_to_utf8_str(pstr, cbuf);
388 text5 = create_text_surf_from_utf8(pstr);
389
390 fc_snprintf(cbuf, sizeof(cbuf), _("Total"));
391 copy_chars_to_utf8_str(pstr, cbuf);
392 text3 = create_text_surf_from_utf8(pstr);
393
394 fc_snprintf(cbuf, sizeof(cbuf), _("Units"));
395 copy_chars_to_utf8_str(pstr, cbuf);
396 text4 = create_text_surf_from_utf8(pstr);
397 name_w = text4->w;
398 FREEUTF8STR(pstr);
399
400 /* --------------- */
401 pstr = create_utf8_from_char_fonto(_("Units Report"), FONTO_ATTENTION);
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
408 add_to_gui_list(ID_UNITS_DIALOG_WINDOW, pwindow);
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,
417 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
418 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
419 FONTO_ATTENTION);
420 buf->action = exit_units_dlg_callback;
421 set_wstate(buf, FC_WS_NORMAL);
422 buf->key = SDLK_ESCAPE;
423
424 add_to_gui_list(ID_BUTTON, buf);
425 /* ------------------------- */
426 /* Totals */
427 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->active_count);
428
429 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
430 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
431
432 buf = create_iconlabel(NULL, pwindow->dst, pstr,
433 WF_RESTORE_BACKGROUND);
434
435 area.h += buf->size.h;
436 buf->size.w = text1->w + adj_size(6);
437 add_to_gui_list(ID_LABEL, buf);
438 /* ---------------------------------------------- */
439 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_SHIELD]);
440
441 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
442 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
443
444 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
445
446 buf->size.w = text1->w;
447 add_to_gui_list(ID_LABEL, buf);
448 /* ---------------------------------------------- */
449 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_FOOD]);
450
451 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
452 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
453
454 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
455
456 buf->size.w = text1->w;
457 add_to_gui_list(ID_LABEL, buf);
458 /* ---------------------------------------------- */
459 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_GOLD]);
460
461 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
462 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
463
464 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
465
466 buf->size.w = text1->w;
467 add_to_gui_list(ID_LABEL, buf);
468 /* ---------------------------------------------- */
469 fc_snprintf(cbuf, sizeof(cbuf), "%d", total->building_count);
470
471 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
472 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
473
474 buf = create_iconlabel(NULL, pwindow->dst, pstr,
475 WF_RESTORE_BACKGROUND);
476
477 buf->size.w = text2->w + adj_size(6);
478 add_to_gui_list(ID_LABEL, buf);
479
480 /* ------------------------- */
481 last = buf;
482 count = 0;
483 unit_type_iterate(i) {
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 */
489 buf = create_iconlabel(adj_surf(get_unittype_surface(i, direction8_invalid())),
490 pwindow->dst, NULL,
491 WF_RESTORE_BACKGROUND | WF_FREE_THEME);
492 if (count > adj_size(72)) {
493 set_wflag(buf, WF_HIDDEN);
494 }
495 hh = buf->size.h;
496 add_to_gui_list(MAX_ID - utype_number(i), buf);
497
498 /* Unit type name */
499 pstr = create_utf8_from_char_fonto(utype_name_translation(i),
500 FONTO_ATTENTION);
501 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
502 buf = create_iconlabel(NULL, pwindow->dst, pstr,
503 (WF_RESTORE_BACKGROUND | WF_SELECT_WITHOUT_BAR));
504 if (upgrade) {
505 buf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
506 buf->action = popup_upgrade_unit_callback;
507 set_wstate(buf, FC_WS_NORMAL);
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)) {
513 set_wflag(buf , WF_HIDDEN);
514 }
515 hh = MAX(hh, buf->size.h);
516 name_w = MAX(buf->size.w, name_w);
517 add_to_gui_list(MAX_ID - utype_number(i), buf);
518
519 /* Active */
520 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].active_count);
521 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
522 pstr->style |= SF_CENTER;
523 buf = create_iconlabel(NULL, pwindow->dst, pstr,
524 WF_RESTORE_BACKGROUND);
525 if (count > adj_size(72)) {
526 set_wflag(buf, WF_HIDDEN);
527 }
528 hh = MAX(hh, buf->size.h);
529 buf->size.w = text1->w + adj_size(6);
530 add_to_gui_list(MAX_ID - utype_number(i), buf);
531
532 /* Shield upkeep */
533 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_SHIELD]);
534 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
535 pstr->style |= SF_CENTER;
536 buf = create_iconlabel(NULL, pwindow->dst, pstr,
537 WF_RESTORE_BACKGROUND);
538 if (count > adj_size(72)) {
539 set_wflag(buf, WF_HIDDEN);
540 }
541 hh = MAX(hh, buf->size.h);
542 buf->size.w = text1->w;
543 add_to_gui_list(MAX_ID - utype_number(i), buf);
544
545 /* Food upkeep */
546 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_FOOD]);
547 pstr = create_utf8_from_char(cbuf, FONTO_DEFAULT);
548 pstr->style |= SF_CENTER;
549 buf = create_iconlabel(NULL, pwindow->dst, pstr,
550 WF_RESTORE_BACKGROUND);
551 if (count > adj_size(72)) {
552 set_wflag(buf, WF_HIDDEN);
553 }
554
555 hh = MAX(hh, buf->size.h);
556 buf->size.w = text1->w;
557 add_to_gui_list(MAX_ID - utype_number(i), buf);
558
559 /* Gold upkeep */
560 fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_GOLD]);
561 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
562 pstr->style |= SF_CENTER;
563 buf = create_iconlabel(NULL, pwindow->dst, pstr,
564 WF_RESTORE_BACKGROUND);
565 if (count > adj_size(72)) {
566 set_wflag(buf, WF_HIDDEN);
567 }
568
569 hh = MAX(hh, buf->size.h);
570 buf->size.w = text1->w;
571 add_to_gui_list(MAX_ID - utype_number(i), buf);
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 }
579 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
580 pstr->style |= SF_CENTER;
581 buf = create_iconlabel(NULL, pwindow->dst, pstr,
582 WF_RESTORE_BACKGROUND);
583 if (count > adj_size(72)) {
584 set_wflag(buf, WF_HIDDEN);
585 }
586 hh = MAX(hh, buf->size.h);
587 buf->size.w = text2->w + adj_size(6);
588 add_to_gui_list(MAX_ID - utype_number(i), buf);
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
599 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
600 pstr->style |= SF_CENTER;
601 buf = create_iconlabel(NULL, pwindow->dst, pstr,
602 WF_RESTORE_BACKGROUND);
603
604 if (count > adj_size(72)) {
605 set_wflag(buf, WF_HIDDEN);
606 }
607 hh = MAX(hh, buf->size.h);
608 buf->size.w = text5->w + adj_size(6);
609 add_to_gui_list(MAX_ID - utype_number(i), buf);
610
611 count += adj_size(8);
612 area.h += (hh / 2);
613 }
614 } unit_type_iterate_end;
615
616 units_dlg->begin_widget_list = buf;
617 area.w = MAX(area.w, (tileset_full_tile_width(tileset) * 2 + name_w + adj_size(15))
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) {
621 units_dlg->end_active_widget_list = last->prev;
622 units_dlg->begin_active_widget_list = units_dlg->begin_widget_list;
623 if (count > adj_size(80)) {
624 units_dlg->active_widget_list = units_dlg->end_active_widget_list;
625 if (units_dlg->scroll) {
626 units_dlg->scroll->count = count;
627 }
628 ww = create_vertical_scrollbar(units_dlg, 8, 10, TRUE, TRUE);
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
641 logo = theme_get_background(active_theme, BACKGROUND_UNITSREP);
642 resize_window(pwindow, logo, NULL,
643 (pwindow->size.w - pwindow->area.w) + area.w,
644 (pwindow->size.h - pwindow->area.h) + area.h);
645 FREESURFACE(logo);
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);
668 dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
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,
674 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
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);
679 FREESURFACE(text3);
680
681 /* total active widget */
682 buf = buf->prev;
683 buf->size.x = area.x + name_w
684 + tileset_full_tile_width(tileset) * 2 + adj_size(17);
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;
710 dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
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,
716 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
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);
721 FREESURFACE(text4);
722
723 /* active count background and label */
724 dst.x = area.x + adj_size(2) + name_w + tileset_full_tile_width(tileset) * 2 + adj_size(15);
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,
732 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
733
734 dst.x += adj_size(3);
735 alphablit(text1, NULL, pwindow->theme, &dst, 255);
736 ww = text1->w;
737 hh = text1->h;
738 FREESURFACE(text1);
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,
749 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
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,
765 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
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,
781 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
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,
798 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
799
800 dst.x += adj_size(3);
801 alphablit(text2, NULL, pwindow->theme, &dst, 255);
802 FREESURFACE(text2);
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,
813 get_theme_color(COLOR_THEME_UNITSREP_FRAME));
814
815 dst.x += adj_size(3);
816 alphablit(text5, NULL, pwindow->theme, &dst, 255);
817 FREESURFACE(text5);
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);
869 if (buf == units_dlg->begin_active_widget_list) {
870 break;
871 }
872 buf = buf->prev;
873 }
874
875 if (units_dlg->scroll) {
876 setup_vertical_scrollbar_area(units_dlg->scroll,
877 area.x + area.w, area.y,
878 area.h, TRUE);
879 }
880
881 }
882 /* ----------------------------------- */
883 redraw_group(units_dlg->begin_widget_list, pwindow, 0);
884 widget_mark_dirty(pwindow);
885
886 flush_dirty();
887}
888
889/**********************************************************************/
892 void real_units_report_dialog_update(void *unused)
893{
894 if (units_dlg) {
895 struct units_entry units[U_LAST];
896 struct units_entry units_total;
897 struct widget *pwidget, *pbuf;
898 bool is_in_list = FALSE;
899 char cbuf[32];
900 bool upgrade;
901 bool search_finished;
902
903 get_units_report_data(units, &units_total);
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 */
907 unit_type_iterate(i) {
908 if ((units[utype_index(i)].active_count > 0)
909 || (units[utype_index(i)].building_count > 0)) {
910 is_in_list = FALSE;
911
912 pbuf = pwidget; /* Unit type icon */
913 while (pbuf != NULL) {
914 if ((MAX_ID - pbuf->id) == utype_number(i)) {
915 is_in_list = TRUE;
916 pwidget = pbuf;
917 break;
918 }
919 if (pbuf->prev->prev->prev->prev->prev->prev->prev ==
920 units_dlg->begin_active_widget_list) {
921 break;
922 }
923
924 /* First widget of next list entry */
925 pbuf = pbuf->prev->prev->prev->prev->prev->prev->prev->prev;
926 }
927
928 if (!is_in_list) {
929 real_activeunits_report_dialog_update(units, &units_total);
930 return;
931 }
932 }
933 } unit_type_iterate_end;
934
935 /* Update list */
936 pwidget = units_dlg->end_active_widget_list;
937 if (pwidget != NULL) {
938 unit_type_iterate(i) {
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
945 search_finished = FALSE;
946 while (!search_finished) {
947 if ((MAX_ID - pbuf->id) == utype_number(i)) {
948 /* List entry for this unit type found */
949
950 upgrade = (can_upgrade_unittype(client.conn.playing, i) != NULL);
951
952 pbuf = pbuf->prev; /* Unit type name */
953 if (upgrade) {
954 pbuf->string_utf8->fgcol
955 = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT);
956 pbuf->action = popup_upgrade_unit_callback;
957 set_wstate(pbuf, FC_WS_NORMAL);
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
1002 search_finished = TRUE;
1003
1004 } else { /* List entry for this unit type not found yet */
1005
1006 /* Search it */
1007 pbuf = pwidget->next;
1008 do {
1009 del_widget_from_vertical_scroll_widget_list(units_dlg,
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? */
1016 del_widget_from_vertical_scroll_widget_list(units_dlg,
1017 pbuf->prev);
1018 pwidget = pbuf->prev; /* units_dlg->begin_active_widget_list */
1019 search_finished = TRUE;
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 {
1033 del_widget_from_vertical_scroll_widget_list(units_dlg,
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) {
1038 del_widget_from_vertical_scroll_widget_list(units_dlg,
1039 pbuf->prev);
1040 }
1041 pwidget = pbuf->prev;
1042 }
1043 }
1044 }
1045 } unit_type_iterate_end;
1046 }
1047
1048 /* -------------------------------------- */
1049
1050 /* Total active */
1051 pbuf = units_dlg->end_widget_list->prev->prev;
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 /* -------------------------------------- */
1076 redraw_group(units_dlg->begin_widget_list, units_dlg->end_widget_list, 0);
1077 widget_mark_dirty(units_dlg->end_widget_list);
1078
1079 flush_dirty();
1080 }
1081}
1082
1083/**********************************************************************/
1086 void units_report_dialog_popup(bool make_modal)
1087{
1088 struct units_entry units[U_LAST];
1089 struct units_entry units_total;
1090
1091 if (units_dlg) {
1092 return;
1093 }
1094
1095 get_units_report_data(units, &units_total);
1096 real_activeunits_report_dialog_update(units, &units_total);
1097}
1098
1099/**************************************************************************
1100 Popdown the units report.
1101**************************************************************************/
1102 void units_report_dialog_popdown(void)
1103{
1104 if (units_dlg) {
1105 if (units_upg_dlg) {
1106 del_group_of_widgets_from_gui_list(units_upg_dlg->begin_widget_list,
1107 units_upg_dlg->end_widget_list);
1108 FC_FREE(units_upg_dlg);
1109 }
1110 popdown_window_group_dialog(units_dlg->begin_widget_list,
1111 units_dlg->end_widget_list);
1112 FC_FREE(units_dlg->scroll);
1113 FC_FREE(units_dlg);
1114 }
1115}
1116
1117/* ===================================================================== */
1118/* ======================== Economy Report ============================= */
1119/* ===================================================================== */
1120 static struct advanced_dialog *economy_dlg = NULL;
1121 static struct small_dialog *economy_sell_dlg = NULL;
1122
1123struct rates_move {
1124 int min, max, tax, x, gov_max;
1125 int *src_rate, *dst_rate;
1126 struct widget *horiz_src, *horiz_dst;
1127 struct widget *label_src, *label_dst;
1128};
1129
1130/**********************************************************************/
1133 static int economy_dialog_callback(struct widget *pwindow)
1134{
1135 if (PRESSED_EVENT(main_data.event)) {
1136 move_window_group(economy_dlg->begin_widget_list, pwindow);
1137 }
1138
1139 return -1;
1140}
1141
1142/**********************************************************************/
1145 static int exit_economy_dialog_callback(struct widget *pwidget)
1146{
1147 if (PRESSED_EVENT(main_data.event)) {
1148 if (economy_dlg) {
1149 if (economy_sell_dlg) {
1150 del_group_of_widgets_from_gui_list(economy_sell_dlg->begin_widget_list,
1151 economy_sell_dlg->end_widget_list);
1152 FC_FREE(economy_sell_dlg);
1153 }
1154 popdown_window_group_dialog(economy_dlg->begin_widget_list,
1155 economy_dlg->end_widget_list);
1156 FC_FREE(economy_dlg->scroll);
1157 FC_FREE(economy_dlg);
1158 set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
1159 widget_redraw(get_tax_rates_widget());
1160 widget_mark_dirty(get_tax_rates_widget());
1161 flush_dirty();
1162 }
1163 }
1164
1165 return -1;
1166}
1167
1168/**********************************************************************/
1171 static int toggle_block_callback(struct widget *pcheckbox)
1172{
1173 if (PRESSED_EVENT(main_data.event)) {
1174 switch (pcheckbox->id) {
1175 case ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX:
1176 sdl3_client_flags ^= CF_CHANGE_TAXRATE_LUX_BLOCK;
1177 return -1;
1178
1179 case ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX:
1180 sdl3_client_flags ^= CF_CHANGE_TAXRATE_SCI_BLOCK;
1181 return -1;
1182
1183 default:
1184 return -1;
1185 }
1186 }
1187
1188 return -1;
1189}
1190
1191/**********************************************************************/
1194 static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
1195 void *data)
1196{
1197 return (Uint16)ID_SCROLLBAR;
1198}
1199
1200/**********************************************************************/
1203 static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
1204 void *data)
1205{
1206 struct rates_move *motion = (struct rates_move *)data;
1207 struct widget *tax_label = economy_dlg->end_widget_list->prev->prev;
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) {
1287 refresh_widget_background(motion->horiz_src);
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) {
1294 refresh_widget_background(motion->horiz_dst);
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/**********************************************************************/
1319 static int horiz_taxrate_callback(struct widget *horiz_src)
1320{
1321 if (PRESSED_EVENT(main_data.event)) {
1322 struct rates_move motion;
1323
1324 motion.horiz_src = horiz_src;
1325 motion.label_src = horiz_src->prev;
1326
1327 switch (horiz_src->id) {
1328 case ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR:
1329 if (sdl3_client_flags & CF_CHANGE_TAXRATE_LUX_BLOCK) {
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;
1336 if ((sdl3_client_flags & CF_CHANGE_TAXRATE_SCI_BLOCK)) {
1337 if (motion.tax <= get_player_bonus(client.conn.playing, EFT_MAX_RATES)) {
1338 motion.horiz_dst = NULL; /* tax */
1339 motion.dst_rate = &motion.tax;
1340 } else {
1341 goto END; /* all blocked */
1342 }
1343 }
1344
1345 break;
1346
1347 case ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR:
1348 if ((sdl3_client_flags & CF_CHANGE_TAXRATE_SCI_BLOCK)) {
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;
1355 if (sdl3_client_flags & CF_CHANGE_TAXRATE_LUX_BLOCK) {
1356 if (motion.tax <= get_player_bonus(client.conn.playing, EFT_MAX_RATES)) {
1357 /* Tax */
1358 motion.horiz_dst = NULL;
1359 motion.dst_rate = &motion.tax;
1360 } else {
1361 goto END; /* All blocked */
1362 }
1363 }
1364
1365 break;
1366
1367 default:
1368 return -1;
1369 }
1370
1371 if (motion.horiz_dst) {
1372 motion.label_dst = motion.horiz_dst->prev;
1373 } else {
1374 /* tax label */
1375 motion.label_dst = economy_dlg->end_widget_list->prev->prev;
1376 }
1377
1378 motion.min = horiz_src->next->size.x + horiz_src->next->size.w + adj_size(2);
1379 motion.gov_max = get_player_bonus(client.conn.playing, EFT_MAX_RATES);
1380 motion.max = motion.min + motion.gov_max * 1.5;
1381 motion.x = horiz_src->size.x;
1382
1383 MOVE_STEP_Y = 0;
1384 /* Filter mouse motion events */
1385 SDL_SetEventFilter(FilterMouseMotionEvents, NULL);
1386 gui_event_loop((void *)(&motion), NULL, NULL, NULL, NULL, NULL, NULL,
1387 NULL, NULL,
1388 report_scroll_mouse_button_up,
1389 report_scroll_mouse_motion_handler);
1390 /* Turn off Filter mouse motion events */
1391 SDL_SetEventFilter(NULL, NULL);
1392 MOVE_STEP_Y = DEFAULT_MOVE_STEP;
1393
1394 END:
1395 unselect_widget_action();
1396 selected_widget = horiz_src;
1397 set_wstate(horiz_src, FC_WS_SELECTED);
1398 widget_redraw(horiz_src);
1399 widget_flush(horiz_src);
1400 }
1401
1402 return -1;
1403}
1404
1405/**********************************************************************/
1408 static int apply_taxrates_callback(struct widget *button)
1409{
1410 if (PRESSED_EVENT(main_data.event)) {
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/**********************************************************************/
1445 static void enable_economy_dlg(void)
1446{
1447 /* lux lock */
1448 struct widget *buf = economy_dlg->end_widget_list->prev->prev->prev->prev->prev->prev;
1449
1450 set_wstate(buf, FC_WS_NORMAL);
1451
1452 /* lux scrollbar */
1453 buf = buf->prev;
1454 set_wstate(buf, FC_WS_NORMAL);
1455
1456 /* sci lock */
1457 buf = buf->prev->prev;
1458 set_wstate(buf, FC_WS_NORMAL);
1459
1460 /* sci scrollbar */
1461 buf = buf->prev;
1462 set_wstate(buf, FC_WS_NORMAL);
1463
1464 /* update button */
1465 buf = buf->prev->prev;
1466 set_wstate(buf, FC_WS_NORMAL);
1467
1468 /* cancel button */
1469 buf = buf->prev;
1470 set_wstate(buf, FC_WS_NORMAL);
1471
1472 set_group_state(economy_dlg->begin_active_widget_list,
1473 economy_dlg->end_active_widget_list, FC_WS_NORMAL);
1474 if (economy_dlg->scroll && economy_dlg->active_widget_list) {
1475 set_wstate(economy_dlg->scroll->up_left_button, FC_WS_NORMAL);
1476 set_wstate(economy_dlg->scroll->down_right_button, FC_WS_NORMAL);
1477 set_wstate(economy_dlg->scroll->pscroll_bar, FC_WS_NORMAL);
1478 }
1479}
1480
1481/**********************************************************************/
1484 static void disable_economy_dlg(void)
1485{
1486 /* lux lock */
1487 struct widget *buf = economy_dlg->end_widget_list->prev->prev->prev->prev->prev->prev;
1488
1489 set_wstate(buf, FC_WS_DISABLED);
1490
1491 /* lux scrollbar */
1492 buf = buf->prev;
1493 set_wstate(buf, FC_WS_DISABLED);
1494
1495 /* sci lock */
1496 buf = buf->prev->prev;
1497 set_wstate(buf, FC_WS_DISABLED);
1498
1499 /* sci scrollbar */
1500 buf = buf->prev;
1501 set_wstate(buf, FC_WS_DISABLED);
1502
1503 /* update button */
1504 buf = buf->prev->prev;
1505 set_wstate(buf, FC_WS_DISABLED);
1506
1507 /* cancel button */
1508 buf = buf->prev;
1509 set_wstate(buf, FC_WS_DISABLED);
1510
1511 set_group_state(economy_dlg->begin_active_widget_list,
1512 economy_dlg->end_active_widget_list, FC_WS_DISABLED);
1513 if (economy_dlg->scroll && economy_dlg->active_widget_list) {
1514 set_wstate(economy_dlg->scroll->up_left_button, FC_WS_DISABLED);
1515 set_wstate(economy_dlg->scroll->down_right_button, FC_WS_DISABLED);
1516 set_wstate(economy_dlg->scroll->pscroll_bar, FC_WS_DISABLED);
1517 }
1518}
1519
1520/* --------------------------------------------------------------- */
1521
1522/**********************************************************************/
1525 static int ok_sell_impr_callback(struct widget *pwidget)
1526{
1527 if (PRESSED_EVENT(main_data.event)) {
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 */
1535 popdown_window_group_dialog(economy_sell_dlg->begin_widget_list,
1536 economy_sell_dlg->end_widget_list);
1537 FC_FREE(economy_sell_dlg);
1538 enable_economy_dlg();
1539
1540 /* send sell */
1541 city_list_iterate(client.conn.playing->cities, pcity) {
1542 if (!pcity->did_sell
1543 && city_has_building(pcity, improvement_by_number(imp))) {
1544 count++;
1545
1546 city_sell_improvement(pcity, imp);
1547 }
1548 } city_list_iterate_end;
1549
1550 if (count == total_count) {
1551 del_widget_from_vertical_scroll_widget_list(economy_dlg, impr);
1552 }
1553 }
1554
1555 return -1;
1556}
1557
1558/**********************************************************************/
1561 static int sell_impr_window_callback(struct widget *pwindow)
1562{
1563 if (PRESSED_EVENT(main_data.event)) {
1564 move_window_group(economy_sell_dlg->begin_widget_list, pwindow);
1565 }
1566
1567 return -1;
1568}
1569
1570/**********************************************************************/
1573 static int cancel_sell_impr_callback(struct widget *pwidget)
1574{
1575 if (PRESSED_EVENT(main_data.event)) {
1576 if (economy_sell_dlg) {
1577 popdown_window_group_dialog(economy_sell_dlg->begin_widget_list,
1578 economy_sell_dlg->end_widget_list);
1579 FC_FREE(economy_sell_dlg);
1580 enable_economy_dlg();
1581 flush_dirty();
1582 }
1583 }
1584
1585 return -1;
1586}
1587
1588/**********************************************************************/
1591 static int popup_sell_impr_callback(struct widget *pwidget)
1592{
1593 if (PRESSED_EVENT(main_data.event)) {
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);
1608 selected_widget = NULL;
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;
1616 value = impr_sell_gold(improvement_by_number(imp));
1617
1618 city_list_iterate(client.conn.playing->cities, pcity) {
1619 if (!pcity->did_sell
1620 && city_has_building(pcity, improvement_by_number(imp))) {
1621 count++;
1622 gold += value;
1623 }
1624 } city_list_iterate_end;
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."),
1630 total_count,
1631 improvement_name_translation(improvement_by_number(imp)),
1632 total_count * value, count, gold);
1633 } else {
1634 fc_snprintf(cbuf, sizeof(cbuf),
1635 _("We can't sell any %s in this turn."),
1636 improvement_name_translation(improvement_by_number(imp)));
1637 }
1638
1639 pstr = create_utf8_from_char_fonto(_("Sell It?"), FONTO_ATTENTION);
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
1647 economy_sell_dlg->end_widget_list = pwindow;
1648
1649 add_to_gui_list(ID_WINDOW, pwindow);
1650
1651 area = pwindow->area;
1652
1653 /* ============================================================= */
1654
1655 /* Create text label */
1656 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
1657 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1658 pstr->fgcol = *get_theme_color(COLOR_THEME_SELLIMPR_TEXT);
1659
1660 text = create_text_surf_from_utf8(pstr);
1661 FREEUTF8STR(pstr);
1662
1663 area.w = MAX(area.w, text->w + adj_size(20));
1664 area.h += (text->h + adj_size(10));
1665
1666 /* Cancel button */
1667 buf = create_themeicon_button_from_chars_fonto(current_theme->cancel_icon,
1668 pwindow->dst, _("No"),
1669 FONTO_ATTENTION, 0);
1670
1671 buf->action = cancel_sell_impr_callback;
1672 set_wstate(buf, FC_WS_NORMAL);
1673
1674 area.h += (buf->size.h + adj_size(20));
1675
1676 add_to_gui_list(ID_BUTTON, buf);
1677
1678 if (count > 0) {
1679 buf = create_themeicon_button_from_chars_fonto(current_theme->ok_icon,
1680 pwindow->dst,
1681 _("Sell"),
1682 FONTO_ATTENTION, 0);
1683
1684 buf->action = ok_sell_impr_callback;
1685 set_wstate(buf, FC_WS_NORMAL);
1686 buf->data.ptr = (void *)pwidget;
1687
1688 add_to_gui_list(ID_BUTTON, buf);
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
1697 economy_sell_dlg->begin_widget_list = buf;
1698
1699 resize_window(pwindow, NULL, get_theme_color(COLOR_THEME_BACKGROUND),
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,
1706 economy_dlg->end_widget_list->size.x +
1707 (economy_dlg->end_widget_list->size.w - pwindow->size.w) / 2,
1708 economy_dlg->end_widget_list->size.y +
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 */
1737 redraw_group(economy_sell_dlg->begin_widget_list, pwindow, 0);
1738 disable_economy_dlg();
1739
1740 widget_mark_dirty(pwindow);
1741 flush_dirty();
1742 }
1743
1744 return -1;
1745}
1746
1747/**********************************************************************/
1750 void real_economy_report_dialog_update(void *unused)
1751{
1752 if (economy_dlg) {
1753 struct widget *pbuf = economy_dlg->end_widget_list;
1754 int tax, total, entries_used = 0;
1755 char cbuf[128];
1756 struct improvement_entry entries[B_LAST];
1757
1758 get_economy_report_data(entries, &entries_used, &total, &tax);
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);
1764 remake_label_size(pbuf);
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);
1770 remake_label_size(pbuf);
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);
1776 remake_label_size(pbuf);
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);
1782 remake_label_size(pbuf);
1783 if (tax - total < 0) {
1784 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_ECONOMYDLG_NEG_TEXT);
1785 } else {
1786 pbuf->string_utf8->fgcol = *get_theme_color(COLOR_THEME_ECONOMYDLG_TEXT);
1787 }
1788
1789 /* ---------------- */
1790 redraw_group(economy_dlg->begin_widget_list, economy_dlg->end_widget_list, 0);
1791 widget_flush(economy_dlg->end_widget_list);
1792 }
1793}
1794
1795/**********************************************************************/
1798 void economy_report_dialog_popdown(void)
1799{
1800 if (economy_dlg) {
1801 if (economy_sell_dlg) {
1802 del_group_of_widgets_from_gui_list(economy_sell_dlg->begin_widget_list,
1803 economy_sell_dlg->end_widget_list);
1804 FC_FREE(economy_sell_dlg);
1805 }
1806 popdown_window_group_dialog(economy_dlg->begin_widget_list,
1807 economy_dlg->end_widget_list);
1808 FC_FREE(economy_dlg->scroll);
1809 FC_FREE(economy_dlg);
1810 set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
1811 widget_redraw(get_tax_rates_widget());
1812 widget_mark_dirty(get_tax_rates_widget());
1813 }
1814}
1815
1816#define TARGETS_ROW 2
1817#define TARGETS_COL 4
1818
1819/**********************************************************************/
1822 void economy_report_dialog_popup(bool make_modal)
1823{
1824 SDL_Color bg_color = {255,255,255,128};
1825 SDL_Color bg_color2 = {255,255,255,136};
1826 SDL_Color bg_color3 = {255,255,255,64};
1827 struct widget *buf;
1828 struct widget *pwindow , *last;
1829 utf8_str *pstr, *pstr2;
1830 SDL_Surface *surf, *text_name, *text, *zoomed;
1831 SDL_Surface *background;
1832 int i, count , h = 0;
1833 int w = 0; /* left column values */
1834 int w2 = 0; /* right column: lock + scrollbar + ... */
1835 int w3 = 0; /* left column text without values */
1836 int tax, total, entries_used = 0;
1837 char cbuf[128];
1838 struct improvement_entry entries[B_LAST];
1839 SDL_Rect dst;
1840 SDL_Rect area;
1841 struct government *gov = government_of_player(client.conn.playing);
1842 SDL_Surface *treasury_text;
1843 SDL_Surface *tax_rate_text;
1844 SDL_Surface *total_income_text;
1845 SDL_Surface *total_cost_text;
1846 SDL_Surface *net_income_text;
1847 SDL_Surface *max_rate_text;
1848
1849 if (economy_dlg) {
1850 return;
1851 }
1852
1853 /* disable "Economy" button */
1854 buf = get_tax_rates_widget();
1855 set_wstate(buf, FC_WS_DISABLED);
1856 widget_redraw(buf);
1857 widget_mark_dirty(buf);
1858
1859 economy_dlg = fc_calloc(1, sizeof(struct advanced_dialog));
1860
1861 get_economy_report_data(entries, &entries_used, &total, &tax);
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);
1870 pwindow->action = economy_dialog_callback;
1871
1872 add_to_gui_list(ID_ECONOMY_DIALOG_WINDOW, pwindow);
1873
1874 area = pwindow->area;
1875
1876 /* ------------------------- */
1877
1878 /* "Treasury" text surface */
1879 fc_snprintf(cbuf, sizeof(cbuf), _("Treasury: "));
1880 pstr2 = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1881 pstr2->style |= TTF_STYLE_BOLD;
1882 treasury_text = create_text_surf_from_utf8(pstr2);
1883 w3 = MAX(w3, treasury_text->w);
1884
1885 /* "Treasury" value label */
1886 fc_snprintf(cbuf, sizeof(cbuf), "%d", client.conn.playing->economic.gold);
1887 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1888 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1889
1890 buf = create_iconlabel(icons->big_coin, pwindow->dst, pstr,
1891 (WF_RESTORE_BACKGROUND|WF_ICON_CENTER_RIGHT));
1892
1893 add_to_gui_list(ID_LABEL, buf);
1894
1895 w = MAX(w, buf->size.w);
1896 h += buf->size.h;
1897
1898 /* "Tax Rate" text surface */
1899 fc_snprintf(cbuf, sizeof(cbuf), _("Tax Rate: "));
1900 copy_chars_to_utf8_str(pstr2, cbuf);
1901 tax_rate_text = create_text_surf_from_utf8(pstr2);
1902 w3 = MAX(w3, tax_rate_text->w);
1903
1904 /* "Tax Rate" value label */
1905 /* It is important to leave 1 space at ending of this string. */
1906 fc_snprintf(cbuf, sizeof(cbuf), "%d%% ", client.conn.playing->economic.tax);
1907 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1908 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1909
1910 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1911
1912 add_to_gui_list(ID_LABEL, buf);
1913
1914 w = MAX(w, buf->size.w + buf->next->size.w);
1915 h += buf->size.h;
1916
1917 /* "Total Income" text surface */
1918 fc_snprintf(cbuf, sizeof(cbuf), _("Total Income: "));
1919 copy_chars_to_utf8_str(pstr2, cbuf);
1920 total_income_text = create_text_surf_from_utf8(pstr2);
1921 w3 = MAX(w3, total_income_text->w);
1922
1923 /* "Total Icome" value label */
1924 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax);
1925 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1926 pstr->style |= TTF_STYLE_BOLD;
1927
1928 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1929
1930 add_to_gui_list(ID_LABEL, buf);
1931
1932 w = MAX(w, buf->size.w);
1933 h += buf->size.h;
1934
1935 /* "Total Cost" text surface */
1936 fc_snprintf(cbuf, sizeof(cbuf), _("Total Cost: "));
1937 copy_chars_to_utf8_str(pstr2, cbuf);
1938 total_cost_text = create_text_surf_from_utf8(pstr2);
1939
1940 /* "Total Cost" value label */
1941 fc_snprintf(cbuf, sizeof(cbuf), "%d", total);
1942 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1943 pstr->style |= TTF_STYLE_BOLD;
1944
1945 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1946
1947 add_to_gui_list(ID_LABEL, buf);
1948
1949 w = MAX(w, buf->size.w);
1950 h += buf->size.h;
1951
1952 /* "Net Income" text surface */
1953 fc_snprintf(cbuf, sizeof(cbuf), _("Net Income: "));
1954 copy_chars_to_utf8_str(pstr2, cbuf);
1955 net_income_text = create_text_surf_from_utf8(pstr2);
1956 w3 = MAX(w3, net_income_text->w);
1957
1958 /* "Net Icome" value label */
1959 fc_snprintf(cbuf, sizeof(cbuf), "%d", tax - total);
1960 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1961 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1962
1963 if (tax - total < 0) {
1964 pstr->fgcol = *get_theme_color(COLOR_THEME_ECONOMYDLG_NEG_TEXT);
1965 }
1966
1967 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1968
1969 add_to_gui_list(ID_LABEL, buf);
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%%"),
1976 government_name_translation(gov),
1977 get_player_bonus(client.conn.playing, EFT_MAX_RATES));
1978 copy_chars_to_utf8_str(pstr2, cbuf);
1979 max_rate_text = create_text_surf_from_utf8(pstr2);
1980
1981 FREEUTF8STR(pstr2);
1982
1983 /* ------------------------- */
1984 /* Lux rate */
1985
1986 /* Lux rate lock */
1987 fc_snprintf(cbuf, sizeof(cbuf), _("Lock"));
1988 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
1989 pstr->style |= TTF_STYLE_BOLD;
1990
1991 buf = create_checkbox(pwindow->dst,
1992 sdl3_client_flags & CF_CHANGE_TAXRATE_LUX_BLOCK,
1993 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
1994 set_new_checkbox_theme(buf, current_theme->lock_icon,
1995 current_theme->unlock_icon);
1996 buf->info_label = pstr;
1997 buf->action = toggle_block_callback;
1998 set_wstate(buf, FC_WS_NORMAL);
1999
2000 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX, buf);
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),
2006 (WF_FREE_DATA | WF_RESTORE_BACKGROUND));
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;
2011 set_wstate(buf, FC_WS_NORMAL);
2012
2013 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR, buf);
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);
2021 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT_PLUS);
2022 pstr->style |= TTF_STYLE_BOLD;
2023
2024 buf = create_iconlabel(icons->big_luxury, pwindow->dst, pstr,
2025 WF_RESTORE_BACKGROUND);
2026 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_LABEL, buf);
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"));
2035 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
2036 pstr->style |= TTF_STYLE_BOLD;
2037
2038 buf = create_checkbox(pwindow->dst,
2039 sdl3_client_flags & CF_CHANGE_TAXRATE_SCI_BLOCK,
2040 WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL);
2041
2042 set_new_checkbox_theme(buf, current_theme->lock_icon,
2043 current_theme->unlock_icon);
2044
2045 buf->info_label = pstr;
2046 buf->action = toggle_block_callback;
2047 set_wstate(buf, FC_WS_NORMAL);
2048
2049 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX, buf);
2050
2051 /* Science rate slider */
2052 buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30),
2053 (WF_FREE_DATA | WF_RESTORE_BACKGROUND));
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
2059 set_wstate(buf, FC_WS_NORMAL);
2060
2061 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR, buf);
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);
2066 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT_PLUS);
2067 pstr->style |= TTF_STYLE_BOLD;
2068
2069 buf = create_iconlabel(icons->big_colb, pwindow->dst, pstr,
2070 WF_RESTORE_BACKGROUND);
2071
2072 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_SCI_LABEL, buf);
2073
2074 /* ---- */
2075
2076 fc_snprintf(cbuf, sizeof(cbuf), _("Update"));
2077 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
2078 buf = create_themeicon_button(current_theme->small_ok_icon, pwindow->dst,
2079 pstr, 0);
2080 buf->action = apply_taxrates_callback;
2081 set_wstate(buf, FC_WS_NORMAL);
2082
2083 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_OK_BUTTON, buf);
2084
2085 /* ---- */
2086
2087 fc_snprintf(cbuf, sizeof(cbuf), _("Close Dialog (Esc)"));
2088 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
2089 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2090 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
2091 buf->info_label = pstr;
2092 buf->action = exit_economy_dialog_callback;
2093 set_wstate(buf, FC_WS_NORMAL);
2094 buf->key = SDLK_ESCAPE;
2095
2096 add_to_gui_list(ID_CHANGE_TAXRATE_DLG_CANCEL_BUTTON, buf);
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_FillSurfaceRect(background, NULL, map_rgba(background->format, bg_color));
2108
2109 create_frame(background,
2110 0, 0, background->w - 1, background->h - 1,
2111 get_theme_color(COLOR_THEME_ECONOMYDLG_FRAME));
2112
2113 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
2114 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
2115 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
2116
2117 for (i = 0; i < entries_used; i++) {
2118 struct improvement_entry *p = &entries[i];
2119 struct impr_type *pimprove = p->type;
2120
2121 surf = crop_rect_from_surface(background, NULL);
2122
2123 fc_snprintf(cbuf, sizeof(cbuf), "%s",
2124 improvement_name_translation(pimprove));
2125
2126 copy_chars_to_utf8_str(pstr, cbuf);
2127 pstr->style |= TTF_STYLE_BOLD;
2128 text_name = create_text_surf_smaller_than_w(pstr, surf->w - adj_size(4));
2129
2130 fc_snprintf(cbuf, sizeof(cbuf), "%s %d\n%s %d",
2131 _("Built"), p->count, _("U Total"),p->total_cost);
2132 copy_chars_to_utf8_str(pstr, cbuf);
2133 pstr->style &= ~TTF_STYLE_BOLD;
2134
2135 text = create_text_surf_from_utf8(pstr);
2136
2137 /*-----------------*/
2138
2139 zoomed = get_building_surface(pimprove);
2140 zoomed = zoomSurface(zoomed, DEFAULT_ZOOM * ((float)54 / zoomed->w),
2141 DEFAULT_ZOOM * ((float)54 / zoomed->w), 1);
2142
2143 dst.x = (surf->w - zoomed->w) / 2;
2144 dst.y = (surf->h / 2 - zoomed->h) / 2;
2145 alphablit(zoomed, NULL, surf, &dst, 255);
2146 dst.y += zoomed->h;
2147 FREESURFACE(zoomed);
2148
2149 dst.x = (surf->w - text_name->w)/2;
2150 dst.y += ((surf->h - dst.y) -
2151 (text_name->h + (icons->big_coin->h + 2) + text->h)) / 2;
2152 alphablit(text_name, NULL, surf, &dst, 255);
2153
2154 dst.y += text_name->h;
2155 if (p->cost) {
2156 dst.x = (surf->w - p->cost * (icons->big_coin->w + 1))/2;
2157 for (count = 0; count < p->cost; count++) {
2158 alphablit(icons->big_coin, NULL, surf, &dst, 255);
2159 dst.x += icons->big_coin->w + 1;
2160 }
2161 } else {
2162
2163 if (!is_wonder(pimprove)) {
2164 copy_chars_to_utf8_str(pstr, _("Nation"));
2165 } else {
2166 copy_chars_to_utf8_str(pstr, _("Wonder"));
2167 }
2168 /* pstr->style &= ~TTF_STYLE_BOLD; */
2169
2170 zoomed = create_text_surf_from_utf8(pstr);
2171
2172 dst.x = (surf->w - zoomed->w) / 2;
2173 alphablit(zoomed, NULL, surf, &dst, 255);
2174 FREESURFACE(zoomed);
2175 }
2176
2177 dst.y += (icons->big_coin->h + adj_size(2));
2178 dst.x = (surf->w - text->w) / 2;
2179 alphablit(text, NULL, surf, &dst, 255);
2180
2181 FREESURFACE(text);
2182 FREESURFACE(text_name);
2183
2184 buf = create_icon2(surf, pwindow->dst,
2185 (WF_RESTORE_BACKGROUND|WF_FREE_THEME|WF_FREE_DATA));
2186
2187 set_wstate(buf, FC_WS_NORMAL);
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
2194 add_to_gui_list(MAX_ID - i, buf);
2195
2196 if (i > (TARGETS_ROW * TARGETS_COL - 1)) {
2197 set_wflag(buf, WF_HIDDEN);
2198 }
2199 }
2200
2201 FREEUTF8STR(pstr);
2202 FREESURFACE(background);
2203
2204 economy_dlg->end_active_widget_list = last->prev;
2205 economy_dlg->begin_widget_list = buf;
2206 economy_dlg->begin_active_widget_list = economy_dlg->begin_widget_list;
2207
2208 if (entries_used > (TARGETS_ROW * TARGETS_COL)) {
2209 economy_dlg->active_widget_list = economy_dlg->end_active_widget_list;
2210 count = create_vertical_scrollbar(economy_dlg,
2211 TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
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 {
2222 economy_dlg->begin_widget_list = buf;
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
2230 background = theme_get_background(active_theme, BACKGROUND_ECONOMYDLG);
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,
2294 get_theme_color(COLOR_THEME_ECONOMYDLG_FRAME));
2295
2296 /* draw statical strings */
2297 dst.x = area.x + adj_size(10);
2298 dst.y = area.y + adj_size(5);
2299
2300 /* "Treasury */
2301 alphablit(treasury_text, NULL, pwindow->theme, &dst, 255);
2302 dst.y += treasury_text->h;
2303 FREESURFACE(treasury_text);
2304
2305 /* Tax Rate */
2306 alphablit(tax_rate_text, NULL, pwindow->theme, &dst, 255);
2307 dst.y += tax_rate_text->h;
2308 FREESURFACE(tax_rate_text);
2309
2310 /* Total Income */
2311 alphablit(total_income_text, NULL, pwindow->theme, &dst, 255);
2312 dst.y += total_income_text->h;
2313 FREESURFACE(total_income_text);
2314
2315 /* Total Cost */
2316 alphablit(total_cost_text, NULL, pwindow->theme, &dst, 255);
2317 dst.y += total_cost_text->h;
2318 FREESURFACE(total_cost_text);
2319
2320 /* Net Income */
2321 alphablit(net_income_text, NULL, pwindow->theme, &dst, 255);
2322 dst.y += net_income_text->h;
2323 FREESURFACE(net_income_text);
2324
2325 /* gov and taxrate */
2326 dst.x = area.x + adj_size(10) + w + ((area.w - (w + adj_size(10)) - max_rate_text->w) / 2);
2327 dst.y = area.y + adj_size(5);
2328
2329 alphablit(max_rate_text, NULL, pwindow->theme, &dst, 255);
2330 dst.y += (max_rate_text->h + 1);
2331 FREESURFACE(max_rate_text);
2332
2333 /* Luxuries Horizontal Scrollbar Background */
2334 dst.x = area.x + adj_size(10) + w + (area.w - (w + adj_size(10)) - adj_size(184)) / 2;
2335 dst.w = adj_size(184);
2336 dst.h = current_theme->horiz->h - adj_size(2);
2337
2338 fill_rect_alpha(pwindow->theme, &dst, &bg_color3);
2339
2340 create_frame(pwindow->theme,
2341 dst.x, dst.y, dst.w - 1, dst.h - 1,
2342 get_theme_color(COLOR_THEME_ECONOMYDLG_FRAME));
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,
2365 get_theme_color(COLOR_THEME_ECONOMYDLG_FRAME));
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) {
2394 setup_vertical_widgets_position(TARGETS_COL,
2395 area.x,
2396 area.y + h,
2397 0, 0, economy_dlg->begin_active_widget_list,
2398 economy_dlg->end_active_widget_list);
2399 if (economy_dlg->scroll) {
2400 setup_vertical_scrollbar_area(economy_dlg->scroll,
2401 area.x + area.w - 1,
2402 area.y + h,
2403 area.h - h - 1, TRUE);
2404 }
2405 }
2406
2407 /* ------------------------ */
2408 redraw_group(economy_dlg->begin_widget_list, pwindow, 0);
2409 widget_mark_dirty(pwindow);
2410 flush_dirty();
2411}
2412
2413/* ===================================================================== */
2414/* ======================== Science Report ============================= */
2415/* ===================================================================== */
2416 static struct small_dialog *science_dlg = NULL;
2417
2418 static struct advanced_dialog *change_tech_dlg = NULL;
2419
2420/**********************************************************************/
2423 SDL_Surface *create_select_tech_icon(utf8_str *pstr, Tech_type_id tech_id,
2424 enum tech_info_mode mode)
2425{
2426 SDL_Surface *surf, *text, *tmp, *tmp2;
2427 SDL_Surface *surf_array[10], **buf_array;
2428 SDL_Rect dst;
2429 SDL_Color color;
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:
2439 color = *get_theme_color(COLOR_THEME_SCIENCEDLG_MED_TECHICON_BG);
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
2447 text = create_text_surf_smaller_than_w(pstr, adj_size(100 - 4));
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_FillSurfaceRect(surf, NULL, map_rgba(surf->format, color));
2459
2460 create_frame(surf,
2461 0,0, surf->w - 1, surf->h - 1,
2462 get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
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 }
2504 } requirement_vector_iterate_end;
2505 } improvement_iterate_end;
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 */
2515 buf_array = surf_array;
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;
2537 unit_type_iterate(un) {
2538 if (is_tech_req_for_utype(un, advance_by_number(tech_id))) {
2539 surf_array[w++] = adj_surf(get_unittype_surface(un, direction8_invalid()));
2540 }
2541 } unit_type_iterate_end;
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);
2552 FREESURFACE(zoomed);
2553 } else {
2554 dst.x = (surf->w - surf_array[0]->w) / 2;
2555 alphablit(surf_array[0], NULL, surf, &dst, 255);
2556 }
2557 FREESURFACE(surf_array[0]);
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;
2567 buf_array = surf_array;
2568 h = 0;
2569 while (w) {
2570 SDL_Surface *zoomed = zoomSurface((*buf_array), zoom, zoom, 1);
2571
2572 FREESURFACE(*buf_array);
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++;
2587 FREESURFACE(zoomed);
2588 } /* while */
2589 } /* w > 1 */
2590 } /* if (w) */
2591 }
2592
2593 FREESURFACE(tmp);
2594
2595 return surf;
2596}
2597
2598/**********************************************************************/
2601 static void enable_science_dialog(void)
2602{
2603 set_group_state(science_dlg->begin_widget_list,
2604 science_dlg->end_widget_list->prev, FC_WS_NORMAL);
2605}
2606
2607/**********************************************************************/
2610 static void disable_science_dialog(void)
2611{
2612 set_group_state(science_dlg->begin_widget_list,
2613 science_dlg->end_widget_list->prev, FC_WS_DISABLED);
2614}
2615
2616/**********************************************************************/
2619 void real_science_report_dialog_update(void *unused)
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;
2627 SDL_Surface *msurf;
2628 SDL_Surface *colb_surface = icons->big_colb;
2629 int step, i, cost;
2630 SDL_Rect dest;
2631 struct widget *change_research_button;
2632 struct widget *change_research_goal_button;
2633 SDL_Rect area;
2634 struct widget *pwindow = science_dlg->end_widget_list;
2635
2636 area = pwindow->area;
2637 change_research_button = pwindow->prev;
2638 change_research_goal_button = pwindow->prev->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 */
2647 FREESURFACE(change_research_button->theme);
2648 change_research_button->theme = get_tech_icon(presearch->researching);
2649 FREESURFACE(change_research_goal_button->theme);
2650 change_research_goal_button->theme = get_tech_icon(presearch->tech_goal);
2651
2652 /* Redraw Window */
2653 widget_redraw(pwindow);
2654
2655 /* ------------------------------------- */
2656
2657 /* Research progress text */
2658 str = create_utf8_from_char_fonto(science_dialog_text(), FONTO_ATTENTION);
2659 str->style |= SF_CENTER;
2660 str->fgcol = *get_theme_color(COLOR_THEME_SCIENCEDLG_TEXT);
2661
2662 msurf = create_text_surf_from_utf8(str);
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
2670 FREESURFACE(msurf);
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,
2677 get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
2678
2679 dest.y += adj_size(6);
2680
2681 widget_set_position(change_research_button, dest.x, dest.y + adj_size(18));
2682
2683 /* current research text */
2684 fc_snprintf(cbuf, sizeof(cbuf), "%s: %s",
2685 research_advance_name_translation(presearch,
2686 presearch->researching),
2687 get_science_target_text(NULL));
2688
2689 copy_chars_to_utf8_str(str, cbuf);
2690
2691 msurf = create_text_surf_from_utf8(str);
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
2699 FREESURFACE(msurf);
2700
2701 /* progress bar */
2702 if (cost > 0) {
2703 int cost_div_safe = cost - 1;
2704
2705 cost_div_safe = (cost_div_safe != 0 ? cost_div_safe : 1);
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,
2722 get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
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 }
2752 } requirement_vector_iterate_end;
2753 } improvement_iterate_end;
2754
2755 dest.x += adj_size(5);
2756
2757 /* Units */
2758 unit_type_iterate(un) {
2759 if (is_tech_req_for_utype(un, advance_by_number(presearch->researching))) {
2760 SDL_Surface *usurf = get_unittype_surface(un, direction8_invalid());
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);
2769 FREESURFACE(msurf);
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 }
2776 } unit_type_iterate_end;
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,
2785 get_theme_color(COLOR_THEME_SCIENCEDLG_FRAME));
2786
2787 dest.x = change_research_button->size.x;
2788 dest.y += adj_size(6);
2789
2790 widget_set_position(change_research_goal_button, dest.x, dest.y + adj_size(16));
2791
2792 /* -------------------------------- */
2793
2794 /* Goals */
2795 if (A_UNSET != presearch->tech_goal) {
2796 /* current goal text */
2797 copy_chars_to_utf8_str(str, research_advance_name_translation
2798 (presearch, presearch->tech_goal));
2799 msurf = create_text_surf_from_utf8(str);
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
2806 FREESURFACE(msurf);
2807
2808 copy_chars_to_utf8_str(str, get_science_goal_text
2809 (presearch->tech_goal));
2810 msurf = create_text_surf_from_utf8(str);
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
2817 FREESURFACE(msurf);
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 }
2829 } requirement_vector_iterate_end;
2830 } improvement_iterate_end;
2831
2832 dest.x += adj_size(6);
2833
2834 /* units */
2835 unit_type_iterate(un) {
2836 if (is_tech_req_for_utype(un, advance_by_number(presearch->tech_goal))) {
2837 SDL_Surface *usurf = get_unittype_surface(un, direction8_invalid());
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);
2846 FREESURFACE(msurf);
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 }
2853 } unit_type_iterate_end;
2854 }
2855
2856 /* -------------------------------- */
2857 widget_mark_dirty(pwindow);
2858 redraw_group(science_dlg->begin_widget_list, pwindow->prev, 1);
2859 flush_dirty();
2860
2861 FREEUTF8STR(str);
2862 }
2863}
2864
2865/**********************************************************************/
2868 static void science_report_dialog_popdown(void)
2869{
2870 if (science_dlg) {
2871 popdown_window_group_dialog(science_dlg->begin_widget_list,
2872 science_dlg->end_widget_list);
2873 FC_FREE(science_dlg);
2874 set_wstate(get_research_widget(), FC_WS_NORMAL);
2875 widget_redraw(get_research_widget());
2876 widget_mark_dirty(get_research_widget());
2877 flush_dirty();
2878 }
2879}
2880
2881/**********************************************************************/
2884 static int exit_change_tech_dlg_callback(struct widget *pwidget)
2885{
2886 if (PRESSED_EVENT(main_data.event)) {
2887 if (change_tech_dlg) {
2888 popdown_window_group_dialog(change_tech_dlg->begin_widget_list,
2889 change_tech_dlg->end_widget_list);
2890 FC_FREE(change_tech_dlg->scroll);
2891 FC_FREE(change_tech_dlg);
2892 enable_science_dialog();
2893 if (pwidget) {
2894 flush_dirty();
2895 }
2896 }
2897 }
2898
2899 return -1;
2900}
2901
2902/**********************************************************************/
2905 static int change_research_callback(struct widget *pwidget)
2906{
2907 if (PRESSED_EVENT(main_data.event)) {
2908 dsend_packet_player_research(&client.conn, (MAX_ID - pwidget->id));
2909 exit_change_tech_dlg_callback(NULL);
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/**********************************************************************/
2920 static int change_research_goal_dialog_callback(struct widget *pwindow)
2921{
2922 if (PRESSED_EVENT(main_data.event)) {
2923 if (select_window_group_dialog(change_tech_dlg->begin_widget_list, pwindow)) {
2924 widget_flush(pwindow);
2925 }
2926 }
2927
2928 return -1;
2929}
2930
2931/**********************************************************************/
2934 static void popup_change_research_dialog(void)
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;
2943 Tech_type_id ac;
2944
2945 if (is_future_tech(presearch->researching)) {
2946 return;
2947 }
2948
2949 ac = advance_count();
2950 advance_index_iterate_max(A_FIRST, aidx, ac) {
2951 if (!research_invention_gettable(presearch, aidx, FALSE)) {
2952 continue;
2953 }
2954 count++;
2955 } advance_index_iterate_max_end;
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?"),
2964 FONTO_ATTENTION);
2965 pstr->style |= TTF_STYLE_BOLD;
2966
2967 pwindow = create_window_skeleton(NULL, pstr, 0);
2968 change_tech_dlg->end_widget_list = pwindow;
2969 set_wstate(pwindow, FC_WS_NORMAL);
2970 pwindow->action = change_research_goal_dialog_callback;
2971
2972 add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_WINDOW, pwindow);
2973
2974 area = pwindow->area;
2975
2976 /* ------------------------- */
2977 /* Exit button */
2978 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
2979 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
2980 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
2981 FONTO_ATTENTION);
2982 area.w += buf->size.w + adj_size(10);
2983 buf->action = exit_change_tech_dlg_callback;
2984 set_wstate(buf, FC_WS_NORMAL);
2985 buf->key = SDLK_ESCAPE;
2986
2987 add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, buf);
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
3014 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
3015 pstr->style |= (TTF_STYLE_BOLD | SF_CENTER);
3016
3017 count = 0;
3018 h = col * max_row;
3019 advance_index_iterate_max(A_FIRST, aidx, ac) {
3020 if (!research_invention_gettable(presearch, aidx, FALSE)) {
3021 continue;
3022 }
3023
3024 count++;
3025
3026 copy_chars_to_utf8_str(pstr, advance_name_translation(advance_by_number(aidx)));
3027 surf = create_select_tech_icon(pstr, aidx, TIM_MED_MODE);
3028 buf = create_icon2(surf, pwindow->dst,
3029 WF_FREE_THEME | WF_RESTORE_BACKGROUND);
3030
3031 set_wstate(buf, FC_WS_NORMAL);
3032 buf->action = change_research_callback;
3033
3034 add_to_gui_list(MAX_ID - aidx, buf);
3035
3036 if (count > h) {
3037 set_wflag(buf, WF_HIDDEN);
3038 }
3039 } advance_index_iterate_max_end;
3040
3041 FREEUTF8STR(pstr);
3042
3043 change_tech_dlg->begin_widget_list = buf;
3044 change_tech_dlg->begin_active_widget_list = change_tech_dlg->begin_widget_list;
3045 change_tech_dlg->end_active_widget_list = change_tech_dlg->end_widget_list->prev->prev;
3046
3047 /* -------------------------------------------------------------- */
3048
3049 i = 0;
3050 if (count > col) {
3051 count = (count + (col - 1)) / col;
3052 if (count > max_row) {
3053 change_tech_dlg->active_widget_list = change_tech_dlg->end_active_widget_list;
3054 count = max_row;
3055 i = create_vertical_scrollbar(change_tech_dlg, col, count, TRUE, TRUE);
3056 }
3057 } else {
3058 count = 1;
3059 }
3060
3061 disable_science_dialog();
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 */
3067 surf = theme_get_background(active_theme, BACKGROUND_CHANGERESEARCHDLG);
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
3084 setup_vertical_widgets_position(col, area.x + 1,
3085 area.y, 0, 0,
3086 change_tech_dlg->begin_active_widget_list,
3087 change_tech_dlg->end_active_widget_list);
3088
3089 if (change_tech_dlg->scroll) {
3090 setup_vertical_scrollbar_area(change_tech_dlg->scroll,
3091 area.x + area.w, area.y,
3092 area.h, TRUE);
3093 }
3094
3095 redraw_group(change_tech_dlg->begin_widget_list, pwindow, FALSE);
3096
3097 widget_flush(pwindow);
3098}
3099
3100/**********************************************************************/
3103 static int change_research_goal_callback(struct widget *pwidget)
3104{
3105 if (PRESSED_EVENT(main_data.event)) {
3106 dsend_packet_player_tech_goal(&client.conn, (MAX_ID - pwidget->id));
3107
3108 exit_change_tech_dlg_callback(NULL);
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 */
3112 real_science_report_dialog_update(NULL);
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/**********************************************************************/
3123 static void popup_change_research_goal_dialog(void)
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;
3133 Tech_type_id ac = advance_count();
3134
3135 /* Collect all techs which are reachable in under 11 steps
3136 * hist will hold afterwards the techid of the current choice
3137 */
3138 advance_index_iterate_max(A_FIRST, aidx, ac) {
3139 if (research_invention_reachable(presearch, aidx)
3140 && TECH_KNOWN != research_invention_state(presearch, aidx)
3141 && (11 > research_goal_unknown_techs(presearch, aidx)
3142 || aidx == presearch->tech_goal)) {
3143 count++;
3144 }
3145 } advance_index_iterate_max_end;
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);
3157 change_tech_dlg->end_widget_list = pwindow;
3158 set_wstate(pwindow, FC_WS_NORMAL);
3159 pwindow->action = change_research_goal_dialog_callback;
3160
3161 add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_WINDOW, pwindow);
3162
3163 area = pwindow->area;
3164
3165 /* ------------------------- */
3166 /* Exit button */
3167 buf = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3168 WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
3169 buf->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3170 FONTO_ATTENTION);
3171 area.w += buf->size.w + adj_size(10);
3172 buf->action = exit_change_tech_dlg_callback;
3173 set_wstate(buf, FC_WS_NORMAL);
3174 buf->key = SDLK_ESCAPE;
3175
3176 add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_CANCEL_BUTTON, buf);
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
3204 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
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;
3212 advance_index_iterate_max(A_FIRST, aidx, ac) {
3213 if (research_invention_reachable(presearch, aidx)
3214 && TECH_KNOWN != research_invention_state(presearch, aidx)
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",
3220 advance_name_translation(advance_by_number(aidx)),
3221 num,
3222 PL_("step", "steps", num));
3223 copy_chars_to_utf8_str(pstr, cbuf);
3224 surf = create_select_tech_icon(pstr, aidx, TIM_FULL_MODE);
3225 buf = create_icon2(surf, pwindow->dst,
3226 WF_FREE_THEME | WF_RESTORE_BACKGROUND);
3227
3228 set_wstate(buf, FC_WS_NORMAL);
3229 buf->action = change_research_goal_callback;
3230
3231 add_to_gui_list(MAX_ID - aidx, buf);
3232
3233 if (count > h) {
3234 set_wflag(buf, WF_HIDDEN);
3235 }
3236 }
3237 } advance_index_iterate_max_end;
3238
3239 FREEUTF8STR(pstr);
3240
3241 change_tech_dlg->begin_widget_list = buf;
3242 change_tech_dlg->begin_active_widget_list = change_tech_dlg->begin_widget_list;
3243 change_tech_dlg->end_active_widget_list = change_tech_dlg->end_widget_list->prev->prev;
3244
3245 /* -------------------------------------------------------------- */
3246
3247 i = 0;
3248 if (count > col) {
3249 count = (count + (col-1)) / col;
3250 if (count > max_row) {
3251 change_tech_dlg->active_widget_list = change_tech_dlg->end_active_widget_list;
3252 count = max_row;
3253 i = create_vertical_scrollbar(change_tech_dlg, col, count, TRUE, TRUE);
3254 }
3255 } else {
3256 count = 1;
3257 }
3258
3259 disable_science_dialog();
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 */
3265 surf = theme_get_background(active_theme, BACKGROUND_CHANGERESEARCHDLG);
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
3282 setup_vertical_widgets_position(col, area.x + 1,
3283 area.y, 0, 0,
3284 change_tech_dlg->begin_active_widget_list,
3285 change_tech_dlg->end_active_widget_list);
3286
3287 if (change_tech_dlg->scroll) {
3288 setup_vertical_scrollbar_area(change_tech_dlg->scroll,
3289 area.x + area.w, area.y,
3290 area.h, TRUE);
3291 }
3292
3293 redraw_group(change_tech_dlg->begin_widget_list, pwindow, FALSE);
3294
3295 widget_flush(pwindow);
3296}
3297
3298/**********************************************************************/
3301 static int science_dialog_callback(struct widget *pwindow)
3302{
3303 if (PRESSED_EVENT(main_data.event)) {
3304 if (!change_tech_dlg) {
3305 if (select_window_group_dialog(science_dlg->begin_widget_list, pwindow)) {
3306 widget_flush(pwindow);
3307 }
3308 if (move_window_group_dialog(science_dlg->begin_widget_list, pwindow)) {
3309 real_science_report_dialog_update(NULL);
3310 }
3311 }
3312 }
3313
3314 return -1;
3315}
3316
3317/**********************************************************************/
3320 static int popup_change_research_dialog_callback(struct widget *pwidget)
3321{
3322 if (PRESSED_EVENT(main_data.event)) {
3323 set_wstate(pwidget, FC_WS_NORMAL);
3324 selected_widget = NULL;
3325 widget_redraw(pwidget);
3326 widget_flush(pwidget);
3327
3328 popup_change_research_dialog();
3329 }
3330
3331 return -1;
3332}
3333
3334/**********************************************************************/
3337 static int popup_change_research_goal_dialog_callback(struct widget *pwidget)
3338{
3339 if (PRESSED_EVENT(main_data.event)) {
3340 set_wstate(pwidget, FC_WS_NORMAL);
3341 selected_widget = NULL;
3342 widget_redraw(pwidget);
3343 widget_flush(pwidget);
3344
3345 popup_change_research_goal_dialog();
3346 }
3347
3348 return -1;
3349}
3350
3351/**********************************************************************/
3354 static int popdown_science_dialog_callback(struct widget *pwidget)
3355{
3356 if (PRESSED_EVENT(main_data.event)) {
3357 science_report_dialog_popdown();
3358 }
3359
3360 return -1;
3361}
3362
3363/**********************************************************************/
3366 void science_report_dialog_popup(bool raise)
3367{
3368 const struct research *presearch;
3369 struct widget *pwidget, *pwindow;
3370 struct widget *change_research_button;
3371 struct widget *change_research_goal_button;
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
3382 presearch = research_get(client_player());
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 */
3393 pstr = create_utf8_from_char_fonto(_("Research"), FONTO_ATTENTION);
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);
3402 pwindow->action = science_dialog_callback;
3403
3404 science_dlg->end_widget_list = pwindow;
3405
3406 background = theme_get_background(active_theme, BACKGROUND_SCIENCEDLG);
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
3418 add_to_gui_list(ID_SCIENCE_DLG_WINDOW, pwindow);
3419
3420 /* count number of researchable techs */
3421 count = 0;
3422 advance_index_iterate(A_FIRST, i) {
3423 if (research_invention_reachable(presearch, i)
3424 && TECH_KNOWN != research_invention_state(presearch, i)) {
3425 count++;
3426 }
3427 } advance_index_iterate_end;
3428
3429 /* current research icon */
3430 tech_icon = get_tech_icon(presearch->researching);
3431 change_research_button = create_icon2(tech_icon, pwindow->dst,
3432 WF_RESTORE_BACKGROUND | WF_FREE_THEME);
3433
3434 change_research_button->action = popup_change_research_dialog_callback;
3435 if (count > 0) {
3436 set_wstate(change_research_button, FC_WS_NORMAL);
3437 }
3438
3439 add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, change_research_button);
3440
3441 /* current research goal icon */
3442 tech_icon = get_tech_icon(presearch->tech_goal);
3443 change_research_goal_button = create_icon2(tech_icon, pwindow->dst,
3444 WF_RESTORE_BACKGROUND | WF_FREE_THEME);
3445
3446 change_research_goal_button->action = popup_change_research_goal_dialog_callback;
3447 if (count > 0) {
3448 set_wstate(change_research_goal_button, FC_WS_NORMAL);
3449 }
3450
3451 add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON, change_research_goal_button);
3452
3453 /* ------ */
3454 /* Exit button */
3455 exit_button = create_themeicon(current_theme->small_cancel_icon, pwindow->dst,
3456 WF_WIDGET_HAS_INFO_LABEL
3457 | WF_RESTORE_BACKGROUND);
3458 exit_button->info_label = create_utf8_from_char_fonto(_("Close Dialog (Esc)"),
3459 FONTO_ATTENTION);
3460 exit_button->action = popdown_science_dialog_callback;
3461 set_wstate(exit_button, FC_WS_NORMAL);
3462 exit_button->key = SDLK_ESCAPE;
3463
3464 add_to_gui_list(ID_SCIENCE_CANCEL_DLG_BUTTON, exit_button);
3465
3466 widget_set_position(exit_button,
3467 area.x + area.w - exit_button->size.w - adj_size(1),
3468 pwindow->size.y + adj_size(2));
3469
3470 /* ======================== */
3471 science_dlg->begin_widget_list = exit_button;
3472
3473 real_science_report_dialog_update(NULL);
3474}
3475
3476/**********************************************************************/
3479 void science_report_dialogs_popdown_all(void)
3480{
3481 if (change_tech_dlg) {
3482 popdown_window_group_dialog(change_tech_dlg->begin_widget_list,
3483 change_tech_dlg->end_widget_list);
3484 FC_FREE(change_tech_dlg->scroll);
3485 FC_FREE(change_tech_dlg);
3486 }
3487 if (science_dlg) {
3488 popdown_window_group_dialog(science_dlg->begin_widget_list,
3489 science_dlg->end_widget_list);
3490 FC_FREE(science_dlg);
3491 set_wstate(get_research_widget(), FC_WS_NORMAL);
3492 widget_redraw(get_research_widget());
3493 widget_mark_dirty(get_research_widget());
3494 }
3495}
3496
3497/**********************************************************************/
3500 void science_report_dialog_redraw(void)
3501{
3502 /* No requirement tree yet. */
3503}
3504
3505/* ===================================================================== */
3506/* ======================== Endgame Report ============================= */
3507/* ===================================================================== */
3508
3509 static char eg_buffer[150 * MAX_NUM_PLAYERS];
3510 static int eg_player_count = 0;
3511 static int eg_players_received = 0;
3512
3513/**********************************************************************/
3517 void endgame_report_dialog_start(const struct packet_endgame_report *packet)
3518{
3519 eg_buffer[0] = '\0';
3520 eg_player_count = packet->player_num;
3521 eg_players_received = 0;
3522}
3523
3524/**********************************************************************/
3527 void endgame_report_dialog_player(const struct packet_endgame_player *packet)
3528{
3529 const struct player *pplayer = player_by_number(packet->player_id);
3530
3531 eg_players_received++;
3532
3533 cat_snprintf(eg_buffer, sizeof(eg_buffer),
3534 PL_("%2d: The %s ruler %s scored %d point\n",
3535 "%2d: The %s ruler %s scored %d points\n",
3536 packet->score),
3537 eg_players_received, nation_adjective_for_player(pplayer),
3538 player_name(pplayer), packet->score);
3539
3540 if (eg_players_received == eg_player_count) {
3541 popup_notify_dialog(_("Final Report:"),
3542 _("The Greatest Civilizations in the world."),
3543 eg_buffer);
3544 }
3545}
entries_used
int entries_used
Definition agents.c:77
entries
struct @126::my_agent entries[MAX_AGENTS]
str
#define str
Definition astring.c:76
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1231
city_production_turns_to_build
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:819
city_production_build_units
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:746
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
output_type_iterate
#define output_type_iterate(output)
Definition city.h:833
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:839
city_sell_improvement
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
Definition citydlg_common.c:1541
client
struct civclient client
Definition client_main.c:150
client_state
enum client_states client_state(void)
Definition client_main.c:1026
client_main.h
client_player
#define client_player()
Definition client_main.h:106
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
incite_cost
char * incite_cost
Definition comments.c:74
popup_notify_dialog
popup_notify_dialog
Definition dialogs_g.h:37
punit
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
cost
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
get_player_bonus
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
current_theme
QString current_theme
Definition fc_client.cpp:65
Tech_type_id
int Tech_type_id
Definition fc_types.h:380
MAX_NUM_PLAYERS
#define MAX_NUM_PLAYERS
Definition fc_types.h:36
Unit_type_id
int Unit_type_id
Definition fc_types.h:385
O_SHIELD
@ O_SHIELD
Definition fc_types.h:101
O_FOOD
@ O_FOOD
Definition fc_types.h:101
O_GOLD
@ O_GOLD
Definition fc_types.h:101
O_LAST
@ O_LAST
Definition fc_types.h:101
fcintl.h
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
game.h
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
government_of_player
struct government * government_of_player(const struct player *pplayer)
Definition government.c:114
government.h
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
units_report_dialog_popdown
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
science_report_dialog_popup
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
endgame_report_dialog_start
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
real_units_report_dialog_update
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
real_economy_report_dialog_update
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
economy_report_dialog_popdown
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
science_report_dialog_redraw
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
science_report_dialog_popdown
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
real_science_report_dialog_update
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
resize_surface
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
main_window_width
int main_window_width(void)
Definition graphics.c:685
fill_rect_alpha
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
create_line
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
crop_rect_from_surface
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
alphablit
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
main_data
struct sdl2_data main_data
Definition graphics.c:57
create_surf
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
create_frame
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
main_window_height
int main_window_height(void)
Definition graphics.c:693
DEFAULT_ZOOM
#define DEFAULT_ZOOM
Definition graphics.h:198
FREESURFACE
#define FREESURFACE(ptr)
Definition graphics.h:322
adj_surf
#define adj_surf(surf)
Definition graphics.h:200
map_rgba
#define map_rgba(format, color)
Definition graphics.h:315
ID_SCIENCE_CANCEL_DLG_BUTTON
@ ID_SCIENCE_CANCEL_DLG_BUTTON
Definition gui_id.h:186
ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR
@ ID_CHANGE_TAXRATE_DLG_SCI_SCROLLBAR
Definition gui_id.h:175
ID_UNITS_DIALOG_WINDOW
@ ID_UNITS_DIALOG_WINDOW
Definition gui_id.h:135
ID_SCIENCE_DLG_CHANGE_GOAL_CANCEL_BUTTON
@ ID_SCIENCE_DLG_CHANGE_GOAL_CANCEL_BUTTON
Definition gui_id.h:193
ID_SCIENCE_DLG_CHANGE_GOAL_WINDOW
@ ID_SCIENCE_DLG_CHANGE_GOAL_WINDOW
Definition gui_id.h:190
ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX
@ ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX
Definition gui_id.h:180
ID_ECONOMY_DIALOG_WINDOW
@ ID_ECONOMY_DIALOG_WINDOW
Definition gui_id.h:134
ID_TERRAIN_ADV_DLG_EXIT_BUTTON
@ ID_TERRAIN_ADV_DLG_EXIT_BUTTON
Definition gui_id.h:202
ID_ERROR
@ ID_ERROR
Definition gui_id.h:26
ID_SCIENCE_DLG_CHANGE_REASARCH_WINDOW
@ ID_SCIENCE_DLG_CHANGE_REASARCH_WINDOW
Definition gui_id.h:188
ID_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_CHANGE_TAXRATE_DLG_SCI_LABEL
@ ID_CHANGE_TAXRATE_DLG_SCI_LABEL
Definition gui_id.h:178
ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR
@ ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR
Definition gui_id.h:174
ID_CHANGE_TAXRATE_DLG_OK_BUTTON
@ ID_CHANGE_TAXRATE_DLG_OK_BUTTON
Definition gui_id.h:183
ID_SCROLLBAR
@ ID_SCROLLBAR
Definition gui_id.h:32
ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON
@ ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON
Definition gui_id.h:187
ID_LABEL
@ ID_LABEL
Definition gui_id.h:27
ID_CHANGE_TAXRATE_DLG_LUX_LABEL
@ ID_CHANGE_TAXRATE_DLG_LUX_LABEL
Definition gui_id.h:177
ID_SCIENCE_DLG_WINDOW
@ ID_SCIENCE_DLG_WINDOW
Definition gui_id.h:185
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX
@ ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX
Definition gui_id.h:181
ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON
@ ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON
Definition gui_id.h:189
ID_CHANGE_TAXRATE_DLG_CANCEL_BUTTON
@ ID_CHANGE_TAXRATE_DLG_CANCEL_BUTTON
Definition gui_id.h:184
FilterMouseMotionEvents
int FilterMouseMotionEvents(void *data, SDL_Event *event)
Definition gui_main.c:577
MOVE_STEP_Y
int MOVE_STEP_Y
Definition gui_main.c:101
gui_event_loop
Uint16 gui_event_loop(void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_Keysym key, void *data), Uint16(*key_up_handler)(SDL_Keysym key, void *data), Uint16(*textinput_handler)(char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:598
CF_CHANGE_TAXRATE_SCI_BLOCK
#define CF_CHANGE_TAXRATE_SCI_BLOCK
Definition gui_main.h:56
selected_widget
struct widget * selected_widget
Definition widget.c:48
adj_size
#define adj_size(size)
Definition gui_main.h:141
DEFAULT_MOVE_STEP
#define DEFAULT_MOVE_STEP
Definition gui_main.h:113
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:71
CF_CHANGE_TAXRATE_LUX_BLOCK
#define CF_CHANGE_TAXRATE_LUX_BLOCK
Definition gui_main.h:55
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_text_surf_from_utf8
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
create_utf8_str_fonto
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241
create_text_surf_smaller_than_w
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
Definition gui_string.c:539
create_utf8_from_char
#define create_utf8_from_char(string_in, ptsize)
Definition gui_string.h:103
FREEUTF8STR
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:65
FONTO_DEFAULT_PLUS
@ FONTO_DEFAULT_PLUS
Definition gui_string.h:66
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:67
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
icons
struct city_icon * icons
Definition gui_tilespec.c:55
get_tech_color
SDL_Color * get_tech_color(Tech_type_id tech_id)
Definition gui_tilespec.c:453
get_tech_icon
SDL_Surface * get_tech_icon(Tech_type_id tech)
Definition gui_tilespec.c:429
get_building_surface
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
Definition gui_tilespec.h:251
get_unittype_surface
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
Definition gui_tilespec.h:259
popup_tech_info
void popup_tech_info(Tech_type_id tech)
Definition helpdlg.c:1935
get_research_widget
struct widget * get_research_widget(void)
Definition mapctrl.c:2219
get_tax_rates_widget
struct widget * get_tax_rates_widget(void)
Definition mapctrl.c:2211
popdown_science_dialog_callback
static int popdown_science_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3354
popup_change_research_goal_dialog
static void popup_change_research_goal_dialog(void)
Definition repodlgs.c:3123
sell_impr_window_callback
static int sell_impr_window_callback(struct widget *pwindow)
Definition repodlgs.c:1561
eg_player_count
static int eg_player_count
Definition repodlgs.c:3510
eg_players_received
static int eg_players_received
Definition repodlgs.c:3511
units_dlg
static struct advanced_dialog * units_dlg
Definition repodlgs.c:61
exit_economy_dialog_callback
static int exit_economy_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:1145
ok_sell_impr_callback
static int ok_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1525
cancel_sell_impr_callback
static int cancel_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1573
horiz_taxrate_callback
static int horiz_taxrate_callback(struct widget *horiz_src)
Definition repodlgs.c:1319
create_select_tech_icon
SDL_Surface * create_select_tech_icon(utf8_str *pstr, Tech_type_id tech_id, enum tech_info_mode mode)
Definition repodlgs.c:2423
ok_upgrade_unit_window_callback
static int ok_upgrade_unit_window_callback(struct widget *pwidget)
Definition repodlgs.c:134
science_report_dialogs_popdown_all
void science_report_dialogs_popdown_all(void)
Definition repodlgs.c:3479
science_dlg
static struct small_dialog * science_dlg
Definition repodlgs.c:2416
change_research_goal_callback
static int change_research_goal_callback(struct widget *pwidget)
Definition repodlgs.c:3103
economy_dialog_callback
static int economy_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:1133
TARGETS_ROW
#define TARGETS_ROW
Definition repodlgs.c:1816
change_tech_dlg
static struct advanced_dialog * change_tech_dlg
Definition repodlgs.c:2418
apply_taxrates_callback
static int apply_taxrates_callback(struct widget *button)
Definition repodlgs.c:1408
toggle_block_callback
static int toggle_block_callback(struct widget *pcheckbox)
Definition repodlgs.c:1171
real_activeunits_report_dialog_update
static void real_activeunits_report_dialog_update(struct units_entry *units, struct units_entry *total)
Definition repodlgs.c:356
enable_economy_dlg
static void enable_economy_dlg(void)
Definition repodlgs.c:1445
cancel_upgrade_unit_callback
static int cancel_upgrade_unit_callback(struct widget *pwidget)
Definition repodlgs.c:165
economy_sell_dlg
static struct small_dialog * economy_sell_dlg
Definition repodlgs.c:1121
popup_change_research_goal_dialog_callback
static int popup_change_research_goal_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3337
eg_buffer
static char eg_buffer[150 *MAX_NUM_PLAYERS]
Definition repodlgs.c:3509
popup_change_research_dialog
static void popup_change_research_dialog(void)
Definition repodlgs.c:2934
TARGETS_COL
#define TARGETS_COL
Definition repodlgs.c:1817
change_research_goal_dialog_callback
static int change_research_goal_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:2920
exit_change_tech_dlg_callback
static int exit_change_tech_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:2884
exit_units_dlg_callback
static int exit_units_dlg_callback(struct widget *pwidget)
Definition repodlgs.c:333
disable_science_dialog
static void disable_science_dialog(void)
Definition repodlgs.c:2610
enable_science_dialog
static void enable_science_dialog(void)
Definition repodlgs.c:2601
popup_change_research_dialog_callback
static int popup_change_research_dialog_callback(struct widget *pwidget)
Definition repodlgs.c:3320
get_units_report_data
static void get_units_report_data(struct units_entry *entries, struct units_entry *total)
Definition repodlgs.c:74
economy_dlg
static struct advanced_dialog * economy_dlg
Definition repodlgs.c:1120
report_scroll_mouse_button_up
static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event, void *data)
Definition repodlgs.c:1194
upgrade_unit_window_callback
static int upgrade_unit_window_callback(struct widget *pwindow)
Definition repodlgs.c:153
units_dialog_callback
static int units_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:120
popup_upgrade_unit_callback
static int popup_upgrade_unit_callback(struct widget *pwidget)
Definition repodlgs.c:182
popup_sell_impr_callback
static int popup_sell_impr_callback(struct widget *pwidget)
Definition repodlgs.c:1591
report_scroll_mouse_motion_handler
static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event, void *data)
Definition repodlgs.c:1203
science_dialog_callback
static int science_dialog_callback(struct widget *pwindow)
Definition repodlgs.c:3301
change_research_callback
static int change_research_callback(struct widget *pwidget)
Definition repodlgs.c:2905
units_upg_dlg
static struct small_dialog * units_upg_dlg
Definition repodlgs.c:62
disable_economy_dlg
static void disable_economy_dlg(void)
Definition repodlgs.c:1484
tech_info_mode
tech_info_mode
Definition repodlgs.h:29
TIM_SMALL_MODE
@ TIM_SMALL_MODE
Definition repodlgs.h:32
TIM_MED_MODE
@ TIM_MED_MODE
Definition repodlgs.h:31
TIM_FULL_MODE
@ TIM_FULL_MODE
Definition repodlgs.h:30
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_SCIENCEDLG
@ BACKGROUND_SCIENCEDLG
Definition themebackgrounds.h:45
BACKGROUND_CHANGERESEARCHDLG
@ BACKGROUND_CHANGERESEARCHDLG
Definition themebackgrounds.h:28
BACKGROUND_UNITSREP
@ BACKGROUND_UNITSREP
Definition themebackgrounds.h:48
BACKGROUND_ECONOMYDLG
@ BACKGROUND_ECONOMYDLG
Definition themebackgrounds.h:35
COLOR_THEME_BACKGROUND
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
COLOR_THEME_ECONOMYDLG_TEXT
@ COLOR_THEME_ECONOMYDLG_TEXT
Definition themecolors.h:85
COLOR_THEME_SCIENCEDLG_MED_TECHICON_BG
@ COLOR_THEME_SCIENCEDLG_MED_TECHICON_BG
Definition themecolors.h:117
COLOR_THEME_UNITUPGRADE_TEXT
@ COLOR_THEME_UNITUPGRADE_TEXT
Definition themecolors.h:122
COLOR_THEME_UNITSREP_FRAME
@ COLOR_THEME_UNITSREP_FRAME
Definition themecolors.h:120
COLOR_THEME_ECONOMYDLG_FRAME
@ COLOR_THEME_ECONOMYDLG_FRAME
Definition themecolors.h:83
COLOR_THEME_SELLIMPR_TEXT
@ COLOR_THEME_SELLIMPR_TEXT
Definition themecolors.h:119
COLOR_THEME_UNITSREP_TEXT
@ COLOR_THEME_UNITSREP_TEXT
Definition themecolors.h:121
COLOR_THEME_ECONOMYDLG_NEG_TEXT
@ COLOR_THEME_ECONOMYDLG_NEG_TEXT
Definition themecolors.h:84
COLOR_THEME_SCIENCEDLG_FRAME
@ COLOR_THEME_SCIENCEDLG_FRAME
Definition themecolors.h:116
COLOR_THEME_SCIENCEDLG_TEXT
@ COLOR_THEME_SCIENCEDLG_TEXT
Definition themecolors.h:118
active_theme
struct theme * active_theme
Definition themespec.c:154
set_group_state
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:898
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
del_group_of_widgets_from_gui_list
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:863
move_window_group_dialog
bool move_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:1016
refresh_widget_background
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
unselect_widget_action
void unselect_widget_action(void)
Definition widget.c:418
select_window_group_dialog
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
setup_vertical_widgets_position
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
redraw_group
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
popdown_window_group_dialog
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
move_window_group
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
MAX_ID
#define MAX_ID
Definition widget.h:38
FC_WS_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
FC_WS_SELECTED
@ FC_WS_SELECTED
Definition widget.h:97
del_widget_from_vertical_scroll_widget_list
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *pwidget) fc__attribute((nonnull(2)))
Definition widget_scrollbar.c:1344
widget_mark_dirty
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
widget_flush
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
get_wflags
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
set_wstate
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
widget_undraw
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
WF_WIDGET_HAS_INFO_LABEL
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
WF_FREE_DATA
@ WF_FREE_DATA
Definition widget.h:78
WF_ICON_CENTER_RIGHT
@ WF_ICON_CENTER_RIGHT
Definition widget.h:84
WF_SELECT_WITHOUT_BAR
@ WF_SELECT_WITHOUT_BAR
Definition widget.h:89
WF_RESTORE_BACKGROUND
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
WF_HIDDEN
@ WF_HIDDEN
Definition widget.h:68
WF_FREE_THEME
@ WF_FREE_THEME
Definition widget.h:72
widget_redraw
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
set_wflag
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
create_themeicon_button
struct widget * create_themeicon_button(SDL_Surface *icon_theme, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_button.c:343
create_themeicon_button_from_chars_fonto
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
Definition widget_button.h:36
set_new_checkbox_theme
int set_new_checkbox_theme(struct widget *cbox, SDL_Surface *true_surf, SDL_Surface *false_surf)
Definition widget_checkbox.c:195
create_checkbox
struct widget * create_checkbox(struct gui_layer *pdest, bool state, Uint32 flags)
Definition widget_checkbox.c:115
create_themeicon
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:212
create_icon2
struct widget * create_icon2(SDL_Surface *icon, struct gui_layer *pdest, Uint32 flags)
Definition widget_icon.c:337
remake_label_size
void remake_label_size(struct widget *label)
Definition widget_label.c:118
create_iconlabel
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
Definition widget_label.c:215
create_horizontal
struct widget * create_horizontal(SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
Definition widget_scrollbar.c:296
setup_vertical_scrollbar_area
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Definition widget_scrollbar.c:567
create_vertical_scrollbar
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
Definition widget_scrollbar.c:486
resize_window
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
Definition widget_window.c:255
create_window_skeleton
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
Definition widget_window.c:180
create_window
struct widget * create_window(struct gui_layer *pdest, utf8_str *title, Uint16 w, Uint16 h, Uint32 flags)
Definition widget_window.c:231
gui_id.h
sdl3_client_flags
Uint32 sdl3_client_flags
Definition gui_main.c:93
gui_tilespec.h
themespec.h
widget.h
cityrep.h
colors.h
dialogs.h
graphics.h
gui_main.h
helpdlg.h
mapctrl.h
mapview.h
repodlgs.h
sprite.h
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:194
impr_sell_gold
int impr_sell_gold(const struct impr_type *pimprove)
Definition improvement.c:334
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:343
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:205
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:199
B_LAST
#define B_LAST
Definition improvement.h:42
log.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
nation_adjective_for_player
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
dsend_packet_player_rates
int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
Definition packets_gen.c:24791
dsend_packet_player_tech_goal
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
Definition packets_gen.c:27308
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:27133
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:31811
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:741
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:849
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
get_economy_report_data
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
Definition repodlgs_common.c:46
endgame_report_dialog_player
endgame_report_dialog_player
Definition repodlgs_g.h:33
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:92
research_goal_unknown_techs
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
research_invention_reachable
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:128
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
research_invention_gettable
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
research.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
MIN
#define MIN(x, y)
Definition shared.h:55
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
step
int step
Definition specpq.h:92
x
struct sprite int x
Definition sprite_g.h:31
advanced_dialog
Definition widget.h:180
advanced_dialog::begin_active_widget_list
struct widget * begin_active_widget_list
Definition widget.h:184
advanced_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:182
advanced_dialog::end_active_widget_list
struct widget * end_active_widget_list
Definition widget.h:185
advanced_dialog::active_widget_list
struct widget * active_widget_list
Definition widget.h:186
advanced_dialog::scroll
struct scroll_bar * scroll
Definition widget.h:187
advanced_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:181
city_icon::big_shield
SDL_Surface * big_shield
Definition gui_tilespec.h:155
city_icon::big_luxury
SDL_Surface * big_luxury
Definition gui_tilespec.h:157
city_icon::big_colb
SDL_Surface * big_colb
Definition gui_tilespec.h:159
city_icon::big_food
SDL_Surface * big_food
Definition gui_tilespec.h:154
city_icon::big_coin
SDL_Surface * big_coin
Definition gui_tilespec.h:158
civclient::conn
struct connection conn
Definition client_main.h:96
color
Definition colors.h:21
connection::playing
struct player * playing
Definition connection.h:151
container
Definition widget.h:102
container::id1
int id1
Definition widget.h:104
container::id0
int id0
Definition widget.h:103
government
Definition government.h:52
gui_layer::surface
SDL_Surface * surface
Definition graphics.h:229
impr_type
Definition improvement.h:50
improvement_entry
Definition repodlgs_common.h:28
improvement_entry::cost
int cost
Definition repodlgs_common.h:30
improvement_entry::type
struct impr_type * type
Definition repodlgs_common.h:29
improvement_entry::total_cost
int total_cost
Definition repodlgs_common.h:30
improvement_entry::count
int count
Definition repodlgs_common.h:30
packet_endgame_player
Definition packets_gen.h:91
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:93
packet_endgame_player::score
int score
Definition packets_gen.h:94
packet_endgame_report
Definition packets_gen.h:85
packet_endgame_report::player_num
int player_num
Definition packets_gen.h:88
player_economic::luxury
int luxury
Definition player.h:64
player_economic::science
int science
Definition player.h:63
player_economic::tax
int tax
Definition player.h:62
player_economic::gold
int gold
Definition player.h:61
player
Definition player.h:247
player::cities
struct city_list * cities
Definition player.h:279
player::units
struct unit_list * units
Definition player.h:280
player::economic
struct player_economic economic
Definition player.h:282
rates_move
Definition repodlgs.c:1123
rates_move::dst_rate
int * dst_rate
Definition repodlgs.c:1125
rates_move::max
int max
Definition repodlgs.c:1124
rates_move::label_dst
struct widget * label_dst
Definition repodlgs.c:1127
rates_move::label_src
struct widget * label_src
Definition repodlgs.c:1127
rates_move::horiz_src
struct widget * horiz_src
Definition repodlgs.c:1126
rates_move::min
int min
Definition repodlgs.c:1124
rates_move::gov_max
int gov_max
Definition repodlgs.c:1124
rates_move::tax
int tax
Definition repodlgs.c:1124
rates_move::x
int x
Definition repodlgs.c:1124
rates_move::horiz_dst
struct widget * horiz_dst
Definition repodlgs.c:1126
rates_move::src_rate
int * src_rate
Definition repodlgs.c:1125
research
Definition research.h:39
scroll_bar::up_left_button
struct widget * up_left_button
Definition widget_scrollbar.h:21
scroll_bar::down_right_button
struct widget * down_right_button
Definition widget_scrollbar.h:23
scroll_bar::count
Uint16 count
Definition widget_scrollbar.h:27
scroll_bar::pscroll_bar
struct widget * pscroll_bar
Definition widget_scrollbar.h:22
sdl2_data::event
SDL_Event event
Definition graphics.h:217
small_dialog
Definition widget.h:174
small_dialog::begin_widget_list
struct widget * begin_widget_list
Definition widget.h:175
small_dialog::end_widget_list
struct widget * end_widget_list
Definition widget.h:176
tileset
Definition tilespec.c:481
unit_type
Definition unittype.h:500
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:148
unit::client
struct unit::@81::@83 client
unit::homecity
int homecity
Definition unit.h:146
units_entry
Definition repodlgs.c:64
units_entry::soonest_completions
int soonest_completions
Definition repodlgs.c:68
units_entry::upkeep
int upkeep[O_LAST]
Definition repodlgs.c:66
units_entry::building_count
int building_count
Definition repodlgs.c:67
units_entry::active_count
int active_count
Definition repodlgs.c:65
utf8_str
Definition gui_string.h:52
utf8_str::fgcol
SDL_Color fgcol
Definition gui_string.h:57
widget
Definition widget.h:112
widget::ptr
void * ptr
Definition widget.h:133
widget::theme
SDL_Surface * theme
Definition widget.h:118
widget::data
union widget::@192 data
widget::prev
struct widget * prev
Definition widget.h:114
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::cont
struct container * cont
Definition widget.h:127
widget::mod
Uint16 mod
Definition widget.h:154
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::action
int(* action)(struct widget *)
Definition widget.h:157
widget::area
SDL_Rect area
Definition widget.h:149
widget::next
struct widget * next
Definition widget.h:113
widget::id
Uint16 id
Definition widget.h:155
widget::size
SDL_Rect size
Definition widget.h:145
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
cat_snprintf
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
fc__fallthrough
#define fc__fallthrough
Definition support.h:119
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
is_future_tech
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
advance_index_iterate_max
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
advance_index_iterate_end
#define advance_index_iterate_end
Definition tech.h:248
advance_index_iterate_max_end
#define advance_index_iterate_max_end
Definition tech.h:258
advance_count
static Tech_type_id advance_count(void)
Definition tech.h:170
A_FIRST
#define A_FIRST
Definition tech.h:44
A_UNSET
#define A_UNSET
Definition tech.h:48
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:244
get_science_target_text
const char * get_science_target_text(double *percent)
Definition text.c:820
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
text.h
tileset_full_tile_width
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:776
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
is_tech_req_for_utype
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
Definition unittype.c:2710
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
unit_upgrade_price
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:852
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:859