语言/控件系统升级,移除LANG.setPublicText
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
local langList,publicText,publicWidgetText={},{},{}
|
||||
local lang = require "parts.scenes.lang"
|
||||
local langList,publicText={},{}
|
||||
local LANG={}
|
||||
|
||||
--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()--Attention, calling this will destory all initializing methods, create a LANG.set()!
|
||||
local function langFallback(T0,T)
|
||||
@@ -27,15 +27,6 @@ function LANG.init()--Attention, calling this will destory all initializing meth
|
||||
L[key]=list
|
||||
end
|
||||
|
||||
--Set public widget text
|
||||
for key,list in next,publicWidgetText do
|
||||
local WT=L.WidgetText
|
||||
if not WT[key]then WT[key]={}end
|
||||
for k,v in next,list do
|
||||
WT[key][k]=v
|
||||
end
|
||||
end
|
||||
|
||||
--Fallback to other language, default zh
|
||||
if i>1 then
|
||||
langFallback(langList[L.fallback or 1],L)
|
||||
@@ -52,7 +43,7 @@ function LANG.init()--Attention, calling this will destory all initializing meth
|
||||
end
|
||||
end
|
||||
|
||||
LANG.init,LANG.setLangList,LANG.setPublicText,LANG.setPublicWidgetText=nil
|
||||
LANG.init,LANG.setLangList,LANG.setPublicText=nil
|
||||
|
||||
function LANG.set(l)
|
||||
text=langList[l]
|
||||
@@ -63,6 +54,14 @@ function LANG.init()--Attention, calling this will destory all initializing meth
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function LANG.addScene(name)
|
||||
for i=1,#langList do
|
||||
if langList[i].WidgetText and not langList[i].WidgetText[name]then
|
||||
langList[i].WidgetText[name]={back=langList[i].back}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return LANG
|
||||
@@ -837,10 +837,8 @@ function WIDGET.set(list)
|
||||
end
|
||||
function WIDGET.setLang(widgetText)
|
||||
for S,L in next,SCN.scenes do
|
||||
if widgetText[S]then
|
||||
for _,W in next,L.widgetList do
|
||||
W.text=W.fText or widgetText[S][W.name]
|
||||
end
|
||||
for _,W in next,L.widgetList do
|
||||
W.text=W.fText or widgetText[S][W.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user