]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/base/key.qc
Adding my current version of the scmenu to the nexuiz cvs.
[divverent/nexuiz.git] / scmenu / 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_Hide =
18 {
19         setkeydest( KEY_GAME );
20 };
21
22 void( string pKey ) Key_Unbind =
23 {
24         cmd( strcat( "unbind ", pKey, "\n" ) );
25 };
26
27 string( float pKey ) Key_GetName =
28 {
29         return keynumtostring( pKey );
30 };
31
32 float( string pKey ) Key_GetNum =
33 {
34         return stringtokeynum( pKey );
35 };
36
37 string( string pCommand ) Key_GetBindList =
38 {
39         return String_Zone( findkeysforcommand( pCommand ) );
40 };
41
42 void(string pKey, string pCommand) Key_Bind =
43 {
44         cmd( strcat( "bind \"", pKey, "\" \"", pCommand, "\"\n" ) );
45 };
46
47 void(float pNum, string pCommand)  Key_LimitBinds =
48 {
49         local string lAltlist;
50         local float  lCounter;
51         local float  lMaxnum;
52         local float  lValue;
53
54         lAltlist = Key_GetBindList( pCommand );
55         lMaxnum = Util_GetAltStringCount( lAltlist );
56
57         for( lCounter = 0 ; lCounter < lMaxnum ; lCounter = lCounter + 1 ) {
58                 lValue = stof( String_Normal( Util_GetAltStringItem( lAltlist, lCounter ) ) );
59
60                 if( lValue == -1 )
61                         break;
62                 if( lCounter >= pNum )
63                         Key_Unbind( Key_GetName( lValue ) );
64         }
65
66         String_Free( lAltlist );
67 };
68