Search in sources :

Example 11 with WorldInfo

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);
    });
}
Also used : GameManifest(org.terasology.engine.game.GameManifest) StateLoading(org.terasology.engine.core.modes.StateLoading) RenderingModuleSettingScreen(org.terasology.engine.rendering.nui.layers.mainMenu.videoSettings.RenderingModuleSettingScreen) SimpleUri(org.terasology.engine.core.SimpleUri) WorldInfo(org.terasology.engine.world.internal.WorldInfo) WorldSetupWrapper(org.terasology.engine.rendering.world.WorldSetupWrapper)

Example 12 with WorldInfo

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());
        }
    });
}
Also used : Canvas(org.terasology.nui.Canvas) WorldInfo(org.terasology.engine.world.internal.WorldInfo) Vector2i(org.joml.Vector2i)

Aggregations

WorldInfo (org.terasology.engine.world.internal.WorldInfo)12 ModuleManager (org.terasology.engine.core.module.ModuleManager)5 GameManifest (org.terasology.engine.game.GameManifest)5 Module (org.terasology.gestalt.module.Module)4 SimpleUri (org.terasology.engine.core.SimpleUri)3 WorldProvider (org.terasology.engine.world.WorldProvider)3 BlockManager (org.terasology.engine.world.block.BlockManager)3 Config (org.terasology.engine.config.Config)2 WorldGenerationConfig (org.terasology.engine.config.WorldGenerationConfig)2 StateLoading (org.terasology.engine.core.modes.StateLoading)2 StateMainMenu (org.terasology.engine.core.modes.StateMainMenu)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 ServerInfoMessage (org.terasology.engine.network.ServerInfoMessage)2 DirectionAndOriginPosRecorderList (org.terasology.engine.recording.DirectionAndOriginPosRecorderList)2 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)2 RecordAndReplaySerializer (org.terasology.engine.recording.RecordAndReplaySerializer)2 RecordAndReplayUtils (org.terasology.engine.recording.RecordAndReplayUtils)2 WorldSetupWrapper (org.terasology.engine.rendering.world.WorldSetupWrapper)2 WorldGenerator (org.terasology.engine.world.generator.WorldGenerator)2 IOException (java.io.IOException)1