整理代码,lang模块功能特化
This commit is contained in:
@@ -12,15 +12,22 @@ local tipMeta={__call=function(L)return L[math.random(#L)]end}
|
||||
|
||||
local langList={}
|
||||
local publicText,publicWidgetText={},{}
|
||||
local function lang_set(l)
|
||||
text=langList[l]
|
||||
WIDGET.setLang(text.WidgetText)
|
||||
for _,s in next,drawableTextLoad do
|
||||
drawableText[s]:set(text[s])
|
||||
end
|
||||
end
|
||||
|
||||
local LANG={}
|
||||
|
||||
--Must call before LANG.init
|
||||
--Call these before call LANG.init()
|
||||
function LANG.setLangList(list)langList=list end
|
||||
function LANG.setPublicText(L)publicText=L end
|
||||
function LANG.setPublicWidgetText(L)publicWidgetText=L end
|
||||
|
||||
function LANG.init()
|
||||
function LANG.init()--Attention, calling this will DESTORY ALL METHODS, only left LANG.set()!
|
||||
for i=1,#langList do
|
||||
local L=langList[i]
|
||||
|
||||
@@ -53,15 +60,8 @@ function LANG.init()
|
||||
v.back=L.back
|
||||
end
|
||||
end
|
||||
LANG.init=nil
|
||||
end
|
||||
|
||||
function LANG.set(l)
|
||||
text=langList[l]
|
||||
WIDGET.setLang(text.WidgetText)
|
||||
for _,s in next,drawableTextLoad do
|
||||
drawableText[s]:set(text[s])
|
||||
end
|
||||
LANG.init,LANG.setLangList,LANG.setPublicText,LANG.setPublicWidgetText=nil
|
||||
LANG.set=lang_set
|
||||
end
|
||||
|
||||
return LANG
|
||||
@@ -3,12 +3,10 @@ local kb=love.keyboard
|
||||
local int,abs=math.floor,math.abs
|
||||
local max,min=math.max,math.min
|
||||
local sub,format=string.sub,string.format
|
||||
local ins=table.insert
|
||||
|
||||
local Timer=love.timer.getTime
|
||||
local setFont,mStr=setFont,mStr
|
||||
|
||||
local widgetList={}
|
||||
local WIDGET={}
|
||||
local widgetMetatable={
|
||||
__tostring=function(self)
|
||||
|
||||
Reference in New Issue
Block a user