KLCardShapeShiftPanel.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ---@class KLCardShapeShiftPanel:UIKmlLuaPanelBase
  2. ---@field view KLCardShapeShiftPanelView
  3. local KLCardShapeShiftPanel = class(UIKmlLuaPanelBase)
  4. local this =KLCardShapeShiftPanel
  5. function this:AsyncLoadUI()
  6. end
  7. ---创建时调用一次
  8. function this:Init()
  9. end
  10. ---注册UI事件和服务器消息
  11. function this:RegistEvents()
  12. GUI:AddOnClickEvent(self.view.btn_close, self, self.btn_close)
  13. GUI:AddOnClickEvent(self.view.img_close, self, self.btn_close)
  14. GUI:AddOnClickEvent(self.view.btn_left, self, self.btn_left)
  15. GUI:AddOnClickEvent(self.view.btn_right, self, self.btn_right)
  16. GUI:SetToggleOnValueChange(self.view.today_show_toggle,self,self.today_show_toggle_value_change)
  17. end
  18. ---界面显示时调用一次
  19. function this:Show()
  20. end
  21. ---创建或者刷新界面数据时调用
  22. function this:Refresh()
  23. SL.HideMainPanel()
  24. if self.args then
  25. self.uiId = self.args
  26. if self.uiId == 101 then
  27. GUI:Image_loadTexture(self.view.img_bg, "Texture/card_shape_cjlj.png")
  28. elseif self.uiId == 102 then
  29. GUI:Image_loadTexture(self.view.img_bg, "Texture/card_shape_ttwz.png")
  30. end
  31. ---@type cfg_system_foreshow_column
  32. self.ui_cfg = SL:GetConfig("cfg_system_foreshow", self.uiId)
  33. local btnShow = {}
  34. local open_server_day = InfoManager.cardShapeShiftInfo.open_server_day
  35. local level = SL:GetMetaValue("LEVEL")
  36. if #self.ui_cfg.btnNeedLevel > 0 then
  37. for i, v in ipairs(self.ui_cfg.btnNeedLevel) do
  38. if v[2] ~= 0 and v[2] <= level then
  39. btnShow[i] = true
  40. end
  41. end
  42. end
  43. if #self.ui_cfg.btnNeedDay > 0 then
  44. for i, v in ipairs(self.ui_cfg.btnNeedDay) do
  45. if v[2] ~= 0 and v[2] <= open_server_day then
  46. else
  47. if btnShow[i] then
  48. btnShow[i] = false
  49. end
  50. end
  51. end
  52. end
  53. if btnShow[1] then
  54. GUI:setVisible(self.view.btn_left, true)
  55. GUI:setVisible(self.view.btn_left_tips, false)
  56. else
  57. GUI:setVisible(self.view.btn_left, false)
  58. GUI:setVisible(self.view.btn_left_tips, true)
  59. if #self.ui_cfg.btnText > 0 then
  60. for i, v in ipairs(self.ui_cfg.btnText) do
  61. if v[1] == "1" then
  62. GUI:Text_setString(self.view.btn_left_tips, v[2])
  63. end
  64. end
  65. end
  66. end
  67. if btnShow[2] then
  68. GUI:setVisible(self.view.btn_right, true)
  69. GUI:setVisible(self.view.btn_right_tips, false)
  70. else
  71. GUI:setVisible(self.view.btn_right, false)
  72. GUI:setVisible(self.view.btn_right_tips, true)
  73. if #self.ui_cfg.btnText > 0 then
  74. for i, v in ipairs(self.ui_cfg.btnText) do
  75. if v[1] == "2" then
  76. GUI:Text_setString(self.view.btn_right_tips, v[2])
  77. end
  78. end
  79. end
  80. end
  81. end
  82. end
  83. function this:btn_close(_, stop)
  84. GUI:UIPanel_Close("dev/outui/CardShapeShift/Panel/KLCardShapeShift/KLCardShapeShiftPanel")
  85. if not stop then
  86. InfoManager.cardShapeShiftInfo:REFRESH_NEXT_CARD_SHAPE_UI()
  87. end
  88. end
  89. function this:btn_left()
  90. if #self.ui_cfg.btnSkip > 0 then
  91. for i, v in ipairs(self.ui_cfg.btnSkip) do
  92. if v[1] == "1" then
  93. GUI:UIPanel_Close("dev/outui/Hook/Panel/KLOnHook/KLOnHookPanel")
  94. self:btn_close(_, true)
  95. local instruction = InfoManager.cardShapeShiftInfo:DeepCopy(v)
  96. table.remove(instruction, 1)
  97. SL:ShortcutDO(instruction)
  98. end
  99. end
  100. end
  101. end
  102. function this:btn_right()
  103. if #self.ui_cfg.btnSkip > 0 then
  104. for i, v in ipairs(self.ui_cfg.btnSkip) do
  105. if v[1] == "2" then
  106. GUI:UIPanel_Close("dev/outui/Hook/Panel/KLOnHook/KLOnHookPanel")
  107. self:btn_close(_, true)
  108. local instruction = InfoManager.cardShapeShiftInfo:DeepCopy(v)
  109. table.remove(instruction, 1)
  110. SL:ShortcutDO(instruction)
  111. end
  112. end
  113. end
  114. end
  115. function this:today_show_toggle_value_change(_, _, data)
  116. self.isToggle = data[1]
  117. end
  118. function this:Close()
  119. if self.isToggle then
  120. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_CANCEL_FSPREVIEW, self.uiId)
  121. end
  122. if not GUI:GetUI("dev/outui/Hook/Panel/KLOnHook/KLOnHookPanel") then
  123. SL.ShowMainPanel()
  124. end
  125. end
  126. return this