| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- local UIArtifactPoolView = require("UIArtifactTips/UIArtifactPoolView_Generate")
- function UIArtifactPoolView:OnAwake(data)
- self.controller = require("UIArtifactTips/UIArtifactPoolCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- end
- function UIArtifactPoolView:AddEventListener()
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_POOL_REFRESH, self, self.OnAckBack)
- end
- function UIArtifactPoolView:FillContent(data, uiBase)
- self.uiBase = uiBase
- local gameObject = self.uiBase:GetRoot()
- if gameObject ~= nil then
- self.gameObject = gameObject
- self.transform = gameObject.transform
- end
- self:InitGenerate(self.transform, data)
- self:Init()
- end
- function UIArtifactPoolView:Init()
- self:InitGrid()
- self.next:SetActive(false)
- self.controller:SendSkillEquipPoolReq()
- end
- function UIArtifactPoolView:OnAckBack()
- self.controller:RefreshRandomPool()
- self:RefreshPool()
- self:RefreshTextShow()
- end
- function UIArtifactPoolView:InitGrid()
- self.opend.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
- return self:GetOpenedItemByRowColumn(gridView, itemIndex, row, column)
- end, nil)
- self.next.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
- return self:GetNextItemByRowColumn(gridView, itemIndex, row, column)
- end, nil)
- end
- function UIArtifactPoolView:RefreshPool()
- local nextLength = self.controller:GetNextRandomPoolLength()
- self.next:SetActive(nextLength > 0)
- if nextLength > 0 then
- local nextLoopGridView = self.next.loopGridView
- nextLoopGridView:SetListItemCount(nextLength, true)
- nextLoopGridView:RefreshAllShownItem()
- end
- local openedLength = self.controller:GetOpenedRandomPoolLength()
- local curLoopGridView = self.opend.loopGridView
- curLoopGridView:SetListItemCount(openedLength, true)
- curLoopGridView:RefreshAllShownItem()
- end
- function UIArtifactPoolView:RefreshTextShow()
- local curId = self.controller:GetCurId()
- local nextRemainDay = self.controller:GetNextRemainDay()
- self.opend.text.uILocalizeScript:SetContent(curId == 1 and "TitleOpend" or "TitleOpendNew")
- self.next.text.uILocalizeScript:SetContentAndValues("TitleNextPool", {nextRemainDay})
- self.notice:SetActive(curId > 1)
- end
- function UIArtifactPoolView:GetOpenedItemByRowColumn(gridView, itemIndex, row, column)
- local showData = self.controller:GetOpendRandomPoolDataByIdx(itemIndex)
- local item = nil
- if showData then
- item = gridView:NewListViewItem("IconItem")
- item.gameObject.name = itemIndex
- local itemlua = CommonUtil.BindGridViewItem2Lua(self, "IconItem", item.gameObject)
- CommonUtil.UpdateItemPrefab(self, itemlua, showData, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
- else
- item = gridView:NewListViewItem('IconEmptyItem')
- end
- return item
- end
- function UIArtifactPoolView:GetNextItemByRowColumn(gridView, itemIndex, row, column)
- local showData = self.controller:GetNextRandomPoolDataByIdx(itemIndex)
- local item = nil
- if showData then
- item = gridView:NewListViewItem("IconItem")
- item.gameObject.name = itemIndex
- local itemlua = CommonUtil.BindGridViewItem2Lua(self, "IconItem", item.gameObject)
- CommonUtil.UpdateItemPrefab(self, itemlua, showData, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
- else
- item = gridView:NewListViewItem('IconEmptyItem')
- end
- return item
- end
- function UIArtifactPoolView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UIArtifactPoolView:AddUIEventListener()
- self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.OnCloseClick)
- self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnCloseClick)
- end
- function UIArtifactPoolView:OnCloseClick()
- self:UIClose()
- end
- function UIArtifactPoolView:ShowItemTips(button, params)
- local skillEuipData = params[0]
- local params = {{cfgId = skillEuipData.cfgId, jobType = skillEuipData.JobType, logicData = skillEuipData}, Enum.ItemIEnterType.SkillEquip, self.uiData.id}
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactTips, params)
- end
- function UIArtifactPoolView:OnHide()
- end
- function UIArtifactPoolView:OnShow(data)
- self.controller:SetData(data)
- end
- function UIArtifactPoolView:OnClose()
- self.opend.loopGridView:Dispose()
- self.next.loopGridView:Dispose()
- end
- function UIArtifactPoolView:OnDispose()
- self.controller:OnDispose()
- end
- return UIArtifactPoolView
|