c1_lua/lua/app/ui/battle/battle_pause_ui.lua
2023-04-27 16:30:09 +08:00

94 lines
2.9 KiB
Lua

local BattlePauseUI = class("BattlePauseUI", BaseUI)
local SELECT_SKILL_CELL = "app/ui/battle/cell/select_skill_cell"
local SKILL_ROGUE_CFG = ConfigManager:getConfig("skill_rogue")
local HIDE_TYPE = {
[9] = true,
[10] = true
}
function BattlePauseUI:isFullScreen()
return false
end
function BattlePauseUI:showCommonBG()
return false
end
function BattlePauseUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_pause_ui.prefab"
end
function BattlePauseUI:ctor(params)
local map = DataManager.BattleData:getSelectSkillMap()
self.skillList = {}
for skillId, info in pairs(map) do
local cfg = SKILL_ROGUE_CFG[skillId]
if cfg and not HIDE_TYPE[cfg.type] then
table.insert(self.skillList, {skillId = skillId, info = info})
end
end
end
function BattlePauseUI:onLoadRootComplete()
self:_display()
self:_addListeners()
end
function BattlePauseUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["battle_pause_ui.skill_node.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_2))
self:_refreshScrollRect()
end
function BattlePauseUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["battle_pause_ui.home_btn"]:addClickListener(function()
local params = {
content = I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_1),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
cancelText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL),
okFunc = function()
ModuleManager.BattleManager:endBattleAndExit(true)
end,
}
GFunc.showMessageBox(params)
end)
uiMap["battle_pause_ui.continue_btn"]:addClickListener(function()
self:closeUI()
end)
end
function BattlePauseUI:_refreshScrollRect()
if self.scrollRect then
self.scrollRect:updateAllCell()
return
end
local uiMap = self.root:genAllChildren()
self.scrollRect = uiMap["battle_pause_ui.skill_node.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return SELECT_SKILL_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
local skillId = self.skillList[index].skillId
local count = self.skillList[index].info.count
local value = self.skillList[index].info.value
local cfg = ConfigManager:getConfig("skill_rogue")[skillId]
local str
if cfg and cfg.attr and ModuleManager.HeroManager:showValueRogue(skillId) then
str = GFunc.getPerStr(cfg.attr.type, value)
end
cell:refresh(skillId, count, str)
cell:addClickListener(function()
ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId, value), cell:getBaseObject())
end)
end)
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.skillList)
end
return BattlePauseUI