local UISpecialTeamInviteInPopUp = UIViewClass() local StrangerIndex = 0 local FriendIndex = 1 local GuildIndex = 2 local RefershFriendInfoCDTime = 1 --刷新好友信息的时间 秒 local MaxShowNum = DataSheetManager.ConstData:GetDataByID("TeamListMax").IntValue function UISpecialTeamInviteInPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_SpecialTeam_CloseAll, self.OnBackButtonPressed) self:RegistSystemEvent(EventID.UI_Team_StrangerListRefresh, self.RefreshInvitePeopleList) self:RegistSystemEvent(EventID.UI_Guild_GuildInfoRefresh, self.RefreshGuildInfos) self:RegistSystemEvent(EventID.UI_UpdateFriendInfo, self.RefreshFriendInfos) UIUtils.SetActive(self.img_Empty, true) MDL.Team.StrangerListReq(MDL.Team.StrangerType.TeamWar) self.group_InviteSort:SelectIndex(0) end function UISpecialTeamInviteInPopUp:RefreshInvitePeopleList() if self.currentIndex ~= StrangerIndex then return end if self.LoopScroll_InvitedPeopleList.Count > 0 then self.LoopScroll_InvitedPeopleList:ClearCells() end local strangerList = MDL.Team.GetStrangerList() for i, v in ipairs(strangerList) do self.LoopScroll_InvitedPeopleList:AddData(v, 0) end UIUtils.SetActive(self.img_Empty, self.LoopScroll_InvitedPeopleList.Count == 0) end function UISpecialTeamInviteInPopUp:RefreshGuildInfos(guildInfos) if self.currentIndex ~= GuildIndex then return end if self.LoopScroll_InvitedPeopleList.Count > 0 then self.LoopScroll_InvitedPeopleList:ClearCells() end if not guildInfos or not guildInfos.members or #guildInfos.members == 0 then UIUtils.SetActive(self.img_Empty, true) return end --工会基础信息 self.guildBaseInfo = guildInfos.listInfo local showLength = #guildInfos.members >= MaxShowNum and MaxShowNum or #guildInfos.members for _, member in pairs(guildInfos.members) do -- 剔除掉自己本身以及不在线的 if member.roleInfo and BattleDataGetter.GetAcID() ~= member.roleInfo.acid and member.roleInfo.isOnline then self.LoopScroll_InvitedPeopleList:AddData(member.roleInfo, 0) if self.LoopScroll_InvitedPeopleList.Count == showLength then break end end end UIUtils.SetActive(self.img_Empty, self.LoopScroll_InvitedPeopleList.Count == 0) end function UISpecialTeamInviteInPopUp:RefreshFriendInfos() if self.currentIndex ~= FriendIndex then return end if self.LoopScroll_InvitedPeopleList.Count > 0 then self.LoopScroll_InvitedPeopleList:ClearCells() end local friends = {} for i, v in ipairs(MDL.Friend.GetSortedList(MDL.Friend.ListType.Friend)) do table.insert(friends, v) end if not friends or #friends == 0 then UIUtils.SetActive(self.img_Empty, true) return end local showLength = #friends >= MaxShowNum and MaxShowNum or #friends for i = 1, showLength do local friend = friends[i] if not friend.isOnline then break end self.LoopScroll_InvitedPeopleList:AddData(friend, 0) end UIUtils.SetActive(self.img_Empty, self.LoopScroll_InvitedPeopleList.Count == 0) end function UISpecialTeamInviteInPopUp:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UISpecialTeamInviteInPopUp:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UISpecialTeamInviteInPopUp:SetInviteTeamInfo(inviteInfo, cell) --好友的数据字段名首字母都是小写,陌生人和势力的数据中字段名都是大写 CTL.Character.SetPortraitAndFrame(cell.UIHeroHead150, inviteInfo.PortraitId or inviteInfo.portraitId, inviteInfo.FrameId or inviteInfo.frameId, inviteInfo.level) UIUtils.SetLabelText(cell.lab_GuildName, Const_IDS["IDS_TeamUI_ActiveInvitation_NoGuild"]) cell.lab_RoleName.text = inviteInfo.name if CTL.SpecialTeam.IsShowPlayerGs() then UIUtils.SetActive(cell.ico_CE, true) cell.lab_CE.text = inviteInfo.gsSum or inviteInfo.power else UIUtils.SetActive(cell.ico_CE, false) UIUtils.SetLabel(cell.lab_CE, UIUtils.GetLocalizedTxt(Const_IDS.IDS_TeamFairTournamen_3v3Point) .. inviteInfo.SyncTvTEloScore) end cell.btn_Invite:SetGray(false) CTL.Player.OperateGenderImage(cell.image_Gender, inviteInfo.sex) local guildId = inviteInfo.guildID local emblemContent = inviteInfo.EmblemContent local emblemFrame = inviteInfo.EmblemFrame --工会的用工会基础信息 if self.currentIndex == GuildIndex and self.guildBaseInfo then guildId = self.guildBaseInfo.id emblemContent = self.guildBaseInfo.emblemContent emblemFrame = self.guildBaseInfo.emblemFrame elseif self.currentIndex == StrangerIndex then guildId = inviteInfo.guildId end --有工会的话显示势力名字、徽记显示 if not string.isNilOrEmpty(inviteInfo.guildName) then cell.lab_GuildName.text = inviteInfo.guildName UIUtils.SetLabel(cell.txt_GuildInitiate, emblemContent) if emblemFrame > 0 then UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(emblemFrame).Image) end UIUtils.SetActive(cell.txt_GuildInitiate, true) UIUtils.SetActive(cell.img_GuildMark, true) else UIUtils.SetActive(cell.txt_GuildInitiate, false) UIUtils.SetActive(cell.img_GuildMark, false) end --同势力显示不同颜色的工会名字 if MDL.Guild.IsSameGuild(guildId) then UIUtils.SetLabel(cell.lab_GuildName, UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, inviteInfo.guildName)) end end function UISpecialTeamInviteInPopUp:OnCellInit(scrollRect, index, cellTable, data) self:SetInviteTeamInfo(data, cellTable) end function UISpecialTeamInviteInPopUp:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Invite then cellTable.btn_Invite:SetGray(true) CTL.SpecialTeam.TryInviteMember(data) else CTL.PlayerInteract.OpenFriendInteractView(data.acid) end end --请求好友信息增加一个1s的CD时间 (避免请求压力大) function UISpecialTeamInviteInPopUp:SendRefreshFriendInfos() if self.lastRefreshFriendInfoStamp == nil then self.lastRefreshFriendInfoStamp = UTL.Time.GetServerTimestamp() MDL.Friend.SendRefreshFriendInfos() else local currentTime = UTL.Time.GetServerTimestamp() if (currentTime - self.lastRefreshFriendInfoStamp) > RefershFriendInfoCDTime then MDL.Friend.SendRefreshFriendInfos() self.lastRefreshFriendInfoStamp = currentTime else self:RefreshFriendInfos() end end end function UISpecialTeamInviteInPopUp:OnValueChanged(comp, index) if comp == self.group_InviteSort then self.currentIndex = index if index == StrangerIndex then MDL.Team.StrangerListReq(MDL.Team.StrangerType.TeamWar) elseif index == FriendIndex then self:SendRefreshFriendInfos() elseif index == GuildIndex then MDL.Guild.GetGuildInfoReq() end end end return UISpecialTeamInviteInPopUp