|
|
RoleHeadShowItem = RoleHeadShowItem or BaseClass(BaseItem)
|
|
function RoleHeadShowItem:__init()
|
|
self.base_file = "newMainRole"
|
|
self.layout_file = "RoleHeadShowItem"
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
self.model = NewMainRoleModel:getInstance()
|
|
self.lock_state = false
|
|
self:Load()
|
|
end
|
|
|
|
--清除界面
|
|
function RoleHeadShowItem:__delete()
|
|
if self.event_id then
|
|
GlobalEventSystem:UnBind(self.event_id)
|
|
self.event_id = nil
|
|
end
|
|
|
|
if self.refresh_activate_id then
|
|
self.model:UnBind(self.refresh_activate_id)
|
|
self.refresh_activate_id = nil
|
|
end
|
|
end
|
|
function RoleHeadShowItem:Load_callback()
|
|
local node = {
|
|
"head:raw","select:obj","lock:obj", "activatable:obj", "equiped:obj"
|
|
}
|
|
self:GetChildren(node)
|
|
SetLocalScale(self.head.transform, 0.7,0.7,0.7)
|
|
|
|
self:InitEvent()
|
|
self:UpdateView()
|
|
self:SetSelect(self.select_state)
|
|
end
|
|
|
|
function RoleHeadShowItem:InitEvent()
|
|
local function onBtnClickHandler(target, x, y)
|
|
if target == self.gameObject then
|
|
if self.callback then
|
|
self.callback(self.index, self.data, self.lock_state)
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.gameObject, onBtnClickHandler, 2)
|
|
end
|
|
|
|
function RoleHeadShowItem:SetData(index, data, callback)
|
|
self.data = data
|
|
self.index = index
|
|
self.callback = callback or nil
|
|
-- 获取锁定状态
|
|
self.lock_state = self.data and self.data.status and self.data.status ~= 2 or false
|
|
if self.is_loaded then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function RoleHeadShowItem:UpdateView( )
|
|
if not self.data then return end
|
|
lua_resM:setOutsideRawImage(self, self.head_raw, GameResPath.GetHeadIcon(self.data.photo_id), true)
|
|
self:RefreshActivate()
|
|
self:RefreshEquipFlag()
|
|
self:SetLock()
|
|
end
|
|
|
|
-- 刷新头像锁定标识
|
|
function RoleHeadShowItem:SetLock()
|
|
self.lock_state = self.data and self.data.status and self.data.status == 0 or false
|
|
self.lock_obj:SetActive(self.lock_state)
|
|
end
|
|
|
|
-- 刷新头像激活标识
|
|
function RoleHeadShowItem:RefreshActivate( )
|
|
local status = self.data and self.data.status or 0
|
|
self.activatable_obj:SetActive(status == 1)
|
|
end
|
|
|
|
-- 刷新头像佩戴标识
|
|
function RoleHeadShowItem:RefreshEquipFlag( )
|
|
if not self.is_loaded then return end
|
|
local cur_head_id = RoleManager.Instance.mainRoleInfo.profile_photo_id
|
|
self.equiped_obj:SetActive(cur_head_id == self.data.photo_id)
|
|
end
|
|
|
|
function RoleHeadShowItem:SetSelect(bool)
|
|
self.select_state = bool
|
|
if self.is_loaded then
|
|
self.select_obj:SetActive(bool)
|
|
end
|
|
end
|