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();
});
}
}
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());
}
}
}
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();
}
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));
}
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();
});
}
}
Aggregations