Search in sources :

Example 1 with NUIManager

use of org.terasology.engine.rendering.nui.NUIManager in project Terasology by MovingBlocks.

the class StartServer method step.

@Override
public boolean step() {
    try {
        Config config = context.get(Config.class);
        int port = config.getNetwork().getServerPort();
        context.get(NetworkSystem.class).host(port, dedicated);
    } catch (HostingFailedException e) {
        NUIManager nui = context.get(NUIManager.class);
        if (nui != null) {
            nui.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Failed to Host", e.getMessage() + " - Reverting to single player");
        } else {
            logger.error("Failed to Host. NUI was also unavailable for warning popup (headless?)", e);
            throw new RuntimeException("Cannot host game successfully from likely headless start, terminating");
        }
    }
    return true;
}
Also used : Config(org.terasology.engine.config.Config) HostingFailedException(org.terasology.engine.network.exceptions.HostingFailedException) NetworkSystem(org.terasology.engine.network.NetworkSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager)

Example 2 with NUIManager

use of org.terasology.engine.rendering.nui.NUIManager in project Terasology by MovingBlocks.

the class InitialiseGraphics method step.

@Override
public boolean step() {
    // Refresh widget library after modules got laoded:
    NUIManager nuiManager = context.get(NUIManager.class);
    ((NUIManagerInternal) nuiManager).refreshWidgetsLibrary();
    return true;
}
Also used : NUIManager(org.terasology.engine.rendering.nui.NUIManager) NUIManagerInternal(org.terasology.engine.rendering.nui.internal.NUIManagerInternal)

Example 3 with NUIManager

use of org.terasology.engine.rendering.nui.NUIManager in project Terasology by MovingBlocks.

the class AbstractState method initEntityAndComponentManagers.

protected void initEntityAndComponentManagers(boolean isHeadless) {
    verifyNotNull(context);
    CoreRegistry.setContext(context);
    // let's get the entity event system running
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    entityManager = context.get(EngineEntityManager.class);
    eventSystem = context.get(EventSystem.class);
    context.put(Console.class, new ConsoleImpl(context));
    if (!isHeadless) {
        NUIManager nuiManager = new NUIManagerInternal((TerasologyCanvasRenderer) context.get(CanvasRenderer.class), context);
        context.put(NUIManager.class, nuiManager);
    }
    componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
    componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) ConsoleSystem(org.terasology.engine.logic.console.ConsoleSystem) ConsoleImpl(org.terasology.engine.logic.console.ConsoleImpl) EventSystem(org.terasology.engine.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager) CoreCommands(org.terasology.engine.logic.console.commands.CoreCommands) NUIManagerInternal(org.terasology.engine.rendering.nui.internal.NUIManagerInternal) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager)

Example 4 with NUIManager

use of org.terasology.engine.rendering.nui.NUIManager in project Terasology by MovingBlocks.

the class UIFormat method load.

public UIData load(JsonElement element, Locale otherLocale) throws IOException {
    NUIManager nuiManager = CoreRegistry.get(NUIManager.class);
    TranslationSystem translationSystem = CoreRegistry.get(TranslationSystem.class);
    TypeHandlerLibrary library = CoreRegistry.get(TypeHandlerLibrary.class).copy();
    library.addTypeHandler(UISkinAsset.class, new AssetTypeHandler<>(UISkinAsset.class));
    library.addTypeHandler(UISkin.class, new UISkinTypeHandler());
    // TODO: Rewrite to use TypeHandlerLibrary
    GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapterFactory(new GsonTypeSerializationLibraryAdapterFactory(library)).registerTypeAdapterFactory(new CaseInsensitiveEnumTypeAdapterFactory()).registerTypeAdapter(UIData.class, new UIDataTypeAdapter()).registerTypeHierarchyAdapter(UIWidget.class, new UIWidgetTypeAdapter(nuiManager));
    // override the String TypeAdapter from the serialization library
    gsonBuilder.registerTypeAdapter(String.class, new I18nStringTypeAdapter(translationSystem, otherLocale));
    Gson gson = gsonBuilder.create();
    return gson.fromJson(element, UIData.class);
}
Also used : TranslationSystem(org.terasology.engine.i18n.TranslationSystem) GsonTypeSerializationLibraryAdapterFactory(org.terasology.engine.persistence.typeHandling.gson.GsonTypeSerializationLibraryAdapterFactory) UISkinAsset(org.terasology.nui.skin.UISkinAsset) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) UISkinTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.UISkinTypeHandler) UIData(org.terasology.nui.asset.UIData) CaseInsensitiveEnumTypeAdapterFactory(org.terasology.engine.utilities.gson.CaseInsensitiveEnumTypeAdapterFactory) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NUIManager(org.terasology.engine.rendering.nui.NUIManager)

