[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28952] trunk/blender/source/blender: Logic Editor - fix for Keyboard Sensor + Copy Game Property fancy submenu
Dalai Felinto
dfelinto at gmail.com
Mon May 24 12:38:06 CEST 2010
Revision: 28952
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28952
Author: dfelinto
Date: 2010-05-24 12:38:05 +0200 (Mon, 24 May 2010)
Log Message:
-----------
Logic Editor - fix for Keyboard Sensor + Copy Game Property fancy submenu
* Keyboard Sensor entry keys (key, modifier 1 and 2) can actually be any key
- (you can use Shift as main key, and D as modifier if you want). It's
- strange in my opinion, but it's 2.49 way of doing it.
* Copy Game Property (operator found in SPACE menu)
- reorganized it so the properties appear as submenu items.
- a "little lot" of work for such a small eye-candie but well I hope more
- people like it as well :)
Matt, I had to recreate the dynamic_enum to make it work. I'm count on you
for a real fix for this ;)
Modified Paths:
--------------
trunk/blender/source/blender/editors/object/object_edit.c
trunk/blender/source/blender/makesrna/intern/rna_sensor.c
Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c 2010-05-24 10:04:54 UTC (rev 28951)
+++ trunk/blender/source/blender/editors/object/object_edit.c 2010-05-24 10:38:05 UTC (rev 28952)
@@ -2239,15 +2239,7 @@
else {
uiItemEnumO(menu, "OBJECT_OT_game_property_copy", NULL, 0, "type", 1);//REPLACE);
uiItemEnumO(menu, "OBJECT_OT_game_property_copy", NULL, 0, "type", 2);//MERGE);
-
- //Menu Separator
- uiItemL(menu, "Copy a Property", 0);
-
- prop= ob->prop.first;
- while(prop) {
- uiItemStringO(menu, prop->name, 0, "OBJECT_OT_game_property_copy", "property", prop->name);
- prop= prop->next;
- }
+ uiItemMenuEnumO(menu, "OBJECT_OT_game_property_copy", "property", "Copy Property", 0);//COPY
}
uiPupMenuEnd(C, pup);
@@ -2255,15 +2247,51 @@
return OPERATOR_CANCELLED;
}
+static EnumPropertyItem gameprops_items[]= {
+ {0, NULL, 0, NULL, NULL}};
+
+static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+ Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem *item= NULL;
+ bProperty *prop;
+ int a, totitem= 0;
+
+ if(!ob)
+ return gameprops_items;
+
+ for(a=1, prop= ob->prop.first; prop; prop=prop->next, a++) {
+ tmp.value= a;
+ tmp.identifier= prop->name;
+ tmp.name= prop->name;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free= 1;
+
+ return item;
+}
+
static int game_property_copy_exec(bContext *C, wmOperator *op)
{
Object *ob=ED_object_active_context(C);
bProperty *prop;
- char prop_name[32];
+ int tmp_int; //need an int pointer to pass for the RNA_enum_name
+ EnumPropertyItem *dyn_props= NULL;
+ const char *prop_name= NULL;
+
int type = RNA_enum_get(op->ptr, "type");
- RNA_string_get(op->ptr, "property", prop_name);
+ int propid= RNA_enum_get(op->ptr, "property");
+ // recreate the dynamic enum with the properties
+ dyn_props = gameprops_itemf(C, NULL, &tmp_int);
+
+ if (propid > 0)
+ RNA_enum_name(dyn_props, propid, &prop_name);
+
if ( type == 1 || type == 2 || type == 3) {
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
if (ob != ob_iter) {
@@ -2279,7 +2307,7 @@
}
CTX_DATA_END;
}
- else if(strlen(prop_name) > 0) { /* copy */
+ else if(prop_name) { /* copy */
prop = (bProperty *) BLI_findstring(&ob->prop, prop_name, offsetof(bProperty, name));
if(prop) {
@@ -2296,6 +2324,7 @@
void OBJECT_OT_game_property_copy(wmOperatorType *ot)
{
+ PropertyRNA *prop;
/* identifiers */
ot->name= "Copy Game Property";
ot->idname= "OBJECT_OT_game_property_copy";
@@ -2309,7 +2338,9 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", game_properties_copy_types, 4, "Operation", "");
- RNA_def_string(ot->srna, "property", "", 32, "Name", "Name of the property to copy");
+ prop=RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
+ RNA_def_enum_funcs(prop, gameprops_itemf);
+ ot->prop=prop;
}
/************************ Copy Logic Bricks ***********************/
Modified: trunk/blender/source/blender/makesrna/intern/rna_sensor.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sensor.c 2010-05-24 10:04:54 UTC (rev 28951)
+++ trunk/blender/source/blender/makesrna/intern/rna_sensor.c 2010-05-24 10:38:05 UTC (rev 28952)
@@ -154,7 +154,7 @@
bSensor *sens= (bSensor *)ptr->data;
bKeyboardSensor *ks = sens->data;
- if (ISKEYBOARD(value) && !ISKEYMODIFIER(value))
+ if (ISKEYBOARD(value))
ks->key = value;
}
@@ -163,7 +163,7 @@
bSensor *sens= (bSensor *)ptr->data;
bKeyboardSensor *ks = sens->data;
- if (ISKEYMODIFIER(value))
+ if (ISKEYBOARD(value))
ks->qual = value;
}
@@ -172,7 +172,7 @@
bSensor *sens= (bSensor *)ptr->data;
bKeyboardSensor *ks = sens->data;
- if (ISKEYMODIFIER(value))
+ if (ISKEYBOARD(value))
ks->qual2 = value;
}
More information about the Bf-blender-cvs
mailing list