use of org.terasology.engine.game.GameManifest in project Terasology by MovingBlocks.
the class SelectGameScreen method loadGame.
private void loadGame(GameInfo item) {
if (isLoadingAsServer()) {
Path blacklistPath = PathManager.getInstance().getHomePath().resolve("blacklist.json");
Path whitelistPath = PathManager.getInstance().getHomePath().resolve("whitelist.json");
if (!Files.exists(blacklistPath)) {
try {
Files.createFile(blacklistPath);
} catch (IOException e) {
logger.error("IO Exception on blacklist generation", e);
}
}
if (!Files.exists(whitelistPath)) {
try {
Files.createFile(whitelistPath);
} catch (IOException e) {
logger.error("IO Exception on whitelist generation", e);
}
}
}
try {
final GameManifest manifest = item.getManifest();
config.getWorldGeneration().setDefaultSeed(manifest.getSeed());
config.getWorldGeneration().setWorldTitle(manifest.getTitle());
Optional.ofNullable(CoreRegistry.get(GameEngine.class)).orElseThrow(() -> new IllegalStateException("Failed to get game engine from CoreRegistry")).changeState(new StateLoading(manifest, (isLoadingAsServer()) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
} catch (Exception e) {
logger.error("Failed to load saved game", e);
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error Loading Game", e.getMessage());
}
}
use of org.terasology.engine.game.GameManifest in project Terasology by MovingBlocks.
the class StartPlayingScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
WidgetUtil.trySubscribe(this, "play", button -> {
universeWrapper.setTargetWorld(targetWorld);
final GameManifest gameManifest = GameManifestProvider.createGameManifest(universeWrapper, moduleManager, config);
if (gameManifest != null) {
gameEngine.changeState(new StateLoading(gameManifest, (universeWrapper.getLoadingAsServer()) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
} else {
getManager().createScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", "Can't create new game!");
}
SimpleUri uri;
WorldInfo worldInfo;
// gameManifest.addWorld(worldInfo);
int i = 0;
for (WorldSetupWrapper world : worldSetupWrappers) {
if (world != targetWorld) {
i++;
uri = world.getWorldGeneratorInfo().getUri();
worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD + i, world.getWorldName().toString(), world.getWorldGenerator().getWorldSeed(), (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), uri);
gameManifest.addWorld(worldInfo);
config.getUniverseConfig().addWorldManager(worldInfo);
}
}
gameEngine.changeState(new StateLoading(gameManifest, (universeWrapper.getLoadingAsServer()) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
});
WidgetUtil.trySubscribe(this, "mainMenu", button -> {
getManager().pushScreen("engine:mainMenuScreen");
});
WidgetUtil.trySubscribe(this, "renderingSettings", button -> {
RenderingModuleSettingScreen renderingModuleSettingScreen = (RenderingModuleSettingScreen) getManager().getScreen(RenderingModuleSettingScreen.ASSET_URI);
if (renderingModuleSettingScreen == null) {
renderingModuleSettingScreen = getManager().createScreen(RenderingModuleSettingScreen.ASSET_URI, RenderingModuleSettingScreen.class);
renderingModuleSettingScreen.setSubContext(this.subContext);
renderingModuleSettingScreen.postInit();
}
triggerForwardAnimation(renderingModuleSettingScreen);
});
}
use of org.terasology.engine.game.GameManifest in project Terasology by MovingBlocks.
the class NameRecordingScreen method loadGame.
/**
* Last step of the recording setup process.
* Copies the save files from the selected game, transplants them into the 'recordings' folder, and renames the map files
* to match the provided recording name. Then launches the game loading state.
*
* @param newTitle The title of the new recording.
*/
private void loadGame(String newTitle) {
try {
final GameManifest manifest = gameInfo.getManifest();
copySaveDirectoryToRecordingLibrary(manifest.getTitle(), newTitle);
recordAndReplayUtils.setGameTitle(newTitle);
config.getWorldGeneration().setDefaultSeed(manifest.getSeed());
config.getWorldGeneration().setWorldTitle(newTitle);
CoreRegistry.get(GameEngine.class).changeState(new StateLoading(manifest, NetworkMode.NONE));
} catch (Exception e) {
logger.error("Failed to load saved game", e);
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error Loading Game", e.getMessage());
}
}
Aggregations