]> icculus.org git repositories - divverent/nexuiz.git/blob - attic/TeamNexuiz/menuqc/menu.qc
moved navnodeedit & TeamNexuiz to attic
[divverent/nexuiz.git] / attic / TeamNexuiz / menuqc / menu.qc
1 ///////////////////////////////////////////////\r
2 // Menu Source File\r
3 ///////////////////////\r
4 // This file belongs to dpmod/darkplaces\r
5 // AK contains all menu functions (especially the required ones)\r
6 ///////////////////////////////////////////////\r
7 \r
8 void() m_updategamestate =\r
9 {\r
10         // update isserver and clientstate\r
11         gamestatus = 0;\r
12         if( isserver() )\r
13                 gamestatus = gamestatus | GAME_ISSERVER;\r
14         if( clientstate() == CS_CONNECTED )\r
15                 gamestatus = gamestatus | GAME_CONNECTED;\r
16         if( cvar("developer") )\r
17                 gamestatus = gamestatus | GAME_DEVELOPER;\r
18 };\r
19 \r
20 void() m_init =\r
21 {\r
22         // init graphic\r
23         Gfx_Init();\r
24 \r
25         // init cursor\r
26         Cursor_Init();\r
27 \r
28         Key_Init();\r
29 \r
30         HostCache_Init();\r
31 \r
32         // init menu\r
33         Menu_Init();\r
34 };\r
35 \r
36 // required menu functions\r
37 void( float pKey, float pAscii ) m_keydown =\r
38 {\r
39         if( !Menu_Active )\r
40                 return;\r
41 \r
42         // actually the menu is the only system that needs to react on key events\r
43         Menu_Key( pKey, pAscii );\r
44 };\r
45 \r
46 void() m_frame =\r
47 {\r
48         Timer_Update();\r
49 \r
50         HostCache_Update();\r
51 \r
52         Key_Update();\r
53 \r
54         // graphic frame\r
55         Gfx_Update();\r
56 \r
57         // cursor frame\r
58         Cursor_Update();\r
59 \r
60         // menu frame\r
61         Menu_Frame();\r
62 };\r
63 \r
64 void() m_draw =\r
65 {\r
66         m_updategamestate();\r
67 \r
68 \r
69         if( !Menu_Active ) {\r
70                 // test whether we want to force it to be displayed\r
71                 if( !(gamestatus & GAME_CONNECTED) && !(gamestatus & GAME_DEVELOPER) && cvar_string( "menu_directmenu" ) != "" ) {\r
72                         m_display();\r
73                 }\r
74                 else {\r
75                         return;\r
76                 }\r
77         }\r
78 \r
79         // call m_frame cause draw is the only menu function called once per frame\r
80         m_frame();\r
81 \r
82         // now the drawing code\r
83         Menu_Draw();\r
84 \r
85         // draw the cursor on top of the menu\r
86         Cursor_Draw();\r
87 \r
88         // and now the gfx drawing code (for special fx)\r
89         Gfx_Draw();\r
90 };\r
91 \r
92 void() m_display =\r
93 {\r
94         Menu_Active = true;\r
95 \r
96         m_updategamestate();\r
97 \r
98         // let also the snd and gfx know (perhaps for sfx)\r
99         Gfx_Display();\r
100         Cursor_Display();\r
101         Key_Display();\r
102 \r
103         // let the menu manager know\r
104         Menu_PerformReinit();\r
105 };\r
106 \r
107 void() m_hide =\r
108 {\r
109         Gfx_Hide();\r
110         Cursor_Hide();\r
111         Key_Hide();\r
112 \r
113         // let the menu manager know\r
114         Menu_Hide();\r
115 \r
116         Menu_Active = false;\r
117 };\r
118 \r
119 void() m_toggle =\r
120 {\r
121         Timer_Update();\r
122 \r
123         if( Menu_Active )\r
124                 m_hide();\r
125         else\r
126                 m_display();\r
127 };\r
128 \r
129 void() m_shutdown =\r
130 {\r
131         Timer_Update();\r
132 \r
133         // shutdown menu\r
134         Menu_Shutdown();\r
135 \r
136         // shutdown timer\r
137         Timer_Quit();\r
138 \r
139         // shutdown key system\r
140         Key_Quit();\r
141 \r
142         // shutdown cursor\r
143         Cursor_Quit();\r
144 \r
145         // shutdown graphic\r
146         Gfx_Quit();\r
147 \r
148         // make sure everything is reset\r
149         setkeydest( KEY_GAME );\r
150         setmousetarget( MT_CLIENT );\r
151 };