KLUIMasterTalentWashUpPanel.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ---@class KLUIMasterTalentWashUpPanel:UIKmlLuaPanelBase
  2. ---@field view KLUIMasterTalentWashUpPanelView
  3. local KLUIMasterTalentWashUpPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUIMasterTalentWashUpPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:SetImageNativeSize(self.view.title)
  8. if self.args and self.args.type then
  9. if self.args.type == EMasterTalentType.CAREER then
  10. GUI:Text_setString(self.view.Text,"将把全部职业天赋重置为0级。\n并重新获得已消耗的所有职业天赋点。\n职业天赋等级不受影响。")
  11. GUI:Text_setString(self.view.Text2,"职业天赋等级不受影响。")
  12. GUI:SetActive(self.view.img4,true)
  13. self:GetCoinInfo(4002)
  14. elseif self.args.type == EMasterTalentType.SKILL then
  15. GUI:Text_setString(self.view.Text,"将把全部强化天赋重置为0级。\n并重新获得已消耗的所有强化天赋点。")
  16. GUI:Text_setString(self.view.Text2,"")
  17. GUI:SetActive(self.view.img4,false)
  18. self:GetCoinInfo(4007)
  19. elseif self.args.type == EMasterTalentType.COMMON then
  20. GUI:Text_setString(self.view.Text,"将把全部通用天赋重置为0级。\n并重新获得已消耗的所有通用天赋点。")
  21. GUI:Text_setString(self.view.Text2,"")
  22. GUI:SetActive(self.view.img4,false)
  23. self:GetCoinInfo(4011)
  24. end
  25. end
  26. end
  27. ---获取货币信息
  28. function this:GetCoinInfo(id)
  29. local cfg = SL:GetConfig("cfg_global",id)
  30. local strArr = string.split(cfg.value,'#')
  31. self.costID = tonumber(strArr[1])
  32. GUI:Item_setItemId(self.view.CostItem,self.costID)
  33. self.costCount = tonumber(strArr[2])
  34. self:RefreshCoinText()
  35. end
  36. ---刷新货币信息
  37. function this:RefreshCoinText()
  38. local color = SL:GetBagItemCount(self.costID) >= self.costCount and "#1add1f" or "#ff2323"
  39. GUI:Text_setString(self.view.textCost,"<color="..color..">"..self.costCount.."</color>")
  40. end
  41. ---注册UI事件和服务器消息
  42. function this:RegistEvents()
  43. GUI:AddOnClickEvent(self.view.CloseButton,self,self.OnClickCloseButton)
  44. GUI:AddOnClickEvent(self.view.MaskCloseButton,self,self.OnClickCloseButton)
  45. GUI:AddOnClickEvent(self.view.CancelButton,self,self.OnClickCloseButton)
  46. GUI:AddOnClickEvent(self.view.OkButton,self,self.OnClickOkButton)
  47. GUI:AddOnClickEvent(self.view.CostItem,self,self.OnClickItemShowTips)
  48. SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.CoinInfo_Change,self)
  49. end
  50. function this:OnClickItemShowTips()
  51. if not self.costID then
  52. return
  53. end
  54. SL:OpenTips(nil,self.costID)
  55. end
  56. function this:CoinInfo_Change(_,message)
  57. self:RefreshCoinText()
  58. end
  59. ---创建或者刷新界面数据时调用
  60. function this:Refresh()
  61. end
  62. function this:OnClickCloseButton()
  63. GUI:UIPanel_Close("dev/outui/MasterTalent/Panel/KLUIMasterTalentWashUp/KLUIMasterTalentWashUpPanel")
  64. end
  65. function this:OnClickOkButton()
  66. if SL:GetBagItemCount(self.costID) < self.costCount then
  67. SL:TipMessage( SL:GetConfig('cfg_string',269).text,1, NoticeType.NoticeMid )--"货币不足!",
  68. return
  69. end
  70. if self.args.series then
  71. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RESET_MASTER,{type = self.args.type,series = self.args.series})
  72. else
  73. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RESET_MASTER,{type = self.args.type})
  74. end
  75. self:OnClickCloseButton()
  76. end
  77. function this:Close()
  78. end
  79. return this