local UIFairSoloTournamentList = UIViewClass() local function SortBySyncSoloPoint(acid_1, acid_2) local point_1 = MDL.FairSoloTournament.GetPlayerSyncSoloPoint(acid_1) local point_2 = MDL.FairSoloTournament.GetPlayerSyncSoloPoint(acid_2) return point_1 > point_2 end function UIFairSoloTournamentList:OnOpened(context) local _, count = CTL.FairSoloTournament.GetGroupPlayerCount() self.lab_Detail.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_WinTip, count) self:RegistSystemEvent(EventID.UI_FairSoloTournament_RefreshPlayerInfo, self.LoadPlayerData) self:RegistSystemEvent(EventID.UI_FairSoloTournament_OnSeasonEnd, self.OnBackButtonPressed) -- 赛程结束关闭界面 self.infoList = {} local moduleInfo = MDL.FairSoloTournament.GetModuleInfo() for i = 1, moduleInfo.groupNum do self.loop_FTJoinTab:AddData(i, 0) end local groupId = MDL.FairSoloTournament.GetGroupCompetitionId() if groupId > 0 then UIUtils.SetActive(self.btn_GroupNow, true) self.txt_Now.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_PlayerGroup, groupId) self.loop_FTJoinTab:SelectIndex(groupId - 1, true) else UIUtils.SetActive(self.group_Mine.gameObject, false) UIUtils.SetActive(self.btn_GroupNow, false) self.loop_FTJoinTab:SelectIndex(0, true) end end function UIFairSoloTournamentList:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_FTJoinTab then local title = string.FormatByIdsId(Const_IDS.IDS_FairTournament_Group, data) cellTable.txt_Name_Nomal.text = title cellTable.txt_Name_Selected.text = title else if index % 2 == 0 then UIUtils.SetActive(cellTable.img_Odd, true) UIUtils.SetActive(cellTable.img_Even, false) else UIUtils.SetActive(cellTable.img_Odd, false) UIUtils.SetActive(cellTable.img_Even, true) end self:SetPlayerInfo(cellTable, data) end end function UIFairSoloTournamentList:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_FTJoinTab then self.selectGroup = data self:LoadPlayerData() end end function UIFairSoloTournamentList:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIFairSoloTournamentList:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_GroupNow then if MDL.FairSoloTournament.GetGroupCompetitionId() > 0 then self.loop_FTJoinTab:SelectIndex(MDL.FairSoloTournament.GetGroupCompetitionId() - 1, true) end elseif comp == self.group_ScoreInfo then UIUtils.SetActive(self.group_ScoreInfo, false) elseif comp == self.btn_Info then UIUtils.SetActive(self.group_ScoreInfo, true) end end function UIFairSoloTournamentList:LoadPlayerData() local groupId = self.selectGroup table.clearArray(self.infoList) if MDL.FairSoloTournament.TryGetAllPlayerInfo(MDL.FairSoloTournament.ConfigStage.Group_1, groupId) == false then local stageInfo = MDL.FairSoloTournament.GetStageInfo(MDL.FairSoloTournament.ConfigStage.Group_1) local hasMyData = false for _, groupInfo in ipairs(stageInfo.groupInfos) do if (CTL.FairSoloTournament.ParseGroupID(groupInfo.groupId) == groupId) then for _, playerInfo in ipairs(groupInfo.playerInfos) do if string.isNilOrEmpty(playerInfo.acid) == false then table.insert(self.infoList, playerInfo.acid) if hasMyData == false and playerInfo.acid == BattleDataGetter.GetAcID() then hasMyData = true end end end end end if #self.infoList > 0 then table.sort(self.infoList, SortBySyncSoloPoint) self.loop_FPPlayerJoinList:ReloadAll(self.infoList) else self.loop_FPPlayerJoinList:ClearCells() end UIUtils.SetActive(self.group_Mine.gameObject, hasMyData) if hasMyData then self:SetPlayerInfo(self.group_Mine, BattleDataGetter.GetAcID()) end end end function UIFairSoloTournamentList:SetPlayerInfo(comp, acid) local showInfo = MDL.FairSoloTournament.GetPlayerShowInfo(acid) if showInfo then UIUtils.SetLabel(comp.txt_Name, showInfo.name .. ".S" .. showInfo.ShowServerId) comp.txt_Point.text = MDL.FairSoloTournament.GetPlayerSyncSoloPoint(acid) if string.isNilOrEmpty(showInfo.guildName) then UIUtils.SetActive(comp.group_Guild, false) else UIUtils.SetActive(comp.group_Guild, true) CTL.Guild.SetGuildEmblem(comp.img_GuildBG, comp.txt_Guild, showInfo.EmblemFrame, showInfo.EmblemContent) UIUtils.SetLabel(comp.txt_GuildName, showInfo.guildName) end end end return UIFairSoloTournamentList