Search in sources :

Example 1 with OwnLabel

use of gaiasky.util.scene2d.OwnLabel in project gaiasky by langurmonkey.

the class GuiUtils method addNoConnectionWindow.

public static void addNoConnectionWindow(Skin skin, Stage stage, Runnable ok) {
    GenericDialog exitw = new GenericDialog(I18n.txt("notif.error", I18n.txt("gui.download.noconnection.title")), skin, stage) {

        @Override
        protected void build() {
            OwnLabel info = new OwnLabel(I18n.txt("gui.download.noconnection.continue"), skin);
            Link manualDownload = new Link(I18n.txt("gui.download.manual"), skin, "link", Settings.settings.program.url.dataMirror);
            content.add(info).pad(10).row();
            content.add(manualDownload).pad(10);
        }

        @Override
        protected void accept() {
            if (ok != null) {
                ok.run();
            }
        }

        @Override
        protected void cancel() {
        }

        @Override
        public void dispose() {
        }
    };
    exitw.setAcceptText(I18n.txt("gui.ok"));
    exitw.setCancelText(null);
    exitw.buildSuper();
    exitw.show(stage);
}
Also used : GenericDialog(gaiasky.interafce.GenericDialog) OwnLabel(gaiasky.util.scene2d.OwnLabel) Link(gaiasky.util.scene2d.Link)

Example 2 with OwnLabel

use of gaiasky.util.scene2d.OwnLabel in project gaiasky by langurmonkey.

the class GuiUtils method addNoVRDataExit.

public static void addNoVRDataExit(Skin skin, Stage stage) {
    GenericDialog exitw = new GenericDialog(I18n.txt("notif.error", I18n.txt("gui.vr.nodata.title")), skin, stage) {

        @Override
        protected void build() {
            OwnLabel info1 = new OwnLabel(I18n.txt("gui.vr.nodata.1"), skin);
            OwnLabel info2 = new OwnLabel(I18n.txt("gui.vr.nodata.2"), skin);
            OwnLabel gsExit = new OwnLabel(I18n.txt("notif.gaiasky.exit"), skin);
            content.add(info1).left().padTop(10).padBottom(5).row();
            content.add(info2).left().padBottom(10).row();
            content.add(gsExit).left().padTop(10).row();
        }

        @Override
        protected void accept() {
            Gdx.app.exit();
        }

        @Override
        protected void cancel() {
            Gdx.app.exit();
        }

        @Override
        public void dispose() {
        }
    };
    exitw.setAcceptText(I18n.txt("gui.exit"));
    exitw.setCancelText(null);
    exitw.buildSuper();
    exitw.show(stage);
}
Also used : GenericDialog(gaiasky.interafce.GenericDialog) OwnLabel(gaiasky.util.scene2d.OwnLabel)

Example 3 with OwnLabel

use of gaiasky.util.scene2d.OwnLabel in project gaiasky by langurmonkey.

the class GuiUtils method addNoConnectionExit.

public static void addNoConnectionExit(Skin skin, Stage stage) {
    GenericDialog exitw = new GenericDialog(I18n.txt("notif.error", I18n.txt("gui.download.noconnection.title")), skin, stage) {

        @Override
        protected void build() {
            OwnLabel info = new OwnLabel(I18n.txt("gui.download.noconnection"), skin);
            OwnLabel gsExit = new OwnLabel(I18n.txt("notif.gaiasky.exit"), skin);
            Link manualDownload = new Link(I18n.txt("gui.download.manual"), skin, "link", "https://gaia.ari.uni-heidelberg.de/gaiasky/files/autodownload");
            content.add(info).left().pad(10).row();
            content.add(gsExit).left().pad(10).row();
            content.add(manualDownload).pad(10);
        }

        @Override
        protected void accept() {
            Gdx.app.exit();
        }

        @Override
        protected void cancel() {
            Gdx.app.exit();
        }

        @Override
        public void dispose() {
        }
    };
    exitw.setAcceptText(I18n.txt("gui.exit"));
    exitw.setCancelText(null);
    exitw.buildSuper();
    exitw.show(stage);
}
Also used : GenericDialog(gaiasky.interafce.GenericDialog) OwnLabel(gaiasky.util.scene2d.OwnLabel) Link(gaiasky.util.scene2d.Link)

Example 4 with OwnLabel

use of gaiasky.util.scene2d.OwnLabel in project gaiasky by langurmonkey.

the class TipGenerator method addTip.

private void addTip(WidgetGroup g, String[] tip) {
    float pad5 = 8f;
    float pad2 = 3.2f;
    g.clear();
    for (String part : tip) {
        boolean def = true;
        String style = "main-title-s";
        String text = part;
        if (part.startsWith("%%")) {
            int idx = text.indexOf(" ");
            text = part.substring(idx + 1);
            style = part.substring(2, idx);
            def = false;
        }
        if (skin.has(style, Label.LabelStyle.class)) {
            OwnLabel label = new OwnLabel(text, skin, style);
            if (def) {
                label.setColor(0.5f, 0.5f, 0.5f, 1f);
                g.addActor(label);
            }
            g.addActor(label);
        } else if (skin.has(style, TextButton.TextButtonStyle.class)) {
            String[] keys = text.split("\\+");
            int n = keys.length;
            for (int i = 0; i < n; i++) {
                OwnTextButton button = new OwnTextButton(keys[i], skin, style);
                button.pad(pad2, pad5, pad2, pad5);
                g.addActor(button);
                if (i < n - 1) {
                    OwnLabel plus = new OwnLabel("+", skin, "main-title-s");
                    plus.setColor(0.5f, 0.5f, 0.5f, 1f);
                    g.addActor(plus);
                }
            }
        }
    }
}
Also used : OwnTextButton(gaiasky.util.scene2d.OwnTextButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) OwnLabel(gaiasky.util.scene2d.OwnLabel) OwnLabel(gaiasky.util.scene2d.OwnLabel)

Example 5 with OwnLabel

use of gaiasky.util.scene2d.OwnLabel 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)

Aggregations

OwnLabel (gaiasky.util.scene2d.OwnLabel)32 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)10 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)10 OwnTextField (gaiasky.util.scene2d.OwnTextField)8 Stage (com.badlogic.gdx.scenes.scene2d.Stage)7 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)5 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)4 GenericDialog (gaiasky.interafce.GenericDialog)4 Texture (com.badlogic.gdx.graphics.Texture)3 Actor (com.badlogic.gdx.scenes.scene2d.Actor)3 Task (com.badlogic.gdx.utils.Timer.Task)3 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)3 Link (gaiasky.util.scene2d.Link)3 OwnCheckBox (gaiasky.util.scene2d.OwnCheckBox)3 OwnTextButton (gaiasky.util.scene2d.OwnTextButton)3 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)2 Container (com.badlogic.gdx.scenes.scene2d.ui.Container)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)2