KeepSakeBook.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. local KeepSakeBook = class("KeepSakeBook")
  2. local pageToggleData = {}
  3. function KeepSakeBook:ctor()
  4. end
  5. function KeepSakeBook:InitGo(host,uiGo)
  6. self.host = host
  7. self.viewLua = CommonUtil.BindGridViewItem2Lua(self.host, "BookItem", uiGo)
  8. self.controller = require("UICollect/KeepSakeBookCtr"):new()
  9. self.host.controller:SetKeepSakeBookCtr(self.controller)
  10. self:InitPanel()
  11. end
  12. function KeepSakeBook:InitPanel()
  13. self:InitGrid()
  14. self.viewLua.qtyCard:SetActive(false)
  15. self.viewLua.qtyPet:SetActive(false)
  16. self.viewLua.qtyCollection:SetActive(true)
  17. self.viewLua.btnMaterials:SetActive(true)
  18. self.viewLua.dscBox:SetActive(true)
  19. self.viewLua.btnReceive:SetActive(false)
  20. end
  21. function KeepSakeBook:Hide()
  22. self.viewLua.gameObject:SetActive(false)
  23. end
  24. function KeepSakeBook:Show()
  25. self.viewLua.gameObject:SetActive(true)
  26. end
  27. function KeepSakeBook:SelectToggle()
  28. CommonUtil.CreateToggleMouduleOnlyBtns(self.host, pageToggleData, self.viewLua.toggleGroup, Enum.CollectQualityType.ALL, self.host.OnValueChangedToggle)
  29. end
  30. function KeepSakeBook:InitGrid()
  31. self.viewLua.scrollView.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  32. return self:GetItemByRowColumn(gridView, itemIndex, row, column)
  33. end, nil)
  34. end
  35. function KeepSakeBook:GetItemByRowColumn(gridView, itemIndex, row, column)
  36. local item = gridView:NewListViewItem('KeepSakeCollect')
  37. local cfgData = self.controller:GetShowDataByIdx(itemIndex + 1)
  38. local itemlua = CommonUtil.BindGridViewItem2Lua(self.host, "KeepSakeCollect", item.gameObject)
  39. CommonUtil.UpdateItemPrefab(self.host, itemlua, cfgData, nil, self, self.OnCollectionClick)
  40. --
  41. --local lv = ManagerContainer.DataMgr.KeepSakeBookData:GetKeepSakeBookDataById(cfgData.Id) or 0
  42. --
  43. --local isMax = cfgData["MaterialLevel"..(lv + 1)] == nil
  44. itemlua.uIRedPointRP:SetActive(cfgData.canLvUp)
  45. return item
  46. end
  47. function KeepSakeBook:OnValueChangedToggle()
  48. --LogHRWarning("OnValueChangedToggle")
  49. local type = pageToggleData.toggleDefaultIndex
  50. self.controller:GetHandBookKeepSakeCfgDatasByType(type)
  51. local count = self.controller:GetCurCount(type)
  52. local length = self.controller:GetCurShowDatasLength()
  53. local maxCount = length
  54. self.viewLua.qtyCollection.text.text.text = count.."/"..maxCount
  55. self.viewLua.qtyCollection.iconAll:SetActive(type == Enum.CollectQualityType.ALL)
  56. self.viewLua.qtyCollection.iconNormal:SetActive(type == Enum.CollectQualityType.NORMAL)
  57. self.viewLua.qtyCollection.iconMini:SetActive(type == Enum.CollectQualityType.MINIBOSS)
  58. self.viewLua.qtyCollection.iconMvp:SetActive(type == Enum.CollectQualityType.MVP)
  59. if length > 0 then
  60. --self.viewLua.scrollView.loopGridView:SetListItemCount(length, true)
  61. self.viewLua.scrollView.loopGridView:RefreshListByIndex(length)
  62. end
  63. end
  64. function KeepSakeBook:OnCollectionClick(button, params)
  65. local cfgId = params[0]
  66. local data = {type = Enum.CollectType.KeepSake, cfgId = cfgId}
  67. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UICollectTips, data)
  68. end
  69. function KeepSakeBook:AddEventListener()
  70. end
  71. function KeepSakeBook:RemoveEventListener()
  72. end
  73. function KeepSakeBook:AddUIEventListener()
  74. self.host.uiBase:AddButtonEventListener(self.viewLua.btnBack.button, self, self.OnBtnBackClick)
  75. self.host.uiBase:AddButtonEventListener(self.viewLua.btnMaterials.button, self, self.OnBtnMaterialClick)
  76. end
  77. function KeepSakeBook:OnBtnBackClick()
  78. if self.host and self.host.BookBack then
  79. self.host:BookBack()
  80. end
  81. end
  82. function KeepSakeBook:OnBtnMaterialClick()
  83. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIMaterialsTips)
  84. end
  85. function KeepSakeBook:Dispose()
  86. self.viewLua.scrollView.loopGridView:Dispose()
  87. self.controller:OnDispose()
  88. self.controller = nil
  89. self.host = nil
  90. self.viewLua:GenerateDestroy()
  91. self.viewLua = nil
  92. pageToggleData = {}
  93. end
  94. return KeepSakeBook