diff options
-rw-r--r-- | source/gameengine/GameLogic/SCA_PropertySensor.cpp | 30 | ||||
-rw-r--r-- | source/gameengine/GameLogic/SCA_PropertySensor.h | 10 | ||||
-rw-r--r-- | source/gameengine/PyDoc/GameTypes.py | 4 |
3 files changed, 43 insertions, 1 deletions
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 134d34fc00d..24dbdb94f95 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -316,10 +316,36 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) { + /* If someone actually do type checking please make sure the 'max' and 'min' + are checked as well (currently they are calling the PrecalculateRangeExpression + function directly */ + /* There is no type checking at this moment, unfortunately... */ return 0; } +int SCA_PropertySensor::validValueForIntervalProperty(void *self, const PyAttributeDef*) +{ + SCA_PropertySensor* sensor = reinterpret_cast<SCA_PropertySensor*>(self); + + if (sensor->m_checktype==KX_PROPSENSOR_INTERVAL) + { + sensor->PrecalculateRangeExpression(); + } + return 0; +} + +int SCA_PropertySensor::modeChange(void *self, const PyAttributeDef* attrdef) +{ + SCA_PropertySensor* sensor = reinterpret_cast<SCA_PropertySensor*>(self); + + if (sensor->m_checktype==KX_PROPSENSOR_INTERVAL) + { + sensor->PrecalculateRangeExpression(); + } + return 0; +} + /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PropertySensor::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -348,9 +374,11 @@ PyMethodDef SCA_PropertySensor::Methods[] = { }; PyAttributeDef SCA_PropertySensor::Attributes[] = { - KX_PYATTRIBUTE_INT_RW("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype), + KX_PYATTRIBUTE_INT_RW_CHECK("mode",KX_PROPSENSOR_NODEF,KX_PROPSENSOR_MAX-1,false,SCA_PropertySensor,m_checktype,modeChange), KX_PYATTRIBUTE_STRING_RW_CHECK("propName",0,100,false,SCA_PropertySensor,m_checkpropname,CheckProperty), KX_PYATTRIBUTE_STRING_RW_CHECK("value",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForProperty), + KX_PYATTRIBUTE_STRING_RW_CHECK("min",0,100,false,SCA_PropertySensor,m_checkpropval,validValueForIntervalProperty), + KX_PYATTRIBUTE_STRING_RW_CHECK("max",0,100,false,SCA_PropertySensor,m_checkpropmaxval,validValueForIntervalProperty), { NULL } //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index 0bc1e9b3579..9a5c4762558 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -95,6 +95,16 @@ public: */ static int validValueForProperty(void* self, const PyAttributeDef*); + /** + * Test whether this is a sensible value for interval (type check) and updates Range Expression + */ + static int validValueForIntervalProperty(void* self, const PyAttributeDef*); + + /** + * Test if the new mode is interval. If positive updates Range Expression + */ + static int modeChange(void* self, const PyAttributeDef* attrdef); + #endif }; diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index cae1b875a1b..7ecae944324 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -5152,6 +5152,10 @@ class SCA_PropertySensor(SCA_ISensor): @type propName: string @ivar value: the value with which the sensor compares to the value of the property. @type value: string + @ivar min: the minimum value of the range used to evaluate the property when in interval mode. + @type min: string + @ivar max: the maximum value of the range used to evaluate the property when in interval mode. + @type max: string """ #{ Deprecated def getType(): |