源战役客户端
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.
 
 
 
 
 

545 lines
18 KiB

OperationView = OperationView or BaseClass(BaseView)
function OperationView:__init()
self.base_file = "sociality"
self.layout_file = "OperationView"
self.layer_name = "Top"
self.destroy_imm = false
self.use_background = true
self.click_bg_toClose = true
self.background_alpha = 0
self.hide_maincancas = false
self.is_set_zdepth = true
self.open_wnd_anim = 0
self.item_list = {}
-- self.nature_item_list = {}
self.model = SocialityModel:getInstance()
-- self:AddPreLoadList("sociality",{"OperationItem"})
self.load_callback = function()
self:LoadSuccess()
self:InitEvent()
end
self.open_callback = function()
self:UpdateView()
end
self.destroy_callback = function()
self:Remove()
end
end
function OperationView:Open(info)
self.info = info
self.is_out_ser = false
if info.ser_id and info.ser_id ~= RoleManager.Instance:GetMainRoleServerId() then
self.is_out_ser = true -- 发现是外服玩家就另外设定
-- self.info.combat = self.info.power and self.info.power or 0 -- 战力字段不同修改下
elseif info.is_local == 1 then--是外服
self.is_out_ser = true -- 发现是外服玩家就另外设定
end
BaseView.Open(self)
end
function OperationView:Remove()
if self.roleItem then
self.roleItem:DeleteMe()
end
if self.vipItem then
self.vipItem:DeleteMe()
end
if self.level_item then
self.level_item:DeleteMe()
self.level_item = nil
end
for k,v in pairs(self.item_list) do
v:DeleteMe()
end
self.item_list = {}
-- for k,v in pairs(self.nature_item_list) do
-- v:DeleteMe()
-- end
-- self.nature_item_list = {}
end
function OperationView:LoadSuccess()
self.nodes = {
"InfoCon/nameCon/name:tmp",
"InfoCon/fight:txt",
"InfoCon/nameCon/sex:img",
"InfoCon/nameCon/vip",
"InfoCon/ScrollView",
"InfoCon/ScrollView/Viewport/Content",
"InfoCon/headCon",
"InfoCon/imgBg:img",
"InfoCon",
"InfoCon/natureCon", -- 用来放性格标签item
}
self:GetChildren(self.nodes)
self.scroll_view_rect = self.ScrollView:GetComponent("ScrollRect")
self.scroll_view_rect.horizontal = false
self.scroll_view_rect.vertical = false
self.roleItem = HeadRoleItem.New(self.headCon)
self.roleItem:SetItemSize(73,73)
self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
self.vipItem = RoleVipItem.New(self.vip)
self.start_pos = self.ScrollView.anchoredPosition.y -- 默认的位置
lua_resM:setOutsideImageSprite(self,self.imgBg_img,GameResPath.GetViewBigBg("operation_view_bg"), false)
end
function OperationView:InitEvent()
local function ANS_CHECK_BIND_MATE( result_id )
if result_id == 1490025 then
--你未添加对方为好友
local function call_yes( )
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
end
Alert.show('您尚未添加对方为好友,\n请添加好友后再申请羁绊?', Alert.Type.Two, call_yes, nil, '添加好友', '取消')
elseif result_id == 1490003 then
--对方未添加你为好友
local function call_yes( )
self.model:Fire(SocialityModel.CHAT_WITH_ROLEID,self.info.role_id)
end
Alert.show('对方尚未添加您为好友,\n请添加好友后再申请羁绊?', Alert.Type.Two, call_yes, nil, '前往提醒', '取消')
elseif result_id == 1490004 then
--亲密度不足
local function call_yes( )
GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, self.info)
end
local need_num = MateModel.GetInstance():GetKeyValueConf("mate_intimacy") or 0
local str = string.format('您与对方的亲密度尚未达到%s,\n赠送礼物可增加亲密度,快去试试吧!',HtmlColorTxt( need_num , '#fa1022'))
Alert.show( str, Alert.Type.Two, call_yes, nil, '前往赠送', '取消' )
elseif result_id == 1 then
-- 可以打开羁绊界面
MateModel:GetInstance():Fire(MateConst.OPEN_ASK_MATE_VIEW,self.info.role_id,self.info)
end
self:Close()
end
self:BindEvent(MateModel:GetInstance(), MateConst.ANS_CHECK_BIND_MATE, ANS_CHECK_BIND_MATE)
end
function OperationView:UpdateView( )
if _use_delete_method then return end
if not self.info then return end
--兼容一些字段不一样的协议
if not self.info.role_id and self.info.player_id then
self.info.role_id = self.info.player_id
end
local vo = self.info
if vo.dress_list then
for i,v in ipairs(vo.dress_list) do
--1气泡 2相框
local icon_name = v.dress_id
if v.dress_type == 2 then
vo.dress_board = icon_name
end
end
end
if self.roleItem then
local head_data = {
vo = {
id=vo.role_id,
career=vo.career,
level=vo.level,
sex=vo.sex,
turn=vo.turn,
dress_board_id = vo.dress_board,
picture_ver = vo.picture_ver,
picture = vo.picture,
profile_photo_id = vo.profile_photo_id,
use_bg = 2,
do_not_click = true,
},
}
self.roleItem:SetData(head_data)
end
if not self.name_tmp then return end
if vo.server_num ~= RoleManager.Instance.mainRoleInfo.server_num then
self.name_tmp.text = GetCSLongName(vo.name,vo.server_num,false)
else
self.name_tmp.text = vo.name
end
SetAnchoredPositionX(self.sex_img.transform,self.name_tmp.preferredWidth+46)
self.vipItem:SetData(vo.vip_flag,vo.sup_vip_type)
local sex_flag = ""
if vo.sex == 1 then
sex_flag = "boy"
elseif vo.sex == 2 then
sex_flag = "girl"
end
--战力
self.fight_txt.text = vo.power or 0
lua_resM:setImageSprite(self,self.sex_img,"common_asset","com_"..sex_flag,true)
local tb = {}
local cfg = Config.ConfigSocial.PlayerOpera
local main_role = RoleManager.Instance.mainRoleInfo
local main_team_id = main_role.team_id
local rela = vo.rela
vo.position = vo.position or 0
local is_friend = rela==1 or rela==2
local is_strange = rela==0 or rela==nil
local is_same_guild = vo.guild_id ~= 0 and vo.guild_id == main_role.guild_id -- 是否同社团
local can_kick = is_same_guild and vo.position and vo.position > main_role.position
local can_pro = is_same_guild and main_role.position == 1
local can_transfer = is_same_guild and main_role.position == 1
local can_fire = is_same_guild and main_role.position <= 2 and vo.position > main_role.position and vo.position <= 3
local is_lover = main_role.is_marriage == 1 and main_role.marriage_id == vo.role_id --是否情侣
local is_marrger = main_role.is_marriage == 2 and main_role.marriage_id == vo.role_id --是否夫妻
local friend_lv = Config.Moduleid[140].open_lv
local show_social = vo.level >= friend_lv and main_role.level>=friend_lv
local can_pro_vice = is_same_guild and main_role.position <= 2 and vo.position > main_role.position
local is_in_black_list = self.model:IsRelaviveType(vo.role_id,Config.ConfigSocial.RelativeType.black)
local is_csgwar_overlord = main_role.is_overlord == 1 --是否霸主
-------------------------
local mate_lv = GetModuleOpenLevel( 149 )
local mate_lv_ok = main_role.level >= mate_lv and vo.level >= mate_lv
local can_mate = mate_lv_ok and (not MateModel:GetInstance():GetIsMateByRoleId( vo.role_id )) --是否可以羁绊
for k,v in ipairs(cfg) do
v.secondTitle = false
if is_in_black_list and show_social then
--只保留查看、取消拉黑、删除好友
if v.id == 1 then --查看
table.insert(tb, v)
elseif v.id == 6 then --取消拉黑
v.secondTitle = true
table.insert(tb, v)
elseif v.id == 5 then
if is_friend then
v.secondTitle = true --删除好友
table.insert(tb, v)
end
end
elseif self.is_out_ser then
if v.id == 1 then --查看
table.insert(tb, v)
elseif v.id == 25 then
--霸主禁言
if is_csgwar_overlord then
table.insert(tb, v)
end
end
else
if v.id == 5 then
if show_social then --添加好友
if is_friend then
v.secondTitle = true --删除好友
end
table.insert(tb, v)
end
elseif v.id == 1 then
--查看
table.insert(tb, v)
elseif v.id == 6 then
--拉黑
if is_in_black_list then
v.secondTitle = true --取消拉黑
end
if show_social then
table.insert(tb, v)
end
elseif v.id == 2 then
--送礼
table.insert(tb, v)
elseif v.id == 3 then
--邀请组队
table.insert(tb, v)
elseif v.id == 4 then
--申请入队
table.insert(tb, v)
elseif v.id == 15 then
table.insert(tb,v)
elseif v.id == 16 then
table.insert(tb,v)
elseif v.id == 8 then
--踢出社团
if can_kick then
table.insert(tb, v)
end
elseif v.id == 9 then
--提升副团长
if can_pro then
table.insert(tb, v)
end
elseif v.id == 10 then
if can_transfer then
table.insert(tb, v)
end
elseif v.id == 19 then
-- 分手
if is_lover then
table.insert(tb, v)
end
elseif v.id == 20 then
-- 离婚
if is_marrger then
table.insert(tb, v)
end
elseif v.id == 11 then
if can_fire then
table.insert(tb, v)
end
elseif v.id == 12 then
--申请羁绊
if can_mate then
table.insert(tb, v)
end
elseif v.id == 13 then
--求婚
if is_lover then
table.insert(tb, v)
end
elseif v.id == 14 then
--私聊
if show_social and not SocialityModel:getInstance().sociality_is_open then
if is_friend or is_strange then
table.insert(tb, v)
end
end
elseif v.id == 21 then
--互动
table.insert(tb,v)
elseif v.id == 22 then
--提升长老
if can_pro_vice then
table.insert(tb,v)
end
elseif v.id == 23 then
--转移队长
if main_team_id == self.info.team_id and TeamModel:getInstance().is_leader then
table.insert(tb, v)
end
elseif v.id == 24 then
--踢出队伍
if main_team_id == self.info.team_id and TeamModel:getInstance().is_leader then
table.insert(tb, v)
end
elseif v.id == 25 then
--霸主禁言
if is_csgwar_overlord then
table.insert(tb, v)
end
end
end
end
-- 性格展示 2021.3.1 砍了
local nature_ch = 0 -- 性格展示占用的高度
-- local tag_data_list = NatureModel:getInstance():DealTagData( self.info.nature_tips )
-- local item_height = 25
-- local item_width = 64
-- local inter_x = 1
-- local inter_y = 10
-- local start_x = 1
-- local colunm = 4
-- for k,v in pairs(self.nature_item_list) do
-- v:SetVisible(false)
-- end
-- if #tag_data_list > 0 then
-- for i,v in ipairs(tag_data_list) do
-- self.nature_item_list[i] = self.nature_item_list[i] or NatureTagItem.New(self.natureCon)
-- local item = self.nature_item_list[i]
-- item:SetData(v, 0.58)
-- item:SetAnchoredPosition( start_x + ((i - 1) % colunm) * (item_width+inter_x), -(math.ceil(i / colunm) - 1) * (item_height+inter_y) )
-- item:SetVisible(true)
-- end
-- nature_ch = 35 * math.ceil(#tag_data_list / colunm)
-- end
-- 计算背景大小 以及 scroll大小
local ch = math.ceil(#tb/2)*(OperationItem.Height+7) + nature_ch
self.ScrollView.sizeDelta = Vector2(280, ch)
local heigh = ch + 108
self.imgBg.sizeDelta = Vector2(280, heigh)
SetAnchoredPositionY(self.ScrollView, self.start_pos + (70 - nature_ch) )
--创建按钮
local call_back = function( vo )
self:ClickOperation(vo)
end
for i,v in ipairs(tb) do
local item = self.item_list[i]
if not item then
item = OperationItem.New(self.Content)
self.item_list[i] = item
end
item:SetVisible(true)
item:SetData(v, call_back)
local x = (OperationItem.Width+7)*((i-1)%2)
local y = -(OperationItem.Height+7)*(math.floor((i-1)/2))+1
item:SetPosition(x,y)
end
for i=#tb+1, #self.item_list do
self.item_list[i]:SetVisible(false)
end
--设置坐标
local x, y = 0,0
if SocialityModel:getInstance().operationPos then
x,y = SocialityModel:getInstance().operationPos.x, SocialityModel:getInstance().operationPos.y
else
local mousePos = SocialityModel:getInstance().mousePos or {x=0, y=0}
x, y = ScreenToViewportPoint(mousePos.x, mousePos.y)
if x+388 > ScreenWidth then
x = ScreenWidth-368-20
elseif x<20 then
x = 20
end
if y-heigh < 0 then
y = heigh+20
elseif y > ScreenHeight then
y = ScreenHeight-20
end
end
self.InfoCon.transform.anchoredPosition = Vector3(x, y, 0)
end
--点击选项处理
function OperationView:ClickOperation( vo )
if not self.info then return end
local mask_close = false
if vo.id == 1 then
--查看
GlobalEventSystem:Fire(EventName.OPEN_LOOK_ROLE_INFO_VIEW,self.info.role_id,self.info.rela)
elseif vo.id == 2 then
--送鲜花
GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, self.info)
elseif vo.id == 3 then
--邀请组队
GlobalEventSystem:Fire(TeamModel.INVITE_PLAYER,{self.info.role_id})
elseif vo.id == 4 then
--申请入队
if not self.info.team_id or self.info.team_id == 0 then
Message.show("该玩家没有队伍")
return
end
GlobalEventSystem:Fire(TeamModel.APPLY_JOIN_TEAM, self.info.team_id)
elseif vo.id == 5 then
if vo.secondTitle then
--删除好友
local function ok_callback( )
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14007, 1, self.info.role_id)
end
-- Alert.show("删除好友,亲密度将清零,是否继续?", Alert.Type.Two, ok_callback, nil,"继续", "取消")
Alert.show("确定删除好友?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
else
--添加好友
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
end
elseif vo.id == 6 then
if vo.secondTitle then
--取消拉黑
ChatModel:getInstance():Fire(ChatModel.SEND_PROTOCAL,11066,2,self.info.role_id)
else
--拉黑
local function ok_callback( )
ChatModel:getInstance():Fire(ChatModel.SEND_PROTOCAL,11066,1,self.info.role_id)
end
Alert.show(string.format("确认将 <color=#10aaf1>%s</color> 拉入黑名单吗?", self.info.name),
Alert.Type.Two, ok_callback, nil,"确定", "取消")
end
elseif vo.id == 7 then
--删除仇人
self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14007, 4, self.info.role_id)
elseif vo.id == 8 then
--踢出社团
local function ok_callback()
GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40014,self.info.role_id)
end
Alert.show(string.format("确定将成员<color=#4eae1a>%s</color>踢出社团吗?", self.info.name),
Alert.Type.Two, ok_callback, nil,"确定", "取消")
elseif vo.id == 9 then
--提升副团长
local function ok_callback()
GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,2)
end
Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为副团职位吗?", self.info.name), Alert.Type.Two, ok_callback)
elseif vo.id == 10 then
--转让团长
local function ok_callback()
GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,1)
end
Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为团长职位吗?", self.info.name), Alert.Type.Two, ok_callback)
elseif vo.id == 11 then
--撤职
local function ok_callback()
GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,5)
end
local str = Trim(Config.Guildpos[self.info.position].name)
Alert.show(string.format("确定移除<color=#4eae1a>%s</color>的%s职位吗?", self.info.name,str), Alert.Type.Two, ok_callback)
elseif vo.id == 12 then
--申请羁绊
MateModel:GetInstance():Fire(MateConst.REQ_CHECK_BIND_MATE, self.info.role_id)
mask_close = true
-- elseif vo.id == 13 then
-- --求婚
-- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17230, self.info.role_id, 2)
elseif vo.id == 14 then
--私聊
local is_in_black_list = self.model:IsRelaviveType(self.info.role_id,Config.ConfigSocial.RelativeType.black)
if is_in_black_list then
Message.show("无法向黑名单玩家发消息哦!","fault")
else
self.model:Fire(SocialityModel.CHAT_WITH_ROLEID,self.info.role_id)
end
-- self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,14020,self.info.role_id)--先把对方加入联系人列表中
-- ChatModel:getInstance().need_chat_key = self.info.role_id
-- GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW, 1)
elseif vo.id == 15 then
--砸蛋
GlobalEventSystem:Fire(EventName.OPEN_SMASH_EGG_VIEW, self.info)
elseif vo.id == 16 then
--头像举报
local function ok_callback()
if self.model.last_inform_id == nil or self.info.role_id ~= self.model.last_inform_id then
Message.show("已收到您的举报,我们将做进一步处理")
self.model.last_inform_id = self.info.role_id
else
Message.show("您已举报过该玩家了")
end
end
Alert.show("您是否要举报 "..self.info.name.." 的头像", Alert.Type.Two, ok_callback)
-- elseif vo.id == 19 then
-- -- 分手
-- -- MarriageModel:getInstance():Fire(MarriageModel.OPEN_ACK_SEPARATE)
-- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17233)
-- elseif vo.id == 20 then
-- -- 离婚
-- -- MarriageModel:getInstance():Fire(MarriageModel.OPEN_CALL_DIVORCE_VIEW)
-- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17233)
elseif vo.id == 21 then
GlobalEventSystem:Fire(EventName.OPEN_INTERACT_ACTION_VIEW, self.info.role_id)
GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD,true, self.info, true)
self.not_close_other_head = true
elseif vo.id == 22 then
--转让团长
local function ok_callback()
GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,3)
end
Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为长老职位吗?", self.info.name), Alert.Type.Two, ok_callback)
elseif vo.id == 23 then
--转让队长
GlobalEventSystem:Fire(TeamModel.APPOINT_NEW_LEADER, self.info.role_id)
elseif vo.id == 24 then
--踢出队伍
GlobalEventSystem:Fire(TeamModel.KICK_PLAYER_OUT, self.info.role_id)
elseif vo.id == 25 then
--霸主禁言
CSGWarModel:GetInstance():Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60120, self.info.role_id)
end
if mask_close then
else
self:Close()
end
end