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