optionally use guarded alloc for tiles compositor, also replace allocation functions...
[blender.git] / source / gameengine / GameLogic / SCA_MouseManager.cpp
index e4d54c943951b928def85eca6cedecebbccd32aa..a067b9c4d5b500d0919f22bf6570b12f5d698973 100644 (file)
@@ -1,18 +1,14 @@
-/**
+/*
  * Manager for mouse events
  *
  *
- * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,7 +17,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.
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file gameengine/GameLogic/SCA_MouseManager.cpp
+ *  \ingroup gamelogic
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(FREE_WINDOWS)
 // This warning tells us about truncation of __long__ stl-generated names.
 // It can occasionally cause DevStudio to have internal compiler warnings.
 #pragma warning( disable : 4786 )     
 #include "SCA_MouseManager.h"
 #include "SCA_MouseSensor.h"
 #include "IntValue.h"
+#include "RAS_ICanvas.h"
 
 
 SCA_MouseManager::SCA_MouseManager(SCA_LogicManager* logicmgr,
-                                                                  SCA_IInputDevice* mousedev)
-       :       SCA_EventManager(MOUSE_EVENTMGR),
+                                                                  SCA_IInputDevice* mousedev,
+                                                                  RAS_ICanvas* canvas)
+       :       SCA_EventManager(logicmgr, MOUSE_EVENTMGR),
                m_mousedevice (mousedev),
-               m_logicmanager(logicmgr)
+               m_canvas(canvas)
 {
        m_xpos = 0;
        m_ypos = 0;
@@ -78,38 +77,31 @@ void SCA_MouseManager::NextFrame()
 {
        if (m_mousedevice)
        {
-               for (unsigned int i = 0; i < m_sensors.size(); i++)
+               SG_DList::iterator<SCA_ISensor> it(m_sensors);
+               for (it.begin();!it.end();++it)
                {
-                       SCA_MouseSensor* mousesensor = (SCA_MouseSensor*) m_sensors[i];
+                       SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it);
                        // (0,0) is the Upper Left corner in our local window
                        // coordinates
                        if (!mousesensor->IsSuspended())
                        {
-                               const SCA_InputEvent& event = 
+                               const SCA_InputEvent& event1 = 
                                        m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEX);
-                               int mx = event.m_eventval;
                                const SCA_InputEvent& event2 = 
                                        m_mousedevice->GetEventValue(SCA_IInputDevice::KX_MOUSEY);
-                               int my = event2.m_eventval;
+
+                               int mx = this->m_canvas->GetMouseX(event1.m_eventval);
+                               int my = this->m_canvas->GetMouseY(event2.m_eventval);
                                
                                mousesensor->setX(mx);
                                mousesensor->setY(my);
                                
-                               mousesensor->Activate(m_logicmanager,NULL);
+                               mousesensor->Activate(m_logicmgr);
                        }
                }
        }
 }
 
-
-
-void  SCA_MouseManager::RegisterSensor(SCA_ISensor* keysensor)
-{
-       m_sensors.push_back(keysensor);
-}
-
-
-
 bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
 {
        /* We should guard for non-mouse events maybe? A rather silly side       */