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

192 lines
6.7 KiB

  1. -- <*
  2. -- @Author: msh
  3. -- @Description: 二级邀请提示界面view
  4. -- *>
  5. CommonAlertInviteTipView = CommonAlertInviteTipView or BaseClass(BaseView)
  6. local CommonAlertInviteTipView = CommonAlertInviteTipView
  7. function CommonAlertInviteTipView:__init()
  8. self.base_file = "common"
  9. self.layout_file = "CommonAlertInviteTipView"
  10. self.layer_name = "Top"
  11. self.destroy_imm = true
  12. self.use_background = G_USING_BG --全屏界面默认使用这个参数
  13. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  14. self.change_scene_close = true
  15. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  16. self.need_show_money = false --是否要显示顶部的金钱栏
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:AddEvent()
  20. end
  21. self.open_callback = function ( )
  22. self:UpdateView()
  23. end
  24. self.switch_callback = function(index)
  25. self:SwitchTab(index)
  26. end
  27. self.destroy_callback = function ( )
  28. self:DestroySuccess()
  29. end
  30. end
  31. function CommonAlertInviteTipView:Open(invite_data)
  32. self.invite_data = invite_data
  33. -- 定制层级
  34. self.layer_name = invite_data.layer_name or self.layer_name
  35. self:InitNodesAndData()
  36. BaseView.Open(self)
  37. end
  38. function CommonAlertInviteTipView:ReOpen(invite_data)
  39. self.invite_data = invite_data
  40. if self.is_loaded then
  41. self:InitNodesAndData()
  42. self:UpdateView()
  43. end
  44. end
  45. function CommonAlertInviteTipView:InitNodesAndData( )
  46. if self.is_loaded then
  47. if self.vip_item then
  48. self.vip_item:SetData(0)
  49. end
  50. self.lb_name_tmp.text = ""
  51. self.lb_content_tmp.text = ""
  52. end
  53. self.auto_close_time = self.invite_data.auto_close_time or 10
  54. -- self.waiting = false
  55. -- self:ClearAutoCloseTimer()
  56. -- self:ClearViewAnimId()
  57. -- self:ClearDestroyTimer()
  58. end
  59. function CommonAlertInviteTipView:LoadSuccess()
  60. local nodes = {
  61. "Window:raw",
  62. "Window/windowCloseBtn:obj",
  63. "Window/windowTitleText:tmp",
  64. "confirmBtn:obj","confirmBtn/lb_confirmBtn:tmp",
  65. "refuseBtn:obj", "refuseBtn/lb_refuseBtn:tmp",
  66. "con_vip:obj", "lb_name:tmp", "lb_content:tmp",
  67. "lb_tip:tmp",
  68. }
  69. self:GetChildren(nodes)
  70. self:UpdateBaseView( )
  71. end
  72. function CommonAlertInviteTipView:UpdateBaseView( )
  73. lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"))
  74. self.vip_item = RoleVipItem.New(self.con_vip)
  75. self.vip_item:SetAnchoredPosition(0, 0)
  76. self.vip_item:SetScale(0.84, 0.84)
  77. self.windowCloseBtn_obj:SetActive(false)
  78. SetAnchoredPositionX(self.lb_content, 0)
  79. end
  80. function CommonAlertInviteTipView:AddEvent()
  81. local on_click = function ( click_obj )
  82. if self.windowCloseBtn_obj == click_obj then
  83. if self.invite_data and self.invite_data.reject_callback then
  84. self.invite_data.reject_callback(self.invite_data)
  85. end
  86. self:CloseCallBack()
  87. elseif self.confirmBtn_obj == click_obj then
  88. if self.invite_data and self.invite_data.accept_callback then
  89. self.invite_data.accept_callback(self.invite_data)
  90. end
  91. self:CloseCallBack()
  92. elseif self.refuseBtn_obj == click_obj then
  93. if self.invite_data and self.invite_data.reject_callback then
  94. self.invite_data.reject_callback(self.invite_data)
  95. end
  96. self:CloseCallBack()
  97. end
  98. end
  99. AddClickEvent(self.windowCloseBtn_obj, on_click)
  100. AddClickEvent(self.confirmBtn_obj, on_click)
  101. AddClickEvent(self.refuseBtn_obj, on_click)
  102. end
  103. -- 关闭界面并回调
  104. function CommonAlertInviteTipView:CloseCallBack( )
  105. self:Close()
  106. CommonController.Instance:Fire(EventName.SHOW_COMMON_INVITE_TIPS)
  107. end
  108. function CommonAlertInviteTipView:UpdateView()
  109. if self.invite_data.invite_type == CommonModel.InviteTipsType.Team then -- 组队邀请
  110. local data = self.invite_data.param_data
  111. local str = string.format('Lv.%s %s', data.level, HtmlColorTxt( data.name, ColorUtil.BLUE_DARK) )
  112. self.lb_name_tmp.text = str
  113. self.lb_content_tmp.text = "邀请与您组队,是否同意请求?"
  114. -- -- 副本目标
  115. -- local main_type = data.activity_id or ""
  116. -- local sub_type = data.subtype or ""
  117. -- local cfg = Config.Teamui[main_type.."@"..sub_type]
  118. -- if cfg then
  119. -- local txt = cfg.subtype_name
  120. -- self.invite_content_tmp.text = "副本:" .. HtmlColorTxt( Trim(txt), "#fdffc2")
  121. -- else
  122. -- self.invite_content_tmp.text = "暂无目标"
  123. -- end
  124. end
  125. -- 设置vip 并调整名字的位置
  126. self.vip_item:SetData(self.invite_data.vip, self.invite_data.svip)
  127. local pos_x = self.invite_data.vip > 0 and 10 or 0
  128. SetAnchoredPositionX(self.lb_name, pos_x)
  129. SetAnchoredPositionX(self.con_vip, pos_x - self.lb_name_tmp.preferredWidth / 2 - 20)
  130. self:StartAutoCloseTimer()
  131. end
  132. -- 自动关闭倒计时
  133. function CommonAlertInviteTipView:StartAutoCloseTimer( )
  134. local end_time = self.auto_close_time + TimeUtil:getServerTime()
  135. self:ClearAutoCloseTimer()
  136. local function auto_close_func()
  137. local left_time = end_time - TimeUtil:getServerTime()
  138. if left_time > 0 then
  139. if self.invite_data.invite_type == CommonModel.InviteTipsType.Team and
  140. SceneManager:getInstance():IsBossMoneyScene() then
  141. self.lb_tip_tmp.text = string.format('(%s)秒后自动同意', HtmlColorTxt( left_time, ColorUtil.GREEN_DARK) )
  142. else
  143. self.lb_tip_tmp.text = string.format('(%s)秒后自动拒绝', HtmlColorTxt( left_time, ColorUtil.GREEN_DARK))
  144. end
  145. elseif left_time <= 0 then
  146. if self.invite_data.invite_type == CommonModel.InviteTipsType.Team and
  147. SceneManager:getInstance():IsBossMoneyScene() then
  148. if self.invite_data and self.invite_data.accept_callback then
  149. self.invite_data.accept_callback(self.invite_data)
  150. end
  151. else
  152. if self.invite_data and self.invite_data.reject_callback then
  153. self.invite_data.reject_callback(self.invite_data)
  154. end
  155. end
  156. self:ClearAutoCloseTimer()
  157. self:CloseCallBack()
  158. end
  159. end
  160. self.auto_close_func_id = GlobalTimerQuest:AddPeriodQuest(auto_close_func, 0.3, -1)
  161. end
  162. function CommonAlertInviteTipView:ClearAutoCloseTimer( )
  163. if self.auto_close_func_id then
  164. GlobalTimerQuest:CancelQuest(self.auto_close_func_id)
  165. self.auto_close_func_id = nil
  166. end
  167. end
  168. function CommonAlertInviteTipView:SwitchTab( index )
  169. end
  170. function CommonAlertInviteTipView:DestroySuccess( )
  171. if self.vip_item then
  172. self.vip_item:DeleteMe()
  173. self.vip_item = nil
  174. end
  175. self:ClearAutoCloseTimer( )
  176. end