some meshgen and map rendering updates
[voxelands-alt.git] / inc / ui.h
blobef585f2ef0853eb8abefba45a6dab2ecbf51b82c
1 #ifndef _UI_H_
2 #define _UI_H_
4 #include "graphics.h"
6 #define EVENT_UNHANDLED 0
7 #define EVENT_HANDLED 1
9 #define SML_FONT 15
10 #define LGE_FONT 20
12 #define UIMSG_OK 0
13 #define UIMSG_YN 1
14 #define UIMSG_OC 2
16 #define UI_WIDGET_NULL 0x00
17 #define UI_WIDGET_LABEL 0x01
18 #define UI_WIDGET_BUTTON 0x02
19 #define UI_WIDGET_CONTAINER 0x03
20 #define UI_WIDGET_TEXT 0x04
21 #define UI_WIDGET_NUM 0x05
22 #define UI_WIDGET_CHECK 0x06
23 #define UI_WIDGET_HEADER 0x07
24 #define UI_WIDGET_CONSOLE 0x08
25 #define UI_WIDGET_PBAR 0x09
26 #define UI_WIDGET_TEXTBOX 0x0A
27 #define UI_WIDGET_HSLIDE 0x0B
28 #define UI_WIDGET_LIST 0x0C
29 #define UI_WIDGET_LISTROW 0x0D
31 struct widget_s;
33 #ifndef _HAVE_SPRITE_TYPE
34 #define _HAVE_SPRITE_TYPE
35 typedef struct sprite_s {
36 GLfloat x;
37 GLfloat y;
38 GLfloat w;
39 GLfloat h;
40 material_t *mat;
41 } sprite_t;
42 #endif
44 #ifndef _HAVE_MSGBOX_DATA_TYPE
45 #define _HAVE_MSGBOX_DATA_TYPE
46 typedef struct msgbox_data_s {
47 struct widget_s *container;
48 struct widget_s *txt;
49 struct widget_s *btn1;
50 struct widget_s *btn2;
51 int (*btn1_func)(struct widget_s*);
52 int (*btn2_func)(struct widget_s*);
53 } msgbox_data_t;
54 #endif
56 #ifndef _HAVE_LISTROW_DATA_TYPE
57 #define _HAVE_LISTROW_DATA_TYPE
58 typedef struct listrow_data_s {
59 char** values;
60 } listrow_data_t;
61 #endif
63 #ifndef _HAVE_LISTCOLUMN_TYPE
64 #define _HAVE_LISTCOLUMN_TYPE
65 typedef struct list_column_s {
66 char* name;
67 int width;
68 } list_column_t;
69 #endif
71 #ifndef _HAVE_LIST_DATA_TYPE
72 #define _HAVE_LIST_DATA_TYPE
73 typedef struct list_data_s {
74 int col_cnt;
75 int rows;
76 int offset;
77 int y;
78 int (*click)(struct widget_s *);
79 list_column_t *columns;
80 } list_data_t;
81 #endif
83 #ifndef _HAVE_OPTBOX_BTN_TYPE
84 #define _HAVE_OPTBOX_BTN_TYPE
85 typedef struct optbox_btn_s {
86 struct widget_s *btn;
87 int (*func)(struct widget_s*);
88 struct optbox_btn_s *next;
89 } optbox_btn_t;
90 #endif
92 #ifndef _HAVE_OPTBOX_DATA_TYPE
93 #define _HAVE_OPTBOX_DATA_TYPE
94 typedef struct optbox_data_s {
95 struct widget_s *container;
96 struct widget_s *txt;
97 optbox_btn_t *buttons;
98 } optbox_data_t;
99 #endif
101 #ifndef _HAVE_OPTION_DATA_TYPE
102 #define _HAVE_OPTION_DATA_TYPE
103 typedef struct option_data_s {
104 char com[100];
105 } option_data_t;
106 #endif
108 #ifndef _HAVE_CHECKBOX_DATA_TYPE
109 #define _HAVE_CHECKBOX_DATA_TYPE
110 typedef struct checkbox_data_s {
111 uint8_t checked;
112 } check_data_t;
113 #endif
115 #ifndef _HAVE_NUMBOX_DATA_TYPE
116 #define _HAVE_NUMBOX_DATA_TYPE
117 typedef struct numbox_data_s {
118 int value;
119 int min;
120 int max;
121 } numbox_data_t;
122 #endif
124 #ifndef _HAVE_CONSOLE_LINE_TYPE
125 #define _HAVE_CONSOLE_LINE_TYPE
126 typedef struct console_line_s {
127 struct console_line_s *prev;
128 struct console_line_s *next;
129 char str[256];
130 } console_line_t;
131 #endif
133 #ifndef _HAVE_CONSOLE_DATA_TYPE
134 #define _HAVE_CONSOLE_DATA_TYPE
135 typedef struct console_data_s {
136 console_line_t *lines;
137 char command[256];
138 int cchar;
139 } console_data_t;
140 #endif
142 #ifndef _HAVE_SLIDE_DATA_TYPE
143 #define _HAVE_SLIDE_DATA_TYPE
144 typedef struct slide_data_s {
145 int value;
146 int min;
147 int max;
148 sprite_t *sld;
149 } slide_data_t;
150 #endif
152 #ifndef _HAVE_PBAR_DATA_TYPE
153 #define _HAVE_PBAR_DATA_TYPE
154 typedef struct pbar_data_s {
155 int max;
156 int value;
157 int blind;
158 colour_t colour;
159 } pbar_data_t;
160 #endif
162 #ifndef _HAVE_WIDGET_DATA_TYPE
163 #define _HAVE_WIDGET_DATA_TYPE
164 typedef union widget_data_u {
165 console_data_t con;
166 numbox_data_t num;
167 check_data_t chk;
168 pbar_data_t pbr;
169 msgbox_data_t msg;
170 optbox_data_t opb;
171 option_data_t opt;
172 slide_data_t sld;
173 list_data_t lst;
174 listrow_data_t row;
175 } widget_data_t;
176 #endif
178 #ifndef _HAVE_WIDGET_EVENTS_TYPE
179 #define _HAVE_WIDGET_EVENTS_TYPE
180 typedef struct widget_events_s {
181 int (*mclick)(struct widget_s *w);
182 int (*mdown)(struct widget_s *w);
183 int (*mup)(struct widget_s *w);
184 int (*sdown)(struct widget_s *w);
185 int (*sup)(struct widget_s *w);
186 int (*mmove)(struct widget_s *w);
187 int (*kdown)(struct widget_s *w);
188 int (*kup)(struct widget_s *w);
189 int (*show)(struct widget_s *w);
190 int (*hide)(struct widget_s *w);
191 } widget_events_t;
192 #endif
194 #ifndef _HAVE_WIDGET_STYLE_TYPE
195 #define _HAVE_WIDGET_STYLE_TYPE
196 typedef struct widget_style_s {
197 int x;
198 int y;
199 int w;
200 int h;
201 int visible;
202 int visibility_changed;
203 sprite_t *bg;
204 colour_t color;
205 colour_t border;
206 int has_border;
207 int text_align;
208 int font_face;
209 int font_size;
210 colour_t ttcolor;
211 colour_t ttbg;
212 int has_ttbg;
213 colour_t ttborder;
214 int has_ttborder;
215 int ttfont_face;
216 int ttfont_size;
217 } widget_style_t;
218 #endif
220 #ifndef _HAVE_WIDGET_TYPE
221 #define _HAVE_WIDGET_TYPE
222 typedef struct widget_s {
223 struct widget_s *prev;
224 struct widget_s *next;
225 uint32_t type;
226 uint32_t id;
227 textbuffer_t text;
228 int hover;
229 textbuffer_t htext;
230 struct xml_tag_s *x;
231 widget_style_t style;
232 widget_data_t *data;
233 widget_events_t *events;
234 struct widget_s *parent;
235 struct widget_s *child;
236 } widget_t;
237 #endif
239 /* defined in ui.c */
240 int ui_init(void);
241 widget_t *ui_widget_container(void);
242 void ui_render(void);
243 void ui_loader(char* str);
244 void ui_msg(uint8_t type, char* txt, int (*func)(), ...);
245 void ui_opt(char* txt, ...);
247 #endif