Fix text:GetLines always returning nil

This commit is contained in:
Kenny Shields 2014-09-27 15:23:29 -04:00
parent 8dabf3e8f4
commit 3a59f46cca

View File

@ -25,6 +25,7 @@ function newobject:initialize()
self.maxw = 0 self.maxw = 0
self.shadowxoffset = 1 self.shadowxoffset = 1
self.shadowyoffset = 1 self.shadowyoffset = 1
self.lines = 0
self.formattedtext = {} self.formattedtext = {}
self.original = {} self.original = {}
self.defaultcolor = {0, 0, 0, 255} self.defaultcolor = {0, 0, 0, 255}
@ -370,7 +371,7 @@ function newobject:SetText(t)
local twidth = 0 local twidth = 0
local drawx = 0 local drawx = 0
local drawy = 0 local drawy = 0
local lines = 0 local lines = 1
local textwidth = 0 local textwidth = 0
local lastwidth = 0 local lastwidth = 0
local totalwidth = 0 local totalwidth = 0
@ -410,11 +411,13 @@ function newobject:SetText(t)
drawy = drawy + largestheight drawy = drawy + largestheight
largestheight = 0 largestheight = 0
text = "" text = ""
lines = lines + 1
elseif (twidth + width) > maxw then elseif (twidth + width) > maxw then
twidth = 0 + width twidth = 0 + width
drawx = 0 drawx = 0
drawy = drawy + largestheight drawy = drawy + largestheight
largestheight = 0 largestheight = 0
lines = lines + 1
else else
twidth = twidth + width twidth = twidth + width
drawx = drawx + prevtextwidth drawx = drawx + prevtextwidth
@ -434,6 +437,7 @@ function newobject:SetText(t)
drawy = drawy + largestheight drawy = drawy + largestheight
largestheight = 0 largestheight = 0
text = "" text = ""
lines = lines + 1
if lastwidth < textwidth then if lastwidth < textwidth then
lastwidth = textwidth lastwidth = textwidth
end end
@ -453,6 +457,8 @@ function newobject:SetText(t)
end end
end end
self.lines = lines
if lastwidth == 0 then if lastwidth == 0 then
textwidth = totalwidth textwidth = totalwidth
end end