-- 暴风选关界面排行榜 local UIStormRank = UIViewClass() function UIStormRank:OnOpened(context) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshStormRankInfo) MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.Storm) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_Storm_RankTitle) end function UIStormRank:RefreshStormRankInfo(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) self.loop_MyRankReward:ReloadAll(MDL.Storm.GetRankRewardData(myRankInfo.index)) else self.state_MyRankBg:SetState(3) UIUtils.SetLabelText(self.txt_MyRank, Const_IDS.IDS_Guild_BlankContent) -- 暂无排名 UIUtils.SetLabelText(self.txt_NoRank, Const_IDS.IDS_Guild_BlankContent) end -- 加载排行榜 local rankInfo = MDL.Rank.GetRankInfoDataByType(MDL.Rank.RankType.Storm) local rankCellData = {} if rankInfo then if #rankInfo <= 0 then self.loop_Rank:ClearCells() 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 end end function UIStormRank:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIStormRank:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIStormRank:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_MyRankReward then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end end function UIStormRank: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, CTL.CrossServer.GetServerShowStr(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 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 end else UIUtils.SetActive(v.template_HeroMain.img_HeroHead, false) UIUtils.SetActive(v.template_HeroMain.img_Empty, true) UIUtils.SetActive(v.template_HeroAssistant.img_HeroHead, false) UIUtils.SetActive(v.template_HeroAssistant.img_Empty, true) UIUtils.SetActive(v.template_HeroMain.group_Level, false) UIUtils.SetActive(v.template_HeroAssistant.group_Level, false) end end UIUtils.SetLabel(cellTable.txt_Score, rankInfo.param1) else UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end return UIStormRank