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);
}
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;
}
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);
}
}
}
}
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();
}
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();
}
Aggregations