]> icculus.org git repositories - divverent/nexuiz.git/blob - menu/mmanager.qh
grappling hook
[divverent/nexuiz.git] / menu / mmanager.qh
1 ///////////////////////////////////////////////
2 // Menu Manager Source File
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all manager constants, etc.
6 ///////////////////////////////////////////////
7 // constants
8
9 // menu_processmous states
10 const float MENU_SELECT_SELECTABLE = 0;
11 const float MENU_SELECT_ALWAYS = 1;
12 const float MENU_SELECT_NEVER  = 2;
13
14 const float MENU_NORMAL = 0;
15 const float MENU_INGAME = 1;
16
17 const float MENU_ENFORCELOADING = false;
18
19 // define these menus in the menu def files or dont
20 // if not defined there will be added default items
21 const string MENU_NORMAL_NAME = "normal";
22 const string MENU_INGAME_NAME = "ingame";
23
24 const string MENU_NORMAL_DEFAULT =
25 "// default normal menu\n"
26 "{\n"
27 "       \"type\"        \"ITEM_WINDOW\"\n"
28 "       \"name\"                \"normal\"\n"
29 "}";
30
31 const string MENU_INGAME_DEFAULT =
32 "// default ingame menu\n"
33 "{\n"
34 "       \"type\"        \"ITEM_WINDOW\"\n"
35 "       \"name\"                \"ingame\"\n"
36 "}";
37
38 // insert the files here
39 var string MENU_FILENAME_LIST =
40 "menu/normal.menu menu/background.menu menu/video.menu menu/options.menu menu/xplayer.menu";
41
42 const float MENU_ALLOWINGAME = FALSE;
43
44 // globals
45
46 entity menu_activewindow;
47
48 // points to the lowest selected menu item (that has no child item selected)
49 entity menu_selected;
50
51 // used to build up the local coord system
52 vector menu_localorigin;
53
54 vector menu_clip_pos, menu_clip_size; // global clip area
55
56 // local coord cursor
57 vector menu_cursor;
58
59 float menu_automatedselection;
60
61 ///////////
62 // fields
63 ///
64
65 // controly type
66 .string type;
67
68 // managing stuff
69 .entity _parent;
70 .string parent;
71
72 //.entity _history;     // used to set up the history -> selectdown prefers _history over _parent
73
74 .string name;
75
76 .entity _next, _prev;           // point to the next, respectively, the previous item
77
78 .entity _child;                 // points to the first child
79
80 // updating stuff
81 .vector click_pos, click_size;
82
83 .float orderpos;        // if FLAG_NOSELECT or FLAG_HIDDEN is set, it cant be selected
84                                         // has to be set always to a correct value or to 0 then it is set
85 .float flag;
86
87 // drawing
88 // the clip_* are only used by menu's (at the moment)
89 .vector clip_pos, clip_size; // set clip_size_x or clip_size_y to 0 to disable clipping
90
91 .vector origin;
92
93 // function pointers
94 .void(void) init;       // called once at object creation
95 .void(void) reinit;
96 .void(void) destroy;
97 .void(void) mouse_enter;
98 .void(void) mouse_leave;
99 .void(void) refresh;
100 .void(void) action;
101 .void(void) draw;
102 .float(float keynr, float ascii) key; // if it returns TRUE, the key was processed by the function
103
104 // hidden function pointers - actually these are called by the manager
105 // and they call the normal ones (used to make controls more generic
106 .void(void) _reinit;    // called in performreinit
107 .void(void) _destroy;   // called when the item is removed -> menu_removeitem
108 .void(void) _mouse_enter;
109 .void(void) _mouse_leave;
110 .void(void) _refresh;
111 .void(void) _action;
112 .void(void) _draw;
113 .void(float keynr, float ascii) _key;
114
115 ///////////////
116 // prototypes
117 ///
118
119 // used for global managing
120 void(void) menu_init;
121 // used to reload everything mmanager related
122 void(void) menu_restart;
123 // loads all files the file lists consists of
124 void(void) menu_load;
125 // used to reset the menu states everytime the menu is activated
126 void(void) menu_performreinit;
127
128 // decide whether to toggle the menu
129 void(void) menu_toggle;
130
131 // use this to add a file to the file list
132 void(string file) menu_addfiletolist;
133 // these 2 functions are pretty private, so dont call them !
134 void(string file) menu_loadmenu;
135 void(void) menu_linkwindows;
136
137 void(void) menu_frame;
138 void(void) menu_draw;
139 void(float keynr, float ascii) menu_keydown;
140 void(void) menu_shutdown;
141
142 // used for menu handling
143 void(void) menu_loopnext;
144 void(void) menu_loopprev;
145 void(void) menu_selectnext;
146 void(void) menu_selectprev;
147 void(void) menu_selectup;
148 void(void) menu_selectdown;
149 void(void) menu_reselect;
150
151 void(entity menu, float setactive) menu_jumptowindow;
152 void(entity menu) menu_drawwindow;
153
154 // when selectalways is true, you can use menu_processmouse to return the last object in the
155 // menu list whose click rectangle fits to the cursor pos (although it only returns an item
156 // if that item allows events
157 void(entity par, float selectalways) menu_processmouse;
158
159 float(entity e) menu_hasevents;
160 float(entity e) menu_isvisible;
161 float(entity e) menu_selectable;
162
163 entity(string item_name) menu_getitem;
164
165 void(entity ent) menu_removeitem;
166
167 // history stuff
168 // MMANAGER_HISTORY
169 //.entity _prev;        <- points to the previous history element
170 //.entity _child;       <- points to the old/calling selected item
171 //.entity _parent;      <- points to the old active window
172 //.entity _next;        <- points to the item which the history is used for
173
174 // points to the last element of the history
175 entity menu_history;
176
177 void(entity ent) menu_pushhistory;
178 void(void) menu_pophistory;
179 float(entity ent) menu_verifyhistory;
180 void(void)      menu_clearhistory;
181
182 // key hook - only as long as there is no history change or the menu is closed
183 var void(float keynr, float ascii) menu_keyhook;
184
185