源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

179 rindas
4.7 KiB

pirms 1 mēnesi
  1. ExitBtnView = ExitBtnView or BaseClass(BaseView)
  2. --[[
  3. 使
  4. local data = {
  5. call_back = function() --回调
  6. self.model:Fire(BeachConst.REQ_QUIT_SCENE)
  7. end,
  8. pos,--自己传位置进来不传就用默认的
  9. }
  10. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP,data)
  11. --]]
  12. local ExitBtnView = ExitBtnView
  13. function ExitBtnView:__init()
  14. self.base_file = "common"
  15. self.layout_file = "ExitBtnView"
  16. self.layer_name = "Main"
  17. self.destroy_imm = true
  18. self.change_scene_close = false
  19. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  20. self.need_show_money = false --是否要显示顶部的金钱栏
  21. -- self.is_set_zdepth = true
  22. self.click_bg_toClose = false
  23. ------------------------
  24. -- 一级全屏界面:
  25. self.hide_maincancas = false --隐藏主界面
  26. self.use_background = false --不一定显示遮罩
  27. self.tween_lite_list = {}
  28. ------------------------
  29. self.load_callback = function ()
  30. self:LoadSuccess()
  31. end
  32. self.open_callback = function ( )
  33. self:OpenSuccess()
  34. end
  35. self.close_win_callback = function ( )
  36. self:Close()
  37. end
  38. self.destroy_callback = function ( )
  39. self:DestroySuccess()
  40. end
  41. end
  42. function ExitBtnView:Open( )
  43. BaseView.Open(self)
  44. end
  45. function ExitBtnView:LoadSuccess()
  46. local nodes = {
  47. "leftCon", "leftCon/exitBtn:obj",
  48. }
  49. self:GetChildren(nodes)
  50. self:AddEvent()
  51. -------------------------
  52. self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
  53. self.transform.localPosition = Vector3(0,0,0)
  54. self.exitBtn_obj:SetActive(false)
  55. self:BindLittleMove(self.leftCon.transform, BaseView.LittleMoveDir.Left, 0)
  56. if self.need_fresh then
  57. self:ShowExitState(self.data)
  58. end
  59. end
  60. function ExitBtnView:AddEvent()
  61. local on_click = function ( click_obj )
  62. if self.exitBtn_obj == click_obj then
  63. if self.data and self.data.call_back then
  64. self.data.call_back()
  65. end
  66. end
  67. end
  68. AddClickEvent(self.exitBtn_obj, on_click)
  69. local function onOrientationChange()
  70. if self.is_loaded and not self._use_delete_method then
  71. SetAnchoredPositionX(self.leftCon.transform, ClientConfig.iphone_x_offset_left)
  72. end
  73. end
  74. self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  75. onOrientationChange()
  76. local function showExitBtnFunc( data )
  77. self:ShowExitState(data)
  78. end
  79. self:BindEvent(GlobalEventSystem, EventName.SHOW_EXIT_BTN_STATE, showExitBtnFunc)
  80. local function hideExitBtnFunc( ... )
  81. self:HideExitState()
  82. end
  83. self:BindEvent(GlobalEventSystem, EventName.HIDE_EXIT_BTN_STATE, hideExitBtnFunc)
  84. local function hide_dialogue_cur_xy_node()--隐藏当前和对话框重叠位置的节点
  85. self:ShowNode(false)
  86. end
  87. local function show_dialogue_cur_xy_node()--显示当前和对话框重叠位置的节点
  88. self:ShowNode(true)
  89. end
  90. self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dialogue_cur_xy_node)
  91. self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dialogue_cur_xy_node)
  92. end
  93. function ExitBtnView:OpenSuccess()
  94. self:UpdateView()
  95. end
  96. function ExitBtnView:UpdateView()
  97. if self.is_loaded then
  98. else
  99. self.need_fresh = true
  100. end
  101. end
  102. --显示
  103. function ExitBtnView:ShowExitState( data )
  104. self.data = data
  105. if not self.is_loaded then
  106. self.need_fresh = true
  107. return
  108. end
  109. if not self.data then
  110. print("huangcong:ExitBtnView [start:112] 没有数据啊,谁传过来的:")
  111. return
  112. end
  113. if not self.is_show then
  114. self.is_show = true
  115. self:CancelHide()
  116. end
  117. SetAnchoredPositionX(self.transform,0)
  118. self.exitBtn_obj:SetActive(true)
  119. local pos = self.data.pos or {x = 200,y = 279}
  120. SetAnchoredPosition(self.exitBtn.transform, pos.x, pos.y)
  121. end
  122. --隐藏
  123. function ExitBtnView:HideExitState( )
  124. if not self.is_loaded then
  125. return
  126. end
  127. self.exitBtn_obj:SetActive(false)
  128. self.data = nil
  129. end
  130. --是否隐藏副本任务栏节点
  131. function ExitBtnView:ShowNode( show )
  132. if not self.is_loaded then
  133. return
  134. end
  135. if self.is_show == show then return end--相同的状态就不再进来做动画了
  136. self.is_show = show
  137. for i,v in ipairs(self.tween_lite_list) do
  138. if v then
  139. TweenLite.Stop(v)
  140. v = nil
  141. end
  142. end
  143. if show then
  144. local function anim_end_func( ... )
  145. self:CancelHide()
  146. end
  147. local pos = 0
  148. self.tween_lite_list[1] = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX, pos, 0.2,anim_end_func)
  149. else
  150. local function anim_end_func( ... )
  151. self:Hide()
  152. end
  153. local pos = -220
  154. self.tween_lite_list[2] = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX, pos, 0.2,anim_end_func)
  155. end
  156. end
  157. function ExitBtnView:DestroySuccess( )
  158. for i,v in ipairs(self.tween_lite_list) do
  159. if v then
  160. TweenLite.Stop(v)
  161. v = nil
  162. end
  163. end
  164. end