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