Search in sources :

Example 1 with ComponentType

use of gaiasky.render.ComponentTypes.ComponentType in project gaiasky by langurmonkey.

the class NaturalCamera method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case FOCUS_CHANGE_CMD:
            setTrackingObject(null, null);
            // Check the type of the parameter: IFocus or String
            IFocus focus = null;
            // Center focus or not
            boolean centerFocus = !Settings.settings.runtime.openVr;
            if (data.length > 1)
                centerFocus = (Boolean) data[1];
            if (data[0] instanceof String) {
                SceneGraphNode sgn = GaiaSky.instance.sceneGraph.getNode((String) data[0]);
                if (sgn instanceof IFocus) {
                    focus = (IFocus) sgn;
                    diverted = !centerFocus;
                }
            } else if (data[0] instanceof IFocus) {
                focus = (IFocus) data[0];
                diverted = !centerFocus;
            }
            setFocus(focus);
            checkFocus();
            break;
        case FOV_CHANGED_CMD:
            boolean checkMax = source instanceof Actor;
            float fov = MathUtilsd.clamp((float) data[0], Constants.MIN_FOV, checkMax ? Constants.MAX_FOV : 179f);
            for (PerspectiveCamera cam : cameras) {
                cam.fieldOfView = fov;
            }
            fovFactor = camera.fieldOfView / 40f;
            if (parent.current == this) {
                EventManager.publish(Event.FOV_CHANGE_NOTIFICATION, this, fov, fovFactor);
            }
            break;
        case CUBEMAP_CMD:
            boolean state = (boolean) data[0];
            CubemapProjection p = (CubemapProjection) data[1];
            if (p.isPlanetarium() && state && !Settings.settings.runtime.openVr) {
                fovBackup = GaiaSky.instance.cameraManager.getCamera().fieldOfView;
            }
            break;
        case CAMERA_POS_CMD:
            synchronized (updateLock) {
                pos.set((double[]) data[0]);
                posinv.set(pos).scl(-1d);
            }
            break;
        case CAMERA_DIR_CMD:
            synchronized (updateLock) {
                direction.set((double[]) data[0]).nor();
            }
            break;
        case CAMERA_UP_CMD:
            synchronized (updateLock) {
                up.set((double[]) data[0]).nor();
            }
            break;
        case CAMERA_PROJECTION_CMD:
            synchronized (updateLock) {
                // Position
                pos.set((double[]) data[0]);
                posinv.set(pos).scl(-1d);
                // Direction
                direction.set((double[]) data[1]).nor();
                // Up
                up.set((double[]) data[2]).nor();
                // Change projection flag
                projectionFlag = true;
            }
            break;
        case CAMERA_FWD:
            synchronized (updateLock) {
                addForwardForce((double) data[0]);
            }
            break;
        case CAMERA_ROTATE:
            synchronized (updateLock) {
                addRotateMovement((double) data[0], (double) data[1], false, true);
            }
            break;
        case CAMERA_TURN:
            synchronized (updateLock) {
                addRotateMovement((double) data[0], (double) data[1], true, true);
            }
            break;
        case CAMERA_PAN:
            break;
        case CAMERA_ROLL:
            synchronized (updateLock) {
                addRoll((double) data[0], Settings.settings.scene.camera.cinematic);
            }
            break;
        case CAMERA_STOP:
            synchronized (updateLock) {
                stopTotalMovement();
            }
            break;
        case CAMERA_CENTER:
            synchronized (updateLock) {
                diverted = false;
            }
            break;
        case GO_TO_OBJECT_CMD:
            if (this.focus != null) {
                final IFocus f = this.focus;
                GaiaSky.postRunnable(() -> {
                    setTrackingObject(null, null);
                    // Position camera near focus
                    stopTotalMovement();
                    f.getAbsolutePosition(aux1b);
                    pos.set(aux1b);
                    double dx = 0d;
                    double dy = f.getSize() / 4d;
                    double dz = -f.getSize() * 4d;
                    if (Settings.settings.runtime.openVr) {
                        dz = -dz;
                    }
                    pos.add(dx, dy, dz);
                    posinv.set(pos).scl(-1d);
                    direction.set(aux1b).sub(pos).nor();
                    up.set(direction.x, direction.z, -direction.y).nor();
                    rotate(up, 0.01);
                    updatePerspectiveCamera();
                });
            }
            break;
        case ORIENTATION_LOCK_CMD:
            synchronized (updateLock) {
                previousOrientationAngle = 0;
            }
            break;
        case FREE_MODE_COORD_CMD:
            synchronized (updateLock) {
                double ra = (Double) data[0];
                double dec = (Double) data[1];
                double dist = 1e12d * Constants.PC_TO_U;
                aux1.set(MathUtilsd.degRad * ra, MathUtilsd.degRad * dec, dist);
                Coordinates.sphericalToCartesian(aux1, aux2);
                freeTargetPos.set(aux2);
                facingFocus = false;
                freeTargetOn = true;
            }
            break;
        case FOCUS_NOT_AVAILABLE:
            if (getMode().isFocus()) {
                boolean found = false;
                if (data[0] instanceof IFocus) {
                    focus = (IFocus) data[0];
                    found = isFocus(focus);
                } else if (data[0] instanceof OctreeWrapper) {
                    OctreeWrapper octree = (OctreeWrapper) data[0];
                    OctreeNode octant = this.focus.getOctant();
                    if (octant != null && octant.getRoot() == octree.root) {
                        found = true;
                    }
                } else if (data[0] instanceof GenericCatalog) {
                    GenericCatalog gc = (GenericCatalog) data[0];
                    if (gc.children != null && gc.children.contains((SceneGraphNode) this.focus, true)) {
                        found = true;
                    }
                }
                if (found) {
                    // Set camera  free
                    EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FREE_MODE);
                }
            }
            break;
        case TOGGLE_VISIBILITY_CMD:
            if (getMode().isFocus()) {
                ComponentType ct = ComponentType.getFromKey((String) data[0]);
                if (this.focus != null && ct != null && this.focus.getCt().isEnabled(ct)) {
                    // Set camera  free
                    EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FREE_MODE);
                }
            }
            break;
        case CAMERA_CENTER_FOCUS_CMD:
            synchronized (updateLock) {
                setCenterFocus((Boolean) data[0]);
            }
            break;
        case CONTROLLER_CONNECTED_INFO:
            Settings.settings.controls.gamepad.addControllerListener(controllerListener, (String) data[0]);
            break;
        case CONTROLLER_DISCONNECTED_INFO:
            // Nothing
            break;
        case NEW_DISTANCE_SCALE_FACTOR:
            synchronized (updateLock) {
                DIST_A = 0.1 * Constants.PC_TO_U;
                DIST_B = 5.0 * Constants.KPC_TO_U;
                DIST_C = 5000.0 * Constants.MPC_TO_U;
            }
            break;
        case CAMERA_TRACKING_OBJECT_CMD:
            final IFocus newTrackingObject = (IFocus) data[0];
            final String newTrackingName = (String) data[1];
            synchronized (updateLock) {
                this.setTrackingObject(newTrackingObject, newTrackingName != null ? newTrackingName.toLowerCase() : null);
            }
            break;
        default:
            break;
    }
}
Also used : ComponentType(gaiasky.render.ComponentTypes.ComponentType) OctreeNode(gaiasky.util.tree.OctreeNode) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Actor(com.badlogic.gdx.scenes.scene2d.Actor) CubemapProjection(gaiasky.util.gdx.contrib.postprocess.effects.CubemapProjections.CubemapProjection) OctreeWrapper(gaiasky.scenegraph.octreewrapper.OctreeWrapper)

