Browse Source

Option 3 add access to Node vars

JimMarlowe 8 years ago
parent
commit
a83a9ab096
1 changed files with 33 additions and 0 deletions
  1. 33 0
      Source/Atomic/Scene/Node.h

+ 33 - 0
Source/Atomic/Scene/Node.h

@@ -602,6 +602,39 @@ public:
     /// Return child scene nodes by name hash, optionally recursive
     /// Return child scene nodes by name hash, optionally recursive
     void GetChildrenWithName(PODVector<Node*>& dest, StringHash nameHash, bool recursive = false) const;
     void GetChildrenWithName(PODVector<Node*>& dest, StringHash nameHash, bool recursive = false) const;
 
 
+    /// Scripting interface to set user data, the data type can be 
+    ///   Int, Bool, Float, Vector2, Vector3, Vector4, Quaternion
+    ///   String, Buffer, ResourceRef, ResourceRefList, IntRect,
+    ///   IntVector2, Matrix3,Matrix3x4, Matrix4, Double, Color
+    /// The data value must be programed in the appropriate string form
+    /// used by the Variant class.
+    void setUserData (const String& name, const String& vartype, const String& value) 
+    { 
+        vars_[name].FromString(vartype, value); 
+    }
+
+    /// Scripting interface to get user data as a string.
+    /// an empty string is returned if the entry name is not present.
+    String getUserData (const String& name) const {
+        if ( isUserData(name) )
+            return vars_[name]->ToString();
+        return String::EMPTY;
+    }
+
+    /// Scripting interface to check if the user data entry exists
+    /// returns true if present, returns false if it is not present.
+    bool isUserData (const String& name) const {
+        return vars_.Contains(name);
+    }
+
+    /// Scripting interface to get user data type as a string
+    /// an empty string is returned if the entry name is not present.
+    String getUserDataType (const String& name) const {
+         if ( isUserData(name) )
+            return vars_[name]->GetTypeName();
+         return String::EMPTY;
+   }
+
     // ATOMIC END
     // ATOMIC END
 
 
 protected:
 protected: