Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl2/wldlg.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
wldlg.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 wldlg.c - description
15 -------------------
16 begin : Wed Sep 18 2002
17 copyright : (C) 2002 by Rafał Bursig
18 email : Rafał Bursig <bursig@poczta.fm>
19***********************************************************************/
20
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24
25#include <stdlib.h>
26
27/* SDL2 */
28#ifdef SDL2_PLAIN_INCLUDE
29#include <SDL.h>
30#else /* SDL2_PLAIN_INCLUDE */
31#include <SDL2/SDL.h>
32#endif /* SDL2_PLAIN_INCLUDE */
33
34/* utility */
35#include "fcintl.h"
36#include "log.h"
37
38/* common */
39#include "game.h"
40#include "movement.h"
41#include "unit.h"
42
43/* client */
44#include "client_main.h"
45#include "climisc.h"
46#include "global_worklist.h"
47
48/* gui-sdl2 */
49#include "citydlg.h"
50#include "colors.h"
51#include "graphics.h"
52#include "gui_id.h"
53#include "gui_main.h"
54#include "gui_tilespec.h"
55#include "helpdlg.h"
56#include "mapview.h"
57#include "sprite.h"
58#include "themespec.h"
59#include "widget.h"
60
61#include "wldlg.h"
62
63#define TARGETS_COL 4
64#define TARGETS_ROW 4
65
66 struct wl_editor {
67 struct widget *begin_widget_list;
68 struct widget *end_widget_list; /* window */
69
70 struct advanced_dialog *targets;
71 struct advanced_dialog *work;
72 struct advanced_dialog *global;
73
74 struct city *pcity;
75 int global_worklist_id;
76 struct worklist worklist_copy;
77 char worklist_name[MAX_LEN_NAME];
78
79 /* shortcuts */
80 struct widget *dock;
81 struct widget *worklist_counter;
82
83 struct widget *production_name;
84 struct widget *production_progress;
85
86 int stock;
87 struct universal currently_building;
88} *editor = NULL;
89
90
91static int worklist_editor_item_callback(struct widget *pwidget);
92static SDL_Surface *get_progress_icon(int stock, int cost, int *progress);
93static const char *get_production_name(struct city *pcity,
94 struct universal prod, int *cost);
95static void refresh_worklist_count_label(void);
96static void refresh_production_label(int stock);
97
98/* =========================================================== */
99
100/**********************************************************************/
103 static int window_worklist_editor_callback(struct widget *pwidget)
104{
105 return -1;
106}
107
108/**********************************************************************/
111 static int popdown_worklist_editor_callback(struct widget *pwidget)
112{
113 if (PRESSED_EVENT(main_data.event)) {
114 popdown_worklist_editor();
115 }
116
117 return -1;
118}
119
120/**********************************************************************/
124 static int ok_worklist_editor_callback(struct widget *pwidget)
125{
126 if (PRESSED_EVENT(main_data.event)) {
127 int i, j;
128 struct city *pcity = editor->pcity;
129
130 /* remove duplicate entry of impv./wonder target from worklist */
131 for (i = 0; i < worklist_length(&editor->worklist_copy); i++) {
132 if (VUT_IMPROVEMENT == editor->worklist_copy.entries[i].kind) {
133 for (j = i + 1; j < worklist_length(&editor->worklist_copy); j++) {
134 if (VUT_IMPROVEMENT == editor->worklist_copy.entries[j].kind
135 && editor->worklist_copy.entries[i].value.building ==
136 editor->worklist_copy.entries[j].value.building) {
137 worklist_remove(&editor->worklist_copy, j);
138 }
139 }
140 }
141 }
142
143 if (pcity) {
144 /* remove duplicate entry of currently building impv./wonder from worklist */
145 if (VUT_IMPROVEMENT == editor->currently_building.kind) {
146 for (i = 0; i < worklist_length(&editor->worklist_copy); i++) {
147 if (VUT_IMPROVEMENT == editor->worklist_copy.entries[i].kind
148 && editor->worklist_copy.entries[i].value.building ==
149 editor->currently_building.value.building) {
150 worklist_remove(&editor->worklist_copy, i);
151 }
152 }
153 }
154
155 /* change production */
156 if (!are_universals_equal(&pcity->production, &editor->currently_building)) {
157 city_change_production(pcity, &editor->currently_building);
158 }
159
160 /* commit new city worklist */
161 city_set_worklist(pcity, &editor->worklist_copy);
162 } else {
163 /* commit global worklist */
164 struct global_worklist *gwl = global_worklist_by_id(editor->global_worklist_id);
165
166 if (gwl) {
167 global_worklist_set(gwl, &editor->worklist_copy);
168 global_worklist_set_name(gwl, editor->worklist_name);
169 update_worklist_report_dialog();
170 }
171 }
172
173 /* popdown dialog */
174 popdown_worklist_editor();
175 }
176
177 return -1;
178}
179
180/**********************************************************************/
183 static int rename_worklist_editor_callback(struct widget *pwidget)
184{
185 if (PRESSED_EVENT(main_data.event)) {
186 if (pwidget->string_utf8->text != NULL) {
187 fc_snprintf(editor->worklist_name, MAX_LEN_NAME, "%s",
188 pwidget->string_utf8->text);
189 } else {
190 /* empty input -> restore previous content */
191 copy_chars_to_utf8_str(pwidget->string_utf8, editor->worklist_name);
192 widget_redraw(pwidget);
193 widget_mark_dirty(pwidget);
194 flush_dirty();
195 }
196 }
197
198 return -1;
199}
200
201/* ====================================================================== */
202
203/**********************************************************************/
206 static void add_target_to_worklist(struct widget *target)
207{
208 struct widget *buf = NULL, *dock = NULL;
209 utf8_str *pstr = NULL;
210 int i;
211 struct universal prod = cid_decode(MAX_ID - target->id);
212
213 set_wstate(target, FC_WS_SELECTED);
214 widget_redraw(target);
215 widget_flush(target);
216
217 /* Deny adding currently building Impr/Wonder Target */
218 if (editor->pcity
219 && VUT_IMPROVEMENT == prod.kind
220 && are_universals_equal(&prod, &editor->currently_building)) {
221 return;
222 }
223
224 if (worklist_length(&editor->worklist_copy) >= MAX_LEN_WORKLIST - 1) {
225 return;
226 }
227
228 for (i = 0; i < worklist_length(&editor->worklist_copy); i++) {
229 if (VUT_IMPROVEMENT == prod.kind
230 && are_universals_equal(&prod, &editor->worklist_copy.entries[i])) {
231 return;
232 }
233 }
234
235 worklist_append(&editor->worklist_copy, &prod);
236
237 /* Create widget entry */
238 if (VUT_UTYPE == prod.kind) {
239 pstr = create_utf8_from_char_fonto(utype_name_translation(prod.value.utype),
240 FONTO_DEFAULT);
241 } else {
242 pstr = create_utf8_from_char_fonto(city_improvement_name_translation(editor->pcity,
243 prod.value.building),
244 FONTO_DEFAULT);
245 }
246
247 pstr->style |= SF_CENTER;
248 buf = create_iconlabel(NULL, target->dst, pstr,
249 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
250
251 set_wstate(buf, FC_WS_NORMAL);
252 buf->action = worklist_editor_item_callback;
253
254 buf->data.ptr = fc_calloc(1, sizeof(int));
255 *((int *)buf->data.ptr) = worklist_length(&editor->worklist_copy) - 1;
256
257 buf->id = MAX_ID - cid_encode(prod);
258
259 if (editor->work->begin_active_widget_list) {
260 dock = editor->work->begin_active_widget_list;
261 } else {
262 dock = editor->dock;
263 }
264
265/* FIXME */
266#if 0
267 if (worklist_length(&editor->worklist_copy) > editor->work->scroll->active + 1) {
268
269 setup_vertical_widgets_position(1,
270 editor->end_widget_list->area.x + adj_size(2),
271 get_widget_pointer_from_main_list(ID_WINDOW)->area.y + adj_size(152) +
272 editor->work->scroll->up_left_button->size.h + 1,
273 adj_size(126), 0, editor->work->begin_widget_list,
274 editor->work->end_widget_list);
275
276 setup_vertical_scrollbar_area(editor->work->scroll,
277 editor->end_widget_list->area.x + adj_size(2),
278 get_widget_pointer_from_main_list(ID_WINDOW)->area.y + adj_size(152),
279 adj_size(225), FALSE);
280
281 show_scrollbar(editor->work->scroll);
282 }
283#endif /* 0 */
284
285 add_widget_to_vertical_scroll_widget_list(editor->work, buf,
286 dock, FALSE,
287 editor->end_widget_list->area.x + adj_size(2),
288 editor->end_widget_list->area.y + adj_size(152));
289
290 buf->size.w = adj_size(126);
291
292 refresh_worklist_count_label();
293 redraw_group(editor->work->begin_widget_list,
294 editor->work->end_widget_list, TRUE);
295 flush_dirty();
296}
297
298/**********************************************************************/
303 static bool are_prods_same_class(const struct universal *one,
304 const struct universal *two)
305{
306 if (one->kind != two->kind) {
307 return FALSE;
308 }
309
310 if (VUT_IMPROVEMENT == one->kind) {
311 if (is_wonder(one->value.building)) {
312 return is_wonder(two->value.building);
313 } else {
314 return !is_wonder(two->value.building);
315 }
316 }
317
318 return FALSE;
319}
320
321/**********************************************************************/
325 static void change_production(struct universal *prod)
326{
327 if (!are_prods_same_class(&editor->currently_building, prod)) {
328 if (editor->stock != editor->pcity->shield_stock) {
329 if (are_prods_same_class(&editor->pcity->production, prod)) {
330 editor->stock = editor->pcity->shield_stock;
331 }
332 } else {
333 editor->stock =
334 city_change_production_penalty(editor->pcity, prod);
335 }
336 }
337
338 editor->currently_building = *prod;
339 refresh_production_label(editor->stock);
340}
341
342/**********************************************************************/
350 static void add_target_to_production(struct widget *target)
351{
352 int dummy;
353 struct universal prod;
354
355 fc_assert_ret(target != NULL);
356
357 /* redraw Target Icon */
358 set_wstate(target, FC_WS_SELECTED);
359 widget_redraw(target);
360 widget_flush(target);
361
362 prod = cid_decode(MAX_ID - target->id);
363
364 /* check if we change to the same target */
365 if (are_universals_equal(&prod, &editor->currently_building)) {
366 /* comit changes and exit - double click detection */
367 ok_worklist_editor_callback(NULL);
368 return;
369 }
370
371 change_production(&prod);
372
373 /* change Production Text Label in Worklist Widget list */
374 copy_chars_to_utf8_str(editor->work->end_active_widget_list->string_utf8,
375 get_production_name(editor->pcity, prod, &dummy));
376
377 editor->work->end_active_widget_list->id = MAX_ID - cid_encode(prod);
378
379 widget_redraw(editor->work->end_active_widget_list);
380 widget_mark_dirty(editor->work->end_active_widget_list);
381
382 flush_dirty();
383}
384
385/**********************************************************************/
388 static void get_target_help_data(struct widget *target)
389{
390 struct universal prod;
391
392 fc_assert_ret(target != NULL);
393
394 /* redraw Target Icon */
395 set_wstate(target, FC_WS_SELECTED);
396 widget_redraw(target);
397 /*widget_flush(target);*/
398
399 prod = cid_decode(MAX_ID - target->id);
400
401 if (VUT_UTYPE == prod.kind) {
402 popup_unit_info(utype_number(prod.value.utype));
403 } else {
404 popup_impr_info(improvement_number(prod.value.building));
405 }
406}
407
408/**********************************************************************/
415 static int worklist_editor_targets_callback(struct widget *pwidget)
416{
417 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
418 switch (main_data.event.button.button) {
419 case SDL_BUTTON_LEFT:
420 if (editor->pcity) {
421 add_target_to_production(pwidget);
422 } else {
423 add_target_to_worklist(pwidget);
424 }
425 break;
426 case SDL_BUTTON_MIDDLE:
427 get_target_help_data(pwidget);
428 break;
429 case SDL_BUTTON_RIGHT:
430 add_target_to_worklist(pwidget);
431 break;
432 default:
433 /* do nothing */
434 break;
435 }
436 } else if (PRESSED_EVENT(main_data.event)) {
437 if (editor->pcity) {
438 add_target_to_production(pwidget);
439 } else {
440 add_target_to_worklist(pwidget);
441 }
442 }
443
444 return -1;
445}
446
447/* ====================================================================== */
448
449/**********************************************************************/
454 static void remove_item_from_worklist(struct widget *item)
455{
456 /* only one item (production) is left */
457 if (worklist_is_empty(&editor->worklist_copy)) {
458 return;
459 }
460
461 if (item->data.ptr) {
462 /* correct "data" widget fields */
463 struct widget *buf = item;
464
465 if (buf != editor->work->begin_active_widget_list) {
466 do {
467 buf = buf->prev;
468 *((int *)buf->data.ptr) = *((int *)buf->data.ptr) - 1;
469 } while (buf != editor->work->begin_active_widget_list);
470 }
471
472 /* remove element from worklist */
473 worklist_remove(&editor->worklist_copy, *((int *)item->data.ptr));
474
475 /* remove widget from widget list */
476 del_widget_from_vertical_scroll_widget_list(editor->work, item);
477 } else {
478 /* change productions to first worklist element */
479 struct widget *buf = item->prev;
480
481 change_production(&editor->worklist_copy.entries[0]);
482 worklist_advance(&editor->worklist_copy);
483 del_widget_from_vertical_scroll_widget_list(editor->work, item);
484 FC_FREE(buf->data.ptr);
485 if (buf != editor->work->begin_active_widget_list) {
486 do {
487 buf = buf->prev;
488 *((int *)buf->data.ptr) = *((int *)buf->data.ptr) - 1;
489 } while (buf != editor->work->begin_active_widget_list);
490 }
491 }
492
493/* FIXME: fix scrollbar code */
494#if 0
495 /* worklist_length(&editor->worklist_copy): without production */
496 if (worklist_length(&editor->worklist_copy) <= editor->work->scroll->active + 1) {
497
498 setup_vertical_widgets_position(1,
499 editor->end_widget_list->area.x + adj_size(2),
500 get_widget_pointer_from_main_list(ID_WINDOW)->area.y + adj_size(152),
501 adj_size(126), 0, editor->work->begin_widget_list,
502 editor->work->end_widget_list);
503#if 0
504 setup_vertical_scrollbar_area(editor->work->scroll,
505 editor->end_widget_list->area.x + adj_size(2),
506 get_widget_pointer_from_main_list(ID_WINDOW)->area.y + adj_size(152),
507 adj_size(225), FALSE);*/
508#endif /* 0 */
509 hide_scrollbar(editor->work->scroll);
510 }
511#endif /* 0 */
512
513 refresh_worklist_count_label();
514 redraw_group(editor->work->begin_widget_list,
515 editor->work->end_widget_list, TRUE);
516 flush_dirty();
517}
518
519/**********************************************************************/
530 static void swap_item_down_from_worklist(struct widget *item)
531{
532 char *text;
533 Uint16 id;
534 bool changed = FALSE;
535 struct universal tmp;
536
537 if (item == editor->work->begin_active_widget_list) {
538 remove_item_from_worklist(item);
539 return;
540 }
541
542 text = item->string_utf8->text;
543 id = item->id;
544
545 /* second item or higher was clicked */
546 if (item->data.ptr) {
547 /* worklist operations -> swap down */
548 int row = *((int *)item->data.ptr);
549
550 tmp = editor->worklist_copy.entries[row];
551 editor->worklist_copy.entries[row] = editor->worklist_copy.entries[row + 1];
552 editor->worklist_copy.entries[row + 1] = tmp;
553
554 changed = TRUE;
555 } else {
556 /* first item was clicked -> change production */
557 change_production(&editor->worklist_copy.entries[0]);
558 editor->worklist_copy.entries[0] = cid_decode(MAX_ID - id);
559 changed = TRUE;
560 }
561
562 if (changed) {
563 item->string_utf8->text = item->prev->string_utf8->text;
564 item->id = item->prev->id;
565
566 item->prev->string_utf8->text = text;
567 item->prev->id = id;
568
569 redraw_group(editor->work->begin_widget_list,
570 editor->work->end_widget_list, TRUE);
571 flush_dirty();
572 }
573}
574
575/**********************************************************************/
587 static void swap_item_up_from_worklist(struct widget *item)
588{
589 char *text = item->string_utf8->text;
590 Uint16 id = item->id;
591 bool changed = FALSE;
592 struct universal tmp;
593
594 /* first item was clicked -> remove */
595 if (item == editor->work->end_active_widget_list) {
596 remove_item_from_worklist(item);
597
598 return;
599 }
600
601 /* third item or higher was clicked */
602 if (item->data.ptr && *((int *)item->data.ptr) > 0) {
603 /* worklist operations -> swap up */
604 int row = *((int *)item->data.ptr);
605
606 tmp = editor->worklist_copy.entries[row];
607 editor->worklist_copy.entries[row] = editor->worklist_copy.entries[row - 1];
608 editor->worklist_copy.entries[row - 1] = tmp;
609
610 changed = TRUE;
611 } else {
612 /* second item was clicked -> change production ... */
613 tmp = editor->currently_building;
614 change_production(&editor->worklist_copy.entries[0]);
615 editor->worklist_copy.entries[0] = tmp;
616
617 changed = TRUE;
618 }
619
620 if (changed) {
621 item->string_utf8->text = item->next->string_utf8->text;
622 item->id = item->next->id;
623
624 item->next->string_utf8->text = text;
625 item->next->id = id;
626
627 redraw_group(editor->work->begin_widget_list,
628 editor->work->end_widget_list, TRUE);
629 flush_dirty();
630 }
631}
632
633/**********************************************************************/
639 static int worklist_editor_item_callback(struct widget *pwidget)
640{
641 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
642 switch (main_data.event.button.button) {
643 case SDL_BUTTON_LEFT:
644 swap_item_up_from_worklist(pwidget);
645 break;
646 case SDL_BUTTON_MIDDLE:
647 remove_item_from_worklist(pwidget);
648 break;
649 case SDL_BUTTON_RIGHT:
650 swap_item_down_from_worklist(pwidget);
651 break;
652 default:
653 ;/* do nothing */
654 break;
655 }
656 } else if (PRESSED_EVENT(main_data.event)) {
657 swap_item_up_from_worklist(pwidget);
658 }
659
660 return -1;
661}
662/* ======================================================= */
663
664/**********************************************************************/
670 static void add_global_worklist(struct widget *pwidget)
671{
672 struct global_worklist *gwl = global_worklist_by_id(MAX_ID - pwidget->id);
673 const struct worklist *pworklist;
674 int count, firstfree;
675
676 if (!gwl
677 || !(pworklist = global_worklist_get(gwl))
678 || worklist_is_empty(pworklist)) {
679 return;
680 }
681
682 if (worklist_length(&editor->worklist_copy) >= MAX_LEN_WORKLIST - 1) {
683 /* Worklist is full */
684 return;
685 }
686
687 firstfree = worklist_length(&editor->worklist_copy);
688 /* Copy global worklist to city worklist */
689 for (count = 0 ; count < worklist_length(pworklist); count++) {
690 struct widget *buf;
691
692 /* Global worklist can have targets unavilable in current state of game
693 then we must remove those targets from new city worklist */
694 if (!can_city_build_later(editor->pcity, &pworklist->entries[count])) {
695 continue;
696 }
697
698 worklist_append(&editor->worklist_copy, &pworklist->entries[count]);
699
700 /* Create widget */
701 if (VUT_UTYPE == pworklist->entries[count].kind) {
702 buf = create_iconlabel(NULL, pwidget->dst,
703 create_utf8_from_char_fonto(
704 utype_name_translation(pworklist->entries[count].value.utype),
705 FONTO_DEFAULT),
706 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
707 buf->id = MAX_ID - cid_encode_unit(pworklist->entries[count].value.utype);
708 } else {
709 buf = create_iconlabel(NULL, pwidget->dst,
710 create_utf8_from_char_fonto(
711 city_improvement_name_translation(editor->pcity,
712 pworklist->entries[count].value.building),
713 FONTO_DEFAULT),
714 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
715 buf->id = MAX_ID - cid_encode_building(pworklist->entries[count].value.building);
716 }
717
718 buf->string_utf8->style |= SF_CENTER;
719 set_wstate(buf, FC_WS_NORMAL);
720 buf->action = worklist_editor_item_callback;
721 buf->size.w = adj_size(126);
722 buf->data.ptr = fc_calloc(1, sizeof(int));
723 *((int *)buf->data.ptr) = firstfree;
724
725 add_widget_to_vertical_scroll_widget_list(editor->work,
726 buf, editor->work->begin_active_widget_list,
727 FALSE,
728 editor->end_widget_list->area.x + adj_size(2),
729 editor->end_widget_list->area.y + adj_size(152));
730
731 firstfree++;
732 if (firstfree == MAX_LEN_WORKLIST - 1) {
733 break;
734 }
735 }
736
737 refresh_worklist_count_label();
738 redraw_group(editor->work->begin_widget_list,
739 editor->work->end_widget_list, TRUE);
740
741 flush_dirty();
742}
743
744/**********************************************************************/
749 static void set_global_worklist(struct widget *pwidget)
750{
751 struct global_worklist *gwl = global_worklist_by_id(MAX_ID - pwidget->id);
752 struct widget *buf = editor->work->end_active_widget_list;
753 const struct worklist *pworklist;
754 struct worklist wl;
755 int count, wl_count;
756 struct universal target;
757
758 if (!gwl
759 || !(pworklist = global_worklist_get(gwl))
760 || worklist_is_empty(pworklist)) {
761 return;
762 }
763
764 /* clear tmp worklist */
765 worklist_init(&wl);
766
767 wl_count = 0;
768 /* copy global worklist to city worklist */
769 for (count = 0; count < worklist_length(pworklist); count++) {
770 /* global worklist can have targets unavilable in current state of game
771 then we must remove those targets from new city worklist */
772 if (!can_city_build_later(editor->pcity, &pworklist->entries[count])) {
773 continue;
774 }
775
776 wl.entries[wl_count] = pworklist->entries[count];
777 wl_count++;
778 }
779 /* --------------------------------- */
780
781 if (!worklist_is_empty(&wl)) {
782 /* free old widget list */
783 if (buf != editor->work->begin_active_widget_list) {
784 buf = buf->prev;
785 if (buf != editor->work->begin_active_widget_list) {
786 do {
787 buf = buf->prev;
788 del_widget_from_vertical_scroll_widget_list(editor->work, buf->next);
789 } while (buf != editor->work->begin_active_widget_list);
790 }
791 del_widget_from_vertical_scroll_widget_list(editor->work, buf);
792 }
793 /* --------------------------------- */
794
795 worklist_copy(&editor->worklist_copy, &wl);
796
797 /* --------------------------------- */
798 /* Create new widget list */
799 for (count = 0; count < MAX_LEN_WORKLIST; count++) {
800 /* End of list */
801 if (!worklist_peek_ith(&editor->worklist_copy, &target, count)) {
802 break;
803 }
804
805 if (VUT_UTYPE == target.kind) {
806 buf = create_iconlabel(NULL, pwidget->dst,
807 create_utf8_from_char_fonto(utype_name_translation(target.value.utype),
808 FONTO_DEFAULT),
809 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
810 buf->id = MAX_ID - B_LAST - utype_number(target.value.utype);
811 } else {
812 buf = create_iconlabel(NULL, pwidget->dst,
813 create_utf8_from_char_fonto(city_improvement_name_translation(editor->pcity,
814 target.value.building),
815 FONTO_DEFAULT),
816 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
817 buf->id = MAX_ID - improvement_number(target.value.building);
818 }
819 buf->string_utf8->style |= SF_CENTER;
820 set_wstate(buf, FC_WS_NORMAL);
821 buf->action = worklist_editor_item_callback;
822 buf->size.w = adj_size(126);
823 buf->data.ptr = fc_calloc(1, sizeof(int));
824 *((int *)buf->data.ptr) = count;
825
826 add_widget_to_vertical_scroll_widget_list(editor->work,
827 buf, editor->work->begin_active_widget_list, FALSE,
828 editor->end_widget_list->area.x + adj_size(2),
829 editor->end_widget_list->area.y + adj_size(152));
830 }
831
832 refresh_worklist_count_label();
833 redraw_group(editor->work->begin_widget_list,
834 editor->work->end_widget_list, TRUE);
835
836 flush_dirty();
837 }
838}
839
840/**********************************************************************/
851 static int global_worklist_callback(struct widget *pwidget)
852{
853 if (main_data.event.type == SDL_MOUSEBUTTONDOWN) {
854 switch (main_data.event.button.button) {
855 case SDL_BUTTON_LEFT:
856 add_global_worklist(pwidget);
857 break;
858 case SDL_BUTTON_MIDDLE:
859 /* nothing */
860 break;
861 case SDL_BUTTON_RIGHT:
862 set_global_worklist(pwidget);
863 break;
864 default:
865 /* do nothing */
866 break;
867 }
868 } else if (PRESSED_EVENT(main_data.event)) {
869 add_global_worklist(pwidget);
870 }
871
872 return -1;
873}
874
875/* ======================================================= */
876
877/**********************************************************************/
880 static const char *get_production_name(struct city *pcity,
881 struct universal prod, int *cost)
882{
883 fc_assert_ret_val(cost != NULL, NULL);
884
885 *cost = universal_build_shield_cost(pcity, &prod);
886
887 if (VUT_UTYPE == prod.kind) {
888 return utype_name_translation(prod.value.utype);
889 } else {
890 return city_improvement_name_translation(pcity, prod.value.building);
891 }
892}
893
894/**********************************************************************/
900 static SDL_Surface *get_progress_icon(int stock, int cost, int *progress)
901{
902 SDL_Surface *icon = NULL;
903 int width;
904
905 fc_assert_ret_val(progress != NULL, NULL);
906
907 if (stock < cost) {
908 width = ((float)stock / cost) * adj_size(116.0);
909 *progress = ((float)stock / cost) * 100.0;
910 if (!width && stock) {
911 *progress = 1;
912 width = 1;
913 }
914 } else {
915 width = adj_size(116);
916 *progress = 100;
917 }
918
919 icon = create_bcgnd_surf(current_theme->edit, FC_WS_NORMAL, adj_size(120), adj_size(30));
920
921 if (width) {
922 SDL_Rect dst = {2,1,0,0};
923 SDL_Surface *buf = create_bcgnd_surf(current_theme->button, FC_WS_DISABLED, width,
924 adj_size(28));
925
926 alphablit(buf, NULL, icon, &dst, 255);
927 FREESURFACE(buf);
928 }
929
930 return icon;
931}
932
933/**********************************************************************/
937 static void refresh_production_label(int stock)
938{
939 int cost, turns;
940 char cbuf[64];
941 SDL_Rect area;
942 bool convert_prod = (VUT_IMPROVEMENT == editor->currently_building.kind)
943 && is_convert_improvement(editor->currently_building.value.building);
944 const char *name = get_production_name(editor->pcity,
945 editor->currently_building, &cost);
946
947 if (convert_prod) {
948 if (improvement_has_flag(editor->currently_building.value.building,
949 IF_GOLD)) {
950 int gold = MAX(0, editor->pcity->surplus[O_SHIELD]);
951
952 fc_snprintf(cbuf, sizeof(cbuf),
953 PL_("%s\n%d gold per turn",
954 "%s\n%d gold per turn", gold),
955 name, gold);
956 } else {
957 fc_snprintf(cbuf, sizeof(cbuf), "%s\n-", name);
958 }
959 } else {
960 if (stock < cost) {
961 turns = city_turns_to_build(editor->pcity,
962 &editor->currently_building, TRUE);
963 if (turns == 999) {
964 fc_snprintf(cbuf, sizeof(cbuf), _("%s\nblocked!"), name);
965 } else {
966 fc_snprintf(cbuf, sizeof(cbuf), _("%s\n%d %s"),
967 name, turns, PL_("turn", "turns", turns));
968 }
969 } else {
970 fc_snprintf(cbuf, sizeof(cbuf), _("%s\nfinished!"), name);
971 }
972 }
973 copy_chars_to_utf8_str(editor->production_name->string_utf8, cbuf);
974
975 widget_undraw(editor->production_name);
976 remake_label_size(editor->production_name);
977
978 editor->production_name->size.x = editor->end_widget_list->area.x +
979 (adj_size(130) - editor->production_name->size.w)/2;
980
981 /* Can't just widget_mark_dirty(), as it may have reduced in size */
982 area.x = editor->end_widget_list->area.x; /* left edge of client area */
983 area.y = editor->production_name->size.y;
984 area.w = adj_size(130);
985 area.h = editor->production_name->size.h;
986 layer_rect_to_screen_rect(editor->end_widget_list->dst, &area);
987
988 if (get_wflags(editor->production_name) & WF_RESTORE_BACKGROUND) {
989 refresh_widget_background(editor->production_name);
990 }
991
992 widget_redraw(editor->production_name);
993 dirty_sdl_rect(&area);
994
995 FREESURFACE(editor->production_progress->theme);
996 editor->production_progress->theme =
997 get_progress_icon(stock, cost, &cost);
998
999 if (!convert_prod) {
1000 fc_snprintf(cbuf, sizeof(cbuf), "%d%%" , cost);
1001 } else {
1002 fc_snprintf(cbuf, sizeof(cbuf), "-");
1003 }
1004 copy_chars_to_utf8_str(editor->production_progress->string_utf8, cbuf);
1005 widget_redraw(editor->production_progress);
1006 widget_mark_dirty(editor->production_progress);
1007}
1008
1009/**********************************************************************/
1012 static void refresh_worklist_count_label(void)
1013{
1014 char cbuf[64];
1015 SDL_Rect area;
1016 int len = worklist_length(&editor->worklist_copy);
1017
1018 if (editor->pcity != NULL) {
1019 len += 1; /* External entry from current production */
1020 }
1021
1022 fc_snprintf(cbuf, sizeof(cbuf),
1023 /* TRANS: length of worklist */
1024 PL_("( %d entry )", "( %d entries )", len), len);
1025 copy_chars_to_utf8_str(editor->worklist_counter->string_utf8, cbuf);
1026
1027 widget_undraw(editor->worklist_counter);
1028 remake_label_size(editor->worklist_counter);
1029
1030 editor->worklist_counter->size.x = editor->end_widget_list->area.x +
1031 (adj_size(130) - editor->worklist_counter->size.w)/2;
1032
1033 if (get_wflags(editor->worklist_counter) & WF_RESTORE_BACKGROUND) {
1034 refresh_widget_background(editor->worklist_counter);
1035 }
1036
1037 widget_redraw(editor->worklist_counter);
1038
1039 /* Can't just widget_mark_dirty(), as it may have reduced in size */
1040 area.x = editor->end_widget_list->area.x; /* left edge of client area */
1041 area.y = editor->worklist_counter->size.y;
1042 area.w = adj_size(130);
1043 area.h = editor->worklist_counter->size.h;
1044 layer_rect_to_screen_rect(editor->end_widget_list->dst, &area);
1045 dirty_sdl_rect(&area);
1046}
1047
1048/* ====================================================================== */
1049
1050/**********************************************************************/
1055 void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
1056{
1057 SDL_Color bg_color = {255,255,255,128};
1058 SDL_Color bg_color2 = {255,255,255,136};
1059 int count = 0, turns;
1060 int widget_w = 0, widget_h = 0;
1061 utf8_str *pstr = NULL;
1062 struct widget *buf = NULL, *pwindow, *last;
1063 SDL_Surface *text = NULL, *text_name = NULL, *zoomed = NULL;
1064 SDL_Surface *main_surf;
1065 SDL_Surface *icon;
1066 SDL_Rect dst;
1067 char cbuf[128];
1068 struct unit_type *punittype = NULL;
1069 char *state = NULL;
1070 bool advanced_tech;
1071 bool can_build, can_eventually_build;
1072 SDL_Rect area;
1073 int len;
1074
1075 if (editor) {
1076 return;
1077 }
1078
1079 editor = fc_calloc(1, sizeof(struct wl_editor));
1080
1081 if (pcity) {
1082 editor->pcity = pcity;
1083 editor->global_worklist_id = -1;
1084 editor->currently_building = pcity->production;
1085 editor->stock = pcity->shield_stock;
1086 worklist_copy(&editor->worklist_copy, &pcity->worklist);
1087 fc_snprintf(editor->worklist_name, sizeof(editor->worklist_name),
1088 "%s worklist", city_name_get(pcity));
1089 } else if (gwl != NULL) {
1090 editor->pcity = NULL;
1091 editor->global_worklist_id = global_worklist_id(gwl);
1092 worklist_copy(&editor->worklist_copy, global_worklist_get(gwl));
1093 sz_strlcpy(editor->worklist_name, global_worklist_name(gwl));
1094 } else {
1095 /* Not valid variant! */
1096 return;
1097 }
1098
1099 len = worklist_length(&editor->worklist_copy);
1100 advanced_tech = (pcity == NULL);
1101
1102 /* --------------- */
1103 /* create Target Background Icon */
1104 main_surf = create_surf(adj_size(116), adj_size(116), SDL_SWSURFACE);
1105 SDL_FillRect(main_surf, NULL, map_rgba(main_surf->format, bg_color));
1106
1107 create_frame(main_surf,
1108 0, 0, main_surf->w - 1, main_surf->h - 1,
1109 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1110
1111 /* ---------------- */
1112 /* Create Main Window */
1113 pwindow = create_window_skeleton(NULL, NULL, 0);
1114 pwindow->action = window_worklist_editor_callback;
1115 set_wstate(pwindow, FC_WS_NORMAL);
1116
1117 add_to_gui_list(ID_WINDOW, pwindow);
1118 editor->end_widget_list = pwindow;
1119
1120 area = pwindow->area;
1121
1122 /* ---------------- */
1123 if (pcity) {
1124 fc_snprintf(cbuf, sizeof(cbuf), _("Worklist of\n%s"), city_name_get(pcity));
1125 len += 1; /* External entry from current production */
1126 } else {
1127 fc_snprintf(cbuf, sizeof(cbuf), "%s", global_worklist_name(gwl));
1128 }
1129
1130 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1131 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1132
1133 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1134
1135 add_to_gui_list(ID_LABEL, buf);
1136 /* --------------------------- */
1137
1138 fc_snprintf(cbuf, sizeof(cbuf),
1139 /* TRANS: Length of worklist */
1140 PL_("( %d entry )", "( %d entries )", len), len);
1141 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
1142 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
1143 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1144 editor->worklist_counter = buf;
1145 add_to_gui_list(ID_LABEL, buf);
1146 /* --------------------------- */
1147
1148 /* Create production progress label or rename worklist edit */
1149 if (pcity) {
1150 /* count == cost */
1151 /* turns == progress */
1152 const char *name = city_production_name_translation(pcity);
1153 bool convert_prod = city_production_is_genus(pcity, IG_CONVERT);
1154
1155 count = city_production_build_shield_cost(pcity);
1156
1157 if (convert_prod) {
1158 if (city_production_has_flag(pcity, IF_GOLD)) {
1159 int gold = MAX(0, pcity->surplus[O_SHIELD]);
1160
1161 fc_snprintf(cbuf, sizeof(cbuf),
1162 PL_("%s\n%d gold per turn",
1163 "%s\n%d gold per turn", gold),
1164 name, gold);
1165 } else {
1166 fc_snprintf(cbuf, sizeof(cbuf), "%s\n-", name);
1167 }
1168 } else {
1169 if (pcity->shield_stock < count) {
1170 turns = city_production_turns_to_build(pcity, TRUE);
1171 if (turns == 999) {
1172 fc_snprintf(cbuf, sizeof(cbuf), _("%s\nblocked!"), name);
1173 } else {
1174 fc_snprintf(cbuf, sizeof(cbuf), _("%s\n%d %s"),
1175 name, turns, PL_("turn", "turns", turns));
1176 }
1177 } else {
1178 fc_snprintf(cbuf, sizeof(cbuf), _("%s\nfinished!"), name);
1179 }
1180 }
1181 pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT);
1182 pstr->style |= SF_CENTER;
1183 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1184
1185 editor->production_name = buf;
1186 add_to_gui_list(ID_LABEL, buf);
1187
1188 icon = get_progress_icon(pcity->shield_stock, count, &turns);
1189
1190 if (!convert_prod) {
1191 fc_snprintf(cbuf, sizeof(cbuf), "%d%%" , turns);
1192 } else {
1193 fc_snprintf(cbuf, sizeof(cbuf), "-");
1194 }
1195 pstr = create_utf8_from_char_fonto(cbuf, FONTO_ATTENTION);
1196 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1197
1198 buf = create_iconlabel(icon, pwindow->dst, pstr,
1199 (WF_RESTORE_BACKGROUND|WF_ICON_CENTER|WF_FREE_THEME));
1200
1201 icon = NULL;
1202 turns = 0;
1203 editor->production_progress = buf;
1204 add_to_gui_list(ID_LABEL, buf);
1205 } else {
1206 buf = create_edit_from_chars_fonto(NULL, pwindow->dst,
1207 global_worklist_name(gwl), FONTO_DEFAULT,
1208 adj_size(120), WF_RESTORE_BACKGROUND);
1209 buf->action = rename_worklist_editor_callback;
1210 set_wstate(buf, FC_WS_NORMAL);
1211
1212 add_to_gui_list(ID_EDIT, buf);
1213 }
1214
1215 /* --------------------------- */
1216 /* Commit Widget */
1217 buf = create_themeicon(current_theme->ok_icon, pwindow->dst, WF_RESTORE_BACKGROUND);
1218
1219 buf->action = ok_worklist_editor_callback;
1220 set_wstate(buf, FC_WS_NORMAL);
1221 buf->key = SDLK_RETURN;
1222
1223 add_to_gui_list(ID_BUTTON, buf);
1224 /* --------------------------- */
1225 /* Cancel Widget */
1226 buf = create_themeicon(current_theme->cancel_icon, pwindow->dst,
1227 WF_RESTORE_BACKGROUND);
1228
1229 buf->action = popdown_worklist_editor_callback;
1230 set_wstate(buf, FC_WS_NORMAL);
1231 buf->key = SDLK_ESCAPE;
1232
1233 add_to_gui_list(ID_BUTTON, buf);
1234 /* --------------------------- */
1235 /* work list */
1236
1237 /*
1238 pwidget->data filed will contains position of target in worklist all
1239 action on worklist (swap/romove/add) must correct this fields
1240
1241 Production Widget Label in worklist Widget list
1242 will have this field NULL
1243 */
1244
1245 editor->work = fc_calloc(1, sizeof(struct advanced_dialog));
1246
1247 editor->work->scroll = fc_calloc(1, sizeof(struct scroll_bar));
1248 editor->work->scroll->count = 0;
1249 editor->work->scroll->active = MAX_LEN_WORKLIST;
1250 editor->work->scroll->step = 1;
1251
1252/* FIXME: this should replace the 4 lines above, but
1253 * editor->work->end_widget_list is not set yet */
1254#if 0
1255 create_vertical_scrollbar(editor->work, 1, MAX_LEN_WORKLIST, TRUE, TRUE);
1256#endif /* 0 */
1257
1258 if (pcity) {
1259 /* Production Widget Label */
1260 pstr = create_utf8_from_char_fonto(city_production_name_translation(pcity),
1261 FONTO_DEFAULT);
1262 turns = city_production_build_shield_cost(pcity);
1263 pstr->style |= SF_CENTER;
1264 buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND);
1265
1266 set_wstate(buf, FC_WS_NORMAL);
1267 buf->action = worklist_editor_item_callback;
1268
1269 add_to_gui_list(MAX_ID - cid_encode(pcity->production), buf);
1270
1271 editor->work->end_widget_list = buf;
1272 editor->work->begin_widget_list = buf;
1273 editor->work->end_active_widget_list = editor->work->end_widget_list;
1274 editor->work->begin_active_widget_list = editor->work->begin_widget_list;
1275 editor->work->scroll->count++;
1276 }
1277
1278 last = buf;
1279 editor->dock = buf;
1280
1281 /* Create Widget Labels of worklist entries */
1282
1283 count = 0;
1284
1285 worklist_iterate(&editor->worklist_copy, prod) {
1286 if (VUT_UTYPE == prod.kind) {
1287 pstr = create_utf8_from_char_fonto(utype_name_translation(prod.value.utype),
1288 FONTO_DEFAULT);
1289 } else {
1290 pstr = create_utf8_from_char_fonto(city_improvement_name_translation(pcity,
1291 prod.value.building),
1292 FONTO_DEFAULT);
1293 }
1294 pstr->style |= SF_CENTER;
1295 buf = create_iconlabel(NULL, pwindow->dst, pstr,
1296 (WF_RESTORE_BACKGROUND|WF_FREE_DATA));
1297
1298 set_wstate(buf, FC_WS_NORMAL);
1299 buf->action = worklist_editor_item_callback;
1300
1301 buf->data.ptr = fc_calloc(1, sizeof(int));
1302 *((int *)buf->data.ptr) = count;
1303
1304 add_to_gui_list(MAX_ID - cid_encode(prod), buf);
1305
1306 count++;
1307
1308 if (count > editor->work->scroll->active - 1) {
1309 set_wflag(buf, WF_HIDDEN);
1310 }
1311
1312 } worklist_iterate_end;
1313
1314 if (count) {
1315 if (!pcity) {
1316 editor->work->end_widget_list = last->prev;
1317 editor->work->end_active_widget_list = editor->work->end_widget_list;
1318 }
1319 editor->work->begin_widget_list = buf;
1320 editor->work->begin_active_widget_list = editor->work->begin_widget_list;
1321 } else {
1322 if (!pcity) {
1323 editor->work->end_widget_list = last;
1324 }
1325 editor->work->begin_widget_list = last;
1326 }
1327
1328/* FIXME */
1329#if 0
1330 editor->work->active_widget_list = editor->work->end_active_widget_list;
1331 create_vertical_scrollbar(editor->work, 1,
1332 editor->work->scroll->active, FALSE, TRUE);
1333 editor->work->scroll->up_left_button->size.w = adj_size(122);
1334 editor->work->scroll->down_right_button->size.w = adj_size(122);
1335
1336 /* count: without production */
1337 if (count <= editor->work->scroll->active + 1) {
1338 if (count > 0) {
1339 struct widget *tmp = last;
1340
1341 do {
1342 tmp = tmp->prev;
1343 clear_wflag(tmp, WF_HIDDEN);
1344 } while (tmp != buf);
1345 }
1346 hide_scrollbar(editor->work->scroll);
1347 }
1348#endif /* 0 */
1349
1350 editor->work->scroll->count += count;
1351 last = editor->work->begin_widget_list;
1352
1353 /* --------------------------- */
1354 /* Global worklists */
1355 if (pcity) {
1356 count = 0;
1357
1358 global_worklists_iterate(iter_gwl) {
1359 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst,
1360 global_worklist_name(iter_gwl),
1361 FONTO_DEFAULT,
1362 WF_RESTORE_BACKGROUND);
1363 set_wstate(buf, FC_WS_NORMAL);
1364 add_to_gui_list(MAX_ID - global_worklist_id(iter_gwl), buf);
1365 buf->string_utf8->style |= SF_CENTER;
1366 buf->action = global_worklist_callback;
1367 buf->string_utf8->fgcol = bg_color;
1368
1369 count++;
1370
1371 if (count > 4) {
1372 set_wflag(buf, WF_HIDDEN);
1373 }
1374 } global_worklists_iterate_end;
1375
1376 if (count) {
1377 editor->global = fc_calloc(1, sizeof(struct advanced_dialog));
1378 editor->global->end_widget_list = last->prev;
1379 editor->global->end_active_widget_list = editor->global->end_widget_list;
1380 editor->global->begin_widget_list = buf;
1381 editor->global->begin_active_widget_list = editor->global->begin_widget_list;
1382
1383 if (count > 6) {
1384 editor->global->active_widget_list = editor->global->end_active_widget_list;
1385
1386 create_vertical_scrollbar(editor->global, 1, 4, FALSE, TRUE);
1387 editor->global->scroll->up_left_button->size.w = adj_size(122);
1388 editor->global->scroll->down_right_button->size.w = adj_size(122);
1389 } else {
1390 struct widget *tmp = last;
1391
1392 do {
1393 tmp = tmp->prev;
1394 clear_wflag(tmp, WF_HIDDEN);
1395 } while (tmp != buf);
1396 }
1397
1398 last = editor->global->begin_widget_list;
1399 }
1400 }
1401 /* ----------------------------- */
1402 count = 0;
1403 /* Targets units and imprv. to build */
1404 pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT);
1405 pstr->style |= (SF_CENTER|TTF_STYLE_BOLD);
1406 pstr->bgcol = (SDL_Color) {0, 0, 0, 0};
1407
1408 improvement_iterate(pimprove) {
1409 can_build = can_player_build_improvement_now(client.conn.playing, pimprove);
1410 can_eventually_build =
1411 can_player_build_improvement_later(client.conn.playing, pimprove);
1412
1413 /* If there's a city, can the city build the improvement? */
1414 if (pcity) {
1415 can_build = can_build && can_city_build_improvement_now(pcity, pimprove);
1416 can_eventually_build = can_eventually_build
1417 && can_city_build_improvement_later(pcity, pimprove);
1418 }
1419
1420 if ((advanced_tech && can_eventually_build)
1421 || (!advanced_tech && can_build)) {
1422
1423 icon = crop_rect_from_surface(main_surf, NULL);
1424
1425 fc_snprintf(cbuf, sizeof(cbuf), "%s", improvement_name_translation(pimprove));
1426 copy_chars_to_utf8_str(pstr, cbuf);
1427 pstr->style |= TTF_STYLE_BOLD;
1428
1429 if (pcity && is_improvement_redundant(pcity, pimprove)) {
1430 pstr->style |= TTF_STYLE_STRIKETHROUGH;
1431 }
1432
1433 text_name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
1434
1435 if (is_wonder(pimprove)) {
1436 if (improvement_obsolete(client.conn.playing, pimprove, pcity)) {
1437 state = _("Obsolete");
1438 } else if (is_great_wonder(pimprove)) {
1439 if (great_wonder_is_built(pimprove)) {
1440 state = _("Built");
1441 } else if (great_wonder_is_destroyed(pimprove)) {
1442 state = _("Destroyed");
1443 } else {
1444 state = _("Great Wonder");
1445 }
1446 } else if (is_small_wonder(pimprove)) {
1447 if (small_wonder_is_built(client.conn.playing, pimprove)) {
1448 state = _("Built");
1449 } else {
1450 state = _("Small Wonder");
1451 }
1452 }
1453 } else {
1454 state = NULL;
1455 }
1456
1457 if (pcity) {
1458 if (!is_convert_improvement(pimprove)) {
1459 struct universal univ = cid_production(cid_encode_building(pimprove));
1460 int cost = impr_build_shield_cost(pcity, pimprove);
1461
1462 turns = city_turns_to_build(pcity, &univ, TRUE);
1463
1464 if (turns == FC_INFINITY) {
1465 if (state) {
1466 fc_snprintf(cbuf, sizeof(cbuf), _("(%s)\n%d/%d %s\n%s"),
1467 state, pcity->shield_stock, cost,
1468 PL_("shield", "shields", cost),
1469 _("never"));
1470 } else {
1471 fc_snprintf(cbuf, sizeof(cbuf), _("%d/%d %s\n%s"),
1472 pcity->shield_stock, cost,
1473 PL_("shield", "shields", cost), _("never"));
1474 }
1475 } else {
1476 if (state) {
1477 fc_snprintf(cbuf, sizeof(cbuf), _("(%s)\n%d/%d %s\n%d %s"),
1478 state, pcity->shield_stock, cost,
1479 PL_("shield", "shields", cost),
1480 turns, PL_("turn", "turns", turns));
1481 } else {
1482 fc_snprintf(cbuf, sizeof(cbuf), _("%d/%d %s\n%d %s"),
1483 pcity->shield_stock, cost,
1484 PL_("shield", "shields", cost),
1485 turns, PL_("turn", "turns", turns));
1486 }
1487 }
1488 } else {
1489 /* coinage-like */
1490 if (improvement_has_flag(pimprove, IF_GOLD)) {
1491 int gold = MAX(0, pcity->surplus[O_SHIELD]);
1492
1493 fc_snprintf(cbuf, sizeof(cbuf), PL_("%d gold per turn",
1494 "%d gold per turn", gold),
1495 gold);
1496 } else {
1497 fc_strlcpy(cbuf, "-", sizeof(cbuf));
1498 }
1499 }
1500 } else {
1501 /* non city mode */
1502 if (!is_convert_improvement(pimprove)) {
1503 int cost = impr_build_shield_cost(NULL, pimprove);
1504
1505 if (state) {
1506 fc_snprintf(cbuf, sizeof(cbuf), _("(%s)\n%d %s"),
1507 state, cost,
1508 PL_("shield", "shields", cost));
1509 } else {
1510 fc_snprintf(cbuf, sizeof(cbuf), _("%d %s"),
1511 cost,
1512 PL_("shield", "shields", cost));
1513 }
1514 } else {
1515 if (improvement_has_flag(pimprove, IF_GOLD)) {
1516 fc_strlcpy(cbuf, _("shields into gold"), sizeof(cbuf));
1517 } else {
1518 fc_strlcpy(cbuf, "-", sizeof(cbuf));
1519 }
1520 }
1521 }
1522
1523 copy_chars_to_utf8_str(pstr, cbuf);
1524 pstr->style &= ~TTF_STYLE_BOLD;
1525 pstr->style &= ~TTF_STYLE_STRIKETHROUGH;
1526
1527 text = create_text_surf_from_utf8(pstr);
1528
1529 /*-----------------*/
1530
1531 zoomed = get_building_surface(pimprove);
1532 zoomed = zoomSurface(zoomed, DEFAULT_ZOOM * ((float)54 / zoomed->w),
1533 DEFAULT_ZOOM * ((float)54 / zoomed->w), 1);
1534 dst.x = (icon->w - zoomed->w) / 2;
1535 dst.y = (icon->h/2 - zoomed->h) / 2;
1536 alphablit(zoomed, NULL, icon, &dst, 255);
1537 dst.y += zoomed->h;
1538 FREESURFACE(zoomed);
1539
1540 dst.x = (icon->w - text_name->w) / 2;
1541 dst.y += ((icon->h - dst.y) - (text_name->h + text->h)) / 2;
1542 alphablit(text_name, NULL, icon, &dst, 255);
1543
1544 dst.x = (icon->w - text->w) / 2;
1545 dst.y += text_name->h;
1546 alphablit(text, NULL, icon, &dst, 255);
1547
1548 FREESURFACE(text);
1549 FREESURFACE(text_name);
1550
1551 buf = create_icon2(icon, pwindow->dst,
1552 WF_RESTORE_BACKGROUND|WF_FREE_THEME);
1553 set_wstate(buf, FC_WS_NORMAL);
1554
1555 widget_w = MAX(widget_w, buf->size.w);
1556 widget_h = MAX(widget_h, buf->size.h);
1557
1558 buf->data.city = pcity;
1559 add_to_gui_list(MAX_ID - improvement_number(pimprove), buf);
1560 buf->action = worklist_editor_targets_callback;
1561
1562 if (count > (TARGETS_ROW * TARGETS_COL - 1)) {
1563 set_wflag(buf, WF_HIDDEN);
1564 }
1565 count++;
1566 }
1567 } improvement_iterate_end;
1568
1569 /* ------------------------------ */
1570
1571 unit_type_iterate(un) {
1572 can_build = can_player_build_unit_now(client.conn.playing, un);
1573 can_eventually_build =
1574 can_player_build_unit_later(client.conn.playing, un);
1575
1576 /* If there's a city, can the city build the unit? */
1577 if (pcity) {
1578 can_build = can_build && can_city_build_unit_now(pcity, un);
1579 can_eventually_build = can_eventually_build
1580 && can_city_build_unit_later(pcity, un);
1581 }
1582
1583 if ((advanced_tech && can_eventually_build)
1584 || (!advanced_tech && can_build)) {
1585
1586 punittype = un;
1587
1588 icon = crop_rect_from_surface(main_surf, NULL);
1589
1590 fc_snprintf(cbuf, sizeof(cbuf), "%s", utype_name_translation(un));
1591
1592 copy_chars_to_utf8_str(pstr, cbuf);
1593 pstr->style |= TTF_STYLE_BOLD;
1594 text_name = create_text_surf_smaller_than_w(pstr, icon->w - 4);
1595
1596 if (pcity) {
1597 struct universal univ = cid_production(cid_encode_unit(un));
1598 int cost = utype_build_shield_cost(pcity, NULL, un);
1599
1600 turns = city_turns_to_build(pcity, &univ, TRUE);
1601
1602 if (turns == FC_INFINITY) {
1603 fc_snprintf(cbuf, sizeof(cbuf),
1604 _("(%d/%d/%s)\n%d/%d %s\nnever"),
1605 punittype->attack_strength,
1606 punittype->defense_strength,
1607 move_points_text(punittype->move_rate, TRUE),
1608 pcity->shield_stock, cost,
1609 PL_("shield", "shields", cost));
1610 } else {
1611 fc_snprintf(cbuf, sizeof(cbuf),
1612 _("(%d/%d/%s)\n%d/%d %s\n%d %s"),
1613 punittype->attack_strength,
1614 punittype->defense_strength,
1615 move_points_text(punittype->move_rate, TRUE),
1616 pcity->shield_stock, cost,
1617 PL_("shield", "shields", cost),
1618 turns, PL_("turn", "turns", turns));
1619 }
1620 } else {
1621 int cost = utype_build_shield_cost(NULL, client_player(), un);
1622
1623 fc_snprintf(cbuf, sizeof(cbuf),
1624 _("(%d/%d/%s)\n%d %s"),
1625 punittype->attack_strength,
1626 punittype->defense_strength,
1627 move_points_text(punittype->move_rate, TRUE),
1628 cost,
1629 PL_("shield", "shields", cost));
1630 }
1631
1632 copy_chars_to_utf8_str(pstr, cbuf);
1633 pstr->style &= ~TTF_STYLE_BOLD;
1634
1635 text = create_text_surf_from_utf8(pstr);
1636
1637 zoomed = adj_surf(get_unittype_surface(un, direction8_invalid()));
1638 dst.x = (icon->w - zoomed->w) / 2;
1639 dst.y = (icon->h / 2 - zoomed->h) / 2;
1640 alphablit(zoomed, NULL, icon, &dst, 255);
1641 FREESURFACE(zoomed);
1642
1643 dst.x = (icon->w - text_name->w) / 2;
1644 dst.y = icon->h / 2 + (icon->h / 2 - (text_name->h + text->h)) / 2;
1645 alphablit(text_name, NULL, icon, &dst, 255);
1646
1647 dst.x = (icon->w - text->w) / 2;
1648 dst.y += text_name->h;
1649 alphablit(text, NULL, icon, &dst, 255);
1650
1651 FREESURFACE(text);
1652 FREESURFACE(text_name);
1653
1654 buf = create_icon2(icon, pwindow->dst,
1655 WF_RESTORE_BACKGROUND|WF_FREE_THEME);
1656 set_wstate(buf, FC_WS_NORMAL);
1657
1658 widget_w = MAX(widget_w, buf->size.w);
1659 widget_h = MAX(widget_h, buf->size.h);
1660
1661 buf->data.city = pcity;
1662 add_to_gui_list(MAX_ID - cid_encode_unit(un), buf);
1663 buf->action = worklist_editor_targets_callback;
1664
1665 if (count > (TARGETS_ROW * TARGETS_COL - 1)) {
1666 set_wflag(buf, WF_HIDDEN);
1667 }
1668 count++;
1669
1670 }
1671 } unit_type_iterate_end;
1672
1673 editor->targets = fc_calloc(1, sizeof(struct advanced_dialog));
1674
1675 editor->targets->end_widget_list = last->prev;
1676 editor->targets->begin_widget_list = buf;
1677 editor->targets->end_active_widget_list = editor->targets->end_widget_list;
1678 editor->targets->begin_active_widget_list = editor->targets->begin_widget_list;
1679 editor->targets->active_widget_list = editor->targets->end_active_widget_list;
1680
1681 /* --------------- */
1682 if (count > (TARGETS_ROW * TARGETS_COL - 1)) {
1683 count = create_vertical_scrollbar(editor->targets,
1684 TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
1685 } else {
1686 count = 0;
1687 }
1688 /* --------------- */
1689
1690 editor->begin_widget_list = editor->targets->begin_widget_list;
1691
1692 /* Window */
1693 area.w = MAX(area.w, widget_w * TARGETS_COL + count + adj_size(130));
1694 area.h = MAX(area.h, widget_h * TARGETS_ROW);
1695
1696 icon = theme_get_background(active_theme, BACKGROUND_WLDLG);
1697 if (resize_window(pwindow, icon, NULL,
1698 (pwindow->size.w - pwindow->area.w) + area.w,
1699 (pwindow->size.h - pwindow->area.h) + area.h)) {
1700 FREESURFACE(icon);
1701 }
1702
1703 area = pwindow->area;
1704
1705 /* Backgrounds */
1706 dst.x = area.x;
1707 dst.y = area.y;
1708 dst.w = adj_size(130);
1709 dst.h = adj_size(145);
1710
1711 SDL_FillRect(pwindow->theme, &dst,
1712 map_rgba(pwindow->theme->format,
1713 *get_theme_color(COLOR_THEME_BACKGROUND)));
1714
1715 create_frame(pwindow->theme,
1716 dst.x, dst.y, dst.w - 1, dst.h - 1,
1717 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1718 create_frame(pwindow->theme,
1719 dst.x + 2, dst.y + 2, dst.w - 5, dst.h - 5,
1720 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1721
1722 dst.x = area.x;
1723 dst.y += dst.h + adj_size(2);
1724 dst.w = adj_size(130);
1725 dst.h = adj_size(228);
1726 fill_rect_alpha(pwindow->theme, &dst, &bg_color2);
1727
1728 create_frame(pwindow->theme,
1729 dst.x, dst.y, dst.w - 1, dst.h - 1,
1730 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1731
1732 if (editor->global) {
1733 dst.x = area.x;
1734 dst.y += dst.h + adj_size(2);
1735 dst.w = adj_size(130);
1736 dst.h = pwindow->size.h - dst.y - adj_size(4);
1737
1738 SDL_FillRect(pwindow->theme, &dst,
1739 map_rgba(pwindow->theme->format,
1740 *get_theme_color(COLOR_THEME_BACKGROUND)));
1741
1742 create_frame(pwindow->theme,
1743 dst.x, dst.y, dst.w - 1, dst.h - 1,
1744 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1745 create_frame(pwindow->theme,
1746 dst.x + adj_size(2), dst.y + adj_size(2),
1747 dst.w - adj_size(5), dst.h - adj_size(5),
1748 get_theme_color(COLOR_THEME_WLDLG_FRAME));
1749 }
1750
1751 widget_set_position(pwindow,
1752 (main_window_width() - pwindow->size.w) / 2,
1753 (main_window_height() - pwindow->size.h) / 2);
1754
1755 /* name */
1756 buf = pwindow->prev;
1757 buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
1758 buf->size.y = area.y + adj_size(4);
1759
1760 /* size of worklist (without production) */
1761 buf = buf->prev;
1762 buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
1763 buf->size.y = buf->next->size.y + buf->next->size.h;
1764
1765 if (pcity) {
1766 /* current build and progress bar */
1767 buf = buf->prev;
1768 buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
1769 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(5);
1770
1771 buf = buf->prev;
1772 buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
1773 buf->size.y = buf->next->size.y + buf->next->size.h;
1774 } else {
1775 /* rename worklist */
1776 buf = buf->prev;
1777 buf->size.x = area.x + (adj_size(130) - buf->size.w) / 2;
1778 buf->size.y = area.y + 1 + (adj_size(145) - buf->size.h) / 2;
1779 }
1780
1781 /* ok button */
1782 buf = buf->prev;
1783 buf->size.x = area.x + (adj_size(65) - buf->size.w) / 2;
1784 buf->size.y = area.y + adj_size(135) - buf->size.h;
1785
1786 /* exit button */
1787 buf = buf->prev;
1788 buf->size.x = area.x + adj_size(65) + (adj_size(65) - buf->size.w) / 2;
1789 buf->size.y = area.y + adj_size(135) - buf->size.h;
1790
1791 /* worklist */
1792 /* editor->work->scroll->count: including production */
1793 if (len > 0) {
1794 /* FIXME */
1795 setup_vertical_widgets_position(1,
1796 area.x + adj_size(2), area.y + adj_size(152)
1797 /* + ((editor->work->scroll->count > editor->work->scroll->active + 2) ?
1798 editor->work->scroll->up_left_button->size.h + 1 : 0)*/,
1799 adj_size(126), 0, editor->work->begin_widget_list,
1800 editor->work->end_widget_list);
1801
1802 setup_vertical_scrollbar_area(editor->work->scroll,
1803 area.x + adj_size(2),
1804 area.y + adj_size(152),
1805 adj_size(225), FALSE);
1806 }
1807
1808 /* global worklists */
1809 if (editor->global) {
1810 setup_vertical_widgets_position(1,
1811 area.x + adj_size(4),
1812 area.y + adj_size(384) +
1813 (editor->global->scroll ?
1814 editor->global->scroll->up_left_button->size.h + 1 : 0),
1815 adj_size(122), 0, editor->global->begin_widget_list,
1816 editor->global->end_widget_list);
1817
1818 if (editor->global->scroll) {
1819 setup_vertical_scrollbar_area(editor->global->scroll,
1820 area.x + adj_size(4),
1821 area.y + adj_size(384),
1822 adj_size(93), FALSE);
1823 }
1824
1825 }
1826
1827 /* Targets */
1828 setup_vertical_widgets_position(TARGETS_COL,
1829 area.x + adj_size(130), area.y,
1830 0, 0, editor->targets->begin_widget_list,
1831 editor->targets->end_widget_list);
1832
1833 if (editor->targets->scroll) {
1834 setup_vertical_scrollbar_area(editor->targets->scroll,
1835 area.x + area.w,
1836 area.y + 1,
1837 area.h - 1, TRUE);
1838
1839 }
1840
1841 /* ----------------------------------- */
1842 FREEUTF8STR(pstr);
1843 FREESURFACE(main_surf);
1844
1845 redraw_group(editor->begin_widget_list, pwindow, 0);
1846 widget_flush(pwindow);
1847}
1848
1849/**********************************************************************/
1852 void popdown_worklist_editor(void)
1853{
1854 if (editor) {
1855 popdown_window_group_dialog(editor->begin_widget_list,
1856 editor->end_widget_list);
1857 FC_FREE(editor->targets->scroll);
1858 FC_FREE(editor->targets);
1859
1860 FC_FREE(editor->work->scroll);
1861 FC_FREE(editor->work);
1862
1863 if (editor->global) {
1864 FC_FREE(editor->global->scroll);
1865 FC_FREE(editor->global);
1866 }
1867
1868 if (city_dialog_is_open(editor->pcity)) {
1869 enable_city_dlg_widgets();
1870 }
1871
1872 FC_FREE(editor);
1873
1874 flush_dirty();
1875 }
1876}
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
city_turns_to_build
int city_turns_to_build(const struct city *pcity, const struct universal *target, bool include_shield_stock)
Definition city.c:1957
city_improvement_name_translation
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:662
city_production_build_shield_cost
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:736
can_city_build_unit_later
bool can_city_build_unit_later(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:965
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1128
city_production_has_flag
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Definition city.c:726
can_city_build_improvement_now
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:853
city_production_turns_to_build
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Definition city.c:819
city_change_production_penalty
int city_change_production_penalty(const struct city *pcity, const struct universal *target)
Definition city.c:1878
can_city_build_later
bool can_city_build_later(const struct city *pcity, const struct universal *target)
Definition city.c:1023
city_production_is_genus
bool city_production_is_genus(const struct city *pcity, enum impr_genus_id genus)
Definition city.c:716
can_city_build_improvement_later
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:870
can_city_build_unit_now
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Definition city.c:945
city_production_name_translation
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:699
city_set_worklist
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Definition citydlg_common.c:1301
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1289
client
struct civclient client
Definition client_main.c:150
client_main.h
client_player
#define client_player()
Definition client_main.h:106
cid_encode_building
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:504
cid_encode
cid cid_encode(struct universal target)
Definition climisc.c:482
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:525
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
climisc.h
cid_production
#define cid_production
Definition climisc.h:71
incite_cost
char * incite_cost
Definition comments.c: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
id
int int id
Definition editgui_g.h:28
editor
static struct editor_state * editor
Definition editor.c:100
current_theme
QString current_theme
Definition fc_client.cpp:64
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
O_SHIELD
@ O_SHIELD
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
global_worklist_by_id
struct global_worklist * global_worklist_by_id(int id)
Definition global_worklist.c:298
global_worklist_set
bool global_worklist_set(struct global_worklist *pgwl, const struct worklist *pwl)
Definition global_worklist.c:263
global_worklist_name
const char * global_worklist_name(const struct global_worklist *pgwl)
Definition global_worklist.c:323
global_worklist_id
int global_worklist_id(const struct global_worklist *pgwl)
Definition global_worklist.c:288
global_worklist_get
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
Definition global_worklist.c:276
global_worklist_set_name
void global_worklist_set_name(struct global_worklist *pgwl, const char *name)
Definition global_worklist.c:312
global_worklist.h
global_worklists_iterate
#define global_worklists_iterate(pgwl)
Definition global_worklist.h:65
global_worklists_iterate_end
#define global_worklists_iterate_end
Definition global_worklist.h:68
city_dialog_is_open
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:579
flush_dirty
void flush_dirty(void)
Definition mapview.c:468
update_worklist_report_dialog
void update_worklist_report_dialog(void)
Definition wldlg.c:116
enable_city_dlg_widgets
void enable_city_dlg_widgets(void)
Definition citydlg.c:1532
get_theme_color
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
main_window_width
int main_window_width(void)
Definition graphics.c:685
layer_rect_to_screen_rect
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:185
fill_rect_alpha
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
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:1350
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_BUTTON
@ ID_BUTTON
Definition gui_id.h:29
ID_EDIT
@ ID_EDIT
Definition gui_id.h:34
ID_LABEL
@ ID_LABEL
Definition gui_id.h:27
ID_WINDOW
@ ID_WINDOW
Definition gui_id.h:30
adj_size
#define adj_size(size)
Definition gui_main.h:141
PRESSED_EVENT
#define PRESSED_EVENT(event)
Definition gui_main.h:71
copy_chars_to_utf8_str
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
create_text_surf_from_utf8
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
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
FREEUTF8STR
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
SF_CENTER
#define SF_CENTER
Definition gui_string.h:40
FONTO_DEFAULT
@ FONTO_DEFAULT
Definition gui_string.h:65
FONTO_ATTENTION
@ FONTO_ATTENTION
Definition gui_string.h:67
create_utf8_from_char_fonto
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
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_impr_info
void popup_impr_info(Impr_type_id impr)
Definition helpdlg.c:202
popup_unit_info
void popup_unit_info(Unit_type_id type_id)
Definition helpdlg.c:632
dirty_sdl_rect
void dirty_sdl_rect(SDL_Rect *Rect)
Definition mapview.c:181
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
BACKGROUND_WLDLG
@ BACKGROUND_WLDLG
Definition themebackgrounds.h:50
COLOR_THEME_BACKGROUND
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:24
COLOR_THEME_WLDLG_FRAME
@ COLOR_THEME_WLDLG_FRAME
Definition themecolors.h:129
active_theme
struct theme * active_theme
Definition themespec.c:154
add_to_gui_list
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
get_widget_pointer_from_main_list
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:578
refresh_widget_background
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
create_bcgnd_surf
SDL_Surface * create_bcgnd_surf(SDL_Surface *ptheme, enum widget_state state, Uint16 width, Uint16 height)
Definition widget.c:78
setup_vertical_widgets_position
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
redraw_group
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
popdown_window_group_dialog
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
widget_set_position
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
MAX_ID
#define MAX_ID
Definition widget.h:38
FC_WS_DISABLED
@ FC_WS_DISABLED
Definition widget.h:99
FC_WS_NORMAL
@ FC_WS_NORMAL
Definition widget.h:96
FC_WS_SELECTED
@ FC_WS_SELECTED
Definition widget.h:97
clear_wflag
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
add_widget_to_vertical_scroll_widget_list
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *new_widget, struct widget *add_dock, bool dir, Sint16 start_x, Sint16 start_y) fc__attribute((nonnull(2)))
Definition widget_scrollbar.c:1146
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_ICON_CENTER
@ WF_ICON_CENTER
Definition widget.h:83
WF_FREE_DATA
@ WF_FREE_DATA
Definition widget.h:78
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_edit_from_chars_fonto
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
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_iconlabel_from_chars_fonto
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
Definition widget_label.h:20
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
hide_scrollbar
#define hide_scrollbar(scrollbar)
Definition widget_scrollbar.h:36
show_scrollbar
#define show_scrollbar(scrollbar)
Definition widget_scrollbar.h:59
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
get_target_help_data
static void get_target_help_data(struct widget *target)
Definition wldlg.c:388
add_target_to_worklist
static void add_target_to_worklist(struct widget *target)
Definition wldlg.c:206
set_global_worklist
static void set_global_worklist(struct widget *pwidget)
Definition wldlg.c:749
are_prods_same_class
static bool are_prods_same_class(const struct universal *one, const struct universal *two)
Definition wldlg.c:303
get_production_name
static const char * get_production_name(struct city *pcity, struct universal prod, int *cost)
Definition wldlg.c:880
window_worklist_editor_callback
static int window_worklist_editor_callback(struct widget *pwidget)
Definition wldlg.c:103
add_target_to_production
static void add_target_to_production(struct widget *target)
Definition wldlg.c:350
swap_item_down_from_worklist
static void swap_item_down_from_worklist(struct widget *item)
Definition wldlg.c:530
popdown_worklist_editor_callback
static int popdown_worklist_editor_callback(struct widget *pwidget)
Definition wldlg.c:111
ok_worklist_editor_callback
static int ok_worklist_editor_callback(struct widget *pwidget)
Definition wldlg.c:124
get_progress_icon
static SDL_Surface * get_progress_icon(int stock, int cost, int *progress)
Definition wldlg.c:900
popup_worklist_editor
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
TARGETS_ROW
#define TARGETS_ROW
Definition wldlg.c:64
remove_item_from_worklist
static void remove_item_from_worklist(struct widget *item)
Definition wldlg.c:454
refresh_worklist_count_label
static void refresh_worklist_count_label(void)
Definition wldlg.c:1012
worklist_editor_item_callback
static int worklist_editor_item_callback(struct widget *pwidget)
Definition wldlg.c:639
global_worklist_callback
static int global_worklist_callback(struct widget *pwidget)
Definition wldlg.c:851
popdown_worklist_editor
void popdown_worklist_editor(void)
Definition wldlg.c:1852
worklist_editor_targets_callback
static int worklist_editor_targets_callback(struct widget *pwidget)
Definition wldlg.c:415
TARGETS_COL
#define TARGETS_COL
Definition wldlg.c:63
add_global_worklist
static void add_global_worklist(struct widget *pwidget)
Definition wldlg.c:670
swap_item_up_from_worklist
static void swap_item_up_from_worklist(struct widget *item)
Definition wldlg.c:587
rename_worklist_editor_callback
static int rename_worklist_editor_callback(struct widget *pwidget)
Definition wldlg.c:183
change_production
static void change_production(struct universal *prod)
Definition wldlg.c:325
refresh_production_label
static void refresh_production_label(int stock)
Definition wldlg.c:937
gui_id.h
gui_tilespec.h
themespec.h
widget.h
citydlg.h
colors.h
graphics.h
gui_main.h
helpdlg.h
mapview.h
sprite.h
wldlg.h
great_wonder_is_built
bool great_wonder_is_built(const struct impr_type *pimprove)
Definition improvement.c:982
is_improvement_redundant
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:641
can_player_build_improvement_later
bool can_player_build_improvement_later(const struct player *p, const struct impr_type *pimprove)
Definition improvement.c:739
great_wonder_is_destroyed
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
Definition improvement.c:993
can_player_build_improvement_now
bool can_player_build_improvement_now(const struct player *p, struct impr_type *pimprove)
Definition improvement.c:722
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
small_wonder_is_built
bool small_wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
Definition improvement.c:1064
impr_build_shield_cost
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Definition improvement.c:294
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:343
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:772
improvement_obsolete
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
Definition improvement.c:411
improvement_has_flag
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Definition improvement.c:383
is_convert_improvement
bool is_convert_improvement(const struct impr_type *pimprove)
Definition improvement.c:811
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
is_small_wonder
bool is_small_wonder(const struct impr_type *pimprove)
Definition improvement.c:780
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
name
const char * name
Definition inputfile.c:127
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
move_points_text
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1016
movement.h
len
int len
Definition packhand.c:127
universal_build_shield_cost
int universal_build_shield_cost(const struct city *pcity, const struct universal *target)
Definition requirements.c:7321
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:6667
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
advanced_dialog
Definition widget.h:180
city
Definition city.h:320
city::surplus
int surplus[O_LAST]
Definition city.h:355
city::worklist
struct worklist worklist
Definition city.h:401
city::production
struct universal production
Definition city.h:396
city::shield_stock
int shield_stock
Definition city.h:368
civclient::conn
struct connection conn
Definition client_main.h:96
connection::playing
struct player * playing
Definition connection.h:151
global_worklist
Definition global_worklist.c:49
item
Definition climisc.h:80
scroll_bar
Definition widget_scrollbar.h:20
sdl2_data::event
SDL_Event event
Definition graphics.h:217
unit_type
Definition unittype.h:507
universal
Definition fc_types.h:908
universal::kind
enum universals_n kind
Definition fc_types.h:910
universal::value
universals_u value
Definition fc_types.h:909
utf8_str
Definition gui_string.h:52
utf8_str::text
char * text
Definition gui_string.h:60
widget
Definition widget.h:112
widget::prev
struct widget * prev
Definition widget.h:114
widget::dst
struct gui_layer * dst
Definition widget.h:116
widget::string_utf8
utf8_str * string_utf8
Definition widget.h:121
widget::area
SDL_Rect area
Definition widget.h:149
widget::id
Uint16 id
Definition widget.h:155
wl_editor
Definition wldlg.c:66
wl_editor::worklist_counter
struct widget * worklist_counter
Definition wldlg.c:81
wl_editor::worklist_copy
struct worklist worklist_copy
Definition wldlg.c:76
wl_editor::global_worklist_id
int global_worklist_id
Definition wldlg.c:75
wl_editor::production_name
struct widget * production_name
Definition wldlg.c:83
wl_editor::stock
int stock
Definition wldlg.c:86
wl_editor::global
struct advanced_dialog * global
Definition wldlg.c:72
wl_editor::worklist_name
char worklist_name[MAX_LEN_NAME]
Definition wldlg.c:77
wl_editor::currently_building
struct universal currently_building
Definition wldlg.c:87
wl_editor::production_progress
struct widget * production_progress
Definition wldlg.c:84
wl_editor::dock
struct widget * dock
Definition wldlg.c:80
wl_editor::targets
struct advanced_dialog * targets
Definition wldlg.c:70
wl_editor::work
struct advanced_dialog * work
Definition wldlg.c:71
wl_editor::begin_widget_list
struct widget * begin_widget_list
Definition wldlg.c:67
wl_editor::end_widget_list
struct widget * end_widget_list
Definition wldlg.c:68
wl_editor::pcity
struct city * pcity
Definition wldlg.c:74
worklist
Definition worklist.h:28
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
fc_strlcpy
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:728
universals_u::building
const struct impr_type * building
Definition fc_types.h:721
unit.h
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
can_player_build_unit_later
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2099
utype_build_shield_cost
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1438
can_player_build_unit_now
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
Definition unittype.c:2078
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:859
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:866
worklist_advance
void worklist_advance(struct worklist *pwl)
Definition worklist.c:104
worklist_copy
void worklist_copy(struct worklist *dst, const struct worklist *src)
Definition worklist.c:112
worklist_init
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
worklist_peek_ith
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
Definition worklist.c:86
worklist_is_empty
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66
worklist_append
bool worklist_append(struct worklist *pwl, const struct universal *prod)
Definition worklist.c:147
worklist_remove
void worklist_remove(struct worklist *pwl, int idx)
Definition worklist.c:122
worklist_length
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57
worklist_iterate_end
#define worklist_iterate_end
Definition worklist.h:59
worklist_iterate
#define worklist_iterate(_list, _p)
Definition worklist.h:51
MAX_LEN_WORKLIST
#define MAX_LEN_WORKLIST
Definition worklist.h:24