KeepSakeBookCtr.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. local KeepSakeBookCtr = class("KeepSakeBookCtr", require("UICtrBase"))
  2. function KeepSakeBookCtr:Init()
  3. end
  4. function KeepSakeBookCtr:GetData()
  5. return self.data
  6. end
  7. function KeepSakeBookCtr:GetCurCount(type)
  8. local count = ManagerContainer.DataMgr.KeepSakeBookData:GetKeepSakeHandBookQualityCountByType(type)
  9. return count
  10. end
  11. function KeepSakeBookCtr:GetHandBookKeepSakeCfgDatas(quality)
  12. local list = clone(ManagerContainer.CfgMgr:GetKeepSakeCfgDatasByLevel(quality))
  13. for _,v in pairs(list) do
  14. v.canLvUp = ManagerContainer.DataMgr.KeepSakeBookData:CanKeepSakeLvUp(v.Id)
  15. v.lv = ManagerContainer.DataMgr.KeepSakeBookData:GetKeepSakeBookDataById(v.Id) or 0
  16. v.front = v.canLvUp
  17. if not v.canLvUp and v.lv > 0 then
  18. v.front = true
  19. end
  20. end
  21. CommonUtil.ArraySortListSelections(list, {Enum.TableSortRule.Down, Enum.TableSortRule.Up, Enum.TableSortRule.Up}, {"front", "CollectionLevel","Id"})
  22. return list
  23. end
  24. function KeepSakeBookCtr:GetHandBookKeepSakeCfgDatasByType(type)
  25. if type == Enum.CollectQualityType.ALL then
  26. local list = {}
  27. for i = 2, 4 do
  28. local list1 = self:GetHandBookKeepSakeCfgDatas(i)
  29. for _,v in pairs(list1) do
  30. list[#list + 1] = v
  31. end
  32. end
  33. CommonUtil.ArraySortListSelections(list, {Enum.TableSortRule.Down, Enum.TableSortRule.Up, Enum.TableSortRule.Up}, {"front", "CollectionLevel","Id"})
  34. self.showData = list
  35. elseif type >= Enum.CollectQualityType.NORMAL or type <= Enum.CollectQualityType.MVP then
  36. self.showData = self:GetHandBookKeepSakeCfgDatas(type)
  37. end
  38. end
  39. function KeepSakeBookCtr:GetCurShowDatasLength()
  40. return self.showData and #self.showData or 0
  41. end
  42. function KeepSakeBookCtr:GetShowDataByIdx(idx)
  43. return self.showData and self.showData[idx] or nil
  44. end
  45. function KeepSakeBookCtr:GetKeepSakeBookOffsetCfgId(cfgId, offset)
  46. if not self.showData then return cfgId end
  47. for i = 1,#self.showData do
  48. if self.showData[i].Id == cfgId then
  49. if i + offset < 1 then
  50. return self.showData[#self.showData].Id
  51. elseif i + offset > #self.showData then
  52. return self.showData[1].Id
  53. else
  54. return self.showData[i + offset].Id
  55. end
  56. end
  57. end
  58. return cfgId
  59. end
  60. function KeepSakeBookCtr:OnDispose()
  61. self.showData = nil
  62. self.data = nil
  63. end
  64. return KeepSakeBookCtr