diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2010-05-09 02:11:00 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2010-05-09 02:11:00 +0400 |
commit | 94cd746566eac365605813f0b7b9a5ed93eec271 (patch) | |
tree | 769ac60011f3058b1e0cc4810af1497a342fd676 /source | |
parent | 5be1fd3592d78c21cafd86cfff69bd23578d77d9 (diff) |
Logic UI - lookup for properties (matt need your help to finish it)
I based this code on drawnode, so I hope this is the right way of doing this.
Working Sensors:
- keyboard
- property
Working Actuators:
- property (partly)
- ipo
- action
- shape action
- message
- random
Need help with:
- actuator sensor
- property actuator (for the second object)
- touch/ray/collision sensors + constraint actuator
(for the material lookup, not the property one)
maybe a doversion + changing the type to material work better here
(as we have in touch sensor)
+ added notifier for the game property.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_logic/logic_window.c | 88 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_actuator.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_property.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sensor.c | 2 |
4 files changed, 90 insertions, 28 deletions
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 3b8ed083ad0..e554d869a4a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3208,6 +3208,14 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_actuator(uiLayout *layout, PointerRNA *ptr) { + /* -- couldnt make it work for actuators + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "actuator", &settings_ptr, "actuators", "", 0); + */ + uiItemR(layout, ptr, "actuator", 0, NULL, 0); } @@ -3296,6 +3304,8 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row, *col; row = uiLayoutRow(layout, 0); @@ -3315,9 +3325,13 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(col, 0); uiItemL(row, "Second Modifier:", 0); uiItemR(row, ptr, "second_modifier_key", UI_ITEM_R_EVENT, "", 0); - - uiItemR(layout, ptr, "target", 0, NULL, 0); - uiItemR(layout, ptr, "log", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "target", &settings_ptr, "properties", NULL, 0); + uiItemPointerR(layout, ptr, "log", &settings_ptr, "properties", NULL, 0); + +// uiItemR(layout, ptr, "target", 0, NULL, 0); +// uiItemR(layout, ptr, "log", 0, NULL, 0); } static void draw_sensor_message(uiLayout *layout, PointerRNA *ptr) @@ -3343,9 +3357,14 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + uiLayout *row; uiItemR(layout, ptr, "evaluation_type", 0, NULL, 0); - uiItemR(layout, ptr, "property", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, 0); switch (RNA_enum_get(ptr, "evaluation_type")) { case SENS_PROP_INTERVAL: @@ -3556,8 +3575,12 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); @@ -3565,7 +3588,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -3577,7 +3600,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "priority", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR uiItemR(row, "stride_length", 0, NULL, 0); @@ -3809,8 +3832,13 @@ static void draw_actuator_game(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row, *subrow, *col; + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "play_type", 0, "", 0); subrow= uiLayoutRow(row, 1); @@ -3823,7 +3851,7 @@ static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "play_type") == ACT_IPO_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -3832,31 +3860,37 @@ static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "child", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); } static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row; + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemR(layout, ptr, "to_property", 0, NULL, 0); uiItemR(layout, ptr, "subject", 0, NULL, 0); - row= uiLayoutRow(layout, 0); + row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "body_type", 0, NULL, 0); if(RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) - uiItemR(row, ptr, "body_message", 0, NULL, 0); + uiItemR(row, ptr, "body_message", 0, "", 0); else // mode == ACT_MESG_PROP - uiItemR(row, ptr, "body_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "body_property", &settings_ptr, "properties", "", 0); } static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) { - uiLayout *split, *row, *col, *subcol; - Object *ob = (Object *)ptr->id.data; + Object *ob; PointerRNA settings_ptr; - + uiLayout *split, *row, *col, *subcol; + + ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); uiItemR(layout, ptr, "mode", 0, NULL, 0); @@ -3957,10 +3991,14 @@ 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; uiItemR(layout, ptr, "mode", 0, NULL, 0); - uiItemR(layout, ptr, "prop_name", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, 0); switch(RNA_enum_get(ptr, "mode")) { @@ -3975,26 +4013,32 @@ 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_prop_name", 0, NULL, 0); + uiItemR(row, ptr, "object_property", 0, NULL, 0); } } static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row; + + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row = uiLayoutRow(layout, 0); uiItemR(row, ptr, "seed", 0, NULL, 0); uiItemR(row, ptr, "distribution", 0, NULL, 0); row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); row = uiLayoutRow(layout, 0); switch (RNA_enum_get(ptr, "distribution")){ case ACT_RANDOM_BOOL_CONST: - uiItemR(row, ptr, "always_true", 0, NULL, 0); + uiItemR(row, ptr, "always_true", UI_ITEM_R_TOGGLE, NULL, 0); break; case ACT_RANDOM_BOOL_UNIFORM: @@ -4056,8 +4100,12 @@ static void draw_actuator_scene(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); @@ -4065,7 +4113,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -4077,7 +4125,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "priority", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR uiItemR(row, "stride_length", 0, NULL, 0); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index cc1cd9b1e1d..43b09c84a12 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -383,8 +383,6 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre 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); } } @@ -400,6 +398,13 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE); + + if (ob != NULL) { + if (ob->type==OB_MESH){ + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); + } + } + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STATE); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_VISIBILITY); @@ -936,8 +941,7 @@ static void rna_def_property_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mode", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); - //XXX add magic property lookup - prop= RNA_def_property(srna, "prop_name", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "The name of the property"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -955,7 +959,7 @@ static void rna_def_property_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); //XXX add even magic'er property lookup (need to look for the property list of the target object) - prop= RNA_def_property(srna, "object_prop_name", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "object_property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Property Name", "Copy this property"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -1340,7 +1344,6 @@ static void rna_def_random_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Seed", "Initial seed of the random generator. Use Python for more freedom (choose 0 for not random)"); RNA_def_property_update(prop, NC_LOGIC, NULL); - //XXX add magic property lookup prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "propname"); RNA_def_property_ui_text(prop, "Property", "Assign the random value to this property"); @@ -1464,7 +1467,7 @@ static void rna_def_message_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "body_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "bodyType"); RNA_def_property_enum_items(prop, prop_body_type_items); - RNA_def_property_ui_text(prop, "Body Type", "Toggle message type: either Text or a PropertyName"); + RNA_def_property_ui_text(prop, "Body", "Toggle message type: either Text or a PropertyName"); /* ACT_MESG_MESG */ prop= RNA_def_property(srna, "body_message", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index c65aa4ac725..7bcb58ea28d 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -30,6 +30,8 @@ #include "DNA_property_types.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include "BKE_property.h" @@ -111,24 +113,29 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Available as GameObject attributes in the game engine's python API"); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GameProperty_name_set"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, gameproperty_type_items); RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_enum_funcs(prop, NULL, "rna_GameProperty_type_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG); RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameBooleanProperty */ srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty"); RNA_def_struct_ui_text(srna , "Game Boolean Property", "Game engine user defined Boolean property"); RNA_def_struct_sdna(srna, "bProperty"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "data", 1); RNA_def_property_ui_text(prop, "Value", "Property value"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameIntProperty */ srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty"); @@ -139,6 +146,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "data"); RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameFloatProperty */ srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty"); @@ -150,6 +158,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameTimerProperty */ srna= RNA_def_struct(brna, "GameTimerProperty", "GameProperty"); @@ -161,6 +170,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameStringProperty */ srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty"); @@ -171,6 +181,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "poin"); RNA_def_property_string_maxlength(prop, MAX_PROPSTRING); RNA_def_property_ui_text(prop, "Value", "Property value"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 3621d6bb6d0..45a660a0895 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -314,7 +314,7 @@ static void rna_def_touch_sensor(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_sdna(prop, NULL, "ma"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material", "Only look for floors with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material"); RNA_def_property_update(prop, NC_LOGIC, NULL); } |