源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

544 wiersze
18 KiB

4 tygodni temu
  1. OperationView = OperationView or BaseClass(BaseView)
  2. function OperationView:__init()
  3. self.base_file = "sociality"
  4. self.layout_file = "OperationView"
  5. self.layer_name = "Top"
  6. self.destroy_imm = false
  7. self.use_background = true
  8. self.click_bg_toClose = true
  9. self.background_alpha = 0
  10. self.hide_maincancas = false
  11. self.is_set_zdepth = true
  12. self.open_wnd_anim = 0
  13. self.item_list = {}
  14. -- self.nature_item_list = {}
  15. self.model = SocialityModel:getInstance()
  16. -- self:AddPreLoadList("sociality",{"OperationItem"})
  17. self.load_callback = function()
  18. self:LoadSuccess()
  19. self:InitEvent()
  20. end
  21. self.open_callback = function()
  22. self:UpdateView()
  23. end
  24. self.destroy_callback = function()
  25. self:Remove()
  26. end
  27. end
  28. function OperationView:Open(info)
  29. self.info = info
  30. self.is_out_ser = false
  31. if info.ser_id and info.ser_id ~= RoleManager.Instance:GetMainRoleServerId() then
  32. self.is_out_ser = true -- 发现是外服玩家就另外设定
  33. -- self.info.combat = self.info.power and self.info.power or 0 -- 战力字段不同修改下
  34. elseif info.is_local == 1 then--是外服
  35. self.is_out_ser = true -- 发现是外服玩家就另外设定
  36. end
  37. BaseView.Open(self)
  38. end
  39. function OperationView:Remove()
  40. if self.roleItem then
  41. self.roleItem:DeleteMe()
  42. end
  43. if self.vipItem then
  44. self.vipItem:DeleteMe()
  45. end
  46. if self.level_item then
  47. self.level_item:DeleteMe()
  48. self.level_item = nil
  49. end
  50. for k,v in pairs(self.item_list) do
  51. v:DeleteMe()
  52. end
  53. self.item_list = {}
  54. -- for k,v in pairs(self.nature_item_list) do
  55. -- v:DeleteMe()
  56. -- end
  57. -- self.nature_item_list = {}
  58. end
  59. function OperationView:LoadSuccess()
  60. self.nodes = {
  61. "InfoCon/nameCon/name:tmp",
  62. "InfoCon/fight:txt",
  63. "InfoCon/nameCon/sex:img",
  64. "InfoCon/nameCon/vip",
  65. "InfoCon/ScrollView",
  66. "InfoCon/ScrollView/Viewport/Content",
  67. "InfoCon/headCon",
  68. "InfoCon/imgBg:img",
  69. "InfoCon",
  70. "InfoCon/natureCon", -- 用来放性格标签item
  71. }
  72. self:GetChildren(self.nodes)
  73. self.scroll_view_rect = self.ScrollView:GetComponent("ScrollRect")
  74. self.scroll_view_rect.horizontal = false
  75. self.scroll_view_rect.vertical = false
  76. self.roleItem = HeadRoleItem.New(self.headCon)
  77. self.roleItem:SetItemSize(73,73)
  78. self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
  79. self.vipItem = RoleVipItem.New(self.vip)
  80. self.start_pos = self.ScrollView.anchoredPosition.y -- 默认的位置
  81. lua_resM:setOutsideImageSprite(self,self.imgBg_img,GameResPath.GetViewBigBg("operation_view_bg"), false)
  82. end
  83. function OperationView:InitEvent()
  84. local function ANS_CHECK_BIND_MATE( result_id )
  85. if result_id == 1490025 then
  86. --你未添加对方为好友
  87. local function call_yes( )
  88. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
  89. end
  90. Alert.show('您尚未添加对方为好友,\n请添加好友后再申请羁绊?', Alert.Type.Two, call_yes, nil, '添加好友', '取消')
  91. elseif result_id == 1490003 then
  92. --对方未添加你为好友
  93. local function call_yes( )
  94. self.model:Fire(SocialityModel.CHAT_WITH_ROLEID,self.info.role_id)
  95. end
  96. Alert.show('对方尚未添加您为好友,\n请添加好友后再申请羁绊?', Alert.Type.Two, call_yes, nil, '前往提醒', '取消')
  97. elseif result_id == 1490004 then
  98. --亲密度不足
  99. local function call_yes( )
  100. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, self.info)
  101. end
  102. local need_num = MateModel.GetInstance():GetKeyValueConf("mate_intimacy") or 0
  103. local str = string.format('您与对方的亲密度尚未达到%s,\n赠送礼物可增加亲密度,快去试试吧!',HtmlColorTxt( need_num , '#fa1022'))
  104. Alert.show( str, Alert.Type.Two, call_yes, nil, '前往赠送', '取消' )
  105. elseif result_id == 1 then
  106. -- 可以打开羁绊界面
  107. MateModel:GetInstance():Fire(MateConst.OPEN_ASK_MATE_VIEW,self.info.role_id,self.info)
  108. end
  109. self:Close()
  110. end
  111. self:BindEvent(MateModel:GetInstance(), MateConst.ANS_CHECK_BIND_MATE, ANS_CHECK_BIND_MATE)
  112. end
  113. function OperationView:UpdateView( )
  114. if _use_delete_method then return end
  115. if not self.info then return end
  116. --兼容一些字段不一样的协议
  117. if not self.info.role_id and self.info.player_id then
  118. self.info.role_id = self.info.player_id
  119. end
  120. local vo = self.info
  121. if vo.dress_list then
  122. for i,v in ipairs(vo.dress_list) do
  123. --1气泡 2相框
  124. local icon_name = v.dress_id
  125. if v.dress_type == 2 then
  126. vo.dress_board = icon_name
  127. end
  128. end
  129. end
  130. if self.roleItem then
  131. local head_data = {
  132. vo = {
  133. id=vo.role_id,
  134. career=vo.career,
  135. level=vo.level,
  136. sex=vo.sex,
  137. turn=vo.turn,
  138. dress_board_id = vo.dress_board,
  139. picture_ver = vo.picture_ver,
  140. picture = vo.picture,
  141. profile_photo_id = vo.profile_photo_id,
  142. use_bg = 2,
  143. do_not_click = true,
  144. },
  145. }
  146. self.roleItem:SetData(head_data)
  147. end
  148. if not self.name_tmp then return end
  149. if vo.server_num ~= RoleManager.Instance.mainRoleInfo.server_num then
  150. self.name_tmp.text = GetCSLongName(vo.name,vo.server_num,false)
  151. else
  152. self.name_tmp.text = vo.name
  153. end
  154. SetAnchoredPositionX(self.sex_img.transform,self.name_tmp.preferredWidth+46)
  155. self.vipItem:SetData(vo.vip_flag,vo.sup_vip_type)
  156. local sex_flag = ""
  157. if vo.sex == 1 then
  158. sex_flag = "boy"
  159. elseif vo.sex == 2 then
  160. sex_flag = "girl"
  161. end
  162. --战力
  163. self.fight_txt.text = vo.power or 0
  164. lua_resM:setImageSprite(self,self.sex_img,"common_asset","com_"..sex_flag,true)
  165. local tb = {}
  166. local cfg = Config.ConfigSocial.PlayerOpera
  167. local main_role = RoleManager.Instance.mainRoleInfo
  168. local main_team_id = main_role.team_id
  169. local rela = vo.rela
  170. vo.position = vo.position or 0
  171. local is_friend = rela==1 or rela==2
  172. local is_strange = rela==0 or rela==nil
  173. local is_same_guild = vo.guild_id ~= 0 and vo.guild_id == main_role.guild_id -- 是否同社团
  174. local can_kick = is_same_guild and vo.position and vo.position > main_role.position
  175. local can_pro = is_same_guild and main_role.position == 1
  176. local can_transfer = is_same_guild and main_role.position == 1
  177. local can_fire = is_same_guild and main_role.position <= 2 and vo.position > main_role.position and vo.position <= 3
  178. local is_lover = main_role.is_marriage == 1 and main_role.marriage_id == vo.role_id --是否情侣
  179. local is_marrger = main_role.is_marriage == 2 and main_role.marriage_id == vo.role_id --是否夫妻
  180. local friend_lv = Config.Moduleid[140].open_lv
  181. local show_social = vo.level >= friend_lv and main_role.level>=friend_lv
  182. local can_pro_vice = is_same_guild and main_role.position <= 2 and vo.position > main_role.position
  183. local is_in_black_list = self.model:IsRelaviveType(vo.role_id,Config.ConfigSocial.RelativeType.black)
  184. local is_csgwar_overlord = main_role.is_overlord == 1 --是否霸主
  185. -------------------------
  186. local mate_lv = GetModuleOpenLevel( 149 )
  187. local mate_lv_ok = main_role.level >= mate_lv and vo.level >= mate_lv
  188. local can_mate = mate_lv_ok and (not MateModel:GetInstance():GetIsMateByRoleId( vo.role_id )) --是否可以羁绊
  189. for k,v in ipairs(cfg) do
  190. v.secondTitle = false
  191. if is_in_black_list and show_social then
  192. --只保留查看、取消拉黑、删除好友
  193. if v.id == 1 then --查看
  194. table.insert(tb, v)
  195. elseif v.id == 6 then --取消拉黑
  196. v.secondTitle = true
  197. table.insert(tb, v)
  198. elseif v.id == 5 then
  199. if is_friend then
  200. v.secondTitle = true --删除好友
  201. table.insert(tb, v)
  202. end
  203. end
  204. elseif self.is_out_ser then
  205. if v.id == 1 then --查看
  206. table.insert(tb, v)
  207. elseif v.id == 25 then
  208. --霸主禁言
  209. if is_csgwar_overlord then
  210. table.insert(tb, v)
  211. end
  212. end
  213. else
  214. if v.id == 5 then
  215. if show_social then --添加好友
  216. if is_friend then
  217. v.secondTitle = true --删除好友
  218. end
  219. table.insert(tb, v)
  220. end
  221. elseif v.id == 1 then
  222. --查看
  223. table.insert(tb, v)
  224. elseif v.id == 6 then
  225. --拉黑
  226. if is_in_black_list then
  227. v.secondTitle = true --取消拉黑
  228. end
  229. if show_social then
  230. table.insert(tb, v)
  231. end
  232. elseif v.id == 2 then
  233. --送礼
  234. table.insert(tb, v)
  235. elseif v.id == 3 then
  236. --邀请组队
  237. table.insert(tb, v)
  238. elseif v.id == 4 then
  239. --申请入队
  240. table.insert(tb, v)
  241. elseif v.id == 15 then
  242. table.insert(tb,v)
  243. elseif v.id == 16 then
  244. table.insert(tb,v)
  245. elseif v.id == 8 then
  246. --踢出社团
  247. if can_kick then
  248. table.insert(tb, v)
  249. end
  250. elseif v.id == 9 then
  251. --提升副团长
  252. if can_pro then
  253. table.insert(tb, v)
  254. end
  255. elseif v.id == 10 then
  256. if can_transfer then
  257. table.insert(tb, v)
  258. end
  259. elseif v.id == 19 then
  260. -- 分手
  261. if is_lover then
  262. table.insert(tb, v)
  263. end
  264. elseif v.id == 20 then
  265. -- 离婚
  266. if is_marrger then
  267. table.insert(tb, v)
  268. end
  269. elseif v.id == 11 then
  270. if can_fire then
  271. table.insert(tb, v)
  272. end
  273. elseif v.id == 12 then
  274. --申请羁绊
  275. if can_mate then
  276. table.insert(tb, v)
  277. end
  278. elseif v.id == 13 then
  279. --求婚
  280. if is_lover then
  281. table.insert(tb, v)
  282. end
  283. elseif v.id == 14 then
  284. --私聊
  285. if show_social and not SocialityModel:getInstance().sociality_is_open then
  286. if is_friend or is_strange then
  287. table.insert(tb, v)
  288. end
  289. end
  290. elseif v.id == 21 then
  291. --互动
  292. table.insert(tb,v)
  293. elseif v.id == 22 then
  294. --提升长老
  295. if can_pro_vice then
  296. table.insert(tb,v)
  297. end
  298. elseif v.id == 23 then
  299. --转移队长
  300. if main_team_id == self.info.team_id and TeamModel:getInstance().is_leader then
  301. table.insert(tb, v)
  302. end
  303. elseif v.id == 24 then
  304. --踢出队伍
  305. if main_team_id == self.info.team_id and TeamModel:getInstance().is_leader then
  306. table.insert(tb, v)
  307. end
  308. elseif v.id == 25 then
  309. --霸主禁言
  310. if is_csgwar_overlord then
  311. table.insert(tb, v)
  312. end
  313. end
  314. end
  315. end
  316. -- 性格展示 2021.3.1 砍了
  317. local nature_ch = 0 -- 性格展示占用的高度
  318. -- local tag_data_list = NatureModel:getInstance():DealTagData( self.info.nature_tips )
  319. -- local item_height = 25
  320. -- local item_width = 64
  321. -- local inter_x = 1
  322. -- local inter_y = 10
  323. -- local start_x = 1
  324. -- local colunm = 4
  325. -- for k,v in pairs(self.nature_item_list) do
  326. -- v:SetVisible(false)
  327. -- end
  328. -- if #tag_data_list > 0 then
  329. -- for i,v in ipairs(tag_data_list) do
  330. -- self.nature_item_list[i] = self.nature_item_list[i] or NatureTagItem.New(self.natureCon)
  331. -- local item = self.nature_item_list[i]
  332. -- item:SetData(v, 0.58)
  333. -- item:SetAnchoredPosition( start_x + ((i - 1) % colunm) * (item_width+inter_x), -(math.ceil(i / colunm) - 1) * (item_height+inter_y) )
  334. -- item:SetVisible(true)
  335. -- end
  336. -- nature_ch = 35 * math.ceil(#tag_data_list / colunm)
  337. -- end
  338. -- 计算背景大小 以及 scroll大小
  339. local ch = math.ceil(#tb/2)*(OperationItem.Height+7) + nature_ch
  340. self.ScrollView.sizeDelta = Vector2(280, ch)
  341. local heigh = ch + 108
  342. self.imgBg.sizeDelta = Vector2(280, heigh)
  343. SetAnchoredPositionY(self.ScrollView, self.start_pos + (70 - nature_ch) )
  344. --创建按钮
  345. local call_back = function( vo )
  346. self:ClickOperation(vo)
  347. end
  348. for i,v in ipairs(tb) do
  349. local item = self.item_list[i]
  350. if not item then
  351. item = OperationItem.New(self.Content)
  352. self.item_list[i] = item
  353. end
  354. item:SetVisible(true)
  355. item:SetData(v, call_back)
  356. local x = (OperationItem.Width+7)*((i-1)%2)
  357. local y = -(OperationItem.Height+7)*(math.floor((i-1)/2))+1
  358. item:SetPosition(x,y)
  359. end
  360. for i=#tb+1, #self.item_list do
  361. self.item_list[i]:SetVisible(false)
  362. end
  363. --设置坐标
  364. local x, y = 0,0
  365. if SocialityModel:getInstance().operationPos then
  366. x,y = SocialityModel:getInstance().operationPos.x, SocialityModel:getInstance().operationPos.y
  367. else
  368. local mousePos = SocialityModel:getInstance().mousePos or {x=0, y=0}
  369. x, y = ScreenToViewportPoint(mousePos.x, mousePos.y)
  370. if x+388 > ScreenWidth then
  371. x = ScreenWidth-368-20
  372. elseif x<20 then
  373. x = 20
  374. end
  375. if y-heigh < 0 then
  376. y = heigh+20
  377. elseif y > ScreenHeight then
  378. y = ScreenHeight-20
  379. end
  380. end
  381. self.InfoCon.transform.anchoredPosition = Vector3(x, y, 0)
  382. end
  383. --点击选项处理
  384. function OperationView:ClickOperation( vo )
  385. if not self.info then return end
  386. local mask_close = false
  387. if vo.id == 1 then
  388. --查看
  389. GlobalEventSystem:Fire(EventName.OPEN_LOOK_ROLE_INFO_VIEW,self.info.role_id,self.info.rela)
  390. elseif vo.id == 2 then
  391. --送鲜花
  392. GlobalEventSystem:Fire(EventName.OPEN_SOCIAL_FLOWER_VIEW, self.info)
  393. elseif vo.id == 3 then
  394. --邀请组队
  395. GlobalEventSystem:Fire(TeamModel.INVITE_PLAYER,{self.info.role_id})
  396. elseif vo.id == 4 then
  397. --申请入队
  398. if not self.info.team_id or self.info.team_id == 0 then
  399. Message.show("该玩家没有队伍")
  400. return
  401. end
  402. GlobalEventSystem:Fire(TeamModel.APPLY_JOIN_TEAM, self.info.team_id)
  403. elseif vo.id == 5 then
  404. if vo.secondTitle then
  405. --删除好友
  406. local function ok_callback( )
  407. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14007, 1, self.info.role_id)
  408. end
  409. -- Alert.show("删除好友,亲密度将清零,是否继续?", Alert.Type.Two, ok_callback, nil,"继续", "取消")
  410. Alert.show("确定删除好友?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
  411. else
  412. --添加好友
  413. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14003, self.info.role_id)
  414. end
  415. elseif vo.id == 6 then
  416. if vo.secondTitle then
  417. --取消拉黑
  418. ChatModel:getInstance():Fire(ChatModel.SEND_PROTOCAL,11066,2,self.info.role_id)
  419. else
  420. --拉黑
  421. local function ok_callback( )
  422. ChatModel:getInstance():Fire(ChatModel.SEND_PROTOCAL,11066,1,self.info.role_id)
  423. end
  424. Alert.show(string.format("确认将 <color=#10aaf1>%s</color> 拉入黑名单吗?", self.info.name),
  425. Alert.Type.Two, ok_callback, nil,"确定", "取消")
  426. end
  427. elseif vo.id == 7 then
  428. --删除仇人
  429. self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT, 14007, 4, self.info.role_id)
  430. elseif vo.id == 8 then
  431. --踢出社团
  432. local function ok_callback()
  433. GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40014,self.info.role_id)
  434. end
  435. Alert.show(string.format("确定将成员<color=#4eae1a>%s</color>踢出社团吗?", self.info.name),
  436. Alert.Type.Two, ok_callback, nil,"确定", "取消")
  437. elseif vo.id == 9 then
  438. --提升副团长
  439. local function ok_callback()
  440. GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,2)
  441. end
  442. Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为副团职位吗?", self.info.name), Alert.Type.Two, ok_callback)
  443. elseif vo.id == 10 then
  444. --转让团长
  445. local function ok_callback()
  446. GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,1)
  447. end
  448. Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为团长职位吗?", self.info.name), Alert.Type.Two, ok_callback)
  449. elseif vo.id == 11 then
  450. --撤职
  451. local function ok_callback()
  452. GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,5)
  453. end
  454. local str = Trim(Config.Guildpos[self.info.position].name)
  455. Alert.show(string.format("确定移除<color=#4eae1a>%s</color>的%s职位吗?", self.info.name,str), Alert.Type.Two, ok_callback)
  456. elseif vo.id == 12 then
  457. --申请羁绊
  458. MateModel:GetInstance():Fire(MateConst.REQ_CHECK_BIND_MATE, self.info.role_id)
  459. mask_close = true
  460. -- elseif vo.id == 13 then
  461. -- --求婚
  462. -- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17230, self.info.role_id, 2)
  463. elseif vo.id == 14 then
  464. --私聊
  465. local is_in_black_list = self.model:IsRelaviveType(self.info.role_id,Config.ConfigSocial.RelativeType.black)
  466. if is_in_black_list then
  467. Message.show("无法向黑名单玩家发消息哦!","fault")
  468. else
  469. self.model:Fire(SocialityModel.CHAT_WITH_ROLEID,self.info.role_id)
  470. end
  471. -- self.model:Fire(SocialityModel.REQUEST_CCMD_EVENT,14020,self.info.role_id)--先把对方加入联系人列表中
  472. -- ChatModel:getInstance().need_chat_key = self.info.role_id
  473. -- GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW, 1)
  474. elseif vo.id == 15 then
  475. --砸蛋
  476. GlobalEventSystem:Fire(EventName.OPEN_SMASH_EGG_VIEW, self.info)
  477. elseif vo.id == 16 then
  478. --头像举报
  479. local function ok_callback()
  480. if self.model.last_inform_id == nil or self.info.role_id ~= self.model.last_inform_id then
  481. Message.show("已收到您的举报,我们将做进一步处理")
  482. self.model.last_inform_id = self.info.role_id
  483. else
  484. Message.show("您已举报过该玩家了")
  485. end
  486. end
  487. Alert.show("您是否要举报 "..self.info.name.." 的头像", Alert.Type.Two, ok_callback)
  488. -- elseif vo.id == 19 then
  489. -- -- 分手
  490. -- -- MarriageModel:getInstance():Fire(MarriageModel.OPEN_ACK_SEPARATE)
  491. -- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17233)
  492. -- elseif vo.id == 20 then
  493. -- -- 离婚
  494. -- -- MarriageModel:getInstance():Fire(MarriageModel.OPEN_CALL_DIVORCE_VIEW)
  495. -- MarriageModel:getInstance():Fire(MarriageModel.PROTO_CCMD_EVENT, 17233)
  496. elseif vo.id == 21 then
  497. GlobalEventSystem:Fire(EventName.OPEN_INTERACT_ACTION_VIEW, self.info.role_id)
  498. GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD,true, self.info, true)
  499. self.not_close_other_head = true
  500. elseif vo.id == 22 then
  501. --转让团长
  502. local function ok_callback()
  503. GuildModel:getInstance():Fire(GuildModel.REQUEST_CCMD_EVENT,40013,self.info.role_id,3)
  504. end
  505. Alert.show(string.format("确定将<color=#4eae1a>%s</color>提升为长老职位吗?", self.info.name), Alert.Type.Two, ok_callback)
  506. elseif vo.id == 23 then
  507. --转让队长
  508. GlobalEventSystem:Fire(TeamModel.APPOINT_NEW_LEADER, self.info.role_id)
  509. elseif vo.id == 24 then
  510. --踢出队伍
  511. GlobalEventSystem:Fire(TeamModel.KICK_PLAYER_OUT, self.info.role_id)
  512. elseif vo.id == 25 then
  513. --霸主禁言
  514. CSGWarModel:GetInstance():Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60120, self.info.role_id)
  515. end
  516. if mask_close then
  517. else
  518. self:Close()
  519. end
  520. end