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