Added dynamic enum itemf for add sensor/actuator operators
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user