| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- ---@class KLGameAnnouncementPanel:UIKmlLuaPanelBase
- ---@field view KLGameAnnouncementPanelView
- ---@field args GongGaoData
- local KLGameAnnouncementPanel = class(UIKmlLuaPanelBase)
- local this =KLGameAnnouncementPanel
- this.selectTogIndex = 1
- ---创建时调用一次
- function this:Init()
- self:InitData()
- --左侧Tog
- GUI:DataListInitData(self.view.selectGamesTogsDataList, function()
- return table.count(self.args.data)
- end, function(realIndex)
- return self:DataListTogItemGetFunc(realIndex)
- end, function(realIndex, kmlcontrol)
- return self:DataListTogItemInitFunc(realIndex, kmlcontrol)
- end, function(realIndex, kmlcontrol)
- return self:DataListTogItemUpdateFunc(realIndex, kmlcontrol)
- end)
- end
- function this:InitData()
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.btn_close,self,self.OnClickClose)
- GUI:AddOnClickEvent(self.view.btn_iknow,self,self.OnClickClose)
- GUI:AddOnClickEvent(self.view.mask,self,self.OnClickClose)
- end
- function this:OnClickClose()
- GUI:UIPanel_Close("dev/ui/Login/Panel/KLGameAnnouncement_PC/KLGameAnnouncementPanel")
- end
- --region 左侧tog
- function this:DataListTogItemGetFunc(realIndex)
- --local item = GUI:UIPanel_Open("dev/ui/Login/Item/KLSelectGame/KLSelectGameItem",self.view.selectGamesDataList,self,self.data[realIndex+1],true)
- --self.subItems[realIndex+1] = item
- --return item.view.root.kmlControl
- end
- function this:DataListTogItemInitFunc(realIndex,kmlcontrol)
- end
- function this:DataListTogItemUpdateFunc(realIndex,kmlcontrol)
- local togData = self.args.data[realIndex+1]
- local tog = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'tog',kmlcontrol)
- local togTest = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'togTest',kmlcontrol)
- local img_zhanshi = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'img_zhanshi',kmlcontrol)
- GUI:SetToggleOnValueChange(tog,self,function(ui,control,_,data)
- local isToggle = data[1]
- if isToggle then
- this.selectTogIndex = realIndex+1
- GUI:Text_setString(self.view.textInfo,togData.content)
- GUI:Text_setString(self.view.title,togData.title)
- if self.lastTogTest then
- GUI:Text_setTextColor(self.lastTogTest,"#6B83A4")
- end
- if self.lastZhanShi then
- GUI:Image_loadTexture(self.lastZhanShi,"img_b","Atlas/SelectGame.spriteatlas")
- end
- self.lastTogTest =togTest
- self.lastZhanShi = img_zhanshi
- GUI:Text_setTextColor(togTest,realIndex+1== this.selectTogIndex and "#FEFEFE" or "#6B83A4")
- GUI:Image_loadTexture(img_zhanshi,realIndex+1== this.selectTogIndex and "img_b_check" or "img_b","Atlas/SelectGame.spriteatlas")
- end
- end)
- local togTest = GUI:GetChildControl(self.view.selectGamesTogsDataList,realIndex,'togTest',kmlcontrol)
- GUI:Text_setString(togTest,togData.sidebarName)
- if realIndex+1== this.selectTogIndex then
- self.lastTogTest = togTest
- self.lastZhanShi = img_zhanshi
- end
- GUI:Text_setTextColor(togTest,realIndex+1== this.selectTogIndex and "#FEFEFE" or "#6B83A4")
- GUI:Image_loadTexture(img_zhanshi,realIndex+1== this.selectTogIndex and "img_b_check" or "img_b","Atlas/SelectGame.spriteatlas")
- --GUI:Toggle_setIsOn(tog,realIndex+1== this.selectTogIndex)
- if realIndex+1== this.selectTogIndex then
- GUI:Toggle_setIsOn(tog,true)
- end
- end
- --endregion
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- GUI:DataListUpdateData(self.view.selectGamesTogsDataList)
- end
- function this:Close()
- end
- return this
|