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

213 rivejä
6.6 KiB

1 kuukausi sitten
  1. EquipCollectMainView = EquipCollectMainView or BaseClass(BaseView)
  2. local EquipCollectMainView = EquipCollectMainView
  3. EquipCollectMainView.TAB_DATA = {
  4. {id = EquipCollectConst.TAB_ID.COLLECT, name = "装备收集", sub_id = 1},
  5. -- {id = EquipCollectConst.TAB_ID.BOSS, name = "装备获取", sub_id = 2},
  6. {id = EquipCollectConst.TAB_ID.UPGRADE, name = "装备升星", sub_id = 3},
  7. -- {id = EquipCollectConst.TAB_ID.TASK, name = "装备交易", sub_id = 4},
  8. }
  9. function EquipCollectMainView:__init()
  10. self.base_file = "equipCollect"
  11. self.layout_file = "EquipCollectMainView"
  12. self.layer_name = "UI"
  13. self.destroy_imm = true
  14. self.use_background = true --全屏界面默认使用这个参数
  15. self.hide_maincancas = false --全屏界面需要放开隐藏主UI
  16. self.change_scene_close = true
  17. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  18. self.need_show_money = false --是否要显示顶部的金钱栏
  19. self.sub_view_list = {}
  20. self.tab_item = {}
  21. self.is_trigger_guide = false
  22. self.close_fog = true
  23. self.model = EquipCollectModel:getInstance()
  24. self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,14510)
  25. self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,15218)
  26. self.cur_select_index = 1
  27. self.model.mask_lead_effect = {}--重置引导特效标记
  28. self.load_callback = function ()
  29. self:LoadSuccess()
  30. self:AddEvent()
  31. end
  32. self.open_callback = function ( )
  33. self:OpenSuccess()
  34. self:UpdateRedDot()
  35. end
  36. self.switch_callback = function(index)
  37. self:SwitchTab(index)
  38. end
  39. self.destroy_callback = function ( )
  40. self:DestroySuccess()
  41. end
  42. end
  43. function EquipCollectMainView:Open( index, id, sub_id, show_first_effect)
  44. self.cur_select_index = index or self.cur_select_index
  45. self.id = id
  46. self.sub_id = sub_id
  47. self.show_first_effect = show_first_effect
  48. BaseView.Open(self)
  49. end
  50. function EquipCollectMainView:LoadSuccess()
  51. local nodes = {
  52. "container", "bg:raw", "close_btn:obj", "tab_con",
  53. "title_image:img",
  54. }
  55. self:GetChildren(nodes)
  56. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("equipCollect_main_bg"),false)
  57. self:AddToStageHandler()
  58. end
  59. function EquipCollectMainView:AddEvent()
  60. local function on_click( target )
  61. if target == self.close_btn_obj then
  62. self:Close()
  63. end
  64. end
  65. AddClickEvent(self.close_btn_obj, on_click)
  66. local function on_ans_update_red_dot( tab_id,bool )--设置红点的状态注意此处的协议是从model那边发过来的
  67. self:UpdateRedDot()
  68. end
  69. self:BindEvent(self.model, EquipCollectConst.ANS_UPDATE_EQUIP_COLLECT_RED_DOT, on_ans_update_red_dot)
  70. local function onGuideTrigger()
  71. self:AddToStageHandler()
  72. end
  73. self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
  74. local function bg_back_func( ... )
  75. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  76. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  77. end
  78. self:MoveUIToBack(self.bg_raw)
  79. end
  80. if self.background_wnd then
  81. bg_back_func()
  82. else
  83. self.bg_back_func = bg_back_func
  84. end
  85. end
  86. function EquipCollectMainView:OpenSuccess()
  87. self:SetTabData()
  88. self:UpdateView()
  89. end
  90. function EquipCollectMainView:UpdateRedDot( )
  91. local red_data = self.model:GetAllEquipExamRedDot()
  92. for k,v in pairs(red_data) do
  93. if self.tab_item[k] then
  94. self.tab_item[k]:ShowRedPoint(v)
  95. end
  96. end
  97. end
  98. function EquipCollectMainView:SetTabData( )
  99. local y_offset = 100
  100. local function on_click( index )
  101. self:SwitchTab(index)
  102. end
  103. local index = 0
  104. for i,v in ipairs(EquipCollectMainView.TAB_DATA) do
  105. local is_open = GetModuleIsOpen(145, v.sub_id)
  106. if is_open then
  107. index = index + 1
  108. local item = self.tab_item[v.id]
  109. if not item then
  110. item = EquipCollectTabItem.New(self.tab_con)
  111. self.tab_item[v.id] = item
  112. item:SetPosition(0,-(index - 1)*y_offset)
  113. item:SetCallBackFunc(on_click)
  114. end
  115. item:SetData(v, v.id)
  116. end
  117. end
  118. end
  119. function EquipCollectMainView:UpdateView()
  120. self:SwitchTab(self.cur_select_index)
  121. end
  122. function EquipCollectMainView:SwitchTab( index )
  123. self.cur_select_index = index
  124. for i,v in pairs(self.tab_item) do
  125. v:SetSelect(i==index)
  126. end
  127. if index == EquipCollectConst.TAB_ID.COLLECT then
  128. lua_resM:setImageSprite(self, self.title_image_img, "equipCollect_asset", "equipCollect_title1", true)
  129. if self.sub_view_list[index] == nil then
  130. self.sub_view_list[index] = EquipCollectSubView.New(self.container)
  131. end
  132. elseif index == EquipCollectConst.TAB_ID.BOSS then
  133. if self.sub_view_list[index] == nil then
  134. self.sub_view_list[index] = EquipExamBossView.New(self.container)
  135. self.sub_view_list[index]:AppendToBackContainer(self)
  136. end
  137. elseif index == EquipCollectConst.TAB_ID.UPGRADE then
  138. lua_resM:setImageSprite(self, self.title_image_img, "equipCollect_asset", "equipCollect_title3", true)
  139. if self.sub_view_list[index] == nil then
  140. self.sub_view_list[index] = EquipExamUpgradeView.New(self.container)
  141. end
  142. elseif index == EquipCollectConst.TAB_ID.TASK then
  143. if self.sub_view_list[index] == nil then
  144. self.sub_view_list[index] = EquipExamTaskView.New(self.container)
  145. end
  146. end
  147. if index ~= EquipCollectConst.TAB_ID.COLLECT then
  148. self.show_first_effect = nil--切页签关掉特效
  149. end
  150. self:PopUpChild(self.sub_view_list[index])
  151. self.sub_view_list[index]:SetData(self.id, self.sub_id, self.show_first_effect)
  152. if index == EquipCollectConst.TAB_ID.COLLECT then
  153. self.id = nil
  154. self.sub_id = nil
  155. end
  156. end
  157. function EquipCollectMainView:DestroySuccess( )
  158. for i,v in pairs(self.sub_view_list) do
  159. v:DeleteMe()
  160. v = nil
  161. end
  162. self.sub_view_list = {}
  163. for i,v in pairs(self.tab_item) do
  164. v:DeleteMe()
  165. v = nil
  166. end
  167. self.tab_item = {}
  168. end
  169. function EquipCollectMainView:AddToStageHandler()
  170. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE,1)
  171. if not helpVo then return end
  172. local help_type = helpVo.help_type
  173. local step = helpVo.step
  174. local button = false
  175. if (help_type == HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE) and step == 1 then
  176. button = self.close_btn_obj
  177. end
  178. if button then
  179. local function call_back()
  180. self:Close()
  181. end
  182. GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, self.transform, call_back, helpVo, self.layout_file)
  183. end
  184. end
  185. function EquipCollectMainView:Close()
  186. --完成引导
  187. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE,1)
  188. if helpVo then
  189. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  190. end
  191. -- if self.is_trigger_guide then
  192. -- GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true, true)
  193. -- end
  194. BaseView.Close(self)
  195. end