예제 #1
0
def handleMouseEvent(event):
    if OfflineMode.handleMouseEvent(event):
        return True
    elif LightingGenerationMode.handleMouseEvent(event):
        return True
    else:
        dx, dy, dz, _ = convertMouseEvent(event)
        if constants.IS_CAT_LOADED:
            import Cat
            if Cat.handleMouseEvent(dx, dy, dz):
                return True
        if g_replayCtrl.isPlaying:
            if g_replayCtrl.handleMouseEvent(dx, dy, dz):
                return True
        if GUI.handleMouseEvent(event):
            return True
        inputHandler = getattr(BigWorld.player(), 'inputHandler', None)
        if inputHandler is not None:
            if inputHandler.handleMouseEvent(dx, dy, dz):
                return True
        for handler in g_mouseEventHandlers:
            try:
                if handler(event):
                    return True
            except Exception:
                LOG_CURRENT_EXCEPTION()

        return False
예제 #2
0
def handleKeyEvent(event):
    if OfflineMode.handleKeyEvent(event):
        return True
    elif LightingGenerationMode.handleKeyEvent(event):
        return True
    else:
        isDown, key, mods, isRepeat = convertKeyEvent(event)
        if g_bootcamp.isRunning():
            g_bootcamp.handleKeyEvent(event)
        if WebBrowser.g_mgr.handleKeyEvent(event):
            return True
        if g_replayCtrl.isPlaying:
            if g_replayCtrl.handleKeyEvent(isDown, key, mods, isRepeat, event):
                return True
        if isRepeat:
            if onRepeatKeyEvent(event):
                return True
        if constants.IS_CAT_LOADED:
            import Cat
            if Cat.handleKeyEventBeforeGUI(isDown, key, mods, event):
                return True
        if not isRepeat:
            InputHandler.g_instance.handleKeyEvent(event)
            if GUI.handleKeyEvent(event):
                return True
        if constants.IS_CAT_LOADED:
            import Cat
            if Cat.handleKeyEventAfterGUI(isDown, key, mods, event):
                return True
        if not isRepeat:
            if MessengerEntry.g_instance.gui.handleKey(event):
                return True
        inputHandler = getattr(BigWorld.player(), 'inputHandler', None)
        if inputHandler is not None:
            if inputHandler.handleKeyEvent(event):
                return True
        for handler in g_keyEventHandlers:
            try:
                if handler(event):
                    return True
            except Exception:
                LOG_CURRENT_EXCEPTION()

        return False
예제 #3
0
def fini():
    global g_replayCtrl
    global g_onBeforeSendEvent
    global g_scenario
    LOG_DEBUG('fini')
    if OfflineMode.enabled():
        return
    elif LightingGenerationMode.enabled():
        return
    else:
        BigWorld.wg_setScreenshotNotifyCallback(None)
        g_critMemHandler.restore()
        g_critMemHandler.destroy()
        if constants.IS_CAT_LOADED:
            import Cat
            Cat.fini()
        MusicControllerWWISE.destroy()
        if RSSDownloader.g_downloader is not None:
            RSSDownloader.g_downloader.destroy()
        ServiceLocator.connectionMgr.onConnected -= onConnected
        ServiceLocator.connectionMgr.onDisconnected -= onDisconnected
        MessengerEntry.g_instance.fini()
        from helpers import EdgeDetectColorController
        if EdgeDetectColorController.g_instance is not None:
            EdgeDetectColorController.g_instance.destroy()
            EdgeDetectColorController.g_instance = None
        BigWorld.resetEntityManager(False, False)
        BigWorld.clearAllSpaces()
        if TriggersManager.g_manager is not None:
            TriggersManager.g_manager.destroy()
            TriggersManager.g_manager = None
        if g_replayCtrl is not None:
            g_replayCtrl.unsubscribe()
        gui_personality.fini()
        tutorialLoaderFini()
        import Vibroeffects
        if Vibroeffects.VibroManager.g_instance is not None:
            Vibroeffects.VibroManager.g_instance.destroy()
            Vibroeffects.VibroManager.g_instance = None
        from LightFx import LightManager
        if LightManager.g_instance is not None:
            LightManager.g_instance.destroy()
            LightManager.g_instance = None
        import AuxiliaryFx
        if AuxiliaryFx.g_instance is not None:
            AuxiliaryFx.g_instance.destroy()
            AuxiliaryFx.g_instance = None
        from predefined_hosts import g_preDefinedHosts
        if g_preDefinedHosts is not None:
            g_preDefinedHosts.fini()
        dependency.clear()
        if g_replayCtrl is not None:
            g_replayCtrl.destroy()
            g_replayCtrl = None
        voipRespHandler = VOIP.getVOIPManager()
        if voipRespHandler is not None:
            voipRespHandler.destroy()
        SoundGroups.g_instance.destroy()
        Settings.g_instance.save()
        if g_scenario is not None:
            g_scenario.fini()
        g_onBeforeSendEvent = None
        return
