UIForgePopView.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. local UIForgePopView = require("UIForgePop/UIForgePopView_Generate")
  2. function UIForgePopView:OnAwake(data)
  3. self.controller = require("UIForgePop/UIForgePopCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIForgePopView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EQUIP_FORGE_SUCCESS, function(type)
  9. self:UIClose()
  10. end)
  11. end
  12. function UIForgePopView:FillContent(data, uiBase)
  13. self.uiBase = uiBase
  14. local gameObject = self.uiBase:GetRoot()
  15. if gameObject ~= nil then
  16. self.gameObject = gameObject
  17. self.transform = gameObject.transform
  18. end
  19. self:InitGenerate(self.transform, data)
  20. self:Init()
  21. end
  22. function UIForgePopView:Init()
  23. local data = self.controller:GetData()
  24. local list = data[1]
  25. local totalCost = data[2]
  26. CommonUtil.LoopGridViewEleCreate(self,
  27. self.scrollView.loopVerticalScrollRect,
  28. self.content.gridLayoutGroup,
  29. list,
  30. 0,
  31. function(itemlua, idx)
  32. CommonUtil.UpdateItemPrefab(self, itemlua, list[idx + 1], Enum.ItemIEnterType.EquipForgePop)
  33. end)
  34. self.text.text.text = totalCost
  35. end
  36. function UIForgePopView:RemoveEventListener()
  37. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  38. end
  39. function UIForgePopView:AddUIEventListener()
  40. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  41. self.uiBase:AddButtonEventListener(self.btnClose.button, function()
  42. self:UIClose()
  43. end)
  44. self.uiBase:AddButtonEventListener(self.btnCompose.button, function()
  45. local data = self.controller:GetData()
  46. self.controller:SendEquipOneKeyForge(data[3], data[4])
  47. end)
  48. end
  49. function UIForgePopView:OnHide()
  50. end
  51. function UIForgePopView:OnShow(data)
  52. self.controller:SetData(data)
  53. self:Init()
  54. end
  55. function UIForgePopView:OnClose()
  56. end
  57. function UIForgePopView:OnDispose()
  58. end
  59. return UIForgePopView