@@ -64,6 +64,34 @@ def __set_hide(prop, value):
64
64
65
65
66
66
def __patch (properties ): # temporary patching, should be removed in the future
67
+ def __patch_override (prop : bpy .props ._PropertyDeferred ):
68
+ """Apply recursively for each mmd_tools property class annotations
69
+
70
+ # Hint for bpy.props._PropertyDeferred class
71
+ p = bpy.props.IntProperty(name='abc123')
72
+ assert isinstance(p, bpy.props._PropertyDeferred)
73
+ assert p.function == bpy.props.IntProperty
74
+ assert p.keywords == {'name': 'abc123'}
75
+ """
76
+ prop .keywords .setdefault ('override' , set ()).add ('LIBRARY_OVERRIDABLE' )
77
+
78
+ if prop .function .__name__ not in {'PointerProperty' , 'CollectionProperty' }:
79
+ return
80
+
81
+ prop_type = prop .keywords ['type' ]
82
+ # The __annotations__ cannot be inherited. Manually search for base classes.
83
+ for inherited_type in [prop_type , * prop_type .__bases__ ]:
84
+ if not inherited_type .__module__ .startswith ('mmd_tools.properties' ):
85
+ continue
86
+ for annotation in inherited_type .__annotations__ .values ():
87
+ if not isinstance (annotation , bpy .props ._PropertyDeferred ):
88
+ continue
89
+ __patch_override (annotation )
90
+
91
+ for props in properties .values ():
92
+ for prop in props .values ():
93
+ __patch_override (prop )
94
+
67
95
prop_obj = properties .setdefault (bpy .types .Object , {})
68
96
69
97
prop_obj ['select' ] = bpy .props .BoolProperty (
0 commit comments