local UIDemonGodRank = UIViewClass() function UIDemonGodRank:OnOpened(context) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshDemonGodRankUI) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_DemonGod_UI_5) self.btn_state:SetState(1) --self:RefreshDemonGodRankUI() end function UIDemonGodRank:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Previous then -- 上期排行 MDL.DemonGod.IsRefreshCurRankList = false MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.DemonGod, {isPreRank = true}, CTL.Rank.SortType.MyServer) self.btn_state:SetState(0) elseif comp == self.btn_Currently then -- 本期排行 MDL.DemonGod.IsRefreshCurRankList = true MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.DemonGod, {isPreRank = false}, CTL.Rank.SortType.MyServer) self.btn_state:SetState(1) end end function UIDemonGodRank:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIDemonGodRank:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Rank then cellTable.state_BgSwitch:SetState(index % 2) local rankInfo = data.data -- 设置排名 if rankInfo.index == nil or rankInfo.index <= 0 then UIUtils.SetLabelText(cellTable.txt_Others, Const_IDS.IDS_Rank_Unranked) cellTable.state_Rank:SetState(3) else UIUtils.SetLabel(cellTable.txt_Others, rankInfo.index) cellTable.state_Rank:SetState(rankInfo.index <= 3 and rankInfo.index - 1 or 3) end UIUtils.SetLabel(cellTable.txt_PlayerName, rankInfo.name) UIUtils.SetLabel(cellTable.txt_ServerID, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rank_ServerIDS), rankInfo.serverId)) local heroList = string.split(rankInfo.extraParam, ",") for k,v in ipairs(cellTable.group_Team) do if heroList and #heroList > 0 and (#heroList > 1 and heroList[1] ~= "") then local key1, key2 = 1, 2 if k == 2 then key1, key2 = 3, 4 elseif k == 3 then key1, key2 = 5, 6 end UIUtils.SetActive(v.template_HeroMain.img_HeroHead, tonumber(heroList[key1]) > 0) UIUtils.SetActive(v.template_HeroMain.img_Empty, tonumber(heroList[key1]) <= 0) UIUtils.SetActive(v.template_HeroAssistant.img_HeroHead, tonumber(heroList[key2]) > 0) UIUtils.SetActive(v.template_HeroAssistant.img_Empty, tonumber(heroList[key2]) <= 0) UIUtils.SetActive(v.template_HeroMain.group_Level, false) UIUtils.SetActive(v.template_HeroAssistant.group_Level, false) if heroList[key1] or heroList[key2] then UIUtils.SetActive(v.gameObject, true) if heroList[key1] and tonumber(heroList[key1]) > 0 then UTL.Item.SetHeroIconByHeroId(v.template_HeroMain.img_HeroHead, tonumber(heroList[key1])) end if heroList[key2] and tonumber(heroList[key2]) > 0 then UTL.Item.SetHeroIconByHeroId(v.template_HeroAssistant.img_HeroHead, tonumber(heroList[key2])) end else UIUtils.SetActive(v.gameObject, false) end else UIUtils.SetActive(v.gameObject, false) end end UIUtils.SetLabel(cellTable.txt_Score, rankInfo.param1) else UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end function UIDemonGodRank:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_MyRankReward then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end function UIDemonGodRank:RefreshDemonGodRankUI(rankType, subData) -- 自己的信息 local myRankInfo = MDL.Rank.GetMyRankInfo() if myRankInfo.index > 0 then self.state_MyRankBg:SetState(myRankInfo.index <= 3 and myRankInfo.index - 1 or 3) UIUtils.SetLabel(self.txt_MyRank, myRankInfo.index) else self.state_MyRankBg:SetState(3) UIUtils.SetLabelText(self.txt_MyRank, Const_IDS.IDS_Guild_BlankContent) -- 暂无排名 end UIUtils.SetLabelText(self.txt_NoRank, Const_IDS.IDS_Guild_BlankContent) -- 暂无排名 local isClearRewardCell = true if CTL.WarZone.IsWarZoneOpen() then for i, v in DataSheetManager.DemonGodBossRankRewardCS:GetEnumerator() do if v.ID == 1 then if myRankInfo.index == v.Rank then local warZoneStartTime = MDL.WarZone.GetTimeInfo().startTime if not MDL.DemonGod.IsRefreshCurRankList and warZoneStartTime > 0 and UTL.Time.GetServerTimestamp() < warZoneStartTime + UTL.Time.TotalSecondsOneDay then self:MyRankReward(DataSheetManager.DemonGodBossRankReward:GetDataByID(1).RankRewardID) else self:MyRankReward(v.RankRewardID) end isClearRewardCell = false end else local lastData = DataSheetManager.DemonGodBossRankRewardCS:GetDataByID(v.ID - 1) if myRankInfo.index > lastData.Rank and myRankInfo.index <= v.Rank then self:MyRankReward(v.RankRewardID) isClearRewardCell = false end end end else for i, v in DataSheetManager.DemonGodBossRankReward:GetEnumerator() do if v.ID == 1 then if myRankInfo.index == v.Rank then self:MyRankReward(v.RankRewardID) isClearRewardCell = false end else local lastData = DataSheetManager.DemonGodBossRankReward:GetDataByID(v.ID - 1) if myRankInfo.index > lastData.Rank and myRankInfo.index <= v.Rank then self:MyRankReward(v.RankRewardID) isClearRewardCell = false end end end end if isClearRewardCell then self.loop_MyRankReward:ClearCells() end local rankInfo = MDL.Rank.GetRankInfoDataByType(MDL.Rank.RankType.DemonGod) local rankCellData = {} if rankInfo then if #rankInfo <= 0 then self.loop_Rank:ClearCells() if not MDL.DemonGod.IsRefreshCurRankList then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_3) end UIUtils.SetActive(self.obj_Rank.gameObject, true) UIUtils.SetLabelText(self.labLocal_Empty, Const_IDS.IDS_Ranking_NoPlayer) else UIUtils.SetActive(self.obj_Rank.gameObject, false) for i, v in ipairs(rankInfo) do table.insert(rankCellData, {data = v, type = rankType}) end self.loop_Rank:ReloadAll(rankCellData) end else if not MDL.DemonGod.IsRefreshCurRankList then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_3) end CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_3) end end function UIDemonGodRank:MyRankReward(rankRewardID) local reward = DataSheetManager.DemonGodBossReward:GetDataByID(rankRewardID) if reward then UIUtils.SetLabel(self.txt_NoRank, "") self.loop_MyRankReward:ReloadAll(reward.Item_Table) end end return UIDemonGodRank