From d5bedb659a146ad5a2622efa617b01919902872a Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 12 Apr 2023 22:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=A4=A7=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/common/cell/large_hero_cell.lua | 67 +++++++++++++++++++ .../ui/common/cell/large_hero_cell.lua.meta | 10 +++ 2 files changed, 77 insertions(+) create mode 100644 lua/app/ui/common/cell/large_hero_cell.lua create mode 100644 lua/app/ui/common/cell/large_hero_cell.lua.meta diff --git a/lua/app/ui/common/cell/large_hero_cell.lua b/lua/app/ui/common/cell/large_hero_cell.lua new file mode 100644 index 00000000..8ec8c504 --- /dev/null +++ b/lua/app/ui/common/cell/large_hero_cell.lua @@ -0,0 +1,67 @@ +local LargeHeroCell = class("LargeHeroCell", BaseCell) + +function LargeHeroCell:init() + local uiMap = self.baseObject:genAllChildren() + self.icon = uiMap["hero_cell.hero_bg.icon"] + self.heroBg = uiMap["hero_cell.hero_bg"] + self.check = uiMap["hero_cell.hero_bg.mask"] + self.matchImg = uiMap["hero_cell.hero_bg.match_img"] + self.isGray = false + + uiMap["large_hero_cell.hero_bg.info_btn"]:addClickListener(function() + if self.clickCallback1 then + self.clickCallback1() + end + end) + + uiMap["large_hero_cell.hero_bg.use_btn"]:addClickListener(function() + if self.clickCallback1 then + self.clickCallback1() + end + end) +end + +function LargeHeroCell:refresh(heroEntity, isGray) + local heroInfo = heroEntity:getConfig() + self:_refresh(heroInfo, isGray) +end + +function LargeHeroCell:refreshWithCfgId(id, isGray) + local heroInfo = ConfigManager:getConfig("hero")[id] + self:_refresh(heroInfo, isGray) +end + +function LargeHeroCell:_refresh(heroInfo, isGray) + if isGray then + self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_GRAY_QLT[heroInfo.qlt]) + else + self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_QLT[heroInfo.qlt]) + end + self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroInfo.icon)) + self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position]) + self.check:setVisible(false) + self:setGray(isGray) +end + +function LargeHeroCell:showCheck(visible) + self.check:setVisible(visible) +end + +function LargeHeroCell:addClickListener(btn1Callback, btn2Callback) + self.clickCallback1 = btn1Callback + self.clickCallback2 = btn2Callback +end + +function LargeHeroCell:setVisible(visible) + self.baseObject:setVisible(visible) +end + +function LargeHeroCell:setGray(isGray) + if self.isGray == isGray then + return + end + self.icon:setImageGray(isGray) + self.matchImg:setImageGray(isGray) +end + +return LargeHeroCell diff --git a/lua/app/ui/common/cell/large_hero_cell.lua.meta b/lua/app/ui/common/cell/large_hero_cell.lua.meta new file mode 100644 index 00000000..3a71d652 --- /dev/null +++ b/lua/app/ui/common/cell/large_hero_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ee14cc3908f42fb44b2d72271bf4cb01 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}