local UITeamInvitedPanel = UIViewClass() local TEAM_INVITED_TYPE = MDL.Team.InvitedType.Team local ROOM_INVITED_TYPE = MDL.Team.InvitedType.Room function UITeamInvitedPanel:OnOpened(context) self:Init() end function UITeamInvitedPanel:Init() self:RegistSystemEvent(EventID.UI_Team_InviteInfoHandle, self.UpdateInviteTeamList) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_TeamUI_InvitationList"]) self:InitInviteTeamList() self.isAutoPopUpValue = CTL.Team.IsAutoPopUpInvitedview() self.toggle_Skip.isOn = not self.isAutoPopUpValue end function UITeamInvitedPanel:OnClosed() --关闭页面的时候,做一个检查,防止主城界面的小按钮不消失 if #MDL.Team.GetInviteList() == 0 then CTL.Team.TeamEchoManager(CTL.Team.EchoType.InviteInfoHandle, true) end if self.toggle_Skip.isOn then if CTL.Team.IsAutoPopUpInvitedview() then PersistentData.DeviceData:Set(CTL.Team.TeamInvitedAutoPopUPKey, UTL.Time.GetServerTimestamp(), true) end else if not CTL.Team.IsAutoPopUpInvitedview() then PersistentData.DeviceData:Set(CTL.Team.TeamInvitedAutoPopUPKey, 0, true) end end end function UITeamInvitedPanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UITeamInvitedPanel:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_IgnoreAll then MDL.Team.ClearInviteList() self:CloseView() end end function UITeamInvitedPanel:AddCellByType(info) if info then if info.type == TEAM_INVITED_TYPE then self.LoopScroll_InviteTeamList:AddData(info, 0) elseif info.type == ROOM_INVITED_TYPE then self.LoopScroll_InviteTeamList:AddData(info, 1) end end end function UITeamInvitedPanel:InitInviteTeamList() local inviteList = MDL.Team.GetInviteList() if #inviteList > 0 then for i, v in ipairs(inviteList) do self:AddCellByType(v) end UIUtils.SetActive(self.group_Empty.gameObject, false) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, true) else UIUtils.SetActive(self.group_Empty.gameObject, true) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, false) end end function UITeamInvitedPanel:UpdateInviteTeamList(isAdd, invitedInfo) if isAdd then self:AddCellByType(invitedInfo) else local index if invitedInfo.type == TEAM_INVITED_TYPE then -- 数据额结构 :invitedInfo = {type = 1, teamId} index = MDL.Team.GetInviteListIndexById(invitedInfo.teamId) elseif invitedInfo.type == ROOM_INVITED_TYPE then -- 数据额结构 : invitedInfo = {type = 2, ActivityID = 901 RoomID = 12345} index = MDL.CustomRoom.GetInviteListIndexByActivityIDAndRoomID(invitedInfo.ActivityID, invitedInfo.RoomID) end if index then self.LoopScroll_InviteTeamList:RemoveIndex(index) end end if self.LoopScroll_InviteTeamList.Count > 0 then UIUtils.SetActive(self.group_Empty.gameObject, false) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, true) else UIUtils.SetActive(self.group_Empty.gameObject, true) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, false) end end function UITeamInvitedPanel:RefreshSingleTeamCell(info, cellTable) local data = info.info.teamInfo local target = data.target UIUtils.SetActive(cellTable.ico_TargetLevel, false) if CTL.Team.IsSpecifiedTarget(target.mainTarget) == false then cellTable.txt_TargetName.text = MDL.Team.GetTeamTargetName(target.mainTarget, target.subTarget) local unlockParam,des = MDL.Team.GetTeamTargetUnlockInfo(target.mainTarget, target.subTarget) UIUtils.SetLabel(cellTable.lab_TargetLevel, des) UIUtils.SetActive(cellTable.lab_TargetLevel, true) else UIUtils.SetLabelText(cellTable.txt_TargetName, CTL.Team.GetSpecifiedTargetTitle(target.mainTarget)) UIUtils.SetActive(cellTable.lab_TargetLevel, false) end if target.subTarget and target.subTarget > 0 then UIUtils.SetActive(cellTable.txt_SubTargetName, true) else UIUtils.SetActive(cellTable.txt_SubTargetName, false) end UIUtils.SetActive(cellTable.group_Legion, false) for i, v in ipairs(cellTable.group_Head) do if data.members[i] then self:RefreshSingleMember(data.members[i], v) UIUtils.SetActive(v.group_Hero, true) else CTL.Character.SetHeadEmpty(v.UIHeroHead150) UIUtils.SetActive(v.group_Hero, false) end end end function UITeamInvitedPanel:RefreshSingleRoomCell(data, cellTable) local houseShowInfo = data.info CTL.Character.SetPortraitAndFrame(cellTable.Head, houseShowInfo.HouseOwner.PortraitID, houseShowInfo.HouseOwner.FrameID) UIUtils.SetLabel(cellTable.lab_RoleName, houseShowInfo.HouseOwner.Name) cellTable.group_Gender:SetState(houseShowInfo.HouseOwner.Sex == 1 and 0 or 1) -- 标题 local activityID = houseShowInfo.BriefInfo.ActivityID local isUnlock, desc = CTL.CustomRoom.GetTabUnlockByActivityID(activityID) UIUtils.SetLabel(cellTable.txt_AimName, CTL.CustomRoom.ActivityTitle[activityID].. desc) UIUtils.SetLabel(cellTable.txt_Name, CTL.CrossServer.GetServerShowStr(houseShowInfo.HouseOwner.ShowServerID)) UIUtils.SetLabel(cellTable.txt_Level, CTL.CustomRoom.GetLevelDescByActivityID(activityID, houseShowInfo.HouseOwner.Dan)) UIUtils.SetLabel(cellTable.txt_RoomName, houseShowInfo.BriefInfo.RoomName) end function UITeamInvitedPanel:RefreshSingleMember(memberInfo, cell) local baseInfo = memberInfo.playerShowInfo CTL.Character.SetPortraitAndFrame(cell.UIHeroHead150, baseInfo.PortraitId, baseInfo.FrameId, baseInfo.level) UIUtils.SetActive(cell.ico_Leader, memberInfo.type == MDL.Team.MemberType.Leader) UIUtils.SetActive(cell.ico_Legion, false) cell.lab_RoleName.text = baseInfo.name CTL.Player.OperateGenderImage(cell.image_Gender, baseInfo.sex) --同势力显示徽记 if MDL.Guild.IsSameGuild(baseInfo.guildId) then UIUtils.SetLabel(cell.txt_GuildInitiate,baseInfo.EmblemContent) if baseInfo.EmblemFrame > 0 then UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(baseInfo.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 end function UITeamInvitedPanel:OnCellInit(scrollRect, index, cellTable, data) if data.type == TEAM_INVITED_TYPE then self:RefreshSingleTeamCell(data, cellTable) elseif data.type == ROOM_INVITED_TYPE then self:RefreshSingleRoomCell(data, cellTable) end end function UITeamInvitedPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Accept then if data.type == TEAM_INVITED_TYPE then MDL.Team.TeamInviteHandleReq(data.info.teamInfo.teamId, true) elseif data.type == ROOM_INVITED_TYPE then CTL.CustomRoom.OnClickEnterRoom(true, data.info.BriefInfo.ActivityID, data.info.BriefInfo.RoomID) end self:CloseView() elseif target == cellTable.btn_Refuse then if data.type == TEAM_INVITED_TYPE then MDL.Team.TeamInviteHandleReq(data.info.teamInfo.teamId, false) else MDL.CustomRoom.RefuseCustomRoomInviteReq(data.info.BriefInfo.ActivityID, data.info.BriefInfo.RoomID) end else for k,v in ipairs(data.info.teamInfo.members) do if target == cellTable.group_Head[k].UIHeroHead150.img_PlayerAvatarBg then if v.playerShowInfo.acid ~= BattleDataGetter.GetAcID() then CTL.PlayerInteract.OpenFriendInteractView(v.playerShowInfo.acid, nil, {isJoinTeam = true}) end end end end end return UITeamInvitedPanel