Example 2 with ComponentType

use of gaiasky.render.ComponentTypes.ComponentType in project gaiasky by langurmonkey.

the class MasterManager method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    int i;
    switch(event) {
        case FOV_CHANGED_CMD:
            if (false) {
                // Each slave has its own fov configured via file/mpcdi
                String sfov = Float.toString((float) data[0]);
                for (String slave : slaves) {
                    if (slaveStates[i] == 0) {
                        HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "setFov?arg0=" + sfov)).GET().build();
                        http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                    }
                    i++;
                }
            }
            break;
        case TOGGLE_VISIBILITY_CMD:
            String key = (String) data[0];
            Boolean state;
            if (data.length == 2) {
                state = (Boolean) data[1];
            } else {
                ComponentType ct = ComponentType.getFromKey(key);
                state = Settings.settings.scene.visibility.get(ct.toString());
            }
            i = 0;
            for (String slave : slaves) {
                if (slaveStates[i] == 0) {
                    HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "setVisibility?arg0=" + key + "&arg1=" + state.toString())).GET().build();
                    http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                }
                i++;
            }
            break;
        case STAR_BRIGHTNESS_CMD:
            float brightness = MathUtilsd.lint((float) data[0], Constants.MIN_STAR_BRIGHTNESS, Constants.MAX_STAR_BRIGHTNESS, Constants.MIN_SLIDER, Constants.MAX_SLIDER);
            String sbr = Float.toString(brightness);
            i = 0;
            for (String slave : slaves) {
                if (slaveStates[i] == 0) {
                    HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "setStarBrightness?arg0=" + sbr)).GET().build();
                    http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                }
                i++;
            }
            break;
        case STAR_POINT_SIZE_CMD:
            float size = (float) data[0];
            String ssize = Float.toString(size);
            i = 0;
            for (String slave : slaves) {
                if (slaveStates[i] == 0) {
                    HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "setStarSize?arg0=" + ssize)).GET().build();
                    http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                }
                i++;
            }
            break;
        case STAR_MIN_OPACITY_CMD:
            float opacity = (float) data[0];
            String sop = Float.toString(opacity);
            i = 0;
            for (String slave : slaves) {
                if (slaveStates[i] == 0) {
                    HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "setMinStarOpacity?arg0=" + sop)).GET().build();
                    http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                }
                i++;
            }
            break;
        case DISPOSE:
            i = 0;
            for (String slave : slaves) {
                if (slaveStates[i] == 0) {
                    HttpRequest req = HttpRequest.newBuilder().uri(URI.create(slave + "quit")).GET().build();
                    http.sendAsync(req, rhandler(i)).thenApply(HttpResponse::body).exceptionally(ehandler(i));
                }
                i++;
            }
            break;
        default:
            break;
    }
}
Also used : HttpRequest(java.net.http.HttpRequest) ComponentType(gaiasky.render.ComponentTypes.ComponentType)

