Atrinik Client  4.0
settings_client.c
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
32 #include <global.h>
33 #include <toolkit/string.h>
34 #include <toolkit/colorspace.h>
35 
41 
45  struct {
50 
55  } text;
57 
61 static button_struct button_category_left, button_category_right, button_apply, button_done;
78 
88 static void setting_change_value(int cat, int set, int64_t val)
89 {
90  setting_struct *setting = setting_categories[cat]->settings[set];
91 
92  if (setting->type == OPT_TYPE_BOOL) {
93  setting_set_int(cat, set, !setting_get_int(cat, set));
94  } else if (setting->type == OPT_TYPE_SELECT || setting->type == OPT_TYPE_RANGE) {
95  int64_t old_val, new_val, advance;
96 
97  if (!val) {
98  return;
99  }
100 
101  new_val = old_val = setting_get_int(cat, set);
102  advance = 1;
103 
104  if (setting->type == OPT_TYPE_RANGE) {
105  advance = SETTING_RANGE(setting)->advance;
106  }
107 
108  new_val = old_val + (advance * val);
109 
110  if (setting->type == OPT_TYPE_SELECT) {
111  setting_select *s_select = SETTING_SELECT(setting);
112 
113  if (new_val >= (int64_t) s_select->options_len) {
114  new_val = 0;
115  } else if (new_val < 0) {
116  new_val = s_select->options_len - 1;
117  }
118  } else if (setting->type == OPT_TYPE_RANGE) {
119  setting_range *range = SETTING_RANGE(setting);
120 
121  new_val = MAX(range->min, MIN(range->max, new_val));
122  }
123 
124  setting_set_int(cat, set, new_val);
125  }
126 }
127 
136 {
137  uint32_t row;
138  setting_struct *setting;
139 
140  for (row = 0; row < list_settings->rows; row++) {
142 
143  if (setting->type == OPT_TYPE_INPUT_TEXT || setting->type == OPT_TYPE_COLOR) {
144  if (&((list_settings_graphic_union *) list_settings->data)[row].text.text_input == text_input) {
145  return row;
146  }
147  }
148  }
149 
150  return -1;
151 }
152 
155 {
156  uint32_t row;
157  setting_struct *setting;
158 
159  for (row = 0; row < list_settings->rows; row++) {
161 
162  if (setting->internal) {
163  break;
164  }
165 
166  if (setting->type == OPT_TYPE_BOOL) {
167  button_struct *button_checkbox;
168 
169  button_checkbox = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
170 
171  if (button == button_checkbox) {
173  break;
174  }
175  } else if (setting->type == OPT_TYPE_SELECT || setting->type == OPT_TYPE_RANGE) {
176  button_struct *button_left, *button_right;
177 
178  button_left = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
179  button_right = &((list_settings_graphic_union *) list_settings->data)[row].button[1];
180 
181  if (button == button_left) {
183  } else if (button == button_right) {
185  }
186  }
187  }
188 }
189 
193 static void settings_list_clear(void)
194 {
195  for (uint32_t row = 0; row < list_settings->rows; row++) {
196  setting_struct *setting =
198 
199  if (setting->internal) {
200  break;
201  }
202 
203  if (setting->type == OPT_TYPE_BOOL) {
205  list_settings->data)[row].button[0]);
206  } else if (setting->type == OPT_TYPE_SELECT ||
207  setting->type == OPT_TYPE_RANGE) {
209  list_settings->data)[row].button[0]);
211  list_settings->data)[row].button[1]);
212  } else if (setting->type == OPT_TYPE_INPUT_TEXT ||
213  setting->type == OPT_TYPE_COLOR) {
215  list_settings->data)[row].text.text_input);
216 
217  if (setting->type == OPT_TYPE_COLOR) {
219  list_settings->data)[row].text.button);
220  }
221  }
222  }
223 }
224 
228 static void settings_list_reload(void)
229 {
230  size_t i;
231  setting_struct *setting;
232 
233  text_input_focused = text_input_selected = NULL;
234  list_settings->data = ereallocz(list_settings->data, sizeof(list_settings_graphic_union) * list_settings->rows, sizeof(list_settings_graphic_union) * setting_categories[setting_category_selected]->settings_num);
235 
236  /* Clear all the rows. */
237  list_clear_rows(list_settings);
238 
241 
242  /* Internal, no need to go any further. */
243  if (setting->internal) {
244  break;
245  }
246 
247  list_add(list_settings, list_settings->rows, 0, NULL);
248 
249  if (setting->type == OPT_TYPE_BOOL) {
250  button_struct *button_checkbox;
251 
252  button_checkbox = &((list_settings_graphic_union *) list_settings->data)[i].button[0];
253  button_create(button_checkbox);
254  button_checkbox->texture = texture_get(TEXTURE_TYPE_SOFTWARE, "rectangle:15,15");
255  button_checkbox->texture_over = button_checkbox->texture_pressed = NULL;
256  button_checkbox->flags = TEXT_MARKUP;
257  button_checkbox->center = 0;
258  button_checkbox->color_shadow = button_checkbox->color_over_shadow = NULL;
259  } else if (setting->type == OPT_TYPE_SELECT || setting->type == OPT_TYPE_RANGE) {
260  button_struct *button_left, *button_right;
261 
262  button_left = &((list_settings_graphic_union *) list_settings->data)[i].button[0];
263  button_right = &((list_settings_graphic_union *) list_settings->data)[i].button[1];
264 
265  button_create(button_left);
266  button_create(button_right);
267  button_left->texture = button_right->texture = texture_get(TEXTURE_TYPE_CLIENT, "button_round");
268  button_left->texture_over = button_right->texture_over = texture_get(TEXTURE_TYPE_CLIENT, "button_round_over");
269  button_left->texture_pressed = button_right->texture_pressed = texture_get(TEXTURE_TYPE_CLIENT, "button_round_down");
270  button_left->repeat_func = button_right->repeat_func = settings_list_button_repeat;
271  } else if (setting->type == OPT_TYPE_INPUT_TEXT || setting->type == OPT_TYPE_COLOR) {
273 
274  text_input = &((list_settings_graphic_union *) list_settings->data)[i].text.text_input;
275  text_input_create(text_input);
276  text_input_set(text_input, setting_get_str(setting_category_selected, i));
277  text_input_set_font(text_input, FONT_ARIAL10);
278  text_input->coords.w = 100;
279  text_input->focus = 0;
280 
281  if (setting->type == OPT_TYPE_COLOR) {
282  button_struct *button;
283 
284  button = &((list_settings_graphic_union *) list_settings->data)[i].text.button;
285  button_create(button);
286  button->color_shadow = button->color_over_shadow = NULL;
287  button->texture = texture_get(TEXTURE_TYPE_SOFTWARE, "rectangle:40,14");
288  button->texture_over = button->texture_pressed = NULL;
289  }
290  }
291  }
292 
293  list_offsets_ensure(list_settings);
294 }
295 
297 static void list_post_column(list_struct *list, uint32_t row, uint32_t col)
298 {
299  setting_struct *setting;
300  int x, y, mx, my;
301 
303 
304  if (setting->internal) {
305  return;
306  }
307 
308  x = list->x + list->frame_offset;
309  y = LIST_ROWS_START(list) + (LIST_ROW_OFFSET(row, list) * LIST_ROW_HEIGHT(list));
310 
311  /* Show the actual setting name. */
312  text_show_shadow_format(list->surface, FONT_ARIAL11, x + 4, y + 3, list->row_selected == row + 1 ? COLOR_HGOLD : COLOR_WHITE, COLOR_BLACK, 0, NULL, "%s:", setting->name);
313 
314  SDL_GetMouseState(&mx, &my);
315 
316  if (setting->type == OPT_TYPE_BOOL) {
317  button_struct *button_checkbox;
318  SDL_Rect box;
319 
320  button_checkbox = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
321 
322  button_checkbox->surface = list->surface;
323  button_checkbox->x = x + list->width - texture_surface(button_checkbox->texture)->w - 2;
324  button_checkbox->y = y + 1;
325  button_checkbox->color = "8c7a7a";
326  button_checkbox->color_over = "b09a9a";
327  button_set_parent(button_checkbox, list->px, list->py);
328  button_show(button_checkbox, setting_get_int(setting_category_selected, row) ? "[x=1][y=1][c=#"COLOR_HGOLD "][line=0,0,12,12][line=12,0,0,12][/c]" : NULL);
329 
330  box.x = button_checkbox->x;
331  box.y = button_checkbox->y;
332  box.w = texture_surface(button_checkbox->texture)->w;
333  box.h = texture_surface(button_checkbox->texture)->h;
334 
335  if (button_checkbox->mouse_over) {
336  border_create_color(list->surface, &box, 1, "b09a9a");
337  } else {
338  border_create_color(list->surface, &box, 1, "8c7a7a");
339  }
340  } else if (setting->type == OPT_TYPE_SELECT || setting->type == OPT_TYPE_RANGE) {
341  button_struct *button_left, *button_right;
342  int64_t val;
343  SDL_Rect dst;
344 
345  button_left = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
346  button_right = &((list_settings_graphic_union *) list_settings->data)[row].button[1];
348 
349  dst.x = x + list->width - 1 - 150 - texture_surface(button_left->texture)->w;
350  dst.y = y + 1;
351  dst.w = 150;
352  dst.h = LIST_ROW_HEIGHT(list) - 2;
353 
354  SDL_FillRect(list->surface, &dst, SDL_MapRGB(list->surface->format, 0, 0, 0));
355 
356  if (setting->type == OPT_TYPE_SELECT) {
357  text_show(list->surface, FONT_ARIAL10, SETTING_SELECT(setting)->options[val], dst.x, dst.y, COLOR_WHITE, TEXT_ALIGN_CENTER, &dst);
358  } else if (setting->type == OPT_TYPE_RANGE) {
359  text_show_format(list->surface, FONT_ARIAL10, dst.x, dst.y, COLOR_WHITE, TEXT_ALIGN_CENTER, &dst, "%"PRId64, val);
360  }
361 
362  button_left->surface = list->surface;
363  button_left->x = dst.x - texture_surface(button_left->texture)->w - 1;
364  button_left->y = dst.y;
365  button_set_parent(button_left, list->px, list->py);
366  button_show(button_left, "<");
367 
368  button_right->surface = list->surface;
369  button_right->x = dst.x + dst.w;
370  button_right->y = dst.y;
371  button_set_parent(button_right, list->px, list->py);
372  button_show(button_right, ">");
373  } else if (setting->type == OPT_TYPE_INPUT_TEXT || setting->type == OPT_TYPE_COLOR) {
375  SDL_Rect dst;
376 
377  dst.x = x + list->width - 2;
378  dst.y = y + 2;
379 
380  if (setting->type == OPT_TYPE_COLOR) {
381  button_struct *button;
382  SDL_Color color;
383  SDL_Rect box;
384  char color_notation[COLOR_BUF];
385 
386  button = &((list_settings_graphic_union *) list_settings->data)[row].text.button;
387  dst.x -= texture_surface(button->texture)->w;
388  button_set_parent(button, list->px, list->py);
389  button->surface = list->surface;
390  button->x = dst.x;
391  button->y = dst.y;
392  button_show(button, NULL);
393 
395  snprintf(color_notation, sizeof(color_notation), "%.2X%.2X%.2X", 255 - color.r, 255 - color.g, 255 - color.b);
396  } else {
397  color.r = color.g = color.b = 0;
398  snprintf(color_notation, sizeof(color_notation), "%.2X%.2X%.2X", 255, 255, 255);
399  }
400 
401  box.w = texture_surface(button->texture)->w;
402  box.h = texture_surface(button->texture)->h;
403  text_show_format(list->surface, FONT_ARIAL11, button->x, button->y, COLOR_BLACK, TEXT_MARKUP, NULL, "[bar=#%.2X%.2X%.2X %d %d]", color.r, color.g, color.b, box.w, box.h);
404  text_show(list->surface, FONT_ARIAL11, "Pick", button->x, button->y, color_notation, TEXT_ALIGN_CENTER | TEXT_VALIGN_CENTER, &box);
405 
406  dst.x -= 5;
407  }
408 
409  text_input = &((list_settings_graphic_union *) list_settings->data)[row].text.text_input;
410  dst.x -= text_input->coords.w;
411  text_input->focus = text_input_focused == text_input;
412  text_input_set_parent(text_input, list->px, list->py);
413  text_input_show(text_input, list->surface, dst.x, dst.y - 1);
414  text_input->focus = 0;
415  }
416 }
417 
419 static void list_handle_enter(list_struct *list, SDL_Event *event)
420 {
421  uint32_t row;
422  setting_struct *setting;
423 
424  if (list->row_selected == 0) {
425  return;
426  }
427 
428  row = list->row_selected - 1;
430 
431  if (setting->type == OPT_TYPE_INPUT_TEXT ||
432  setting->type == OPT_TYPE_COLOR) {
433  list_settings_graphic_union *settings_graphic;
434 
435  settings_graphic = list_settings->data;
436  text_input_focused = &settings_graphic[row].text.text_input;
437  } else {
439  }
440 }
441 
443 static void list_handle_mouse_row(list_struct *list, uint32_t row, SDL_Event *event)
444 {
445  if (event->type == SDL_MOUSEMOTION) {
446  list->row_selected = row + 1;
447  }
448 }
449 
451 static void color_picker_callback(color_picker_struct *color_picker)
452 {
453  char color_notation[MAX_BUF];
454  double rgb[3];
455  int i;
456 
457  colorspace_hsv2rgb(color_picker->hsv, rgb);
458  snprintf(color_notation, sizeof(color_notation), "#%.2X%.2X%.2X", (int) (255 * rgb[0]), (int) (255 * rgb[1]), (int) (255 * rgb[2]));
459 
460  i = setting_find_by_text_input(text_input_selected);
461 
462  if (i != -1) {
463  text_input_set(text_input_selected, color_notation);
464  setting_set_str(setting_category_selected, i, color_notation);
465  }
466 }
467 
469 static void button_repeat(button_struct *button)
470 {
471  size_t new_cat;
472 
473  new_cat = setting_category_selected;
474 
475  if (button == &button_category_right) {
476  if (new_cat == setting_categories_num - 1) {
477  new_cat = 0;
478  } else {
479  new_cat++;
480  }
481  } else if (button == &button_category_left) {
482  if (new_cat == 0) {
483  new_cat = setting_categories_num - 1;
484  } else {
485  new_cat--;
486  }
487  }
488 
489  if (new_cat != setting_category_selected) {
491  setting_category_selected = new_cat;
493  }
494 }
495 
497 static int popup_draw(popup_struct *popup)
498 {
499  SDL_Rect box;
500  setting_struct *setting;
501 
502  box.w = popup->surface->w;
503  box.h = 38;
504  text_show(popup->surface, FONT_SERIF20, "Client Settings", 0, 0, COLOR_HGOLD, TEXT_ALIGN_CENTER | TEXT_VALIGN_CENTER, &box);
505 
506  list_show(list_settings, 30, 50);
507  list_set_parent(list_settings, popup->x, popup->y);
508 
509  setting = setting_categories[setting_category_selected]->settings[list_settings->row_selected - 1];
510 
511  box.w = list_settings->width;
512  box.h = 0;
513  text_show(popup->surface, FONT_SERIF14, setting_categories[setting_category_selected]->name, list_settings->x, list_settings->y - 3, COLOR_HGOLD, TEXT_ALIGN_CENTER, &box);
514 
515  button_set_parent(&button_category_left, popup->x, popup->y);
516  button_set_parent(&button_category_right, popup->x, popup->y);
517  button_set_parent(&button_apply, popup->x, popup->y);
518  button_set_parent(&button_done, popup->x, popup->y);
519 
520  button_category_left.x = list_settings->x;
521  button_category_left.y = 50;
522  button_show(&button_category_left, "<");
523 
524  button_category_right.x = list_settings->x + list_settings->width - texture_surface(button_category_right.texture)->w;
525  button_category_right.y = 50;
526  button_show(&button_category_right, ">");
527 
528  button_apply.x = list_settings->x + LIST_WIDTH_FULL(list_settings) - texture_surface(button_apply.texture)->w;
529  button_apply.y = popup->surface->h - 72;
530  button_show(&button_apply, "Apply");
531 
532  button_done.x = list_settings->x + LIST_WIDTH_FULL(list_settings) - texture_surface(button_done.texture)->w;
533  button_done.y = popup->surface->h - 50;
534  button_show(&button_done, "Done");
535 
536  if (setting->desc) {
537  box.w = LIST_WIDTH_FULL(list_settings) - texture_surface(button_apply.texture)->w;
538  box.h = 66;
539  text_show_shadow(popup->surface, FONT_ARIAL11, setting->desc, list_settings->x - 2, popup->surface->h - 75, COLOR_WHITE, COLOR_BLACK, TEXT_WORD_WRAP | TEXT_MARKUP, &box);
540  }
541 
542  return 1;
543 }
544 
546 static int popup_event(popup_struct *popup, SDL_Event *event)
547 {
548  uint32_t row;
549  setting_struct *setting;
550 
551  if (event->type == SDL_KEYDOWN) {
552  if (text_input_focused) {
553  text_input_focused->focus = 1;
554 
555  if (event->key.keysym.sym == SDLK_ESCAPE) {
556  text_input_focused = NULL;
557  return 1;
558  } else if (IS_ENTER(event->key.keysym.sym)) {
559  int i;
561 
562  i = setting_find_by_text_input(text_input_focused);
563 
564  if (i == -1) {
565  return 1;
566  }
567 
569  text_input = &((list_settings_graphic_union *) list_settings->data)[i].text.text_input;
570  text_input_focused = NULL;
571 
572  if (setting->type == OPT_TYPE_COLOR && !text_color_parse(text_input->str, NULL)) {
573  text_input_set(text_input, setting_get_str(setting_category_selected, i));
574  return 1;
575  }
576 
578  return 1;
579  } else if (text_input_event(text_input_focused, event)) {
580  return 1;
581  }
582  }
583 
584  if (event->key.keysym.sym == SDLK_ESCAPE) {
585  popup_destroy(popup);
586  return 1;
587  } else if (event->key.keysym.sym == SDLK_RIGHT) {
588  if (event->key.keysym.mod & KMOD_SHIFT) {
589  button_repeat(&button_category_right);
590  } else {
592  }
593 
594  return 1;
595  } else if (event->key.keysym.sym == SDLK_LEFT) {
596  if (event->key.keysym.mod & KMOD_SHIFT) {
597  button_repeat(&button_category_left);
598  } else {
600  }
601 
602  return 1;
603  }
604  }
605 
606  if (event->type == SDL_MOUSEBUTTONDOWN && event->button.button == SDL_BUTTON_LEFT) {
607  text_input_focused = NULL;
608  }
609 
610  for (row = 0; row < list_settings->rows; row++) {
612 
613  if (setting->internal) {
614  break;
615  }
616 
617  if (setting->type == OPT_TYPE_BOOL) {
618  button_struct *button_checkbox;
619 
620  button_checkbox = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
621 
622  if (button_event(button_checkbox, event)) {
623  settings_list_button_repeat(button_checkbox);
624  return 1;
625  }
626  } else if (setting->type == OPT_TYPE_SELECT || setting->type == OPT_TYPE_RANGE) {
627  button_struct *button_left, *button_right;
628 
629  button_left = &((list_settings_graphic_union *) list_settings->data)[row].button[0];
630  button_right = &((list_settings_graphic_union *) list_settings->data)[row].button[1];
631 
632  if (button_event(button_left, event)) {
633  settings_list_button_repeat(button_left);
634  return 1;
635  } else if (button_event(button_right, event)) {
636  settings_list_button_repeat(button_right);
637  return 1;
638  }
639  } else if (setting->type == OPT_TYPE_INPUT_TEXT || setting->type == OPT_TYPE_COLOR) {
641 
642  text_input = &((list_settings_graphic_union *) list_settings->data)[row].text.text_input;
643 
644  if (setting->type == OPT_TYPE_COLOR) {
645  button_struct *button;
646 
647  button = &((list_settings_graphic_union *) list_settings->data)[row].text.button;
648 
649  if (button_event(button, event)) {
650  color_picker_struct *color_picker;
651 
652  text_input_selected = text_input;
653 
654  color_picker = color_chooser_open();
655  color_picker->callback_func = color_picker_callback;
656  color_picker_set_notation(color_picker, setting_get_str(setting_category_selected, row));
657 
658  return 1;
659  }
660  }
661 
662  if ((event->type == SDL_MOUSEBUTTONDOWN && event->button.button == SDL_BUTTON_LEFT && text_input_mouse_over(text_input, event->motion.x, event->motion.y))) {
663  text_input_focused = text_input;
664  return 1;
665  }
666  }
667  }
668 
669  if (button_event(&button_category_left, event)) {
670  button_repeat(&button_category_left);
671  return 1;
672  } else if (button_event(&button_category_right, event)) {
673  button_repeat(&button_category_right);
674  return 1;
675  } else if (button_event(&button_apply, event)) {
677  return 1;
678  } else if (button_event(&button_done, event)) {
679  popup_destroy(popup);
680  return 1;
681  } else if (list_handle_keyboard(list_settings, event)) {
682  return 1;
683  } else if (list_handle_mouse(list_settings, event)) {
684  return 1;
685  }
686 
687  return -1;
688 }
689 
692 {
695  list_remove(list_settings);
696  list_settings = NULL;
697 
698  button_destroy(&button_category_left);
699  button_destroy(&button_category_right);
700  button_destroy(&button_apply);
701  button_destroy(&button_done);
702 
703  return 1;
704 }
705 
707 static int popup_button_event(popup_button *button)
708 {
709  help_show("client settings");
710  return 1;
711 }
712 
713 void settings_client_open(void)
714 {
715  popup_struct *popup;
716 
718 
719  popup = popup_create(texture_get(TEXTURE_TYPE_CLIENT, "popup"));
720  popup->draw_func = popup_draw;
721  popup->event_func = popup_event;
723 
725  popup_button_set_text(&popup->button_left, "?");
726 
727  button_create(&button_category_left);
728  button_create(&button_category_right);
729  button_create(&button_apply);
730  button_create(&button_done);
731 
732  button_category_left.texture = button_category_right.texture = texture_get(TEXTURE_TYPE_CLIENT, "button_round");
733  button_category_left.texture_over = button_category_right.texture_over = texture_get(TEXTURE_TYPE_CLIENT, "button_round_over");
734  button_category_left.texture_pressed = button_category_right.texture_pressed = texture_get(TEXTURE_TYPE_CLIENT, "button_round_down");
735  button_category_left.repeat_func = button_category_right.repeat_func = button_repeat;
736 
737  button_category_left.surface = button_category_right.surface = button_apply.surface = button_done.surface = popup->surface;
738 
739  list_settings = list_create(9, 1, 8);
740  list_settings->surface = popup->surface;
741  list_settings->post_column_func = list_post_column;
742  list_settings->row_highlight_func = NULL;
743  list_settings->row_selected_func = NULL;
744  list_settings->handle_enter_func = list_handle_enter;
746  list_set_column(list_settings, 0, 430, 7, NULL, -1);
747  list_set_font(list_settings, FONT_SANS14);
748  list_scrollbar_enable(list_settings);
750 }
static void settings_list_button_repeat(button_struct *button)
void(* row_selected_func)(struct list_struct *list, SDL_Rect box)
Definition: list.h:184
list_struct * list_create(uint32_t max_rows, uint32_t cols, int spacing)
Definition: list.c:113
void * data
Definition: list.h:147
#define COLOR_BLACK
Definition: text.h:323
#define TEXT_WORD_WRAP
Definition: text.h:226
int text_color_parse(const char *color_notation, SDL_Color *color)
Definition: text.c:603
int(* event_func)(struct popup_struct *popup, SDL_Event *event)
Definition: popup.h:148
int(* draw_func)(struct popup_struct *popup)
Definition: popup.h:127
int64_t min
Definition: settings.h:183
static text_input_struct * text_input_selected
void list_remove(list_struct *list)
Definition: list.c:522
static void button_repeat(button_struct *button)
static void settings_list_reload(void)
SDL_Surface * texture_surface(texture_struct *texture)
Definition: texture.c:303
int x
Definition: list.h:36
int button_event(button_struct *button, SDL_Event *event)
Definition: button.c:222
void list_set_column(list_struct *list, uint32_t col, int width, int spacing, const char *name, int centered)
Definition: list.c:242
int(* destroy_callback_func)(struct popup_struct *popup)
Definition: popup.h:159
uint8_t type
Definition: settings.h:215
SDL_Rect coords
Definition: text_input.h:96
void button_destroy(button_struct *button)
Definition: button.c:94
void settings_apply_change(void)
Definition: settings.c:572
int list_handle_mouse(list_struct *list, SDL_Event *event)
Definition: list.c:698
void text_show(SDL_Surface *surface, font_struct *font, const char *text, int x, int y, const char *color_notation, uint64_t flags, SDL_Rect *box)
Definition: text.c:1983
void list_add(list_struct *list, uint32_t row, uint32_t col, const char *str)
Definition: list.c:163
int16_t frame_offset
Definition: list.h:94
#define LIST_ROWS_START(list)
Definition: list.h:258
static void list_post_column(list_struct *list, uint32_t row, uint32_t col)
void setting_set_int(int cat, int setting, int64_t val)
Definition: settings.c:592
void setting_set_str(int cat, int setting, const char *val)
Definition: settings.c:616
int x
Definition: popup.h:87
#define COLOR_HGOLD
Definition: text.h:319
int y
Definition: list.h:39
static size_t setting_category_selected
static int setting_find_by_text_input(text_input_struct *text_input)
static text_input_struct text_input
Definition: interface.c:59
int px
Definition: list.h:45
static int popup_destroy_callback(popup_struct *popup)
texture_struct * texture_get(texture_type_t type, const char *name)
Definition: texture.c:279
const char * color_shadow
Definition: button.h:90
int py
Definition: list.h:51
void(* repeat_func)(struct button_struct *button)
Definition: button.h:127
#define TEXT_MARKUP
Definition: text.h:224
#define LIST_ROW_HEIGHT(list)
Definition: list.h:256
text_input_struct text_input
#define TEXT_ALIGN_CENTER
Definition: text.h:230
void(* handle_mouse_row_func)(struct list_struct *list, uint32_t row, SDL_Event *event)
Definition: list.h:252
static list_struct * list_settings
void help_show(const char *name)
Definition: help.c:219
#define LIST_ROW_OFFSET(row, list)
Definition: list.h:267
struct list_settings_graphic_union::@3 text
void list_clear_rows(list_struct *list)
Definition: list.c:457
static void list_handle_enter(list_struct *list, SDL_Event *event)
void text_show_shadow_format(SDL_Surface *surface, font_struct *font, int x, int y, const char *color_notation, const char *color_shadow_notation, uint64_t flags, SDL_Rect *box, const char *format,...)
Definition: text.c:2305
static void color_picker_callback(color_picker_struct *color_picker)
void list_offsets_ensure(list_struct *list)
Definition: list.c:501
setting_category ** setting_categories
Definition: settings.c:43
char * desc
Definition: settings.h:212
static int popup_button_event(popup_button *button)
texture_struct * texture_over
Definition: button.h:67
const char * color_over_shadow
Definition: button.h:96
size_t setting_categories_num
Definition: settings.c:45
#define LIST_WIDTH_FULL(list)
Definition: list.h:276
static void settings_list_clear(void)
int64_t setting_get_int(int cat, int setting)
Definition: settings.c:414
int(* event_func)(struct popup_button *button)
Definition: popup.h:56
void button_create(button_struct *button)
Definition: button.c:65
void text_show_shadow(SDL_Surface *surface, font_struct *font, const char *text, int x, int y, const char *color_notation, const char *color_shadow_notation, uint64_t flags, SDL_Rect *box)
Definition: text.c:2278
void(* row_highlight_func)(struct list_struct *list, SDL_Rect box)
Definition: list.h:175
setting_struct ** settings
Definition: settings.h:241
color_picker_struct * color_chooser_open(void)
Definition: color_chooser.c:75
texture_struct * texture
Definition: button.h:61
void(* post_column_func)(struct list_struct *list, uint32_t row, uint32_t col)
Definition: list.h:239
char str[HUGE_BUF]
Definition: text_input.h:55
int width
Definition: list.h:54
const char * setting_get_str(int cat, int setting)
Definition: settings.c:400
int list_handle_keyboard(list_struct *list, SDL_Event *event)
Definition: list.c:622
SDL_Surface * surface
Definition: list.h:138
int y
Definition: popup.h:90
SDL_Surface * surface
Definition: button.h:46
popup_button button_left
Definition: popup.h:93
uint8_t center
Definition: button.h:84
texture_struct * texture_pressed
Definition: button.h:73
void list_set_font(list_struct *list, font_struct *font)
Definition: list.c:284
void list_show(list_struct *list, int x, int y)
Definition: list.c:337
char * name
Definition: settings.h:209
uint8_t internal
Definition: settings.h:218
void list_set_parent(list_struct *list, int px, int py)
Definition: list.c:96
SDL_Surface * surface
Definition: popup.h:65
#define SETTING_RANGE(_setting)
Definition: settings.h:250
void text_show_format(SDL_Surface *surface, font_struct *font, int x, int y, const char *color_notation, uint64_t flags, SDL_Rect *box, const char *format,...)
Definition: text.c:2289
#define SETTING_SELECT(_setting)
Definition: settings.h:248
void border_create_color(SDL_Surface *surface, SDL_Rect *coords, int thickness, const char *color_notation)
Definition: sprite.c:1359
static int popup_event(popup_struct *popup, SDL_Event *event)
static int popup_draw(popup_struct *popup)
void list_scrollbar_enable(list_struct *list)
Definition: list.c:302
size_t settings_num
Definition: settings.h:244
int64_t max
Definition: settings.h:186
const char * color_over
Definition: button.h:93
void button_show(button_struct *button, const char *text)
Definition: button.c:161
#define TEXT_VALIGN_CENTER
Definition: text.h:246
uint64_t flags
Definition: button.h:79
static void setting_change_value(int cat, int set, int64_t val)
uint32_t rows
Definition: list.h:60
void(* handle_enter_func)(struct list_struct *list, SDL_Event *event)
Definition: list.h:201
void text_input_destroy(text_input_struct *text_input)
Definition: text_input.c:96
uint32_t row_selected
Definition: list.h:109
#define COLOR_WHITE
Definition: text.h:289
static void list_handle_mouse_row(list_struct *list, uint32_t row, SDL_Event *event)
int mouse_over
Definition: button.h:99
static text_input_struct * text_input_focused
size_t options_len
Definition: settings.h:201
const char * color
Definition: button.h:87
static button_struct button_category_left