Browse Source

Fix mac/osx build issue where event.h include guard and enum types are already in use by the SDK headers

Paul 11 years ago
parent
commit
7b48ae1f89

+ 1 - 1
QGearsMain/include/core/Background2D.h

@@ -28,7 +28,7 @@ public:
     Background2D();
     virtual ~Background2D();
 
-    void InputDebug( const Event& event );
+    void InputDebug(const QGears::Event& event);
     void Update();
     void UpdateDebug();
     void OnResize();

+ 1 - 1
QGearsMain/include/core/CameraManager.h

@@ -14,7 +14,7 @@ public:
     CameraManager();
     virtual ~CameraManager();
 
-    void Input(const Event& event , Ogre::Real timeSinceLastFrame);
+    void Input(const QGears::Event& event , Ogre::Real timeSinceLastFrame);
     void Update();
     void OnResize();
 

+ 1 - 1
QGearsMain/include/core/Console.h

@@ -19,7 +19,7 @@ public:
     Console();
     ~Console();
 
-    void Input( const Event& event );
+    void Input(const QGears::Event& event);
     void Update();
     void UpdateDraw();
     void UpdateNotification();

+ 1 - 1
QGearsMain/include/core/EntityManager.h

@@ -18,7 +18,7 @@ public:
     EntityManager();
     virtual ~EntityManager();
 
-    void Input( const Event& event );
+    void Input(const QGears::Event& event);
     void Update();
     void UpdateDebug();
     void OnResize();

+ 39 - 42
QGearsMain/include/core/Event.h

@@ -1,54 +1,51 @@
-#ifndef EVENT_H
-#define EVENT_H
+#pragma once
 
 // add this include because this is only common file between everything that uses Input fucntion
 #include <OIS.h>
 
 
-
-enum EventType
-{
-    ET_NULL = 0,
-    ET_KEY_PRESS,
-    ET_KEY_REPEAT,
-    ET_KEY_IMPULSE,
-    ET_KEY_RELEASE,
-    ET_MOUSE_PRESS,
-    ET_MOUSE_RELEASE,
-    ET_MOUSE_MOVE,
-    ET_MOUSE_SCROLL
-};
-
-
-
-struct Event
+namespace QGears
 {
-    Event():
-        type( ET_NULL ),
-        param1( 0 ),
-        param2( 0 )
+    enum EventType
     {
+        ET_NULL = 0,
+        ET_KEY_PRESS,
+        ET_KEY_REPEAT,
+        ET_KEY_IMPULSE,
+        ET_KEY_RELEASE,
+        ET_MOUSE_PRESS,
+        ET_MOUSE_RELEASE,
+        ET_MOUSE_MOVE,
+        ET_MOUSE_SCROLL
     };
 
-    Event( EventType n ):
-        type( n ),
-        param1( 0 ),
-        param2( 0 )
-    {
-    };
 
-    Event( EventType n, float p1, float p2 ):
-        type( n ),
-        param1( p1 ),
-        param2( p2 )
+
+    struct Event
     {
+        Event() :
+            type(ET_NULL),
+            param1(0),
+            param2(0)
+        {
+        };
+
+        Event(EventType n) :
+            type(n),
+            param1(0),
+            param2(0)
+        {
+        };
+
+        Event(EventType n, float p1, float p2) :
+            type(n),
+            param1(p1),
+            param2(p2)
+        {
+        };
+
+        EventType type;
+        float param1;
+        float param2;
     };
-
-    EventType type;
-    float param1;
-    float param2;
-};
-
-
-
-#endif // EVENT_H
+}

+ 1 - 1
QGearsMain/include/core/InputManager.h

@@ -10,7 +10,7 @@
 
 
 
-typedef std::vector< Event > InputEventArray;
+typedef std::vector< QGears::Event > InputEventArray;
 typedef std::vector< int > ButtonList;
 
 

+ 1 - 1
QGearsMain/include/core/ScriptManager.h

@@ -64,7 +64,7 @@ public:
     ScriptManager();
     virtual ~ScriptManager();
 
