UIPetExchangeMatsCtr.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. local UIPetExchangeMatsCtr = class("UIPetExchangeMatsCtr", require("UICtrBase"))
  2. function UIPetExchangeMatsCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIPetExchangeMatsCtr:SetData(data)
  6. self.asyncIdx = 0
  7. if data == nil then return end
  8. self.data = data
  9. self.tempselectCount = self.data.selectInfo.selectCount
  10. if self.data.selectInfo and self.data.selectInfo.conditions then
  11. self.data.selectInfo.maxNum = self.data.selectInfo.conditions[4]
  12. end
  13. end
  14. function UIPetExchangeMatsCtr:RefreshShowDataType()
  15. local showDataLength = 0
  16. if self.data.list then
  17. showDataLength = #self.data.list
  18. if self.row and self.minColumn then
  19. local curColumn = Mathf.Ceil(showDataLength / self.row) + 4
  20. if curColumn < self.minColumn then
  21. curColumn = self.minColumn
  22. end
  23. showDataLength = curColumn * self.row
  24. end
  25. end
  26. self.showDataLength = showDataLength
  27. end
  28. function UIPetExchangeMatsCtr:SetGridRowColumn(row, minColumn)
  29. self.row = row
  30. self.minColumn = minColumn
  31. end
  32. function UIPetExchangeMatsCtr:Getconditions()
  33. return self.data.selectInfo.conditions
  34. end
  35. function UIPetExchangeMatsCtr:GetenterType()
  36. return self.data.selectInfo.enterType
  37. end
  38. function UIPetExchangeMatsCtr:GetIndexInfo()
  39. return self.data.selectInfo.indexInfo
  40. end
  41. function UIPetExchangeMatsCtr:GetotherSelectList()
  42. return self.data.selectInfo.otherSelectList
  43. end
  44. function UIPetExchangeMatsCtr:GetSelectList()
  45. return self.data.selectInfo.selectList
  46. end
  47. function UIPetExchangeMatsCtr:GetSelectCount()
  48. return self.data.selectInfo.selectCount
  49. end
  50. function UIPetExchangeMatsCtr:GetTempSelectCount()
  51. return self.tempselectCount
  52. end
  53. function UIPetExchangeMatsCtr:SetCurrSelectCount(count)
  54. self.data.selectInfo.selectCount = count
  55. end
  56. function UIPetExchangeMatsCtr:executeCallBack()
  57. if self.data.callback then
  58. self.data.callback[2](self.data.callback[1],self.data.selectInfo)
  59. end
  60. end
  61. function UIPetExchangeMatsCtr:GetMaxSelectNum()
  62. return self.data.selectInfo.conditions and self.data.selectInfo.conditions[4] or 0
  63. end
  64. function UIPetExchangeMatsCtr:GetShowDataLength()
  65. return self.showDataLength or 0
  66. end
  67. function UIPetExchangeMatsCtr:GetRealShowDataLength()
  68. return self.data.list and #self.data.list or 0
  69. end
  70. function UIPetExchangeMatsCtr:GetShowDatas()
  71. return self.data.list
  72. end
  73. function UIPetExchangeMatsCtr:GetShowData(itemIndex)
  74. return self.data.list and self.data.list[itemIndex + 1] or nil
  75. end
  76. function UIPetExchangeMatsCtr:GetPetDataById(id)
  77. for k,v in pairs(self.data.list) do
  78. if v.id == id then
  79. return v, k
  80. end
  81. end
  82. return nil, nil
  83. end
  84. function UIPetExchangeMatsCtr:GetAsyncIdx()
  85. self.asyncIdx = self.asyncIdx + 1
  86. return self.asyncIdx
  87. end
  88. function UIPetExchangeMatsCtr:GetData()
  89. return self.data
  90. end
  91. function UIPetExchangeMatsCtr:OnDispose()
  92. self.data = nil
  93. self.view = nil
  94. end
  95. return UIPetExchangeMatsCtr