From ec42c6d2bd0b99b57be3dd1e0076d2c82152b0c8 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Mon, 12 Aug 2024 17:22:30 +0200 Subject: [PATCH] save and load? --- .../propGroups/conversions_from_prop_group.py | 2 ++ .../propGroups/conversions_to_prop_group.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/blenvy/add_ons/bevy_components/propGroups/conversions_from_prop_group.py b/tools/blenvy/add_ons/bevy_components/propGroups/conversions_from_prop_group.py index 75366b3..f109e78 100644 --- a/tools/blenvy/add_ons/bevy_components/propGroups/conversions_from_prop_group.py +++ b/tools/blenvy/add_ons/bevy_components/propGroups/conversions_from_prop_group.py @@ -25,6 +25,8 @@ conversion_tables = { "bevy_color::srgba::Srgba": lambda value: "Srgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")", "bevy_color::linear_rgba::LinearRgba": lambda value: "LinearRgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")", "bevy_color::hsva::Hsva": lambda value: "Hsva(hue:"+str(value[0])+ ", saturation:"+str(value[1])+ ", value:"+str(value[2])+ ", alpha:"+str(value[3])+ ")", + + "bevy_ecs::entity::Entity": lambda value: "Entity(name:" + str(value) + ")" } #converts the value of a property group(no matter its complexity) into a single custom property value diff --git a/tools/blenvy/add_ons/bevy_components/propGroups/conversions_to_prop_group.py b/tools/blenvy/add_ons/bevy_components/propGroups/conversions_to_prop_group.py index c70d7d7..36ff172 100644 --- a/tools/blenvy/add_ons/bevy_components/propGroups/conversions_to_prop_group.py +++ b/tools/blenvy/add_ons/bevy_components/propGroups/conversions_to_prop_group.py @@ -1,3 +1,4 @@ +import bpy from bpy_types import PropertyGroup import re @@ -126,6 +127,10 @@ def parse_color_hsva(value, caster, typeName): parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") ) return [caster(parsed['hue']), caster(parsed['saturation']), caster(parsed['value']), caster(parsed['alpha'])] +def parse_entity(value): + parsed = parse_struct_string(value.replace("Entity","").replace("(", "").replace(")","") ) + bpy.context.scene.objects[parsed["name"]] + def to_int(input): return int(float(input)) @@ -171,7 +176,7 @@ type_mappings = { "bevy_color::linear_rgba::LinearRgba": lambda value: parse_color_rgba(value, float, "LinearRgba"), "bevy_color::hsva::Hsva": lambda value: parse_color_hsva(value, float, "Hsva"), - 'bevy_ecs::entity::Entity': lambda value: int(value), # TODO: whatdafuq do we do here? + "bevy_ecs::entity::Entity": parse_entity, } def is_def_value_type(definition, registry):