KLUIItemPreviewItem.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ---@class KLUIItemPreviewItem:UIKmlLuaPanelBase
  2. ---@field view KLUIItemPreviewItemView
  3. local KLUIItemPreviewItem = class(UIKmlLuaPanelBase)
  4. local this = KLUIItemPreviewItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:RefreshItem(args)
  10. self.args = args
  11. GUI:Item_setItemId(self.view.equip_item,self.args.cfgId)
  12. --GUI:Item_setItemId(self.view.equip_item,20900002)
  13. if SL:GetConfig('cfg_item', self.args.cfgId).type ~= EItemType.Equip then
  14. GUI:setVisible(self.view.arrow, false)
  15. else
  16. if SL:CheckEquipBaseCareer(self.args) and SL:CompareInitGrage(self.args) == 1 then
  17. GUI:setVisible(self.view.arrow, true)
  18. else
  19. GUI:setVisible(self.view.arrow, false)
  20. end
  21. local entryLib = nil
  22. if SL:HasConfig('cfg_equip_entryLib', self.args.cfgId) then
  23. entryLib = SL:GetConfig('cfg_equip_entryLib', self.args.cfgId)
  24. end
  25. local img_quality = self.view.img_quality
  26. GUI:setVisible(img_quality, false)
  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. end
  39. local effect_id = SL:GetConfig("cfg_item",self.args.cfgId,"id").sEffect
  40. if effect_id and effect_id ~= 0 then
  41. local effect_tbl = SL:GetConfig("cfg_model_effect",effect_id,"id")
  42. GUI:Model_setSrc(self.view.effect_model,effect_tbl.path)
  43. GUI:setVisible(self.view.effect_model, true)
  44. else
  45. GUI:setVisible(self.view.effect_model, false)
  46. end
  47. end
  48. ---注册UI事件和服务器消息
  49. function this:RegistEvents()
  50. GUI:AddOnClickEvent(self.view.btn,self,self.BtnClick)
  51. end
  52. function this:BtnClick()
  53. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLIUItemTipsOther/KLIUItemTipsOtherPanel")
  54. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel")
  55. GUI:UIPanel_Close("dev/outui/Archangel/Panel/KLArchangelGrailTips/KLArchangelGrailTipsPanel")
  56. local tab = SL:GetConfig('cfg_item', self.args.cfgId)
  57. local equip_pos = self.args.equip_pos
  58. local is_right = false
  59. if not string.isNullOrEmpty(equip_pos) and equip_pos == "bag" then
  60. is_right = true
  61. end
  62. local _posX = 0
  63. if is_right then
  64. _posX = -804
  65. else
  66. _posX = -365
  67. end
  68. if tab.type == 2 then
  69. SL:OpenTips("", self.args.cfgId,nil,nil,nil,{hideComparsion = true,posX=_posX,hideBtn=true,isRight = is_right,hideMask=true})
  70. elseif tab.type == 9 then
  71. GUI:UIPanel_Open("dev/outui/Archangel/Panel/KLArchangelGrailTips/KLArchangelGrailTipsPanel",nil,nil,{ equip_pos = "", cfgId = self.args.cfgId, info={posX=_posX,isRight = is_right,hideMask=true} })
  72. else
  73. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLIUItemTipsOther/KLIUItemTipsOtherPanel")
  74. GUI:UIPanel_Open("dev/ui/Tips/Panel/KLIUItemTipsOther/KLIUItemTipsOtherPanel",nil,nil,{ equip_pos = "", cfgId = self.args.cfgId, info={posX=_posX,isRight = is_right,hideMask=true} })
  75. end
  76. end
  77. function this:Close()
  78. end
  79. return this