forked from bartvdbraak/blender
minor edits to xml presets
- check 'SKIP_SAVE' property (used for active theme area which become annoying) - indent presets better
This commit is contained in:
parent
535d27dac2
commit
ef3fbdd683
@ -32,7 +32,13 @@ def build_property_typemap(skip_classes):
|
|||||||
if issubclass(cls, skip_classes):
|
if issubclass(cls, skip_classes):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
properties = cls.bl_rna.properties.keys()
|
## to support skip-save we cant get all props
|
||||||
|
# properties = cls.bl_rna.properties.keys()
|
||||||
|
properties = []
|
||||||
|
for prop_id, prop in cls.bl_rna.properties.items():
|
||||||
|
if not prop.is_skip_save:
|
||||||
|
properties.append(prop_id)
|
||||||
|
|
||||||
properties.remove("rna_type")
|
properties.remove("rna_type")
|
||||||
property_typemap[attr] = properties
|
property_typemap[attr] = properties
|
||||||
|
|
||||||
@ -47,6 +53,7 @@ def rna2xml(fw=print_ln,
|
|||||||
root_node="",
|
root_node="",
|
||||||
root_rna=None, # must be set
|
root_rna=None, # must be set
|
||||||
root_rna_skip=set(),
|
root_rna_skip=set(),
|
||||||
|
root_ident="",
|
||||||
ident_val=" ",
|
ident_val=" ",
|
||||||
skip_classes=(bpy.types.Operator,
|
skip_classes=(bpy.types.Operator,
|
||||||
bpy.types.Panel,
|
bpy.types.Panel,
|
||||||
@ -173,10 +180,11 @@ def rna2xml(fw=print_ln,
|
|||||||
# needs re-workign to be generic
|
# needs re-workign to be generic
|
||||||
|
|
||||||
if root_node:
|
if root_node:
|
||||||
fw("<%s>\n" % root_node)
|
fw("%s<%s>\n" % (root_ident, root_node))
|
||||||
|
|
||||||
# bpy.data
|
# bpy.data
|
||||||
if method == 'DATA':
|
if method == 'DATA':
|
||||||
|
ident = root_ident + ident_val
|
||||||
for attr in dir(root_rna):
|
for attr in dir(root_rna):
|
||||||
|
|
||||||
# exceptions
|
# exceptions
|
||||||
@ -192,16 +200,16 @@ def rna2xml(fw=print_ln,
|
|||||||
ls = None
|
ls = None
|
||||||
|
|
||||||
if type(ls) == list:
|
if type(ls) == list:
|
||||||
fw("%s<%s>\n" % (ident_val, attr))
|
fw("%s<%s>\n" % (ident, attr))
|
||||||
for blend_id in ls:
|
for blend_id in ls:
|
||||||
rna2xml_node(ident_val + ident_val, blend_id, None)
|
rna2xml_node(ident + ident_val, blend_id, None)
|
||||||
fw("%s</%s>\n" % (ident_val, attr))
|
fw("%s</%s>\n" % (ident_val, attr))
|
||||||
# any attribute
|
# any attribute
|
||||||
elif method == 'ATTR':
|
elif method == 'ATTR':
|
||||||
rna2xml_node("", root_rna, None)
|
rna2xml_node(root_ident, root_rna, None)
|
||||||
|
|
||||||
if root_node:
|
if root_node:
|
||||||
fw("</%s>\n" % root_node)
|
fw("%s</%s>\n" % (root_ident, root_node))
|
||||||
|
|
||||||
|
|
||||||
def xml2rna(root_xml,
|
def xml2rna(root_xml,
|
||||||
@ -350,7 +358,11 @@ def xml_file_write(context, filepath, rna_map):
|
|||||||
for rna_path, xml_tag in rna_map:
|
for rna_path, xml_tag in rna_map:
|
||||||
# xml_tag is ignored, we get this from the rna
|
# xml_tag is ignored, we get this from the rna
|
||||||
value = _get_context_val(context, rna_path)
|
value = _get_context_val(context, rna_path)
|
||||||
rna2xml(fw, root_rna=value, method='ATTR')
|
rna2xml(fw,
|
||||||
|
root_rna=value,
|
||||||
|
method='ATTR',
|
||||||
|
root_ident=" ",
|
||||||
|
ident_val=" ")
|
||||||
|
|
||||||
fw("</bpy>\n")
|
fw("</bpy>\n")
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -1970,6 +1970,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
|
|||||||
|
|
||||||
prop= RNA_def_property(srna, "theme_area", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "theme_area", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "active_theme_area");
|
RNA_def_property_enum_sdna(prop, NULL, "active_theme_area");
|
||||||
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||||
RNA_def_property_enum_items(prop, active_theme_area);
|
RNA_def_property_enum_items(prop, active_theme_area);
|
||||||
RNA_def_property_ui_text(prop, "Active Theme Area", "");
|
RNA_def_property_ui_text(prop, "Active Theme Area", "");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user