2 // control/visual/label.qc
10 // calculate the size if necessary
11 if( self.size == '0 0 0' ) {
12 self.size_x = self.fontSize_x * strlen( self.text );
13 self.size_y = self.fontSize_y;
14 } else if( self.fontSize == '0 0 0' ) {
15 self.fontSize_x = self.size_x / strlen( self.text );
16 self.fontSize_y = self.size_y;
20 void() Item_Label_Update =
25 void() Item_Label_Draw =
27 local vector lAligned;
28 // do we need to align the text?
29 if( self.alignment == ITEM_ALIGN_LEFT )
30 lAligned_x = self.pos_x;
31 else if( self.alignment & ITEM_ALIGN_CENTER )
32 lAligned_x = self.pos_x + (self.size_x - strlen( self.text ) * self.fontSize_x) / 2;
33 else if( self.alignment & ITEM_ALIGN_RIGHT )
34 lAligned_x = self.pos_x + self.size_x - strlen( self.text ) * self.fontSize_x;
36 lAligned_x = self.pos_x;
37 lAligned_y = self.pos_y;
39 Menu_DrawString( lAligned, self.text, self.fontSize, self.color, self.alpha, self.drawFlag );
42 void() Item_Label_Destroy =
44 String_EntityFree( self, text );
47 void() Item_Label_Spawn =
50 self.flag = self.flag | FLAG_DRAWUPDATEONLY;
52 String_EntityZone( self, text );
56 if( self.alignment & ITEM_ALIGN_FIX_CENTER )
57 self.pos_x = self.pos_x - self.size_x / 2;
58 else if( self.alignment & ITEM_ALIGN_FIX_LEFT )
59 self.pos_x = self.pos_x - self.size_x;
61 self._destroy = Item_Label_Destroy;
62 self._draw = Item_Label_Draw;
63 self._update = Item_Label_Update;