Example 3 with ComponentType

use of gaiasky.render.ComponentTypes.ComponentType in project gaiasky by langurmonkey.

the class IndividualVisibilityWindow method build.

@Override
protected void build() {
    content.clear();
    final String cct = currentComponentType;
    // Components
    float buttonPadHor = 6f;
    int visTableCols = 7;
    Table buttonTable = new Table(skin);
    // Always one button checked
    ButtonGroup<Button> buttonGroup = new ButtonGroup<>();
    buttonGroup.setMinCheckCount(1);
    buttonGroup.setMaxCheckCount(1);
    content.add(buttonTable).top().left().padBottom(pad10).row();
    elementsCell = content.add().top().left();
    ComponentType[] visibilityEntities = ComponentType.values();
    for (int i = 0; i < visibilityEntities.length; i++) {
        final ComponentType ct = visibilityEntities[i];
        final String name = ct.getName();
        if (name != null) {
            Button button;
            if (ct.style != null) {
                Image icon = new Image(skin.getDrawable(ct.style));
                button = new OwnTextIconButton("", icon, skin, "toggle");
            } else {
                button = new OwnTextButton(name, skin, "toggle");
            }
            // Name is the key
            button.setName(ct.key);
            // Tooltip (with or without hotkey)
            String hk = KeyBindings.instance.getStringKeys("action.toggle/" + ct.key);
            if (hk != null) {
                button.addListener(new OwnTextHotkeyTooltip(TextUtils.capitalise(ct.getName()), hk, skin));
            } else {
                button.addListener(new OwnTextTooltip(TextUtils.capitalise(ct.getName()), skin));
            }
            button.addListener(event -> {
                if (event instanceof ChangeListener.ChangeEvent && button.isChecked()) {
                    // Change content only when button is checked!
                    Group elementsList = visibilitySwitcher(ct, TextUtils.capitalise(ct.getName()), ct.getName());
                    elementsCell.clearActor();
                    elementsCell.setActor(elementsList);
                    content.pack();
                    currentComponentType = name;
                    currentCt = ct;
                    return true;
                }
                return false;
            });
            if (name.equals(cct)) {
                button.setChecked(true);
            }
            Cell<?> c = buttonTable.add(button);
            if ((i + 1) % visTableCols == 0) {
                buttonTable.row();
            } else {
                c.padRight(buttonPadHor);
            }
            buttonGroup.add(button);
        }
    }
    if (cct != null)
        buttonGroup.setChecked(cct);
    content.pack();
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) ComponentType(gaiasky.render.ComponentTypes.ComponentType) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 4 with ComponentType

use of gaiasky.render.ComponentTypes.ComponentType in project gaiasky by langurmonkey.

the class ControllerGui method rebuildGui.

