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