KLUIMasterTalentCareerSwitchPanel.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---@class KLUIMasterTalentCareerSwitchPanel:UIKmlLuaPanelBase
  2. ---@field view KLUIMasterTalentCareerSwitchPanelView
  3. local KLUIMasterTalentCareerSwitchPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUIMasterTalentCareerSwitchPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:SetImageNativeSize(self.view.Title)
  8. GUI:SetImageNativeSize(self.view.img6)
  9. GUI:SetImageNativeSize(self.view.img7)
  10. GUI:SetActive(self.view.LeftConsume,not(self.args and self.args.isFirst))
  11. GUI:SetActive(self.view.LeftText,self.args and self.args.isFirst)
  12. self.series = self.args.series
  13. self.type = self.args.type
  14. self:GetCoinInfo()
  15. self:RefreshCoinText()
  16. end
  17. ---获取货币信息
  18. function this:GetCoinInfo()
  19. local cfg = SL:GetConfig("cfg_global",4001)
  20. local strArr = string.split(cfg.value,'#')
  21. self.costID = tonumber(strArr[1])
  22. GUI:Item_setItemId(self.view.ConsumeItem,self.costID)
  23. self.costCount = tonumber(strArr[2])
  24. end
  25. ---刷新货币信息
  26. function this:RefreshCoinText()
  27. local color = SL:GetBagItemCount(self.costID) >= self.costCount and "#1add1f" or "#ff2323"
  28. GUI:Text_setString(self.view.ConsumeText,"<color="..color..">"..self.costCount.."</color>")
  29. end
  30. ---注册UI事件和服务器消息
  31. function this:RegistEvents()
  32. GUI:AddOnClickEvent(self.view.CloseButton,self,self.OnClickCloseButton)
  33. GUI:AddOnClickEvent(self.view.MaskCloseButton,self,self.OnClickCloseButton)
  34. GUI:AddOnClickEvent(self.view.LeftButton,self,self.OnClickLeftButton)
  35. GUI:AddOnClickEvent(self.view.RightButton,self,self.OnClickRightButton)
  36. GUI:AddOnClickEvent(self.view.ConsumeItem,self,self.OnClickItemShowTips)
  37. SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.CoinInfo_Change,self)
  38. end
  39. function this:OnClickItemShowTips()
  40. if not self.costID then
  41. return
  42. end
  43. SL:OpenTips(nil,self.costID)
  44. end
  45. function this:CoinInfo_Change(_,message)
  46. self:RefreshCoinText()
  47. end
  48. ---创建或者刷新界面数据时调用
  49. function this:Refresh()
  50. end
  51. function this:OnClickLeftButton()
  52. if not self.args.isFirst and SL:GetBagItemCount(self.costID) < self.costCount then
  53. SL:TipMessage(SL:GetConfig('cfg_string',269).text, 1, NoticeType.NoticeMid )--"货币不足!",
  54. return
  55. end
  56. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_OPEN_MASTER_TYPE,{series = self.series,type = self.type})
  57. self:OnClickCloseButton()
  58. end
  59. function this:OnClickRightButton()
  60. --GUI:UIPanel_Close("dev/outui/MasterTalent/Panel/KLUIMasterTalentMain/KLUIMasterTalentMainPanel")
  61. --self:OnClickCloseButton()
  62. --GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  63. end
  64. function this:OnClickCloseButton()
  65. GUI:UIPanel_Close("dev/outui/MasterTalent/Panel/KLUIMasterTalentCareerSwitch/KLUIMasterTalentCareerSwitchPanel")
  66. end
  67. function this:Close()
  68. end
  69. return this