From aeb1c8e24ae931a56ad5f15539aefc62d30f31df Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 30 Aug 2023 17:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E7=9A=AE=E8=82=A4=E5=8D=A1?= =?UTF-8?q?=E9=9D=A2=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/common/cell/hero_cell.lua | 19 +++++++++++++++++-- .../common/component/hero_formation_comp.lua | 2 +- lua/app/userdata/skin/skin_data.lua | 11 +++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lua/app/ui/common/cell/hero_cell.lua b/lua/app/ui/common/cell/hero_cell.lua index 5abcdc27..c3e2e0d3 100644 --- a/lua/app/ui/common/cell/hero_cell.lua +++ b/lua/app/ui/common/cell/hero_cell.lua @@ -31,6 +31,9 @@ function HeroCell:init() self:bind(DataManager.BagData.ItemData, "dirty", function() self:refreshRedPoint() end) + self:bind(DataManager.SkinData, "isDirty", function() + self:refreshHeroIcon() + end) end function HeroCell:refresh(heroEntity, isGray) @@ -92,6 +95,15 @@ function HeroCell:refresh(heroEntity, isGray) self:refreshRedPoint() end +-- 刷新英雄icon +function HeroCell:refreshHeroIcon(iconName) + if self.heroEntity ~= nil then + self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO_2, DataManager.SkinData:getIcon(self.heroEntity:getSkinId())) + elseif iconName then + self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO_2, tostring(iconName)) + end +end + -- 刷新红点 function HeroCell:refreshRedPoint() if self.heroEntity == nil then @@ -123,7 +135,10 @@ function HeroCell:getHeroId() return self.heroEntity:getCfgId() end -function HeroCell:refreshBriefInfo(id, level) +function HeroCell:refreshBriefInfo(heroEntity) + self.heroEntity = heroEntity + local id = self.heroEntity:getCfgId() + local level = self.heroEntity:getLv() self.selfNode:setVisible(false) self.otherNode:setVisible(true) @@ -165,10 +180,10 @@ function HeroCell:_refresh(heroInfo, isGray) self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.FRAME_QLT[heroInfo.qlt]) end self.heroDec:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_DEC_QLT[heroInfo.qlt]) - self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO_2, tostring(heroInfo.icon)) self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position]) self.check:setVisible(false) self.sImg:setVisible(heroInfo.qlt >= 4) + self:refreshHeroIcon(heroInfo.icon) self:setGray(isGray) end diff --git a/lua/app/ui/common/component/hero_formation_comp.lua b/lua/app/ui/common/component/hero_formation_comp.lua index db92912b..6b0a242c 100644 --- a/lua/app/ui/common/component/hero_formation_comp.lua +++ b/lua/app/ui/common/component/hero_formation_comp.lua @@ -59,7 +59,7 @@ function HeroFormationComp:refreshByEntitys(formation) local heroEntity = formation[i] if heroEntity then heroCell:setVisible(true, 1) - heroCell:refreshBriefInfo(heroEntity:getCfgId(), heroEntity:getLv()) + heroCell:refreshBriefInfo(heroEntity) heroCell:addClickListener(function() ModuleManager.HeroManager:showHeroDetailUI(heroEntity:getCfgId(), true, heroEntity) end) diff --git a/lua/app/userdata/skin/skin_data.lua b/lua/app/userdata/skin/skin_data.lua index 18674baa..bd08a7ae 100644 --- a/lua/app/userdata/skin/skin_data.lua +++ b/lua/app/userdata/skin/skin_data.lua @@ -133,6 +133,17 @@ function SkinData:getModelId(skinId) return cfg and cfg.model_id end +-- 获取icon名称 +function SkinData:getIcon(skinId) + local cfg = self:getSkinCfg(skinId) + if cfg and cfg.icon then + return cfg.icon + else + local heroInfo = ConfigManager:getConfig("hero")[self:getHeroIdBySkinId(skinId)] + return heroInfo.icon + end +end + -- 获取皮肤来源 function SkinData:getSource(skinId) return I18N:getGlobalText("SKIN_GOT_" .. self:getSkinCfg(skinId).got)