KeepSakeBook.lua 3.7 KB

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