2 // control/data/valueswitch.qc
6 Item_DataLink_ValueSwitch_DataEvent
9 void( float pEvent ) Item_DataLink_ValueSwitch_DataEvent =
11 Item_DataLink_Update();
13 if( pEvent == ITEM_DATALINK_SET ) {
14 Item_DataLink_Value_Clamp();
16 self._link._realValue = self._realValue;
17 String_EntitySet( self._link, value, ftos( self._realValue ) );
18 Raise_DataEvent( self._link, ITEM_DATALINK_SET );
20 } else if( !self._link )
22 else if( pEvent == ITEM_DATALINK_GET ) {
25 Raise_DataEvent( self._link, ITEM_DATALINK_GET );
27 self._realValue = stof( self._link.value );
28 Item_DataLink_Value_Clamp();
30 lPos = rint( (self._realValue - self.minValue) / self.stepValue );
31 String_EntitySet( self, value, String_Normal( Util_GetAltStringItem( self.descList, lPos ) ) );
33 Raise_DataEvent( self._link, pEvent );
38 Item_DataLink_ValueSwitch_Spawn
41 void() Item_DataLink_ValueSwitch_Spawn =
43 Item_DataLink_Switch_Init();
45 if( self.maxValue == 0.0 )
46 self.maxValue = self.minValue + (Util_GetAltStringCount( self.descList ) - 1) * self.stepValue;
50 lCount = Util_GetAltStringCount( self.descList );
52 self.stepValue = (self.maxValue - self.minValue ) / (lCount - 1);
57 self._dataEvent = Item_DataLink_ValueSwitch_DataEvent;
58 self._destroy = Item_DataLink_Switch_Destroy;