UIViewBase.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. local UIViewBase = class("UIViewBase")
  2. function UIViewBase:Init()
  3. self.fxGoes = {}
  4. end
  5. function UIViewBase:UIHide(needBackIn)
  6. ManagerContainer.LuaUIMgr:Hide(self.uiData.id, needBackIn or false)
  7. end
  8. function UIViewBase:UIClose()
  9. ManagerContainer.LuaUIMgr:ClosePage(self.uiData.id, true)
  10. end
  11. function UIViewBase:OnBaseShow()
  12. --LogError(self.uiData.name.." show")
  13. if self.uiData.type == Enum.UIType.TotalWin or self.uiData.type == Enum.UIType.Total then
  14. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DISPLAY_MAIN_TOP, not self.uiData.hide_main_top, self.uiBase.SortingOrder)
  15. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DISPLAY_MAIN_BOTTOM, not self.uiData.hide_main_bottom, self.uiBase.SortingOrder)
  16. end
  17. if self.uiData.top_res_id > 0 then
  18. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_MAIN_TOP_RES_TYPE, self.uiData.top_res_id)
  19. end
  20. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FILLCONTENT_COMPELETED, self)
  21. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UISTORY_CONDITION_TRIGGER, Enum.UIStoryCondType.FirstUIOpen, self.uiData.id)
  22. ManagerContainer.LuaUIMgr:OnShowPage(self.uiData)
  23. --打开限时礼包
  24. --if self.uiData.can_limit_gift then
  25. -- ManagerContainer.LuaUIMgr:OpenLimitRechargeUI()
  26. --end
  27. end
  28. function UIViewBase:OnBaseHide()
  29. --LogError(self.uiData.name.." hide")
  30. ManagerContainer.LuaUIMgr:OnRemovePage(self.uiData)
  31. CommonUtil.CloseUIClearAsyncSeqIds(self)
  32. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_CLOSE_COMPELETED, self)
  33. end
  34. function UIViewBase:OnSubClose(path)
  35. local target = CommonUtil.ParseUITargetPath(self, path)
  36. if target == nil then
  37. return
  38. end
  39. local animator = target.gameObject:GetComponent(Enum.TypeInfo.Animator)
  40. if animator then
  41. CommonUtil.ResetAnimator(animator)
  42. end
  43. target:SetActive(false)
  44. end
  45. function UIViewBase:OnBaseClose()
  46. ManagerContainer.LuaUIMgr:OnRemovePage(self.uiData)
  47. end
  48. function UIViewBase:OnBaseDispose()
  49. --if owner.uiData.hide_main_top then
  50. -- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DISPLAY_MAIN_TOP, true)
  51. --end
  52. --if owner.uiData.hide_main_bottom then
  53. -- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DISPLAY_MAIN_BOTTOM, true)
  54. --end
  55. if self.fxGoes ~= nil then
  56. for i =1, #self.fxGoes do
  57. ManagerContainer.ResMgr:RecycleGO(Constants.EffectPath,self.fxGoes[i].name,self.fxGoes[i].go)
  58. self.fxGoes[i].item.uiParticle = nil
  59. end
  60. end
  61. self.fxGoes = nil
  62. CommonUtil.ClearGridViewItem(self)
  63. CommonUtil.BatchDisposeItems(self)
  64. CommonUtil.CloseUIClearAsyncSeqIds(self)
  65. end
  66. function UIViewBase:DisposeView()
  67. if self.controller then
  68. self.controller:OnDispose()
  69. self.controller = nil
  70. end
  71. if self.inited then
  72. self:GenerateDestroy()
  73. end
  74. if self.uiData then
  75. local uiId = self.uiData.id
  76. ManagerContainer.LuaUIMgr:RemoveUIView(uiId, self)
  77. self.gameObject = nil
  78. self.transform = nil
  79. self.uiBase = nil
  80. self.uiData = nil
  81. ManagerContainer.LuaUIMgr:DestroyUIView(uiId)
  82. end
  83. end
  84. function UIViewBase:AddNewEffect(itemlua,effectName,effectGo)
  85. if effectName == nil or effectGo == nil then
  86. return
  87. else
  88. self.fxGoes[#self.fxGoes+1] = {item =itemlua,name=effectName,go=effectGo}
  89. end
  90. end
  91. function UIViewBase:RemoveEffect(itemlua,effectName,effectGo)
  92. if effectName == nil or effectGo == nil or self.fxGoes == nil then
  93. return
  94. else
  95. for i =1, #self.fxGoes do
  96. if self.fxGoes[i].item == itemlua and self.fxGoes[i].name == effectName and self.fxGoes[i].go == effectGo then
  97. table.remove(self.fxGoes, i)
  98. return
  99. end
  100. end
  101. end
  102. end
  103. function UIViewBase:OnPageOutEnd()
  104. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_PAGE_OUT_END_NTF, self.uiData.id)
  105. end
  106. function UIViewBase:OnPageInEnd()
  107. if self.uiData == nil then return end
  108. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_PAGE_IN_END_NTF, self.uiData.id)
  109. if self.uiBase.MSourceUIID > 0 and self.uiBase.MUIType == Enum.UIType.TotalWin then
  110. ManagerContainer.LuaUIMgr:Hide(self.uiBase.MSourceUIID, false)
  111. end
  112. end
  113. return UIViewBase