c1_lua/lua/app/ui/main_city/module_unlock_ui.lua
2023-05-30 15:32:58 +08:00

52 lines
1.5 KiB
Lua

local ModuleUnlockUI = class("ModuleUnlockUI", BaseUI)
function ModuleUnlockUI:getPrefabPath()
return "assets/prefabs/ui/main_city/module_unlock_ui.prefab"
end
function ModuleUnlockUI:isFullScreen()
return false
end
function ModuleUnlockUI:ctor(params)
self.chapterId = params and params.chapterId
self.unlockList = {}
local cfg = ConfigManager:getConfig("func_open")
for k, v in pairs(cfg) do
if v.stage == self.chapterId and v.pop_ups == nil then
table.insert(self.unlockList, k)
end
end
end
function ModuleUnlockUI:onLoadRootComplete()
self.uiMap = self.root:genAllChildren()
self.uiMap["module_unlock_ui.bg"]:addClickListener(function()
self:showModuleUnlockAnimation()
end)
self.moduleNameTx = self.uiMap["module_unlock_ui.name_tx"]
self.moduleIcon = self.uiMap["module_unlock_ui.icon"]
self.uiMap["module_unlock_ui.continue"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_TO_CONTINUE))
self.uiMap["module_unlock_ui.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.FUNC_UNLOCK))
self:showModuleUnlockAnimation()
end
function ModuleUnlockUI:showModuleUnlockAnimation()
if #self.unlockList <= 0 then
self:closeUI()
return
end
local moduleKey = table.remove(self.unlockList, 1)
local info = ConfigManager:getConfig("func_open")[moduleKey]
local i18nInfo = I18N:getConfig("func_open")[moduleKey]
if info == nil or i18nInfo == nil then
self:closeUI()
return
end
self.moduleNameTx:setText(i18nInfo.name)
end
return ModuleUnlockUI