2 // control/visual/list.qc
4 void() Item_List_Draw =
16 lLines = floor( self.size_y / ( self.fontSize_y + 2 ) );
17 lStart = max( 0, floor( Item_DataLink_Switch_GetOrdinal( self._target, self._target._realValue ) - lLines / 2 ) );
18 lEnd = min( lStart + lLines, Item_DataLink_Switch_GetOrdinal( self._target, self._target.maxValue ) );
20 lPos = '0 1 0' + self.pos;
21 for( lLine = lStart ; lLine <= lEnd ; lLine++ ) {
23 lText = Util_GetAltStringItem( self._target.descList, lLine );
24 if( lLine == Item_DataLink_Switch_GetOrdinal( self._target, self._target._realValue ) ) {
25 if( self._state == ITEM_STATE_SELECTED )
26 Menu_DrawString( lPos, lText, self.fontSize, self.colorSelected, self.alphas_y, self.drawFlags_y );
27 else if( self._state == ITEM_STATE_PRESSED )
28 Menu_DrawString( lPos, lText, self.fontSize, self.colorPressed, self.alphas_z, self.drawFlags_z );
30 Menu_DrawString( lPos, lText, self.fontSize, self.colorInactive, self.alphaInactive, self.drawFlagInactive );
32 Menu_DrawString( lPos, lText, self.fontSize, self.color, self.alphas_x, self.drawFlags_x );
35 lPos_y = lPos_y + self.fontSize_y + 1;
41 void() Item_List_Update =
43 Item_DataUser_Update();
45 if( self._presstime + ITEM_BUTTON_ACTIONTIME > Timer_Time )
46 self._state = ITEM_STATE_PRESSED;
47 else if( Menu_ActiveItem == self )
48 self._state = ITEM_STATE_SELECTED;
50 self._state = ITEM_STATE_NORMAL;
52 /*if( Menu_HasRunFlag( self, RUNFLAG_MOUSEINAREA ) ) {
57 lLines = floor( self.size_y / ( self.fontSize_y + 2 ) );
58 lStart = max( 0, floor( Item_DataLink_Switch_GetOrdinal( self._target, self._target._realValue ) - lLines / 2 ) );
59 lItem = floor( ( Menu_Cursor_Position_y - self.pos_y ) / ( self.fontSize_y + 2 ) );
60 lItem = min( lStart + lItem, Item_DataLink_Switch_GetOrdinal( self._target, self._target.maxValue ) );
62 print( ftos( lItem ), "\n" );
64 self._target._realValue = lItem * self._target.stepValue + self._target.minValue;
65 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
71 void( bool pSelect, bool pUser ) Item_List_Select =
73 if( pSelect && pUser )
74 Sound_Play( self.soundSelected );
77 bool( float pKey, float pAscii ) Item_List_Key =
79 if( pKey == K_DOWNARROW ) {
80 Sound_Play( self.soundPressed );
81 self._presstime = Timer_Time;
83 self._target._realValue = self._target._realValue + 1;
84 if( self._target._realValue > self._target.maxValue )
85 self._target._realValue = self._target.minValue;
86 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
90 } else if( pKey == K_UPARROW ) {
91 Sound_Play( self.soundPressed );
92 self._presstime = Timer_Time;
94 self._target._realValue = self._target._realValue - 1;
95 if( self._target._realValue < self._target.minValue )
96 self._target._realValue = self._target.maxValue;
98 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
106 void() Item_List_Destroy =
110 String_EntityFree( self, soundSelected );
111 String_EntityFree( self, soundPressed );
113 Item_DataUser_Destroy();
116 void() Item_List_Spawn =
118 Item_DataUser_Init();
120 String_EntityZone( self, soundSelected );
121 String_EntityZone( self, soundPressed );
123 Sound_Precache( self.soundSelected );
124 Sound_Precache( self.soundPressed );
126 self._draw = Item_List_Draw;
127 self._update = Item_List_Update;
128 self._select = Item_List_Select;
129 self._key = Item_List_Key;
130 self._reinit = CtCall_Reinit;