RankItem = RankItem or BaseClass(BaseItem)
|
|
local RankItem = RankItem
|
|
|
|
function RankItem:__init()
|
|
self.base_file = "rank"
|
|
self.layout_file = "RankItem"
|
|
self.model = RankModel:getInstance()
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function RankItem:Load_callback()
|
|
self.nodes = {
|
|
"bg:obj",
|
|
"select_bg:obj",--选中框
|
|
"vip_icon:img","sex_icon:img",--性别和vip
|
|
"type_icon:img:obj",--社团图标
|
|
"rank_icon:img",--前三排行icon
|
|
"head_con",--头像框
|
|
"rank:tmp",--三名以后的排名
|
|
"type_name:tmp","name:tmp",--名字和社团名字
|
|
"rank_power:tmp",--排行榜类型战力
|
|
"nameClick:obj",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
self.vipItem = RoleVipItem.New(self.vip_icon)
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function RankItem:AddEvents( )
|
|
local on_click = function ( click_obj , x, y)
|
|
if self.bg_obj == click_obj then
|
|
if not self.select then
|
|
if self.call_back and self.data then
|
|
self:SetSelect(not self.select)
|
|
self.call_back(self.item_id)
|
|
end
|
|
end
|
|
elseif self.nameClick_obj == click_obj then
|
|
self.operation_x = x
|
|
self.operation_y = y
|
|
local chat_info = {}
|
|
if self.model.is_cs_rank then
|
|
chat_info.ser_id = self.data.server_id
|
|
else
|
|
chat_info.ser_id = RoleManager.Instance:GetMainRoleServerId()
|
|
end
|
|
if RoleManager.Instance.mainRoleInfo.level < Config.Modulesub["110@2"].open_lv then
|
|
Message.show("查看功能未开放")
|
|
return
|
|
end
|
|
|
|
if chat_info.ser_id ~= RoleManager.Instance:GetMainRoleServerId() then--跨服玩家先请求figure数据
|
|
self.model.request_cs_rank_role_figure = true
|
|
self.model:Fire(RankModel.REQUEST_CCMD_EVENT, 22109, self.data.player_id)
|
|
else
|
|
--请求协议获取对方信息
|
|
if self.data.player_id and chat_info.ser_id then
|
|
SocialityModel:getInstance():Fire(SocialityModel.REQUEST_OTHER_INFO, self.data.player_id, x, y, chat_info)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.bg_obj, on_click)
|
|
AddClickEvent(self.nameClick_obj, on_click)
|
|
|
|
local function show_cs_operation_view(vo)
|
|
if vo.role_id == self.data.player_id and not self.model.request_cs_role_by_top then
|
|
local chat_info = vo
|
|
chat_info.ser_id = self.data.server_id
|
|
SocialityModel:getInstance():Fire(SocialityModel.REQUEST_OTHER_INFO, self.data.player_id, self.operation_x, self.operation_y, chat_info)
|
|
end
|
|
end
|
|
self:BindEvent(self.model,RankModel.SHOW_CS_OPERATION_VIEW,show_cs_operation_view)
|
|
|
|
end
|
|
|
|
function RankItem:SetSelect(bool)
|
|
if self.is_loaded then
|
|
if self.select ~= bool then
|
|
self.select = bool
|
|
self.select_bg_obj:SetActive(bool)
|
|
end
|
|
self.isSelect = nil
|
|
else
|
|
self.isSelect = bool
|
|
end
|
|
end
|
|
|
|
function RankItem:UpdateView( )
|
|
--vip图标
|
|
self.vipItem:SetData(self.data.vip_flag,self.data.sup_vip_type)
|
|
|
|
--排名
|
|
if self.data.rank <= 3 then
|
|
lua_resM:setImageSprite(self, self.rank_icon_img, "rank_asset","rank_rank_"..self.data.rank, true)
|
|
self.rank_tmp.text = ""
|
|
else
|
|
lua_resM:setImageSprite(self, self.rank_icon_img, "uiComponent_asset","com_empty")
|
|
self.rank_tmp.text = self.data.rank
|
|
end
|
|
|
|
--名字
|
|
if self.model.is_cs_rank then
|
|
self.name_tmp.text = GetCSLongName(self.data.name,self.data.server_num)
|
|
else
|
|
self.name_tmp.text = self.data.name
|
|
end
|
|
--性别
|
|
lua_resM:setImageSprite(self, self.sex_icon_img, "common_asset", self.data.sex == 1 and "com_boy" or "com_girl",true)
|
|
local pos_x, pox_y = GetAnchoredPosition(self.name)
|
|
SetAnchoredPositionX(self.sex_icon,pos_x + self.name_tmp.preferredWidth -18)
|
|
|
|
local rank_des_type = "战力:"
|
|
if self.model.selectId >= 2000 and self.model.selectId <= 2004 then--战力榜
|
|
rank_des_type = "战力:"
|
|
elseif self.model.selectId >= 3000 and self.model.selectId <= 3004 then--等级榜
|
|
rank_des_type = "等级:"
|
|
elseif self.model.selectId >= 1520 and self.model.selectId <= 1524 then--装备榜
|
|
rank_des_type = "战力:"
|
|
elseif self.model.selectId == 411 or self.model.selectId == 413 or self.model.selectId == 112 then--称号&时装&聊天装扮
|
|
rank_des_type = "收集数:"
|
|
elseif self.model.selectId == 163 then--孩子
|
|
rank_des_type = "战力:"
|
|
elseif self.model.selectId >= 1461 and self.model.selectId <= 1464 then--进阶
|
|
rank_des_type = ""
|
|
elseif self.model.selectId >= 1465 and self.model.selectId <= 1468 then--ai娘
|
|
rank_des_type = "等级:"
|
|
elseif self.model.selectId == 2231 then--人气值
|
|
rank_des_type = "人气:"
|
|
elseif self.model.selectId == 2232 then--壕气值
|
|
rank_des_type = "壕气:"
|
|
elseif self.model.selectId == 407 then--社团
|
|
rank_des_type = "社团战力:"
|
|
end
|
|
|
|
--排行榜分数
|
|
if self.model.selectId >= 1461 and self.model.selectId <= 1464 then--进阶
|
|
self.rank_power_tmp.text = string.format(" %s阶%s星", self.data.first_value, self.data.second_value)
|
|
elseif self.model.selectId >= 1465 and self.model.selectId <= 1468 then--ai娘
|
|
self.rank_power_tmp.text = rank_des_type..self.data.first_value
|
|
else
|
|
self.rank_power_tmp.text = rank_des_type..self.data.first_value
|
|
end
|
|
|
|
if self.isSelect ~= nil then
|
|
self:SetSelect(self.isSelect)
|
|
end
|
|
if self.item_id == self.model.rank_req_idx then
|
|
self.model:Fire(RankModel.RANK_LIST_UPDATE_NEXT, self.item_id)
|
|
end
|
|
end
|
|
|
|
function RankItem:SetData(item_id,data,call_back,tab_data,sub_tab_id)
|
|
self.item_id = item_id
|
|
self.data = data
|
|
self.call_back = call_back
|
|
self.tab_data = tab_data
|
|
self.sub_tab_id = sub_tab_id
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function RankItem:__delete( )
|
|
if self.vipItem then
|
|
self.vipItem:DeleteMe()
|
|
self.vipItem = nil
|
|
end
|
|
end
|