源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

123 lines
3.5 KiB

CecretChatItem = CecretChatItem or BaseClass(BaseItem)
function CecretChatItem:__init()
self.base_file = "chat"
self.layout_file = "cecretChatItem"
self.model = ChatModel:getInstance()
self.vo = nil
self.index = nil
self:Load()
end
function CecretChatItem:Load_callback()
self.headIcon = self:GetChild("headIcon"):GetComponent("Image")
self.deleteBtn = self:GetChild("deleteBtn").gameObject
self.chatBtn = self:GetChild("chatBtn").gameObject
self.titleIcon = self:GetChild("titleIcon"):GetComponent("Image")
self.nameText = self:GetChild("nameText"):GetComponent("Text")
self.levelText = self:GetChild("levelText"):GetComponent("Text")
self.vipIcon = self:GetChild("vipIcon"):GetComponent("Image")
self.vip_con = self:GetChild("vipIcon").gameObject
self.redPoint = self:GetChild("redPoint").gameObject
self.amount = self:GetChild("redPoint/amount"):GetComponent("Text")
self.title_con = self:GetChild("titleIcon")
self.name_con = self:GetChild("nameText")
if self.need_refreshData then
self:SetData()
end
local function onClickBtnHandler(target)
if target == self.deleteBtn then
local function ok()
self.model:Fire(ChatModel.DELETE_CECRET_CHAT_ITEM,self.index,self.vo.key_id)
end
Alert.show("是否确定删除?",Alert.Type.Two,ok)
elseif target == self.chatBtn then
if self.vo then
GlobalEventSystem:Fire(EventName.OPEN_CHAT_CECRET_CHANNEL,self.vo.key_id,self.vo.key_name)
end
end
end
AddClickEvent(self.deleteBtn,onClickBtnHandler)
AddClickEvent(self.chatBtn,onClickBtnHandler)
end
function CecretChatItem:SetData(index,vo)
self.vo = vo or self.vo
self.index = index or self.index
local info = self:GetPlayerInfo()
if info == nil then return end
self.vo.key_name = info.name
self.vo.key_vip = info.vip_flag
self.vo.key_touxian = info.touxian
if self.is_loaded then
self.need_refreshData = false
self.nameText.text = info.name
self.levelText.text = info.level
lua_resM:setImageSprite(self,self.headIcon,"mainUI_asset","head_circle_" .. info.career, true)
local result,num = self.model:NeedShowCecretItemRedPoint(self.vo.key_id)
self:SetRedPointState(result,num)
local config = Config.Title[self.vo.key_touxian]
if config then
RoleTitleModel:getInstance():SetTitleImage(self,self.titleIcon,config.icon_name)
end
self:SetPositionFormat()
self.transform.localPosition = Vector3(0, -(self.index-1) * 100, 0)
else
self.need_refreshData = true
end
end
--设置VIP 头衔 位置的格式
function CecretChatItem:SetPositionFormat()
if self.vo then
local is_vip = self.vo.key_vip > 0
local x = is_vip and 140 or 105
self.vip_con:SetActive(is_vip)
if self.vo.key_touxian == 0 then
self.title_con.gameObject:SetActive(false)
self.name_con.localPosition = Vector3(x ,-34,0)
else
self.title_con.gameObject:SetActive(true)
self.title_con.localPosition = Vector3(x ,-32,0)
self.name_con.localPosition = Vector3(x + self.titleIcon.preferredWidth + 14,-34,0)
end
end
end
function CecretChatItem:SetSelect(bool)
end
function CecretChatItem:ShowRedPoint()
if self.redPoint ~= nil then
self.redPoint:SetActive(true)
end
end
function CecretChatItem:HideRedPoint()
if self.redPoint ~= nil then
self.redPoint:SetActive(false)
end
end
function CecretChatItem:SetRedPointState(result,num)
if result then
self:ShowRedPoint()
self.amount.text = num
else
self:HideRedPoint()
end
end
function CecretChatItem:GetPlayerInfo()
if self.vo ~= nil then
if self.vo.key_id == self.vo.player_list[1].player_id then
return self.vo.player_list[1]
else
return self.vo.player_list[2]
end
end
end