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