]> icculus.org git repositories - divverent/nexuiz.git/blob - data/source/base/key.qc
restructure
[divverent/nexuiz.git] / data / source / base / key.qc
1 // NG-Menu
2 // base/key.qc
3
4 void() Key_Init =
5 {
6 };
7
8 void() Key_Quit =
9 {
10 };
11
12 void() Key_Display =
13 {
14         setkeydest( KEY_MENU );
15 };
16
17 void() Key_Update =
18 {
19 #ifdef BRAVEMENU
20         // make sure that we have the input focus
21         setkeydest( KEY_MENU );
22 #else
23         if( getkeydest() != KEY_MENU ) {
24                 m_hide();
25         }
26 #endif
27 };
28
29 void() Key_Hide =
30 {
31         setkeydest( KEY_GAME );
32 };
33
34 void( string pKey ) Key_Unbind =
35 {
36         cmd( strcat( "unbind ", pKey, "\n" ) );
37 };
38
39 string( float pKey ) Key_GetName =
40 {
41         return keynumtostring( pKey );
42 };
43
44 float( string pKey ) Key_GetNum =
45 {
46         return stringtokeynum( pKey );
47 };
48
49 string( string pCommand ) Key_GetBindList =
50 {
51         return String_Zone( findkeysforcommand( pCommand ) );
52 };
53
54 void(string pKey, string pCommand) Key_Bind =
55 {
56         cmd( strcat( "bind \"", pKey, "\" \"", pCommand, "\"\n" ) );
57 };
58
59 void(float pNum, string pCommand)  Key_LimitBinds =
60 {
61         local string lAltlist;
62         local float  lCounter;
63         local float  lMaxnum;
64         local float  lValue;
65
66         lAltlist = Key_GetBindList( pCommand );
67         lMaxnum = Util_GetAltStringCount( lAltlist );
68
69         for( lCounter = 0 ; lCounter < lMaxnum ; lCounter = lCounter + 1 ) {
70                 lValue = stof( String_Normal( Util_GetAltStringItem( lAltlist, lCounter ) ) );
71
72                 if( lValue == -1 )
73                         break;
74                 if( lCounter >= pNum )
75                         Key_Unbind( Key_GetName( lValue ) );
76         }
77
78         String_Free( lAltlist );
79 };
80