KLStrengthBagPanel.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ---@class KLStrengthBagPanel:UIKmlLuaPanelBase
  2. ---@field view KLStrengthBagPanelView
  3. local KLStrengthBagPanel = class(UIKmlLuaPanelBase)
  4. local this =KLStrengthBagPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self:InitData(self.args)
  8. local bag_info = SL:GetConfig('cfg_global',6).value
  9. self.maxHor = tonumber(bag_info[1])
  10. self.maxVet = tonumber(bag_info[2])
  11. EquipFunc:ReplaceEquipBagButton({self.view.person_shop_btn,self.view.storage_btn,self.view.recycle_btn,self.view.tidy_btn})
  12. ---@type KLUIBagTileScrollViewItem
  13. GUI:UIPanel_Open("dev/ui/Common/Item/KLUIBagTileScrollView/KLUIBagTileScrollViewItem", self.view.root,self,
  14. {itemList=SL:GetMetaValue("BAG_DATA")[1],
  15. id=E_BagTileScrollViewType.Strength, hor = tonumber(bag_info[1]), vet=tonumber(bag_info[2]),
  16. canDrag=false,itemClick=(self.args and self.args.itemClickCallBack), callBackUI=self.args.callBackUI},nil,function(bag)
  17. self.bagTileScrollView = bag
  18. end)
  19. end
  20. ---初始化数据
  21. function this:InitData(data)
  22. self.x=(data and data.x)or 0
  23. self.y=(data and data.y)or 0
  24. end
  25. ---创建或者刷新界面数据时调用
  26. function this:Refresh()
  27. local x = self.x
  28. local y = self.y
  29. GUI:setPosition(self.view.root, x, y)
  30. end
  31. ---注册UI事件和服务器消息
  32. function this:RegistEvents()
  33. GUI:AddOnClickEvent(self.view.closeBtn, self, self.closeBtn )
  34. SL:RegisterLUAEvent(Event.BagInfo_Change, self.BagInfo_Change, self)
  35. GUI:AddOnClickEvent(self.view.person_shop_btn, self, self.personBtn)
  36. GUI:AddOnClickEvent(self.view.storage_btn, self, self.personBtn)
  37. GUI:AddOnClickEvent(self.view.recycle_btn, self, self.personBtn)
  38. GUI:AddOnClickEvent(self.view.tidy_btn, self, self.personBtn)
  39. end
  40. function this:personBtn()
  41. SL:MessageTip({id=502})
  42. end
  43. function this:closeBtn()
  44. GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
  45. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipStrengthUI/KLEquipStrengthUIPanel")
  46. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipAppendUI/KLEquipAppendUIPanel")
  47. GUI:UIPanel_Close("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel")
  48. end
  49. function this:Close()
  50. end
  51. ---@param eventData {index:number,item:CommonProtos.Item}[]
  52. function this:BagInfo_Change(eventId, eventData)
  53. self.bagTileScrollView:Item_Change(eventData)
  54. end
  55. return this