diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_texture.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 54 |
1 files changed, 54 insertions, 0 deletions
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 <float.h> +#include <stdio.h> #include <stdlib.h> #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; a<MAX_MTEX; a++) + if(mtex[a] == ptr->data) + 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"); |