KLCrossServerIntroducePanel.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. ---@class KLCrossServerIntroducePanel:UIKmlLuaPanelBase
  2. ---@field view KLCrossServerIntroducePanelView
  3. local KLCrossServerIntroducePanel = class(UIKmlLuaPanelBase)
  4. local this = KLCrossServerIntroducePanel
  5. ---创建时调用一次
  6. function this:Init()
  7. SL.HideMainPanel()
  8. GUI:DataListInitData(self.view.activity_panel_dl,function()
  9. return self:BtnDataListItemCountFunc()
  10. end,function(realIndex)
  11. return self:BtnDataListItemGetFunc(realIndex)
  12. end,function(realIndex, kmlcontrol)
  13. return self:BtnDataListItemInitFunc(realIndex, kmlcontrol)
  14. end, function(realIndex, kmlcontrol)
  15. return self:BtnDataListItemUpdateFunc(realIndex, kmlcontrol)
  16. end)
  17. self.all_item = {}
  18. self.allActivity = {
  19. }
  20. local activity_1 = SL:GetConfig("cfg_global",11004)
  21. local one = SL:Split(activity_1.value, "|")
  22. --SL:LogTable(activity_1,true)
  23. table.insert(self.allActivity,{id=11004,name="跨服系统",data=one})
  24. local activity_2 = SL:GetConfig("cfg_global",11005)
  25. local two = SL:Split(activity_2.value, "|")
  26. --SL:LogTable(activity_2,true)
  27. table.insert(self.allActivity,{id=11005,name="诸神降临",data=two})
  28. end
  29. ---创建或者刷新界面数据时调用
  30. function this:Refresh()
  31. self.select_id = self.allActivity[1].id
  32. GUI:DataListUpdateData(self.view.activity_panel_dl)
  33. self:SelectActicity()
  34. end
  35. ---注册UI事件和服务器消息
  36. function this:RegistEvents()
  37. GUI:AddOnClickEvent(self.view.btn_close,self,self.CloseOnclick)
  38. --SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PRIVILEGE_BOSS_PANEL,self.RES_PRIVILEGE_BOSS_PANEL,self)
  39. end
  40. function this:CloseOnclick()
  41. GUI:UIPanel_Close("dev/outui/CrossServer/Panel/KLCrossServerIntroduce/KLCrossServerIntroducePanel")
  42. end
  43. function this:BtnDataListItemCountFunc()
  44. return #self.allActivity
  45. end
  46. function this:BtnDataListItemGetFunc(realIndex)
  47. local index = realIndex + 1
  48. local data = self.allActivity[index]
  49. local item = GUI:UIPanel_Open("dev/outui/CrossServer/Item/KLUCrossServerMainBtnItem/KLUCrossServerMainBtnItem",self.view.activity_panel_dl,self,nil,true)
  50. self.all_item[index] = item
  51. self.all_item[index]:RefreshItem(data,self.select_id,self)
  52. if data.id == self.select_id then
  53. self.LevelBtn = self.all_item[index]
  54. end
  55. return item.view.root
  56. end
  57. function this:BtnDataListItemInitFunc(realIndex, kmlcontrol)
  58. end
  59. function this:BtnDataListItemUpdateFunc(realIndex, kmlcontrol)
  60. local index = realIndex + 1
  61. local data = self.allActivity[index]
  62. self.all_item[index]:RefreshItem(data,self.select_id,self)
  63. if data.id == self.select_id then
  64. self.LevelBtn = self.all_item[index]
  65. end
  66. end
  67. function this:HideSelect()
  68. if self.LevelBtn then
  69. self.LevelBtn:HideItem()
  70. end
  71. end
  72. function this:Select(id,Btn)
  73. self.LevelBtn = Btn
  74. self.select_id = id
  75. self:SelectActicity()
  76. end
  77. function this:SelectActicity()
  78. local one
  79. for i=1,#self.allActivity,1 do
  80. if self.allActivity[i].id == self.select_id then
  81. one = self.allActivity[i]
  82. end
  83. end
  84. if one then
  85. if one.data[1] then
  86. local title_and_con = string.split(one.data[1],'&')
  87. GUI:setVisible(self.view.text1_title,true)
  88. GUI:setVisible(self.view.text1,true)
  89. GUI:setVisible(self.view.text1_space,true)
  90. GUI:Text_setString(self.view.text1_title,title_and_con[1])
  91. GUI:Text_setString(self.view.text1,title_and_con[2])
  92. else
  93. GUI:setVisible(self.view.text1_title,false)
  94. GUI:setVisible(self.view.text1,false)
  95. GUI:setVisible(self.view.text1_space,false)
  96. end
  97. if one.data[2] then
  98. local title_and_con = string.split(one.data[2],'&')
  99. GUI:setVisible(self.view.text2_title,true)
  100. GUI:setVisible(self.view.text2,true)
  101. GUI:setVisible(self.view.text2_space,true)
  102. GUI:Text_setString(self.view.text2_title,title_and_con[1])
  103. GUI:Text_setString(self.view.text2,title_and_con[2])
  104. else
  105. GUI:setVisible(self.view.text2_title,false)
  106. GUI:setVisible(self.view.text2,false)
  107. GUI:setVisible(self.view.text2_space,false)
  108. end
  109. if one.data[3] then
  110. local title_and_con = string.split(one.data[3],'&')
  111. GUI:setVisible(self.view.text3_title,true)
  112. GUI:setVisible(self.view.text3,true)
  113. GUI:setVisible(self.view.text3_space,true)
  114. GUI:Text_setString(self.view.text3_title,title_and_con[1])
  115. GUI:Text_setString(self.view.text3,title_and_con[2])
  116. else
  117. GUI:setVisible(self.view.text3_title,false)
  118. GUI:setVisible(self.view.text3,false)
  119. GUI:setVisible(self.view.text3_space,false)
  120. end
  121. end
  122. end
  123. function this:Close()
  124. end
  125. return this