Search in sources :

Example 1 with TypeRegistry

use of org.terasology.reflection.TypeRegistry 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)

Example 2 with TypeRegistry

use of org.terasology.reflection.TypeRegistry in project Terasology by MovingBlocks.

the class EntitySystemSetupUtil method addReflectionBasedLibraries.

public static void addReflectionBasedLibraries(Context context) {
    ReflectionReflectFactory reflectFactory = new ReflectionReflectFactory();
    context.put(ReflectFactory.class, reflectFactory);
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    context.put(CopyStrategyLibrary.class, copyStrategyLibrary);
    ModuleManager moduleManager = context.get(ModuleManager.class);
    TypeRegistry typeRegistry = context.get(TypeRegistry.class);
    TypeHandlerLibrary typeHandlerLibrary = TypeHandlerLibraryImpl.forModuleEnvironment(moduleManager, typeRegistry);
    context.put(TypeHandlerLibrary.class, typeHandlerLibrary);
    EntitySystemLibrary library = new EntitySystemLibrary(context, typeHandlerLibrary);
    context.put(EntitySystemLibrary.class, library);
    context.put(ComponentLibrary.class, library.getComponentLibrary());
    context.put(EventLibrary.class, library.getEventLibrary());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) EntitySystemLibrary(org.terasology.engine.entitySystem.metadata.EntitySystemLibrary) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) ModuleManager(org.terasology.engine.core.module.ModuleManager) TypeRegistry(org.terasology.reflection.TypeRegistry)

Aggregations

ModuleManager (org.terasology.engine.core.module.ModuleManager)2 TypeRegistry (org.terasology.reflection.TypeRegistry)2 ModuleContext (org.terasology.engine.core.module.ModuleContext)1 EntitySystemLibrary (org.terasology.engine.entitySystem.metadata.EntitySystemLibrary)1 SubtypeLayoutBuilder (org.terasology.engine.rendering.nui.widgets.types.object.SubtypeLayoutBuilder)1 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)1 CopyStrategyLibrary (org.terasology.reflection.copy.CopyStrategyLibrary)1 ReflectionReflectFactory (org.terasology.reflection.reflect.ReflectionReflectFactory)1