local UIFightThroneBattleRank = UIViewClass() local RankType = { GuildRank = 0, PlayerRank = 1, } function UIFightThroneBattleRank:OnOpened(context) self.curRankType = 0 self.rankDataList = {} self:RegistSystemEvent(EventID.FightThrone_RankRefresh, self.OnRankRefresh) self:OnValueChanged(self.group_Tab, 0) end function UIFightThroneBattleRank:OnValueChanged(comp, value) if comp == self.group_Tab then if value == RankType.GuildRank then self.tab_state:SetState(0) self.curRankType = RankType.GuildRank self:OnRankRefresh() elseif value == RankType.PlayerRank then self.tab_state:SetState(1) self.curRankType = RankType.PlayerRank self:OnRankRefresh() end end end function UIFightThroneBattleRank:OnCellInit(scrollRect, index, cellTable, data) cellTable.obj_bgState:SetState(index % 2) if data.index <= 3 then cellTable.section_Rank:SetState(data.index - 1) else cellTable.section_Rank:SetState(3) cellTable.txt_Rank.text = data.index end if data.id == MDL.FightThrone.GetMyGuildDmg().id or data.acid == BattleDataGetter.GetAcID() then if data.serId and data.serId > 0 then UIUtils.SetLabel(cellTable.txt_Name, UTL.Color.FormatGreenColor(data.name) .. string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], data.serId)) else UIUtils.SetLabel(cellTable.txt_Name, UTL.Color.FormatGreenColor(data.name)) end else if data.serId and data.serId > 0 then UIUtils.SetLabel(cellTable.txt_Name, data.name .. string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], data.serId)) else UIUtils.SetLabel(cellTable.txt_Name, data.name) end end UIUtils.SetLabel(cellTable.txt_Score, UTL.String.GetCountStr(data.damage)) end function UIFightThroneBattleRank:OnRankRefresh() if self.curRankType == RankType.GuildRank then if MDL.FightThrone.FightThroneGuildRankIsEmpty() then self:ShowRankEmpty() else self:ShowRank() end elseif self.curRankType == RankType.PlayerRank then if MDL.FightThrone.FightThronePlayerRankIsEmpty() then self:ShowRankEmpty() else self:ShowRank() end end end function UIFightThroneBattleRank:ShowRankEmpty() UIUtils.SetActive(self.section_Empty, true) UIUtils.SetActive(self.group_Mine, false) self.LoopScroll_GuildBossBattleRankDamage:ClearCells() UIUtils.SetLabelText(self.lab_Empty, Const_IDS[self.curRankType == RankType.GuildRank and "IDS_GuildBoss_RankingNoGuild" or "IDS_GuildBoss_RankingNoPlayer"]) end function UIFightThroneBattleRank:ShowRank() UIUtils.SetActive(self.section_Empty, false) table.clearArray(self.rankDataList) if self.curRankType == RankType.GuildRank then local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossGuildRankShow").IntValue self:SetSelfInfo(MDL.FightThrone.GetMyGuildDmg(), maxCount) for i, v in MDL.FightThrone.GetFightThroneGuildRankIterator() do if i > maxCount then break end table.insert(self.rankDataList, v) end else local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossPlayerRankShow").IntValue self:SetSelfInfo(MDL.FightThrone.GetMyDmg(), maxCount) for i, v in MDL.FightThrone.GetFightThronePlayerRankIterator() do if i > maxCount then break end table.insert(self.rankDataList, v) end end self.LoopScroll_GuildBossBattleRankDamage:ReloadAll(self.rankDataList) end function UIFightThroneBattleRank:SetSelfInfo(data, maxIndex) if data == nil or data.damage <= 0 then UIUtils.SetActive(self.group_Mine, false) return end UIUtils.SetActive(self.group_Mine, true) if data.index > 0 and data.index <= 3 then self.section_Rank:SetState(data.index - 1) else if data.index > maxIndex then self.section_Rank:SetState(4) else self.section_Rank:SetState(3) self.txt_Rank.text = data.index end end UIUtils.SetLabel(self.txt_Name, UTL.Color.FormatGreenColor(data.name)) UIUtils.SetLabel(self.txt_Score, UTL.String.GetCountStr(data.damage)) end return UIFightThroneBattleRank