-    void Input( const Event& event );
+    void Input(const QGears::Event& event);
     void Update( const Type type );
 
     void RunString( const Ogre::String& lua );

+ 5 - 5
QGearsMain/src/core/Background2D.cpp

@@ -88,23 +88,23 @@ Background2D::~Background2D()
 
 //------------------------------------------------------------------------------
 void
-Background2D::InputDebug( const Event& event )
+Background2D::InputDebug(const QGears::Event& event)
 {
     if( cv_background2d_manual.GetB() == true )
     {
-        if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_W )
+        if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_W)
         {
             m_PositionReal.y += 2;
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_A )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_A)
         {
             m_PositionReal.x += 2;
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_S )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_S)
         {
             m_PositionReal.y -= 2;
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_D )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_D)
         {
             m_PositionReal.x -= 2;
         }

+ 8 - 8
QGearsMain/src/core/CameraManager.cpp

@@ -53,7 +53,7 @@ CameraManager::~CameraManager()
 
 
 void
-CameraManager::Input( const Event& event, Ogre::Real timeSinceLastFrame )
+CameraManager::Input(const QGears::Event& event, Ogre::Real timeSinceLastFrame)
 {
     if( m_CameraFree == true )
     {
@@ -63,31 +63,31 @@ CameraManager::Input( const Event& event, Ogre::Real timeSinceLastFrame )
             speed *= 4;
         }
 
-        if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_W )
+        if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_W)
         {
             m_Camera->moveRelative( Ogre::Vector3( 0, 0, -speed ) );
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_A )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_A)
         {
             m_Camera->moveRelative( Ogre::Vector3( -speed, 0, 0 ) );
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_S )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_S)
         {
             m_Camera->moveRelative( Ogre::Vector3( 0, 0, speed ) );
         }
-        else if( event.type == ET_KEY_IMPULSE && event.param1 == OIS::KC_D )
+        else if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_D)
         {
             m_Camera->moveRelative( Ogre::Vector3( speed, 0, 0 ) );
         }
-        else if( event.type == ET_MOUSE_PRESS && event.param1 == OIS::MB_Right )
+        else if (event.type == QGears::ET_MOUSE_PRESS && event.param1 == OIS::MB_Right)
         {
             m_CameraFreeRotate = true;
         }
-        else if( event.type == ET_MOUSE_RELEASE && event.param1 == OIS::MB_Right )
+        else if (event.type == QGears::ET_MOUSE_RELEASE && event.param1 == OIS::MB_Right)
         {
             m_CameraFreeRotate = false;
         }
-        else if( event.type == ET_MOUSE_MOVE && m_CameraFreeRotate == true )
+        else if (event.type == QGears::ET_MOUSE_MOVE && m_CameraFreeRotate == true)
         {
             m_Camera->rotate( Ogre::Vector3::UNIT_Z, Ogre::Radian( Ogre::Degree( -event.param1 * 0.13 ) ) );
             m_Camera->pitch( Ogre::Degree( -event.param2 * 0.13 ) );

+ 19 - 19
QGearsMain/src/core/Console.cpp

@@ -71,12 +71,12 @@ Console::~Console()
 
 
 void
-Console::Input( const Event& event )
+Console::Input(const QGears::Event& event)
 {
     if( m_Visible != true )
     {
         // add console
-        if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE )
+        if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
         {
             SetToVisible();
         }
@@ -85,7 +85,7 @@ Console::Input( const Event& event )
     }
 
     // input command
-    else if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_RETURN && m_InputLine.size() )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_RETURN && m_InputLine.size())
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -115,17 +115,17 @@ Console::Input( const Event& event )
         m_CursorPosition = 0;
         ResetAutoCompletion();
     }
-    else if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_TAB )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_TAB)
     {
         CompleteInput();
     }
     // remove console
