Search in sources :

Example 6 with NaturalCamera

use of gaiasky.scenegraph.camera.NaturalCamera in project gaiasky by langurmonkey.

the class BookmarksComponent method initialize.

@Override
public void initialize() {
    float contentWidth = ControlsWindow.getContentWidth();
    searchBox = new OwnTextField("", skin);
    searchBox.setName("search box");
    searchBox.setWidth(contentWidth);
    searchBox.setMessageText(I18n.txt("gui.objects.search"));
    searchBox.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            if (ie.getType() == Type.keyUp && !searchBox.getText().isEmpty()) {
                String text = searchBox.getText().toLowerCase().trim();
                if (sg.containsNode(text)) {
                    SceneGraphNode node = sg.getNode(text);
                    if (node instanceof IFocus) {
                        IFocus focus = (IFocus) node;
                        boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                        boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                        if (!timeOverflow && ctOn) {
                            GaiaSky.postRunnable(() -> {
                                EventManager.publish(Event.CAMERA_MODE_CMD, searchBox, CameraMode.FOCUS_MODE, true);
                                EventManager.publish(Event.FOCUS_CHANGE_CMD, searchBox, focus, true);
                            });
                        } else if (timeOverflow) {
                            info(I18n.txt("gui.objects.search.timerange.1", text), I18n.txt("gui.objects.search.timerange.2"));
                        } else {
                            info(I18n.txt("gui.objects.search.invisible.1", text), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                        }
                    }
                } else {
                    info(null, null);
                }
                if (GaiaSky.instance.getICamera() instanceof NaturalCamera)
                    ((NaturalCamera) GaiaSky.instance.getICamera()).getCurrentMouseKbdListener().removePressedKey(ie.getKeyCode());
                if (ie.getKeyCode() == Keys.ESCAPE) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            } else if (ie.getType() == Type.keyDown) {
                if (ie.getKeyCode() == Keys.CONTROL_LEFT || ie.getKeyCode() == Keys.CONTROL_RIGHT) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            }
            return true;
        }
        return false;
    });
    // Info message
    infoTable = new Table(skin);
    infoCell1 = infoTable.add();
    infoTable.row();
    infoCell2 = infoTable.add();
    infoMessage1 = new OwnLabel("", skin, "default-blue");
    infoMessage2 = new OwnLabel("", skin, "default-blue");
    /*
         * OBJECTS
         */
    bookmarksTree = new Tree<>(skin);
    bookmarksTree.setName("bookmarks tree");
    reloadBookmarksTree();
    bookmarksTree.addListener(event -> {
        if (events)
            if (event instanceof ChangeEvent) {
                ChangeEvent ce = (ChangeEvent) event;
                Actor actor = ce.getTarget();
                TreeNode selected = (TreeNode) ((Tree) actor).getSelectedNode();
                if (selected != null && !selected.hasChildren()) {
                    String name = selected.getValue();
                    if (sg.containsNode(name)) {
                        SceneGraphNode node = sg.getNode(name);
                        if (node instanceof IFocus) {
                            IFocus focus = (IFocus) node;
                            boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                            boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                            if (!timeOverflow && ctOn) {
                                GaiaSky.postRunnable(() -> {
                                    EventManager.publish(Event.CAMERA_MODE_CMD, bookmarksTree, CameraMode.FOCUS_MODE, true);
                                    EventManager.publish(Event.FOCUS_CHANGE_CMD, bookmarksTree, focus, true);
                                });
                                info(null, null);
                            } else if (timeOverflow) {
                                info(I18n.txt("gui.objects.search.timerange.1", name), I18n.txt("gui.objects.search.timerange.2"));
                            } else {
                                info(I18n.txt("gui.objects.search.invisible.1", name), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                            }
                        }
                    } else {
                        info(null, null);
                    }
                }
                return true;
            } else if (event instanceof InputEvent) {
                InputEvent ie = (InputEvent) event;
                ie.toCoordinates(event.getListenerActor(), tmpCoords);
                if (ie.getType() == Type.touchDown && ie.getButton() == Input.Buttons.RIGHT) {
                    TreeNode target = bookmarksTree.getNodeAt(tmpCoords.y);
                    // Context menu!
                    if (target != null) {
                        // selectBookmark(target.getValue(), true);
                        GaiaSky.postRunnable(() -> {
                            ContextMenu cm = new ContextMenu(skin, "default");
                            // New folder...
                            BookmarkNode parent = target.node.getFirstFolderAncestor();
                            String parentName = "/" + (parent == null ? "" : parent.path.toString());
                            MenuItem newDirectory = new MenuItem(I18n.txt("gui.bookmark.context.newfolder", parentName), skin);
                            newDirectory.addListener(evt -> {
                                if (evt instanceof ChangeEvent) {
                                    NewBookmarkFolderDialog newBookmarkFolderDialog = new NewBookmarkFolderDialog(parent != null ? parent.path.toString() : "/", skin, stage);
                                    newBookmarkFolderDialog.setAcceptRunnable(() -> {
                                        String folderName = newBookmarkFolderDialog.input.getText();
                                        EventManager.publish(Event.BOOKMARKS_ADD, newDirectory, parent != null ? parent.path.resolve(folderName).toString() : folderName, true);
                                        reloadBookmarksTree();
                                    });
                                    newBookmarkFolderDialog.show(stage);
                                    return true;
                                }
                                return false;
                            });
                            cm.addItem(newDirectory);
                            // Delete
                            MenuItem delete = new MenuItem(I18n.txt("gui.bookmark.context.delete", target.getValue()), skin);
                            delete.addListener(evt -> {
                                if (evt instanceof ChangeEvent) {
                                    EventManager.publish(Event.BOOKMARKS_REMOVE, delete, target.node.path.toString());
                                    reloadBookmarksTree();
                                    return true;
                                }
                                return false;
                            });
                            cm.addItem(delete);
                            cm.addSeparator();
                            // Move up and down
                            MenuItem moveUp = new MenuItem(I18n.txt("gui.bookmark.context.move.up"), skin);
                            moveUp.addListener(evt -> {
                                if (evt instanceof ChangeEvent) {
                                    EventManager.publish(Event.BOOKMARKS_MOVE_UP, moveUp, target.node);
                                    reloadBookmarksTree();
                                    return true;
                                }
                                return false;
                            });
                            cm.addItem(moveUp);
                            MenuItem moveDown = new MenuItem(I18n.txt("gui.bookmark.context.move.down"), skin);
                            moveDown.addListener(evt -> {
                                if (evt instanceof ChangeEvent) {
                                    EventManager.publish(Event.BOOKMARKS_MOVE_DOWN, moveDown, target.node);
                                    reloadBookmarksTree();
                                    return true;
                                }
                                return false;
                            });
                            cm.addItem(moveDown);
                            // Move to...
                            if (target.node.parent != null) {
                                MenuItem move = new MenuItem(I18n.txt("gui.bookmark.context.move", target.getValue(), "/"), skin);
                                move.addListener(evt -> {
                                    if (evt instanceof ChangeEvent) {
                                        EventManager.publish(Event.BOOKMARKS_MOVE, move, target.node, null);
                                        reloadBookmarksTree();
                                        return true;
                                    }
                                    return false;
                                });
                                cm.addItem(move);
                            }
                            List<BookmarkNode> folders = GaiaSky.instance.getBookmarksManager().getFolders();
                            for (BookmarkNode folder : folders) {
                                if (!target.node.isDescendantOf(folder)) {
                                    MenuItem mv = new MenuItem(I18n.txt("gui.bookmark.context.move", target.getValue(), "/" + folder.path.toString()), skin);
                                    mv.addListener(evt -> {
                                        if (evt instanceof ChangeEvent) {
                                            EventManager.publish(Event.BOOKMARKS_MOVE, mv, target.node, folder);
                                            reloadBookmarksTree();
                                            return true;
                                        }
                                        return false;
                                    });
                                    cm.addItem(mv);
                                }
                            }
                            newMenu(cm);
                            cm.showMenu(stage, Gdx.input.getX(ie.getPointer()) / Settings.settings.program.ui.scale, stage.getHeight() - Gdx.input.getY(ie.getPointer()) / Settings.settings.program.ui.scale);
                        });
                    } else {
                        // New folder
                        GaiaSky.postRunnable(() -> {
                            ContextMenu cm = new ContextMenu(skin, "default");
                            // New folder...
                            String parentName = "/";
                            MenuItem newDirectory = new MenuItem(I18n.txt("gui.bookmark.context.newfolder", parentName), skin);
                            newDirectory.addListener(evt -> {
                                if (evt instanceof ChangeEvent) {
                                    NewBookmarkFolderDialog nbfd = new NewBookmarkFolderDialog("/", skin, stage);
                                    nbfd.setAcceptRunnable(() -> {
                                        String folderName = nbfd.input.getText();
                                        EventManager.publish(Event.BOOKMARKS_ADD, newDirectory, folderName, true);
                                        reloadBookmarksTree();
                                    });
                                    nbfd.show(stage);
                                    return true;
                                }
                                return false;
                            });
                            cm.addItem(newDirectory);
                            newMenu(cm);
                            cm.showMenu(stage, Gdx.input.getX(ie.getPointer()), Gdx.graphics.getHeight() - Gdx.input.getY(ie.getPointer()));
                        });
                    }
                }
                event.setBubbles(false);
                return true;
            }
        return false;
    });
    bookmarksScrollPane = new OwnScrollPane(bookmarksTree, skin, "minimalist-nobg");
    bookmarksScrollPane.setName("bookmarks scroll");
    bookmarksScrollPane.setFadeScrollBars(false);
    bookmarksScrollPane.setScrollingDisabled(true, false);
    bookmarksScrollPane.setHeight(160f);
    bookmarksScrollPane.setWidth(contentWidth);
    /*
         * ADD TO CONTENT
         */
    VerticalGroup objectsGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(pad12);
    objectsGroup.addActor(searchBox);
    if (bookmarksScrollPane != null) {
        objectsGroup.addActor(bookmarksScrollPane);
    }
    objectsGroup.addActor(infoTable);
    component = objectsGroup;
}
Also used : NewBookmarkFolderDialog(gaiasky.interafce.NewBookmarkFolderDialog) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) BookmarkNode(gaiasky.interafce.BookmarksManager.BookmarkNode) IFocus(gaiasky.scenegraph.IFocus) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 7 with NaturalCamera

