Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
 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
Ejemplo n.º 14
0
    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
Ejemplo n.º 15
0
 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
Ejemplo n.º 16
0
 def deactivate(self):
     if not self.__isActive:
         LOG_DEBUG_DEV_BOOTCAMP(
             'State.deactivate: state is already not active')
         return
     self._doDeactivate()
     self.__isActive = False
Ejemplo n.º 17
0
 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
Ejemplo n.º 18
0
 def stop(cls):
     LOG_DEBUG_DEV_BOOTCAMP('TRANSITION_end', cls)
     if cls._transitionWindow:
         cls._transitionWindow.active(False)
         cls._transitionWindow.close()
         cls._transitionWindow = None
     return
Ejemplo n.º 19
0
 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
Ejemplo n.º 20
0
 def clear(self):
     LOG_DEBUG_DEV_BOOTCAMP('_StaticObjectMarker3D.clear', self.__model)
     self.setVisible(False)
     self.__animator = None
     self.__model = None
     self.__destroyed = True
     return
Ejemplo n.º 21
0
 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
Ejemplo n.º 22
0
 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
Ejemplo n.º 23
0
 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
Ejemplo n.º 24
0
 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()
Ejemplo n.º 25
0
 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
Ejemplo n.º 26
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
Ejemplo n.º 27
0
 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
Ejemplo n.º 28
0
 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
Ejemplo n.º 30
0
 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