-    else if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
     {
         SetToHide();
     }
     // history up
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_UP )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_UP)
     {
         if( m_HistoryLine < ( int )m_History.size() - 1 )
         {
@@ -134,7 +134,7 @@ Console::Input( const Event& event )
         }
     }
     // history down
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_DOWN )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DOWN)
     {
         if( m_HistoryLine > 0 )
         {
@@ -143,7 +143,7 @@ Console::Input( const Event& event )
         }
     }
     // scroll display to previous row
-    else if( event.type == ET_MOUSE_SCROLL && event.param1 > 0 )
+    else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
     {
         if( m_DisplayLine > 0 )
         {
@@ -151,7 +151,7 @@ Console::Input( const Event& event )
         }
     }
     // scroll display to next row
-    else if( event.type == ET_MOUSE_SCROLL && event.param1 < 0 )
+    else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 < 0)
     {
         if( m_DisplayLine < m_OutputLine.size() )
         {
@@ -160,7 +160,7 @@ Console::Input( const Event& event )
 
     }
     // scroll display to previous row
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_PGUP )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGUP)
     {
         if( m_DisplayLine > 0 )
         {
@@ -168,7 +168,7 @@ Console::Input( const Event& event )
         }
     }
     // scroll display to next row
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_PGDOWN )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_PGDOWN)
     {
         if( m_DisplayLine < m_OutputLine.size() )
         {
@@ -176,7 +176,7 @@ Console::Input( const Event& event )
         }
     }
     // delete character after cursor
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_DELETE )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_DELETE)
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -191,7 +191,7 @@ Console::Input( const Event& event )
         }
     }
     // delete character before cursor
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_BACK )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_BACK)
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -207,7 +207,7 @@ Console::Input( const Event& event )
         }
     }
     // move cursor to left
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_LEFT )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_LEFT)
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -221,7 +221,7 @@ Console::Input( const Event& event )
         }
     }
     // move cursor to right
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && event.param1 == OIS::KC_RIGHT )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && event.param1 == OIS::KC_RIGHT)
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -234,14 +234,14 @@ Console::Input( const Event& event )
             ++m_CursorPosition;
         }
     }
-    else if ( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_ESCAPE )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_ESCAPE)
     {
         m_InputLine.clear();
         m_CursorPosition = 0;
         ResetAutoCompletion();
     }
     // move cursor to start of string
-    else if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_HOME )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_HOME)
     {
         m_CursorPosition = 0;
 
@@ -252,7 +252,7 @@ Console::Input( const Event& event )
         }
     }
     // move cursor to end of string
