Logic UI: using the RNA interface as default - commit pre-subversion bumping (i.e. no DNA changes here)

Also: extra set funcs, layout adjustments

The patch for the subversion commit was getting too big, and it will be hard to distinguish what was essentially do_version + DNA changes and what was layout adjustments.

So this is the first part of the commit. The next may take a bit more because I'm not so confident in my readfile changes.
This commit is contained in:
Dalai Felinto
2010-05-11 06:56:59 +00:00
parent daba1d23ff
commit 8828234902
4 changed files with 153 additions and 37 deletions

View File

@@ -3217,11 +3217,24 @@ static void draw_sensor_actuator(uiLayout *layout, PointerRNA *ptr)
static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr)
{
bSensor *sens = (bSensor*)ptr->data;
bArmatureSensor *as = (bArmatureSensor *) sens->data;
Object *ob = (Object *)ptr->id.data;
PointerRNA pose_ptr, pchan_ptr;
PropertyRNA *bones_prop;
uiLayout *row;
row = uiLayoutRow(layout, 1);
uiItemR(row, ptr, "channel_name", 0, NULL, 0);
uiItemR(row, ptr, "constraint_name", 0, NULL, 0);
if (ob->pose) {
RNA_pointer_create((ID *)ob, &RNA_Pose, ob->pose, &pose_ptr);
bones_prop = RNA_struct_find_property(&pose_ptr, "bones");
}
if (&pose_ptr.data) {
uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, as->posechannel, &pchan_ptr))
uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
}
row = uiLayoutRow(layout, 1);
uiItemR(row, ptr, "test_type", 0, NULL, 0);
uiItemR(row, ptr, "value", 0, NULL, 0);
@@ -3346,7 +3359,7 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr)
uiItemR(layout, ptr, "property", 0, NULL, 0);
row= uiLayoutRow(layout, 0);
row= uiLayoutRow(layout, 1);
uiItemR(row, ptr, "distance", 0, NULL, 0);
uiItemR(row, ptr, "reset_distance", 0, NULL, 0);
}
@@ -3503,7 +3516,7 @@ static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr)
static void draw_controller_python(uiLayout *layout, PointerRNA *ptr)
{
uiLayout *row, *split, *subsplit;
uiLayout *split, *subsplit;
split = uiLayoutSplit(layout, 0.3, 1);
uiItemR(split, ptr, "mode", 0, "", 0);
@@ -3671,7 +3684,7 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr)
static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr)
{
uiLayout *row, *subrow, *col, *subcol, *split;
uiLayout *row, *col, *subcol, *split;
uiItemR(layout, ptr, "mode", 0, NULL, 0);
switch (RNA_enum_get(ptr, "mode"))
@@ -3815,7 +3828,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr)
{
uiLayout *split;
uiLayout *row, *split;
uiItemR(layout, ptr, "mode", 0, NULL, 0);
switch (RNA_enum_get(ptr, "mode"))
@@ -3825,8 +3838,10 @@ static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr)
uiItemR(layout, ptr, "glsl_shader", 0, NULL, 0);
break;
case ACT_2DFILTER_MOTIONBLUR:
split=uiLayoutSplit(layout, 0.9, 0);
uiItemR(split, ptr, "motion_blur_value", 0, NULL, 0);
split=uiLayoutSplit(layout, 0.75, 1);
row= uiLayoutRow(split, 0);
uiLayoutSetActive(row, RNA_boolean_get(ptr, "enable_motion_blur")==1);
uiItemR(row, ptr, "motion_blur_value", 0, NULL, 0);
uiItemR(split, ptr, "enable_motion_blur", UI_ITEM_R_TOGGLE, NULL, 0);
break;
default: // all other 2D Filters
@@ -4004,12 +4019,16 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr)
static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
PointerRNA settings_ptr;
uiLayout *row;
bActuator *act = (bActuator *)ptr->data;
bPropertyActuator *pa = (bPropertyActuator *) act->data;
Object *ob_from= pa->ob;
PointerRNA settings_ptr, obj_settings_ptr;
uiItemR(layout, ptr, "mode", 0, NULL, 0);
uiLayout *row, *subrow;
RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
uiItemR(layout, ptr, "mode", 0, NULL, 0);
uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, 0);
switch(RNA_enum_get(ptr, "mode"))
@@ -4025,7 +4044,16 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
case ACT_PROP_COPY:
row = uiLayoutRow(layout, 0);
uiItemR(row, ptr, "object", 0, NULL, 0);
uiItemR(row, ptr, "object_property", 0, NULL, 0);
if(ob_from){
RNA_pointer_create((ID *)ob_from, &RNA_GameObjectSettings, ob_from, &obj_settings_ptr);
uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, 0);
}else
{
subrow= uiLayoutRow(row, 0);
uiLayoutSetActive(subrow, 0);
uiItemR(subrow, ptr, "object_property", 0, NULL, 0);
}
break;
}
}
@@ -4555,7 +4583,7 @@ void logic_buttons(bContext *C, ARegion *ar)
* pin so changing states dosnt hide the logic brick */
char pin;
if (G.rt != 0) {
if (G.rt == 0) {
logic_buttons_new(C, ar);
return;
}

View File

@@ -260,8 +260,7 @@ typedef struct bJoystickSensor {
* ... The reason for this is that we need to be backward compatible,
* and have a proper default value for this thing.
* */
/* #define SENS_COLLISION_PROPERTY 0 */
#define SENS_COLLISION_PROPERTY 0 // uncommenting to use with RNA/UI. will check if it's working/fix it later - dfelinto
#define SENS_COLLISION_PROPERTY 0
#define SENS_COLLISION_MATERIAL 1
#define SENS_COLLISION_PULSE 2

View File

@@ -27,21 +27,23 @@
#include "RNA_define.h"
#include "rna_internal.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_actuator_types.h"
#include "DNA_scene_types.h" // for MAXFRAME
#include "WM_types.h"
/* Always keep in alphabetical order */
EnumPropertyItem actuator_type_items[] ={
{ACT_ACTION, "ACTION", 0, "Action", ""},
{ACT_ARMATURE, "ARMATURE", 0, "Armature", ""},
{ACT_CAMERA, "CAMERA", 0, "Camera", ""},
{ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""},
{ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""},
{ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""},
{ACT_GAME, "GAME", 0, "Game", ""},
{ACT_IPO, "F-Curve", 0, "F-Curve", ""},
{ACT_2DFILTER, "FILTER_2D", 0, "Filter 2D", ""},
{ACT_GAME, "GAME", 0, "Game", ""},
{ACT_MESSAGE, "MESSAGE", 0, "Message", ""},
{ACT_OBJECT, "OBJECT", 0, "Motion", ""},
{ACT_PARENT, "PARENT", 0, "Parent", ""},
@@ -366,6 +368,7 @@ static EnumPropertyItem *rna_EditObjectActuator_mode_itemf(bContext *C, PointerR
return item;
}
/* Always keep in alphabetical order */
EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free)
{
EnumPropertyItem *item= NULL;
@@ -389,9 +392,9 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_EDIT_OBJECT);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_IPO);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_2DFILTER);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_GAME);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_IPO);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MESSAGE);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_OBJECT);
RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PARENT);
@@ -415,6 +418,40 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre
return item;
}
static void rna_Actuator_Armature_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bActuator *act= (bActuator *)ptr->data;
bArmatureActuator *aa = act->data;
Object *ob = (Object *)ptr->id.data;
char *posechannel= aa->posechannel;
char *constraint= aa->constraint;
/* check that bone exist in the active object */
if (ob->type == OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;
bPose *pose = ob->pose;
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
if (!strcmp(pchan->name, posechannel)) {
/* found it, now look for constraint channel */
bConstraint *con;
for (con=pchan->constraints.first; con; con=con->next) {
if (!strcmp(con->name, constraint)) {
/* found it, all ok */
return;
}
}
/* didn't find constraint, make empty */
constraint[0] = 0;
return;
}
}
}
/* didn't find any */
posechannel[0] = 0;
constraint[0] = 0;
}
#else
void rna_def_actuator(BlenderRNA *brna)
@@ -1288,8 +1325,9 @@ static void rna_def_scene_actuator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Scene", "");
RNA_def_property_update(prop, NC_LOGIC, NULL);
//XXX filter only camera objects
prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Camera");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Camera Object", "Set this Camera. Leave empty to refer to self object");
RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -1590,7 +1628,7 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 99); //MAX_RENDER_PASS-1
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "motion_blur_value", PROP_FLOAT, PROP_PERCENTAGE);
prop= RNA_def_property(srna, "motion_blur_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "float_arg");
RNA_def_property_ui_text(prop, "Value", "Set motion blur value");
RNA_def_property_range(prop, 0.0, 1.0);
@@ -1599,7 +1637,7 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna)
/* booleans */
prop= RNA_def_property(srna, "enable_motion_blur", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 1);
RNA_def_property_ui_text(prop, "D", "Enable/Disable Motion Blur");
RNA_def_property_ui_text(prop, "Enable", "Enable/Disable Motion Blur");
RNA_def_property_update(prop, NC_LOGIC, NULL);
}
@@ -1776,18 +1814,12 @@ static void rna_def_armature_actuator(BlenderRNA *brna)
prop= RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "posechannel");
RNA_def_property_ui_text(prop, "Bone", "Bone on which the constraint is defined");
RNA_def_property_update(prop, NC_LOGIC, NULL);
// XXX uiButSetFunc(but, check_armature_actuator, but, armAct); // the bone must be from the armature
/* XXX eventually move to a datablock pointer. However datablocking this may be a problem
we would need to update the value whenever the armature changes. */
RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update");
prop= RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "constraint");
RNA_def_property_ui_text(prop, "Constraint", "Name of the constraint you want to control");
RNA_def_property_update(prop, NC_LOGIC, NULL);
// XXX uiButSetFunc(but, check_armature_actuator, but, armAct); // the constraintbone must be from the armature
/* XXX eventually move to a datablock pointer.
(more likely to work than for the Bone in my opinion) */
RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update");
prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
@@ -1819,7 +1851,7 @@ void RNA_def_actuator(BlenderRNA *brna)
rna_def_camera_actuator(brna);
rna_def_sound_actuator(brna);
rna_def_property_actuator(brna);
rna_def_constraint_actuator(brna); // to be done
rna_def_constraint_actuator(brna);
rna_def_edit_object_actuator(brna);
rna_def_scene_actuator(brna);
rna_def_random_actuator(brna);

