]> icculus.org git repositories - divverent/nexuiz.git/blob - data/source/control/visual/switchbutton.qc
restructure
[divverent/nexuiz.git] / data / 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 + self._target.stepValue;
14                 if( self._target._realValue > self._target.maxValue )
15                         self._target._realValue = self._target.minValue;
16
17                 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
18
19                 CtCall_Action();
20                 return true;
21         } else if( pKey == K_BACKSPACE || pKey == K_MOUSE2 || pKey == K_LEFTARROW ) {
22                 Sound_Play( self.soundPressed );
23                 self._presstime = Timer_Time;
24
25                 self._target._realValue = self._target._realValue - self._target.stepValue;
26                 if( self._target._realValue < self._target.minValue )
27                         self._target._realValue = self._target.maxValue;
28
29                 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
30
31                 CtCall_Action();
32                 return true;
33         }
34
35         return false;
36 };
37
38 void() Item_SwitchButton_Spawn =
39 {
40         Item_ValueButton_Spawn();
41
42         self._key = Item_SwitchButton_Key;
43 };