[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17674] branches/blender2.5/blender/source /blender/makesrna: * rna_property completed

Hamed Zaghaghi hamed.zaghaghi at gmail.com
Tue Dec 2 02:05:24 CET 2008


Revision: 17674
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17674
Author:   zaghaghi
Date:     2008-12-02 02:05:23 +0100 (Tue, 02 Dec 2008)

Log Message:
-----------
* rna_property completed
CAUTION: some defines like PROP_INT in DNA_property_types.h are the same 
as enums in RNA_types.h, and may be encounter hidden errors in future.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2008-12-01 23:38:22 UTC (rev 17673)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2008-12-02 01:05:23 UTC (rev 17674)
@@ -53,6 +53,11 @@
 extern StructRNA RNA_EnumPropertyItem;
 extern StructRNA RNA_FloatProperty;
 extern StructRNA RNA_GameProperty;
+extern StructRNA RNA_GameBooleanProperty;
+extern StructRNA RNA_GameFloatProperty;
+extern StructRNA RNA_GameIntProperty;
+extern StructRNA RNA_GameStringProperty;
+extern StructRNA RNA_GameTimeProperty;
 extern StructRNA RNA_Group;
 extern StructRNA RNA_ID;
 extern StructRNA RNA_IDProperty;

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c	2008-12-01 23:38:22 UTC (rev 17673)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c	2008-12-02 01:05:23 UTC (rev 17674)
@@ -31,9 +31,26 @@
 #include "rna_internal.h"
 
 #include "DNA_object_types.h"
+#include "DNA_property_types.h"
 
 #ifdef RNA_RUNTIME
-
+static struct StructRNA* rna_Object_gameproperties_type(struct CollectionPropertyIterator *iter)
+{
+	bProperty *property= (bProperty*)iter->ptr.data;
+	switch(property->type){
+		case PROP_BOOL:
+			return &RNA_GameBooleanProperty;
+		case PROP_INT:
+			return &RNA_GameIntProperty;
+		case PROP_FLOAT:
+			return &RNA_GameFloatProperty;
+		case PROP_STRING:
+			return &RNA_GameStringProperty;
+		case PROP_TIME:
+			return &RNA_GameTimeProperty;
+	}
+	return &RNA_UnknownType;
+}
 #else
 
 void RNA_def_object(BlenderRNA *brna)
@@ -76,10 +93,8 @@
 
 	prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "prop", NULL);
-	RNA_def_property_struct_type(prop, "GameProperty");
+	RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, "rna_Object_gameproperties_type", 0, 0, 0);
 	RNA_def_property_ui_text(prop, "Property", "Properties of this object.");
-
-
 }
 
 #endif

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c	2008-12-01 23:38:22 UTC (rev 17673)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_property.c	2008-12-02 01:05:23 UTC (rev 17674)
@@ -49,6 +49,7 @@
 		{PROP_TIME, "TIME", "Time", ""},
 		{0, NULL, NULL, NULL}};
 
+	/* Base Struct for GameProperty */
 	srna= RNA_def_struct(brna, "GameProperty", NULL , "GameProperty");
 	RNA_def_struct_sdna(srna, "bProperty");
 
@@ -57,12 +58,58 @@
 	RNA_def_property_string_maxlength(prop, 31);
 	RNA_def_property_ui_text(prop, "Name", "Game Property name.");
 
-	/* type is not editable, would need to do proper data free/alloc */
 	prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
 	RNA_def_property_enum_items(prop, gameproperty_types_items);
 	RNA_def_property_ui_text(prop, "Game Property Types", "Game Property types.");
 
+	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", "Show debug information for this property.");
+
+	/* GameBooleanProperty */
+	srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty" , "GameBooleanProperty");
+	RNA_def_struct_sdna(srna, "bProperty");
+
+	prop= RNA_def_property(srna, "boolean_value", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "data", 1);
+	RNA_def_property_ui_text(prop, "Value", "Property value.");
+
+	/* GameIntProperty */
+	srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty" , "GameIntProperty");
+	RNA_def_struct_sdna(srna, "bProperty");
+
+	prop= RNA_def_property(srna, "int_value", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "data");
+	RNA_def_property_ui_text(prop, "Value", "Property value.");
+	RNA_def_property_range(prop, -10000, 10000);
+
+	/* GameFloatProperty */
+	srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty" , "GameFloatProperty");
+	RNA_def_struct_sdna(srna, "bProperty");
+
+	prop= RNA_def_property(srna, "float_value", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "data");
+	RNA_def_property_ui_text(prop, "Value", "Property value.");
+	RNA_def_property_range(prop, -10000, 10000);
+
+	/* GameTimerProperty */
+	srna= RNA_def_struct(brna, "GameTimeProperty", "GameProperty" , "GameTimeProperty");
+	RNA_def_struct_sdna(srna, "bProperty");
+
+	prop= RNA_def_property(srna, "timer_value", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "data");
+	RNA_def_property_ui_text(prop, "Value", "Property value.");
+	RNA_def_property_range(prop, -10000, 10000);
+
+	/* GameStringProperty */
+	srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty" , "GameStringProperty");
+	RNA_def_struct_sdna(srna, "bProperty");
+
+	prop= RNA_def_property(srna, "string_value", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "poin");
+	RNA_def_property_string_maxlength(prop, MAX_PROPSTRING-1);
+	RNA_def_property_ui_text(prop, "Value", "Property value.");
 }
 
 #endif





More information about the Bf-blender-cvs mailing list