--排行奖励弹窗 local UICommandTheWorldRank = UIViewClass() local LocalSeverTabIndex = 1 --本服排行Tab索引 local BattleAreaTabIndex = 2 --战区排行Tab索引 local private = {} --region 生命周期方法 function UICommandTheWorldRank:OnOpened(context) UIManager.ActiveUIModle(false, "UICommandTheWorldRank") self:RegistSystemEvent(EventID.UI_CommandTheWorld_RefreshRankReward, self.InitData) --刷新 UTL.Item.SetLocalizationImage(self.loc_TitleLoc, self.img_Title, "hltxtc_msz_phjl.png") self.tabParam = context.tabParam self:InitData() end function UICommandTheWorldRank:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UICommandTheWorldRank:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.group_Own.group_Search then --显示提示 UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, {target = self.group_Own.group_Search, posType = LuaConst.DescriptionPanelType.LeftLower, text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_BattlefieldMuster_HonorRewardTips)}) end end function UICommandTheWorldRank:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_RankListNew then --显示排名 if data.index <= 3 then cellTable.group_Rank.UIState:SetState(data.index - 1) else cellTable.group_Rank.UIState:SetState(3) end UIUtils.SetLabel(cellTable.group_Rank.txt_Rank,data.index) UIUtils.SetActive(cellTable.group_Prize.gameObject,false) UIUtils.SetActive(cellTable.group_ServerPrize.gameObject,false) if self.tabParam == LocalSeverTabIndex then--本服 UIUtils.SetActive(cellTable.group_Prize.gameObject,true) if data.param1 < 0 then UIUtils.SetLabel(cellTable.group_Prize.txt_Integral,"--") --积分 UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerName,"") --玩家名字 UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerNameEmpty,tostring(data.name)) --无玩家时的显示 else UIUtils.SetLabel(cellTable.group_Prize.txt_Integral,tostring(data.param1)) --积分 --玩家名字,玩家自己名字变色 if BattleDataGetter.GetAcID() == data.acid then UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerName,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, data.name)) else UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerName,tostring(data.name)) end --无工会时,用另一个组件,因为txt_PlayerNameEmpty 是居中的 if data.guildSingleInfo and data.guildSingleInfo.guildName ~="" then UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerNameEmpty,"") else UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerNameEmpty,tostring(data.name)) UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_PlayerName,"") end end --显示势力信息 if data.guildSingleInfo and data.guildSingleInfo.guildName ~="" then local guildName = data.guildSingleInfo.guildName if MDL.Guild.IsSameGuild(data.guildSingleInfo.guildID) then guildName = UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, guildName) end UIUtils.SetActive(cellTable.group_Prize.group_PlayerName.txt_Name,true) UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_Name,guildName) --显示势力徽记 UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_Guild,data.guildSingleInfo.emblemContent) --有可能刚开始消息还没推过来,所以存在为0的情况 if data.guildSingleInfo.emblemFrame > 0 then UIUtils.SetActive(cellTable.group_Prize.group_PlayerName.img_Guild,true) UTL.Item.SetAtlasSprite(cellTable.group_Prize.group_PlayerName.img_Guild, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.guildSingleInfo.emblemFrame).Image) end else UIUtils.SetActive(cellTable.group_Prize.group_PlayerName.txt_Name,false) UIUtils.SetLabel(cellTable.group_Prize.group_PlayerName.txt_Guild,"") UIUtils.SetActive(cellTable.group_Prize.group_PlayerName.img_Guild,false) end --奖励列表 local rankData = MDL.CommandTheWorld.GetCommandWorldLocalRanking(data.index) if rankData then for i, v in ipairs(rankData.Reward_Table) do if not cellTable.group_Prize.group_PersonalPrize[i] then self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.group_Prize.group_PersonalPrize, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(cellTable.group_Prize.group_PersonalPrize[i], v.RewardID, v.RewardNum) cellTable.group_Prize.group_PersonalPrize[i].gameObject:SetActive(true) end for i = #rankData.Reward_Table + 1, #cellTable.group_Prize.group_PersonalPrize do cellTable.group_Prize.group_PersonalPrize[i].gameObject:SetActive(false) end end else --跨服 UIUtils.SetActive(cellTable.group_ServerPrize.gameObject,true) --玩家名字,玩家自己名字变色 if BattleDataGetter.GetAcID() == data.acid then UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_PlayerName,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Green, data.name)) else UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_PlayerName,tostring(data.name)) end if data.param1< 0 then UIUtils.SetLabel(cellTable.group_ServerPrize.txt_Integral,"--") --积分 else UIUtils.SetLabel(cellTable.group_ServerPrize.txt_Integral,tostring(data.param1)) --积分 end UIUtils.SetActive(cellTable.group_ServerPrize.group_PlayerName.txt_Name,true) if data.param2 == "--" then --预览数据 UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_Name, data.param2) else if MDL.Login.GetServerShowId() == data.param2 then UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_Name, UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue,"S."..tostring(data.param2))) else UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_Name, "S."..tostring(data.param2)) end end UIUtils.SetLabel(cellTable.group_ServerPrize.group_PlayerName.txt_Guild,"") UIUtils.SetActive(cellTable.group_ServerPrize.group_PlayerName.img_Guild,false) local rankData = MDL.CommandTheWorld.GetCommandWorldWarZoneRanking(data.index) if rankData then --荣誉榜奖励 UIUtils.SetActive(cellTable.group_ServerPrize.group_Prize.group_ServerPrize[1].gameObject,false) UIUtils.SetActive(cellTable.group_ServerPrize.group_Prize.group_ServerPrize[2].gameObject,false) for i,v in ipairs(rankData.HonorReward_Table) do UTL.Item.SetItemCell(cellTable.group_ServerPrize.group_Prize.group_ServerPrize[i], v.HonorRewardID, v.HonorRewardNum) UIUtils.SetActive(cellTable.group_ServerPrize.group_Prize.group_ServerPrize[i].gameObject,true) end --个人奖励 for i = 1, 4 do UIUtils.SetActive(cellTable.group_ServerPrize.group_Prize.group_PersonalPrize[i].gameObject,false) end for i,v in ipairs(rankData.RankReward_Table) do if i <=4 then UTL.Item.SetItemCell(cellTable.group_ServerPrize.group_Prize.group_PersonalPrize[i], v.RankRewardID, v.RankRewardNum) UIUtils.SetActive(cellTable.group_ServerPrize.group_Prize.group_PersonalPrize[i].gameObject,true) end end end end end end function UICommandTheWorldRank:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RankListNew then local rankData,group_PersonalPrize,group_ServerPrize if self.tabParam == LocalSeverTabIndex then rankData = MDL.CommandTheWorld.GetCommandWorldLocalRanking(data.index) group_PersonalPrize = cellTable.group_Prize.group_PersonalPrize else rankData = MDL.CommandTheWorld.GetCommandWorldWarZoneRanking(data.index) group_PersonalPrize = cellTable.group_ServerPrize.group_Prize.group_PersonalPrize group_ServerPrize = cellTable.group_ServerPrize.group_Prize.group_ServerPrize --本服奖励 for i, v in ipairs(group_ServerPrize) do if v.event_Click == target then local rewardTable = rankData.HonorReward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].HonorRewardID) return end end end --个人奖励道具点击 for i, v in ipairs(group_PersonalPrize) do if v.event_Click == target then if self.tabParam == LocalSeverTabIndex then local rewardTable = rankData.Reward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].RewardID) else local rewardTable = rankData.RankReward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].RankRewardID) end return end end --点击其他人弹出交互 if data.acid ~= nil and data.acid ~= BattleDataGetter.GetAcID() then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(data.acid) end end end function UICommandTheWorldRank:OnClosed() UIManager.ActiveUIModle(true, "UICommandTheWorldRank") end --endregion function UICommandTheWorldRank:InitData(tabParam) if tabParam then self.tabParam = tabParam end -- 本服排行 local rankFullData if self.tabParam == LocalSeverTabIndex then rankFullData = MDL.CommandTheWorld.GetLocalRankFullData() else --跨服 rankFullData = MDL.CommandTheWorld.GetCrossRankFullData() end --显示排行信息 self:ShowRank(rankFullData.perRankInfo.records) --缓存数据 比对,避免频繁刷新导致的UI显示问题 if not self:CheckNeedRefresh(rankFullData.perRankInfo.myRank) then return end if self.tabParam == LocalSeverTabIndex then self.state_Prize:SetState(0) else --战区排行 self.state_Prize:SetState(1) end --我的排名信息 self:ShowMyRankInfo(rankFullData.perRankInfo.myRank) end --显示排行信息(没有数据时,还要填充预览奖励信息) function UICommandTheWorldRank:ShowRank(records) --构造预览数据 local data = {} if IsServerDataNotNil(records) then for i,v in ipairs(records) do table.insert(data,v) end end local count --奖励数量 if self.tabParam == LocalSeverTabIndex then --本服 count = MDL.CommandTheWorld.GetCommandWorldLocalRankingCount() else --跨服 count = MDL.CommandTheWorld.GetCommandWorldWorldWarZoneRankingCount() end for i=1, count do if i > #data then local showData = {index = i,name = UIUtils.GetLocalizedTxt(Const_IDS.IDS_MultiplayerDungeon_None),param1 = -1,param2 = "--"} table.insert(data,showData) end end self.loop_RankListNew:ReloadAll(data) end --缓存数据 比对,避免频繁刷新导致的UI显示问题 function UICommandTheWorldRank:CheckNeedRefresh(myRank) if self.lastRankIndex == nil then self.lastRankIndex = myRank.index self.lastRankParam1 = myRank.param1 self.lastTabParam = self.tabParam else if self.lastTabParam == self.tabParam and self.lastRankIndex == myRank.index and self.lastRankParam1 == myRank.param1 then return false else self.lastRankIndex = myRank.index self.lastRankParam1 = myRank.param1 self.lastTabParam = self.tabParam end end return true end --显示我的排名信息 function UICommandTheWorldRank:ShowMyRankInfo(myRank) if myRank.index > 0 then --入榜 UIUtils.SetLabel(self.group_Own.lab_MyRanking,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_MyRanking, tostring(myRank.index))) UIUtils.SetLabel(self.group_Own.lab_CurrentPoints,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Prestige,tostring(myRank.param1))) else --未入榜 UIUtils.SetLabelText(self.group_Own.lab_MyRanking,Const_IDS.IDS_Rank_Unranked) local integral = MDL.CommandTheWorld.GetIntegralByType(self.tabParam) if myRank.param1 >= integral then UIUtils.SetLabel(self.group_Own.lab_CurrentPoints,string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Prestige,tostring(myRank.param1))) else UIUtils.SetLabel(self.group_Own.lab_CurrentPoints, string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_RankCondition, tostring(myRank.param1),tostring(MDL.CommandTheWorld.GetIntegralByType(self.tabParam)))) end end end return UICommandTheWorldRank