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