Atrinik Client  4.0
interface.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/packet.h>
34 #include <toolkit/string.h>
35 
51 static const char character_shortcuts[] = "123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM{}<>/?~!@#$%^&*()";
60 
67 {
68  if (!data) {
69  return;
70  }
71 
72  if (data->message) {
73  efree(data->message);
74  }
75 
76  if (data->title) {
77  efree(data->title);
78  }
79 
80  if (data->icon) {
81  efree(data->icon);
82  }
83 
84  if (data->text_input_prepend) {
85  efree(data->text_input_prepend);
86  }
87 
88  if (data->text_autocomplete) {
89  efree(data->text_autocomplete);
90  }
91 
92  if (data->anim != NULL) {
93  object_remove(data->anim);
94  }
95 
96  object_remove(data->objects);
97  cpl.interface = NULL;
98 
99  utarray_free(data->links);
100  font_free(data->font);
101  efree(data);
102 }
103 
105 static int text_anchor_handle(const char *anchor_action, const char *buf, size_t len, void *custom_data)
106 {
107  if (anchor_action[0] == '\0' && buf[0] != '/') {
108  if (!interface_data->progressed || SDL_GetTicks() >= interface_data->progressed_ticks) {
109  StringBuffer *sb = stringbuffer_new();
110  char *cp;
111 
112  stringbuffer_append_printf(sb, "/talk 1 %s", buf);
113  cp = stringbuffer_finish(sb);
114  send_command_check(cp);
115  efree(cp);
116 
117  interface_data->progressed = 1;
118  interface_data->progressed_ticks = SDL_GetTicks() + INTERFACE_PROGRESSED_TICKS;
119  }
120 
121  return 1;
122  } else if (!strcmp(anchor_action, "close")) {
123  interface_data->destroy = 1;
124  return 1;
125  }
126 
127  return 0;
128 }
129 
130 static void interface_execute_link(size_t link_id)
131 {
132  char **p;
133  text_info_struct info;
134 
135  p = (char **) utarray_eltptr(interface_data->links, link_id);
136 
137  if (!p) {
138  return;
139  }
140 
141  text_anchor_parse(&info, *p);
143  text_anchor_execute(&info, NULL);
145 }
146 
148 static int popup_draw_func(popup_struct *popup)
149 {
150  if (interface_data->anim != NULL &&
151  SDL_GetTicks() - interface_data->last_anim > 125) {
152  interface_data->last_anim = SDL_GetTicks();
153 
154  if (object_animate(interface_data->anim)) {
155  popup->redraw = 1;
156  }
157  }
158 
159  if (popup->redraw) {
160  SDL_Rect box;
161 
162  surface_show(popup->surface, 0, 0, NULL, texture_surface(popup->texture));
163 
164  if (interface_data->icon != NULL) {
165  text_show_format(popup->surface, FONT_ARIAL10,
167  TEXT_MARKUP, NULL, "[icon=%s %d %d]", interface_data->icon,
169  } else if (interface_data->anim != NULL) {
170  image_request_face(interface_data->anim->face);
171  object_show_centered(popup->surface, interface_data->anim,
174  }
175 
176  box.w = INTERFACE_TITLE_WIDTH;
177  box.h = FONT_HEIGHT(FONT_SERIF14);
178  text_show(popup->surface, FONT_SERIF14, interface_data->title, INTERFACE_TITLE_STARTX, INTERFACE_TITLE_STARTY + INTERFACE_TITLE_HEIGHT / 2 - box.h / 2, COLOR_HGOLD, TEXT_MARKUP | TEXT_WORD_WRAP, &box);
179 
180  box.w = INTERFACE_TEXT_WIDTH;
181  box.h = INTERFACE_TEXT_HEIGHT;
182  box.x = 0;
183  box.y = interface_data->scroll_offset;
187  text_set_selection(NULL, NULL, NULL);
189 
190  popup->redraw = 0;
191  }
192 
193  return !interface_data->destroy;
194 }
195 
198 {
199  scrollbar_show(&interface_data->scrollbar, ScreenSurface, popup->x + 432, popup->y + 71);
200 
201  button_hello.x = popup->x + INTERFACE_BUTTON_HELLO_STARTX;
202  button_hello.y = popup->y + INTERFACE_BUTTON_HELLO_STARTY;
203  button_show(&button_hello, "Hello");
204 
205  button_close.x = popup->x + INTERFACE_BUTTON_CLOSE_STARTX;
206  button_close.y = popup->y + INTERFACE_BUTTON_CLOSE_STARTY;
207  button_show(&button_close, "Close");
208 
209  if (interface_data->text_input) {
210  text_input_show(&text_input, ScreenSurface, popup->x + popup->surface->w / 2 - text_input.coords.w / 2, popup->y + popup->surface->h - text_input.coords.h - 15);
211  }
212 
213  surface_show(ScreenSurface, popup->x, popup->y, NULL, TEXTURE_CLIENT("interface_border"));
214  return 1;
215 }
216 
219 {
220  interface_destroy(interface_data);
221  interface_data = NULL;
222  interface_popup = NULL;
223 
224  button_destroy(&button_hello);
225  button_destroy(&button_close);
226 
227  packet_struct *packet = packet_new(SERVER_CMD_TALK, 32, 0);
228  packet_append_uint8(packet, CMD_TALK_CLOSE);
229  socket_send_packet(packet);
230 
231  return 1;
232 }
233 
236 {
237  help_show("npc interface");
238  return 1;
239 }
240 
244 static void button_hello_event(void)
245 {
246  if (!interface_data->progressed || SDL_GetTicks() >= interface_data->progressed_ticks) {
247  keybind_process_command("?HELLO");
248  interface_data->progressed = 1;
249  interface_data->progressed_ticks = SDL_GetTicks() + INTERFACE_PROGRESSED_TICKS;
250  }
251 }
252 
254 static int popup_event_func(popup_struct *popup, SDL_Event *event)
255 {
256  if (scrollbar_event(&interface_data->scrollbar, event)) {
257  return 1;
258  } else if (button_event(&button_hello, event)) {
260  return 1;
261  } else if (button_event(&button_close, event)) {
262  popup_destroy(popup);
263  return 1;
264  } else if (event->type == SDL_KEYDOWN) {
265  if (interface_data->text_input) {
266  if (event->key.keysym.sym == SDLK_ESCAPE) {
267  interface_data->text_input = 0;
268  return 1;
269  } else if (IS_ENTER(event->key.keysym.sym) || (event->key.keysym.sym == SDLK_TAB && interface_data->text_autocomplete && !string_iswhite(text_input.str) && text_input.pos == text_input.num)) {
270  char *input_string;
271 
272  input_string = estrdup(text_input.str);
273 
274  if (!interface_data->input_cleanup_disable) {
275  string_whitespace_squeeze(input_string);
276  string_whitespace_trim(input_string);
277  }
278 
279  if (*input_string != '\0' || interface_data->input_allow_empty) {
280  StringBuffer *sb;
281  char *cp;
282 
283  sb = stringbuffer_new();
284 
285  if (!interface_data->text_input_prepend || interface_data->text_input_prepend[0] != '/') {
286  stringbuffer_append_string(sb, "/talk 1 ");
287  }
288 
289  if (interface_data->text_input_prepend) {
290  stringbuffer_append_string(sb, interface_data->text_input_prepend);
291  }
292 
293  if (event->key.keysym.sym == SDLK_TAB) {
294  stringbuffer_append_string(sb, interface_data->text_autocomplete);
295  }
296 
297  stringbuffer_append_string(sb, input_string);
298 
299  cp = stringbuffer_finish(sb);
300  send_command_check(cp);
301  efree(cp);
302  }
303 
304  efree(input_string);
305 
306  if (event->key.keysym.sym != SDLK_TAB) {
307  interface_data->text_input = 0;
308  }
309  } else if (event->key.keysym.sym == SDLK_TAB && interface_data->allow_tab) {
310  text_input_add_char(&text_input, '\t');
311  }
312 
313  if (text_input_event(&text_input, event)) {
314  return 1;
315  }
316  }
317 
318  switch (event->key.keysym.sym) {
319  case SDLK_DOWN:
320  scrollbar_scroll_adjust(&interface_data->scrollbar, 1);
321  return 1;
322 
323  case SDLK_UP:
324  scrollbar_scroll_adjust(&interface_data->scrollbar, -1);
325  return 1;
326 
327  case SDLK_PAGEDOWN:
328  scrollbar_scroll_adjust(&interface_data->scrollbar, interface_data->scrollbar.max_lines);
329  return 1;
330 
331  case SDLK_PAGEUP:
332  scrollbar_scroll_adjust(&interface_data->scrollbar, -interface_data->scrollbar.max_lines);
333  return 1;
334 
335  case SDLK_RETURN:
336  case SDLK_KP_ENTER:
337  interface_data->text_input = 1;
338  text_input_reset(&text_input);
339  return 1;
340 
341  default:
342 
343  if (!keys[event->key.keysym.sym].repeated) {
344  char c;
345  size_t i, len, links_len;
346 
347  if (event->key.keysym.sym >= SDLK_KP0 && event->key.keysym.sym <= SDLK_KP9) {
348  c = '0' + event->key.keysym.sym - SDLK_KP0;
349  } else {
350  c = event->key.keysym.unicode & 0xff;
351  }
352 
353  len = strlen(character_shortcuts);
354  links_len = utarray_len(interface_data->links);
355 
356  for (i = 0; i < len && i < links_len; i++) {
357  if (c == character_shortcuts[i]) {
358  interface_execute_link(i);
359  return 1;
360  }
361  }
362  }
363 
364  break;
365  }
366 
367  if (keybind_command_matches_event("?HELLO", &event->key) && !keys[event->key.keysym.sym].repeated) {
369  return 1;
370  }
371  } else if (event->type == SDL_MOUSEBUTTONDOWN && event->motion.x >= popup->x && event->motion.x < popup->x + popup->surface->w && event->motion.y >= popup->y && event->motion.y < popup->y + popup->surface->h) {
372  if (event->button.button == SDL_BUTTON_WHEELDOWN) {
373  scrollbar_scroll_adjust(&interface_data->scrollbar, 1);
374  return 1;
375  } else if (event->button.button == SDL_BUTTON_WHEELUP) {
376  scrollbar_scroll_adjust(&interface_data->scrollbar, -1);
377  return 1;
378  }
379  }
380 
381  return -1;
382 }
383 
385 static const char *popup_clipboard_copy_func(popup_struct *popup)
386 {
387  return interface_data->message;
388 }
389 
391 void socket_command_interface(uint8_t *data, size_t len, size_t pos)
392 {
393  uint8_t scroll_bottom = 0, type;
394  StringBuffer *sb_message;
395  SDL_Rect box;
396  interface_struct *old_interface_data;
397 
398  if (len == pos) {
399  if (interface_data) {
400  interface_data->destroy = 1;
401  }
402 
403  return;
404  }
405 
406  if (!interface_popup) {
407  interface_popup = popup_create(texture_get(TEXTURE_TYPE_CLIENT, "interface"));
408  interface_popup->draw_func = popup_draw_func;
409  interface_popup->draw_post_func = popup_draw_post_func;
411  interface_popup->event_func = popup_event_func;
413  interface_popup->disable_texture_drawing = 1;
414 
416  interface_popup->button_left.x = 380;
417  interface_popup->button_left.y = 4;
418  popup_button_set_text(&interface_popup->button_left, "?");
419 
420  interface_popup->button_right.x = 411;
421  interface_popup->button_right.y = 4;
422  } else {
423  button_destroy(&button_hello);
424  button_destroy(&button_close);
425  }
426 
427  if (!text_input_history) {
428  text_input_history = text_input_history_create();
429  text_input_create(&text_input);
430  text_input_set_history(&text_input, text_input_history);
431  }
432 
433  old_interface_data = interface_data;
434  sb_message = NULL;
435 
436  /* Create new interface. */
437  interface_data = ecalloc(1, sizeof(*interface_data));
438  interface_popup->redraw = 1;
439  interface_popup->selection_start = interface_popup->selection_end = -1;
440  interface_data->font = font_get("arial", 11);
441  interface_data->objects = object_create(NULL, 0, 0);
442  utarray_new(interface_data->links, &ut_str_icd);
443 
444  /* Parse the data. */
445  while (pos < len) {
446  type = packet_to_uint8(data, len, &pos);
447 
448  switch (type) {
449  case CMD_INTERFACE_TEXT:
450 
451  if (!sb_message) {
452  sb_message = stringbuffer_new();
453  }
454 
455  packet_to_stringbuffer(data, len, &pos, sb_message);
456  break;
457 
458  case CMD_INTERFACE_LINK:
459  {
460  char interface_link[HUGE_BUF], *cp;
461 
462  packet_to_string(data, len, &pos, interface_link, sizeof(interface_link));
463  cp = interface_link;
464  utarray_push_back(interface_data->links, &cp);
465  break;
466  }
467 
468  case CMD_INTERFACE_ICON:
469  {
470  char icon[MAX_BUF];
471 
472  packet_to_string(data, len, &pos, icon, sizeof(icon));
473  interface_data->icon = estrdup(icon);
474  break;
475  }
476 
477  case CMD_INTERFACE_TITLE:
478  {
479  char title[HUGE_BUF];
480 
481  packet_to_string(data, len, &pos, title, sizeof(title));
482  interface_data->title = estrdup(title);
483  break;
484  }
485 
486  case CMD_INTERFACE_INPUT:
487  {
488  char text_input_content[HUGE_BUF];
489 
490  interface_data->text_input = 1;
491  packet_to_string(data, len, &pos, text_input_content, sizeof(text_input_content));
492  text_input_reset(&text_input);
493  text_input_set(&text_input, text_input_content);
494  break;
495  }
496 
497  case CMD_INTERFACE_INPUT_PREPEND:
498  {
499  if (interface_data->text_input_prepend != NULL) {
500  efree(interface_data->text_input_prepend);
501  }
502 
503  char text_input_prepend[HUGE_BUF];
504 
505  packet_to_string(data, len, &pos, text_input_prepend, sizeof(text_input_prepend));
506  interface_data->text_input_prepend = estrdup(text_input_prepend);
507  break;
508  }
509 
510  case CMD_INTERFACE_ALLOW_TAB:
511  interface_data->allow_tab = 1;
512  break;
513 
514  case CMD_INTERFACE_INPUT_CLEANUP_DISABLE:
515  interface_data->input_cleanup_disable = 1;
516  break;
517 
518  case CMD_INTERFACE_INPUT_ALLOW_EMPTY:
519  interface_data->input_allow_empty = 1;
520  break;
521 
522  case CMD_INTERFACE_SCROLL_BOTTOM:
523  scroll_bottom = 1;
524  break;
525 
526  case CMD_INTERFACE_AUTOCOMPLETE:
527  {
528  if (interface_data->text_autocomplete != NULL) {
529  efree(interface_data->text_autocomplete);
530  }
531 
532  char text_autocomplete[HUGE_BUF];
533 
534  packet_to_string(data, len, &pos, text_autocomplete, sizeof(text_autocomplete));
535  interface_data->text_autocomplete = estrdup(text_autocomplete);
536  break;
537  }
538 
539  case CMD_INTERFACE_RESTORE:
540 
541  if (old_interface_data) {
542  interface_destroy(interface_data);
543  interface_data = old_interface_data;
544  }
545 
546  break;
547 
548  case CMD_INTERFACE_APPEND_TEXT:
549 
550  if (interface_data->message) {
551  StringBuffer *sb;
552 
553  sb = stringbuffer_new();
554  stringbuffer_append_string(sb, interface_data->message);
555  packet_to_stringbuffer(data, len, &pos, sb);
556 
557  efree(interface_data->message);
558  interface_data->message = stringbuffer_finish(sb);
559  }
560 
561  break;
562 
563  case CMD_INTERFACE_ANIM:
564  {
565  interface_data->anim = object_create(NULL, 0, 0);
566  interface_data->anim->animation_id = packet_to_uint16(data, len,
567  &pos);
568  interface_data->anim->anim_speed = packet_to_uint8(data, len, &pos);
569  interface_data->anim->direction = packet_to_uint8(data, len, &pos);
570  interface_data->anim->last_anim = interface_data->anim->anim_speed;
571  break;
572  }
573 
574  case CMD_INTERFACE_OBJECT:
575  {
576  uint16_t flags = packet_to_uint16(data, len, &pos);
577  tag_t tag = packet_to_uint32(data, len, &pos);
578  object *old_obj = object_find(tag);
579  object *obj = object_create(interface_data->objects, tag, 0);
580  command_item_update(data, len, &pos, flags, obj);
581 
582  if (old_obj != NULL && old_obj->env != cpl.interface) {
583  object_remove(obj);
584  }
585 
586  break;
587  }
588 
589  default:
590  break;
591  }
592  }
593 
594  if (sb_message) {
595  size_t links_len, char_shortcuts_len, i;
596 
597  links_len = utarray_len(interface_data->links);
598 
599  if (links_len) {
600  stringbuffer_append_string(sb_message, "\n");
601  }
602 
603  char_shortcuts_len = strlen(character_shortcuts);
604 
605  for (i = 0; i < links_len; i++) {
606  stringbuffer_append_string(sb_message, "\n");
607 
608  if (i < char_shortcuts_len) {
609  stringbuffer_append_printf(sb_message, "[c=#AF7817]&lsqb;%c&rsqb;[/c] ", character_shortcuts[i]);
610  }
611 
612  stringbuffer_append_string(sb_message, *((char **) utarray_eltptr(interface_data->links, i)));
613  }
614 
615  interface_data->message = stringbuffer_finish(sb_message);
616  }
617 
618  if (!interface_data->message) {
619  interface_data->message = estrdup("");
620  }
621 
622  box.w = INTERFACE_TEXT_WIDTH;
623  box.h = INTERFACE_TEXT_HEIGHT;
625  interface_data->num_lines = box.h;
626 
627  scrollbar_create(&interface_data->scrollbar, 11, 434, &interface_data->scroll_offset, &interface_data->num_lines, box.y);
628  interface_data->scrollbar.redraw = &interface_popup->redraw;
629 
630  if (scroll_bottom) {
631  interface_data->scroll_offset = interface_data->num_lines - box.y;
632  }
633 
634  button_create(&button_hello);
635  button_create(&button_close);
636 
637  button_hello.texture = button_close.texture = texture_get(TEXTURE_TYPE_CLIENT, "button_large");
638  button_hello.texture_over = button_close.texture_over = texture_get(TEXTURE_TYPE_CLIENT, "button_large_over");
639  button_hello.texture_pressed = button_close.texture_pressed = texture_get(TEXTURE_TYPE_CLIENT, "button_large_down");
640  button_set_font(&button_hello, FONT_ARIAL13);
641  button_set_font(&button_close, FONT_ARIAL13);
642 
643  /* Destroy previous interface data. */
644  if (interface_data != old_interface_data) {
645  interface_destroy(old_interface_data);
646  }
647 
648  cpl.interface = interface_data->objects;
649 }
650 
655 {
656  if (interface_popup) {
657  interface_popup->redraw = 1;
658  }
659 }
660 
665 {
666  if (text_input_history != NULL) {
667  text_input_history_free(text_input_history);
668  text_input_destroy(&text_input);
669  }
670 }
#define INTERFACE_PROGRESSED_TICKS
Definition: interface.h:172
static void button_hello_event(void)
Definition: interface.c:244
Definition: item.h:43
static int popup_destroy_callback(popup_struct *popup)
Definition: interface.c:218
#define TEXT_WORD_WRAP
Definition: text.h:226
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
void text_set_selection(int64_t *start, int64_t *end, uint8_t *started)
Definition: text.c:425
#define TEXT_LINES_SKIP
Definition: text.h:263
static button_struct button_hello
Definition: interface.c:47
static button_struct button_close
Definition: updater.c:111
uint16_t animation_id
Definition: item.h:75
uint8_t text_input
Definition: interface.h:87
int(* draw_post_func)(struct popup_struct *popup)
Definition: popup.h:137
SDL_Surface * texture_surface(texture_struct *texture)
Definition: texture.c:303
#define INTERFACE_TEXT_WIDTH
Definition: interface.h:134
#define INTERFACE_TEXT_HEIGHT
Definition: interface.h:136
int button_event(button_struct *button, SDL_Event *event)
Definition: button.c:222
object * object_create(object *env, tag_t tag, int bflag)
Definition: item.c:327
int16_t face
Definition: item.h:72
int(* destroy_callback_func)(struct popup_struct *popup)
Definition: popup.h:159
SDL_Rect coords
Definition: text_input.h:96
int y
Definition: popup.h:41
void button_destroy(button_struct *button)
Definition: button.c:94
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
static const char character_shortcuts[]
Definition: interface.c:51
font_struct * font
Definition: interface.h:50
static void interface_destroy(interface_struct *data)
Definition: interface.c:66
#define INTERFACE_TITLE_STARTY
Definition: interface.h:146
uint32_t num_lines
Definition: interface.h:62
UT_array * links
Definition: interface.h:53
int x
Definition: popup.h:87
#define COLOR_HGOLD
Definition: text.h:319
scrollbar_struct scrollbar
Definition: interface.h:65
uint32_t scroll_offset
Definition: interface.h:59
#define INTERFACE_TITLE_HEIGHT
Definition: interface.h:150
object * objects
Definition: interface.h:103
static text_input_struct text_input
Definition: interface.c:59
texture_struct * texture_get(texture_type_t type, const char *name)
Definition: texture.c:279
void font_free(font_struct *font)
Definition: text.c:262
font_struct * font_get(const char *name, uint8_t size)
Definition: text.c:216
#define INTERFACE_BUTTON_HELLO_STARTX
Definition: interface.h:158
static int popup_button_event_func(popup_button *button)
Definition: interface.c:235
SDL_Surface * ScreenSurface
Definition: main.c:47
uint8_t input_cleanup_disable
Definition: interface.h:81
#define TEXT_MARKUP
Definition: text.h:224
int object_animate(object *ob)
Definition: item.c:442
uint32_t max_lines
Definition: scrollbar.h:77
const char *(* clipboard_copy_func)(struct popup_struct *popup)
Definition: popup.h:168
#define INTERFACE_TITLE_WIDTH
Definition: interface.h:148
uint8_t direction
Definition: item.h:106
void scrollbar_show(scrollbar_struct *scrollbar, SDL_Surface *surface, int x, int y)
Definition: scrollbar.c:443
void help_show(const char *name)
Definition: help.c:219
uint8_t redraw
Definition: popup.h:114
void image_request_face(int pnum)
Definition: image.c:402
uint8_t progressed
Definition: interface.h:68
uint32_t last_anim
Definition: interface.h:108
static interface_struct * interface_data
Definition: interface.c:39
uint8_t input_allow_empty
Definition: interface.h:84
#define INTERFACE_TEXT_STARTX
Definition: interface.h:130
#define INTERFACE_TEXT_STARTY
Definition: interface.h:132
#define INTERFACE_ICON_STARTY
Definition: interface.h:118
Client_Player cpl
Definition: client.c:50
void text_set_anchor_handle(text_anchor_handle_func func)
Definition: text.c:437
struct obj * env
Definition: item.h:54
#define INTERFACE_BUTTON_CLOSE_STARTX
Definition: interface.h:163
uint32_t progressed_ticks
Definition: interface.h:75
void button_set_font(button_struct *button, font_struct *font)
Definition: button.c:114
texture_struct * texture_over
Definition: button.h:67
uint8_t selection_started
Definition: popup.h:111
uint8_t destroy
Definition: interface.h:56
uint16_t last_anim
Definition: item.h:84
int(* event_func)(struct popup_button *button)
Definition: popup.h:56
void button_create(button_struct *button)
Definition: button.c:65
void interface_deinit(void)
Definition: interface.c:664
char * message
Definition: interface.h:38
#define FONT_HEIGHT(font)
Definition: text.h:327
object * interface
Definition: player.h:120
char * text_input_prepend
Definition: interface.h:47
static int popup_event_func(popup_struct *popup, SDL_Event *event)
Definition: interface.c:254
void scrollbar_scroll_adjust(scrollbar_struct *scrollbar, int adjust)
Definition: scrollbar.c:427
void scrollbar_create(scrollbar_struct *scrollbar, int w, int h, uint32_t *scroll_offset, uint32_t *num_lines, uint32_t max_lines)
Definition: scrollbar.c:350
void text_anchor_execute(text_info_struct *info, void *custom_data)
Definition: text.c:632
static text_input_history_struct * text_input_history
Definition: interface.c:55
static int popup_draw_post_func(popup_struct *popup)
Definition: interface.c:197
char * text_autocomplete
Definition: interface.h:93
static int text_anchor_handle(const char *anchor_action, const char *buf, size_t len, void *custom_data)
Definition: interface.c:105
#define INTERFACE_BUTTON_HELLO_STARTY
Definition: interface.h:160
texture_struct * texture
Definition: button.h:61
void text_anchor_parse(text_info_struct *info, const char *text)
Definition: text.c:2471
char str[HUGE_BUF]
Definition: text_input.h:55
int keybind_command_matches_event(const char *cmd, SDL_KeyboardEvent *event)
Definition: keybind.c:391
uint8_t allow_tab
Definition: interface.h:78
#define INTERFACE_ICON_HEIGHT
Definition: interface.h:122
int y
Definition: popup.h:90
uint8_t * redraw
Definition: scrollbar.h:87
popup_button button_left
Definition: popup.h:93
static const char * popup_clipboard_copy_func(popup_struct *popup)
Definition: interface.c:385
object * object_find(tag_t tag)
Definition: item.c:139
object * anim
Definition: interface.h:98
texture_struct * texture_pressed
Definition: button.h:73
int x
Definition: popup.h:38
uint16_t anim_speed
Definition: item.h:78
#define INTERFACE_TITLE_STARTX
Definition: interface.h:144
int send_command_check(const char *cmd)
Definition: menu.c:376
void surface_show(SDL_Surface *surface, int x, int y, SDL_Rect *srcrect, SDL_Surface *src)
Definition: sprite.c:761
int scrollbar_event(scrollbar_struct *scrollbar, SDL_Event *event)
Definition: scrollbar.c:529
uint8_t repeated
Definition: event.h:56
popup_button button_right
Definition: popup.h:96
static popup_struct * interface_popup
Definition: interface.c:43
void object_remove(object *op)
Definition: item.c:174
static int popup_draw_func(popup_struct *popup)
Definition: interface.c:148
#define INTERFACE_ICON_STARTX
Definition: interface.h:116
#define TEXT_LINES_CALC
Definition: text.h:259
SDL_Surface * surface
Definition: popup.h:65
int64_t selection_end
Definition: popup.h:108
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
void socket_command_interface(uint8_t *data, size_t len, size_t pos)
Definition: interface.c:391
#define INTERFACE_ICON_WIDTH
Definition: interface.h:120
#define INTERFACE_BUTTON_CLOSE_STARTY
Definition: interface.h:165
void object_show_centered(SDL_Surface *surface, object *tmp, int x, int y, int w, int h, bool fit)
Definition: item.c:545
void interface_redraw(void)
Definition: interface.c:654
void button_show(button_struct *button, const char *text)
Definition: button.c:161
int keybind_process_command(const char *cmd)
Definition: keybind.c:553
texture_struct * texture
Definition: popup.h:70
uint8_t disable_texture_drawing
Definition: popup.h:75
void text_input_destroy(text_input_struct *text_input)
Definition: text_input.c:96
int64_t selection_start
Definition: popup.h:105
#define COLOR_WHITE
Definition: text.h:289