local UISyncFourCountryWarRank = UIViewClass() function UISyncFourCountryWarRank:OnOpened(context) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshRankInfo) MDL.Rank.GetRankInfoReq(MDL.Unlock.FunctionType.SyncFourCountryWar) end function UISyncFourCountryWarRank:RefreshRankInfo() local rankInfo = MDL.Rank.GetRankInfoDataByType(MDL.Unlock.FunctionType.SyncFourCountryWar) if #rankInfo == 0 then UIUtils.SetActive(self.group_Empty, true) UIUtils.SetActive(self.loopScroll_SFCWRank, false) else UIUtils.SetActive(self.loopScroll_SFCWRank, true) for i, v in ipairs(rankInfo) do self.loopScroll_SFCWRank:AddData(v, 0) end UIUtils.SetActive(self.group_Empty, false) end local myRankInfo = MDL.Rank.GetMyRankInfo() if myRankInfo.index <= 3 and myRankInfo.index > 0 then self.group_Self.state:SetState(myRankInfo.index - 1) else self.group_Self.state:SetState(3) self.group_Self.lab_Rank.text = MDL.SyncFourCountryWar.GetRankText(myRankInfo.index, myRankInfo.param1) end self:OnCellInit(nil, myRankInfo.index - 1, self.group_Self, myRankInfo) end function UISyncFourCountryWarRank:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UISyncFourCountryWarRank:OnCellInit(scrollRect, index, cellTable, data) if index > 2 then cellTable.lab_Rank.text = MDL.SyncFourCountryWar.GetRankText(index + 1, data.param1) cellTable.state:SetState(3) elseif index >= 0 then cellTable.state:SetState(index) end cellTable.txt_Name.text = data.name CTL.Character.SetPortraitAndFrame(cellTable.hero, data.portraitId, data.frameId) if data.guildSingleInfo.emblemFrame > 0 then CTL.Guild.SetGuildEmblem(cellTable.img_GuildBG, cellTable.txt_Guild, data.guildSingleInfo.emblemFrame, data.guildSingleInfo.emblemContent) cellTable.txt_GuildName.text = data.guildSingleInfo.guildName UIUtils.SetActive(cellTable.group_Guild, true) else UIUtils.SetActive(cellTable.group_Guild, false) cellTable.txt_GuildEmpty.text = "----" end cellTable.lab_Server.text = string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, data.serverId) cellTable.lab_Honor.text = data.param1 end return UISyncFourCountryWarRank