KLUISkillUpTipsPanel.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. ---@class KLUISkillUpTipsPanel:UIKmlLuaPanelBase
  2. ---@field view KLUISkillUpTipsPanelView
  3. local KLUISkillUpTipsPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUISkillUpTipsPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. --天赋
  8. if self.args and self.args.masterID and self.args.type then
  9. self.masterID = self.args.masterID
  10. self.type = self.args.type
  11. self:ShowMasterInfo()
  12. end
  13. self.x = self.args["x"]
  14. self.y = self.args["y"]
  15. if self.x then
  16. GUI:setPositionX(self.view.root,self.x)
  17. end
  18. if self.y then
  19. GUI:setPositionY(self.view.root,self.y)
  20. end
  21. end
  22. ---显示天赋信息
  23. function this:ShowMasterInfo(isRefreshCalc)
  24. ---是否是技能,技能需要读cfg_skill_info
  25. local isSkill = false
  26. ---@type cfg_master_protalent_column
  27. local _cfg = nil
  28. if self.type == EMasterTalentType.COMMON then
  29. _cfg = SL:GetConfig('cfg_master_commontalent',self.masterID)
  30. elseif self.type == EMasterTalentType.CAREER then
  31. _cfg = SL:GetConfig('cfg_master_protalent',self.masterID)
  32. if _cfg.type == 2 then
  33. isSkill = true
  34. end
  35. elseif self.type == EMasterTalentType.SKILL then
  36. _cfg = SL:GetConfig('cfg_master_skilltalent',self.masterID)
  37. end
  38. self.masterLevel = InfoManager.masterTalentInfo:GetMasterLevel(self.type,_cfg.series,_cfg.id)
  39. ---@type cfg_master_info_column
  40. local masterNowCfg = InfoManager.masterTalentInfo:GetMasterCfg(self.masterID,self.masterLevel)
  41. ---@type cfg_master_info_column
  42. local masterNextCfg = InfoManager.masterTalentInfo:GetMasterCfg(self.masterID,self.masterLevel + 1)
  43. if isSkill then
  44. ---@type cfg_skill_info_column
  45. local nowSkillInfo = nil
  46. ---@type cfg_skill_info_column
  47. local nextSkillInfo = nil
  48. if SL:HasConfigTwoKeys('cfg_skill_info',_cfg.skillId,self.masterLevel,'skillID','skillLevel') then
  49. nowSkillInfo = SL:GetConfigTwoKeys('cfg_skill_info',_cfg.skillId,self.masterLevel,'skillID','skillLevel')
  50. end
  51. if SL:HasConfigTwoKeys('cfg_skill_info',_cfg.skillId,self.masterLevel + 1,'skillID','skillLevel') then
  52. nextSkillInfo = SL:GetConfigTwoKeys('cfg_skill_info',_cfg.skillId,self.masterLevel + 1,'skillID','skillLevel')
  53. end
  54. GUI:Text_setString(self.view.NowSkillInfo,nowSkillInfo and nowSkillInfo.tips or "")
  55. GUI:Text_setString(self.view.NextSkillInfo,nextSkillInfo and nextSkillInfo.tips or "")
  56. else
  57. GUI:Text_setString(self.view.NowSkillInfo,masterNowCfg and masterNowCfg.description or "")
  58. GUI:Text_setString(self.view.NextSkillInfo,masterNextCfg and masterNextCfg.description or "")
  59. end
  60. if self.masterLevel == 0 then
  61. GUI:Text_setString(self.view.NowSkillInfo,"天赋未激活")
  62. end
  63. GUI:Text_setString(self.view.SkillLv,self.masterLevel.."/".._cfg.minMaxLevel[2])
  64. GUI:Image_loadTexture(self.view.SkillIcon,_cfg.icon,"Atlas/UIOutSkillIcon.spriteatlas")
  65. GUI:Text_setString(self.view.SkillName,_cfg.name)
  66. local frontNum = 0
  67. if masterNextCfg then
  68. frontNum = masterNextCfg.frontNum
  69. end
  70. --前置点数不足显示红色
  71. if not InfoManager.masterTalentInfo:IsCanUpLevel(_cfg.id,_cfg.series,_cfg.steps,self.type) then
  72. --"#1add1f" or "#ff2323"
  73. GUI:Text_setString(self.view.NeedPoint,"<color=#ff2323>"..frontNum.."</color>")
  74. else
  75. GUI:Text_setString(self.view.NeedPoint,tostring(frontNum))
  76. end
  77. local isMaxLevel = self.masterLevel >= _cfg.minMaxLevel[2]
  78. GUI:SetActive(self.view.UpButton,not isMaxLevel)
  79. GUI:SetActive(self.view.NeedPoint,not isMaxLevel)
  80. if isMaxLevel then
  81. GUI:Text_setString(self.view.NextSkillInfo,"天赋已点满")
  82. end
  83. if isRefreshCalc then
  84. self:RefreshCalcPanel(_cfg,isMaxLevel)
  85. end
  86. end
  87. ---注册UI事件和服务器消息
  88. function this:RegistEvents()
  89. GUI:AddOnClickEvent(self.view.UpButton,self,self.OnClickUpButton)
  90. GUI:AddOnClickEvent(self.view.MaskCloseButton,self,self.OnClickCloseButton)
  91. SL:RegisterLUAEvent(LUA_EVENT_MASTER_SKILL_DATA_CHANGE, self.LUA_EVENT_MASTER_SKILL_DATA_CHANGE, self)
  92. end
  93. ---响应:大师变化信息
  94. function this:LUA_EVENT_MASTER_SKILL_DATA_CHANGE(id,message)
  95. if message and message["type"] then
  96. local type = tonumber(message["type"])
  97. if type == self.type then
  98. self:ShowMasterInfo(true)
  99. end
  100. end
  101. end
  102. ---刷新输入框
  103. ---@param _cfg cfg_master_protalent_column
  104. function this:RefreshCalcPanel(_cfg,isMaxLevel)
  105. if isMaxLevel then
  106. GUI:UIPanel_Close("dev/ui/Common/Panel/KLCalc/KLCalcPanel")
  107. GUI:setPositionX(self.view.root,0)
  108. GUI:setPositionY(self.view.root,0)
  109. return
  110. end
  111. ---@type KLCalcPanel
  112. local panel = GUI:GetUI("dev/ui/Common/Panel/KLCalc/KLCalcPanel")
  113. if panel then
  114. panel.maxNum = InfoManager.masterTalentInfo:GetMaxPoint(self.masterID,self.masterLevel,_cfg.minMaxLevel[2],self.type,_cfg.series)
  115. panel:Refresh()
  116. end
  117. end
  118. function this:OnClickCloseButton()
  119. GUI:UIPanel_Close("dev/outui/SkillTips/Panel/KLUISkillUpTips/KLUISkillUpTipsPanel")
  120. GUI:UIPanel_Close("dev/ui/Common/Panel/KLCalc/KLCalcPanel")
  121. end
  122. function this:OnClickUpButton()
  123. if self.args and self.args.callBack then
  124. self.args.callBack()
  125. end
  126. end
  127. ---创建或者刷新界面数据时调用
  128. function this:Refresh()
  129. end
  130. function this:Close()
  131. end
  132. return this