KLEquipQualityEntryItem.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---@class KLEquipQualityEntryItem:UIKmlLuaPanelBase
  2. ---@field view KLEquipQualityEntryItemView
  3. local KLEquipQualityEntryItem = class(UIKmlLuaPanelBase)
  4. local this =KLEquipQualityEntryItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.equipAttItems = {}
  8. end
  9. ---注册UI事件和服务器消息
  10. function this:RegistEvents()
  11. end
  12. ---创建或者刷新界面数据时调用
  13. function this:Refresh()
  14. local cfgId = self.args.cfgId
  15. local img_quality = self.view.imgQuality
  16. GUI:setVisible(img_quality, false)
  17. -- self:Recycle()
  18. if not cfgId then
  19. return
  20. end
  21. --装备品阶
  22. ---@type cfg_equip_entryLib_column
  23. local entryLib = nil
  24. if SL:HasConfig('cfg_equip_entryLib', cfgId) then
  25. entryLib = SL:GetConfig('cfg_equip_entryLib', cfgId)
  26. end
  27. if entryLib then
  28. local qualityTbl = SL:GetConfigTable("cfg_equip_quality")
  29. ---@param v cfg_equip_quality_column
  30. for _, v in pairs(qualityTbl) do
  31. if not string.isNullOrEmpty(v.logo) and entryLib.initialRating >= v.stage[1] and entryLib.initialRating <= v.stage[2] then
  32. GUI:setVisible(img_quality, true)
  33. GUI:Image_loadTexture(img_quality, v.logo, "Atlas/UIBagPanel.spriteatlas")
  34. break
  35. end
  36. end
  37. end
  38. --卓越词条数量
  39. local count = self.args.entryCount or 0
  40. for i=1, count do
  41. if i > #self.equipAttItems then
  42. ---@type KLCommonImageItem
  43. local attItem = GUI:UIPanel_Open("dev/ui/Equip/Item/KLCommonImage/KLCommonImageItem", self.view.imgQuality, self, {
  44. sprite = "img_equipAtt", altas = "Atlas/UIBagPanel.spriteatlas"
  45. }, true)
  46. table.insert(self.equipAttItems, attItem)
  47. attItem:SetSize(20, 20)
  48. attItem:SetPosition(-2, -18 - (i - 1) * 8)
  49. else
  50. GUI:SetActive(self.equipAttItems[i].view.root, true)
  51. end
  52. end
  53. for i=count+1, #self.equipAttItems do
  54. GUI:SetActive(self.equipAttItems[i].view.root, false)
  55. end
  56. end
  57. function this:SetData(cfgId, entryCount)
  58. self.args = {
  59. cfgId = cfgId,
  60. entryCount = entryCount
  61. }
  62. self:Refresh()
  63. end
  64. function this:Recycle()
  65. for _, v in pairs(self.equipAttItems) do
  66. GUI:UIPanel_Close(nil, v)
  67. end
  68. table.clear(self.equipAttItems)
  69. end
  70. function this:Close()
  71. self:Recycle()
  72. end
  73. return this