Yoshi-Networks

gui color label updated

Mar 17th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. text = { }
  2. text.__index = text
  3.  
  4. function text:Create ( aX, aY, aW, aH, aText, aRelative, aParent, aFont )
  5. if (
  6. type ( aX ) == "number"
  7. and
  8. type ( aY ) == "number"
  9. and
  10. type ( aW ) == "number"
  11. and
  12. type ( aH ) == "number"
  13. and
  14. type ( aText ) == "string"
  15. )
  16. then
  17. local vText = { }
  18. local pat = "(.-)#(%x%x%x%x%x%x)"
  19. local s, e, cap, col = aText:find(pat, 1)
  20. local last = 1
  21. while s do
  22. if ( cap == "" and col ) then r, g, b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ),
  23. tonumber( "0x"..col:sub( 5, 6 ) ) end
  24. if ( s ~= 1 or cap ~= "" ) then
  25. local w = dxGetTextWidth(cap, 1.0, aFont)
  26. uLabel = guiCreateLabel ( aX, aY, aW + w, aH, cap, aRelative or false, aParent or nil )
  27. r, g, b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) )
  28. guiLabelSetColor ( uLabel, 255, 255, 255 )
  29. guiSetFont ( uLabel, aFont )
  30. table.insert ( vText, uLabel )
  31. aW = aW + w
  32. last = e + 1
  33. s, e, cap, col = aText:find( pat, last )
  34. if last <= #aText then
  35. cap = aText:sub( last )
  36. local w = dxGetTextWidth(cap, 1.0, aFont)
  37. utLabel = guiCreateLabel ( aX, aY, aW + w, aH, cap, aRelative, aParent )
  38. local x, y = guiGetPosition ( utLabel, false )
  39. guiSetPosition ( utLabel, guiLabelGetTextExtent ( uLabel ) + 58, y, false )
  40. guiLabelSetColor ( utLabel, r, g, b )
  41. guiSetFont ( utLabel, aFont )
  42. table.insert ( vText, utLabel )
  43. break
  44. end
  45. end
  46. end
  47. end
  48. return vText
  49. end
Advertisement
Add Comment
Please, Sign In to add comment