From 4df00c670ef2e03d3dc55b67594e96cc49766831 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 23:22:43 +0000 Subject: RNA: * Added a MaterialSlot collection in Object rather than giving the list of materials immediately. This should more correctly reflect how this data is organized, even though there is no equivalent C struct. * Added name properties to MaterialSlot/TextureSlot/ParticleSystem. --- source/blender/makesrna/intern/rna_texture.c | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'source/blender/makesrna/intern/rna_texture.c') diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index be97fd863f5..1d8a63bf83a 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -23,6 +23,7 @@ */ #include +#include #include #include "RNA_define.h" @@ -30,8 +31,11 @@ #include "rna_internal.h" +#include "DNA_brush_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_texture_types.h" +#include "DNA_world_types.h" #ifdef RNA_RUNTIME @@ -71,6 +75,50 @@ StructRNA *rna_Texture_refine(struct PointerRNA *ptr) } } +static int rna_texture_slot_index(PointerRNA *ptr) +{ + ID *id= ptr->id.data; + MTex **mtex; + int a; + + if(id) { + switch(GS(id->name)) { + case ID_MA: mtex= ((Material*)id)->mtex; break; + case ID_WO: mtex= ((World*)id)->mtex; break; + case ID_LA: mtex= ((Lamp*)id)->mtex; break; + case ID_BR: mtex= ((Brush*)id)->mtex; break; + default: return 0; + } + + for(a=0; adata) + return a; + } + + return 0; +} + +static int rna_TextureSlot_name_length(PointerRNA *ptr) +{ + MTex *mtex= ptr->data; + + if(mtex->tex) + return strlen(mtex->tex->id.name+2) + 10; + + return 10; +} + +static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) +{ + MTex *mtex= ptr->data; + int index= rna_texture_slot_index(ptr); + + sprintf(str, "%d: ", index+1); + + if(mtex->tex) + strcat(str, mtex->tex->id.name+2); +} + #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -190,6 +238,12 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Texture", "Texture datablock used by this texture slot."); + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Texture slot name."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + /* mapping */ prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "ofs"); -- cgit v1.2.3