Pārlūkot izejas kodu

Merge remote-tracking branch 'upstream/master' into installer

Paul 11 gadi atpakaļ
vecāks
revīzija
9ea264b0d4
83 mainītis faili ar 2987 papildinājumiem un 3796 dzēšanām
  1. 28 1
      QGearsMain/include/core/UiTextArea.h
  2. 2 0
      QGearsMain/include/data/QGearsBackgroundFile.h
  3. 1 1
      QGearsMain/src/Main.cpp
  4. 8 8
      QGearsMain/src/common/File.cpp
  5. 3 3
      QGearsMain/src/common/FileSystem.cpp
  6. 20 20
      QGearsMain/src/common/QGearsManualObject.cpp
  7. 118 158
      QGearsMain/src/core/AudioManager.cpp
  8. 255 262
      QGearsMain/src/core/Background2D.cpp
  9. 35 38
      QGearsMain/src/core/Background2DAnimation.cpp
  10. 67 73
      QGearsMain/src/core/CameraManager.cpp
  11. 0 6
      QGearsMain/src/core/ConfigCmd.cpp
  12. 17 25
      QGearsMain/src/core/ConfigCmdManager.cpp
  13. 23 25
      QGearsMain/src/core/ConfigFile.cpp
  14. 2 16
      QGearsMain/src/core/ConfigVar.cpp
  15. 14 19
      QGearsMain/src/core/ConfigVarManager.cpp
  16. 198 222
      QGearsMain/src/core/Console.cpp
  17. 167 251
      QGearsMain/src/core/DebugDraw.cpp
  18. 177 252
      QGearsMain/src/core/Entity.cpp
  19. 9 12
      QGearsMain/src/core/EntityCollision.cpp
  20. 8 12
      QGearsMain/src/core/EntityDirection.cpp
  21. 227 305
      QGearsMain/src/core/EntityManager.cpp
  22. 46 55
      QGearsMain/src/core/EntityModel.cpp
  23. 17 29
      QGearsMain/src/core/EntityPoint.cpp
  24. 37 51
      QGearsMain/src/core/EntityTrigger.cpp
  25. 63 79
      QGearsMain/src/core/GameFrameListner.cpp
  26. 46 60
      QGearsMain/src/core/InputManager.cpp
  27. 206 234
      QGearsMain/src/core/ScriptManager.cpp
  28. 8 19
      QGearsMain/src/core/Timer.cpp
  29. 80 104
      QGearsMain/src/core/UiAnimation.cpp
  30. 16 28
      QGearsMain/src/core/UiFont.cpp
  31. 60 82
      QGearsMain/src/core/UiManager.cpp
  32. 68 82
      QGearsMain/src/core/UiSprite.cpp
  33. 99 197
      QGearsMain/src/core/UiTextArea.cpp
  34. 141 208
      QGearsMain/src/core/UiWidget.cpp
  35. 121 125
      QGearsMain/src/core/Utilites.cpp
  36. 56 76
      QGearsMain/src/core/Walkmesh.cpp
  37. 42 47
      QGearsMain/src/core/XmlBackground2DFile.cpp
  38. 60 74
      QGearsMain/src/core/XmlFile.cpp
  39. 26 30
      QGearsMain/src/core/XmlFontFile.cpp
  40. 8 12
      QGearsMain/src/core/XmlFontsFile.cpp
  41. 61 64
      QGearsMain/src/core/XmlMapFile.cpp
  42. 17 22
      QGearsMain/src/core/XmlMapsFile.cpp
  43. 11 15
      QGearsMain/src/core/XmlMusicsFile.cpp
  44. 9 13
      QGearsMain/src/core/XmlPrototypesFile.cpp
  45. 171 226
      QGearsMain/src/core/XmlScreenFile.cpp
  46. 8 12
      QGearsMain/src/core/XmlScreensFile.cpp
  47. 13 17
      QGearsMain/src/core/XmlScriptsFile.cpp
  48. 9 13
      QGearsMain/src/core/XmlTextFile.cpp
  49. 15 19
      QGearsMain/src/core/XmlTextsFile.cpp
  50. 2 2
      QGearsMain/src/core/XmlWalkmeshFile.cpp
  51. 2 2
      QGearsMain/src/core/particles/Particle.cpp
  52. 1 1
      QGearsMain/src/core/particles/ParticleEmitter.cpp
  53. 1 1
      QGearsMain/src/core/particles/ParticleEmitterTranslator.cpp
  54. 1 1
      QGearsMain/src/core/particles/ParticleRenderer.cpp
  55. 1 1
      QGearsMain/src/core/particles/ParticleRendererTranslator.cpp
  56. 1 1
      QGearsMain/src/core/particles/ParticleSystem.cpp
  57. 6 6
      QGearsMain/src/core/particles/ParticleSystemManager.cpp
  58. 1 1
      QGearsMain/src/core/particles/ParticleSystemTranslatorManager.cpp
  59. 9 9
      QGearsMain/src/core/particles/ParticleTechnique.cpp
  60. 1 1
      QGearsMain/src/core/particles/ParticleVisual.cpp
  61. 2 2
      QGearsMain/src/core/particles/renderer/ParticleEntityRenderer.cpp
  62. 1 1
      QGearsMain/src/data/QGearsAFileManager.cpp
  63. 1 1
      QGearsMain/src/data/QGearsBackgroundFileManager.cpp
  64. 1 1
      QGearsMain/src/data/QGearsCameraMatrixFileManager.cpp
  65. 6 6
      QGearsMain/src/data/QGearsFLevelFile.cpp
  66. 1 1
      QGearsMain/src/data/QGearsFLevelFileManager.cpp
  67. 6 6
      QGearsMain/src/data/QGearsHRCFile.cpp
  68. 1 1
      QGearsMain/src/data/QGearsHRCFileManager.cpp
  69. 1 1
      QGearsMain/src/data/QGearsLGPArchive.cpp
  70. 1 1
      QGearsMain/src/data/QGearsLZSFLevelFileManager.cpp
  71. 1 1
      QGearsMain/src/data/QGearsPFileManager.cpp
  72. 1 1
      QGearsMain/src/data/QGearsPaletteFileManager.cpp
  73. 1 1
      QGearsMain/src/data/QGearsRSDFileManager.cpp
  74. 4 4
      QGearsMain/src/data/QGearsTexCodec.cpp
  75. 9 9
      QGearsMain/src/data/QGearsXMLSerializer.cpp
  76. 1 1
      QGearsMain/src/map/QGearsBackground2DFileManager.cpp
  77. 2 2
      QGearsMain/src/map/QGearsBackground2DFileXMLSerializer.cpp
  78. 1 1
      QGearsMain/src/map/QGearsMapFileManager.cpp
  79. 6 6
      QGearsMain/src/map/QGearsMapFileXMLSerializer.cpp
  80. 1 1
      QGearsMain/src/map/QGearsWalkmeshFileManager.cpp
  81. 1 1
      QGearsMain/src/map/QGearsWalkmeshFileXMLSerializer.cpp
  82. 3 3
      QGearsMain/src/modules/worldmap/WorldMapModule.cpp
  83. 16 16
      QGearsMain/src/viewer/ViewerModule.cpp

+ 28 - 1
QGearsMain/include/core/UiTextArea.h

@@ -76,6 +76,33 @@ private:
     TiXmlNode*                          m_TextNode;
     TiXmlNode*                          m_TextNode;
 };
 };
 
 
-
+inline
+void WriteTriangleVertex(float *&writeIterator, const Ogre::Vector3 &coord,
+                const Ogre::ColourValue &colour, const float u, const float v)
+{
+    *writeIterator++ = coord.x;
+    *writeIterator++ = coord.y;
+    *writeIterator++ = coord.z;
+    *writeIterator++ = colour.r;
+    *writeIterator++ = colour.g;
+    *writeIterator++ = colour.b;
+    *writeIterator++ = colour.a;
+    *writeIterator++ = u;
+    *writeIterator++ = v;
+}
+
+inline void
+WriteGlyph(float *&writeIterator, const Ogre::Vector3 coords[],
+           const Ogre::ColourValue &colour, const Ogre::FloatRect &texture)
+{
+    // draw two triangles with a colour and texture.
+    WriteTriangleVertex(writeIterator, coords[0], colour, texture.left, texture.top);
+    WriteTriangleVertex(writeIterator, coords[1], colour, texture.right, texture.top);
+    WriteTriangleVertex(writeIterator, coords[2], colour, texture.right, texture.bottom);
+    // Triangle two
+    WriteTriangleVertex(writeIterator, coords[0], colour, texture.left, texture.top);
+    WriteTriangleVertex(writeIterator, coords[2], colour, texture.right, texture.bottom);
+    WriteTriangleVertex(writeIterator, coords[3], colour, texture.left, texture.bottom);
+}
 
 
 #endif // UI_TEXT_AREA_H
 #endif // UI_TEXT_AREA_H

+ 2 - 0
QGearsMain/include/data/QGearsBackgroundFile.h

@@ -33,6 +33,8 @@ THE SOFTWARE.
 #include "common/TypeDefine.h"
 #include "common/TypeDefine.h"
 #include "data/QGearsPaletteFile.h"
 #include "data/QGearsPaletteFile.h"
 
 
+#include <array>
+
 namespace QGears
 namespace QGears
 {
 {
     // TODO inherit from Qgears Ressource
     // TODO inherit from Qgears Ressource

+ 1 - 1
QGearsMain/src/Main.cpp

@@ -43,7 +43,7 @@ main(int argc, char *argv[])
 
 
         Ogre::Root         *root(app.getRoot());
         Ogre::Root         *root(app.getRoot());
         Ogre::RenderWindow *window(app.getRenderWindow());
         Ogre::RenderWindow *window(app.getRenderWindow());
-        Ogre::SceneManager *scene_manager(NULL);
+        Ogre::SceneManager *scene_manager(nullptr);
 
 
         auto timer = std::make_unique<Timer>();
         auto timer = std::make_unique<Timer>();
         auto particle_system_manager = std::make_unique<ParticleSystemManager>();
         auto particle_system_manager = std::make_unique<ParticleSystemManager>();

+ 8 - 8
QGearsMain/src/common/File.cpp

@@ -10,7 +10,7 @@
 //-------------------------------------------------------------------------
 //-------------------------------------------------------------------------
 File::File(const Ogre::String& file):
 File::File(const Ogre::String& file):
   m_FileName(file),
   m_FileName(file),
-  m_Buffer(NULL),
+  m_Buffer(nullptr),
   m_BufferSize(0)
   m_BufferSize(0)
 {
 {
     LOG_TRIVIAL("Loading file: " + m_FileName + "\n");
     LOG_TRIVIAL("Loading file: " + m_FileName + "\n");
@@ -25,11 +25,11 @@ File::File(const Ogre::String& file):
 }
 }
 
 
 //-------------------------------------------------------------------------
 //-------------------------------------------------------------------------
-File::File( const File* pFile, u32 offset, u32 length):
-  m_Buffer(NULL),
+File::File(const File* pFile, u32 offset, u32 length):
+  m_Buffer(nullptr),
   m_BufferSize(length)
   m_BufferSize(length)
 {
 {
-    assert(pFile != NULL);
+    assert(pFile != nullptr);
 
 
     m_FileName = pFile->GetFileName();
     m_FileName = pFile->GetFileName();
 
 
@@ -40,19 +40,19 @@ File::File( const File* pFile, u32 offset, u32 length):
 //-------------------------------------------------------------------------
 //-------------------------------------------------------------------------
 File::File(const u8* pBuffer, u32 offset, u32 length):
 File::File(const u8* pBuffer, u32 offset, u32 length):
   m_FileName("BUFFER"),
   m_FileName("BUFFER"),
-  m_Buffer(NULL),
+  m_Buffer(nullptr),
   m_BufferSize(length)
   m_BufferSize(length)
 {
 {
-    assert(pBuffer != NULL);
+    assert(pBuffer != nullptr);
 
 
     m_Buffer = (u8*)malloc(sizeof(u8) * m_BufferSize);
     m_Buffer = (u8*)malloc(sizeof(u8) * m_BufferSize);
     memcpy(m_Buffer, pBuffer + offset, m_BufferSize);
     memcpy(m_Buffer, pBuffer + offset, m_BufferSize);
 }
 }
 
 
 //-------------------------------------------------------------------------
 //-------------------------------------------------------------------------
-File::File( const File* pFile )
+File::File(const File* pFile)
 {
 {
-    assert(pFile != NULL);
+    assert(pFile != nullptr);
 
 
     m_BufferSize = pFile->GetFileSize();
     m_BufferSize = pFile->GetFileSize();
     m_FileName   = pFile->GetFileName();
     m_FileName   = pFile->GetFileName();

+ 3 - 3
QGearsMain/src/common/FileSystem.cpp

@@ -10,7 +10,7 @@ FileSystem::GetFileSize(const Ogre::String &path)
 {
 {
     FILE* file = fopen(path.c_str(), "rb");
     FILE* file = fopen(path.c_str(), "rb");
 
 
-    if (file == NULL)
+    if (file == nullptr)
     {
     {
         LOG_ERROR("Can't open file " + path + ".\n");
         LOG_ERROR("Can't open file " + path + ".\n");
         return 0;
         return 0;
@@ -30,7 +30,7 @@ FileSystem::ReadFile(const Ogre::String &path, void* buffer, const unsigned int
 {
 {
     FILE* file = fopen(path.c_str(), "rb");
     FILE* file = fopen(path.c_str(), "rb");
 
 
-    if (file == NULL)
+    if (file == nullptr)
     {
     {
         LOG_ERROR("Can't open file " + path + ".\n");
         LOG_ERROR("Can't open file " + path + ".\n");
         return false;
         return false;
@@ -55,7 +55,7 @@ FileSystem::WriteFile(const Ogre::String &path, const void* buffer, const unsign
 {
 {
     FILE* file = fopen(path.c_str(), "ab");
     FILE* file = fopen(path.c_str(), "ab");
 
 
-    if (file == NULL)
+    if (file == nullptr)
     {
     {
         return false;
         return false;
     }
     }

+ 20 - 20
QGearsMain/src/common/QGearsManualObject.cpp

@@ -36,14 +36,14 @@ namespace QGears
     //-------------------------------------------------------------------------
     //-------------------------------------------------------------------------
     ManualObject::ManualObject( Ogre::Mesh *mesh ) :
     ManualObject::ManualObject( Ogre::Mesh *mesh ) :
         m_mesh( mesh )
         m_mesh( mesh )
-       ,m_section( NULL )
+       ,m_section( nullptr )
        ,m_bbox( mesh->getBounds() )
        ,m_bbox( mesh->getBounds() )
        ,m_radius( mesh->getBoundingSphereRadius() )
        ,m_radius( mesh->getBoundingSphereRadius() )
-       ,m_position( NULL )
-       ,m_normal( NULL )
-       ,m_colour( NULL )
-       ,m_texture_coordinate( NULL )
-       ,m_index( NULL )
+       ,m_position( nullptr )
+       ,m_normal( nullptr )
+       ,m_colour( nullptr )
+       ,m_texture_coordinate( nullptr )
+       ,m_index( nullptr )
        ,colour_type( Ogre::VertexElement::getBestColourVertexElementType() )
        ,colour_type( Ogre::VertexElement::getBestColourVertexElementType() )
     {
     {
     }
     }
@@ -142,11 +142,11 @@ namespace QGears
         }
         }
 
 
         resetBuffer( m_index_buffer );
         resetBuffer( m_index_buffer );
-        m_position = NULL;
-        m_normal = NULL;
-        m_colour = NULL;
-        m_texture_coordinate = NULL;
-        m_index = NULL;
+        m_position = nullptr;
+        m_normal = nullptr;
+        m_colour = nullptr;
+        m_texture_coordinate = nullptr;
+        m_index = nullptr;
     }
     }
 
 
     //-------------------------------------------------------------------------
     //-------------------------------------------------------------------------
@@ -154,14 +154,14 @@ namespace QGears
     ManualObject::begin( const String &name, const String &material_name
     ManualObject::begin( const String &name, const String &material_name
                         ,size_t vertex_count, size_t index_count )
                         ,size_t vertex_count, size_t index_count )
     {
     {
-        if( m_mesh == NULL )
+        if( m_mesh == nullptr )
         {
         {
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 				"You cannot begin a section without a Mesh",
 				"You cannot begin a section without a Mesh",
 				"ManualObject::begin");
 				"ManualObject::begin");
         }
         }
 
 
-        if( m_section != NULL )
+        if( m_section != nullptr )
         {
         {
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 				"You cannot begin a section without ending the old one first",
 				"You cannot begin a section without ending the old one first",
@@ -191,7 +191,7 @@ namespace QGears
     void
     void
     ManualObject::position( const Ogre::Vector3 &position )
     ManualObject::position( const Ogre::Vector3 &position )
     {
     {
-        if( m_position == NULL )
+        if( m_position == nullptr )
         {
         {
             createPositionBuffer();
             createPositionBuffer();
         }
         }
@@ -205,7 +205,7 @@ namespace QGears
     void
     void
     ManualObject::normal( const Ogre::Vector3 &normal )
     ManualObject::normal( const Ogre::Vector3 &normal )
     {
     {
-        if( m_normal == NULL )
+        if( m_normal == nullptr )
         {
         {
             createNormalBuffer();
             createNormalBuffer();
         }
         }
@@ -216,7 +216,7 @@ namespace QGears
     void
     void
     ManualObject::colour( const Ogre::ColourValue &colour )
     ManualObject::colour( const Ogre::ColourValue &colour )
     {
     {
-        if( m_colour == NULL )
+        if( m_colour == nullptr )
         {
         {
             createColourBuffer();
             createColourBuffer();
         }
         }
@@ -227,7 +227,7 @@ namespace QGears
     void
     void
     ManualObject::textureCoord( const Ogre::Vector2 &texture_coordinate )
     ManualObject::textureCoord( const Ogre::Vector2 &texture_coordinate )
     {
     {
-        if( m_texture_coordinate == NULL )
+        if( m_texture_coordinate == nullptr )
         {
         {
             createTextureCoordinateBuffer();
             createTextureCoordinateBuffer();
         }
         }
@@ -238,7 +238,7 @@ namespace QGears
     void
     void
     ManualObject::index( const uint32 idx )
     ManualObject::index( const uint32 idx )
     {
     {
-        if( m_index == NULL )
+        if( m_index == nullptr )
         {
         {
             createIndexBuffer();
             createIndexBuffer();
         }
         }
@@ -261,7 +261,7 @@ namespace QGears
     void
     void
     ManualObject::end()
     ManualObject::end()
     {
     {
-        if( m_section == NULL )
+        if( m_section == nullptr )
         {
         {
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 			OGRE_EXCEPT( Ogre::Exception::ERR_INVALIDPARAMS,
 				"You cannot end a section without beginning one first",
 				"You cannot end a section without beginning one first",
@@ -270,7 +270,7 @@ namespace QGears
 
 
         m_mesh->_setBounds( m_bbox );
         m_mesh->_setBounds( m_bbox );
         m_mesh->_setBoundingSphereRadius( m_radius );
         m_mesh->_setBoundingSphereRadius( m_radius );
-        m_section = NULL;
+        m_section = nullptr;
         resetBuffers();
         resetBuffers();
     }
     }
 
 

+ 118 - 158
QGearsMain/src/core/AudioManager.cpp

@@ -1,200 +1,186 @@
-#include "core/AudioManager.h"
-
 #include <list>
 #include <list>
 #include <boost/thread.hpp>
 #include <boost/thread.hpp>
 
 
+#include "core/AudioManager.h"
 #include "core/XmlMusicsFile.h"
 #include "core/XmlMusicsFile.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 
 
 
 
-
-template<>AudioManager *Ogre::Singleton< AudioManager >::msSingleton = NULL;
+template<>AudioManager *Ogre::Singleton<AudioManager>::msSingleton = nullptr;
 
 
 ALsizei AudioManager::m_ChannelBufferNumber = 2;
 ALsizei AudioManager::m_ChannelBufferNumber = 2;
 int AudioManager::m_ChannelBufferSize = 96 * 1024;
 int AudioManager::m_ChannelBufferSize = 96 * 1024;
 
 
 
 
-
 AudioManager::AudioManager():
 AudioManager::AudioManager():
-    m_Initialized( false ),
-    m_ThreadContinue( true ),
+    m_Initialized(false),
+    m_ThreadContinue(true),
     m_UpdateMutex(),
     m_UpdateMutex(),
-    m_Music( &m_UpdateMutex )
+    m_Music(&m_UpdateMutex)
 {
 {
-    m_ALDevice = alcOpenDevice( NULL );
-    if( m_ALDevice != NULL )
+    m_ALDevice = alcOpenDevice(nullptr);
+    if(m_ALDevice != nullptr)
     {
     {
-        m_ALContext = alcCreateContext( m_ALDevice, NULL );
-        if( m_ALContext != NULL )
+        m_ALContext = alcCreateContext(m_ALDevice, nullptr);
+        if(m_ALContext != nullptr)
         {
         {
-            alcMakeContextCurrent( m_ALContext );
+            alcMakeContextCurrent(m_ALContext);
 
 
             // listeners
             // listeners
-            ALfloat position[ 3 ] = { 0.0f, 0.0f, 0.0f };
-            ALfloat velocity[ 3 ] = { 0.0f, 0.0f, 0.0f };
-            ALfloat orientation[ 6 ] = { 0.0f, 0.0f, -1.0f,  0.0f, 1.0f, 0.0f };
+            ALfloat position[3] = { 0.0f, 0.0f, 0.0f };
+            ALfloat velocity[3] = { 0.0f, 0.0f, 0.0f };
+            ALfloat orientation[6] = { 0.0f, 0.0f, -1.0f,  0.0f, 1.0f, 0.0f };
             alListenerfv( AL_POSITION, position );
             alListenerfv( AL_POSITION, position );
             alListenerfv( AL_VELOCITY, velocity );
             alListenerfv( AL_VELOCITY, velocity );
             alListenerfv( AL_ORIENTATION, orientation );
             alListenerfv( AL_ORIENTATION, orientation );
             m_Initialized = true;
             m_Initialized = true;
 
 
-            m_Buffer       = new char[ m_ChannelBufferSize ];
-            m_UpdateThread = new boost::thread( boost::ref( *this ) );
+            m_Buffer       = new char[m_ChannelBufferSize];
+            m_UpdateThread = new boost::thread(boost::ref(*this));
 
 
-            LOG_TRIVIAL( "AudioManager initialised." );
+            LOG_TRIVIAL("AudioManager initialised.");
         }
         }
         else
         else
         {
         {
-            LOG_ERROR( "AudioManager failed to initialised. Could not create context for sound device." );
+            LOG_ERROR("AudioManager failed to initialised. Could not create context for sound device.");
         }
         }
     }
     }
     else
     else
     {
     {
-        LOG_ERROR( "AudioManager failed to initialised. There's no default sound device." );
+        LOG_ERROR("AudioManager failed to initialised. There's no default sound device.");
     }
     }
 
 
-
-
     // Load musics
     // Load musics
-    XmlMusicsFile musics( "./data/musics.xml" );
+    XmlMusicsFile musics("./data/musics.xml");
     musics.LoadMusics();
     musics.LoadMusics();
 }
 }
 
 
 
 
-
 AudioManager::~AudioManager()
 AudioManager::~AudioManager()
 {
 {
     MusicStop();
     MusicStop();
 
 
-    if( m_Initialized )
+    if(m_Initialized)
     {
     {
         m_ThreadContinue = false;
         m_ThreadContinue = false;
         m_UpdateThread->join();
         m_UpdateThread->join();
         delete m_UpdateThread;
         delete m_UpdateThread;
         delete[] m_Buffer;
         delete[] m_Buffer;
 
 
-        alcMakeContextCurrent( NULL );
-        alcDestroyContext( m_ALContext );
-        alcCloseDevice( m_ALDevice );
-        LOG_TRIVIAL( "AudioManager destroyed." );
+        alcMakeContextCurrent(nullptr);
+        alcDestroyContext(m_ALContext);
+        alcCloseDevice(m_ALDevice);
+        LOG_TRIVIAL("AudioManager destroyed.");
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::operator()()
 AudioManager::operator()()
 {
 {
-    while( m_ThreadContinue )
+    while(m_ThreadContinue)
     {
     {
         Update();
         Update();
 
 
         boost::xtime xt;
         boost::xtime xt;
-        boost::xtime_get( &xt, boost::TIME_UTC_ );
+        boost::xtime_get(&xt, boost::TIME_UTC_);
         xt.nsec += 250000000; // sleep for 250 ms
         xt.nsec += 250000000; // sleep for 250 ms
-        boost::thread::sleep( xt );
+        boost::thread::sleep(xt);
 
 
         m_UpdateThread->yield();
         m_UpdateThread->yield();
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::Update()
 AudioManager::Update()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
     m_Music.Update();
     m_Music.Update();
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::MusicPause()
 AudioManager::MusicPause()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
     m_Music.Pause();
     m_Music.Pause();
 }
 }
 
 
 
 
-
 void
 void
-AudioManager::MusicPlay( const Ogre::String& name )
+AudioManager::MusicPlay(const Ogre::String& name)
 {
 {
-    if( m_Initialized )
+    if(m_Initialized)
     {
     {
-        boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+        boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
-        AudioManager::Music* music = GetMusic( name );
-        if( music == NULL )
+        AudioManager::Music* music = GetMusic(name);
+        if(music == nullptr)
         {
         {
-            LOG_ERROR( "No music found with name \"" + name + "\"." );
+            LOG_ERROR("No music found with name \"" + name + "\".");
             return;
             return;
         }
         }
 
 
-        m_Music.SetLoop( music->loop );
-        m_Music.Play( music->file );
+        m_Music.SetLoop(music->loop);
+        m_Music.Play(music->file);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::MusicStop()
 AudioManager::MusicStop()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
     m_Music.Stop();
     m_Music.Stop();
 }
 }
 
 
 
 
-
 void
 void
-AudioManager::AddMusic( const AudioManager::Music& music )
+AudioManager::AddMusic(const AudioManager::Music& music)
 {
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
-    for( std::list< AudioManager::Music >::iterator it = m_MusicList.begin(); it != m_MusicList.end(); ++it )
+    for(std::list<AudioManager::Music>::iterator it = m_MusicList.begin(); it != m_MusicList.end(); ++it )
     {
     {
-        if( it->name == music.name )
+        if(it->name == music.name)
         {
         {
             LOG_ERROR( "Music with name '" + music.name + "' already exists." );
             LOG_ERROR( "Music with name '" + music.name + "' already exists." );
             return;
             return;
         }
         }
     }
     }
 
 
-    m_MusicList.push_back( music );
+    m_MusicList.push_back(music);
 }
 }
 
 
 
 
-
 AudioManager::Music*
 AudioManager::Music*
-AudioManager::GetMusic( const Ogre::String& name )
+AudioManager::GetMusic(const Ogre::String& name)
 {
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
 
-    for( auto it = m_MusicList.begin(); it != m_MusicList.end(); ++it )
+    for(auto it = m_MusicList.begin(); it != m_MusicList.end(); ++it)
     {
     {
-        if( it->name == name )
+        if(it->name == name)
         {
         {
-            return &( *it );
+            return &(*it);
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 const char*
 const char*
 AudioManager::ALError()
 AudioManager::ALError()
 {
 {
     //ALenum error_code = alGetError();
     //ALenum error_code = alGetError();
     //if( error_code == AL_NO_ERROR )
     //if( error_code == AL_NO_ERROR )
     {
     {
-        return NULL;
+        return nullptr;
     }
     }
     //else
     //else
     //{
     //{
@@ -203,16 +189,15 @@ AudioManager::ALError()
 }
 }
 
 
 
 
-
 const char*
 const char*
-AudioManager::ALCError( const ALCdevice* device )
+AudioManager::ALCError(const ALCdevice* device)
 {
 {
-    //const ALCdevice *alc_device = ( ( device == NULL ) ? const_cast< ALCdevice* >( m_ALDevice ) : const_cast< ALCdevice* >( device ) );
+    //const ALCdevice *alc_device = ( ( device == nullptr ) ? const_cast< ALCdevice* >( m_ALDevice ) : const_cast< ALCdevice* >( device ) );
 
 
     //ALCenum error_code = alcGetError( const_cast< ALCdevice* >( alc_device ) );
     //ALCenum error_code = alcGetError( const_cast< ALCdevice* >( alc_device ) );
     //if( error_code == ALC_NO_ERROR )
     //if( error_code == ALC_NO_ERROR )
     {
     {
-        return NULL;
+        return nullptr;
     }
     }
     //else
     //else
     //{
     //{
@@ -221,140 +206,140 @@ AudioManager::ALCError( const ALCdevice* device )
 }
 }
 
 
 
 
-
-AudioManager::Player::Player( boost::recursive_mutex* mutex ):
-    m_Loop( -1.0 ),
-    m_VorbisInfo( NULL ),
-    m_VorbisSection( 0 ),
-    m_StreamFinished( false ),
-    m_UpdateMutex( mutex )
+AudioManager::Player::Player(boost::recursive_mutex* mutex):
+    m_Loop(-1.0),
+    m_VorbisInfo(nullptr),
+    m_VorbisSection(0),
+    m_StreamFinished(false),
+    m_UpdateMutex(mutex)
 {
 {
 }
 }
 
 
 
 
-
 AudioManager::Player::~Player()
 AudioManager::Player::~Player()
 {
 {
     Stop();
     Stop();
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::Player::Pause()
 AudioManager::Player::Pause()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
 
-    alSourcePause( m_Source );
+    alSourcePause(m_Source);
 }
 }
 
 
 
 
-
 void
 void
-AudioManager::Player::Play( const Ogre::String &file )
+AudioManager::Player::Play(const Ogre::String &file)
 {
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
 
     // open vorbis file
     // open vorbis file
-    if( ov_fopen( const_cast< char* >( file.c_str() ), &m_VorbisFile ) )
+    if(ov_fopen(const_cast<char*>(file.c_str()), &m_VorbisFile))
     {
     {
-        LOG_ERROR( "Can't play file \"" + file + "\"." );
+        LOG_ERROR("Can't play file \"" + file + "\".");
         return;
         return;
     }
     }
 
 
     // get file info
     // get file info
-    m_VorbisInfo = ov_info( &m_VorbisFile, -1.0f );
+    m_VorbisInfo = ov_info(&m_VorbisFile, -1.0f);
 
 
     // create sound source
     // create sound source
-    alGenSources( 1, &m_Source );
+    alGenSources(1, &m_Source);
 
 
     // create buffers
     // create buffers
-    ALuint buffers[ m_ChannelBufferNumber ];
-    alGenBuffers( m_ChannelBufferNumber, buffers );
+    ALuint buffers[m_ChannelBufferNumber];
+    alGenBuffers(m_ChannelBufferNumber, buffers);
 
 
     // set source parameters
     // set source parameters
-    alSourcei( m_Source, AL_LOOPING, AL_FALSE );
+    alSourcei(m_Source, AL_LOOPING, AL_FALSE);
 
 
     // fill buffers
     // fill buffers
-    for( int i = 0; i < m_ChannelBufferNumber; ++i )
+    for(int i = 0; i < m_ChannelBufferNumber; ++i)
     {
     {
         ALsizei buffer_size = FillBuffer();
         ALsizei buffer_size = FillBuffer();
 
 
-        if( buffer_size )
+        if(buffer_size)
         {
         {
-            alBufferData( buffers[ i ], m_VorbisInfo->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, ( const ALvoid* )AudioManager::getSingleton().m_Buffer, ( ALsizei )buffer_size, ( ALsizei )m_VorbisInfo->rate );
-            alSourceQueueBuffers( m_Source, 1, &buffers[ i ] );
+            alBufferData(buffers[i], m_VorbisInfo->channels ==
+                         1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
+                         (const ALvoid*)AudioManager::getSingleton().m_Buffer,
+                         (ALsizei)buffer_size, (ALsizei)m_VorbisInfo->rate);
+            alSourceQueueBuffers(m_Source, 1, &buffers[i]);
         }
         }
         else
         else
         {
         {
             m_StreamFinished = true;
             m_StreamFinished = true;
-            alDeleteBuffers( 1, &buffers[ i ] );
+            alDeleteBuffers(1, &buffers[i]);
         }
         }
     }
     }
 
 
     // start playback
     // start playback
-    alSourcePlay( m_Source );
+    alSourcePlay(m_Source);
 }
 }
 
 
 
 
 void
 void
 AudioManager::Player::Stop()
 AudioManager::Player::Stop()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
 
     // stop source
     // stop source
-    alSourceStop( m_Source );
+    alSourceStop(m_Source);
 
 
     // get source buffers
     // get source buffers
     int queued_count = 0;
     int queued_count = 0;
-    alGetSourcei( m_Source, AL_BUFFERS_QUEUED, &queued_count );
+    alGetSourcei(m_Source, AL_BUFFERS_QUEUED, &queued_count);
 
 
     // unqueue and delete buffers
     // unqueue and delete buffers
-    for( int i = 0; i < queued_count; ++i )
+    for(int i = 0; i < queued_count; ++i)
     {
     {
         ALuint buffer_id;
         ALuint buffer_id;
-        alSourceUnqueueBuffers( m_Source, 1, &buffer_id );
-        alDeleteBuffers( 1, &buffer_id );
+        alSourceUnqueueBuffers(m_Source, 1, &buffer_id);
+        alDeleteBuffers(1, &buffer_id);
     }
     }
 
 
     // delete source
     // delete source
-    alDeleteSources( 1, &m_Source );
+    alDeleteSources(1, &m_Source);
 
 
     // rest cleanup
     // rest cleanup
-    ov_clear( &m_VorbisFile );
+    ov_clear(&m_VorbisFile);
 }
 }
 
 
 
 
-
 void
 void
-AudioManager::Player::SetLoop( const float loop )
+AudioManager::Player::SetLoop(const float loop)
 {
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
 
     m_Loop = loop;
     m_Loop = loop;
 }
 }
 
 
 
 
-
 void
 void
 AudioManager::Player::Update()
 AudioManager::Player::Update()
 {
 {
     // try to fill processed buffers
     // try to fill processed buffers
     {
     {
         int processed;
         int processed;
-        alGetSourcei( m_Source, AL_BUFFERS_PROCESSED, &processed );
+        alGetSourcei(m_Source, AL_BUFFERS_PROCESSED, &processed);
 
 
-        for( int i = 0; i < processed; ++i )
+        for(int i = 0; i < processed; ++i)
         {
         {
             // try fill buffer
             // try fill buffer
             ALsizei buffer_size = FillBuffer();
             ALsizei buffer_size = FillBuffer();
 
 
-            if( buffer_size )
+            if(buffer_size)
             {
             {
                 ALuint buffer_id;
                 ALuint buffer_id;
-                alSourceUnqueueBuffers( m_Source, 1, &buffer_id );
-                alBufferData( buffer_id, m_VorbisInfo->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, ( const ALvoid* )AudioManager::getSingleton().m_Buffer, ( ALsizei )buffer_size, ( ALsizei )m_VorbisInfo->rate );
-                alSourceQueueBuffers( m_Source, 1, &buffer_id );
+                alSourceUnqueueBuffers(m_Source, 1, &buffer_id);
+                alBufferData(buffer_id, m_VorbisInfo->channels ==
+                             1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
+                             (const ALvoid*)AudioManager::getSingleton().m_Buffer,
+                             (ALsizei)buffer_size, (ALsizei)m_VorbisInfo->rate);
+                alSourceQueueBuffers(m_Source, 1, &buffer_id);
             }
             }
             // finished reading stream
             // finished reading stream
             else
             else
@@ -368,35 +353,34 @@ AudioManager::Player::Update()
     // manage source state
     // manage source state
     {
     {
         int processed;
         int processed;
-        alGetSourcei( m_Source, AL_BUFFERS_PROCESSED, &processed );
+        alGetSourcei(m_Source, AL_BUFFERS_PROCESSED, &processed);
 
 
         int queued;
         int queued;
-        alGetSourcei( m_Source, AL_BUFFERS_QUEUED, &queued );
+        alGetSourcei(m_Source, AL_BUFFERS_QUEUED, &queued);
 
 
-        if( m_StreamFinished && processed == queued )
+        if(m_StreamFinished && processed == queued)
         {
         {
             Stop();
             Stop();
         }
         }
         else
         else
         {
         {
             ALenum source_state;
             ALenum source_state;
-            alGetSourcei( m_Source, AL_SOURCE_STATE, &source_state );
-            if( source_state == AL_STOPPED )
+            alGetSourcei(m_Source, AL_SOURCE_STATE, &source_state);
+            if(source_state == AL_STOPPED)
             {
             {
-                alSourcePlay( m_Source );
+                alSourcePlay(m_Source);
             }
             }
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 ALsizei
 ALsizei
 AudioManager::Player::FillBuffer()
 AudioManager::Player::FillBuffer()
 {
 {
     ALsizei read = 0;
     ALsizei read = 0;
 
 
-    if( m_StreamFinished )
+    if(m_StreamFinished)
     {
     {
         return read;
         return read;
     }
     }
@@ -406,9 +390,11 @@ AudioManager::Player::FillBuffer()
     bool finished = false;
     bool finished = false;
     do
     do
     {
     {
-        long result = ov_read( &m_VorbisFile, buffer + read, m_ChannelBufferSize - read, 0, 2, 1, &m_VorbisSection );
+        long result = ov_read(&m_VorbisFile, buffer + read,
+                              m_ChannelBufferSize - read, 0, 2, 1,
+                              &m_VorbisSection);
 
 
-        switch( result )
+        switch(result)
         {
         {
             // error
             // error
             case OV_HOLE:
             case OV_HOLE:
@@ -423,7 +409,7 @@ AudioManager::Player::FillBuffer()
             case 0:
             case 0:
             {
             {
                 // if there isn't loop point or can't seek
                 // if there isn't loop point or can't seek
-                if( m_Loop < 0.0f || ov_time_seek( &m_VorbisFile, m_Loop ) )
+                if(m_Loop < 0.0f || ov_time_seek(&m_VorbisFile, m_Loop))
                 {
                 {
                     finished = true;
                     finished = true;
                 }
                 }
@@ -434,54 +420,28 @@ AudioManager::Player::FillBuffer()
             default:
             default:
             {
             {
                 read += result;
                 read += result;
-                if( read == m_ChannelBufferSize )
+                if(read == m_ChannelBufferSize)
                 {
                 {
                     finished = true;
                     finished = true;
                 }
                 }
             }
             }
         }
         }
     }
     }
-    while( finished == false );
+    while(finished == false);
 
 
     return read;
     return read;
 }
 }
 
 
 
 
-
 float
 float
 AudioManager::Player::GetPosition()
 AudioManager::Player::GetPosition()
 {
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
 
     int play_offset;
     int play_offset;
-    alGetSourcei( m_Source, AL_SAMPLE_OFFSET, &play_offset );
-    return ( ov_pcm_tell( &m_VorbisFile ) - ( m_ChannelBufferNumber * m_ChannelBufferSize / m_VorbisInfo->channels / sizeof( int16_t ) - play_offset ) ) * 1000 / m_VorbisInfo->rate;
+    alGetSourcei(m_Source, AL_SAMPLE_OFFSET, &play_offset);
+    return (ov_pcm_tell(&m_VorbisFile) -
+            (m_ChannelBufferNumber * m_ChannelBufferSize /
+             m_VorbisInfo->channels / sizeof(int16_t) -
+             play_offset)) * 1000 / m_VorbisInfo->rate;
 }
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 255 - 262
QGearsMain/src/core/Background2D.cpp


+ 35 - 38
QGearsMain/src/core/Background2DAnimation.cpp

@@ -1,110 +1,109 @@
-#include "core/Background2DAnimation.h"
-
 #include <OgreVector2.h>
 #include <OgreVector2.h>
 
 
+#include "core/Background2DAnimation.h"
 #include "core/Background2D.h"
 #include "core/Background2D.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 
 
 
 
-
-//------------------------------------------------------------------------------
-Background2DAnimation::Background2DAnimation( const Ogre::String& name, Background2D* background, const int tile_index ):
-    m_Name( name ),
-    m_Background( background ),
-    m_TileIndex( tile_index ),
-    m_Time( 0 ),
-    m_Length( 0 )
+Background2DAnimation::Background2DAnimation(const Ogre::String& name, Background2D* background, const int tile_index):
+    m_Name(name),
+    m_Background(background),
+    m_TileIndex(tile_index),
+    m_Time(0),
+    m_Length(0)
 {
 {
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 Background2DAnimation::~Background2DAnimation()
 Background2DAnimation::~Background2DAnimation()
 {
 {
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::AddTime( const float time )
+Background2DAnimation::AddTime(const float time)
 {
 {
     m_Time += time;
     m_Time += time;
-    if( m_Time > m_Length )
+    if(m_Time > m_Length)
     {
     {
         m_Time = m_Length;
         m_Time = m_Length;
     }
     }
 
 
-    if( m_UV.size() > 0 )
+    if(m_UV.size() > 0)
     {
     {
         int min_id = -1;
         int min_id = -1;
         float min_time = 0;
         float min_time = 0;
 
 
-        for( unsigned int i = 0; i < m_UV.size(); ++i )
+        for(unsigned int i = 0; i < m_UV.size(); ++i)
         {
         {
-            if( m_UV[ i ].time <= m_Time && m_UV[ i ].time >= min_time )
+            if(m_UV[i].time <= m_Time && m_UV[i].time >= min_time)
             {
             {
                 min_id = i;
                 min_id = i;
-                min_time = m_UV[ i ].time;
+                min_time = m_UV[i].time;
             }
             }
         }
         }
 
 
-        if( min_id != -1 )
+        if(min_id != -1)
         {
         {
-            m_Background->UpdateTileUV( m_TileIndex, m_UV[ min_id ].u1, m_UV[ min_id ].v1, m_UV[ min_id ].u2, m_UV[ min_id ].v2 );
+            m_Background->UpdateTileUV(m_TileIndex,
+                                       m_UV[min_id].u1, m_UV[min_id].v1,
+                                       m_UV[min_id].u2, m_UV[min_id].v2);
         }
         }
     }
     }
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 const Ogre::String&
 const Ogre::String&
 Background2DAnimation::GetName() const
 Background2DAnimation::GetName() const
 {
 {
     return m_Name;
     return m_Name;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::SetTime( const float time )
+Background2DAnimation::SetTime(const float time)
 {
 {
     m_Time = time;
     m_Time = time;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 float
 float
 Background2DAnimation::GetTime() const
 Background2DAnimation::GetTime() const
 {
 {
     return m_Time;
     return m_Time;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::SetLength( const float time )
+Background2DAnimation::SetLength(const float time)
 {
 {
     m_Length = time;
     m_Length = time;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 float
 float
 Background2DAnimation::GetLength() const
 Background2DAnimation::GetLength() const
 {
 {
     return m_Length;
     return m_Length;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::AddUVKeyFrame( const QGears::KeyFrame key_frame )
+Background2DAnimation::AddUVKeyFrame(const QGears::KeyFrame key_frame)
 {
 {
-    AddUVKeyFrame( key_frame.time, key_frame.uv );
+    AddUVKeyFrame(key_frame.time, key_frame.uv);
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::AddUVKeyFrame( const float time, const Ogre::Vector4& uv )
+Background2DAnimation::AddUVKeyFrame(const float time, const Ogre::Vector4& uv)
 {
 {
-    AddUVKeyFrame( time, uv.x, uv.y, uv.z, uv.w );
+    AddUVKeyFrame(time, uv.x, uv.y, uv.z, uv.w);
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void
 void
-Background2DAnimation::AddUVKeyFrame( const float time, const float u1, const float v1, const float u2, const float v2 )
+Background2DAnimation::AddUVKeyFrame(const float time, const float u1, const float v1, const float u2, const float v2)
 {
 {
     Background2DKeyFrameUV uv_key_frame;
     Background2DKeyFrameUV uv_key_frame;
     uv_key_frame.time = time;
     uv_key_frame.time = time;
@@ -112,7 +111,5 @@ Background2DAnimation::AddUVKeyFrame( const float time, const float u1, const fl
     uv_key_frame.v1 = v1;
     uv_key_frame.v1 = v1;
     uv_key_frame.u2 = u2;
     uv_key_frame.u2 = u2;
     uv_key_frame.v2 = v2;
     uv_key_frame.v2 = v2;
-    m_UV.push_back( uv_key_frame );
+    m_UV.push_back(uv_key_frame);
 }
 }
-
-//------------------------------------------------------------------------------

+ 67 - 73
QGearsMain/src/core/CameraManager.cpp

@@ -1,158 +1,154 @@
-#include "core/CameraManager.h"
-#include "core/CameraManagerCommands.h"
-
 #include <OgreRenderWindow.h>
 #include <OgreRenderWindow.h>
 #include <OgreRoot.h>
 #include <OgreRoot.h>
 #include <OIS.h>
 #include <OIS.h>
 
 
+#include "core/CameraManager.h"
+#include "core/CameraManagerCommands.h"
 #include "common/QGearsApplication.h"
 #include "common/QGearsApplication.h"
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
 #include "core/InputManager.h"
 #include "core/InputManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 
 
 
 
-
-ConfigVar cv_cam_speed( "camera_speed", "Camera speed", "0.02" );
-
-
-
-template<>CameraManager* Ogre::Singleton< CameraManager >::msSingleton = NULL;
-
+ConfigVar cv_cam_speed("camera_speed", "Camera speed", "0.02");
+template<>CameraManager* Ogre::Singleton<CameraManager>::msSingleton = nullptr;
 
 
 
 
 CameraManager::CameraManager():
 CameraManager::CameraManager():
-    m_CameraFree( false ),
-    m_CameraFreeRotate( false ),
+    m_CameraFree(false),
+    m_CameraFreeRotate(false),
 
 
-    m_2DPosition( Ogre::Vector3::ZERO ),
-    m_2DOrientation( Ogre::Quaternion::ZERO ),
-    m_2DFOV( 0 ),
-    m_2DScroll( Ogre::Vector2::ZERO )
+    m_2DPosition(Ogre::Vector3::ZERO),
+    m_2DOrientation(Ogre::Quaternion::ZERO),
+    m_2DFOV(0),
+    m_2DScroll(Ogre::Vector2::ZERO)
 {
 {
-    LOG_TRIVIAL( "CameraManager started." );
+    LOG_TRIVIAL("CameraManager started.");
 
 
     InitCommands();
     InitCommands();
 
 
-    m_Camera = Ogre::Root::getSingleton().getSceneManager( "Scene" )->createCamera( "Camera" );
-    m_Camera->setNearClipDistance( 0.001f );
-    m_Camera->setFarClipDistance( 1000.0f );
-    m_Camera->setPosition( Ogre::Vector3( 0, 0, 0 ) );
-    m_Camera->lookAt( Ogre::Vector3( 0, 0, 0 ) );
-    m_Viewport = QGears::Application::getSingleton().getRenderWindow()->addViewport( m_Camera, 0 );
-    m_Viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 0 ) );
-    m_Camera->setAspectRatio( Ogre::Real( m_Viewport->getActualWidth() ) / Ogre::Real( m_Viewport->getActualHeight() ) );
+    m_Camera = Ogre::Root::getSingleton().getSceneManager("Scene")->createCamera("Camera");
+    m_Camera->setNearClipDistance(0.001f);
+    m_Camera->setFarClipDistance(1000.0f);
+    m_Camera->setPosition(Ogre::Vector3(0, 0, 0));
+    m_Camera->lookAt(Ogre::Vector3(0, 0, 0));
+    m_Viewport = QGears::Application::getSingleton().getRenderWindow()->addViewport(m_Camera, 0);
+    m_Viewport->setBackgroundColour(Ogre::ColourValue(0, 0, 0));
+    m_Camera->setAspectRatio(Ogre::Real(m_Viewport->getActualWidth()) / Ogre::Real(m_Viewport->getActualHeight()));
 }
 }
 
 
 
 
-
 CameraManager::~CameraManager()
 CameraManager::~CameraManager()
 {
 {
-    LOG_TRIVIAL( "CameraManager finished." );
+    LOG_TRIVIAL("CameraManager finished.");
 }
 }
 
 
 
 
-
 void
 void
 CameraManager::Input(const QGears::Event& event, Ogre::Real timeSinceLastFrame)
 CameraManager::Input(const QGears::Event& event, Ogre::Real timeSinceLastFrame)
 {
 {
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
     {
         float speed = cv_cam_speed.GetF() * timeSinceLastFrame;
         float speed = cv_cam_speed.GetF() * timeSinceLastFrame;
-        if( InputManager::getSingleton().IsButtonPressed( OIS::KC_RSHIFT ) || InputManager::getSingleton().IsButtonPressed( OIS::KC_LSHIFT ) )
+        if(InputManager::getSingleton().IsButtonPressed(OIS::KC_RSHIFT)
+                || InputManager::getSingleton().IsButtonPressed(OIS::KC_LSHIFT))
         {
         {
             speed *= 4;
             speed *= 4;
         }
         }
 
 
         if (event.type == QGears::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 ) );
+            m_Camera->moveRelative(Ogre::Vector3(0, 0, -speed));
         }
         }
-        else if (event.type == QGears::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 ) );
+            m_Camera->moveRelative(Ogre::Vector3(-speed, 0, 0));
         }
         }
-        else if (event.type == QGears::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 ) );
+            m_Camera->moveRelative(Ogre::Vector3(0, 0, speed));
         }
         }
-        else if (event.type == QGears::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 ) );
+            m_Camera->moveRelative(Ogre::Vector3(speed, 0, 0));
         }
         }
-        else if (event.type == QGears::ET_MOUSE_PRESS && event.param1 == OIS::MB_Right)
+        else if (event.type == QGears::ET_MOUSE_PRESS
+                 && event.param1 == OIS::MB_Right)
         {
         {
             m_CameraFreeRotate = true;
             m_CameraFreeRotate = true;
         }
         }
-        else if (event.type == QGears::ET_MOUSE_RELEASE && event.param1 == OIS::MB_Right)
+        else if (event.type == QGears::ET_MOUSE_RELEASE
+                 && event.param1 == OIS::MB_Right)
         {
         {
             m_CameraFreeRotate = false;
             m_CameraFreeRotate = false;
         }
         }
-        else if (event.type == QGears::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.13f ) ) );
-            m_Camera->pitch( Ogre::Degree( -event.param2 * 0.13f ) );
+            m_Camera->rotate(Ogre::Vector3::UNIT_Z,
+                             Ogre::Radian(Ogre::Degree(-event.param1 * 0.13f)));
+            m_Camera->pitch(Ogre::Degree(-event.param2 * 0.13f));
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 CameraManager::Update()
 CameraManager::Update()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 CameraManager::OnResize()
 CameraManager::OnResize()
 {
 {
-    m_Camera->setAspectRatio( Ogre::Real( m_Viewport->getActualWidth() ) / Ogre::Real( m_Viewport->getActualHeight() ) );
+    m_Camera->setAspectRatio(Ogre::Real(m_Viewport->getActualWidth())
+                             / Ogre::Real(m_Viewport->getActualHeight()));
 }
 }
 
 
 
 
-
 void
 void
-CameraManager::SetCameraFree( const bool enable )
+CameraManager::SetCameraFree(const bool enable)
 {
 {
     m_CameraFree = enable;
     m_CameraFree = enable;
 
 
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
     {
         m_Camera->resetFrustumExtents();
         m_Camera->resetFrustumExtents();
-        CameraManager::getSingleton().GetCurrentCamera()->setFOVy( Ogre::Radian( Ogre::Math::PI / 4.0f ) );
+        CameraManager::getSingleton().GetCurrentCamera()->setFOVy(Ogre::Radian(Ogre::Math::PI / 4.0f));
     }
     }
     else
     else
     {
     {
-        CameraManager::getSingleton().GetCurrentCamera()->setPosition( m_2DPosition );
-        CameraManager::getSingleton().GetCurrentCamera()->setOrientation( m_2DOrientation );
-        CameraManager::getSingleton().GetCurrentCamera()->setFOVy( m_2DFOV );
-        Set2DScroll( Get2DScroll() );
+        CameraManager::getSingleton().GetCurrentCamera()->setPosition(m_2DPosition);
+        CameraManager::getSingleton().GetCurrentCamera()->setOrientation(m_2DOrientation);
+        CameraManager::getSingleton().GetCurrentCamera()->setFOVy(m_2DFOV);
+        Set2DScroll(Get2DScroll());
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-CameraManager::Set2DCamera( const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov )
+CameraManager::Set2DCamera(const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov)
 {
 {
     m_2DPosition = position;
     m_2DPosition = position;
     m_2DOrientation = orientation;
     m_2DOrientation = orientation;
     m_2DFOV = fov;
     m_2DFOV = fov;
-    CameraManager::getSingleton().GetCurrentCamera()->setPosition( m_2DPosition );
-    CameraManager::getSingleton().GetCurrentCamera()->setOrientation( m_2DOrientation );
-    CameraManager::getSingleton().GetCurrentCamera()->setFOVy( m_2DFOV );
-    Set2DScroll( Ogre::Vector2::ZERO );
+    CameraManager::getSingleton().GetCurrentCamera()->setPosition(m_2DPosition);
+    CameraManager::getSingleton().GetCurrentCamera()->setOrientation(m_2DOrientation);
+    CameraManager::getSingleton().GetCurrentCamera()->setFOVy(m_2DFOV);
+    Set2DScroll(Ogre::Vector2::ZERO);
 }
 }
 
 
 
 
-
 void
 void
-CameraManager::Set2DScroll( const Ogre::Vector2& position )
+CameraManager::Set2DScroll(const Ogre::Vector2& position)
 {
 {
     m_2DScroll = position;
     m_2DScroll = position;
 
 
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
     {
         return;
         return;
     }
     }
@@ -161,14 +157,14 @@ CameraManager::Set2DScroll( const Ogre::Vector2& position )
     float height = static_cast<float>(m_Viewport->getActualHeight());
     float height = static_cast<float>(m_Viewport->getActualHeight());
     float left, right, top, bottom;
     float left, right, top, bottom;
     m_Camera->resetFrustumExtents();
     m_Camera->resetFrustumExtents();
-    m_Camera->getFrustumExtents( left, right, top, bottom );
-    float move_x = ( ( right - left ) / width ) * position.x;
-    float move_y = ( ( bottom - top ) / height ) * -position.y;
-    m_Camera->setFrustumExtents( left - move_x, right - move_x, top + move_y, bottom + move_y );
+    m_Camera->getFrustumExtents(left, right, top, bottom);
+    float move_x = ((right - left) / width) * position.x;
+    float move_y = ((bottom - top) / height) * -position.y;
+    m_Camera->setFrustumExtents(left - move_x, right - move_x,
+                                top + move_y, bottom + move_y);
 }
 }
 
 
 
 
-
 const Ogre::Vector2&
 const Ogre::Vector2&
 CameraManager::Get2DScroll() const
 CameraManager::Get2DScroll() const
 {
 {
@@ -176,9 +172,8 @@ CameraManager::Get2DScroll() const
 }
 }
 
 
 
 
-
 const Ogre::Vector3
 const Ogre::Vector3
-CameraManager::ProjectPointToScreen( const Ogre::Vector3& point )
+CameraManager::ProjectPointToScreen(const Ogre::Vector3& point)
 {
 {
     Ogre::Vector3 view = m_Camera->getViewMatrix() * point;
     Ogre::Vector3 view = m_Camera->getViewMatrix() * point;
     float z = view.z;
     float z = view.z;
@@ -195,24 +190,23 @@ CameraManager::ProjectPointToScreen( const Ogre::Vector3& point )
 }
 }
 
 
 
 
-
 Ogre::Camera*
 Ogre::Camera*
 CameraManager::GetCurrentCamera()
 CameraManager::GetCurrentCamera()
 {
 {
     return m_Camera;
     return m_Camera;
 }
 }
 
 
-//--------------------------------------------------------------------------
+
 Ogre::Viewport*
 Ogre::Viewport*
 CameraManager::getViewport()
 CameraManager::getViewport()
 {
 {
     return m_Viewport;
     return m_Viewport;
 }
 }
 
 
-//--------------------------------------------------------------------------
+
 void CameraManager::EnableWireFrame(bool)
 void CameraManager::EnableWireFrame(bool)
 {
 {
-    if ( m_Camera )
+    if (m_Camera)
     {
     {
         //m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);
         //m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);
         //    m_Camera->rotate( Ogre::Vector3::UNIT_Z, Ogre::Radian( Ogre::Degree( 180 ) ) );
         //    m_Camera->rotate( Ogre::Vector3::UNIT_Z, Ogre::Radian( Ogre::Degree( 180 ) ) );

+ 0 - 6
QGearsMain/src/core/ConfigCmd.cpp

@@ -1,7 +1,6 @@
 #include "core/ConfigCmd.h"
 #include "core/ConfigCmd.h"
 
 
 
 
-
 ConfigCmd::ConfigCmd(const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion):
 ConfigCmd::ConfigCmd(const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion):
     m_Name(name),
     m_Name(name),
     m_Description(description),
     m_Description(description),
@@ -12,7 +11,6 @@ ConfigCmd::ConfigCmd(const Ogre::String& name, const Ogre::String& description,
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigCmd::GetName() const
 ConfigCmd::GetName() const
 {
 {
@@ -20,7 +18,6 @@ ConfigCmd::GetName() const
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigCmd::GetDescription() const
 ConfigCmd::GetDescription() const
 {
 {
@@ -28,7 +25,6 @@ ConfigCmd::GetDescription() const
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigCmd::GetParamsDescription() const
 ConfigCmd::GetParamsDescription() const
 {
 {
@@ -36,7 +32,6 @@ ConfigCmd::GetParamsDescription() const
 }
 }
 
 
 
 
-
 ConfigCmdHandler
 ConfigCmdHandler
 ConfigCmd::GetHandler() const
 ConfigCmd::GetHandler() const
 {
 {
@@ -44,7 +39,6 @@ ConfigCmd::GetHandler() const
 }
 }
 
 
 
 
-
 ConfigCmdCompletion
 ConfigCmdCompletion
 ConfigCmd::GetCompletion() const
 ConfigCmd::GetCompletion() const
 {
 {

+ 17 - 25
QGearsMain/src/core/ConfigCmdManager.cpp

@@ -1,12 +1,10 @@
+#include "common/make_unique.h"
+#include "core/Assert.h"
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigCmdManagerCommands.h"
 #include "core/ConfigCmdManagerCommands.h"
 
 
-#include "core/Assert.h"
-#include "common/make_unique.h"
-
-
-template<>ConfigCmdManager *Ogre::Singleton< ConfigCmdManager >::msSingleton = NULL;
 
 
+template<>ConfigCmdManager *Ogre::Singleton<ConfigCmdManager>::msSingleton = nullptr;
 
 
 
 
 ConfigCmdManager::ConfigCmdManager()
 ConfigCmdManager::ConfigCmdManager()
@@ -15,53 +13,48 @@ ConfigCmdManager::ConfigCmdManager()
 }
 }
 
 
 
 
-
 ConfigCmdManager::~ConfigCmdManager()
 ConfigCmdManager::~ConfigCmdManager()
 {
 {
 
 
 }
 }
 
 
 
 
-
 void
 void
-ConfigCmdManager::AddCommand( const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion )
+ConfigCmdManager::AddCommand(const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion)
 {
 {
-    QGEARS_ASSERT( name != "", "Command name shouldn't be empty." );
-    QGEARS_ASSERT( handler, "Null command handler." );
+    QGEARS_ASSERT(name != "", "Command name shouldn't be empty.");
+    QGEARS_ASSERT(handler, "Null command handler.");
 
 
     // see if command already added
     // see if command already added
-    for( unsigned int i = 0; i < m_Commands.size(); ++i )
+    for(unsigned int i = 0; i < m_Commands.size(); ++i)
     {
     {
-        QGEARS_ASSERT( m_Commands[ i ]->GetName() != name, "Command already exist." );
+        QGEARS_ASSERT(m_Commands[i]->GetName() != name, "Command already exist.");
     }
     }
 
 
-    m_Commands.emplace_back( std::make_unique<ConfigCmd>( name, description, params_description, handler, completion ) );
+    m_Commands.emplace_back(std::make_unique<ConfigCmd>(name, description, params_description, handler, completion));
 }
 }
 
 
 
 
-
 void
 void
-ConfigCmdManager::ExecuteString( const Ogre::String& cmd_string )
+ConfigCmdManager::ExecuteString(const Ogre::String& cmd_string)
 {
 {
 }
 }
 
 
 
 
-
 ConfigCmd*
 ConfigCmd*
-ConfigCmdManager::Find( const Ogre::String& name ) const
+ConfigCmdManager::Find(const Ogre::String& name) const
 {
 {
-    for( unsigned int i = 0; i < m_Commands.size(); ++i )
+    for(unsigned int i = 0; i < m_Commands.size(); ++i)
     {
     {
-        if( m_Commands[ i ]->GetName() == name )
+        if(m_Commands[i]->GetName() == name)
         {
         {
-            return m_Commands[ i ].get();
+            return m_Commands[i].get();
         }
         }
     }
     }
     return nullptr;
     return nullptr;
 }
 }
 
 
 
 
-
 int
 int
 ConfigCmdManager::GetConfigCmdNumber()
 ConfigCmdManager::GetConfigCmdNumber()
 {
 {
@@ -69,13 +62,12 @@ ConfigCmdManager::GetConfigCmdNumber()
 }
 }
 
 
 
 
-
 ConfigCmd*
 ConfigCmd*
-ConfigCmdManager::GetConfigCmd( unsigned int i ) const
+ConfigCmdManager::GetConfigCmd(unsigned int i) const
 {
 {
-    if( i < m_Commands.size() )
+    if(i < m_Commands.size())
     {
     {
-        return m_Commands[ i ].get();
+        return m_Commands[i].get();
     }
     }
 
 
     return nullptr;
     return nullptr;

+ 23 - 25
QGearsMain/src/core/ConfigFile.cpp

@@ -1,78 +1,76 @@
-#include "core/ConfigFile.h"
-
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigCmdManager.h"
+#include "core/ConfigFile.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/Utilites.h"
 #include "core/Utilites.h"
 
 
 
 
-
 void
 void
-ConfigFile::Execute( const Ogre::String& name )
+ConfigFile::Execute(const Ogre::String& name)
 {
 {
     // Open the configuration file
     // Open the configuration file
     std::ifstream fp;
     std::ifstream fp;
     // Always open in binary mode
     // Always open in binary mode
-    fp.open( name.c_str(), std::ios::in | std::ios::binary );
-    if( !fp )
+    fp.open(name.c_str(), std::ios::in | std::ios::binary);
+    if(!fp)
     {
     {
-        LOG_WARNING( "Config file\"" + name + "\" not found!" );
+        LOG_WARNING("Config file\"" + name + "\" not found!");
     }
     }
     else
     else
     {
     {
         Ogre::String command = "";
         Ogre::String command = "";
 
 
-        while( true )
+        while(true)
         {
         {
             char c = fp.get(); // get character from file
             char c = fp.get(); // get character from file
-            if( fp.good() == false )
+            if(fp.good() == false)
             {
             {
                 break;
                 break;
             }
             }
 
 
-            if( c == '\r' || ( c == '\n' && command.size() == 0 ) )
+            if(c == '\r' || (c == '\n' && command.size() == 0))
             {
             {
             }
             }
-            else if( c == '\n' && command.size() > 0 )
+            else if(c == '\n' && command.size() > 0)
             {
             {
-                Ogre::StringVector params = StringTokenise( command );
+                Ogre::StringVector params = StringTokenise(command);
 
 
-                if( params.size() > 0 )
+                if(params.size() > 0)
                 {
                 {
                     // handle command
                     // handle command
-                    ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-                    if( cmd != NULL )
+                    ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+                    if(cmd != nullptr)
                     {
                     {
-                        cmd->GetHandler()( params );
+                        cmd->GetHandler()(params);
                     }
                     }
                     else
                     else
                     {
                     {
-                        LOG_ERROR( "Can't find command \"" + params[ 0 ] + "\"." );
+                        LOG_ERROR("Can't find command \"" + params[0] + "\".");
                     }
                     }
                 }
                 }
 
 
                 command = "";
                 command = "";
             }
             }
-            else if( c >= 0 ) // use only ascii characters
+            else if(c >= 0) // use only ascii characters
             {
             {
                 command += c;
                 command += c;
             }
             }
         }
         }
 
 
-        if( command.size() > 0 )
+        if(command.size() > 0)
         {
         {
-            Ogre::StringVector params = StringTokenise( command );
+            Ogre::StringVector params = StringTokenise(command);
 
 
-            if( params.size() > 0 )
+            if(params.size() > 0)
             {
             {
-                ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
+                ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
 
 
-                if( cmd != NULL )
+                if(cmd != nullptr)
                 {
                 {
-                    cmd->GetHandler()( params );
+                    cmd->GetHandler()(params);
                 }
                 }
                 else
                 else
                 {
                 {
-                    LOG_ERROR( "Can't find command \"" + params[ 0 ] + "\"." );
+                    LOG_ERROR("Can't find command \"" + params[0] + "\".");
                 }
                 }
             }
             }
         }
         }

+ 2 - 16
QGearsMain/src/core/ConfigVar.cpp

@@ -1,13 +1,10 @@
-#include "core/ConfigVar.h"
-
 #include <OgreStringConverter.h>
 #include <OgreStringConverter.h>
 
 
 #include "core/Assert.h"
 #include "core/Assert.h"
+#include "core/ConfigVar.h"
 
 
 
 
-
-ConfigVar* ConfigVar::m_StaticConfigVarList = NULL;
-
+ConfigVar* ConfigVar::m_StaticConfigVarList = nullptr;
 
 
 
 
 ConfigVar::ConfigVar(const Ogre::String& name, const Ogre::String& description, const Ogre::String& default_value):
 ConfigVar::ConfigVar(const Ogre::String& name, const Ogre::String& description, const Ogre::String& default_value):
@@ -35,7 +32,6 @@ ConfigVar::ConfigVar(const Ogre::String& name, const Ogre::String& description,
 }
 }
 
 
 
 
-
 int
 int
 ConfigVar::GetI() const
 ConfigVar::GetI() const
 {
 {
@@ -43,7 +39,6 @@ ConfigVar::GetI() const
 }
 }
 
 
 
 
-
 float
 float
 ConfigVar::GetF() const
 ConfigVar::GetF() const
 {
 {
@@ -51,7 +46,6 @@ ConfigVar::GetF() const
 }
 }
 
 
 
 
-
 bool
 bool
 ConfigVar::GetB() const
 ConfigVar::GetB() const
 {
 {
@@ -59,7 +53,6 @@ ConfigVar::GetB() const
 }
 }
 
 
 
 
-
 Ogre::String
 Ogre::String
 ConfigVar::GetS() const
 ConfigVar::GetS() const
 {
 {
@@ -76,7 +69,6 @@ ConfigVar::SetI(int value)
 }
 }
 
 
 
 
-
 void
 void
 ConfigVar::SetF(float value)
 ConfigVar::SetF(float value)
 {
 {
@@ -85,7 +77,6 @@ ConfigVar::SetF(float value)
 }
 }
 
 
 
 
-
 void
 void
 ConfigVar::SetB(bool value)
 ConfigVar::SetB(bool value)
 {
 {
@@ -94,7 +85,6 @@ ConfigVar::SetB(bool value)
 }
 }
 
 
 
 
-
 void
 void
 ConfigVar::SetS(const Ogre::String& value)
 ConfigVar::SetS(const Ogre::String& value)
 {
 {
@@ -103,7 +93,6 @@ ConfigVar::SetS(const Ogre::String& value)
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigVar::GetName() const
 ConfigVar::GetName() const
 {
 {
@@ -111,7 +100,6 @@ ConfigVar::GetName() const
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigVar::GetDescription() const
 ConfigVar::GetDescription() const
 {
 {
@@ -119,7 +107,6 @@ ConfigVar::GetDescription() const
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 ConfigVar::GetDefaultValue() const
 ConfigVar::GetDefaultValue() const
 {
 {
@@ -127,7 +114,6 @@ ConfigVar::GetDefaultValue() const
 }
 }
 
 
 
 
-
 void
 void
 ConfigVar::UpdateVariables()
 ConfigVar::UpdateVariables()
 {
 {

+ 14 - 19
QGearsMain/src/core/ConfigVarManager.cpp

@@ -1,42 +1,38 @@
 #include "core/ConfigVarManager.h"
 #include "core/ConfigVarManager.h"
 
 
 
 
-
-template<>ConfigVarManager *Ogre::Singleton< ConfigVarManager >::msSingleton = NULL;
-
+template<>ConfigVarManager *Ogre::Singleton<ConfigVarManager>::msSingleton = nullptr;
 
 
 
 
 ConfigVarManager::ConfigVarManager()
 ConfigVarManager::ConfigVarManager()
 {
 {
-    if( ConfigVar::m_StaticConfigVarList != ( ConfigVar* )0xffffffff )
+    if(ConfigVar::m_StaticConfigVarList != (ConfigVar*)0xffffffff)
     {
     {
-        for( ConfigVar* cvar = ConfigVar::m_StaticConfigVarList; cvar; cvar = cvar->m_Previous )
+        for(ConfigVar* cvar = ConfigVar::m_StaticConfigVarList; cvar; cvar = cvar->m_Previous)
         {
         {
-            m_ConfigVars.push_back( cvar );
+            m_ConfigVars.push_back(cvar);
         }
         }
 
 
-        ConfigVar::m_StaticConfigVarList = ( ConfigVar* )0xffffffff;
+        ConfigVar::m_StaticConfigVarList = (ConfigVar*)0xffffffff;
     }
     }
 }
 }
 
 
 
 
-
 ConfigVar*
 ConfigVar*
-ConfigVarManager::Find( const Ogre::String& name ) const
+ConfigVarManager::Find(const Ogre::String& name) const
 {
 {
-    for( size_t i = 0; i < m_ConfigVars.size(); ++i )
+    for(size_t i = 0; i < m_ConfigVars.size(); ++i)
     {
     {
-        if( m_ConfigVars[ i ]->GetName() == name )
+        if(m_ConfigVars[i]->GetName() == name)
         {
         {
-            return m_ConfigVars[ i ];
+            return m_ConfigVars[i];
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 unsigned int
 unsigned int
 ConfigVarManager::GetConfigVarNumber() const
 ConfigVarManager::GetConfigVarNumber() const
 {
 {
@@ -44,14 +40,13 @@ ConfigVarManager::GetConfigVarNumber() const
 }
 }
 
 
 
 
-
 ConfigVar*
 ConfigVar*
-ConfigVarManager::GetConfigVar( const unsigned int i ) const
+ConfigVarManager::GetConfigVar(const unsigned int i) const
 {
 {
-    if( i < m_ConfigVars.size() )
+    if(i < m_ConfigVars.size())
     {
     {
-        return m_ConfigVars[ i ];
+        return m_ConfigVars[i];
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }

+ 198 - 222
QGearsMain/src/core/Console.cpp

@@ -1,10 +1,9 @@
-#include "core/Console.h"
-
 #include <OgreRenderWindow.h>
 #include <OgreRenderWindow.h>
 
 
 #include "common/QGearsApplication.h"
 #include "common/QGearsApplication.h"
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigVarManager.h"
 #include "core/ConfigVarManager.h"
+#include "core/Console.h"
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
@@ -13,67 +12,61 @@
 #include <OgreFontManager.h>
 #include <OgreFontManager.h>
 
 
 
 
-template<>Console *Ogre::Singleton< Console >::msSingleton = NULL;
-
-
-
-ConfigVar cv_console_notification( "console_notification", "Draw console strings even when console is hided", "false" );
-
+template<>Console *Ogre::Singleton<Console>::msSingleton = nullptr;
+ConfigVar cv_console_notification("console_notification", "Draw console strings even when console is hided", "false");
 
 
 
 
 Console::Console():
 Console::Console():
-    m_ToVisible( false ),
-    m_Visible( false ),
-    m_Height( 0 ),
+    m_ToVisible(false),
+    m_Visible(false),
+    m_Height(0),
 
 
-    m_MaxOutputLine( 128 ),
-    m_DisplayLine( 0 ),
-    m_InputLine( "" ),
-    m_CursorPosition( 0 ),
-    m_CursorBlinkTime( 0 ),
+    m_MaxOutputLine(128),
+    m_DisplayLine(0),
+    m_InputLine(""),
+    m_CursorPosition(0),
+    m_CursorBlinkTime(0),
 
 
-    m_HistoryLine( -1 ),
-    m_HistorySize( 32 ),
+    m_HistoryLine(-1),
+    m_HistorySize(32),
 
 
-    m_AutoCompletitionLine( 0 )
+    m_AutoCompletitionLine(0)
 {
 {
 
 
-    Ogre::FontPtr font = Ogre::FontManager::getSingleton().getByName( "CourierNew" );
-    if( font.isNull() == false )
+    Ogre::FontPtr font = Ogre::FontManager::getSingleton().getByName("CourierNew");
+    if(font.isNull() == false)
     {
     {
-        m_LetterWidth = static_cast<int>(font->getGlyphAspectRatio( '_' ) * 16);
+        m_LetterWidth = static_cast<int>(font->getGlyphAspectRatio('_') * 16);
     }
     }
     else
     else
     {
     {
-        LOG_ERROR( "Console::frameStarted: Font for console not found." );
+        LOG_ERROR("Console::frameStarted: Font for console not found.");
     }
     }
 
 
     // calculate width and height of console depending on size of application
     // calculate width and height of console depending on size of application
-    Ogre::RenderTarget *render_target( QGears::Application::getSingleton().getRenderWindow() );
+    Ogre::RenderTarget *render_target(QGears::Application::getSingleton().getRenderWindow());
     m_ConsoleWidth = render_target->getWidth();
     m_ConsoleWidth = render_target->getWidth();
     m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
     m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
-    m_LineWidth = ( m_ConsoleWidth - 20 ) / 8;
+    m_LineWidth = (m_ConsoleWidth - 20) / 8;
 
 
-    LOG_TRIVIAL( "Created console width " + Ogre::StringConverter::toString( m_ConsoleWidth ) + ", height " + Ogre::StringConverter::toString( m_ConsoleHeight ) );
+    LOG_TRIVIAL("Created console width " + Ogre::StringConverter::toString(m_ConsoleWidth) + ", height " + Ogre::StringConverter::toString(m_ConsoleHeight));
 
 
     // add as frame and log listner
     // add as frame and log listner
-    Ogre::LogManager::getSingleton().getDefaultLog()->addListener( this );
+    Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this);
 }
 }
 
 
 
 
-
 Console::~Console()
 Console::~Console()
 {
 {
     // remove as listner
     // remove as listner
-    Ogre::LogManager::getSingleton().getDefaultLog()->removeListener( this );
+    Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
 }
 }
 
 
 
 
-
 void
 void
 Console::Input(const QGears::Event& event)
 Console::Input(const QGears::Event& event)
 {
 {
-    if( m_Visible != true )
+    if(m_Visible != true)
     {
     {
         // add console
         // add console
         if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
         if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
@@ -87,23 +80,23 @@ Console::Input(const QGears::Event& event)
     // input command
     // input command
     else if (event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
+            m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
         }
         }
 
 
-        AddTextToOutput( m_InputLine );
+        AddTextToOutput(m_InputLine);
         AddInputToHistory();
         AddInputToHistory();
 
 
         // backslashed text are console commands, otherwise - script commands
         // backslashed text are console commands, otherwise - script commands
-        if( '\\' == m_InputLine[ 0 ] || '/' == m_InputLine[ 0 ] )
+        if('\\' == m_InputLine[0] || '/' == m_InputLine[0])
         {
         {
-            if( m_InputLine.size() > 1 )
+            if(m_InputLine.size() > 1)
             {
             {
                 // remove backslash
                 // remove backslash
-                m_InputLine.erase( 0, 1 );
+                m_InputLine.erase(0, 1);
 
 
-                ExecuteCommand( m_InputLine );
+                ExecuteCommand(m_InputLine);
             }
             }
         }
         }
         else
         else
@@ -127,7 +120,7 @@ Console::Input(const QGears::Event& event)
     // history up
     // history up
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_HistoryLine < (int)m_History.size() - 1)
         {
         {
             ++m_HistoryLine;
             ++m_HistoryLine;
             SetInputLineFromHistory();
             SetInputLineFromHistory();
@@ -136,7 +129,7 @@ Console::Input(const QGears::Event& event)
     // history down
     // history down
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_HistoryLine > 0)
         {
         {
             --m_HistoryLine;
             --m_HistoryLine;
             SetInputLineFromHistory();
             SetInputLineFromHistory();
@@ -145,7 +138,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to previous row
     // scroll display to previous row
     else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
     else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
     {
     {
-        if( m_DisplayLine > 0 )
+        if(m_DisplayLine > 0)
         {
         {
             m_DisplayLine -= 1;
             m_DisplayLine -= 1;
         }
         }
@@ -153,7 +146,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to next row
     // scroll display to next row
     else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 < 0)
     else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 < 0)
     {
     {
-        if( m_DisplayLine < m_OutputLine.size() )
+        if(m_DisplayLine < m_OutputLine.size())
         {
         {
             m_DisplayLine += 1;
             m_DisplayLine += 1;
         }
         }
@@ -162,7 +155,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to previous row
     // scroll display to previous row
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_DisplayLine > 0)
         {
         {
             m_DisplayLine -= 1;
             m_DisplayLine -= 1;
         }
         }
@@ -170,7 +163,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to next row
     // scroll display to next row
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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() )
+        if(m_DisplayLine < m_OutputLine.size())
         {
         {
             m_DisplayLine += 1;
             m_DisplayLine += 1;
         }
         }
@@ -178,30 +171,30 @@ Console::Input(const QGears::Event& event)
     // delete character after cursor
     // delete character after cursor
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
         else
         else
         {
         {
-            if( m_InputLine.size() > 0 && m_CursorPosition < m_InputLine.size() )
+            if(m_InputLine.size() > 0 && m_CursorPosition < m_InputLine.size())
             {
             {
-                m_InputLine.erase( m_CursorPosition, 1 );
+                m_InputLine.erase(m_CursorPosition, 1);
             }
             }
         }
         }
     }
     }
     // delete character before cursor
     // delete character before cursor
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
         else
         else
         {
         {
-            if( m_CursorPosition > 0 )
+            if(m_CursorPosition > 0)
             {
             {
-                m_InputLine.erase( m_CursorPosition - 1, 1 );
+                m_InputLine.erase(m_CursorPosition - 1, 1);
                 --m_CursorPosition;
                 --m_CursorPosition;
             }
             }
         }
         }
@@ -209,13 +202,13 @@ Console::Input(const QGears::Event& event)
     // move cursor to left
     // move cursor to left
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
+            m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
 
 
-        if( m_CursorPosition > 0 )
+        if(m_CursorPosition > 0)
         {
         {
             --m_CursorPosition;
             --m_CursorPosition;
         }
         }
@@ -223,13 +216,13 @@ Console::Input(const QGears::Event& event)
     // move cursor to right
     // move cursor to right
     else if ((event.type == QGears::ET_KEY_PRESS || event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
+            m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
 
 
-        if( m_CursorPosition <  m_InputLine.size() )
+        if(m_CursorPosition <  m_InputLine.size())
         {
         {
             ++m_CursorPosition;
             ++m_CursorPosition;
         }
         }
@@ -245,18 +238,18 @@ Console::Input(const QGears::Event& event)
     {
     {
         m_CursorPosition = 0;
         m_CursorPosition = 0;
 
 
-        if( m_AutoCompletition.size() > 0 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
+            m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
     }
     }
     // move cursor to end of string
     // move cursor to end of string
     else if (event.type == QGears::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 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            m_InputLine += m_AutoCompletition[ m_AutoCompletitionLine ];
+            m_InputLine += m_AutoCompletition[m_AutoCompletitionLine];
             ResetAutoCompletion();
             ResetAutoCompletion();
         }
         }
 
 
@@ -267,12 +260,12 @@ Console::Input(const QGears::Event& event)
     {
     {
         char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
         char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
         char txt = static_cast<char>(event.param2);
         char txt = static_cast<char>(event.param2);
-        for( unsigned int c = 0; c < sizeof( legalchars ) - 1; ++c )
+        for(unsigned int c = 0; c < sizeof(legalchars ) - 1; ++c)
         {
         {
-            if( legalchars[ c ] == txt )
+            if(legalchars[c] == txt)
             {
             {
                 std::string::iterator i = m_InputLine.begin() + m_CursorPosition;
                 std::string::iterator i = m_InputLine.begin() + m_CursorPosition;
-                m_InputLine.insert( i, txt );
+                m_InputLine.insert(i, txt);
                 ++m_CursorPosition;
                 ++m_CursorPosition;
                 ResetAutoCompletion();
                 ResetAutoCompletion();
                 break;
                 break;
@@ -282,138 +275,134 @@ Console::Input(const QGears::Event& event)
 }
 }
 
 
 
 
-
 void
 void
 Console::Update()
 Console::Update()
 {
 {
     float delta_time = Timer::getSingleton().GetSystemTimeDelta();
     float delta_time = Timer::getSingleton().GetSystemTimeDelta();
 
 
-    if( m_ToVisible == true && m_Height < m_ConsoleHeight )
+    if(m_ToVisible == true && m_Height < m_ConsoleHeight)
     {
     {
+        // TODO: Convert this to a constant.
         m_Height += delta_time * 1500;
         m_Height += delta_time * 1500;
 
 
-        if( m_Height >= m_ConsoleHeight )
+        if(m_Height >= m_ConsoleHeight)
         {
         {
             m_Height = static_cast<float>(m_ConsoleHeight);
             m_Height = static_cast<float>(m_ConsoleHeight);
         }
         }
     }
     }
-    else if( m_ToVisible == false && m_Height > 0 )
+    else if(m_ToVisible == false && m_Height > 0)
     {
     {
         m_Height -= delta_time * 1500;
         m_Height -= delta_time * 1500;
 
 
-        if( m_Height <= 0 )
+        if(m_Height <= 0)
         {
         {
             m_Height = 0;
             m_Height = 0;
             m_Visible = false;
             m_Visible = false;
         }
         }
     }
     }
 
 
-    if( m_Visible == true )
+    if(m_Visible == true)
     {
     {
         UpdateDraw();
         UpdateDraw();
     }
     }
-    else if( cv_console_notification.GetB() == true )
+    else if(cv_console_notification.GetB() == true)
     {
     {
         UpdateNotification();
         UpdateNotification();
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 Console::UpdateDraw()
 Console::UpdateDraw()
 {
 {
     float delta_time = Timer::getSingleton().GetSystemTimeDelta();
     float delta_time = Timer::getSingleton().GetSystemTimeDelta();
 
 
-    DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
-    DEBUG_DRAW.SetScreenSpace( true );
-    DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.05f, 0.06f, 0.2f, 0.95f ) );
-    DEBUG_DRAW.SetZ( -0.5f );
-    DEBUG_DRAW.Quad( 0.0f, 0.0f, static_cast<float>(m_ConsoleWidth), 0.0f, static_cast<float>(m_ConsoleWidth), m_Height, 0.0f, m_Height );
-    DEBUG_DRAW.SetColour( Ogre::ColourValue(  0.18f, 0.22f, 0.74f, 0.95f ) );
-    DEBUG_DRAW.SetZ( -0.6f );
-    DEBUG_DRAW.Line( 0.0f, m_Height, static_cast<float>(m_ConsoleWidth), m_Height );
+    DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+    DEBUG_DRAW.SetScreenSpace(true);
+    DEBUG_DRAW.SetColour(Ogre::ColourValue(0.05f, 0.06f, 0.2f, 0.95f));
+    DEBUG_DRAW.SetZ(-0.5f);
+    DEBUG_DRAW.Quad(0.0f, 0.0f, static_cast<float>(m_ConsoleWidth), 0.0f, static_cast<float>(m_ConsoleWidth), m_Height, 0.0f, m_Height);
+    DEBUG_DRAW.SetColour(Ogre::ColourValue(0.18f, 0.22f, 0.74f, 0.95f));
+    DEBUG_DRAW.SetZ(-0.6f);
+    DEBUG_DRAW.Line(0.0f, m_Height, static_cast<float>(m_ConsoleWidth), m_Height);
 
 
     int row = 1;
     int row = 1;
-    int rows = ( m_ConsoleHeight - 30 ) / 16;
+    int rows = (m_ConsoleHeight - 30) / 16;
     int y = static_cast<int>(-m_ConsoleHeight + m_Height);
     int y = static_cast<int>(-m_ConsoleHeight + m_Height);
     int empty = rows - m_DisplayLine;
     int empty = rows - m_DisplayLine;
-    if( empty > 0 )
+    if(empty > 0)
     {
     {
         y += empty * 16;
         y += empty * 16;
     }
     }
 
 
-    std::list< OutputLine >::iterator i;
-    for( i = m_OutputLine.begin(); i != m_OutputLine.end(); ++i, ++row )
+    std::list<OutputLine>::iterator i;
+    for(i = m_OutputLine.begin(); i != m_OutputLine.end(); ++i, ++row)
     {
     {
-        if( row > ( int )m_DisplayLine - rows && row <= ( int )m_DisplayLine )
+        if(row > (int)m_DisplayLine - rows && row <= (int)m_DisplayLine)
         {
         {
 
 
-            DEBUG_DRAW.SetColour( ( *i ).colour );
-            DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), ( *i ).text );
+            DEBUG_DRAW.SetColour((*i).colour);
+            DEBUG_DRAW.Text(5.0f, static_cast<float>(y), (*i).text);
             y += 16;
             y += 16;
         }
         }
     }
     }
-    if( m_DisplayLine != m_OutputLine.size() )
+    if(m_DisplayLine != m_OutputLine.size())
     {
     {
         Ogre::String temp = "";
         Ogre::String temp = "";
-        for( unsigned int i = 0; i < m_LineWidth; ++i )
+        for(unsigned int i = 0; i < m_LineWidth; ++i)
         {
         {
             temp += "^";
             temp += "^";
         }
         }
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1.0f, 0.0f, 0.0f, 1.0f ) );
-        DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), temp );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f, 1.0f));
+        DEBUG_DRAW.Text(5.0f, static_cast<float>(y), temp);
     }
     }
 
 
-
-
     m_CursorBlinkTime += delta_time;
     m_CursorBlinkTime += delta_time;
-    if( ( ( ( int )( m_CursorBlinkTime * 1000 ) ) >> 8 ) & 1 )
+    if((((int)(m_CursorBlinkTime * 1000)) >> 8) & 1)
     {
     {
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.88f, 0.88f, 0.88f, 1 ) );
-        DEBUG_DRAW.Text( static_cast<float>(12 + m_CursorPosition * m_LetterWidth), static_cast<float>(-19 + m_Height), "_" );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(0.88f, 0.88f, 0.88f, 1));
+        DEBUG_DRAW.Text(static_cast<float>(12 + m_CursorPosition * m_LetterWidth), static_cast<float>(-19 + m_Height), "_");
     }
     }
 
 
 
 
-    if( m_AutoCompletition.size() > 0 )
+    if(m_AutoCompletition.size() > 0)
     {
     {
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
-        DEBUG_DRAW.Text( 12, -20 + m_Height, m_InputLine);
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 0, 1, 0, 1 ) );
-        DEBUG_DRAW.Text( static_cast<float>(12 + ( m_InputLine.size() * m_LetterWidth )), static_cast<float>(-20 + m_Height), m_AutoCompletition[ m_AutoCompletitionLine ] );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+        DEBUG_DRAW.Text(12, -20 + m_Height, m_InputLine);
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(0, 1, 0, 1));
+        DEBUG_DRAW.Text(static_cast<float>(12 + (m_InputLine.size() * m_LetterWidth)), static_cast<float>(-20 + m_Height), m_AutoCompletition[m_AutoCompletitionLine]);
     }
     }
     else
     else
     {
     {
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
-        DEBUG_DRAW.Text( 12, -20 + m_Height, m_InputLine );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+        DEBUG_DRAW.Text(12, -20 + m_Height, m_InputLine);
     }
     }
 
 
-    DEBUG_DRAW.SetZ( 0 );
+    DEBUG_DRAW.SetZ(0);
 }
 }
 
 
 
 
-
 void
 void
 Console::UpdateNotification()
 Console::UpdateNotification()
 {
 {
-    DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
-    DEBUG_DRAW.SetScreenSpace( true );
-    DEBUG_DRAW.SetZ( -0.6f );
+    DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+    DEBUG_DRAW.SetScreenSpace(true);
+    DEBUG_DRAW.SetZ(-0.6f);
 
 
     std::list< OutputLine >::reverse_iterator i;
     std::list< OutputLine >::reverse_iterator i;
-    int y = ( m_OutputLine.size() > 10 ) ? 160 : m_OutputLine.size() * 16;
+    int y = (m_OutputLine.size() > 10) ? 160 : m_OutputLine.size() * 16;
     int line = 0;
     int line = 0;
     float max_time = 3.0f;
     float max_time = 3.0f;
 
 
-    for( i = m_OutputLine.rbegin(); i != m_OutputLine.rend() && line < 10; ++i )
+    for(i = m_OutputLine.rbegin(); i != m_OutputLine.rend() && line < 10; ++i)
     {
     {
-        float time = Timer::getSingleton().GetSystemTimeTotal() - ( *i ).time;
-        if( time < max_time )
+        float time = Timer::getSingleton().GetSystemTimeTotal() - (*i).time;
+        if(time < max_time)
         {
         {
-            Ogre::ColourValue colour = ( *i ).colour;
-            colour.a = ( max_time - time ) / max_time;
-            DEBUG_DRAW.SetColour( colour );
-            DEBUG_DRAW.Text( 5.0f, static_cast<float>(y), ( *i ).text );
+            Ogre::ColourValue colour = (*i).colour;
+            colour.a = (max_time - time) / max_time;
+            DEBUG_DRAW.SetColour(colour);
+            DEBUG_DRAW.Text(5.0f, static_cast<float>(y), (*i).text);
             y -= 16;
             y -= 16;
             ++line;
             ++line;
         }
         }
@@ -421,24 +410,22 @@ Console::UpdateNotification()
 }
 }
 
 
 
 
-
 void
 void
 Console::OnResize()
 Console::OnResize()
 {
 {
     // calculate width and height of console depending on size of application
     // calculate width and height of console depending on size of application
-    Ogre::RenderTarget *render_target( QGears::Application::getSingleton().getRenderWindow() );
+    Ogre::RenderTarget *render_target(QGears::Application::getSingleton().getRenderWindow());
     m_ConsoleWidth = render_target->getWidth();
     m_ConsoleWidth = render_target->getWidth();
     m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
     m_ConsoleHeight = static_cast<int>(render_target->getHeight() / 2.5f);
-    m_LineWidth = ( m_ConsoleWidth - 20 ) / 8;
+    m_LineWidth = (m_ConsoleWidth - 20) / 8;
 
 
-    LOG_TRIVIAL( "Resized console width to " + Ogre::StringConverter::toString( m_ConsoleWidth ) + ", height to " + Ogre::StringConverter::toString( m_ConsoleHeight ) );
+    LOG_TRIVIAL("Resized console width to " + Ogre::StringConverter::toString(m_ConsoleWidth) + ", height to " + Ogre::StringConverter::toString(m_ConsoleHeight));
 
 
     // update height of already opened console
     // update height of already opened console
-    m_Height = ( m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
+    m_Height = (m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
 }
 }
 
 
 
 
-
 void
 void
 Console::SetToVisible()
 Console::SetToVisible()
 {
 {
@@ -447,7 +434,6 @@ Console::SetToVisible()
 }
 }
 
 
 
 
-
 void
 void
 Console::SetToHide()
 Console::SetToHide()
 {
 {
@@ -455,7 +441,6 @@ Console::SetToHide()
 }
 }
 
 
 
 
-
 bool
 bool
 Console::IsVisible() const
 Console::IsVisible() const
 {
 {
@@ -463,9 +448,8 @@ Console::IsVisible() const
 }
 }
 
 
 
 
-
 void
 void
-Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& colour )
+Console::AddTextToOutput(const Ogre::String& text, const Ogre::ColourValue& colour)
 {
 {
     // go through line and add it to output correctly
     // go through line and add it to output correctly
     const char* str = text.c_str();
     const char* str = text.c_str();
@@ -473,32 +457,32 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
     unsigned int string_size = 0;
     unsigned int string_size = 0;
     bool indent = false;
     bool indent = false;
     unsigned int c = 0;
     unsigned int c = 0;
-    for( ; c < text.size(); ++c )
+    for(; c < text.size(); ++c)
     {
     {
         // add space at start of string if we want indent
         // add space at start of string if we want indent
-        if( string_size == 0 && indent == true )
+        if(string_size == 0 && indent == true)
         {
         {
-            output_line.push_back( ' ' );
+            output_line.push_back(' ');
             ++string_size;
             ++string_size;
         }
         }
 
 
-        if( str[ c ] != '\n' )
+        if(str[c] != '\n')
         {
         {
-            output_line.push_back( str[ c ] );
+            output_line.push_back(str[c]);
             ++string_size;
             ++string_size;
         }
         }
 
 
-        if( str[ c ] == '\n' || string_size >= m_LineWidth || c >= text.size() - 1 )
+        if(str[c] == '\n' || string_size >= m_LineWidth || c >= text.size() - 1)
         {
         {
             // if string is larger than output size than add indent
             // if string is larger than output size than add indent
-            indent = ( string_size >= m_LineWidth ) ? true : false;
+            indent = (string_size >= m_LineWidth) ? true : false;
 
 
-            if( m_OutputLine.size() >= m_MaxOutputLine )
+            if(m_OutputLine.size() >= m_MaxOutputLine)
             {
             {
                 m_OutputLine.pop_front();
                 m_OutputLine.pop_front();
             }
             }
 
 
-            if( m_OutputLine.size() == m_DisplayLine )
+            if(m_OutputLine.size() == m_DisplayLine)
             {
             {
                 ++m_DisplayLine;
                 ++m_DisplayLine;
             }
             }
@@ -507,7 +491,7 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
             line.text = output_line;
             line.text = output_line;
             line.colour = colour;
             line.colour = colour;
             line.time = Timer::getSingleton().GetSystemTimeTotal();
             line.time = Timer::getSingleton().GetSystemTimeTotal();
-            m_OutputLine.push_back( line );
+            m_OutputLine.push_back(line);
 
 
             output_line.clear();
             output_line.clear();
             string_size = 0;
             string_size = 0;
@@ -515,14 +499,14 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
     }
     }
 
 
     // add one more string if text ended with \n
     // add one more string if text ended with \n
-    if( text.size() == 0 || str[ text.size() - 1 ] == '\n' )
+    if(text.size() == 0 || str[text.size() - 1] == '\n')
     {
     {
-        if( m_OutputLine.size() >= m_MaxOutputLine )
+        if(m_OutputLine.size() >= m_MaxOutputLine)
         {
         {
             m_OutputLine.pop_front();
             m_OutputLine.pop_front();
         }
         }
 
 
-        if( m_OutputLine.size() == m_DisplayLine )
+        if(m_OutputLine.size() == m_DisplayLine)
         {
         {
             ++m_DisplayLine;
             ++m_DisplayLine;
         }
         }
@@ -531,209 +515,205 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
         line.text = "";
         line.text = "";
         line.colour = colour;
         line.colour = colour;
         line.time = Timer::getSingleton().GetSystemTimeTotal();
         line.time = Timer::getSingleton().GetSystemTimeTotal();
-        m_OutputLine.push_back( line );
+        m_OutputLine.push_back(line);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-Console::ExecuteCommand( const Ogre::String& command )
+Console::ExecuteCommand(const Ogre::String& command)
 {
 {
     bool handled = false;
     bool handled = false;
-
-    Ogre::StringVector params = StringTokenise( command );
+    Ogre::StringVector params = StringTokenise(command);
 
 
     // is it cvar
     // is it cvar
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find( params[ 0 ] );
+    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(params[0]);
 
 
-    if( cvar != NULL )
+    if(cvar != nullptr)
     {
     {
         handled = true;
         handled = true;
 
 
-        if( params.size() > 1 )
+        if(params.size() > 1)
         {
         {
-            cvar->SetS( params[ 1 ] );
+            cvar->SetS(params[1]);
 
 
-            AddTextToOutput( params[ 0 ] + " changed to \"" + params[ 1 ] + "\".\n" );
+            AddTextToOutput(params[0] + " changed to \"" + params[1] + "\".\n");
         }
         }
         else
         else
         {
         {
-            AddTextToOutput( params[ 0 ] + " = \"" + cvar->GetS() + "\".\n" +
+            AddTextToOutput(params[0] + " = \"" + cvar->GetS() + "\".\n" +
                             " default:\"" + cvar->GetDefaultValue() + "\".\n" +
                             " default:\"" + cvar->GetDefaultValue() + "\".\n" +
                             " description: " + cvar->GetDescription() + ".\n" );
                             " description: " + cvar->GetDescription() + ".\n" );
         }
         }
     }
     }
 
 
-    if( handled == false )
+    if(handled == false)
     {
     {
         // handle command
         // handle command
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-        if( cmd != NULL )
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+        if(cmd != nullptr)
         {
         {
-            cmd->GetHandler()( params );
+            cmd->GetHandler()(params);
             return;
             return;
         }
         }
         else
         else
         {
         {
-            AddTextToOutput( "Can't find command \"" + params[ 0 ] + "\".\n" );
+            AddTextToOutput("Can't find command \"" + params[0] + "\".\n");
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 Console::ExecuteScript()
 Console::ExecuteScript()
 {
 {
-    ScriptManager::getSingleton().RunString( m_InputLine );
+    ScriptManager::getSingleton().RunString(m_InputLine);
 }
 }
 
 
 
 
-
 void
 void
 Console::CompleteInput()
 Console::CompleteInput()
 {
 {
     bool add_slash = false;
     bool add_slash = false;
 
 
-    if( m_AutoCompletition.size() == 0 )
+    if(m_AutoCompletition.size() == 0)
     {
     {
         // remove backslash
         // remove backslash
-        if( m_InputLine.size() > 0 && ( '\\' == m_InputLine[ 0 ] || '/' == m_InputLine[ 0 ] ) )
+        if(m_InputLine.size() > 0 && ('\\' == m_InputLine[0] || '/' == m_InputLine[0]))
         {
         {
-            m_InputLine.erase( 0, 1 );
+            m_InputLine.erase(0, 1);
         }
         }
 
 
         size_t input_size = m_InputLine.size();
         size_t input_size = m_InputLine.size();
 
 
-        Ogre::StringVector params = StringTokenise( m_InputLine );
+        Ogre::StringVector params = StringTokenise(m_InputLine);
 
 
-        if( params.size() == 0 )
+        if(params.size() == 0)
         {
         {
             // add cvars
             // add cvars
             int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
             int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
-            for( int i = 0; i < num_vars; ++i )
+            for(int i = 0; i < num_vars; ++i)
             {
             {
-                m_AutoCompletition.push_back( ConfigVarManager::getSingleton().GetConfigVar( i )->GetName() );
+                m_AutoCompletition.push_back(ConfigVarManager::getSingleton().GetConfigVar(i)->GetName());
             }
             }
 
 
             // add commands
             // add commands
             int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
             int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
-            for( int i = 0; i < num_cmds; ++i )
+            for(int i = 0; i < num_cmds; ++i)
             {
             {
-                m_AutoCompletition.push_back( ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetName() );
+                m_AutoCompletition.push_back(ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName());
             }
             }
 
 
             add_slash = true;
             add_slash = true;
         }
         }
-        else if( params.size() == 1 )
+        else if(params.size() == 1)
         {
         {
-            m_InputLine = params[ 0 ];
+            m_InputLine = params[0];
 
 
             // add cvars
             // add cvars
             int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
             int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
-            for( int i = 0; i < num_vars; ++i )
+            for(int i = 0; i < num_vars; ++i)
             {
             {
-                Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar( i )->GetName();
-                unsigned int pos = name.find( m_InputLine );
-                if( pos == 0 )
+                Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar(i)->GetName();
+                unsigned int pos = name.find(m_InputLine);
+                if(pos == 0)
                 {
                 {
                     add_slash = true;
                     add_slash = true;
 
 
-                    if( input_size != name.size() )
+                    if(input_size != name.size())
                     {
                     {
-                        Ogre::String part = name.substr( input_size, name.size() - input_size );
-                        m_AutoCompletition.push_back( part );
+                        Ogre::String part = name.substr(input_size, name.size() - input_size);
+                        m_AutoCompletition.push_back(part);
                     }
                     }
                 }
                 }
             }
             }
 
 
             // add commands
             // add commands
             int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
             int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
-            for( int i = 0; i < num_cmds; ++i )
+            for(int i = 0; i < num_cmds; ++i)
             {
             {
-                Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetName();
+                Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName();
 
 
-                int pos = name.find( m_InputLine );
-                if( pos == 0 )
+                int pos = name.find(m_InputLine);
+                if(pos == 0)
                 {
                 {
                     add_slash = true;
                     add_slash = true;
 
 
-                    if( name != params[ 0 ] )
+                    if(name != params[0])
                     {
                     {
-                        Ogre::String part = name.substr( input_size, name.size() - input_size );
-                        m_AutoCompletition.push_back( part );
+                        Ogre::String part = name.substr(input_size, name.size() - input_size);
+                        m_AutoCompletition.push_back(part);
                     }
                     }
-                    else if( ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetCompletion() != NULL )
+                    else if(ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion() != nullptr)
                     {
                     {
                         m_InputLine += " ";
                         m_InputLine += " ";
-                        ConfigCmdManager::getSingleton().GetConfigCmd( i )->GetCompletion()( m_AutoCompletition );
+                        ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion()(m_AutoCompletition);
                     }
                     }
                 }
                 }
             }
             }
         }
         }
-        else if( params.size() > 1 )
+        else if(params.size() > 1)
         {
         {
-            Ogre::String all_params = params[ 1 ];
+            Ogre::String all_params = params[1];
 
 
-            for( size_t i = 2; i < params.size(); ++i )
+            for(size_t i = 2; i < params.size(); ++i)
             {
             {
-                all_params += " " + params[ i ];
+                all_params += " " + params[i];
             }
             }
 
 
             // add commands arguments
             // add commands arguments
-            ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-            if( cmd != NULL )
+            ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+            if(cmd != nullptr)
             {
             {
                 add_slash = true;
                 add_slash = true;
 
 
-                if( cmd->GetCompletion() != NULL )
+                if(cmd->GetCompletion() != nullptr)
                 {
                 {
                     Ogre::StringVector full_complete;
                     Ogre::StringVector full_complete;
-                    cmd->GetCompletion()( full_complete );
-                    if( full_complete.size() > 0 )
+                    cmd->GetCompletion()(full_complete);
+                    if(full_complete.size() > 0)
                     {
                     {
-                        std::sort( full_complete.begin(), full_complete.end() );
+                        std::sort(full_complete.begin(), full_complete.end());
 
 
-                        for( size_t i = 0 ; i < full_complete.size(); ++i )
+                        for(size_t i = 0 ; i < full_complete.size(); ++i)
                         {
                         {
-                            int pos = full_complete[ i ].find( all_params );
-                            if( pos == 0 && all_params != full_complete[ i ] )
+                            int pos = full_complete[i].find(all_params);
+                            if(pos == 0 && all_params != full_complete[i])
                             {
                             {
-                                Ogre::String part = full_complete[ i ].substr( all_params.size(), full_complete[ i ].size() - all_params.size() );
-                                m_AutoCompletition.push_back( part );
+                                Ogre::String part = full_complete[i].substr(all_params.size(), full_complete[i].size() - all_params.size());
+                                m_AutoCompletition.push_back(part);
                             }
                             }
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
 
 
-            m_InputLine = params[ 0 ] + " " + all_params;
+            m_InputLine = params[0] + " " + all_params;
         }
         }
 
 
         // if we found at least one match
         // if we found at least one match
-        if( add_slash == true )
+        if(add_slash == true)
         {
         {
             m_InputLine = "/" + m_InputLine;
             m_InputLine = "/" + m_InputLine;
         }
         }
         m_CursorPosition = m_InputLine.size();
         m_CursorPosition = m_InputLine.size();
 
 
         // sort list
         // sort list
-        std::sort( m_AutoCompletition.begin(), m_AutoCompletition.end() );
+        std::sort(m_AutoCompletition.begin(), m_AutoCompletition.end());
         m_AutoCompletitionLine = 0;
         m_AutoCompletitionLine = 0;
 
 
-        for( size_t i = 0; i < m_AutoCompletition.size(); ++i )
+        for(size_t i = 0; i < m_AutoCompletition.size(); ++i)
         {
         {
-            AddTextToOutput( " " + m_InputLine + m_AutoCompletition[ i ] );
+            AddTextToOutput(" " + m_InputLine + m_AutoCompletition[i]);
         }
         }
-        if( m_AutoCompletition.size() > 0 )
+        if(m_AutoCompletition.size() > 0)
         {
         {
-            AddTextToOutput( "\n" );
+            AddTextToOutput("\n");
         }
         }
     }
     }
     else
     else
     {
     {
-        if( m_AutoCompletitionLine < m_AutoCompletition.size() - 1 )
+        if(m_AutoCompletitionLine < m_AutoCompletition.size() - 1)
         {
         {
             ++m_AutoCompletitionLine;
             ++m_AutoCompletitionLine;
         }
         }
@@ -745,7 +725,6 @@ Console::CompleteInput()
 }
 }
 
 
 
 
-
 void
 void
 Console::ResetAutoCompletion()
 Console::ResetAutoCompletion()
 {
 {
@@ -754,31 +733,29 @@ Console::ResetAutoCompletion()
 }
 }
 
 
 
 
-
 void
 void
 Console::AddInputToHistory()
 Console::AddInputToHistory()
 {
 {
-    if( m_History.size() >= m_HistorySize )
+    if(m_History.size() >= m_HistorySize)
     {
     {
         m_History.pop_back();
         m_History.pop_back();
     }
     }
-    m_History.push_front( m_InputLine );
+    m_History.push_front(m_InputLine);
     m_HistoryLine = -1;
     m_HistoryLine = -1;
 }
 }
 
 
 
 
-
 void
 void
 Console::SetInputLineFromHistory()
 Console::SetInputLineFromHistory()
 {
 {
     ResetAutoCompletion();
     ResetAutoCompletion();
 
 
-    std::list< Ogre::String >::iterator i = m_History.begin();
-    for( int count = 0; i != m_History.end(); ++i, ++count )
+    std::list<Ogre::String>::iterator i = m_History.begin();
+    for(int count = 0; i != m_History.end(); ++i, ++count)
     {
     {
-        if( count == m_HistoryLine )
+        if(count == m_HistoryLine)
         {
         {
-            m_InputLine = ( *i );
+            m_InputLine = (*i);
             m_CursorPosition = m_InputLine.size();
             m_CursorPosition = m_InputLine.size();
             break;
             break;
         }
         }
@@ -786,15 +763,14 @@ Console::SetInputLineFromHistory()
 }
 }
 
 
 
 
-
 void
 void
-Console::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String& logName, bool& skipThisMessage )
+Console::messageLogged(const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String& logName, bool& skipThisMessage)
 {
 {
     Ogre::ColourValue colour = Ogre::ColourValue::White;
     Ogre::ColourValue colour = Ogre::ColourValue::White;
-    switch( ( int )lml )
+    switch((int)lml)
     {
     {
-        case 2: colour = Ogre::ColourValue( 1, 1, 0, 1 ); break;
-        case 3: colour = Ogre::ColourValue( 1, 0, 0, 1 ); break;
+        case 2: colour = Ogre::ColourValue(1, 1, 0, 1); break;
+        case 3: colour = Ogre::ColourValue(1, 0, 0, 1); break;
     }
     }
-    AddTextToOutput( message, colour );
+    AddTextToOutput(message, colour);
 }
 }

+ 167 - 251
QGearsMain/src/core/DebugDraw.cpp

@@ -1,31 +1,30 @@
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
-
 #include <OgreFontManager.h>
 #include <OgreFontManager.h>
 #include <OgreHardwareBufferManager.h>
 #include <OgreHardwareBufferManager.h>
 #include <OgreMaterialManager.h>
 #include <OgreMaterialManager.h>
 
 
 #include "core/CameraManager.h"
 #include "core/CameraManager.h"
+#include "core/DebugDraw.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/UiTextArea.h"
 
 
 
 
-
-template<>DebugDraw *Ogre::Singleton< DebugDraw >::msSingleton = NULL;
-
+template<>DebugDraw *Ogre::Singleton<DebugDraw>::msSingleton = nullptr;
 
 
 
 
 DebugDraw::DebugDraw():
 DebugDraw::DebugDraw():
-    m_Colour( 1, 1, 1, 1 ),
-    m_ScreenSpace( true ),
-    m_Z( 0 ),
-    m_FadeStartSquare( 999999 ),
-    m_FadeEndSquare( 999999 ),
-    m_FontHeight( 16 ),
-    m_LineMaxVertexCount( 0 ),
-    m_Line3dMaxVertexCount( 0 ),
-    m_QuadMaxVertexCount( 0 ),
-    m_TextMaxVertexCount( 0 )
+    m_Colour(1, 1, 1, 1),
+    m_ScreenSpace(true),
+    m_Z(0),
+    m_FadeStartSquare(999999),
+    m_FadeEndSquare(999999),
+    m_FontHeight(16),
+    m_LineMaxVertexCount(0),
+    m_Line3dMaxVertexCount(0),
+    m_QuadMaxVertexCount(0),
+    m_TextMaxVertexCount(0)
 {
 {
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
 
 
     CreateLineVertexBuffer();
     CreateLineVertexBuffer();
@@ -34,51 +33,50 @@ DebugDraw::DebugDraw():
     CreateQuadVertexBuffer();
     CreateQuadVertexBuffer();
     CreateTextVertexBuffer();
     CreateTextVertexBuffer();
 
 
-    m_Material = Ogre::MaterialManager::getSingleton().create( "DebugDraw", "General" );
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
-    pass->setCullingMode( Ogre::CULL_NONE );
-    pass->setDepthCheckEnabled( true );
-    pass->setDepthWriteEnabled( true );
-    pass->setLightingEnabled( false );
-    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
-
-    m_Material3d = Ogre::MaterialManager::getSingleton().create( "DebugDraw3d", "General" );
-    pass = m_Material3d->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
-    pass->setCullingMode( Ogre::CULL_NONE );
-    pass->setDepthCheckEnabled( true );
-    pass->setDepthWriteEnabled( true );
-    pass->setLightingEnabled( false );
-    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
-
-    m_Font = Ogre::FontManager::getSingleton().getByName( "CourierNew" );
-    if( m_Font.isNull() )
+    m_Material = Ogre::MaterialManager::getSingleton().create("DebugDraw", "General");
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
+    pass->setCullingMode(Ogre::CULL_NONE);
+    pass->setDepthCheckEnabled(true);
+    pass->setDepthWriteEnabled(true);
+    pass->setLightingEnabled(false);
+    pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+
+    m_Material3d = Ogre::MaterialManager::getSingleton().create("DebugDraw3d", "General");
+    pass = m_Material3d->getTechnique( 0 )->getPass(0);
+    pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
+    pass->setCullingMode(Ogre::CULL_NONE);
+    pass->setDepthCheckEnabled(true);
+    pass->setDepthWriteEnabled(true);
+    pass->setLightingEnabled(false);
+    pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+
+    m_Font = Ogre::FontManager::getSingleton().getByName("CourierNew");
+    if(m_Font.isNull())
     {
     {
-        LOG_ERROR( "Could not find font \"CourierNew\" for debug draw." );
+        LOG_ERROR("Could not find font \"CourierNew\" for debug draw.");
         throw std::runtime_error("Font load failure");
         throw std::runtime_error("Font load failure");
     }
     }
 
 
     m_Font->load();
     m_Font->load();
-    pass = m_Font->getMaterial()->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
-    pass->setCullingMode( Ogre::CULL_NONE );
-    pass->setDepthCheckEnabled( true );
-    pass->setDepthWriteEnabled( true );
-    pass->setLightingEnabled( false );
-    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
+    pass = m_Font->getMaterial()->getTechnique(0)->getPass(0);
+    pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
+    pass->setCullingMode(Ogre::CULL_NONE);
+    pass->setDepthCheckEnabled(true);
+    pass->setDepthWriteEnabled(true);
+    pass->setLightingEnabled(false);
+    pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
 
 
     //Ogre::MaterialSerializer mat;
     //Ogre::MaterialSerializer mat;
     //mat.exportMaterial( m_Font->getMaterial(), "font.material" );
     //mat.exportMaterial( m_Font->getMaterial(), "font.material" );
 
 
-    m_SceneManager->addRenderQueueListener( this );
+    m_SceneManager->addRenderQueueListener(this);
 }
 }
 
 
 
 
-
 DebugDraw::~DebugDraw()
 DebugDraw::~DebugDraw()
 {
 {
-    m_SceneManager->removeRenderQueueListener( this );
+    m_SceneManager->removeRenderQueueListener(this);
 
 
     DestroyLineVertexBuffer();
     DestroyLineVertexBuffer();
     DestroyLine3dVertexBuffer();
     DestroyLine3dVertexBuffer();
@@ -88,69 +86,64 @@ DebugDraw::~DebugDraw()
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::SetColour( const Ogre::ColourValue& colour )
+DebugDraw::SetColour(const Ogre::ColourValue& colour)
 {
 {
     m_Colour = colour;
     m_Colour = colour;
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::SetScreenSpace( const bool screen_space )
+DebugDraw::SetScreenSpace(const bool screen_space)
 {
 {
     m_ScreenSpace = screen_space;
     m_ScreenSpace = screen_space;
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::SetZ( const float z )
+DebugDraw::SetZ(const float z)
 {
 {
     m_Z = z;
     m_Z = z;
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::SetFadeDistance( const float fade_s, const float fade_e )
+DebugDraw::SetFadeDistance(const float fade_s, const float fade_e)
 {
 {
     m_FadeStartSquare = fade_s * fade_s;
     m_FadeStartSquare = fade_s * fade_s;
     m_FadeEndSquare = fade_e * fade_e;
     m_FadeEndSquare = fade_e * fade_e;
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::SetTextAlignment( TextAlignment alignment )
+DebugDraw::SetTextAlignment(TextAlignment alignment)
 {
 {
     m_TextAlignment = alignment;
     m_TextAlignment = alignment;
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Line( const float x1, const float y1, const float x2, const float y2 )
+DebugDraw::Line(const float x1, const float y1, const float x2, const float y2)
 {
 {
-    if( m_LineRenderOp.vertexData->vertexCount + 2 > m_LineMaxVertexCount )
+    if(m_LineRenderOp.vertexData->vertexCount + 2 > m_LineMaxVertexCount)
     {
     {
-        LOG_ERROR( "Max number of lines reached. Can't create more than " + Ogre::StringConverter::toString( m_LineMaxVertexCount / 2 ) + " lines." );
+        LOG_ERROR("Max number of lines reached. Can't create more than " + Ogre::StringConverter::toString( m_LineMaxVertexCount / 2 ) + " lines.");
         return;
         return;
     }
     }
 
 
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float height = static_cast<float>(viewport->getActualHeight());
 
 
-    float new_x1 = ( m_ScreenSpace == true ) ? ( ( int ) x1 / width ) * 2 - 1 : x1;
-    float new_y1 = ( m_ScreenSpace == true ) ? -( ( ( int ) y1 / height ) * 2 - 1 ) : y1;
-    float new_x2 = ( m_ScreenSpace == true ) ? ( ( int ) x2 / width ) * 2 - 1 : x2;
-    float new_y2 = ( m_ScreenSpace == true ) ? -( ( ( int ) y2 / height ) * 2 - 1 ) : y2;
+    float new_x1 = (m_ScreenSpace == true) ?  ((int) x1 / width) * 2 - 1 : x1;
+    float new_y1 = (m_ScreenSpace == true) ? -(((int) y1 / height) * 2 - 1) : y1;
+    float new_x2 = (m_ScreenSpace == true) ?  ((int) x2 / width) * 2 - 1 : x2;
+    float new_y2 = (m_ScreenSpace == true) ? -(((int) y2 / height) * 2 - 1) : y2;
 
 
-    float* writeIterator = ( float* ) m_LineVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_LineVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += m_LineRenderOp.vertexData->vertexCount * 7;
     writeIterator += m_LineRenderOp.vertexData->vertexCount * 7;
 
 
+    // TODO: This and the method below could be refactored
     *writeIterator++ = new_x1;
     *writeIterator++ = new_x1;
     *writeIterator++ = new_y1;
     *writeIterator++ = new_y1;
     *writeIterator++ = m_Z;
     *writeIterator++ = m_Z;
@@ -173,17 +166,16 @@ DebugDraw::Line( const float x1, const float y1, const float x2, const float y2
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Line3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2 )
+DebugDraw::Line3d(const Ogre::Vector3& point1, const Ogre::Vector3& point2)
 {
 {
-    if( m_Line3dRenderOp.vertexData->vertexCount + 2 > m_Line3dMaxVertexCount )
+    if(m_Line3dRenderOp.vertexData->vertexCount + 2 > m_Line3dMaxVertexCount)
     {
     {
-        LOG_ERROR( "Max number of 3d lines reached. Can't create more than " + Ogre::StringConverter::toString( m_Line3dMaxVertexCount / 2 ) + " 3d lines." );
+        LOG_ERROR("Max number of 3d lines reached. Can't create more than " + Ogre::StringConverter::toString(m_Line3dMaxVertexCount / 2) + " 3d lines.");
         return;
         return;
     }
     }
 
 
-    float* writeIterator = ( float* ) m_Line3dVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_Line3dVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += m_Line3dRenderOp.vertexData->vertexCount * 7;
     writeIterator += m_Line3dRenderOp.vertexData->vertexCount * 7;
 
 
     *writeIterator++ = point1.x;
     *writeIterator++ = point1.x;
@@ -208,17 +200,16 @@ DebugDraw::Line3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2 )
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Triangle3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2, const Ogre::Vector3& point3 )
+DebugDraw::Triangle3d(const Ogre::Vector3& point1, const Ogre::Vector3& point2, const Ogre::Vector3& point3)
 {
 {
-    if( m_Triangle3dRenderOp.vertexData->vertexCount + 3 > m_Triangle3dMaxVertexCount )
+    if(m_Triangle3dRenderOp.vertexData->vertexCount + 3 > m_Triangle3dMaxVertexCount)
     {
     {
-        LOG_ERROR( "Max number of 3d triangles reached. Can't create more than " + Ogre::StringConverter::toString( m_Triangle3dMaxVertexCount / 3 ) + " 3d triangles." );
+        LOG_ERROR("Max number of 3d triangles reached. Can't create more than " + Ogre::StringConverter::toString(m_Triangle3dMaxVertexCount / 3) + " 3d triangles.");
         return;
         return;
     }
     }
 
 
-    float* writeIterator = ( float* ) m_Triangle3dVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_Triangle3dVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += m_Triangle3dRenderOp.vertexData->vertexCount * 7;
     writeIterator += m_Triangle3dRenderOp.vertexData->vertexCount * 7;
 
 
     *writeIterator++ = point1.x;
     *writeIterator++ = point1.x;
@@ -251,30 +242,29 @@ DebugDraw::Triangle3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2,
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Quad( const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4 )
+DebugDraw::Quad(const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4)
 {
 {
-    if( m_QuadRenderOp.vertexData->vertexCount + 6 > m_QuadMaxVertexCount )
+    if(m_QuadRenderOp.vertexData->vertexCount + 6 > m_QuadMaxVertexCount)
     {
     {
-        LOG_ERROR( "Max number of quads reached. Can't create more than " + Ogre::StringConverter::toString( m_QuadMaxVertexCount / 6 ) + " quads." );
+        LOG_ERROR("Max number of quads reached. Can't create more than " + Ogre::StringConverter::toString( m_QuadMaxVertexCount / 6 ) + " quads.");
         return;
         return;
     }
     }
 
 
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float height = static_cast<float>(viewport->getActualHeight());
 
 
-    float new_x1 = ( m_ScreenSpace == true ) ? ( ( int ) x1 / width ) * 2 - 1 : x1;
-    float new_y1 = ( m_ScreenSpace == true ) ? -( ( ( int ) y1 / height ) * 2 - 1 ) : y1;
-    float new_x2 = ( m_ScreenSpace == true ) ? ( ( int ) x2 / width ) * 2 - 1 : x2;
-    float new_y2 = ( m_ScreenSpace == true ) ? -( ( y2 / height ) * 2 - 1 ) : y2;
-    float new_x3 = ( m_ScreenSpace == true ) ? ( ( int ) x3 / width ) * 2 - 1 : x3;
-    float new_y3 = ( m_ScreenSpace == true ) ? -( ( ( int ) y3 / height ) * 2 - 1 ) : y3;
-    float new_x4 = ( m_ScreenSpace == true ) ? ( ( int ) x4 / width ) * 2 - 1 : x4;
-    float new_y4 = ( m_ScreenSpace == true ) ? -( ( ( int ) y4 / height ) * 2 - 1 ) : y4;
+    float new_x1 = (m_ScreenSpace == true) ?  ((int) x1 / width) * 2 - 1 : x1;
+    float new_y1 = (m_ScreenSpace == true) ? -(((int) y1 / height) * 2 - 1) : y1;
+    float new_x2 = (m_ScreenSpace == true) ?  ((int) x2 / width) * 2 - 1 : x2;
+    float new_y2 = (m_ScreenSpace == true) ? -((y2 / height) * 2 - 1) : y2;
+    float new_x3 = (m_ScreenSpace == true) ?  ((int) x3 / width) * 2 - 1 : x3;
+    float new_y3 = (m_ScreenSpace == true) ? -(((int) y3 / height) * 2 - 1) : y3;
+    float new_x4 = (m_ScreenSpace == true) ?  ((int) x4 / width) * 2 - 1 : x4;
+    float new_y4 = (m_ScreenSpace == true) ? -(((int) y4 / height) * 2 - 1) : y4;
 
 
-    float* writeIterator = ( float* ) m_QuadVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_QuadVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += m_QuadRenderOp.vertexData->vertexCount * 7;
     writeIterator += m_QuadRenderOp.vertexData->vertexCount * 7;
 
 
     *writeIterator++ = new_x1;
     *writeIterator++ = new_x1;
@@ -331,122 +321,58 @@ DebugDraw::Quad( const float x1, const float y1, const float x2, const float y2,
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Text( const float x, const float y, const Ogre::String& text )
+DebugDraw::Text(const float x, const float y, const Ogre::String& text)
 {
 {
-    if( m_TextRenderOp.vertexData->vertexCount + text.size() * 6 > m_TextMaxVertexCount )
+    if(m_TextRenderOp.vertexData->vertexCount + text.size() * 6 > m_TextMaxVertexCount)
     {
     {
-        LOG_ERROR( "Max number of text reached. Can't add text \"" + text + "\". Max number of letters is " + Ogre::StringConverter::toString( m_TextMaxVertexCount / 6 ) + "." );
+        LOG_ERROR("Max number of text reached. Can't add text \"" + text + "\". Max number of letters is " +
+                   Ogre::StringConverter::toString( m_TextMaxVertexCount / 6 ) + ".");
         return;
         return;
     }
     }
 
 
-    float* writeIterator = ( float* ) m_TextVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_TextVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += m_TextRenderOp.vertexData->vertexCount * 9;
     writeIterator += m_TextRenderOp.vertexData->vertexCount * 9;
 
 
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float height = static_cast<float>(viewport->getActualHeight());
 
 
     float length = 0;
     float length = 0;
-    if( m_TextAlignment != LEFT )
+    if(m_TextAlignment != LEFT)
     {
     {
-        for( unsigned int i = 0; i < text.size(); ++i )
+        for(auto &c : text)
         {
         {
-            length += ( ( m_Font->getGlyphAspectRatio( text[ i ] ) * m_FontHeight ) / width ) * 2;
+            length += ((m_Font->getGlyphAspectRatio(c) * m_FontHeight) / width) * 2;
         }
         }
 
 
-        if( m_TextAlignment == CENTER )
+        if(m_TextAlignment == CENTER)
         {
         {
             length /= 2;
             length /= 2;
         }
         }
     }
     }
 
 
-    float current_x = ( m_ScreenSpace == true ) ? ( ( int ) x / width ) * 2 - 1 : x;
+    float current_x = (m_ScreenSpace == true) ? ((int) x / width) * 2 - 1 : x;
     current_x -= length;
     current_x -= length;
-    float current_y =  ( m_ScreenSpace == true ) ? -( ( ( int ) y / height ) * 2 - 1 ) : y;
-    float char_height = -( m_FontHeight / height ) * 2;
+    float current_y =  (m_ScreenSpace == true) ? -(((int) y / height) * 2 - 1) : y;
+    float char_height = -(m_FontHeight / height) * 2;
 
 
-    for( unsigned int i = 0; i < text.size(); ++i )
+    for(auto &c : text)
     {
     {
-        float char_width = ( ( m_Font->getGlyphAspectRatio( text[ i ] ) * m_FontHeight ) / width ) * 2;
-
-        float new_x1 = current_x;
-        float new_y1 = current_y;
-
-        float new_x2 = current_x + char_width;
-        float new_y2 = current_y;
-
-        float new_x3 = current_x + char_width;
-        float new_y3 = current_y + char_height;
-
-        float new_x4 = current_x;
-        float new_y4 = current_y + char_height;
-
+        // for each character, compute the size of the glyph.
+        // create a square from 2 triangles for the glyph and
+        // set x, y, color and texture location
+        float char_width = ((m_Font->getGlyphAspectRatio(c) * m_FontHeight) / width) * 2;
+
+        Ogre::Vector3 coords[4] = {
+            Ogre::Vector3(current_x, current_y, m_Z),
+            Ogre::Vector3(current_x + char_width, current_y, m_Z),
+            Ogre::Vector3(current_x + char_width, current_y + char_height, m_Z),
+            Ogre::Vector3(current_x, current_y + char_height, m_Z),
+        };
         current_x += char_width;
         current_x += char_width;
-
-        const Ogre::Font::UVRect& uv = m_Font->getGlyphTexCoords( text[ i ] );
-
-        *writeIterator++ = new_x1;
-        *writeIterator++ = new_y1;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.left;
-        *writeIterator++ = uv.top;
-
-        *writeIterator++ = new_x2;
-        *writeIterator++ = new_y2;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.right;
-        *writeIterator++ = uv.top;
-
-        *writeIterator++ = new_x3;
-        *writeIterator++ = new_y3;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.right;
-        *writeIterator++ = uv.bottom;
-
-        *writeIterator++ = new_x1;
-        *writeIterator++ = new_y1;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.left;
-        *writeIterator++ = uv.top;
-
-        *writeIterator++ = new_x3;
-        *writeIterator++ = new_y3;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.right;
-        *writeIterator++ = uv.bottom;
-
-        *writeIterator++ = new_x4;
-        *writeIterator++ = new_y4;
-        *writeIterator++ = m_Z;
-        *writeIterator++ = m_Colour.r;
-        *writeIterator++ = m_Colour.g;
-        *writeIterator++ = m_Colour.b;
-        *writeIterator++ = m_Colour.a;
-        *writeIterator++ = uv.left;
-        *writeIterator++ = uv.bottom;
-
+        const Ogre::Font::UVRect& uv = m_Font->getGlyphTexCoords(c);
+        WriteGlyph(writeIterator, coords, m_Colour, m_Font->getGlyphTexCoords(c));
         m_TextRenderOp.vertexData->vertexCount += 6;
         m_TextRenderOp.vertexData->vertexCount += 6;
     }
     }
 
 
@@ -454,84 +380,81 @@ DebugDraw::Text( const float x, const float y, const Ogre::String& text )
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::Text( const Ogre::Vector3& point, const float x, const float y, const Ogre::String& text )
+DebugDraw::Text(const Ogre::Vector3& point, const float x, const float y, const Ogre::String& text)
 {
 {
-    Ogre::Vector3 point2d = CameraManager::getSingleton().ProjectPointToScreen( point );
+    Ogre::Vector3 point2d = CameraManager::getSingleton().ProjectPointToScreen(point);
 
 
-    if( point2d.z <= 0 )
+    if(point2d.z <= 0)
     {
     {
-        float dist_sq = point.squaredDistance( CameraManager::getSingleton().GetCurrentCamera()->getPosition() );
+        float dist_sq = point.squaredDistance(CameraManager::getSingleton().GetCurrentCamera()->getPosition());
 
 
-        if( dist_sq < m_FadeEndSquare )
+        if(dist_sq < m_FadeEndSquare)
         {
         {
-            float a = ( dist_sq > m_FadeStartSquare ) ? ( 1.0f - ( dist_sq - m_FadeStartSquare ) / ( m_FadeEndSquare - m_FadeStartSquare ) ) : 1.0f;
+            float a = (dist_sq > m_FadeStartSquare) ? (1.0f - (dist_sq - m_FadeStartSquare ) / ( m_FadeEndSquare - m_FadeStartSquare)) : 1.0f;
             Ogre::ColourValue colour = m_Colour;
             Ogre::ColourValue colour = m_Colour;
             colour.a = a;
             colour.a = a;
-            SetColour( colour );
-            Text( point2d.x + x, point2d.y + y, text );
+            SetColour(colour);
+            Text(point2d.x + x, point2d.y + y, text);
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-DebugDraw::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation )
+DebugDraw::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
 {
 {
-    if( queueGroupId == Ogre::RENDER_QUEUE_OVERLAY )
+    if(queueGroupId == Ogre::RENDER_QUEUE_OVERLAY)
     {
     {
-        m_RenderSystem->clearFrameBuffer( Ogre::FBT_DEPTH );
-        m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
-        m_RenderSystem->_setViewMatrix( Ogre::Matrix4::IDENTITY );
-        m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
+        m_RenderSystem->clearFrameBuffer(Ogre::FBT_DEPTH);
+        m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+        m_RenderSystem->_setViewMatrix(Ogre::Matrix4::IDENTITY);
+        m_RenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
 
 
-        if( m_LineRenderOp.vertexData->vertexCount != 0 )
+        if(m_LineRenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_SceneManager->_setPass( m_Material->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_LineRenderOp );
+            m_SceneManager->_setPass(m_Material->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_LineRenderOp);
             m_LineRenderOp.vertexData->vertexCount = 0;
             m_LineRenderOp.vertexData->vertexCount = 0;
         }
         }
 
 
-        if( m_QuadRenderOp.vertexData->vertexCount != 0 )
+        if(m_QuadRenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_SceneManager->_setPass( m_Material->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_QuadRenderOp );
+            m_SceneManager->_setPass(m_Material->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_QuadRenderOp);
             m_QuadRenderOp.vertexData->vertexCount = 0;
             m_QuadRenderOp.vertexData->vertexCount = 0;
         }
         }
 
 
-        if( m_TextRenderOp.vertexData->vertexCount != 0 )
+        if(m_TextRenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_SceneManager->_setPass( m_Font->getMaterial()->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_TextRenderOp );
+            m_SceneManager->_setPass(m_Font->getMaterial()->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_TextRenderOp);
             m_TextRenderOp.vertexData->vertexCount = 0;
             m_TextRenderOp.vertexData->vertexCount = 0;
         }
         }
     }
     }
-    else if( queueGroupId == Ogre::RENDER_QUEUE_MAIN )
+    else if(queueGroupId == Ogre::RENDER_QUEUE_MAIN)
     {
     {
-        m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
-        m_RenderSystem->_setViewMatrix( CameraManager::getSingleton().GetCurrentCamera()->getViewMatrix() );
-        m_RenderSystem->_setProjectionMatrix( CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrix() );
+        m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+        m_RenderSystem->_setViewMatrix(CameraManager::getSingleton().GetCurrentCamera()->getViewMatrix());
+        m_RenderSystem->_setProjectionMatrix(CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrix());
 
 
-        if( m_Line3dRenderOp.vertexData->vertexCount != 0 )
+        if(m_Line3dRenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_SceneManager->_setPass( m_Material3d->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_Line3dRenderOp );
+            m_SceneManager->_setPass(m_Material3d->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_Line3dRenderOp);
             m_Line3dRenderOp.vertexData->vertexCount = 0;
             m_Line3dRenderOp.vertexData->vertexCount = 0;
         }
         }
 
 
-        if( m_Triangle3dRenderOp.vertexData->vertexCount != 0 )
+        if(m_Triangle3dRenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_SceneManager->_setPass( m_Material3d->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_Triangle3dRenderOp );
+            m_SceneManager->_setPass(m_Material3d->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_Triangle3dRenderOp);
             m_Triangle3dRenderOp.vertexData->vertexCount = 0;
             m_Triangle3dRenderOp.vertexData->vertexCount = 0;
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::CreateLineVertexBuffer()
 DebugDraw::CreateLineVertexBuffer()
 {
 {
@@ -542,19 +465,18 @@ DebugDraw::CreateLineVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_LineRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_LineRenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
 
-    m_LineVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_LineMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_LineVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_LineMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_LineRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_LineVertexBuffer );
+    m_LineRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_LineVertexBuffer);
     m_LineRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     m_LineRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     m_LineRenderOp.useIndexes = false;
     m_LineRenderOp.useIndexes = false;
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::DestroyLineVertexBuffer()
 DebugDraw::DestroyLineVertexBuffer()
 {
 {
@@ -565,7 +487,6 @@ DebugDraw::DestroyLineVertexBuffer()
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::CreateLine3dVertexBuffer()
 DebugDraw::CreateLine3dVertexBuffer()
 {
 {
@@ -576,13 +497,13 @@ DebugDraw::CreateLine3dVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_Line3dRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_Line3dRenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
 
-    m_Line3dVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_Line3dMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_Line3dVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize( 0 ), m_Line3dMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_Line3dRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_Line3dVertexBuffer );
+    m_Line3dRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_Line3dVertexBuffer);
     m_Line3dRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     m_Line3dRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     m_Line3dRenderOp.useIndexes = false;
     m_Line3dRenderOp.useIndexes = false;
 }
 }
@@ -598,7 +519,6 @@ DebugDraw::DestroyLine3dVertexBuffer()
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::CreateTriangle3dVertexBuffer()
 DebugDraw::CreateTriangle3dVertexBuffer()
 {
 {
@@ -609,13 +529,13 @@ DebugDraw::CreateTriangle3dVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_Triangle3dRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_Triangle3dRenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
 
-    m_Triangle3dVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_Triangle3dMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_Triangle3dVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_Triangle3dMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_Triangle3dRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_Triangle3dVertexBuffer );
+    m_Triangle3dRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_Triangle3dVertexBuffer);
     m_Triangle3dRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_Triangle3dRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_Triangle3dRenderOp.useIndexes = false;
     m_Triangle3dRenderOp.useIndexes = false;
 }
 }
@@ -631,7 +551,6 @@ DebugDraw::DestroyTriangle3dVertexBuffer()
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::CreateQuadVertexBuffer()
 DebugDraw::CreateQuadVertexBuffer()
 {
 {
@@ -642,19 +561,18 @@ DebugDraw::CreateQuadVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_QuadRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_QuadRenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
 
-    m_QuadVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_QuadMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_QuadVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_QuadMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_QuadRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_QuadVertexBuffer );
+    m_QuadRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_QuadVertexBuffer);
     m_QuadRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_QuadRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_QuadRenderOp.useIndexes = false;
     m_QuadRenderOp.useIndexes = false;
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::DestroyQuadVertexBuffer()
 DebugDraw::DestroyQuadVertexBuffer()
 {
 {
@@ -665,7 +583,6 @@ DebugDraw::DestroyQuadVertexBuffer()
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::CreateTextVertexBuffer()
 DebugDraw::CreateTextVertexBuffer()
 {
 {
@@ -676,21 +593,20 @@ DebugDraw::CreateTextVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_TextRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_TextRenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
 
 
-    m_TextVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_TextMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_TextVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_TextMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_TextRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_TextVertexBuffer );
+    m_TextRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_TextVertexBuffer);
     m_TextRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_TextRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_TextRenderOp.useIndexes = false;
     m_TextRenderOp.useIndexes = false;
 }
 }
 
 
 
 
-
 void
 void
 DebugDraw::DestroyTextVertexBuffer()
 DebugDraw::DestroyTextVertexBuffer()
 {
 {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 177 - 252
QGearsMain/src/core/Entity.cpp


+ 9 - 12
QGearsMain/src/core/EntityCollision.cpp

@@ -1,7 +1,7 @@
-#include "core/EntityCollision.h"
-
 #include <OgreHardwareBufferManager.h>
 #include <OgreHardwareBufferManager.h>
 
 
+#include "core/EntityCollision.h"
+
 
 
 EntityCollision::EntityCollision()
 EntityCollision::EntityCollision()
 {
 {
@@ -16,14 +16,14 @@ EntityCollision::EntityCollision()
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
     Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
 
 
-    decl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
+    decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
     Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-            decl->getVertexSize( 0 ),
+            decl->getVertexSize(0),
             mRenderOp.vertexData->vertexCount,
             mRenderOp.vertexData->vertexCount,
-            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( 0, vbuf0 );
+            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+    bind->setBinding(0, vbuf0);
 
 
-    float* pPos = static_cast< float* >( vbuf0->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
+    float* pPos = static_cast<float*>(vbuf0->lock(Ogre::HardwareBuffer::HBL_DISCARD));
 
 
     *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
     *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  0.0f;
     *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
     *pPos++ = -1.0f; *pPos++ =  0.0f; *pPos++ =  1.0f;
@@ -116,26 +116,23 @@ EntityCollision::EntityCollision()
 
 
     Ogre::AxisAlignedBox aabb;
     Ogre::AxisAlignedBox aabb;
     aabb.setInfinite();
     aabb.setInfinite();
-    setBoundingBox( aabb );
+    setBoundingBox(aabb);
 }
 }
 
 
 
 
-
 EntityCollision::~EntityCollision()
 EntityCollision::~EntityCollision()
 {
 {
     delete mRenderOp.vertexData;
     delete mRenderOp.vertexData;
 }
 }
 
 
 
 
-
 Ogre::Real
 Ogre::Real
-EntityCollision::getSquaredViewDepth( const Ogre::Camera* cam ) const
+EntityCollision::getSquaredViewDepth(const Ogre::Camera* cam) const
 {
 {
     return 0.0f;
     return 0.0f;
 }
 }
 
 
 
 
-
 Ogre::Real
 Ogre::Real
 EntityCollision::getBoundingRadius() const
 EntityCollision::getBoundingRadius() const
 {
 {

+ 8 - 12
QGearsMain/src/core/EntityDirection.cpp

@@ -1,7 +1,6 @@
-#include "core/EntityDirection.h"
-
 #include <OgreHardwareBufferManager.h>
 #include <OgreHardwareBufferManager.h>
 
 
+#include "core/EntityDirection.h"
 
 
 
 
 EntityDirection::EntityDirection()
 EntityDirection::EntityDirection()
@@ -17,14 +16,14 @@ EntityDirection::EntityDirection()
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
     Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
 
 
-    decl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
+    decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
     Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-            decl->getVertexSize( 0 ),
+            decl->getVertexSize(0),
             mRenderOp.vertexData->vertexCount,
             mRenderOp.vertexData->vertexCount,
-            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( 0, vbuf0 );
+            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
+    bind->setBinding(0, vbuf0);
 
 
-    float* pPos = static_cast< float* >( vbuf0->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
+    float* pPos = static_cast<float*>(vbuf0->lock(Ogre::HardwareBuffer::HBL_DISCARD));
 
 
     *pPos++ = 0.0f; *pPos++ = 0.0f; *pPos++ = 0.0f;
     *pPos++ = 0.0f; *pPos++ = 0.0f; *pPos++ = 0.0f;
     *pPos++ = 0.0f; *pPos++ = -1.0f; *pPos++ = 0.0f;
     *pPos++ = 0.0f; *pPos++ = -1.0f; *pPos++ = 0.0f;
@@ -33,26 +32,23 @@ EntityDirection::EntityDirection()
 
 
     Ogre::AxisAlignedBox aabb;
     Ogre::AxisAlignedBox aabb;
     aabb.setInfinite();
     aabb.setInfinite();
-    setBoundingBox( aabb );
+    setBoundingBox(aabb);
 }
 }
 
 
 
 
-
 EntityDirection::~EntityDirection()
 EntityDirection::~EntityDirection()
 {
 {
     delete mRenderOp.vertexData;
     delete mRenderOp.vertexData;
 }
 }
 
 
 
 
-
 Ogre::Real
 Ogre::Real
-EntityDirection::getSquaredViewDepth( const Ogre::Camera* cam ) const
+EntityDirection::getSquaredViewDepth(const Ogre::Camera* cam) const
 {
 {
     return 0.0f;
     return 0.0f;
 }
 }
 
 
 
 
-
 Ogre::Real
 Ogre::Real
 EntityDirection::getBoundingRadius() const
 EntityDirection::getBoundingRadius() const
 {
 {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 227 - 305
QGearsMain/src/core/EntityManager.cpp


+ 46 - 55
QGearsMain/src/core/EntityModel.cpp

@@ -1,57 +1,51 @@
-#include "core/EntityModel.h"
-
 #include <OgreEntity.h>
 #include <OgreEntity.h>
 #include <OgreRoot.h>
 #include <OgreRoot.h>
 
 
+#include "core/EntityModel.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/Timer.h"
 #include "core/Timer.h"
 
 
 
 
-
-EntityModel::EntityModel( const Ogre::String& name, const Ogre::String file_name, Ogre::SceneNode* node ):
-    Entity( name, node ),
-    m_AnimationCurrent( NULL )
+EntityModel::EntityModel(const Ogre::String& name, const Ogre::String file_name, Ogre::SceneNode* node):
+    Entity(name, node),
+    m_AnimationCurrent(nullptr)
 {
 {
     Ogre::SceneManager* scene_manager;
     Ogre::SceneManager* scene_manager;
-    scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    m_Model = scene_manager->createEntity( m_Name, file_name );
-    m_Model->setVisible( true );
+    scene_manager = Ogre::Root::getSingleton().getSceneManager("Scene");
+    m_Model = scene_manager->createEntity(m_Name, file_name);
+    m_Model->setVisible(true);
 
 
-    PlayAnimation( m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1 );
+    PlayAnimation(m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
 
 
-    m_ModelNode->attachObject( m_Model );
+    m_ModelNode->attachObject(m_Model);
 }
 }
 
 
 
 
-
 EntityModel::~EntityModel()
 EntityModel::~EntityModel()
 {
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Model );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(m_Model);
 }
 }
 
 
 
 
-
 void
 void
 EntityModel::Update()
 EntityModel::Update()
 {
 {
-    if( m_AnimationAutoPlay == true )
+    if(m_AnimationAutoPlay == true)
     {
     {
-        UpdateAnimation( Timer::getSingleton().GetGameTimeDelta() );
+        UpdateAnimation(Timer::getSingleton().GetGameTimeDelta());
     }
     }
 
 
     Entity::Update();
     Entity::Update();
 }
 }
 
 
 
 
-
 void
 void
-EntityModel::SetVisible( const bool visible )
+EntityModel::SetVisible(const bool visible)
 {
 {
-    m_Model->setVisible( visible );
+    m_Model->setVisible(visible);
 }
 }
 
 
 
 
-
 bool
 bool
 EntityModel::IsVisible() const
 EntityModel::IsVisible() const
 {
 {
@@ -59,83 +53,80 @@ EntityModel::IsVisible() const
 }
 }
 
 
 
 
-
 void
 void
-EntityModel::PlayAnimation( const Ogre::String& animation, Entity::AnimationState state, Entity::AnimationPlayType play_type, const float start, const float end )
+EntityModel::PlayAnimation(const Ogre::String& animation, Entity::AnimationState state, Entity::AnimationPlayType play_type, const float start, const float end)
 {
 {
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != nullptr)
     {
     {
-        m_AnimationCurrent->setEnabled( false );
+        m_AnimationCurrent->setEnabled(false);
     }
     }
 
 
-    if( m_Model->getAllAnimationStates()->hasAnimationState( animation ) == true )
+    if(m_Model->getAllAnimationStates()->hasAnimationState(animation) == true)
     {
     {
         m_AnimationCurrentName = animation;
         m_AnimationCurrentName = animation;
-        m_AnimationCurrent = m_Model->getAnimationState( animation );
-        m_AnimationCurrent->setLoop( ( play_type == Entity::PLAY_LOOPED ) ? true : false );
-        m_AnimationCurrent->setEnabled( true );
-        m_AnimationCurrent->setTimePosition( ( start == -1 ) ? m_AnimationCurrent->getLength() : start );
+        m_AnimationCurrent = m_Model->getAnimationState(animation);
+        m_AnimationCurrent->setLoop((play_type == Entity::PLAY_LOOPED) ? true : false);
+        m_AnimationCurrent->setEnabled(true);
+        m_AnimationCurrent->setTimePosition((start == -1) ? m_AnimationCurrent->getLength() : start);
 
 
-        m_AnimationEndTime = ( end == -1 ) ? m_AnimationCurrent->getLength() : end;
+        m_AnimationEndTime = (end == -1) ? m_AnimationCurrent->getLength() : end;
         m_AnimationState = state;
         m_AnimationState = state;
         m_AnimationPlayType = play_type;
         m_AnimationPlayType = play_type;
     }
     }
     else
     else
     {
     {
-        LOG_ERROR( "Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'." );
+        LOG_ERROR("Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'.");
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-EntityModel::PlayAnimationContinue( const Ogre::String& animation )
+EntityModel::PlayAnimationContinue(const Ogre::String& animation)
 {
 {
-    if( m_AnimationCurrent == NULL ||                                                 // if animation isn't played
-        ( m_Model->getAllAnimationStates()->hasAnimationState( animation ) == true && // and we want to play animation that exist (use this to avoid exception)
-          ( m_AnimationCurrent != m_Model->getAnimationState( animation ) ||          // and animation we want is not animation that currently playing
-            m_AnimationPlayType != Entity::PLAY_LOOPED ) ) )                                       // or now playing animation we want but it doesn't looped
+    if(m_AnimationCurrent == nullptr ||                                                 // if animation isn't played
+        (m_Model->getAllAnimationStates()->hasAnimationState(animation) == true && // and we want to play animation that exist (use this to avoid exception)
+          (m_AnimationCurrent != m_Model->getAnimationState(animation) ||          // and animation we want is not animation that currently playing
+            m_AnimationPlayType != Entity::PLAY_LOOPED)))                                       // or now playing animation we want but it doesn't looped
     {
     {
-        PlayAnimation( animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1 );
+        PlayAnimation(animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-EntityModel::UpdateAnimation( const float delta )
+EntityModel::UpdateAnimation(const float delta)
 {
 {
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != nullptr)
     {
     {
         float delta_mod = delta * m_AnimationSpeed;
         float delta_mod = delta * m_AnimationSpeed;
 
 
-        bool stop_check = ( m_AnimationCurrent->hasEnded() == true ) || ( m_AnimationCurrent->getTimePosition() + delta_mod >= m_AnimationEndTime );
+        bool stop_check = (m_AnimationCurrent->hasEnded() == true) || (m_AnimationCurrent->getTimePosition() + delta_mod >= m_AnimationEndTime);
 
 
-        if( stop_check == true )
+        if(stop_check == true)
         {
         {
-            //LOG_TRIVIAL( "Animation finished for entity \"" + m_Name + "\"." );
-            for( size_t i = 0; i < m_AnimationSync.size(); ++i)
+            //LOG_TRIVIAL("Animation finished for entity \"" + m_Name + "\".");
+            for(size_t i = 0; i < m_AnimationSync.size(); ++i)
             {
             {
-                ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationSync[ i ] );
+                ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationSync[i]);
             }
             }
             m_AnimationSync.clear();
             m_AnimationSync.clear();
 
 
-            if( m_AnimationPlayType == Entity::PLAY_DEFAULT )
+            if(m_AnimationPlayType == Entity::PLAY_DEFAULT)
             {
             {
-                float time = ( m_AnimationCurrent->hasEnded() != true ) ? m_AnimationCurrent->getTimePosition() : 0;
-                PlayAnimation( m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, time, -1 );
-                m_AnimationCurrent->addTime( delta_mod );
+                float time = (m_AnimationCurrent->hasEnded() != true) ? m_AnimationCurrent->getTimePosition() : 0;
+                PlayAnimation(m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, time, -1);
+                m_AnimationCurrent->addTime(delta_mod);
             }
             }
-            else if( m_AnimationPlayType == Entity::PLAY_LOOPED )
+            else if(m_AnimationPlayType == Entity::PLAY_LOOPED)
             {
             {
-                float time = ( m_AnimationCurrent->hasEnded() != true ) ? m_AnimationCurrent->getTimePosition() : m_AnimationCurrent->getTimePosition() - m_AnimationCurrent->getLength();
-                PlayAnimation( m_AnimationCurrentName, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, time, -1 );
-                m_AnimationCurrent->addTime( delta_mod );
+                float time = (m_AnimationCurrent->hasEnded() != true) ? m_AnimationCurrent->getTimePosition() : m_AnimationCurrent->getTimePosition() - m_AnimationCurrent->getLength();
+                PlayAnimation(m_AnimationCurrentName, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, time, -1);
+                m_AnimationCurrent->addTime(delta_mod);
             }
             }
         }
         }
         else
         else
         {
         {
-            m_AnimationCurrent->addTime( delta_mod );
+            m_AnimationCurrent->addTime(delta_mod);
         }
         }
     }
     }
 }
 }

+ 17 - 29
QGearsMain/src/core/EntityPoint.cpp

@@ -1,49 +1,43 @@
-#include "core/EntityPoint.h"
-
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
+#include "core/EntityPoint.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
 
 
 
 
-
-ConfigVar cv_debug_point( "debug_point", "Draw point debug info", "false" );
+ConfigVar cv_debug_point("debug_point", "Draw point debug info", "false");
 
 
 
 
-
-EntityPoint::EntityPoint( const Ogre::String& name ):
-    m_Name( name ),
-    m_Position( Ogre::Vector3::ZERO ),
-    m_Rotation( 0 )
+EntityPoint::EntityPoint(const Ogre::String& name):
+    m_Name(name),
+    m_Position(Ogre::Vector3::ZERO),
+    m_Rotation(0)
 {
 {
 }
 }
 
 
 
 
-
 EntityPoint::~EntityPoint()
 EntityPoint::~EntityPoint()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 EntityPoint::UpdateDebug()
 EntityPoint::UpdateDebug()
 {
 {
-    if( cv_debug_point.GetB() == true )
+    if(cv_debug_point.GetB() == true)
     {
     {
-        DEBUG_DRAW.SetColour( Ogre::ColourValue::White );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
         Ogre::Vector3 point1 = m_Position;
         Ogre::Vector3 point1 = m_Position;
         point1.z += 0.5f;
         point1.z += 0.5f;
         Ogre::Vector3 point2 = m_Position;
         Ogre::Vector3 point2 = m_Position;
         point2.z -= 0.5f;
         point2.z -= 0.5f;
-        DEBUG_DRAW.Line3d( point1, point2 );
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.CENTER );
-        DEBUG_DRAW.SetFadeDistance( 30, 40 );
-        DEBUG_DRAW.Text( m_Position, 0, 0, m_Name );
+        DEBUG_DRAW.Line3d(point1, point2);
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.CENTER);
+        DEBUG_DRAW.SetFadeDistance(30, 40);
+        DEBUG_DRAW.Text(m_Position, 0, 0, m_Name);
     }
     }
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 EntityPoint::GetName() const
 EntityPoint::GetName() const
 {
 {
@@ -51,16 +45,14 @@ EntityPoint::GetName() const
 }
 }
 
 
 
 
-
 void
 void
-EntityPoint::SetPosition( const Ogre::Vector3& point )
+EntityPoint::SetPosition(const Ogre::Vector3& point)
 {
 {
     m_Position = point;
     m_Position = point;
 
 
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
 EntityPoint::GetPosition() const
 EntityPoint::GetPosition() const
 {
 {
@@ -68,25 +60,22 @@ EntityPoint::GetPosition() const
 }
 }
 
 
 
 
-
 void
 void
 EntityPoint::ScriptGetPosition() const
 EntityPoint::ScriptGetPosition() const
 {
 {
-    ScriptManager::getSingleton().AddValueToStack( m_Position.x );
-    ScriptManager::getSingleton().AddValueToStack( m_Position.y );
-    ScriptManager::getSingleton().AddValueToStack( m_Position.z );
+    ScriptManager::getSingleton().AddValueToStack(m_Position.x);
+    ScriptManager::getSingleton().AddValueToStack(m_Position.y);
+    ScriptManager::getSingleton().AddValueToStack(m_Position.z);
 }
 }
 
 
 
 
-
 void
 void
-EntityPoint::SetRotation( const float rotation )
+EntityPoint::SetRotation(const float rotation)
 {
 {
     m_Rotation = rotation;
     m_Rotation = rotation;
 }
 }
 
 
 
 
-
 float
 float
 EntityPoint::GetRotation() const
 EntityPoint::GetRotation() const
 {
 {
@@ -94,7 +83,6 @@ EntityPoint::GetRotation() const
 }
 }
 
 
 
 
-
 float
 float
 EntityPoint::ScriptGetRotation() const
 EntityPoint::ScriptGetRotation() const
 {
 {

+ 37 - 51
QGearsMain/src/core/EntityTrigger.cpp

@@ -1,69 +1,63 @@
-#include "core/EntityTrigger.h"
-
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
 #include "core/Entity.h"
 #include "core/Entity.h"
+#include "core/EntityTrigger.h"
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
 
 
 
 
-
-ConfigVar cv_debug_trigger( "debug_trigger", "Draw entity trigger debug info", "0" );
+ConfigVar cv_debug_trigger("debug_trigger", "Draw entity trigger debug info", "0");
 
 
 
 
-
-EntityTrigger::EntityTrigger( const Ogre::String& name ):
+EntityTrigger::EntityTrigger(const Ogre::String& name):
     m_Name(name),
     m_Name(name),
-    m_Enabled( false ),
-    m_Point1( Ogre::Vector3::ZERO ),
-    m_Point2( Ogre::Vector3::ZERO )
+    m_Enabled(false),
+    m_Point1(Ogre::Vector3::ZERO),
+    m_Point2(Ogre::Vector3::ZERO)
 {
 {
 }
 }
 
 
 
 
-
 EntityTrigger::~EntityTrigger()
 EntityTrigger::~EntityTrigger()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 EntityTrigger::UpdateDebug()
 EntityTrigger::UpdateDebug()
 {
 {
-    if( cv_debug_trigger.GetB() == true )
+    if(cv_debug_trigger.GetB() == true)
     {
     {
-        if( m_Enabled == false )
+        if(m_Enabled == false)
         {
         {
-            DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.5f, 0.5f, 0.5f ) );
+            DEBUG_DRAW.SetColour(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
         }
         }
-        else if( m_Activators.size() > 0 )
+        else if(m_Activators.size() > 0)
         {
         {
-            DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.04f, 0.9f, 0.5f ) );
+            DEBUG_DRAW.SetColour(Ogre::ColourValue(0.04f, 0.9f, 0.5f));
         }
         }
         else
         else
         {
         {
-            DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.04f, 0.5f, 0.9f ) );
+            DEBUG_DRAW.SetColour(Ogre::ColourValue(0.04f, 0.5f, 0.9f));
         }
         }
-        DEBUG_DRAW.Line3d( m_Point1, m_Point2 );
+        DEBUG_DRAW.Line3d(m_Point1, m_Point2);
 
 
-        DEBUG_DRAW.SetColour( Ogre::ColourValue::White );
-        DEBUG_DRAW.SetScreenSpace( true );
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.CENTER );
-        DEBUG_DRAW.SetFadeDistance( 30, 40 );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
+        DEBUG_DRAW.SetScreenSpace(true);
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.CENTER);
+        DEBUG_DRAW.SetFadeDistance(30, 40);
 
 
-        Ogre::Vector3 center = m_Point2 - ( ( m_Point2 - m_Point1 ) / 2 );
+        Ogre::Vector3 center = m_Point2 - ((m_Point2 - m_Point1) / 2);
 
 
-        DEBUG_DRAW.Text( center, 0, 0, m_Name );
+        DEBUG_DRAW.Text(center, 0, 0, m_Name);
 
 
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.04f, 0.9f, 0.5f ) );
-        for( unsigned int i = 0; i < m_Activators.size(); ++i )
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(0.04f, 0.9f, 0.5f));
+        for(unsigned int i = 0; i < m_Activators.size(); ++i)
         {
         {
-            DEBUG_DRAW.Text( center, 0.0f, static_cast<float>(( i + 1 ) * 16), m_Activators[ i ]->GetName() );
+            DEBUG_DRAW.Text(center, 0.0f, static_cast<float>((i + 1) * 16), m_Activators[i]->GetName());
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 EntityTrigger::GetName() const
 EntityTrigger::GetName() const
 {
 {
@@ -71,20 +65,18 @@ EntityTrigger::GetName() const
 }
 }
 
 
 
 
-
 void
 void
-EntityTrigger::SetEnabled( const bool enabled )
+EntityTrigger::SetEnabled(const bool enabled)
 {
 {
     m_Enabled = enabled;
     m_Enabled = enabled;
 
 
-    if( enabled == false )
+    if(enabled == false)
     {
     {
         m_Activators.clear();
         m_Activators.clear();
     }
     }
 }
 }
 
 
 
 
-
 bool
 bool
 EntityTrigger::IsEnabled() const
 EntityTrigger::IsEnabled() const
 {
 {
@@ -92,48 +84,45 @@ EntityTrigger::IsEnabled() const
 }
 }
 
 
 
 
-
 void
 void
-EntityTrigger::AddActivator( Entity* activator )
+EntityTrigger::AddActivator(Entity* activator)
 {
 {
     // add only if this activator don't exist
     // add only if this activator don't exist
     unsigned int i = 0;
     unsigned int i = 0;
-    for( ; i < m_Activators.size(); ++i )
+    for(; i < m_Activators.size(); ++i)
     {
     {
-        if( m_Activators[ i ] == activator )
+        if(m_Activators[i] == activator)
         {
         {
             break;
             break;
         }
         }
     }
     }
-    if( i == m_Activators.size() )
+    if(i == m_Activators.size())
     {
     {
-        m_Activators.push_back( activator );
+        m_Activators.push_back(activator);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-EntityTrigger::RemoveActivator( Entity* activator )
+EntityTrigger::RemoveActivator(Entity* activator)
 {
 {
-    for( unsigned int i = 0; i < m_Activators.size(); ++i )
+    for(unsigned int i = 0; i < m_Activators.size(); ++i)
     {
     {
-        if( m_Activators[ i ] == activator )
+        if(m_Activators[i] == activator)
         {
         {
-            m_Activators.erase( m_Activators.begin() + i );
+            m_Activators.erase(m_Activators.begin() + i);
             return;
             return;
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 bool
 bool
-EntityTrigger::IsActivator( Entity* activator )
+EntityTrigger::IsActivator(Entity* activator)
 {
 {
-    for( unsigned int i = 0; i < m_Activators.size(); ++i )
+    for(unsigned int i = 0; i < m_Activators.size(); ++i)
     {
     {
-        if( m_Activators[ i ] == activator )
+        if(m_Activators[i] == activator)
         {
         {
             return true;
             return true;
         }
         }
@@ -143,16 +132,14 @@ EntityTrigger::IsActivator( Entity* activator )
 }
 }
 
 
 
 
-
 void
 void
-EntityTrigger::SetPoints( const Ogre::Vector3& point1, const Ogre::Vector3& point2 )
+EntityTrigger::SetPoints(const Ogre::Vector3& point1, const Ogre::Vector3& point2)
 {
 {
     m_Point1 = point1;
     m_Point1 = point1;
     m_Point2 = point2;
     m_Point2 = point2;
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
 EntityTrigger::GetPoint1() const
 EntityTrigger::GetPoint1() const
 {
 {
@@ -160,7 +147,6 @@ EntityTrigger::GetPoint1() const
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
 EntityTrigger::GetPoint2() const
 EntityTrigger::GetPoint2() const
 {
 {

+ 63 - 79
QGearsMain/src/core/GameFrameListner.cpp

@@ -1,5 +1,3 @@
-#include "core/GameFrameListner.h"
-
 #include <OgreStringConverter.h>
 #include <OgreStringConverter.h>
 
 
 #include "QGearsGameState.h"
 #include "QGearsGameState.h"
@@ -8,6 +6,7 @@
 #include "core/Console.h"
 #include "core/Console.h"
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
 #include "core/EntityManager.h"
 #include "core/EntityManager.h"
+#include "core/GameFrameListner.h"
 #include "core/InputManager.h"
 #include "core/InputManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
@@ -15,80 +14,75 @@
 #include "core/UiManager.h"
 #include "core/UiManager.h"
 
 
 
 
-
-ConfigVar cv_debug_fps( "debug_fps", "Debug FPS", "false" );
-
+ConfigVar cv_debug_fps("debug_fps", "Debug FPS", "false");
 
 
 
 
-GameFrameListener::GameFrameListener( Ogre::RenderWindow* win ):
-    m_Window( win ),
+GameFrameListener::GameFrameListener(Ogre::RenderWindow* win):
+    m_Window(win),
 
 
-    m_InputManager( 0 ),
-    m_Keyboard( 0 )
+    m_InputManager(0),
+    m_Keyboard(0)
 {
 {
     OIS::ParamList pl;
     OIS::ParamList pl;
     size_t windowHnd = 0;
     size_t windowHnd = 0;
     std::ostringstream windowHndStr;
     std::ostringstream windowHndStr;
 
 
-    win->getCustomAttribute( "WINDOW", &windowHnd );
+    win->getCustomAttribute("WINDOW", &windowHnd);
     windowHndStr << windowHnd;
     windowHndStr << windowHnd;
-    pl.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) );
+    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 
 
 #if defined __WIN32__
 #if defined __WIN32__
-    pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string( "DISCL_FOREGROUND" ) ) );
-    pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string( "DISCL_NONEXCLUSIVE" ) ) );
+    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
 #else
 #else
-    pl.insert( std::make_pair( std::string( "x11_mouse_grab" ), std::string( "false" ) ) );
-    pl.insert( std::make_pair( std::string( "x11_mouse_hide" ), std::string( "false" ) ) );
-   // pl.insert( std::make_pair(std::string( "x11_keyboard_grab" ), std::string( "false" ) ) );
+    pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
+    pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
+   // pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
 #endif
 #endif
 
 
-    m_InputManager = OIS::InputManager::createInputSystem( pl );
+    m_InputManager = OIS::InputManager::createInputSystem(pl);
 
 
-    m_Keyboard = static_cast< OIS::Keyboard* >( m_InputManager->createInputObject( OIS::OISKeyboard, true ) );
-    m_Keyboard->setEventCallback( this );
+    m_Keyboard = static_cast< OIS::Keyboard* >(m_InputManager->createInputObject(OIS::OISKeyboard, true));
+    m_Keyboard->setEventCallback(this);
 
 
-    m_Mouse = static_cast< OIS::Mouse* >( m_InputManager->createInputObject( OIS::OISMouse, true ) );
-    m_Mouse->setEventCallback( this );
-    windowResized( m_Window );
+    m_Mouse = static_cast< OIS::Mouse* >(m_InputManager->createInputObject(OIS::OISMouse, true));
+    m_Mouse->setEventCallback(this);
+    windowResized(m_Window);
 
 
     //Register as a Window listener
     //Register as a Window listener
-    Ogre::WindowEventUtilities::addWindowEventListener( m_Window, this );
+    Ogre::WindowEventUtilities::addWindowEventListener(m_Window, this);
 }
 }
 
 
 
 
-
 GameFrameListener::~GameFrameListener()
 GameFrameListener::~GameFrameListener()
 {
 {
-    m_InputManager->destroyInputObject( m_Keyboard );
-    m_InputManager->destroyInputObject( m_Mouse );
+    m_InputManager->destroyInputObject(m_Keyboard);
+    m_InputManager->destroyInputObject(m_Mouse);
 
 
-    OIS::InputManager::destroyInputSystem( m_InputManager );
+    OIS::InputManager::destroyInputSystem(m_InputManager);
 
 
     //Remove ourself as a Window listener
     //Remove ourself as a Window listener
-    Ogre::WindowEventUtilities::removeWindowEventListener( m_Window, this );
-    windowClosed( m_Window );
+    Ogre::WindowEventUtilities::removeWindowEventListener(m_Window, this);
+    windowClosed(m_Window);
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::frameStarted( const Ogre::FrameEvent& evt )
+GameFrameListener::frameStarted(const Ogre::FrameEvent& evt)
 {
 {
-    Timer::getSingleton().AddTime( evt.timeSinceLastFrame );
+    Timer::getSingleton().AddTime(evt.timeSinceLastFrame);
 
 
-    if( QGears::g_ApplicationState == QGears::G_EXIT )
+    if(QGears::g_ApplicationState == QGears::G_EXIT)
     {
     {
         return false;
         return false;
     }
     }
 
 
-    if( m_Keyboard )
+    if(m_Keyboard)
     {
     {
        m_Keyboard->capture();
        m_Keyboard->capture();
     }
     }
 
 
-
-    if( m_Mouse )
+    if(m_Mouse)
     {
     {
        m_Mouse->capture();
        m_Mouse->capture();
     }
     }
@@ -98,25 +92,25 @@ GameFrameListener::frameStarted( const Ogre::FrameEvent& evt )
     static InputEventArray input_event_array;
     static InputEventArray input_event_array;
     input_event_array.clear();
     input_event_array.clear();
 
 
-    InputManager::getSingleton().GetInputEvents( input_event_array );
+    InputManager::getSingleton().GetInputEvents(input_event_array);
 
 
     bool console_active = Console::getSingleton().IsVisible();
     bool console_active = Console::getSingleton().IsVisible();
 
 
-    for( size_t i = 0; i < input_event_array.size(); ++i )
+    for(size_t i = 0; i < input_event_array.size(); ++i)
     {
     {
-        Console::getSingleton().Input( input_event_array[ i ] );
+        Console::getSingleton().Input(input_event_array[ i ]);
 
 
-        if( console_active != true )
+        if(console_active != true)
         {
         {
-            EntityManager::getSingleton().Input( input_event_array[ i ] );
-            ScriptManager::getSingleton().Input( input_event_array[ i ] );
-            CameraManager::getSingleton().Input( input_event_array[ i ], evt.timeSinceLastFrame );
+            EntityManager::getSingleton().Input(input_event_array[ i ]);
+            ScriptManager::getSingleton().Input(input_event_array[ i ]);
+            CameraManager::getSingleton().Input(input_event_array[ i ], evt.timeSinceLastFrame);
         }
         }
     }
     }
 
 
     Console::getSingleton().Update();
     Console::getSingleton().Update();
 
 
-    ScriptManager::getSingleton().Update( ScriptManager::SYSTEM );
+    ScriptManager::getSingleton().Update(ScriptManager::SYSTEM);
     UiManager::getSingleton().Update();
     UiManager::getSingleton().Update();
     CameraManager::getSingleton().Update();
     CameraManager::getSingleton().Update();
     EntityManager::getSingleton().Update();
     EntityManager::getSingleton().Update();
@@ -125,39 +119,36 @@ GameFrameListener::frameStarted( const Ogre::FrameEvent& evt )
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::frameEnded( const Ogre::FrameEvent& evt )
+GameFrameListener::frameEnded(const Ogre::FrameEvent& evt)
 {
 {
-    if( cv_debug_fps.GetB() == true )
+    if(cv_debug_fps.GetB() == true)
     {
     {
         const Ogre::RenderTarget::FrameStats& stats = m_Window->getStatistics();
         const Ogre::RenderTarget::FrameStats& stats = m_Window->getStatistics();
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
-        DEBUG_DRAW.SetScreenSpace( true );
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
-        DEBUG_DRAW.Text( 10, 10, "Current FPS:" + Ogre::StringConverter::toString( stats.lastFPS ) );
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+        DEBUG_DRAW.SetScreenSpace(true);
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+        DEBUG_DRAW.Text(10, 10, "Current FPS:" + Ogre::StringConverter::toString(stats.lastFPS));
     }
     }
 
 
     return true;
     return true;
 }
 }
 
 
 
 
-
 void
 void
-GameFrameListener::windowMoved( Ogre::RenderWindow* rw )
+GameFrameListener::windowMoved(Ogre::RenderWindow* rw)
 {
 {
 }
 }
 
 
 
 
-
 void
 void
-GameFrameListener::windowResized( Ogre::RenderWindow *rw )
+GameFrameListener::windowResized(Ogre::RenderWindow *rw)
 {
 {
-    if( m_Mouse )
+    if(m_Mouse)
     {
     {
         const OIS::MouseState& ms = m_Mouse->getMouseState();
         const OIS::MouseState& ms = m_Mouse->getMouseState();
-        ms.width = ( int )rw->getWidth();
-        ms.height = ( int )rw->getHeight();
+        ms.width = (int)rw->getWidth();
+        ms.height = (int)rw->getHeight();
     }
     }
 
 
     Console::getSingleton().OnResize();
     Console::getSingleton().OnResize();
@@ -167,73 +158,66 @@ GameFrameListener::windowResized( Ogre::RenderWindow *rw )
 }
 }
 
 
 
 
-
 void
 void
-GameFrameListener::windowClosed( Ogre::RenderWindow* rw )
+GameFrameListener::windowClosed(Ogre::RenderWindow* rw)
 {
 {
     QGears::g_ApplicationState = QGears::G_EXIT;
     QGears::g_ApplicationState = QGears::G_EXIT;
 }
 }
 
 
 
 
-
 void
 void
-GameFrameListener::windowFocusChange( Ogre::RenderWindow* rw )
+GameFrameListener::windowFocusChange(Ogre::RenderWindow* rw)
 {
 {
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::keyPressed( const OIS::KeyEvent& event )
+GameFrameListener::keyPressed(const OIS::KeyEvent& event)
 {
 {
-    InputManager::getSingleton().ButtonPressed( event.key, event.text, true );
+    InputManager::getSingleton().ButtonPressed(event.key, event.text, true);
 
 
     return true;
     return true;
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::keyReleased( const OIS::KeyEvent& event )
+GameFrameListener::keyReleased(const OIS::KeyEvent& event)
 {
 {
-    InputManager::getSingleton().ButtonPressed( event.key, event.text, false );
+    InputManager::getSingleton().ButtonPressed(event.key, event.text, false);
 
 
     return true;
     return true;
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::mouseMoved( const OIS::MouseEvent& e )
+GameFrameListener::mouseMoved(const OIS::MouseEvent& e)
 {
 {
-    if( e.state.Z.rel != 0 )
+    if(e.state.Z.rel != 0)
     {
     {
-        InputManager::getSingleton().MouseScrolled( e.state.Z.rel );
+        InputManager::getSingleton().MouseScrolled(e.state.Z.rel);
     }
     }
     else
     else
     {
     {
-        InputManager::getSingleton().MouseMoved( e.state.X.rel, e.state.Y.rel );
+        InputManager::getSingleton().MouseMoved(e.state.X.rel, e.state.Y.rel);
     }
     }
 
 
     return true;
     return true;
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::mousePressed( const OIS::MouseEvent& e, OIS::MouseButtonID id )
+GameFrameListener::mousePressed(const OIS::MouseEvent& e, OIS::MouseButtonID id)
 {
 {
-    InputManager::getSingleton().MousePressed( id, true );
+    InputManager::getSingleton().MousePressed(id, true);
 
 
     return true;
     return true;
 }
 }
 
 
 
 
-
 bool
 bool
-GameFrameListener::mouseReleased( const OIS::MouseEvent& e, OIS::MouseButtonID id )
+GameFrameListener::mouseReleased(const OIS::MouseEvent& e, OIS::MouseButtonID id)
 {
 {
-    InputManager::getSingleton().MousePressed( id, false );
+    InputManager::getSingleton().MousePressed(id, false);
 
 
     return true;
     return true;
 }
 }

+ 46 - 60
QGearsMain/src/core/InputManager.cpp

@@ -1,20 +1,17 @@
-#include "core/InputManager.h"
-#include "core/InputManagerCommands.h"
-
 #include "core/ConfigCmdManager.h"
 #include "core/ConfigCmdManager.h"
 #include "core/Console.h"
 #include "core/Console.h"
+#include "core/InputManager.h"
+#include "core/InputManagerCommands.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/Timer.h"
 #include "core/Timer.h"
 
 
 
 
-
-template<>InputManager *Ogre::Singleton< InputManager >::msSingleton = NULL;
-
+template<>InputManager *Ogre::Singleton<InputManager>::msSingleton = nullptr;
 
 
 
 
 InputManager::InputManager():
 InputManager::InputManager():
-    m_RepeatFirstWait( true ),
-    m_RepeatTimer( 0 )
+    m_RepeatFirstWait(true),
+    m_RepeatTimer(0)
 {
 {
     InitCmd();
     InitCmd();
 
 
@@ -22,31 +19,28 @@ InputManager::InputManager():
 }
 }
 
 
 
 
-
 InputManager::~InputManager()
 InputManager::~InputManager()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 InputManager::Reset()
 InputManager::Reset()
 {
 {
-    for( int button = 0; button < 256; ++button )
+    for(int button = 0; button < 256; ++button)
     {
     {
-        m_ButtonState[ button ] = false;
+        m_ButtonState[button] = false;
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-InputManager::ButtonPressed( int button, char text, bool down )
+InputManager::ButtonPressed(int button, char text, bool down)
 {
 {
-    if( m_ButtonState[ button ] != down )
+    if(m_ButtonState[button] != down)
     {
     {
-        m_ButtonState[ button ] = down;
-        m_ButtonText[ button ] = text;
+        m_ButtonState[button] = down;
+        m_ButtonText[button] = text;
 
 
         m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_KEY_PRESS : QGears::ET_KEY_RELEASE, static_cast<float>(button), static_cast<float>(text)));
         m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_KEY_PRESS : QGears::ET_KEY_RELEASE, static_cast<float>(button), static_cast<float>(text)));
 
 
@@ -54,48 +48,44 @@ InputManager::ButtonPressed( int button, char text, bool down )
         m_RepeatTimer = 0;
         m_RepeatTimer = 0;
     }
     }
 
 
-    if( down == true && Console::getSingleton().IsVisible() != true )
+    if(down == true && Console::getSingleton().IsVisible() != true)
     {
     {
-        ActivateBinds( button );
+        ActivateBinds(button);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-InputManager::MousePressed( int button, bool down )
+InputManager::MousePressed(int button, bool down)
 {
 {
     m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_MOUSE_PRESS : QGears::ET_MOUSE_RELEASE, static_cast<float>(button), 0.0f));
     m_EventQueue.push_back(QGears::Event((down == true) ? QGears::ET_MOUSE_PRESS : QGears::ET_MOUSE_RELEASE, static_cast<float>(button), 0.0f));
 }
 }
 
 
 
 
-
 void
 void
-InputManager::MouseMoved( int x, int y )
+InputManager::MouseMoved(int x, int y)
 {
 {
     m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_MOVE, static_cast<float>(x), static_cast<float>(y)));
     m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_MOVE, static_cast<float>(x), static_cast<float>(y)));
 }
 }
 
 
 
 
-
 void
 void
-InputManager::MouseScrolled( int value )
+InputManager::MouseScrolled(int value)
 {
 {
     m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_SCROLL, static_cast<float>(value), 0.0f));
     m_EventQueue.push_back(QGears::Event(QGears::ET_MOUSE_SCROLL, static_cast<float>(value), 0.0f));
 }
 }
 
 
 
 
-
 void
 void
 InputManager::Update()
 InputManager::Update()
 {
 {
     m_RepeatTimer += Timer::getSingleton().GetSystemTimeDelta();
     m_RepeatTimer += Timer::getSingleton().GetSystemTimeDelta();
 
 
-    if( ( m_RepeatFirstWait == true && m_RepeatTimer >= 0.5 ) || ( m_RepeatFirstWait == false && m_RepeatTimer >= 0.05 ) )
+    if((m_RepeatFirstWait == true && m_RepeatTimer >= 0.5) || (m_RepeatFirstWait == false && m_RepeatTimer >= 0.05))
     {
     {
-        for( int button = 0; button < 256; ++button )
+        for(int button = 0; button < 256; ++button)
         {
         {
-            if( m_ButtonState[ button ] == true )
+            if(m_ButtonState[button] == true)
             {
             {
                 m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_REPEAT, static_cast<float>(button), static_cast<float>(m_ButtonText[button])));
                 m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_REPEAT, static_cast<float>(button), static_cast<float>(m_ButtonText[button])));
             }
             }
@@ -106,9 +96,9 @@ InputManager::Update()
     }
     }
 
 
     // send impulses
     // send impulses
-    for( int button = 0; button < 256; ++button )
+    for(int button = 0; button < 256; ++button)
     {
     {
-        if( m_ButtonState[ button ] == true )
+        if(m_ButtonState[button] == true)
         {
         {
             m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_IMPULSE, static_cast<float>(button), static_cast<float>(m_ButtonText[button])));
             m_EventQueue.push_back(QGears::Event(QGears::ET_KEY_IMPULSE, static_cast<float>(button), static_cast<float>(m_ButtonText[button])));
         }
         }
@@ -116,17 +106,15 @@ InputManager::Update()
 }
 }
 
 
 
 
-
 bool
 bool
-InputManager::IsButtonPressed( int button ) const
+InputManager::IsButtonPressed(int button) const
 {
 {
-    return m_ButtonState[ button ];
+    return m_ButtonState[button];
 }
 }
 
 
 
 
-
 void
 void
-InputManager::GetInputEvents( InputEventArray& input_events )
+InputManager::GetInputEvents(InputEventArray& input_events)
 {
 {
     input_events = m_EventQueue;
     input_events = m_EventQueue;
 
 
@@ -134,71 +122,69 @@ InputManager::GetInputEvents( InputEventArray& input_events )
 }
 }
 
 
 
 
-
 void
 void
-InputManager::BindCommand( const Ogre::String& cmd, const ButtonList& buttons )
+InputManager::BindCommand(const Ogre::String& cmd, const ButtonList& buttons)
 {
 {
-    BindInfo info = BindInfo( cmd, buttons );
-    m_Binds.push_back( info );
+    BindInfo info = BindInfo(cmd, buttons);
+    m_Binds.push_back(info);
 }
 }
 
 
 
 
-
 void
 void
-InputManager::ActivateBinds( int button )
+InputManager::ActivateBinds(int button)
 {
 {
     std::vector< int > binds_indexes;
     std::vector< int > binds_indexes;
-    for( size_t i = 0; i < m_Binds.size(); ++i )
+    for(size_t i = 0; i < m_Binds.size(); ++i)
     {
     {
         // if we found pressed button in this bind
         // if we found pressed button in this bind
-        if( std::find( m_Binds[ i ].key_set.begin(), m_Binds[ i ].key_set.end(), button ) != m_Binds[ i ].key_set.end() )
+        if(std::find(m_Binds[i].key_set.begin(), m_Binds[i].key_set.end(), button) != m_Binds[i].key_set.end())
         {
         {
             size_t j = 0;
             size_t j = 0;
-            for( ; j < m_Binds[ i ].key_set.size(); ++j )
+            for(; j < m_Binds[i].key_set.size(); ++j)
             {
             {
-                if( IsButtonPressed( m_Binds[ i ].key_set[ j ] ) == false )
+                if(IsButtonPressed(m_Binds[i].key_set[j]) == false)
                 {
                 {
                     break;
                     break;
                 }
                 }
             }
             }
 
 
-            if( j >= m_Binds[ i ].key_set.size() )
+            if(j >= m_Binds[i].key_set.size())
             {
             {
-                binds_indexes.push_back( i );
+                binds_indexes.push_back(i);
             }
             }
         }
         }
     }
     }
 
 
     std::vector< int > binds_to_activate;
     std::vector< int > binds_to_activate;
     size_t max_size = 0;
     size_t max_size = 0;
-    for( size_t i = 0; i < binds_indexes.size(); ++i )
+    for(size_t i = 0; i < binds_indexes.size(); ++i)
     {
     {
-        if( max_size < m_Binds[ binds_indexes[ i ] ].key_set.size() )
+        if(max_size < m_Binds[binds_indexes[i]].key_set.size())
         {
         {
-            max_size = m_Binds[ binds_indexes[ i ] ].key_set.size();
+            max_size = m_Binds[binds_indexes[i]].key_set.size();
 
 
             binds_to_activate.clear();
             binds_to_activate.clear();
-            binds_to_activate.push_back( binds_indexes[ i ] );
+            binds_to_activate.push_back(binds_indexes[i]);
         }
         }
-        else if( max_size == m_Binds[ binds_indexes[ i ] ].key_set.size() )
+        else if(max_size == m_Binds[binds_indexes[i]].key_set.size())
         {
         {
-            binds_to_activate.push_back( binds_indexes[ i ] );
+            binds_to_activate.push_back(binds_indexes[i]);
         }
         }
     }
     }
 
 
-    for( size_t i = 0; i < binds_to_activate.size(); ++i )
+    for(size_t i = 0; i < binds_to_activate.size(); ++i)
     {
     {
-        Ogre::StringVector params = StringTokenise( m_Binds[ binds_to_activate[ i ] ].cmd );
+        Ogre::StringVector params = StringTokenise(m_Binds[binds_to_activate[i]].cmd);
 
 
         // handle command
         // handle command
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-        if( cmd != NULL )
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+        if(cmd != nullptr)
         {
         {
-            cmd->GetHandler()( params );
+            cmd->GetHandler()(params);
         }
         }
         else
         else
         {
         {
-            LOG_ERROR( "Can't find command \"" + params[ 0 ] + "\" in bind command \"" + m_Binds[ i ].cmd + "\"." );
+            LOG_ERROR("Can't find command \"" + params[0] + "\" in bind command \"" + m_Binds[i].cmd + "\".");
         }
         }
     }
     }
 }
 }

+ 206 - 234
QGearsMain/src/core/ScriptManager.cpp

@@ -1,66 +1,59 @@
-#include "core/ScriptManager.h"
-#include "core/ScriptManagerBinds.h"
-#include "core/ScriptManagerCommands.h"
-
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/ScriptManager.h"
+#include "core/ScriptManagerBinds.h"
+#include "core/ScriptManagerCommands.h"
 #include "core/Timer.h"
 #include "core/Timer.h"
 #include "core/Utilites.h"
 #include "core/Utilites.h"
 #include "core/XmlScriptsFile.h"
 #include "core/XmlScriptsFile.h"
 #include "LuaIncludes.h"
 #include "LuaIncludes.h"
 
 
 
 
-ConfigVar cv_debug_script( "debug_script", "Debug script flags. 0x01 - System, 0x02 - Entity, 0x04 - Ui.", "0" );
+ConfigVar cv_debug_script("debug_script", "Debug script flags. 0x01 - System, 0x02 - Entity, 0x04 - Ui.", "0");
+template<>ScriptManager *Ogre::Singleton<ScriptManager>::msSingleton = nullptr;
+Ogre::String script_entity_type[] = {"SYSTEM", "ENTITY", "UI"};
 
 
-Ogre::String script_entity_type[] = { "SYSTEM", "ENTITY", "UI" };
 
 
 bool
 bool
-priority_queue_compare( QueueScript a, QueueScript b )
+priority_queue_compare(QueueScript a, QueueScript b)
 {
 {
     return a.priority < b.priority;
     return a.priority < b.priority;
 }
 }
 
 
 
 
-
-template<>ScriptManager *Ogre::Singleton< ScriptManager >::msSingleton = NULL;
-
-
-
 ScriptManager::ScriptManager():
 ScriptManager::ScriptManager():
-    m_SystemTableName( "System" ),
-    m_EntityTableName( "EntityContainer" ),
-    m_UiTableName( "UiContainer" )
+    m_SystemTableName("System"),
+    m_EntityTableName("EntityContainer"),
+    m_UiTableName("UiContainer")
 {
 {
-    LOG_TRIVIAL( "ScriptManager started." );
+    LOG_TRIVIAL("ScriptManager started.");
 
 
     m_LuaState = lua_open();
     m_LuaState = lua_open();
-    luabind::open( m_LuaState );
-    luaopen_base( m_LuaState );
-    luaopen_string( m_LuaState );
-    luaopen_table( m_LuaState );
-    luaopen_math( m_LuaState );
+    luabind::open(m_LuaState);
+    luaopen_base(m_LuaState);
+    luaopen_string(m_LuaState);
+    luaopen_table(m_LuaState);
+    luaopen_math(m_LuaState);
 
 
     InitBinds();
     InitBinds();
     InitCmd();
     InitCmd();
 
 
-    RunFile( "system/system.lua" );
+    RunFile("system/system.lua");
 
 
-    XmlScriptsFile scripts( "./data/scripts.xml" );
+    XmlScriptsFile scripts("./data/scripts.xml");
     scripts.LoadScripts();
     scripts.LoadScripts();
 }
 }
 
 
 
 
-
 ScriptManager::~ScriptManager()
 ScriptManager::~ScriptManager()
 {
 {
-    lua_close( m_LuaState );
+    lua_close(m_LuaState);
 
 
-    LOG_TRIVIAL( "ScriptManager closed." );
+    LOG_TRIVIAL("ScriptManager closed.");
 }
 }
 
 
 
 
-
 void
 void
 ScriptManager::Input(const QGears::Event& event)
 ScriptManager::Input(const QGears::Event& event)
 {
 {
@@ -74,9 +67,9 @@ ScriptManager::Input(const QGears::Event& event)
                                         event.param1 == OIS::KC_RIGHT ||
                                         event.param1 == OIS::KC_RIGHT ||
                                         event.param1 == OIS::KC_DOWN ||
                                         event.param1 == OIS::KC_DOWN ||
                                         event.param1 == OIS::KC_UP
                                         event.param1 == OIS::KC_UP
-                                      ) )
+                                     ))
     {
     {
-        for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+        for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
         {
         {
             Ogre::String argument2 = "";
             Ogre::String argument2 = "";
             if (event.type == QGears::ET_KEY_PRESS)
             if (event.type == QGears::ET_KEY_PRESS)
@@ -87,84 +80,81 @@ ScriptManager::Input(const QGears::Event& event)
             {
             {
                 argument2 = "Repeat";
                 argument2 = "Repeat";
             }
             }
-            ScriptRequest( &m_ScriptEntity[ i ], "on_button", 100, KeyToString( ( OIS::KeyCode )((int)event.param1) ), argument2, false, false );
+            ScriptRequest(&m_ScriptEntity[i], "on_button", 100, KeyToString((OIS::KeyCode)((int)event.param1)), argument2, false, false);
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::Update( const ScriptManager::Type type )
+ScriptManager::Update(const ScriptManager::Type type)
 {
 {
     // resort all queue. This will give us correct info for debug draw.
     // resort all queue. This will give us correct info for debug draw.
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( m_ScriptEntity[ i ].type == type )
+        if(m_ScriptEntity[i].type == type)
         {
         {
-            if( m_ScriptEntity[ i ].queue.size() > 0 )
+            if(m_ScriptEntity[i].queue.size() > 0)
             {
             {
-                if( m_ScriptEntity[ i ].resort == true )
+                if(m_ScriptEntity[i].resort == true)
                 {
                 {
-                    std::stable_sort( m_ScriptEntity[ i ].queue.begin(), m_ScriptEntity[ i ].queue.end(), priority_queue_compare );
-                    m_ScriptEntity[ i ].resort = false;
+                    std::stable_sort(m_ScriptEntity[i].queue.begin(), m_ScriptEntity[i].queue.end(), priority_queue_compare);
+                    m_ScriptEntity[i].resort = false;
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
-
-
     // draw debug before update. This way it will be posible to see scripts that run once
     // draw debug before update. This way it will be posible to see scripts that run once
     int debug = cv_debug_script.GetI();
     int debug = cv_debug_script.GetI();
-    if( debug != 0 )
+    if(debug != 0)
     {
     {
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
-        DEBUG_DRAW.SetScreenSpace( true );
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+        DEBUG_DRAW.SetScreenSpace(true);
         int y = 34;
         int y = 34;
 
 
-        for( unsigned int i = 0; i < 3; ++i )
+        for(unsigned int i = 0; i < 3; ++i)
         {
         {
-            if( ( debug & ( 1 << i ) ) != 0 )
+            if((debug & (1 << i)) != 0)
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.8f, 0.8f, 0.0f, 1.0f ) );
-                DEBUG_DRAW.Text( 10.0f, static_cast<float>(y), "Script \"" + script_entity_type[ i ] + "\" entity:" );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(0.8f, 0.8f, 0.0f, 1.0f));
+                DEBUG_DRAW.Text(10.0f, static_cast<float>(y), "Script \"" + script_entity_type[i] + "\" entity:");
                 y += 16;
                 y += 16;
 
 
-                for( unsigned int j = 0; j < m_ScriptEntity.size(); ++j )
+                for(unsigned int j = 0; j < m_ScriptEntity.size(); ++j)
                 {
                 {
-                    if( m_ScriptEntity[ j ].type == i )
+                    if(m_ScriptEntity[j].type == i)
                     {
                     {
-                        Ogre::String text = m_ScriptEntity[ j ].name;
+                        Ogre::String text = m_ScriptEntity[j].name;
 
 
-                        unsigned int queue_size = m_ScriptEntity[ j ].queue.size();
-                        if( queue_size > 0 )
+                        unsigned int queue_size = m_ScriptEntity[j].queue.size();
+                        if(queue_size > 0)
                         {
                         {
                             text += ": ";
                             text += ": ";
-                            DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.8f, 0.8f, 0.0f, 1.0f ) );
+                            DEBUG_DRAW.SetColour(Ogre::ColourValue(0.8f, 0.8f, 0.0f, 1.0f));
                         }
                         }
                         else
                         else
                         {
                         {
-                            DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.5, 0.5, 0.5, 1 ) );
+                            DEBUG_DRAW.SetColour(Ogre::ColourValue(0.5, 0.5, 0.5, 1));
                         }
                         }
-                        for( unsigned int k = 0; k < queue_size; ++k )
+                        for(unsigned int k = 0; k < queue_size; ++k)
                         {
                         {
-                            if( k > 0 )
+                            if(k > 0)
                             {
                             {
                                 text += ", ";
                                 text += ", ";
                             }
                             }
-                            text += "(" + Ogre::StringConverter::toString( m_ScriptEntity[ j ].queue[ k ].priority ) + ")" + m_ScriptEntity[ j ].queue[ k ].function;
+                            text += "(" + Ogre::StringConverter::toString(m_ScriptEntity[j].queue[k].priority) + ")" + m_ScriptEntity[j].queue[k].function;
 
 
-                            if( m_ScriptEntity[ j ].queue[ k ].wait == true )
+                            if(m_ScriptEntity[j].queue[k].wait == true)
                             {
                             {
-                                if( m_ScriptEntity[ j ].queue[ k ].seconds_to_wait != 0 )
+                                if(m_ScriptEntity[j].queue[k].seconds_to_wait != 0)
                                 {
                                 {
-                                    text += ":wait( " + Ogre::StringConverter::toString( m_ScriptEntity[ j ].queue[ k ].seconds_to_wait ) + " )";
+                                    text += ":wait(" + Ogre::StringConverter::toString(m_ScriptEntity[j].queue[k].seconds_to_wait) + ")";
                                 }
                                 }
                             }
                             }
                         }
                         }
 
 
-                        DEBUG_DRAW.Text( 20.0f, static_cast<float>(y), text );
+                        DEBUG_DRAW.Text(20.0f, static_cast<float>(y), text);
                         y += 16;
                         y += 16;
                     }
                     }
                 }
                 }
@@ -172,119 +162,117 @@ ScriptManager::Update( const ScriptManager::Type type )
         }
         }
     }
     }
 
 
-
-
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( m_ScriptEntity[ i ].type == type )
+        if(m_ScriptEntity[i].type == type)
         {
         {
-            if( m_ScriptEntity[ i ].queue.size() > 0 )
+            if(m_ScriptEntity[i].queue.size() > 0)
             {
             {
-                m_CurrentScriptId.entity = m_ScriptEntity[ i ].name;
-                m_CurrentScriptId.function = m_ScriptEntity[ i ].queue[ 0 ].function;
+                m_CurrentScriptId.entity = m_ScriptEntity[i].name;
+                m_CurrentScriptId.function = m_ScriptEntity[i].queue[0].function;
 
 
-                if( m_ScriptEntity[ i ].queue[ 0 ].wait == false )
+                if(m_ScriptEntity[i].queue[0].wait == false)
                 {
                 {
-                    if( m_ScriptEntity[ i ].queue[ 0 ].yield == false)
+                    if(m_ScriptEntity[i].queue[0].yield == false)
                     {
                     {
-                        LOG_TRIVIAL( "[SCRIPT] Start script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\"." );
+                        LOG_TRIVIAL("[SCRIPT] Start script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\".");
 
 
-                        if( m_ScriptEntity[ i ].queue[ 0 ].paused_script_start.entity != "" )
+                        if(m_ScriptEntity[i].queue[0].paused_script_start.entity != "")
                         {
                         {
-                            ContinueScriptExecution( m_ScriptEntity[ i ].queue[ 0 ].paused_script_start );
-                            m_ScriptEntity[ i ].queue[ 0 ].paused_script_start.entity = "";
+                            ContinueScriptExecution(m_ScriptEntity[i].queue[0].paused_script_start);
+                            m_ScriptEntity[i].queue[0].paused_script_start.entity = "";
                         }
                         }
 
 
-                        luabind::object table = GetTableByEntityName( type, m_CurrentScriptId.entity, m_ScriptEntity[ i ].queue[ 0 ].state );
+                        luabind::object table = GetTableByEntityName(type, m_CurrentScriptId.entity, m_ScriptEntity[i].queue[0].state);
 
 
-                        if( table.is_valid() &&
-                            luabind::type( table ) == LUA_TTABLE &&
-                            luabind::type( table[ m_CurrentScriptId.function ] ) == LUA_TFUNCTION )
+                        if(table.is_valid() &&
+                            luabind::type(table) == LUA_TTABLE &&
+                            luabind::type(table[m_CurrentScriptId.function]) == LUA_TFUNCTION)
                         {
                         {
                             int ret = 0;
                             int ret = 0;
 
 
                             try
                             try
                             {
                             {
-                                ret = luabind::resume_function< int >( table[ m_CurrentScriptId.function ], table, m_ScriptEntity[ i ].queue[ 0 ].argument1.c_str(), m_ScriptEntity[ i ].queue[ 0 ].argument2.c_str() );
+                                ret = luabind::resume_function< int >(table[m_CurrentScriptId.function], table, m_ScriptEntity[i].queue[0].argument1.c_str(), m_ScriptEntity[i].queue[0].argument2.c_str());
                             }
                             }
-                            catch( luabind::error& /*e*/ )
+                            catch(luabind::error& /*e*/)
                             {
                             {
-                                LOG_ERROR( Ogre::String( lua_tostring( m_ScriptEntity[ i ].queue[ 0 ].state , -1 ) ) );
+                                LOG_ERROR(Ogre::String(lua_tostring(m_ScriptEntity[i].queue[0].state , -1)));
                             }
                             }
 
 
-                            if( ret == 0 )
+                            if(ret == 0)
                             {
                             {
-                                LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" finished." );
-                                if( m_ScriptEntity[ i ].queue[ 0 ].function != "on_update" )
+                                LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" finished.");
+                                if(m_ScriptEntity[i].queue[0].function != "on_update")
                                 {
                                 {
-                                    RemoveEntityTopScript( m_ScriptEntity[ i ] );
+                                    RemoveEntityTopScript(m_ScriptEntity[i]);
                                 }
                                 }
                             }
                             }
-                            else if( ret == 1 )
+                            else if(ret == 1)
                             {
                             {
-                                LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not paused and will be continued next cycle." );
-                                m_ScriptEntity[ i ].queue[ 0 ].yield = true;
+                                LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not paused and will be continued next cycle.");
+                                m_ScriptEntity[i].queue[0].yield = true;
                             }
                             }
                             else
                             else
                             {
                             {
-                                LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not finished yet." );
-                                m_ScriptEntity[ i ].queue[ 0 ].yield = true;
-                                m_ScriptEntity[ i ].queue[ 0 ].wait = true;
+                                LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not finished yet.");
+                                m_ScriptEntity[i].queue[0].yield = true;
+                                m_ScriptEntity[i].queue[0].wait = true;
                             }
                             }
                         }
                         }
                         else
                         else
                         {
                         {
-                            LOG_WARNING( "Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" doesn't exist." );
-                            RemoveEntityTopScript( m_ScriptEntity[ i ] );
+                            LOG_WARNING("Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" doesn't exist.");
+                            RemoveEntityTopScript(m_ScriptEntity[i]);
                         }
                         }
                     }
                     }
                     else
                     else
                     {
                     {
-                        LOG_TRIVIAL( "[SCRIPT] Continue function \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\"." );
+                        LOG_TRIVIAL("[SCRIPT] Continue function \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\".");
 
 
                         int ret = 0;
                         int ret = 0;
 
 
                         try
                         try
                         {
                         {
-                            ret = luabind::resume< int >( m_ScriptEntity[ i ].queue[ 0 ].state );
+                            ret = luabind::resume< int >(m_ScriptEntity[i].queue[0].state);
                         }
                         }
-                        catch( luabind::error& e )
+                        catch(luabind::error& e)
                         {
                         {
-                            luabind::object error_msg( luabind::from_stack( e.state(), -1 ) );
-                            LOG_WARNING( Ogre::String( luabind::object_cast< std::string >( error_msg ) ) );
+                            luabind::object error_msg(luabind::from_stack(e.state(), -1));
+                            LOG_WARNING(Ogre::String(luabind::object_cast< std::string >(error_msg)));
                         }
                         }
 
 
-                        if( ret == 0 ) // finished
+                        if(ret == 0) // finished
                         {
                         {
-                            LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" finished." );
+                            LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" finished.");
 
 
                             // stop yield for on_update
                             // stop yield for on_update
-                            m_ScriptEntity[ i ].queue[ 0 ].yield = false;
+                            m_ScriptEntity[i].queue[0].yield = false;
 
 
-                            if( m_ScriptEntity[ i ].queue[ 0 ].function != "on_update" )
+                            if(m_ScriptEntity[i].queue[0].function != "on_update")
                             {
                             {
-                                RemoveEntityTopScript( m_ScriptEntity[ i ] );
+                                RemoveEntityTopScript(m_ScriptEntity[i]);
                             }
                             }
                         }
                         }
-                        else if( ret == 1 )
+                        else if(ret == 1)
                         {
                         {
-                            LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not paused and will be continued next cycle." );
+                            LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not paused and will be continued next cycle.");
                         }
                         }
                         else
                         else
                         {
                         {
-                            LOG_TRIVIAL( "[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not finished yet." );
-                            m_ScriptEntity[ i ].queue[ 0 ].wait = true;
+                            LOG_TRIVIAL("[SCRIPT] Script \"" + m_CurrentScriptId.function + "\" for entity \"" + m_CurrentScriptId.entity + "\" not finished yet.");
+                            m_ScriptEntity[i].queue[0].wait = true;
                         }
                         }
                     }
                     }
                 }
                 }
-                else if( m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait > 0 )
+                else if(m_ScriptEntity[i].queue[0].seconds_to_wait > 0)
                 {
                 {
-                    m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait -= Timer::getSingleton().GetGameTimeDelta();
-                    m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait = ( m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait < 0 ) ? 0 : m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait;
+                    m_ScriptEntity[i].queue[0].seconds_to_wait -= Timer::getSingleton().GetGameTimeDelta();
+                    m_ScriptEntity[i].queue[0].seconds_to_wait = (m_ScriptEntity[i].queue[0].seconds_to_wait < 0) ? 0 : m_ScriptEntity[i].queue[0].seconds_to_wait;
 
 
-                    if( m_ScriptEntity[ i ].queue[ 0 ].seconds_to_wait == 0 )
+                    if(m_ScriptEntity[i].queue[0].seconds_to_wait == 0)
                     {
                     {
-                        m_ScriptEntity[ i ].queue[ 0 ].wait = false;
+                        m_ScriptEntity[i].queue[0].wait = false;
                     }
                     }
                 }
                 }
             }
             }
@@ -293,104 +281,100 @@ ScriptManager::Update( const ScriptManager::Type type )
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::RunString( const Ogre::String& lua )
+ScriptManager::RunString(const Ogre::String& lua)
 {
 {
-    if( luaL_dostring( m_LuaState, lua.c_str() ) == 1 )
+    if(luaL_dostring(m_LuaState, lua.c_str()) == 1)
     {
     {
-        LOG_ERROR( Ogre::String( lua_tostring( m_LuaState, -1 ) ) );
+        LOG_ERROR(Ogre::String(lua_tostring(m_LuaState, -1)));
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::RunFile( const Ogre::String& file )
+ScriptManager::RunFile(const Ogre::String& file)
 {
 {
-    if( luaL_dofile( m_LuaState, ( "./data/" + file ).c_str() ) == 1 )
+    if(luaL_dofile(m_LuaState, ("./data/" + file).c_str()) == 1)
     {
     {
-        LOG_ERROR( Ogre::String( lua_tostring( m_LuaState, -1 ) ) );
+        LOG_ERROR(Ogre::String(lua_tostring(m_LuaState, -1)));
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::AddEntity( const ScriptManager::Type type, const Ogre::String& entity_name, Entity* entity )
+ScriptManager::AddEntity(const ScriptManager::Type type, const Ogre::String& entity_name, Entity* entity)
 {
 {
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( m_ScriptEntity[ i ].type == type && m_ScriptEntity[ i ].name == entity_name )
+        if(m_ScriptEntity[i].type == type && m_ScriptEntity[i].name == entity_name)
         {
         {
-            LOG_ERROR( "Script \"" + script_entity_type[ type ] + "\" entity \"" + entity_name + "\" already exist in script manager." );
+            LOG_ERROR("Script \"" + script_entity_type[type] + "\" entity \"" + entity_name + "\" already exist in script manager.");
             return;
             return;
         }
         }
     }
     }
 
 
-    luabind::object table = GetTableByEntityName( type, entity_name, m_LuaState );
+    luabind::object table = GetTableByEntityName(type, entity_name, m_LuaState);
 
 
-    if( table.is_valid() && luabind::type( table ) == LUA_TTABLE )
+    if(table.is_valid() && luabind::type(table) == LUA_TTABLE)
     {
     {
         ScriptEntity script_entity;
         ScriptEntity script_entity;
         script_entity.name = entity_name;
         script_entity.name = entity_name;
         script_entity.type = type;
         script_entity.type = type;
 
 
         // init entity field for model entity
         // init entity field for model entity
-        if( entity != NULL )
+        if(entity != nullptr)
         {
         {
-            table[ "entity" ] = boost::ref( *entity );
+            table["entity"] = boost::ref(*entity);
         }
         }
 
 
         // check "on_start" script
         // check "on_start" script
-        if( luabind::type( table[ "on_start" ] ) == LUA_TFUNCTION )
+        if(luabind::type(table["on_start"]) == LUA_TFUNCTION)
         {
         {
             QueueScript script;
             QueueScript script;
             script.function = "on_start";
             script.function = "on_start";
             script.priority = 0;
             script.priority = 0;
-            script.state = lua_newthread( m_LuaState );
+            script.state = lua_newthread(m_LuaState);
             // we dont want thread to be garbage collected so we store it
             // we dont want thread to be garbage collected so we store it
-            script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
             script.seconds_to_wait = 0;
             script.seconds_to_wait = 0;
             script.wait = false;
             script.wait = false;
             script.yield = false;
             script.yield = false;
-            script_entity.queue.push_back( script );
+            script_entity.queue.push_back(script);
         }
         }
 
 
         // check "on_update" script
         // check "on_update" script
-        if( luabind::type( table[ "on_update" ] ) == LUA_TFUNCTION )
+        if(luabind::type(table["on_update"]) == LUA_TFUNCTION)
         {
         {
             QueueScript script;
             QueueScript script;
             script.function = "on_update";
             script.function = "on_update";
             script.priority = 999;
             script.priority = 999;
-            script.state = lua_newthread( m_LuaState );
+            script.state = lua_newthread(m_LuaState);
             // we dont want thread to be garbage collected so we store it
             // we dont want thread to be garbage collected so we store it
-            script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
             script.seconds_to_wait = 0;
             script.seconds_to_wait = 0;
             script.wait = false;
             script.wait = false;
             script.yield = false;
             script.yield = false;
-            script_entity.queue.push_back( script );
+            script_entity.queue.push_back(script);
         }
         }
 
 
-        m_ScriptEntity.push_back( script_entity );
+        m_ScriptEntity.push_back(script_entity);
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::RemoveEntity( const ScriptManager::Type type, const Ogre::String& entity_name )
+ScriptManager::RemoveEntity(const ScriptManager::Type type, const Ogre::String& entity_name)
 {
 {
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( m_ScriptEntity[ i ].type == type && m_ScriptEntity[ i ].name == entity_name )
+        if(m_ScriptEntity[i].type == type && m_ScriptEntity[i].name == entity_name)
         {
         {
-            while( m_ScriptEntity[ i ].queue.size() > 0 )
+            while(m_ScriptEntity[i].queue.size() > 0)
             {
             {
-                ScriptManager::RemoveEntityTopScript( m_ScriptEntity[ i ] );
+                ScriptManager::RemoveEntityTopScript(m_ScriptEntity[i]);
             }
             }
 
 
-            m_ScriptEntity.erase( m_ScriptEntity.begin() + i );
+            m_ScriptEntity.erase(m_ScriptEntity.begin() + i);
 
 
             return;
             return;
         }
         }
@@ -398,50 +382,48 @@ ScriptManager::RemoveEntity( const ScriptManager::Type type, const Ogre::String&
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::RemoveEntityTopScript( ScriptEntity& entity )
+ScriptManager::RemoveEntityTopScript(ScriptEntity& entity)
 {
 {
-    if( entity.queue.size() > 0 )
+    if(entity.queue.size() > 0)
     {
     {
         // delete thread
         // delete thread
-        luaL_unref( m_LuaState, LUA_REGISTRYINDEX, entity.queue[ 0 ].state_id );
+        luaL_unref(m_LuaState, LUA_REGISTRYINDEX, entity.queue[0].state_id);
 
 
-        if( entity.queue[ 0 ].paused_script_end.entity != "" )
+        if(entity.queue[0].paused_script_end.entity != "")
         {
         {
-            ContinueScriptExecution( entity.queue[ 0 ].paused_script_end );
-            entity.queue[ 0 ].paused_script_end.entity = "";
+            ContinueScriptExecution(entity.queue[0].paused_script_end);
+            entity.queue[0].paused_script_end.entity = "";
         }
         }
 
 
-        entity.queue.erase( entity.queue.begin() );
+        entity.queue.erase(entity.queue.begin());
     }
     }
 }
 }
 
 
 
 
-
 luabind::object
 luabind::object
-ScriptManager::GetTableByEntityName( const ScriptManager::Type type, const Ogre::String& name, lua_State* state ) const
+ScriptManager::GetTableByEntityName(const ScriptManager::Type type, const Ogre::String& name, lua_State* state) const
 {
 {
     // get real table by name
     // get real table by name
-    Ogre::StringVector table_path = StringTokenise( name, "." );
-    luabind::object table = luabind::globals( state );
+    Ogre::StringVector table_path = StringTokenise(name, ".");
+    luabind::object table = luabind::globals(state);
 
 
-    switch( type )
+    switch(type)
     {
     {
-        case ScriptManager::SYSTEM: table = table[ m_SystemTableName ]; break;
-        case ScriptManager::ENTITY: table = table[ m_EntityTableName ]; break;
-        case ScriptManager::UI: table = table[ m_UiTableName ]; break;
+        case ScriptManager::SYSTEM: table = table[m_SystemTableName]; break;
+        case ScriptManager::ENTITY: table = table[m_EntityTableName]; break;
+        case ScriptManager::UI: table = table[m_UiTableName]; break;
     }
     }
 
 
-    if( luabind::type( table ) != LUA_TTABLE )
+    if(luabind::type(table) != LUA_TTABLE)
     {
     {
         return luabind::object();
         return luabind::object();
     }
     }
 
 
-    for( unsigned int i = 0; i < table_path.size(); ++i )
+    for(unsigned int i = 0; i < table_path.size(); ++i)
     {
     {
-        table = table[ table_path[ i ] ];
-        if( luabind::type( table ) != LUA_TTABLE )
+        table = table[table_path[i]];
+        if(luabind::type(table) != LUA_TTABLE)
         {
         {
             return luabind::object();
             return luabind::object();
         }
         }
@@ -451,47 +433,44 @@ ScriptManager::GetTableByEntityName( const ScriptManager::Type type, const Ogre:
 }
 }
 
 
 
 
-
 QueueScript*
 QueueScript*
-ScriptManager::GetScriptByScriptId( const ScriptId& script ) const
+ScriptManager::GetScriptByScriptId(const ScriptId& script) const
 {
 {
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( script.entity == m_ScriptEntity[ i ].name )
+        if(script.entity == m_ScriptEntity[i].name)
         {
         {
-            for( unsigned int j = 0; j < m_ScriptEntity[ i ].queue.size(); ++j )
+            for(unsigned int j = 0; j < m_ScriptEntity[i].queue.size(); ++j)
             {
             {
-                if( script.function == m_ScriptEntity[ i ].queue[ j ].function )
+                if(script.function == m_ScriptEntity[i].queue[j].function)
                 {
                 {
-                    return ( QueueScript* ) &( m_ScriptEntity[ i ].queue[ j ] );
+                    return (QueueScript*) &(m_ScriptEntity[i].queue[j]);
                 }
                 }
             }
             }
 
 
-            return NULL;
+            return nullptr;
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 ScriptEntity*
 ScriptEntity*
-ScriptManager::GetScriptEntityByName( const Type type, const Ogre::String& entity_name ) const
+ScriptManager::GetScriptEntityByName(const Type type, const Ogre::String& entity_name) const
 {
 {
-    for( unsigned int i = 0; i < m_ScriptEntity.size(); ++i )
+    for(unsigned int i = 0; i < m_ScriptEntity.size(); ++i)
     {
     {
-        if( m_ScriptEntity[ i ].type == type && m_ScriptEntity[ i ].name == entity_name )
+        if(m_ScriptEntity[i].type == type && m_ScriptEntity[i].name == entity_name)
         {
         {
-            return ( ScriptEntity* ) &( m_ScriptEntity[ i ] );
+            return (ScriptEntity*) &(m_ScriptEntity[i]);
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 const ScriptId
 const ScriptId
 ScriptManager::GetCurrentScriptId() const
 ScriptManager::GetCurrentScriptId() const
 {
 {
@@ -499,15 +478,14 @@ ScriptManager::GetCurrentScriptId() const
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::ContinueScriptExecution( const ScriptId& script )
+ScriptManager::ContinueScriptExecution(const ScriptId& script)
 {
 {
-    QueueScript* script_pointer = GetScriptByScriptId( script );
+    QueueScript* script_pointer = GetScriptByScriptId(script);
 
 
-    if( script_pointer == NULL )
+    if(script_pointer == nullptr)
     {
     {
-        LOG_ERROR( "There is no script \"" + script.function + "\" for entity \"" + script.entity + "\". Can't continue script execution." );
+        LOG_ERROR("There is no script \"" + script.function + "\" for entity \"" + script.entity + "\". Can't continue script execution.");
         return;
         return;
     }
     }
 
 
@@ -515,21 +493,20 @@ ScriptManager::ContinueScriptExecution( const ScriptId& script )
 }
 }
 
 
 
 
-
 int
 int
-ScriptManager::ScriptWait( const float seconds )
+ScriptManager::ScriptWait(const float seconds)
 {
 {
-    LOG_TRIVIAL( "script:wait: We set script wait for " + Ogre::StringConverter::toString( seconds ) + " seconds." );
+    LOG_TRIVIAL("script:wait: We set script wait for " + Ogre::StringConverter::toString(seconds) + " seconds.");
 
 
-    QueueScript* script = GetScriptByScriptId( m_CurrentScriptId );
+    QueueScript* script = GetScriptByScriptId(m_CurrentScriptId);
 
 
-    if( script == NULL )
+    if(script == nullptr)
     {
     {
-        LOG_ERROR( "script:wait: Currently no any script running." );
+        LOG_ERROR("script:wait: Currently no any script running.");
         return 1;
         return 1;
     }
     }
 
 
-    if( seconds == 0 )
+    if(seconds == 0)
     {
     {
         return 1;
         return 1;
     }
     }
@@ -540,48 +517,46 @@ ScriptManager::ScriptWait( const float seconds )
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::ScriptRequest( const Type type, const char* entity, const char* function, const int priority )
+ScriptManager::ScriptRequest(const Type type, const char* entity, const char* function, const int priority)
 {
 {
-    LOG_TRIVIAL( "[SCRIPT] script:request: Request function \"" + Ogre::String( function ) + "\" for entity \"" + Ogre::String( entity ) + "\" with priority " + Ogre::StringConverter::toString( priority ) + "." );
+    LOG_TRIVIAL("[SCRIPT] script:request: Request function \"" + Ogre::String(function) + "\" for entity \"" + Ogre::String(entity) + "\" with priority " + Ogre::StringConverter::toString(priority) + ".");
 
 
-    ScriptEntity* script_entity = GetScriptEntityByName( type, Ogre::String( entity ) );
+    ScriptEntity* script_entity = GetScriptEntityByName(type, Ogre::String(entity));
 
 
-    if( script_entity == NULL )
+    if(script_entity == nullptr)
     {
     {
-        LOG_WARNING( "[SCRIPT] script:request: Entity \"" + Ogre::String( entity ) + "\" doesn't exist." );
+        LOG_WARNING("[SCRIPT] script:request: Entity \"" + Ogre::String(entity) + "\" doesn't exist.");
         return;
         return;
     }
     }
 
 
-    bool added = ScriptRequest( script_entity, function, priority, "", "", false, false );
+    bool added = ScriptRequest(script_entity, function, priority, "", "", false, false);
 
 
-    if( added == false )
+    if(added == false)
     {
     {
-        LOG_WARNING( "Script '" + Ogre::String( function ) + "' for entity '" +  Ogre::String( entity ) + "' doesn't exist." );
+        LOG_WARNING("Script '" + Ogre::String(function) + "' for entity '" +  Ogre::String(entity) + "' doesn't exist.");
     }
     }
 }
 }
 
 
 
 
-
 int
 int
-ScriptManager::ScriptRequestStartSync( const Type type, const char* entity, const char* function, const int priority )
+ScriptManager::ScriptRequestStartSync(const Type type, const char* entity, const char* function, const int priority)
 {
 {
-    LOG_TRIVIAL( "[SCRIPT] script:request_start_sync: Request function \"" + Ogre::String( function ) + "\" for entity \"" + Ogre::String( entity ) + "\" with priority " + Ogre::StringConverter::toString( priority ) + "." );
+    LOG_TRIVIAL("[SCRIPT] script:request_start_sync: Request function \"" + Ogre::String(function) + "\" for entity \"" + Ogre::String(entity) + "\" with priority " + Ogre::StringConverter::toString(priority) + ".");
 
 
-    ScriptEntity* script_entity = GetScriptEntityByName( type, Ogre::String( entity ) );
+    ScriptEntity* script_entity = GetScriptEntityByName(type, Ogre::String(entity));
 
 
-    if( script_entity == NULL )
+    if(script_entity == nullptr)
     {
     {
-        LOG_ERROR( "[SCRIPT] script:request_start_sync: Entity \"" + Ogre::String( entity ) + "\" doesn't exist." );
+        LOG_ERROR("[SCRIPT] script:request_start_sync: Entity \"" + Ogre::String(entity) + "\" doesn't exist.");
         return 1;
         return 1;
     }
     }
 
 
-    bool added = ScriptRequest( script_entity, function, priority, "", "", true, false );
+    bool added = ScriptRequest(script_entity, function, priority, "", "", true, false);
 
 
-    if( added == false )
+    if(added == false)
     {
     {
-        LOG_WARNING( "Script '" + Ogre::String( function ) + "' for entity '" +  Ogre::String( entity ) + "' doesn't exist." );
+        LOG_WARNING("Script '" + Ogre::String(function) + "' for entity '" +  Ogre::String(entity) + "' doesn't exist.");
         return 1;
         return 1;
     }
     }
 
 
@@ -589,25 +564,24 @@ ScriptManager::ScriptRequestStartSync( const Type type, const char* entity, cons
 }
 }
 
 
 
 
-
 int
 int
-ScriptManager::ScriptRequestEndSync( const Type type, const char* entity, const char* function, const int priority )
+ScriptManager::ScriptRequestEndSync(const Type type, const char* entity, const char* function, const int priority)
 {
 {
-    LOG_TRIVIAL( "[SCRIPT] script:request_end_sync: Request function \"" + Ogre::String( function ) + "\" for entity \"" + Ogre::String( entity ) + "\" with priority " + Ogre::StringConverter::toString( priority ) + "." );
+    LOG_TRIVIAL("[SCRIPT] script:request_end_sync: Request function \"" + Ogre::String(function) + "\" for entity \"" + Ogre::String(entity) + "\" with priority " + Ogre::StringConverter::toString(priority) + ".");
 
 
-    ScriptEntity* script_entity = GetScriptEntityByName( type, Ogre::String( entity ) );
+    ScriptEntity* script_entity = GetScriptEntityByName(type, Ogre::String(entity));
 
 
-    if( script_entity == NULL )
+    if(script_entity == nullptr)
     {
     {
-        LOG_ERROR( "[SCRIPT] script:request_end_sync: Entity \"" + Ogre::String( entity ) + "\" doesn't exist." );
+        LOG_ERROR("[SCRIPT] script:request_end_sync: Entity \"" + Ogre::String(entity) + "\" doesn't exist.");
         return 1;
         return 1;
     }
     }
 
 
-    bool added = ScriptRequest( script_entity, function, priority, "", "", false, true );
+    bool added = ScriptRequest(script_entity, function, priority, "", "", false, true);
 
 
-    if( added == false )
+    if(added == false)
     {
     {
-        LOG_WARNING( "Script '" + Ogre::String( function ) + "' for entity '" +  Ogre::String( entity ) + "' doesn't exist." );
+        LOG_WARNING("Script '" + Ogre::String(function) + "' for entity '" +  Ogre::String(entity) + "' doesn't exist.");
         return 1;
         return 1;
     }
     }
 
 
@@ -615,33 +589,32 @@ ScriptManager::ScriptRequestEndSync( const Type type, const char* entity, const
 }
 }
 
 
 
 
-
 bool
 bool
-ScriptManager::ScriptRequest( ScriptEntity* script_entity, const Ogre::String& function, const int priority, const Ogre::String& argument1, const Ogre::String& argument2, bool start_sync, bool end_sync )
+ScriptManager::ScriptRequest(ScriptEntity* script_entity, const Ogre::String& function, const int priority, const Ogre::String& argument1, const Ogre::String& argument2, bool start_sync, bool end_sync)
 {
 {
-    luabind::object table = GetTableByEntityName( script_entity->type, script_entity->name, m_LuaState );
-    if( table.is_valid() && luabind::type( table ) == LUA_TTABLE && luabind::type( table[ function ] ) == LUA_TFUNCTION )
+    luabind::object table = GetTableByEntityName(script_entity->type, script_entity->name, m_LuaState);
+    if(table.is_valid() && luabind::type(table) == LUA_TTABLE && luabind::type(table[function]) == LUA_TFUNCTION)
     {
     {
         QueueScript script;
         QueueScript script;
         script.function = function;
         script.function = function;
         script.argument1 = argument1;
         script.argument1 = argument1;
         script.argument2 = argument2;
         script.argument2 = argument2;
         script.priority = priority;
         script.priority = priority;
-        script.state = lua_newthread( m_LuaState );
+        script.state = lua_newthread(m_LuaState);
         // we dont want thread to be garbage collected so we store it
         // we dont want thread to be garbage collected so we store it
-        script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+        script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
         script.seconds_to_wait = 0;
         script.seconds_to_wait = 0;
         script.wait = false;
         script.wait = false;
         script.yield = false;
         script.yield = false;
-        if( start_sync == true )
+        if(start_sync == true)
         {
         {
             script.paused_script_start = GetCurrentScriptId();
             script.paused_script_start = GetCurrentScriptId();
         }
         }
-        if( end_sync == true )
+        if(end_sync == true)
         {
         {
             script.paused_script_end = GetCurrentScriptId();
             script.paused_script_end = GetCurrentScriptId();
         }
         }
-        script_entity->queue.push_back( script );
+        script_entity->queue.push_back(script);
         script_entity->resort = true;
         script_entity->resort = true;
 
 
         return true;
         return true;
@@ -651,13 +624,12 @@ ScriptManager::ScriptRequest( ScriptEntity* script_entity, const Ogre::String& f
 }
 }
 
 
 
 
-
 void
 void
-ScriptManager::AddValueToStack( const float value )
+ScriptManager::AddValueToStack(const float value)
 {
 {
-    QueueScript* script = GetScriptByScriptId( m_CurrentScriptId );
-    if( script != NULL )
+    QueueScript* script = GetScriptByScriptId(m_CurrentScriptId);
+    if(script != nullptr)
     {
     {
-        lua_pushnumber( script->state, value );
+        lua_pushnumber(script->state, value);
     }
     }
 }
 }

+ 8 - 19
QGearsMain/src/core/Timer.cpp

@@ -1,27 +1,20 @@
-#include "core/Timer.h"
-
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
+#include "core/Timer.h"
 
 
 
 
-
-ConfigVar cv_timer_scale_game( "timer_scale_game", "Timer speed for game related things", "1" );
-
-
-
-template<>Timer *Ogre::Singleton< Timer >::msSingleton = NULL;
-
+ConfigVar cv_timer_scale_game("timer_scale_game", "Timer speed for game related things", "1");
+template<>Timer *Ogre::Singleton<Timer>::msSingleton = nullptr;
 
 
 
 
 Timer::Timer():
 Timer::Timer():
-    m_SystemTimeTotal( 0 ),
-    m_SystemTimeDelta( 0 ),
-    m_GameTimeTotal( 0 ),
-    m_GameTimeDelta( 0 )
+    m_SystemTimeTotal(0),
+    m_SystemTimeDelta(0),
+    m_GameTimeTotal(0),
+    m_GameTimeDelta(0)
 {
 {
 }
 }
 
 
 
 
-
 float
 float
 Timer::GetSystemTimeTotal()
 Timer::GetSystemTimeTotal()
 {
 {
@@ -29,7 +22,6 @@ Timer::GetSystemTimeTotal()
 }
 }
 
 
 
 
-
 float
 float
 Timer::GetSystemTimeDelta()
 Timer::GetSystemTimeDelta()
 {
 {
@@ -37,7 +29,6 @@ Timer::GetSystemTimeDelta()
 }
 }
 
 
 
 
-
 float
 float
 Timer::GetGameTimeTotal()
 Timer::GetGameTimeTotal()
 {
 {
@@ -45,7 +36,6 @@ Timer::GetGameTimeTotal()
 }
 }
 
 
 
 
-
 float
 float
 Timer::GetGameTimeDelta()
 Timer::GetGameTimeDelta()
 {
 {
@@ -53,9 +43,8 @@ Timer::GetGameTimeDelta()
 }
 }
 
 
 
 
-
 void
 void
-Timer::AddTime( float time )
+Timer::AddTime(float time)
 {
 {
     m_SystemTimeDelta = time;
     m_SystemTimeDelta = time;
     m_SystemTimeTotal += m_SystemTimeDelta;
     m_SystemTimeTotal += m_SystemTimeDelta;

+ 80 - 104
QGearsMain/src/core/UiAnimation.cpp

@@ -1,230 +1,215 @@
-#include "core/UiAnimation.h"
-
 #include <OgreVector2.h>
 #include <OgreVector2.h>
 
 
+#include "core/UiAnimation.h"
 #include "core/UiWidget.h"
 #include "core/UiWidget.h"
 
 
 
 
-
-UiAnimation::UiAnimation( const Ogre::String& name, UiWidget* widget ):
-    m_Name( name ),
-    m_Widget( widget ),
-    m_Time( 0 ),
-    m_Length( 0 )
+UiAnimation::UiAnimation(const Ogre::String& name, UiWidget* widget):
+    m_Name(name),
+    m_Widget(widget),
+    m_Time(0),
+    m_Length(0)
 {
 {
 }
 }
 
 
 
 
-
 UiAnimation::~UiAnimation()
 UiAnimation::~UiAnimation()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddTime( const float time )
+UiAnimation::AddTime(const float time)
 {
 {
     m_Time += time;
     m_Time += time;
-    if( m_Time > m_Length )
+    if(m_Time > m_Length)
     {
     {
         m_Time = m_Length;
         m_Time = m_Length;
     }
     }
 
 
-
-
     // update all
     // update all
-    if( m_Scale.size() > 0 )
+    if(m_Scale.size() > 0)
     {
     {
-        Ogre::Vector2 min_value = m_Scale[ 0 ].value;
+        Ogre::Vector2 min_value = m_Scale[0].value;
         Ogre::Vector2 max_value = min_value;
         Ogre::Vector2 max_value = min_value;
         float min = 0;
         float min = 0;
         float max = m_Length;
         float max = m_Length;
 
 
-        for( size_t i = 0; i < m_Scale.size(); ++i )
+        for(size_t i = 0; i < m_Scale.size(); ++i)
         {
         {
-            if( m_Scale[ i ].time < m_Time && m_Scale[ i ].time > min )
+            if(m_Scale[i].time < m_Time && m_Scale[i].time > min)
             {
             {
-                min_value = m_Scale[ i ].value;
-                min = m_Scale[ i ].time;
+                min_value = m_Scale[i].value;
+                min = m_Scale[i].time;
             }
             }
 
 
-            if( m_Scale[ i ].time >= m_Time && m_Scale[ i ].time <= max )
+            if(m_Scale[i].time >= m_Time && m_Scale[i].time <= max)
             {
             {
-                max_value = m_Scale[ i ].value;
-                max = m_Scale[ i ].time;
+                max_value = m_Scale[i].value;
+                max = m_Scale[i].time;
             }
             }
         }
         }
 
 
         Ogre::Vector2 value;
         Ogre::Vector2 value;
 
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
         {
             value = min_value;
             value = min_value;
         }
         }
         else
         else
         {
         {
-            value = min_value + ( max_value - min_value ) * ( ( m_Time - min ) / ( max - min ) );
+            value = min_value + (max_value - min_value) * ((m_Time - min) / (max - min));
         }
         }
 
 
-        m_Widget->SetScale( value );
+        m_Widget->SetScale(value);
     }
     }
 
 
-
-
-    if( m_X.size() > 0 )
+    if(m_X.size() > 0)
     {
     {
-        Ogre::Vector2 min_value = m_X[ 0 ].value;
+        Ogre::Vector2 min_value = m_X[0].value;
         Ogre::Vector2 max_value = min_value;
         Ogre::Vector2 max_value = min_value;
         float min = 0;
         float min = 0;
         float max = m_Length;
         float max = m_Length;
 
 
-        for( size_t i = 0; i < m_X.size(); ++i )
+        for(size_t i = 0; i < m_X.size(); ++i)
         {
         {
-            if( m_X[ i ].time < m_Time && m_X[ i ].time > min )
+            if(m_X[i].time < m_Time && m_X[i].time > min)
             {
             {
-                min_value = m_X[ i ].value;
-                min = m_X[ i ].time;
+                min_value = m_X[i].value;
+                min = m_X[i].time;
             }
             }
 
 
-            if( m_X[ i ].time >= m_Time && m_X[ i ].time <= max )
+            if(m_X[i].time >= m_Time && m_X[i].time <= max)
             {
             {
-                max_value = m_X[ i ].value;
-                max = m_X[ i ].time;
+                max_value = m_X[i].value;
+                max = m_X[i].time;
             }
             }
         }
         }
 
 
         Ogre::Vector2 value;
         Ogre::Vector2 value;
 
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
         {
             value = min_value;
             value = min_value;
         }
         }
         else
         else
         {
         {
-            value = min_value + ( max_value - min_value ) * ( ( m_Time - min ) / ( max - min ) );
+            value = min_value + (max_value - min_value) * ((m_Time - min) / (max - min));
         }
         }
 
 
-        m_Widget->SetX( value.x, value.y );
+        m_Widget->SetX(value.x, value.y);
     }
     }
 
 
-
-
-    if( m_Y.size() > 0 )
+    if(m_Y.size() > 0)
     {
     {
-        Ogre::Vector2 min_value = m_Y[ 0 ].value;
+        Ogre::Vector2 min_value = m_Y[0].value;
         Ogre::Vector2 max_value = min_value;
         Ogre::Vector2 max_value = min_value;
         float min = 0;
         float min = 0;
         float max = m_Length;
         float max = m_Length;
 
 
-        for( size_t i = 0; i < m_Y.size(); ++i )
+        for(size_t i = 0; i < m_Y.size(); ++i)
         {
         {
-            if( m_Y[ i ].time < m_Time && m_Y[ i ].time > min )
+            if(m_Y[i].time < m_Time && m_Y[i].time > min)
             {
             {
-                min_value = m_Y[ i ].value;
-                min = m_Y[ i ].time;
+                min_value = m_Y[i].value;
+                min = m_Y[i].time;
             }
             }
 
 
-            if( m_Y[ i ].time >= m_Time && m_Y[ i ].time <= max )
+            if(m_Y[i].time >= m_Time && m_Y[i].time <= max)
             {
             {
-                max_value = m_Y[ i ].value;
-                max = m_Y[ i ].time;
+                max_value = m_Y[i].value;
+                max = m_Y[i].time;
             }
             }
         }
         }
 
 
         Ogre::Vector2 value;
         Ogre::Vector2 value;
 
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
         {
             value = min_value;
             value = min_value;
         }
         }
         else
         else
         {
         {
-            value = min_value + ( max_value - min_value ) * ( ( m_Time - min ) / ( max - min ) );
+            value = min_value + (max_value - min_value) * ((m_Time - min) / (max - min));
         }
         }
 
 
-        m_Widget->SetY( value.x, value.y );
+        m_Widget->SetY(value.x, value.y);
     }
     }
 
 
-
-
-    if( m_Rotation.size() > 0 )
+    if(m_Rotation.size() > 0)
     {
     {
-        float min_value = m_Rotation[ 0 ].value;
+        float min_value = m_Rotation[0].value;
         float max_value = min_value;
         float max_value = min_value;
         float min = 0;
         float min = 0;
         float max = m_Length;
         float max = m_Length;
 
 
-        for( size_t i = 0; i < m_Rotation.size(); ++i )
+        for(size_t i = 0; i < m_Rotation.size(); ++i)
         {
         {
-            if( m_Rotation[ i ].time < m_Time && m_Rotation[ i ].time > min )
+            if(m_Rotation[i].time < m_Time && m_Rotation[i].time > min)
             {
             {
-                min_value = m_Rotation[ i ].value;
-                min = m_Rotation[ i ].time;
+                min_value = m_Rotation[i].value;
+                min = m_Rotation[i].time;
             }
             }
 
 
-            if( m_Rotation[ i ].time >= m_Time && m_Rotation[ i ].time <= max )
+            if(m_Rotation[i].time >= m_Time && m_Rotation[i].time <= max)
             {
             {
-                max_value = m_Rotation[ i ].value;
-                max = m_Rotation[ i ].time;
+                max_value = m_Rotation[i].value;
+                max = m_Rotation[i].time;
             }
             }
         }
         }
 
 
         float value;
         float value;
 
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
         {
             value = min_value;
             value = min_value;
         }
         }
         else
         else
         {
         {
-            value = min_value + ( max_value - min_value ) * ( ( m_Time - min ) / ( max - min ) );
+            value = min_value + (max_value - min_value) * ((m_Time - min) / (max - min));
         }
         }
 
 
-        m_Widget->SetRotation( value );
+        m_Widget->SetRotation(value);
     }
     }
 
 
-
-
-    if( m_Alpha.size() > 0 )
+    if(m_Alpha.size() > 0)
     {
     {
-        float min_value = m_Alpha[ 0 ].value;
+        float min_value = m_Alpha[0].value;
         float max_value = min_value;
         float max_value = min_value;
         float min = 0;
         float min = 0;
         float max = m_Length;
         float max = m_Length;
 
 
-        for( size_t i = 0; i < m_Alpha.size(); ++i )
+        for(size_t i = 0; i < m_Alpha.size(); ++i)
         {
         {
-            if( m_Alpha[ i ].time < m_Time && m_Alpha[ i ].time > min )
+            if(m_Alpha[i].time < m_Time && m_Alpha[i].time > min)
             {
             {
-                min_value = m_Alpha[ i ].value;
-                min = m_Alpha[ i ].time;
+                min_value = m_Alpha[i].value;
+                min = m_Alpha[i].time;
             }
             }
 
 
-            if( m_Alpha[ i ].time >= m_Time && m_Alpha[ i ].time <= max )
+            if(m_Alpha[i].time >= m_Time && m_Alpha[i].time <= max)
             {
             {
-                max_value = m_Alpha[ i ].value;
-                max = m_Alpha[ i ].time;
+                max_value = m_Alpha[i].value;
+                max = m_Alpha[i].time;
             }
             }
         }
         }
 
 
         float value;
         float value;
 
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
         {
             value = min_value;
             value = min_value;
         }
         }
         else
         else
         {
         {
-            value = min_value + ( max_value - min_value ) * ( ( m_Time - min ) / ( max - min ) );
+            value = min_value + (max_value - min_value) * ((m_Time - min) / (max - min));
         }
         }
 
 
-        m_Widget->SetAlpha( value );
+        m_Widget->SetAlpha(value);
     }
     }
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 UiAnimation::GetName() const
 UiAnimation::GetName() const
 {
 {
@@ -232,15 +217,13 @@ UiAnimation::GetName() const
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::SetTime( const float time )
+UiAnimation::SetTime(const float time)
 {
 {
     m_Time = time;
     m_Time = time;
 }
 }
 
 
 
 
-
 float
 float
 UiAnimation::GetTime() const
 UiAnimation::GetTime() const
 {
 {
@@ -248,15 +231,13 @@ UiAnimation::GetTime() const
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::SetLength( const float time )
+UiAnimation::SetLength(const float time)
 {
 {
     m_Length = time;
     m_Length = time;
 }
 }
 
 
 
 
-
 float
 float
 UiAnimation::GetLength() const
 UiAnimation::GetLength() const
 {
 {
@@ -264,41 +245,36 @@ UiAnimation::GetLength() const
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddScaleKeyFrame( const UiKeyFrameVector2& key_frame )
+UiAnimation::AddScaleKeyFrame(const UiKeyFrameVector2& key_frame)
 {
 {
-    m_Scale.push_back( key_frame );
+    m_Scale.push_back(key_frame);
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddXKeyFrame( const UiKeyFrameVector2& key_frame )
+UiAnimation::AddXKeyFrame(const UiKeyFrameVector2& key_frame)
 {
 {
-    m_X.push_back( key_frame );
+    m_X.push_back(key_frame);
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddYKeyFrame( const UiKeyFrameVector2& key_frame )
+UiAnimation::AddYKeyFrame(const UiKeyFrameVector2& key_frame)
 {
 {
-    m_Y.push_back( key_frame );
+    m_Y.push_back(key_frame);
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddRotationKeyFrame( const UiKeyFrameFloat& key_frame )
+UiAnimation::AddRotationKeyFrame(const UiKeyFrameFloat& key_frame)
 {
 {
-    m_Rotation.push_back( key_frame );
+    m_Rotation.push_back(key_frame);
 }
 }
 
 
 
 
-
 void
 void
-UiAnimation::AddAlphaKeyFrame( const UiKeyFrameFloat& key_frame )
+UiAnimation::AddAlphaKeyFrame(const UiKeyFrameFloat& key_frame)
 {
 {
-    m_Alpha.push_back( key_frame );
+    m_Alpha.push_back(key_frame);
 }
 }

+ 16 - 28
QGearsMain/src/core/UiFont.cpp

@@ -1,26 +1,22 @@
-#include "core/UiFont.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/UiFont.h"
 
 
 
 
-
-UiFont::UiFont( const Ogre::String& name ):
-    m_Name( name ),
-    m_ImageName( "" ),
-    m_ImageWidth( 0 ),
-    m_ImageHeight( 0 ),
-    m_Height( 0 )
+UiFont::UiFont(const Ogre::String& name):
+    m_Name(name),
+    m_ImageName(""),
+    m_ImageWidth(0),
+    m_ImageHeight(0),
+    m_Height(0)
 {
 {
 }
 }
 
 
 
 
-
 UiFont::~UiFont()
 UiFont::~UiFont()
 {
 {
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 UiFont::GetName() const
 UiFont::GetName() const
 {
 {
@@ -28,9 +24,8 @@ UiFont::GetName() const
 }
 }
 
 
 
 
-
 void
 void
-UiFont::SetImage( const Ogre::String& image, const int width, const int height )
+UiFont::SetImage(const Ogre::String& image, const int width, const int height)
 {
 {
     m_ImageName = image;
     m_ImageName = image;
     m_ImageWidth = width;
     m_ImageWidth = width;
@@ -38,7 +33,6 @@ UiFont::SetImage( const Ogre::String& image, const int width, const int height )
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 UiFont::GetImageName() const
 UiFont::GetImageName() const
 {
 {
@@ -46,7 +40,6 @@ UiFont::GetImageName() const
 }
 }
 
 
 
 
-
 int
 int
 UiFont::GetImageWidth() const
 UiFont::GetImageWidth() const
 {
 {
@@ -54,7 +47,6 @@ UiFont::GetImageWidth() const
 }
 }
 
 
 
 
-
 int
 int
 UiFont::GetImageHeight() const
 UiFont::GetImageHeight() const
 {
 {
@@ -62,15 +54,13 @@ UiFont::GetImageHeight() const
 }
 }
 
 
 
 
-
 void
 void
-UiFont::SetHeight( const int height )
+UiFont::SetHeight(const int height)
 {
 {
     m_Height = height;
     m_Height = height;
 }
 }
 
 
 
 
-
 int
 int
 UiFont::GetHeight() const
 UiFont::GetHeight() const
 {
 {
@@ -78,27 +68,25 @@ UiFont::GetHeight() const
 }
 }
 
 
 
 
-
 void
 void
-UiFont::AddCharData( const UiCharData& data )
+UiFont::AddCharData(const UiCharData& data)
 {
 {
-    m_CharData.push_back( data );
+    m_CharData.push_back(data);
 }
 }
 
 
 
 
-
 UiCharData
 UiCharData
-UiFont::GetCharData( const int char_code ) const
+UiFont::GetCharData(const int char_code) const
 {
 {
-    for( size_t i = 0; i < m_CharData.size(); ++i )
+    for(size_t i = 0; i < m_CharData.size(); ++i)
     {
     {
-        if( m_CharData[ i ].char_code == char_code )
+        if(m_CharData[i].char_code == char_code)
         {
         {
-            return m_CharData[ i ];
+            return m_CharData[i];
         }
         }
     }
     }
 
 
-    LOG_ERROR( "There is no char with char code " + Ogre::StringConverter::toString( char_code ) + " in font " + m_Name + "." );
+    LOG_ERROR("There is no char with char code " + Ogre::StringConverter::toString(char_code) + " in font " + m_Name + ".");
     UiCharData ret = {};
     UiCharData ret = {};
     return ret;
     return ret;
 }
 }

+ 60 - 82
QGearsMain/src/core/UiManager.cpp

@@ -1,10 +1,9 @@
-#include "core/UiManager.h"
-
 #include <OgreRoot.h>
 #include <OgreRoot.h>
 #include <OgreStringVector.h>
 #include <OgreStringVector.h>
 
 
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
+#include "core/UiManager.h"
 #include "core/Utilites.h"
 #include "core/Utilites.h"
 #include "core/XmlFontsFile.h"
 #include "core/XmlFontsFile.h"
 #include "core/XmlPrototypesFile.h"
 #include "core/XmlPrototypesFile.h"
@@ -12,206 +11,187 @@
 #include "core/XmlTextsFile.h"
 #include "core/XmlTextsFile.h"
 
 
 
 
-
-template<>UiManager *Ogre::Singleton< UiManager >::msSingleton = NULL;
-
+template<>UiManager *Ogre::Singleton<UiManager>::msSingleton = nullptr;
 
 
 
 
 UiManager::UiManager()
 UiManager::UiManager()
 {
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->addRenderQueueListener( this );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->addRenderQueueListener(this);
 }
 }
 
 
 
 
-
 UiManager::~UiManager()
 UiManager::~UiManager()
 {
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->removeRenderQueueListener( this );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->removeRenderQueueListener(this);
 
 
     UnloadTexts();
     UnloadTexts();
 
 
-    for( size_t i = 0; i < m_Fonts.size(); ++i )
+    for(size_t i = 0; i < m_Fonts.size(); ++i)
     {
     {
-        delete m_Fonts[ i ];
+        delete m_Fonts[i];
     }
     }
 
 
-    for( size_t i = 0; i < m_Widgets.size(); ++i )
+    for(size_t i = 0; i < m_Widgets.size(); ++i)
     {
     {
-        delete m_Widgets[ i ];
+        delete m_Widgets[i];
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 UiManager::Initialise()
 UiManager::Initialise()
 {
 {
-    XmlFontsFile fonts( "./data/fonts.xml" );
+    XmlFontsFile fonts("./data/fonts.xml");
     fonts.LoadFonts();
     fonts.LoadFonts();
 
 
-    XmlPrototypesFile prototypes( "./data/screens/prototypes.xml" );
+    XmlPrototypesFile prototypes("./data/screens/prototypes.xml");
     prototypes.LoadPrototypes();
     prototypes.LoadPrototypes();
 
 
-    XmlScreensFile screens( "./data/screens.xml" );
+    XmlScreensFile screens("./data/screens.xml");
     screens.LoadScreens();
     screens.LoadScreens();
 }
 }
 
 
 
 
-
 void
 void
 UiManager::Update()
 UiManager::Update()
 {
 {
     // update all ui scripts
     // update all ui scripts
-    ScriptManager::getSingleton().Update( ScriptManager::UI );
-
-
-
-    for( unsigned int i = 0; i < m_Widgets.size(); ++i )
+    ScriptManager::getSingleton().Update(ScriptManager::UI);
+    for(unsigned int i = 0; i < m_Widgets.size(); ++i)
     {
     {
-        m_Widgets[ i ]->Update();
+        m_Widgets[i]->Update();
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 UiManager::OnResize()
 UiManager::OnResize()
 {
 {
-    for( unsigned int i = 0; i < m_Widgets.size(); ++i )
+    for(unsigned int i = 0; i < m_Widgets.size(); ++i)
     {
     {
-        m_Widgets[ i ]->OnResize();
+        m_Widgets[i]->OnResize();
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-UiManager::SetLanguage( const Ogre::String& language )
+UiManager::SetLanguage(const Ogre::String& language)
 {
 {
     UnloadTexts();
     UnloadTexts();
 
 
-    XmlTextsFile texts( "./data/texts.xml" );
-    texts.LoadTexts( language );
+    XmlTextsFile texts("./data/texts.xml");
+    texts.LoadTexts(language);
 }
 }
 
 
 
 
-
 void
 void
-UiManager::AddText( const Ogre::String& name, TiXmlNode* text )
+UiManager::AddText(const Ogre::String& name, TiXmlNode* text)
 {
 {
     UiText ui_text;
     UiText ui_text;
     ui_text.name = name;
     ui_text.name = name;
     ui_text.node = text;
     ui_text.node = text;
-    m_Texts.push_back( ui_text );
+    m_Texts.push_back(ui_text);
 }
 }
 
 
 
 
-
 void
 void
 UiManager::UnloadTexts()
 UiManager::UnloadTexts()
 {
 {
-    for( unsigned int i = 0; i < m_Texts.size(); ++i )
+    for(unsigned int i = 0; i < m_Texts.size(); ++i)
     {
     {
-        delete m_Texts[ i ].node;
+        delete m_Texts[i].node;
     }
     }
     m_Texts.clear();
     m_Texts.clear();
 }
 }
 
 
 
 
-
 TiXmlNode*
 TiXmlNode*
-UiManager::GetText( const Ogre::String& name ) const
+UiManager::GetText(const Ogre::String& name) const
 {
 {
-    for( unsigned int i = 0; i < m_Texts.size(); ++i )
+    for(unsigned int i = 0; i < m_Texts.size(); ++i)
     {
     {
-        if( m_Texts[ i ].name == name )
+        if(m_Texts[i].name == name)
         {
         {
-            return m_Texts[ i ].node;
+            return m_Texts[i].node;
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 void
 void
-UiManager::AddFont( UiFont* font )
+UiManager::AddFont(UiFont* font)
 {
 {
-    m_Fonts.push_back( font );
+    m_Fonts.push_back(font);
 }
 }
 
 
 
 
-
 UiFont*
 UiFont*
-UiManager::GetFont( const Ogre::String& name )
+UiManager::GetFont(const Ogre::String& name)
 {
 {
-    for( unsigned int i = 0; i < m_Fonts.size(); ++i )
+    for(unsigned int i = 0; i < m_Fonts.size(); ++i)
     {
     {
-        if( m_Fonts[ i ]->GetName() == name )
+        if(m_Fonts[i]->GetName() == name)
         {
         {
-            return m_Fonts[ i ];
+            return m_Fonts[i];
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 void
 void
-UiManager::AddPrototype( const Ogre::String& name, TiXmlNode* prototype )
+UiManager::AddPrototype(const Ogre::String& name, TiXmlNode* prototype)
 {
 {
     UiPrototype ui_prototype;
     UiPrototype ui_prototype;
     ui_prototype.name = name;
     ui_prototype.name = name;
     ui_prototype.node = prototype;
     ui_prototype.node = prototype;
-    m_Prototypes.push_back( ui_prototype );
+    m_Prototypes.push_back(ui_prototype);
 }
 }
 
 
 
 
-
 TiXmlNode*
 TiXmlNode*
-UiManager::GetPrototype( const Ogre::String& name ) const
+UiManager::GetPrototype(const Ogre::String& name) const
 {
 {
-    for( unsigned int i = 0; i < m_Prototypes.size(); ++i )
+    for(unsigned int i = 0; i < m_Prototypes.size(); ++i)
     {
     {
-        if( m_Prototypes[ i ].name == name )
+        if(m_Prototypes[i].name == name)
         {
         {
-            return m_Prototypes[ i ].node;
+            return m_Prototypes[i].node;
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 void
 void
-UiManager::AddWidget( UiWidget* widget )
+UiManager::AddWidget(UiWidget* widget)
 {
 {
-    m_Widgets.push_back( widget );
+    m_Widgets.push_back(widget);
 }
 }
 
 
 
 
-
 UiWidget*
 UiWidget*
-UiManager::GetWidget( const Ogre::String& name )
+UiManager::GetWidget(const Ogre::String& name)
 {
 {
     // get real table by name
     // get real table by name
-    Ogre::StringVector table_path = StringTokenise( name, "." );
-    UiWidget* widget = NULL;
+    Ogre::StringVector table_path = StringTokenise(name, ".");
+    UiWidget* widget = nullptr;
 
 
-    if( table_path.size() > 0 )
+    if(table_path.size() > 0)
     {
     {
-        for( unsigned int i = 0; i < m_Widgets.size(); ++i )
+        for(unsigned int i = 0; i < m_Widgets.size(); ++i)
         {
         {
-            if( m_Widgets[ i ]->GetName() == table_path[ 0 ] )
+            if(m_Widgets[i]->GetName() == table_path[0])
             {
             {
-                widget = m_Widgets[ i ];
+                widget = m_Widgets[i];
 
 
-                for( unsigned int j = 1; ( j < table_path.size() ) && ( widget != NULL ); ++j )
+                for(unsigned int j = 1; (j < table_path.size()) && (widget != nullptr); ++j)
                 {
                 {
-                    widget = widget->GetChild( table_path[ j ] );
+                    widget = widget->GetChild(table_path[j]);
                 }
                 }
             }
             }
         }
         }
@@ -221,25 +201,23 @@ UiManager::GetWidget( const Ogre::String& name )
 }
 }
 
 
 
 
-
 UiWidget*
 UiWidget*
-UiManager::ScriptGetWidget( const char* name )
+UiManager::ScriptGetWidget(const char* name)
 {
 {
-    return GetWidget( Ogre::String( name ) );
+    return GetWidget(Ogre::String(name));
 }
 }
 
 
 
 
-
 void
 void
-UiManager::renderQueueStarted( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation )
+UiManager::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
 {
 {
-    if( queueGroupId == Ogre::RENDER_QUEUE_OVERLAY )
+    if(queueGroupId == Ogre::RENDER_QUEUE_OVERLAY)
     {
     {
-        Ogre::Root::getSingletonPtr()->getRenderSystem()->clearFrameBuffer( Ogre::FBT_DEPTH );
+        Ogre::Root::getSingletonPtr()->getRenderSystem()->clearFrameBuffer(Ogre::FBT_DEPTH);
 
 
-        for( unsigned int i = 0; i < m_Widgets.size(); ++i)
+        for(unsigned int i = 0; i < m_Widgets.size(); ++i)
         {
         {
-            m_Widgets[ i ]->Render();
+            m_Widgets[i]->Render();
         }
         }
     }
     }
 }
 }

+ 68 - 82
QGearsMain/src/core/UiSprite.cpp

@@ -1,62 +1,56 @@
-#include "core/UiSprite.h"
-
 #include <OgreHardwareBufferManager.h>
 #include <OgreHardwareBufferManager.h>
 #include <OgreMaterialManager.h>
 #include <OgreMaterialManager.h>
 
 
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/UiSprite.h"
 
 
 
 
-
-UiSprite::UiSprite( const Ogre::String& name ):
-    UiWidget( name )
+UiSprite::UiSprite(const Ogre::String& name):
+    UiWidget(name)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
-UiSprite::UiSprite( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent ):
-    UiWidget( name, path_name, parent )
+UiSprite::UiSprite(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent):
+    UiWidget(name, path_name, parent)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
 UiSprite::~UiSprite()
 UiSprite::~UiSprite()
 {
 {
     DestroyVertexBuffer();
     DestroyVertexBuffer();
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::Initialise()
 UiSprite::Initialise()
 {
 {
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
 
 
-    m_Material = Ogre::MaterialManager::getSingleton().create( "UiMaterials." + m_PathName, "General" );
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
-    pass->setCullingMode( Ogre::CULL_NONE );
-    pass->setDepthCheckEnabled( true );
-    pass->setDepthWriteEnabled( true );
-    pass->setLightingEnabled( false );
-    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
-
-    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
-    pass->setAlphaRejectValue( 0 );
+    m_Material = Ogre::MaterialManager::getSingleton().create("UiMaterials." + m_PathName, "General");
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
+    pass->setCullingMode(Ogre::CULL_NONE);
+    pass->setDepthCheckEnabled(true);
+    pass->setDepthWriteEnabled(true);
+    pass->setLightingEnabled(false);
+    pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+
+    pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
+    pass->setAlphaRejectValue(0);
     Ogre::TextureUnitState* tex = pass->createTextureUnitState();
     Ogre::TextureUnitState* tex = pass->createTextureUnitState();
-    tex->setTextureName( "system/blank.png" );
-    tex->setNumMipmaps( -1 );
-    tex->setTextureFiltering( Ogre::TFO_NONE );
+    tex->setTextureName("system/blank.png");
+    tex->setNumMipmaps(-1);
+    tex->setTextureFiltering(Ogre::TFO_NONE);
 
 
     CreateVertexBuffer();
     CreateVertexBuffer();
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::Update()
 UiSprite::Update()
 {
 {
@@ -64,23 +58,22 @@ UiSprite::Update()
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::Render()
 UiSprite::Render()
 {
 {
-    if( m_Visible == true )
+    if(m_Visible == true)
     {
     {
-        if( m_RenderOp.vertexData->vertexCount != 0 )
+        if(m_RenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
-            m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
-            m_RenderSystem->_setViewMatrix( Ogre::Matrix4::IDENTITY );
+            m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+            m_RenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
+            m_RenderSystem->_setViewMatrix(Ogre::Matrix4::IDENTITY);
 
 
-            m_SceneManager->_setPass( m_Material->getTechnique( 0 )->getPass( 0 ), true, false );
+            m_SceneManager->_setPass(m_Material->getTechnique(0)->getPass(0), true, false);
 
 
-            m_RenderSystem->setScissorTest( true, m_ScissorLeft, m_ScissorTop, m_ScissorRight, m_ScissorBottom );
-            m_RenderSystem->_render( m_RenderOp );
-            m_RenderSystem->setScissorTest( false );
+            m_RenderSystem->setScissorTest(true, m_ScissorLeft, m_ScissorTop, m_ScissorRight, m_ScissorBottom);
+            m_RenderSystem->_render(m_RenderOp);
+            m_RenderSystem->setScissorTest(false);
         }
         }
     }
     }
 
 
@@ -88,7 +81,6 @@ UiSprite::Render()
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::UpdateTransformation()
 UiSprite::UpdateTransformation()
 {
 {
@@ -97,37 +89,33 @@ UiSprite::UpdateTransformation()
 }
 }
 
 
 
 
-
 void
 void
-UiSprite::SetImage( const Ogre::String& image )
+UiSprite::SetImage(const Ogre::String& image)
 {
 {
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    Ogre::TextureUnitState* tex = pass->getTextureUnitState( 0 );
-    tex->setTextureName( image );
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    Ogre::TextureUnitState* tex = pass->getTextureUnitState(0);
+    tex->setTextureName(image);
 }
 }
 
 
 
 
-
 void
 void
-UiSprite::SetVertexShader( const Ogre::String& shader )
+UiSprite::SetVertexShader(const Ogre::String& shader)
 {
 {
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexProgram( shader, true );
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    pass->setVertexProgram(shader, true);
     pass->getVertexProgram()->load();
     pass->getVertexProgram()->load();
 }
 }
 
 
 
 
-
 void
 void
-UiSprite::SetFragmentShader( const Ogre::String& shader )
+UiSprite::SetFragmentShader(const Ogre::String& shader)
 {
 {
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    pass->setFragmentProgram( shader, true );
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    pass->setFragmentProgram(shader, true);
     pass->getFragmentProgram()->load();
     pass->getFragmentProgram()->load();
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::UpdateGeometry()
 UiSprite::UpdateGeometry()
 {
 {
@@ -140,14 +128,14 @@ UiSprite::UpdateGeometry()
 
 
     int x1, y1, x2, y2, x3, y3, x4, y4;
     int x1, y1, x2, y2, x3, y3, x4, y4;
 
 
-    //LOG_ERROR( m_Name + ", rotation = " + Ogre::StringConverter::toString( rotation ) );
-    //LOG_ERROR( "local_x1 = " + Ogre::StringConverter::toString( local_x1 ) + ", local_y1 = " + Ogre::StringConverter::toString( local_y1 ) );
-    //LOG_ERROR( "local_x2 = " + Ogre::StringConverter::toString( local_x2 ) + ", local_y2 = " + Ogre::StringConverter::toString( local_y2 ) );
+    //LOG_ERROR(m_Name + ", rotation = " + Ogre::StringConverter::toString(rotation));
+    //LOG_ERROR("local_x1 = " + Ogre::StringConverter::toString(local_x1) + ", local_y1 = " + Ogre::StringConverter::toString(local_y1));
+    //LOG_ERROR("local_x2 = " + Ogre::StringConverter::toString(local_x2) + ", local_y2 = " + Ogre::StringConverter::toString(local_y2));
 
 
-    if( m_FinalRotation != 0 )
+    if(m_FinalRotation != 0)
     {
     {
-        float cos = Ogre::Math::Cos( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
-        float sin = Ogre::Math::Sin( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
+        float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
+        float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
 
 
         x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
         x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
         y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
         y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -170,22 +158,22 @@ UiSprite::UpdateGeometry()
         y4 = static_cast<int>(local_y2 + y);
         y4 = static_cast<int>(local_y2 + y);
     }
     }
 
 
-    //LOG_ERROR( "x1 = " + Ogre::StringConverter::toString( x1 ) + ", y1 = " + Ogre::StringConverter::toString( y1 ) );
-    //LOG_ERROR( "x2 = " + Ogre::StringConverter::toString( x2 ) + ", y2 = " + Ogre::StringConverter::toString( y2 ) );
-    //LOG_ERROR( "x3 = " + Ogre::StringConverter::toString( x3 ) + ", y3 = " + Ogre::StringConverter::toString( y3 ) );
-    //LOG_ERROR( "x4 = " + Ogre::StringConverter::toString( x4 ) + ", y4 = " + Ogre::StringConverter::toString( y4 ) );
-
-    float new_x1 = ( x1 / m_ScreenWidth ) * 2 - 1;
-    float new_y1 = -( ( y1 / m_ScreenHeight ) * 2 - 1 );
-    float new_x2 = ( x2 / m_ScreenWidth ) * 2 - 1;
-    float new_y2 = -( ( y2 / m_ScreenHeight ) * 2 - 1 );
-    float new_x3 = ( x3 / m_ScreenWidth ) * 2 - 1;
-    float new_y3 = -( ( y3 / m_ScreenHeight ) * 2 - 1 );
-    float new_x4 = ( x4 / m_ScreenWidth ) * 2 - 1;
-    float new_y4 = -( ( y4 / m_ScreenHeight ) * 2 - 1 );
-
-    float* writeIterator = ( float* ) m_VertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
-
+    //LOG_ERROR("x1 = " + Ogre::StringConverter::toString(x1) + ", y1 = " + Ogre::StringConverter::toString(y1));
+    //LOG_ERROR("x2 = " + Ogre::StringConverter::toString(x2) + ", y2 = " + Ogre::StringConverter::toString(y2));
+    //LOG_ERROR("x3 = " + Ogre::StringConverter::toString(x3) + ", y3 = " + Ogre::StringConverter::toString(y3));
+    //LOG_ERROR("x4 = " + Ogre::StringConverter::toString(x4) + ", y4 = " + Ogre::StringConverter::toString(y4));
+
+    float new_x1 = (x1 / m_ScreenWidth) * 2 - 1;
+    float new_y1 = -((y1 / m_ScreenHeight) * 2 - 1);
+    float new_x2 = (x2 / m_ScreenWidth) * 2 - 1;
+    float new_y2 = -((y2 / m_ScreenHeight) * 2 - 1);
+    float new_x3 = (x3 / m_ScreenWidth) * 2 - 1;
+    float new_y3 = -((y3 / m_ScreenHeight) * 2 - 1);
+    float new_x4 = (x4 / m_ScreenWidth) * 2 - 1;
+    float new_y4 = -((y4 / m_ScreenHeight) * 2 - 1);
+
+    float* writeIterator = (float*) m_VertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    // TODO: use WriteGlyph (should probably rename and move to utils)
     *writeIterator++ = new_x1;
     *writeIterator++ = new_x1;
     *writeIterator++ = new_y1;
     *writeIterator++ = new_y1;
     *writeIterator++ = m_FinalZ;
     *writeIterator++ = m_FinalZ;
@@ -252,7 +240,6 @@ UiSprite::UpdateGeometry()
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::CreateVertexBuffer()
 UiSprite::CreateVertexBuffer()
 {
 {
@@ -262,21 +249,20 @@ UiSprite::CreateVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
 
 
-    m_VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), 6, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), 6, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_RenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_VertexBuffer );
+    m_RenderOp.vertexData->vertexBufferBinding->setBinding(0, m_VertexBuffer);
     m_RenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_RenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_RenderOp.useIndexes = false;
     m_RenderOp.useIndexes = false;
 }
 }
 
 
 
 
-
 void
 void
 UiSprite::DestroyVertexBuffer()
 UiSprite::DestroyVertexBuffer()
 {
 {

+ 99 - 197
QGearsMain/src/core/UiTextArea.cpp

@@ -1,54 +1,48 @@
-#include "core/UiTextArea.h"
-
 #include <OgreFontManager.h>
 #include <OgreFontManager.h>
 #include <OgreHardwareBufferManager.h>
 #include <OgreHardwareBufferManager.h>
 #include <OgreMaterialManager.h>
 #include <OgreMaterialManager.h>
 
 
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/UiManager.h"
+#include "core/UiTextArea.h"
 
 
 
 
-
-UiTextArea::UiTextArea( const Ogre::String& name ):
-    UiWidget( name )
+UiTextArea::UiTextArea(const Ogre::String& name):
+    UiWidget(name)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
-UiTextArea::UiTextArea( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent ):
-    UiWidget( name, path_name, parent )
+UiTextArea::UiTextArea(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent):
+    UiWidget(name, path_name, parent)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
 UiTextArea::~UiTextArea()
 UiTextArea::~UiTextArea()
 {
 {
     DestroyVertexBuffer();
     DestroyVertexBuffer();
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::Initialise()
 UiTextArea::Initialise()
 {
 {
-    m_Font = NULL;
+    m_Font = nullptr;
     m_MaxLetters = 0;
     m_MaxLetters = 0;
     m_TextAlign = UiTextArea::LEFT;
     m_TextAlign = UiTextArea::LEFT;
     m_Text = "";
     m_Text = "";
-    m_TextNode = NULL;
+    m_TextNode = nullptr;
 
 
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
 
 
     CreateVertexBuffer();
     CreateVertexBuffer();
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::Update()
 UiTextArea::Update()
 {
 {
@@ -56,23 +50,22 @@ UiTextArea::Update()
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::Render()
 UiTextArea::Render()
 {
 {
-    if( m_Visible == true )
+    if(m_Visible == true)
     {
     {
-        if( m_RenderOp.vertexData->vertexCount != 0 )
+        if(m_RenderOp.vertexData->vertexCount != 0)
         {
         {
-            m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
-            m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
-            m_RenderSystem->_setViewMatrix( Ogre::Matrix4::IDENTITY );
+            m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+            m_RenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
+            m_RenderSystem->_setViewMatrix(Ogre::Matrix4::IDENTITY);
 
 
-            m_SceneManager->_setPass( m_Material->getTechnique( 0 )->getPass( 0 ), true, false );
+            m_SceneManager->_setPass(m_Material->getTechnique(0)->getPass(0), true, false);
 
 
-            m_RenderSystem->setScissorTest( true, m_ScissorLeft, m_ScissorTop, m_ScissorRight, m_ScissorBottom );
-            m_RenderSystem->_render( m_RenderOp );
-            m_RenderSystem->setScissorTest( false );
+            m_RenderSystem->setScissorTest(true, m_ScissorLeft, m_ScissorTop, m_ScissorRight, m_ScissorBottom);
+            m_RenderSystem->_render(m_RenderOp);
+            m_RenderSystem->setScissorTest(false);
         }
         }
     }
     }
 
 
@@ -80,7 +73,6 @@ UiTextArea::Render()
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::UpdateTransformation()
 UiTextArea::UpdateTransformation()
 {
 {
@@ -89,96 +81,89 @@ UiTextArea::UpdateTransformation()
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetTextAlign( const TextAlign align )
+UiTextArea::SetTextAlign(const TextAlign align)
 {
 {
     m_TextAlign = align;
     m_TextAlign = align;
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetText( const Ogre::UTFString& text )
+UiTextArea::SetText(const Ogre::UTFString& text)
 {
 {
     m_Text = text;
     m_Text = text;
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetText( TiXmlNode* text )
+UiTextArea::SetText(TiXmlNode* text)
 {
 {
     m_TextNode = text;
     m_TextNode = text;
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetFont( const Ogre::String& font )
+UiTextArea::SetFont(const Ogre::String& font)
 {
 {
-    m_Font = UiManager::getSingleton().GetFont( font );
+    m_Font = UiManager::getSingleton().GetFont(font);
 
 
-    if( m_Font == NULL )
+    if(m_Font == nullptr)
     {
     {
-        LOG_ERROR( "Could not find font \"" + font + "\" for \"" + m_PathName + "\"." );
+        LOG_ERROR("Could not find font \"" + font + "\" for \"" + m_PathName + "\".");
         return;
         return;
     }
     }
 
 
-    m_Material = Ogre::MaterialManager::getSingleton().create( "UiMaterials." + m_PathName, "General" );
-    Ogre::Pass* pass = m_Material->getTechnique( 0 )->getPass( 0 );
-    pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
-    pass->setCullingMode( Ogre::CULL_NONE );
-    pass->setDepthCheckEnabled( false );
-    pass->setDepthWriteEnabled( false );
-    pass->setLightingEnabled( false );
-    pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
-
-    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
-    pass->setAlphaRejectValue( 0 );
+    m_Material = Ogre::MaterialManager::getSingleton().create("UiMaterials." + m_PathName, "General");
+    Ogre::Pass* pass = m_Material->getTechnique(0)->getPass(0);
+    pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
+    pass->setCullingMode(Ogre::CULL_NONE);
+    pass->setDepthCheckEnabled(false);
+    pass->setDepthWriteEnabled(false);
+    pass->setLightingEnabled(false);
+    pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+
+    pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
+    pass->setAlphaRejectValue(0);
     Ogre::TextureUnitState* tex = pass->createTextureUnitState();
     Ogre::TextureUnitState* tex = pass->createTextureUnitState();
-    tex->setTextureName( m_Font->GetImageName() );
-    tex->setNumMipmaps( -1 );
-    tex->setTextureFiltering( Ogre::TFO_NONE );
+    tex->setTextureName(m_Font->GetImageName());
+    tex->setNumMipmaps(-1);
+    tex->setTextureFiltering(Ogre::TFO_NONE);
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::UpdateGeometry()
 UiTextArea::UpdateGeometry()
 {
 {
-    if( m_Font == NULL )
+    if(m_Font == nullptr)
     {
     {
-        LOG_ERROR( "Font for \"" + m_PathName + "\" if not set." );
+        LOG_ERROR("Font for \"" + m_PathName + "\" if not set.");
         return;
         return;
     }
     }
 
 
-    if( m_Text.size() > m_MaxLetters )
+    if(m_Text.size() > m_MaxLetters)
     {
     {
-        LOG_ERROR( "Max number of text reached in \"" + m_PathName + "\". Can't render text \"" + m_Text + "\". Max number of letters is " + Ogre::StringConverter::toString( m_MaxLetters ) + "." );
+        LOG_ERROR("Max number of text reached in \"" + m_PathName + "\". Can't render text \"" + m_Text + "\". Max number of letters is " + Ogre::StringConverter::toString(m_MaxLetters) + ".");
         return;
         return;
     }
     }
 
 
     float length = 0;
     float length = 0;
-    if( m_TextAlign != LEFT )
+    if(m_TextAlign != LEFT)
     {
     {
-        if( m_TextNode != NULL )
+        if(m_TextNode != nullptr)
         {
         {
-            length = GetTextLengthFromNode( m_TextNode );
+            length = GetTextLengthFromNode(m_TextNode);
         }
         }
         else
         else
         {
         {
-            length = GetTextLength( m_Text );
+            length = GetTextLength(m_Text);
         }
         }
 
 
-        if( m_TextAlign == CENTER )
+        if(m_TextAlign == CENTER)
         {
         {
             length /= 2;
             length /= 2;
         }
         }
     }
     }
 
 
-
-
     TextBlockData data;
     TextBlockData data;
     data.local_x1 = -m_FinalOrigin.x - length;
     data.local_x1 = -m_FinalOrigin.x - length;
     data.local_y1 = -m_FinalOrigin.y;
     data.local_y1 = -m_FinalOrigin.y;
@@ -187,40 +172,39 @@ UiTextArea::UpdateGeometry()
     TextStyle style;
     TextStyle style;
     style.colour = m_Colour1;
     style.colour = m_Colour1;
 
 
-    if( m_TextNode != NULL )
+    if(m_TextNode != nullptr)
     {
     {
-        SetTextGeometryFromNode( m_TextNode, data, style );
+        SetTextGeometryFromNode(m_TextNode, data, style);
     }
     }
     else
     else
     {
     {
-        SetTextGeometry( m_Text, data, style );
+        SetTextGeometry(m_Text, data, style);
     }
     }
 }
 }
 
 
 
 
-
 float
 float
-UiTextArea::GetTextLengthFromNode( TiXmlNode* node ) const
+UiTextArea::GetTextLengthFromNode(TiXmlNode* node) const
 {
 {
     float length = 0;
     float length = 0;
 
 
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        switch( node->Type() )
+        switch(node->Type())
         {
         {
             case TiXmlNode::TINYXML_TEXT:
             case TiXmlNode::TINYXML_TEXT:
             {
             {
                 TiXmlText* childText = node->ToText();
                 TiXmlText* childText = node->ToText();
-                if( childText )
+                if(childText)
                 {
                 {
-                    length += GetTextLength( childText->Value() );
+                    length += GetTextLength(childText->Value());
                 }
                 }
             }
             }
             break;
             break;
 
 
             case TiXmlNode::TINYXML_ELEMENT:
             case TiXmlNode::TINYXML_ELEMENT:
             {
             {
-                length +=GetTextLengthFromNode( node->FirstChild() );
+                length +=GetTextLengthFromNode(node->FirstChild());
             }
             }
             break;
             break;
         }
         }
@@ -232,35 +216,33 @@ UiTextArea::GetTextLengthFromNode( TiXmlNode* node ) const
 }
 }
 
 
 
 
-
 float
 float
-UiTextArea::GetTextLength( const Ogre::UTFString& text ) const
+UiTextArea::GetTextLength(const Ogre::UTFString& text) const
 {
 {
     float length = 0;
     float length = 0;
-    for( size_t i = 0; i < text.size(); ++i )
+    for(size_t i = 0; i < text.size(); ++i)
     {
     {
-        UiCharData char_data = m_Font->GetCharData( text[ i ] );
-        length += ( char_data.pre + char_data.width + char_data.post ) * m_FinalScale.x * m_ScreenHeight / 720.0f;
+        UiCharData char_data = m_Font->GetCharData(text[i]);
+        length += (char_data.pre + char_data.width + char_data.post) * m_FinalScale.x * m_ScreenHeight / 720.0f;
     }
     }
 
 
     return length;
     return length;
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const TextStyle& style )
+UiTextArea::SetTextGeometryFromNode(TiXmlNode* node, TextBlockData& data, const TextStyle& style)
 {
 {
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        switch( node->Type() )
+        switch(node->Type())
         {
         {
             case TiXmlNode::TINYXML_TEXT:
             case TiXmlNode::TINYXML_TEXT:
             {
             {
                 TiXmlText* childText = node->ToText();
                 TiXmlText* childText = node->ToText();
-                if( childText )
+                if(childText)
                 {
                 {
-                    SetTextGeometry( childText->Value(), data, style );
+                    SetTextGeometry(childText->Value(), data, style);
                 }
                 }
             }
             }
             break;
             break;
@@ -271,13 +253,13 @@ UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const
                 style_child.colour = style.colour;
                 style_child.colour = style.colour;
 
 
                 Ogre::String name = node->ValueStr();
                 Ogre::String name = node->ValueStr();
-                if( name == "colour" )
+                if(name == "colour")
                 {
                 {
-                    style_child.colour = Ogre::StringConverter::parseColourValue( node->ToElement()->Attribute( "value" ) );
+                    style_child.colour = Ogre::StringConverter::parseColourValue(node->ToElement()->Attribute("value"));
                 }
                 }
 
 
                 TiXmlNode* node_child = node->FirstChild();
                 TiXmlNode* node_child = node->FirstChild();
-                SetTextGeometryFromNode( node_child, data, style_child );
+                SetTextGeometryFromNode(node_child, data, style_child);
             }
             }
             break;
             break;
         }
         }
@@ -287,11 +269,10 @@ UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const
 }
 }
 
 
 
 
-
 void
 void
-UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, const TextStyle& style )
+UiTextArea::SetTextGeometry(const Ogre::UTFString& text, TextBlockData& data, const TextStyle& style)
 {
 {
-    float* writeIterator = ( float* ) m_VertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*) m_VertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += data.position * 9 * 6;
     writeIterator += data.position * 9 * 6;
     m_RenderOp.vertexData->vertexCount = data.position * 6;
     m_RenderOp.vertexData->vertexCount = data.position * 6;
 
 
@@ -301,9 +282,9 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
     float x = m_FinalTranslate.x;
     float x = m_FinalTranslate.x;
     float y = m_FinalTranslate.y;
     float y = m_FinalTranslate.y;
 
 
-    for( size_t i = 0; i < text.size(); ++i )
+    for(auto &c : text)
     {
     {
-        UiCharData char_data = m_Font->GetCharData( text[ i ] );
+        UiCharData char_data = m_Font->GetCharData(c);
 
 
         local_x1 += char_data.pre * m_FinalScale.x * m_ScreenHeight / 720.0f;
         local_x1 += char_data.pre * m_FinalScale.x * m_ScreenHeight / 720.0f;
         float local_x2 = local_x1 + char_data.width * m_FinalScale.x * m_ScreenHeight / 720.0f;
         float local_x2 = local_x1 + char_data.width * m_FinalScale.x * m_ScreenHeight / 720.0f;
@@ -311,14 +292,10 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
 
 
         int x1, y1, x2, y2, x3, y3, x4, y4;
         int x1, y1, x2, y2, x3, y3, x4, y4;
 
 
-        //LOG_ERROR( m_Name );
-        //LOG_ERROR( "local_x1 = " + Ogre::StringConverter::toString( local_x1 ) + ", local_y1 = " + Ogre::StringConverter::toString( local_y1 ) );
-        //LOG_ERROR( "local_x2 = " + Ogre::StringConverter::toString( local_x2 ) + ", local_y2 = " + Ogre::StringConverter::toString( local_y2 ) );
-
-        if( m_FinalRotation != 0 )
+        if(m_FinalRotation != 0)
         {
         {
-            float cos = Ogre::Math::Cos( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
-            float sin = Ogre::Math::Sin( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
+            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
+            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
 
 
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -341,100 +318,27 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
             y4 = static_cast<int>(local_y2 + y);
             y4 = static_cast<int>(local_y2 + y);
         }
         }
 
 
-        //LOG_ERROR( "x1 = " + Ogre::StringConverter::toString( x1 ) + ", y1 = " + Ogre::StringConverter::toString( y1 ) );
-        //LOG_ERROR( "x2 = " + Ogre::StringConverter::toString( x2 ) + ", y2 = " + Ogre::StringConverter::toString( y2 ) );
-        //LOG_ERROR( "x3 = " + Ogre::StringConverter::toString( x3 ) + ", y3 = " + Ogre::StringConverter::toString( y3 ) );
-        //LOG_ERROR( "x4 = " + Ogre::StringConverter::toString( x4 ) + ", y4 = " + Ogre::StringConverter::toString( y4 ) );
-
-        float new_x1 = ( x1 / m_ScreenWidth ) * 2 - 1;
-        float new_y1 = -( ( y1 / m_ScreenHeight ) * 2 - 1 );
-        float new_x2 = ( x2 / m_ScreenWidth ) * 2 - 1;
-        float new_y2 = -( ( y2 / m_ScreenHeight ) * 2 - 1 );
-        float new_x3 = ( x3 / m_ScreenWidth ) * 2 - 1;
-        float new_y3 = -( ( y3 / m_ScreenHeight ) * 2 - 1 );
-        float new_x4 = ( x4 / m_ScreenWidth ) * 2 - 1;
-        float new_y4 = -( ( y4 / m_ScreenHeight ) * 2 - 1 );
-
-        local_x1 += ( char_data.width + char_data.post ) * m_FinalScale.x * m_ScreenHeight / 720.0f;
+        local_x1 += (char_data.width + char_data.post) * m_FinalScale.x * m_ScreenHeight / 720.0f;
 
 
         float width = static_cast<float>(m_Font->GetImageWidth());
         float width = static_cast<float>(m_Font->GetImageWidth());
         float height = static_cast<float>(m_Font->GetImageHeight());
         float height = static_cast<float>(m_Font->GetImageHeight());
-        float left = ( float )char_data.x / width;
-        float right = ( float )( char_data.x + char_data.width ) / width;
-        float top = ( float )char_data.y / height;
-        float bottom = ( float )( char_data.y + char_data.height ) / height;
-
-        //LOG_ERROR( "width = " + Ogre::StringConverter::toString( width ) + "." );
-        //LOG_ERROR( "height = " + Ogre::StringConverter::toString( height ) + "." );
-        //LOG_ERROR( "char_data.x = " + Ogre::StringConverter::toString( char_data.x ) + "." );
-        //LOG_ERROR( "char_data.y = " + Ogre::StringConverter::toString( char_data.y ) + "." );
-        //LOG_ERROR( "char_data.width = " + Ogre::StringConverter::toString( char_data.width ) + "." );
-        //LOG_ERROR( "char_data.height = " + Ogre::StringConverter::toString( char_data.height ) + "." );
-        //LOG_ERROR( "left = " + Ogre::StringConverter::toString( left ) + "." );
-        //LOG_ERROR( "right = " + Ogre::StringConverter::toString( right ) + "." );
-        //LOG_ERROR( "top = " + Ogre::StringConverter::toString( top ) + "." );
-        //LOG_ERROR( "bottom = " + Ogre::StringConverter::toString( bottom ) + "." );
-
-        *writeIterator++ = new_x1;
-        *writeIterator++ = new_y1;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = left;
-        *writeIterator++ = top;
-
-        *writeIterator++ = new_x2;
-        *writeIterator++ = new_y2;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = right;
-        *writeIterator++ = top;
-
-        *writeIterator++ = new_x3;
-        *writeIterator++ = new_y3;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = right;
-        *writeIterator++ = bottom;
-
-        *writeIterator++ = new_x1;
-        *writeIterator++ = new_y1;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = left;
-        *writeIterator++ = top;
-
-        *writeIterator++ = new_x3;
-        *writeIterator++ = new_y3;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = right;
-        *writeIterator++ = bottom;
-
-        *writeIterator++ = new_x4;
-        *writeIterator++ = new_y4;
-        *writeIterator++ = m_FinalZ;
-        *writeIterator++ = style.colour.r;
-        *writeIterator++ = style.colour.g;
-        *writeIterator++ = style.colour.b;
-        *writeIterator++ = style.colour.a;
-        *writeIterator++ = left;
-        *writeIterator++ = bottom;
 
 
+        Ogre::Vector3 coords[4] = {
+            Ogre::Vector3((x1 / m_ScreenWidth) * 2 - 1, -((y1 / m_ScreenHeight) * 2 - 1), m_FinalZ),
+            Ogre::Vector3((x2 / m_ScreenWidth) * 2 - 1, -((y2 / m_ScreenHeight) * 2 - 1), m_FinalZ),
+            Ogre::Vector3((x3 / m_ScreenWidth) * 2 - 1, -((y3 / m_ScreenHeight) * 2 - 1), m_FinalZ),
+            Ogre::Vector3((x4 / m_ScreenWidth) * 2 - 1, -((y4 / m_ScreenHeight) * 2 - 1), m_FinalZ)
+        };
+        auto texture = Ogre::FloatRect(
+            (float)char_data.x / width, // left
+            (float)char_data.y / height, // top
+            (float)(char_data.x + char_data.width) / width, // right
+            (float)(char_data.y + char_data.height) / height // bottom
+       );
+        Ogre::ColourValue colour = style.colour;
+
+        // draw two triangles with a colour and texture.
+        WriteGlyph(writeIterator, coords, colour, texture);
         m_RenderOp.vertexData->vertexCount += 6;
         m_RenderOp.vertexData->vertexCount += 6;
         data.position += 1;
         data.position += 1;
     }
     }
@@ -446,7 +350,6 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::CreateVertexBuffer()
 UiTextArea::CreateVertexBuffer()
 {
 {
@@ -457,21 +360,20 @@ UiTextArea::CreateVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
 
 
     size_t offset = 0;
     size_t offset = 0;
-    vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
-    offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
-    vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
+    vDecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
+    offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
+    vDecl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
 
 
-    m_VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_MaxLetters * 6, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_MaxLetters * 6, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
 
-    m_RenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_VertexBuffer );
+    m_RenderOp.vertexData->vertexBufferBinding->setBinding(0, m_VertexBuffer);
     m_RenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_RenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_RenderOp.useIndexes = false;
     m_RenderOp.useIndexes = false;
 }
 }
 
 
 
 
-
 void
 void
 UiTextArea::DestroyVertexBuffer()
 UiTextArea::DestroyVertexBuffer()
 {
 {

+ 141 - 208
QGearsMain/src/core/UiWidget.cpp

@@ -1,5 +1,3 @@
-#include "core/UiWidget.h"
-
 #include <OgreMath.h>
 #include <OgreMath.h>
 #include <OgreRoot.h>
 #include <OgreRoot.h>
 
 
@@ -9,51 +7,47 @@
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
 #include "core/Timer.h"
 #include "core/Timer.h"
+#include "core/UiWidget.h"
 
 
 
 
-
-ConfigVar cv_debug_ui( "debug_ui", "Draw ui debug info", "0" );
-
+ConfigVar cv_debug_ui("debug_ui", "Draw ui debug info", "0");
 
 
 
 
-UiWidget::UiWidget( const Ogre::String& name ):
-    m_Name( name ),
-    m_PathName( name ),
-    m_Parent( NULL )
+UiWidget::UiWidget(const Ogre::String& name):
+    m_Name(name),
+    m_PathName(name),
+    m_Parent(nullptr)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
-UiWidget::UiWidget( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent ):
-    m_Name( name ),
-    m_PathName( path_name ),
-    m_Parent( parent )
+UiWidget::UiWidget(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent):
+    m_Name(name),
+    m_PathName(path_name),
+    m_Parent(parent)
 {
 {
     Initialise();
     Initialise();
 }
 }
 
 
 
 
-
 UiWidget::~UiWidget()
 UiWidget::~UiWidget()
 {
 {
-    for( unsigned int i = 0; i < m_Animations.size(); ++i )
+    for(unsigned int i = 0; i < m_Animations.size(); ++i)
     {
     {
-        delete m_Animations[ i ];
+        delete m_Animations[i];
     }
     }
 
 
-    ScriptManager::getSingleton().RemoveEntity( ScriptManager::UI, m_PathName );
+    ScriptManager::getSingleton().RemoveEntity(ScriptManager::UI, m_PathName);
 
 
     RemoveAllChildren();
     RemoveAllChildren();
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::Initialise()
 UiWidget::Initialise()
 {
 {
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     m_ScreenHeight = static_cast<float>(viewport->getActualHeight());
     m_ScreenHeight = static_cast<float>(viewport->getActualHeight());
 
 
@@ -67,8 +61,8 @@ UiWidget::Initialise()
     m_FinalZ = 0;
     m_FinalZ = 0;
     m_FinalOrigin = Ogre::Vector2::ZERO;
     m_FinalOrigin = Ogre::Vector2::ZERO;
     m_FinalTranslate = Ogre::Vector2::ZERO;
     m_FinalTranslate = Ogre::Vector2::ZERO;
-    m_FinalSize = Ogre::Vector2( m_ScreenWidth, m_ScreenHeight );
-    m_FinalScale = Ogre::Vector2( 1, 1 );
+    m_FinalSize = Ogre::Vector2(m_ScreenWidth, m_ScreenHeight);
+    m_FinalScale = Ogre::Vector2(1, 1);
     m_FinalRotation = 0;
     m_FinalRotation = 0;
 
 
     m_OriginXPercent = 0;
     m_OriginXPercent = 0;
@@ -84,7 +78,7 @@ UiWidget::Initialise()
     m_Width = 0;
     m_Width = 0;
     m_HeightPercent = 100;
     m_HeightPercent = 100;
     m_Height = 0;
     m_Height = 0;
-    m_Scale = Ogre::Vector2( 1.0f, 1.0f );
+    m_Scale = Ogre::Vector2(1.0f, 1.0f);
     m_Rotation = 0.0f;
     m_Rotation = 0.0f;
 
 
     m_Scissor = false;
     m_Scissor = false;
@@ -93,80 +87,74 @@ UiWidget::Initialise()
     m_ScissorLeft = 0;
     m_ScissorLeft = 0;
     m_ScissorRight = static_cast<int>(m_ScreenWidth);
     m_ScissorRight = static_cast<int>(m_ScreenWidth);
 
 
-    m_AnimationCurrent = NULL;
+    m_AnimationCurrent = nullptr;
     m_AnimationDefault = "";
     m_AnimationDefault = "";
     m_AnimationState = UiAnimation::DEFAULT;
     m_AnimationState = UiAnimation::DEFAULT;
-    m_Colour1 = Ogre::ColourValue( 1, 1, 1, 1 );
-    m_Colour2 = Ogre::ColourValue( 1, 1, 1, 1 );
-    m_Colour3 = Ogre::ColourValue( 1, 1, 1, 1 );
-    m_Colour4 = Ogre::ColourValue( 1, 1, 1, 1 );
+    m_Colour1 = Ogre::ColourValue(1, 1, 1, 1);
+    m_Colour2 = Ogre::ColourValue(1, 1, 1, 1);
+    m_Colour3 = Ogre::ColourValue(1, 1, 1, 1);
+    m_Colour4 = Ogre::ColourValue(1, 1, 1, 1);
 
 
-    ScriptManager::getSingleton().AddEntity( ScriptManager::UI, m_PathName, NULL );
+    ScriptManager::getSingleton().AddEntity(ScriptManager::UI, m_PathName, nullptr);
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::Update()
 UiWidget::Update()
 {
 {
-    if( m_Visible != true )
+    if(m_Visible != true)
     {
     {
         return;
         return;
     }
     }
 
 
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != nullptr)
     {
     {
         float delta_time = Timer::getSingleton().GetGameTimeDelta();
         float delta_time = Timer::getSingleton().GetGameTimeDelta();
         float time = m_AnimationCurrent->GetTime();
         float time = m_AnimationCurrent->GetTime();
 
 
         // if animation ended
         // if animation ended
-        if( time + delta_time >= m_AnimationEndTime )
+        if(time + delta_time >= m_AnimationEndTime)
         {
         {
-            if( time != m_AnimationEndTime)
+            if(time != m_AnimationEndTime)
             {
             {
-                m_AnimationCurrent->AddTime( m_AnimationEndTime - time );
+                m_AnimationCurrent->AddTime(m_AnimationEndTime - time);
             }
             }
 
 
-            for( unsigned int i = 0; i < m_AnimationSync.size(); ++i)
+            for(unsigned int i = 0; i < m_AnimationSync.size(); ++i)
             {
             {
-                ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationSync[ i ] );
+                ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationSync[i]);
             }
             }
             m_AnimationSync.clear();
             m_AnimationSync.clear();
 
 
-            if( m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "" )
+            if(m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "")
             {
             {
                 // in case of cycled default we need to sync with end
                 // in case of cycled default we need to sync with end
                 time = time + delta_time - m_AnimationCurrent->GetLength();
                 time = time + delta_time - m_AnimationCurrent->GetLength();
-                PlayAnimation( m_AnimationDefault, UiAnimation::DEFAULT, time, -1 );
+                PlayAnimation(m_AnimationDefault, UiAnimation::DEFAULT, time, -1);
             }
             }
         }
         }
         else
         else
         {
         {
-            m_AnimationCurrent->AddTime( delta_time );
+            m_AnimationCurrent->AddTime(delta_time);
         }
         }
     }
     }
-    else if( m_AnimationCurrent == NULL && m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "" )
+    else if(m_AnimationCurrent == nullptr && m_AnimationState == UiAnimation::DEFAULT && m_AnimationDefault != "")
     {
     {
-        PlayAnimation( m_AnimationDefault, UiAnimation::DEFAULT, 0, -1 );
+        PlayAnimation(m_AnimationDefault, UiAnimation::DEFAULT, 0, -1);
     }
     }
 
 
-
-
-    for( size_t i = 0; i < m_Children.size(); ++i )
+    for(size_t i = 0; i < m_Children.size(); ++i)
     {
     {
-        m_Children[ i ]->Update();
+        m_Children[i]->Update();
     }
     }
 
 
-
-
-    if( m_UpdateTransformation == true )
+    if(m_UpdateTransformation == true)
     {
     {
         UpdateTransformation();
         UpdateTransformation();
     }
     }
 
 
-
     // debug output
     // debug output
-    if( cv_debug_ui.GetI() >= 1 )
+    if(cv_debug_ui.GetI() >= 1)
     {
     {
         float local_x1 = -m_FinalOrigin.x;
         float local_x1 = -m_FinalOrigin.x;
         float local_y1 = -m_FinalOrigin.y;
         float local_y1 = -m_FinalOrigin.y;
@@ -175,16 +163,16 @@ UiWidget::Update()
         float x = m_FinalTranslate.x;
         float x = m_FinalTranslate.x;
         float y = m_FinalTranslate.y;
         float y = m_FinalTranslate.y;
 
 
-        DEBUG_DRAW.SetScreenSpace( true );
+        DEBUG_DRAW.SetScreenSpace(true);
 
 
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
 
 
         int x1, y1, x2, y2, x3, y3, x4, y4;
         int x1, y1, x2, y2, x3, y3, x4, y4;
 
 
-        if( m_FinalRotation != 0 )
+        if(m_FinalRotation != 0)
         {
         {
-            float cos = Ogre::Math::Cos( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
-            float sin = Ogre::Math::Sin( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
+            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
+            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
 
 
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -214,68 +202,64 @@ UiWidget::Update()
         DEBUG_DRAW.Line(static_cast<float>(x4), static_cast<float>(y4), static_cast<float>(x1), static_cast<float>(y1));
         DEBUG_DRAW.Line(static_cast<float>(x4), static_cast<float>(y4), static_cast<float>(x1), static_cast<float>(y1));
 
 
         // draw translation
         // draw translation
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 0, 1, 0, 1 ) );
-        Ogre::Vector2 area_origin = ( m_Parent != NULL ) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
-        Ogre::Vector2 area_translate = ( m_Parent != NULL ) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(0, 1, 0, 1));
+        Ogre::Vector2 area_origin = (m_Parent != nullptr) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
+        Ogre::Vector2 area_translate = (m_Parent != nullptr) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
         Ogre::Vector2 pos = area_translate - area_origin;
         Ogre::Vector2 pos = area_translate - area_origin;
-        DEBUG_DRAW.Line( pos.x, pos.y, x, y );
-        DEBUG_DRAW.Quad( x - 2, y - 2, x + 2, y - 2, x + 2, y + 2, x - 2, y + 2 );
+        DEBUG_DRAW.Line(pos.x, pos.y, x, y);
+        DEBUG_DRAW.Quad(x - 2, y - 2, x + 2, y - 2, x + 2, y + 2, x - 2, y + 2);
 
 
-        if( cv_debug_ui.GetI() >= 2 )
+        if(cv_debug_ui.GetI() >= 2)
         {
         {
-            DEBUG_DRAW.SetColour( Ogre::ColourValue::White );
-            DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
+            DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
+            DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
             DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1), m_PathName);
             DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1), m_PathName);
             DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1 + 12), GetCurrentAnimationName());
             DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1 + 12), GetCurrentAnimationName());
         }
         }
 
 
         // draw origin
         // draw origin
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
-        DEBUG_DRAW.Line( x, y, static_cast<float>(x1), static_cast<float>(y1 + 1) );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
+        DEBUG_DRAW.Line(x, y, static_cast<float>(x1), static_cast<float>(y1 + 1));
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::OnResize()
 UiWidget::OnResize()
 {
 {
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     m_ScreenHeight = static_cast<float>(viewport->getActualHeight());
     m_ScreenHeight = static_cast<float>(viewport->getActualHeight());
 
 
-    for( size_t i = 0; i < m_Children.size(); ++i )
+    for(size_t i = 0; i < m_Children.size(); ++i)
     {
     {
-        m_Children[ i ]->OnResize();
+        m_Children[i]->OnResize();
     }
     }
 
 
     m_UpdateTransformation = true;
     m_UpdateTransformation = true;
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::Render()
 UiWidget::Render()
 {
 {
-    if( m_Visible == true )
+    if(m_Visible == true)
     {
     {
-        for( size_t i = 0; i < m_Children.size(); ++i )
+        for(size_t i = 0; i < m_Children.size(); ++i)
         {
         {
-            m_Children[ i ]->Render();
+            m_Children[i]->Render();
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetVisible( const bool visible )
+UiWidget::SetVisible(const bool visible)
 {
 {
     m_Visible = visible;
     m_Visible = visible;
 }
 }
 
 
 
 
-
 bool
 bool
 UiWidget::IsVisible() const
 UiWidget::IsVisible() const
 {
 {
@@ -283,7 +267,6 @@ UiWidget::IsVisible() const
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 UiWidget::GetName() const
 UiWidget::GetName() const
 {
 {
@@ -291,55 +274,50 @@ UiWidget::GetName() const
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::AddChild( UiWidget *widget )
+UiWidget::AddChild(UiWidget *widget)
 {
 {
-    m_Children.push_back( widget );
+    m_Children.push_back(widget);
 }
 }
 
 
 
 
-
 UiWidget*
 UiWidget*
-UiWidget::GetChild( const Ogre::String& name )
+UiWidget::GetChild(const Ogre::String& name)
 {
 {
-    for( size_t i = 0; i < m_Children.size(); ++i )
+    for(size_t i = 0; i < m_Children.size(); ++i)
     {
     {
-        if( m_Children[ i ]->GetName() == name )
+        if(m_Children[i]->GetName() == name)
         {
         {
-            return m_Children[ i ];
+            return m_Children[i];
         }
         }
     }
     }
 
 
-    return NULL;
+    return nullptr;
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::RemoveAllChildren()
 UiWidget::RemoveAllChildren()
 {
 {
-    for( size_t i = 0; i < m_Children.size(); ++i )
+    for(size_t i = 0; i < m_Children.size(); ++i)
     {
     {
-        delete m_Children[ i ];
+        delete m_Children[i];
     }
     }
     m_Children.clear();
     m_Children.clear();
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::AddAnimation( UiAnimation* animation )
+UiWidget::AddAnimation(UiAnimation* animation)
 {
 {
-    m_Animations.push_back( animation );
+    m_Animations.push_back(animation);
 }
 }
 
 
 
 
-
 const Ogre::String&
 const Ogre::String&
 UiWidget::GetCurrentAnimationName() const
 UiWidget::GetCurrentAnimationName() const
 {
 {
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != nullptr)
     {
     {
         return m_AnimationCurrent->GetName();
         return m_AnimationCurrent->GetName();
     }
     }
@@ -348,150 +326,134 @@ UiWidget::GetCurrentAnimationName() const
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::PlayAnimation( const Ogre::String& animation, UiAnimation::State state, const float start, const float end )
+UiWidget::PlayAnimation(const Ogre::String& animation, UiAnimation::State state, const float start, const float end)
 {
 {
-    for( size_t i = 0; i < m_Animations.size(); ++i)
+    for(size_t i = 0; i < m_Animations.size(); ++i)
     {
     {
-        if( m_Animations[ i ]->GetName() == animation )
+        if(m_Animations[i]->GetName() == animation)
         {
         {
-            m_AnimationCurrent = m_Animations[ i ];
-            m_AnimationCurrent->SetTime( ( start == -1 ) ? m_AnimationCurrent->GetLength() : start );
-            m_AnimationCurrent->AddTime( 0 );
-            m_AnimationEndTime = ( end == -1 ) ? m_AnimationCurrent->GetLength() : end;
+            m_AnimationCurrent = m_Animations[i];
+            m_AnimationCurrent->SetTime((start == -1) ? m_AnimationCurrent->GetLength() : start);
+            m_AnimationCurrent->AddTime(0);
+            m_AnimationEndTime = (end == -1) ? m_AnimationCurrent->GetLength() : end;
             m_AnimationState = state;
             m_AnimationState = state;
             return;
             return;
         }
         }
     }
     }
 
 
     // stop current state and animation
     // stop current state and animation
-    m_AnimationCurrent = NULL;
+    m_AnimationCurrent = nullptr;
     m_AnimationState = UiAnimation::ONCE;
     m_AnimationState = UiAnimation::ONCE;
-    LOG_ERROR( "Widget '" + m_Name + "' doesn't has animation '" + animation + "'." );
+    LOG_ERROR("Widget '" + m_Name + "' doesn't has animation '" + animation + "'.");
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::ScriptPlayAnimation( const char* name )
+UiWidget::ScriptPlayAnimation(const char* name)
 {
 {
-    PlayAnimation( Ogre::String( name ), UiAnimation::DEFAULT, 0, -1 );
+    PlayAnimation(Ogre::String(name), UiAnimation::DEFAULT, 0, -1);
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::ScriptPlayAnimationStop( const char* name )
+UiWidget::ScriptPlayAnimationStop(const char* name)
 {
 {
-    PlayAnimation( Ogre::String( name ), UiAnimation::ONCE, 0, -1 );
+    PlayAnimation(Ogre::String(name), UiAnimation::ONCE, 0, -1);
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::ScriptPlayAnimation( const char* name, const float start, const float end )
+UiWidget::ScriptPlayAnimation(const char* name, const float start, const float end)
 {
 {
-    PlayAnimation( Ogre::String( name ), UiAnimation::DEFAULT, start, end );
+    PlayAnimation(Ogre::String(name), UiAnimation::DEFAULT, start, end);
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::ScriptPlayAnimationStop( const char* name, const float start, const float end )
+UiWidget::ScriptPlayAnimationStop(const char* name, const float start, const float end)
 {
 {
-    PlayAnimation( Ogre::String( name ), UiAnimation::ONCE, start, end );
+    PlayAnimation(Ogre::String(name), UiAnimation::ONCE, start, end);
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::ScriptSetDefaultAnimation( const char* animation )
+UiWidget::ScriptSetDefaultAnimation(const char* animation)
 {
 {
-    m_AnimationDefault = Ogre::String( animation );
+    m_AnimationDefault = Ogre::String(animation);
     m_AnimationState = UiAnimation::DEFAULT;
     m_AnimationState = UiAnimation::DEFAULT;
 }
 }
 
 
 
 
-
 int
 int
 UiWidget::ScriptAnimationSync()
 UiWidget::ScriptAnimationSync()
 {
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
-    m_AnimationSync.push_back( script );
+    m_AnimationSync.push_back(script);
     return -1;
     return -1;
 }
 }
 
 
 
 
-
 void
 void
 UiWidget::UpdateTransformation()
 UiWidget::UpdateTransformation()
 {
 {
-    Ogre::Vector2 area_scale = ( m_Parent != NULL ) ? m_Parent->GetFinalScale() : Ogre::Vector2( 1, 1 );
-    Ogre::Vector2 area_origin = ( m_Parent != NULL ) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
-    Ogre::Vector2 area_translate = ( m_Parent != NULL ) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
-    Ogre::Vector2 area_size = ( m_Parent != NULL ) ? m_Parent->GetFinalSize() : Ogre::Vector2( m_ScreenWidth, m_ScreenHeight );
-    float area_rotation = ( m_Parent != NULL ) ? m_Parent->GetFinalRotation() : 0;
+    Ogre::Vector2 area_scale = (m_Parent != nullptr) ? m_Parent->GetFinalScale() : Ogre::Vector2(1, 1);
+    Ogre::Vector2 area_origin = (m_Parent != nullptr) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
+    Ogre::Vector2 area_translate = (m_Parent != nullptr) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
+    Ogre::Vector2 area_size = (m_Parent != nullptr) ? m_Parent->GetFinalSize() : Ogre::Vector2(m_ScreenWidth, m_ScreenHeight);
+    float area_rotation = (m_Parent != nullptr) ? m_Parent->GetFinalRotation() : 0;
 
 
-    float local_x = ( ( area_size.x * m_XPercent ) / 100.0f + ( m_X * m_ScreenHeight / 720.0f ) * area_scale.x ) - area_origin.x;
-    float local_y = ( ( area_size.y * m_YPercent ) / 100.0f + ( m_Y * m_ScreenHeight / 720.0f ) * area_scale.y ) - area_origin.y;
+    float local_x = ((area_size.x * m_XPercent) / 100.0f + (m_X * m_ScreenHeight / 720.0f) * area_scale.x) - area_origin.x;
+    float local_y = ((area_size.y * m_YPercent) / 100.0f + (m_Y * m_ScreenHeight / 720.0f) * area_scale.y) - area_origin.y;
 
 
     float x = local_x;
     float x = local_x;
     float y = local_y;
     float y = local_y;
 
 
-    if( area_rotation != 0 )
+    if(area_rotation != 0)
     {
     {
-        float cos = Ogre::Math::Cos( Ogre::Radian( Ogre::Degree( area_rotation ) ) );
-        float sin = Ogre::Math::Sin( Ogre::Radian( Ogre::Degree( area_rotation ) ) );
+        float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(area_rotation)));
+        float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(area_rotation)));
         x = local_x * cos - local_y * sin;
         x = local_x * cos - local_y * sin;
         y = local_x * sin + local_y * cos;
         y = local_x * sin + local_y * cos;
     }
     }
 
 
-
-
     m_FinalTranslate.x = area_translate.x;
     m_FinalTranslate.x = area_translate.x;
-    if( m_Align == RIGHT )
+    if(m_Align == RIGHT)
     {
     {
         m_FinalTranslate.x = area_translate.x + area_size.x;
         m_FinalTranslate.x = area_translate.x + area_size.x;
     }
     }
-    else if( m_Align == CENTER )
+    else if(m_Align == CENTER)
     {
     {
         m_FinalTranslate.x = area_translate.x + area_size.x / 2;
         m_FinalTranslate.x = area_translate.x + area_size.x / 2;
     }
     }
     m_FinalTranslate.x += x;
     m_FinalTranslate.x += x;
 
 
-
-
     m_FinalTranslate.y = area_translate.y;
     m_FinalTranslate.y = area_translate.y;
-    if( m_VerticalAlign == BOTTOM )
+    if(m_VerticalAlign == BOTTOM)
     {
     {
         m_FinalTranslate.y = area_translate.y + area_size.y;
         m_FinalTranslate.y = area_translate.y + area_size.y;
     }
     }
-    else if( m_VerticalAlign == MIDDLE )
+    else if(m_VerticalAlign == MIDDLE)
     {
     {
         m_FinalTranslate.y = area_translate.y + area_size.y / 2;
         m_FinalTranslate.y = area_translate.y + area_size.y / 2;
     }
     }
     m_FinalTranslate.y += y;
     m_FinalTranslate.y += y;
 
 
-
-
-    m_FinalZ = ( m_Parent != NULL ) ? m_Parent->GetFinalZ() + m_Z : m_Z;
+    m_FinalZ = (m_Parent != nullptr) ? m_Parent->GetFinalZ() + m_Z : m_Z;
     m_FinalScale = area_scale * m_Scale;
     m_FinalScale = area_scale * m_Scale;
-    m_FinalSize.x = ( area_size.x * m_WidthPercent * m_Scale.x ) / 100.0f + ( m_Width * m_ScreenHeight / 720.0f ) * m_FinalScale.x;
-    m_FinalSize.y = ( area_size.y * m_HeightPercent * m_Scale.y ) / 100.0f + ( m_Height * m_ScreenHeight / 720.0f ) * m_FinalScale.y;
-    m_FinalOrigin.x = ( m_FinalSize.x * m_OriginXPercent ) / 100.0f + m_OriginX * m_ScreenHeight * m_FinalScale.x / 720.0f;
-    m_FinalOrigin.y = ( m_FinalSize.y * m_OriginYPercent ) / 100.0f + m_OriginY * m_ScreenHeight * m_FinalScale.y / 720.0f;
+    m_FinalSize.x = (area_size.x * m_WidthPercent * m_Scale.x) / 100.0f + (m_Width * m_ScreenHeight / 720.0f) * m_FinalScale.x;
+    m_FinalSize.y = (area_size.y * m_HeightPercent * m_Scale.y) / 100.0f + (m_Height * m_ScreenHeight / 720.0f) * m_FinalScale.y;
+    m_FinalOrigin.x = (m_FinalSize.x * m_OriginXPercent) / 100.0f + m_OriginX * m_ScreenHeight * m_FinalScale.x / 720.0f;
+    m_FinalOrigin.y = (m_FinalSize.y * m_OriginYPercent) / 100.0f + m_OriginY * m_ScreenHeight * m_FinalScale.y / 720.0f;
     m_FinalRotation = area_rotation + m_Rotation;
     m_FinalRotation = area_rotation + m_Rotation;
 
 
-
-
     // scissor update
     // scissor update
-    m_ScissorTop = ( m_Parent != NULL ) ? m_Parent->GetScissorTop() : 0;
-    m_ScissorBottom = ( m_Parent != NULL ) ? m_Parent->GetScissorBottom() : static_cast<int>(m_ScreenHeight);
-    m_ScissorLeft = ( m_Parent != NULL ) ? m_Parent->GetScissorLeft() : 0;
-    m_ScissorRight = (m_Parent != NULL) ? m_Parent->GetScissorRight() : static_cast<int>(m_ScreenWidth);
+    m_ScissorTop = (m_Parent != nullptr) ? m_Parent->GetScissorTop() : 0;
+    m_ScissorBottom = (m_Parent != nullptr) ? m_Parent->GetScissorBottom() : static_cast<int>(m_ScreenHeight);
+    m_ScissorLeft = (m_Parent != nullptr) ? m_Parent->GetScissorLeft() : 0;
+    m_ScissorRight = (m_Parent != nullptr) ? m_Parent->GetScissorRight() : static_cast<int>(m_ScreenWidth);
 
 
-    if( m_Scissor == true )
+    if(m_Scissor == true)
     {
     {
         float local_x1 = -m_FinalOrigin.x;
         float local_x1 = -m_FinalOrigin.x;
         float local_y1 = -m_FinalOrigin.y;
         float local_y1 = -m_FinalOrigin.y;
@@ -502,10 +464,10 @@ UiWidget::UpdateTransformation()
 
 
         int x1, y1, x2, y2, x3, y3, x4, y4;
         int x1, y1, x2, y2, x3, y3, x4, y4;
 
 
-        if( m_FinalRotation != 0 )
+        if(m_FinalRotation != 0)
         {
         {
-            float cos = Ogre::Math::Cos( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
-            float sin = Ogre::Math::Sin( Ogre::Radian( Ogre::Degree( m_FinalRotation ) ) );
+            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
+            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(m_FinalRotation)));
 
 
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -528,42 +490,35 @@ UiWidget::UpdateTransformation()
             y4 = static_cast<int>(local_y2 + y);
             y4 = static_cast<int>(local_y2 + y);
         }
         }
 
 
-        m_ScissorTop = std::max( m_ScissorTop, std::min( std::min( y1 , y2 ), std::min( y3 , y4 ) ) );
-        m_ScissorBottom = std::min( m_ScissorBottom, std::max( std::max( y1 , y2 ), std::max( y3 , y4 ) ) );
-        m_ScissorLeft = std::max( m_ScissorLeft, std::min( std::min( x1 , x2 ), std::min( x3 , x4 ) ) );
-        m_ScissorRight = std::min( m_ScissorRight, std::max( std::max( x1 , x2 ), std::max( x3 , x4 ) ) );
+        m_ScissorTop = std::max(m_ScissorTop, std::min(std::min(y1 , y2), std::min(y3 , y4)));
+        m_ScissorBottom = std::min(m_ScissorBottom, std::max(std::max(y1 , y2), std::max(y3 , y4)));
+        m_ScissorLeft = std::max(m_ScissorLeft, std::min(std::min(x1 , x2), std::min(x3 , x4)));
+        m_ScissorRight = std::min(m_ScissorRight, std::max(std::max(x1 , x2), std::max(x3 , x4)));
     }
     }
 
 
-
-
     m_UpdateTransformation = false;
     m_UpdateTransformation = false;
 
 
-
-
-    for( size_t i = 0; i < m_Children.size(); ++i )
+    for(size_t i = 0; i < m_Children.size(); ++i)
     {
     {
-        m_Children[ i ]->UpdateTransformation();
+        m_Children[i]->UpdateTransformation();
     }
     }
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetAlign( const UiWidget::Align align )
+UiWidget::SetAlign(const UiWidget::Align align)
 {
 {
     m_Align = align;
     m_Align = align;
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetVerticalAlign( const UiWidget::VerticalAlign valign )
+UiWidget::SetVerticalAlign(const UiWidget::VerticalAlign valign)
 {
 {
     m_VerticalAlign = valign;
     m_VerticalAlign = valign;
 }
 }
 
 
 
 
-
 float
 float
 UiWidget::GetFinalZ() const
 UiWidget::GetFinalZ() const
 {
 {
@@ -571,7 +526,6 @@ UiWidget::GetFinalZ() const
 }
 }
 
 
 
 
-
 Ogre::Vector2
 Ogre::Vector2
 UiWidget::GetFinalOrigin() const
 UiWidget::GetFinalOrigin() const
 {
 {
@@ -579,7 +533,6 @@ UiWidget::GetFinalOrigin() const
 }
 }
 
 
 
 
-
 Ogre::Vector2
 Ogre::Vector2
 UiWidget::GetFinalTranslate() const
 UiWidget::GetFinalTranslate() const
 {
 {
@@ -587,7 +540,6 @@ UiWidget::GetFinalTranslate() const
 }
 }
 
 
 
 
-
 Ogre::Vector2
 Ogre::Vector2
 UiWidget::GetFinalSize() const
 UiWidget::GetFinalSize() const
 {
 {
@@ -595,7 +547,6 @@ UiWidget::GetFinalSize() const
 }
 }
 
 
 
 
-
 Ogre::Vector2
 Ogre::Vector2
 UiWidget::GetFinalScale() const
 UiWidget::GetFinalScale() const
 {
 {
@@ -603,7 +554,6 @@ UiWidget::GetFinalScale() const
 }
 }
 
 
 
 
-
 float
 float
 UiWidget::GetFinalRotation() const
 UiWidget::GetFinalRotation() const
 {
 {
@@ -611,9 +561,8 @@ UiWidget::GetFinalRotation() const
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetOriginX( const float percent, const float x )
+UiWidget::SetOriginX(const float percent, const float x)
 {
 {
     m_OriginXPercent = percent;
     m_OriginXPercent = percent;
     m_OriginX = x;
     m_OriginX = x;
@@ -621,9 +570,8 @@ UiWidget::SetOriginX( const float percent, const float x )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetOriginY( const float percent, const float y )
+UiWidget::SetOriginY(const float percent, const float y)
 {
 {
     m_OriginYPercent = percent;
     m_OriginYPercent = percent;
     m_OriginY = y;
     m_OriginY = y;
@@ -631,9 +579,8 @@ UiWidget::SetOriginY( const float percent, const float y )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetX( const float percent, const float x )
+UiWidget::SetX(const float percent, const float x)
 {
 {
     m_XPercent = percent;
     m_XPercent = percent;
     m_X = x;
     m_X = x;
@@ -641,9 +588,8 @@ UiWidget::SetX( const float percent, const float x )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetY( const float percent, const float y )
+UiWidget::SetY(const float percent, const float y)
 {
 {
     m_YPercent = percent;
     m_YPercent = percent;
     m_Y = y;
     m_Y = y;
@@ -651,18 +597,16 @@ UiWidget::SetY( const float percent, const float y )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetZ( const float z )
+UiWidget::SetZ(const float z)
 {
 {
     m_Z = z;
     m_Z = z;
     m_UpdateTransformation = true;
     m_UpdateTransformation = true;
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetWidth( const float percent, const float width )
+UiWidget::SetWidth(const float percent, const float width)
 {
 {
     m_WidthPercent = percent;
     m_WidthPercent = percent;
     m_Width = width;
     m_Width = width;
@@ -670,9 +614,8 @@ UiWidget::SetWidth( const float percent, const float width )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetHeight( const float percent, const float height )
+UiWidget::SetHeight(const float percent, const float height)
 {
 {
     m_HeightPercent = percent;
     m_HeightPercent = percent;
     m_Height = height;
     m_Height = height;
@@ -680,34 +623,30 @@ UiWidget::SetHeight( const float percent, const float height )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetScale( const Ogre::Vector2& scale )
+UiWidget::SetScale(const Ogre::Vector2& scale)
 {
 {
     m_Scale = scale;
     m_Scale = scale;
     m_UpdateTransformation = true;
     m_UpdateTransformation = true;
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetRotation( const float degree )
+UiWidget::SetRotation(const float degree)
 {
 {
     m_Rotation = degree;
     m_Rotation = degree;
     m_UpdateTransformation = true;
     m_UpdateTransformation = true;
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetScissor( bool scissor )
+UiWidget::SetScissor(bool scissor)
 {
 {
     m_Scissor = scissor;
     m_Scissor = scissor;
     m_UpdateTransformation = true;
     m_UpdateTransformation = true;
 }
 }
 
 
 
 
-
 int
 int
 UiWidget::GetScissorTop() const
 UiWidget::GetScissorTop() const
 {
 {
@@ -715,7 +654,6 @@ UiWidget::GetScissorTop() const
 }
 }
 
 
 
 
-
 int
 int
 UiWidget::GetScissorBottom() const
 UiWidget::GetScissorBottom() const
 {
 {
@@ -723,7 +661,6 @@ UiWidget::GetScissorBottom() const
 }
 }
 
 
 
 
-
 int
 int
 UiWidget::GetScissorLeft() const
 UiWidget::GetScissorLeft() const
 {
 {
@@ -731,7 +668,6 @@ UiWidget::GetScissorLeft() const
 }
 }
 
 
 
 
-
 int
 int
 UiWidget::GetScissorRight() const
 UiWidget::GetScissorRight() const
 {
 {
@@ -739,9 +675,8 @@ UiWidget::GetScissorRight() const
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetColour( const float r, const float g, const float b )
+UiWidget::SetColour(const float r, const float g, const float b)
 {
 {
     m_Colour1.r = r; m_Colour1.g = g; m_Colour1.b = b;
     m_Colour1.r = r; m_Colour1.g = g; m_Colour1.b = b;
     m_Colour2.r = r; m_Colour2.g = g; m_Colour2.b = b;
     m_Colour2.r = r; m_Colour2.g = g; m_Colour2.b = b;
@@ -751,9 +686,8 @@ UiWidget::SetColour( const float r, const float g, const float b )
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetColours( const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, const float r3, const float g3, const float b3, const float r4, const float g4, const float b4 )
+UiWidget::SetColours(const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, const float r3, const float g3, const float b3, const float r4, const float g4, const float b4)
 {
 {
     m_Colour1.r = r1; m_Colour1.g = g1; m_Colour1.b = b1;
     m_Colour1.r = r1; m_Colour1.g = g1; m_Colour1.b = b1;
     m_Colour2.r = r2; m_Colour2.g = g2; m_Colour2.b = b2;
     m_Colour2.r = r2; m_Colour2.g = g2; m_Colour2.b = b2;
@@ -763,9 +697,8 @@ UiWidget::SetColours( const float r1, const float g1, const float b1, const floa
 }
 }
 
 
 
 
-
 void
 void
-UiWidget::SetAlpha( const float a )
+UiWidget::SetAlpha(const float a)
 {
 {
     m_Colour1.a = a;
     m_Colour1.a = a;
     m_Colour2.a = a;
     m_Colour2.a = a;

+ 121 - 125
QGearsMain/src/core/Utilites.cpp

@@ -1,122 +1,120 @@
-#include "core/Utilites.h"
-
 #include <OgreStringConverter.h>
 #include <OgreStringConverter.h>
 
 
+#include "core/Utilites.h"
 
 
 
 
 const Ogre::String
 const Ogre::String
 CreateAutoName(const Ogre::String prefix)
 CreateAutoName(const Ogre::String prefix)
 {
 {
     static int enumerator = 0;
     static int enumerator = 0;
-    return prefix + Ogre::StringConverter::toString( enumerator++ );
+    return prefix + Ogre::StringConverter::toString(enumerator++);
 }
 }
 
 
 
 
-
 struct KeyName
 struct KeyName
 {
 {
     Ogre::String name;
     Ogre::String name;
     OIS::KeyCode key;
     OIS::KeyCode key;
 };
 };
 
 
+
 KeyName key_names[] =
 KeyName key_names[] =
 {
 {
-    { "Enter", OIS::KC_RETURN },
-    { "Escape", OIS::KC_ESCAPE },
-    { "Space", OIS::KC_SPACE },
-    { "LShift", OIS::KC_LSHIFT },
-    { "RShift", OIS::KC_RSHIFT },
-    { "LCtrl", OIS::KC_LCONTROL },
-    { "RCtrl", OIS::KC_RCONTROL },
-    { "LAlt", OIS::KC_LMENU },
-    { "RAlt", OIS::KC_RMENU },
-
-    { "0", OIS::KC_0 },
-    { "1", OIS::KC_1 },
-    { "2", OIS::KC_2 },
-    { "3", OIS::KC_3 },
-    { "4", OIS::KC_4 },
-    { "5", OIS::KC_5 },
-    { "6", OIS::KC_6 },
-    { "7", OIS::KC_7 },
-    { "8", OIS::KC_8 },
-    { "9", OIS::KC_9 },
-
-    { "A", OIS::KC_A },
-    { "B", OIS::KC_B },
-    { "C", OIS::KC_C },
-    { "D", OIS::KC_D },
-    { "E", OIS::KC_E },
-    { "F", OIS::KC_F },
-    { "G", OIS::KC_G },
-    { "H", OIS::KC_H },
-    { "I", OIS::KC_I },
-    { "J", OIS::KC_J },
-    { "K", OIS::KC_K },
-    { "L", OIS::KC_L },
-    { "M", OIS::KC_M },
-    { "N", OIS::KC_N },
-    { "O", OIS::KC_O },
-    { "P", OIS::KC_P },
-    { "Q", OIS::KC_Q },
-    { "R", OIS::KC_R },
-    { "S", OIS::KC_S },
-    { "T", OIS::KC_T },
-    { "U", OIS::KC_U },
-    { "V", OIS::KC_V },
-    { "W", OIS::KC_W },
-    { "X", OIS::KC_X },
-    { "Y", OIS::KC_Y },
-    { "Z", OIS::KC_Z },
-
-    { "Left", OIS::KC_LEFT },
-    { "Up", OIS::KC_UP },
-    { "Down", OIS::KC_DOWN },
-    { "Right", OIS::KC_RIGHT },
-
-    { "Num0", OIS::KC_NUMPAD0 },
-    { "Num1", OIS::KC_NUMPAD1 },
-    { "Num2", OIS::KC_NUMPAD2 },
-    { "Num3", OIS::KC_NUMPAD3 },
-    { "Num4", OIS::KC_NUMPAD4 },
-    { "Num5", OIS::KC_NUMPAD5 },
-    { "Num6", OIS::KC_NUMPAD6 },
-    { "Num7", OIS::KC_NUMPAD7 },
-    { "Num8", OIS::KC_NUMPAD8 },
-    { "Num9", OIS::KC_NUMPAD9 },
-    { "NumLock", OIS::KC_NUMLOCK },
-    { "NumDiv", OIS::KC_DIVIDE },
-    { "NumMult", OIS::KC_MULTIPLY },
-    { "NumSub", OIS::KC_SUBTRACT },
-    { "NumAdd", OIS::KC_ADD },
-    { "NumEnter", OIS::KC_NUMPADENTER },
-    { "NumDec", OIS::KC_DECIMAL },
-
-    { "F1", OIS::KC_F1 },
-    { "F2", OIS::KC_F2 },
-    { "F3", OIS::KC_F3 },
-    { "F4", OIS::KC_F4 },
-    { "F5", OIS::KC_F5 },
-    { "F6", OIS::KC_F6 },
-    { "F7", OIS::KC_F7 },
-    { "F8", OIS::KC_F8 },
-    { "F9", OIS::KC_F9 },
-    { "F10", OIS::KC_F10 },
-    { "F11", OIS::KC_F11 },
-    { "F12", OIS::KC_F12 },
-
-    { "UNASSIGNED", OIS::KC_UNASSIGNED },
+    {"Enter", OIS::KC_RETURN},
+    {"Escape", OIS::KC_ESCAPE},
+    {"Space", OIS::KC_SPACE},
+    {"LShift", OIS::KC_LSHIFT},
+    {"RShift", OIS::KC_RSHIFT},
+    {"LCtrl", OIS::KC_LCONTROL},
+    {"RCtrl", OIS::KC_RCONTROL},
+    {"LAlt", OIS::KC_LMENU},
+    {"RAlt", OIS::KC_RMENU},
+
+    {"0", OIS::KC_0},
+    {"1", OIS::KC_1},
+    {"2", OIS::KC_2},
+    {"3", OIS::KC_3},
+    {"4", OIS::KC_4},
+    {"5", OIS::KC_5},
+    {"6", OIS::KC_6},
+    {"7", OIS::KC_7},
+    {"8", OIS::KC_8},
+    {"9", OIS::KC_9},
+
+    {"A", OIS::KC_A},
+    {"B", OIS::KC_B},
+    {"C", OIS::KC_C},
+    {"D", OIS::KC_D},
+    {"E", OIS::KC_E},
+    {"F", OIS::KC_F},
+    {"G", OIS::KC_G},
+    {"H", OIS::KC_H},
+    {"I", OIS::KC_I},
+    {"J", OIS::KC_J},
+    {"K", OIS::KC_K},
+    {"L", OIS::KC_L},
+    {"M", OIS::KC_M},
+    {"N", OIS::KC_N},
+    {"O", OIS::KC_O},
+    {"P", OIS::KC_P},
+    {"Q", OIS::KC_Q},
+    {"R", OIS::KC_R},
+    {"S", OIS::KC_S},
+    {"T", OIS::KC_T},
+    {"U", OIS::KC_U},
+    {"V", OIS::KC_V},
+    {"W", OIS::KC_W},
+    {"X", OIS::KC_X},
+    {"Y", OIS::KC_Y},
+    {"Z", OIS::KC_Z},
+
+    {"Left", OIS::KC_LEFT},
+    {"Up", OIS::KC_UP},
+    {"Down", OIS::KC_DOWN},
+    {"Right", OIS::KC_RIGHT},
+
+    {"Num0", OIS::KC_NUMPAD0},
+    {"Num1", OIS::KC_NUMPAD1},
+    {"Num2", OIS::KC_NUMPAD2},
+    {"Num3", OIS::KC_NUMPAD3},
+    {"Num4", OIS::KC_NUMPAD4},
+    {"Num5", OIS::KC_NUMPAD5},
+    {"Num6", OIS::KC_NUMPAD6},
+    {"Num7", OIS::KC_NUMPAD7},
+    {"Num8", OIS::KC_NUMPAD8},
+    {"Num9", OIS::KC_NUMPAD9},
+    {"NumLock", OIS::KC_NUMLOCK},
+    {"NumDiv", OIS::KC_DIVIDE},
+    {"NumMult", OIS::KC_MULTIPLY},
+    {"NumSub", OIS::KC_SUBTRACT},
+    {"NumAdd", OIS::KC_ADD},
+    {"NumEnter", OIS::KC_NUMPADENTER},
+    {"NumDec", OIS::KC_DECIMAL},
+
+    {"F1", OIS::KC_F1},
+    {"F2", OIS::KC_F2},
+    {"F3", OIS::KC_F3},
+    {"F4", OIS::KC_F4},
+    {"F5", OIS::KC_F5},
+    {"F6", OIS::KC_F6},
+    {"F7", OIS::KC_F7},
+    {"F8", OIS::KC_F8},
+    {"F9", OIS::KC_F9},
+    {"F10", OIS::KC_F10},
+    {"F11", OIS::KC_F11},
+    {"F12", OIS::KC_F12},
+
+    {"UNASSIGNED", OIS::KC_UNASSIGNED},
 };
 };
 
 
 
 
-
 Ogre::String
 Ogre::String
-KeyToString( OIS::KeyCode key )
+KeyToString(OIS::KeyCode key)
 {
 {
     // find string by key
     // find string by key
-    for( KeyName* kn = key_names; kn->name != "UNASSIGNED"; ++kn )
+    for(KeyName* kn = key_names; kn->name != "UNASSIGNED"; ++kn)
     {
     {
-        if( kn->key == key )
+        if(kn->key == key)
         {
         {
             return kn->name;
             return kn->name;
         }
         }
@@ -126,19 +124,18 @@ KeyToString( OIS::KeyCode key )
 }
 }
 
 
 
 
-
 OIS::KeyCode
 OIS::KeyCode
-StringToKey( const Ogre::String& str )
+StringToKey(const Ogre::String& str)
 {
 {
-    if( str == "" )
+    if(str == "")
     {
     {
         return OIS::KC_UNASSIGNED;
         return OIS::KC_UNASSIGNED;
     }
     }
 
 
     // find key by string
     // find key by string
-    for( KeyName* kn = key_names; kn->name != "UNASSIGNED"; ++kn )
+    for(KeyName* kn = key_names; kn->name != "UNASSIGNED"; ++kn)
     {
     {
-        if( kn->name == str )
+        if(kn->name == str)
         {
         {
             return kn->key;
             return kn->key;
         }
         }
@@ -148,9 +145,8 @@ StringToKey( const Ogre::String& str )
 }
 }
 
 
 
 
-
 Ogre::StringVector
 Ogre::StringVector
-StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve, const Ogre::String& quote, const Ogre::String& esc )
+StringTokenise(const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve, const Ogre::String& quote, const Ogre::String& esc)
 {
 {
     Ogre::StringVector ret;
     Ogre::StringVector ret;
 
 
@@ -167,10 +163,10 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
     Ogre::String::size_type len = str.length();  // length of the input-string
     Ogre::String::size_type len = str.length();  // length of the input-string
 
 
     // for every char in the input-string
     // for every char in the input-string
-    while( len > pos )
+    while(len > pos)
     {
     {
         // get the character of the string and reset the delimiter buffer
         // get the character of the string and reset the delimiter buffer
-        ch = str.at( pos );
+        ch = str.at(pos);
         delimiter = 0;
         delimiter = 0;
 
 
         // assume ch isn't a delimiter
         // assume ch isn't a delimiter
@@ -180,16 +176,16 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
 
 
         // ... if the delimiter is an escaped character
         // ... if the delimiter is an escaped character
         bool escaped = false; // indicates if the next char is protected
         bool escaped = false; // indicates if the next char is protected
-        if( esc.empty() == false ) // check if esc-chars are provided
+        if(esc.empty() == false) // check if esc-chars are provided
         {
         {
-            if( esc.find_first_of( ch ) != std::string::npos )
+            if(esc.find_first_of(ch) != std::string::npos)
             {
             {
                 // get the escaped char
                 // get the escaped char
                 ++pos;
                 ++pos;
-                if( pos < len ) // if there are more chars left
+                if(pos < len) // if there are more chars left
                 {
                 {
                     // get the next one
                     // get the next one
-                    ch = str.at( pos );
+                    ch = str.at(pos);
 
 
                     // add the escaped character to the token
                     // add the escaped character to the token
                     add_char = true;
                     add_char = true;
@@ -206,14 +202,14 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
         }
 
 
         // ... if the delimiter is a quote
         // ... if the delimiter is a quote
-        if( quote.empty() == false && escaped == false )
+        if(quote.empty() == false && escaped == false)
         {
         {
             // if quote chars are provided and the char isn't protected
             // if quote chars are provided and the char isn't protected
-            if( quote.find_first_of( ch ) != std::string::npos )
+            if(quote.find_first_of(ch) != std::string::npos)
             {
             {
                 // if not quoted, set state to open quote and set
                 // if not quoted, set state to open quote and set
                 // the quote character
                 // the quote character
-                if( quoted == false )
+                if(quoted == false)
                 {
                 {
                     quoted = true;
                     quoted = true;
                     current_quote = ch;
                     current_quote = ch;
@@ -224,7 +220,7 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
                 else // if quote is open already
                 else // if quote is open already
                 {
                 {
                     // check if it is the matching character to close it
                     // check if it is the matching character to close it
-                    if( current_quote == ch )
+                    if(current_quote == ch)
                     {
                     {
                         // close quote and reset the quote character
                         // close quote and reset the quote character
                         quoted = false;
                         quoted = false;
@@ -238,15 +234,15 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
         }
 
 
         // if the delimiter isn't preserved
         // if the delimiter isn't preserved
-        if( delimiters.empty() == false && escaped == false && quoted == false )
+        if(delimiters.empty() == false && escaped == false && quoted == false)
         {
         {
             // if a delimiter is provided and the char isn't protected by
             // if a delimiter is provided and the char isn't protected by
             // quote or escape char
             // quote or escape char
-            if( delimiters.find_first_of( ch ) != std::string::npos )
+            if(delimiters.find_first_of(ch) != std::string::npos)
             {
             {
                 // if ch is a delimiter and the token string isn't empty
                 // if ch is a delimiter and the token string isn't empty
                 // the token is complete
                 // the token is complete
-                if( token.empty() == false )
+                if(token.empty() == false)
                 {
                 {
                     token_complete = true;
                     token_complete = true;
                 }
                 }
@@ -258,14 +254,14 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
 
 
         // if the delimiter is preserved - add it as a token
         // if the delimiter is preserved - add it as a token
         bool add_delimiter = false;
         bool add_delimiter = false;
-        if( delimiters_preserve.empty() == false && escaped == false && quoted == false )
+        if(delimiters_preserve.empty() == false && escaped == false && quoted == false)
         {
         {
             // if a delimiter which will be preserved is provided and the
             // if a delimiter which will be preserved is provided and the
             // char isn't protected by quote or escape char
             // char isn't protected by quote or escape char
-            if( delimiters_preserve.find_first_of( ch ) != std::string::npos )
+            if(delimiters_preserve.find_first_of(ch) != std::string::npos)
             {
             {
                 // if ch is a delimiter and the token string isn't empty the token is complete
                 // if ch is a delimiter and the token string isn't empty the token is complete
-                if( token.empty() == false )
+                if(token.empty() == false)
                 {
                 {
                     token_complete = true;
                     token_complete = true;
                 }
                 }
@@ -280,17 +276,17 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
         }
 
 
         // add the character to the token
         // add the character to the token
-        if( add_char == true )
+        if(add_char == true)
         {
         {
             // add the current char
             // add the current char
-            token.push_back( ch );
+            token.push_back(ch);
         }
         }
 
 
         // add the token if it is complete
         // add the token if it is complete
-        if( token_complete == true && token.empty() == false )
+        if(token_complete == true && token.empty() == false)
         {
         {
             // add the token string
             // add the token string
-            ret.push_back( token );
+            ret.push_back(token);
 
 
             // clear the contents
             // clear the contents
             token.clear();
             token.clear();
@@ -300,12 +296,12 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
         }
 
 
         // add the delimiter
         // add the delimiter
-        if( add_delimiter == true )
+        if(add_delimiter == true)
         {
         {
             // the next token is the delimiter
             // the next token is the delimiter
             Ogre::String delim_token;
             Ogre::String delim_token;
-            delim_token.push_back( delimiter );
-            ret.push_back( delim_token );
+            delim_token.push_back(delimiter);
+            ret.push_back(delim_token);
         }
         }
 
 
         // repeat for the next character
         // repeat for the next character
@@ -313,9 +309,9 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
     }
     }
 
 
     // add the final token
     // add the final token
-    if( token.empty() == false )
+    if(token.empty() == false)
     {
     {
-        ret.push_back( token );
+        ret.push_back(token);
     }
     }
 
 
     return ret;
     return ret;

+ 56 - 76
QGearsMain/src/core/Walkmesh.cpp

@@ -1,13 +1,11 @@
-#include "core/Walkmesh.h"
-
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
 #include "core/DebugDraw.h"
 #include "core/DebugDraw.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/Walkmesh.h"
 #include "map/QGearsWalkmeshFile.h"
 #include "map/QGearsWalkmeshFile.h"
 
 
 
 
-ConfigVar cv_debug_walkmesh( "debug_walkmesh", "Draw walkmesh and walkmesh debug info", "false" );
-
+ConfigVar cv_debug_walkmesh("debug_walkmesh", "Draw walkmesh and walkmesh debug info", "false");
 
 
 
 
 
 
@@ -16,75 +14,71 @@ Walkmesh::Walkmesh()
 }
 }
 
 
 
 
-
 Walkmesh::~Walkmesh()
 Walkmesh::~Walkmesh()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 Walkmesh::UpdateDebug()
 Walkmesh::UpdateDebug()
 {
 {
-    if( cv_debug_walkmesh.GetB() == true )
+    if(cv_debug_walkmesh.GetB() == true)
     {
     {
-        DEBUG_DRAW.SetScreenSpace( true );
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.CENTER );
+        DEBUG_DRAW.SetScreenSpace(true);
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.CENTER);
 
 
-        for( unsigned int i = 0; i < m_Triangles.size(); ++i )
+        for(const auto &triangle : m_Triangles)
         {
         {
-            if( m_Triangles[ i ].access_side[ 0 ] == -1 )
+            if(triangle.access_side[0] == -1)
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             }
             else
             else
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             }
             }
-            DEBUG_DRAW.Line3d( m_Triangles[ i ].a, m_Triangles[ i ].b );
+            DEBUG_DRAW.Line3d(triangle.a, triangle.b);
 
 
-            if( m_Triangles[ i ].access_side[ 1 ] == -1 )
+            if(triangle.access_side[1] == -1)
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             }
             else
             else
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             }
             }
-            DEBUG_DRAW.Line3d( m_Triangles[ i ].b, m_Triangles[ i ].c );
+            DEBUG_DRAW.Line3d(triangle.b, triangle.c);
 
 
-            if( m_Triangles[ i ].access_side[ 2 ] == -1 )
+            if(triangle.access_side[2] == -1)
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             }
             else
             else
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             }
             }
-            DEBUG_DRAW.Line3d( m_Triangles[ i ].c, m_Triangles[ i ].a );
+            DEBUG_DRAW.Line3d(triangle.c, triangle.a);
 
 
             /*
             /*
-            if( m_Triangles[ i ].locked == false )
+            if(m_Triangles[i].locked == false)
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 0.5 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 0.5));
             }
             }
             else
             else
             {
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 0.5 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 0.5));
             }
             }
             */
             */
-            //DEBUG_DRAW.Triangle3d( m_Triangles[ i ].a, m_Triangles[ i ].b, m_Triangles[ i ].c );
+            //DEBUG_DRAW.Triangle3d(m_Triangles[i].a, m_Triangles[i].b, m_Triangles[i].c);
 
 
-            DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 1, 1, 1 ) );
-            DEBUG_DRAW.SetFadeDistance( 40, 50 );
-            Ogre::Vector3 triangle_pos = ( m_Triangles[ i ].a + m_Triangles[ i ].b + m_Triangles[ i ].c) / 3;
-            DEBUG_DRAW.Text( triangle_pos, 0, 0, Ogre::StringConverter::toString( i ) );
+            DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+            DEBUG_DRAW.SetFadeDistance(40, 50);
+            Ogre::Vector3 triangle_pos = (triangle.a + triangle.b + triangle.c) / 3;
         }
         }
     }
     }
 }
 }
 
 
 
 
-
 void
 void
 Walkmesh::Clear()
 Walkmesh::Clear()
 {
 {
@@ -92,77 +86,71 @@ Walkmesh::Clear()
 }
 }
 
 
 
 
-
 void
 void
-Walkmesh::AddTriangle( const WalkmeshTriangle& triangle )
+Walkmesh::AddTriangle(const WalkmeshTriangle& triangle)
 {
 {
-    m_Triangles.push_back( triangle );
+    m_Triangles.push_back(triangle);
 }
 }
 
 
 
 
-
 int
 int
-Walkmesh::GetAccessSide( unsigned int triangle_id, unsigned char side ) const
+Walkmesh::GetAccessSide(unsigned int triangle_id, unsigned char side) const
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return -1;
         return -1;
     }
     }
 
 
-    if( side >= 3 )
+    if(side >= 3)
     {
     {
-        LOG_ERROR( "Side greater than 2. Side indexed from 0 to 2." );
+        LOG_ERROR("Side greater than 2. Side indexed from 0 to 2.");
         return -1;
         return -1;
     }
     }
 
 
-    return m_Triangles[ triangle_id ].access_side[ side ];
+    return m_Triangles[triangle_id].access_side[side];
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
-Walkmesh::GetA( unsigned int triangle_id ) const
+Walkmesh::GetA(unsigned int triangle_id) const
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
         return Ogre::Vector3::ZERO;
     }
     }
 
 
-    return m_Triangles[ triangle_id ].a;
+    return m_Triangles[triangle_id].a;
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
-Walkmesh::GetB( unsigned int triangle_id ) const
+Walkmesh::GetB(unsigned int triangle_id) const
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
         return Ogre::Vector3::ZERO;
     }
     }
 
 
-    return m_Triangles[ triangle_id ].b;
+    return m_Triangles[triangle_id].b;
 }
 }
 
 
 
 
-
 const Ogre::Vector3&
 const Ogre::Vector3&
-Walkmesh::GetC( unsigned int triangle_id ) const
+Walkmesh::GetC(unsigned int triangle_id) const
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
         return Ogre::Vector3::ZERO;
     }
     }
 
 
-    return m_Triangles[ triangle_id ].c;
+    return m_Triangles[triangle_id].c;
 }
 }
 
 
 
 
-
 int
 int
 Walkmesh::GetNumberOfTriangles() const
 Walkmesh::GetNumberOfTriangles() const
 {
 {
@@ -170,44 +158,36 @@ Walkmesh::GetNumberOfTriangles() const
 }
 }
 
 
 
 
-
 void
 void
-Walkmesh::LockWalkmesh( unsigned int triangle_id, bool lock )
+Walkmesh::LockWalkmesh(unsigned int triangle_id, bool lock)
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return;
         return;
     }
     }
 
 
-    m_Triangles[ triangle_id ].locked = lock;
+    m_Triangles[triangle_id].locked = lock;
 }
 }
 
 
 
 
-
 bool
 bool
-Walkmesh::IsLocked( unsigned int triangle_id ) const
+Walkmesh::IsLocked(unsigned int triangle_id) const
 {
 {
-    if( triangle_id >= m_Triangles.size() )
+    if(triangle_id >= m_Triangles.size())
     {
     {
-        LOG_ERROR( "Triangle_id greater than number of triangles in walkmesh or less than zero." );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return false;
         return false;
     }
     }
 
 
-    return m_Triangles[ triangle_id ].locked;
+    return m_Triangles[triangle_id].locked;
 }
 }
 
 
-//------------------------------------------------------------------------------
+
 void Walkmesh::load(const QGears::WalkmeshFilePtr &walkmesh)
 void Walkmesh::load(const QGears::WalkmeshFilePtr &walkmesh)
 {
 {
-    QGears::WalkmeshFile::TriangleList &triangles( walkmesh->getTriangles() );
-    QGears::WalkmeshFile::TriangleList::const_iterator it( triangles.begin() );
-    QGears::WalkmeshFile::TriangleList::const_iterator it_end( triangles.end() );
-    while( it != it_end )
+    for(const auto &triangle : walkmesh->getTriangles())
     {
     {
-        AddTriangle( *it );
-        ++it;
+        AddTriangle(triangle);
     }
     }
 }
 }
-
-//------------------------------------------------------------------------------

+ 42 - 47
QGearsMain/src/core/XmlBackground2DFile.cpp

@@ -1,106 +1,101 @@
-#include "core/XmlBackground2DFile.h"
-
 #include "core/Background2D.h"
 #include "core/Background2D.h"
 #include "core/Background2DAnimation.h"
 #include "core/Background2DAnimation.h"
 #include "core/CameraManager.h"
 #include "core/CameraManager.h"
 #include "core/EntityManager.h"
 #include "core/EntityManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/XmlBackground2DFile.h"
 
 
 
 
-
-
-XmlBackground2DFile::XmlBackground2DFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlBackground2DFile::XmlBackground2DFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlBackground2DFile::~XmlBackground2DFile()
 XmlBackground2DFile::~XmlBackground2DFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlBackground2DFile::Load()
 XmlBackground2DFile::Load()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
     Background2D* background = EntityManager::getSingleton().GetBackground2D();
     Background2D* background = EntityManager::getSingleton().GetBackground2D();
 
 
-    if( node == NULL || node->ValueStr() != "background2d" )
+    if(node == nullptr || node->ValueStr() != "background2d")
     {
     {
-        LOG_ERROR( "XML 2D Background loader: " + m_File.ValueStr() + " is not a valid background2d file! No <background2d> in root." );
+        LOG_ERROR("XML 2D Background loader: " + m_File.ValueStr() + " is not a valid background2d file! No <background2d> in root.");
         return;
         return;
     }
     }
 
 
-    Ogre::String image = GetString( node, "image", "" );
+    Ogre::String image = GetString(node, "image", "");
 
 
-    if( image != "" )
+    if(image != "")
     {
     {
-        background->SetImage( image );
+        background->SetImage(image);
 
 
-        Ogre::Quaternion range = GetQuaternion( node, "range", Ogre::Quaternion( -100000, -100000, 100000, 100000 ) );
-        background->SetRange( ( int )range.w, ( int )range.x, ( int )range.y, ( int )range.z );
+        Ogre::Quaternion range = GetQuaternion(node, "range", Ogre::Quaternion(-100000, -100000, 100000, 100000));
+        background->SetRange((int)range.w, (int)range.x, (int)range.y, (int)range.z);
 
 
-        Ogre::Vector3 position = GetVector3( node, "position", Ogre::Vector3::ZERO );
-        Ogre::Quaternion orientation = GetQuaternion( node, "orientation", Ogre::Quaternion::IDENTITY );
-        float fov = GetFloat( node, "fov", 45 );
-        CameraManager::getSingleton().Set2DCamera( position, orientation, Ogre::Radian( Ogre::Degree( fov ) ) );
+        Ogre::Vector3 position = GetVector3(node, "position", Ogre::Vector3::ZERO);
+        Ogre::Quaternion orientation = GetQuaternion(node, "orientation", Ogre::Quaternion::IDENTITY);
+        float fov = GetFloat(node, "fov", 45);
+        CameraManager::getSingleton().Set2DCamera(position, orientation, Ogre::Radian(Ogre::Degree(fov)));
 
 
         int tile_id = 0;
         int tile_id = 0;
 
 
         node = node->FirstChild();
         node = node->FirstChild();
-        while( node != NULL )
+        while(node != nullptr)
         {
         {
-            if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "tile" )
+            if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "tile")
             {
             {
-                int width = GetInt( node, "width", 0 );
-                int height = GetInt( node, "height", 0 );
+                int width = GetInt(node, "width", 0);
+                int height = GetInt(node, "height", 0);
 
 
-                Ogre::Vector2 destination = GetVector2( node, "destination", Ogre::Vector2::ZERO );
-                Ogre::Vector4 uv = GetVector4( node, "uv", Ogre::Vector4::ZERO );
-                float depth = GetFloat( node, "depth", 0 );
-                Ogre::String blending_str = GetString( node, "blending", "alpha" );
+                Ogre::Vector2 destination = GetVector2(node, "destination", Ogre::Vector2::ZERO);
+                Ogre::Vector4 uv = GetVector4(node, "uv", Ogre::Vector4::ZERO);
+                float depth = GetFloat(node, "depth", 0);
+                Ogre::String blending_str = GetString(node, "blending", "alpha");
 
 
-                QGears::Blending blending = ( blending_str == "add" ) ? QGears::B_ADD : QGears::B_ALPHA;
+                QGears::Blending blending = (blending_str == "add") ? QGears::B_ADD : QGears::B_ALPHA;
 
 
-                Ogre::Vector4 distance = Ogre::Vector4( 0, 0, -depth, 1 );
+                Ogre::Vector4 distance = Ogre::Vector4(0, 0, -depth, 1);
                 Ogre::Vector4 res = CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth() * distance;
                 Ogre::Vector4 res = CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth() * distance;
                 res = res / res.w;
                 res = res / res.w;
-                background->AddTile( static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, res.z, uv.x, uv.y, uv.z, uv.w, blending );
+                background->AddTile(static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, res.z, uv.x, uv.y, uv.z, uv.w, blending);
 
 
                 TiXmlNode* node2 = node->FirstChild();
                 TiXmlNode* node2 = node->FirstChild();
-                while( node2 != NULL )
+                while(node2 != nullptr)
                 {
                 {
-                    if( node2->Type() == TiXmlNode::TINYXML_ELEMENT && node2->ValueStr() == "animation" )
+                    if(node2->Type() == TiXmlNode::TINYXML_ELEMENT && node2->ValueStr() == "animation")
                     {
                     {
-                        Ogre::String name = GetString( node2, "name", "" );
-                        if( name != "" )
+                        Ogre::String name = GetString(node2, "name", "");
+                        if(name != "")
                         {
                         {
-                            Background2DAnimation* animation = new Background2DAnimation( name, background, tile_id );
+                            Background2DAnimation* animation = new Background2DAnimation(name, background, tile_id);
 
 
-                            animation->SetLength( GetFloat( node2, "length", 0 ) );
+                            animation->SetLength(GetFloat(node2, "length", 0));
 
 
-                            Ogre::String uv = GetString( node2, "uv", "" );
-                            if( uv != "" )
+                            Ogre::String uv = GetString(node2, "uv", "");
+                            if(uv != "")
                             {
                             {
-                                Ogre::StringVector key_frame = Ogre::StringUtil::split( uv, "," );
-                                for( unsigned int i = 0; i < key_frame.size(); ++i )
+                                Ogre::StringVector key_frame = Ogre::StringUtil::split(uv, ",");
+                                for(unsigned int i = 0; i < key_frame.size(); ++i)
                                 {
                                 {
-                                    Ogre::StringUtil::trim( key_frame[ i ] );
+                                    Ogre::StringUtil::trim(key_frame[i]);
 
 
-                                    Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                                    if( data.size() > 1 )
+                                    Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                                    if(data.size() > 1)
                                     {
                                     {
-                                        float time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                                        Ogre::Vector4 value = Ogre::StringConverter::parseVector4( data[ 1 ] );
-                                        animation->AddUVKeyFrame( time, value.x, value.y, value.z, value.w );
+                                        float time = Ogre::StringConverter::parseReal(data[0]);
+                                        Ogre::Vector4 value = Ogre::StringConverter::parseVector4(data[1]);
+                                        animation->AddUVKeyFrame(time, value.x, value.y, value.z, value.w);
                                     }
                                     }
                                 }
                                 }
                             }
                             }
 
 
-                            background->AddAnimation( animation );
+                            background->AddAnimation(animation);
                         }
                         }
                     }
                     }
 
 

+ 60 - 74
QGearsMain/src/core/XmlFile.cpp

@@ -1,42 +1,38 @@
-#include "core/XmlFile.h"
-
 #include <OgreStringConverter.h>
 #include <OgreStringConverter.h>
 
 
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/XmlFile.h"
 
 
 
 
-
-XmlFile::XmlFile( const Ogre::String& file ):
-    m_File( file )
+XmlFile::XmlFile(const Ogre::String& file):
+    m_File(file)
 {
 {
-    m_File.SetCondenseWhiteSpace( false );
+    m_File.SetCondenseWhiteSpace(false);
     m_NormalFile = m_File.LoadFile();
     m_NormalFile = m_File.LoadFile();
 
 
-    if( m_NormalFile == false )
+    if(m_NormalFile == false)
     {
     {
-        LOG_ERROR( "Can't open " + file + ". TinyXml Error: " + m_File.ErrorDesc() );
+        LOG_ERROR("Can't open " + file + ". TinyXml Error: " + m_File.ErrorDesc());
     }
     }
 }
 }
 
 
 
 
-
 XmlFile::~XmlFile()
 XmlFile::~XmlFile()
 {
 {
 }
 }
 
 
 
 
-
 bool
 bool
-XmlFile::GetBool( TiXmlNode* node, const Ogre::String& tag, bool def ) const
+XmlFile::GetBool(TiXmlNode* node, const Ogre::String& tag, bool def) const
 {
 {
     bool ret = def;
     bool ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseBool( *string );
+            ret = Ogre::StringConverter::parseBool(*string);
         }
         }
     }
     }
 
 
@@ -44,18 +40,17 @@ XmlFile::GetBool( TiXmlNode* node, const Ogre::String& tag, bool def ) const
 }
 }
 
 
 
 
-
 int
 int
-XmlFile::GetInt( TiXmlNode* node, const Ogre::String& tag, int def ) const
+XmlFile::GetInt(TiXmlNode* node, const Ogre::String& tag, int def) const
 {
 {
     int ret = def;
     int ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseInt( *string );
+            ret = Ogre::StringConverter::parseInt(*string);
         }
         }
     }
     }
 
 
@@ -63,18 +58,17 @@ XmlFile::GetInt( TiXmlNode* node, const Ogre::String& tag, int def ) const
 }
 }
 
 
 
 
-
 float
 float
-XmlFile::GetFloat( TiXmlNode* node, const Ogre::String& tag, float def ) const
+XmlFile::GetFloat(TiXmlNode* node, const Ogre::String& tag, float def) const
 {
 {
     float ret = def;
     float ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseReal( *string );
+            ret = Ogre::StringConverter::parseReal(*string);
         }
         }
     }
     }
 
 
@@ -82,16 +76,15 @@ XmlFile::GetFloat( TiXmlNode* node, const Ogre::String& tag, float def ) const
 }
 }
 
 
 
 
-
 const Ogre::String
 const Ogre::String
-XmlFile::GetString( TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def ) const
+XmlFile::GetString(TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def) const
 {
 {
     Ogre::String ret = def;
     Ogre::String ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
             ret = *string;
             ret = *string;
         }
         }
@@ -101,18 +94,17 @@ XmlFile::GetString( TiXmlNode* node, const Ogre::String& tag, const Ogre::String
 }
 }
 
 
 
 
-
 const Ogre::UTFString
 const Ogre::UTFString
-XmlFile::GetUTFString( TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def ) const
+XmlFile::GetUTFString(TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def) const
 {
 {
     Ogre::UTFString ret = def;
     Ogre::UTFString ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = ( *string ).c_str();
+            ret = (*string).c_str();
         }
         }
     }
     }
 
 
@@ -120,18 +112,17 @@ XmlFile::GetUTFString( TiXmlNode* node, const Ogre::String& tag, const Ogre::UTF
 }
 }
 
 
 
 
-
 const Ogre::Vector2
 const Ogre::Vector2
-XmlFile::GetVector2( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def ) const
+XmlFile::GetVector2(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def) const
 {
 {
     Ogre::Vector2 ret = def;
     Ogre::Vector2 ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseVector2( *string );
+            ret = Ogre::StringConverter::parseVector2(*string);
         }
         }
     }
     }
 
 
@@ -139,18 +130,17 @@ XmlFile::GetVector2( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 }
 }
 
 
 
 
-
 const Ogre::Vector3
 const Ogre::Vector3
-XmlFile::GetVector3( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def ) const
+XmlFile::GetVector3(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def) const
 {
 {
     Ogre::Vector3 ret = def;
     Ogre::Vector3 ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseVector3( *string );
+            ret = Ogre::StringConverter::parseVector3(*string);
         }
         }
     }
     }
 
 
@@ -158,18 +148,17 @@ XmlFile::GetVector3( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 }
 }
 
 
 
 
-
 const Ogre::Vector4
 const Ogre::Vector4
-XmlFile::GetVector4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def ) const
+XmlFile::GetVector4(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def) const
 {
 {
     Ogre::Vector4 ret = def;
     Ogre::Vector4 ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseVector4( *string );
+            ret = Ogre::StringConverter::parseVector4(*string);
         }
         }
     }
     }
 
 
@@ -177,18 +166,17 @@ XmlFile::GetVector4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 }
 }
 
 
 
 
-
 const Ogre::Matrix4
 const Ogre::Matrix4
-XmlFile::GetMatrix4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def ) const
+XmlFile::GetMatrix4(TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def) const
 {
 {
     Ogre::Matrix4 ret = def;
     Ogre::Matrix4 ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseMatrix4( *string );
+            ret = Ogre::StringConverter::parseMatrix4(*string);
         }
         }
     }
     }
 
 
@@ -196,18 +184,17 @@ XmlFile::GetMatrix4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Matri
 }
 }
 
 
 
 
-
 const Ogre::Quaternion
 const Ogre::Quaternion
-XmlFile::GetQuaternion( TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def ) const
+XmlFile::GetQuaternion(TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def) const
 {
 {
     Ogre::Quaternion ret = def;
     Ogre::Quaternion ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseQuaternion( *string );
+            ret = Ogre::StringConverter::parseQuaternion(*string);
         }
         }
     }
     }
 
 
@@ -215,18 +202,17 @@ XmlFile::GetQuaternion( TiXmlNode* node, const Ogre::String& tag, const Ogre::Qu
 }
 }
 
 
 
 
-
 const Ogre::ColourValue
 const Ogre::ColourValue
-XmlFile::GetColourValue( TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def ) const
+XmlFile::GetColourValue(TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def) const
 {
 {
     Ogre::ColourValue ret = def;
     Ogre::ColourValue ret = def;
 
 
-    if( node->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if(node->Type() == TiXmlNode::TINYXML_ELEMENT)
     {
     {
-        const std::string* string = node->ToElement()->Attribute( tag );
-        if( string != NULL )
+        const std::string* string = node->ToElement()->Attribute(tag);
+        if(string != nullptr)
         {
         {
-            ret = Ogre::StringConverter::parseColourValue( *string );
+            ret = Ogre::StringConverter::parseColourValue(*string);
         }
         }
     }
     }
 
 

+ 26 - 30
QGearsMain/src/core/XmlFontFile.cpp

@@ -1,73 +1,69 @@
-#include "core/XmlFontFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/UiManager.h"
 #include "core/UiFont.h"
 #include "core/UiFont.h"
+#include "core/XmlFontFile.h"
 
 
 
 
-
-XmlFontFile::XmlFontFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlFontFile::XmlFontFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlFontFile::~XmlFontFile()
 XmlFontFile::~XmlFontFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlFontFile::LoadFont()
 XmlFontFile::LoadFont()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "font" )
+    if(node == nullptr || node->ValueStr() != "font")
     {
     {
-        LOG_ERROR( m_File.ValueStr() + " is not a valid font file! No <font> in root." );
+        LOG_ERROR(m_File.ValueStr() + " is not a valid font file! No <font> in root.");
         return;
         return;
     }
     }
 
 
-    Ogre::String name = GetString( node, "name", "" );
-    Ogre::String image = GetString( node, "image", "" );
-    Ogre::Vector2 size = GetVector2( node, "image_size", Ogre::Vector2::ZERO );
-    int height = GetInt( node, "height", 0 );
+    Ogre::String name = GetString(node, "name", "");
+    Ogre::String image = GetString(node, "image", "");
+    Ogre::Vector2 size = GetVector2(node, "image_size", Ogre::Vector2::ZERO);
+    int height = GetInt(node, "height", 0);
 
 
-    if( name != "" && image != "" && size.x != 0 && size.y != 0 )
+    if(name != "" && image != "" && size.x != 0 && size.y != 0)
     {
     {
-        UiFont* font = new UiFont( name );
-        font->SetImage( image, ( int )size.x, ( int )size.y );
-        font->SetHeight( height );
+        UiFont* font = new UiFont(name);
+        font->SetImage(image, (int)size.x, (int)size.y);
+        font->SetHeight(height);
 
 
         node = node->FirstChild();
         node = node->FirstChild();
 
 
-        while( node != NULL )
+        while(node != nullptr)
         {
         {
-            if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char" )
+            if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char")
             {
             {
                 UiCharData data;
                 UiCharData data;
 
 
-                Ogre::UTFString name = GetUTFString( node, "name", "" );
-                if( name != "" )
+                Ogre::UTFString name = GetUTFString(node, "name", "");
+                if(name != "")
                 {
                 {
-                    data.char_code = *( name.c_str() );
+                    data.char_code = *(name.c_str());
                 }
                 }
 
 
-                data.x = GetInt( node, "x", 0 );
-                data.y = GetInt( node, "y", 0 );
-                data.width = GetInt( node, "width", 0 );
-                data.height = GetInt( node, "height", 0 );
-                data.pre = GetInt( node, "pre", 0 );
-                data.post = GetInt( node, "post", 0 );
+                data.x = GetInt(node, "x", 0);
+                data.y = GetInt(node, "y", 0);
+                data.width = GetInt(node, "width", 0);
+                data.height = GetInt(node, "height", 0);
+                data.pre = GetInt(node, "pre", 0);
+                data.post = GetInt(node, "post", 0);
 
 
-                font->AddCharData( data );
+                font->AddCharData(data);
             }
             }
 
 
             node = node->NextSibling();
             node = node->NextSibling();
         }
         }
 
 
-        UiManager::getSingleton().AddFont( font );
+        UiManager::getSingleton().AddFont(font);
     }
     }
 }
 }

+ 8 - 12
QGearsMain/src/core/XmlFontsFile.cpp

@@ -1,40 +1,36 @@
-#include "core/XmlFontsFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/XmlFontFile.h"
 #include "core/XmlFontFile.h"
+#include "core/XmlFontsFile.h"
 
 
 
 
-
-XmlFontsFile::XmlFontsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlFontsFile::XmlFontsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlFontsFile::~XmlFontsFile()
 XmlFontsFile::~XmlFontsFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlFontsFile::LoadFonts()
 XmlFontsFile::LoadFonts()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "fonts" )
+    if(node == nullptr || node->ValueStr() != "fonts")
     {
     {
-        LOG_ERROR( "UI XML Manager: " + m_File.ValueStr() + " is not a valid fonts file! No <fonts> in root." );
+        LOG_ERROR("UI XML Manager: " + m_File.ValueStr() + " is not a valid fonts file! No <fonts> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "font" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "font")
         {
         {
-            XmlFontFile font( "./data/" + GetString( node, "file_name" ) );
+            XmlFontFile font("./data/" + GetString(node, "file_name"));
             font.LoadFont();
             font.LoadFont();
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();

+ 61 - 64
QGearsMain/src/core/XmlMapFile.cpp

@@ -1,133 +1,130 @@
-#include "core/XmlMapFile.h"
-
 #include "core/EntityManager.h"
 #include "core/EntityManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
 #include "core/XmlBackground2DFile.h"
 #include "core/XmlBackground2DFile.h"
+#include "core/XmlMapFile.h"
 
 
 #include "map/QGearsBackground2DFileManager.h"
 #include "map/QGearsBackground2DFileManager.h"
 #include "map/QGearsWalkmeshFileManager.h"
 #include "map/QGearsWalkmeshFileManager.h"
 
 
 
 
-XmlMapFile::XmlMapFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMapFile::XmlMapFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlMapFile::~XmlMapFile()
 XmlMapFile::~XmlMapFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlMapFile::LoadMap()
 XmlMapFile::LoadMap()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "map" )
+    if(node == nullptr || node->ValueStr() != "map")
     {
     {
-        LOG_ERROR( m_File.ValueStr() + " is not a valid fields map file! No <map> in root." );
+        LOG_ERROR(m_File.ValueStr() + " is not a valid fields map file! No <map> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "walkmesh" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "walkmesh")
         {
         {
-            Ogre::String name( GetString( node, "file_name" ) );
-            if( !name.empty() )
+            Ogre::String name(GetString(node, "file_name"));
+            if(!name.empty())
             {
             {
                 QGears::WalkmeshFileManager::getSingleton();
                 QGears::WalkmeshFileManager::getSingleton();
-                QGears::WalkmeshFilePtr walkmesh =  QGears::WalkmeshFileManager::getSingleton().load( name, "Game" ).staticCast<QGears::WalkmeshFile>();
-                EntityManager::getSingleton().GetWalkmesh()->load( walkmesh );
+                QGears::WalkmeshFilePtr walkmesh =  QGears::WalkmeshFileManager::getSingleton().load(name, "Game").staticCast<QGears::WalkmeshFile>();
+                EntityManager::getSingleton().GetWalkmesh()->load(walkmesh);
             }
             }
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "movement_rotation" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "movement_rotation")
         {
         {
-            Ogre::Degree rotation = Ogre::Degree( GetFloat( node, "degree", 0 ) );
-            EntityManager::getSingleton().SetPlayerMoveRotation( Ogre::Radian( rotation ) );
+            Ogre::Degree rotation = Ogre::Degree(GetFloat(node, "degree", 0));
+            EntityManager::getSingleton().SetPlayerMoveRotation(Ogre::Radian(rotation));
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "background2d" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "background2d")
         {
         {
-            Ogre::String name = GetString( node, "file_name" );
-            if( name != "" )
+            Ogre::String name = GetString(node, "file_name");
+            if(name != "")
             {
             {
                 // TODO migrate this code to a Resource and use it's group to load background
                 // TODO migrate this code to a Resource and use it's group to load background
-                QGears::Background2DFilePtr background =  QGears::Background2DFileManager::getSingleton().load( name, "Game" ).staticCast<QGears::Background2DFile>();
-                EntityManager::getSingleton().GetBackground2D()->load( background );
+                QGears::Background2DFilePtr background =  QGears::Background2DFileManager::getSingleton().load(name, "Game").staticCast<QGears::Background2DFile>();
+                EntityManager::getSingleton().GetBackground2D()->load(background);
             }
             }
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_model" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_model")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            if( name == "" )
+            Ogre::String name = GetString(node, "name");
+            if(name == "")
             {
             {
-                LOG_ERROR( "There is no name specified for <entity_model> tag." );
+                LOG_ERROR("There is no name specified for <entity_model> tag.");
                 continue;
                 continue;
             }
             }
-            Ogre::String file_name = GetString( node, "file_name" );
-            if( file_name == "" )
+            Ogre::String file_name = GetString(node, "file_name");
+            if(file_name == "")
             {
             {
-                LOG_ERROR( "There is no file_name specified for <entity_model> tag." );
+                LOG_ERROR("There is no file_name specified for <entity_model> tag.");
                 continue;
                 continue;
             }
             }
 
 
-            Ogre::Vector3 position( GetVector3( node, "position" ) );
-            Ogre::Degree direction( Ogre::Degree( GetFloat( node, "direction" ) ) );
-            Ogre::Vector3 scale( GetVector3( node, "scale", Ogre::Vector3::UNIT_SCALE ) );
-            Ogre::Quaternion orientation( GetQuaternion( node, "root_orientation" ) );
+            Ogre::Vector3 position(GetVector3(node, "position"));
+            Ogre::Degree direction(Ogre::Degree(GetFloat(node, "direction")));
+            Ogre::Vector3 scale(GetVector3(node, "scale", Ogre::Vector3::UNIT_SCALE));
+            Ogre::Quaternion orientation(GetQuaternion(node, "root_orientation"));
 
 
-            EntityManager::getSingleton().AddEntity( name, file_name, position, direction, scale, orientation );
+            EntityManager::getSingleton().AddEntity(name, file_name, position, direction, scale, orientation);
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_trigger" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_trigger")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            if( name == "" )
+            Ogre::String name = GetString(node, "name");
+            if(name == "")
             {
             {
-                LOG_ERROR( "There is no name specified for <entity_trigger> tag." );
+                LOG_ERROR("There is no name specified for <entity_trigger> tag.");
                 continue;
                 continue;
             }
             }
 
 
-            Ogre::Vector3 point1 = GetVector3( node, "point1", Ogre::Vector3::ZERO );
-            Ogre::Vector3 point2 = GetVector3( node, "point2", Ogre::Vector3::ZERO );
-            bool enabled = GetBool( node, "enabled", false );
+            Ogre::Vector3 point1 = GetVector3(node, "point1", Ogre::Vector3::ZERO);
+            Ogre::Vector3 point2 = GetVector3(node, "point2", Ogre::Vector3::ZERO);
+            bool enabled = GetBool(node, "enabled", false);
 
 
-            EntityManager::getSingleton().AddEntityTrigger( name, point1, point2, enabled );
+            EntityManager::getSingleton().AddEntityTrigger(name, point1, point2, enabled);
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_point" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_point")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            if( name == "" )
+            Ogre::String name = GetString(node, "name");
+            if(name == "")
             {
             {
-                LOG_ERROR( "There is no name specified for <entity_point> tag." );
+                LOG_ERROR("There is no name specified for <entity_point> tag.");
                 continue;
                 continue;
             }
             }
 
 
-            Ogre::Vector3 position = GetVector3( node, "position" );
-            float rotation = GetFloat( node, "rotation" );
-            EntityManager::getSingleton().AddEntityPoint( name, position, rotation );
+            Ogre::Vector3 position = GetVector3(node, "position");
+            float rotation = GetFloat(node, "rotation");
+            EntityManager::getSingleton().AddEntityPoint(name, position, rotation);
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_script" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_script")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            if( name == "" )
+            Ogre::String name = GetString(node, "name");
+            if(name == "")
             {
             {
-                LOG_ERROR( "There is no name specified for <entity_script> tag." );
+                LOG_ERROR("There is no name specified for <entity_script> tag.");
                 continue;
                 continue;
             }
             }
 
 
-            EntityManager::getSingleton().AddEntityScript( name );
+            EntityManager::getSingleton().AddEntityScript(name);
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "script" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "script")
         {
         {
-            Ogre::String file_name = GetString( node, "file_name" );
-            if( file_name != "" )
+            Ogre::String file_name = GetString(node, "file_name");
+            if(file_name != "")
             {
             {
-                ScriptManager::getSingleton().RunFile( file_name );
+                ScriptManager::getSingleton().RunFile(file_name);
             }
             }
         }
         }
 
 
@@ -142,22 +139,22 @@ XmlMapFile::GetWalkmeshFileName()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "map" )
+    if(node == nullptr || node->ValueStr() != "map")
     {
     {
-        LOG_ERROR( "Field Map XML Manager: " + m_File.ValueStr() + " is not a valid fields map file! No <map> in root." );
+        LOG_ERROR("Field Map XML Manager: " + m_File.ValueStr() + " is not a valid fields map file! No <map> in root.");
         return "";
         return "";
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "walkmesh" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "walkmesh")
         {
         {
-            return GetString( node, "file_name" );
+            return GetString(node, "file_name");
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();
     }
     }
 
 
-    LOG_WARNING( "Can't find field's walkmesh in " + m_File.ValueStr() + "." );
+    LOG_WARNING("Can't find field's walkmesh in " + m_File.ValueStr() + ".");
     return "";
     return "";
 }
 }

+ 17 - 22
QGearsMain/src/core/XmlMapsFile.cpp

@@ -1,69 +1,64 @@
-#include "core/XmlMapsFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/XmlMapsFile.h"
 
 
 
 
-
-XmlMapsFile::XmlMapsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMapsFile::XmlMapsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlMapsFile::~XmlMapsFile()
 XmlMapsFile::~XmlMapsFile()
 {
 {
 }
 }
 
 
 
 
-
 const Ogre::String
 const Ogre::String
-XmlMapsFile::GetMapFileNameByName( const Ogre::String& name )
+XmlMapsFile::GetMapFileNameByName(const Ogre::String& name)
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "maps" )
+    if(node == nullptr || node->ValueStr() != "maps")
     {
     {
-        LOG_ERROR( "Field XML Manager: " + m_File.ValueStr() + " is not a valid maps file! No <maps> in root." );
+        LOG_ERROR("Field XML Manager: " + m_File.ValueStr() + " is not a valid maps file! No <maps> in root.");
         return "";
         return "";
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map")
         {
         {
-            if( GetString( node, "name" ) == name )
+            if(GetString(node, "name") == name)
             {
             {
-                return GetString( node, "file_name" );
+                return GetString(node, "file_name");
             }
             }
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();
     }
     }
 
 
-    LOG_WARNING( "Can't find map \"" + name + "\" in " + m_File.ValueStr() + "." );
+    LOG_WARNING("Can't find map \"" + name + "\" in " + m_File.ValueStr() + ".");
     return "";
     return "";
 }
 }
 
 
 
 
-
 void
 void
-XmlMapsFile::GetMapNames( Ogre::StringVector& complete_params )
+XmlMapsFile::GetMapNames(Ogre::StringVector& complete_params)
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "maps" )
+    if(node == nullptr || node->ValueStr() != "maps")
     {
     {
-        LOG_ERROR( "Field XML Manager: " + m_File.ValueStr() + " is not a valid maps file! No <maps> in root." );
+        LOG_ERROR("Field XML Manager: " + m_File.ValueStr() + " is not a valid maps file! No <maps> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map")
         {
         {
-            complete_params.push_back( GetString( node, "name" ) );
+            complete_params.push_back(GetString(node, "name"));
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();
     }
     }

+ 11 - 15
QGearsMain/src/core/XmlMusicsFile.cpp

@@ -1,45 +1,41 @@
-#include "core/XmlMusicsFile.h"
-
 #include "core/AudioManager.h"
 #include "core/AudioManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
+#include "core/XmlMusicsFile.h"
 
 
 
 
-
-XmlMusicsFile::XmlMusicsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMusicsFile::XmlMusicsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlMusicsFile::~XmlMusicsFile()
 XmlMusicsFile::~XmlMusicsFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlMusicsFile::LoadMusics()
 XmlMusicsFile::LoadMusics()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "musics" )
+    if(node == nullptr || node->ValueStr() != "musics")
     {
     {
-        LOG_ERROR( m_File.ValueStr() + " is not a valid musics file! No <musics> in root." );
+        LOG_ERROR(m_File.ValueStr() + " is not a valid musics file! No <musics> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "music" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "music")
         {
         {
             AudioManager::Music music;
             AudioManager::Music music;
-            music.name = GetString( node, "name" );
-            music.file = "./data/" + GetString( node, "file_name" );
-            music.loop = GetFloat( node, "loop", -1 );
+            music.name = GetString(node, "name");
+            music.file = "./data/" + GetString(node, "file_name");
+            music.loop = GetFloat(node, "loop", -1);
 
 
-            AudioManager::getSingleton().AddMusic( music );
+            AudioManager::getSingleton().AddMusic(music);
 
 
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();

+ 9 - 13
QGearsMain/src/core/XmlPrototypesFile.cpp

@@ -1,41 +1,37 @@
-#include "core/XmlPrototypesFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/UiManager.h"
+#include "core/XmlPrototypesFile.h"
 
 
 
 
-
-XmlPrototypesFile::XmlPrototypesFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlPrototypesFile::XmlPrototypesFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlPrototypesFile::~XmlPrototypesFile()
 XmlPrototypesFile::~XmlPrototypesFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlPrototypesFile::LoadPrototypes()
 XmlPrototypesFile::LoadPrototypes()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "prototypes" )
+    if(node == nullptr || node->ValueStr() != "prototypes")
     {
     {
-        LOG_ERROR( "UI Manager: " + m_File.ValueStr() + " is not a valid prototypes file! No <prototypes> in root." );
+        LOG_ERROR("UI Manager: " + m_File.ValueStr() + " is not a valid prototypes file! No <prototypes> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            UiManager::getSingleton().AddPrototype( name, node->Clone() );
+            Ogre::String name = GetString(node, "name");
+            UiManager::getSingleton().AddPrototype(name, node->Clone());
         }
         }
 
 
         node = node->NextSibling();
         node = node->NextSibling();

+ 171 - 226
QGearsMain/src/core/XmlScreenFile.cpp

@@ -1,416 +1,362 @@
-#include "core/XmlScreenFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
 #include "core/UiManager.h"
 #include "core/UiManager.h"
 #include "core/UiSprite.h"
 #include "core/UiSprite.h"
 #include "core/UiTextArea.h"
 #include "core/UiTextArea.h"
 #include "core/UiWidget.h"
 #include "core/UiWidget.h"
+#include "core/XmlScreenFile.h"
 
 
 
 
-
-XmlScreenFile::XmlScreenFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScreenFile::XmlScreenFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlScreenFile::~XmlScreenFile()
 XmlScreenFile::~XmlScreenFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlScreenFile::LoadScreen()
 XmlScreenFile::LoadScreen()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "screen" )
+    if(node == nullptr || node->ValueStr() != "screen")
     {
     {
-        LOG_ERROR( m_File.ValueStr() + " is not a valid screen file! No <screen> in root." );
+        LOG_ERROR(m_File.ValueStr() + " is not a valid screen file! No <screen> in root.");
         return;
         return;
     }
     }
 
 
-    Ogre::String base_name = GetString( node, "name" );
-    Ogre::String script = GetString( node, "script" );
-    if( script != "" )
+    Ogre::String base_name = GetString(node, "name");
+    Ogre::String script = GetString(node, "script");
+    if(script != "")
     {
     {
-        ScriptManager::getSingleton().RunFile( script );
+        ScriptManager::getSingleton().RunFile(script);
     }
     }
 
 
-    UiWidget* widget = new UiWidget( base_name );
-    widget->SetVisible( GetBool( node, "visible", false ) );
+    UiWidget* widget = new UiWidget(base_name);
+    widget->SetVisible(GetBool(node, "visible", false));
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    if( node != NULL )
+    if(node != nullptr)
     {
     {
-        LoadScreenRecursive( node, base_name, widget );
+        LoadScreenRecursive(node, base_name, widget);
     }
     }
 
 
-    UiManager::getSingleton().AddWidget( widget );
+    UiManager::getSingleton().AddWidget(widget);
 }
 }
 
 
 
 
-
 void
 void
-XmlScreenFile::LoadScreenRecursive( TiXmlNode* node, const Ogre::String& base_name, UiWidget* widget )
+XmlScreenFile::LoadScreenRecursive(TiXmlNode* node, const Ogre::String& base_name, UiWidget* widget)
 {
 {
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
         // parse widgets
         // parse widgets
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && ( node->ValueStr() == "widget" || node->ValueStr() == "sprite" || node->ValueStr() == "text_area" || node->ValueStr() == "prototype" ) )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && (node->ValueStr() == "widget" || node->ValueStr() == "sprite" || node->ValueStr() == "text_area" || node->ValueStr() == "prototype"))
         {
         {
-            if( node->ValueStr() == "prototype" )
+            if(node->ValueStr() == "prototype")
             {
             {
-                Ogre::String name = GetString( node, "name" );
-                if( name != "" )
+                Ogre::String name = GetString(node, "name");
+                if(name != "")
                 {
                 {
-                    TiXmlNode* node2 = UiManager::getSingleton().GetPrototype( name );
-                    if( node != NULL )
+                    TiXmlNode* node2 = UiManager::getSingleton().GetPrototype(name);
+                    if(node != nullptr)
                     {
                     {
                         node2 = node2->FirstChild();
                         node2 = node2->FirstChild();
-                        if( node2 != NULL )
+                        if(node2 != nullptr)
                         {
                         {
-                            LoadScreenRecursive( node2, base_name, widget );
+                            LoadScreenRecursive(node2, base_name, widget);
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
             else
             else
             {
             {
-                Ogre::String name = GetString( node, "name" );
-                if( name != "" )
+                Ogre::String name = GetString(node, "name");
+                if(name != "")
                 {
                 {
                     UiWidget* widget2;
                     UiWidget* widget2;
 
 
-                    if( node->ValueStr() == "sprite" )
+                    if(node->ValueStr() == "sprite")
                     {
                     {
-                        widget2 = new UiSprite( name, base_name + "." + name, widget );
+                        widget2 = new UiSprite(name, base_name + "." + name, widget);
                     }
                     }
-                    else if( node->ValueStr() == "text_area" )
+                    else if(node->ValueStr() == "text_area")
                     {
                     {
-                        widget2 = new UiTextArea( name, base_name + "." + name, widget );
+                        widget2 = new UiTextArea(name, base_name + "." + name, widget);
                     }
                     }
                     else
                     else
                     {
                     {
-                        widget2 = new UiWidget( name, base_name + "." + name, widget );
+                        widget2 = new UiWidget(name, base_name + "." + name, widget);
                     }
                     }
 
 
-                    if( node->ValueStr() == "sprite" )
+                    if(node->ValueStr() == "sprite")
                     {
                     {
-                        Ogre::String image = GetString( node, "image" );
-                        if( image != "" )
+                        Ogre::String image = GetString(node, "image");
+                        if(image != "")
                         {
                         {
-                            ( ( UiSprite* )widget2 )->SetImage( image );
+                            ((UiSprite*)widget2)->SetImage(image);
                         }
                         }
 
 
-                        Ogre::String vertex_shader = GetString( node, "vertex_shader" );
-                        if( vertex_shader != "" )
+                        Ogre::String vertex_shader = GetString(node, "vertex_shader");
+                        if(vertex_shader != "")
                         {
                         {
-                            ( ( UiSprite* )widget2 )->SetVertexShader( vertex_shader );
+                            ((UiSprite*)widget2)->SetVertexShader(vertex_shader);
                         }
                         }
 
 
-                        Ogre::String fragment_shader = GetString( node, "fragment_shader" );
-                        if( fragment_shader != "" )
+                        Ogre::String fragment_shader = GetString(node, "fragment_shader");
+                        if(fragment_shader != "")
                         {
                         {
-                            ( ( UiSprite* )widget2 )->SetFragmentShader( fragment_shader );
+                            ((UiSprite*)widget2)->SetFragmentShader(fragment_shader);
                         }
                         }
                     }
                     }
 
 
-
-
-                    if( node->ValueStr() == "text_area" )
+                    if(node->ValueStr() == "text_area")
                     {
                     {
-                        Ogre::String text = GetString( node, "text_name", "" );
-                        if( text != "" )
+                        Ogre::String text = GetString(node, "text_name", "");
+                        if(text != "")
                         {
                         {
-                            TiXmlNode* utf = UiManager::getSingleton().GetText( text );
-                            ( ( UiTextArea* )widget2 )->SetText( utf );
+                            TiXmlNode* utf = UiManager::getSingleton().GetText(text);
+                            ((UiTextArea*)widget2)->SetText(utf);
                         }
                         }
 
 
-                        Ogre::String font = GetString( node, "font", "" );
-                        if( font != "" )
+                        Ogre::String font = GetString(node, "font", "");
+                        if(font != "")
                         {
                         {
-                            ( ( UiTextArea* )widget2 )->SetFont( font );
+                            ((UiTextArea*)widget2)->SetFont(font);
                         }
                         }
 
 
-                        Ogre::String align = GetString( node, "text_align", "" );
-                        if( align != "" )
+                        Ogre::String align = GetString(node, "text_align", "");
+                        if(align != "")
                         {
                         {
-                            ( ( UiTextArea* )widget2 )->SetTextAlign( ( align == "center" ) ? UiTextArea::CENTER : ( ( align == "right" ) ? UiTextArea::RIGHT : UiTextArea::LEFT ) );
+                            ((UiTextArea*)widget2)->SetTextAlign((align == "center") ? UiTextArea::CENTER : ((align == "right") ? UiTextArea::RIGHT : UiTextArea::LEFT));
                         }
                         }
                     }
                     }
 
 
-
-
-                    Ogre::String colours = GetString( node, "colours", "" );
-                    if( colours != "" )
+                    Ogre::String colours = GetString(node, "colours", "");
+                    if(colours != "")
                     {
                     {
-                        Ogre::StringVector colour_string = Ogre::StringUtil::split( colours, "," );
-                        Ogre::Vector3 colour[ 4 ];
-                        for( unsigned int i = 0; i < 4; ++i )
+                        Ogre::StringVector colour_string = Ogre::StringUtil::split(colours, ",");
+                        Ogre::Vector3 colour[4];
+                        for(unsigned int i = 0; i < 4; ++i)
                         {
                         {
-                            Ogre::StringUtil::trim( colour_string[ i ] );
-                            colour[ i ] = ( i < colour_string.size() ) ? Ogre::StringConverter::parseVector3( colour_string[ i ] ) : Ogre::Vector3( 1, 1, 1 );
+                            Ogre::StringUtil::trim(colour_string[i]);
+                            colour[i] = (i < colour_string.size()) ? Ogre::StringConverter::parseVector3(colour_string[i]) : Ogre::Vector3(1, 1, 1);
                         }
                         }
-                        widget2->SetColours( colour[ 0 ].x, colour[ 0 ].y, colour[ 0 ].z, colour[ 1 ].x, colour[ 1 ].y, colour[ 1 ].z, colour[ 2 ].x, colour[ 2 ].y, colour[ 2 ].z, colour[ 3 ].x, colour[ 3 ].y, colour[ 3 ].z );
+                        widget2->SetColours(colour[0].x, colour[0].y, colour[0].z, colour[1].x, colour[1].y, colour[1].z, colour[2].x, colour[2].y, colour[2].z, colour[3].x, colour[3].y, colour[3].z);
                     }
                     }
                     else
                     else
                     {
                     {
-                        Ogre::Vector3 colour = GetVector3( node, "colour", Ogre::Vector3( 1, 1, 1 ) );
-                        widget2->SetColour( colour.x, colour.y, colour.z );
+                        Ogre::Vector3 colour = GetVector3(node, "colour", Ogre::Vector3(1, 1, 1));
+                        widget2->SetColour(colour.x, colour.y, colour.z);
                     }
                     }
 
 
+                    float alpha = GetFloat(node, "alpha", 1);
+                    widget2->SetAlpha(alpha);
 
 
-
-                    float alpha = GetFloat( node, "alpha", 1 );
-                    widget2->SetAlpha( alpha );
-
-
-
-
-                    Ogre::String align = GetString( node, "align" );
-                    if( align != "" )
+                    Ogre::String align = GetString(node, "align");
+                    if(align != "")
                     {
                     {
-                        widget2->SetAlign( ( align == "center" ) ? UiWidget::CENTER : ( ( align == "right" ) ? UiWidget::RIGHT : UiWidget::LEFT ) );
+                        widget2->SetAlign((align == "center") ? UiWidget::CENTER : ((align == "right") ? UiWidget::RIGHT : UiWidget::LEFT));
                     }
                     }
 
 
-
-
-                    Ogre::String valign = GetString( node, "valign" );
-                    if( valign != "" )
+                    Ogre::String valign = GetString(node, "valign");
+                    if(valign != "")
                     {
                     {
-                        widget2->SetVerticalAlign( ( valign == "middle" ) ? UiWidget::MIDDLE : ( ( valign == "bottom" ) ? UiWidget::BOTTOM : UiWidget::TOP ) );
+                        widget2->SetVerticalAlign((valign == "middle") ? UiWidget::MIDDLE : ((valign == "bottom") ? UiWidget::BOTTOM : UiWidget::TOP));
                     }
                     }
 
 
-
-
-                    Ogre::String origin_x_str = GetString( node, "origin_x" );
-                    if( origin_x_str != "" )
+                    Ogre::String origin_x_str = GetString(node, "origin_x");
+                    if(origin_x_str != "")
                     {
                     {
                         float x_percent = 0;
                         float x_percent = 0;
                         float x = 0;
                         float x = 0;
-                        ParsePersent( x_percent, x, origin_x_str );
-                        widget2->SetOriginX( x_percent, x );
+                        ParsePersent(x_percent, x, origin_x_str);
+                        widget2->SetOriginX(x_percent, x);
                     }
                     }
 
 
-
-
-                    Ogre::String origin_y_str = GetString( node, "origin_y" );
-                    if( origin_y_str != "" )
+                    Ogre::String origin_y_str = GetString(node, "origin_y");
+                    if(origin_y_str != "")
                     {
                     {
                         float y_percent = 0;
                         float y_percent = 0;
                         float y = 0;
                         float y = 0;
-                        ParsePersent( y_percent, y, origin_y_str );
-                        widget2->SetOriginY( y_percent, y );
+                        ParsePersent(y_percent, y, origin_y_str);
+                        widget2->SetOriginY(y_percent, y);
                     }
                     }
 
 
-
-
-                    Ogre::String x_str = GetString( node, "x" );
-                    if( x_str != "" )
+                    Ogre::String x_str = GetString(node, "x");
+                    if(x_str != "")
                     {
                     {
                         float x_percent = 0;
                         float x_percent = 0;
                         float x = 0;
                         float x = 0;
-                        ParsePersent( x_percent, x, x_str );
-                        widget2->SetX( x_percent, x );
+                        ParsePersent(x_percent, x, x_str);
+                        widget2->SetX(x_percent, x);
                     }
                     }
 
 
-
-
-                    Ogre::String y_str = GetString( node, "y" );
-                    if( y_str != "" )
+                    Ogre::String y_str = GetString(node, "y");
+                    if(y_str != "")
                     {
                     {
                         float y_percent = 0;
                         float y_percent = 0;
                         float y = 0;
                         float y = 0;
-                        ParsePersent( y_percent, y, y_str );
-                        widget2->SetY( y_percent, y );
+                        ParsePersent(y_percent, y, y_str);
+                        widget2->SetY(y_percent, y);
                     }
                     }
 
 
-
-
-                    Ogre::String width_str = GetString( node, "width" );
-                    if( width_str != "" )
+                    Ogre::String width_str = GetString(node, "width");
+                    if(width_str != "")
                     {
                     {
                         float width_percent = 0;
                         float width_percent = 0;
                         float width = 0;
                         float width = 0;
-                        ParsePersent( width_percent, width, width_str );
-                        widget2->SetWidth( width_percent, width );
+                        ParsePersent(width_percent, width, width_str);
+                        widget2->SetWidth(width_percent, width);
                     }
                     }
 
 
-
-
-                    Ogre::String height_str  = GetString( node, "height" );
-                    if( height_str != "" )
+                    Ogre::String height_str  = GetString(node, "height");
+                    if(height_str != "")
                     {
                     {
                         float height_percent = 0;
                         float height_percent = 0;
                         float height = 0;
                         float height = 0;
-                        ParsePersent( height_percent, height, height_str );
-                        widget2->SetHeight( height_percent, height );
+                        ParsePersent(height_percent, height, height_str);
+                        widget2->SetHeight(height_percent, height);
                     }
                     }
 
 
+                    Ogre::Vector2 scale = GetVector2(node, "scale", Ogre::Vector2(1.0f, 1.0f));
+                    widget2->SetScale(scale);
+                    widget2->SetRotation(GetFloat(node, "rotation", 0.0f));
+                    widget2->SetScissor(GetBool(node, "scissor", false));
+                    widget2->SetVisible(GetBool(node, "visible", false));
 
 
-
-                    Ogre::Vector2 scale = GetVector2( node, "scale", Ogre::Vector2( 1.0f, 1.0f ) );
-                    widget2->SetScale( scale );
-
-
-
-                    widget2->SetRotation( GetFloat( node, "rotation", 0.0f ) );
-
-
-
-                    widget2->SetScissor( GetBool( node, "scissor", false ) );
-
-
-
-                    widget2->SetVisible( GetBool( node, "visible", false ) );
-
-
-
-                    if( node->ValueStr() == "sprite" )
+                    if(node->ValueStr() == "sprite")
                     {
                     {
-                        ( ( UiSprite* )widget2 )->UpdateGeometry();
+                        ((UiSprite*)widget2)->UpdateGeometry();
                     }
                     }
-                    else if( node->ValueStr() == "text_area" )
+                    else if(node->ValueStr() == "text_area")
                     {
                     {
-                        ( ( UiTextArea* )widget2 )->UpdateGeometry();
+                        ((UiTextArea*)widget2)->UpdateGeometry();
                     }
                     }
 
 
-
-
-                    widget->AddChild( widget2 );
+                    widget->AddChild(widget2);
 
 
                     TiXmlNode* node2 = node->FirstChild();
                     TiXmlNode* node2 = node->FirstChild();
-                    if( node2 != NULL )
+                    if(node2 != nullptr)
                     {
                     {
-                        LoadScreenRecursive( node2, base_name + "." + name, widget2 );
+                        LoadScreenRecursive(node2, base_name + "." + name, widget2);
                     }
                     }
                 }
                 }
                 else
                 else
                 {
                 {
-                    LOG_ERROR( "There is no name in entity with base name " + base_name );
+                    LOG_ERROR("There is no name in entity with base name " + base_name);
                 }
                 }
             }
             }
         }
         }
         // parse animation data for widget
         // parse animation data for widget
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "animation" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "animation")
         {
         {
-            Ogre::String name = GetString( node, "name", "" );
-            if( name != "" )
+            Ogre::String name = GetString(node, "name", "");
+            if(name != "")
             {
             {
-                UiAnimation* animation = new UiAnimation( name, widget );
+                UiAnimation* animation = new UiAnimation(name, widget);
 
 
-                animation->SetLength( GetFloat( node, "length", 0 ) );
+                animation->SetLength(GetFloat(node, "length", 0));
 
 
-                Ogre::String scale = GetString( node, "scale", "" );
-                if( scale != "" )
+                Ogre::String scale = GetString(node, "scale", "");
+                if(scale != "")
                 {
                 {
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split( scale, "," );
-                    for( unsigned int i = 0; i < key_frame.size(); ++i )
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(scale, ",");
+                    for(unsigned int i = 0; i < key_frame.size(); ++i)
                     {
                     {
-                        Ogre::StringUtil::trim( key_frame[ i ] );
+                        Ogre::StringUtil::trim(key_frame[i]);
 
 
-                        Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                        if( data.size() > 1 )
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                        if(data.size() > 1)
                         {
                         {
                             UiKeyFrameVector2 key;
                             UiKeyFrameVector2 key;
-                            key.time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                            key.value = Ogre::StringConverter::parseVector2( data[ 1 ] );
-                            animation->AddScaleKeyFrame( key );
+                            key.time = Ogre::StringConverter::parseReal(data[0]);
+                            key.value = Ogre::StringConverter::parseVector2(data[1]);
+                            animation->AddScaleKeyFrame(key);
                         }
                         }
                     }
                     }
                 }
                 }
 
 
-
-
-                Ogre::String x = GetString( node, "x", "" );
-                if( x != "" )
+                Ogre::String x = GetString(node, "x", "");
+                if(x != "")
                 {
                 {
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split( x, "," );
-                    for( unsigned int i = 0; i < key_frame.size(); ++i )
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(x, ",");
+                    for(unsigned int i = 0; i < key_frame.size(); ++i)
                     {
                     {
-                        Ogre::StringUtil::trim( key_frame[ i ] );
+                        Ogre::StringUtil::trim(key_frame[i]);
 
 
-                        Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                        if( data.size() > 1 )
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                        if(data.size() > 1)
                         {
                         {
                             UiKeyFrameVector2 key;
                             UiKeyFrameVector2 key;
-                            key.time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                            key.value = Ogre::StringConverter::parseVector2( data[ 1 ] );
-                            animation->AddXKeyFrame( key );
+                            key.time = Ogre::StringConverter::parseReal(data[0]);
+                            key.value = Ogre::StringConverter::parseVector2(data[1]);
+                            animation->AddXKeyFrame(key);
                         }
                         }
                     }
                     }
                 }
                 }
 
 
-
-
-                Ogre::String y = GetString( node, "y", "" );
-                if( y != "" )
+                Ogre::String y = GetString(node, "y", "");
+                if(y != "")
                 {
                 {
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split( y, "," );
-                    for( unsigned int i = 0; i < key_frame.size(); ++i )
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(y, ",");
+                    for(unsigned int i = 0; i < key_frame.size(); ++i)
                     {
                     {
-                        Ogre::StringUtil::trim( key_frame[ i ] );
+                        Ogre::StringUtil::trim(key_frame[i]);
 
 
-                        Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                        if( data.size() > 1 )
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                        if(data.size() > 1)
                         {
                         {
                             UiKeyFrameVector2 key;
                             UiKeyFrameVector2 key;
-                            key.time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                            key.value = Ogre::StringConverter::parseVector2( data[ 1 ] );
-                            animation->AddYKeyFrame( key );
+                            key.time = Ogre::StringConverter::parseReal(data[0]);
+                            key.value = Ogre::StringConverter::parseVector2(data[1]);
+                            animation->AddYKeyFrame(key);
                         }
                         }
                     }
                     }
                 }
                 }
 
 
-
-
-                Ogre::String rotation = GetString( node, "rotation", "" );
-                if( rotation != "" )
+                Ogre::String rotation = GetString(node, "rotation", "");
+                if(rotation != "")
                 {
                 {
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split( rotation, "," );
-                    for( unsigned int i = 0; i < key_frame.size(); ++i )
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(rotation, ",");
+                    for(unsigned int i = 0; i < key_frame.size(); ++i)
                     {
                     {
-                        Ogre::StringUtil::trim( key_frame[ i ] );
+                        Ogre::StringUtil::trim(key_frame[i]);
 
 
-                        Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                        if( data.size() > 1 )
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                        if(data.size() > 1)
                         {
                         {
                             UiKeyFrameFloat key;
                             UiKeyFrameFloat key;
-                            key.time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                            key.value = Ogre::StringConverter::parseReal( data[ 1 ] );
-                            animation->AddRotationKeyFrame( key );
+                            key.time = Ogre::StringConverter::parseReal(data[0]);
+                            key.value = Ogre::StringConverter::parseReal(data[1]);
+                            animation->AddRotationKeyFrame(key);
                         }
                         }
                     }
                     }
                 }
                 }
 
 
-
-
-                Ogre::String alpha = GetString( node, "alpha", "" );
-                if( alpha != "" )
+                Ogre::String alpha = GetString(node, "alpha", "");
+                if(alpha != "")
                 {
                 {
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split( alpha, "," );
-                    for( unsigned int i = 0; i < key_frame.size(); ++i )
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(alpha, ",");
+                    for(unsigned int i = 0; i < key_frame.size(); ++i)
                     {
                     {
-                        Ogre::StringUtil::trim( key_frame[ i ] );
+                        Ogre::StringUtil::trim(key_frame[i]);
 
 
-                        Ogre::StringVector data = Ogre::StringUtil::split( key_frame[ i ], ":" );
-                        if( data.size() > 1 )
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
+                        if(data.size() > 1)
                         {
                         {
                             UiKeyFrameFloat key;
                             UiKeyFrameFloat key;
-                            key.time = Ogre::StringConverter::parseReal( data[ 0 ] );
-                            key.value = Ogre::StringConverter::parseReal( data[ 1 ] );
-                            animation->AddAlphaKeyFrame( key );
+                            key.time = Ogre::StringConverter::parseReal(data[0]);
+                            key.value = Ogre::StringConverter::parseReal(data[1]);
+                            animation->AddAlphaKeyFrame(key);
                         }
                         }
                     }
                     }
                 }
                 }
-
-
-
-                widget->AddAnimation( animation );
+                widget->AddAnimation(animation);
             }
             }
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();
@@ -418,27 +364,26 @@ XmlScreenFile::LoadScreenRecursive( TiXmlNode* node, const Ogre::String& base_na
 }
 }
 
 
 
 
-
 void
 void
-XmlScreenFile::ParsePersent( float& value_percent, float& value, const Ogre::String& string )
+XmlScreenFile::ParsePersent(float& value_percent, float& value, const Ogre::String& string)
 {
 {
-    if( string.at( string.size() - 1 ) == '%' )
+    if(string.at(string.size() - 1) == '%')
     {
     {
-        value_percent = Ogre::StringConverter::parseReal( string.substr( 0, string.size() - 1 ) );
+        value_percent = Ogre::StringConverter::parseReal(string.substr(0, string.size() - 1));
         value = 0;
         value = 0;
     }
     }
     else
     else
     {
     {
-        Ogre::StringVector param = Ogre::StringUtil::split( string, "%" );
-        if( param.size() > 1 )
+        Ogre::StringVector param = Ogre::StringUtil::split(string, "%");
+        if(param.size() > 1)
         {
         {
-            value_percent = Ogre::StringConverter::parseReal( param[ 0 ] );
-            value = Ogre::StringConverter::parseReal( param[ 1 ] );
+            value_percent = Ogre::StringConverter::parseReal(param[0]);
+            value = Ogre::StringConverter::parseReal(param[1]);
         }
         }
         else
         else
         {
         {
             value_percent = 0;
             value_percent = 0;
-            value = Ogre::StringConverter::parseReal( string );
+            value = Ogre::StringConverter::parseReal(string);
         }
         }
     }
     }
 }
 }

+ 8 - 12
QGearsMain/src/core/XmlScreensFile.cpp

@@ -1,40 +1,36 @@
-#include "core/XmlScreensFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/XmlScreenFile.h"
 #include "core/XmlScreenFile.h"
+#include "core/XmlScreensFile.h"
 
 
 
 
-
-XmlScreensFile::XmlScreensFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScreensFile::XmlScreensFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlScreensFile::~XmlScreensFile()
 XmlScreensFile::~XmlScreensFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlScreensFile::LoadScreens()
 XmlScreensFile::LoadScreens()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "screens" )
+    if(node == nullptr || node->ValueStr() != "screens")
     {
     {
-        LOG_ERROR( "UI XML Manager: " + m_File.ValueStr() + " is not a valid screens file! No <screens> in root." );
+        LOG_ERROR("UI XML Manager: " + m_File.ValueStr() + " is not a valid screens file! No <screens> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "screen" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "screen")
         {
         {
-            XmlScreenFile screen( "./data/" + GetString( node, "file_name" ) );
+            XmlScreenFile screen("./data/" + GetString(node, "file_name"));
             screen.LoadScreen();
             screen.LoadScreen();
         }
         }
         node = node->NextSibling();
         node = node->NextSibling();

+ 13 - 17
QGearsMain/src/core/XmlScriptsFile.cpp

@@ -1,52 +1,48 @@
-#include "core/XmlScriptsFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
+#include "core/XmlScriptsFile.h"
 
 
 
 
-
-XmlScriptsFile::XmlScriptsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScriptsFile::XmlScriptsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlScriptsFile::~XmlScriptsFile()
 XmlScriptsFile::~XmlScriptsFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlScriptsFile::LoadScripts()
 XmlScriptsFile::LoadScripts()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "scripts" )
+    if(node == nullptr || node->ValueStr() != "scripts")
     {
     {
-        LOG_ERROR( m_File.ValueStr() + " is not a valid scripts file! No <scripts> in root." );
+        LOG_ERROR(m_File.ValueStr() + " is not a valid scripts file! No <scripts> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
     ScriptManager &script_manager(ScriptManager::getSingleton());
     ScriptManager &script_manager(ScriptManager::getSingleton());
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "script" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "script")
         {
         {
-            script_manager.RunFile( GetString( node, "file" ) );
+            script_manager.RunFile(GetString(node, "file"));
         }
         }
-        else if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "system_script" )
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "system_script")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            if( name == "" )
+            Ogre::String name = GetString(node, "name");
+            if(name == "")
             {
             {
-                LOG_ERROR( "There is no name specified for <system_script> tag." );
+                LOG_ERROR("There is no name specified for <system_script> tag.");
                 continue;
                 continue;
             }
             }
 
 
-            script_manager.AddEntity( ScriptManager::SYSTEM, name, NULL );
+            script_manager.AddEntity(ScriptManager::SYSTEM, name, nullptr);
         }
         }
 
 
         node = node->NextSibling();
         node = node->NextSibling();

+ 9 - 13
QGearsMain/src/core/XmlTextFile.cpp

@@ -1,41 +1,37 @@
-#include "core/XmlTextFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/UiManager.h"
+#include "core/XmlTextFile.h"
 
 
 
 
-
-XmlTextFile::XmlTextFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlTextFile::XmlTextFile(const Ogre::String& file):
+    XmlFile(file)
 {
 {
 }
 }
 
 
 
 
-
 XmlTextFile::~XmlTextFile()
 XmlTextFile::~XmlTextFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
 XmlTextFile::LoadText()
 XmlTextFile::LoadText()
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "texts" )
+    if(node == nullptr || node->ValueStr() != "texts")
     {
     {
-        LOG_ERROR( "UI Manager: " + m_File.ValueStr() + " is not a valid text file! No <texts> in root." );
+        LOG_ERROR("UI Manager: " + m_File.ValueStr() + " is not a valid text file! No <texts> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "text" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "text")
         {
         {
-            Ogre::String name = GetString( node, "name" );
-            UiManager::getSingleton().AddText( name, node->Clone() );
+            Ogre::String name = GetString(node, "name");
+            UiManager::getSingleton().AddText(name, node->Clone());
         }
         }
 
 
         node = node->NextSibling();
         node = node->NextSibling();

+ 15 - 19
QGearsMain/src/core/XmlTextsFile.cpp

@@ -1,55 +1,51 @@
-#include "core/XmlTextsFile.h"
-
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/XmlTextFile.h"
 #include "core/XmlTextFile.h"
+#include "core/XmlTextsFile.h"
 
 
 
 
-
-XmlTextsFile::XmlTextsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlTextsFile::XmlTextsFile( const Ogre::String& file):
+    XmlFile( file)
 {
 {
 }
 }
 
 
 
 
-
 XmlTextsFile::~XmlTextsFile()
 XmlTextsFile::~XmlTextsFile()
 {
 {
 }
 }
 
 
 
 
-
 void
 void
-XmlTextsFile::LoadTexts( const Ogre::String& language )
+XmlTextsFile::LoadTexts( const Ogre::String& language)
 {
 {
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
 
 
-    if( node == NULL || node->ValueStr() != "texts" )
+    if( node == nullptr || node->ValueStr() != "texts")
     {
     {
-        LOG_ERROR( "UI Text Manager: " + m_File.ValueStr() + " is not a valid texts file! No <texts> in root." );
+        LOG_ERROR( "UI Text Manager: " + m_File.ValueStr() + " is not a valid texts file! No <texts> in root.");
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while( node != nullptr)
     {
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "language" )
+        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "language")
         {
         {
-            if( GetString( node, "name" ) == language )
+            if( GetString( node, "name") == language)
             {
             {
                 TiXmlNode* node2 = node->FirstChild();
                 TiXmlNode* node2 = node->FirstChild();
-                while( node2 != NULL )
+                while( node2 != nullptr)
                 {
                 {
-                    if( node2->Type() == TiXmlNode::TINYXML_ELEMENT && node2->ValueStr() == "text" )
+                    if( node2->Type() == TiXmlNode::TINYXML_ELEMENT && node2->ValueStr() == "text")
                     {
                     {
-                        Ogre::String file = GetString( node2, "file" );
-                        if( file != "" )
+                        Ogre::String file = GetString( node2, "file");
+                        if( file != "")
                         {
                         {
-                            XmlTextFile text( "./data/" + file );
+                            XmlTextFile text( "./data/" + file);
                             text.LoadText();
                             text.LoadText();
                         }
                         }
                         else
                         else
                         {
                         {
-                            LOG_ERROR( "Empty filename in language " + language + "." );
+                            LOG_ERROR( "Empty filename in language " + language + ".");
                         }
                         }
                     }
                     }
                     node2 = node2->NextSibling();
                     node2 = node2->NextSibling();

+ 2 - 2
QGearsMain/src/core/XmlWalkmeshFile.cpp

@@ -25,14 +25,14 @@ XmlWalkmeshFile::Load()
     TiXmlNode* node = m_File.RootElement();
     TiXmlNode* node = m_File.RootElement();
     Walkmesh* walkmesh = EntityManager::getSingleton().GetWalkmesh();
     Walkmesh* walkmesh = EntityManager::getSingleton().GetWalkmesh();
 
 
-    if( node == NULL || node->ValueStr() != "walkmesh" )
+    if( node == nullptr || node->ValueStr() != "walkmesh" )
     {
     {
         LOG_ERROR( "Field XML Manager: " + m_File.ValueStr() + " is not a valid walkmesh file! No <walkmesh> in root." );
         LOG_ERROR( "Field XML Manager: " + m_File.ValueStr() + " is not a valid walkmesh file! No <walkmesh> in root." );
         return;
         return;
     }
     }
 
 
     node = node->FirstChild();
     node = node->FirstChild();
-    while( node != NULL )
+    while( node != nullptr )
     {
     {
         if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "triangle" )
         if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "triangle" )
         {
         {

+ 2 - 2
QGearsMain/src/core/particles/Particle.cpp

@@ -3,12 +3,12 @@
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 Particle::Particle():
 Particle::Particle():
-    m_ParentEmitter(NULL),
+    m_ParentEmitter(nullptr),
     m_ParticleType(PT_VISUAL),
     m_ParticleType(PT_VISUAL),
     m_Enabled(true),
     m_Enabled(true),
     m_Emittable(false),
     m_Emittable(false),
 
 
-    additional_data(NULL),
+    additional_data(nullptr),
     position(Ogre::Vector3::ZERO),
     position(Ogre::Vector3::ZERO),
     direction(Ogre::Vector3::ZERO),
     direction(Ogre::Vector3::ZERO),
     time_to_live(10),
     time_to_live(10),

+ 1 - 1
QGearsMain/src/core/particles/ParticleEmitter.cpp

@@ -14,7 +14,7 @@ ParticleEmitterDictionary::Direction        ParticleEmitter::m_DirectionDictiona
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 ParticleEmitter::ParticleEmitter(void) :
 ParticleEmitter::ParticleEmitter(void) :
     Particle(),
     Particle(),
-    m_ParentTechnique(NULL),
+    m_ParentTechnique(nullptr),
     m_Name(Ogre::StringUtil::BLANK),
     m_Name(Ogre::StringUtil::BLANK),
     m_EmitsName(Ogre::StringUtil::BLANK),
     m_EmitsName(Ogre::StringUtil::BLANK),
     m_EmitsType(PT_VISUAL),
     m_EmitsType(PT_VISUAL),

+ 1 - 1
QGearsMain/src/core/particles/ParticleEmitterTranslator.cpp

@@ -20,7 +20,7 @@ ParticleEmitterTranslator::translate(Ogre::ScriptCompiler *compiler, const Ogre:
     ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(obj->parent->context);
     ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(obj->parent->context);
 
 
     ParticleEmitter* emitter = tech->CreateEmitter(obj->name);
     ParticleEmitter* emitter = tech->CreateEmitter(obj->name);
-    if (emitter == NULL)
+    if (emitter == nullptr)
     {
     {
         compiler->addError(Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line);
         compiler->addError(Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line);
         return;
         return;

+ 1 - 1
QGearsMain/src/core/particles/ParticleRenderer.cpp

@@ -2,7 +2,7 @@
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 ParticleRenderer::ParticleRenderer():
 ParticleRenderer::ParticleRenderer():
-    m_ParentTechnique(NULL),
+    m_ParentTechnique(nullptr),
     m_RendererInitialised(false)
     m_RendererInitialised(false)
 {
 {
 }
 }

+ 1 - 1
QGearsMain/src/core/particles/ParticleRendererTranslator.cpp

@@ -20,7 +20,7 @@ ParticleRendererTranslator::translate(Ogre::ScriptCompiler *compiler, const Ogre
     ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(obj->parent->context);
     ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(obj->parent->context);
 
 
     ParticleRenderer* rend = tech->CreateRenderer(obj->name);
     ParticleRenderer* rend = tech->CreateRenderer(obj->name);
-    if (rend == NULL)
+    if (rend == nullptr)
     {
     {
         compiler->addError(Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line);
         compiler->addError(Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line);
         return;
         return;

+ 1 - 1
QGearsMain/src/core/particles/ParticleSystem.cpp

@@ -31,7 +31,7 @@ ParticleSystem::CopyAttributesTo( ParticleSystem* ps )
     ps->DestroyAllTechniques();
     ps->DestroyAllTechniques();
 
 
     // Copy techniques
     // Copy techniques
-    ParticleTechnique* cloned_technique = NULL;
+    ParticleTechnique* cloned_technique = nullptr;
     for( unsigned int i = 0; i < m_Techniques.size(); ++i )
     for( unsigned int i = 0; i < m_Techniques.size(); ++i )
     {
     {
         cloned_technique = ParticleSystemManager::getSingletonPtr()->CloneTechnique( m_Techniques[ i ] );
         cloned_technique = ParticleSystemManager::getSingletonPtr()->CloneTechnique( m_Techniques[ i ] );

+ 6 - 6
QGearsMain/src/core/particles/ParticleSystemManager.cpp

@@ -8,7 +8,7 @@
 #include "core/particles/renderer/ParticleEntityRendererFactory.h"
 #include "core/particles/renderer/ParticleEntityRendererFactory.h"
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
-template<> ParticleSystemManager* Ogre::Singleton<ParticleSystemManager>::msSingleton = NULL;
+template<> ParticleSystemManager* Ogre::Singleton<ParticleSystemManager>::msSingleton = nullptr;
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 ParticleSystemManager::ParticleSystemManager()
 ParticleSystemManager::ParticleSystemManager()
@@ -135,9 +135,9 @@ ParticleSystemManager::CreateTechnique()
 ParticleTechnique*
 ParticleTechnique*
 ParticleSystemManager::CloneTechnique(ParticleTechnique* technique)
 ParticleSystemManager::CloneTechnique(ParticleTechnique* technique)
 {
 {
-    if (technique == NULL)
+    if (technique == nullptr)
     {
     {
-        return NULL;
+        return nullptr;
     }
     }
 
 
     ParticleTechnique* cloned_technique = CreateTechnique();
     ParticleTechnique* cloned_technique = CreateTechnique();
@@ -172,7 +172,7 @@ ParticleSystemManager::CloneEmitter(ParticleEmitter* emitter)
 {
 {
     if (!emitter)
     if (!emitter)
     {
     {
-        return NULL;
+        return nullptr;
     }
     }
 
 
     ParticleEmitter* cloned_emitter = CreateEmitter(emitter->GetEmitterType());
     ParticleEmitter* cloned_emitter = CreateEmitter(emitter->GetEmitterType());
@@ -212,9 +212,9 @@ ParticleSystemManager::CreateRenderer(const Ogre::String& renderer_type)
 ParticleRenderer*
 ParticleRenderer*
 ParticleSystemManager::CloneRenderer(ParticleRenderer* renderer)
 ParticleSystemManager::CloneRenderer(ParticleRenderer* renderer)
 {
 {
-    if (renderer == NULL)
+    if (renderer == nullptr)
     {
     {
-        return NULL;
+        return nullptr;
     }
     }
 
 
     ParticleRenderer* cloned_renderer = CreateRenderer(renderer->GetRendererType());
     ParticleRenderer* cloned_renderer = CreateRenderer(renderer->GetRendererType());

+ 1 - 1
QGearsMain/src/core/particles/ParticleSystemTranslatorManager.cpp

@@ -13,7 +13,7 @@ ParticleSystemTranslatorManager::getNumTranslators() const
 Ogre::ScriptTranslator*
 Ogre::ScriptTranslator*
 ParticleSystemTranslatorManager::getTranslator(const Ogre::AbstractNodePtr &node)
 ParticleSystemTranslatorManager::getTranslator(const Ogre::AbstractNodePtr &node)
 {
 {
-    Ogre::ScriptTranslator* translator = NULL;
+    Ogre::ScriptTranslator* translator = nullptr;
     if (node->type == Ogre::ANT_OBJECT)
     if (node->type == Ogre::ANT_OBJECT)
     {
     {
         Ogre::ObjectAbstractNode* obj = reinterpret_cast<Ogre::ObjectAbstractNode*>(node.get());
         Ogre::ObjectAbstractNode* obj = reinterpret_cast<Ogre::ObjectAbstractNode*>(node.get());

+ 9 - 9
QGearsMain/src/core/particles/ParticleTechnique.cpp

@@ -8,7 +8,7 @@
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 ParticleTechnique::ParticleTechnique():
 ParticleTechnique::ParticleTechnique():
-    m_Renderer(NULL),
+    m_Renderer(nullptr),
 
 
     m_VisualParticleQuota(10),
     m_VisualParticleQuota(10),
     m_VisualParticlePoolIncreased(false),
     m_VisualParticlePoolIncreased(false),
@@ -87,7 +87,7 @@ ParticleTechnique::Initialize()
         if (m_VisualParticleQuota > old_size)
         if (m_VisualParticleQuota > old_size)
         {
         {
             // Create new visual particles
             // Create new visual particles
-            VisualParticle* particle = NULL;
+            VisualParticle* particle = nullptr;
             for (int i = old_size; i < m_VisualParticleQuota; ++i)
             for (int i = old_size; i < m_VisualParticleQuota; ++i)
             {
             {
                 particle = new VisualParticle();
                 particle = new VisualParticle();
@@ -173,7 +173,7 @@ ParticleTechnique::Update(Ogre::Real time_elapsed)
         VisualParticle* particle = m_VisualParticlesPool.GetFirst();
         VisualParticle* particle = m_VisualParticlesPool.GetFirst();
         while (!m_VisualParticlesPool.End())
         while (!m_VisualParticlesPool.End())
         {
         {
-            if (particle != NULL)
+            if (particle != nullptr)
             {
             {
                 Ogre::LogManager::getSingletonPtr()->logMessage("ParticleTechnique::Update found particle with ttl " + Ogre::StringConverter::toString(particle->time_to_live));
                 Ogre::LogManager::getSingletonPtr()->logMessage("ParticleTechnique::Update found particle with ttl " + Ogre::StringConverter::toString(particle->time_to_live));
                 if (particle->time_to_live > time_elapsed)
                 if (particle->time_to_live > time_elapsed)
@@ -276,7 +276,7 @@ ParticleTechnique::DestroyRenderer()
     if (m_Renderer)
     if (m_Renderer)
     {
     {
         ParticleSystemManager::getSingletonPtr()->DestroyRenderer(m_Renderer);
         ParticleSystemManager::getSingletonPtr()->DestroyRenderer(m_Renderer);
-        m_Renderer = NULL;
+        m_Renderer = nullptr;
     }
     }
 }
 }
 
 
@@ -284,7 +284,7 @@ ParticleTechnique::DestroyRenderer()
 ParticleEmitter*
 ParticleEmitter*
 ParticleTechnique::CreateEmitter(const Ogre::String& emitter_type)
 ParticleTechnique::CreateEmitter(const Ogre::String& emitter_type)
 {
 {
-    ParticleEmitter* emitter = NULL;
+    ParticleEmitter* emitter = nullptr;
 
 
     if (emitter_type != Ogre::StringUtil::BLANK)
     if (emitter_type != Ogre::StringUtil::BLANK)
     {
     {
@@ -301,7 +301,7 @@ ParticleTechnique::CreateEmitter(const Ogre::String& emitter_type)
 void
 void
 ParticleTechnique::AddEmitter(ParticleEmitter* emitter)
 ParticleTechnique::AddEmitter(ParticleEmitter* emitter)
 {
 {
-    if (emitter != NULL)
+    if (emitter != nullptr)
     {
     {
         m_Emitters.push_back(emitter);
         m_Emitters.push_back(emitter);
         emitter->SetParentTechnique(this);
         emitter->SetParentTechnique(this);
@@ -379,7 +379,7 @@ ParticleTechnique::ExecuteEmitParticles(ParticleEmitter* emitter, int requested,
     for (int j = 0; j < requested; ++j)
     for (int j = 0; j < requested; ++j)
     {
     {
         // Create a new particle & init using emitter
         // Create a new particle & init using emitter
-        Particle* particle = NULL;
+        Particle* particle = nullptr;
         switch (emitter->GetEmitsType())
         switch (emitter->GetEmitsType())
         {
         {
             case Particle::PT_VISUAL: particle = m_VisualParticlesPool.ReleaseElement(); break;
             case Particle::PT_VISUAL: particle = m_VisualParticlesPool.ReleaseElement(); break;
@@ -387,7 +387,7 @@ ParticleTechnique::ExecuteEmitParticles(ParticleEmitter* emitter, int requested,
         }
         }
 
 
         // Return if there is no particle left anymore, or the name cannot be found
         // Return if there is no particle left anymore, or the name cannot be found
-        if (particle == NULL)
+        if (particle == nullptr)
         {
         {
             Ogre::LogManager::getSingletonPtr()->logMessage("ParticleTechnique::ExecuteEmitParticles request there is no particles left.");
             Ogre::LogManager::getSingletonPtr()->logMessage("ParticleTechnique::ExecuteEmitParticles request there is no particles left.");
             return;
             return;
@@ -406,7 +406,7 @@ ParticleTechnique::ResetVisualParticles()
 {
 {
     for( unsigned int i = 0; i < m_VisualParticles.size(); ++i )
     for( unsigned int i = 0; i < m_VisualParticles.size(); ++i )
     {
     {
-        m_VisualParticles[i]->additional_data = NULL;
+        m_VisualParticles[i]->additional_data = nullptr;
     }
     }
     m_VisualParticlesPool.LockAllElements();
     m_VisualParticlesPool.LockAllElements();
 }
 }

+ 1 - 1
QGearsMain/src/core/particles/ParticleVisual.cpp

@@ -14,7 +14,7 @@ VisualParticle::InitForExpiration()
 {
 {
     Particle::InitForExpiration();
     Particle::InitForExpiration();
 
 
-    if (additional_data != NULL)
+    if (additional_data != nullptr)
     {
     {
         additional_data->SetVisible(false);
         additional_data->SetVisible(false);
     }
     }

+ 2 - 2
QGearsMain/src/core/particles/renderer/ParticleEntityRenderer.cpp

@@ -28,7 +28,7 @@ ParticleEntityRenderer::ParticleEntityRenderer():
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 ParticleEntityRenderer::~ParticleEntityRenderer()
 ParticleEntityRenderer::~ParticleEntityRenderer()
 {
 {
-    if (m_ParentTechnique == NULL)
+    if (m_ParentTechnique == nullptr)
     {
     {
         return;
         return;
     }
     }
@@ -70,7 +70,7 @@ ParticleEntityRenderer::SetMeshName(const Ogre::String& mesh_name)
 void
 void
 ParticleEntityRenderer::Clear()
 ParticleEntityRenderer::Clear()
 {
 {
-    if (m_ParentTechnique == NULL)
+    if (m_ParentTechnique == nullptr)
     {
     {
         return;
         return;
     }
     }

+ 1 - 1
QGearsMain/src/data/QGearsAFileManager.cpp

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 */
 */
 #include "data/QGearsAFileManager.h"
 #include "data/QGearsAFileManager.h"
 
 
-template<> QGears::AFileManager *Ogre::Singleton<QGears::AFileManager>::msSingleton = NULL;
+template<> QGears::AFileManager *Ogre::Singleton<QGears::AFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsBackgroundFileManager.cpp

@@ -26,7 +26,7 @@ THE SOFTWARE.
 #include "data/QGearsBackgroundFileManager.h"
 #include "data/QGearsBackgroundFileManager.h"
 
 
 //-------------------------------------------------------------------------
 //-------------------------------------------------------------------------
-template<> QGears::BackgroundFileManager *Ogre::Singleton<QGears::BackgroundFileManager>::msSingleton = NULL;
+template<> QGears::BackgroundFileManager *Ogre::Singleton<QGears::BackgroundFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsCameraMatrixFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsCameraMatrixFileManager.h"
 #include "data/QGearsCameraMatrixFileManager.h"
 
 
-template<> QGears::CameraMatrixFileManager *Ogre::Singleton<QGears::CameraMatrixFileManager>::msSingleton = NULL;
+template<> QGears::CameraMatrixFileManager *Ogre::Singleton<QGears::CameraMatrixFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 6 - 6
QGearsMain/src/data/QGearsFLevelFile.cpp

@@ -52,8 +52,8 @@ namespace QGears
                  ,const String &group, bool isManual
                  ,const String &group, bool isManual
                  ,Ogre::ManualResourceLoader *loader ) :
                  ,Ogre::ManualResourceLoader *loader ) :
         Resource( creator, name, handle, group, isManual, loader )
         Resource( creator, name, handle, group, isManual, loader )
-       ,m_background_texture_loader( NULL )
-       ,m_background_2d_loader( NULL )
+       ,m_background_texture_loader( nullptr )
+       ,m_background_2d_loader( nullptr )
     {
     {
         createParamDictionary( getResourceType() );
         createParamDictionary( getResourceType() );
     }
     }
@@ -66,7 +66,7 @@ namespace QGears
             assert( !m_background_texture.isNull() );
             assert( !m_background_texture.isNull() );
             Ogre::TextureManager::getSingleton().remove( m_background_texture->getHandle() );
             Ogre::TextureManager::getSingleton().remove( m_background_texture->getHandle() );
             delete m_background_texture_loader;
             delete m_background_texture_loader;
-            m_background_texture_loader = NULL;
+            m_background_texture_loader = nullptr;
         }
         }
         m_background_texture.setNull();
         m_background_texture.setNull();
 
 
@@ -75,7 +75,7 @@ namespace QGears
             assert( !m_background_2d.isNull() );
             assert( !m_background_2d.isNull() );
             Background2DFileManager::getSingleton().remove( m_background_2d->getHandle() );
             Background2DFileManager::getSingleton().remove( m_background_2d->getHandle() );
             delete m_background_2d_loader;
             delete m_background_2d_loader;
-            m_background_2d_loader = NULL;
+            m_background_2d_loader = nullptr;
         }
         }
         m_background_2d.setNull();
         m_background_2d.setNull();
 
 
@@ -96,14 +96,14 @@ namespace QGears
         serializer.importFLevelFile( stream, this );
         serializer.importFLevelFile( stream, this );
 
 
         String background_texture_name( getBackgroundTextureName() );
         String background_texture_name( getBackgroundTextureName() );
-        if( m_background_texture_loader == NULL )
+        if( m_background_texture_loader == nullptr )
         {
         {
             m_background_texture_loader = new FLevelTextureLoader( *this );
             m_background_texture_loader = new FLevelTextureLoader( *this );
             m_background_texture = Ogre::TextureManager::getSingleton().create( background_texture_name, mGroup, true, m_background_texture_loader );
             m_background_texture = Ogre::TextureManager::getSingleton().create( background_texture_name, mGroup, true, m_background_texture_loader );
         }
         }
 
 
         String background_2d_name( getBackground2DName() );
         String background_2d_name( getBackground2DName() );
-        if( m_background_2d_loader == NULL )
+        if( m_background_2d_loader == nullptr )
         {
         {
             m_background_2d_loader = new FLevelBackground2DLoader( *this );
             m_background_2d_loader = new FLevelBackground2DLoader( *this );
             m_background_2d = Background2DFileManager::getSingleton().createResource( background_2d_name, mGroup, true, m_background_2d_loader ).staticCast<Background2DFile>();
             m_background_2d = Background2DFileManager::getSingleton().createResource( background_2d_name, mGroup, true, m_background_2d_loader ).staticCast<Background2DFile>();

+ 1 - 1
QGearsMain/src/data/QGearsFLevelFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsFLevelFileManager.h"
 #include "data/QGearsFLevelFileManager.h"
 
 
-template<> QGears::FLevelFileManager *Ogre::Singleton<QGears::FLevelFileManager>::msSingleton = NULL;
+template<> QGears::FLevelFileManager *Ogre::Singleton<QGears::FLevelFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 6 - 6
QGearsMain/src/data/QGearsHRCFile.cpp

@@ -48,8 +48,8 @@ namespace QGears
                      ,const String &group, bool isManual
                      ,const String &group, bool isManual
                      ,Ogre::ManualResourceLoader *loader ) :
                      ,Ogre::ManualResourceLoader *loader ) :
         Ogre::Resource( creator, name, handle, group, isManual, loader )
         Ogre::Resource( creator, name, handle, group, isManual, loader )
-       ,m_mesh_loader( NULL )
-       ,m_skeleton_loader( NULL )
+       ,m_mesh_loader( nullptr )
+       ,m_skeleton_loader( nullptr )
     {
     {
         createParamDictionary( RESOURCE_TYPE );
         createParamDictionary( RESOURCE_TYPE );
     }
     }
@@ -61,13 +61,13 @@ namespace QGears
         {
         {
             Ogre::SkeletonManager::getSingleton().remove( m_skeleton->getHandle() );
             Ogre::SkeletonManager::getSingleton().remove( m_skeleton->getHandle() );
             delete m_skeleton_loader;
             delete m_skeleton_loader;
-            m_skeleton_loader = NULL;
+            m_skeleton_loader = nullptr;
         }
         }
         if( m_mesh_loader )
         if( m_mesh_loader )
         {
         {
             Ogre::MeshManager::getSingleton().remove( m_mesh->getHandle() );
             Ogre::MeshManager::getSingleton().remove( m_mesh->getHandle() );
             delete m_mesh_loader;
             delete m_mesh_loader;
-            m_mesh_loader = NULL;
+            m_mesh_loader = nullptr;
         }
         }
 
 
         m_skeleton.setNull();
         m_skeleton.setNull();
@@ -88,7 +88,7 @@ namespace QGears
         m_skeleton = skeleton_manager.getByName( skeleton_file_name, mGroup );
         m_skeleton = skeleton_manager.getByName( skeleton_file_name, mGroup );
         if( m_skeleton.isNull() )
         if( m_skeleton.isNull() )
         {
         {
-            assert( m_skeleton_loader == NULL );
+            assert( m_skeleton_loader == nullptr );
             m_skeleton_loader = new HRCSkeletonLoader( *this );
             m_skeleton_loader = new HRCSkeletonLoader( *this );
             m_skeleton = skeleton_manager.create( skeleton_file_name, mGroup, true, m_skeleton_loader );
             m_skeleton = skeleton_manager.create( skeleton_file_name, mGroup, true, m_skeleton_loader );
         }
         }
@@ -100,7 +100,7 @@ namespace QGears
         m_mesh = mesh_manager.getByName( mesh_file_name, mGroup );
         m_mesh = mesh_manager.getByName( mesh_file_name, mGroup );
         if( m_mesh.isNull() )
         if( m_mesh.isNull() )
         {
         {
-            assert( m_mesh_loader == NULL );
+            assert( m_mesh_loader == nullptr );
             m_mesh_loader = new HRCMeshLoader( *this );
             m_mesh_loader = new HRCMeshLoader( *this );
             m_mesh = mesh_manager.create( mesh_file_name, mGroup, true, m_mesh_loader );
             m_mesh = mesh_manager.create( mesh_file_name, mGroup, true, m_mesh_loader );
         }
         }

+ 1 - 1
QGearsMain/src/data/QGearsHRCFileManager.cpp

@@ -27,7 +27,7 @@ THE SOFTWARE.
 
 
 #include <OgreLogManager.h>
 #include <OgreLogManager.h>
 
 
-template<> QGears::HRCFileManager *Ogre::Singleton<QGears::HRCFileManager>::msSingleton = NULL;
+template<> QGears::HRCFileManager *Ogre::Singleton<QGears::HRCFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsLGPArchive.cpp

@@ -98,7 +98,7 @@ namespace QGears
     LGPArchive::open( const String& filename, bool readOnly ) const
     LGPArchive::open( const String& filename, bool readOnly ) const
     {
     {
         LOG_DEBUG( "file:" + filename + " readOnly: " + Ogre::StringConverter::toString(readOnly) );
         LOG_DEBUG( "file:" + filename + " readOnly: " + Ogre::StringConverter::toString(readOnly) );
-        Ogre::MemoryDataStream* buffer( NULL );
+        Ogre::MemoryDataStream* buffer( nullptr );
         if( !m_lgp_file.isNull() )
         if( !m_lgp_file.isNull() )
         {
         {
             FileList::const_iterator it( m_files.begin() );
             FileList::const_iterator it( m_files.begin() );

+ 1 - 1
QGearsMain/src/data/QGearsLZSFLevelFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsLZSFLevelFileManager.h"
 #include "data/QGearsLZSFLevelFileManager.h"
 
 
-template<> QGears::LZSFLevelFileManager *Ogre::Singleton<QGears::LZSFLevelFileManager>::msSingleton = NULL;
+template<> QGears::LZSFLevelFileManager *Ogre::Singleton<QGears::LZSFLevelFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsPFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsPFileManager.h"
 #include "data/QGearsPFileManager.h"
 
 
-template<> QGears::PFileManager *Ogre::Singleton<QGears::PFileManager>::msSingleton = NULL;
+template<> QGears::PFileManager *Ogre::Singleton<QGears::PFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsPaletteFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsPaletteFileManager.h"
 #include "data/QGearsPaletteFileManager.h"
 
 
-template<> QGears::PaletteFileManager *Ogre::Singleton<QGears::PaletteFileManager>::msSingleton = NULL;
+template<> QGears::PaletteFileManager *Ogre::Singleton<QGears::PaletteFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/data/QGearsRSDFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "data/QGearsRSDFileManager.h"
 #include "data/QGearsRSDFileManager.h"
 
 
-template<> QGears::RSDFileManager *Ogre::Singleton<QGears::RSDFileManager>::msSingleton = NULL;
+template<> QGears::RSDFileManager *Ogre::Singleton<QGears::RSDFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 4 - 4
QGearsMain/src/data/QGearsTexCodec.cpp

@@ -90,13 +90,13 @@ namespace QGears
     }
     }
 
 
     //---------------------------------------------------------------------
     //---------------------------------------------------------------------
-    TexCodec *TexCodec::ms_tex_codex( NULL );
+    TexCodec *TexCodec::ms_tex_codex( nullptr );
 
 
     //---------------------------------------------------------------------
     //---------------------------------------------------------------------
     void TexCodec::install()
     void TexCodec::install()
     {
     {
         //install called - create stuff here
         //install called - create stuff here
-        if( ms_tex_codex == NULL )
+        if( ms_tex_codex == nullptr )
         {
         {
             ms_tex_codex = OGRE_NEW TexCodec();
             ms_tex_codex = OGRE_NEW TexCodec();
         }
         }
@@ -124,10 +124,10 @@ namespace QGears
     void TexCodec::uninstall()
     void TexCodec::uninstall()
     {
     {
         //uninstall called - delete stuff here
         //uninstall called - delete stuff here
-        if( ms_tex_codex != NULL )
+        if( ms_tex_codex != nullptr )
         {
         {
             OGRE_DELETE ms_tex_codex;
             OGRE_DELETE ms_tex_codex;
-            ms_tex_codex = NULL;
+            ms_tex_codex = nullptr;
         }
         }
     }
     }
 }
 }

+ 9 - 9
QGearsMain/src/data/QGearsXMLSerializer.cpp

@@ -61,7 +61,7 @@ namespace QGears
     XMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, bool &pDest, const bool &pDefault)
     XMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, bool &pDest, const bool &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -75,7 +75,7 @@ namespace QGears
     XMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, int &pDest, const int &pDefault)
     XMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, int &pDest, const int &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -90,7 +90,7 @@ namespace QGears
                                 , String &pDest, const String &pDefault )
                                 , String &pDest, const String &pDefault )
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -104,7 +104,7 @@ namespace QGears
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Real &pDest, const Ogre::Real &pDefault)
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Real &pDest, const Ogre::Real &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -118,7 +118,7 @@ namespace QGears
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector2 &pDest, const Ogre::Vector2 &pDefault)
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector2 &pDest, const Ogre::Vector2 &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -132,7 +132,7 @@ namespace QGears
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector3 &pDest, const Ogre::Vector3 &pDefault)
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector3 &pDest, const Ogre::Vector3 &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -146,7 +146,7 @@ namespace QGears
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector4 &pDest, const Ogre::Vector4 &pDefault)
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Vector4 &pDest, const Ogre::Vector4 &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -160,7 +160,7 @@ namespace QGears
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Quaternion &pDest, const Ogre::Quaternion &pDefault)
     XMLSerializer::readAttribute(TiXmlNode &node, const String &attribute, Ogre::Quaternion &pDest, const Ogre::Quaternion &pDefault)
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;
@@ -174,7 +174,7 @@ namespace QGears
     XMLSerializer::findChildNode( TiXmlNode &node, const String &tag )
     XMLSerializer::findChildNode( TiXmlNode &node, const String &tag )
     {
     {
         TiXmlNode* child( node.FirstChild() );
         TiXmlNode* child( node.FirstChild() );
-        while( child != NULL && child->ValueStr() != tag )
+        while( child != nullptr && child->ValueStr() != tag )
         {
         {
             child = child->NextSibling();
             child = child->NextSibling();
         }
         }

+ 1 - 1
QGearsMain/src/map/QGearsBackground2DFileManager.cpp

@@ -25,7 +25,7 @@ THE SOFTWARE.
 */
 */
 #include "map/QGearsBackground2DFileManager.h"
 #include "map/QGearsBackground2DFileManager.h"
 
 
-template<> QGears::Background2DFileManager *Ogre::Singleton<QGears::Background2DFileManager>::msSingleton = NULL;
+template<> QGears::Background2DFileManager *Ogre::Singleton<QGears::Background2DFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 2 - 2
QGearsMain/src/map/QGearsBackground2DFileXMLSerializer.cpp

@@ -49,7 +49,7 @@ namespace QGears
     void
     void
     Background2DFileXMLSerializer::readHeader( TiXmlNode *node )
     Background2DFileXMLSerializer::readHeader( TiXmlNode *node )
     {
     {
-        if( node == NULL || node->ValueStr() != "background2d" )
+        if( node == nullptr || node->ValueStr() != "background2d" )
         {
         {
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                 ,"not a valid background2d file, no <background2d> in root"
                 ,"not a valid background2d file, no <background2d> in root"
@@ -62,7 +62,7 @@ namespace QGears
     Background2DFileXMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, Blending &pDest, const Blending &pDefault )
     Background2DFileXMLSerializer::readAttribute( TiXmlNode &node, const String &attribute, Blending &pDest, const Blending &pDefault )
     {
     {
         const String *value( readAttribute( node, attribute ) );
         const String *value( readAttribute( node, attribute ) );
-        if( value == NULL )
+        if( value == nullptr )
         {
         {
             pDest = pDefault;
             pDest = pDefault;
             return false;
             return false;

+ 1 - 1
QGearsMain/src/map/QGearsMapFileManager.cpp

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 */
 */
 #include "map/QGearsMapFileManager.h"
 #include "map/QGearsMapFileManager.h"
 
 
-template<> QGears::MapFileManager *Ogre::Singleton<QGears::MapFileManager>::msSingleton = NULL;
+template<> QGears::MapFileManager *Ogre::Singleton<QGears::MapFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 6 - 6
QGearsMain/src/map/QGearsMapFileXMLSerializer.cpp

@@ -35,7 +35,7 @@ namespace QGears
     //--------------------------------------------------------------------------
     //--------------------------------------------------------------------------
     void MapFileXMLSerializer::readHeader( TiXmlNode *node )
     void MapFileXMLSerializer::readHeader( TiXmlNode *node )
     {
     {
-        if( node == NULL || node->ValueStr() != "map" )
+        if( node == nullptr || node->ValueStr() != "map" )
         {
         {
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                 ,"not a valid map file, no <map> in root"
                 ,"not a valid map file, no <map> in root"
@@ -66,7 +66,7 @@ namespace QGears
     MapFileXMLSerializer::readScript( TiXmlNode &node, MapFile *pDest )
     MapFileXMLSerializer::readScript( TiXmlNode &node, MapFile *pDest )
     {
     {
         TiXmlNode *child( findChildNode( node, "script" ) );
         TiXmlNode *child( findChildNode( node, "script" ) );
-        if( child != NULL )
+        if( child != nullptr )
         {
         {
             String file_name;
             String file_name;
             readAttribute( *child, "file_name", file_name );
             readAttribute( *child, "file_name", file_name );
@@ -79,7 +79,7 @@ namespace QGears
     MapFileXMLSerializer::readBackground2D( TiXmlNode &node, MapFile *pDest )
     MapFileXMLSerializer::readBackground2D( TiXmlNode &node, MapFile *pDest )
     {
     {
         TiXmlNode *child( findChildNode( node, "background2d" ) );
         TiXmlNode *child( findChildNode( node, "background2d" ) );
-        if( child != NULL )
+        if( child != nullptr )
         {
         {
             String file_name;
             String file_name;
             readAttribute( *child, "file_name", file_name );
             readAttribute( *child, "file_name", file_name );
@@ -92,7 +92,7 @@ namespace QGears
     MapFileXMLSerializer::readWalkmesh( TiXmlNode &node, MapFile *pDest )
     MapFileXMLSerializer::readWalkmesh( TiXmlNode &node, MapFile *pDest )
     {
     {
         TiXmlNode *child( findChildNode( node, "walkmesh" ) );
         TiXmlNode *child( findChildNode( node, "walkmesh" ) );
-        if( child != NULL )
+        if( child != nullptr )
         {
         {
             String file_name;
             String file_name;
             readAttribute( *child, "file_name", file_name );
             readAttribute( *child, "file_name", file_name );
@@ -105,7 +105,7 @@ namespace QGears
     MapFileXMLSerializer::readForwardDirection( TiXmlNode &node, MapFile *pDest )
     MapFileXMLSerializer::readForwardDirection( TiXmlNode &node, MapFile *pDest )
     {
     {
         TiXmlNode *child( findChildNode( node, "movement_rotation" ) );
         TiXmlNode *child( findChildNode( node, "movement_rotation" ) );
-        if( child != NULL )
+        if( child != nullptr )
         {
         {
             Ogre::Real degree;
             Ogre::Real degree;
             readAttribute( *child, "degree", degree );
             readAttribute( *child, "degree", degree );
@@ -155,7 +155,7 @@ namespace QGears
     {
     {
         pDest.clear();
         pDest.clear();
         TiXmlNode* child( node.FirstChild() );
         TiXmlNode* child( node.FirstChild() );
-        while( child != NULL )
+        while( child != nullptr )
         {
         {
             if( child->Type() == TiXmlNode::TINYXML_ELEMENT && child->ValueStr() == tag )
             if( child->Type() == TiXmlNode::TINYXML_ELEMENT && child->ValueStr() == tag )
             {
             {

+ 1 - 1
QGearsMain/src/map/QGearsWalkmeshFileManager.cpp

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 */
 */
 #include "map/QGearsWalkmeshFileManager.h"
 #include "map/QGearsWalkmeshFileManager.h"
 
 
-template<> QGears::WalkmeshFileManager *Ogre::Singleton<QGears::WalkmeshFileManager>::msSingleton = NULL;
+template<> QGears::WalkmeshFileManager *Ogre::Singleton<QGears::WalkmeshFileManager>::msSingleton = nullptr;
 
 
 namespace QGears
 namespace QGears
 {
 {

+ 1 - 1
QGearsMain/src/map/QGearsWalkmeshFileXMLSerializer.cpp

@@ -19,7 +19,7 @@ namespace QGears
     //--------------------------------------------------------------------------
     //--------------------------------------------------------------------------
     void WalkmeshFileXMLSerializer::readHeader( TiXmlNode *node )
     void WalkmeshFileXMLSerializer::readHeader( TiXmlNode *node )
     {
     {
-        if( node == NULL || node->ValueStr() != "walkmesh" )
+        if( node == nullptr || node->ValueStr() != "walkmesh" )
         {
         {
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
             OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                 ,"not a valid walkmesh file, no <walkmesh> in root"
                 ,"not a valid walkmesh file, no <walkmesh> in root"

+ 3 - 3
QGearsMain/src/modules/worldmap/WorldMapModule.cpp

@@ -12,7 +12,7 @@
 #include "data/worldmap/TxzFileSerializer.h"
 #include "data/worldmap/TxzFileSerializer.h"
 #include "data/worldmap/MapFileManager.h"
 #include "data/worldmap/MapFileManager.h"
 
 
-template<> QGears::WorldMapModule *Ogre::Singleton< QGears::WorldMapModule >::msSingleton = NULL;
+template<> QGears::WorldMapModule *Ogre::Singleton< QGears::WorldMapModule >::msSingleton = nullptr;
 
 
 BEGIN_QGEARS
 BEGIN_QGEARS
 
 
@@ -321,7 +321,7 @@ static void createReferenceTextureFileInstance(QGears::TxzFileSerializer& s)
     class TestFile : public QGears::TxzFile
     class TestFile : public QGears::TxzFile
     {
     {
     public:
     public:
-        TestFile() : QGears::TxzFile( NULL, "", 0, "" ) {}
+        TestFile() : QGears::TxzFile( nullptr, "", 0, "" ) {}
     };
     };
 
 
     const char* file_name = "/home/paul/qgears/data/cd1/world/wm0.txz";
     const char* file_name = "/home/paul/qgears/data/cd1/world/wm0.txz";
@@ -342,7 +342,7 @@ static void createReferenceFileInstance(std::function<void(Ogre::DataStreamPtr&
     class TestFile : public QGears::WorldMapFile
     class TestFile : public QGears::WorldMapFile
     {
     {
     public:
     public:
-        TestFile() : QGears::WorldMapFile( NULL, "", 0, "" ) {}
+        TestFile() : QGears::WorldMapFile( nullptr, "", 0, "" ) {}
     };
     };
 
 
     const char* file_name = "./data/wm/WM0.MAP";
     const char* file_name = "./data/wm/WM0.MAP";

+ 16 - 16
QGearsMain/src/viewer/ViewerModule.cpp

@@ -19,11 +19,11 @@
 
 
 
 
 ViewerModule::ViewerModule():
 ViewerModule::ViewerModule():
-    m_Entity( NULL ),
-    m_Walkmesh( NULL ),
+    m_Entity( nullptr ),
+    m_Walkmesh( nullptr ),
 
 
-    m_Grid( NULL ),
-    m_Axis( NULL )
+    m_Grid( nullptr ),
+    m_Axis( nullptr )
 {
 {
     m_SceneNode = Ogre::Root::getSingleton().getSceneManager( "Scene" )->getRootSceneNode()->createChildSceneNode( "ViewerModule" );
     m_SceneNode = Ogre::Root::getSingleton().getSceneManager( "Scene" )->getRootSceneNode()->createChildSceneNode( "ViewerModule" );
 
 
@@ -130,11 +130,11 @@ ViewerModule::ViewerModule():
 
 
 ViewerModule::~ViewerModule()
 ViewerModule::~ViewerModule()
 {
 {
-    if( m_Grid != NULL )
+    if( m_Grid != nullptr )
     {
     {
         Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Grid );
         Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Grid );
     }
     }
-    if( m_Axis != NULL )
+    if( m_Axis != nullptr )
     {
     {
         Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Axis );
         Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Axis );
     }
     }
@@ -154,9 +154,9 @@ ViewerModule::Input( const Event& event )
     if (event.type == ET_KEY_PRESS && event.param1 == OIS::KC_DOWN)
     if (event.type == ET_KEY_PRESS && event.param1 == OIS::KC_DOWN)
     {
     {
         bool change = false;
         bool change = false;
-        if (m_Entity != NULL)
+        if (m_Entity != nullptr)
         {
         {
-            if (m_Entity->getAllAnimationStates() != NULL)
+            if (m_Entity->getAllAnimationStates() != nullptr)
             {
             {
                 Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
                 Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
 
 
@@ -184,7 +184,7 @@ ViewerModule::Input( const Event& event )
     else if (event.type == ET_KEY_PRESS && event.param1 == OIS::KC_UP)
     else if (event.type == ET_KEY_PRESS && event.param1 == OIS::KC_UP)
     {
     {
         bool change = false;
         bool change = false;
-        if (m_Entity != NULL && m_Entity->getAllAnimationStates() != NULL)
+        if (m_Entity != nullptr && m_Entity->getAllAnimationStates() != nullptr)
         {
         {
             Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
             Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
 
 
@@ -217,7 +217,7 @@ ViewerModule::Update()
 {
 {
     float delta_time = Timer::getSingleton().GetGameTimeDelta();
     float delta_time = Timer::getSingleton().GetGameTimeDelta();
 
 
-    if (m_Entity != NULL && m_Entity->getAllAnimationStates() != NULL)
+    if (m_Entity != nullptr && m_Entity->getAllAnimationStates() != nullptr)
     {
     {
         Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
         Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
 
 
@@ -240,11 +240,11 @@ ViewerModule::Update()
 void
 void
 ViewerModule::PlayAnimation(const Ogre::String& name)
 ViewerModule::PlayAnimation(const Ogre::String& name)
 {
 {
-    if (m_Entity != NULL)
+    if (m_Entity != nullptr)
     {
     {
         Ogre::String info_text = "Model: " + m_Entity->getName();
         Ogre::String info_text = "Model: " + m_Entity->getName();
 
 
-        if (m_Entity->getAllAnimationStates() != NULL && m_Entity->getAllAnimationStates()->hasAnimationState(name))
+        if (m_Entity->getAllAnimationStates() != nullptr && m_Entity->getAllAnimationStates()->hasAnimationState(name))
         {
         {
             Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
             Ogre::AnimationStateIterator animations = m_Entity->getAllAnimationStates()->getAnimationStateIterator();
             while (animations.hasMoreElements() == true)
             while (animations.hasMoreElements() == true)
@@ -277,15 +277,15 @@ ViewerModule::PlayAnimation(const Ogre::String& name)
 void
 void
 ViewerModule::Clear()
 ViewerModule::Clear()
 {
 {
-    if (m_Entity != NULL)
+    if (m_Entity != nullptr)
     {
     {
         Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(m_Entity);
         Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(m_Entity);
-        m_Entity = NULL;
+        m_Entity = nullptr;
     }
     }
-    if (m_Walkmesh != NULL)
+    if (m_Walkmesh != nullptr)
     {
     {
         delete m_Walkmesh;
         delete m_Walkmesh;
-        m_Walkmesh = NULL;
+        m_Walkmesh = nullptr;
     }
     }
 
 
     m_SceneNode->removeAndDestroyAllChildren();
     m_SceneNode->removeAndDestroyAllChildren();

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels