def readUISettingsFile(path): settingsConfig = ResMgr.openSection(path) if settingsConfig is None: raise Exception("Can't open config file (%s)" % path) allPrebattleSettings = {} allBattleSettings = {} allGarageSettings = {} allRibbonsSettings = {} for name, section in settingsConfig.items(): if name == 'lesson': lessonId = section['id'].asInt lobbySettings = copy(g_defaultLobbyUiSettings) visString = section['visible_garage'].asString visibilityNames = visString.split() for visName in visibilityNames: hideName = 'hide' + visName if hideName in lobbySettings: lobbySettings[hideName] = False else: showName = 'show' + visName if showName in lobbySettings: lobbySettings[showName] = True else: LOG_DEBUG_DEV_BOOTCAMP('Unknown setting name (%s)' % hideName) allGarageSettings[lessonId] = lobbySettings battleSettings = copy(g_defaultBattleUiSettings) visString = section['visible_battle'].asString visibilityNames = visString.split() for visName in visibilityNames: hideName = 'hide' + visName if hideName in battleSettings: battleSettings[hideName] = False else: showName = 'show' + visName if showName in battleSettings: battleSettings[showName] = True else: LOG_DEBUG_DEV_BOOTCAMP('Unknown setting name (%s)' % hideName) allBattleSettings[lessonId] = battleSettings ribbonsSettings = copy(g_defaultBattleRibbonsSettings) ribString = section['ribbons'].asString ribbonNames = ribString.split() for ribName in ribbonNames: if ribName in ribbonsSettings: ribbonsSettings[ribName] = True allRibbonsSettings[lessonId] = ribbonsSettings prebattleSettings = {} prebattleSection = section['prebattle'] if prebattleSection.has_key('timeout'): prebattleSettings['timeout'] = prebattleSection[ 'timeout'].asFloat allPrebattleSettings[lessonId] = prebattleSettings return (allPrebattleSettings, allRibbonsSettings, allBattleSettings, allGarageSettings)
def checkReturnToHangar(self): if self.isLessonSuspended: g_bootcampGarage.highlightLobbyHint('HangarButton', True, True) elif self.isLessonFinished: if self.canGoToBattle: LOG_DEBUG_DEV_BOOTCAMP("checkReturnToHangar - hiding 'HangarButton' highlight (isLessonFinished and canGoToBattle)") g_bootcampGarage.highlightLobbyHint('HangarButton', False, True) else: LOG_DEBUG_DEV_BOOTCAMP("checkReturnToHangar - highlighting 'HangarButton' (isLessonFinished and not canGoToBattle)") g_bootcampGarage.highlightLobbyHint('HangarButton', True, True) elif self.__lessonId == g_bootcamp.getContextIntParameter('randomBattleLesson'): name = 'hideHeaderBattleSelector' if name in self.bootcampCtrl.getLobbySettings(): if self.bootcampCtrl.getLobbySettings()[name]: g_bootcampGarage.highlightLobbyHint('HangarButton', True, True) return try: items = battle_selector_items.getItems() if not items.isSelected('random'): return except: LOG_CURRENT_EXCEPTION_BOOTCAMP() LOG_ERROR_BOOTCAMP('battle_selector_items exception') g_bootcampGarage.highlightLobbyHint('HangarButton', True, True) else: g_bootcampGarage.highlightLobbyHint('HangarButton', True, True)
def showHint(self, componentID): LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_showHint', componentID) self.__activeHints.add(componentID) self.updateDescriptors(componentID) self.as_addHighlightS(componentID) if componentID not in self.HIGHLIGHT_NO_SOUNDS: soundID = 'bc_new_ui_element_button' if componentID in self.BUTTON_SOUNDS else 'bc_new_ui_element' activeSoundComponentID, activeSound = self.__soundsBySoundID.get( soundID, (None, None)) if activeSound is not None and activeSound.isPlaying: LOG_DEBUG_DEV_BOOTCAMP( 'BCHighlights_showHint - skipping {0} (already playing from component {1})' .format(soundID, activeSoundComponentID)) return prevSoundID, snd = self.__soundsByComponentID.get( componentID, (None, None)) if snd is None: snd = SoundGroups.g_instance.getSound2D(soundID) self.__soundsByComponentID[componentID] = (soundID, snd) else: raise prevSoundID == soundID or AssertionError self.__soundsBySoundID[soundID] = (componentID, snd) LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_showHint - playing', soundID) snd.play() if componentID not in ('HangarButton', 'TechTreeButton', 'SecondTank'): from bootcamp.BootcampGarage import g_bootcampGarage g_bootcampGarage.resumeLesson() return
def onGarageLessonFinished(self, lessonId): LOG_DEBUG_DEV_BOOTCAMP('onGarageLessonFinished', lessonId) self.__account.base.completeBootcampLesson(0) lastLesson = self.getContextIntParameter('lastLessonNum') if self.__lessonId == lastLesson: LOG_DEBUG_DEV_BOOTCAMP('Finished last lesson', lessonId) else: self.enqueueBattleLesson()
def onGarageLessonFinished(self, lessonId): LOG_DEBUG_DEV_BOOTCAMP('onGarageLessonFinished', lessonId) self.__account.base.completeBootcampLesson(0) lastLesson = self.getContextIntParameter('lastLessonNum') if self.__lessonId == lastLesson: LOG_DEBUG_DEV_BOOTCAMP('Finished last lesson', lessonId) else: self.enqueueBattleLesson() functional = self.tutorialLoader.tutorial.getChapterFunctionalContext() functional.stopVSEPlans()
def __init__(self, assistant): super(AbstractMission, self).__init__() LOG_DEBUG_DEV_BOOTCAMP('Mission {0} __init__'.format( self.__class__.__name__)) self.__vehicles = [] self.__hints = [] self.__markers = [] self.__detectedVehicles = set() self.__triggerListener = TriggerListener(self) self.__callbackID = None self._markerMgrRef = weakref.proxy(assistant.getMarkers()) self._avatar = BigWorld.player() self._assistant = assistant self._actionEventMap = { BOOTCAMP_BATTLE_ACTION.PLAYER_MOVE: self.__onActionPlayerMove, BOOTCAMP_BATTLE_ACTION.PLAYER_SPOTTED: self.__onActionPlayerSpoted, BOOTCAMP_BATTLE_ACTION.PLAYER_HIT_VEHICLE: self.__onActionPlayerHitVehicle, BOOTCAMP_BATTLE_ACTION.SET_SCENERY_CONSTANT: self.__onActionSetSceneryConstant } self._soundFilter = BCFilter() self.__combatMusic = None BigWorld.player().arena.onPeriodChange += self._onPeriodChange return
def showFinalVideo(self, callback): LOG_DEBUG_DEV_BOOTCAMP('showFinalVideo') MC.g_musicController.muteMusic(True) self.__finalVideoCallback = callback self.__currentState.deactivate() self.__currentState = StateOutroVideo() self.__currentState.activate()
def __showHint(self, hintName): if hintName is not None: LOG_DEBUG_DEV_BOOTCAMP('showNextHint - {0}'.format(hintName)) callback = self.getCallbackByName(hintName) if callback is not None: callback() return
def enableCheckpointGUI(self): actionStart = self.__bootcampGarageActions.actionStart checkpoint = self.__checkpoint currentAction = actionStart visibleElements = [] cyclicController = CyclicController() cyclicError = 'enableCheckpointGUI, lessonId - {0}, currentAction - {1}' LOG_DEBUG_DEV_BOOTCAMP( 'Start to enableCheckpointGUI, lessonId - {0}, currentAction - {1}, checkpoint - {2}' .format(self.__lessonId, currentAction, self.__checkpoint)) while currentAction != checkpoint: cyclicController.checkCyclic( currentAction, cyclicError.format(self.__lessonId, currentAction)) if currentAction is None: return currentAction = self.collectVisibleElements( currentAction, visibleElements) for action in self.__showActionsHistory: self.collectVisibleElements(action, visibleElements) if visibleElements: self.enableGarageGUIElements(visibleElements) return
def delDataCallback(self, eventName, callback): if eventName not in self.__queues: LOG_DEBUG_DEV_BOOTCAMP('Failed to del replay data callback:', eventName) return queue = self.__queues[eventName] queue.delDataCallback(callback)
def showVehiclePreview(vehTypeCompDescr, previewAlias=VIEW_ALIAS.LOBBY_HANGAR, vehStrCD=None): from CurrentVehicle import g_currentPreviewVehicle if g_currentPreviewVehicle.isPresent(): g_currentPreviewVehicle.selectVehicle(vehTypeCompDescr) else: if constants.IS_BOOTCAMP_ENABLED: if g_bootcamp.isRunning(): from debug_utils_bootcamp import LOG_DEBUG_DEV_BOOTCAMP LOG_DEBUG_DEV_BOOTCAMP('showVehiclePreview', vehTypeCompDescr, previewAlias) g_eventBus.handleEvent(events.LoadViewEvent( VIEW_ALIAS.BOOTCAMP_VEHICLE_PREVIEW, ctx={ 'itemCD': vehTypeCompDescr, 'previewAlias': previewAlias }), scope=EVENT_BUS_SCOPE.LOBBY) return g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.VEHICLE_PREVIEW, ctx={ 'itemCD': vehTypeCompDescr, 'previewAlias': previewAlias, 'vehicleStrCD': vehStrCD }), scope=EVENT_BUS_SCOPE.LOBBY)
def checkCyclic(self, element, info): LOG_DEBUG_DEV_BOOTCAMP('[checkCyclic] Element {0}'.format(element)) if element == '': raise Exception('[checkCyclic] Empty element found!') if element in self.__elements: raise Exception('[checkCyclic] Infinite cycle found! Aborting! Info - {0}'.format(info)) self.__elements.add(element)
def clear(self): LOG_DEBUG_DEV_BOOTCAMP('_DirectionIndicatorCtrl.clear', hex(id(self))) self.setVisible(False) if self.__indicator is not None: self.__indicator.remove() self.__indicator = None return
def start(self): LOG_DEBUG_DEV_BOOTCAMP('Mission {0} start'.format(self.__class__.__name__)) self.assistant.combatSound.onStartMission() for id_, vehicle in self._avatar.arena.vehicles.items(): vehLink = self.__getVehLink(id_) if vehLink is None: self.createVehicle(vehicle['name']) for vehicle in self._avatar.vehicles: self.__onVehicleEnterWorld(vehicle) hintSystem = self._assistant.getHintSystem() for hintLink in self.__hints: hint = HintCustom(self._avatar, hintLink.hintTypeId, hintLink.timeCompleted, hintLink.cooldownAfter, hintLink.message, hintLink.timeStartDelay, hintLink.timeDuration, hintLink.timeInnerCooldown, hintLink.timeCompleteDuration, hintLink.voiceover) hintLink.hintObject = hint hintSystem.addHint(hint) hint.start() self._avatar.onVehicleEnterWorld += self.__onVehicleEnterWorld self._avatar.onVehicleLeaveWorld += self.__onVehicleLeaveWorld g_bootcampEvents.onBattleAction += self.__onBattleAction self._avatar.arena.onTeamBasePointsUpdate += self.onTeamBasePointsUpdate self._avatar.arena.onTeamBaseCaptured += self.onTeamBaseCaptured for markerLink in self.__markers: markerLink.hide(True) self.update() return
def onHighlightHint(self, event): hintWindow = self.findViewByAlias( ViewTypes.WINDOW, VIEW_ALIAS.BOOTCAMP_BATTLE_HIGHLIGHTS) LOG_DEBUG_DEV_BOOTCAMP('onHighlightHint', hintWindow, event.ctx) if hintWindow is not None: hintWindow.showHint(event.ctx) return
def deactivate(self): if not self.__isActive: LOG_DEBUG_DEV_BOOTCAMP( 'State.deactivate: state is already not active') return self._doDeactivate() self.__isActive = False
def delDataCallback(self, callback): if callback is not self.__callback: LOG_DEBUG_DEV_BOOTCAMP('Multiple callback unsubscribe:', self.__name) return else: self.__callback = None return
def stop(cls): LOG_DEBUG_DEV_BOOTCAMP('TRANSITION_end', cls) if cls._transitionWindow: cls._transitionWindow.active(False) cls._transitionWindow.close() cls._transitionWindow = None return
def hideHint(self, componentID, shouldStop=True): soundID, snd = self.__soundsByComponentID.pop(componentID, (None, None)) if snd is not None: LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_hideHint', componentID, shouldStop) activeSoundComponentID, activeSound = self.__soundsBySoundID.get(soundID, None) if activeSound is snd: if shouldStop: LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_hideHint - stopping', soundID) snd.stop() elif snd.isPlaying: self.__orphanedSounds.append(activeSound) LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_hideHint - removing from active sounds', soundID) del self.__soundsBySoundID[soundID] self.as_removeHighlightS(componentID) self.__activeHints.discard(componentID) return
def clear(self): LOG_DEBUG_DEV_BOOTCAMP('_StaticObjectMarker3D.clear', self.__model) self.setVisible(False) self.__animator = None self.__model = None self.__destroyed = True return
def showGarageGUIElements(self, elementsList, callback): self.startLobbyAssistance() LOG_DEBUG_DEV_BOOTCAMP('showGarageGUIElements', elementsList) g_eventBus.handleEvent(events.LoadViewEvent(events.BootcampEvent.SHOW_NEW_ELEMENTS, None, {'keys': elementsList, 'callback': callback}), EVENT_BUS_SCOPE.LOBBY) self.changeGarageGUIElementsVisibility(elementsList, False, update=False) return
def saveCheckpointToServer(self): if g_playerEvents.isPlayerEntityChanging: LOG_DEBUG_DEV_BOOTCAMP('events.isPlayerEntityChanging', g_playerEvents.isPlayerEntityChanging) return else: if self.__account is not None: self.__account.base.saveBootcampCheckpoint(self.__checkpoint, self.__lessonId) return
def hideHint(self): if self.__prevHint is not None: LOG_DEBUG_DEV_BOOTCAMP('hideHint - {0}'.format(self.__prevHint)) callback = self.getCallbackByName(self.__prevHint) self.__prevHint = None if callback is not None: callback(True) return
def onBattleLoaded(self, lessonId): from states.StateInBattle import StateInBattle LOG_DEBUG_DEV_BOOTCAMP('onBattleLoaded called') self.__currentState.deactivate() self.__avatar = BigWorld.player() self.__currentState = StateInBattle(lessonId, self.__avatar, self.__chapter, self.__gui) self.__currentState.activate()
def onTriggerActivated(self, args): if args['type'] == TriggersManager.TRIGGER_TYPE.PLAYER_SHOOT: markerSize = self._avatar.gunRotator.markerInfo[2] LOG_DEBUG_DEV_BOOTCAMP('PLAYER_SHOOT, markerSize - ', markerSize) if self.__aimFactor < markerSize: self.__curAimlessShootCount += 1 else: self.__curAimlessShootCount = 0
def stopVideo(self): if self.__movieFiles is not None and len(self.__movieFiles): self.__showNextMovie() return else: LOG_DEBUG_DEV_BOOTCAMP('Startup Video: STOP') self.__onFinish() return
def init(self, entitiesParams, bootcampGui): LOG_DEBUG_DEV_BOOTCAMP('BootcampMarkers.init') self.__entitiesParams = entitiesParams self.__gui = bootcampGui if not BattleReplay.g_replayCtrl.isPlaying: TriggersManager.g_manager.addListener(self) g_bootcampEvents.onUIStateChanged += self._onUIStateChanged InputHandler.g_instance.onKeyDown += self._handleKeyEvent
def clear(self): LOG_DEBUG_DEV_BOOTCAMP('_StaticMinimapMarker2D.clear', self.__markerID) minimap = self.__minimap() if minimap is not None and self.__markerID: minimap.delTarget(self.__markerID) self.__markerID = '' self.__minimap = None return
def init(self, entities, markers, bootcampGui): LOG_DEBUG_DEV_BOOTCAMP('BootcampMarkers.init') self.__entitiesParams = entities self.__markersParams = markers self.__gui = bootcampGui if not BattleReplay.g_replayCtrl.isPlaying: TriggersManager.g_manager.addListener(self) g_bootcampEvents.onUIStateChanged += self._onUIStateChanged
def showHint(self, componentID): LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_showHint', componentID) self.__activeHints.add(componentID) self.as_addHighlightS(componentID) if componentID not in self.HIGHLIGHT_NO_SOUNDS: soundID = 'bc_new_ui_element_button' if componentID in self.BUTTON_SOUNDS else 'bc_new_ui_element' activeSoundComponentID, activeSound = self.__soundsBySoundID.get(soundID, (None, None)) if activeSound is not None and activeSound.isPlaying: LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_showHint - skipping {0} (already playing from component {1})'.format(soundID, activeSoundComponentID)) return prevSoundID, snd = self.__soundsByComponentID.get(componentID, (None, None)) if snd is None: snd = SoundGroups.g_instance.getSound2D(soundID) self.__soundsByComponentID[componentID] = (soundID, snd) self.__soundsBySoundID[soundID] = (componentID, snd) LOG_DEBUG_DEV_BOOTCAMP('BCHighlights_showHint - playing', soundID) snd.play() return