Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text = { }
- text.__index = text
- function text:Create ( aX, aY, aW, aH, aText, aRelative, aParent, aFont )
- if (
- type ( aX ) == "number"
- and
- type ( aY ) == "number"
- and
- type ( aW ) == "number"
- and
- type ( aH ) == "number"
- and
- type ( aText ) == "string"
- )
- then
- local vText = { }
- local pat = "(.-)#(%x%x%x%x%x%x)"
- local s, e, cap, col = aText:find(pat, 1)
- local last = 1
- while s do
- if ( cap == "" and col ) then r, g, b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ),
- tonumber( "0x"..col:sub( 5, 6 ) ) end
- if ( s ~= 1 or cap ~= "" ) then
- local w = dxGetTextWidth(cap, 1.0, aFont)
- uLabel = guiCreateLabel ( aX, aY, aW + w, aH, cap, aRelative or false, aParent or nil )
- r, g, b = tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) )
- guiLabelSetColor ( uLabel, 255, 255, 255 )
- guiSetFont ( uLabel, aFont )
- table.insert ( vText, uLabel )
- aW = aW + w
- last = e + 1
- s, e, cap, col = aText:find( pat, last )
- if last <= #aText then
- cap = aText:sub( last )
- local w = dxGetTextWidth(cap, 1.0, aFont)
- utLabel = guiCreateLabel ( aX, aY, aW + w, aH, cap, aRelative, aParent )
- local x, y = guiGetPosition ( utLabel, false )
- guiSetPosition ( utLabel, guiLabelGetTextExtent ( uLabel ) + 58, y, false )
- guiLabelSetColor ( utLabel, r, g, b )
- guiSetFont ( utLabel, aFont )
- table.insert ( vText, utLabel )
- break
- end
- end
- end
- end
- return vText
- end
Advertisement
Add Comment
Please, Sign In to add comment