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
parent97687969266c5df6ec0d797692dd13576db4bf70 (diff)
Added dynamic enum itemf for add sensor/actuator operators
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_logic/logic_ops.c6
-rw-r--r--source/blender/editors/space_logic/logic_window.c8
-rw-r--r--source/blender/makesrna/RNA_enum_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c26
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c26
5 files changed, 44 insertions, 28 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index ee65068e537..3b4915692dd 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -289,7 +289,8 @@ void LOGIC_OT_sensor_add(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- prop= RNA_def_enum(ot->srna, "type", sensor_type_items, SENS_ALWAYS, "Type", "Type of sensor to add");
+ prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add");
+ RNA_def_enum_funcs(prop, rna_Sensor_type_itemf);
}
/* ************* Add/Remove Controller Operator ************* */
@@ -474,7 +475,8 @@ void LOGIC_OT_actuator_add(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- prop= RNA_def_enum(ot->srna, "type", actuator_type_items, CONT_LOGIC_AND, "Type", "Type of actuator to add");
+ prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add");
+ RNA_def_enum_funcs(prop, rna_Actuator_type_itemf);
}
void ED_operatortypes_logic(void)
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 91a0dd9ee4f..90f60dfaad9 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -4313,7 +4313,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
{
PointerRNA settings_ptr;
row = uiLayoutRow(layout, 0);
- RNA_pointer_create(NULL, &RNA_GameObjectSettings, ob, &settings_ptr);
+ RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
uiItemR(row, &logic_ptr, "controllers_show_initial_state", UI_ITEM_R_NO_BG, "", 0);
uiTemplateLayers(row, &settings_ptr, "state", &settings_ptr, "used_state", 0);
@@ -4346,7 +4346,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
uiItemS(layout);
for(cont= ob->controllers.first; cont; cont=cont->next) {
- RNA_pointer_create(&ob->id, &RNA_Controller, cont, &ptr);
+ RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &ptr);
if (!(ob->state & cont->state_mask))
continue;
@@ -4421,7 +4421,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
uiItemS(layout);
for(sens= ob->sensors.first; sens; sens=sens->next) {
- RNA_pointer_create(&ob->id, &RNA_Sensor, sens, &ptr);
+ RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr);
if ((slogic->scaflag & BUTS_SENS_STATE) ||
(sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
@@ -4480,7 +4480,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
for(act= ob->actuators.first; act; act=act->next) {
- RNA_pointer_create(&ob->id, &RNA_Actuator, act, &ptr);
+ RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr);
if ((slogic->scaflag & BUTS_ACT_STATE) ||
!(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index fd96d1d41d7..bb0a1ba2c52 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -75,12 +75,8 @@ extern EnumPropertyItem object_type_items[];
extern EnumPropertyItem object_type_curve_items[];
-extern EnumPropertyItem sensor_type_items[];
-
extern EnumPropertyItem controller_type_items[];
-extern EnumPropertyItem actuator_type_items[];
-
extern EnumPropertyItem space_type_items[];
extern EnumPropertyItem keymap_propvalue_items[];
@@ -97,6 +93,8 @@ extern EnumPropertyItem viewport_shading_items[];
struct bContext;
struct PointerRNA;
EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
+EnumPropertyItem *rna_Sensor_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
+EnumPropertyItem *rna_Actuator_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
/* Generic functions, return an enum from library data, index is the position
* in the linked list can add more for different types as needed */
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);
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);