Search in sources :

Example 1 with CameraMode

use of gaiasky.scenegraph.camera.CameraManager.CameraMode in project gaiasky by langurmonkey.

the class Spacecraft method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case CAMERA_MODE_CMD:
            CameraMode mode = (CameraMode) data[0];
            render = mode == CameraMode.SPACECRAFT_MODE;
            break;
        case SPACECRAFT_STABILISE_CMD:
            leveling = (Boolean) data[0];
            break;
        case SPACECRAFT_STOP_CMD:
            stopping = (Boolean) data[0];
            break;
        case SPACECRAFT_THRUST_DECREASE_CMD:
            decreaseThrustFactorIndex(true);
            break;
        case SPACECRAFT_THRUST_INCREASE_CMD:
            increaseThrustFactorIndex(true);
            break;
        case SPACECRAFT_THRUST_SET_CMD:
            setThrustFactorIndex((Integer) data[0], false);
            break;
        case SPACECRAFT_MACHINE_SELECTION_CMD:
            int newMachineIndex = (Integer) data[0];
            // Update machine
            GaiaSky.postRunnable(() -> {
                this.setToMachine(machines[newMachineIndex], true);
                this.currentMachine = newMachineIndex;
                EventManager.publish(Event.SPACECRAFT_MACHINE_SELECTION_INFO, this, machines[newMachineIndex]);
            });
            break;
        default:
            break;
    }
}
Also used : CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode)

Example 2 with CameraMode

use of gaiasky.scenegraph.camera.CameraManager.CameraMode in project gaiasky by langurmonkey.

the class CameraComponent method initialize.

