KLSuitEquipItem.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---@class KLSuitEquipItem:UIKmlLuaPanelBase
  2. ---@field view KLSuitEquipItemView
  3. ---@field baseUI KLSuitItem
  4. ---@field
  5. local KLSuitEquipItem = class(UIKmlLuaPanelBase)
  6. local this = KLSuitEquipItem
  7. ---创建时调用一次
  8. function this:Init()
  9. self.lastClick = 0
  10. end
  11. function this:UpdateUI(suitIndex, luaIndex, cfgId, isSelect, isUnlocked)
  12. self.suitIndex = suitIndex
  13. self.luaIndex = luaIndex
  14. self.isUnlocked = isUnlocked
  15. GUI:Item_setItemId(self.view.EquipItem, cfgId)
  16. GUI:setVisible(self.view.img_quality, false)
  17. --装备品阶
  18. if SL:HasConfig('cfg_equip_entryLib', cfgId) then
  19. ---@type cfg_equip_entryLib_column
  20. local entryLib = SL:GetConfig('cfg_equip_entryLib', cfgId)
  21. local qualityTbl = SL:GetConfigTable("cfg_equip_quality")
  22. ---@param v cfg_equip_quality_column
  23. for _, v in pairs(qualityTbl) do
  24. if not string.isNullOrEmpty(v.logo) and entryLib.initialRating >= v.stage[1] and entryLib.initialRating <= v.stage[2] then
  25. GUI:setVisible(self.view.img_quality, true)
  26. GUI:Image_loadTexture(self.view.img_quality, v.logo, "Atlas/AppearGroup.spriteatlas")
  27. break
  28. end
  29. end
  30. end
  31. if isSelect then
  32. self:BtnEquipOnSelect()
  33. else
  34. self:SetState(false)
  35. end
  36. GUI:SetActive(self.view.SpMask, not isUnlocked)
  37. GUI:SetActive(self.view.SpLock, not isUnlocked)
  38. end
  39. ---注册UI事件和服务器消息
  40. function this:RegistEvents()
  41. GUI:AddOnClickEvent(self.view.BtnEquip, self, self.BtnEquipOnSelect)
  42. end
  43. function this:BtnEquipOnSelect()
  44. if Time.frameCount - self.lastClick < 3 then
  45. return
  46. end
  47. self.lastClick = Time.frameCount
  48. return self.baseUI.baseUI:OnEquipItemSelect(self, self.suitIndex, self.luaIndex, self.isUnlocked)
  49. end
  50. function this:SetState(isSelect)
  51. return GUI:SetActive(self.view.SpState, isSelect)
  52. end
  53. function this:Close()
  54. end
  55. return this