Search in sources :

Example 1 with DataDescriptor

use of gaiasky.util.datadesc.DataDescriptor in project gaiasky by langurmonkey.

the class WelcomeGui method initialize.

@Override
public void initialize(AssetManager assetManager, SpriteBatch sb) {
    // User interface
    ScreenViewport vp = new ScreenViewport();
    vp.setUnitsPerPixel(unitsPerPixel);
    ui = new Stage(vp, sb);
    popupInterface = new PopupNotificationsInterface(skin);
    popupInterface.top().right();
    popupInterface.setFillParent(true);
    if (vrStatus.vrInitFailed()) {
        if (vrStatus.equals(VRStatus.ERROR_NO_CONTEXT))
            GaiaSky.postRunnable(() -> GuiUtils.addNoVRConnectionExit(skin, ui));
        else if (vrStatus.equals(VRStatus.ERROR_RENDERMODEL))
            GaiaSky.postRunnable(() -> GuiUtils.addNoVRDataExit(skin, ui));
    } else if (Settings.settings.program.net.slave.active || GaiaSky.instance.isHeadless()) {
        // If slave or headless, data load can start
        gaiaSky();
    } else {
        // Otherwise, check for updates, etc.
        clearGui();
        dataDescriptor = Gdx.files.absolute(SysUtils.getTempDir(Settings.settings.data.location) + "/gaiasky-data.json");
        DownloadHelper.downloadFile(Settings.settings.program.url.dataDescriptor, dataDescriptor, null, null, (digest) -> GaiaSky.postRunnable(() -> {
            // Data descriptor ok. Skip welcome screen only if flag and base data present
            if (skipWelcome && baseDataPresent()) {
                gaiaSky();
            } else {
                buildWelcomeUI();
            }
        }), () -> {
            // Fail?
            downloadError = true;
            logger.error(I18n.txt("gui.welcome.error.nointernet"));
            if (baseDataPresent()) {
                // Go on all in
                GaiaSky.postRunnable(() -> GuiUtils.addNoConnectionWindow(skin, ui, () -> buildWelcomeUI()));
            } else {
                // Error and exit
                logger.error(I18n.txt("gui.welcome.error.nobasedata"));
                GaiaSky.postRunnable(() -> GuiUtils.addNoConnectionExit(skin, ui));
            }
        }, null);
        /* CAPTURE SCROLL FOCUS */
        ui.addListener(event -> {
            if (event instanceof InputEvent) {
                InputEvent ie = (InputEvent) event;
                if (ie.getType() == Type.keyUp) {
                    if (ie.getKeyCode() == Input.Keys.ESCAPE) {
                        Gdx.app.exit();
                    } else if (ie.getKeyCode() == Input.Keys.ENTER) {
                        if (baseDataPresent()) {
                            gaiaSky();
                        } else {
                            addDatasetManagerWindow(serverDatasets);
                        }
                    }
                }
            }
            return false;
        });
    }
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) GaiaSky(gaiasky.GaiaSky) SysUtils(gaiasky.desktop.util.SysUtils) 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) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) Gdx(com.badlogic.gdx.Gdx) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) Texture(com.badlogic.gdx.graphics.Texture) HashSet(java.util.HashSet) SpriteDrawable(com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable) DataDescriptorUtils(gaiasky.util.datadesc.DataDescriptorUtils) DatasetDesc(gaiasky.util.datadesc.DatasetDesc) Input(com.badlogic.gdx.Input) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) OwnTextIconButton(gaiasky.util.scene2d.OwnTextIconButton) Path(java.nio.file.Path) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Type(com.badlogic.gdx.scenes.scene2d.InputEvent.Type) Graphics(com.badlogic.gdx.Graphics) AssetManager(com.badlogic.gdx.assets.AssetManager) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Files(java.nio.file.Files) SystemCursor(com.badlogic.gdx.graphics.Cursor.SystemCursor) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) Set(java.util.Set) Event(gaiasky.event.Event) gaiasky.util(gaiasky.util) Align(com.badlogic.gdx.utils.Align) DataDescriptor(gaiasky.util.datadesc.DataDescriptor) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) Paths(java.nio.file.Paths) VRStatus(gaiasky.vr.openvr.VRStatus) Log(gaiasky.util.Logger.Log) OwnLabel(gaiasky.util.scene2d.OwnLabel) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) EventManager(gaiasky.event.EventManager) ColorUtils(gaiasky.util.color.ColorUtils) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Aggregations

Gdx (com.badlogic.gdx.Gdx)1 Graphics (com.badlogic.gdx.Graphics)1 Input (com.badlogic.gdx.Input)1 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)1 FileHandle (com.badlogic.gdx.files.FileHandle)1 SystemCursor (com.badlogic.gdx.graphics.Cursor.SystemCursor)1 Texture (com.badlogic.gdx.graphics.Texture)1 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Type (com.badlogic.gdx.scenes.scene2d.InputEvent.Type)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)1 SpriteDrawable (com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable)1