@Override
protected void rebuildGui() {
    // Clean up
    content.clear();
    menu.clear();
    tabButtons.clear();
    tabContents.clear();
    model.clear();
    float w = 1440f;
    float h = 640f;
    // Widget width
    float ww = 400f;
    float wh = 64f;
    float sw = ww;
    float sh = 96f;
    float tfw = 240f;
    // Tab width
    float tw = 224f;
    // Create contents
    // SEARCH
    Actor[][] searchModel = new Actor[11][5];
    model.add(searchModel);
    searchT = new Table(skin);
    searchT.setSize(w, h);
    searchField = new OwnTextField("", skin, "big");
    searchField.setProgrammaticChangeEvents(true);
    searchField.setSize(ww, wh);
    searchField.setMessageText("Search...");
    searchField.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            ChangeEvent ie = (ChangeEvent) event;
            if (!searchField.getText().equals(currentInputText) && !searchField.getText().isBlank()) {
                // Process only if text changed
                currentInputText = searchField.getText();
                String name = currentInputText.toLowerCase().trim();
                if (!checkString(name, sg)) {
                    if (name.matches("[0-9]+")) {
                        // Check with 'HIP '
                        checkString("hip " + name, sg);
                    } else if (name.matches("hip [0-9]+") || name.matches("HIP [0-9]+")) {
                        // Check without 'HIP '
                        checkString(name.substring(4), sg);
                    }
                }
            }
        }
        return false;
    });
    searchT.add(searchField).colspan(11).padBottom(pad5).row();
    infoMessage = new OwnLabel("", skin, "default-blue");
    infoCell = searchT.add();
    infoCell.colspan(10).padBottom(pad20).row();
    // First row
    addTextKey("Q", searchModel, 0, 0, false);
    addTextKey("W", searchModel, 1, 0, false);
    addTextKey("E", searchModel, 2, 0, false);
    addTextKey("R", searchModel, 3, 0, false);
    addTextKey("T", searchModel, 4, 0, false);
    addTextKey("Y", searchModel, 5, 0, false);
    addTextKey("U", searchModel, 6, 0, false);
    addTextKey("I", searchModel, 7, 0, false);
    addTextKey("O", searchModel, 8, 0, false);
    addTextKey("P", searchModel, 9, 0, false);
    addTextKey("<--", (event) -> {
        if (event instanceof ChangeEvent) {
            if (!searchField.getText().isBlank()) {
                searchField.setText(searchField.getText().substring(0, searchField.getText().length() - 1));
            }
        }
        return false;
    }, searchModel, 10, 0, true, tfw / 1.5f, pad10, 0);
    // Second row
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("A", searchModel, 1, 1, false);
    addTextKey("S", searchModel, 2, 1, false);
    addTextKey("D", searchModel, 3, 1, false);
    addTextKey("F", searchModel, 4, 1, false);
    addTextKey("G", searchModel, 5, 1, false);
    addTextKey("H", searchModel, 6, 1, false);
    addTextKey("J", searchModel, 7, 1, false);
    addTextKey("K", searchModel, 8, 1, false);
    addTextKey("L", searchModel, 9, 1, false);
    addTextKey("Clear", (event) -> {
        if (event instanceof ChangeEvent) {
            if (!searchField.getText().isBlank()) {
                searchField.setText("");
            }
        }
        return false;
    }, searchModel, 10, 1, true, tfw / 1.5f, pad10, 0);
    // Third row
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("Z", searchModel, 2, 2, false);
    addTextKey("X", searchModel, 3, 2, false);
    addTextKey("C", searchModel, 4, 2, false);
    addTextKey("V", searchModel, 5, 2, false);
    addTextKey("B", searchModel, 6, 2, false);
    addTextKey("N", searchModel, 7, 2, false);
    addTextKey("M", searchModel, 8, 2, false);
    addTextKey("-", searchModel, 9, 2, true);
    // Fourth row
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("SPACE", (event) -> {
        if (event instanceof ChangeEvent) {
            searchField.setText(searchField.getText() + " ");
        }
        return false;
    }, searchModel, 5, 3, false, tfw * 2f, pad5, 6);
    tabContents.add(container(searchT, w, h));
    updatePads(searchT);
    // CAMERA
    Actor[][] cameraModel = new Actor[2][4];
    model.add(cameraModel);
    camT = new Table(skin);
    camT.setSize(w, h);
    CameraManager cm = GaiaSky.instance.getCameraManager();
    // Focus
    cameraFocus = new OwnTextButton(CameraMode.FOCUS_MODE.toStringI18n(), skin, "toggle-big");
    cameraModel[0][0] = cameraFocus;
    cameraFocus.setWidth(ww);
    cameraFocus.setChecked(cm.getMode().isFocus());
    cameraFocus.addListener(event -> {
        if (event instanceof ChangeEvent) {
            if (cameraFocus.isChecked()) {
                em.post(Event.CAMERA_MODE_CMD, cameraFocus, CameraMode.FOCUS_MODE);
                cameraFree.setProgrammaticChangeEvents(false);
                cameraFree.setChecked(false);
                cameraFree.setProgrammaticChangeEvents(true);
            }
            return true;
        }
        return false;
    });
    // Free
    cameraFree = new OwnTextButton(CameraMode.FREE_MODE.toStringI18n(), skin, "toggle-big");
    cameraModel[0][1] = cameraFree;
    cameraFree.setWidth(ww);
    cameraFree.setChecked(cm.getMode().isFree());
    cameraFree.addListener(event -> {
        if (event instanceof ChangeEvent) {
            if (cameraFree.isChecked()) {
                em.post(Event.CAMERA_MODE_CMD, cameraFree, CameraMode.FREE_MODE);
                cameraFocus.setProgrammaticChangeEvents(false);
                cameraFocus.setChecked(false);
                cameraFocus.setProgrammaticChangeEvents(true);
            }
            return true;
        }
        return false;
    });
    // Cinematic
    cameraCinematic = new OwnTextButton(I18n.txt("gui.camera.cinematic"), skin, "toggle-big");
    cameraModel[0][2] = cameraCinematic;
    cameraCinematic.setWidth(ww);
    cameraCinematic.setChecked(Settings.settings.scene.camera.cinematic);
    cameraCinematic.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.CAMERA_CINEMATIC_CMD, cameraCinematic, cameraCinematic.isChecked());
            return true;
        }
        return false;
    });
    // FOV
    fovSlider = new OwnSliderPlus(I18n.txt("gui.camera.fov"), Constants.MIN_FOV, Constants.MAX_FOV, Constants.SLIDER_STEP_SMALL, false, skin);
    cameraModel[1][0] = fovSlider;
    fovSlider.setValueSuffix("°");
    fovSlider.setName("field of view");
    fovSlider.setWidth(sw);
    fovSlider.setHeight(sh);
    fovSlider.setValue(Settings.settings.scene.camera.fov);
    fovSlider.setDisabled(Settings.settings.program.modeCubemap.isFixedFov());
    fovSlider.addListener(event -> {
        if (event instanceof ChangeEvent && !SlaveManager.projectionActive() && !Settings.settings.program.modeCubemap.isFixedFov()) {
            float value = fovSlider.getMappedValue();
            EventManager.publish(Event.FOV_CHANGED_CMD, fovSlider, value);
            return true;
        }
        return false;
    });
    // Speed
    camSpeedSlider = new OwnSliderPlus(I18n.txt("gui.camera.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_CAM_SPEED, Constants.MAX_CAM_SPEED, skin);
    cameraModel[1][1] = camSpeedSlider;
    camSpeedSlider.setName("camera speed");
    camSpeedSlider.setWidth(sw);
    camSpeedSlider.setHeight(sh);
    camSpeedSlider.setMappedValue(Settings.settings.scene.camera.speed);
    camSpeedSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.CAMERA_SPEED_CMD, camSpeedSlider, camSpeedSlider.getMappedValue(), false);
            return true;
        }
        return false;
    });
    // Rot
    camRotSlider = new OwnSliderPlus(I18n.txt("gui.rotation.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_ROT_SPEED, Constants.MAX_ROT_SPEED, skin);
    cameraModel[1][2] = camRotSlider;
    camRotSlider.setName("rotate speed");
    camRotSlider.setWidth(sw);
    camRotSlider.setHeight(sh);
    camRotSlider.setMappedValue(Settings.settings.scene.camera.rotate);
    camRotSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.ROTATION_SPEED_CMD, camRotSlider, camRotSlider.getMappedValue());
            return true;
        }
        return false;
    });
    // Turn
    camTurnSlider = new OwnSliderPlus(I18n.txt("gui.turn.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_TURN_SPEED, Constants.MAX_TURN_SPEED, skin);
    cameraModel[1][3] = camTurnSlider;
    camTurnSlider.setName("turn speed");
    camTurnSlider.setWidth(sw);
    camTurnSlider.setHeight(sh);
    camTurnSlider.setMappedValue(Settings.settings.scene.camera.turn);
    camTurnSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.TURNING_SPEED_CMD, camTurnSlider, camTurnSlider.getMappedValue(), false);
            return true;
        }
        return false;
    });
    camT.add(cameraFocus).padBottom(pad10).padRight(pad30);
    camT.add(fovSlider).padBottom(pad10).row();
    camT.add(cameraFree).padBottom(pad10).padRight(pad30);
    camT.add(camSpeedSlider).padBottom(pad10).row();
    camT.add(cameraCinematic).padBottom(pad10).padRight(pad30);
    camT.add(camRotSlider).padBottom(pad10).row();
    camT.add().padBottom(pad10).padRight(pad30);
    camT.add(camTurnSlider).padBottom(pad10).row();
    tabContents.add(container(camT, w, h));
    updatePads(camT);
    // TIME
    Actor[][] timeModel = new Actor[3][2];
    model.add(timeModel);
    timeT = new Table(skin);
    boolean timeOn = Settings.settings.runtime.timeOn;
    timeStartStop = new OwnTextButton(I18n.txt(timeOn ? "gui.time.pause" : "gui.time.start"), skin, "toggle-big");
    timeModel[1][0] = timeStartStop;
    timeStartStop.setWidth(ww);
    timeStartStop.setChecked(timeOn);
    timeStartStop.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_STATE_CMD, timeStartStop, timeStartStop.isChecked());
            timeStartStop.setText(I18n.txt(timeStartStop.isChecked() ? "gui.time.pause" : "gui.time.start"));
            return true;
        }
        return false;
    });
    timeUp = new OwnTextIconButton(I18n.txt("gui.time.speedup"), Align.right, skin, "fwd");
    timeModel[2][0] = timeUp;
    timeUp.setWidth(ww);
    timeUp.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_WARP_INCREASE_CMD, timeUp);
            return true;
        }
        return false;
    });
    timeDown = new OwnTextIconButton(I18n.txt("gui.time.slowdown"), skin, "bwd");
    timeModel[0][0] = timeDown;
    timeDown.setWidth(ww);
    timeDown.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_WARP_DECREASE_CMD, timeDown);
            return true;
        }
        return false;
    });
    timeReset = new OwnTextIconButton(I18n.txt("action.resettime"), Align.center, skin, "reload");
    timeModel[1][1] = timeReset;
    timeReset.setWidth(ww);
    timeReset.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_CHANGE_CMD, timeReset, Instant.now());
            return true;
        }
        return false;
    });
    timeT.add(timeDown).padBottom(pad30).padRight(pad10);
    timeT.add(timeStartStop).padBottom(pad30).padRight(pad10);
    timeT.add(timeUp).padBottom(pad30).row();
    timeT.add(timeReset).padRight(pad10).padLeft(pad10).colspan(3).padBottom(pad10).row();
    tabContents.add(container(timeT, w, h));
    updatePads(timeT);
    // TYPES
    int visTableCols = 6;
    Actor[][] typesModel = new Actor[visTableCols][7];
    model.add(typesModel);
    typesT = new Table(skin);
    float buttonPadHor = 9.6f;
    float buttonPadVert = 4f;
    Set<Button> buttons = new HashSet<>();
    ComponentType[] visibilityEntities = ComponentType.values();
    boolean[] visible = new boolean[visibilityEntities.length];
    for (int i = 0; i < visibilityEntities.length; i++) visible[i] = GaiaSky.instance.sgr.visible.get(visibilityEntities[i].ordinal());
    if (visibilityEntities != null) {
        int di = 0, dj = 0;
        for (int i = 0; i < visibilityEntities.length; i++) {
            final ComponentType ct = visibilityEntities[i];
            final String name = ct.getName();
            if (name != null) {
                Button button;
                if (ct.style != null) {
                    Image icon = new Image(skin.getDrawable(ct.style));
                    button = new OwnTextIconButton("", icon, skin, "toggle");
                } else {
                    button = new OwnTextButton(name, skin, "toggle");
                }
                // Name is the key
                button.setName(ct.key);
                typesModel[di][dj] = button;
                button.setChecked(visible[i]);
                button.addListener(event -> {
                    if (event instanceof ChangeEvent) {
                        EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, button, ct.key, button.isChecked());
                        return true;
                    }
                    return false;
                });
                Cell c = typesT.add(button).padBottom(buttonPadVert).left();
                if ((i + 1) % visTableCols == 0) {
                    typesT.row();
                    di = 0;
                    dj++;
                } else {
                    c.padRight(buttonPadHor);
                    di++;
                }
                buttons.add(button);
            }
        }
    }
    typesT.setSize(w, h);
    tabContents.add(container(typesT, w, h));
    updatePads(typesT);
    // OPTIONS
    Actor[][] optionsModel = new Actor[1][4];
    model.add(optionsModel);
    optT = new Table(skin);
    // Slider
    bloomSlider = new OwnSliderPlus(I18n.txt("gui.bloom"), Constants.MIN_SLIDER, Constants.MAX_SLIDER * 0.2f, 1f, false, skin, "ui-19");
    bloomSlider.setWidth(sw);
    bloomSlider.setHeight(sh);
    bloomSlider.setValue(Settings.settings.postprocess.bloom.intensity * 10f);
    bloomSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.BLOOM_CMD, bloomSlider, bloomSlider.getValue() / 10f);
            return true;
        }
        return false;
    });
    optionsModel[0][0] = bloomSlider;
    optT.add(bloomSlider).padBottom(pad10).row();
    // Lens flare
    flareButton = new OwnTextButton(I18n.txt("gui.lensflare"), skin, "toggle-big");
    optionsModel[0][1] = flareButton;
    flareButton.setWidth(ww);
    flareButton.setChecked(Settings.settings.postprocess.lensFlare);
    flareButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.LENS_FLARE_CMD, flareButton, flareButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(flareButton).padBottom(pad10).row();
    // Star glow
    starGlowButton = new OwnTextButton(I18n.txt("gui.lightscattering"), skin, "toggle-big");
    optionsModel[0][2] = starGlowButton;
    starGlowButton.setWidth(ww);
    starGlowButton.setChecked(Settings.settings.postprocess.lightGlow);
    starGlowButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.LIGHT_SCATTERING_CMD, starGlowButton, starGlowButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(starGlowButton).padBottom(pad10).row();
    // Motion blur
    motionBlurButton = new OwnTextButton(I18n.txt("gui.motionblur"), skin, "toggle-big");
    optionsModel[0][3] = motionBlurButton;
    motionBlurButton.setWidth(ww);
    motionBlurButton.setChecked(Settings.settings.postprocess.motionBlur);
    motionBlurButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.MOTION_BLUR_CMD, motionBlurButton, motionBlurButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(motionBlurButton);
    tabContents.add(container(optT, w, h));
    updatePads(optT);
    // SYSTEM
    Actor[][] systemModel = new Actor[1][1];
    model.add(systemModel);
    sysT = new Table(skin);
    quit = new OwnTextIconButton(I18n.txt("gui.quit.title"), Align.center, skin, "quit");
    systemModel[0][0] = quit;
    quit.setWidth(ww);
    quit.addListener(event -> {
        if (event instanceof ChangeEvent) {
            GaiaSky.postRunnable(() -> Gdx.app.exit());
            return true;
        }
        return false;
    });
    sysT.add(quit);
    tabContents.add(container(sysT, w, h));
    updatePads(sysT);
    // Create tab buttons
    searchButton = new OwnTextButton(I18n.txt("gui.search"), skin, "toggle-big");
    tabButtons.add(searchButton);
    searchButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(searchButton);
            updateTabs();
        }
        return false;
    });
    cameraButton = new OwnTextButton(I18n.txt("gui.camera"), skin, "toggle-big");
    tabButtons.add(cameraButton);
    cameraButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(cameraButton);
            updateTabs();
        }
        return false;
    });
    timeButton = new OwnTextButton(I18n.txt("gui.time"), skin, "toggle-big");
    tabButtons.add(timeButton);
    timeButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(timeButton);
            updateTabs();
        }
        return false;
    });
    typesButton = new OwnTextButton(I18n.txt("gui.types"), skin, "toggle-big");
    tabButtons.add(typesButton);
    typesButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(typesButton);
            updateTabs();
        }
        return false;
    });
    optionsButton = new OwnTextButton(I18n.txt("gui.options"), skin, "toggle-big");
    tabButtons.add(optionsButton);
    optionsButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(optionsButton);
            updateTabs();
        }
        return false;
    });
    systemButton = new OwnTextButton(I18n.txt("gui.system"), skin, "toggle-big");
    tabButtons.add(systemButton);
    systemButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(systemButton);
            updateTabs();
        }
        return false;
    });
    for (OwnTextButton b : tabButtons) {
        b.pad(pad10);
        b.setMinWidth(tw);
    }
    // Left and Right indicators
    OwnTextButton lb, rb;
    rb = new OwnTextIconButton("RB", Align.right, skin, "caret-right");
    rb.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            tabRight();
        }
        return false;
    });
    rb.pad(pad10);
    lb = new OwnTextIconButton("LB", Align.left, skin, "caret-left");
    lb.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            tabLeft();
        }
        return false;
    });
    lb.pad(pad10);
    menu.add(lb).center().padBottom(pad10).padRight(pad30);
    menu.add(searchButton).center().padBottom(pad10);
    menu.add(cameraButton).center().padBottom(pad10);
    menu.add(timeButton).center().padBottom(pad10);
    menu.add(typesButton).center().padBottom(pad10);
    menu.add(optionsButton).center().padBottom(pad10);
    menu.add(systemButton).center().padBottom(pad10);
    menu.add(rb).center().padBottom(pad10).padLeft(pad30).row();
    contentCell = menu.add().colspan(7);
    Table padTable = new Table(skin);
    padTable.pad(pad30);
    padTable.setBackground("table-border");
    menu.pack();
    padTable.add(menu).center();
    content.add(padTable);
    content.setFillParent(true);
    content.center();
    content.pack();
    updateTabs();
    updateFocused(true);
    if (sg == null)
        sg = GaiaSky.instance.sceneGraph;
}
Also used : ComponentType(gaiasky.render.ComponentTypes.ComponentType) CameraManager(gaiasky.scenegraph.camera.CameraManager) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) Actor(com.badlogic.gdx.scenes.scene2d.Actor) HashSet(java.util.HashSet)

