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:
authorDalai Felinto <dfelinto@gmail.com>2010-05-14 14:45:50 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-05-14 14:45:50 +0400
commit8b4b68becb710e687d8093685d1463a39ca350fe (patch)
treeb1568de40a8231bf3b69abe4bc89f74800e11fd0 /source/blender/editors/space_logic/logic_ops.c
parent56808c6d75c4e44d119000319ad46993dacfa5a6 (diff)
Logic UI: add name option for add operators + ALL button in controller states is working now + fix for actuator STATES filtering option.
Extra comments related bugs: 1)"actuators_show_active_states" doesn't seem to produce any effect (maybe because PIN is not implemented yet? therefore it's always on? 2)If you set the name to be bigger than 32 it will crashes blender (somehow for s/c/a the get function instead of using the defined 32 maxlen it's using 160 (from UserPrerencesFilePaths_python_scriptsdirectory_get ), 3)properties currently can have the same name as s/c/a and they shouldn't. 4)we need an option to show and/or set the STATE of a given controller (in 2.49 it's the number by the controller name)
Diffstat (limited to 'source/blender/editors/space_logic/logic_ops.c')
-rw-r--r--source/blender/editors/space_logic/logic_ops.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index e7abf49e95b..632331459cb 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -263,6 +263,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op)
PropertyRNA *prop;
const char *sens_name;
int type= RNA_enum_get(op->ptr, "type");
+ char name[32];
sens= new_sensor(type);
BLI_addtail(&(ob->sensors), sens);
@@ -270,9 +271,15 @@ static int sensor_add_exec(bContext *C, wmOperator *op)
/* set the sensor name based on rna type enum */
RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &sens_ptr);
prop = RNA_struct_find_property(&sens_ptr, "type");
- RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
- BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
-
+
+ RNA_string_get(op->ptr, "name", name);
+ if(BLI_strnlen(name, 32) < 1){
+ RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
+ BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
+ }
+ else
+ BLI_strncpy(sens->name, name, sizeof(sens->name));
+
make_unique_prop_names(C, sens->name);
ob->scaflag |= OB_SHOWSENS;
@@ -301,6 +308,7 @@ void LOGIC_OT_sensor_add(wmOperatorType *ot)
/* properties */
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);
+ prop= RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Sensor to add");
}
/* ************* Add/Remove Controller Operator ************* */
@@ -360,6 +368,7 @@ static int controller_add_exec(bContext *C, wmOperator *op)
const char *cont_name;
int type= RNA_enum_get(op->ptr, "type");
int bit;
+ char name[32];
cont= new_controller(type);
BLI_addtail(&(ob->controllers), cont);
@@ -367,11 +376,16 @@ static int controller_add_exec(bContext *C, wmOperator *op)
/* set the controller name based on rna type enum */
RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &cont_ptr);
prop = RNA_struct_find_property(&cont_ptr, "type");
- RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name);
- BLI_strncpy(cont->name, cont_name, sizeof(cont->name));
-
+
+ RNA_string_get(op->ptr, "name", name);
+ if(BLI_strnlen(name, 32) < 1){
+ RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name);
+ BLI_strncpy(cont->name, cont_name, sizeof(cont->name));
+ }
+ else
+ BLI_strncpy(cont->name, name, sizeof(cont->name));
+
make_unique_prop_names(C, cont->name);
-
/* set the controller state mask from the current object state.
A controller is always in a single state, so select the lowest bit set
from the object state */
@@ -411,6 +425,7 @@ void LOGIC_OT_controller_add(wmOperatorType *ot)
/* properties */
prop= RNA_def_enum(ot->srna, "type", controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add");
+ prop= RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Controller to add");
}
/* ************* Add/Remove Actuator Operator ************* */
@@ -468,6 +483,8 @@ static int actuator_add_exec(bContext *C, wmOperator *op)
PointerRNA act_ptr;
PropertyRNA *prop;
const char *act_name;
+ char name[32];
+ //XXX RNA_string_get is not using maxlen, it's using UserPreferencesFilePaths_python_scripts_directory_get instead (what limits the string copy to 160 chars in this case and CRASHES Blender).
int type= RNA_enum_get(op->ptr, "type");
act= new_actuator(type);
@@ -476,9 +493,15 @@ static int actuator_add_exec(bContext *C, wmOperator *op)
/* set the actuator name based on rna type enum */
RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &act_ptr);
prop = RNA_struct_find_property(&act_ptr, "type");
- RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
- BLI_strncpy(act->name, act_name, sizeof(act->name));
-
+
+ RNA_string_get(op->ptr, "name", name);
+ if (BLI_strnlen(name, 32) < 1){
+ RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
+ BLI_strncpy(act->name, act_name, sizeof(act->name));
+ }
+ else
+ BLI_strncpy(act->name, name, sizeof(act->name));
+
make_unique_prop_names(C, act->name);
ob->scaflag |= OB_SHOWACT;
@@ -507,6 +530,7 @@ void LOGIC_OT_actuator_add(wmOperatorType *ot)
/* properties */
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);
+ prop= RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Actuator to add");
}
void ED_operatortypes_logic(void)