Search in sources :

Example 1 with NUIManagerInternal

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

the class StateLoading method init.

@Override
public void init(GameEngine engine) {
    this.context = engine.createChildContext();
    headless = context.get(DisplayDevice.class).isHeadless();
    CoreRegistry.setContext(context);
    systemConfig = context.get(SystemConfig.class);
    if (!headless) {
        this.nuiManager = new NUIManagerInternal((TerasologyCanvasRenderer) context.get(CanvasRenderer.class), context);
        context.put(NUIManager.class, nuiManager);
    }
    EngineTime time = (EngineTime) context.get(Time.class);
    time.setPaused(true);
    time.setGameTime(gameManifest.getTime());
    context.get(Game.class).load(gameManifest);
    switch(netMode) {
        case CLIENT:
            initClient();
            break;
        default:
            initHost();
            break;
    }
    progress = 0;
    maxProgress = 0;
    for (LoadProcess process : loadProcesses) {
        maxProgress += process.getExpectedCost();
    }
    popStep();
    if (nuiManager != null) {
        loadingScreen = nuiManager.pushScreen("engine:loadingScreen", LoadingScreen.class);
        loadingScreen.updateStatus(current.getMessage(), current.getProgress());
    }
    chunkGenerationStarted = false;
}
Also used : SystemConfig(org.terasology.engine.config.SystemConfig) Game(org.terasology.engine.game.Game) CanvasRenderer(org.terasology.nui.canvas.CanvasRenderer) TerasologyCanvasRenderer(org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer) EngineTime(org.terasology.engine.core.EngineTime) EngineTime(org.terasology.engine.core.EngineTime) Time(org.terasology.engine.core.Time) LoadingScreen(org.terasology.engine.rendering.nui.layers.mainMenu.loadingScreen.LoadingScreen) TerasologyCanvasRenderer(org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer) NUIManagerInternal(org.terasology.engine.rendering.nui.internal.NUIManagerInternal)

Example 2 with NUIManagerInternal

use of org.terasology.engine.rendering.nui.internal.NUIManagerInternal 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 3 with NUIManagerInternal

use of org.terasology.engine.rendering.nui.internal.NUIManagerInternal 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 4 with NUIManagerInternal

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

the class ContextMenuUtilsTest method setupInput.

@BeforeAll
public static void setupInput() {
    context.put(InputSystem.class, new InputSystem());
    context.put(TranslationSystem.class, new TranslationSystemImpl(context));
    context.put(CanvasRenderer.class, new HeadlessCanvasRenderer());
    context.put(NUIManager.class, new NUIManagerInternal((TerasologyCanvasRenderer) context.get(CanvasRenderer.class), context));
    File file = new File(ContextMenuUtilsTest.class.getClassLoader().getResource("contextMenuBuilderInput.ui").getFile());
    String content = null;
    try {
        content = Files.asCharSource(file, Charsets.UTF_8).read();
    } catch (IOException e) {
        fail("Could not load input file", e);
    }
    inputTree = JsonTreeConverter.serialize(new JsonParser().parse(content));
}
Also used : TranslationSystemImpl(org.terasology.engine.i18n.TranslationSystemImpl) CanvasRenderer(org.terasology.nui.canvas.CanvasRenderer) TerasologyCanvasRenderer(org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer) HeadlessCanvasRenderer(org.terasology.engine.core.subsystem.headless.renderer.HeadlessCanvasRenderer) InputSystem(org.terasology.engine.input.InputSystem) IOException(java.io.IOException) TerasologyCanvasRenderer(org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer) File(java.io.File) HeadlessCanvasRenderer(org.terasology.engine.core.subsystem.headless.renderer.HeadlessCanvasRenderer) NUIManagerInternal(org.terasology.engine.rendering.nui.internal.NUIManagerInternal) JsonParser(com.google.gson.JsonParser) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

NUIManagerInternal (org.terasology.engine.rendering.nui.internal.NUIManagerInternal)4 NUIManager (org.terasology.engine.rendering.nui.NUIManager)2 TerasologyCanvasRenderer (org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer)2 CanvasRenderer (org.terasology.nui.canvas.CanvasRenderer)2 JsonParser (com.google.gson.JsonParser)1 File (java.io.File)1 IOException (java.io.IOException)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 SystemConfig (org.terasology.engine.config.SystemConfig)1 ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)1 EngineTime (org.terasology.engine.core.EngineTime)1 Time (org.terasology.engine.core.Time)1 HeadlessCanvasRenderer (org.terasology.engine.core.subsystem.headless.renderer.HeadlessCanvasRenderer)1 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)1 EventSystem (org.terasology.engine.entitySystem.event.internal.EventSystem)1 Game (org.terasology.engine.game.Game)1 TranslationSystemImpl (org.terasology.engine.i18n.TranslationSystemImpl)1 InputSystem (org.terasology.engine.input.InputSystem)1 ConsoleImpl (org.terasology.engine.logic.console.ConsoleImpl)1 ConsoleSystem (org.terasology.engine.logic.console.ConsoleSystem)1