Search in sources :

Example 1 with UIScreenLayer

use of org.terasology.rendering.nui.UIScreenLayer in project Terasology by MovingBlocks.

the class NUIManagerInternal method popScreen.

@Override
public void popScreen() {
    if (!screens.isEmpty()) {
        UIScreenLayer top = screens.peek();
        closeScreen(top);
        if (!top.isLowerLayerVisible()) {
            UIScreenLayer current = screens.peek();
            if (current != null) {
                current.onShow();
            }
        }
    }
}
Also used : UIScreenLayer(org.terasology.rendering.nui.UIScreenLayer)

Example 2 with UIScreenLayer

use of org.terasology.rendering.nui.UIScreenLayer in project Terasology by MovingBlocks.

the class NUIManagerInternal method invalidate.

@Override
public void invalidate() {
    assetManager.getLoadedAssets(UIElement.class).forEach(UIElement::dispose);
    boolean hudVisible = isHUDVisible();
    if (hudVisible) {
        setHUDVisible(false);
    }
    Deque<ResourceUrn> reverseUrns = new LinkedList<>();
    Map<UIScreenLayer, ResourceUrn> inverseLookup = screenLookup.inverse();
    for (UIScreenLayer screen : screens) {
        screen.onClosed();
        reverseUrns.addFirst(inverseLookup.get(screen));
    }
    screens.clear();
    screenLookup.clear();
    reverseUrns.forEach(this::pushScreen);
    if (hudVisible) {
        setHUDVisible(true);
    }
}
Also used : UIElement(org.terasology.rendering.nui.asset.UIElement) ResourceUrn(org.terasology.assets.ResourceUrn) UIScreenLayer(org.terasology.rendering.nui.UIScreenLayer) LinkedList(java.util.LinkedList)

Example 3 with UIScreenLayer

use of org.terasology.rendering.nui.UIScreenLayer in project Terasology by MovingBlocks.

the class NUIManagerInternal method pushScreen.

@Override
public void pushScreen(UIScreenLayer screen) {
    if (!screen.isLowerLayerVisible()) {
        UIScreenLayer current = screens.peek();
        if (current != null) {
            current.onHide();
        }
    }
    screens.push(screen);
    screen.onOpened();
    String id = screen.getId();
    if (ResourceUrn.isValid(id)) {
        ResourceUrn uri = new ResourceUrn(id);
        screenLookup.put(uri, screen);
    }
}
Also used : UIScreenLayer(org.terasology.rendering.nui.UIScreenLayer) ResourceUrn(org.terasology.assets.ResourceUrn)

Example 4 with UIScreenLayer

use of org.terasology.rendering.nui.UIScreenLayer in project Terasology by MovingBlocks.

the class NUIManagerInternal method closeScreen.

private void closeScreen(ResourceUrn screenUri, boolean sendEvents) {
    UIScreenLayer screen = screenLookup.remove(screenUri);
    if (screen != null) {
        screens.remove(screen);
        onCloseScreen(screen, screenUri, sendEvents);
    }
}
Also used : UIScreenLayer(org.terasology.rendering.nui.UIScreenLayer)

Example 5 with UIScreenLayer

use of org.terasology.rendering.nui.UIScreenLayer 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)

Aggregations

UIScreenLayer (org.terasology.rendering.nui.UIScreenLayer)6 ResourceUrn (org.terasology.assets.ResourceUrn)2 ControlWidget (org.terasology.rendering.nui.ControlWidget)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 InputSystem (org.terasology.input.InputSystem)1 UIElement (org.terasology.rendering.nui.asset.UIElement)1