예제 #4
0
def start():
    LOG_DEBUG('start')
    if OfflineMode.onStartup():
        LOG_DEBUG('OfflineMode')
        return
    elif LightingGenerationMode.onStartup():
        LOG_DEBUG('LightingGenerationMode')
        return
    else:
        ServiceLocator.connectionMgr.onConnected += onConnected
        ServiceLocator.connectionMgr.onDisconnected += onDisconnected
        if len(sys.argv) > 2:
            if sys.argv[1] == 'scriptedTest':
                try:
                    scriptName = sys.argv[2]
                    if scriptName[-3:] == '.py':
                        scriptName = scriptName[:-3]
                    try:
                        __import__(scriptName)
                    except ImportError:
                        try:
                            __import__('tests.' + scriptName)
                        except ImportError:
                            __import__('Cat.' + scriptName)

                    ServiceLocator.gameplay.start()
                except Exception:
                    LOG_CURRENT_EXCEPTION()
                    BigWorld.wg_writeToStdOut('Failed to run scripted test, Python exception was thrown, see python.log')
                    BigWorld.quit()

            elif sys.argv[1] == 'offlineTest':
                try:
                    from Cat.Tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    LOG_DEBUG('starting offline test: %s', sys.argv[2])
                    if len(sys.argv) > 3:
                        TestArena2Object.startOffline(sys.argv[2], sys.argv[3])
                    else:
                        TestArena2Object.startOffline(sys.argv[2])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'spinTest':
                try:
                    from Cat.Tasks.TestArena2 import TestArena2Object
                    LOG_DEBUG(sys.argv)
                    targetDirectory = sys.argv[4] if len(sys.argv) > 4 else 'SpinTestResult'
                    LOG_DEBUG('starting offline test: %s %s %s', sys.argv[2], sys.argv[3], targetDirectory)
                    TestArena2Object.startOffline(sys.argv[2], mapName=sys.argv[3], targetDirectory=targetDirectory)
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

            elif sys.argv[1] == 'hangarOverride':
                try:
                    LOG_DEBUG(sys.argv)
                    from Tests.auto.HangarOverride import HangarOverride
                    HangarOverride.setHangar('spaces/' + sys.argv[2])
                    if len(sys.argv) > 3 and sys.argv[3] is not None:
                        LOG_DEBUG('Setting default client inactivity timeout: %s' % sys.argv[3])
                        constants.CLIENT_INACTIVITY_TIMEOUT = int(sys.argv[3])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                ServiceLocator.gameplay.start()
                gui_personality.start()
            elif sys.argv[1] == 'replayTimeout':
                try:
                    g_replayCtrl.replayTimeout = float(sys.argv[2])
                except Exception:
                    LOG_DEBUG('Game start FAILED with:')
                    LOG_CURRENT_EXCEPTION()

                ServiceLocator.gameplay.start()
                gui_personality.start()
            elif sys.argv[1] == 'botInit' or sys.argv[1] == 'botExecute':
                ServiceLocator.gameplay.start()
                gui_personality.start()
                try:
                    LOG_DEBUG('BOTNET: Playing scenario "%s" with bot "%s"...' % (sys.argv[2], sys.argv[3]))
                    if sys.argv[1] == 'botInit':
                        scenarioPlayer().initBot(sys.argv[3], sys.argv[2])
                    elif sys.argv[1] == 'botExecute':
                        scenarioPlayer().execute(sys.argv[3], sys.argv[2])
                except Exception:
                    LOG_DEBUG('BOTNET: Failed to start the client with:')
                    LOG_CURRENT_EXCEPTION()

            else:
                ServiceLocator.gameplay.start()
                gui_personality.start()
        else:
            ServiceLocator.gameplay.start()
            gui_personality.start()
        try:
            import Vibroeffects
            Vibroeffects.VibroManager.g_instance.start()
        except Exception:
            LOG_CURRENT_EXCEPTION()

        try:
            from LightFx import LightManager
            if LightManager.g_instance is not None:
                LightManager.g_instance.start()
            from AuxiliaryFx import g_instance
            if g_instance is not None:
                g_instance.start()
        except Exception:
            LOG_CURRENT_EXCEPTION()

        return