Search in sources :

Example 1 with GameInfo

use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.

the class ReplayScreen method initialise.

@Override
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    initWidgets();
    if (isValidScreen()) {
        initSaveGamePathWidget(PathManager.getInstance().getRecordingsPath());
        getGameInfos().subscribeSelection((widget, item) -> {
            load.setEnabled(item != null);
            delete.setEnabled(item != null);
            updateDescription(item);
        });
        getGameInfos().subscribe((widget, item) -> loadGame(item));
        load.subscribe(e -> {
            GameInfo gameInfo = getGameInfos().getSelection();
            if (gameInfo != null) {
                loadGame(gameInfo);
            }
        });
        delete.subscribe(button -> {
            TwoButtonPopup confirmationPopup = getManager().pushScreen(TwoButtonPopup.ASSET_URI, TwoButtonPopup.class);
            confirmationPopup.setMessage(translationSystem.translate("${engine:menu#remove-confirmation-popup" + "-title}"), translationSystem.translate("${engine:menu#remove-confirmation-popup-message}"));
            confirmationPopup.setLeftButton(translationSystem.translate("${engine:menu#dialog-yes}"), this::removeSelectedReplay);
            confirmationPopup.setRightButton(translationSystem.translate("${engine:menu#dialog-no}"), () -> {
            });
        });
        close.subscribe(button -> {
            recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.NOT_ACTIVATED);
            triggerBackAnimation();
        });
    }
}
Also used : GameInfo(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo)

Example 2 with GameInfo

use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.

the class SelectionScreen method remove.

protected void remove(final UIList<GameInfo> gameList, Path world, String removeString) {
    final GameInfo gameInfo = gameList.getSelection();
    if (gameInfo != null) {
        try {
            FilesUtil.recursiveDelete(world);
            gameList.getList().remove(gameInfo);
            gameList.setSelection(null);
            gameList.select(0);
        } catch (Exception e) {
            logger.error("Failed to delete " + removeString, e);
            getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error Deleting Game", e.getMessage());
        }
    }
}
Also used : GameInfo(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo) IOException(java.io.IOException)

Example 3 with GameInfo

use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.

the class Terasology method getLatestGameManifest.

private static GameManifest getLatestGameManifest() {
    GameInfo latestGame = null;
    List<GameInfo> savedGames = GameProvider.getSavedGames();
    for (GameInfo savedGame : savedGames) {
        if (latestGame == null || savedGame.getTimestamp().after(latestGame.getTimestamp())) {
            latestGame = savedGame;
        }
    }
    if (latestGame == null) {
        return null;
    }
    return latestGame.getManifest();
}
Also used : GameInfo(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo)

Example 4 with GameInfo

use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.

the class StateHeadlessSetup method init.

@Override
public void init(GameEngine gameEngine) {
    context = gameEngine.createChildContext();
    initEntityAndComponentManagers(true);
    createLocalPlayer(context);
    GameManifest gameManifest;
    List<GameInfo> savedGames = GameProvider.getSavedGames();
    if (savedGames.size() > 0) {
        gameManifest = savedGames.get(0).getManifest();
    } else {
        gameManifest = createGameManifest();
    }
    Config config = context.get(Config.class);
    WorldInfo worldInfo = gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD);
    config.getUniverseConfig().addWorldManager(worldInfo);
    config.getUniverseConfig().setSpawnWorldTitle(worldInfo.getTitle());
    config.getUniverseConfig().setUniverseSeed(gameManifest.getSeed());
    gameEngine.changeState(new StateLoading(gameManifest, NetworkMode.LISTEN_SERVER));
}
Also used : GameInfo(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo) GameManifest(org.terasology.engine.game.GameManifest) StateLoading(org.terasology.engine.core.modes.StateLoading) WorldGenerationConfig(org.terasology.engine.config.WorldGenerationConfig) Config(org.terasology.engine.config.Config) WorldInfo(org.terasology.engine.world.internal.WorldInfo)

Example 5 with GameInfo

use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.

the class RecordScreen method initialise.

@Override
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    initWidgets();
    if (isValidScreen()) {
        initSaveGamePathWidget(PathManager.getInstance().getSavesPath());
        NameRecordingScreen nameRecordingScreen = getManager().createScreen(NameRecordingScreen.ASSET_URI, NameRecordingScreen.class);
        getGameInfos().subscribeSelection((widget, item) -> {
            load.setEnabled(item != null);
            updateDescription(item);
        });
        getGameInfos().subscribe((widget, item) -> launchNamingScreen(nameRecordingScreen, item));
        load.subscribe(button -> {
            final GameInfo gameInfo = getGameInfos().getSelection();
            if (gameInfo != null) {
                launchNamingScreen(nameRecordingScreen, gameInfo);
            }
        });
        close.subscribe(button -> {
            recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.NOT_ACTIVATED);
            triggerBackAnimation();
        });
    }
}
Also used : GameInfo(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo)

Aggregations

GameInfo (org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo)7 IOException (java.io.IOException)2 Config (org.terasology.engine.config.Config)2 BufferedImage (java.awt.image.BufferedImage)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 PlayerConfig (org.terasology.engine.config.PlayerConfig)1 WorldGenerationConfig (org.terasology.engine.config.WorldGenerationConfig)1 TerasologyConstants (org.terasology.engine.core.TerasologyConstants)1 StateLoading (org.terasology.engine.core.modes.StateLoading)1 GameManifest (org.terasology.engine.game.GameManifest)1 TranslationSystem (org.terasology.engine.i18n.TranslationSystem)1 GamePreviewImageProvider (org.terasology.engine.persistence.internal.GamePreviewImageProvider)1 In (org.terasology.engine.registry.In)1