diff options
author | Matt Ebb <matt@mke3.net> | 2010-05-07 06:01:50 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-05-07 06:01:50 +0400 |
commit | f259da614193c762db2f1530d8fc3a8971c43535 (patch) | |
tree | f4331c616cd170e521e4dd414a7c02078bd3082f /source/blender/makesrna/intern/rna_actuator.c | |
parent | 97687969266c5df6ec0d797692dd13576db4bf70 (diff) |
Added dynamic enum itemf for add sensor/actuator operators
Diffstat (limited to 'source/blender/makesrna/intern/rna_actuator.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_actuator.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index ff735d35ade..11995264c94 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -174,19 +174,27 @@ static EnumPropertyItem *rna_EditObjectActuator_mode_itemf(bContext *C, PointerR return item; } -static EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) { EnumPropertyItem *item= NULL; - Object *ob = (Object *)ptr->id.data; - + Object *ob= NULL; int totitem= 0; - if (ob->type==OB_ARMATURE) - { - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); + + if (ptr->type == &RNA_Actuator) { + ob = (Object *)ptr->id.data; + } else { + /* can't use ob from ptr->id.data because that enum is also used by operators */ + ob = CTX_data_active_object(C); + } + + if (ob != NULL) { + if (ob->type==OB_ARMATURE) { + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); + } else { + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); + } } - else - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT); |