local UIGuildEscortReport = UIViewClass() local TabType = { GuildReward = 1, TransportReward = 2, CutOutReward = 3, } local TabTypeIds = { [TabType.GuildReward] = Const_IDS.IDS_Escort_GuildData, [TabType.TransportReward] = Const_IDS.IDS_Escort_EscortData, [TabType.CutOutReward] = Const_IDS.IDS_Escort_RobData, } local FilterType = { Personal = 1, All = 2, } local FilterTypeIds = { [FilterType.Personal] = Const_IDS.IDS_Escort_OnlyMyself, [FilterType.All] = Const_IDS.IDS_Escort_AllGuild, } -------------------- function UIGuildEscortReport:OnOpened(context) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshGuild) self:RegistSystemEvent(EventID.GuildEscort_RefreshReport, self.RefreshReport) self.curTabType = 0 self.curFilterType = FilterType.All -- 默认选中个人页签 self.switchDetailOpen = false self.guildRankIsWarZone = false CTL.GuildEscort.ShowMainNotice(false) self:InitInitPanel() end function UIGuildEscortReport:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildEscortReport:OnButtonClicked(comp) if self.btn_Close == comp then self:CloseView(true) elseif self.btn_Switch == comp then self:SwitchDetailShow(not self.switchDetailOpen) else for i = 1, #self.group_CheckBtns do local item = self.group_CheckBtns[i] if item.btn_Button == comp then self.curFilterType = i self:SwitchDetailShow(false) self:RefreshReport() break end end end end function UIGuildEscortReport:OnValueChanged(comp, value) if self.group_Toggle == comp then -- 重置上次选中的toggle颜色 for i = 1, self.group_Toggle.Count do self.group_Toggle:GetToggleComponent(i, "state_Color"):SetState(0) end self.curTabType = value + 1 -- c#从0开始 self.group_Toggle:GetToggleComponent(self.curTabType, "state_Color"):SetState(1) if TabType.GuildReward == self.curTabType then CTL.Rank.TryGetRankInfo(MDL.Rank.RankType.GuildEscort, nil, CTL.Rank.GetRankSort(MDL.Rank.RankType.GuildEscort)) self.State:SetState(1) -- 切换页签 elseif TabType.TransportReward == self.curTabType then self.curFilterType = FilterType.All -- 默认选中个人页签 self.State:SetState(0) MDL.GuildEscort.GetEscortBattleLogRequest(MDL.GuildEscort.EscortType.Transport) elseif TabType.CutOutReward == self.curTabType then self.curFilterType = FilterType.All -- 默认选中个人页签 self.State:SetState(0) MDL.GuildEscort.GetEscortBattleLogRequest(MDL.GuildEscort.EscortType.CutOut) end self:SwitchDetailShow(false) end end function UIGuildEscortReport:OnCellInit(scrollRect, index, cellTable, data) if self.loop_GuildData == scrollRect then -- 设置排名 self:SetGuildRank(cellTable, data.index) -- 设置公会相关 UIUtils.SetLabel(cellTable.txt_GuildName, data.guildName) self:SetGuildEmblem(cellTable, data.emblemContent, data.emblemFrame) -- 设置主公 UIUtils.SetLabel(cellTable.txt_PlayerName, data.guildLeaderName) -- 设置积分 UIUtils.SetLabel(cellTable.txt_Score, tostring(data.param1)) -- 设置区服 self:SetGuildServerID(cellTable, data.ServerId) -- 按照单双号设置背景 if index % 2 == 1 then cellTable.state_Bg:SetState(1) else cellTable.state_Bg:SetState(0) end elseif self.Loop_Info == scrollRect then if data.info then -- 有这个字段表示是简洁cell self:SetConciseReport(cellTable, data.info) else -- 否则是详细cell self:SetDetailReport(cellTable, data) end end end function UIGuildEscortReport:OnCellClicked(scrollRect, index, cellTable, target, data) if self.Loop_Info == scrollRect then if data.info then -- 有这个字段表示是简洁cell if cellTable.rect == target then if data.isOpen then data.isOpen = false cellTable.obj_arrowState:SetState(1) self.Loop_Info:RemoveIndex(index + 1) else data.isOpen = true cellTable.obj_arrowState:SetState(0) self.Loop_Info:InsertData(index + 1, data.info, 1) end end else -- 点击奖励 local content = cellTable.content for i = 1, #content do local item = content[i] if item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.rewards[i].ItemId) return end end -- 点击玩家头像(我方) self:ClickTeamHead(cellTable.obj_selfTeam, data.escortInfo.headers, target) -- 点击玩家头像(敌方) self:ClickTeamHead(cellTable.obj_otherTeam, data.escortOptInfo.headers, target) end end end -------------------- function UIGuildEscortReport:InitInitPanel() -- 设置顶层列表 UTL.Toggle.InitToggleGroupByIDS(self.group_Toggle, "txtName", TabTypeIds) self.group_Toggle:SelectIndex(0) end function UIGuildEscortReport:RefreshGuild(rankType, subData) self.guildRankIsWarZone = CTL.Rank.GetRankSort(MDL.Rank.RankType.GuildEscort) == CTL.Rank.SortType.WarZone UIUtils.SetActive(self.obj_ServerID, self.guildRankIsWarZone) UIUtils.SetActive(self.Line4, self.guildRankIsWarZone) if rankType ~= MDL.Rank.RankType.GuildEscort then return end -- 势力榜_势力运镖 local rankInfo = MDL.Rank.GetRankInfoDataByType(rankType, subData) if not rankInfo then return end -- 设置自身公会信息 self:SetSelfGuildInfo() -- 排行榜信息 UIUtils.SetActive(self.obj_GuildEmpty.gameObject, #rankInfo <= 0) self.loop_GuildData:ReloadAll(rankInfo) end function UIGuildEscortReport:RefreshReport() self.Loop_Info:ClearCells() local isPersonal = self.curFilterType == FilterType.Personal local isEmpty = true if self.curTabType == TabType.TransportReward then for _, v in MDL.GuildEscort.GetEscortLogsIterator(MDL.GuildEscort.EscortType.Transport, isPersonal) do self.Loop_Info:AddData({info = v, isOpen = false}, 0) isEmpty = false end elseif self.curTabType == TabType.CutOutReward then for _, v in MDL.GuildEscort.GetEscortLogsIterator(MDL.GuildEscort.EscortType.CutOut, isPersonal) do self.Loop_Info:AddData({info = v, isOpen = false}, 0) isEmpty = false end end UIUtils.SetActive(self.obj_ReportEmpty, isEmpty) end function UIGuildEscortReport:SwitchDetailShow(show) self.switchDetailOpen = show if show then self.ArrowState:SetState(0) for i = 1, #self.group_CheckBtns do local item = self.group_CheckBtns[i] if i == self.curFilterType then item.state_Select:SetState(0) else item.state_Select:SetState(1) end end else self.ArrowState:SetState(1) UIUtils.SetLabelText(self.txt_Switch, FilterTypeIds[self.curFilterType]) end UIUtils.SetActive(self.group_CheckBtns.gameObject, show) end -- 设置自身公会信息 function UIGuildEscortReport:SetSelfGuildInfo() local guildInfo = MDL.Guild.GetMyGuildInfo() if string.isNilOrEmpty(guildInfo.guildId) then self.obj_selfGuild.obj_groupState:SetState(1) else -- 自己的信息 local myRankInfo = MDL.Rank.GetMyRankInfo() if IsServerDataNotNil(myRankInfo) then self.obj_selfGuild.obj_groupState:SetState(0) -- 设置排名 self:SetGuildRank(self.obj_selfGuild, myRankInfo.index) -- 设置公会相关 UIUtils.SetLabel(self.obj_selfGuild.txt_GuildName, guildInfo.guildName) self:SetGuildEmblem(self.obj_selfGuild, guildInfo.emblemContent, guildInfo.emblemFrame) -- 设置主公 UIUtils.SetLabel(self.obj_selfGuild.txt_PlayerName, guildInfo.leaderName) -- 设置积分 UIUtils.SetLabel(self.obj_selfGuild.txt_Score, tostring(myRankInfo.param1)) -- 设置区服 self:SetGuildServerID(self.obj_selfGuild, MDL.Login.GetServerShowId()) else self.obj_selfGuild.obj_groupState:SetState(1) end end end -- 通用设置军团标记 function UIGuildEscortReport:SetGuildEmblem(obj, emblemContent, emblemFrame) if not string.isNilOrEmpty(emblemContent) then UIUtils.SetActive(obj.img_GuildIcon.gameObject, true) UIUtils.SetLabel(obj.txt_GuildNameInitiate, emblemContent) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(emblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(obj.img_GuildIcon, "UI_Guild", guildEmblemCfg.Image) end else UIUtils.SetActive(obj.img_GuildIcon.gameObject, false) end end -- 设置名字、排行等基础信息 function UIGuildEscortReport:SetGuildRank(obj, rank) -- 设置排名 if rank == nil or rank <= 0 then UIUtils.SetLabelText(obj.txt_Number, Const_IDS.IDS_Rank_Unranked) obj.obj_RankState:SetState(3) else UIUtils.SetLabel(obj.txt_Number, rank) if rank <= 3 then obj.obj_RankState:SetState(rank - 1) else obj.obj_RankState:SetState(3) end end end -- 设置区服 function UIGuildEscortReport:SetGuildServerID(cell, serverID) if self.guildRankIsWarZone then UIUtils.SetActive(cell.txt_ServerID.gameObject, true) UIUtils.SetActive(cell.Line4, true) UIUtils.SetLabel(cell.txt_ServerID, string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, serverID)) else UIUtils.SetActive(cell.txt_ServerID.gameObject, false) UIUtils.SetActive(cell.Line4, false) end end function UIGuildEscortReport:SetConciseReport(cellTable, data) local selfEscortInfo = data.escortInfo -- 设置我方公会信息 self:SetGuildEmblem(cellTable.group_GuildName, selfEscortInfo.emblemContent, selfEscortInfo.emblemFrame) UIUtils.SetLabel(cellTable.group_GuildName.txt_GuildName, selfEscortInfo.guildName) -- 设置我方队长名字 UIUtils.SetLabel(cellTable.txt_PlayerName, selfEscortInfo.teamLeaderName) -- 是否有队长标记 UIUtils.SetActive(cellTable.img_LeaderFlag, #selfEscortInfo.headers > 1) if data.robResult ~= MDL.GuildEscort.EscortLogRobResult.NotRob then cellTable.obj_otherState:SetState(0) local otherEscortInfo = data.escortOptInfo -- 设置敌方公会信息 self:SetGuildEmblem(cellTable.group_GuildName2, otherEscortInfo.emblemContent, otherEscortInfo.emblemFrame) UIUtils.SetLabel(cellTable.group_GuildName2.txt_GuildName, otherEscortInfo.guildName) -- 设置敌方队长名字 UIUtils.SetLabel(cellTable.txt_PlayerName2, otherEscortInfo.teamLeaderName) -- 是否有队长标记 UIUtils.SetActive(cellTable.img_LeaderFlag2, #otherEscortInfo.headers > 1) else cellTable.obj_otherState:SetState(1) end -- 设置箭头 if data.isOpen then cellTable.obj_arrowState:SetState(0) else cellTable.obj_arrowState:SetState(1) end -- 设置镖车品势 local escortData = DataSheetManager.GuildEscortData:GetDataByID(data.quality) UIUtils.SetImageByAssetBundle(cellTable.img_Mark, escortData.CarIcon) -- 设置规则显示 if self.curTabType == TabType.TransportReward then if data.robResult == MDL.GuildEscort.EscortLogRobResult.NotRob then UIUtils.SetLabelText(cellTable.txt_Result, Const_IDS.IDS_Escort_GuardSuccess2) elseif data.robResult == MDL.GuildEscort.EscortLogRobResult.RobSucceed then UIUtils.SetLabelText(cellTable.txt_Result, Const_IDS.IDS_Escort_GuardFail) elseif data.robResult == MDL.GuildEscort.EscortLogRobResult.RobFail then UIUtils.SetLabelText(cellTable.txt_Result, Const_IDS.IDS_Escort_GuardSuccess) end elseif self.curTabType == TabType.CutOutReward then -- 主动劫镖仅有成功失败两种 if data.robResult == MDL.GuildEscort.EscortLogRobResult.RobSucceed then UIUtils.SetLabelText(cellTable.txt_Result, Const_IDS.IDS_Escort_RobSuccess2) elseif data.robResult == MDL.GuildEscort.EscortLogRobResult.RobFail then UIUtils.SetLabelText(cellTable.txt_Result, Const_IDS.IDS_Escort_RobFail2) end end end function UIGuildEscortReport:SetDetailReport(cellTable, data) if data.robResult == MDL.GuildEscort.EscortLogRobResult.RobSucceed then cellTable.obj_rewardState:SetState(0) if self.curTabType == TabType.TransportReward then UIUtils.SetLabelText(cellTable.txt_Resources, Const_IDS.IDS_Escort_ProtectNotFine) elseif self.curTabType == TabType.CutOutReward then UIUtils.SetLabelText(cellTable.txt_Resources, Const_IDS.IDS_Escort_RobSuccessReward) end elseif data.robResult == MDL.GuildEscort.EscortLogRobResult.RobFail then cellTable.obj_rewardState:SetState(1) if self.curTabType == TabType.TransportReward then UIUtils.SetLabelText(cellTable.txt_ResourcesNotReward, Const_IDS.IDS_Escort_ProtectFine) elseif self.curTabType == TabType.CutOutReward then UIUtils.SetLabelText(cellTable.txt_ResourcesNotReward, Const_IDS.IDS_Escort_RobFailReward) end end -- 设置奖励 local content = cellTable.content for i, v in ipairs(data.rewards) do local item = content[i] if not item then item = self:InstantiateCellCollection(cellTable.cell.gameObject, content, self.template_Item.gameObject) end UIUtils.SetActive(item.gameObject, true) UTL.Item.SetItemCell(item, v.ItemId, v.ItemCount) end for i = #data.rewards + 1, #content do UIUtils.SetActive(content[i].gameObject, false) end -- 设置我方阵容 self:SetTeamHead(data.escortInfo, cellTable.obj_selfTeam) -- 设置敌方阵容 self:SetTeamHead(data.escortOptInfo, cellTable.obj_otherTeam) end function UIGuildEscortReport:SetTeamHead(escortInfo, teamArray) local headers = escortInfo.headers for i = 1, #teamArray do local item = teamArray[i] if i <= #headers then local data = headers[i] UIUtils.SetActive(item.gameObject, true) CTL.Character.SetPortraitAndFrame(item.HeroHead, data.PortraitId, data.FrameId) UIUtils.SetLabel(item.txt_Name, data.name) UIUtils.SetActive(item.img_LeaderFlag, #headers > 1 and escortInfo.teamLeaderName == data.name) else UIUtils.SetActive(item.gameObject, false) end end end function UIGuildEscortReport:ClickTeamHead(teamArray, headers, target) for i = 1, #teamArray do local item = teamArray[i] if item.HeroHead.img_PlayerAvatarBg == target then if headers[i].acid ~= BattleDataGetter.GetAcID() then CTL.PlayerInteract.OpenFriendInteractView(headers[i].acid) end return end end end return UIGuildEscortReport