KLEquipStrengthUIPanel.lua 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. ---@class KLEquipStrengthUIPanel:UIKmlLuaPanelBase
  2. ---@field view KLEquipStrengthUIPanelView
  3. --- kml代码lua化 会有较多冗余代码
  4. local KLEquipStrengthUIPanel = class(UIKmlLuaPanelBase)
  5. local this =KLEquipStrengthUIPanel
  6. ---创建时调用一次
  7. function this:Init()
  8. GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",nil,nil,
  9. {x=-465, hideTips=true, callBack=self.CloseEquipUi,forgeGroupType=EForgeGroupType.Strength},nil,function(equipPanel)
  10. self.equipPanel = equipPanel
  11. self:Refresh()
  12. end)
  13. self.bagIndex = nil
  14. self.equipIndex = nil
  15. self.strengthAttTextList = {}
  16. self.costList = {}
  17. self.showLiuGuang = false
  18. GUI:setVisible(self.view.equip_show_tips, false)
  19. GUI:DataListInitData(self.view.strength_list, function()
  20. return table.count(self.strengthAttTextList)
  21. end,function()
  22. end,function()
  23. end,function(realIndex)
  24. local strengthInfo = self.strengthAttTextList[realIndex+1]
  25. local name = strengthInfo['attrName']
  26. local preValue = strengthInfo['preValue']
  27. local nextValue = strengthInfo['nextValue']
  28. local arrowShow = strengthInfo['arrowShow']
  29. local attControl = GUI:GetChildControl(self.view.strength_list,realIndex,'attrName')
  30. local preControl = GUI:GetChildControl(self.view.strength_list,realIndex,'preValue')
  31. local nextControl = GUI:GetChildControl(self.view.strength_list,realIndex,'nextValue')
  32. local arrowControl = GUI:GetChildControl(self.view.strength_list,realIndex,'arrow')
  33. local result = ""
  34. local len = utf8.len(name) -- 获取字符串的 UTF-8 长度
  35. local i = 1
  36. local j = 1
  37. -- 使用 utf8.offset 来逐个字符提取
  38. while i <= len do
  39. local char = utf8.sub(name, i, i+1)
  40. result = result .. char .. " "
  41. i = i+1 -- 移动到下一个字符
  42. end
  43. GUI:Text_setString(attControl, result)
  44. GUI:Text_setString(preControl, tostring(preValue))
  45. GUI:Text_setString(nextControl, tostring(nextValue))
  46. GUI:setVisible(arrowControl, arrowShow)
  47. end)
  48. GUI:DataListInitData(self.view.cost_list, function()
  49. return table.count(self.costList)
  50. end,function()
  51. end,function()
  52. end,function(realIndex)
  53. local costInfo = self.costList[realIndex+1]
  54. local cfgId = costInfo['cfgId']
  55. local needCount = costInfo['needCount']
  56. local itemControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_item')
  57. local nameControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_name')
  58. local numControl = GUI:GetChildControl(self.view.cost_list,realIndex,'cost_num')
  59. local costAddBtn = GUI:GetChildControl(self.view.cost_list,realIndex,'costAddBtn')
  60. if SL:GetConfig('cfg_item', cfgId) == nil then
  61. return
  62. end
  63. GUI:Item_setItemId(itemControl, cfgId)
  64. local name = SL:GetConfig('cfg_item', cfgId).name
  65. GUI:Text_setString(nameControl, name)
  66. local haveCount = SL:GetBagItemCount(cfgId)
  67. if haveCount < needCount then
  68. GUI:Text_setString(numControl, string.format('<color="#9b1818">%d</color>/%d', haveCount, needCount))
  69. else
  70. GUI:Text_setString(numControl, string.format('<color="#1add1f">%d</color>/%d', haveCount, needCount))
  71. end
  72. GUI:AddOnClickEvent(costAddBtn, self, self.costAddBtn, {cfgId=cfgId})
  73. end)
  74. self.updateEquipCo = nil
  75. end
  76. function this:costAddBtn(control, eventData)
  77. local cfgId = eventData.cfgId
  78. SL:CommonItemGetPath(nil, cfgId)
  79. end
  80. ---创建或者刷新界面数据时调用
  81. function this:Refresh()
  82. if not self.equipPanel then
  83. return
  84. end
  85. self.bagIndex = nil
  86. self.equipIndex = nil
  87. self:SelectEquip(self.args and self.args.equipSlot or nil)
  88. SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
  89. if self.args and self.args.equipSlot then
  90. self.args.equipSlot = nil
  91. end
  92. end
  93. ---注册UI事件和服务器消息
  94. function this:RegistEvents()
  95. GUI:AddOnClickEvent(self.view.CloseButton, self, self.CloseButton)
  96. GUI:AddOnClickEvent(self.view.strengthButton, self, self.strengthButton)
  97. GUI:AddOnClickEvent(self.view.closeMask, self, self.closeMask)
  98. GUI:AddOnClickEvent(self.view.liuGuangBtn, self, self.liuGuangBtn)
  99. GUI:AddOnClickEvent(self.view.strengthMasterBtn, self, self.strengthMasterBtn)
  100. GUI:AddOnClickEvent(self.view.item_model, self, self.item_modelOnClick)
  101. SL:RegisterLUAEvent(LUA_EVENT_EQUIP_GRID_CLICK, self.LUA_EVENT_EQUIP_GRID_CLICK, self)
  102. --SL:RegisterLUAEvent(LUA_EVENT_BAG_CHANGE_AFTER, self.LUA_EVENT_BAG_CHANGE_AFTER, self)
  103. --SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.LUA_EVENT_MONEYCHANGE, self)
  104. SL:RegisterLuaNetMsg(LuaMessageIdToClient.STRENGTH_EQUIP_RESULT, self.STRENGTH_EQUIP_RESULT, self)
  105. GUI:SetToggleOnValueChange(self.view.equipBtn, self, self.equipBtn)
  106. GUI:SetToggleOnValueChange(self.view.bagBtn, self, self.ClickBag)
  107. SL:RegisterLUAEvent(LUA_EVENT_FORGE_GROUP_PANEL_CLOSE, self.CloseButton, self)
  108. end
  109. function this:item_modelOnClick()
  110. SL:OpenTips("equip",self.equipInfo.cfgId,self.equipInfo.id,nil, self.equipInfo, {hideBtn=true})
  111. end
  112. function this:liuGuangBtn()
  113. if self.showLiuGuang == false then
  114. local stream = SL:GetConfig('cfg_equip_strengthen', self.equipInfo.cfgId).stream
  115. if stream then
  116. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  117. for _, streamInfo in pairs(stream) do
  118. local nowStrengthLevel = streamInfo[1]
  119. local streamId = streamInfo[2]
  120. if strengthLevel < nowStrengthLevel then
  121. GUI:SetStreamAttr(self.view.item_model, streamId)
  122. GUI:setVisible(self.view.liuguangInfo, true)
  123. GUI:Text_setString(self.view.liuguangInfo, '+' .. nowStrengthLevel .. '流光效果')
  124. self.showLiuGuang = true
  125. return
  126. end
  127. end
  128. end
  129. else
  130. self:SetLiuGuang(self.equipInfo)
  131. GUI:setVisible(self.view.liuguangInfo, false)
  132. self.showLiuGuang = false
  133. end
  134. end
  135. function this:strengthMasterBtn()
  136. GUI:UIPanel_Open("dev/outui/Equip/Panel/KLUIForgingMaster/KLUIForgingMasterPanel", nil, nil, { uiType = 1, cfgId = self.equipInfo.cfgId })
  137. end
  138. function this:equipBtn()
  139. self.isOpenBag = false
  140. self.equipPanel = GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",nil,nil,
  141. {x=-465, hideTips=true, callBack=self.CloseEquipUi,forgeGroupType=EForgeGroupType.Strength})
  142. GUI:UIPanel_Close("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel")
  143. self.selectItem = nil
  144. self:SelectEquip()
  145. end
  146. function this.CloseEquipUi()
  147. GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
  148. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  149. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipStrengthUI/KLEquipStrengthUIPanel")
  150. end
  151. function this:closeMask()
  152. GUI:setVisible(self.view.equip_show_tips, false)
  153. end
  154. -- 强化结果回调
  155. ---@param message {issuccess:boolean, strengthlv:number, itemId:number}
  156. function this:STRENGTH_EQUIP_RESULT(id, message)
  157. GUI:SetActive(self.view.strength_ok, false)
  158. GUI:SetActive(self.view.strength_fail, false)
  159. if message.issuccess then
  160. GUI:SetActive(self.view.strength_ok, true)
  161. local costId = SL:GetConfig('cfg_equip_strengthen', self.equipInfo.cfgId).costId
  162. local firstRate = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, message.strengthlv, 'costGroupId', 'level').firstRate
  163. if firstRate == 1 then
  164. self:ShowEquipSuccessMask(self.equipInfo.cfgId, message.strengthlv)
  165. end
  166. else
  167. GUI:SetActive(self.view.strength_fail, true)
  168. end
  169. SL:onLUAEvent(LUA_EVENT_STRENGTH_OK,message)
  170. self:ClickEquip(self.equipInfo)
  171. SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
  172. self.equipPanel:UpdateAllItem()
  173. end
  174. -- 强化跑马灯展示(特定等级展示)
  175. function this:ShowEquipSuccessMask(cfgId, strengthLevel)
  176. GUI:setVisible(self.view.equip_show_tips, true)
  177. local name = SL:GetConfig("cfg_item", cfgId).name
  178. GUI:Text_setString(self.view.mask_text, string.format("%s+%d", name, strengthLevel))
  179. GUI:Item_setItemId(self.view.mask_item, cfgId)
  180. local liuGuangId = EquipFunc.GetEquipLiuGuangId(self.equipInfo)
  181. GUI:SetStreamAttr(self.view.mask_item, liuGuangId)
  182. end
  183. -- 点击强化按钮
  184. function this:strengthButton()
  185. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_STRENGTH_EQUIP,{itemId=self.equipInfo.id})
  186. -- self:STRENGTH_EQUIP_RESULT(_, {isSuccess = true})
  187. end
  188. -- 背包改变后
  189. function this:LUA_EVENT_BAG_CHANGE_AFTER(_,message)
  190. if self.isOpenBag then
  191. return
  192. end
  193. if not message then
  194. return
  195. end
  196. if self.equipInfo then
  197. local lv = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  198. local isMax = this.IsMaxEquip(self.equipInfo,lv)
  199. if not isMax then
  200. self:SetEquipCostInfo(self.equipInfo.cfgId, lv)
  201. end
  202. end
  203. -- 临时处理下, 等后端整合成一个消息包
  204. if self.updateEquipCo == nil then
  205. self.updateEquipCo = Coroutine.Start(function()
  206. Coroutine.Wait(0.2)
  207. self.equipPanel:UpdateAllItem()
  208. SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
  209. self.updateEquipCo = nil
  210. end)
  211. end
  212. end
  213. -- 货币变更
  214. function this:LUA_EVENT_MONEYCHANGE(_,message)
  215. if self.isOpenBag then
  216. return
  217. end
  218. if self.equipInfo then
  219. local lv = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  220. local isMax = this.IsMaxEquip(self.equipInfo,lv)
  221. if not isMax then
  222. self:SetEquipCostInfo(self.equipInfo.cfgId, lv)
  223. end
  224. end
  225. if self.updateEquipCo == nil then
  226. self.updateEquipCo = Coroutine.Start(function()
  227. Coroutine.Wait(0.2)
  228. self.equipPanel:UpdateAllItem()
  229. SL:RefreshPanelALLRedPoint("KLUIForgeGroupPanel")
  230. self.updateEquipCo = nil
  231. end)
  232. end
  233. end
  234. -- 点击装备事件回调
  235. function this:LUA_EVENT_EQUIP_GRID_CLICK(_, index)
  236. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  237. if index == E_AppearEquipType.Weapon and equip == nil then
  238. equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, E_AppearEquipType.TwoHandWeapon)
  239. end
  240. if equip then
  241. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
  242. if strength_tbl then
  243. self.bagIndex = nil
  244. self.equipPanel:SetSelectIndex(index)
  245. self:ClickEquip(equip)
  246. return
  247. else
  248. SL:TipMessage( SL:GetConfig('cfg_string',268).text, 1, NoticeType.NoticeMid )--"该装备无法被强化",
  249. end
  250. end
  251. end
  252. -- 关闭按钮回调
  253. function this:CloseButton()
  254. GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
  255. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  256. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipStrengthUI/KLEquipStrengthUIPanel")
  257. GUI:UIPanel_Close("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel")
  258. self.selectItem = nil
  259. self.equipPanel = nil
  260. end
  261. function this:Close()
  262. end
  263. -- 选择装备
  264. function this:SelectEquip(_index)
  265. if self.selectItem then
  266. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', self.selectItem.item.cfgId)
  267. if strength_tbl then
  268. self.bagIndex = nil
  269. ---@type cfg_item_column
  270. local part = SL:GetConfig("cfg_item",self.selectItem.item.cfgId).subType
  271. self.equipPanel:SetSelectIndex(part)
  272. self:ClickEquip(self.selectItem.item)
  273. return
  274. end
  275. end
  276. if _index then
  277. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, _index)
  278. if equip then
  279. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
  280. if strength_tbl then
  281. self.bagIndex = nil
  282. self.equipPanel:SetSelectIndex(_index)
  283. self:ClickEquip(equip)
  284. return
  285. end
  286. end
  287. end
  288. -- 策划要求先选中武器
  289. local equip_boot = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, EEquipSlotType.TwoHandWeapon)
  290. if equip_boot then
  291. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip_boot['cfgId'])
  292. if strength_tbl then
  293. self.bagIndex = nil
  294. self.equipPanel:SetSelectIndex(EEquipSlotType.TwoHandWeapon)
  295. self:ClickEquip(equip_boot)
  296. return
  297. end
  298. end
  299. for index=1, 15 do
  300. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  301. if equip then
  302. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equip['cfgId'])
  303. if strength_tbl then
  304. self.bagIndex = nil
  305. self.equipPanel:SetSelectIndex(index)
  306. self:ClickEquip(equip)
  307. return
  308. end
  309. end
  310. end
  311. GUI:setVisible(self.view.noticeText, true)
  312. end
  313. -- 初始化UI为初始状态
  314. function this:ResetUi()
  315. GUI:setVisible(self.view.maxLevelTips, false)
  316. GUI:setVisible(self.view.strengthIcon, false)
  317. GUI:setVisible(self.view.baseSuccessRatioText, false)
  318. GUI:setVisible(self.view.successIcon, false)
  319. GUI:setVisible(self.view.strengthIcon_1, false)
  320. GUI:setVisible(self.view.StrengthCustomScrollView, false)
  321. GUI:setVisible(self.view.strengthButton, false)
  322. GUI:setVisible(self.view.strengthLevelBg, false)
  323. GUI:setVisible(self.view.maxStrengthLevelBg, false)
  324. GUI:setVisible(self.view.item_model, false)
  325. GUI:setVisible(self.view.equipName, false)
  326. GUI:setVisible(self.view.noticeText, false)
  327. GUI:setVisible(self.view.liuGuangBtn, false)
  328. GUI:setVisible(self.view.liuguangInfo, false)
  329. GUI:setVisible(self.view.strengthMasterBtn, false)
  330. self.showLiuGuang = false
  331. end
  332. -- 点击装备(装备栏内)
  333. -- local testLevel = 0
  334. function this:ClickEquip(equipInfo)
  335. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', equipInfo.cfgId)
  336. if strength_tbl then
  337. self.equipInfo = equipInfo
  338. self:ResetUi()
  339. GUI:setVisible(self.view.liuGuangBtn, true)
  340. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  341. self:SetEquipName(self.equipInfo.cfgId, strengthLevel)
  342. self:SetEquipModel(self.equipInfo.cfgId)
  343. self:SetLiuGuang(self.equipInfo)
  344. self:SetLiuGuangBtn(self.equipInfo)
  345. local isMax = this.IsMaxEquip(self.equipInfo,strengthLevel)
  346. if isMax then
  347. GUI:setVisible(self.view.maxLevelTips, true)
  348. GUI:Text_setString(self.view.maxLevel, "+" .. strengthLevel)
  349. GUI:setVisible(self.view.maxStrengthLevelBg, true)
  350. self:SetMaxAttrInfo(self.equipInfo.cfgId, strengthLevel)
  351. else
  352. self:RefreshSuccessRatio(self.equipInfo.cfgId, strengthLevel)
  353. self:SetEquipLevelInfo(strengthLevel)
  354. self:SetEquipAttrInfo(self.equipInfo.cfgId, strengthLevel)
  355. self:SetEquipCostInfo(self.equipInfo.cfgId, strengthLevel)
  356. GUI:setVisible(self.view.strengthButton, true)
  357. self:SetEquipFailText(self.equipInfo.cfgId, strengthLevel)
  358. end
  359. -- testLevel = testLevel + 1
  360. end
  361. ---@type cfg_item_column
  362. local item = SL:GetConfig("cfg_item", equipInfo.cfgId)
  363. local masterId = tonumber(item.strPart[1] .. "01")
  364. ---@type cfg_equip_masterGroup_column
  365. local master = SL:GetConfig("cfg_equip_masterGroup", masterId)
  366. if master then
  367. GUI:setVisible(self.view.strengthMasterBtn, true)
  368. else
  369. GUI:setVisible(self.view.strengthMasterBtn, false)
  370. end
  371. end
  372. function this:SetLiuGuangBtn(equipInfo)
  373. local stream = SL:GetConfig('cfg_equip_strengthen', equipInfo.cfgId).stream
  374. if stream then
  375. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  376. for _, streamInfo in pairs(stream) do
  377. local nowStrengthLevel = streamInfo[1]
  378. if strengthLevel < nowStrengthLevel then
  379. GUI:setVisible(self.view.liuGuangBtn, true)
  380. return
  381. end
  382. end
  383. end
  384. GUI:setVisible(self.view.liuGuangBtn, false)
  385. end
  386. -- 设置流光
  387. function this:SetLiuGuang(equipInfo)
  388. local liuGuangId = EquipFunc.GetEquipLiuGuangId(equipInfo)
  389. if liuGuangId then
  390. GUI:SetStreamAttr(self.view.item_model, liuGuangId)
  391. else
  392. GUI:ResetStreamAttr(self.view.item_model)
  393. end
  394. end
  395. -- 点击背包
  396. function this:ClickBag()
  397. self.isOpenBag = true
  398. self:ResetUi()
  399. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  400. GUI:UIPanel_Open("dev/outui/Bag/Panel/KLStrengthBag/KLStrengthBagPanel", nil, nil, {x=-481, itemClickCallBack=self.itemClickCallBack,callBackUI=self})
  401. end
  402. -- 点击道具回调(背包)
  403. function this:itemClickCallBack(control, item)
  404. if SL:HasConfig('cfg_equip_strengthen', item.cfgId) then
  405. local itemInfo = SL:GetItemInfoByItemId(item.id)
  406. self:ClickEquip(itemInfo)
  407. self:HideSelectItem(false)
  408. control.ui:SetSelect(true)
  409. self.selectItem = control.ui
  410. else
  411. SL:TipMessage( SL:GetConfig('cfg_string',268).text, 1, NoticeType.NoticeMid )--"该装备无法被强化",
  412. end
  413. end
  414. function this:HideSelectItem()
  415. if self.selectItem then
  416. self.selectItem:SetSelect(false)
  417. end
  418. end
  419. -- 满级属性
  420. function this:SetMaxAttrInfo(cfgId, strengthLevel)
  421. self.strengthAttTextList = {}
  422. GUI:setVisible(self.view.strengthIcon, true)
  423. local groupId = SL:GetConfig('cfg_equip_strengthen', cfgId).groupId
  424. local nowAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv').att
  425. local now_attr_map = {}
  426. for _, nowAttr in pairs(nowAttrInfo) do
  427. now_attr_map[nowAttr[1]] = nowAttr[2]
  428. end
  429. local minAtk = now_attr_map[201021]
  430. local maxAtk = now_attr_map[201011]
  431. if minAtk and maxAtk then
  432. local tbl= {
  433. attrName = "攻击力",
  434. preValue = minAtk .. '~' .. maxAtk,
  435. nextValue = "",
  436. arrowShow = false
  437. }
  438. table.insert(self.strengthAttTextList, tbl)
  439. end
  440. local minMAtk = now_attr_map[202021]
  441. local maxMAtk = now_attr_map[202011]
  442. if minMAtk and maxMAtk then
  443. local tbl= {
  444. --attrName = "魔法攻击力",
  445. attrName = "攻击力",
  446. preValue = minMAtk .. '~' .. maxMAtk,
  447. nextValue = "",
  448. arrowShow = false
  449. }
  450. table.insert(self.strengthAttTextList, tbl)
  451. end
  452. minAtk = now_attr_map[200011]
  453. maxAtk = now_attr_map[200021]
  454. if minAtk and maxAtk then
  455. local tbl= {
  456. attrName = "攻击力",
  457. preValue = minAtk .. '~' .. maxAtk,
  458. nextValue = "",
  459. arrowShow = false
  460. }
  461. table.insert(self.strengthAttTextList, tbl)
  462. end
  463. for attrId, attrValue in pairs(now_attr_map) do
  464. if attrId ~= 201021 and attrId ~= 201011 and attrId ~= 202021 and attrId ~= 202011 and attrId ~= 200011 and attrId ~= 200021 then
  465. local name = SL:GetConfig("cfg_att_info", attrId).name
  466. local att_remark = SL:GetConfig("cfg_att_info", attrId).remarks
  467. local tbl = {}
  468. if att_remark == 1 then
  469. tbl = {
  470. attrName = name,
  471. preValue = attrValue,
  472. nextValue = "",
  473. arrowShow = false
  474. }
  475. else
  476. tbl = {
  477. attrName = name,
  478. preValue = attrValue/100 .. '%',
  479. nextValue = "",
  480. arrowShow = false
  481. }
  482. end
  483. table.insert(self.strengthAttTextList, tbl)
  484. end
  485. end
  486. GUI:DataListUpdateData(self.view.strength_list)
  487. end
  488. --失败文本
  489. function this:SetEquipFailText(cfgId, strengthLevel)
  490. local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
  491. local fail_tips = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, strengthLevel+1, 'costGroupId', 'level').tips
  492. if fail_tips then
  493. GUI:setVisible(self.view.failTips, true)
  494. GUI:Text_setString(self.view.failTips, fail_tips)
  495. end
  496. end
  497. -- 消耗道具
  498. function this:SetEquipCostInfo(cfgId, strengthLevel)
  499. self.costList = {}
  500. GUI:setVisible(self.view.strengthIcon_1, true)
  501. GUI:setVisible(self.view.StrengthCustomScrollView, true)
  502. local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
  503. local next_level = strengthLevel + 1
  504. local cost_info = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, next_level, "costGroupId", "level").cost
  505. for _, cost in pairs(cost_info) do
  506. local tbl = {
  507. cfgId = cost[1],
  508. needCount = cost[2],
  509. }
  510. table.insert(self.costList, tbl)
  511. end
  512. GUI:DataListUpdateData(self.view.cost_list)
  513. end
  514. -- 装备属性
  515. function this:SetEquipAttrInfo(cfgId, strengthLevel)
  516. self.strengthAttTextList = {}
  517. GUI:setVisible(self.view.strengthIcon, true)
  518. local groupId = SL:GetConfig('cfg_equip_strengthen', cfgId).groupId
  519. local nowAttrInfo
  520. if SL:HasConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv') then
  521. nowAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel, 'group', 'lv')
  522. end
  523. nowAttrInfo = nowAttrInfo and nowAttrInfo.att or {}
  524. local nextAttrInfo
  525. if SL:HasConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv') then
  526. nextAttrInfo = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv')
  527. end
  528. nextAttrInfo = nextAttrInfo and nextAttrInfo.att or {}
  529. local now_attr_map = {}
  530. for _, nowAttr in pairs(nowAttrInfo) do
  531. now_attr_map[nowAttr[1]] = nowAttr[2]
  532. end
  533. local next_attr_map = {}
  534. for _, nextAttr in pairs(nextAttrInfo) do
  535. next_attr_map[nextAttr[1]] = tonumber(nextAttr[2])
  536. end
  537. for nextId, _ in pairs(next_attr_map) do
  538. if now_attr_map[nextId] == nil then
  539. now_attr_map[nextId] = 0
  540. end
  541. end
  542. local minAtk = now_attr_map[201021]
  543. local maxAtk = now_attr_map[201011]
  544. if minAtk and maxAtk then
  545. local nextMinAtk = next_attr_map[201021]
  546. local nextMaxAtk = next_attr_map[201011]
  547. local tbl= {
  548. attrName = "攻击力",
  549. preValue = minAtk .. '~' .. maxAtk,
  550. nextValue = nextMinAtk .. '~' .. nextMaxAtk,
  551. arrowShow = true
  552. }
  553. table.insert(self.strengthAttTextList, tbl)
  554. end
  555. local minMAtk = now_attr_map[202021]
  556. local maxMAtk = now_attr_map[202011]
  557. if minMAtk and maxMAtk then
  558. local nextMinAtk = next_attr_map[202021]
  559. local nextMaxAtk = next_attr_map[202011]
  560. local tbl= {
  561. --attrName = "魔法攻击力",
  562. attrName = "攻击力",
  563. preValue = minMAtk .. '~' .. maxMAtk,
  564. nextValue = nextMinAtk .. '~' .. nextMaxAtk,
  565. arrowShow = true
  566. }
  567. table.insert(self.strengthAttTextList, tbl)
  568. end
  569. minAtk = now_attr_map[200011]
  570. maxAtk = now_attr_map[200021]
  571. if minAtk and maxAtk then
  572. local nextMinAtk = next_attr_map[200011]
  573. local nextMaxAtk = next_attr_map[200021]
  574. local tbl= {
  575. attrName = "攻击力",
  576. preValue = minAtk .. '~' .. maxAtk,
  577. nextValue = nextMinAtk .. '~' .. nextMaxAtk,
  578. arrowShow = true
  579. }
  580. table.insert(self.strengthAttTextList, tbl)
  581. end
  582. for attrId, attrValue in pairs(now_attr_map) do
  583. if attrId ~= 201021 and attrId ~= 201011 and attrId ~= 202021 and attrId ~= 202011 and attrId ~= 200011 and attrId ~= 200021 then
  584. local nextValue = next_attr_map[attrId] or 0
  585. local name = SL:GetConfig("cfg_att_info", attrId).name
  586. local att_remark = SL:GetConfig("cfg_att_info", attrId).remarks
  587. local tbl = {}
  588. if att_remark == 1 then
  589. tbl = {
  590. attrName = name,
  591. preValue = attrValue,
  592. nextValue = nextValue,
  593. arrowShow = true
  594. }
  595. else
  596. tbl = {
  597. attrName = name,
  598. preValue = attrValue/100 .. '%',
  599. nextValue = nextValue/100 .. '%',
  600. arrowShow = true
  601. }
  602. end
  603. table.insert(self.strengthAttTextList, tbl)
  604. end
  605. end
  606. local tips = SL:GetConfigTwoKeys('cfg_equip_strengthenGroup', groupId, strengthLevel+1, 'group', 'lv').tips
  607. if not string.isNullOrEmpty(tips) then
  608. local tbl = {
  609. attrName = tips,
  610. preValue = '',
  611. nextValue = '',
  612. arrowShow = false
  613. }
  614. table.insert(self.strengthAttTextList, tbl)
  615. end
  616. GUI:DataListUpdateData(self.view.strength_list)
  617. end
  618. -- 装备等级
  619. function this:SetEquipLevelInfo(strengthLevel)
  620. GUI:setVisible(self.view.strengthLevelBg, true)
  621. GUI:Text_setString(self.view.preLevel, "+" .. strengthLevel)
  622. GUI:Text_setString(self.view.nextLevel, "+" .. strengthLevel+1)
  623. end
  624. -- 成功率
  625. function this:RefreshSuccessRatio(cfgId, strengthLevel)
  626. GUI:setVisible(self.view.baseSuccessRatioText, true)
  627. GUI:setVisible(self.view.successIcon, true)
  628. local costId = SL:GetConfig('cfg_equip_strengthen', cfgId).costId
  629. local next_level = strengthLevel + 1
  630. local rate_client = SL:GetConfigTwoKeys('cfg_equip_strengthenCost', costId, next_level, "costGroupId", "level").rateClient
  631. rate_client = rate_client // 100
  632. GUI:Text_setString(self.view.baseSuccessRatioText, rate_client .. '%')
  633. end
  634. -- 装备名字
  635. function this:SetEquipName(cfgId, strengthLevel)
  636. GUI:setVisible(self.view.equipName, true)
  637. local equipName = SL:GetConfig('cfg_item', cfgId).name
  638. local colorStr = EquipFunc.GetEquipNameColor(cfgId)
  639. if strengthLevel > 0 then
  640. equipName = equipName .. '+' .. strengthLevel
  641. end
  642. GUI:Text_setString(self.view.equipName, string.format("<color=%s>%s</color>", colorStr, equipName))
  643. end
  644. -- 装备模型
  645. function this:SetEquipModel(cfgId)
  646. GUI:setVisible(self.view.item_model, true)
  647. GUI:Item_setItemId(self.view.item_model, cfgId)
  648. end
  649. --是否是满级装备
  650. function this.IsMaxEquip(equipInfo, strength_level)
  651. local cfgId = equipInfo.cfgId
  652. --local strength_level = equipInfo["strengthlevel"]
  653. ---首饰换表处理
  654. local ornament_tbl = SL:HasConfig('cfg_equip_ornamentsMain', cfgId)
  655. if ornament_tbl then
  656. if InfoManager.equipJewelryInfo:GetCurLevelMaxStrength(equipInfo) <= strength_level then
  657. return true
  658. end
  659. return false
  660. end
  661. local strength_tbl = SL:GetConfig('cfg_equip_strengthen', cfgId)
  662. if strength_tbl then
  663. if strength_tbl.maxLevel <= strength_level then
  664. return true
  665. end
  666. return false
  667. end
  668. return false
  669. end
  670. return this