c1_lua/lua/app/ui/battle/battle_pause_ui.lua
2023-05-31 18:06:16 +08:00

130 lines
4.4 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 = {
[10] = true
}
local HIDE_ID = {
[29] = 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)
self.battleType = params.battleType
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] and not HIDE_ID[skillId] 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()
self:refreshDailyChallengeNode()
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
function BattlePauseUI:refreshDailyChallengeNode()
local uiMap = self.root:genAllChildren()
local node = uiMap["battle_pause_ui.daily_challenge_node"]
if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE then
node:setVisible(false)
return
end
node:setVisible(true)
local buffDescs = {}
for _, id in ipairs(DataManager.DailyChallengeData:getTodayBuffIds()) do
local cfg = ConfigManager:getConfig("buff_daily_challenge")[id]
if cfg then
buffDescs[cfg.buff_type] = ModuleManager.DailyChallengeManager:getBuffDesc(id)
end
end
local buffBtns = {
uiMap["battle_pause_ui.daily_challenge_node.buff_1"],
uiMap["battle_pause_ui.daily_challenge_node.buff_2"]
}
for i, obj in ipairs(buffBtns) do
obj:addClickListener(function()
ModuleManager.TipsManager:showDescTips(buffDescs[i] or GConst.EMPTY_STRING, obj)
end)
end
uiMap["battle_pause_ui.daily_challenge_node.task"]:addClickListener(function()
ModuleManager.DailyChallengeManager:showBattleTaskUI()
end)
uiMap["battle_pause_ui.daily_challenge_node.buff_title"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUFF_DESC))
uiMap["battle_pause_ui.daily_challenge_node.task_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.TASK_NAME))
end
return BattlePauseUI