fix for all propgroups other than tuple, that already worked
This commit is contained in:
parent
0e62da4d19
commit
7f4c8d34f3
|
@ -3,6 +3,7 @@ from .utils import generate_wrapper_propertyGroup
|
||||||
from . import process_component
|
from . import process_component
|
||||||
|
|
||||||
def process_list(registry, definition, update, nesting_long_names=[]):
|
def process_list(registry, definition, update, nesting_long_names=[]):
|
||||||
|
blender_property_mapping = registry.blender_property_mapping
|
||||||
value_types_defaults = registry.value_types_defaults
|
value_types_defaults = registry.value_types_defaults
|
||||||
type_infos = registry.type_infos
|
type_infos = registry.type_infos
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ def process_list(registry, definition, update, nesting_long_names=[]):
|
||||||
|
|
||||||
item_definition = type_infos[ref_name]
|
item_definition = type_infos[ref_name]
|
||||||
item_long_name = item_definition["long_name"]
|
item_long_name = item_definition["long_name"]
|
||||||
is_item_value_type = item_long_name in value_types_defaults
|
is_item_value_type = item_long_name in blender_property_mapping
|
||||||
|
|
||||||
property_group_class = None
|
property_group_class = None
|
||||||
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
||||||
|
|
|
@ -3,6 +3,7 @@ from .utils import generate_wrapper_propertyGroup
|
||||||
from . import process_component
|
from . import process_component
|
||||||
|
|
||||||
def process_map(registry, definition, update, nesting_long_names=[]):
|
def process_map(registry, definition, update, nesting_long_names=[]):
|
||||||
|
blender_property_mapping = registry.blender_property_mapping
|
||||||
value_types_defaults = registry.value_types_defaults
|
value_types_defaults = registry.value_types_defaults
|
||||||
type_infos = registry.type_infos
|
type_infos = registry.type_infos
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ def process_map(registry, definition, update, nesting_long_names=[]):
|
||||||
if key_ref_name in type_infos:
|
if key_ref_name in type_infos:
|
||||||
key_definition = type_infos[key_ref_name]
|
key_definition = type_infos[key_ref_name]
|
||||||
original_long_name = key_definition["long_name"]
|
original_long_name = key_definition["long_name"]
|
||||||
is_key_value_type = original_long_name in value_types_defaults
|
is_key_value_type = original_long_name in blender_property_mapping
|
||||||
definition_link = definition["keyType"]["type"]["$ref"]
|
definition_link = definition["keyType"]["type"]["$ref"]
|
||||||
|
|
||||||
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
||||||
|
@ -38,7 +39,7 @@ def process_map(registry, definition, update, nesting_long_names=[]):
|
||||||
if value_ref_name in type_infos:
|
if value_ref_name in type_infos:
|
||||||
value_definition = type_infos[value_ref_name]
|
value_definition = type_infos[value_ref_name]
|
||||||
original_long_name = value_definition["long_name"]
|
original_long_name = value_definition["long_name"]
|
||||||
is_value_value_type = original_long_name in value_types_defaults
|
is_value_value_type = original_long_name in blender_property_mapping
|
||||||
definition_link = definition["valueType"]["type"]["$ref"]
|
definition_link = definition["valueType"]["type"]["$ref"]
|
||||||
|
|
||||||
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
|
||||||
|
|
|
@ -17,12 +17,15 @@ def process_structs(registry, definition, properties, update, nesting_long_names
|
||||||
if ref_name in type_infos:
|
if ref_name in type_infos:
|
||||||
original = type_infos[ref_name]
|
original = type_infos[ref_name]
|
||||||
original_long_name = original["long_name"]
|
original_long_name = original["long_name"]
|
||||||
is_value_type = original_long_name in value_types_defaults
|
|
||||||
value = value_types_defaults[original_long_name] if is_value_type else None
|
is_value_type = original_long_name in blender_property_mapping
|
||||||
|
has_default_value = original_long_name in value_types_defaults
|
||||||
|
|
||||||
|
value = value_types_defaults[original_long_name] if has_default_value else None
|
||||||
default_values[property_name] = value
|
default_values[property_name] = value
|
||||||
|
|
||||||
if is_value_type:
|
if is_value_type:
|
||||||
if original_long_name in blender_property_mapping:
|
if has_default_value:
|
||||||
blender_property_def = blender_property_mapping[original_long_name]
|
blender_property_def = blender_property_mapping[original_long_name]
|
||||||
blender_property = blender_property_def["type"](
|
blender_property = blender_property_def["type"](
|
||||||
**blender_property_def["presets"],# we inject presets first
|
**blender_property_def["presets"],# we inject presets first
|
||||||
|
@ -31,6 +34,14 @@ def process_structs(registry, definition, properties, update, nesting_long_names
|
||||||
update = update
|
update = update
|
||||||
)
|
)
|
||||||
__annotations__[property_name] = blender_property
|
__annotations__[property_name] = blender_property
|
||||||
|
else:
|
||||||
|
blender_property_def = blender_property_mapping[original_long_name]
|
||||||
|
blender_property = blender_property_def["type"](
|
||||||
|
**blender_property_def["presets"],# we inject presets first
|
||||||
|
name = property_name,
|
||||||
|
update = update
|
||||||
|
)
|
||||||
|
__annotations__[property_name] = blender_property
|
||||||
else:
|
else:
|
||||||
original_long_name = original["long_name"]
|
original_long_name = original["long_name"]
|
||||||
(sub_component_group, _) = process_component.process_component(registry, original, update, {"nested": True, "long_name": original_long_name}, nesting_long_names+[property_name])
|
(sub_component_group, _) = process_component.process_component(registry, original, update, {"nested": True, "long_name": original_long_name}, nesting_long_names+[property_name])
|
||||||
|
|
|
@ -11,7 +11,9 @@ from bpy_types import PropertyGroup
|
||||||
def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, definition_link, registry, update, nesting_long_names=[]):
|
def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, definition_link, registry, update, nesting_long_names=[]):
|
||||||
value_types_defaults = registry.value_types_defaults
|
value_types_defaults = registry.value_types_defaults
|
||||||
blender_property_mapping = registry.blender_property_mapping
|
blender_property_mapping = registry.blender_property_mapping
|
||||||
is_item_value_type = item_long_name in value_types_defaults
|
|
||||||
|
is_item_value_type = item_long_name in blender_property_mapping
|
||||||
|
has_item_default_value = item_long_name in value_types_defaults
|
||||||
|
|
||||||
|
|
||||||
wrapper_name = "wrapper_" + wrapped_type_long_name
|
wrapper_name = "wrapper_" + wrapped_type_long_name
|
||||||
|
@ -42,15 +44,23 @@ def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, defin
|
||||||
|
|
||||||
|
|
||||||
blender_property = StringProperty(default="", update=update)
|
blender_property = StringProperty(default="", update=update)
|
||||||
if item_long_name in blender_property_mapping:
|
if is_item_value_type:
|
||||||
value = value_types_defaults[item_long_name] if is_item_value_type else None
|
value = value_types_defaults[item_long_name] if has_item_default_value else None
|
||||||
blender_property_def = blender_property_mapping[item_long_name]
|
if has_item_default_value:
|
||||||
blender_property = blender_property_def["type"](
|
blender_property_def = blender_property_mapping[item_long_name]
|
||||||
**blender_property_def["presets"],# we inject presets first
|
blender_property = blender_property_def["type"](
|
||||||
name = "property_name",
|
**blender_property_def["presets"],# we inject presets first
|
||||||
default = value,
|
name = "property_name",
|
||||||
update = update
|
default = value,
|
||||||
)
|
update = update
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
blender_property_def = blender_property_mapping[item_long_name]
|
||||||
|
blender_property = blender_property_def["type"](
|
||||||
|
**blender_property_def["presets"],# we inject presets first
|
||||||
|
name = "property_name",
|
||||||
|
update = update
|
||||||
|
)
|
||||||
|
|
||||||
wrapper_annotations = {
|
wrapper_annotations = {
|
||||||
'0' : blender_property
|
'0' : blender_property
|
||||||
|
|
Loading…
Reference in New Issue