use of gaiasky.scenegraph.camera.NaturalCamera in project gaiasky by langurmonkey.

the class ObjectsComponent method initialize.

@Override
public void initialize() {
    float contentWidth = ControlsWindow.getContentWidth();
    searchBox = new OwnTextField("", skin);
    searchBox.setName("search box");
    searchBox.setWidth(contentWidth);
    searchBox.setMessageText(I18n.txt("gui.objects.search"));
    searchBox.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            if (ie.getType() == Type.keyUp && !searchBox.getText().isEmpty()) {
                String text = searchBox.getText().toLowerCase().trim();
                if (sg.containsNode(text)) {
                    SceneGraphNode node = sg.getNode(text);
                    if (node instanceof IFocus) {
                        IFocus focus = (IFocus) node;
                        boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                        boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                        if (!timeOverflow && ctOn) {
                            GaiaSky.postRunnable(() -> {
                                EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE, true);
                                EventManager.publish(Event.FOCUS_CHANGE_CMD, this, focus, true);
                            });
                        } else if (timeOverflow) {
                            info(I18n.txt("gui.objects.search.timerange.1", text), I18n.txt("gui.objects.search.timerange.2"));
                        } else {
                            info(I18n.txt("gui.objects.search.invisible.1", text), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                        }
                    }
                } else {
                    info(null, null);
                }
                if (GaiaSky.instance.getICamera() instanceof NaturalCamera)
                    ((NaturalCamera) GaiaSky.instance.getICamera()).getCurrentMouseKbdListener().removePressedKey(ie.getKeyCode());
                if (ie.getKeyCode() == Keys.ESCAPE) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            } else if (ie.getType() == Type.keyDown) {
                if (ie.getKeyCode() == Keys.CONTROL_LEFT || ie.getKeyCode() == Keys.CONTROL_RIGHT) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            }
            return true;
        }
        return false;
    });
    // Info message
    infoTable = new Table(skin);
    infoCell1 = infoTable.add();
    infoTable.row();
    infoCell2 = infoTable.add();
    infoMessage1 = new OwnLabel("", skin, "default-blue");
    infoMessage2 = new OwnLabel("", skin, "default-blue");
    /*
         * OBJECTS
         */
    final com.badlogic.gdx.scenes.scene2d.ui.List<String> focusList = new com.badlogic.gdx.scenes.scene2d.ui.List<>(skin);
    focusList.setName("objects list");
    Array<IFocus> focusableObjects = sg.getFocusableObjects();
    Array<String> names = new Array<>(false, focusableObjects.size);
    for (IFocus focus : focusableObjects) {
        // Omit stars with no proper names
        if (focus.getName() != null && !GlobalResources.isNumeric(focus.getName())) {
            names.add(focus.getName());
        }
    }
    names.sort();
    SceneGraphNode sol = sg.getNode("Sun");
    if (sol != null) {
        Array<IFocus> solChildren = new Array<>();
        sol.addFocusableObjects(solChildren);
        solChildren.sort(new CelestialBodyComparator());
        for (IFocus cb : solChildren) names.insert(0, cb.getName());
    }
    focusList.setItems(names);
    // 
    focusList.pack();
    focusList.addListener(event -> {
        if (event instanceof ChangeEvent) {
            ChangeEvent ce = (ChangeEvent) event;
            Actor actor = ce.getTarget();
            @SuppressWarnings("unchecked") final String text = ((com.badlogic.gdx.scenes.scene2d.ui.List<String>) actor).getSelected().toLowerCase().trim();
            if (sg.containsNode(text)) {
                SceneGraphNode node = sg.getNode(text);
                if (node instanceof IFocus) {
                    IFocus focus = (IFocus) node;
                    boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                    boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                    if (!timeOverflow && ctOn) {
                        GaiaSky.postRunnable(() -> {
                            EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE, true);
                            EventManager.publish(Event.FOCUS_CHANGE_CMD, this, focus, true);
                        });
                    } else if (timeOverflow) {
                        info(I18n.txt("gui.objects.search.timerange.1", text), I18n.txt("gui.objects.search.timerange.2"));
                    } else {
                        info(I18n.txt("gui.objects.search.invisible.1", text), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                    }
                }
            } else {
                info(null, null);
            }
            return true;
        }
        return false;
    });
    objectsList = focusList;
    focusListScrollPane = new OwnScrollPane(objectsList, skin, "minimalist-nobg");
    focusListScrollPane.setName("objects list scroll");
    focusListScrollPane.setFadeScrollBars(false);
    focusListScrollPane.setScrollingDisabled(true, false);
    focusListScrollPane.setHeight(160f);
    focusListScrollPane.setWidth(contentWidth);
    /*
         * ADD TO CONTENT
         */
    VerticalGroup objectsGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(pad12);
    objectsGroup.addActor(searchBox);
    if (focusListScrollPane != null) {
        objectsGroup.addActor(focusListScrollPane);
    }
    objectsGroup.addActor(infoTable);
    component = objectsGroup;
}
Also used : SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) CelestialBodyComparator(gaiasky.util.comp.CelestialBodyComparator) OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) OwnTextField(gaiasky.util.scene2d.OwnTextField) IFocus(gaiasky.scenegraph.IFocus) Array(com.badlogic.gdx.utils.Array) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera) OwnLabel(gaiasky.util.scene2d.OwnLabel)

