local UIFairSoloTournamentCourse = UIViewClass() local CourseStageTab = { MDL.FairSoloTournament.ConfigStage.Group_1, MDL.FairSoloTournament.ConfigStage.Group_2, MDL.FairSoloTournament.ConfigStage.Finals_128T64, MDL.FairSoloTournament.ConfigStage.Finals_64T32, MDL.FairSoloTournament.ConfigStage.Finals_32T16, MDL.FairSoloTournament.ConfigStage.Finals_16T8, MDL.FairSoloTournament.ConfigStage.Finals_8T4, MDL.FairSoloTournament.ConfigStage.Finals_4T2, MDL.FairSoloTournament.ConfigStage.Finals_2T1, } function UIFairSoloTournamentCourse:OnOpened() self:RegistSystemEvent(EventID.UI_FairSoloTournament_OnSeasonEnd, self.OnBackButtonPressed) --这里在 GetZeroTimestamp 内补偿时区是因为防止 os.time 产生跨天问题,默认改成服务器时间,这个 startDayZeroTimestamp 只用来计算天数。 self.startDayZeroTimestamp = UTL.Time.GetServerZeroTimestampByTimestamp(MDL.FairSoloTournament.GetModuleInfo().startTm) for i, v in ipairs(CourseStageTab) do self.loop_CourseList:AddData(v, 0) end end function UIFairSoloTournamentCourse:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIFairSoloTournamentCourse:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UIFairSoloTournamentCourse:OnCellInit(scrollRect, index, cellTable, data) if index % 2 == 0 then UIUtils.SetActive(cellTable.img_01, true) UIUtils.SetActive(cellTable.img_02, false) else UIUtils.SetActive(cellTable.img_01, false) UIUtils.SetActive(cellTable.img_02, true) end local stageCfg = DataSheetManager.FairMatchStage:GetDataByID(data) local colorStr if data == MDL.FairSoloTournament.ConfigStage.Group_1 or data == MDL.FairSoloTournament.ConfigStage.Group_2 then colorStr = "ffffff" elseif data > MDL.FairSoloTournament.ConfigStage.Finals_8T4 then colorStr = "ff4b4b" else colorStr = "eea11a" end cellTable.txt_Date.text = self:GetTimeShow(stageCfg, colorStr) self:FormatCondition(cellTable.txt_Rule, data, colorStr) self:FormatDesc(cellTable.txt_Course, stageCfg, colorStr) end function UIFairSoloTournamentCourse:FormatDesc(txt, cfg, colorStr) local stage = cfg.ID if stage == MDL.FairSoloTournament.ConfigStage.Group_1 or stage == MDL.FairSoloTournament.ConfigStage.Group_2 then UIUtils.SetLabel(txt, UTL.Color.FormatTextByColor(colorStr, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairTournament_Race1))) elseif stage > MDL.FairSoloTournament.ConfigStage.Finals_8T4 then --晋级赛 UIUtils.SetLabel(txt, UTL.Color.FormatTextByColor(colorStr, string.format("%s-%s", UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairTournament_Race2), UIUtils.GetLocalizedTxt(Const_IDS[cfg.InterfaceDes])))) else --决赛 UIUtils.SetLabel(txt, UTL.Color.FormatTextByColor(colorStr, string.format("%s-%s", UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairTournament_Race3), UIUtils.GetLocalizedTxt(Const_IDS[cfg.InterfaceDes])))) end end function UIFairSoloTournamentCourse:GetTimeShow(cfg, colorStr) local stage = cfg.NowStage local sumDay = -1 for k, v in DataSheetManager.FairMatchTime:GetEnumerator() do if v.ID <= stage then sumDay = sumDay + v.Day end end --有几个赛事需要总天数减1天,跟服务器约定目前都是写死 if cfg.ID == MDL.FairSoloTournament.ConfigStage.Group_1 or cfg.ID == MDL.FairSoloTournament.ConfigStage.Finals_128T64 or cfg.ID == MDL.FairSoloTournament.ConfigStage.Finals_64T32 then sumDay = sumDay - 1 end local targetTimestamp = self.startDayZeroTimestamp + sumDay * UTL.Time.TotalSecondsOneDay + DataSheetManager.TimeRefresh:GetDataByID(cfg.RaceStartTime).HMS local date = UTL.Time.OsDateOriginal("*t", targetTimestamp) local monthDayStr = UTL.String.FormatMonthDay(date.month, date.day) if GameAppInfo.IsVietnamPackage() then return UTL.Color.FormatTextByColor(colorStr, os.date(UTL.Time.FormatDateEnum.HMS, targetTimestamp) .. " " .. monthDayStr) else return UTL.Color.FormatTextByColor(colorStr, monthDayStr .. " " .. os.date(UTL.Time.FormatDateEnum.HMS, targetTimestamp)) end end function UIFairSoloTournamentCourse:FormatCondition(txt, stage, colorStr) if stage <= MDL.FairSoloTournament.ConfigStage.Group_2 then -- 小组赛 local _, count = CTL.FairSoloTournament.GetGroupPlayerCount() UIUtils.SetLabel(txt, UTL.Color.FormatTextByColor(colorStr, string.FormatByIdsId(Const_IDS.IDS_FairTournament_UpCondition, count))) elseif stage >= MDL.FairSoloTournament.ConfigStage.Finals_2T1 then UIUtils.SetLabel(txt, UTL.Color.FormatTextByColor(colorStr, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairTournament_UpCondition2))) end end return UIFairSoloTournamentCourse