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