Example 8 with NaturalCamera

use of gaiasky.scenegraph.camera.NaturalCamera in project gaiasky by langurmonkey.

the class SearchDialog method build.

public void build() {
    candidates = new Table(skin);
    candidates.setBackground("table-bg");
    candidates.setFillParent(false);
    // Info message
    searchInput = new OwnTextField("", skin);
    searchInput.setWidth(480f);
    searchInput.setMessageText(I18n.txt("gui.objects.search"));
    searchInput.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            int matchingSize = matching.size();
            int code = ie.getKeyCode();
            if (ie.getType() == Type.keyUp) {
                if (code == Keys.ESCAPE || code == Keys.ENTER) {
                    if (cIdx >= 0) {
                        checkString(searchInput.getText(), sg);
                    }
                    removeCandidates();
                    me.remove();
                    return true;
                } else if (code == Keys.UP && matchingSize > 0) {
                    cIdx = cIdx - 1 < 0 ? matchingSize - 1 : cIdx - 1;
                    selectMatch();
                } else if (code == Keys.DOWN && matchingSize > 0) {
                    cIdx = (cIdx + 1) % matchingSize;
                    selectMatch();
                } else if (!searchInput.getText().equals(currentInputText) && !searchInput.getText().isBlank()) {
                    // Process only if text changed
                    if (suggestions) {
                        currentInputText = searchInput.getText();
                        String name = currentInputText.toLowerCase().trim();
                        // New task
                        Task task = new Task() {

                            public void run() {
                                synchronized (matching) {
                                    matchingNodes(name, sg);
                                    if (!matching.isEmpty()) {
                                        cIdx = -1;
                                        candidates.clear();
                                        int n = matching.size();
                                        matching.stream().forEach(match -> {
                                            OwnLabel m = new OwnLabel(match, skin);
                                            m.addListener((evt) -> {
                                                if (evt instanceof InputEvent) {
                                                    InputEvent iEvt = (InputEvent) evt;
                                                    if (iEvt.getType() == Type.touchDown) {
                                                        checkString(match, sg);
                                                        searchInput.setText(match);
                                                        accept();
                                                        return true;
                                                    }
                                                }
                                                return false;
                                            });
                                            matchingLabels.add(m);
                                            m.setWidth(searchInput.getWidth());
                                            Cell<?> c = candidates.add(m).left().padBottom(pad5);
                                            c.row();
                                        });
                                        candidates.pack();
                                        searchInput.localToStageCoordinates(aux.set(0, 0));
                                        candidates.setPosition(aux.x, aux.y, Align.topLeft);
                                        stage.addActor(candidates);
                                    } else {
                                        removeCandidates();
                                    }
                                }
                            }
                        };
                        // Cancel others
                        cancelTasks();
                        tasks.add(task);
                        // Schedule with delay
                        Timer.schedule(task, 0.5f);
                        // Actually check and select
                        if (!checkString(name, sg)) {
                            if (name.matches("[0-9]+")) {
                                // Check with 'HIP '
                                if (checkString("hip " + name, sg)) {
                                    cancelTasks();
                                    removeCandidates();
                                }
                            } else if (name.matches("hip [0-9]+") || name.matches("HIP [0-9]+")) {
                                // Check without 'HIP '
                                if (checkString(name.substring(4), sg)) {
                                    cancelTasks();
                                    removeCandidates();
                                }
                            }
                        } else {
                            cancelTasks();
                            removeCandidates();
                        }
                    }
                } else {
                    removeCandidates();
                }
                if (GaiaSky.instance.getICamera() instanceof NaturalCamera)
                    ((NaturalCamera) GaiaSky.instance.getICamera()).getCurrentMouseKbdListener().removePressedKey(ie.getKeyCode());
            }
        }
        return false;
    });
    // Info message
    infoMessage = new OwnLabel("", skin, "default-blue");
    content.add(searchInput).top().left().expand().row();
    infoCell = content.add();
    infoCell.top().left().padTop(pad5).expand().row();
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) CatalogInfo(gaiasky.util.CatalogInfo) GaiaSky(gaiasky.GaiaSky) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) IFocus(gaiasky.scenegraph.IFocus) SortedSet(java.util.SortedSet) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Array(com.badlogic.gdx.utils.Array) Task(com.badlogic.gdx.utils.Timer.Task) ParticleGroup(gaiasky.scenegraph.ParticleGroup) Logger(gaiasky.util.Logger) Action(com.badlogic.gdx.scenes.scene2d.Action) TreeSet(java.util.TreeSet) I18n(gaiasky.util.I18n) Vector2(com.badlogic.gdx.math.Vector2) Cell(com.badlogic.gdx.scenes.scene2d.ui.Cell) OwnTextField(gaiasky.util.scene2d.OwnTextField) Stage(com.badlogic.gdx.scenes.scene2d.Stage) NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera) Type(com.badlogic.gdx.scenes.scene2d.InputEvent.Type) Timer(com.badlogic.gdx.utils.Timer) ISceneGraph(gaiasky.scenegraph.ISceneGraph) Event(gaiasky.event.Event) Align(com.badlogic.gdx.utils.Align) Keys(com.badlogic.gdx.Input.Keys) Log(gaiasky.util.Logger.Log) OwnLabel(gaiasky.util.scene2d.OwnLabel) Optional(java.util.Optional) EventManager(gaiasky.event.EventManager) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) ColorUtils(gaiasky.util.color.ColorUtils) Task(com.badlogic.gdx.utils.Timer.Task) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) OwnTextField(gaiasky.util.scene2d.OwnTextField) NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera) OwnLabel(gaiasky.util.scene2d.OwnLabel) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Cell(com.badlogic.gdx.scenes.scene2d.ui.Cell)

