KLUIDailyRaffleRewardItem.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---@class KLUIDailyRaffleRewardItem:UIKmlLuaPanelBase
  2. ---@field view KLUIDailyRaffleRewardItemView
  3. local KLUIDailyRaffleRewardItem = class(UIKmlLuaPanelBase)
  4. local this = KLUIDailyRaffleRewardItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:RefreshItem(args)
  10. self.args = args
  11. GUI:setPosition(self.view.root,self.args.pos.x,self.args.pos.y)
  12. GUI:Item_setItemId(self.view.equip_item,self.args.cfgId)
  13. GUI:Item_setItemCount(self.view.equip_item,self.args.count)
  14. --GUI:Item_setItemId(self.view.equip_item,20900002)
  15. if SL:GetConfig('cfg_item', self.args.cfgId).type ~= EItemType.Equip then
  16. GUI:setVisible(self.view.arrow, false)
  17. else
  18. if SL:CheckEquipBaseCareer(self.args) and SL:CompareInitGrage(self.args) == 1 then
  19. GUI:setVisible(self.view.arrow, true)
  20. else
  21. GUI:setVisible(self.view.arrow, false)
  22. end
  23. local entryLib = nil
  24. if SL:HasConfig('cfg_equip_entryLib', self.args.cfgId) then
  25. entryLib = SL:GetConfig('cfg_equip_entryLib', self.args.cfgId)
  26. end
  27. local img_quality = self.view.img_quality
  28. GUI:setVisible(img_quality, false)
  29. if entryLib then
  30. local qualityTbl = SL:GetConfigTable("cfg_equip_quality")
  31. ---@param v cfg_equip_quality_column
  32. for _, v in pairs(qualityTbl) do
  33. if not string.isNullOrEmpty(v.logo) and entryLib.initialRating >= v.stage[1] and entryLib.initialRating <= v.stage[2] then
  34. GUI:setVisible(img_quality, true)
  35. GUI:Image_loadTexture(img_quality, v.logo, "Atlas/UIBagPanel.spriteatlas")
  36. break
  37. end
  38. end
  39. end
  40. end
  41. local effect_id = SL:GetConfig("cfg_item",self.args.cfgId,"id").sEffect
  42. if effect_id and effect_id ~= 0 then
  43. local effect_tbl = SL:GetConfig("cfg_model_effect",effect_id,"id")
  44. GUI:Model_setSrc(self.view.effect_model,effect_tbl.path)
  45. GUI:setVisible(self.view.effect_model, true)
  46. else
  47. GUI:setVisible(self.view.effect_model, false)
  48. end
  49. end
  50. ---注册UI事件和服务器消息
  51. function this:RegistEvents()
  52. GUI:AddOnClickEvent(self.view.btn,self,self.BtnClick)
  53. end
  54. function this:BtnClick()
  55. SL:OpenTips("", self.args.cfgId)
  56. end
  57. function this:Close()
  58. end
  59. function this:select()
  60. GUI:setVisible(self.view.select, true)
  61. end
  62. function this:noselect()
  63. GUI:setVisible(self.view.select, false)
  64. end
  65. return this