rename and negate DISABLE_PYTHON --> WITH_PYTHON
[blender.git] / source / gameengine / GameLogic / SCA_MouseSensor.cpp
index c6703452337d360a55b8b51e58bf0111c58e86ae..af11353c93e0672f5b7e37789e60e4d54d61f215 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
 #include "ConstExpr.h"
 #include <iostream>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 /* ------------------------------------------------------------------------- */
 /* Native functions                                                          */
 /* ------------------------------------------------------------------------- */
@@ -51,14 +47,13 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
                                                                 short int mousemode,
                                                                 SCA_IObject* gameobj)
     : SCA_ISensor(gameobj,eventmgr),
-       m_pMouseMgr(eventmgr),
        m_x(startx),
        m_y(starty)
 {
        m_mousemode   = mousemode;
        m_triggermode = true;
 
-       UpdateHotkey(this, NULL);
+       UpdateHotkey(this);
        Init();
 }
 
@@ -73,7 +68,7 @@ SCA_MouseSensor::~SCA_MouseSensor()
     /* Nothing to be done here. */
 }
 
-int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
+void SCA_MouseSensor::UpdateHotkey(void *self)
 {
        // gosh, this function is so damn stupid
        // its here because of a design mistake in the mouse sensor, it should only
@@ -101,9 +96,6 @@ int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
        default:
                ; /* ignore, no hotkey */
        }
-       // return value is used in py_setattro(), 
-       // 0=attribute checked ok (see Attributes array definition)
-       return 0;
 }
 
 CValue* SCA_MouseSensor::GetReplica()
@@ -147,7 +139,7 @@ bool SCA_MouseSensor::Evaluate()
 {
        bool result = false;
        bool reset = m_reset && m_level;
-       SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
+       SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
 
        m_reset = false;
        switch (m_mousemode) {
@@ -240,34 +232,12 @@ bool SCA_MouseSensor::isValid(SCA_MouseSensor::KX_MOUSESENSORMODE m)
        return ((m > KX_MOUSESENSORMODE_NODEF) && (m < KX_MOUSESENSORMODE_MAX));
 }
 
+#ifdef WITH_PYTHON
+
 /* ------------------------------------------------------------------------- */
 /* Python functions                                                          */
 /* ------------------------------------------------------------------------- */
 
-//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() {
-       ShowDeprecationWarning("getXPosition()", "the position property");
-       return PyLong_FromSsize_t(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() {
-       ShowDeprecationWarning("getYPosition()", "the position property");
-       return PyLong_FromSsize_t(m_y);
-}
-//<----- Deprecated
-
 KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
 "getButtonStatus(button)\n"
 "\tGet the given button's status (KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED).\n")
@@ -282,7 +252,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
                        return NULL;
                }
                
-               SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
+               SCA_IInputDevice* mousedev = ((SCA_MouseManager *)m_eventmgr)->GetInputDevice();
                const SCA_InputEvent& event = mousedev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) button);
                return PyLong_FromSsize_t(event.m_status);
        }
@@ -317,18 +287,24 @@ PyTypeObject SCA_MouseSensor::Type = {
 };
 
 PyMethodDef SCA_MouseSensor::Methods[] = {
-       //Deprecated functions ------>
-       {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (const char *)GetXPosition_doc},
-       {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (const char *)GetYPosition_doc},
-       //<----- Deprecated
        KX_PYMETHODTABLE_O(SCA_MouseSensor, getButtonStatus),
        {NULL,NULL} //Sentinel
 };
 
+int SCA_MouseSensor::UpdateHotkeyPy(void *self, const PyAttributeDef*)
+{
+       UpdateHotkey(self);
+       // return value is used in py_setattro(),
+       // 0=attribute checked ok (see Attributes array definition)
+       return 0;
+}
+
 PyAttributeDef SCA_MouseSensor::Attributes[] = {
-       KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkey),
+       KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkeyPy),
        KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2),
        { NULL }        //Sentinel
 };
 
+#endif // WITH_PYTHON
+
 /* eof */