Example 9 with NaturalCamera

use of gaiasky.scenegraph.camera.NaturalCamera in project gaiasky by langurmonkey.

the class ControllerGui method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    // Empty by default
    switch(event) {
        case SHOW_CONTROLLER_GUI_ACTION:
            NaturalCamera cam = (NaturalCamera) data[0];
            if (content.isVisible() && content.getParent() != null) {
                // Hide and remove
                searchField.setText("");
                content.setVisible(false);
                content.remove();
                ui.setKeyboardFocus(null);
                // Remove GUI listener, add natural listener
                cam.addControllerListener();
                removeControllerListener();
            } else {
                // Show
                // Add and show
                ui.addActor(content);
                content.setVisible(true);
                updateFocused();
                // Remove natural listener, add GUI listener
                cam.removeControllerListener();
                addControllerListener(cam, cam.getControllerListener().getMappings());
            }
            break;
        case TIME_STATE_CMD:
            boolean on = (Boolean) data[0];
            timeStartStop.setProgrammaticChangeEvents(false);
            timeStartStop.setChecked(on);
            timeStartStop.setText(on ? "Stop time" : "Start time");
            timeStartStop.setProgrammaticChangeEvents(true);
            break;
        case SCENE_GRAPH_LOADED:
            this.sg = (ISceneGraph) data[0];
            break;
        default:
            break;
    }
}
Also used : NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera)

