Search in sources :

Example 1 with SubtypeLayoutBuilder

use of org.terasology.engine.rendering.nui.widgets.types.object.SubtypeLayoutBuilder in project Terasology by MovingBlocks.

the class TypeWidgetLibraryImpl method getBaseTypeWidget.

@Override
public <T> Optional<UIWidget> getBaseTypeWidget(Binding<T> binding, TypeInfo<T> baseType) {
    try (ModuleContext.ContextSpan ignored = ModuleContext.setContext(contextModule)) {
        if (Primitives.isWrapperType(baseType.getRawType()) || baseType.getRawType().isPrimitive()) {
            return getWidget(binding, baseType);
        }
        ModuleManager moduleManager = context.get(ModuleManager.class);
        TypeRegistry typeRegistry = context.get(TypeRegistry.class);
        SubtypeLayoutBuilder<T> builder = new SubtypeLayoutBuilder<>(baseType, this, moduleManager, typeRegistry);
        return Optional.of(builder.build(binding));
    }
}
Also used : ModuleContext(org.terasology.engine.core.module.ModuleContext) ModuleManager(org.terasology.engine.core.module.ModuleManager) TypeRegistry(org.terasology.reflection.TypeRegistry) SubtypeLayoutBuilder(org.terasology.engine.rendering.nui.widgets.types.object.SubtypeLayoutBuilder)

Aggregations

ModuleContext (org.terasology.engine.core.module.ModuleContext)1 ModuleManager (org.terasology.engine.core.module.ModuleManager)1 SubtypeLayoutBuilder (org.terasology.engine.rendering.nui.widgets.types.object.SubtypeLayoutBuilder)1 TypeRegistry (org.terasology.reflection.TypeRegistry)1