From 536cc1dfc38eac63fb8ec498f85a128e9f3e5fd5 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 1 Aug 2023 10:28:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=93=E5=85=B7=E8=8E=B7=E5=8F=96=E7=9A=84?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E5=93=81=E8=B4=A8=E9=A2=9C=E8=89=B2=E9=94=99?= =?UTF-8?q?=E8=AF=AFfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/common/cell/player_head_cell.lua | 9 +++------ lua/app/ui/player_info/avatar_cell.lua | 9 +++------ lua/app/ui/player_info/player_info_ui.lua | 9 +++------ lua/app/userdata/player/player_data.lua | 15 +++++++++++---- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lua/app/ui/common/cell/player_head_cell.lua b/lua/app/ui/common/cell/player_head_cell.lua index 19f3648b..557088dd 100644 --- a/lua/app/ui/common/cell/player_head_cell.lua +++ b/lua/app/ui/common/cell/player_head_cell.lua @@ -16,12 +16,9 @@ function PlayerHeadCell:refresh(avatarId, frameId, showRp) end -- 背景颜色 - local heroId = DataManager.PlayerData:getAvatarHeroId(avatarId) - if heroId then - local smallFrame = ModuleManager.HeroManager:getHeroSmallFrame(heroId) - if smallFrame then - self.baseObject:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) - end + local smallFrame = DataManager.PlayerData:getAvatarBg(avatarId) + if smallFrame then + self.baseObject:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) end -- 头像 diff --git a/lua/app/ui/player_info/avatar_cell.lua b/lua/app/ui/player_info/avatar_cell.lua index 2333e65d..0ea61ce0 100644 --- a/lua/app/ui/player_info/avatar_cell.lua +++ b/lua/app/ui/player_info/avatar_cell.lua @@ -27,12 +27,9 @@ function AvatarCell:refresh(id, isSelect) end -- 背景 - local heroId = DataManager.PlayerData:getAvatarHeroId(self.id) - if heroId then - local smallFrame = ModuleManager.HeroManager:getHeroSmallFrame(heroId) - if smallFrame then - self.baseObject:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) - end + local smallFrame = DataManager.PlayerData:getAvatarBg(self.id) + if smallFrame then + self.baseObject:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) end self.select:setActive(isSelect) diff --git a/lua/app/ui/player_info/player_info_ui.lua b/lua/app/ui/player_info/player_info_ui.lua index 3500c313..c68b8757 100644 --- a/lua/app/ui/player_info/player_info_ui.lua +++ b/lua/app/ui/player_info/player_info_ui.lua @@ -202,12 +202,9 @@ end -- 刷新头像和头像框 function PlayerInfoUI:refreshAvatarAndFrame() - local heroId = DataManager.PlayerData:getAvatarHeroId(self.selectAvatarId) - if heroId then - local smallFrame = ModuleManager.HeroManager:getHeroSmallFrame(heroId) - if smallFrame then - self.bgAvatar:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) - end + local smallFrame = DataManager.PlayerData:getAvatarBg(self.selectAvatarId) + if smallFrame then + self.bgAvatar:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) end local avatarName = DataManager.PlayerData:getAvatarIconId(self.selectAvatarId) if avatarName then diff --git a/lua/app/userdata/player/player_data.lua b/lua/app/userdata/player/player_data.lua index b6bc9827..083754da 100644 --- a/lua/app/userdata/player/player_data.lua +++ b/lua/app/userdata/player/player_data.lua @@ -403,12 +403,19 @@ function PlayerData:getCanUnlockAvatarIds(checkData) return ids end --- 获取头像对应的英雄id -function PlayerData:getAvatarHeroId(id) +-- 获取头像背景 +function PlayerData:getAvatarBg(id) local cfg = ConfigManager:getConfig("avatar")[id] - if cfg then - return cfg.hero + if cfg.hero then + -- hero来源 + local hero = ConfigManager:getConfig("hero")[cfg.hero] + return hero and GConst.HERO_SMALL_FRAME_QLT[hero.qlt] + elseif cfg.item then + -- item来源 + local item = ConfigManager:getConfig("item")[cfg.item] + return item and GConst.HERO_SMALL_FRAME_QLT[item.qlt] end + return nil end -- 头像框-----------------------------------------------------------------------------------