Freeciv-3.2
Loading...
Searching...
No Matches
optiondlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 optiondlg.c - description
16 -------------------
17 begin : Sun Aug 11 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26#include <stdarg.h>
27#include <stdlib.h>
28
29/* SDL3 */
30#include <SDL3/SDL.h>
31
32/* utility */
33#include "fcintl.h"
34#include "log.h"
35#include "string_vector.h"
36
37/* common */
38#include "fc_types.h"
39#include "game.h"
40
41/* client */
42#include "client_main.h"
43#include "climisc.h"
44#include "clinet.h"
45#include "connectdlg_common.h"
46#include "global_worklist.h"
47
48/* gui-sdl3 */
49#include "colors.h"
50#include "connectdlg.h"
51#include "dialogs.h"
52#include "graphics.h"
53#include "gui_id.h"
54#include "gui_main.h"
55#include "gui_tilespec.h"
56#include "helpdlg.h"
57#include "mapctrl.h"
58#include "mapview.h"
59#include "menu.h"
60#include "messagewin.h"
61#include "pages.h"
62#include "themespec.h"
63#include "widget.h"
64#include "wldlg.h"
65
66#include "optiondlg.h"
67
73
75 const struct option_set *poptset;
76 struct widget *widget_list;
77 int category;
78};
79
81 struct widget *edited_name;
82};
83
84struct option_dialog {
85 struct widget *end_widget_list;
91 union {
92 struct option_dialog_optset optset;
94 };
95};
96
97
101
102
103static struct widget *option_widget_new(struct option *poption,
104 struct widget *window,
105 bool hide);
106static void option_widget_update(struct option *poption);
107static void option_widget_apply(struct option *poption);
108
109static struct option_dialog *option_dialog_new(void);
110static void option_dialog_destroy(struct option_dialog *pdialog);
111
112static void option_dialog_optset(struct option_dialog *pdialog,
113 const struct option_set *poptset);
114static void option_dialog_optset_category(struct option_dialog *pdialog,
115 int category);
116
117static void option_dialog_worklist(struct option_dialog *pdialog);
118
119/************************************************************************/
123static void arrange_widgets(struct widget *window, int widgets_per_row,
124 int rows_shown, struct widget *begin,
125 struct widget *end, ...)
126{
127 struct widget *widget;
131 int w, h, i, j;
132 va_list args;
133
134 fc_assert_ret(NULL != window);
135 fc_assert_ret(NULL != begin);
136 fc_assert_ret(NULL != end);
138
139 /* Get window dimensions. */
140 memset(longest, 0, sizeof(longest));
141 for (widget = begin, i = 0; widget != end; widget = widget->next, i++) {
142 j = i % widgets_per_row;
143 longest[j] = MAX(longest[j], widget->size.w);
144 }
145
146 fc_assert(0 == (i % widgets_per_row));
147
148 if (-1 == rows_shown) {
149 h = 30 * (i / widgets_per_row);
150 } else {
151 h = 30 * MIN((i / widgets_per_row), rows_shown);
152 }
153
154 w = (1 - widgets_per_row) * adj_size(20);
155 for (j = 0; j < widgets_per_row; j++) {
156 w += longest[j];
157 }
158 if (-1 != rows_shown) {
159 w += adj_size(20);
160 }
161
162 /* Clear former area. */
163 area = window->area;
164 area.w += window->size.x;
165 area.h += window->size.y;
167
168 /* Resize window. */
170 if (resize_window(window, logo, NULL,
171 adj_size(w + 80), adj_size(h + 80))) {
173 }
174
175 /* Set window position. */
176 widget_set_position(window, (main_window_width() - window->size.w) / 2,
177 (main_window_height() - window->size.h) / 2);
178
179 area = window->area;
180
181 /* Set icons position. */
182 va_start(args, end);
183 w = 0;
184 while ((widget = va_arg(args, struct widget *))) {
185 w += widget->size.w;
186 widget_set_position(widget, area.x + area.w - w - 1,
187 window->size.y + adj_size(2));
188 }
189 va_end(args);
190
191 if (1 < widgets_per_row) {
192 xpos[widgets_per_row - 1] = area.x + adj_size(20);
193 for (j = widgets_per_row - 2; j >= 0; j--) {
194 xpos[j] = xpos[j + 1] + adj_size(20) + longest[j + 1];
195 }
196 }
197
198 /* Set button position. */
199 h = 30 * (i / widgets_per_row + 1);
200 for (widget = begin, i = 0; widget != end; widget = widget->next, i++) {
201 j = i % widgets_per_row;
202 if (0 == j) {
203 h -= 30;
204 }
206 if (1 == widgets_per_row) {
207 widget_set_position(widget, area.x + (area.w - widget->size.w) / 2,
208 area.y + adj_size(h));
209 } else {
211 }
212 }
213
214 redraw_group(begin, window, 0);
215 widget_mark_dirty(window);
216 flush_all();
217}
218
219/************************************************************************/
222static int main_optiondlg_callback(struct widget *pwindow)
223{
227 }
228
229 return -1;
230}
231
232/************************************************************************/
235static int back_callback(struct widget *pwidget)
236{
238 return -1;
239 }
240
241 if (ODM_MAIN == option_dialog->mode) {
242 if (client.conn.established) {
243 /* Back to game. */
248 flush_dirty();
249 } else {
250 /* Back to main page. */
253 }
254 return -1;
255 }
256
258 && -1 != option_dialog->optset.category) {
259 /* Back to option set category menu. */
263 }
268
271
273
276
281 return -1;
282 }
283
285 && NULL != option_dialog->advanced) {
289 }
290
291 /* Back to main options menu. */
294
296
304
305 return -1;
306}
307
308/************************************************************************/
311static int client_options_callback(struct widget *pwidget)
312{
314 option_dialog_popup(_("Local Options"), client_optset);
315 }
316
317 return -1;
318}
319
320/************************************************************************/
323static int server_options_callback(struct widget *pwidget)
324{
326 option_dialog_popup(_("Server options"), server_optset);
327 }
328
329 return -1;
330}
331
332/************************************************************************/
336{
339 }
340
341 return -1;
342}
343
344/************************************************************************/
347static int save_client_options_callback(struct widget *pwidget)
348{
351 }
352
353 return -1;
354}
355
356/************************************************************************/
359static int save_game_callback(struct widget *pwidget)
360{
364 }
365
366 return -1;
367}
368
369/************************************************************************/
372static int help_browser_callback(struct widget *pwidget)
373{
376 }
377
378 return -1;
379}
380
381/************************************************************************/
384static int disconnect_callback(struct widget *pwidget)
385{
390 }
391
392 return -1;
393}
394
395/************************************************************************/
398static int exit_callback(struct widget *pwidget)
399{
404 }
405
406 return 0;
407}
408
409/************************************************************************/
413{
416 }
417
418 return -1;
419}
420
421/************************************************************************/
439
440/************************************************************************/
443static int none_callback(struct widget *widget)
444{
445 return -1;
446}
447
448/************************************************************************/
451static struct strvec *video_mode_list(void)
452{
453 struct strvec *video_modes = strvec_new();
454 int display_count;
455 int mode_count;
456 int i, j;
459
461
462 if (ids == NULL) {
463 log_error(_("Failed to get display count: %s"), SDL_GetError());
464 return NULL;
465 }
466
467 for (i = 0; i < display_count; i++) {
469
470 if (modes == NULL) {
471 log_error(_("Failed to get display modes for display %d: %s"),
472 ids[i], SDL_GetError());
473 break;
474 }
475
476 for (j = 0; j < mode_count; j++) {
477 char buf[64];
478 struct video_mode vmod = { .width = modes[j]->w, .height = modes[j]->h };
479
480 if (video_mode_to_string(buf, sizeof(buf), &vmod)) {
482 }
483 }
484
486 }
487
488 SDL_free(ids);
489
490 return video_modes;
491}
492
493/************************************************************************/
497{
499}
500
501/************************************************************************/
505{
508}
509
510/************************************************************************/
513static struct widget *option_widget_new(struct option *poption,
514 struct widget *window,
515 bool hide)
516{
517 struct widget *widget;
518 char *help_text;
521
523 fc_assert_ret_val(NULL != window, NULL);
524
527
539
540 widget = NULL;
541 switch (option_type(poption)) {
542 case OT_BOOLEAN:
545 break;
546
547 case OT_INTEGER:
548 {
549 char buf[64];
550
551 fc_snprintf(buf, sizeof(buf), "%d", option_int_get(poption));
554 adj_size(25),
556 }
557 break;
558
559 case OT_STRING:
560 {
561 const struct strvec *values = option_str_values(poption);
562
563 if (NULL != values) {
566 option_str_get(poption), values,
567 adj_size(25),
569 } else {
573 adj_size(25),
575 }
576 }
577 break;
578
579 case OT_ENUM:
580 {
581 const struct strvec *values = option_enum_values(poption);
583 int i;
584
586 for (i = 0; i < strvec_size(values); i++) {
588 }
589
596 }
597 break;
598
599 case OT_VIDEO_MODE:
600 {
601 char buf[64];
602 struct video_mode vmod;
603
605 if (!video_mode_to_string(buf, sizeof(buf), &vmod)) {
606 /* Always fails. */
608 }
609
615 }
616 break;
617
618 case OT_FONT:
619 {
623 adj_size(25),
625 }
626 break;
627
628 case OT_BITWISE:
629 case OT_COLOR:
630 log_error("Option type %s (%d) not supported yet.",
633 break;
634 }
635
636 if (NULL == widget) {
637 /* Not implemented. */
639 FONTO_ATTENTION, flags);
640 } else {
646 }
647 }
648
651
653
654 return widget;
655}
656
657/************************************************************************/
661{
662 struct widget *widget;
663
667
671
672 switch (option_type(poption)) {
673 case OT_BOOLEAN:
676 }
677 break;
678
679 case OT_INTEGER:
680 {
681 char buf[64];
682
683 fc_snprintf(buf, sizeof(buf), "%d", option_int_get(poption));
685 }
686 break;
687
688 case OT_STRING:
690 break;
691
692 case OT_ENUM:
695 break;
696
697 case OT_VIDEO_MODE:
698 {
699 char buf[64];
700 struct video_mode vmod;
701
703 if (video_mode_to_string(buf, sizeof(buf), &vmod)) {
705 } else {
706 /* Always fails. */
708 }
709 }
710 break;
711
712 case OT_FONT:
714 break;
715
716 case OT_BITWISE:
717 case OT_COLOR:
718 log_error("Option type %s (%d) not supported yet.",
721 break;
722 }
723
726}
727
728/************************************************************************/
732{
733 struct widget *widget;
734
738
739 switch (option_type(poption)) {
740 case OT_BOOLEAN:
742 break;
743
744 case OT_INTEGER:
745 {
746 int value;
747
748 if (str_to_int(widget->string_utf8->text, &value)) {
749 (void) option_int_set(poption, value);
750 }
751 }
752 break;
753
754 case OT_STRING:
756 break;
757
758 case OT_ENUM:
759 {
760 int i;
761
762 /* 'str' is translated, so we cannot use directly
763 * option_enum_set_str(). */
764 for (i = 0; i < strvec_size(widget->data.vector); i++) {
767 break;
768 }
769 }
770 }
771 break;
772
773 case OT_VIDEO_MODE:
774 {
775 struct video_mode mode;
776
779 } else {
780 /* Always fails. */
782 }
783 }
784 break;
785
786 case OT_FONT:
788 break;
789
790 case OT_BITWISE:
791 case OT_COLOR:
792 log_error("Option type %s (%d) not supported yet.",
795 break;
796 }
797}
798
799/************************************************************************/
803{
804 struct option_dialog *pdialog = fc_calloc(1, sizeof(*pdialog));
805 struct widget *window, *close_button, *widget;
806 utf8_str *str;
807
808 pdialog->mode = ODM_MAIN;
809
810 /* Create window widget. */
812 str->style |= TTF_STYLE_BOLD;
813
814 window = create_window_skeleton(NULL, str, 0);
816
817 set_wstate(window, FC_WS_NORMAL);
819 pdialog->end_widget_list = window;
820
821 /* Create close button widget. */
822 close_button = create_themeicon(current_theme->small_cancel_icon,
823 window->dst,
826 close_button->info_label
827 = create_utf8_from_char_fonto(_("Close Dialog (Esc)"), FONTO_ATTENTION);
828 close_button->action = back_callback;
829 set_wstate(close_button, FC_WS_NORMAL);
830 close_button->key = SDLK_ESCAPE;
832 pdialog->core_widget_list = close_button;
833
834 /* Create client options button widget. */
836 _("Local options"),
837 FONTO_ATTENTION, 0);
842
843 /* Create server options button widget. */
845 _("Server options"),
846 FONTO_ATTENTION, 0);
848 if (client.conn.established) {
850 }
853
854 /* Create global worklists button widget. */
856 _("Worklists"),
857 FONTO_ATTENTION, 0);
859 if (C_S_RUNNING == client_state()) {
861 }
864
865 /* Create save game button widget. */
867 _("Save Local Options"),
868 FONTO_ATTENTION, 0);
873
874 /* Create save game button widget. */
876 _("Save Game"),
877 FONTO_ATTENTION, 0);
879 if (C_S_RUNNING == client_state()) {
881 }
884
885 /* Create help browser button widget. */
887 _("Help Browser"),
888 FONTO_ATTENTION, 0);
890 widget->key = SDLK_H;
891 if (client.conn.established) {
893 }
896
897 /* Create leave game button widget. */
899 _("Leave Game"),
900 FONTO_ATTENTION, 0);
902 widget->key = SDLK_Q;
903 if (client.conn.established) {
905 }
908
909 /* Create quit widget button. */
911 _("Quit"),
912 FONTO_ATTENTION, 0);
914 widget->key = SDLK_Q;
918
919 pdialog->begin_widget_list = widget;
920 pdialog->main_widget_list = widget;
921
922 arrange_widgets(window, 1, -1, widget, pdialog->core_widget_list,
923 pdialog->core_widget_list, NULL);
924
925 return pdialog;
926}
927
928/************************************************************************/
931static void option_dialog_destroy(struct option_dialog *pdialog)
932{
933 fc_assert_ret(NULL != pdialog);
934
935 if (ODM_OPTSET == pdialog->mode && -1 != pdialog->optset.category) {
937 if (pdialog->optset.category == option_category(poption)) {
939 }
941 }
942
943 if (NULL != pdialog->advanced) {
944 free(pdialog->advanced->scroll);
945 free(pdialog->advanced);
946 }
947
949 pdialog->end_widget_list);
950
951 free(pdialog);
952}
953
954/************************************************************************/
957static int optset_category_option_count(const struct option_set *poptset,
958 int category)
959{
960 int count = 0;
961
962 options_iterate(poptset, poption) {
963 if (category == option_category(poption)) {
964 count++;
965 }
967
968 return count;
969}
970
971/************************************************************************/
974static void option_dialog_optset(struct option_dialog *pdialog,
975 const struct option_set *poptset)
976{
978 struct widget *window;
979 struct widget *widget = NULL;
980 int i, category_num;
981
982 fc_assert_ret(NULL != pdialog);
983 fc_assert_ret(NULL != poptset);
984 category_num = optset_category_number(poptset);
985 fc_assert_ret(0 < category_num);
986
987 poptset_dialog = &pdialog->optset;
988 pdialog->mode = ODM_OPTSET;
989 poptset_dialog->poptset = poptset;
990 poptset_dialog->category = -1;
991
992 window = pdialog->end_widget_list;
993
994 /* Hide ODM_MAIN widget group. */
996
997 /* Otherwise we don't enter next loop at all, and widget will remain NULL */
998 fc_assert(category_num > 0);
999
1000 /* Make the category buttons. */
1001 for (i = 0; i < category_num; i++) {
1002 if (0 == optset_category_option_count(poptset, i)) {
1003 continue;
1004 }
1005
1007 optset_category_name(poptset, i),
1008 FONTO_ATTENTION, 0);
1013 }
1014
1015 poptset_dialog->widget_list = widget;
1016 pdialog->begin_widget_list = widget;
1017
1018 arrange_widgets(window, 1, -1, widget, pdialog->main_widget_list,
1019 pdialog->core_widget_list, NULL);
1020}
1021
1022/************************************************************************/
1026 int category)
1027{
1029 const struct option_set *poptset;
1030 struct widget *window, *widget = NULL, *apply_button;
1031 const int MAX_SHOWN = 10;
1032 SDL_Rect area;
1033 int i;
1034
1035 fc_assert_ret(NULL != pdialog);
1036 fc_assert_ret(ODM_OPTSET == pdialog->mode);
1037 fc_assert_ret(NULL == pdialog->advanced);
1038 poptset_dialog = &pdialog->optset;
1039 poptset = poptset_dialog->poptset;
1040 fc_assert_ret(0 < optset_category_option_count(poptset, category));
1041
1042 /* Hide ODM_OPTSET widget group. */
1043 hide_group(poptset_dialog->widget_list, pdialog->main_widget_list->prev);
1044
1045 poptset_dialog->category = category;
1046 window = pdialog->end_widget_list;
1047
1048 /* Create the apply button. */
1049 apply_button = create_themeicon(current_theme->small_ok_icon, window->dst,
1052 apply_button->info_label = create_utf8_from_char_fonto(_("Apply changes"),
1054 apply_button->action = apply_callback;
1057
1058 /* Create the option widgets. */
1059 i = 0;
1060 options_iterate(poptset, poption) {
1061 if (category != option_category(poption)) {
1062 continue;
1063 }
1064
1066 i++;
1068
1069 /* Scrollbar. */
1070 pdialog->advanced = fc_calloc(1, sizeof(*pdialog->advanced));
1071 pdialog->advanced->end_widget_list = pdialog->end_widget_list;
1073 pdialog->advanced->begin_widget_list = widget;
1075
1077
1078 if (i >= MAX_SHOWN) {
1079 pdialog->advanced->active_widget_list =
1081 } else {
1082 hide_scrollbar(pdialog->advanced->scroll);
1083 }
1084
1085 pdialog->begin_widget_list = pdialog->advanced->begin_widget_list;
1086
1087 arrange_widgets(window, 2, MAX_SHOWN,
1091
1092 area = window->area;
1094 area.x + area.w - 1, area.y + 1,
1095 area.h - adj_size(32), TRUE);
1096
1098 pdialog->advanced->active_widget_list, 0);
1099 widget_flush(window);
1100}
1101
1102
1103/************************************************************************/
1107{
1109
1110 if (NULL == option_dialog
1112 || NULL == pgwl) {
1113 return -1;
1114 }
1115
1117 switch (main_data.event.button.button) {
1118 case SDL_BUTTON_LEFT:
1119 /* Edit. */
1122 break;
1123
1124 case SDL_BUTTON_RIGHT:
1125 {
1126 /* Delete. */
1127 struct advanced_dialog *advanced = option_dialog->advanced;
1128 bool scroll = (NULL != advanced->active_widget_list);
1129
1132
1133 /* Find if there was scrollbar hide. */
1134 if (scroll && advanced->active_widget_list == NULL) {
1135 int len = advanced->scroll->up_left_button->size.w;
1136
1137 widget = advanced->end_active_widget_list->next;
1138 do {
1139 widget = widget->prev;
1140 widget->size.w += len;
1142 } while (widget != advanced->begin_active_widget_list);
1143 }
1144
1148 flush_dirty();
1149 }
1150 break;
1151 }
1152 } else if (PRESSED_EVENT(main_data.event)) {
1153 /* Edit. */
1156 }
1157
1158 return -1;
1159}
1160
1161/************************************************************************/
1165{
1168 struct widget *window = option_dialog->end_widget_list;
1169 struct global_worklist *pgwl = global_worklist_new(_("empty worklist"));
1170 struct advanced_dialog *advanced = option_dialog->advanced;
1171 bool scroll = advanced->active_widget_list == NULL;
1172 bool redraw_all = FALSE;
1173
1176
1177 /* Create list element. */
1184 new_worklist_widget->string_utf8->style |= SF_CENTER;
1186 new_worklist_widget->size.w = widget->size.w;
1188
1189 /* Add to widget list. */
1192 window->area.x + adj_size(17),
1193 window->area.y + adj_size(17));
1194
1195 /* Find if there was scrollbar shown. */
1196 if (scroll && advanced->active_widget_list != NULL) {
1197 int len = advanced->scroll->up_left_button->size.w;
1198
1199 window = advanced->end_active_widget_list->next;
1200 do {
1201 window = window->prev;
1202 window->size.w -= len;
1203 window->area.w -= len;
1204 FREESURFACE(window->gfx);
1205 } while (window != advanced->begin_active_widget_list);
1206 }
1207
1208 if (redraw_all) {
1212 } else {
1213 /* Redraw only new widget and dock widget. */
1216 }
1219
1220 if (!new_worklist_widget->gfx
1223 }
1226 }
1227 flush_dirty();
1228 }
1229
1230 return -1;
1231}
1232
1233/************************************************************************/
1237static void option_dialog_worklist(struct option_dialog *pdialog)
1238{
1239 SDL_Color bg_color = {255, 255, 255, 128};
1240 struct widget *widget, *window, *background;
1241 int count = 0, scrollbar_width = 0, longest = 0;
1242 SDL_Rect area;
1243
1244 pdialog->mode = ODM_WORKLIST;
1245 pdialog->worklist.edited_name = NULL;
1246 window = pdialog->end_widget_list;
1247
1248 /* Hide main widget group. */
1249 hide_group(pdialog->main_widget_list, pdialog->core_widget_list->prev);
1250
1251 /* Create white background. */
1252 background = create_iconlabel(NULL, window->dst, NULL, WF_FREE_THEME);
1253 add_to_gui_list(ID_LABEL, background);
1254
1255 /* Build the global worklists list. */
1265 longest = MAX(longest, widget->size.w);
1266 count++;
1267
1268 if (count > 13) {
1270 }
1272
1273 /* Create the adding item. */
1275 _("Add new worklist"),
1282 longest = MAX(longest, widget->size.w);
1283 count++;
1284
1285 if (count > 13) {
1287 }
1288
1289 /* Advanced dialog. */
1290 pdialog->advanced = fc_calloc(1, sizeof(*pdialog->advanced));
1291 pdialog->advanced->end_widget_list = pdialog->end_widget_list;
1293 pdialog->main_widget_list->prev->prev;
1294 pdialog->advanced->begin_widget_list = widget;
1296
1297 /* Clear former area. */
1298 area = window->area;
1299 area.w += window->size.x;
1300 area.h += window->size.y;
1302
1303 /* Resize window. */
1304 resize_window(window, NULL, NULL,
1305 adj_size(longest + 40), window->size.h);
1306 area = window->area;
1307
1308 /* Move close button. */
1309 widget = pdialog->core_widget_list;
1311 window->size.y + adj_size(2));
1312
1313 /* Resize white background. */
1314 area.x += adj_size(12);
1315 area.y += adj_size(12);
1316 area.w -= adj_size(12) + adj_size(12);
1317 area.h -= adj_size(12) + adj_size(12);
1318 background->theme = create_surf(area.w, area.h);
1319 widget_set_area(background, area);
1320 widget_set_position(background, area.x, area.y);
1321 SDL_FillSurfaceRect(background->theme, NULL,
1322 map_rgba(background->theme->format, bg_color));
1323
1324 create_frame(background->theme,
1325 0, 0, background->theme->w - 1, background->theme->h - 1,
1327
1328 /* Create the Scrollbar. */
1330 1, 13, TRUE, TRUE);
1332 area.x + area.w - 1, area.y + 1,
1333 area.h - adj_size(32), TRUE);
1334
1335 if (count > 13) {
1336 pdialog->advanced->active_widget_list =
1338 } else {
1339 hide_scrollbar(pdialog->advanced->scroll);
1340 scrollbar_width = 0;
1341 }
1342
1343 /* Draw! */
1345 area.y + adj_size(5),
1346 area.w - adj_size(10) - scrollbar_width, 0,
1349
1350 pdialog->begin_widget_list = pdialog->advanced->begin_widget_list;
1351
1352 redraw_group(pdialog->begin_widget_list, pdialog->end_widget_list, 0);
1353 widget_flush(window);
1354}
1355
1356/************************************************************************/
1360{
1363 clear_surface(pbutton->dst->surface, &pbutton->size);
1366
1368 }
1369
1370 return -1;
1371}
1372
1373/* ======================================================================= */
1374/* =================================== Public ============================ */
1375/* ======================================================================= */
1376
1377/************************************************************************/
1384
1385/************************************************************************/
1392
1393/************************************************************************/
1417
1418/************************************************************************/
1442
1443/************************************************************************/
1447{
1448 if (NULL != option_dialog) {
1449 return;
1450 }
1451
1454 flush_dirty();
1455
1457
1459 flush_dirty();
1460}
1461
1462/************************************************************************/
1466{
1467 if (NULL == option_dialog) {
1468 return;
1469 }
1470
1473
1474 if (!leave_game) {
1476 }
1477
1480 }
1481}
1482
1483/************************************************************************/
1486void option_dialog_popup(const char *name, const struct option_set *poptset)
1487{
1488 if (NULL == option_dialog) {
1490 } else if (ODM_OPTSET == option_dialog->mode
1491 && poptset == option_dialog->optset.poptset) {
1492 /* Already in use. */
1493 return;
1494 } else {
1495 while (ODM_MAIN != option_dialog->mode) {
1497 }
1498 }
1499
1501}
1502
1503/************************************************************************/
1506void option_dialog_popdown(const struct option_set *poptset)
1507{
1508 while (NULL != option_dialog
1510 && poptset == option_dialog->optset.poptset) {
1512 }
1513}
1514
1515/************************************************************************/
1519{
1520 if (NULL != option_dialog
1525 }
1526
1527 if (!strcmp(option_name(poption), "nationset")) {
1529 }
1530}
1531
1532/************************************************************************/
1545
1546/************************************************************************/
#define str
Definition astring.c:76
struct civclient client
enum client_states client_state(void)
@ C_S_RUNNING
Definition client_main.h:47
void disconnect_from_server(bool leaving_sound)
Definition clinet.c:306
char * incite_cost
Definition comments.c:75
void send_save_game(const char *filename)
QString current_theme
Definition fc_client.cpp:65
#define _(String)
Definition fcintl.h:67
struct global_worklist * global_worklist_by_id(int id)
const char * global_worklist_name(const struct global_worklist *pgwl)
int global_worklist_id(const struct global_worklist *pgwl)
void global_worklist_destroy(struct global_worklist *pgwl)
struct global_worklist * global_worklist_new(const char *name)
#define global_worklists_iterate(pgwl)
#define global_worklists_iterate_end
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
static GtkTextBuffer * help_text
Definition helpdlg.c:70
void flush_dirty(void)
Definition mapview.c:468
void meswin_dialog_popup(bool raise)
Definition messagewin.c:417
bool meswin_dialog_is_open(void)
Definition messagewin.c:443
void option_gui_remove(struct option *poption)
Definition optiondlg.c:1041
void option_dialog_popdown(const struct option_set *poptset)
Definition optiondlg.c:986
static void option_dialog_destroy(struct option_dialog *pdialog)
Definition optiondlg.c:405
void option_gui_add(struct option *poption)
Definition optiondlg.c:1027
void option_gui_update(struct option *poption)
Definition optiondlg.c:1013
void option_dialog_popup(const char *name, const struct option_set *poptset)
Definition optiondlg.c:972
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
void nationset_changed(void)
Definition dialogs.c:3565
int main_window_width(void)
Definition graphics.c:685
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
#define map_rgba(format, color)
Definition graphics.h:315
@ ID_OPTIONS_DISC_BUTTON
Definition gui_id.h:78
@ ID_OPTIONS_SAVE_BUTTON
Definition gui_id.h:75
@ ID_OPTIONS_APPLY_BUTTON
Definition gui_id.h:80
@ ID_CLIENT_OPTIONS
Definition gui_id.h:38
@ ID_OPTIONS_CLIENT_BUTTON
Definition gui_id.h:72
@ ID_OPTIONS_WORKLIST_BUTTON
Definition gui_id.h:74
@ ID_ADD_NEW_WORKLIST
Definition gui_id.h:214
@ ID_OPTIONS_SAVE_GAME_BUTTON
Definition gui_id.h:76
@ ID_OPTIONS_HELP_BROWSER_BUTTON
Definition gui_id.h:77
@ ID_OPTIONS_BACK_BUTTON
Definition gui_id.h:79
@ ID_OPTIONS_WINDOW
Definition gui_id.h:71
@ ID_LABEL
Definition gui_id.h:27
@ ID_OPTIONS_SERVER_BUTTON
Definition gui_id.h:73
@ ID_OPTIONS_EXIT_BUTTON
Definition gui_id.h:81
void force_exit_from_event_loop(void)
Definition gui_main.c:565
struct widget * selected_widget
Definition widget.c:48
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
#define SF_CENTER
Definition gui_string.h:40
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
void popup_help_browser(void)
Definition helpdlg.c:77
void enable_main_widgets(void)
Definition mapctrl.c:2180
void disable_main_widgets(void)
Definition mapctrl.c:2102
void dirty_sdl_rect(SDL_Rect *Rect)
Definition mapview.c:181
void flush_all(void)
Definition mapview.c:201
struct widget * options_button
Definition optiondlg.c:103
static int disconnect_callback(struct widget *pwidget)
Definition optiondlg.c:388
void update_worklist_report_dialog(void)
Definition optiondlg.c:1409
static int save_game_callback(struct widget *pwidget)
Definition optiondlg.c:363
static int optset_category_option_count(const struct option_set *poptset, int category)
Definition optiondlg.c:943
static int work_lists_callback(struct widget *widget)
Definition optiondlg.c:339
static void option_widget_apply(struct option *poption)
Definition optiondlg.c:717
static int server_options_callback(struct widget *pwidget)
Definition optiondlg.c:327
static struct option_dialog * option_dialog_new(void)
Definition optiondlg.c:788
static bool restore_meswin_dialog
Definition optiondlg.c:104
void enable_options_button(void)
Definition optiondlg.c:1366
void popdown_optiondlg(bool leave_game)
Definition optiondlg.c:1451
static int main_optiondlg_callback(struct widget *pwindow)
Definition optiondlg.c:226
static void enum_widget_destroy(struct widget *widget)
Definition optiondlg.c:482
static int edit_worklist_callback(struct widget *widget)
Definition optiondlg.c:1092
static int exit_callback(struct widget *pwidget)
Definition optiondlg.c:402
static int client_options_callback(struct widget *pwidget)
Definition optiondlg.c:315
static void video_mode_widget_destroy(struct widget *widget)
Definition optiondlg.c:490
void init_options_button(void)
Definition optiondlg.c:1382
static int save_client_options_callback(struct widget *pwidget)
Definition optiondlg.c:351
void disable_options_button(void)
Definition optiondlg.c:1374
static int add_new_worklist_callback(struct widget *widget)
Definition optiondlg.c:1150
option_dialog_mode
Definition optiondlg.c:72
@ ODM_MAIN
Definition optiondlg.c:73
@ ODM_WORKLIST
Definition optiondlg.c:75
@ ODM_OPTSET
Definition optiondlg.c:74
static int back_callback(struct widget *pwidget)
Definition optiondlg.c:239
static int none_callback(struct widget *widget)
Definition optiondlg.c:447
void popup_optiondlg(void)
Definition optiondlg.c:1432
static struct widget * option_widget_new(struct option *poption, struct widget *window, bool hide)
Definition optiondlg.c:499
static int help_browser_callback(struct widget *pwidget)
Definition optiondlg.c:376
static int apply_callback(struct widget *widget)
Definition optiondlg.c:428
static void arrange_widgets(struct widget *window, int widgets_per_row, int rows_shown, struct widget *begin, struct widget *end,...)
Definition optiondlg.c:127
static void option_dialog_optset_category(struct option_dialog *pdialog, int category)
Definition optiondlg.c:1011
static void option_widget_update(struct option *poption)
Definition optiondlg.c:646
int optiondlg_callback(struct widget *pbutton)
Definition optiondlg.c:1345
static int option_category_callback(struct widget *widget)
Definition optiondlg.c:416
static struct strvec * video_mode_list(void)
Definition optiondlg.c:455
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ BACKGROUND_OPTIONDLG
@ COLOR_THEME_OPTIONDLG_WORKLISTLIST_FRAME
struct theme * active_theme
Definition themespec.c:154
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:863
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
void show_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:934
void hide_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:915
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
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)))
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *pwidget) fc__attribute((nonnull(2)))
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
static void widget_resize(struct widget *pwidget, int w, int h)
Definition widget.h:271
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
#define hide(id)
Definition widget.h:238
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define create_icon_button_from_chars_fonto(icon, pdest, char_string, fonto, flags)
void toggle_checkbox(struct widget *cbox)
bool get_checkbox_state(struct widget *cbox)
struct widget * create_checkbox(struct gui_layer *pdest, bool state, Uint32 flags)
void combo_popdown(struct widget *combo)
#define combo_new_from_chars_fonto(background, dest, fonto, char_string, vector, length, flags)
#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags)
Definition widget_edit.h:29
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
void remake_label_size(struct widget *label)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
#define hide_scrollbar(scrollbar)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
Definition wldlg.c:1055
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_error(message,...)
Definition log.h:103
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
const struct strvec * option_str_values(const struct option *poption)
Definition options.c:915
const struct option_set * server_optset
Definition options.c:4016
const char * option_description(const struct option *poption)
Definition options.c:638
const char * option_help_text(const struct option *poption)
Definition options.c:648
const char * option_enum_get_str(const struct option *poption)
Definition options.c:992
int option_number(const struct option *poption)
Definition options.c:618
int option_category(const struct option *poption)
Definition options.c:668
bool option_str_set(struct option *poption, const char *str)
Definition options.c:926
const struct option_set * client_optset
Definition options.c:1280
const char * option_name(const struct option *poption)
Definition options.c:628
int option_int_get(const struct option *poption)
Definition options.c:834
bool option_bool_set(struct option *poption, bool val)
Definition options.c:819
bool option_is_changeable(const struct option *poption)
Definition options.c:689
bool option_video_mode_set(struct option *poption, struct video_mode mode)
Definition options.c:1253
void option_set_gui_data(struct option *poption, void *data)
Definition options.c:767
const char * option_str_get(const struct option *poption)
Definition options.c:893
void * option_get_gui_data(const struct option *poption)
Definition options.c:777
const struct strvec * option_enum_values(const struct option *poption)
Definition options.c:1029
bool option_enum_set_int(struct option *poption, int val)
Definition options.c:1040
bool option_bool_get(const struct option *poption)
Definition options.c:797
int optset_category_number(const struct option_set *poptset)
Definition options.c:457
enum option_type option_type(const struct option *poption)
Definition options.c:658
bool video_mode_to_string(char *buf, size_t buf_len, struct video_mode *mode)
Definition options.c:6499
const struct option_set * option_optset(const struct option *poption)
Definition options.c:608
struct video_mode option_video_mode_get(const struct option *poption)
Definition options.c:1228
const char * optset_category_name(const struct option_set *poptset, int category)
Definition options.c:467
bool option_font_set(struct option *poption, const char *font)
Definition options.c:1174
void options_save(option_save_log_callback log_cb)
Definition options.c:6089
bool string_to_video_mode(const char *buf, struct video_mode *mode)
Definition options.c:6507
const char * option_font_get(const struct option *poption)
Definition options.c:1141
bool option_int_set(struct option *poption, int val)
Definition options.c:878
#define options_iterate(poptset, poption)
Definition options.h:550
#define options_iterate_end
Definition options.h:555
int len
Definition packhand.c:127
void set_client_page(enum client_pages page)
bool str_to_int(const char *str, int *pint)
Definition shared.c:517
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
void strvec_destroy(struct strvec *psv)
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
void strvec_append(struct strvec *psv, const char *string)
void strvec_reserve(struct strvec *psv, size_t reserve)
const char * strvec_get(const struct strvec *psv, size_t svindex)
struct strvec * strvec_new(void)
size_t strvec_size(const struct strvec *psv)
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
struct connection conn
Definition client_main.h:96
bool established
Definition connection.h:140
const struct option_set * poptset
Definition optiondlg.c:79
struct widget * widget_list
Definition optiondlg.c:80
struct widget * edited_name
Definition optiondlg.c:85
struct option_dialog_optset optset
Definition optiondlg.c:96
enum option_dialog_mode mode
Definition optiondlg.c:94
struct widget * main_widget_list
Definition optiondlg.c:91
struct option_dialog_worklist worklist
Definition optiondlg.c:97
struct widget * core_widget_list
Definition optiondlg.c:90
struct advanced_dialog * advanced
Definition optiondlg.c:93
struct widget * begin_widget_list
Definition optiondlg.c:92
const struct option_set * poptset
Definition optiondlg.c:42
struct widget * end_widget_list
Definition optiondlg.c:89
struct widget * up_left_button
struct gui_layer * gui
Definition graphics.h:215
SDL_Event event
Definition graphics.h:217
Uint8 style
Definition gui_string.h:53
char * text
Definition gui_string.h:60
int width
Definition options.h:47
union widget::@194 data
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
struct widget * widget
Definition widget.h:132
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
utf8_str * string_utf8
Definition widget.h:121
const struct strvec * vector
Definition widget.h:126
int(* action)(struct widget *)
Definition widget.h:157
SDL_Rect area
Definition widget.h:149
SDL_Surface * gfx
Definition widget.h:120
struct widget * next
Definition widget.h:113
void(* destroy)(struct widget *pwidget)
Definition widget.h:170
utf8_str * info_label
Definition widget.h:122
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_break_lines(char *str, size_t desired_len)
Definition support.c:1149
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47