KLHuntingDemonsMainPanel.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ---@class KLHuntingDemonsMainPanel:UIKmlLuaPanelBase
  2. ---@field view KLHuntingDemonsMainPanelView
  3. local KLHuntingDemonsMainPanel = class(UIKmlLuaPanelBase)
  4. local this =KLHuntingDemonsMainPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. ---已经打开的子界面
  8. self.openPanelPath = nil
  9. ---选择的toggle
  10. self.selectToggleIndex = nil
  11. ---所有toggle
  12. self.toggleList =
  13. {
  14. [1] = self.view.toggle_HallOfFame,
  15. [2] = self.view.toggle_Reward,
  16. }
  17. end
  18. ---注册UI事件和服务器消息
  19. function this:RegistEvents()
  20. GUI:SetToggleOnValueChange(self.view.toggle_HallOfFame, self, self.OnToggleClick,1)
  21. GUI:SetToggleOnValueChange(self.view.toggle_Reward, self, self.OnToggleClick,2)
  22. GUI:AddOnClickEvent(self.view.button_close, self, self.OnClickClose)
  23. GUI:AddOnClickEvent(self.view.MaskButton, self, self.OnClickClose)
  24. end
  25. ---点击关闭
  26. function this:OnClickClose()
  27. if self.openPanelPath then
  28. GUI:UIPanel_Close(self.openPanelPath)
  29. end
  30. GUI:UIPanel_Close("dev/outui/HuntingDemons/Panel/KLHuntingDemonsMain/KLHuntingDemonsMainPanel")
  31. end
  32. ---点击选择页签
  33. function this:OnToggleClick(kmlCtrl, eventData, args)
  34. if args[1] and self.selectToggleIndex ~= eventData then
  35. if self.openPanelPath then
  36. GUI:UIPanel_Close(self.openPanelPath)
  37. end
  38. self.selectToggleIndex = eventData
  39. if eventData == 1 then
  40. self.openPanelPath = "dev/outui/HuntingDemons/Panel/KLHuntingDemonsHallOfFame/KLHuntingDemonsHallOfFamePanel"
  41. elseif eventData == 2 then
  42. self.openPanelPath = "dev/outui/HuntingDemons/Panel/KLHuntingDemonsReward/KLHuntingDemonsRewardPanel"
  43. end
  44. GUI:UIPanel_Open(self.openPanelPath,_,_,{mainPanel = self})
  45. end
  46. end
  47. ---界面显示时调用一次
  48. function this:Show()
  49. end
  50. ---创建或者刷新界面数据时调用
  51. function this:Refresh()
  52. InfoManager.uiHuntingDemonsInfo:SetIsStartReqRankData(true)
  53. local toggleIndex = 1
  54. if self.args and self.args.toggleIndex then
  55. toggleIndex = self.args.toggleIndex
  56. end
  57. self:SelectTogglePanel(toggleIndex)
  58. end
  59. ---设置哪个页签选中
  60. function this:SelectTogglePanel(index)
  61. GUI:Toggle_setIsOn(self.toggleList[index],true)
  62. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MONSTER_HUNT_RANK)
  63. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MONSTER_HUNT_INFO)
  64. end
  65. function this:Hide()
  66. end
  67. function this:Close()
  68. InfoManager.uiHuntingDemonsInfo:SetIsStartReqRankData(false)
  69. end
  70. return this