]> icculus.org git repositories - divverent/darkplaces.git/blob - ui.h
changed back to profiling, with optimizations, and back to alsa 0.5 sound
[divverent/darkplaces.git] / ui.h
1
2 #ifndef UI_H
3 #define UI_H
4
5 // these defines and structures are for internal use only
6 // (ui_t is passed around by users of the system, but should not be altered)
7 #define MAX_UI_COUNT 16
8 #define MAX_UI_ITEMS 256
9
10 typedef struct
11 {
12         char name[32];
13         int flags;
14         char *draw_picname;
15         char *draw_string;
16         int draw_x, draw_y;
17         int click_x, click_y, click_x2, click_y2;
18         void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2);
19         void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2);
20         void(*enterkey)(void *nativedata1, void *nativedata2, float data1, float data2);
21         void(*mouseclick)(void *nativedata1, void *nativedata2, float data1, float data2, float xfrac, float yfrac);
22         void *nativedata1, *nativedata2;
23         float data1, data2;
24 }
25 ui_item_t;
26
27 typedef struct
28 {
29         int item_count;
30         int pad;
31         ui_item_t items[MAX_UI_ITEMS];
32 }
33 ui_t;
34
35 // engine use:
36 // initializes the ui system
37 void ui_init(void);
38 // updates the mouse position, given an absolute loation (some input systems use this)
39 void ui_mouseupdate(float x, float y);
40 // updates the mouse position, by an offset from the previous location (some input systems use this)
41 void ui_mouseupdaterelative(float x, float y);
42 // left key update
43 void ui_leftkeyupdate(int pressed);
44 // right key update
45 void ui_rightkeyupdate(int pressed);
46 // up key update
47 void ui_upkeyupdate(int pressed);
48 // down key update
49 void ui_downkeyupdate(int pressed);
50 // mouse button update (note: 0 = left, 1 = right, 2 = middle, 3+ not supported yet)
51 void ui_mousebuttonupdate(int button, int pressed);
52 // perform input updates and check for clicks on items (note: calls callbacks)
53 void ui_update(void);
54 // draw all items of all panels
55 void ui_draw(void);
56
57 // intentionally public functions:
58 // creates a panel
59 ui_t *ui_create(void);
60 // frees a panel
61 void ui_free(ui_t *ui);
62 // empties a panel, removing all the items
63 void ui_clear(ui_t *ui);
64 // sets an item in a panel (adds or replaces the item)
65 void ui_item
66 (
67         ui_t *ui, char *basename, int number,
68         float x, float y, char *picname, char *string,
69         float left, float top, float width, float height,
70         void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2),
71         void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2),
72         void(*enterkey)(void *nativedata1, void *nativedata2, float data1, float data2),
73         void(*mouseclick)(void *nativedata1, void *nativedata2, float data1, float data2, float xfrac, float yfrac),
74         void *nativedata1, void *nativedata2, float data1, float data2
75 );
76 // removes an item from a panel
77 void ui_item_remove(ui_t *ui, char *basename, int number);
78 // checks if a panel is enabled
79 int ui_uiactive(ui_t *ui);
80 // enables/disables a panel on the screen
81 void ui_activate(ui_t *ui, int yes);
82
83 #endif