KLGameAnnouncementPanel.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ---@class KLGameAnnouncementPanel:UIKmlLuaPanelBase
  2. ---@field view KLGameAnnouncementPanelView
  3. ---@field args GongGaoData
  4. local KLGameAnnouncementPanel = class(UIKmlLuaPanelBase)
  5. local this =KLGameAnnouncementPanel
  6. this.selectTogIndex = 1
  7. ---创建时调用一次
  8. function this:Init()
  9. self:InitData()
  10. --左侧Tog
  11. GUI:DataListInitData(self.view.selectGamesTogsDataList, function()
  12. return table.count(self.args.data)
  13. end, function(realIndex)
  14. return self:DataListTogItemGetFunc(realIndex)
  15. end, function(realIndex, kmlcontrol)
  16. return self:DataListTogItemInitFunc(realIndex, kmlcontrol)
  17. end, function(realIndex, kmlcontrol)
  18. return self:DataListTogItemUpdateFunc(realIndex, kmlcontrol)
  19. end)
  20. end
  21. function this:InitData()
  22. end
  23. ---注册UI事件和服务器消息
  24. function this:RegistEvents()
  25. GUI:AddOnClickEvent(self.view.btn_close,self,self.OnClickClose)
  26. GUI:AddOnClickEvent(self.view.btn_iknow,self,self.OnClickClose)
  27. GUI:AddOnClickEvent(self.view.mask,self,self.OnClickClose)
  28. end
  29. function this:OnClickClose()
  30. GUI:UIPanel_Close("dev/ui/Login/Panel/KLGameAnnouncement_PC/KLGameAnnouncementPanel")
  31. end
  32. --region 左侧tog
  33. function this:DataListTogItemGetFunc(realIndex)
  34. --local item = GUI:UIPanel_Open("dev/ui/Login/Item/KLSelectGame/KLSelectGameItem",self.view.selectGamesDataList,self,self.data[realIndex+1],true)
  35. --self.subItems[realIndex+1] = item
  36. --return item.view.root.kmlControl
  37. end
  38. function this:DataListTogItemInitFunc(realIndex,kmlcontrol)
  39. end
  40. function this:DataListTogItemUpdateFunc(realIndex,kmlcontrol)
  41. local togData = self.args.data[realIndex+1]
  42. local tog = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'tog',kmlcontrol)
  43. local togTest = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'togTest',kmlcontrol)
  44. local img_zhanshi = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'img_zhanshi',kmlcontrol)
  45. GUI:SetToggleOnValueChange(tog,self,function(ui,control,_,data)
  46. local isToggle = data[1]
  47. if isToggle then
  48. this.selectTogIndex = realIndex+1
  49. GUI:Text_setString(self.view.textInfo,togData.content)
  50. GUI:Text_setString(self.view.title,togData.title)
  51. if self.lastTogTest then
  52. GUI:Text_setTextColor(self.lastTogTest,"#6B83A4")
  53. end
  54. if self.lastZhanShi then
  55. GUI:Image_loadTexture(self.lastZhanShi,"img_b","Atlas/SelectGame.spriteatlas")
  56. end
  57. self.lastTogTest =togTest
  58. self.lastZhanShi = img_zhanshi
  59. GUI:Text_setTextColor(togTest,realIndex+1== this.selectTogIndex and "#FEFEFE" or "#6B83A4")
  60. GUI:Image_loadTexture(img_zhanshi,realIndex+1== this.selectTogIndex and "img_b_check" or "img_b","Atlas/SelectGame.spriteatlas")
  61. end
  62. end)
  63. local togTest = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'togTest',kmlcontrol)
  64. GUI:Text_setString(togTest,togData.sidebarName)
  65. if realIndex+1== this.selectTogIndex then
  66. self.lastTogTest = togTest
  67. self.lastZhanShi = img_zhanshi
  68. end
  69. GUI:Text_setTextColor(togTest,realIndex+1== this.selectTogIndex and "#FEFEFE" or "#6B83A4")
  70. GUI:Image_loadTexture(img_zhanshi,realIndex+1== this.selectTogIndex and "img_b_check" or "img_b","Atlas/SelectGame.spriteatlas")
  71. --GUI:Toggle_setIsOn(tog,realIndex+1== this.selectTogIndex)
  72. if realIndex+1== this.selectTogIndex then
  73. GUI:Toggle_setIsOn(tog,true)
  74. end
  75. end
  76. --endregion
  77. ---创建或者刷新界面数据时调用
  78. function this:Refresh()
  79. GUI:DataListUpdateData(self.view.selectGamesTogsDataList)
  80. end
  81. function this:Close()
  82. end
  83. return this