2 // control/data/textswitch.qc
5 void( float pEvent ) Item_DataLink_TextSwitch_DataEvent =
7 Item_DataLink_Update();
9 if( pEvent == ITEM_DATALINK_SET ) {
10 Item_DataLink_Value_Clamp();
12 String_EntitySet( self._link, value, String_Normal( Util_GetAltStringItem( self.valueList, self._realValue ) ) );
13 Raise_DataEvent( self._link, ITEM_DATALINK_SET );
15 } else if( !self._link )
17 else if( pEvent == ITEM_DATALINK_GET ) {
18 local float lPos, lCount;
20 Raise_DataEvent( self._link, ITEM_DATALINK_GET );
22 // check if we need a full resync
23 // TODO: Remove this check since we actually dont want to support twice-defined entries
24 if( String_Normal( Util_GetAltStringItem( self.valueList, self._realValue ) ) == self._link.value ) {
25 String_EntitySet( self, value, String_Normal( Util_GetAltStringItem( self.descList, self._realValue ) ) );
30 lCount = Util_GetAltStringCount( self.valueList );
31 for( lPos = 0 ; lPos < lCount ; ++lPos )
32 if( String_Normal( Util_GetAltStringItem( self.valueList, lPos ) ) == self._link.value )
36 // if there is no match test for a custom entry
37 if( Util_GetAltStringCount( self.descList ) > lCount ) {
43 self._realValue = lPos;
44 String_EntitySet( self, value, String_Normal( Util_GetAltStringItem( self.descList, lPos ) ) );
46 Raise_DataEvent( self._link, pEvent );
49 void() Item_DataLink_TextSwitch_Destroy =
51 String_EntityFree( self, valueList );
52 Item_DataLink_Switch_Destroy();
55 void() Item_DataLink_TextSwitch_Spawn =
57 Item_DataLink_Switch_Init();
58 String_EntityZone( self, valueList );
61 if( self.maxValue == 0.0 )
62 self.maxValue = Util_GetAltStringCount( self.valueList ) - 1;
63 if( self.maxValue == 0.0 )
68 self._destroy = Item_DataLink_TextSwitch_Destroy;
69 self._dataEvent = Item_DataLink_TextSwitch_DataEvent;