源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

172 linhas
5.6 KiB

SocialityFriendSelectItem = SocialityFriendSelectItem or BaseClass(BaseItem)
function SocialityFriendSelectItem:__init()
self.base_file = "sociality"
self.layout_file = "SocialityFriendSelectItem"
self.model = SocialityModel:getInstance()
self:Load()
end
function SocialityFriendSelectItem:Load_callback()
self.nodes = {
"nameCon","headCon",
"nameCon/name:tmp","heartText:tmp","heart:img",
"nameCon/sex:img","vip",
"chooseBtn:obj:img", "chooseBg:obj", "getFriendBtn:obj", "sendGiftBtn:obj", "emptyBlock:obj",
}
self:GetChildren(self.nodes)
self.emptyBlock_obj:SetActive(false)
self.roleItem = HeadRoleItem.New(self.headCon)
self.roleItem:SetItemSize(70,70)
self.vipItem = RoleVipItem.New(self.vip)
self:InitEvent()
if self.need_refreshData then
self:SetData(self.info,self.index)
self:SetSelected(self.is_selected)
end
end
function SocialityFriendSelectItem:InitEvent()
local on_click = function ( click_obj )
if self.chooseBtn_obj == click_obj or self.chooseBg_obj == click_obj then
self.model.need_show_operation = "none"--收回14010协议后既不打开互动面板,也不对送礼界面进行开闭
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14010, self.info.role_id)
self.model:Fire(SocialityModel.SELECT_FIREND, self.info, self.op_type)
GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FRIEND_SEL_VIEW, false)
self.model.select_info = nil
lua_resM:setImageSprite(self, self.chooseBtn_img, "sociality_asset","sociality_btn_accept")
elseif self.getFriendBtn_obj == click_obj then
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
self.getFriendBtn_obj:SetActive(false)
elseif self.sendGiftBtn_obj == click_obj then
local role_vo = SocialityModel:getInstance():GetFriendData(self.info.role_id)
role_vo.vip_flag = role_vo.vip --好友那边的vip_flag字段自动转化成vip了,会拿不到vip数据,要重新转换回来
GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, role_vo)
GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FRIEND_SEL_VIEW, false)
end
end
AddClickEvent(self.chooseBtn_obj, on_click)
AddClickEvent(self.chooseBg_obj, on_click)
AddClickEvent(self.getFriendBtn_obj, on_click)
AddClickEvent(self.sendGiftBtn_obj, on_click)
end
function SocialityFriendSelectItem:SetData(info,index,op_type)
if not info or not info.sex then return end
self.info = info
self.index = index
self.op_type = op_type or 1--点击类型,1为显示右侧按钮,2为不显示按钮,整个区域做点击热区
if not self.is_loaded then
self.need_refreshData = true
return
end
self.need_refreshData = false
if self.roleItem then
local head_data = {
vo = {
id = info.role_id,
server_id = info.ser_id,
career = info.career,
sex = info.sex,
turn = info.turn,
picture_ver = info.picture_ver,
picture = info.picture,
profile_photo_id = info.profile_photo_id,
dress_board_id = info.dress_board,
level = info.lv,
empty_head = false, -- 是否是空数据头像
}
}
self.roleItem:SetData(head_data)
end
local role_lv = WordManager:GetRoleLevel(info.lv,info.turn)
-- self.level_tmp.text = role_lv
self.vipItem:SetData(info.vip,info.sup_vip_type)
if self.info.vip and self.info.vip > 0 then
SetAnchoredPositionX(self.nameCon,36)
else
SetAnchoredPositionX(self.nameCon,-3)
end
self.name_tmp.text = info.role_name
local sex_res = info.sex == 1 and "com_boy" or "com_girl"
lua_resM:setImageSprite(self, self.sex_img, "common_asset", sex_res, true)
SetAnchoredPositionX(self.sex,self.name_tmp.preferredWidth+4)
local lv = self.model:GetLvByIntimacy(info.intimacy)
local cfg = Config.Intimacylv[lv]
if not self.model:IsRelaviveType(self.info.role_id, Config.ConfigSocial.RelativeType.friend)
or self.model:IsOneWayToFriend(self.info.role_id) then
if self.op_type == 1 then
self.heartText_tmp.text = string.format("%s(临时好友)",info.intimacy)
self.chooseBtn_obj:SetActive(true)
self.getFriendBtn_obj:SetActive(false)
elseif self.op_type == 2 then
self.heartText_tmp.text = string.format("<color=#ff203a>%s(临时好友)</color>",info.intimacy)
self.chooseBtn_obj:SetActive(false)
self.getFriendBtn_obj:SetActive(true)
end
self.sendGiftBtn_obj:SetActive(false)
else
if self.op_type == 1 then
self.heartText_tmp.text = string.format("%s(%s)",info.intimacy,Trim(cfg.name))
elseif self.op_type == 2 then
if info.intimacy >= MateModel:GetInstance():GetKeyValueConf("mate_intimacy") then
self.heartText_tmp.text = string.format("%s(%s)",info.intimacy,Trim(cfg.name))
self.chooseBtn_obj:SetActive(true)
self.sendGiftBtn_obj:SetActive(false)
else
self.heartText_tmp.text = string.format("<color=#ff203a>%s(%s)</color>",info.intimacy,Trim(cfg.name))
self.chooseBtn_obj:SetActive(false)
self.sendGiftBtn_obj:SetActive(true)
end
end
self.getFriendBtn_obj:SetActive(false)
end
lua_resM:setImageSprite(self, self.heart_img, "sociality_asset","sociality_intimacy_"..lv,true)
-- self.chooseBtn_obj:SetActive(self.op_type == 1)
-- self.chooseBg_obj:SetActive(self.op_type == 2)
end
function SocialityFriendSelectItem:SetSelected(bool)
self.is_selected = bool
if not self.is_loaded then return end
-- if self.selectBg_obj then
-- self.selectBg_obj:SetActive(bool)
-- end
if bool then
self.model.select_info = self.info
end
end
function SocialityFriendSelectItem:__delete( )
if self.roleItem then
self.roleItem:DeleteMe()
self.roleItem = nil
end
if self.vipItem then
self.vipItem:DeleteMe()
self.vipItem = nil
end
end