View Issue Details

IDProjectCategoryView StatusLast Update
0004178Multi Theft Auto : San AndreasScriptingpublic2009-06-25 00:06
ReporterNeonBlackAssigned Tomabako 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target Version1.0Fixed in Version1.0 
Summary0004178: guiLabelGetTextExtent does not support multiple lines
Description

guiLabelGetTextExtent does not return the needed space of the longest line but the needed space if the \n would be a normal character if using with a text containing line breaks.

TagsNo tags attached.

Relationships

related to 0004432 resolvedArc Source patches Patch for Issue 4178 (guiLabelGetTextExtent does not support multiple lines) 

Activities

NeonBlack

2009-04-14 18:45

viewer   ~~0008810

Temporary solution:


function GetMultipleLineExtent(text)
local extent = 0
local lines = Explode("\n", text)
local label = guiCreateLabel(0, 0, 0, 0, "", false)
guiSetVisible(label, false)

for _, line in pairs(lines) do
    guiSetText(label, line)
    local lineWidth = guiLabelGetTextExtent(label)
    outputChatBox(line)
    if (lineWidth > extent) then extent = lineWidth end
end

destroyElement(label)
return extent

end
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Uses:


function Explode(separator, ensemble, autoformat)
local seplen = #separator

if (#ensemble == 0) then return {} end
local i, j = 1, ensemble:find(separator)
local pieces = {}

while (i) do
    if (j) then j = j - 1 end
    if (autoformat) then table.insert(pieces, tonumber(ensemble:sub(i, j)) or ensemble:sub(i, j))
    else table.insert(pieces, ensemble:sub(i, j)) end

    if (j) then
        i = j + seplen + 1
        j = ensemble:find(separator, i)
    else break end
end

return pieces

end
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Inefficient but works. Both must be clientside though Explode can also be used serverside.

Issue History

Date Modified Username Field Change