Martin Scheffler
unread,Jul 12, 2012, 7:37:25 AM7/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to dtenti...@googlegroups.com
Hi all,
just a notice about the changes I just committed.
I added a CMake flag CALL_ONPROPERTYCHANGED_METHOD. When this is set
to false, the method PropertyContainer::OnPropertyChanged will be set
to private so it can no longer be overwritten. Also it is no longer
called in the code. If you need to react to property changes, use
properties in dtEntity/dynamicproperty.h instead.
Currently the flag defaults to ON, but I will soon change that, and at
some point I will remove the OnPropertyChanged stuff completely from
the code.
I also did some changes to the way properties of JavaScript components
/ entity systems are created.
These changes are also in when CALL_ONPROPERTYCHANGED_METHOD is on.
Before, all properties of the JS component were converted to dtEntity
properties the first time a js component was accessed from C++.
The type of the properties would be determined from the type of the
javascript property.
function MyComponent() {
this.items = 30;
this.temperature = 30.0;
}
This component, opened in the editor, would show two integer
properties because values with .0 are treated as ints by javascript.
Another problem was that properties not meant for conversion to
dtEntity properties had to begin with "__", forgetting that could
cause problems.
The new way works like this:
function MyComponent() {
createUint32Prop(this, "items", 30);
createNumberProp(this, "temperature", 30.0);
createStringProp(this, "Projection", "3d", function() { return
this.value; }, function(val) { this.value = val; });
}
create*Property has this form:
function(object, propertyname, value, getter, setter);
When value is omitted then value is undefined.
getter and setter, if defined, are functions that are called to set or
get the property. The "this" in these functions references an empty
object that can be used for storage purposes. If omitted, these
functions take the form
getter = function() { return this.value}
setter = function(v) { this.value = v; }
You can set these functions to react to property changes. The values
are converted to the type of the property.
This code is very fresh so expect problems.
Cheers,
Martin