@Override
public void initialize() {
    final float contentWidth = ControlsWindow.getContentWidth();
    cinematic = new OwnCheckBox(I18n.txt("gui.camera.cinematic"), skin, pad8);
    cinematic.setName("cinematic camera");
    cinematic.setChecked(Settings.settings.scene.camera.cinematic);
    cinematic.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.CAMERA_CINEMATIC_CMD, cinematic, cinematic.isChecked());
            return true;
        }
        return false;
    });
    final Label modeLabel = new Label(I18n.txt("gui.camera.mode"), skin, "default");
    final int cameraModes = CameraMode.values().length;
    final CameraComboBoxBean[] cameraOptions = new CameraComboBoxBean[cameraModes];
    for (int i = 0; i < cameraModes; i++) {
        cameraOptions[i] = new CameraComboBoxBean(Objects.requireNonNull(CameraMode.getMode(i)).toStringI18n(), CameraMode.getMode(i));
    }
    cameraMode = new OwnSelectBox<>(skin);
    cameraMode.setName("camera mode");
    cameraMode.setWidth(contentWidth);
    cameraMode.setItems(cameraOptions);
    cameraMode.addListener(event -> {
        if (event instanceof ChangeEvent) {
            CameraComboBoxBean selection = cameraMode.getSelected();
            CameraMode mode = selection.mode;
            EventManager.publish(Event.CAMERA_MODE_CMD, cameraMode, mode);
            return true;
        }
        return false;
    });
    if (!Settings.settings.runtime.openVr) {
        final Image icon3d = new Image(skin.getDrawable("3d-icon"));
        button3d = new OwnTextIconButton("", icon3d, skin, "toggle");
        final String hk3d = KeyBindings.instance.getStringKeys("action.toggle/element.stereomode");
        button3d.addListener(new OwnTextHotkeyTooltip(TextUtils.capitalise(I18n.txt("element.stereomode")), hk3d, skin));
        button3d.setName("3d");
        button3d.addListener(event -> {
            if (event instanceof ChangeEvent) {
                if (button3d.isChecked()) {
                    buttonCubemap.setProgrammaticChangeEvents(true);
                    buttonCubemap.setChecked(false);
                    buttonDome.setProgrammaticChangeEvents(true);
                    buttonDome.setChecked(false);
                }
                // Enable/disable
                EventManager.publish(Event.STEREOSCOPIC_CMD, button3d, button3d.isChecked());
                return true;
            }
            return false;
        });
        final Image iconDome = new Image(skin.getDrawable("dome-icon"));
        buttonDome = new OwnTextIconButton("", iconDome, skin, "toggle");
        final String hkDome = KeyBindings.instance.getStringKeys("action.toggle/element.planetarium");
        buttonDome.addListener(new OwnTextHotkeyTooltip(TextUtils.capitalise(I18n.txt("element.planetarium")), hkDome, skin));
        buttonDome.setName("dome");
        buttonDome.addListener(event -> {
            if (event instanceof ChangeEvent) {
                if (buttonDome.isChecked()) {
                    buttonCubemap.setProgrammaticChangeEvents(true);
                    buttonCubemap.setChecked(false);
                    button3d.setProgrammaticChangeEvents(true);
                    button3d.setChecked(false);
                }
                // Enable/disable
                EventManager.publish(Event.CUBEMAP_CMD, buttonDome, buttonDome.isChecked(), CubemapProjection.FISHEYE);
                fieldOfView.setDisabled(buttonDome.isChecked());
                return true;
            }
            return false;
        });
        final Image iconCubemap = new Image(skin.getDrawable("cubemap-icon"));
        buttonCubemap = new OwnTextIconButton("", iconCubemap, skin, "toggle");
        buttonCubemap.setProgrammaticChangeEvents(false);
        final String hkCubemap = KeyBindings.instance.getStringKeys("action.toggle/element.360");
        buttonCubemap.addListener(new OwnTextHotkeyTooltip(TextUtils.capitalise(I18n.txt("element.360")), hkCubemap, skin));
        buttonCubemap.setName("cubemap");
        buttonCubemap.addListener(event -> {
            if (event instanceof ChangeEvent) {
                if (buttonCubemap.isChecked()) {
                    buttonDome.setProgrammaticChangeEvents(true);
                    buttonDome.setChecked(false);
                    button3d.setProgrammaticChangeEvents(true);
                    button3d.setChecked(false);
                }
                // Enable/disable
                EventManager.publish(Event.CUBEMAP_CMD, buttonCubemap, buttonCubemap.isChecked(), CubemapProjection.EQUIRECTANGULAR);
                fieldOfView.setDisabled(buttonCubemap.isChecked());
                return true;
            }
            return false;
        });
        if (Settings.settings.program.net.isMasterInstance()) {
            final Image iconMaster = new Image(skin.getDrawable("iconic-link-intact"));
            buttonMaster = new OwnTextIconButton("", iconMaster, skin, "default");
            buttonMaster.setProgrammaticChangeEvents(false);
            buttonMaster.setSize(28f, 29.6f);
            final String hkmaster = KeyBindings.instance.getStringKeys("action.slave.configure");
            buttonMaster.addListener(new OwnTextHotkeyTooltip(TextUtils.capitalise(I18n.txt("element.slave.config")), hkmaster, skin));
            buttonMaster.setName("master");
            buttonMaster.addListener(event -> {
                if (event instanceof ChangeEvent) {
                    // Enable/disable
                    EventManager.publish(Event.SHOW_SLAVE_CONFIG_ACTION, buttonMaster);
                    return true;
                }
                return false;
            });
        }
    }
    fieldOfView = new OwnSliderPlus(I18n.txt("gui.camera.fov"), Constants.MIN_FOV, Constants.MAX_FOV, Constants.SLIDER_STEP_SMALL, false, skin);
    fieldOfView.setValueSuffix("°");
    fieldOfView.setName("field of view");
    fieldOfView.setWidth(contentWidth);
    fieldOfView.setValue(Settings.settings.scene.camera.fov);
    fieldOfView.setDisabled(Settings.settings.program.modeCubemap.isFixedFov());
    fieldOfView.addListener(event -> {
        if (fovFlag && event instanceof ChangeEvent && !SlaveManager.projectionActive() && !Settings.settings.program.modeCubemap.isFixedFov()) {
            final float value = fieldOfView.getMappedValue();
            EventManager.publish(Event.FOV_CHANGED_CMD, fieldOfView, value);
            return true;
        }
        return false;
    });
    // CAMERA SPEED LIMIT
    final String[] speedLimits = new String[19];
    speedLimits[0] = I18n.txt("gui.camera.speedlimit.100kmh");
    speedLimits[1] = I18n.txt("gui.camera.speedlimit.cfactor", "0.5");
    speedLimits[2] = I18n.txt("gui.camera.speedlimit.cfactor", "0.8");
    speedLimits[3] = I18n.txt("gui.camera.speedlimit.cfactor", "0.9");
    speedLimits[4] = I18n.txt("gui.camera.speedlimit.cfactor", "0.99");
    speedLimits[5] = I18n.txt("gui.camera.speedlimit.cfactor", "0.99999");
    speedLimits[6] = I18n.txt("gui.camera.speedlimit.c");
    speedLimits[7] = I18n.txt("gui.camera.speedlimit.cfactor", 2);
    speedLimits[8] = I18n.txt("gui.camera.speedlimit.cfactor", 10);
    speedLimits[9] = I18n.txt("gui.camera.speedlimit.cfactor", 1000);
    speedLimits[10] = I18n.txt("gui.camera.speedlimit.aus", 1);
    speedLimits[11] = I18n.txt("gui.camera.speedlimit.aus", 10);
    speedLimits[12] = I18n.txt("gui.camera.speedlimit.aus", 1000);
    speedLimits[13] = I18n.txt("gui.camera.speedlimit.aus", 10000);
    speedLimits[14] = I18n.txt("gui.camera.speedlimit.pcs", 1);
    speedLimits[15] = I18n.txt("gui.camera.speedlimit.pcs", 2);
    speedLimits[16] = I18n.txt("gui.camera.speedlimit.pcs", 10);
    speedLimits[17] = I18n.txt("gui.camera.speedlimit.pcs", 1000);
    speedLimits[18] = I18n.txt("gui.camera.speedlimit.nolimit");
    cameraSpeedLimit = new OwnSelectBox<>(skin);
    cameraSpeedLimit.setName("camera speed limit");
    cameraSpeedLimit.setWidth(contentWidth);
    cameraSpeedLimit.setItems(speedLimits);
    cameraSpeedLimit.addListener(event -> {
        if (event instanceof ChangeEvent) {
            final int idx = cameraSpeedLimit.getSelectedIndex();
            EventManager.publish(Event.SPEED_LIMIT_CMD, cameraSpeedLimit, idx);
            return true;
        }
        return false;
    });
    cameraSpeedLimit.setSelectedIndex(Settings.settings.scene.camera.speedLimitIndex);
    // CAMERA SPEED
    cameraSpeed = 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);
    cameraSpeed.setName("camera speed");
    cameraSpeed.setWidth(contentWidth);
    cameraSpeed.setMappedValue(Settings.settings.scene.camera.speed);
    cameraSpeed.addListener(event -> {
        if (!fieldLock && event instanceof ChangeEvent) {
            EventManager.publish(Event.CAMERA_SPEED_CMD, cameraSpeed, cameraSpeed.getMappedValue());
            return true;
        }
        return false;
    });
    // ROTATION SPEED
    rotateSpeed = 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);
    rotateSpeed.setName("rotate speed");
    rotateSpeed.setWidth(contentWidth);
    rotateSpeed.setMappedValue(Settings.settings.scene.camera.rotate);
    rotateSpeed.addListener(event -> {
        if (!fieldLock && event instanceof ChangeEvent) {
            EventManager.publish(Event.ROTATION_SPEED_CMD, rotateSpeed, rotateSpeed.getMappedValue());
            return true;
        }
        return false;
    });
    // TURNING SPEED
    turnSpeed = 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);
    turnSpeed.setName("turn speed");
    turnSpeed.setWidth(contentWidth);
    turnSpeed.setMappedValue(Settings.settings.scene.camera.turn);
    turnSpeed.addListener(event -> {
        if (!fieldLock && event instanceof ChangeEvent) {
            EventManager.publish(Event.TURNING_SPEED_CMD, turnSpeed, turnSpeed.getMappedValue(), true);
            return true;
        }
        return false;
    });
    // FOCUS_MODE lock
    focusLock = new CheckBox(" " + I18n.txt("gui.camera.lock"), skin);
    focusLock.setName("focus lock");
    focusLock.setChecked(Settings.settings.scene.camera.focusLock.position);
    focusLock.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.FOCUS_LOCK_CMD, focusLock, I18n.txt("gui.camera.lock"), focusLock.isChecked());
            orientationLock.setVisible(focusLock.isChecked());
            return true;
        }
        return false;
    });
    // FOCUS_MODE orientation lock
    orientationLock = new CheckBox(" " + I18n.txt("gui.camera.lock.orientation"), skin);
    orientationLock.setName("orientation lock");
    orientationLock.setChecked(Settings.settings.scene.camera.focusLock.orientation);
    orientationLock.setVisible(Settings.settings.scene.camera.focusLock.position);
    orientationLock.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.ORIENTATION_LOCK_CMD, orientationLock, I18n.txt("gui.camera.lock.orientation"), orientationLock.isChecked());
            return true;
        }
        return false;
    });
    HorizontalGroup buttonGroup = null;
    if (!Settings.settings.runtime.openVr) {
        buttonGroup = new HorizontalGroup();
        buttonGroup.space(pad4);
        buttonGroup.addActor(button3d);
        buttonGroup.addActor(buttonDome);
        buttonGroup.addActor(buttonCubemap);
        if (Settings.settings.program.net.isMasterInstance())
            buttonGroup.addActor(buttonMaster);
    }
    final Table cameraGroup = new Table(skin);
    cameraGroup.align(Align.left);
    cameraGroup.add(group(modeLabel, cameraMode, pad3)).top().left().padBottom(pad9).row();
    cameraGroup.add(group(new Label(I18n.txt("gui.camera.speedlimit"), skin, "default"), cameraSpeedLimit, pad3)).top().left().padBottom(pad9).row();
    cameraGroup.add(fieldOfView).top().left().padBottom(pad9).row();
    cameraGroup.add(cameraSpeed).top().left().padBottom(pad9).row();
    cameraGroup.add(rotateSpeed).top().left().padBottom(pad9).row();
    cameraGroup.add(turnSpeed).top().left().padBottom(pad9).row();
    cameraGroup.add(cinematic).top().left().padBottom(pad9).row();
    cameraGroup.add(focusLock).top().left().padBottom(pad9).row();
    cameraGroup.add(orientationLock).top().left().padBottom(pad9).row();
    if (!Settings.settings.runtime.openVr)
        cameraGroup.add(group(new Label("", skin), buttonGroup, pad3)).top().center();
    component = cameraGroup;
    cameraGroup.pack();
    EventManager.instance.subscribe(this, Event.CAMERA_MODE_CMD, Event.ROTATION_SPEED_CMD, Event.TURNING_SPEED_CMD, Event.CAMERA_SPEED_CMD, Event.SPEED_LIMIT_CMD, Event.STEREOSCOPIC_CMD, Event.FOV_CHANGE_NOTIFICATION, Event.CUBEMAP_CMD, Event.CAMERA_CINEMATIC_CMD, Event.ORIENTATION_LOCK_CMD);
}
Also used : CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) CameraComboBoxBean(gaiasky.interafce.beans.CameraComboBoxBean) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)

Example 3 with CameraMode

use of gaiasky.scenegraph.camera.CameraManager.CameraMode in project gaiasky by langurmonkey.

the class CameraComponent method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case CAMERA_CINEMATIC_CMD:
            final boolean gui = source == cinematic;
            if (!gui) {
                cinematic.setProgrammaticChangeEvents(false);
                cinematic.setChecked((Boolean) data[0]);
                cinematic.setProgrammaticChangeEvents(true);
            }
            break;
        case CAMERA_MODE_CMD:
            // Update camera mode selection
            final CameraMode mode = (CameraMode) data[0];
            Array<CameraComboBoxBean> cModes = cameraMode.getItems();
            CameraComboBoxBean selected = null;
            for (CameraComboBoxBean ccbb : cModes) {
                if (ccbb.mode == mode) {
                    selected = ccbb;
                    break;
                }
            }
            if (selected != null) {
                cameraMode.getSelection().setProgrammaticChangeEvents(false);
                cameraMode.setSelected(selected);
                cameraMode.getSelection().setProgrammaticChangeEvents(true);
            }
            break;
        case ROTATION_SPEED_CMD:
            if (source != rotateSpeed) {
                float value = (Float) data[0];
                fieldLock = true;
                rotateSpeed.setMappedValue(value);
                fieldLock = false;
            }
            break;
        case CAMERA_SPEED_CMD:
            if (source != cameraSpeed) {
                final float value = (Float) data[0];
                fieldLock = true;
                cameraSpeed.setMappedValue(value);
                fieldLock = false;
            }
            break;
        case TURNING_SPEED_CMD:
            if (source != turnSpeed) {
                final float value = (Float) data[0];
                fieldLock = true;
                turnSpeed.setMappedValue(value);
                fieldLock = false;
            }
            break;
        case SPEED_LIMIT_CMD:
            if (source != cameraSpeedLimit) {
                final int value = (Integer) data[0];
                cameraSpeedLimit.getSelection().setProgrammaticChangeEvents(false);
                cameraSpeedLimit.setSelectedIndex(value);
                cameraSpeedLimit.getSelection().setProgrammaticChangeEvents(true);
            }
            break;
        case ORIENTATION_LOCK_CMD:
            if (source != orientationLock) {
                final boolean lock = (Boolean) data[1];
                orientationLock.setProgrammaticChangeEvents(false);
                orientationLock.setChecked(lock);
                orientationLock.setProgrammaticChangeEvents(true);
            }
            break;
        case STEREOSCOPIC_CMD:
            if (source != button3d && !Settings.settings.runtime.openVr) {
                button3d.setProgrammaticChangeEvents(false);
                button3d.setChecked((boolean) data[0]);
                button3d.setProgrammaticChangeEvents(true);
            }
            break;
        case FOV_CHANGE_NOTIFICATION:
            fovFlag = false;
            fieldOfView.setValue(Settings.settings.scene.camera.fov);
            fovFlag = true;
            break;
        case CUBEMAP_CMD:
            if (!Settings.settings.runtime.openVr) {
                final CubemapProjection proj = (CubemapProjection) data[1];
                final boolean enable = (boolean) data[0];
                if (proj.isPanorama() && source != buttonCubemap) {
                    buttonCubemap.setProgrammaticChangeEvents(false);
                    buttonCubemap.setChecked(enable);
                    buttonCubemap.setProgrammaticChangeEvents(true);
                    fieldOfView.setDisabled(enable);
                } else if (proj.isPlanetarium() && source != buttonDome) {
                    buttonDome.setProgrammaticChangeEvents(false);
                    buttonDome.setChecked(enable);
                    buttonDome.setProgrammaticChangeEvents(true);
                    fieldOfView.setDisabled(enable);
                }
            }
            break;
        default:
            break;
    }
}
Also used : CameraComboBoxBean(gaiasky.interafce.beans.CameraComboBoxBean) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) CubemapProjection(gaiasky.util.gdx.contrib.postprocess.effects.CubemapProjections.CubemapProjection)

