Search in sources :

Example 1 with DisplayDevice

use of org.terasology.engine.core.subsystem.DisplayDevice in project Terasology by MovingBlocks.

the class InputSystemTests method setUpDisplayDevice.

private void setUpDisplayDevice(Context context) {
    DisplayDevice displayDevice = mock(DisplayDevice.class);
    when(displayDevice.hasFocus()).thenReturn(true);
    context.put(DisplayDevice.class, displayDevice);
}
Also used : DisplayDevice(org.terasology.engine.core.subsystem.DisplayDevice)

Example 2 with DisplayDevice

use of org.terasology.engine.core.subsystem.DisplayDevice in project Terasology by MovingBlocks.

the class Metric method filterMetricMap.

/**
 * Filter the metric map by the binding map.
 * If the user doesn't want the field to be sent, its value will be covered by "Disabled Field".
 * @param bindingMap the binding map.
 * @return a new metric map that covers the field that the user doesn't want to send by "Disabled Field".
 */
protected Map<String, Object> filterMetricMap(Map<String, Boolean> bindingMap) {
    TelemetryCategory telemetryCategory = this.getClass().getAnnotation(TelemetryCategory.class);
    Context context = CoreRegistry.get(Context.class);
    DisplayDevice display = context.get(DisplayDevice.class);
    if (display.isHeadless() || telemetryCategory.isOneMapMetric()) {
        return telemetryFieldToValue;
    }
    Map<String, Object> metricMapAfterPermission = new HashMap<>();
    for (String fieldName : telemetryFieldToValue.keySet()) {
        String fieldNameWithID = telemetryCategory.id() + ":" + fieldName;
        if (bindingMap.containsKey(fieldNameWithID)) {
            if (bindingMap.get(fieldNameWithID)) {
                metricMapAfterPermission.put(fieldName, telemetryFieldToValue.get(fieldName));
            } else {
                metricMapAfterPermission.put(fieldName, "Disabled Field");
            }
        }
    }
    return metricMapAfterPermission;
}
Also used : Context(org.terasology.engine.context.Context) TelemetryCategory(org.terasology.engine.telemetry.TelemetryCategory) DisplayDevice(org.terasology.engine.core.subsystem.DisplayDevice) HashMap(java.util.HashMap)

Example 3 with DisplayDevice

use of org.terasology.engine.core.subsystem.DisplayDevice in project Terasology by MovingBlocks.

the class ComponentSystemManager method loadSystems.

public void loadSystems(ModuleEnvironment environment, NetworkMode netMode) {
    DisplayDevice display = context.get(DisplayDevice.class);
    boolean isHeadless = display.isHeadless();
    ListMultimap<Name, Class<?>> systemsByModule = ArrayListMultimap.create();
    for (Class<?> type : environment.getTypesAnnotatedWith(RegisterSystem.class)) {
        if (!ComponentSystem.class.isAssignableFrom(type)) {
            logger.error("Cannot load {}, must be a subclass of ComponentSystem", type.getSimpleName());
            continue;
        }
        Name moduleId = environment.getModuleProviding(type);
        RegisterSystem registerInfo = type.getAnnotation(RegisterSystem.class);
        if (registerInfo.value().isValidFor(netMode.isAuthority(), isHeadless) && areOptionalRequirementsContained(registerInfo, environment)) {
            systemsByModule.put(moduleId, type);
        }
    }
    for (Module module : environment.getModulesOrderedByDependencies()) {
        for (Class<?> system : systemsByModule.get(module.getId())) {
            String id = module.getId() + ":" + system.getSimpleName();
            logger.debug("Registering system {}", id);
            if (checkOptionalDependenciesPresent(system)) {
                tryToLoadSystem(system, id);
            } else {
                logger.warn("Skip system {} for loading - possibly missing optional dependencies", id);
            }
        }
    }
}
Also used : DisplayDevice(org.terasology.engine.core.subsystem.DisplayDevice) RegisterSystem(org.terasology.engine.entitySystem.systems.RegisterSystem) ComponentSystem(org.terasology.engine.entitySystem.systems.ComponentSystem) Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name)

Example 4 with DisplayDevice

use of org.terasology.engine.core.subsystem.DisplayDevice in project Terasology by MovingBlocks.

the class StateIngame method render.

@Override
public void render() {
    DisplayDevice display = context.get(DisplayDevice.class);
    display.prepareToRender();
    if (worldRenderer != null) {
        if (!context.get(Config.class).getRendering().isVrSupport()) {
            worldRenderer.render(RenderingStage.MONO);
        } else {
            worldRenderer.render(RenderingStage.LEFT_EYE);
            worldRenderer.render(RenderingStage.RIGHT_EYE);
        }
    }
    /* UI */
    PerformanceMonitor.startActivity("Render and Update UI");
    renderUserInterface();
    PerformanceMonitor.endActivity();
}
Also used : DisplayDevice(org.terasology.engine.core.subsystem.DisplayDevice) Config(org.terasology.engine.config.Config)

Example 5 with DisplayDevice

use of org.terasology.engine.core.subsystem.DisplayDevice in project Terasology by MovingBlocks.

the class PathManager method chooseHomePathManually.

/**
 * Gives user the option to manually choose home path.
 * @throws IOException Thrown when required directories cannot be accessed.
 */
public void chooseHomePathManually() throws IOException {
    DisplayDevice display = context.get(DisplayDevice.class);
    boolean isHeadless = display.isHeadless();
    if (!isHeadless) {
        Path rawPath = new JFileChooser().getFileSystemView().getDefaultDirectory().toPath();
        homePath = rawPath.resolve("Terasology");
    } else {
        // If the system is headless
        homePath = Paths.get("").toAbsolutePath();
    }
    updateDirs();
}
Also used : Path(java.nio.file.Path) DisplayDevice(org.terasology.engine.core.subsystem.DisplayDevice) JFileChooser(javax.swing.JFileChooser)

Aggregations

DisplayDevice (org.terasology.engine.core.subsystem.DisplayDevice)6 HashMap (java.util.HashMap)2 Context (org.terasology.engine.context.Context)2 TelemetryCategory (org.terasology.engine.telemetry.TelemetryCategory)2 Path (java.nio.file.Path)1 JFileChooser (javax.swing.JFileChooser)1 Config (org.terasology.engine.config.Config)1 ComponentSystem (org.terasology.engine.entitySystem.systems.ComponentSystem)1 RegisterSystem (org.terasology.engine.entitySystem.systems.RegisterSystem)1 Module (org.terasology.gestalt.module.Module)1 Name (org.terasology.gestalt.naming.Name)1