c1_lua/lua/app/ui/summon/cell/summon_hero_cell.lua
2025-08-20 17:44:03 +08:00

88 lines
3.0 KiB
Lua
Executable File

local SummonBallCell = class("SummonBallCell", BaseCell)
function SummonBallCell:init()
local uiMap = self:getUIMap()
self.heroBg = uiMap["summon_hero_cell.bg"]
self.icon = uiMap["summon_hero_cell.icon"]
self.matchImg = uiMap["summon_hero_cell.match_img"]
self.heroDec = uiMap["summon_hero_cell.dec"]
self.selectImg = uiMap["summon_hero_cell.select_img"]
self.nameTx = uiMap["summon_hero_cell.name_tx"]
self.countTx = uiMap["summon_hero_cell.count_tx"]
self.descTx = uiMap["summon_hero_cell.desc_tx"]
self.infoBtn = uiMap["summon_hero_cell.info_btn"]
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_WISH_UNSELECT))
self.baseObject:addClickListener(function()
if self.callback then
self.callback(self.heroId)
end
end)
self.infoBtn:addClickListener(function()
ModuleManager.HeroManager:showHeroDetailUI(self.heroId, true)
end)
end
function SummonBallCell:refresh(wishHeroId, heroId, callback, select)
self.heroId = heroId
self.callback = callback
if not heroId or heroId == 0 then
self:refreshEmpty()
return
end
local cfg = DataManager.HeroData:getHeroConfig(heroId)
-- self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, cfg.icon)
-- self.heroBg:setSprite(GConst.ATLAS_PATH.HERO, GConst.FRAME_QLT[cfg.qlt])
self.heroBg:setSprite(GConst.ATLAS_PATH.UI_SUMMON, "summon_card_" .. cfg.qlt)
self.heroDec:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_DEC_QLT[cfg.qlt])
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[cfg.position])
self.nameTx:setText(ModuleManager.HeroManager:getHeroName(heroId))
if select then
self.countTx:setText("x100")
self.infoBtn:setActive(false)
self.selectImg:setVisible(false)
else
self.countTx:setText("")
self.infoBtn:setActive(true)
self.selectImg:setVisible(wishHeroId == heroId)
end
self.icon:setActive(true)
self.heroDec:setActive(true)
self.matchImg:setActive(true)
self.descTx:setActive(false)
end
function SummonBallCell:refreshEmpty()
self.heroBg:setSprite(GConst.ATLAS_PATH.UI_SUMMON, "summon_card_0")
self.nameTx:setText("")
self.countTx:setText("")
self.infoBtn:setActive(false)
self.icon:setActive(false)
self.selectImg:setActive(false)
self.heroDec:setActive(false)
self.matchImg:setActive(false)
self.descTx:setActive(true)
end
function SummonBallCell:refreshInfo(heroId)
self.heroId = heroId
local cfg = DataManager.HeroData:getHeroConfig(heroId)
-- self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, cfg.icon)
self.heroBg:setSprite(GConst.ATLAS_PATH.UI_SUMMON, "summon_card_" .. cfg.qlt)
self.heroDec:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_DEC_QLT[cfg.qlt])
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[cfg.position])
self.nameTx:setText(ModuleManager.HeroManager:getHeroName(heroId))
self.countTx:setText("")
self.infoBtn:setActive(false)
self.selectImg:setVisible(false)
self.icon:setActive(true)
self.heroDec:setActive(true)
self.matchImg:setActive(true)
self.descTx:setActive(false)
end
return SummonBallCell