UIArtifactPoolView.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. local UIArtifactPoolView = require("UIArtifactTips/UIArtifactPoolView_Generate")
  2. function UIArtifactPoolView:OnAwake(data)
  3. self.controller = require("UIArtifactTips/UIArtifactPoolCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIArtifactPoolView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_POOL_REFRESH, self, self.OnAckBack)
  10. end
  11. function UIArtifactPoolView:FillContent(data, uiBase)
  12. self.uiBase = uiBase
  13. local gameObject = self.uiBase:GetRoot()
  14. if gameObject ~= nil then
  15. self.gameObject = gameObject
  16. self.transform = gameObject.transform
  17. end
  18. self:InitGenerate(self.transform, data)
  19. self:Init()
  20. end
  21. function UIArtifactPoolView:Init()
  22. self:InitGrid()
  23. self.next:SetActive(false)
  24. self.controller:SendSkillEquipPoolReq()
  25. end
  26. function UIArtifactPoolView:OnAckBack()
  27. self.controller:RefreshRandomPool()
  28. self:RefreshPool()
  29. self:RefreshTextShow()
  30. end
  31. function UIArtifactPoolView:InitGrid()
  32. self.opend.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  33. return self:GetOpenedItemByRowColumn(gridView, itemIndex, row, column)
  34. end, nil)
  35. self.next.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  36. return self:GetNextItemByRowColumn(gridView, itemIndex, row, column)
  37. end, nil)
  38. end
  39. function UIArtifactPoolView:RefreshPool()
  40. local nextLength = self.controller:GetNextRandomPoolLength()
  41. self.next:SetActive(nextLength > 0)
  42. if nextLength > 0 then
  43. local nextLoopGridView = self.next.loopGridView
  44. nextLoopGridView:SetListItemCount(nextLength, true)
  45. nextLoopGridView:RefreshAllShownItem()
  46. end
  47. local openedLength = self.controller:GetOpenedRandomPoolLength()
  48. local curLoopGridView = self.opend.loopGridView
  49. curLoopGridView:SetListItemCount(openedLength, true)
  50. curLoopGridView:RefreshAllShownItem()
  51. end
  52. function UIArtifactPoolView:RefreshTextShow()
  53. local curId = self.controller:GetCurId()
  54. local nextRemainDay = self.controller:GetNextRemainDay()
  55. self.opend.text.uILocalizeScript:SetContent(curId == 1 and "TitleOpend" or "TitleOpendNew")
  56. self.next.text.uILocalizeScript:SetContentAndValues("TitleNextPool", {nextRemainDay})
  57. self.notice:SetActive(curId > 1)
  58. end
  59. function UIArtifactPoolView:GetOpenedItemByRowColumn(gridView, itemIndex, row, column)
  60. local showData = self.controller:GetOpendRandomPoolDataByIdx(itemIndex)
  61. local item = nil
  62. if showData then
  63. item = gridView:NewListViewItem("IconItem")
  64. item.gameObject.name = itemIndex
  65. local itemlua = CommonUtil.BindGridViewItem2Lua(self, "IconItem", item.gameObject)
  66. CommonUtil.UpdateItemPrefab(self, itemlua, showData, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
  67. else
  68. item = gridView:NewListViewItem('IconEmptyItem')
  69. end
  70. return item
  71. end
  72. function UIArtifactPoolView:GetNextItemByRowColumn(gridView, itemIndex, row, column)
  73. local showData = self.controller:GetNextRandomPoolDataByIdx(itemIndex)
  74. local item = nil
  75. if showData then
  76. item = gridView:NewListViewItem("IconItem")
  77. item.gameObject.name = itemIndex
  78. local itemlua = CommonUtil.BindGridViewItem2Lua(self, "IconItem", item.gameObject)
  79. CommonUtil.UpdateItemPrefab(self, itemlua, showData, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
  80. else
  81. item = gridView:NewListViewItem('IconEmptyItem')
  82. end
  83. return item
  84. end
  85. function UIArtifactPoolView:RemoveEventListener()
  86. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  87. end
  88. function UIArtifactPoolView:AddUIEventListener()
  89. self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.OnCloseClick)
  90. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnCloseClick)
  91. end
  92. function UIArtifactPoolView:OnCloseClick()
  93. self:UIClose()
  94. end
  95. function UIArtifactPoolView:ShowItemTips(button, params)
  96. local skillEuipData = params[0]
  97. local params = {{cfgId = skillEuipData.cfgId, jobType = skillEuipData.JobType, logicData = skillEuipData}, Enum.ItemIEnterType.SkillEquip, self.uiData.id}
  98. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactTips, params)
  99. end
  100. function UIArtifactPoolView:OnHide()
  101. end
  102. function UIArtifactPoolView:OnShow(data)
  103. self.controller:SetData(data)
  104. end
  105. function UIArtifactPoolView:OnClose()
  106. self.opend.loopGridView:Dispose()
  107. self.next.loopGridView:Dispose()
  108. end
  109. function UIArtifactPoolView:OnDispose()
  110. self.controller:OnDispose()
  111. end
  112. return UIArtifactPoolView