def tryLeaveRequest(self, _): resStr = 'quitBattle' replayCtrl = BattleReplay.g_replayCtrl canRespawn = False player = BigWorld.player() if hasRespawns(): isVehicleAlive = not g_sessionProvider.getArenaDP().getVehicleInteractiveStats().stopRespawn canRespawn = isVehicleAlive else: isVehicleAlive = getattr(player, 'isVehicleAlive', False) isVehicleOverturned = getattr(player, 'isVehicleOverturned', False) isNotTraining = self.__arena.guiType != constants.ARENA_GUI_TYPE.TRAINING if not replayCtrl.isPlaying: if constants.IS_KOREA and gui.GUI_SETTINGS.igrEnabled and self.__arena is not None and isNotTraining: vehicleID = getattr(player, 'playerVehicleID', -1) if vehicleID in self.__arena.vehicles: vehicle = self.__arena.vehicles[vehicleID] if isVehicleAlive and vehicle.get('igrType') != constants.IGR_TYPE.NONE: resStr = 'quitBattleIGR' else: LOG_ERROR("Player's vehicle not found", vehicleID) if canRespawn: isDeserter = isVehicleAlive and isNotTraining else: isDeserter = isVehicleAlive and isNotTraining and not isVehicleOverturned if isDeserter: resStr += '/deserter' else: isDeserter = False self.__callEx('tryLeaveResponse', [resStr, isDeserter]) return
def __init__(self, appNS): self.__ns = appNS self.__soundManager = None self.__arena = BigWorld.player().arena self.__plugins = PluginsCollection(self) plugins = {} if hasFlags(): plugins['flagNotification'] = FlagNotificationPlugin if hasRespawns() and not BattleReplay.g_replayCtrl.isPlaying: plugins['respawnView'] = RespawnViewPlugin if hasResourcePoints(): plugins['resources'] = ResourcePointsPlugin self.__plugins.addPlugins(plugins) BattleWindow.__init__(self, 'battle.swf') self.__isHelpWindowShown = False self.__cameraMode = None self.component.wg_inputKeyMode = 1 self.component.position.z = DEPTH_OF_Battle self.movie.backgroundAlpha = 0 self.addFsCallbacks({'battle.leave': self.onExitBattle}) self.addExternalCallbacks({'battle.showCursor': self.cursorVisibility, 'battle.tryLeaveRequest': self.tryLeaveRequest, 'battle.populateFragCorrelationBar': self.populateFragCorrelationBar, 'Battle.UsersRoster.Appeal': self.onDenunciationReceived, 'Battle.selectPlayer': self.selectPlayer, 'battle.helpDialogOpenStatus': self.helpDialogOpenStatus, 'battle.initLobbyDialog': self._initLobbyDialog, 'battle.reportBug': self.reportBug}) self.__dynSquadListener = None BigWorld.wg_setRedefineKeysMode(False) self.onPostmortemVehicleChanged(BigWorld.player().playerVehicleID) return
def __init__(self, appNS): self.__ns = appNS self.__soundManager = None self.__arena = BigWorld.player().arena self.__plugins = PluginsCollection(self) plugins = {} if hasFlags(): plugins['flagNotification'] = FlagNotificationPlugin if hasRespawns() and not BattleReplay.g_replayCtrl.isPlaying: plugins['respawnView'] = RespawnViewPlugin if hasResourcePoints(): plugins['resources'] = ResourcePointsPlugin self.__plugins.addPlugins(plugins) BattleWindow.__init__(self, 'battle.swf') self.__isHelpWindowShown = False self.__cameraMode = None self.component.wg_inputKeyMode = 1 self.component.position.z = DEPTH_OF_Battle self.movie.backgroundAlpha = 0 self.addFsCallbacks({'battle.leave': self.onExitBattle}) self.addExternalCallbacks({'battle.showCursor': self.cursorVisibility, 'battle.tryLeaveRequest': self.tryLeaveRequest, 'battle.populateFragCorrelationBar': self.populateFragCorrelationBar, 'Battle.UsersRoster.Appeal': self.onDenunciationReceived, 'Battle.selectPlayer': self.selectPlayer, 'battle.helpDialogOpenStatus': self.helpDialogOpenStatus, 'battle.initLobbyDialog': self._initLobbyDialog, 'battle.reportBug': self.reportBug}) self.__dynSquadListener = None BigWorld.wg_setRedefineKeysMode(False) self.onPostmortemVehicleChanged(BigWorld.player().playerVehicleID)
def invalidateVehiclesInfo(self, arenaDP): regionGetter = self._battleCtx.getRegionCode isSpeaking = self.app.voiceChatManager.isPlayerSpeaking userGetter = self.usersStorage.getUser actionGetter = VehicleActions.getBitMask playerTeam = arenaDP.getNumberOfTeam() for isEnemy in (False, True): result = [] for vInfoVO, _, viStatsVO in arenaDP.getVehiclesIterator(isEnemy, hasRespawns()): result.append(self._makeItem(vInfoVO, viStatsVO, userGetter, isSpeaking, actionGetter, regionGetter, playerTeam, isEnemy, self._getSquadIdx(arenaDP, vInfoVO), self.__isFallout)) self.as_setVehiclesDataS({'vehiclesInfo': result, 'isEnemy': isEnemy})
def invalidateVehiclesInfo(self, arenaDP): regionGetter = player_format.getRegionCode isSpeaking = self.app.voiceChatManager.isPlayerSpeaking userGetter = self.usersStorage.getUser actionGetter = VehicleActions.getBitMask playerTeam = arenaDP.getNumberOfTeam() result = [] if hasRespawns(): sortFunction = getRespawnVOsComparator else: sortFunction = None for vInfoVO, _, viStatsVO in arenaDP.getAllVehiclesIteratorByTeamScore(sortFunction=sortFunction): result.append(self._makeItem(vInfoVO, viStatsVO, userGetter, isSpeaking, actionGetter, regionGetter, playerTeam, playerTeam != vInfoVO.team, self._getSquadIdx(arenaDP, vInfoVO))) self.as_setVehiclesDataS({'vehiclesInfo': result}) return
def __init__(self, appNS): g_sessionProvider.registerViewComponents(*_COMPONENTS_TO_CTRLS) self.__ns = appNS self.__soundManager = None self.__arena = BigWorld.player().arena self.__plugins = PluginsCollection(self) plugins = {} if hasFlags(): plugins['flagNotification'] = FlagNotificationPlugin if hasRepairPoints(): plugins['repairTimer'] = RepairTimerPlugin if hasRespawns() and (constants.IS_DEVELOPMENT or not BattleReplay.g_replayCtrl.isPlaying): plugins['respawnView'] = RespawnViewPlugin if hasResourcePoints(): plugins['resources'] = ResourcePointsPlugin if hasGasAttack(): plugins['gasAttack'] = GasAttackPlugin self.__plugins.addPlugins(plugins) self.__denunciator = BattleDenunciator() self.__timerSounds = {} for timer, sounds in self.VEHICLE_DEATHZONE_TIMER_SOUND.iteritems(): self.__timerSounds[timer] = {} for level, sound in sounds.iteritems(): self.__timerSounds[timer][level] = SoundGroups.g_instance.getSound2D(sound) self.__timerSound = None BattleWindow.__init__(self, 'battle.swf') self.__isHelpWindowShown = False self.__cameraMode = None self.component.wg_inputKeyMode = 1 self.component.position.z = DEPTH_OF_Battle self.movie.backgroundAlpha = 0 self.addFsCallbacks({'battle.leave': self.onExitBattle}) self.addExternalCallbacks({'battle.showCursor': self.cursorVisibility, 'battle.tryLeaveRequest': self.tryLeaveRequest, 'battle.populateFragCorrelationBar': self.populateFragCorrelationBar, 'Battle.UsersRoster.Appeal': self.onDenunciationReceived, 'Battle.selectPlayer': self.selectPlayer, 'battle.helpDialogOpenStatus': self.helpDialogOpenStatus, 'battle.initLobbyDialog': self._initLobbyDialog, 'battle.reportBug': self.reportBug}) self.__dynSquadListener = None BigWorld.wg_setRedefineKeysMode(False) self.onPostmortemVehicleChanged(BigWorld.player().playerVehicleID) return
def invalidateVehiclesInfo(self, arenaDP): regionGetter = self._battleCtx.getRegionCode isSpeaking = self.app.voiceChatManager.isPlayerSpeaking userGetter = self.usersStorage.getUser actionGetter = VehicleActions.getBitMask playerTeam = arenaDP.getNumberOfTeam() result = [] for vInfoVO, _, viStatsVO in sorted(arenaDP.getAllVehiclesIteratorByTeamScore(hasRespawns())): result.append(self._makeItem(vInfoVO, viStatsVO, userGetter, isSpeaking, actionGetter, regionGetter, playerTeam, playerTeam != vInfoVO.team, self._getSquadIdx(arenaDP, vInfoVO))) self.as_setVehiclesDataS({'vehiclesInfo': result})
def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate = True): pNamesList, fragsList, vNamesList, additionalDataList = ([], [], [], []) valuesHashes = [] teamsList, teamScoreList = [], [] playerIdx = -1 playerTeamID = avatar_getter.getPlayerTeam() teamScores = defaultdict(list) teamIds = arenaDP.getMultiTeamsIndexes() camraVehicleID = self._battleUI.getCameraVehicleID() playerNameLength = int(self._battleUI.getPlayerNameLength(isEnemy)) vehicleNameLength = int(self._battleUI.getVehicleNameLength(isEnemy)) for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getAllVehiclesIteratorByTeamScore(hasRespawns())): team = vInfoVO.team isEnemy = arenaDP.isEnemyTeam(team) ctx = makeTeamCtx(team, isEnemy, arenaDP, playerNameLength, vehicleNameLength, camraVehicleID) if ctx.playerVehicleID == vInfoVO.vehicleID: playerIdx = index playerFullName = self._battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False) if not playerFullName: playerFullName = vInfoVO.player.getPlayerLabel() pName, frags, vName, additionalData = self._battleUI.statsForm.getFormattedStrings(vInfoVO, vStatsVO, viStatsVO, ctx, playerFullName) pNamesList.append(pName) fragsList.append(frags) vNamesList.append(vName) additionalDataList.append(additionalData) valuesHashes.append({'vehicleState': 0 if viStatsVO.stopRespawn else _VEHICLE_STATUS.IS_ALIVE, 'vehicleType': vInfoVO.vehicleType.getClassName(), 'teamColorScheme': 'vm_enemy' if isEnemy else 'vm_ally'}) teamIdx = teamIds[team] if (team, teamIdx) not in teamsList: teamsList.append((team, teamIdx)) format = self._battleUI.statsForm.getTeamScoreFormat() teamScores[team].append((viStatsVO.winPoints, format)) for team, _ in teamsList: teamScore = teamScores[team] totalScore = sum([ score for score, _ in teamScore ]) scoreIndexForTable = len(teamScore) / 2 for index, (score, format) in enumerate(teamScore): teamScoreStr = format % ' ' if index == scoreIndexForTable: teamScoreStr = format % BigWorld.wg_getNiceNumberFormat(totalScore) teamScoreList.append(teamScoreStr) self._battleUI.setMultiteamValues(self._makeMultiTeamValues(playerTeamID, playerIdx, pNamesList, fragsList, vNamesList, teamsList, teamScoreList, additionalDataList, valuesHashes, arenaDP.getMultiTeamsType()))
def _updateTeamData(self, isEnemy, team, arenaDP, isFragsUpdate = True): pNamesList, fragsList, vNamesList, additionalDataList = ([], [], [], []) valuesHashes = [] ctx = makeTeamCtx(team, isEnemy, arenaDP, int(self._battleUI.getPlayerNameLength(isEnemy)), int(self._battleUI.getVehicleNameLength(isEnemy)), self._battleUI.getCameraVehicleID()) if isFragsUpdate: fragCorrelation = self._battleUI.fragCorrelation fragCorrelation.clear(team) for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getTeamIterator(team)): if not self._battleCtx.isObserver(vInfoVO.vehicleID): fragCorrelation.addVehicle(team, vInfoVO.vehicleID, vInfoVO.vehicleType.getClassName(), vInfoVO.isAlive()) if not vInfoVO.isAlive(): fragCorrelation.addKilled(team) playerAccountID = getAvatarDatabaseID() inviteSendingProhibited = isEnemy or self.prbInvites.getSentInviteCount() >= 100 if not inviteSendingProhibited: inviteSendingProhibited = not self._isSquadAllowToInvite(arenaDP) invitesReceivingProhibited = arenaDP.getVehicleInfo(playerAccountID).player.forbidInBattleInvitations for index, (vInfoVO, vStatsVO, viStatsVO) in enumerate(arenaDP.getVehiclesIterator(isEnemy, hasRespawns())): if index >= PLAYERS_PANEL_LENGTH: LOG_WARNING('Max players in panel are', PLAYERS_PANEL_LENGTH) break if self._battleCtx.isObserver(vInfoVO.vehicleID) and self._battleCtx.isPlayerObserver(): continue playerFullName = self._battleCtx.getFullPlayerName(vID=vInfoVO.vehicleID, showVehShortName=False) if not playerFullName: playerFullName = vInfoVO.player.getPlayerLabel() valuesHash = self._makeHash(index, playerFullName, vInfoVO, vStatsVO, viStatsVO, ctx, playerAccountID, inviteSendingProhibited, invitesReceivingProhibited, isEnemy) pName, frags, vName, additionalData = self._battleUI.statsForm.getFormattedStrings(vInfoVO, vStatsVO, viStatsVO, ctx, playerFullName) pNamesList.append(pName) fragsList.append(frags) vNamesList.append(vName) additionalDataList.append(additionalData) valuesHashes.append(valuesHash) self._battleUI.setTeamValuesData(self._makeTeamValues(isEnemy, ctx, pNamesList, fragsList, vNamesList, additionalDataList, valuesHashes))