修复快速设置语言产生大量内存垃圾并在返回主菜单时卡顿 close #118

This commit is contained in:
MrZ626
2021-07-10 23:38:12 +08:00
parent 9c2974e4f0
commit b650999f96
2 changed files with 14 additions and 10 deletions

View File

@@ -34,11 +34,13 @@ function LANG.init(langList,publicText)--Attention, calling this will destory al
LANG.init,LANG.setLangList,LANG.setPublicText=nil
function LANG.set(l)
text=langList[l]
WIDGET.setLang(text.WidgetText)
for k,v in next,drawableText do
if text[k]then
v:set(text[k])
if text~=langList[l]then
text=langList[l]
WIDGET.setLang(text.WidgetText)
for k,v in next,drawableText do
if text[k]then
v:set(text[k])
end
end
end
end

View File

@@ -15,12 +15,14 @@ function scene.sceneBack()
FILE.save(SETTING,'conf/settings')
end
local function setLang(n)
SETTING.lang=n
LANG.set(n)
TEXT.show(langList[n],640,500,100,'appear',.626)
local function _setLang(n)
return function()
SETTING.lang=n
LANG.set(n)
TEXT.show(langList[n],640,500,100,'appear',.626)
collectgarbage()
end
end
local function _setLang(n)return function()setLang(n)end end
scene.widgetList={
WIDGET.newButton{x=200,y=100,w=200,h=120,fText=langList[1],color='R',font=35,code=_setLang(1)},
WIDGET.newButton{x=420,y=100,w=200,h=120,fText=langList[2],color='dR',font=35,code=_setLang(2)},