Example 4 with CameraMode

use of gaiasky.scenegraph.camera.CameraManager.CameraMode in project gaiasky by langurmonkey.

the class KeyBindings method initActions.

private void initActions() {
    /*
         * INITIALISE ACTIONS
         */
    // Condition which checks the current GUI is the FullGui
    BooleanRunnable fullGuiCondition = () -> GaiaSky.instance.getGuiRegistry().current instanceof FullGui;
    // Condition that checks the current camera is not Game
    BooleanRunnable noGameCondition = () -> !GaiaSky.instance.getCameraManager().getMode().isGame();
    // Condition that checks the GUI is visible (no clean mode)
    BooleanRunnable noCleanMode = () -> Settings.settings.runtime.displayGui || GaiaSky.instance.externalView;
    // Condition that checks that panorama mode is off
    BooleanRunnable noPanorama = () -> !(Settings.settings.program.modeCubemap.active && Settings.settings.program.modeCubemap.projection.isPanorama());
    // Condition that checks that planetarium mode is off
    BooleanRunnable noPlanetarium = () -> !(Settings.settings.program.modeCubemap.active && Settings.settings.program.modeCubemap.projection.isPlanetarium());
    // Condition that checks that we are not a slave with a special projection
    BooleanRunnable noSlaveProj = () -> !SlaveManager.projectionActive();
    // Condition that checks that we are a master and have slaves
    BooleanRunnable masterWithSlaves = MasterManager::hasSlaves;
    // about action
    final Runnable runnableAbout = () -> EventManager.publish(Event.SHOW_ABOUT_ACTION, this);
    // help dialog
    addAction(new ProgramAction("action.help", runnableAbout, noCleanMode));
    // help dialog
    addAction(new ProgramAction("action.help", runnableAbout, noCleanMode));
    // show quit
    final Runnable runnableQuit = () -> {
        // Quit action
        EventManager.publish(Event.SHOW_QUIT_ACTION, this);
    };
    // run quit action
    addAction(new ProgramAction("action.exit", runnableQuit, noCleanMode));
    // exit
    // addAction(new ProgramAction("action.exit", runnableQuit), CTRL_L, Keys.Q);
    // show preferences dialog
    addAction(new ProgramAction("action.preferences", () -> EventManager.publish(Event.SHOW_PREFERENCES_ACTION, this), noCleanMode));
    // minimap toggle
    addAction(new ProgramAction("action.toggle/gui.minimap.title", () -> EventManager.publish(Event.TOGGLE_MINIMAP, this), noCleanMode));
    // load catalog
    addAction(new ProgramAction("action.loadcatalog", () -> EventManager.publish(Event.SHOW_LOAD_CATALOG_ACTION, this), noCleanMode));
    // show log dialog
    addAction(new ProgramAction("action.log", () -> EventManager.publish(Event.SHOW_LOG_ACTION, this), noCleanMode));
    // show play camera dialog
    // addAction(new ProgramAction("action.playcamera", () ->
    // EventManager.publish(Events.SHOW_PLAYCAMERA_ACTION), fullGuiCondition), Keys.C);
    // Toggle orbits
    addAction(new ProgramAction("action.toggle/element.orbits", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.orbits")));
    // Toggle planets
    addAction(new ProgramAction("action.toggle/element.planets", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.planets")));
    // Toggle moons
    addAction(new ProgramAction("action.toggle/element.moons", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.moons")));
    // Toggle stars
    addAction(new ProgramAction("action.toggle/element.stars", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.stars"), noGameCondition));
    // Toggle satellites
    addAction(new ProgramAction("action.toggle/element.satellites", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.satellites")));
    // Toggle asteroids
    addAction(new ProgramAction("action.toggle/element.asteroids", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.asteroids"), noGameCondition));
    // Toggle labels
    addAction(new ProgramAction("action.toggle/element.labels", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.labels")));
    // Toggle constellations
    addAction(new ProgramAction("action.toggle/element.constellations", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.constellations"), noGameCondition));
    // Toggle boundaries
    addAction(new ProgramAction("action.toggle/element.boundaries", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.boundaries")));
    // Toggle equatorial
    addAction(new ProgramAction("action.toggle/element.equatorial", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.equatorial")));
    // Toggle ecliptic
    addAction(new ProgramAction("action.toggle/element.ecliptic", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.ecliptic")));
    // Toggle galactic
    addAction(new ProgramAction("action.toggle/element.galactic", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.galactic")));
    // Toggle recgrid
    addAction(new ProgramAction("action.toggle/element.recursivegrid", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.recursivegrid")));
    // toggle meshes
    addAction(new ProgramAction("action.toggle/element.meshes", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.meshes")));
    // toggle clusters
    addAction(new ProgramAction("action.toggle/element.clusters", () -> EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, this, "element.clusters")));
    // divide speed
    addAction(new ProgramAction("action.dividetime", () -> EventManager.publish(Event.TIME_WARP_DECREASE_CMD, this)));
    // double speed
    addAction(new ProgramAction("action.doubletime", () -> EventManager.publish(Event.TIME_WARP_INCREASE_CMD, this)));
    // toggle time
    addAction(new ProgramAction("action.pauseresume", () -> {
        // Game mode has space bound to 'up'
        if (!GaiaSky.instance.cameraManager.mode.isGame())
            EventManager.publish(Event.TIME_STATE_CMD, this, !Settings.settings.runtime.timeOn);
    }));
    // increase field of view
    addAction(new ProgramAction("action.incfov", () -> EventManager.publish(Event.FOV_CHANGED_CMD, this, Settings.settings.scene.camera.fov + 1f), noSlaveProj));
    // decrease field of view
    addAction(new ProgramAction("action.decfov", () -> EventManager.publish(Event.FOV_CHANGED_CMD, this, Settings.settings.scene.camera.fov - 1f), noSlaveProj));
    // fullscreen
    addAction(new ProgramAction("action.togglefs", () -> {
        Settings.settings.graphics.fullScreen.active = !Settings.settings.graphics.fullScreen.active;
        EventManager.publish(Event.SCREEN_MODE_CMD, this);
    }));
    // take screenshot
    addAction(new ProgramAction("action.screenshot", () -> EventManager.publish(Event.SCREENSHOT_CMD, this, Settings.settings.screenshot.resolution[0], Settings.settings.screenshot.resolution[1], Settings.settings.screenshot.location)));
    // toggle frame output
    addAction(new ProgramAction("action.toggle/element.frameoutput", () -> EventManager.publish(Event.FRAME_OUTPUT_CMD, this, !Settings.settings.frame.active)));
    // toggle UI collapse/expand
    addAction(new ProgramAction("action.toggle/element.controls", () -> EventManager.publish(Event.GUI_FOLD_CMD, this), fullGuiCondition, noCleanMode));
    // toggle planetarium mode
    addAction(new ProgramAction("action.toggle/element.planetarium", () -> {
        boolean enable = !Settings.settings.program.modeCubemap.active;
        EventManager.publish(Event.CUBEMAP_CMD, this, enable, CubemapProjection.FISHEYE);
    }, noPanorama));
    // toggle cubemap mode
    addAction(new ProgramAction("action.toggle/element.360", () -> {
        boolean enable = !Settings.settings.program.modeCubemap.active;
        EventManager.publish(Event.CUBEMAP_CMD, this, enable, CubemapProjection.EQUIRECTANGULAR);
    }, noPlanetarium));
    // toggle cubemap projection
    addAction(new ProgramAction("action.toggle/element.projection", () -> {
        int newprojidx = (Settings.settings.program.modeCubemap.projection.ordinal() + 1) % (CubemapProjection.HAMMER.ordinal() + 1);
        EventManager.publish(Event.CUBEMAP_PROJECTION_CMD, this, CubemapProjection.values()[newprojidx]);
    }));
    // increase star point size by 0.5
    addAction(new ProgramAction("action.starpointsize.inc", () -> EventManager.publish(Event.STAR_POINT_SIZE_INCREASE_CMD, this)));
    // decrease star point size by 0.5
    addAction(new ProgramAction("action.starpointsize.dec", () -> EventManager.publish(Event.STAR_POINT_SIZE_DECREASE_CMD, this)));
    // reset star point size
    addAction(new ProgramAction("action.starpointsize.reset", () -> EventManager.publish(Event.STAR_POINT_SIZE_RESET_CMD, this)));
    // new keyframe
    addAction(new ProgramAction("action.keyframe", () -> EventManager.publish(Event.KEYFRAME_ADD, this)));
    // toggle debug information
    addAction(new ProgramAction("action.toggle/element.debugmode", () -> EventManager.publish(Event.SHOW_DEBUG_CMD, this), noCleanMode));
    // search dialog
    final Runnable runnableSearch = () -> EventManager.publish(Event.SHOW_SEARCH_ACTION, this);
    addAction(new ProgramAction("action.search", runnableSearch, fullGuiCondition, noCleanMode));
    // search dialog
    addAction(new ProgramAction("action.search", runnableSearch, fullGuiCondition, noCleanMode));
    // search dialog
    addAction(new ProgramAction("action.search", runnableSearch, fullGuiCondition, noCleanMode));
    // toggle particle fade
    addAction(new ProgramAction("action.toggle/element.octreeparticlefade", () -> EventManager.publish(Event.OCTREE_PARTICLE_FADE_CMD, this, I18n.txt("element.octreeparticlefade"), !Settings.settings.scene.octree.fade)));
    // toggle stereoscopic mode
    addAction(new ProgramAction("action.toggle/element.stereomode", () -> EventManager.publish(Event.STEREOSCOPIC_CMD, this, !Settings.settings.program.modeStereo.active)));
    // switch stereoscopic profile
    addAction(new ProgramAction("action.switchstereoprofile", () -> {
        int newidx = Settings.settings.program.modeStereo.profile.ordinal();
        newidx = (newidx + 1) % values().length;
        EventManager.publish(Event.STEREO_PROFILE_CMD, this, newidx);
    }));
    // Toggle clean (no GUI) mode
    addAction(new ProgramAction("action.toggle/element.cleanmode", () -> EventManager.publish(Event.DISPLAY_GUI_CMD, this, !Settings.settings.runtime.displayGui, I18n.txt("notif.cleanmode"))));
    // Travel to focus object
    addAction(new ProgramAction("action.gotoobject", () -> EventManager.publish(Event.GO_TO_OBJECT_CMD, this)));
    // Reset time to current system time
    addAction(new ProgramAction("action.resettime", () -> EventManager.publish(Event.TIME_CHANGE_CMD, this, Instant.now())));
    // Back home
    addAction(new ProgramAction("action.home", () -> EventManager.publish(Event.HOME_CMD, this)));
    // Expand/collapse time pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.time", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "TimeComponent"), noCleanMode));
    // Expand/collapse camera pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.camera", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "CameraComponent"), noCleanMode));
    // Expand/collapse visibility pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.visibility", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "VisibilityComponent"), noCleanMode));
    // Expand/collapse visual effects pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.lighting", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "VisualEffectsComponent"), noCleanMode));
    // Expand/collapse datasets pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.dataset.title", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "DatasetsComponent"), noCleanMode));
    // Expand/collapse objects pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.objects", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "ObjectsComponent"), noCleanMode));
    // Expand/collapse bookmarks pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.bookmarks", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "BookmarksComponent"), noCleanMode));
    // Expand/collapse music pane
    addAction(new ProgramAction("action.expandcollapse.pane/gui.music", () -> EventManager.publish(Event.TOGGLE_EXPANDCOLLAPSE_PANE_CMD, this, "MusicComponent"), noCleanMode));
    // Toggle mouse capture
    addAction(new ProgramAction("action.toggle/gui.mousecapture", () -> EventManager.publish(Event.MOUSE_CAPTURE_TOGGLE, this)));
    // Reload UI (debugging)
    addAction(new ProgramAction("action.ui.reload", () -> EventManager.publish(Event.UI_RELOAD_CMD, this, GaiaSky.instance.getGlobalResources())));
    // Configure slave
    addAction(new ProgramAction("action.slave.configure", () -> EventManager.publish(Event.SHOW_SLAVE_CONFIG_ACTION, this), masterWithSlaves));
    // Camera modes
    for (CameraMode mode : CameraMode.values()) {
        addAction(new ProgramAction("camera.full/camera." + mode.toString(), () -> EventManager.publish(Event.CAMERA_MODE_CMD, this, mode)));
    }
    // Controller GUI
    addAction(new ProgramAction("action.controller.gui.in", () -> EventManager.publish(Event.SHOW_CONTROLLER_GUI_ACTION, this)));
}
Also used : CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode)

Example 5 with CameraMode

use of gaiasky.scenegraph.camera.CameraManager.CameraMode in project gaiasky by langurmonkey.

the class TopInfoInterface method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case TIME_CHANGE_INFO:
        case TIME_CHANGE_CMD:
            // Update input time
            Instant datetime = (Instant) data[0];
            GaiaSky.postRunnable(() -> {
                date.setText(dfDate.format(datetime));
                time.setText(dfTime.format(datetime) + " UTC");
                pack();
            });
            break;
        case TIME_WARP_CHANGED_INFO:
            if (data.length == 1)
                pace.setText("(" + TextUtils.getFormattedTimeWarp((double) data[0]) + ")");
            break;
        case TIME_STATE_CMD:
            Boolean t = (Boolean) data[0];
            if (!t) {
                pace.setText("(" + I18n.txt("gui.top.time.off") + ")");
            } else {
                pace.setText("(" + TextUtils.getFormattedTimeWarp() + ")");
            }
            break;
        case CAMERA_CLOSEST_INFO:
            IFocus closestObject = (IFocus) data[0];
            if (closestObject != null) {
                closest.setText(TextUtils.capString(closestObject.getClosestName(), maxNameLen));
                closest.setText(I18n.txt("gui.top.closest", closest.getText()));
            } else {
                closest.setText("");
            }
            break;
        case CAMERA_MODE_CMD:
            CameraMode mode = (CameraMode) data[0];
            if (!mode.isFocus()) {
                focus.setText("");
                s1.setText("");
            } else {
                focus.setText(I18n.txt("gui.top.focus", lastFocusName));
                s1.setText("|");
            }
            break;
        case FOCUS_CHANGE_CMD:
            IFocus f = null;
            if (data[0] instanceof String) {
                SceneGraphNode sgn = GaiaSky.instance.sceneGraph.getNode((String) data[0]);
                if (sgn instanceof IFocus)
                    f = (IFocus) sgn;
            } else {
                f = (IFocus) data[0];
            }
            if (f != null) {
                String candidate = f.getCandidateName();
                lastFocusName = TextUtils.capString(candidate, maxNameLen);
                focus.setText(I18n.txt("gui.top.focus", lastFocusName));
                s1.setText("|");
            }
            break;
        default:
            break;
    }
}
Also used : Instant(java.time.Instant) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) IFocus(gaiasky.scenegraph.IFocus)

Aggregations

CameraMode (gaiasky.scenegraph.camera.CameraManager.CameraMode)9 IFocus (gaiasky.scenegraph.IFocus)3 PointCloudData (gaiasky.data.util.PointCloudData)2 CameraComboBoxBean (gaiasky.interafce.beans.CameraComboBoxBean)2 LoggerLevel (gaiasky.util.Logger.LoggerLevel)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)1 StringBuilder (com.badlogic.gdx.utils.StringBuilder)1 SGLoaderParameter (gaiasky.assets.SGLoader.SGLoaderParameter)1 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)1 RotationComponent (gaiasky.scenegraph.component.RotationComponent)1 CubemapProjection (gaiasky.util.gdx.contrib.postprocess.effects.CubemapProjections.CubemapProjection)1 Matrix4d (gaiasky.util.math.Matrix4d)1 Vector3b (gaiasky.util.math.Vector3b)1 Instant (java.time.Instant)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1