KLTipBtntem.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ---@class KLTipBtntem:UIKmlLuaPanelBase
  2. ---@field view KLTipBtntemView
  3. local KLTipBtntem = class(UIKmlLuaPanelBase)
  4. local this = KLTipBtntem
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:Button_setTitleText(self.view.button_id,self.args.nameStr)
  8. end
  9. ---创建或者刷新界面数据时调用
  10. function this:Refresh()
  11. end
  12. ---注册UI事件和服务器消息
  13. function this:RegistEvents()
  14. GUI:AddOnClickEvent(self.view.button_id,self,self.BtnOnClick)
  15. end
  16. function this:BtnOnClick()
  17. if not InfoManager.equipOrItemTipsInfo:IsCanOnClickButton(self.args.btnType) then
  18. return
  19. end
  20. if self.args.btnType[1] == "0" then
  21. self:CloseEquipTips()
  22. elseif self.args.btnType[1] == "1" then
  23. self:UseItem()
  24. elseif self.args.btnType[1] == "2" then
  25. self:RecycleItem()
  26. elseif self.args.btnType[1] == "3" then
  27. self:PutOneEquip()
  28. elseif self.args.btnType[1] == "9" then
  29. local name = SL:GetEquipValue(EMetaVarGetKey.EQUIP_NAME, self.args.equip_pos, self.args.cfgId, self.args.id)
  30. SL:CommonTipsMessage({ showTips = "是否摧毁"..name ,
  31. ui = self,
  32. sureBtnText = "确定",
  33. cancelBtnText = "取消",
  34. callback = self.DestroyItem
  35. })
  36. elseif self.args.btnType[1] == "10" then
  37. self:JieFeng()
  38. elseif self.args.btnType[1] == "11" then
  39. self:DiuQi()
  40. elseif self.args.btnType[1] == "13" then
  41. self:Decompose()
  42. elseif self.args.btnType[1] == "99" then
  43. self:OpenPanel()
  44. end
  45. end
  46. function this:RecycleItem()
  47. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  48. GUI:UIPanel_Close("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel")
  49. GUI:UIPanel_Open("dev/ui/Recover/Panel/KLRecover/KLRecoverPanel")
  50. self:CloseEquipTips()
  51. end
  52. function this:CloseEquipTips()
  53. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel")
  54. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLIUItemTips/KLUIItemTipsPanel")
  55. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLUIEquipTipsComparsion/KLUIEquipTipsComparsionPanel")
  56. end
  57. function this:PutOneEquip()
  58. local ItemInfo = SL:GetPosItemInfo(self.args.equip_pos,self.args.cfgId,self.args.id)
  59. SL:PutOnEquip(ItemInfo)
  60. self:CloseEquipTips()
  61. end
  62. function this.DestroyItem(returnData)
  63. local ui = returnData.ui
  64. local index = SL:GetBagIndex(ui.args.id)
  65. SL:ReqDestroyItemMessage(index)
  66. ui:CloseEquipTips()
  67. end
  68. function this:JieFeng()
  69. self:CloseEquipTips()
  70. end
  71. function this:DiuQi()
  72. local index = SL:GetBagIndex(self.args.id)
  73. SL:ReqGiveUpItemMessage(index)
  74. self:CloseEquipTips()
  75. end
  76. function this:Decompose()
  77. self:CloseEquipTips()
  78. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  79. GUI:UIPanel_Close("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel")
  80. SL:OpenForgeGroupUI(EForgeGroupType.Decompose)
  81. end
  82. function this:UseItem()
  83. SL:UseItem(self.args.cfgId, self.args.id, self.args.count)
  84. self:CloseItemTips()
  85. end
  86. function this:OpenPanel()
  87. if #self.args.btnType < 3 then
  88. return
  89. end
  90. self:CloseEquipTips()
  91. GUI:UIPanel_Close("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel")
  92. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  93. local panel = self.args.btnType[4]
  94. if #self.args.btnType == 4 then
  95. GUI:UIPanel_Open(panel)
  96. elseif #self.args.btnType == 5 then
  97. local num = self.args.btnType[5]
  98. if tonumber(num) then
  99. num = tonumber(num)
  100. end
  101. GUI:UIPanel_Open(panel,nil,nil,num)
  102. elseif #self.args.btnType >=7 then
  103. local message = {}
  104. for i=5,#self.args.btnType-2,3 do
  105. if self.args.btnType[i] and self.args.btnType[i+1] and self.args.btnType[i+2] then
  106. if self.args.btnType[i+1] == "string" then
  107. message[self.args.btnType[i]] = self.args.btnType[i+2]
  108. else
  109. message[self.args.btnType[i]] = tonumber(self.args.btnType[i+2])
  110. end
  111. end
  112. end
  113. GUI:UIPanel_Open(panel,nil,nil,message)
  114. end
  115. SL.HideMainPanel()
  116. end
  117. function this:Close()
  118. end
  119. return this