Yoshi-Networks

guiCreateColorLabel

Mar 5th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. function guiCreateColorLabel ( ax, ay, bx, by, sText, relative, scale, font, parent )
  2. if type( ax ) == 'number' and
  3. type( ay ) == 'number' and
  4. type( bx ) == 'number' and
  5. type( by ) == 'number' and
  6. type( sText ) == 'string' and
  7. type( relative ) == 'boolean'
  8. then
  9. local tLabels = { }
  10. --local uRoot = createElement( 'label' )
  11. local last = 0
  12. local nCount = 0
  13. local wight = 0
  14. local one,second,third = string.find( sText,'#%x%x%x%x%x%x', 1 )
  15. while true do
  16. if ( one or second or third ) then
  17. local sTemp = string.sub( sText,one,second,third )
  18. sTemp = sTemp:gsub( '#','' )
  19. local r, g, b = tonumber( '0x' .. sTemp:sub( 1, 2 ) ), tonumber( '0x' .. sTemp:sub( 3, 4 ) ),tonumber( '0x' .. sTemp:sub( 5, 6 ) )
  20. nCount = nCount + 1
  21. --local uLabel = createElement( 'label','id' .. tostring( nCount ) )
  22. local text = string.gsub( string.sub( sText,last,third ),'#%x%x%x%x%x%x','' )
  23. local uCurrentLabel = guiCreateLabel ( ax + wight, ay, bx + wight*1.5, by, text, relative, parent )
  24. wight = wight + dxGetTextWidth( text, scale or 1, font or 'default' )
  25. guiLabelSetColor ( uCurrentLabel, r, g, b )
  26. guiLabelSetHorizontalAlign ( uCurrentLabel, "center", false )
  27. guiLabelSetVerticalAlign ( uCurrentLabel, "center" )
  28. guiSetFont ( uCurrentLabel, wsCFont )
  29. --setElementParent( uLabel,uCurrentLabel )
  30. table.insert( tLabels, uCurrentLabel )
  31. --guiSetFont( uLabel, 'sa-header' )
  32. --setElementParent( uLabel,uRoot )
  33. last = second
  34. else
  35. if last == 0 then
  36. local uCurrentLabel = guiCreateLabel ( ax, ay, bx, by, sText, relative, parent )
  37. guiLabelSetColor ( uCurrentLabel, 255, 255, 255 )
  38. guiLabelSetHorizontalAlign ( uCurrentLabel, "center", false )
  39. guiLabelSetVerticalAlign ( uCurrentLabel, "center" )
  40. guiSetFont ( uCurrentLabel, wsCFont )
  41. table.insert( tLabels, uCurrentLabel )
  42. end
  43. break
  44. end
  45. end
  46. return tLabels
  47. end
  48. return false
  49. end
Advertisement
Add Comment
Please, Sign In to add comment