--[[ 宠物繁殖邀请弹窗 ]]-- local UIPetInvitePopUp = UIViewClass() local GuildIndex = 0 local FriendIndex = 1 local StrangerIndex = 2 local MaxShowNum = 50 local RefreshFriendInfoCDTime = 1 function UIPetInvitePopUp:OnOpened(context) UIUtils.SetActive(self.img_Empty, true) self:RegistSystemEvent(EventID.UI_Team_StrangerListRefresh, self.RefreshInvitePeopleList) self:RegistSystemEvent(EventID.UI_Guild_GuildInfoRefresh, self.RefreshGuildInfos) self:RegistSystemEvent(EventID.UI_UpdateFriendInfo, self.RefreshFriendInfos) self.group_InviteSort:SelectIndex(0) end function UIPetInvitePopUp: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 --请求好友信息增加一个1s的CD时间 (避免请求压力大) function UIPetInvitePopUp:SendRefreshFriendInfos() if self.lastRefreshFriendInfoStamp == nil then self.lastRefreshFriendInfoStamp = UTL.Time.GetServerTimestamp() MDL.Friend.SendRefreshFriendInfos() else local currentTime = UTL.Time.GetServerTimestamp() if (currentTime - self.lastRefreshFriendInfoStamp) > RefreshFriendInfoCDTime then MDL.Friend.SendRefreshFriendInfos() self.lastRefreshFriendInfoStamp = currentTime else self:RefreshFriendInfos() end end end function UIPetInvitePopUp:OnValueChanged(comp, value) self.currentIndex = value if value == StrangerIndex then MDL.Team.StrangerListReq(MDL.Team.StrangerType.All) elseif value == FriendIndex then self:SendRefreshFriendInfos() elseif value == GuildIndex then MDL.Guild.GetGuildInfoReq() end end function UIPetInvitePopUp:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIPetInvitePopUp:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UIPetInvitePopUp:OnCellInit(scrollRect, index, cellTable, data) self:SetCellInfo(data, cellTable) end function UIPetInvitePopUp:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Invite then cellTable.btn_Invite:SetGray(true) MDL.Pet.BreedPetInviteReq(data.acid, 1) else CTL.PlayerInteract.OpenFriendInteractView(data.acid) end end function UIPetInvitePopUp:SetCellInfo(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 cell.lab_CE.text = inviteInfo.gsSum or inviteInfo.power 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 UIPetInvitePopUp: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 UIPetInvitePopUp: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 return UIPetInvitePopUp