-    else if( event.type == ET_KEY_PRESS && event.param1 == OIS::KC_END )
+    else if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_END)
     {
         if( m_AutoCompletition.size() > 0 )
         {
@@ -263,7 +263,7 @@ Console::Input( const Event& event )
         m_CursorPosition = m_InputLine.size();
     }
     // input ascii character
-    else if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) && m_InputLine.size() < m_LineWidth )
+    else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) && m_InputLine.size() < m_LineWidth)
     {
         char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
         char txt = event.param2;

+ 5 - 5
QGearsMain/src/core/EntityManager.cpp

@@ -118,7 +118,7 @@ EntityManager::~EntityManager()
 
 
 void
-EntityManager::Input( const Event& event )
+EntityManager::Input(const QGears::Event& event)
 {
     m_Background2D.InputDebug( event );
 
@@ -133,21 +133,21 @@ EntityManager::Input( const Event& event )
 
     if( m_PlayerEntity != NULL && m_PlayerLock == false )
     {
-        if( ( event.type == ET_KEY_IMPULSE ) && ( event.param1 == OIS::KC_LEFT ) )
+        if ((event.type == QGears::ET_KEY_IMPULSE) && (event.param1 == OIS::KC_LEFT))
         {
             m_PlayerMove.x = -1;
         }
-        else if( ( event.type == ET_KEY_IMPULSE ) && ( event.param1 == OIS::KC_RIGHT ) )
+        else if ((event.type == QGears::ET_KEY_IMPULSE) && (event.param1 == OIS::KC_RIGHT))
         {
             m_PlayerMove.x = 1;
         }
 
-        if( ( event.type == ET_KEY_IMPULSE ) && ( event.param1 == OIS::KC_DOWN ) )
+        if ((event.type == QGears::ET_KEY_IMPULSE) && (event.param1 == OIS::KC_DOWN))
         {
             m_PlayerMove.y = -1;
         }
 
-        if( ( event.type == ET_KEY_IMPULSE ) && ( event.param1 == OIS::KC_UP ) )
+        if ((event.type == QGears::ET_KEY_IMPULSE) && (event.param1 == OIS::KC_UP))
         {
             m_PlayerMove.y = 1;
         }

+ 6 - 6
QGearsMain/src/core/InputManager.cpp

@@ -48,7 +48,7 @@ InputManager::ButtonPressed( int button, char text, bool down )
         m_ButtonState[ button ] = down;
         m_ButtonText[ button ] = text;
 
-        m_EventQueue.push_back( Event( ( down == true ) ? ET_KEY_PRESS : ET_KEY_RELEASE, button, text ) );
+        m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_KEY_PRESS : QGears::ET_KEY_RELEASE, button, text));
 
         m_RepeatFirstWait = true;
         m_RepeatTimer = 0;
@@ -65,7 +65,7 @@ InputManager::ButtonPressed( int button, char text, bool down )
 void
 InputManager::MousePressed( int button, bool down )
 {
-    m_EventQueue.push_back( Event( ( down == true ) ? ET_MOUSE_PRESS : ET_MOUSE_RELEASE, button, 0 ) );
+    m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_MOUSE_PRESS : QGears::ET_MOUSE_RELEASE, button, 0));
 }
 
 
@@ -73,7 +73,7 @@ InputManager::MousePressed( int button, bool down )
 void
 InputManager::MouseMoved( int x, int y )
 {
-    m_EventQueue.push_back( Event( ET_MOUSE_MOVE, x, y ) );
+    m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_MOVE, x, y));
 }
 
 
@@ -81,7 +81,7 @@ InputManager::MouseMoved( int x, int y )
 void
 InputManager::MouseScrolled( int value )
 {
-    m_EventQueue.push_back( Event( ET_MOUSE_SCROLL, value, 0 ) );
+    m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_SCROLL, value, 0));
 }
 
 
@@ -97,7 +97,7 @@ InputManager::Update()
         {
             if( m_ButtonState[ button ] == true )
             {
-                m_EventQueue.push_back( Event( ET_KEY_REPEAT, button, m_ButtonText[ button ] ) );
+                m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_REPEAT, button, m_ButtonText[button]));
             }
         }
 
@@ -110,7 +110,7 @@ InputManager::Update()
     {
         if( m_ButtonState[ button ] == true )
         {
-            m_EventQueue.push_back( Event( ET_KEY_IMPULSE, button, m_ButtonText[ button ] ) );
+            m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_IMPULSE, button, m_ButtonText[button]));
         }
     }
 }

+ 4 - 4
QGearsMain/src/core/ScriptManager.cpp

@@ -62,9 +62,9 @@ ScriptManager::~ScriptManager()
 
 
 void
-ScriptManager::Input( const Event& event )
+ScriptManager::Input(const QGears::Event& event)
 {
-    if( ( event.type == ET_KEY_PRESS || event.type == ET_KEY_REPEAT ) &&
+    if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::ET_KEY_REPEAT) &&
                                       (
                                         event.param1 == OIS::KC_RETURN ||
                                         event.param1 == OIS::KC_ESCAPE ||
@@ -79,11 +79,11 @@ ScriptManager::Input( const Event& event )
         for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
         {
             Ogre::String argument2 = "";
-            if( event.type == ET_KEY_PRESS )
+            if (event.type == QGears::ET_KEY_PRESS)
             {
                 argument2 = "Press";
             }
-            else if( event.type == ET_KEY_REPEAT )
+            else if (event.type == QGears::ET_KEY_REPEAT)
             {
                 argument2 = "Repeat";
             }