]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/control/visual/switchbutton.qc
Adding my current version of the scmenu to the nexuiz cvs.
[divverent/nexuiz.git] / scmenu / source / control / visual / switchbutton.qc
1 // DP/Nex Menu
2 // control/visual/switchbutton.qc
3
4 bool( float pKey, float pAscii ) Item_SwitchButton_Key =
5 {
6         if( !self._target )
7                 return false;
8
9         if( pKey == K_SPACE || pKey == K_ENTER || pKey == K_MOUSE1 || pKey == K_RIGHTARROW ) {
10                 Sound_Play( self.soundPressed );
11                 self._presstime = Timer_Time;
12
13                 self._target._realValue = self._target._realValue + 1;
14                 if( self._target._realValue > self._target.maxValue )
15                         self._target._realValue = self._target.minValue;
16                 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
17
18                 CtCall_Action();
19                 return true;
20         } else if( pKey == K_BACKSPACE || pKey == K_MOUSE2 || pKey == K_LEFTARROW ) {
21                 Sound_Play( self.soundPressed );
22                 self._presstime = Timer_Time;
23
24                 self._target._realValue = self._target._realValue - 1;
25                 if( self._target._realValue < self._target.minValue )
26                         self._target._realValue = self._target.maxValue;
27
28                 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
29
30                 CtCall_Action();
31                 return true;
32         }
33
34         return false;
35 };
36
37 void() Item_SwitchButton_Spawn =
38 {
39         Item_ValueButton_Spawn();
40
41         self._key = Item_SwitchButton_Key;
42 };