Example 10 with NaturalCamera

use of gaiasky.scenegraph.camera.NaturalCamera in project gaiasky by langurmonkey.

the class EventScriptingInterface method setCameraFocus.

@Override
public void setCameraFocus(final String focusName, final float waitTimeSeconds) {
    if (checkString(focusName, "focusName")) {
        SceneGraphNode sgn = getObject(focusName);
        if (sgn instanceof IFocus) {
            IFocus focus = (IFocus) sgn;
            focus = focus.getFocus(focusName);
            NaturalCamera cam = GaiaSky.instance.cameraManager.naturalCamera;
            changeFocus(focus, cam, waitTimeSeconds);
        } else {
            logger.error("FOCUS_MODE object does not exist: " + focusName);
        }
    }
}
Also used : NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera)

Aggregations

NaturalCamera (gaiasky.scenegraph.camera.NaturalCamera)12 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3 IFocus (gaiasky.scenegraph.IFocus)3 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)3 Vector3 (com.badlogic.gdx.math.Vector3)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)2 Array (com.badlogic.gdx.utils.Array)2 OwnLabel (gaiasky.util.scene2d.OwnLabel)2 OwnTextField (gaiasky.util.scene2d.OwnTextField)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Keys (com.badlogic.gdx.Input.Keys)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Action (com.badlogic.gdx.scenes.scene2d.Action)1 Type (com.badlogic.gdx.scenes.scene2d.InputEvent.Type)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)1 Cell (com.badlogic.gdx.scenes.scene2d.ui.Cell)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1