Example 5 with NUIManager

use of org.terasology.engine.rendering.nui.NUIManager in project Terasology by MovingBlocks.

the class StateMainMenu method init.

@Override
public void init(GameEngine gameEngine) {
    context = gameEngine.createChildContext();
    headless = context.get(DisplayDevice.class).isHeadless();
    initEntityAndComponentManagers(headless);
    createLocalPlayer(context);
    if (!headless) {
        // TODO: REMOVE this and handle refreshing of core game state at the engine level - see Issue #1127
        new RegisterInputSystem(context).step();
        nuiManager = context.get(NUIManager.class);
        eventSystem.registerEventHandler(nuiManager);
        NUIEditorSystem nuiEditorSystem = new NUIEditorSystem();
        context.put(NUIEditorSystem.class, nuiEditorSystem);
        componentSystemManager.register(nuiEditorSystem, "engine:NUIEditorSystem");
        NUISkinEditorSystem nuiSkinEditorSystem = new NUISkinEditorSystem();
        context.put(NUISkinEditorSystem.class, nuiSkinEditorSystem);
        componentSystemManager.register(nuiSkinEditorSystem, "engine:NUISkinEditorSystem");
        inputSystem = context.get(InputSystem.class);
    }
    componentSystemManager.initialise();
    console = context.get(Console.class);
    storageServiceWorker = context.get(StorageServiceWorker.class);
    playBackgroundMusic();
    if (!headless) {
        // guiManager.openWindow("main");
        context.get(NUIManager.class).pushScreen("engine:mainMenuScreen");
    }
    if (!messageOnLoad.isEmpty()) {
        TranslationSystem translationSystem = context.get(TranslationSystem.class);
        if (headless) {
            throw new RuntimeException(String.format("Game could not be started, server attempted to return to main menu: [%s]. See logs before", translationSystem.translate(messageOnLoad)));
        } else {
            MessagePopup popup = nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
            popup.setMessage("Error", translationSystem.translate(messageOnLoad));
        }
    }
// TODO: enable it when exposing the telemetry to users
// pushLaunchPopup();
}
Also used : NUIEditorSystem(org.terasology.engine.rendering.nui.editor.systems.NUIEditorSystem) TranslationSystem(org.terasology.engine.i18n.TranslationSystem) Console(org.terasology.engine.logic.console.Console) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) RegisterInputSystem(org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem) NUISkinEditorSystem(org.terasology.engine.rendering.nui.editor.systems.NUISkinEditorSystem) RegisterInputSystem(org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem) InputSystem(org.terasology.engine.input.InputSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager) StorageServiceWorker(org.terasology.engine.identity.storageServiceClient.StorageServiceWorker)

Aggregations

NUIManager (org.terasology.engine.rendering.nui.NUIManager)7 Config (org.terasology.engine.config.Config)3 Lists (com.google.common.collect.Lists)2 ByteBuffer (java.nio.ByteBuffer)2 List (java.util.List)2 Callable (java.util.concurrent.Callable)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Context (org.terasology.engine.context.Context)2 ModuleManager (org.terasology.engine.core.module.ModuleManager)2 TranslationSystem (org.terasology.engine.i18n.TranslationSystem)2 In (org.terasology.engine.registry.In)2 Texture (org.terasology.engine.rendering.assets.texture.Texture)2 TextureData (org.terasology.engine.rendering.assets.texture.TextureData)2 CoreScreenLayer (org.terasology.engine.rendering.nui.CoreScreenLayer)2 MenuAnimationSystems (org.terasology.engine.rendering.nui.animation.MenuAnimationSystems)2 NUIManagerInternal (org.terasology.engine.rendering.nui.internal.NUIManagerInternal)2 FacetLayerPreview (org.terasology.engine.rendering.nui.layers.mainMenu.preview.FacetLayerPreview)2 PreviewGenerator (org.terasology.engine.rendering.nui.layers.mainMenu.preview.PreviewGenerator)2