KLSettingTogglePanel.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ---@class KLSettingTogglePanel:UIKmlLuaPanelBase
  2. ---@field view KLSettingTogglePanelView
  3. local KLSettingTogglePanel = class(UIKmlLuaPanelBase)
  4. local this = KLSettingTogglePanel
  5. ---创建时调用一次
  6. function this:Init()
  7. this.BasicPanelPath = ""
  8. this.BasicPanelPath = "dev/ui/Setting/Panel/KLBasic/KLBasicPanel"
  9. end
  10. ---创建或者刷新界面数据时调用
  11. function this:Refresh()
  12. if not self.args or (self.args == ESettingType.BasicTog) then
  13. GUI:SetIsOnWithoutNotify(self.view.basicSettingToggle, true)
  14. GUI:UIPanel_Open(this.BasicPanelPath)
  15. elseif self.args == ESettingType.OnHookTog then
  16. GUI:SetIsOnWithoutNotify(self.view.hookSettingToggle, true)
  17. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLHook/KLHookPanel")
  18. elseif self.args == ESettingType.DiaplayTog then
  19. GUI:SetIsOnWithoutNotify(self.view.showSettingToggle, true)
  20. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLDisplay/KLDisplayPanel")
  21. elseif self.args == ESettingType.PickUpTog then
  22. GUI:SetIsOnWithoutNotify(self.view.pickUpSettingToggle, true)
  23. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLPickUp/KLPickUpPanel")
  24. end
  25. end
  26. ---注册UI事件和服务器消息
  27. function this:RegistEvents()
  28. GUI:SetToggleOnValueChange(self.view.basicSettingToggle, self, self.BasicSettingOnValueChange)
  29. GUI:SetToggleOnValueChange(self.view.hookSettingToggle, self, self.HookSettingOnValueChange)
  30. GUI:SetToggleOnValueChange(self.view.pickUpSettingToggle, self, self.PickUpSettingOnValueChange)
  31. GUI:SetToggleOnValueChange(self.view.showSettingToggle, self, self.ShowSettingOnValueChange)
  32. GUI:SetToggleOnValueChange(self.view.codeToggle, self, self.CodeOnValueChange)
  33. GUI:SetToggleOnValueChange(self.view.inviteFriendToggle, self, self.InviteFriendOnValueChange)
  34. GUI:AddOnClickEvent(self.view.closeBtn, self, self.CloseOnClick)
  35. GUI:AddOnTouchEvent(self.view.title, self, self.OnTouchEvent)
  36. end
  37. local clickCounter = 0
  38. local lastClickTime = 0
  39. local clickDelta = 2
  40. ---@param kmlCtrl UIKmlLuaControl
  41. ---@param eventType EUIEventName
  42. function this:OnTouchEvent(kmlCtrl, eventType, args)
  43. if eventType == EUIEventName.onDoublePointerClick then
  44. if Time.time - lastClickTime > clickDelta then
  45. clickCounter = 0
  46. end
  47. lastClickTime = Time.time
  48. clickCounter = clickCounter + 1
  49. if clickCounter == 3 then
  50. clickCounter = 0
  51. self:CloseOnClick()
  52. SL.UIManager:ShowNotHideUI("UIGMPanel")
  53. end
  54. end
  55. end
  56. function this:BasicSettingOnValueChange(control, _, data)
  57. local isToggle = data[1]
  58. if isToggle then
  59. GUI:UIPanel_Open(this.BasicPanelPath)
  60. else
  61. GUI:UIPanel_Close(this.BasicPanelPath)
  62. end
  63. end
  64. function this:HookSettingOnValueChange(control, _, data)
  65. local isToggle = data[1]
  66. if isToggle then
  67. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLHook/KLHookPanel")
  68. else
  69. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLHook/KLHookPanel")
  70. end
  71. end
  72. function this:PickUpSettingOnValueChange(control, _, data)
  73. local isToggle = data[1]
  74. if isToggle then
  75. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLPickUp/KLPickUpPanel")
  76. else
  77. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLPickUp/KLPickUpPanel")
  78. end
  79. end
  80. function this:ShowSettingOnValueChange(control, _, data)
  81. local isToggle = data[1]
  82. if isToggle then
  83. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLDisplay/KLDisplayPanel")
  84. else
  85. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLDisplay/KLDisplayPanel")
  86. end
  87. end
  88. function this:CodeOnValueChange(control, _, data)
  89. local isToggle = data[1]
  90. if isToggle then
  91. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLCode/KLCodePanel")
  92. else
  93. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLCode/KLCodePanel")
  94. end
  95. end
  96. function this:InviteFriendOnValueChange(control, _, data)
  97. local isToggle = data[1]
  98. if isToggle then
  99. GUI:UIPanel_Open("dev/ui/Setting/Panel/KLInViteFriend/KLInViteFriendPanel")
  100. else
  101. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLInViteFriend/KLInViteFriendPanel")
  102. end
  103. end
  104. function this:CloseOnClick()
  105. GUI:UIPanel_Close(this.BasicPanelPath)
  106. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLHook/KLHookPanel")
  107. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLPickUp/KLPickUpPanel")
  108. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLDisplay/KLDisplayPanel")
  109. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLCode/KLCodePanel")
  110. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLInViteFriend/KLInViteFriendPanel")
  111. GUI:UIPanel_Close("dev/ui/Setting/Panel/KLSettingToggle/KLSettingTogglePanel")
  112. end
  113. function this:Close()
  114. end
  115. return this