]> icculus.org git repositories - divverent/nexuiz.git/blob - menu/menu.qc
added secondary fire zoom on nex
[divverent/nexuiz.git] / menu / menu.qc
1 ///////////////////////////////////////////////
2 // Menu Source File
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all menu functions (especially the required ones)
6 ///////////////////////////////////////////////
7
8 void(void) m_init =
9 {
10         // init graphic
11         gfx_init();
12
13         // init sound
14         snd_init();
15
16         // init cursor
17         cursor_init();
18
19         // init menu
20         menu_init();
21
22         // init editor
23         //editor_init();
24 };
25
26 // required menu functions
27 void(float keynr, float ascii) m_keydown =
28 {
29         if(!menu_active)
30                 return;
31
32         // let also the gfx and sound know
33         gfx_keydown(keynr, ascii);
34         snd_keydown(keynr, ascii);
35
36         // actually only the menu may react on keydown messages
37         menu_keydown(keynr, ascii);
38
39         // let the editor also know
40         //editor_keydown(keynr, ascii);
41 };
42
43 void(void) m_frame =
44 {
45         // graphic frame
46         gfx_frame();
47
48         // sound frame
49         snd_frame();
50
51         // cursor frame
52         cursor_frame();
53
54         // menu frame
55         menu_frame();
56
57         // editor frame
58         //editor_frame();
59 };
60
61 void(void) m_draw =
62 {
63         if(!menu_active)
64                 return;
65
66         // call m_frame cause draw is the only menu function called once per frame
67         m_frame();
68
69         // now the drawing code
70         menu_draw();
71
72         // editor drawing code
73         //editor_draw();
74
75         // draw the cursor on top of the menu
76         cursor_draw();
77
78         // and now the gfx drawing code (for special fx)
79         gfx_draw();
80 };
81
82 void(void) m_toggle =
83 {
84         if(!menu_active)
85         {
86                 menu_active = true;
87
88                 // update isserver and clientstate
89                 gamestatus = 0;
90                 if(isserver())
91                         gamestatus = gamestatus | GAME_ISSERVER;
92                 if(clientstate() == CS_CONNECTED)
93                         gamestatus = gamestatus | GAME_CONNECTED;
94                 if(cvar("developer"))
95                         gamestatus = gamestatus | GAME_DEVELOPER;
96
97                 // redirect keyboard input
98                 setkeydest(KEY_MENU);
99                 // stop the client getting mouse coords
100                 setmousetarget(MT_MENU);
101
102                 // let also the snd and gfx know (perhaps for sfx)
103                 gfx_toggle();
104                 snd_toggle();
105
106                 cursor_toggle();
107
108                 // let the menu manager know
109                 menu_performreinit();
110         } else
111         {
112                 setkeydest(KEY_GAME);
113                 setmousetarget(MT_CLIENT);
114                 menu_active = false;
115         }
116 };
117
118 void(void) m_shutdown =
119 {
120         // shutdown editor
121         //editor_shutdown();
122
123         // shutdown menu
124         menu_shutdown();
125
126         // shutdown cursor
127         cursor_shutdown();
128
129         // shutdown sound
130         snd_shutdown();
131
132         // shutdown graphic
133         gfx_shutdown();
134
135         // make sure everything is reset
136         setkeydest(KEY_GAME);
137         setmousetarget(MT_CLIENT);
138 };