Skip to content
Snippets Groups Projects
Commit 2b5af11b authored by Alex Ksandra's avatar Alex Ksandra
Browse files

Removed redunant functions.

parent 8f573890
No related branches found
No related tags found
1 merge request!104Many a fix to colored string rendering.
......@@ -824,77 +824,6 @@ function __get_uid_entity(uid)
end
local tmps = core.display.newSurface(1, 1)
getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g, b, alpha_from_texture, limit_w)
local list = str:split("#" * (Puid + Pcolorcodefull + Pcolorname + Pfontstyle + Pextra) * "#", true)
r = r or 255
g = g or 255
b = b or 255
limit_w = limit_w or 99999999
local oldr, oldg, oldb = r, g, b
local max_h = 0
local sw = 0
local bx, by = x, y
for i, v in ipairs(list) do
local nr, ng, nb = lpeg.match("#" * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * "#", v)
local col = lpeg.match("#" * lpeg.C(Pcolorname) * "#", v)
local uid, mo = lpeg.match("#" * Puid_cap * "#", v)
local fontstyle = lpeg.match("#" * Pfontstyle_cap * "#", v)
local extra = lpeg.match("#" * lpeg.C(Pextra) * "#", v)
if nr and ng and nb then
oldr, oldg, oldb = r, g, b
r, g, b = nr:parseHex(), ng:parseHex(), nb:parseHex()
elseif col then
if col == "LAST" then
r, g, b = oldr, oldg, oldb
else
oldr, oldg, oldb = r, g, b
r, g, b = colors[col].r, colors[col].g, colors[col].b
end
elseif uid and mo and game.level then
uid = tonumber(uid)
mo = tonumber(mo)
local e = __uids[uid]
if e then
local surf = e:getEntityFinalSurface(game.level.map.tiles, font:lineSkip(), font:lineSkip())
if surf then
local w, h = surf:getSize()
if sw + w > limit_w then break end
s:merge(surf, x, y)
if h > max_h then max_h = h end
x = x + (w or 0)
sw = sw + (w or 0)
end
end
elseif fontstyle then
font:setStyle(fontstyle)
elseif extra then
--
else
local w, h = font:size(v)
local stop = false
while sw + w > limit_w do
v = v:sub(1, #v - 1)
if #v == 0 then break end
w, h = font:size(v)
stop = true
end
if h > max_h then max_h = h end
s:drawStringBlended(font, v, x, y, r, g, b, alpha_from_texture)
x = x + w
sw = sw + w
if stop then break end
end
end
return r, g, b, sw, max_h, bx, by
end
getmetatable(tmps).__index.drawColorStringCentered = function(s, font, str, dx, dy, dw, dh, r, g, b, alpha_from_texture, limit_w)
local w, h = font:size(str)
local x, y = dx + (dw - w) / 2, dy + (dh - h) / 2
s:drawColorString(font, str, x, y, r, g, b, alpha_from_texture, limit_w)
end
getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y, r, g, b, alpha_from_texture, limit_w)
local list = str:split("#" * (Puid + Pcolorcodefull + Pcolorname + Pfontstyle + Pextra) * "#", true)
r = r or 255
......@@ -958,12 +887,14 @@ getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y,
end
return r, g, b, sw, max_h, bx, by
end
getmetatable(tmps).__index.drawColorString = getmetatable(tmps).__index.drawColorStringBlended
getmetatable(tmps).__index.drawColorStringBlendedCentered = function(s, font, str, dx, dy, dw, dh, r, g, b, alpha_from_texture, limit_w)
local w, h = font:size(str)
local x, y = dx + (dw - w) / 2, dy + (dh - h) / 2
s:drawColorStringBlended(font, str, x, y, r, g, b, alpha_from_texture, limit_w)
end
getmetatable(tmps).__index.drawColorStringCentered = getmetatable(tmps).__index.drawColorStringBlendedCentered
local font_cache = {}
local oldNewFont = core.display.newFont
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment