use of org.terasology.engine.world.internal.WorldInfo 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.world.internal.WorldInfo in project Terasology by MovingBlocks.
the class GameDetailsScreen method setUpGameWorlds.
private void setUpGameWorlds() {
gameWorlds.subscribeSelection((widget, worldInfo) -> {
if (worldInfo == null) {
return;
}
descriptionTitle.setText(translationSystem.translate("${engine:menu#game-details-world-description}"));
description.setText(getWorldDescription(worldInfo));
gameModules.setSelection(null);
blocks.setSelection(null);
});
gameWorlds.setItemRenderer(new AbstractItemRenderer<WorldInfo>() {
@Override
public void draw(WorldInfo value, Canvas canvas) {
if (value.getCustomTitle().isEmpty()) {
canvas.drawText(value.getTitle());
} else {
canvas.drawText(value.getCustomTitle());
}
}
@Override
public Vector2i getPreferredSize(WorldInfo value, Canvas canvas) {
String text = value.getCustomTitle();
return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight());
}
});
}
Aggregations