View File

@@ -29,11 +29,13 @@
#include "rna_internal.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_sensor_types.h"
#include "WM_types.h"
/* Always keep in alphabetical order */
EnumPropertyItem sensor_type_items[] ={
{SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""},
{SENS_ALWAYS, "ALWAYS", 0, "Always", ""},
@@ -106,6 +108,7 @@ static void rna_Sensor_type_set(struct PointerRNA *ptr, int value)
}
}
/* Always keep in alphabetical order */
EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free)
{
EnumPropertyItem *item= NULL;
@@ -180,6 +183,58 @@ static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value)
ks->qual2 = value;
}
static void rna_Sensor_tap_set(struct PointerRNA *ptr, int value)
{
bSensor *sens= (bSensor*)ptr->data;
sens->tap = value;
if(sens->tap == 1)
sens->level = 0;
}
static void rna_Sensor_level_set(struct PointerRNA *ptr, int value)
{
bSensor *sens= (bSensor*)ptr->data;
sens->level = value;
if(sens->level == 1)
sens->tap = 0;
}
static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bSensor *sens= (bSensor *)ptr->data;
bArmatureSensor *as = sens->data;
Object *ob = (Object *)ptr->id.data;
char *posechannel= as->posechannel;
char *constraint= as->constraint;
/* check that bone exist in the active object */
if (ob->type == OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;
bPose *pose = ob->pose;
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
if (!strcmp(pchan->name, posechannel)) {
/* found it, now look for constraint channel */
bConstraint *con;
for (con=pchan->constraints.first; con; con=con->next) {
if (!strcmp(con->name, constraint)) {
/* found it, all ok */
return;
}
}
/* didn't find constraint, make empty */
constraint[0] = 0;
return;
}
}
}
/* didn't find any */
posechannel[0] = 0;
constraint[0] = 0;
}
#else
static void rna_def_sensor(BlenderRNA *brna)
@@ -216,6 +271,7 @@ static void rna_def_sensor(BlenderRNA *brna)
prop= RNA_def_property(srna, "level", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Level", "Level detector, trigger controllers of new states(only applicable upon logic state transition)");
RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_level_set");
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "pulse_true_level", PROP_BOOLEAN, PROP_NONE);
@@ -234,8 +290,9 @@ static void rna_def_sensor(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 10000);
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "tap", PROP_BOOLEAN, PROP_NONE);\
prop= RNA_def_property(srna, "tap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "tap", 1);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Sensor_tap_set");
RNA_def_property_ui_text(prop, "Tap", "Trigger controllers only for an instant, even while the sensor remains true");
RNA_def_property_update(prop, NC_LOGIC, NULL);
}
@@ -429,15 +486,15 @@ static void rna_def_armature_sensor(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Test Type", "Type of value and test");
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "channel_name", PROP_STRING, PROP_NONE);
prop= RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "posechannel");
RNA_def_property_ui_text(prop, "Bone name", "Identify the bone to check value from");
RNA_def_property_update(prop, NC_LOGIC, NULL);
RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
prop= RNA_def_property(srna, "constraint_name", PROP_STRING, PROP_NONE);
prop= RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "constraint");
RNA_def_property_ui_text(prop, "Constraint name", "Identify the bone constraint to check value from");
RNA_def_property_update(prop, NC_LOGIC, NULL);
RNA_def_property_update(prop, NC_LOGIC, "rna_Sensor_Armature_update");
prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "value");
@@ -594,7 +651,7 @@ static void rna_def_ray_sensor(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem prop_ray_type_items[]= {
{0, "PROPERTY", ICON_LOGIC, "Property", "Use a material for ray intersections"},
{SENS_COLLISION_PROPERTY, "PROPERTY", ICON_LOGIC, "Property", "Use a material for ray intersections"},
{SENS_COLLISION_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Use a property for ray intersections"},
{0, NULL, 0, NULL, NULL}};