1 ///////////////////////////////////////////////
2 // Menu Manager Source File
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all manager constants, etc.
6 ///////////////////////////////////////////////
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;
14 const float MENU_NORMAL = 0;
15 const float MENU_INGAME = 1;
17 const float MENU_ENFORCELOADING = false;
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";
24 const string MENU_NORMAL_DEFAULT =
25 "// default normal menu\n"
27 " \"type\" \"ITEM_WINDOW\"\n"
28 " \"name\" \"normal\"\n"
31 const string MENU_INGAME_DEFAULT =
32 "// default ingame menu\n"
34 " \"type\" \"ITEM_WINDOW\"\n"
35 " \"name\" \"ingame\"\n"
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";
42 const float MENU_ALLOWINGAME = FALSE;
46 entity menu_activewindow;
48 // points to the lowest selected menu item (that has no child item selected)
51 // used to build up the local coord system
52 vector menu_localorigin;
54 vector menu_clip_pos, menu_clip_size; // global clip area
59 float menu_automatedselection;
72 //.entity _history; // used to set up the history -> selectdown prefers _history over _parent
76 .entity _next, _prev; // point to the next, respectively, the previous item
78 .entity _child; // points to the first child
81 .vector click_pos, click_size;
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
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
94 .void(void) init; // called once at object creation
97 .void(void) mouse_enter;
98 .void(void) mouse_leave;
102 .float(float keynr, float ascii) key; // if it returns TRUE, the key was processed by the function
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;
113 .void(float keynr, float ascii) _key;
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;
128 // decide whether to toggle the menu
129 void(void) menu_toggle;
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;
137 void(void) menu_frame;
138 void(void) menu_draw;
139 void(float keynr, float ascii) menu_keydown;
140 void(void) menu_shutdown;
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;
151 void(entity menu, float setactive) menu_jumptowindow;
152 void(entity menu) menu_drawwindow;
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;
159 float(entity e) menu_hasevents;
160 float(entity e) menu_isvisible;
161 float(entity e) menu_selectable;
163 entity(string item_name) menu_getitem;
165 void(entity ent) menu_removeitem;
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
174 // points to the last element of the history
177 void(entity ent) menu_pushhistory;
178 void(void) menu_pophistory;
179 float(entity ent) menu_verifyhistory;
180 void(void) menu_clearhistory;
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;