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