Search in sources :

Example 1 with InputSystem

use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.

the class NUIManagerInternal method update.

@Override
public void update(float delta) {
    canvas.processMousePosition(mouse.getPosition());
    // modifying a collection while iterating of it is typically not supported
    for (UIScreenLayer screen : new ArrayList<>(screens)) {
        screen.update(delta);
    }
    for (ControlWidget widget : overlays.values()) {
        widget.update(delta);
    }
    InputSystem inputSystem = context.get(InputSystem.class);
    inputSystem.getMouseDevice().setGrabbed(inputSystem.isCapturingMouse() && !(this.isReleasingMouse()));
}
Also used : ControlWidget(org.terasology.rendering.nui.ControlWidget) ArrayList(java.util.ArrayList) InputSystem(org.terasology.input.InputSystem) UIScreenLayer(org.terasology.rendering.nui.UIScreenLayer)

Example 2 with InputSystem

use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.

the class OpenVRInput method postInitialise.

/**
 * Set up listeners and input devices.
 * @param rootContext
 */
@Override
public void postInitialise(Context rootContext) {
    config = context.get(Config.class);
    if (!config.getRendering().isVrSupport()) {
        return;
    }
    this.context = rootContext;
    InputSystem inputSystem = context.get(InputSystem.class);
    if (inputSystem == null) {
        inputSystem = new InputSystem();
        inputSystem.setMouseDevice(new LwjglMouseDevice());
        inputSystem.setKeyboardDevice(new LwjglKeyboardDevice());
        context.put(InputSystem.class, inputSystem);
    }
    controllerDevice = new OpenVRControllers();
    vrProvider.getState().addControllerListener(controllerDevice);
    inputSystem.setControllerDevice(controllerDevice);
}
Also used : Config(org.terasology.config.Config) LwjglMouseDevice(org.terasology.input.lwjgl.LwjglMouseDevice) LwjglKeyboardDevice(org.terasology.input.lwjgl.LwjglKeyboardDevice) InputSystem(org.terasology.input.InputSystem)

Example 3 with InputSystem

use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.

the class StateMainMenu method init.

@Override
public void init(GameEngine gameEngine) {
    context = gameEngine.createChildContext();
    CoreRegistry.setContext(context);
    // let's get the entity event system running
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = context.get(EngineEntityManager.class);
    eventSystem = context.get(EventSystem.class);
    console = new ConsoleImpl(context);
    context.put(Console.class, console);
    nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
    context.put(NUIManager.class, nuiManager);
    eventSystem.registerEventHandler(nuiManager);
    componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    // TODO: Reduce coupling between Input system and CameraTargetSystem,
    // TODO: potentially eliminating the following lines. See Issue #1126
    CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
    context.put(CameraTargetSystem.class, cameraTargetSystem);
    componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
    componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
    componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
    NUIEditorSystem nuiEditorSystem = new NUIEditorSystem();
    context.put(NUIEditorSystem.class, nuiEditorSystem);
    componentSystemManager.register(nuiEditorSystem, "engine:NUIEditorSystem");
    NUISkinEditorSystem nuiSkinEditorSystem = new NUISkinEditorSystem();
    context.put(NUISkinEditorSystem.class, nuiSkinEditorSystem);
    componentSystemManager.register(nuiSkinEditorSystem, "engine:NUISkinEditorSystem");
    inputSystem = context.get(InputSystem.class);
    // TODO: REMOVE this and handle refreshing of core game state at the engine level - see Issue #1127
    new RegisterInputSystem(context).step();
    EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
    LocalPlayer localPlayer = new LocalPlayer();
    context.put(LocalPlayer.class, localPlayer);
    localPlayer.setClientEntity(localPlayerEntity);
    componentSystemManager.initialise();
    storageServiceWorker = context.get(StorageServiceWorker.class);
    playBackgroundMusic();
    // guiManager.openWindow("main");
    context.get(NUIManager.class).pushScreen("engine:mainMenuScreen");
    if (!messageOnLoad.isEmpty()) {
        nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", messageOnLoad);
    }
// TODO: enable it when exposing the telemetry to users
// pushLaunchPopup();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) NUIEditorSystem(org.terasology.rendering.nui.editor.systems.NUIEditorSystem) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) LocalPlayer(org.terasology.logic.players.LocalPlayer) MessagePopup(org.terasology.rendering.nui.layers.mainMenu.MessagePopup) NUISkinEditorSystem(org.terasology.rendering.nui.editor.systems.NUISkinEditorSystem) RegisterInputSystem(org.terasology.engine.modes.loadProcesses.RegisterInputSystem) RegisterInputSystem(org.terasology.engine.modes.loadProcesses.RegisterInputSystem) InputSystem(org.terasology.input.InputSystem) CoreCommands(org.terasology.logic.console.commands.CoreCommands) ClientComponent(org.terasology.network.ClientComponent) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) ConsoleSystem(org.terasology.logic.console.ConsoleSystem) EventSystem(org.terasology.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.rendering.nui.NUIManager) EntityRef(org.terasology.entitySystem.entity.EntityRef) StorageServiceWorker(org.terasology.identity.storageServiceClient.StorageServiceWorker) CameraTargetSystem(org.terasology.input.cameraTarget.CameraTargetSystem)

Example 4 with InputSystem

use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.

the class RegisterInputSystem method step.

@Override
public boolean step() {
    ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
    LocalPlayerSystem localPlayerSystem = new LocalPlayerSystem();
    componentSystemManager.register(localPlayerSystem, "engine:localPlayerSystem");
    context.put(LocalPlayerSystem.class, localPlayerSystem);
    CameraTargetSystem cameraTargetSystem = new CameraTargetSystem();
    context.put(CameraTargetSystem.class, cameraTargetSystem);
    componentSystemManager.register(cameraTargetSystem, "engine:CameraTargetSystem");
    InputSystem inputSystem = context.get(InputSystem.class);
    componentSystemManager.register(inputSystem, "engine:InputSystem");
    return true;
}
Also used : LocalPlayerSystem(org.terasology.logic.players.LocalPlayerSystem) InputSystem(org.terasology.input.InputSystem) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) CameraTargetSystem(org.terasology.input.cameraTarget.CameraTargetSystem)

Example 5 with InputSystem

use of org.terasology.input.InputSystem in project Terasology by MovingBlocks.

the class HeadlessInput method initControls.

private void initControls(Context context) {
    InputSystem inputSystem = new InputSystem();
    context.put(InputSystem.class, inputSystem);
}
Also used : InputSystem(org.terasology.input.InputSystem)

Aggregations

InputSystem (org.terasology.input.InputSystem)8 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)2 CameraTargetSystem (org.terasology.input.cameraTarget.CameraTargetSystem)2 LwjglKeyboardDevice (org.terasology.input.lwjgl.LwjglKeyboardDevice)2 LwjglMouseDevice (org.terasology.input.lwjgl.LwjglMouseDevice)2 NUIManagerInternal (org.terasology.rendering.nui.internal.NUIManagerInternal)2 JsonParser (com.google.gson.JsonParser)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.junit.BeforeClass)1 LWJGLException (org.lwjgl.LWJGLException)1 Config (org.terasology.config.Config)1 ControllerConfig (org.terasology.config.ControllerConfig)1 RegisterInputSystem (org.terasology.engine.modes.loadProcesses.RegisterInputSystem)1 HeadlessCanvasRenderer (org.terasology.engine.subsystem.headless.renderer.HeadlessCanvasRenderer)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)1 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)1 TranslationSystemImpl (org.terasology.i18n.TranslationSystemImpl)1