玩家头像抽象成独立cell
This commit is contained in:
parent
c2734a66fb
commit
cbec901af5
@ -171,6 +171,7 @@ GConst.TYPEOF_LUA_CLASS = {
|
|||||||
-- cell
|
-- cell
|
||||||
ITEM_CELL = "app/ui/common/cell/item_cell",
|
ITEM_CELL = "app/ui/common/cell/item_cell",
|
||||||
HERO_CELL = "app/ui/common/cell/hero_cell",
|
HERO_CELL = "app/ui/common/cell/hero_cell",
|
||||||
|
PLAYER_HEAD_CELL = "app/ui/common/cell/player_head_cell",
|
||||||
REWARD_CELL = "app/ui/common/cell/reward_cell",
|
REWARD_CELL = "app/ui/common/cell/reward_cell",
|
||||||
LARGE_HERO_CELL = "app/ui/common/cell/large_hero_cell",
|
LARGE_HERO_CELL = "app/ui/common/cell/large_hero_cell",
|
||||||
POP_HERO_CELL = "app/ui/shop/cell/pop_hero_cell",
|
POP_HERO_CELL = "app/ui/shop/cell/pop_hero_cell",
|
||||||
|
|||||||
36
lua/app/ui/common/cell/player_head_cell.lua
Normal file
36
lua/app/ui/common/cell/player_head_cell.lua
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
local PlayerHeadCell = class("PlayerHeadCell", BaseCell)
|
||||||
|
|
||||||
|
function PlayerHeadCell:init()
|
||||||
|
local uiMap = self.baseObject:genAllChildren()
|
||||||
|
|
||||||
|
self.imgFrame = uiMap["player_head_cell.img_frame"]
|
||||||
|
self.imgAvatar = uiMap["player_head_cell.img_avatar"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayerHeadCell:refresh()
|
||||||
|
-- 头像
|
||||||
|
local avatarName = DataManager.PlayerData:getAvatarIconId(DataManager.PlayerData:getUsingAvatarId())
|
||||||
|
if avatarName then
|
||||||
|
self.imgAvatar:setSprite(GConst.ATLAS_PATH.ICON_HERO, avatarName, function()
|
||||||
|
self.imgAvatar:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 头像框
|
||||||
|
local frameName = DataManager.PlayerData:getFrameIconId(DataManager.PlayerData:getUsingFrameId())
|
||||||
|
if frameName then
|
||||||
|
self.imgFrame:setSprite(GConst.ATLAS_PATH.ICON_AVATAR, frameName, function()
|
||||||
|
self.imgFrame:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 红点
|
||||||
|
if DataManager.PlayerData:hasNewAvatar() or DataManager.PlayerData:hasNewFrame() then
|
||||||
|
self.baseObject:addRedPoint(50, 50, 0.7)
|
||||||
|
else
|
||||||
|
self.baseObject:removeRedPoint()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return PlayerHeadCell
|
||||||
10
lua/app/ui/common/cell/player_head_cell.lua.meta
Normal file
10
lua/app/ui/common/cell/player_head_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 48bedef5797f1be4b91882994a4ff540
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -596,36 +596,18 @@ function MainCityUI:initPlayerInfo()
|
|||||||
self.playerSlider = self.uiMap["main_ui.player_node.info.slider.img_prog"]
|
self.playerSlider = self.uiMap["main_ui.player_node.info.slider.img_prog"]
|
||||||
self.playerLvTx = self.uiMap["main_ui.player_node.info.slider.tx_lv"]
|
self.playerLvTx = self.uiMap["main_ui.player_node.info.slider.tx_lv"]
|
||||||
self.playerNameTx = self.uiMap["main_ui.player_node.info.tx_name"]
|
self.playerNameTx = self.uiMap["main_ui.player_node.info.tx_name"]
|
||||||
self.playerAvatarImg = self.uiMap["main_ui.player_node.avatar.img_avatar"]
|
self.headCell = CellManager:addCellComp(self.uiMap["main_ui.player_node.player_head_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_HEAD_CELL)
|
||||||
self.playerFrameImg = self.uiMap["main_ui.player_node.avatar.img_frame"]
|
|
||||||
self.playerAvatar = self.uiMap["main_ui.player_node.avatar"]
|
|
||||||
self.uiMap["main_ui.player_node"]:addClickListener(function ()
|
self.uiMap["main_ui.player_node"]:addClickListener(function ()
|
||||||
UIManager:showUI("app/ui/player_info/player_info_ui")
|
UIManager:showUI("app/ui/player_info/player_info_ui")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:refreshPlayerInfo()
|
function MainCityUI:refreshPlayerInfo()
|
||||||
|
self.headCell:refresh()
|
||||||
local lv = DataManager.PlayerData:getLv()
|
local lv = DataManager.PlayerData:getLv()
|
||||||
self.playerLvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, lv))
|
self.playerLvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, lv))
|
||||||
self.playerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.PlayerData:getExpPercent()
|
self.playerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.PlayerData:getExpPercent()
|
||||||
self.playerNameTx:setText(DataManager.PlayerData:getNickname())
|
self.playerNameTx:setText(DataManager.PlayerData:getNickname())
|
||||||
local avatarName = DataManager.PlayerData:getAvatarIconId(DataManager.PlayerData:getUsingAvatarId())
|
|
||||||
if avatarName then
|
|
||||||
self.playerAvatarImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, avatarName, function()
|
|
||||||
self.playerAvatarImg:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
local frameName = DataManager.PlayerData:getFrameIconId(DataManager.PlayerData:getUsingFrameId())
|
|
||||||
if frameName then
|
|
||||||
self.playerFrameImg:setSprite(GConst.ATLAS_PATH.ICON_AVATAR, frameName, function()
|
|
||||||
self.playerFrameImg:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
if DataManager.PlayerData:hasNewAvatar() or DataManager.PlayerData:hasNewFrame() then
|
|
||||||
self.playerAvatar:addRedPoint(50, 50, 0.7)
|
|
||||||
else
|
|
||||||
self.playerAvatar:removeRedPoint()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:initTopNode()
|
function MainCityUI:initTopNode()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user