Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-05-07 06:01:50 +0400
committerMatt Ebb <matt@mke3.net>2010-05-07 06:01:50 +0400
commitf259da614193c762db2f1530d8fc3a8971c43535 (patch)
treef4331c616cd170e521e4dd414a7c02078bd3082f /source/blender/makesrna/intern/rna_sensor.c
parent97687969266c5df6ec0d797692dd13576db4bf70 (diff)
Added dynamic enum itemf for add sensor/actuator operators
Diffstat (limited to 'source/blender/makesrna/intern/rna_sensor.c')
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index 5a52a779aee..c8407dfced2 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -104,23 +104,31 @@ static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
}
}
-static EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free)
+EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free)
{
EnumPropertyItem *item= NULL;
- Object *ob = (Object *)ptr->id.data;
-
+ Object *ob=NULL;
int totitem= 0;
+ if (ptr->type == &RNA_Sensor) {
+ 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);
+ }
+
RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR);
RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS);
- if (ob->type==OB_ARMATURE)
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE);
- else if(ob->type==OB_MESH){
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION);
- RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH);
+ if (ob != NULL) {
+ if (ob->type==OB_ARMATURE) {
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE);
+ } else if(ob->type==OB_MESH) {
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION);
+ RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH);
+ }
}
-
+
RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY);
RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK);
RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD);