mirror of
https://github.com/mt-mods/signs_lib.git
synced 2025-01-12 08:40:23 +01:00
Cache character textures
This commit is contained in:
parent
b057341a07
commit
c199a33bb8
20
init.lua
20
init.lua
@ -26,6 +26,9 @@ signs_lib.gettext = S
|
|||||||
-- text encoding
|
-- text encoding
|
||||||
dofile(signs_lib.path .. "/encoding.lua");
|
dofile(signs_lib.path .. "/encoding.lua");
|
||||||
|
|
||||||
|
-- Initialize character texture cache
|
||||||
|
local ctexcache = {}
|
||||||
|
|
||||||
|
|
||||||
local wall_dir_change = {
|
local wall_dir_change = {
|
||||||
[0] = 4,
|
[0] = 4,
|
||||||
@ -362,14 +365,19 @@ end
|
|||||||
-- make char texture file name
|
-- make char texture file name
|
||||||
-- if texture file does not exist use fallback texture instead
|
-- if texture file does not exist use fallback texture instead
|
||||||
local function char_tex(font_name, ch)
|
local function char_tex(font_name, ch)
|
||||||
local c = ch:byte()
|
if ctexcache[font_name..ch] then
|
||||||
local exists, tex = file_exists(CHAR_PATH:format(font_name, c))
|
return ctexcache[font_name..ch], true
|
||||||
if exists and c ~= 14 then
|
|
||||||
tex = CHAR_FILE:format(font_name, c)
|
|
||||||
else
|
else
|
||||||
tex = CHAR_FILE:format(font_name, 0x0)
|
local c = ch:byte()
|
||||||
|
local exists, tex = file_exists(CHAR_PATH:format(font_name, c))
|
||||||
|
if exists and c ~= 14 then
|
||||||
|
tex = CHAR_FILE:format(font_name, c)
|
||||||
|
else
|
||||||
|
tex = CHAR_FILE:format(font_name, 0x0)
|
||||||
|
end
|
||||||
|
ctexcache[font_name..ch] = tex
|
||||||
|
return tex, exists
|
||||||
end
|
end
|
||||||
return tex, exists
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_line_texture(line, lineno, pos)
|
local function make_line_texture(line, lineno, pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user