local UICountryTeamEnter = UIViewClass() function UICountryTeamEnter:OnOpened(context) local CLOSE_TIME = context.time local showInfo,isAttacker,mapId = self:GetShowInfo() CTL.Character.SetPortraitAndFrame(self.HeroHead.UIHeroHead190, showInfo.PortraitId, showInfo.FrameId, showInfo.PlayerLevel) local activityData = DataSheetManager.ActivityData:GetDataByID(context.activityId) self.AutomaticAgree = activityData.AutomaticAgree if activityData.AutomaticAgree then self.cdTimer:ResetAndBeginCustomTimer(false, CLOSE_TIME, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Invite_AutoReceive), 1) else self.cdTimer:ResetAndBeginCustomTimer(false, CLOSE_TIME, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountryPVP_Invite_AutoRefuse), 1) end local contentIds if isAttacker then contentIds = Const_IDS.IDS_CountryPVP_InvateTeam_Info_2 else contentIds = Const_IDS.IDS_CountryPVP_InvateTeam_Info_1 end -- 名字,地图名,敌方国家 ,敌方名字 local enemyData = self:GetEnemyData(showInfo.countryId) local mapInfo = DataSheetManager.LevelInfoData:GetDataByLevelID(mapId) local mapName = "" if mapInfo then mapName = UIUtils.GetLocalizedTxt(Const_IDS[mapInfo.LevelNameIDS]) else logging.error(LTAG.ERROR,"LevelInfoData not find",mapId) end local content = string.FormatByIdsId(contentIds, showInfo.PlayerName ,mapName ,CTL.Country.GetCountryName(enemyData.countryId) ,enemyData.PlayerName) UIUtils.SetLabel(self.txt_Main,content) self:StartRepeatFunc(self.OnExitFunc,CLOSE_TIME,1) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_CountryPVP_Title) end function UICountryTeamEnter:OnExitFunc(deltaTime, timeSinceUpdate) self:CloseView() end function UICountryTeamEnter:OnClosed() --没有确认的话,关闭时按照配置自动取消或确认 if self.hasConfirm == nil then MDL.TeamMatch.MatchStateConfirmReq(self.AutomaticAgree) end end --获取攻击者或是被攻击者 function UICountryTeamEnter:GetShowInfo() local memberNames = {} local nameAndMapId = {} for i, v in ipairs(MDL.Team.GetAllMembersInfo()) do table.insert(memberNames,v.playerShowInfo.name) nameAndMapId[v.playerShowInfo.name] = v.detailInfo.mapId end local matchMembers = MDL.TeamMatch.GetMatchMemberInfo() for i, v in ipairs(matchMembers) do if v.isAutoSendConfirm and table.containValue(memberNames,v.PlayerName) then return v,v.isAttacker,nameAndMapId[v.PlayerName] end end return nil end function UICountryTeamEnter:GetEnemyData(countryId) local matchMembers = MDL.TeamMatch.GetMatchMemberInfo() for i, v in ipairs(matchMembers) do if v.countryId ~= countryId then return v end end return nil end function UICountryTeamEnter:OnButtonClicked(comp) if comp == self.btn_Goto then MDL.TeamMatch.MatchStateConfirmReq(true) self.hasConfirm = true self:CloseView() elseif comp == self.btn_Cancel or comp == self.UICommonPopUp.btn_Close then self.hasConfirm = true MDL.TeamMatch.MatchStateConfirmReq(false) self:CloseView() end end return UICountryTeamEnter