Example 5 with ComponentType

use of gaiasky.render.ComponentTypes.ComponentType in project gaiasky by langurmonkey.

the class DatasetLoadDialog method addParticlesWidget.

private void addParticlesWidget(Table container) {
    OwnLabel particleProps = new OwnLabel(I18n.txt("gui.dsload.particles.properties"), skin, "hud-subheader");
    container.add(particleProps).colspan(2).left().padTop(pad15).padBottom(pad10).row();
    // Name
    addFileName(container);
    // Particle color
    addParticleColor(container);
    // Color noise
    colorNoise = new OwnSliderPlus(I18n.txt("gui.dsload.color.noise"), Constants.MIN_COLOR_NOISE, Constants.MAX_COLOR_NOISE, Constants.SLIDER_STEP_TINY, false, skin);
    colorNoise.setName("profile decay");
    colorNoise.setWidth(sliderWidth);
    colorNoise.setValue(0.2f);
    colorNoise.addListener(event -> {
        if (event instanceof ChangeEvent) {
            updateFrameBuffer();
            return true;
        }
        return false;
    });
    container.add(GuiUtils.tooltipHg(colorNoise, "gui.dsload.color.noise.tooltip", skin)).colspan(2).left().padBottom(pad15).row();
    // Label color
    addLabelColor(container);
    // Particle size
    particleSize = new OwnSliderPlus(I18n.txt("gui.dsload.size"), Constants.MIN_PARTICLE_SIZE, Constants.MAX_PARTICLE_SIZE, Constants.SLIDER_STEP_SMALL, false, skin);
    particleSize.setName("profile decay");
    particleSize.setWidth(sliderWidth);
    particleSize.setValue(10f);
    particleSize.addListener(event -> {
        if (event instanceof ChangeEvent) {
            updateFrameBuffer();
            return true;
        }
        return false;
    });
    container.add(particleSize).colspan(2).left().padBottom(pad10).row();
    // Profile falloff
    FloatValidator falloffVal = new FloatValidator(0.3f, 200f);
    profileDecay = new OwnTextField("5.0", skin, falloffVal);
    profileDecay.setWidth(fieldWidth);
    container.add(new OwnLabel(I18n.txt("gui.dsload.profiledecay"), skin, titleWidth)).left().padRight(pad10).padBottom(pad15);
    container.add(GuiUtils.tooltipHg(profileDecay, "gui.dsload.profiledecay.tooltip", skin)).left().padBottom(pad15).row();
    // Component type
    ComponentType[] componentTypes = new ComponentType[] { ComponentType.Others, ComponentType.Stars, ComponentType.Galaxies, ComponentType.Clusters, ComponentType.Asteroids, ComponentType.Locations };
    componentType = new OwnSelectBox<>(skin);
    componentType.setWidth(fieldWidth);
    componentType.setItems(componentTypes);
    componentType.setSelected(ComponentType.Galaxies);
    container.add(new OwnLabel(I18n.txt("gui.dsload.ct"), skin, titleWidth)).left().padRight(pad10).padBottom(pad5);
    container.add(componentType).left().padBottom(pad5).row();
    // Fade
    addFadeAttributes(container);
}
Also used : ComponentType(gaiasky.render.ComponentTypes.ComponentType) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) FloatValidator(gaiasky.util.validator.FloatValidator)

Aggregations

ComponentType (gaiasky.render.ComponentTypes.ComponentType)12 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Group (com.badlogic.gdx.scenes.scene2d.Group)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 Timer (com.badlogic.gdx.utils.Timer)1 DatasetOptions (gaiasky.data.group.DatasetOptions)1 ComboBoxBean (gaiasky.interafce.beans.ComboBoxBean)1 CameraManager (gaiasky.scenegraph.camera.CameraManager)1 OctreeWrapper (gaiasky.scenegraph.octreewrapper.OctreeWrapper)1 CubemapProjection (gaiasky.util.gdx.contrib.postprocess.effects.CubemapProjections.CubemapProjection)1 OwnLabel (gaiasky.util.scene2d.OwnLabel)1 OctreeNode (gaiasky.util.tree.OctreeNode)1 VersionCheckEvent (gaiasky.util.update.VersionCheckEvent)1 VersionChecker (gaiasky.util.update.VersionChecker)1 FloatValidator (gaiasky.util.validator.FloatValidator)1 HttpRequest (java.net.http.HttpRequest)1 HashSet (java.util.HashSet)1