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