KLEquipRegenerateUIPanel.lua 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. ---@class KLEquipRegenerateUIPanel:UIKmlLuaPanelBase
  2. ---@field view KLEquipRegenerateUIPanelView
  3. --- kml代码lua化 会有较多冗余代码
  4. local KLEquipRegenerateUIPanel = class(UIKmlLuaPanelBase)
  5. local this =KLEquipRegenerateUIPanel
  6. ---创建时调用一次
  7. function this:Init()
  8. self.equipPanel = GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel",nil,nil, {x=-465, hideTips=true, callBack=self.CloseEquipUi})
  9. self.equipIndex = nil
  10. self.equipInfo = nil
  11. self.xilianList = {}
  12. self.currentAttList = {}
  13. self.AllCiTiao = {}
  14. GUI:DataListInitData(self.view.datalist_yulan, function()
  15. return self:AllCountFunc()
  16. end, function(realIndex)
  17. return self:AllGetFunc(realIndex)
  18. end, function(realIndex, kmlcontrol)
  19. return self:AllInitFunc(realIndex, kmlcontrol)
  20. end, function(realIndex, kmlcontrol)
  21. return self:AllUpdateFunc(realIndex, kmlcontrol)
  22. end)
  23. GUI:DataListInitData(self.view.datalist_current, function()
  24. return self:CurrentCountFunc()
  25. end, function(realIndex)
  26. return self:CurrentGetFunc(realIndex)
  27. end, function(realIndex, kmlcontrol)
  28. return self:CurrentInitFunc(realIndex, kmlcontrol)
  29. end, function(realIndex, kmlcontrol)
  30. return self:CurrentUpdateFunc(realIndex, kmlcontrol)
  31. end)
  32. GUI:DataListInitData(self.view.datalist_new, function()
  33. return self:NewCountFunc()
  34. end, function(realIndex)
  35. return self:NewGetFunc(realIndex)
  36. end, function(realIndex, kmlcontrol)
  37. return self:NewInitFunc(realIndex, kmlcontrol)
  38. end, function(realIndex, kmlcontrol)
  39. return self:NewUpdateFunc(realIndex, kmlcontrol)
  40. end)
  41. self.consume = {}
  42. GUI:DataListInitData(self.view.cost_list, function()
  43. return self:ConsumeCountFunc()
  44. end, function(realIndex)
  45. return self:ConsumeGetFunc(realIndex)
  46. end, function(realIndex, kmlcontrol)
  47. return self:ConsumeInitFunc(realIndex, kmlcontrol)
  48. end, function(realIndex, kmlcontrol)
  49. return self:ConsumeUpdateFunc(realIndex, kmlcontrol)
  50. end)
  51. self.jinhua_list = {}
  52. GUI:DataListInitData(self.view.datalist_jinhua, function()
  53. return self:JinHuaCiTiaoCountFunc()
  54. end, function(realIndex)
  55. return self:JinHuaCiTiaoGetFunc(realIndex)
  56. end, function(realIndex, kmlcontrol)
  57. return self:JinHuaCiTiaoInitFunc(realIndex, kmlcontrol)
  58. end, function(realIndex, kmlcontrol)
  59. return self:JinHuaCiTiaoUpdateFunc(realIndex, kmlcontrol)
  60. end)
  61. self.jinhua_consume = {}
  62. GUI:DataListInitData(self.view.jinhua_cost_list, function()
  63. return self:JinHuaConsumeCountFunc()
  64. end, function(realIndex)
  65. return self:JinHuaConsumeGetFunc(realIndex)
  66. end, function(realIndex, kmlcontrol)
  67. return self:JinHuaConsumeInitFunc(realIndex, kmlcontrol)
  68. end, function(realIndex, kmlcontrol)
  69. return self:JinHuaConsumeUpdateFunc(realIndex, kmlcontrol)
  70. end)
  71. self.lock_list = {0,0,0,0,0,0,0,0,0,0}
  72. self.is_xilian = true
  73. GUI:setVisible(self.view.xilian_panel,false)
  74. GUI:setVisible(self.view.jinhua_panel,false)
  75. GUI:Text_setString(self.view.equipName, "")
  76. GUI:Text_setString(self.view.equipName2, "")
  77. GUI:Text_setString(self.view.equipName_yulan, "")
  78. self:SelectXilian()
  79. end
  80. ---创建或者刷新界面数据时调用
  81. function this:Refresh()
  82. self.equipIndex = nil
  83. self:SelectEquip()
  84. end
  85. ---注册UI事件和服务器消息
  86. function this:RegistEvents()
  87. GUI:AddOnClickEvent(self.view.CloseButton, self, self.CloseButton)
  88. GUI:AddOnClickEvent(self.view.yulan_btn, self, self.YuLan)
  89. GUI:AddOnClickEvent(self.view.yulan_close_btn, self, self.YuLanClose)
  90. GUI:AddOnClickEvent(self.view.btn_xilian, self, self.SelectXilian)
  91. GUI:AddOnClickEvent(self.view.btn_jinhua, self, self.SelectJingHua)
  92. GUI:AddOnClickEvent(self.view.xilian_btn, self, self.XiLian)
  93. GUI:AddOnClickEvent(self.view.tihuan_btn, self, self.TiHuan)
  94. GUI:AddOnClickEvent(self.view.jinhua_btn, self, self.JinHua)
  95. SL:RegisterLUAEvent(LUA_EVENT_EQUIP_GRID_CLICK, self.LUA_EVENT_EQUIP_GRID_CLICK, self)
  96. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_UP_REGENERATION_ATTR,self.RES_UP_REGENERATION_ATTR,self) --响应上一次再生词条洗练数据
  97. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_EQUIP_REGENERATION,self.RES_EQUIP_REGENERATION,self) --响应装备再生
  98. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_REPLACE_REGENERATION_ATTR,self.RES_REPLACE_REGENERATION_ATTR,self) --响应替换再生属性
  99. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_STRENGTH_REGENERATION_ATTR,self.RES_STRENGTH_REGENERATION_ATTR,self) --响应强化再生属性
  100. SL:RegisterLUAEvent(LUA_EVENT_FORGE_GROUP_PANEL_CLOSE, self.CloseButton, self)
  101. end
  102. function this:CloseEquipUi()
  103. GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
  104. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  105. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipRegenerateUI/KLEquipRegenerateUIPanel")
  106. end
  107. function this:closeMask()
  108. GUI:setVisible(self.view.equip_show_tips, false)
  109. end
  110. function this:CloseButton()
  111. GUI:UIPanel_Close("dev/ui/UIForgeGroup/Panel/KLUIForgeGroup/KLUIForgeGroupPanel")
  112. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel")
  113. GUI:UIPanel_Close("dev/outui/Equip/Panel/KLEquipRegenerateUI/KLEquipRegenerateUIPanel")
  114. end
  115. function this:Close()
  116. if self.coHide then
  117. SL:UnSchedule(self.coHide)
  118. self.coHide = nil
  119. end
  120. end
  121. function this:SelectXilian()
  122. self.is_xilian = true
  123. GUI:setVisible(self.view.xilian_panel,true)
  124. GUI:setVisible(self.view.jinhua_panel,false)
  125. GUI:setVisible(self.view.btn_xilian_select,true)
  126. GUI:setVisible(self.view.btn_jinhua_select,false)
  127. GUI:setVisible(self.view.xilian_top,true)
  128. GUI:setVisible(self.view.jinhua_top,false)
  129. GUI:setVisible(self.view.yulan_panel,false)
  130. if not self.equipInfo then
  131. GUI:setVisible(self.view.lock,false)
  132. GUI:setVisible(self.view.info_panel,false)
  133. return
  134. end
  135. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  136. local tbl = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId)
  137. if strengthLevel < tbl.condition then
  138. GUI:setVisible(self.view.lock,true)
  139. GUI:setVisible(self.view.info_panel,false)
  140. else
  141. GUI:setVisible(self.view.lock,false)
  142. GUI:setVisible(self.view.info_panel,true)
  143. self:UpdateCurrentCiTiao()
  144. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_UP_EQUIP_REGENERATION, {itemId=self.equipInfo.id})
  145. end
  146. end
  147. function this:SelectJingHua()
  148. if not self.equipInfo then
  149. SL:TipMessage(SL:GetConfig('cfg_string',266).text, 1, NoticeType.NoticeMid )--"没有词条无法进化",
  150. return
  151. end
  152. local message = EquipFunc.GetEquipRegenerate(self.equipInfo)
  153. if message then
  154. local all_attr_id = {}
  155. for i=1,10,1 do
  156. if message[tostring(i)] then
  157. table.insert(all_attr_id,message[tostring(i)].id)
  158. else
  159. break
  160. end
  161. end
  162. if #all_attr_id < 1 then
  163. SL:TipMessage( SL:GetConfig('cfg_string',266).text,1, NoticeType.NoticeMid )--"没有词条无法进化",
  164. return
  165. end
  166. else
  167. SL:TipMessage( SL:GetConfig('cfg_string',266).text, 1, NoticeType.NoticeMid )--"没有词条无法进化",
  168. return
  169. end
  170. self.is_xilian = false
  171. GUI:setVisible(self.view.jinhua_panel,true)
  172. GUI:setVisible(self.view.xilian_panel,false)
  173. GUI:setVisible(self.view.btn_jinhua_select,true)
  174. GUI:setVisible(self.view.btn_xilian_select,false)
  175. GUI:setVisible(self.view.xilian_top,false)
  176. GUI:setVisible(self.view.jinhua_top,true)
  177. self:UpdateJinHuaUI()
  178. end
  179. function this:SelectEquip()
  180. for index=1, 15 do
  181. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  182. if equip then
  183. if SL:HasConfig('cfg_equip_regeneration', equip['cfgId']) then
  184. local tbl = SL:GetConfig('cfg_equip_regeneration', equip['cfgId'])
  185. self.equipPanel:SetSelectIndex(index)
  186. self:ClickEquip(equip)
  187. return
  188. end
  189. end
  190. end
  191. end
  192. function this:LUA_EVENT_EQUIP_GRID_CLICK(_, index)
  193. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  194. if index == E_AppearEquipType.Weapon and equip == nil then
  195. equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, E_AppearEquipType.TwoHandWeapon)
  196. end
  197. if equip then
  198. if SL:HasConfig('cfg_equip_regeneration', equip['cfgId']) then
  199. local tbl = SL:GetConfig('cfg_equip_regeneration', equip['cfgId'])
  200. self.equipPanel:SetSelectIndex(index)
  201. self:ClickEquip(equip)
  202. return
  203. else
  204. SL:TipMessage( SL:GetConfig('cfg_string',267).text, 1, NoticeType.NoticeMid )--"该部位装备无法再生",
  205. end
  206. end
  207. end
  208. function this:ResetUi()
  209. end
  210. -- local testLevel = 0
  211. function this:ClickEquip(equipInfo)
  212. local tbl = SL:GetConfig('cfg_equip_regeneration', equipInfo.cfgId)
  213. if tbl then
  214. self.equipInfo = equipInfo
  215. self:ResetUi()
  216. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  217. self:SetEquipName(self.equipInfo.cfgId, strengthLevel)
  218. self:SetEquipModel(self.equipInfo.cfgId)
  219. local message = EquipFunc.GetEquipRegenerate(self.equipInfo)
  220. if message then
  221. local all_attr_id = {}
  222. for i=1,10,1 do
  223. if message[tostring(i)] then
  224. table.insert(all_attr_id,message[tostring(i)].id)
  225. else
  226. break
  227. end
  228. end
  229. if #all_attr_id < 1 then
  230. self.is_xilian = true
  231. end
  232. else
  233. self.is_xilian = true
  234. end
  235. if self.is_xilian then
  236. self:ResetLock()
  237. self:UpdateConsume()
  238. self:SelectXilian()
  239. else
  240. self:SelectJingHua()
  241. end
  242. end
  243. end
  244. function this:CheckTiHuanBtn()
  245. if self.xilianList and #self.xilianList > 0 then
  246. GUI:setVisible(self.view.tihuan_btn,true)
  247. GUI:setPosition(self.view.xilian_btn,72,-360)
  248. else
  249. GUI:setVisible(self.view.tihuan_btn,false)
  250. GUI:setPosition(self.view.xilian_btn,0,-360)
  251. end
  252. local num = 0
  253. for i, v in ipairs(self.lock_list) do
  254. if v == 1 then
  255. num = num + 1
  256. end
  257. end
  258. self:UpdateConsume(num)
  259. end
  260. function this:UpdateCurrentCiTiao()
  261. self.currentAttList = {}
  262. local message = EquipFunc.GetEquipRegenerate(self.equipInfo)
  263. -- SL:LogError("获得当前再生词条")
  264. -- SL:LogTable(message,true)
  265. if message then
  266. local all_attr_id = {}
  267. for i=1,10,1 do
  268. if message[tostring(i)] then
  269. --SL:LogTable(message[tostring(i)].id,true)
  270. table.insert(all_attr_id,message[tostring(i)].id)
  271. else
  272. break
  273. end
  274. end
  275. for i, v in ipairs(all_attr_id) do
  276. local att = SL:GetConfig('cfg_equip_regenerationGroup', v)
  277. table.insert(self.currentAttList,att)
  278. end
  279. end
  280. GUI:DataListUpdateData(self.view.datalist_current)
  281. end
  282. function this:XiLian()
  283. local lock = {}
  284. for i, v in ipairs(self.currentAttList) do
  285. if self.lock_list[i] == 1 then
  286. table.insert(lock,self.currentAttList[i].id)
  287. end
  288. end
  289. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_EQUIP_REGENERATION, {itemId=self.equipInfo.id,lockattrpos=lock})
  290. end
  291. function this:RES_EQUIP_REGENERATION(_id, message)
  292. if not message then
  293. return
  294. end
  295. -- SL:LogError("洗练返回")
  296. -- SL:LogTable(message,true)
  297. self:UpdateXiLianUI(message)
  298. end
  299. function this:RES_UP_REGENERATION_ATTR(_id, message)
  300. -- SL:LogError("请求上次洗练数据返回")
  301. -- SL:LogTable(message,true)
  302. self:UpdateXiLianUI(message and message.entryAttr or {})
  303. end
  304. function this:TiHuan()
  305. SL:CommonTipsMessage({ stringTblID=212, ui = self, sureBtnText = "确定", cancelBtnText = "取消",
  306. callback = function()
  307. self:BeginTiHuan()
  308. end})
  309. end
  310. function this:BeginTiHuan()
  311. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_REPLACE_REGENERATION_ATTR, {itemId=self.equipInfo.id})
  312. end
  313. function this:RES_REPLACE_REGENERATION_ATTR(_id, message)
  314. if not message then
  315. return
  316. end
  317. -- SL:LogError("请求替换返回")
  318. -- SL:LogTable(message,true)
  319. self:ResetLock()
  320. self:SelectXilian()
  321. end
  322. function this:ResetLock()
  323. for i = 1, 10, 1 do
  324. self.lock_list[i] = 0
  325. end
  326. end
  327. function this:UpdateXiLianUI(message)
  328. local all_attr_id = {}
  329. for i=1,10,1 do
  330. if message[tostring(i)] then
  331. table.insert(all_attr_id,message[tostring(i)])
  332. else
  333. break
  334. end
  335. end
  336. self.xilianList = {}
  337. for i, v in ipairs(all_attr_id) do
  338. local att = SL:GetConfig('cfg_equip_regenerationGroup', v)
  339. table.insert(self.xilianList,att)
  340. end
  341. GUI:DataListUpdateData(self.view.datalist_new)
  342. self:CheckTiHuanBtn()
  343. end
  344. function this:UpdateConsume(num)
  345. self.consume = {}
  346. if not num or num == 0 then
  347. if self.currentAttList and #self.currentAttList > 0 then
  348. self.consume = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId).again
  349. else
  350. self.consume = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId).start
  351. end
  352. else
  353. local tbl = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId)
  354. if #tbl.lock < num and #tbl.lock >0 then
  355. self.consume = tbl.lock[#tbl.lock]
  356. else
  357. self.consume = tbl.lock[num]
  358. end
  359. end
  360. GUI:DataListUpdateData(self.view.cost_list)
  361. end
  362. function this:SetEquipName(cfgId, strengthLevel)
  363. GUI:setVisible(self.view.equipName, true)
  364. local equipName = SL:GetConfig('cfg_item', cfgId).name
  365. local colorStr = EquipFunc.GetEquipNameColor(cfgId)
  366. if strengthLevel > 0 then
  367. equipName = equipName .. '+' .. strengthLevel
  368. end
  369. GUI:Text_setString(self.view.equipName, string.format("<color=%s>%s</color>", colorStr, equipName))
  370. GUI:Text_setString(self.view.equipName2, string.format("<color=%s>%s</color>", colorStr, equipName))
  371. end
  372. function this:SetEquipModel(cfgId)
  373. GUI:setVisible(self.view.item_model, true)
  374. GUI:Item_setItemId(self.view.item_model, cfgId)
  375. GUI:setVisible(self.view.item_model2, true)
  376. GUI:Item_setItemId(self.view.item_model2, cfgId)
  377. end
  378. function this:YuLan()
  379. GUI:setVisible(self.view.yulan_panel, true)
  380. if self.equipInfo then
  381. local equipName = SL:GetConfig('cfg_item', self.equipInfo.cfgId).name
  382. local colorStr = EquipFunc.GetEquipNameColor(self.equipInfo.cfgId)
  383. equipName = equipName .. '词条'
  384. GUI:Text_setString(self.view.equipName_yulan, string.format("<color=%s>%s</color>", colorStr, equipName))
  385. else
  386. GUI:Text_setString(self.view.equipName_yulan, "全部词条")
  387. end
  388. local tbl
  389. if self.equipInfo then
  390. tbl = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId)
  391. end
  392. local AllCiTiao = SL:FindConfigs('cfg_equip_regenerationGroup', "level",1)
  393. self.AllCiTiao = {}
  394. --table.insert(self.AllCiTiao,{attName="词条"})
  395. for i, v in ipairs(AllCiTiao) do
  396. if tbl then
  397. if v.group == tbl.Group then
  398. table.insert(self.AllCiTiao,v)
  399. end
  400. else
  401. table.insert(self.AllCiTiao,v)
  402. end
  403. end
  404. GUI:DataListUpdateData(self.view.datalist_yulan)
  405. end
  406. function this:YuLanClose()
  407. GUI:setVisible(self.view.yulan_panel, false)
  408. end
  409. ---词条预览显示
  410. function this:AllCountFunc()
  411. return #self.AllCiTiao
  412. end
  413. function this:AllGetFunc(realIndex)
  414. end
  415. function this:AllInitFunc(realIndex, kmlcontrol)
  416. end
  417. function this:AllUpdateFunc(realIndex, kmlcontrol)
  418. local data = self.AllCiTiao[realIndex + 1]
  419. local name = GUI:GetChildControl(self.view.datalist_yulan, realIndex, "value")
  420. local bg = GUI:GetChildControl(self.view.datalist_yulan, realIndex, "bg")
  421. if realIndex % 2 == 1 then
  422. GUI:setVisible(bg, true)
  423. else
  424. GUI:setVisible(bg, false)
  425. end
  426. if data.att then
  427. local name_str,num_str= self:GetAttStr(data.att)
  428. GUI:Text_setString(name, name_str.." +"..num_str)
  429. else
  430. GUI:Text_setString(name, data.attName)
  431. end
  432. end
  433. function this:ConsumeCountFunc()
  434. return #self.consume
  435. end
  436. function this:ConsumeGetFunc(realIndex)
  437. end
  438. function this:ConsumeInitFunc(realIndex, kmlcontrol)
  439. end
  440. function this:ConsumeUpdateFunc(realIndex, kmlcontrol)
  441. local data = self.consume[realIndex + 1]
  442. local cost_item = GUI:GetChildControl(self.view.cost_list, realIndex, "cost_item")
  443. local cost_name = GUI:GetChildControl(self.view.cost_list, realIndex, "cost_name")
  444. local cost_num = GUI:GetChildControl(self.view.cost_list, realIndex, "cost_num")
  445. local costAddBtn = GUI:GetChildControl(self.view.cost_list, realIndex, "costAddBtn")
  446. local name = SL:GetConfig("cfg_item", data[1]).name
  447. GUI:Item_setItemId(cost_item, data[1])
  448. GUI:Text_setString(cost_name, name)
  449. local needCount = data[2]
  450. local haveCount = SL:GetBagItemCount(data[1])
  451. if haveCount < needCount then
  452. GUI:Text_setString(cost_num, string.format('<color="#9b1818">%d</color>/%d', haveCount, needCount))
  453. else
  454. GUI:Text_setString(cost_num, string.format('<color="#2a8430">%d</color>/%d', haveCount, needCount))
  455. end
  456. GUI:AddOnClickEvent(costAddBtn, self, self.costAddBtn, {cfgId=data[1]})
  457. end
  458. function this:costAddBtn(control, eventData)
  459. local cfgId = eventData.cfgId
  460. SL:CommonItemGetPath(nil, cfgId)
  461. end
  462. ---洗练当前词条显示
  463. function this:CurrentCountFunc()
  464. --SL:LogError(#self.currentAttList)
  465. return #self.currentAttList
  466. end
  467. function this:CurrentGetFunc(realIndex)
  468. end
  469. function this:CurrentInitFunc(realIndex, kmlcontrol)
  470. end
  471. function this:CurrentUpdateFunc(realIndex, kmlcontrol)
  472. local data = self.currentAttList[realIndex + 1]
  473. local name = GUI:GetChildControl(self.view.datalist_current, realIndex, "value")
  474. --GUI:Text_setString(name, data.attName)
  475. local name_str,num_str= self:GetAttStr(data.att)
  476. GUI:Text_setString(name, name_str.." +"..num_str)
  477. local btn_baoliu = GUI:GetChildControl(self.view.datalist_current, realIndex, "btn_baoliu")
  478. local btn_cancel = GUI:GetChildControl(self.view.datalist_current, realIndex, "btn_cancel")
  479. GUI:AddOnClickEvent(btn_baoliu, self, self.BaoLiu, {index=realIndex + 1})
  480. GUI:AddOnClickEvent(btn_cancel, self, self.JieChu, {index=realIndex + 1})
  481. if self.lock_list[realIndex + 1] == 0 then
  482. GUI:setVisible(btn_baoliu,true)
  483. GUI:setVisible(btn_cancel,false)
  484. else
  485. GUI:setVisible(btn_baoliu,false)
  486. GUI:setVisible(btn_cancel,true)
  487. end
  488. end
  489. function this:BaoLiu(control, eventData)
  490. local index = eventData.index
  491. local current_num = 0
  492. for i, v in ipairs(self.lock_list) do
  493. if v == 1 then
  494. current_num = current_num + 1
  495. end
  496. end
  497. local tbl = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId)
  498. local max_num = #tbl.lock
  499. if current_num >= max_num then
  500. local str = string.format("该装备最多锁定%s个词条",max_num)
  501. SL:TipMessage( str, 1, NoticeType.NoticeMid )
  502. return
  503. end
  504. self.lock_list[index] = 1
  505. local num = 0
  506. for i, v in ipairs(self.lock_list) do
  507. if v == 1 then
  508. num = num + 1
  509. end
  510. end
  511. GUI:DataListUpdateData(self.view.datalist_current)
  512. self:UpdateConsume(num)
  513. end
  514. function this:JieChu(control, eventData)
  515. local index = eventData.index
  516. self.lock_list[index] = 0
  517. local num = 0
  518. for i, v in ipairs(self.lock_list) do
  519. if v == 1 then
  520. num = num + 1
  521. end
  522. end
  523. GUI:DataListUpdateData(self.view.datalist_current)
  524. self:UpdateConsume(num)
  525. end
  526. ---洗练新词条显示
  527. function this:NewCountFunc()
  528. return #self.xilianList
  529. end
  530. function this:NewGetFunc(realIndex)
  531. end
  532. function this:NewInitFunc(realIndex, kmlcontrol)
  533. end
  534. function this:NewUpdateFunc(realIndex, kmlcontrol)
  535. local data = self.xilianList[realIndex + 1]
  536. local name = GUI:GetChildControl(self.view.datalist_new, realIndex, "value")
  537. --GUI:Text_setString(name, data.attName)
  538. local name_str,num_str= self:GetAttStr(data.att)
  539. GUI:Text_setString(name, name_str.." +"..num_str)
  540. end
  541. function this:UpdateJinHuaUI()
  542. if not self.equipInfo then
  543. GUI:setVisible(self.view.lock,false)
  544. GUI:setVisible(self.view.info_panel,false)
  545. return
  546. end
  547. local strengthLevel = EquipFunc.GetEquipStrengthLevel(self.equipInfo)
  548. local tbl = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId)
  549. if strengthLevel < tbl.condition then
  550. GUI:setVisible(self.view.jinhua_lock,true)
  551. GUI:setVisible(self.view.jinhua_info_panel,false)
  552. else
  553. GUI:setVisible(self.view.jinhua_lock,false)
  554. GUI:setVisible(self.view.jinhua_info_panel,true)
  555. end
  556. self:UpdateJinHuaCiTiao()
  557. end
  558. function this:UpdateJinHuaCiTiao()
  559. local AttList = {}
  560. local message = EquipFunc.GetEquipRegenerate(self.equipInfo)
  561. if message then
  562. local all_attr_id = {}
  563. for i=1,10,1 do
  564. if message[tostring(i)] then
  565. --SL:LogTable(message[tostring(i)].id,true)
  566. table.insert(all_attr_id,message[tostring(i)].id)
  567. else
  568. break
  569. end
  570. end
  571. for i, v in ipairs(all_attr_id) do
  572. local att = SL:GetConfig('cfg_equip_regenerationGroup', v)
  573. table.insert(AttList,att)
  574. end
  575. end
  576. self.jinhua_list = {}
  577. local max_level = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId).levelMax
  578. local current_level = EquipFunc.GetEquipRegenerateLevel(self.equipInfo)
  579. local next_level = current_level + 1
  580. if next_level > max_level then
  581. next_level = max_level
  582. end
  583. GUI:Text_setString(self.view.preLevel,"+".. tostring(current_level))
  584. GUI:Text_setString(self.view.nextLevel,"+".. tostring(next_level))
  585. if current_level >= max_level then
  586. GUI:setVisible(self.view.maxLevelTips,true)
  587. GUI:setVisible(self.view.jilv_img,false)
  588. GUI:setVisible(self.view.panel_jinhua_cailiao,false)
  589. GUI:setVisible(self.view.img_manji,true)
  590. GUI:setVisible(self.view.nextLevel,false)
  591. GUI:setVisible(self.view.jinhua_info_panel_arrow,false)
  592. else
  593. GUI:setVisible(self.view.maxLevelTips,false)
  594. GUI:setVisible(self.view.jilv_img,true)
  595. GUI:setVisible(self.view.panel_jinhua_cailiao,true)
  596. GUI:setVisible(self.view.img_manji,false)
  597. GUI:setVisible(self.view.nextLevel,true)
  598. GUI:setVisible(self.view.jinhua_info_panel_arrow,true)
  599. end
  600. for i, one_data in ipairs(AttList) do
  601. local id = one_data.id
  602. local level = one_data.level
  603. local tab = {}
  604. local name_str,num_str= self:GetAttStr(one_data.att)
  605. tab.note = name_str
  606. if level >= max_level then
  607. tab.before = ""
  608. tab.after = num_str
  609. else
  610. local next_id = id+1
  611. local next_tab = SL:GetConfig('cfg_equip_regenerationGroup',next_id)
  612. local name2,num_str2= self:GetAttStr(next_tab.att)
  613. tab.before = num_str
  614. tab.after = num_str2
  615. end
  616. table.insert(self.jinhua_list,tab)
  617. end
  618. GUI:DataListUpdateData(self.view.datalist_jinhua)
  619. self:UpdateJinHuaConsume()
  620. end
  621. function this:GetAttStr(str)
  622. -- SL:LogError(str)
  623. if string.isNullOrEmpty(str) then
  624. return "",""
  625. end
  626. local oneList = string.split(str,'#')
  627. local att_id = tonumber(oneList[1])
  628. local num = tonumber(oneList[2])
  629. local attrTbl = SL:GetConfig("cfg_att_info", att_id)
  630. local name = attrTbl.name
  631. local remarks = attrTbl.remarks
  632. local num_str = ""
  633. if remarks == 1 then
  634. num_str = num
  635. else
  636. num_str = string.format("%.2".. "f", num / 100) .. "%"
  637. end
  638. -- SL:LogError(num_str)
  639. return name,num_str
  640. end
  641. ---进化词条显示
  642. function this:JinHuaCiTiaoCountFunc()
  643. return #self.jinhua_list
  644. end
  645. function this:JinHuaCiTiaoGetFunc(realIndex)
  646. end
  647. function this:JinHuaCiTiaoInitFunc(realIndex, kmlcontrol)
  648. end
  649. function this:JinHuaCiTiaoUpdateFunc(realIndex, kmlcontrol)
  650. local data = self.jinhua_list[realIndex + 1]
  651. local name = GUI:GetChildControl(self.view.datalist_jinhua, realIndex, "name")
  652. local before = GUI:GetChildControl(self.view.datalist_jinhua, realIndex, "before")
  653. local after = GUI:GetChildControl(self.view.datalist_jinhua, realIndex, "after")
  654. local arrow = GUI:GetChildControl(self.view.datalist_jinhua, realIndex, "arrow")
  655. if data.before == "" then
  656. GUI:setVisible(arrow,false)
  657. else
  658. GUI:setVisible(arrow,true)
  659. end
  660. GUI:Text_setString(name, tostring(data.note))
  661. GUI:Text_setString(before, tostring(data.before))
  662. GUI:Text_setString(after, tostring(data.after))
  663. end
  664. ---进化所需材料
  665. function this:JinHuaConsumeCountFunc()
  666. return #self.jinhua_consume
  667. end
  668. function this:JinHuaConsumeGetFunc(realIndex)
  669. end
  670. function this:JinHuaConsumeInitFunc(realIndex, kmlcontrol)
  671. end
  672. function this:JinHuaConsumeUpdateFunc(realIndex, kmlcontrol)
  673. local data = self.jinhua_consume[realIndex + 1]
  674. local cost_item = GUI:GetChildControl(self.view.jinhua_cost_list, realIndex, "cost_item")
  675. local cost_name = GUI:GetChildControl(self.view.jinhua_cost_list, realIndex, "cost_name")
  676. local cost_num = GUI:GetChildControl(self.view.jinhua_cost_list, realIndex, "cost_num")
  677. local costAddBtn = GUI:GetChildControl(self.view.jinhua_cost_list, realIndex, "costAddBtn")
  678. local name = SL:GetConfig("cfg_item", data[1]).name
  679. GUI:Item_setItemId(cost_item, data[1])
  680. GUI:Text_setString(cost_name, name)
  681. local needCount = data[2]
  682. local haveCount = SL:GetBagItemCount(data[1])
  683. if haveCount < needCount then
  684. GUI:Text_setString(cost_num, string.format('<color="#9b1818">%d</color>/%d', haveCount, needCount))
  685. else
  686. GUI:Text_setString(cost_num, string.format('<color="#2a8430">%d</color>/%d', haveCount, needCount))
  687. end
  688. GUI:AddOnClickEvent(costAddBtn, self, self.costAddBtn, {cfgId=data[1]})
  689. end
  690. function this:UpdateJinHuaConsume()
  691. local level = EquipFunc.GetEquipRegenerateLevel(self.equipInfo)
  692. self.jinhua_consume = {}
  693. local costId = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId).costId
  694. local id = costId * 100 + level
  695. local has = SL:HasConfig('cfg_equip_regenerationCost', id)
  696. if not has then
  697. return
  698. end
  699. local tab = SL:GetConfig('cfg_equip_regenerationCost', id)
  700. self.jinhua_consume = tab.cost
  701. GUI:DataListUpdateData(self.view.jinhua_cost_list)
  702. local rateClient = tab.rateClient
  703. rateClient = math.floor(rateClient/100)
  704. GUI:Text_setString(self.view.jilv,rateClient.."%")
  705. end
  706. function this:JinHua()
  707. local max_level = SL:GetConfig('cfg_equip_regeneration', self.equipInfo.cfgId).levelMax
  708. local current_level = EquipFunc.GetEquipRegenerateLevel(self.equipInfo)
  709. if current_level >= max_level then
  710. SL:TipMessage( SL:GetConfig('cfg_string',241).text,"已经是最高等级了", 1, NoticeType.NoticeMid )
  711. return
  712. end
  713. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_STRENGTH_REGENERATION_ATTR, {itemId=self.equipInfo.id})
  714. end
  715. function this:RES_STRENGTH_REGENERATION_ATTR(_id, message)
  716. -- SL:LogError("响应进化")
  717. -- SL:LogTable(message,true)
  718. GUI:setVisible(self.view.success_anim, true)
  719. if message then
  720. GUI:Text_setString(self.view.successText, "进化成功")
  721. GUI:Text_setTextColor(self.view.successText, "#FFE800")
  722. GUI:Image_loadTexture(self.view.success_anim, "img_function_13" ,"Atlas/UIEquipStrengthPanel.spriteatlas")
  723. else
  724. GUI:Text_setString(self.view.successText, "进化失败")
  725. GUI:Text_setTextColor(self.view.successText, "#DCE1E5")
  726. GUI:Image_loadTexture(self.view.success_anim, "strength_fail" ,"Atlas/UIEquipStrengthPanel.spriteatlas")
  727. end
  728. if self.coHide ~= nil then
  729. SL:UnSchedule(self.coHide)
  730. end
  731. self.coHide = SL:ScheduleOnce(1.5,function ()
  732. GUI:setVisible(self.view.success_anim, false)
  733. end
  734. )
  735. self:SelectJingHua()
  736. end
  737. return this