Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-12-29 19:36:58 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2008-12-29 19:36:58 +0300
commit1c663bbc7e53cda1fe35579302574b0d98aa8db3 (patch)
tree4c0d3be6453932c01a9dc0fee0f820275cd6701d
parentd91daaa5f690645153adf647c371262c9c6cb009 (diff)
First batch of GE API cleanup.
The principle is to replace most get/set methods of logic bricks by direct property access. To make porting of game code easier, the properties have usually the same type and use than the return values/parameters of the get/set methods. More details on http://wiki.blender.org/index.php/GameEngineDev/Python_API_Clean_Up Old methods are still available but will produce deprecation warnings on the console: "<method> is deprecated, use the <property> property instead" You can avoid these messages by turning on the "Ignore deprecation warnings" option in Game menu. PyDoc is updated to include the new properties and display a deprecation warning for the get/set methods that are being deprecated.
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp4
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h15
-rw-r--r--source/gameengine/Expressions/Value.cpp12
-rw-r--r--source/gameengine/Expressions/Value.h5
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp24
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h1
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp45
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h1
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp222
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h12
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp161
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h3
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp179
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h16
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp233
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h10
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp35
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp52
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp24
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h1
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp64
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h1
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp32
-rw-r--r--source/gameengine/PyDoc/KX_ActuatorSensor.py7
-rw-r--r--source/gameengine/PyDoc/SCA_DelaySensor.py17
-rw-r--r--source/gameengine/PyDoc/SCA_ILogicBrick.py9
-rw-r--r--source/gameengine/PyDoc/SCA_ISensor.py34
-rw-r--r--source/gameengine/PyDoc/SCA_JoystickSensor.py59
-rw-r--r--source/gameengine/PyDoc/SCA_KeyboardSensor.py65
-rw-r--r--source/gameengine/PyDoc/SCA_MouseSensor.py11
-rw-r--r--source/gameengine/PyDoc/SCA_PropertyActuator.py11
-rw-r--r--source/gameengine/PyDoc/SCA_PropertySensor.py17
-rw-r--r--source/gameengine/PyDoc/SCA_PythonController.py10
-rw-r--r--source/gameengine/PyDoc/SCA_RandomActuator.py32
37 files changed, 1182 insertions, 247 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 4410763ec53..f046942af75 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -81,6 +81,7 @@
/***/
#include "GPU_extensions.h"
+#include "Value.h"
#ifdef __cplusplus
extern "C" {
@@ -139,6 +140,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
+ bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
// create the canvas, rasterizer and rendertools
RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
@@ -195,6 +197,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetUseFixedTime(usefixed);
ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
+ CValue::SetDeprecationWarnings(nodepwarnings);
+
//lock frame and camera enabled - storing global values
int tmp_lay= G.scene->lay;
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index 3a054454a0b..55998ce1c97 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -185,7 +185,10 @@ static inline void Py_Fatal(const char *M) {
#define KX_PYMETHODTABLE(class_name, method_name) \
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc}
-#define KX_PYMETHODTABLE_NOARG(class_name, method_name) \
+#define KX_PYMETHODTABLE_O(class_name, method_name) \
+ {#method_name , (PyCFunction) class_name::sPy##method_name, METH_O, (PY_METHODCHAR)class_name::method_name##_doc}
+
+#define KX_PYMETHODTABLE_NOARGS(class_name, method_name) \
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)class_name::method_name##_doc}
/**
@@ -195,7 +198,15 @@ static inline void Py_Fatal(const char *M) {
const char class_name::method_name##_doc[] = doc_string; \
PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*)
-#define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \
+#define KX_PYMETHODDEF_DOC_VARARGS(class_name, method_name, doc_string) \
+const char class_name::method_name##_doc[] = doc_string; \
+PyObject* class_name::Py##method_name(PyObject*, PyObject* args)
+
+#define KX_PYMETHODDEF_DOC_O(class_name, method_name, doc_string) \
+const char class_name::method_name##_doc[] = doc_string; \
+PyObject* class_name::Py##method_name(PyObject*, PyObject* value)
+
+#define KX_PYMETHODDEF_DOC_NOARGS(class_name, method_name, doc_string) \
const char class_name::method_name##_doc[] = doc_string; \
PyObject* class_name::Py##method_name(PyObject*)
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 7296dfbec10..f2b5569c76e 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -32,6 +32,7 @@
//////////////////////////////////////////////////////////////////////
double CValue::m_sZeroVec[3] = {0.0,0.0,0.0};
+bool CValue::m_ignore_deprecation_warnings(false);
#ifndef NO_EXP_PYTHON_EMBEDDING
@@ -849,4 +850,15 @@ void CValue::SetValue(CValue* newval)
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
+/* deprecation warning management */
+void CValue::SetDeprecationWarnings(bool ignoreDeprecationWarnings)
+{
+ m_ignore_deprecation_warnings = ignoreDeprecationWarnings;
+}
+
+void CValue::ShowDeprecationWarning(const char* old_way,const char* new_way)
+{
+ if (!m_ignore_deprecation_warnings)
+ printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way);
+}
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index 74fcdae5756..56a4991af27 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -318,6 +318,10 @@ public:
STR_String op2str(VALUE_OPERATOR op);
+ /** enable/disable display of deprecation warnings */
+ static void SetDeprecationWarnings(bool ignoreDeprecationWarnings);
+ /** Shows a deprecation warning */
+ static void ShowDeprecationWarning(const char* method,const char* prop);
// setting / getting flags
inline void SetSelected(bool bSelected) { m_ValFlags.Selected = bSelected; }
@@ -349,6 +353,7 @@ private:
ValueFlags m_ValFlags; // Frequently used flags in a bitfield (low memoryusage)
int m_refcount; // Reference Counter
static double m_sZeroVec[3];
+ static bool m_ignore_deprecation_warnings;
};
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index 7c37b237d60..5ad28dbf329 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -149,21 +149,44 @@ PyParentObject SCA_ActuatorSensor::Parents[] = {
};
PyMethodDef SCA_ActuatorSensor::Methods[] = {
+ //Deprecated functions ------>
{"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (PY_METHODCHAR)GetActuator_doc},
{"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (PY_METHODCHAR)SetActuator_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) {
+ if (attr == "actuator") {
+ return PyString_FromString(m_checkactname);
+ }
_getattr_up(SCA_ISensor); /* implicit return! */
}
+int SCA_ActuatorSensor::_setattr(const STR_String& attr, PyObject *value) {
+ if (PyString_Check(value)) {
+ char* sval = PyString_AsString(value);
+ if (attr == "actuator") {
+ SCA_IActuator* act = GetParent()->FindActuator(STR_String(sval));
+ if (act) {
+ m_checkactname = sval;
+ m_actuator = act;
+ return 0;
+ }
+ PyErr_SetString(PyExc_AttributeError, "string does not correspond to an actuator");
+ return 1;
+ }
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 3. getActuator */
const char SCA_ActuatorSensor::GetActuator_doc[] =
"getActuator()\n"
"\tReturn the Actuator with which the sensor operates.\n";
PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self)
{
+ ShowDeprecationWarning("getActuator()", "the actuator property");
return PyString_FromString(m_checkactname);
}
@@ -175,6 +198,7 @@ const char SCA_ActuatorSensor::SetActuator_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setActuator()", "the actuator property");
/* We should query whether the name exists. Or should we create a prop */
/* on the fly? */
char *actNameArg = NULL;
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index a71145f6852..4fe4700602c 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -62,6 +62,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 3. setProperty */
KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index f15d4c7249f..362483b58a2 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -158,6 +158,7 @@ PyParentObject SCA_DelaySensor::Parents[] = {
};
PyMethodDef SCA_DelaySensor::Methods[] = {
+ //Deprecated functions ------>
/* setProperty */
{"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (PY_METHODCHAR)SetDelay_doc},
{"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (PY_METHODCHAR)SetDuration_doc},
@@ -166,13 +167,51 @@ PyMethodDef SCA_DelaySensor::Methods[] = {
{"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (PY_METHODCHAR)GetDelay_doc},
{"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (PY_METHODCHAR)GetDuration_doc},
{"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (PY_METHODCHAR)GetRepeat_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) {
+ if (attr == "delay") {
+ return PyInt_FromLong(m_delay);
+ }
+ if (attr == "duration") {
+ return PyInt_FromLong(m_duration);
+ }
+ if (attr == "repeat") {
+ return PyInt_FromLong(m_repeat);
+ }
_getattr_up(SCA_ISensor);
}
+int SCA_DelaySensor::_setattr(const STR_String& attr, PyObject *value) {
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ if (attr == "delay") {
+ if (ival < 0) {
+ PyErr_SetString(PyExc_ValueError, "Delay cannot be negative");
+ return 1;
+ }
+ m_delay = ival;
+ return 0;
+ }
+ if (attr == "duration") {
+ if (ival < 0) {
+ PyErr_SetString(PyExc_ValueError, "Duration cannot be negative");
+ return 1;
+ }
+ m_duration = ival;
+ return 0;
+ }
+ if (attr == "repeat") {
+ m_repeat = (ival != 0);
+ return 0;
+ }
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
+
const char SCA_DelaySensor::SetDelay_doc[] =
"setDelay(delay)\n"
"\t- delay: length of the initial OFF period as number of frame\n"
@@ -180,6 +219,7 @@ const char SCA_DelaySensor::SetDelay_doc[] =
"\tSet the initial delay before the positive trigger\n";
PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setDelay()", "the delay property");
int delay;
if(!PyArg_ParseTuple(args, "i", &delay)) {
@@ -201,6 +241,7 @@ const char SCA_DelaySensor::SetDuration_doc[] =
"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n";
PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setDuration()", "the duration property");
int duration;
if(!PyArg_ParseTuple(args, "i", &duration)) {
@@ -221,6 +262,7 @@ const char SCA_DelaySensor::SetRepeat_doc[] =
"\tSet the sensor repeat mode\n";
PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setRepeat()", "the repeat property");
int repeat;
if(!PyArg_ParseTuple(args, "i", &repeat)) {
@@ -235,6 +277,7 @@ const char SCA_DelaySensor::GetDelay_doc[] =
"\tReturn the delay parameter value\n";
PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self)
{
+ ShowDeprecationWarning("getDelay()", "the delay property");
return PyInt_FromLong(m_delay);
}
@@ -243,6 +286,7 @@ const char SCA_DelaySensor::GetDuration_doc[] =
"\tReturn the duration parameter value\n";
PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self)
{
+ ShowDeprecationWarning("getDuration()", "the duration property");
return PyInt_FromLong(m_duration);
}
@@ -251,6 +295,7 @@ const char SCA_DelaySensor::GetRepeat_doc[] =
"\tReturn the repeat parameter value\n";
PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self)
{
+ ShowDeprecationWarning("getRepeat()", "the repeat property");
return BoolToPyArg(m_repeat);
}
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
index a997fabe3cd..ff3afe16542 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -61,6 +61,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* setProperty */
KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index b10ac676464..6e46c8504bb 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -139,71 +139,6 @@ void SCA_ISensor::DecLink() {
}
}
-/* python integration */
-
-PyTypeObject SCA_ISensor::Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
- "SCA_ISensor",
- sizeof(SCA_ISensor),
- 0,
- PyDestructor,
- 0,
- __getattr,
- __setattr,
- 0, //&MyPyCompare,
- __repr,
- 0, //&cvalue_as_number,
- 0,
- 0,
- 0,
- 0
-};
-
-PyParentObject SCA_ISensor::Parents[] = {
- &SCA_ISensor::Type,
- &SCA_ILogicBrick::Type,
- &CValue::Type,
- NULL
-};
-PyMethodDef SCA_ISensor::Methods[] = {
- {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
- METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
- {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
- METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
- {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
- METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
- {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
- METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
- {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
- METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
- {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
- METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
- {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
- METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
- {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
- METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
- {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
- METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
- {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
- METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
- {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
- METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
- {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
- METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
- {"reset", (PyCFunction) SCA_ISensor::sPyReset,
- METH_NOARGS, (PY_METHODCHAR)Reset_doc},
- {NULL,NULL} //Sentinel
-};
-
-
-PyObject*
-SCA_ISensor::_getattr(const STR_String& attr)
-{
- _getattr_up(SCA_ILogicBrick);
-}
-
-
void SCA_ISensor::RegisterToManager()
{
// sensor is just activated, initialize it
@@ -275,13 +210,17 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
}
}
}
+/* ----------------------------------------------- */
+/* Python Functions */
+/* ----------------------------------------------- */
-/* Python functions: */
+//Deprecated Functions ------>
const char SCA_ISensor::IsPositive_doc[] =
"isPositive()\n"
"\tReturns whether the sensor is in an active state.\n";
PyObject* SCA_ISensor::PyIsPositive(PyObject* self)
{
+ ShowDeprecationWarning("isPositive()", "the read-only positive property");
int retval = IsPositiveTrigger();
return PyInt_FromLong(retval);
}
@@ -291,6 +230,7 @@ const char SCA_ISensor::IsTriggered_doc[] =
"\tReturns whether the sensor has triggered the current controller.\n";
PyObject* SCA_ISensor::PyIsTriggered(PyObject* self)
{
+ ShowDeprecationWarning("isTriggered()", "the read-only triggered property");
// check with the current controller
int retval = 0;
if (SCA_PythonController::m_sCurrentController)
@@ -306,6 +246,7 @@ const char SCA_ISensor::GetUsePosPulseMode_doc[] =
"\tReturns whether positive pulse mode is active.\n";
PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self)
{
+ ShowDeprecationWarning("getUsePosPulseMode()", "the usePosPulseMode property");
return BoolToPyArg(m_pos_pulsemode);
}
@@ -319,6 +260,7 @@ const char SCA_ISensor::SetUsePosPulseMode_doc[] =
"\tSet whether to do pulsing when positive pulses occur.\n";
PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setUsePosPulseMode()", "the usePosPulseMode property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_pos_pulsemode = PyArgToBool(pyarg);
@@ -333,6 +275,7 @@ const char SCA_ISensor::GetFrequency_doc[] =
"\tReturns the frequency of the updates in pulse mode.\n" ;
PyObject* SCA_ISensor::PyGetFrequency(PyObject* self)
{
+ ShowDeprecationWarning("getFrequency()", "the frequency property");
return PyInt_FromLong(m_pulse_frequency);
}
@@ -346,6 +289,7 @@ const char SCA_ISensor::SetFrequency_doc[] =
"\tIf the frequency is negative, it is set to 0.\n" ;
PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setFrequency()", "the frequency property");
int pulse_frequencyArg = 0;
if(!PyArg_ParseTuple(args, "i", &pulse_frequencyArg)) {
@@ -368,6 +312,7 @@ const char SCA_ISensor::GetInvert_doc[] =
"\tReturns whether or not pulses from this sensor are inverted.\n" ;
PyObject* SCA_ISensor::PyGetInvert(PyObject* self)
{
+ ShowDeprecationWarning("getInvert()", "the invert property");
return BoolToPyArg(m_invert);
}
@@ -377,6 +322,7 @@ const char SCA_ISensor::SetInvert_doc[] =
"\tSet whether to invert pulses.\n";
PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setInvert()", "the invert property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_invert = PyArgToBool(pyarg);
@@ -392,6 +338,7 @@ const char SCA_ISensor::GetLevel_doc[] =
"\tA edge detector will wait for a state change before generating a pulse.\n";
PyObject* SCA_ISensor::PyGetLevel(PyObject* self)
{
+ ShowDeprecationWarning("getLevel()", "the level property");
return BoolToPyArg(m_level);
}
@@ -401,6 +348,7 @@ const char SCA_ISensor::SetLevel_doc[] =
"\tSet whether to detect level or edge transition when entering a state.\n";
PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setLevel()", "the level property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_level = PyArgToBool(pyarg);
@@ -412,6 +360,7 @@ const char SCA_ISensor::GetUseNegPulseMode_doc[] =
"\tReturns whether negative pulse mode is active.\n";
PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self)
{
+ ShowDeprecationWarning("getUseNegPulseMode()", "the useNegPulseMode property");
return BoolToPyArg(m_neg_pulsemode);
}
@@ -422,21 +371,156 @@ const char SCA_ISensor::SetUseNegPulseMode_doc[] =
"\tSet whether to do pulsing when negative pulses occur.\n";
PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setUseNegPulseMode()", "the useNegPulseMode property");
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_neg_pulsemode = PyArgToBool(pyarg);
Py_Return;
}
+//<------Deprecated
-const char SCA_ISensor::Reset_doc[] =
+KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
"reset()\n"
"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
-"\tThe sensor is put in its initial state as if it was just activated.\n";
-PyObject* SCA_ISensor::PyReset(PyObject* self)
+"\tThe sensor is put in its initial state as if it was just activated.\n")
{
Init();
Py_Return;
}
+/* ----------------------------------------------- */
+/* Python Integration Hooks */
+/* ----------------------------------------------- */
+
+PyTypeObject SCA_ISensor::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_ISensor",
+ sizeof(SCA_ISensor),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_ISensor::Parents[] = {
+ &SCA_ISensor::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+PyMethodDef SCA_ISensor::Methods[] = {
+ //Deprecated functions ----->
+ {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
+ METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
+ {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
+ METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
+ {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
+ METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
+ {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
+ METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
+ {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
+ METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
+ {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
+ METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
+ {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
+ METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
+ {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
+ METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
+ {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
+ METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
+ {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
+ METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
+ {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
+ METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
+ {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
+ METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_NOARGS(SCA_ISensor, reset),
+ {NULL,NULL} //Sentinel
+};
+
+PyObject*
+SCA_ISensor::_getattr(const STR_String& attr)
+{
+ if (attr == "usePosPulseMode")
+ return PyInt_FromLong(m_pos_pulsemode);
+ if (attr == "useNegPulseMode")
+ return PyInt_FromLong(m_neg_pulsemode);
+ if (attr == "frequency")
+ return PyInt_FromLong(m_pulse_frequency);
+ if (attr == "invert")
+ return PyInt_FromLong(m_invert);
+ if (attr == "level")
+ return PyInt_FromLong(m_level);
+ if (attr == "triggered")
+ {
+ int retval = 0;
+ if (SCA_PythonController::m_sCurrentController)
+ retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
+ return PyInt_FromLong(retval);
+ }
+ if (attr == "positive")
+ {
+ int retval = IsPositiveTrigger();
+ return PyInt_FromLong(retval);
+ }
+
+ _getattr_up(SCA_ILogicBrick);
+}
+
+int SCA_ISensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (attr == "triggered")
+ PyErr_SetString(PyExc_AttributeError, "attribute \"triggered\" is read only");
+ if (attr == "positive")
+ PyErr_SetString(PyExc_AttributeError, "attribute \"positive\" is read only");
+
+ if (PyInt_Check(value))
+ {
+ int val = PyInt_AsLong(value);
+
+ if (attr == "usePosPulseMode")
+ {
+ m_pos_pulsemode = (val != 0);
+ return 0;
+ }
+
+ if (attr == "useNegPulseMode")
+ {
+ m_neg_pulsemode = (val != 0);
+ return 0;
+ }
+
+ if (attr == "invert")
+ {
+ m_invert = (val != 0);
+ return 0;
+ }
+ if (attr == "level")
+ {
+ m_level = (val != 0);
+ return 0;
+ }
+
+ if (attr == "frequency")
+ {
+ if (val < 0)
+ val = 0;
+ m_pulse_frequency = val;
+ return 0;
+ }
+ }
+
+ return SCA_ILogicBrick::_setattr(attr, value);
+}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index d1872009291..1b57c4621e4 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -93,8 +93,7 @@ public:
virtual bool Evaluate(CValue* event) = 0;
virtual bool IsPositiveTrigger();
virtual void Init();
-
- virtual PyObject* _getattr(const STR_String& attr);
+
virtual CValue* GetReplica()=0;
/** Set parameters for the pulsing behaviour.
@@ -141,6 +140,11 @@ public:
{ return !m_links; }
/* Python functions: */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
+
+ //Deprecated functions ----->
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsTriggered);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode);
@@ -153,8 +157,8 @@ public:
KX_PYMETHOD_DOC(SCA_ISensor,SetInvert);
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel);
KX_PYMETHOD_DOC(SCA_ISensor,SetLevel);
- KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,Reset);
-
+ //<------
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,reset);
};
#endif //__SCA_ISENSOR
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 8b96840b149..ec5921bad85 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -304,6 +304,7 @@ PyParentObject SCA_JoystickSensor::Parents[] = {
PyMethodDef SCA_JoystickSensor::Methods[] = {
+ //Deprecated functions ------>
{"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc},
{"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc},
{"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc},
@@ -313,27 +314,144 @@ PyMethodDef SCA_JoystickSensor::Methods[] = {
{"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc},
{"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc},
{"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (PY_METHODCHAR)SetButton_doc},
- {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc},
{"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc},
{"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc},
{"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc},
{"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (PY_METHODCHAR)NumberOfButtons_doc},
{"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (PY_METHODCHAR)NumberOfHats_doc},
{"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (PY_METHODCHAR)Connected_doc},
+ {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc},
+ //<----- Deprecated
+ {"getButtonActiveList",(PyCFunction) SCA_JoystickSensor::sPyGetButtonActiveList, METH_NOARGS,(PY_METHODCHAR)GetButtonActiveList_doc},
+ {"getButtonStatus",(PyCFunction) SCA_JoystickSensor::sPyGetButtonStatus, METH_VARARGS,(PY_METHODCHAR)GetButtonStatus_doc},
{NULL,NULL} //Sentinel
};
PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ if (attr == "axisPosition") {
+ if(joy)
+ return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
+ else
+ return Py_BuildValue("[iiii]", 0, 0, 0, 0);
+ }
+ if (attr == "numAxis") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
+ }
+ if (attr == "numButtons") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
+ }
+ if (attr == "numHats") {
+ return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
+ }
+ if (attr == "connected") {
+ return PyBool_FromLong( joy ? joy->Connected() : 0 );
+ }
+ if (attr == "index") {
+ return PyInt_FromLong(m_joyindex);
+ }
+ if (attr == "threshold") {
+ return PyInt_FromLong(m_precision);
+ }
+ if (attr == "button") {
+ return PyInt_FromLong(m_button);
+ }
+ if (attr == "axis") {
+ return Py_BuildValue("[ii]",m_axis, m_axisf);
+ }
+ if (attr == "hat") {
+ return Py_BuildValue("[ii]",m_hat, m_hatf);
+ }
_getattr_up(SCA_ISensor);
}
+int SCA_JoystickSensor::_setattr(const STR_String& attr, PyObject *value) {
+ if (attr == "axisPosition") {
+ PyErr_SetString(PyExc_AttributeError, "axisPosition is read only");
+ return 1;
+ }
+ if (attr == "numAxis") {
+ PyErr_SetString(PyExc_AttributeError, "numaxis is read only");
+ return 1;
+ }
+ if (attr == "numButtons") {
+ PyErr_SetString(PyExc_AttributeError, "numbuttons is read only");
+ return 1;
+ }
+ if (attr == "numHats") {
+ PyErr_SetString(PyExc_AttributeError, "numhats is read only");
+ return 1;
+ }
+ if (attr == "connected") {
+ PyErr_SetString(PyExc_AttributeError, "connected is read only");
+ return 1;
+ }
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ if (attr == "index") {
+ if (ival < 0 || ival >= JOYINDEX_MAX) {
+ PyErr_SetString(PyExc_ValueError, "joystick index out of range");
+ return 1;
+ }
+ m_joyindex = ival;
+ } else if (attr == "threshold") {
+ m_precision = ival;
+ } else if (attr == "button") {
+ if (ival < 0) {
+ PyErr_SetString(PyExc_ValueError, "button out of range");
+ return 1;
+ }
+ m_button = ival;
+ }
+ return 0;
+ }
+ if (PySequence_Check(value)) {
+ if (attr == "axis" || attr == "hat") {
+ if (PySequence_Size(value) != 2) {
+ PyErr_SetString(PyExc_ValueError, "value must be sequence of 2 integers");
+ return 1;
+ }
+ int ival = -1;
+ int ivalf = -1;
+ PyObject *item = PySequence_GetItem(value, 0); /* new ref */
+ ival = PyInt_AsLong(item);
+ Py_DECREF(item);
+ item = PySequence_GetItem(value, 1); /* new ref */
+ ivalf = PyInt_AsLong(item);
+ Py_DECREF(item);
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_ValueError, "one or more of the items in the sequence was not an integer");
+ return 1;
+ }
+ if (attr == "axis") {
+ if (ival < 1 || ival > 2 || ivalf < 0 || ivalf > 3) {
+ PyErr_SetString(PyExc_ValueError, "items in the sequence are out of range");
+ return 1;
+ }
+ m_axis = ival;
+ m_axisf = ivalf;
+ } else {
+ if (ival < 1 || ival > 2) {
+ PyErr_SetString(PyExc_ValueError, "items in the sequence are out of range");
+ return 1;
+ }
+ m_hat = ival;
+ m_hatf = ivalf;
+ }
+ }
+ return 0;
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* get index ---------------------------------------------------------- */
const char SCA_JoystickSensor::GetIndex_doc[] =
"getIndex\n"
"\tReturns the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) {
+ ShowDeprecationWarning("getIndex()", "the index property");
return PyInt_FromLong(m_joyindex);
}
@@ -343,6 +461,7 @@ const char SCA_JoystickSensor::SetIndex_doc[] =
"setIndex\n"
"\tSets the joystick index to use.\n";
PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) {
+ ShowDeprecationWarning("setIndex()", "the index property");
int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */
if (index < 0 || index >= JOYINDEX_MAX) {
PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int");
@@ -358,6 +477,7 @@ const char SCA_JoystickSensor::GetAxis_doc[] =
"getAxis\n"
"\tReturns the current axis this sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) {
+ ShowDeprecationWarning("getAxis()", "the axis property");
return Py_BuildValue("[ii]",m_axis, m_axisf);
}
@@ -367,6 +487,7 @@ const char SCA_JoystickSensor::SetAxis_doc[] =
"setAxis\n"
"\tSets the current axis this sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setAxis()", "the axis property");
int axis,axisflag;
if(!PyArg_ParseTuple(args, "ii", &axis, &axisflag)){
@@ -383,6 +504,7 @@ const char SCA_JoystickSensor::GetAxisValue_doc[] =
"getAxisValue\n"
"\tReturns a list of the values for the current state of each axis.\n";
PyObject* SCA_JoystickSensor::PyGetAxisValue( PyObject* self) {
+ ShowDeprecationWarning("getAxisValue()", "the axisPosition property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
if(joy)
return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
@@ -396,6 +518,7 @@ const char SCA_JoystickSensor::GetThreshold_doc[] =
"getThreshold\n"
"\tReturns the threshold of the axis.\n";
PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) {
+ ShowDeprecationWarning("getThreshold()", "the threshold property");
return PyInt_FromLong(m_precision);
}
@@ -405,6 +528,7 @@ const char SCA_JoystickSensor::SetThreshold_doc[] =
"setThreshold\n"
"\tSets the threshold of the axis.\n";
PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setThreshold()", "the threshold property");
int thresh;
if(!PyArg_ParseTuple(args, "i", &thresh)){
return NULL;
@@ -418,6 +542,7 @@ const char SCA_JoystickSensor::GetButton_doc[] =
"getButton\n"
"\tReturns the current button this sensor is checking.\n";
PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) {
+ ShowDeprecationWarning("getButton()", "the button property");
return PyInt_FromLong(m_button);
}
@@ -426,6 +551,7 @@ const char SCA_JoystickSensor::SetButton_doc[] =
"setButton\n"
"\tSets the button the sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* value ) {
+ ShowDeprecationWarning("setButton()", "the button property");
int button = PyInt_AsLong(value);
if(button==-1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError, "expected an int");
@@ -440,6 +566,15 @@ const char SCA_JoystickSensor::GetButtonValue_doc[] =
"getButtonValue\n"
"\tReturns a list containing the indicies of the current pressed state of each button.\n";
PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) {
+ ShowDeprecationWarning("getButtonValue()", "getButtonActiveList");
+ return PyGetButtonActiveList(self);
+}
+
+/* get button active list -------------------------------------------------- */
+const char SCA_JoystickSensor::GetButtonActiveList_doc[] =
+"getButtonActiveList\n"
+"\tReturns a list containing the indicies of the button currently pressed.\n";
+PyObject* SCA_JoystickSensor::PyGetButtonActiveList( PyObject* self) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
PyObject *ls = PyList_New(0);
PyObject *value;
@@ -457,11 +592,30 @@ PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) {
return ls;
}
+/* get button status -------------------------------------------------- */
+const char SCA_JoystickSensor::GetButtonStatus_doc[] =
+"getButtonStatus(buttonIndex)\n"
+"\tReturns a bool of the current pressed state of the specified button.\n";
+PyObject* SCA_JoystickSensor::PyGetButtonStatus( PyObject* self, PyObject* args ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ PyObject *value;
+ int index;
+
+ if(!PyArg_ParseTuple(args, "i", &index)){
+ return NULL;
+ }
+ if(joy && index >= 0 && index < joy->GetNumberOfButtons()) {
+ return PyBool_FromLong(joy->aButtonPressIsPositive(index) ? 1 : 0);
+ }
+ return PyBool_FromLong(0);
+}
+
/* get hat ----------------------------------------------------------- */
const char SCA_JoystickSensor::GetHat_doc[] =
"getHat\n"
"\tReturns the current direction of the hat.\n";
PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) {
+ ShowDeprecationWarning("getHat()", "the hat property");
return Py_BuildValue("[ii]",m_hat, m_hatf);
}
@@ -471,6 +625,7 @@ const char SCA_JoystickSensor::SetHat_doc[] =
"setHat\n"
"\tSets the hat the sensor reacts to.\n";
PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) {
+ ShowDeprecationWarning("setHat()", "the hat property");
int hat,hatflag;
if(!PyArg_ParseTuple(args, "ii", &hat, &hatflag)){
return NULL;
@@ -486,6 +641,7 @@ const char SCA_JoystickSensor::NumberOfAxes_doc[] =
"getNumAxes\n"
"\tReturns the number of axes .\n";
PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) {
+ ShowDeprecationWarning("getNumAxes()", "the numAxis property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
// when the joystick is null their is 0 exis still. dumb but scripters should use isConnected()
return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
@@ -496,6 +652,7 @@ const char SCA_JoystickSensor::NumberOfButtons_doc[] =
"getNumButtons\n"
"\tReturns the number of buttons .\n";
PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) {
+ ShowDeprecationWarning("getNumButtons()", "the numButtons property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
}
@@ -505,6 +662,7 @@ const char SCA_JoystickSensor::NumberOfHats_doc[] =
"getNumHats\n"
"\tReturns the number of hats .\n";
PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) {
+ ShowDeprecationWarning("getNumHats()", "the numHats property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
}
@@ -513,6 +671,7 @@ const char SCA_JoystickSensor::Connected_doc[] =
"getConnected\n"
"\tReturns True if a joystick is connected at this joysticks index.\n";
PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) {
+ ShowDeprecationWarning("getConnected()", "the connected property");
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index d316ad1119c..03653070db7 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -122,6 +122,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* Joystick Index */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
@@ -136,6 +137,8 @@ public:
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton);
KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetButton);
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonValue);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonActiveList);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,GetButtonStatus);
/* Hats */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat);
KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat);
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index fa39a13679f..f880cd7768e 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -545,42 +545,17 @@ void SCA_KeyboardSensor::LogKeystrokes(void)
/* ------------------------------------------------------------------------- */
-/* Python functions : specific */
+/* Python Functions */
/* ------------------------------------------------------------------------- */
-
-PyObject* SCA_KeyboardSensor::PySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
- bool allkeys;
-
- if (!PyArg_ParseTuple(args, "i", &allkeys))
- {
- return NULL;
- }
-
- m_bAllKeys = allkeys;
- Py_Return
-}
-
-
-
-PyObject* SCA_KeyboardSensor::sPySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
-// printf("sPyIsPositive\n");
- return ((SCA_KeyboardSensor*) self)->PyIsPositive(self);
-}
-
-
+//Deprecated ----->
/** 1. GetKey : check which key this sensor looks at */
const char SCA_KeyboardSensor::GetKey_doc[] =
"getKey()\n"
"\tReturn the code of the key this sensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getKey()", "the key property");
return PyInt_FromLong(m_hotkey);
}
@@ -591,6 +566,7 @@ const char SCA_KeyboardSensor::SetKey_doc[] =
"\tSet the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetKey(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setKey()", "the key property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -611,6 +587,7 @@ const char SCA_KeyboardSensor::GetHold1_doc[] =
"\tsensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetHold1(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getHold1()", "the hold1 property");
return PyInt_FromLong(m_qual);
}
@@ -621,6 +598,7 @@ const char SCA_KeyboardSensor::SetHold1_doc[] =
"\tSet the first modifier to the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setHold1()", "the hold1 property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -641,6 +619,7 @@ const char SCA_KeyboardSensor::GetHold2_doc[] =
"\tsensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetHold2(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getHold2()", "the hold2 property");
return PyInt_FromLong(m_qual2);
}
@@ -651,6 +630,7 @@ const char SCA_KeyboardSensor::SetHold2_doc[] =
"\tSet the first modifier to the key this sensor should listen to.\n" ;
PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setHold2()", "the hold2 property");
int keyCode;
if(!PyArg_ParseTuple(args, "i", &keyCode)) {
@@ -671,6 +651,8 @@ const char SCA_KeyboardSensor::GetPressedKeys_doc[] =
PyObject* SCA_KeyboardSensor::PyGetPressedKeys(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getPressedKeys()", "getEventList()");
+
SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
int num = inputdev->GetNumJustEvents();
@@ -711,6 +693,8 @@ const char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] =
PyObject* SCA_KeyboardSensor::PyGetCurrentlyPressedKeys(PyObject* self, PyObject* args, PyObject* kwds)
{
+ShowDeprecationWarning("getCurrentlyPressedKeys()", "getEventList()");
+
SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
int num = inputdev->GetNumActiveEvents();
@@ -743,9 +727,54 @@ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
Py_Return;
}
+//<---- Deprecated
+
+KX_PYMETHODDEF_DOC_NOARGS(SCA_KeyboardSensor, getEventList,
+"getEventList()\n"
+"\tGet the list of the keyboard events in this frame.\n")
+{
+ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
+
+ PyObject* resultlist = PyList_New(0);
+
+ for (int i=SCA_IInputDevice::KX_BEGINKEY ; i< SCA_IInputDevice::KX_ENDKEY;i++)
+ {
+ const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
+ if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS)
+ {
+ PyObject* keypair = PyList_New(2);
+ PyList_SetItem(keypair,0,PyInt_FromLong(i));
+ PyList_SetItem(keypair,1,PyInt_FromLong(inevent.m_status));
+ PyList_Append(resultlist,keypair);
+ }
+ }
+ return resultlist;
+}
+
+KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
+"getKeyStatus(keycode)\n"
+"\tGet the given key's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
+{
+ if (PyInt_Check(value))
+ {
+ int keycode = PyInt_AsLong(value);
+
+ if ((keycode < SCA_IInputDevice::KX_BEGINKEY)
+ || (keycode > SCA_IInputDevice::KX_ENDKEY)){
+ PyErr_SetString(PyExc_AttributeError, "invalid keycode specified!");
+ return NULL;
+ }
+
+ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
+ const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) keycode);
+ return PyInt_FromLong(inevent.m_status);
+ }
+
+ Py_Return;
+}
/* ------------------------------------------------------------------------- */
-/* Python functions : integration hooks */
+/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
PyTypeObject SCA_KeyboardSensor::Type = {
@@ -776,23 +805,91 @@ PyParentObject SCA_KeyboardSensor::Parents[] = {
};
PyMethodDef SCA_KeyboardSensor::Methods[] = {
- {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc},
- {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc},
- {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc},
- {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc},
- {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc},
- {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc},
-// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)GetUseAllKeys_doc},
-// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)SetUseAllKeys_doc},
- {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc},
- {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc},
-// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, (PY_METHODCHAR)GetKeyEvents_doc},
- {NULL,NULL} //Sentinel
+ //Deprecated functions ------>
+ {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc},
+ {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc},
+ {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc},
+ {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc},
+ {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc},
+ {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc},
+ {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc},
+ {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_NOARGS(SCA_KeyboardSensor, getEventList),
+ KX_PYMETHODTABLE_O(SCA_KeyboardSensor, getKeyStatus),
+ {NULL,NULL} //Sentinel
};
PyObject*
SCA_KeyboardSensor::_getattr(const STR_String& attr)
{
+ if (attr == "key")
+ return PyInt_FromLong(m_hotkey);
+
+ if (attr == "hold1")
+ return PyInt_FromLong(m_qual);
+
+ if (attr == "hold2")
+ return PyInt_FromLong(m_qual2);
+
+ if (attr == "toggleProperty")
+ return PyString_FromString(m_toggleprop);
+
+ if (attr == "targetProperty")
+ return PyString_FromString(m_targetprop);
+
+ if (attr == "useAllKeys")
+ return PyInt_FromLong(m_bAllKeys);
+
_getattr_up(SCA_ISensor);
}
+int SCA_KeyboardSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (PyInt_Check(value))
+ {
+ int val = PyInt_AsLong(value);
+
+ if (attr == "key")
+ {
+ m_hotkey = val;
+ return 0;
+ }
+
+ if (attr == "hold1")
+ {
+ m_qual = val;
+ return 0;
+ }
+
+ if (attr == "hold2")
+ {
+ m_qual2 = val;
+ return 0;
+ }
+
+ if (attr == "useAllKeys")
+ {
+ m_bAllKeys = (val != 0);
+ return 0;
+ }
+ }
+
+ if (PyString_Check(value))
+ {
+ STR_String val = PyString_AsString(value);
+ if (attr == "logToggleProperty")
+ {
+ m_toggleprop = val;
+ return 0;
+ }
+
+ if (attr == "logTargetProperty")
+ {
+ m_targetprop = val;
+ return 0;
+ }
+ }
+
+ return SCA_ISensor::_setattr(attr, value);
+}
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index b86f6931d27..4efbe9366cc 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -127,15 +127,9 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
-
- PyObject* PySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds);
- static PyObject* sPySetAllMode(PyObject* self,
- PyObject* args,
- PyObject* kwds);
-
+ //Deprecated functions ----->
/** 1. GetKey : check which key this sensor looks at */
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetKey);
/** 2. SetKey: change the key to look at */
@@ -152,6 +146,12 @@ public:
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetPressedKeys);
/** 9. GetCurrrentlyPressedKeys: */
KX_PYMETHOD_DOC(SCA_KeyboardSensor,GetCurrentlyPressedKeys);
+ // <------
+
+ // KeyEvents:
+ KX_PYMETHOD_DOC_NOARGS(SCA_KeyboardSensor,getEventList);
+ // KeyStatus:
+ KX_PYMETHOD_DOC_O(SCA_KeyboardSensor,getKeyStatus);
};
#endif //__KX_KEYBOARDSENSOR
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index d4952ce4777..9562003aec0 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -25,7 +25,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): José I. Romero (cleanup and fixes)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -59,6 +59,29 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
m_mousemode = mousemode;
m_triggermode = true;
+ UpdateHotkey();
+ Init();
+}
+
+void SCA_MouseSensor::Init()
+{
+ m_val = (m_invert)?1:0; /* stores the latest attribute */
+ m_reset = true;
+}
+
+SCA_MouseSensor::~SCA_MouseSensor()
+{
+ /* Nothing to be done here. */
+}
+
+void SCA_MouseSensor::UpdateHotkey()
+{
+ // gosh, this function is so damn stupid
+ // its here because of a design mistake in the mouse sensor, it should only
+ // have 3 trigger modes (button, wheel, move), and let the user set the
+ // hotkey separately, like the other sensors. but instead it has a mode for
+ // each friggin key and i have to update the hotkey based on it... genius!
+
switch (m_mousemode) {
case KX_MOUSESENSORMODE_LEFTBUTTON:
m_hotkey = SCA_IInputDevice::KX_LEFTMOUSE;
@@ -78,22 +101,8 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
default:
; /* ignore, no hotkey */
}
- Init();
-}
-
-void SCA_MouseSensor::Init()
-{
- m_val = (m_invert)?1:0; /* stores the latest attribute */
- m_reset = true;
}
-SCA_MouseSensor::~SCA_MouseSensor()
-{
- /* Nothing to be done here. */
-}
-
-
-
CValue* SCA_MouseSensor::GetReplica()
{
SCA_MouseSensor* replica = new SCA_MouseSensor(*this);
@@ -137,15 +146,6 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
bool reset = m_reset && m_level;
SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
-
-
-// SCA_ILogicBrick::RegisterEvent(event);
-// if (m_mousemode == KX_MOUSESENSORMODE_MOVEMENT) cout << "\nChecking for movement...";
-//CValue* val = event->GetProperty("val");
-
- /* both MOUSEX and MOUSEY. Treat all of these as key-presses. */
- /* So, treat KX_MOUSESENSORMODE_POSITION as */
- /* KX_MOUSESENSORMODE_POSITIONX || KX_MOUSESENSORMODE_POSITIONY */
m_reset = false;
switch (m_mousemode) {
case KX_MOUSESENSORMODE_LEFTBUTTON:
@@ -155,42 +155,34 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
case KX_MOUSESENSORMODE_WHEELDOWN:
{
const SCA_InputEvent& event = mousedev->GetEventValue(m_hotkey);
- if (event.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- {
+ switch (event.m_status){
+ case SCA_InputEvent::KX_JUSTACTIVATED:
m_val = 1;
result = true;
- } else
- {
- if (event.m_status == SCA_InputEvent::KX_JUSTRELEASED)
+ break;
+ case SCA_InputEvent::KX_JUSTRELEASED:
+ m_val = 0;
+ result = true;
+ break;
+ case SCA_InputEvent::KX_ACTIVE:
+ if (m_val == 0)
+ {
+ m_val = 1;
+ if (m_level)
+ result = true;
+ }
+ break;
+ default:
+ if (m_val == 1)
{
m_val = 0;
result = true;
- } else
- {
- if (event.m_status == SCA_InputEvent::KX_ACTIVE)
- {
- if (m_val == 0)
- {
- m_val = 1;
- if (m_level)
- {
- result = true;
- }
- }
- } else
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
- }
}
+ break;
}
break;
}
case KX_MOUSESENSORMODE_MOVEMENT:
-
{
const SCA_InputEvent& eventX = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
const SCA_InputEvent& eventY = mousedev->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
@@ -198,27 +190,26 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
if (eventX.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
eventY.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
eventX.m_status == SCA_InputEvent::KX_ACTIVE ||
- eventY.m_status == SCA_InputEvent::KX_ACTIVE)
-
+ eventY.m_status == SCA_InputEvent::KX_ACTIVE)
{
m_val = 1;
result = true;
- } else
- {
- if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED ||
+ }
+ else if (eventX.m_status == SCA_InputEvent::KX_JUSTRELEASED ||
eventY.m_status == SCA_InputEvent::KX_JUSTRELEASED )
+ {
+ m_val = 0;
+ result = true;
+ }
+ else //KX_NO_IMPUTSTATUS
+ {
+ if (m_val == 1)
{
m_val = 0;
result = true;
- } else
- {
- if (m_val == 1)
- {
- m_val = 0;
- result = true;
- }
}
}
+
break;
}
default:
@@ -243,18 +234,67 @@ void SCA_MouseSensor::setY(short y)
bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m)
{
- bool res = false;
+ return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
- res = ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
+//Deprecated functions ------>
+/* get x position ---------------------------------------------------------- */
+const char SCA_MouseSensor::GetXPosition_doc[] =
+"getXPosition\n"
+"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n"
+"\tThe lower-left corner is the origin. The coordinate is given in\n"
+"\tpixels\n";
+PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("getXPosition()", "the position property");
+ return PyInt_FromLong(m_x);
+}
+
+/* get y position ---------------------------------------------------------- */
+const char SCA_MouseSensor::GetYPosition_doc[] =
+"getYPosition\n"
+"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n"
+"\tThe lower-left corner is the origin. The coordinate is given in\n"
+"\tpixels\n";
+PyObject* SCA_MouseSensor::PyGetYPosition(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ ShowDeprecationWarning("getYPosition()", "the position property");
+ return PyInt_FromLong(m_y);
+}
+//<----- Deprecated
+
+KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
+"getButtonStatus(button)\n"
+"\tGet the given button's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
+{
+ if (PyInt_Check(value))
+ {
+ int button = PyInt_AsLong(value);
+
+ if ((button < SCA_IInputDevice::KX_LEFTMOUSE)
+ || (button > SCA_IInputDevice::KX_MIDDLEMOUSE)){
+ PyErr_SetString(PyExc_ValueError, "invalid button specified!");
+ return NULL;
+ }
+
+ SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
+ const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button);
+ return PyInt_FromLong(event.m_status);
+ }
- return res;
+ Py_Return;
}
/* ------------------------------------------------------------------------- */
-/* Python functions */
+/* Python Integration Hooks */
/* ------------------------------------------------------------------------- */
-/* Integration hooks ------------------------------------------------------- */
PyTypeObject SCA_MouseSensor::Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -283,37 +323,54 @@ PyParentObject SCA_MouseSensor::Parents[] = {
};
PyMethodDef SCA_MouseSensor::Methods[] = {
+ //Deprecated functions ------>
{"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (PY_METHODCHAR)GetXPosition_doc},
{"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (PY_METHODCHAR)GetYPosition_doc},
+ //<----- Deprecated
+ KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus),
{NULL,NULL} //Sentinel
};
PyObject* SCA_MouseSensor::_getattr(const STR_String& attr) {
+ if (attr == "position")
+ return Py_BuildValue("[ii]", m_x, m_y);
+
+ if (attr == "mode")
+ return PyInt_FromLong(m_mousemode);
+
_getattr_up(SCA_ISensor);
}
-/* get x position ---------------------------------------------------------- */
-const char SCA_MouseSensor::GetXPosition_doc[] =
-"getXPosition\n"
-"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n"
-"\tThe lower-left corner is the origin. The coordinate is given in\n"
-"\tpixels\n";
-PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return PyInt_FromLong(m_x);
-}
+int SCA_MouseSensor::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (PyInt_Check(value))
+ {
+ int val = PyInt_AsLong(value);
-/* get y position ---------------------------------------------------------- */
-const char SCA_MouseSensor::GetYPosition_doc[] =
-"getYPosition\n"
-"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n"
-"\tThe lower-left corner is the origin. The coordinate is given in\n"
-"\tpixels\n";
-PyObject* SCA_MouseSensor::PyGetYPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return PyInt_FromLong(m_y);
+ if (attr == "mode")
+ {
+ if ((val < KX_MOUSESENSORMODE_NODEF)
+ || (val > KX_MOUSESENSORMODE_MAX)){
+
+ PyErr_SetString(PyExc_ValueError, "invalid mode specified!");
+ return NULL;
+ }
+
+ m_mousemode = val;
+ UpdateHotkey();
+ return 0;
+ }
+ }
+ else
+ {
+ if (attr == "position")
+ {
+ PyErr_SetString(PyExc_AttributeError, "read-only property!");
+ return NULL;
+ }
+ }
+
+ return SCA_ISensor::_setattr(attr, value);
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 26a1c5e3fd2..6d6e641c798 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -24,7 +24,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): José I. Romero (cleanup and fixes)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -87,6 +87,8 @@ class SCA_MouseSensor : public SCA_ISensor
bool isValid(KX_MOUSESENSORMODE);
+ void UpdateHotkey();
+
SCA_MouseSensor(class SCA_MouseManager* keybdmgr,
int startx,int starty,
short int mousemode,
@@ -108,11 +110,17 @@ class SCA_MouseSensor : public SCA_ISensor
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
+ //Deprecated functions ----->
/* read x-coordinate */
KX_PYMETHOD_DOC(SCA_MouseSensor,GetXPosition);
/* read y-coordinate */
KX_PYMETHOD_DOC(SCA_MouseSensor,GetYPosition);
+ //<----- deprecated
+
+ // get button status
+ KX_PYMETHOD_DOC_O(SCA_MouseSensor,getButtonStatus);
};
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 3b541e87f02..f8509fe380e 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -245,17 +245,48 @@ PyParentObject SCA_PropertyActuator::Parents[] = {
};
PyMethodDef SCA_PropertyActuator::Methods[] = {
+ //Deprecated functions ------>
{"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
{"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
{"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
PyObject* SCA_PropertyActuator::_getattr(const STR_String& attr) {
+ if (attr == "property") {
+ return PyString_FromString(m_propname);
+ }
+ if (attr == "value") {
+ return PyString_FromString(m_exprtxt);
+ }
_getattr_up(SCA_IActuator);
}
+int SCA_PropertyActuator::_setattr(const STR_String& attr, PyObject *value) {
+ if (PyString_Check(value)) {
+ char* sval = PyString_AsString(value);
+ if (attr == "property") {
+ CValue* prop = GetParent()->FindIdentifier(sval);
+ bool error = prop->IsError();
+ prop->Release();
+ if (!prop->IsError()) {
+ m_propname = sval;
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_ValueError, "string does not correspond to a property");
+ return 1;
+ }
+ }
+ if (attr == "value") {
+ m_exprtxt = sval;
+ return 0;
+ }
+ }
+ return SCA_IActuator::_setattr(attr, value);
+}
+
/* 1. setProperty */
const char SCA_PropertyActuator::SetProperty_doc[] =
"setProperty(name)\n"
@@ -264,6 +295,7 @@ const char SCA_PropertyActuator::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
/* Check whether the name exists first ! */
char *nameArg;
if (!PyArg_ParseTuple(args, "s", &nameArg)) {
@@ -288,6 +320,7 @@ const char SCA_PropertyActuator::GetProperty_doc[] =
"\tReturn the property on which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_propname);
}
@@ -300,6 +333,7 @@ const char SCA_PropertyActuator::SetValue_doc[] =
"\t action is ignored.\n";
PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setValue()", "the value property");
char *valArg;
if(!PyArg_ParseTuple(args, "s", &valArg)) {
return NULL;
@@ -316,6 +350,7 @@ const char SCA_PropertyActuator::GetValue_doc[] =
"\tReturns the value with which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getValue()", "the value property");
return PyString_FromString(m_exprtxt);
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 1e435684572..cdfeee4c67d 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -86,6 +86,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
// python wrapped methods
KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 64e3d49c6cb..19ee85207bb 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -333,25 +333,72 @@ PyParentObject SCA_PropertySensor::Parents[] = {
};
PyMethodDef SCA_PropertySensor::Methods[] = {
+ //Deprecated functions ------>
{"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
{"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
{"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
{"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
{"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) {
+ if (attr == "type") {
+ return PyInt_FromLong(m_checktype);
+ }
+ if (attr == "property") {
+ return PyString_FromString(m_checkpropname);
+ }
+ if (attr == "value") {
+ return PyString_FromString(m_checkpropval);
+ }
_getattr_up(SCA_ISensor); /* implicit return! */
}
+int SCA_PropertySensor::_setattr(const STR_String& attr, PyObject *value) {
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ if (attr == "type") {
+ if ((ival <= KX_PROPSENSOR_NODEF) || (ival >= KX_PROPSENSOR_MAX)) {
+ PyErr_SetString(PyExc_ValueError, "type out of range");
+ return 1;
+ }
+ m_checktype = ival;
+ }
+ return 0;
+ }
+ if (PyString_Check(value)) {
+ char* sval = PyString_AsString(value);
+ if (attr == "property") {
+ CValue *prop = FindIdentifier(STR_String(sval));
+ bool error = prop->IsError();
+ prop->Release();
+ if (error) {
+ PyErr_SetString(PyExc_ValueError, "string does not correspond to a property");
+ return 1;
+ }
+ m_checkpropname = sval;
+ } else if (attr == "value") {
+ if (!validValueForProperty(sval, m_checkpropname)) {
+ PyErr_SetString(PyExc_ValueError, "string does not represent a suitable value for the property");
+ return 1;
+ }
+ m_checkpropval = sval;
+ }
+ return 0;
+ }
+ return SCA_ISensor::_setattr(attr, value);
+}
+
/* 1. getType */
const char SCA_PropertySensor::GetType_doc[] =
"getType()\n"
"\tReturns the type of check this sensor performs.\n";
PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getType()", "the type property");
return PyInt_FromLong(m_checktype);
}
@@ -364,6 +411,7 @@ const char SCA_PropertySensor::SetType_doc[] =
"\tSet the type of check to perform.\n";
PyObject* SCA_PropertySensor::PySetType(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setType()", "the type property");
int typeArg;
if (!PyArg_ParseTuple(args, "i", &typeArg)) {
@@ -384,6 +432,7 @@ const char SCA_PropertySensor::GetProperty_doc[] =
"\tReturn the property with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_checkpropname);
}
@@ -395,6 +444,7 @@ const char SCA_PropertySensor::SetProperty_doc[] =
"\tof this name, the call is ignored.\n";
PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
/* We should query whether the name exists. Or should we create a prop */
/* on the fly? */
char *propNameArg = NULL;
@@ -419,6 +469,7 @@ const char SCA_PropertySensor::GetValue_doc[] =
"\tReturns the value with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("getValue()", "the value property");
return PyString_FromString(m_checkpropval);
}
@@ -431,6 +482,7 @@ const char SCA_PropertySensor::SetValue_doc[] =
"\t action is ignored.\n";
PyObject* SCA_PropertySensor::PySetValue(PyObject* self, PyObject* args, PyObject* kwds)
{
+ ShowDeprecationWarning("setValue()", "the value property");
/* Here, we need to check whether the value is 'valid' for this property.*/
/* We know that the property exists, or is NULL. */
char *propValArg = NULL;
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index 6871cb3afdc..81203c78f9d 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -90,6 +90,7 @@ public:
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 1. getType */
KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index c354ab39747..e879481a444 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -233,9 +233,11 @@ PyMethodDef SCA_PythonController::Methods[] = {
{"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc},
{"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc},
{"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc},
- {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
{"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
+ //Deprecated functions ------>
+ {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
{"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS},
+ //<----- Deprecated
{NULL,NULL} //Sentinel
};
@@ -329,9 +331,27 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
PyObject* SCA_PythonController::_getattr(const STR_String& attr)
{
+ if (attr == "script") {
+ return PyString_FromString(m_scriptText);
+ }
+ if (attr == "state") {
+ return PyInt_FromLong(m_statemask);
+ }
_getattr_up(SCA_IController);
}
+int SCA_PythonController::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (attr == "script") {
+ PyErr_SetString(PyExc_AttributeError, "script is read only, use setScript() to update the script");
+ return 1;
+ }
+ if (attr == "state") {
+ PyErr_SetString(PyExc_AttributeError, "state is read only");
+ return 1;
+ }
+ return SCA_IController::_setattr(attr, value);
+}
PyObject* SCA_PythonController::PyGetActuators(PyObject* self)
@@ -420,6 +440,7 @@ SCA_PythonController::PyGetSensors(PyObject* self)
/* 1. getScript */
PyObject* SCA_PythonController::PyGetScript(PyObject* self)
{
+ ShowDeprecationWarning("getScript()", "the script property");
return PyString_FromString(m_scriptText);
}
@@ -443,6 +464,7 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self, PyObject* value)
/* 1. getScript */
PyObject* SCA_PythonController::PyGetState(PyObject* self)
{
+ ShowDeprecationWarning("getState()", "the state property");
return PyInt_FromLong(m_statemask);
}
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index d9b2e242bea..1918cc488d8 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -77,6 +77,7 @@ class SCA_PythonController : public SCA_IController
static PyObject* sPyAddActiveActuator(PyObject* self,
PyObject* args);
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 7b50a483cd8..8dd405c3d82 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -339,6 +339,7 @@ PyParentObject SCA_RandomActuator::Parents[] = {
};
PyMethodDef SCA_RandomActuator::Methods[] = {
+ //Deprecated functions ------>
{"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
{"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc},
{"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, (PY_METHODCHAR)GetPara1_doc},
@@ -346,6 +347,7 @@ PyMethodDef SCA_RandomActuator::Methods[] = {
{"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, (PY_METHODCHAR)GetDistribution_doc},
{"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ //<----- Deprecated
{"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, (PY_METHODCHAR)SetBoolConst_doc},
{"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, (PY_METHODCHAR)SetBoolUniform_doc},
{"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, (PY_METHODCHAR)SetBoolBernouilli_doc},
@@ -360,9 +362,60 @@ PyMethodDef SCA_RandomActuator::Methods[] = {
};
PyObject* SCA_RandomActuator::_getattr(const STR_String& attr) {
+ if (attr == "seed") {
+ return PyInt_FromLong(m_base->GetSeed());
+ }
+ if (attr == "para1") {
+ return PyFloat_FromDouble(m_parameter1);
+ }
+ if (attr == "para2") {
+ return PyFloat_FromDouble(m_parameter2);
+ }
+ if (attr == "distribution") {
+ return PyInt_FromLong(m_distribution);
+ }
+ if (attr == "property") {
+ return PyString_FromString(m_propname);
+ }
_getattr_up(SCA_IActuator);
}
+int SCA_RandomActuator::_setattr(const STR_String& attr, PyObject *value)
+{
+ if (attr == "para1") {
+ PyErr_SetString(PyExc_AttributeError, "para1 is read only");
+ }
+ if (attr == "para2") {
+ PyErr_SetString(PyExc_AttributeError, "para2 is read only");
+ }
+ if (attr == "distribution") {
+ PyErr_SetString(PyExc_AttributeError, "distribution is read only");
+ }
+ if (PyInt_Check(value)) {
+ int ival = PyInt_AsLong(value);
+ if (attr == "seed") {
+ m_base->SetSeed(ival);
+ }
+ return 0;
+ }
+ if (PyString_Check(value)) {
+ char* sval = PyString_AsString(value);
+ if (attr == "property") {
+ CValue* prop = GetParent()->FindIdentifier(sval);
+ bool error = prop->IsError();
+ prop->Release();
+ if (!prop->IsError()) {
+ m_propname = sval;
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_ValueError, "string does not correspond to a property");
+ return 1;
+ }
+ }
+ }
+ return SCA_IActuator::_setattr(attr, value);
+}
+
/* 1. setSeed */
const char SCA_RandomActuator::SetSeed_doc[] =
"setSeed(seed)\n"
@@ -371,6 +424,7 @@ const char SCA_RandomActuator::SetSeed_doc[] =
"\tequal series. If the seed is 0, the generator will produce\n"
"\tthe same value on every call.\n";
PyObject* SCA_RandomActuator::PySetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setSeed()", "the seed property");
long seedArg;
if(!PyArg_ParseTuple(args, "i", &seedArg)) {
return NULL;
@@ -386,6 +440,7 @@ const char SCA_RandomActuator::GetSeed_doc[] =
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
PyObject* SCA_RandomActuator::PyGetSeed(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getSeed()", "the seed property");
return PyInt_FromLong(m_base->GetSeed());
}
@@ -396,6 +451,7 @@ const char SCA_RandomActuator::GetPara1_doc[] =
"\tto the documentation of the generator types for the meaning\n"
"\tof this value.";
PyObject* SCA_RandomActuator::PyGetPara1(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getPara1()", "the para1 property");
return PyFloat_FromDouble(m_parameter1);
}
@@ -406,6 +462,7 @@ const char SCA_RandomActuator::GetPara2_doc[] =
"\tto the documentation of the generator types for the meaning\n"
"\tof this value.";
PyObject* SCA_RandomActuator::PyGetPara2(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getPara2()", "the para2 property");
return PyFloat_FromDouble(m_parameter2);
}
@@ -414,6 +471,7 @@ const char SCA_RandomActuator::GetDistribution_doc[] =
"getDistribution()\n"
"\tReturns the type of the active distribution.\n";
PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getDistribution()", "the distribution property");
return PyInt_FromLong(m_distribution);
}
@@ -424,6 +482,7 @@ const char SCA_RandomActuator::SetProperty_doc[] =
"\tSet the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("setProperty()", "the 'property' property");
char *nameArg;
if (!PyArg_ParseTuple(args, "s", &nameArg)) {
return NULL;
@@ -446,6 +505,7 @@ const char SCA_RandomActuator::GetProperty_doc[] =
"\tReturn the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
PyObject* SCA_RandomActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) {
+ ShowDeprecationWarning("getProperty()", "the 'property' property");
return PyString_FromString(m_propname);
}
@@ -463,9 +523,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self,
}
m_distribution = KX_RANDOMACT_BOOL_CONST;
- if (paraArg) {
- m_parameter1 = 1;
- }
+ m_parameter1 = (paraArg) ? 1.0 : 0.0;
Py_Return;
}
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index f6da0595d1a..2fc14f9a0b7 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -97,6 +97,7 @@ class SCA_RandomActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ virtual int _setattr(const STR_String& attr, PyObject *value);
/* 1. setSeed */
KX_PYMETHOD_DOC(SCA_RandomActuator,SetSeed);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index d0a2d0b05f2..e858c852b70 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -530,6 +530,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0);
+ bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0);
@@ -604,6 +605,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
m_ketsjiengine->SetAudioDevice(m_audiodevice);
m_ketsjiengine->SetTimingDisplay(frameRate, false, false);
+ CValue::SetDeprecationWarnings(nodepwarnings);
+
m_ketsjiengine->SetUseFixedTime(fixed_framerate);
m_ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index c6f6bc2db01..bb9072b34dc 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -65,15 +65,15 @@ PyParentObject KX_PolyProxy::Parents[] = {
};
PyMethodDef KX_PolyProxy::Methods[] = {
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialIndex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getNumVertex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isVisible),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isCollider),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialName),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getTextureName),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialIndex),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getNumVertex),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isVisible),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,isCollider),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterialName),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getTextureName),
KX_PYMETHODTABLE(KX_PolyProxy,getVertexIndex),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMesh),
- KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterial),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMesh),
+ KX_PYMETHODTABLE_NOARGS(KX_PolyProxy,getMaterial),
{NULL,NULL} //Sentinel
};
@@ -171,7 +171,7 @@ void KX_PolyProxy::ReplicaSetName(STR_String) {};
// stuff for python integration
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
"getMaterialIndex() : return the material index of the polygon in the mesh\n")
{
RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
@@ -186,31 +186,31 @@ KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex,
return PyInt_FromLong(matid);
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getNumVertex,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
{
return PyInt_FromLong(m_polygon->VertexCount());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isVisible,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
"isVisible() : returns whether the polygon is visible or not\n")
{
return PyInt_FromLong(m_polygon->IsVisible());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isCollider,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
"isCollider() : returns whether the polygon is receives collision or not\n")
{
return PyInt_FromLong(m_polygon->IsCollider());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialName,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getTextureName,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
{
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
@@ -239,14 +239,14 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
return PyInt_FromLong(0);
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMesh,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
"getMesh() : returns a mesh proxy\n")
{
KX_MeshProxy* meshproxy = new KX_MeshProxy((RAS_MeshObject*)m_mesh);
return meshproxy;
}
-KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterial,
+KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial,
"getMaterial() : returns a material\n")
{
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
diff --git a/source/gameengine/PyDoc/KX_ActuatorSensor.py b/source/gameengine/PyDoc/KX_ActuatorSensor.py
index cdfbf27576e..b0e138a8009 100644
--- a/source/gameengine/PyDoc/KX_ActuatorSensor.py
+++ b/source/gameengine/PyDoc/KX_ActuatorSensor.py
@@ -8,15 +8,22 @@ class KX_ActuatorSensor(SCA_ISensor):
Actuator sensor detect change in actuator state of the parent object.
It generates a positive pulse if the corresponding actuator is activated
and a negative pulse if the actuator is deactivated.
+
+ Properties:
+
+ @ivar actuator: the name of the actuator that the sensor is monitoring.
+ @type actuator: string
"""
def getActuator():
"""
+ DEPRECATED: use the actuator property
Return the Actuator with which the sensor operates.
@rtype: string
"""
def setActuator(name):
"""
+ DEPRECATED: use the actuator property
Sets the Actuator with which to operate. If there is no Actuator
of this name, the function has no effect.
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
index 19df589ea7b..b99ed08bed5 100644
--- a/source/gameengine/PyDoc/SCA_DelaySensor.py
+++ b/source/gameengine/PyDoc/SCA_DelaySensor.py
@@ -13,9 +13,21 @@ class SCA_DelaySensor(SCA_ISensor):
The sensor runs the OFF-ON cycle once unless the repeat option is set: the
OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
Use SCA_ISensor::reset() at any time to restart sensor.
+
+ Properties:
+
+ @ivar delay: length of the initial OFF period as number of frame, 0 for immediate trigger.
+ @type delay: integer.
+ @ivar duration: length of the ON period in number of frame after the initial OFF period.
+ If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+ @type duration: integer
+ @ivar repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+ @type repeat: integer
+
"""
def setDelay(delay):
"""
+ DEPRECATED: use the delay property
Set the initial delay before the positive trigger.
@param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
@@ -23,6 +35,7 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def setDuration(duration):
"""
+ DEPRECATED: use the duration property
Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
@@ -31,6 +44,7 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def setRepeat(repeat):
"""
+ DEPRECATED: use the repeat property
Set if the sensor repeat mode.
@param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
@@ -38,18 +52,21 @@ class SCA_DelaySensor(SCA_ISensor):
"""
def getDelay():
"""
+ DEPRECATED: use the delay property
Return the delay parameter value.
@rtype: integer
"""
def getDuration():
"""
+ DEPRECATED: use the duration property
Return the duration parameter value
@rtype: integer
"""
def getRepeat():
"""
+ DEPRECATED: use the repeat property
Return the repeat parameter value
@rtype: KX_TRUE or KX_FALSE
diff --git a/source/gameengine/PyDoc/SCA_ILogicBrick.py b/source/gameengine/PyDoc/SCA_ILogicBrick.py
index ea09fcaea37..18cb900f28d 100644
--- a/source/gameengine/PyDoc/SCA_ILogicBrick.py
+++ b/source/gameengine/PyDoc/SCA_ILogicBrick.py
@@ -5,6 +5,9 @@ from KX_GameObject import *
class SCA_ILogicBrick:
"""
Base class for all logic bricks.
+
+ @ivar executePriority: This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
+ @type executePriority: int
"""
def getOwner():
@@ -13,6 +16,8 @@ class SCA_ILogicBrick:
@rtype: L{KX_GameObject}
"""
+
+ #--The following methods are deprecated--
def setExecutePriority(priority):
"""
Sets the priority of this logic brick.
@@ -20,6 +25,8 @@ class SCA_ILogicBrick:
This determines the order controllers are evaluated, and actuators are activated.
Bricks with lower priority will be executed first.
+ Deprecated: Use the "executePriority" property instead.
+
@type priority: integer
@param priority: the priority of this logic brick.
"""
@@ -27,6 +34,8 @@ class SCA_ILogicBrick:
"""
Gets the execution priority of this logic brick.
+ Deprecated: Use the "executePriority" property instead.
+
@rtype: integer
@return: this logic bricks current priority.
"""
diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py
index 14858505e24..ab35996aa50 100644
--- a/source/gameengine/PyDoc/SCA_ISensor.py
+++ b/source/gameengine/PyDoc/SCA_ISensor.py
@@ -5,8 +5,35 @@ from SCA_ILogicBrick import *
class SCA_ISensor(SCA_ILogicBrick):
"""
Base class for all sensor logic bricks.
+
+ @ivar usePosPulseMode: Flag to turn positive pulse mode on and off.
+ @type usePosPulseMode: boolean
+ @ivar useNegPulseMode: Flag to turn negative pulse mode on and off.
+ @type useNegPulseMode: boolean
+ @ivar frequency: The frequency for pulse mode sensors.
+ @type frequency: int
+ @ivar level: Flag to set whether to detect level or edge transition when entering a state.
+ It makes a difference only in case of logic state transition (state actuator).
+ A level detector will immediately generate a pulse, negative or positive
+ depending on the sensor condition, as soon as the state is activated.
+ A edge detector will wait for a state change before generating a pulse.
+ @type level: boolean
+ @ivar invert: Flag to set if this sensor activates on positive or negative events.
+ @type invert: boolean
+ @ivar triggered: True if this sensor brick is in a positive state. (Read only)
+ @type triggered: boolean
+ @ivar positive: True if this sensor brick is in a positive state. (Read only)
+ @type positive: boolean
"""
+ def reset():
+ """
+ Reset sensor internal state, effect depends on the type of sensor and settings.
+
+ The sensor is put in its initial state as if it was just activated.
+ """
+
+ #--The following methods are deprecated--
def isPositive():
"""
True if this sensor brick is in a positive state.
@@ -82,10 +109,3 @@ class SCA_ISensor(SCA_ILogicBrick):
@param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
@type level: boolean
"""
- def reset():
- """
- Reset sensor internal state, effect depends on the type of sensor and settings.
-
- The sensor is put in its initial state as if it was just activated.
- """
-
diff --git a/source/gameengine/PyDoc/SCA_JoystickSensor.py b/source/gameengine/PyDoc/SCA_JoystickSensor.py
index d1dab9afcaf..111ee7f4cfa 100644
--- a/source/gameengine/PyDoc/SCA_JoystickSensor.py
+++ b/source/gameengine/PyDoc/SCA_JoystickSensor.py
@@ -5,15 +5,58 @@ from SCA_ISensor import *
class SCA_JoystickSensor(SCA_ISensor):
"""
This sensor detects player joystick events.
+
+ Properties:
+
+ @ivar axisPosition: (read-only) The state of the joysticks axis as a list of 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
+ The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
+ left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
+ @type axisPosition: [integer, integer, integer, integer]
+ @ivar numAxis: (read-only) The number of axes for the joystick at this index.
+ @type numAxis: integer
+ @ivar numButtons: (read-only) The number of buttons for the joystick at this index.
+ @type numButtons: integer
+ @ivar numHats: (read-only) The number of hats for the joystick at this index.
+ @type numHats: integer
+ @ivar connected: (read-only) True if a joystick is connected at this joysticks index.
+ @type connected: boolean
+ @ivar index: The joystick index to use (from 0 to 7). The first joystick is always 0.
+ @type index: integer
+ @ivar threshold: Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
+ @type threshold: integer
+ @ivar button: The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
+ @type button: integer
+ @ivar axis: The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
+ axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
+ axisDirection: 0=right, 1=up, 2=left, 3=down
+ @type axis: [integer, integer]
+ @ivar hat: The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
+ hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat.
+ hatDirection: 0-11
+ @type hat: [integer, integer]
"""
+ def getButtonActiveList():
+ """
+ Returns a list containing the indicies of the currently pressed buttons.
+ @rtype: list
+ """
+ def getButtonStatus(buttonIndex):
+ """
+ Returns a bool of the current pressed state of the specified button.
+ @param buttonIndex: the button index, 0=first button
+ @type buttonIndex: integer
+ @rtype: bool
+ """
def getIndex():
"""
+ DEPRECATED: use the 'index' property.
Returns the joystick index to use (from 1 to 8).
@rtype: integer
"""
def setIndex(index):
"""
+ DEPRECATED: use the 'index' property.
Sets the joystick index to use.
@param index: The index of this joystick sensor, Clamped between 1 and 8.
@type index: integer
@@ -21,6 +64,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getAxis():
"""
+ DEPRECATED: use the 'axis' property.
Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
@rtype: list
@return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
@@ -28,6 +72,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def setAxis(axisIndex, axisDirection):
"""
+ DEPRECATED: use the 'axis' property.
@param axisIndex: Set the axis index to use when detecting axis movement.
@type axisIndex: integer from 1 to 2
@param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
@@ -36,6 +81,7 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getAxisValue():
"""
+ DEPRECATED: use the 'axisPosition' property.
Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
@rtype: list
@return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
@@ -47,60 +93,71 @@ class SCA_JoystickSensor(SCA_ISensor):
"""
def getThreshold():
"""
+ DEPRECATED: use the 'threshold' property.
Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
@rtype: integer
"""
def setThreshold(threshold):
"""
+ DEPRECATED: use the 'threshold' property.
Set the axis threshold.
@param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
@type threshold: integer
"""
def getButton():
"""
+ DEPRECATED: use the 'button' property.
Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons.
@rtype: integer
@note: When the "All Events" toggle is set, this option has no effect.
"""
def setButton(index):
"""
+ DEPRECATED: use the 'button' property.
Sets the button index the sensor reacts to when the "All Events" option is not set.
@note: When the "All Events" toggle is set, this option has no effect.
"""
def getButtonValue():
"""
+ DEPRECATED: use the 'getButtonActiveList' method.
Returns a list containing the indicies of the currently pressed buttons.
@rtype: list
"""
def getHat():
"""
+ DEPRECATED: use the 'hat' property.
Returns the current hat direction this sensor is set to.
[hatNumber, hatDirection].
@rtype: list
@note: When the "All Events" toggle is set, this option has no effect.
"""
- def setHat(index):
+ def setHat(index,direction):
"""
+ DEPRECATED: use the 'hat' property.
Sets the hat index the sensor reacts to when the "All Events" option is not set.
@type index: integer
"""
def getNumAxes():
"""
+ DEPRECATED: use the 'numAxis' property.
Returns the number of axes for the joystick at this index.
@rtype: integer
"""
def getNumButtons():
"""
+ DEPRECATED: use the 'numButtons' property.
Returns the number of buttons for the joystick at this index.
@rtype: integer
"""
def getNumHats():
"""
+ DEPRECATED: use the 'numHats' property.
Returns the number of hats for the joystick at this index.
@rtype: integer
"""
def isConnected():
"""
+ DEPRECATED: use the 'connected' property.
Returns True if a joystick is detected at this joysticks index.
@rtype: bool
"""
diff --git a/source/gameengine/PyDoc/SCA_KeyboardSensor.py b/source/gameengine/PyDoc/SCA_KeyboardSensor.py
index 2f741f7d6a2..f6a7a7d8a97 100644
--- a/source/gameengine/PyDoc/SCA_KeyboardSensor.py
+++ b/source/gameengine/PyDoc/SCA_KeyboardSensor.py
@@ -7,44 +7,99 @@ class SCA_KeyboardSensor(SCA_ISensor):
A keyboard sensor detects player key presses.
See module L{GameKeys} for keycode values.
+
+ @ivar key: The key code this sensor is looking for.
+ @type key: keycode from L{GameKeys} module
+ @ivar hold1: The key code for the first modifier this sensor is looking for.
+ @type hold1: keycode from L{GameKeys} module
+ @ivar hold2: The key code for the second modifier this sensor is looking for.
+ @type hold2: keycode from L{GameKeys} module
+ @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
+ @type toggleProperty: string
+ @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
+ @type targetProperty: string
+ @ivar useAllKeys: Flag to determine whether or not to accept all keys.
+ @type useAllKeys: boolean
"""
+ def getEventList():
+ """
+ Get a list of pressed keys that have either been pressed, or just released, or are active this frame.
+
+ @rtype: list of key status. [[keycode, status]]
+ @return: A list of keyboard events
+ """
+
+ def getKeyStatus(keycode):
+ """
+ Get the status of a key.
+
+ @rtype: key state (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED)
+ @return: The state of the given key
+ @type keycode: integer
+ @param keycode: The code that represents the key you want to get the state of
+ """
+ #--The following methods are deprecated--
def getKey():
"""
Returns the key code this sensor is looking for.
+
+ Deprecated: Use the "key" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
def setKey(keycode):
"""
Set the key this sensor should listen for.
+ Deprecated: Use the "key" property instead.
+
@type keycode: keycode from L{GameKeys} module
"""
def getHold1():
"""
Returns the key code for the first modifier this sensor is looking for.
+
+ Deprecated: Use the "hold1" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
- def setHold1():
+ def setHold1(keycode):
"""
Sets the key code for the first modifier this sensor should look for.
+
+ Deprecated: Use the "hold1" property instead.
+
+ @type keycode: keycode from L{GameKeys} module
"""
def getHold2():
"""
Returns the key code for the second modifier this sensor is looking for.
+
+ Deprecated: Use the "hold2" property instead.
+
+ @rtype: keycode from L{GameKeys} module
"""
- def setHold2():
+ def setHold2(keycode):
"""
Sets the key code for the second modifier this sensor should look for.
+
+ Deprecated: Use the "hold2" property instead.
+
+ @type keycode: keycode from L{GameKeys} module
"""
def getPressedKeys():
"""
Get a list of keys that have either been pressed, or just released this frame.
+ Deprecated: Use getEventList() instead.
+
@rtype: list of key status. [[keycode, status]]
"""
@@ -52,7 +107,7 @@ class SCA_KeyboardSensor(SCA_ISensor):
"""
Get a list of currently pressed keys that have either been pressed, or just released
+ Deprecated: Use getEventList() instead.
+
@rtype: list of key status. [[keycode, status]]
- """
-
-
+ """ \ No newline at end of file
diff --git a/source/gameengine/PyDoc/SCA_MouseSensor.py b/source/gameengine/PyDoc/SCA_MouseSensor.py
index 06b261f67fa..9550cbb4105 100644
--- a/source/gameengine/PyDoc/SCA_MouseSensor.py
+++ b/source/gameengine/PyDoc/SCA_MouseSensor.py
@@ -5,10 +5,20 @@ from SCA_ISensor import *
class SCA_MouseSensor(SCA_ISensor):
"""
Mouse Sensor logic brick.
+
+ Properties:
+
+ @ivar position: current [x,y] coordinates of the mouse, in frame coordinates (pixels)
+ @type position: [integer,interger]
+ @ivar mode: sensor mode: 1=KX_MOUSESENSORMODE_LEFTBUTTON 2=KX_MOUSESENSORMODE_MIDDLEBUTTON
+ 3=KX_MOUSESENSORMODE_RIGHTBUTTON 4=KX_MOUSESENSORMODE_WHEELUP
+ 5=KX_MOUSESENSORMODE_WHEELDOWN 9=KX_MOUSESENSORMODE_MOVEMENT
+ @type mode: integer
"""
def getXPosition():
"""
+ DEPRECATED: use the position property
Gets the x coordinate of the mouse.
@rtype: integer
@@ -16,6 +26,7 @@ class SCA_MouseSensor(SCA_ISensor):
"""
def getYPosition():
"""
+ DEPRECATED: use the position property
Gets the y coordinate of the mouse.
@rtype: integer
diff --git a/source/gameengine/PyDoc/SCA_PropertyActuator.py b/source/gameengine/PyDoc/SCA_PropertyActuator.py
index dc1233ddfb7..52aefcae651 100644
--- a/source/gameengine/PyDoc/SCA_PropertyActuator.py
+++ b/source/gameengine/PyDoc/SCA_PropertyActuator.py
@@ -5,9 +5,17 @@ from SCA_IActuator import *
class SCA_PropertyActuator(SCA_IActuator):
"""
Property Actuator
+
+ Properties:
+
+ @ivar property: the property on which to operate.
+ @type property: string
+ @ivar value: the value with which the actuator operates.
+ @type value: string
"""
def setProperty(prop):
"""
+ DEPRECATED: use the 'property' property
Set the property on which to operate.
If there is no property of this name, the call is ignored.
@@ -17,12 +25,14 @@ class SCA_PropertyActuator(SCA_IActuator):
"""
def getProperty():
"""
+ DEPRECATED: use the 'property' property
Returns the name of the property on which to operate.
@rtype: string
"""
def setValue(value):
"""
+ DEPRECATED: use the 'value' property
Set the value with which the actuator operates.
If the value is not compatible with the type of the
@@ -32,6 +42,7 @@ class SCA_PropertyActuator(SCA_IActuator):
"""
def getValue():
"""
+ DEPRECATED: use the 'value' property
Gets the value with which this actuator operates.
@rtype: string
diff --git a/source/gameengine/PyDoc/SCA_PropertySensor.py b/source/gameengine/PyDoc/SCA_PropertySensor.py
index 22de8d8b986..949ffd3b703 100644
--- a/source/gameengine/PyDoc/SCA_PropertySensor.py
+++ b/source/gameengine/PyDoc/SCA_PropertySensor.py
@@ -5,10 +5,22 @@ from SCA_ISensor import *
class SCA_PropertySensor(SCA_ISensor):
"""
Activates when the game object property matches.
+
+ Properties:
+
+ @ivar type: type of check on the property:
+ KX_PROPSENSOR_EQUAL(1), KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
+ KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
+ @type type: integer
+ @ivar property: the property with which the sensor operates.
+ @type property: string
+ @ivar value: the value with which the sensor compares to the value of the property.
+ @type value: string
"""
def getType():
"""
+ DEPRECATED: use the type property
Gets when to activate this sensor.
@return: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
@@ -18,6 +30,7 @@ class SCA_PropertySensor(SCA_ISensor):
def setType(checktype):
"""
+ DEPRECATED: use the type property
Set the type of check to perform.
@type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
@@ -27,6 +40,7 @@ class SCA_PropertySensor(SCA_ISensor):
def getProperty():
"""
+ DEPRECATED: use the property property
Return the property with which the sensor operates.
@rtype: string
@@ -34,6 +48,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def setProperty(name):
"""
+ DEPRECATED: use the property property
Sets the property with which to operate. If there is no property
of that name, this call is ignored.
@@ -41,6 +56,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def getValue():
"""
+ DEPRECATED: use the value property
Return the value with which the sensor compares to the value of the property.
@rtype: string
@@ -48,6 +64,7 @@ class SCA_PropertySensor(SCA_ISensor):
"""
def setValue(value):
"""
+ DEPRECATED: use the value property
Set the value with which the sensor operates. If the value
is not compatible with the type of the property, the subsequent
action is ignored.
diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py
index 6d91736d636..06f2b7e9d1d 100644
--- a/source/gameengine/PyDoc/SCA_PythonController.py
+++ b/source/gameengine/PyDoc/SCA_PythonController.py
@@ -6,6 +6,14 @@ class SCA_PythonController(SCA_IController):
"""
A Python controller uses a Python script to activate it's actuators,
based on it's sensors.
+
+ Properties:
+
+ @ivar script: the Python script this controller executes
+ @type script: string, read-only
+ @ivar state: the controllers state bitmask.
+ This can be used with the GameObject's state to test if the controller is active.
+ @type state: integer
"""
def getSensors():
@@ -36,6 +44,7 @@ class SCA_PythonController(SCA_IController):
"""
def getScript():
"""
+ DEPRECATED: use the script property
Gets the Python script this controller executes.
@rtype: string
@@ -48,6 +57,7 @@ class SCA_PythonController(SCA_IController):
"""
def getState():
"""
+ DEPRECATED: use the state property
Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
This for instance will always be true however you could compare with a previous state to see when the state was activated.
GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
diff --git a/source/gameengine/PyDoc/SCA_RandomActuator.py b/source/gameengine/PyDoc/SCA_RandomActuator.py
index 353b398b1ff..000a1af7846 100644
--- a/source/gameengine/PyDoc/SCA_RandomActuator.py
+++ b/source/gameengine/PyDoc/SCA_RandomActuator.py
@@ -5,9 +5,35 @@ from SCA_IActuator import *
class SCA_RandomActuator(SCA_IActuator):
"""
Random Actuator
+
+ Properties:
+
+ @ivar seed: Seed of the random number generator.
+ Equal seeds produce equal series. If the seed is 0,
+ the generator will produce the same value on every call.
+ @type seed: integer
+ @ivar para1: the first parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para1: float, read-only
+ @ivar para2: the second parameter of the active distribution.
+ Refer to the documentation of the generator types for the meaning
+ of this value.
+ @type para2: float, read-only
+ @ivar distribution: distribution type:
+ KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
+ KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
+ KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
+ KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
+ @type distribution: integer, read-only
+ @ivar property: the name of the property to set with the random value.
+ If the generator and property types do not match, the assignment is ignored.
+ @type property: string
+
"""
def setSeed(seed):
"""
+ DEPRECATED: use the seed property
Sets the seed of the random number generator.
Equal seeds produce equal series. If the seed is 0,
@@ -17,12 +43,14 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getSeed():
"""
+ DEPRECATED: use the seed property
Returns the initial seed of the generator.
@rtype: integer
"""
def getPara1():
"""
+ DEPRECATED: use the para1 property
Returns the first parameter of the active distribution.
Refer to the documentation of the generator types for the meaning
@@ -32,6 +60,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getPara2():
"""
+ DEPRECATED: use the para2 property
Returns the second parameter of the active distribution.
Refer to the documentation of the generator types for the meaning
@@ -41,6 +70,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getDistribution():
"""
+ DEPRECATED: use the distribution property
Returns the type of random distribution.
@rtype: distribution type
@@ -51,6 +81,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def setProperty(property):
"""
+ DEPRECATED: use the property property
Set the property to which the random value is assigned.
If the generator and property types do not match, the assignment is ignored.
@@ -60,6 +91,7 @@ class SCA_RandomActuator(SCA_IActuator):
"""
def getProperty():
"""
+ DEPRECATED: use the property property
Returns the name of the property to set.
@rtype: string