2022-03-04 12:32:45 +01:00
|
|
|
local ScrollScales = {}
|
|
|
|
local TextWidths = {}
|
|
|
|
local Size = {}
|
|
|
|
local TextWidth = {}
|
2022-02-26 18:26:55 +01:00
|
|
|
|
|
|
|
function textmaker(text, fontsize, maxWidth, x, y, w, h, lenght, scissorY, id) -- testing is needed
|
2022-02-19 02:38:37 +01:00
|
|
|
gfx.FontSize(fontsize)
|
|
|
|
local x1,y1,x2,y2 = gfx.TextBounds(x,y, text)
|
|
|
|
|
2022-02-26 18:26:55 +01:00
|
|
|
TextWidths[id] = (x2 - x1)
|
|
|
|
TextWidth[id] = maxWidth
|
|
|
|
Size[id] = lenght+maxWidth
|
2022-02-19 02:38:37 +01:00
|
|
|
|
2022-02-26 18:26:55 +01:00
|
|
|
if (ScrollScales[id] == nil) then
|
|
|
|
ScrollScales[id] = 0;
|
|
|
|
end
|
|
|
|
gfx.Scissor(x,y + scissorY,w,h) -- debug
|
2022-02-19 02:38:37 +01:00
|
|
|
gfx.FillColor(255,255,255)
|
|
|
|
if (x2-x1) < maxWidth then
|
|
|
|
gfx.Text(text,x,y)
|
|
|
|
else
|
2022-03-25 23:47:24 +01:00
|
|
|
gfx.Text(text,x,y) ---ScrollScales[id]
|
2022-02-26 18:26:55 +01:00
|
|
|
|
2022-02-19 02:38:37 +01:00
|
|
|
gfx.FillColor(255,255,0)
|
|
|
|
end
|
|
|
|
gfx.ResetScissor()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function tickScroll(deltaTime)
|
2022-02-26 18:26:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
for i, ScrollScale in ipairs(ScrollScales) do
|
|
|
|
if ScrollScale < TextWidths[i]+TextWidth[i] then
|
|
|
|
ScrollScales[i] = ScrollScale + deltaTime + 1 * math.min(1,deltaTime/ 0.002)
|
|
|
|
else
|
|
|
|
ScrollScales[i] = -TextWidths[i]-Size[i]/1.9
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-19 02:38:37 +01:00
|
|
|
end
|
|
|
|
|
2022-02-26 18:26:55 +01:00
|
|
|
function resetIds()
|
|
|
|
ScrollScales = {}
|
|
|
|
TextWidths = {}
|
|
|
|
end
|
2022-02-19 02:38:37 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
textmaker = textmaker,
|
2022-02-26 18:26:55 +01:00
|
|
|
tickScroll = tickScroll,
|
|
|
|
resetIds = resetIds
|
2022-02-19 02:38:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- * = debug things
|