KLArchangelBreakthroughPanel.lua 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. ---@class KLArchangelBreakthroughPanel:UIKmlLuaPanelBase
  2. ---@field view KLArchangelBreakthroughPanelView
  3. ---@field costList table<number,table<number,number>> @ 消耗道具数量
  4. ---@field tbl cfg_equip_angelAtt_column[]
  5. ---@field isCanBreak boolean
  6. local KLArchangelBreakthroughPanel = class(UIKmlLuaPanelBase)
  7. local this = KLArchangelBreakthroughPanel
  8. function this:AsyncLoadUI()
  9. end
  10. ---创建时调用一次
  11. function this:Init()
  12. local equipPanel = GUI:GetUI("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  13. if equipPanel then
  14. self.equipPanel = equipPanel
  15. else
  16. GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel", nil, nil,
  17. { x = -465, hideTips = true, callBack = self.ClosePanel, forgeGroupType = EForgeGroupType.Breakthrough },true,function(equipPanelView)
  18. self.equipPanel =equipPanelView
  19. end)
  20. end
  21. self.selectEquipCfgId = self.args and self.args.selectId or nil
  22. self.equipPanel:SetSelfWearBarType(EEquipWearBarType.Archange)
  23. GUI:DataListInitData(self.view.cost_list, function()
  24. return #self.costList
  25. end, function(realIndex)
  26. end, function(realIndex, kmlcontrol)
  27. end, function(realIndex, kmlcontrol)
  28. return self:CostUpdateItem(realIndex, kmlcontrol)
  29. end)
  30. end
  31. function this:CostUpdateItem(realIndex, kmlcontrol)
  32. local data = self.costList[realIndex + 1]
  33. local cost_item = GUI:GetChildControl(self.view.cost_list,realIndex, "cost_item")
  34. GUI:Item_setItemId(cost_item, data[1])
  35. local itemCfg = SL:GetConfig("cfg_item", data[1], "id")
  36. local cost_name = GUI:GetChildControl(self.view.cost_list,realIndex, "cost_name")
  37. GUI:Text_setString(cost_name, itemCfg.name)
  38. local costNumStr = ""
  39. local bagCount = SL:GetBagItemCount(data[1])
  40. if bagCount >= data[2] then
  41. costNumStr = "<color='#1add1f'>" .. tostring(bagCount) .. "</color>/" .. tostring(data[2])
  42. self.isCost = true
  43. else
  44. costNumStr = "<color='#ff2323'>" .. tostring(bagCount) .. "</color>/" .. tostring(data[2])
  45. self.isCost = false
  46. end
  47. local cost_num = GUI:GetChildControl(self.view.cost_list,realIndex, "cost_num")
  48. GUI:Text_setString(cost_num, costNumStr)
  49. local costAddBtn = GUI:GetChildControl(self.view.cost_list,realIndex, "costAddBtn")
  50. GUI:AddOnClickEvent(costAddBtn, self, function()
  51. --获取途径
  52. SL:CommonItemGetPath(nil, data[1])
  53. end)
  54. end
  55. ---注册UI事件和服务器消息w
  56. function this:RegistEvents()
  57. SL:RegisterLUAEvent(LUA_EVENT_EQUIP_GRID_CLICK, self.LUA_EVENT_EQUIP_GRID_CLICK, self)
  58. GUI:AddOnClickEvent(self.view.CloseButton, self, self.CloseButton)
  59. GUI:AddOnClickEvent(self.view.BreakthroughBtn, self, self.Breakthrough)
  60. GUI:AddOnClickEvent(self.view.btn_tips, self, self.BtnHelpOnClick)
  61. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_ANGEL_EQUIPMENT_BREAK_RESULT, self.RES_ANGEL_EQUIPMENT_BREAK_RESULT, self)
  62. end
  63. ---界面显示时调用一次
  64. function this:Show()
  65. end
  66. ---创建或者刷新界面数据时调用
  67. function this:Refresh()
  68. self:EquipNull()
  69. local select = {
  70. EEquipSlotType.ArchangelWeapon, -- 天使武器
  71. EEquipSlotType.ArchangelTwoHandWeapon,
  72. EEquipSlotType.ArchangelGlove, -- 天使手套
  73. EEquipSlotType.ArchangelHelmet, -- 天使头盔
  74. EEquipSlotType.ArchangelArmor, -- 天使衣服
  75. EEquipSlotType.ArchangelPant, -- 天使裤子
  76. EEquipSlotType.ArchangelOffHandWeapon, -- 天使副手
  77. EEquipSlotType.ArchangelBoot, -- 天使鞋子
  78. --ArchangelTwoHandWeapon = enum(73), -- 天使双手武器
  79. }
  80. --local equips = SL:GetWearBarsData(EEquipWearBarType.BaseEquip)
  81. -- if #equips == 0 then
  82. -- self:EquipNull()
  83. -- return
  84. -- end
  85. self.isCanBreak = false
  86. local equip
  87. local index
  88. for i, v in pairs(select) do
  89. equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 9, v)
  90. if equip then
  91. if self.selectEquipCfgId then
  92. if equip.cfgId == self.selectEquipCfgId then
  93. index = v
  94. break
  95. end
  96. else
  97. index = v
  98. break
  99. end
  100. end
  101. end
  102. if not equip then
  103. self:EquipNull()
  104. return
  105. end
  106. --self:LUA_EVENT_EQUIP_GRID_CLICK(equip)
  107. self.selectEquip = equip
  108. self.equipPanel:SetSelectIndex(index)
  109. self:SetEquip()
  110. SL:RefreshPanelALLRedPoint("KLArchangelGroupPanel")
  111. end
  112. function this:LUA_EVENT_EQUIP_GRID_CLICK(_, pos)
  113. local equip = SL:GetMetaValue("EQUIP_DATA_LIST", pos)[1]
  114. if pos == EEquipSlotType.ArchangelWeapon and not equip then
  115. equip = SL:GetMetaValue("EQUIP_DATA_LIST", EEquipSlotType.ArchangelTwoHandWeapon)[1]
  116. end
  117. if pos == EEquipSlotType.ArchangelTwoHandWeapon and not equip then
  118. equip = SL:GetMetaValue("EQUIP_DATA_LIST", EEquipSlotType.ArchangelWeapon)[1]
  119. end
  120. if not equip then
  121. return
  122. end
  123. self.isCanBreak = false
  124. self.selectEquip = equip
  125. ---@type cfg_item_column
  126. local itemCfg = SL:GetConfig("cfg_item", self.selectEquip.cfgId, "id")
  127. if itemCfg.wearBarID[1] ~= 9 then
  128. self:EquipNull()
  129. return
  130. end
  131. local group = SL:GetConfig("cfg_equip_angelGroup", self.selectEquip.cfgId, "id").angelEquipGroup
  132. ---@type cfg_equip_angelAtt_column[]
  133. --self.tbl = SL:FindConfigs("cfg_equip_angelAtt", "ornamentsGroup", group)
  134. self.equipPanel:SetSelectIndex(pos)
  135. self:SetEquip()
  136. end
  137. function this:SetEquip()
  138. self.isCanBreak = false
  139. --GUI:setVisible(self.view.effectSucceed, false)
  140. --GUI:setVisible(self.view.effectfail, false)
  141. ---@type cfg_item_column
  142. local itemCfg = SL:GetConfig("cfg_item", self.selectEquip.cfgId, "id")
  143. if not itemCfg then
  144. self:EquipNull()
  145. return
  146. end
  147. GUI:setVisible(self.view.noselect_img, false)
  148. GUI:setVisible(self.view.noselect, true)
  149. local textColor = SL:GetConfig("cfg_color", itemCfg.color, "id").color
  150. GUI:Text_setTextColor(self.view.equipName, textColor)
  151. GUI:Text_setString(self.view.equipName, itemCfg.name)
  152. GUI:Item_setItemId(self.view.item_model, itemCfg.id)
  153. local info = InfoManager.archangeEquipInfo:GetEquipLevelInfo(self.selectEquip.id)
  154. local level = info.level
  155. local rank = info.rank
  156. local maxLv = InfoManager.archangeEquipInfo:GetMaxLevel(rank, self.selectEquip.cfgId)
  157. local nextMaxLv = InfoManager.archangeEquipInfo:GetMaxLevel(rank + 1, self.selectEquip.cfgId)
  158. local nextRank = rank + 1
  159. GUI:Text_setString(self.view.preLevel, tostring(rank))
  160. GUI:Text_setString(self.view.nextLevel, tostring(nextRank))
  161. --消耗材料
  162. local group = SL:GetConfig("cfg_equip_angelGroup", self.selectEquip.cfgId, "id").angelEquipGroup
  163. ---@type cfg_equip_angelAtt_column
  164. local localtbl = SL:GetConfigTwoKeys("cfg_equip_angelAtt", group, maxLv, "ornamentsGroup", "lv")
  165. self.costList = localtbl.breakMaterial
  166. -- 更新datalist
  167. GUI:DataListUpdateData(self.view.cost_list)
  168. if rank == InfoManager.archangeEquipInfo:GetMaxRank(self.selectEquip.cfgId) then
  169. GUI:setVisible(self.view.hidepanel, false)
  170. GUI:setVisible(self.view.noticeText, false)
  171. GUI:setVisible(self.view.maxLevelTips, true)
  172. GUI:setVisible(self.view.nextLevel, false)
  173. GUI:setVisible(self.view.arrow, false)
  174. GUI:setVisible(self.view.BreakthroughBtn, false)
  175. return
  176. end
  177. GUI:setVisible(self.view.nextLevel, true)
  178. GUI:setVisible(self.view.hidepanel, true)
  179. GUI:setVisible(self.view.arrow, true)
  180. GUI:setVisible(self.view.BreakthroughBtn, true)
  181. GUI:setVisible(self.view.maxLevelTips, false)
  182. if level < maxLv then
  183. GUI:setVisible(self.view.hidepanel, false)
  184. GUI:setVisible(self.view.noticeText, true)
  185. GUI:Button_setGrey(self.view.BreakthroughBtn, true)
  186. self.isGray = true
  187. return
  188. end
  189. self.isCanBreak = true
  190. self.isGray = false
  191. GUI:Button_setGrey(self.view.BreakthroughBtn, false)
  192. GUI:setVisible(self.view.noticeText, false)
  193. GUI:Text_setString(self.view.preValue, tostring(maxLv))
  194. GUI:Text_setString(self.view.nextValue, tostring(nextMaxLv))
  195. end
  196. function this:Breakthrough()
  197. if self.isGray then
  198. return
  199. end
  200. if self.selectEquip and self.isCanBreak and self.isCost then
  201. GUI:setVisible(self.view.effectSucceed, false)
  202. GUI:setVisible(self.view.effectfail, false)
  203. local data = {
  204. itemConfigId = self.selectEquip.cfgId,
  205. itemId = self.selectEquip.id,
  206. groupId = SL:GetConfig("cfg_equip_angelGroup", self.selectEquip.cfgId, "id").angelEquipGroup
  207. }
  208. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_BREAK_ANGEL_EQUIP, data)
  209. else
  210. SL:MessageTip({ id = 253 })
  211. end
  212. end
  213. function this:BtnHelpOnClick()
  214. local helpCfg = SL:GetConfig("cfg_rule_text", 28001)
  215. if helpCfg then
  216. SL:CommonStrTipsMessage({ title = helpCfg.menutxt, str = helpCfg.location })
  217. end
  218. end
  219. function this:EquipNull()
  220. GUI:Text_setString(self.view.equipName, "")
  221. GUI:Item_setItemId(self.view.item_model, "")
  222. GUI:setVisible(self.view.noticeText, false)
  223. GUI:setVisible(self.view.hidepanel, false)
  224. GUI:Text_setString(self.view.nextLevel, "")
  225. GUI:Text_setString(self.view.preLevel, "")
  226. GUI:setVisible(self.view.noselect_img, true)
  227. GUI:setVisible(self.view.noselect, false)
  228. end
  229. function this:CloseButton()
  230. self.equipPanel:CloseOnClick()
  231. end
  232. function this:ClosePanel()
  233. GUI:UIPanel_Close("dev/outui/Archangel/Panel/KLArchangelBreakthrough/KLArchangelBreakthroughPanel")
  234. GUI:UIPanel_Close("dev/outui/Archangel/Panel/KLArchangelGroup/KLArchangelGroupPanel")
  235. end
  236. function this:Close()
  237. SL:RefreshPanelALLRedPoint("KLUISystemLeftPanel")
  238. if self.refreshSchedule then
  239. SL:UnSchedule(self.refreshSchedule)
  240. end
  241. GUI:UIPanel_Close(nil, self.equipPanel)
  242. end
  243. function this:RES_ANGEL_EQUIPMENT_BREAK_RESULT(_, message)
  244. if message then
  245. if table.contains(InfoManager.archangeEquipInfo.canBreakthrough, self.selectEquip.id) then
  246. table.removeByValue(InfoManager.archangeEquipInfo.canBreakthrough, self.selectEquip.id)
  247. end
  248. GUI:setVisible(self.view.effectSucceed, true)
  249. local group = GUI:GetUI("dev/outui/Archangel/Panel/KLArchangelGroup/KLArchangelGroupPanel")
  250. if group then
  251. group:RefreshRed()
  252. end
  253. else
  254. GUI:setVisible(self.view.effectfail, true)
  255. end
  256. self.equipPanel:SetSelfWearBarType(EEquipWearBarType.Archange)
  257. self:SetEquip()
  258. SL:RefreshPanelALLRedPoint("KLArchangelGroupPanel")
  259. end
  260. return this