local UITeamFairChampionshipBase = UIViewClass() function UITeamFairChampionshipBase:OnCreated() self.selectStageId = -1 self.curStageIndex = 1 self.lastSelectStageCell = nil end function UITeamFairChampionshipBase:OnOpened(context) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_RefreshInfo, self.OnMatchInfoRefresh) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TeamFairChampionship, self.RefreshTeamFairChampionshipRp) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_ActiveBaseBG, self.OnActiveBaseBG) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_BattleBet, self.SetGuessingData) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_RefreshMyMatchInfo, self.SetMyMatchRecord) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_RefreshOneStage, self.RefreshStage) self:RegistSystemEvent(EventID.TimerWheelStartTimeOver, self.OnActivityStart) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, self.context:GetTitleIds()) self.context:OnViewOpened() self:InitMatchStages() self:SetMatchTime() self:SetMyMatchRecord() self:RefreshAttendButtonState() self:RefreshTeamFairChampionshipRp() self:RefreshTaskButtonState() UTL.UIRender.AdaptiveImageSizeFit(self.img_Bottom, true) end --活动时间开始 function UITeamFairChampionshipBase:OnActivityStart(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.TeamFairChampionship then self:RefreshAttendButtonState() end end function UITeamFairChampionshipBase:RefreshStage(stageId) self:SetMatchTime() self:RefreshAttendButtonState() self:SetMyMatchRecord() end function UITeamFairChampionshipBase:OnActiveBaseBG(state) UIUtils.SetActive(self.img_Bottom, state) end function UITeamFairChampionshipBase:InitMatchStages() local matchStages = self.context:GetMatchStages() self.selectStageId = self.context:GetCurMatchStage() self.curStageIndex = 1 for index, stageId in ipairs(matchStages) do if self.selectStageId == stageId then self.curStageIndex = index break end end self.loop_Progress:ReloadAll(matchStages) self.loop_Progress:SelectIndex(self.curStageIndex-1) end function UITeamFairChampionshipBase:TryUpdateSelectStage() local curStageID = self.context:GetCurMatchStage() if curStageID ~= self.selectStageId then self:InitMatchStages() end end function UITeamFairChampionshipBase:SetMatchTime() local bigMatchStageTime = self.context:GetBigMatchStageTime() if not string.isNilOrEmpty(bigMatchStageTime) then UIUtils.SetActive(self.group_Time, true) local stageCfg = self.context:GetMatchStageDataCfg(MDL.TeamFairChampionship.GetCurStageID()) UIUtils.SetLabel(self.lab_Time, UIUtils.GetLocalizedTxt(Const_IDS[stageCfg.InterfaceDes]) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroMatch3v3_ActivityTime)) UIUtils.SetLabel(self.txt_Time, bigMatchStageTime) else UIUtils.SetActive(self.group_Time, false) end local filterBetLeftTime = self.context:GetFilterBetLeftTime() if filterBetLeftTime > 0 then self.txt_GuessTime:ResetAndBeginCustomTimer(false, filterBetLeftTime, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairTournament_PickEndTime1), 1) else self.txt_GuessTime:EndTimer() end local leftTime, matchTimeIds = self.context:GetBattleStageDisplayInfo() if leftTime<=0 then UIUtils.SetActive(self.tips_Attend, false) else UIUtils.SetActive(self.tips_Attend, true) self.cdTimer:ResetAndBeginCustomTimer(false, leftTime, 0, string.FormatByIdsId(Const_IDS[matchTimeIds]).."\n{0}:{1}:{2}") end end function UITeamFairChampionshipBase:OnCellInit(scrollRect, index, cellTable, data) local stageCfg = self.context:GetMatchStageDataCfg(data) if self.context:IsInFilterMatchStage(data) then UIUtils.SetLabelText(cellTable.txt_Progress, Const_IDS.IDS_FairTournament_Race1) else UIUtils.SetLabel(cellTable.txt_Progress, string.FormatByIdsId(Const_IDS[stageCfg.InterfaceDes])) end if index+1 == self.curStageIndex then cellTable.btn_Select:SetGray(false, true) elseif index