Explorar el Código

Make space between inner and outer parens and brackets conisitent.

Bryce Groff hace 11 años
padre
commit
f8f8486ca8
Se han modificado 41 ficheros con 2788 adiciones y 2784 borrados
  1. 113 102
      QGearsMain/src/core/AudioManager.cpp
  2. 242 246
      QGearsMain/src/core/Background2D.cpp
  3. 24 22
      QGearsMain/src/core/Background2DAnimation.cpp
  4. 63 53
      QGearsMain/src/core/CameraManager.cpp
  5. 15 15
      QGearsMain/src/core/ConfigCmdManager.cpp
  6. 22 22
      QGearsMain/src/core/ConfigFile.cpp
  7. 12 12
      QGearsMain/src/core/ConfigVarManager.cpp
  8. 197 199
      QGearsMain/src/core/Console.cpp
  9. 147 162
      QGearsMain/src/core/DebugDraw.cpp
  10. 224 224
      QGearsMain/src/core/Entity.cpp
  11. 7 7
      QGearsMain/src/core/EntityCollision.cpp
  12. 7 7
      QGearsMain/src/core/EntityDirection.cpp
  13. 252 249
      QGearsMain/src/core/EntityManager.cpp
  14. 45 45
      QGearsMain/src/core/EntityModel.cpp
  15. 16 16
      QGearsMain/src/core/EntityPoint.cpp
  16. 36 37
      QGearsMain/src/core/EntityTrigger.cpp
  17. 62 62
      QGearsMain/src/core/GameFrameListner.cpp
  18. 44 44
      QGearsMain/src/core/InputManager.cpp
  19. 200 200
      QGearsMain/src/core/ScriptManager.cpp
  20. 7 7
      QGearsMain/src/core/Timer.cpp
  21. 79 79
      QGearsMain/src/core/UiAnimation.cpp
  22. 15 15
      QGearsMain/src/core/UiFont.cpp
  23. 55 55
      QGearsMain/src/core/UiManager.cpp
  24. 67 67
      QGearsMain/src/core/UiSprite.cpp
  25. 87 87
      QGearsMain/src/core/UiTextArea.cpp
  26. 136 136
      QGearsMain/src/core/UiWidget.cpp
  27. 119 119
      QGearsMain/src/core/Utilites.cpp
  28. 58 58
      QGearsMain/src/core/Walkmesh.cpp
  29. 41 41
      QGearsMain/src/core/XmlBackground2DFile.cpp
  30. 59 59
      QGearsMain/src/core/XmlFile.cpp
  31. 25 25
      QGearsMain/src/core/XmlFontFile.cpp
  32. 7 7
      QGearsMain/src/core/XmlFontsFile.cpp
  33. 60 60
      QGearsMain/src/core/XmlMapFile.cpp
  34. 16 16
      QGearsMain/src/core/XmlMapsFile.cpp
  35. 10 10
      QGearsMain/src/core/XmlMusicsFile.cpp
  36. 8 8
      QGearsMain/src/core/XmlPrototypesFile.cpp
  37. 170 170
      QGearsMain/src/core/XmlScreenFile.cpp
  38. 7 7
      QGearsMain/src/core/XmlScreensFile.cpp
  39. 12 12
      QGearsMain/src/core/XmlScriptsFile.cpp
  40. 8 8
      QGearsMain/src/core/XmlTextFile.cpp
  41. 14 14
      QGearsMain/src/core/XmlTextsFile.cpp

+ 113 - 102
QGearsMain/src/core/AudioManager.cpp

@@ -6,52 +6,52 @@
 #include "core/Logger.h"
 
 
-template<>AudioManager *Ogre::Singleton< AudioManager >::msSingleton = NULL;
+template<>AudioManager *Ogre::Singleton<AudioManager>::msSingleton = NULL;
 
 ALsizei AudioManager::m_ChannelBufferNumber = 2;
 int AudioManager::m_ChannelBufferSize = 96 * 1024;
 
 
 AudioManager::AudioManager():
-    m_Initialized( false ),
-    m_ThreadContinue( true ),
+    m_Initialized(false),
+    m_ThreadContinue(true),
     m_UpdateMutex(),
-    m_Music( &m_UpdateMutex )
+    m_Music(&m_UpdateMutex)
 {
-    m_ALDevice = alcOpenDevice( NULL );
-    if( m_ALDevice != NULL )
+    m_ALDevice = alcOpenDevice(NULL);
+    if(m_ALDevice != NULL)
     {
-        m_ALContext = alcCreateContext( m_ALDevice, NULL );
-        if( m_ALContext != NULL )
+        m_ALContext = alcCreateContext(m_ALDevice, NULL);
+        if(m_ALContext != NULL)
         {
-            alcMakeContextCurrent( m_ALContext );
+            alcMakeContextCurrent(m_ALContext);
 
             // 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_VELOCITY, velocity );
             alListenerfv( AL_ORIENTATION, orientation );
             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
         {
-            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
     {
-        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
-    XmlMusicsFile musics( "./data/musics.xml" );
+    XmlMusicsFile musics("./data/musics.xml");
     musics.LoadMusics();
 }
 
@@ -60,17 +60,17 @@ AudioManager::~AudioManager()
 {
     MusicStop();
 
-    if( m_Initialized )
+    if(m_Initialized)
     {
         m_ThreadContinue = false;
         m_UpdateThread->join();
         delete m_UpdateThread;
         delete[] m_Buffer;
 
-        alcMakeContextCurrent( NULL );
-        alcDestroyContext( m_ALContext );
-        alcCloseDevice( m_ALDevice );
-        LOG_TRIVIAL( "AudioManager destroyed." );
+        alcMakeContextCurrent(NULL);
+        alcDestroyContext(m_ALContext);
+        alcCloseDevice(m_ALDevice);
+        LOG_TRIVIAL("AudioManager destroyed.");
     }
 }
 
@@ -78,14 +78,14 @@ AudioManager::~AudioManager()
 void
 AudioManager::operator()()
 {
-    while( m_ThreadContinue )
+    while(m_ThreadContinue)
     {
         Update();
 
         boost::xtime xt;
-        boost::xtime_get( &xt, boost::TIME_UTC_ );
+        boost::xtime_get(&xt, boost::TIME_UTC_);
         xt.nsec += 250000000; // sleep for 250 ms
-        boost::thread::sleep( xt );
+        boost::thread::sleep(xt);
 
         m_UpdateThread->yield();
     }
@@ -95,7 +95,7 @@ AudioManager::operator()()
 void
 AudioManager::Update()
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
     m_Music.Update();
 }
@@ -104,28 +104,28 @@ AudioManager::Update()
 void
 AudioManager::MusicPause()
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
     m_Music.Pause();
 }
 
 
 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 == NULL)
         {
-            LOG_ERROR( "No music found with name \"" + name + "\"." );
+            LOG_ERROR("No music found with name \"" + name + "\".");
             return;
         }
 
-        m_Music.SetLoop( music->loop );
-        m_Music.Play( music->file );
+        m_Music.SetLoop(music->loop);
+        m_Music.Play(music->file);
     }
 }
 
@@ -133,40 +133,40 @@ AudioManager::MusicPlay( const Ogre::String& name )
 void
 AudioManager::MusicStop()
 {
-    boost::recursive_mutex::scoped_lock lock( m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(m_UpdateMutex);
 
     m_Music.Stop();
 }
 
 
 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." );
             return;
         }
     }
 
-    m_MusicList.push_back( music );
+    m_MusicList.push_back(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);
         }
     }
 
@@ -190,7 +190,7 @@ AudioManager::ALError()
 
 
 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 ) );
 
@@ -206,12 +206,12 @@ 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(NULL),
+    m_VorbisSection(0),
+    m_StreamFinished(false),
+    m_UpdateMutex(mutex)
 {
 }
 
@@ -225,91 +225,94 @@ AudioManager::Player::~Player()
 void
 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
-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
-    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;
     }
 
     // get file info
-    m_VorbisInfo = ov_info( &m_VorbisFile, -1.0f );
+    m_VorbisInfo = ov_info(&m_VorbisFile, -1.0f);
 
     // create sound source
-    alGenSources( 1, &m_Source );
+    alGenSources(1, &m_Source);
 
     // create buffers
-    ALuint buffers[ m_ChannelBufferNumber ];
-    alGenBuffers( m_ChannelBufferNumber, buffers );
+    ALuint buffers[m_ChannelBufferNumber];
+    alGenBuffers(m_ChannelBufferNumber, buffers);
 
     // set source parameters
-    alSourcei( m_Source, AL_LOOPING, AL_FALSE );
+    alSourcei(m_Source, AL_LOOPING, AL_FALSE);
 
     // fill buffers
-    for( int i = 0; i < m_ChannelBufferNumber; ++i )
+    for(int i = 0; i < m_ChannelBufferNumber; ++i)
     {
         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
         {
             m_StreamFinished = true;
-            alDeleteBuffers( 1, &buffers[ i ] );
+            alDeleteBuffers(1, &buffers[i]);
         }
     }
 
     // start playback
-    alSourcePlay( m_Source );
+    alSourcePlay(m_Source);
 }
 
 
 void
 AudioManager::Player::Stop()
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
     // stop source
-    alSourceStop( m_Source );
+    alSourceStop(m_Source);
 
     // get source buffers
     int queued_count = 0;
-    alGetSourcei( m_Source, AL_BUFFERS_QUEUED, &queued_count );
+    alGetSourcei(m_Source, AL_BUFFERS_QUEUED, &queued_count);
 
     // unqueue and delete buffers
-    for( int i = 0; i < queued_count; ++i )
+    for(int i = 0; i < queued_count; ++i)
     {
         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
-    alDeleteSources( 1, &m_Source );
+    alDeleteSources(1, &m_Source);
 
     // rest cleanup
-    ov_clear( &m_VorbisFile );
+    ov_clear(&m_VorbisFile);
 }
 
 
 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;
 }
@@ -321,19 +324,22 @@ AudioManager::Player::Update()
     // try to fill processed buffers
     {
         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
             ALsizei buffer_size = FillBuffer();
 
-            if( buffer_size )
+            if(buffer_size)
             {
                 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
             else
@@ -347,22 +353,22 @@ AudioManager::Player::Update()
     // manage source state
     {
         int processed;
-        alGetSourcei( m_Source, AL_BUFFERS_PROCESSED, &processed );
+        alGetSourcei(m_Source, AL_BUFFERS_PROCESSED, &processed);
 
         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();
         }
         else
         {
             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);
             }
         }
     }
@@ -374,7 +380,7 @@ AudioManager::Player::FillBuffer()
 {
     ALsizei read = 0;
 
-    if( m_StreamFinished )
+    if(m_StreamFinished)
     {
         return read;
     }
@@ -384,9 +390,11 @@ AudioManager::Player::FillBuffer()
     bool finished = false;
     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
             case OV_HOLE:
@@ -401,7 +409,7 @@ AudioManager::Player::FillBuffer()
             case 0:
             {
                 // 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;
                 }
@@ -412,14 +420,14 @@ AudioManager::Player::FillBuffer()
             default:
             {
                 read += result;
-                if( read == m_ChannelBufferSize )
+                if(read == m_ChannelBufferSize)
                 {
                     finished = true;
                 }
             }
         }
     }
-    while( finished == false );
+    while(finished == false);
 
     return read;
 }
@@ -428,9 +436,12 @@ AudioManager::Player::FillBuffer()
 float
 AudioManager::Player::GetPosition()
 {
-    boost::recursive_mutex::scoped_lock lock( *m_UpdateMutex );
+    boost::recursive_mutex::scoped_lock lock(*m_UpdateMutex);
 
     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;
 }

+ 242 - 246
QGearsMain/src/core/Background2D.cpp

@@ -10,76 +10,74 @@
 #include "core/Logger.h"
 #include "core/Timer.h"
 
-//------------------------------------------------------------------------------
 
-ConfigVar cv_debug_background2d( "debug_background2d", "Draw background debug info", "false" );
-ConfigVar cv_show_background2d( "show_background2d", "Draw background", "true" );
-ConfigVar cv_background2d_manual( "background2d_manual", "Manual scrolling for 2d background", "false" );
+ConfigVar cv_debug_background2d("debug_background2d", "Draw background debug info", "false");
+ConfigVar cv_show_background2d("show_background2d", "Draw background", "true");
+ConfigVar cv_background2d_manual("background2d_manual", "Manual scrolling for 2d background", "false");
+
 
-//------------------------------------------------------------------------------
 Background2D::Background2D():
-    m_AlphaMaxVertexCount( 0 ),
-    m_AddMaxVertexCount( 0 ),
-
-    m_ScrollEntity( NULL ),
-    m_ScrollPositionStart( Ogre::Vector2::ZERO ),
-    m_ScrollPositionEnd( Ogre::Vector2::ZERO ),
-    m_ScrollType( Background2D::NONE ),
-    m_ScrollSeconds( 0 ),
-    m_ScrollCurrentSeconds( 0 ),
-    m_Position( Ogre::Vector2::ZERO ),
-    m_PositionReal( Ogre::Vector2::ZERO )
-
-   ,m_range( Ogre::AxisAlignedBox::BOX_INFINITE )
+    m_AlphaMaxVertexCount(0),
+    m_AddMaxVertexCount(0),
+
+    m_ScrollEntity(NULL),
+    m_ScrollPositionStart(Ogre::Vector2::ZERO),
+    m_ScrollPositionEnd(Ogre::Vector2::ZERO),
+    m_ScrollType(Background2D::NONE),
+    m_ScrollSeconds(0),
+    m_ScrollCurrentSeconds(0),
+    m_Position(Ogre::Vector2::ZERO),
+    m_PositionReal(Ogre::Vector2::ZERO),
+    m_range(Ogre::AxisAlignedBox::BOX_INFINITE),
     // for ffvii
-   ,m_virtual_screen_size( 320, 240 )
+    m_virtual_screen_size(320, 240)
 {
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
 
     CreateVertexBuffers();
 
-    m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAlpha", "General" );
-    Ogre::Pass* pass = m_AlphaMaterial->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_AlphaMaterial = Ogre::MaterialManager::getSingleton().create("Background2DAlpha", "General");
+    Ogre::Pass* pass = m_AlphaMaterial->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();
-    tex->setTextureName( "system/blank.png" );
-    tex->setNumMipmaps( -1 );
-    tex->setTextureFiltering( Ogre::TFO_NONE );
-
-    m_AddMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAdd", "General" );
-    pass = m_AddMaterial->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_ADD );
-    pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
-    pass->setAlphaRejectValue( 0 );
+    tex->setTextureName("system/blank.png");
+    tex->setNumMipmaps(-1);
+    tex->setTextureFiltering(Ogre::TFO_NONE);
+
+    m_AddMaterial = Ogre::MaterialManager::getSingleton().create("Background2DAdd", "General");
+    pass = m_AddMaterial->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_ADD);
+    pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
+    pass->setAlphaRejectValue(0);
     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);
 
-    m_SceneManager->addRenderQueueListener( this );
+    m_SceneManager->addRenderQueueListener(this);
 }
 
 
 Background2D::~Background2D()
 {
-    m_SceneManager->removeRenderQueueListener( this );
+    m_SceneManager->removeRenderQueueListener(this);
 
-    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];
     }
 
     DestroyVertexBuffers();
@@ -89,7 +87,7 @@ Background2D::~Background2D()
 void
 Background2D::InputDebug(const QGears::Event& event)
 {
-    if( cv_background2d_manual.GetB() == true )
+    if(cv_background2d_manual.GetB() == true)
     {
         if (event.type == QGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_W)
         {
@@ -108,7 +106,7 @@ Background2D::InputDebug(const QGears::Event& event)
             m_PositionReal.x -= 2;
         }
 
-        CameraManager::getSingleton().Set2DScroll( m_PositionReal );
+        CameraManager::getSingleton().Set2DScroll(m_PositionReal);
     }
 }
 
@@ -116,55 +114,55 @@ Background2D::InputDebug(const QGears::Event& event)
 void
 Background2D::Update()
 {
-    for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
+    for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
     {
         for( unsigned int j = 0; j < m_Animations.size(); ++j )
         {
-            if( m_Animations[ j ]->GetName() == m_AnimationPlayed[ i ].name )
+            if( m_Animations[j]->GetName() == m_AnimationPlayed[i].name)
             {
                 float delta_time = Timer::getSingleton().GetGameTimeDelta();
-                float time = m_Animations[ j ]->GetTime();
-                float end_time = m_Animations[ j ]->GetLength();
+                float time = m_Animations[j]->GetTime();
+                float end_time = m_Animations[j]->GetLength();
 
                 // if animation ended
-                if( time + delta_time >= end_time )
+                if(time + delta_time >= end_time)
                 {
                     // set to last frame of animation
-                    if( time != end_time )
+                    if(time != end_time)
                     {
-                        m_Animations[ j ]->SetTime( end_time );
+                        m_Animations[j]->SetTime(end_time);
                     }
 
-                    if( m_AnimationPlayed[ i ].state == Background2DAnimation::ONCE )
+                    if(m_AnimationPlayed[i].state == Background2DAnimation::ONCE)
                     {
-                        for( unsigned int k = 0; k < m_AnimationPlayed[ i ].sync.size(); ++k )
+                        for(unsigned int k = 0; k < m_AnimationPlayed[i].sync.size(); ++k)
                         {
-                            ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationPlayed[ i ].sync[ k ] );
+                            ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationPlayed[i].sync[k]);
                         }
-                        m_AnimationPlayed[ i ].sync.clear();
-                        m_AnimationPlayed[ i ].name = ""; // mark to erase this way
+                        m_AnimationPlayed[i].sync.clear();
+                        m_AnimationPlayed[i].name = ""; // mark to erase this way
                     }
                     else // LOOPED
                     {
                         // in case of looped we need to sync with end
-                        m_Animations[ j ]->SetTime( time + delta_time - end_time );
+                        m_Animations[j]->SetTime(time + delta_time - end_time);
                     }
                 }
                 else
                 {
-                    m_Animations[ j ]->AddTime( delta_time );
+                    m_Animations[j]->AddTime(delta_time);
                 }
             }
         }
     }
 
     // remove stopped animations
-    std::vector< AnimationPlayed >::iterator i = m_AnimationPlayed.begin();
-    for( ; i != m_AnimationPlayed.end(); )
+    std::vector<AnimationPlayed>::iterator i = m_AnimationPlayed.begin();
+    for(; i != m_AnimationPlayed.end();)
     {
-        if( ( *i ).name == "" )
+        if((*i).name == "")
         {
-            i = m_AnimationPlayed.erase( i );
+            i = m_AnimationPlayed.erase(i);
         }
         else
         {
@@ -177,30 +175,30 @@ Background2D::Update()
 void
 Background2D::UpdateDebug()
 {
-    // is this necessary? does it cost to apply camera 2d Scroll?
+    // TODO: is this necessary? does it cost to apply camera 2d Scroll?
     // if so maybe move this check to applyScroll
-    if( m_PositionReal != GetScreenScroll() )
+    if(m_PositionReal != GetScreenScroll())
     {
         applyScroll();
     }
 
-    if( cv_debug_background2d.GetB() == true )
+    if(cv_debug_background2d.GetB() == true)
     {
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.LEFT );
-        DEBUG_DRAW.SetScreenSpace( true );
-        DEBUG_DRAW.SetColour( Ogre::ColourValue( 0.0f, 0.8f, 0.8f, 1.0f ) );
-        for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+        DEBUG_DRAW.SetScreenSpace(true);
+        DEBUG_DRAW.SetColour(Ogre::ColourValue(0.0f, 0.8f, 0.8f, 1.0f));
+        for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
         {
-            DEBUG_DRAW.Text( 150.0f, static_cast<float>(34 + i * 12), "Background 2D animation: " + m_AnimationPlayed[ i ].name );
+            DEBUG_DRAW.Text(150.0f, static_cast<float>(34 + i * 12), "Background 2D animation: " + m_AnimationPlayed[i].name);
         }
     }
 }
 
 
 void
-Background2D::calculateScreenScale( void )
+Background2D::calculateScreenScale()
 {
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     Ogre::Real scale_width = static_cast<Ogre::Real>(viewport->getActualWidth());
     Ogre::Real scale_height = static_cast<Ogre::Real>(viewport->getActualHeight());
 
@@ -218,18 +216,18 @@ Background2D::OnResize()
 {
     calculateScreenScale();
 
-    for( unsigned int i = 0; i < m_Tiles.size(); ++i )
+    for(unsigned int i = 0; i < m_Tiles.size(); ++i)
     {
-        Tile &tile( m_Tiles[ i ] );
+        Tile &tile(m_Tiles[ i ]);
         Ogre::Vector2   top_left(static_cast<Ogre::Real>(tile.x), static_cast<Ogre::Real>(- tile.y));
         Ogre::Vector2   top_right(static_cast<Ogre::Real>(tile.x + tile.width), static_cast<Ogre::Real>(top_left.y));
         Ogre::Vector2   bottom_right(static_cast<Ogre::Real>(top_right.x), static_cast<Ogre::Real>(-(tile.y + tile.height)));
         Ogre::Vector2   bottom_left(static_cast<Ogre::Real>(top_left.x), static_cast<Ogre::Real>(bottom_right.y));
 
-        virtualScreenToWorldSpace( top_left );
-        virtualScreenToWorldSpace( top_right );
-        virtualScreenToWorldSpace( bottom_right );
-        virtualScreenToWorldSpace( bottom_left );
+        virtualScreenToWorldSpace(top_left);
+        virtualScreenToWorldSpace(top_right);
+        virtualScreenToWorldSpace(bottom_right);
+        virtualScreenToWorldSpace(bottom_left);
 
         float new_x1 = top_left.x;
         float new_y1 = top_left.y;
@@ -245,18 +243,18 @@ Background2D::OnResize()
 
         Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
 
-        if( m_Tiles[ i ].blending == QGears::B_ALPHA )
+        if(m_Tiles[i].blending == QGears::B_ALPHA)
         {
             vertex_buffer = m_AlphaVertexBuffer;
         }
-        else if( m_Tiles[ i ].blending == QGears::B_ADD )
+        else if(m_Tiles[i].blending == QGears::B_ADD )
         {
             vertex_buffer = m_AddVertexBuffer;
         }
 
-        float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+        float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
 
-        writeIterator += m_Tiles[ i ].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
+        writeIterator += m_Tiles[i].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
 
         *writeIterator++ = new_x1;
         *writeIterator++ = new_y1;
@@ -303,17 +301,17 @@ Background2D::Clear()
     m_range = Ogre::AxisAlignedBox::BOX_INFINITE;
     UnsetScroll();
 
-    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];
     }
     m_Animations.clear();
 
-    for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
+    for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
     {
-        for( unsigned int j = 0; j < m_AnimationPlayed[ i ].sync.size(); ++j )
+        for(unsigned int j = 0; j < m_AnimationPlayed[i].sync.size(); ++j)
         {
-            ScriptManager::getSingleton().ContinueScriptExecution( m_AnimationPlayed[ i ].sync[ j ] );
+            ScriptManager::getSingleton().ContinueScriptExecution(m_AnimationPlayed[i].sync[j]);
         }
     }
     m_AnimationPlayed.clear();
@@ -325,7 +323,7 @@ Background2D::Clear()
 
 
 void
-Background2D::ScriptAutoScrollToEntity( Entity* entity )
+Background2D::ScriptAutoScrollToEntity(Entity* entity)
 {
     m_ScrollEntity = entity;
 }
@@ -339,17 +337,17 @@ Background2D::GetAutoScrollEntity() const
 
 
 void
-Background2D::ScriptScrollToPosition( const float x, const float y, const ScrollType type, const float seconds )
+Background2D::ScriptScrollToPosition(const float x, const float y, const ScrollType type, const float seconds)
 {
-    LOG_TRIVIAL( "[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString( Ogre::Vector2( x, y ) ) + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString(Ogre::Vector2(x, y)) + "\".");
 
-    Ogre::Vector2 position = Ogre::Vector2( x, y );
+    Ogre::Vector2 position = Ogre::Vector2(x, y);
 
     m_ScrollEntity = NULL;
 
-    if( type == Background2D::NONE )
+    if(type == Background2D::NONE)
     {
-        SetScroll( position );
+        SetScroll(position);
         return;
     }
 
@@ -366,9 +364,9 @@ Background2D::ScriptScrollSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait Background2d scroll for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait Background2d scroll for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_ScrollSync.push_back( script );
+    m_ScrollSync.push_back(script);
     return -1;
 }
 
@@ -378,9 +376,9 @@ Background2D::UnsetScroll()
 {
     m_ScrollType = Background2D::NONE;
 
-    for( unsigned int i = 0; i < m_ScrollSync.size(); ++i )
+    for(unsigned int i = 0; i < m_ScrollSync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_ScrollSync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_ScrollSync[i]);
     }
     m_ScrollSync.clear();
 }
@@ -415,7 +413,7 @@ Background2D::GetScrollSeconds() const
 
 
 void
-Background2D::SetScrollCurrentSeconds( const float seconds )
+Background2D::SetScrollCurrentSeconds(const float seconds)
 {
     m_ScrollCurrentSeconds = seconds;
 }
@@ -429,26 +427,26 @@ Background2D::GetScrollCurrentSeconds() const
 
 
 void
-Background2D::SetScreenScroll( const Ogre::Vector2& position )
+Background2D::SetScreenScroll(const Ogre::Vector2& position)
 {
-    SetScroll( position / m_screen_scale );
+    SetScroll(position / m_screen_scale);
 }
 
 
 void
-Background2D::SetScroll( const Ogre::Vector2& position )
+Background2D::SetScroll(const Ogre::Vector2& position)
 {
     m_Position = position;
-    Ogre::Vector3 pos_3d( m_Position.x, m_Position.y, 0 );
+    Ogre::Vector3 pos_3d(m_Position.x, m_Position.y, 0);
 
-    if( !m_range.contains( pos_3d ) )
+    if( !m_range.contains(pos_3d))
     {
-        Ogre::Vector3 max_3d( m_range.getMaximum() );
-        Ogre::Vector3 min_3d( m_range.getMinimum() );
-        Ogre::Vector2 max( max_3d.x, max_3d.y );
-        Ogre::Vector2 min( min_3d.x, min_3d.y );
-        m_Position.makeCeil( min );
-        m_Position.makeFloor( max );
+        Ogre::Vector3 max_3d(m_range.getMaximum());
+        Ogre::Vector3 min_3d(m_range.getMinimum());
+        Ogre::Vector2 max(max_3d.x, max_3d.y);
+        Ogre::Vector2 min(min_3d.x, min_3d.y);
+        m_Position.makeCeil(min);
+        m_Position.makeFloor(max);
     }
 
     applyScroll();
@@ -458,10 +456,10 @@ Background2D::SetScroll( const Ogre::Vector2& position )
 void
 Background2D::applyScroll()
 {
-    if( cv_background2d_manual.GetB() != true )
+    if(cv_background2d_manual.GetB() != true)
     {
         m_PositionReal = GetScreenScroll();
-        CameraManager::getSingleton().Set2DScroll( m_PositionReal );
+        CameraManager::getSingleton().Set2DScroll(m_PositionReal);
     }
 }
 
@@ -481,36 +479,36 @@ Background2D::GetScreenScroll() const
 
 
 void
-Background2D::SetImage( const Ogre::String& image )
+Background2D::SetImage(const Ogre::String& image)
 {
     Ogre::LogManager::getSingleton().stream()
         << "Background2D::SetImage " << image;
-    Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
-    Ogre::TextureUnitState* tex = pass->getTextureUnitState( 0 );
-    tex->setTextureName( image );
-    pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
-    tex = pass->getTextureUnitState( 0 );
-    tex->setTextureName( image );
+    Ogre::Pass* pass = m_AlphaMaterial->getTechnique(0)->getPass(0);
+    Ogre::TextureUnitState* tex = pass->getTextureUnitState(0);
+    tex->setTextureName(image);
+    pass = m_AddMaterial->getTechnique(0)->getPass(0);
+    tex = pass->getTextureUnitState(0);
+    tex->setTextureName(image);
 }
 
 
 void
-Background2D::SetRange( const Ogre::Vector4& range )
+Background2D::SetRange(const Ogre::Vector4& range)
 {
-    SetRange( ( int )range.x, ( int )range.y, ( int )range.z, ( int )range.w );
+    SetRange((int)range.x, (int)range.y, (int)range.z, (int)range.w);
 }
 
 
 void
-Background2D::SetRange( const int min_x, const int min_y, const int max_x, const int max_y )
+Background2D::SetRange(const int min_x, const int min_y, const int max_x, const int max_y)
 {
     Ogre::LogManager::getSingleton().stream()
         << "Background2D::SetRange " << min_x << " " << min_y << " " << max_x << " " << max_y;
 
-    Ogre::Vector2   half_virtual_screen_size( m_virtual_screen_size / 2 );
+    Ogre::Vector2 half_virtual_screen_size(m_virtual_screen_size / 2);
     half_virtual_screen_size /= m_screen_proportion;
-    m_range.setMaximum( max_x - half_virtual_screen_size.x , max_y - half_virtual_screen_size.y, 1 );
-    m_range.setMinimum( min_x + half_virtual_screen_size.x , min_y + half_virtual_screen_size.y, 0 );
+    m_range.setMaximum(max_x - half_virtual_screen_size.x , max_y - half_virtual_screen_size.y, 1);
+    m_range.setMinimum(min_x + half_virtual_screen_size.x , min_y + half_virtual_screen_size.y, 0);
 
     Ogre::LogManager::getSingleton().stream()
         << "Background2D::SetRange " << m_range;
@@ -520,17 +518,17 @@ Background2D::SetRange( const int min_x, const int min_y, const int max_x, const
 
 
 void
-Background2D::AddTile(  const QGears::Tile& tile )
+Background2D::AddTile(const QGears::Tile& tile)
 {
     // TODO: move depth calculation to flevelBackgroundLoader maybe? and let Backgorund2D only handle 0 <= depth <= 1 or so?
     // maybe just move the < 4095 part to flevel background loader?
-    Ogre::Real depth( 0.0001f );
-    if( tile.depth >= 1 )
+    Ogre::Real depth(0.0001f);
+    if(tile.depth >= 1)
     {
-        if( tile.depth < 4095 )
+        if(tile.depth < 4095)
         {
-            const Ogre::Matrix4 &cam_projection( CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth() );
-            Ogre::Vector4 res( 0, 0, -tile.depth, 1 );
+            const Ogre::Matrix4 &cam_projection(CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrixWithRSDepth());
+            Ogre::Vector4 res(0, 0, -tile.depth, 1);
             res = cam_projection * res;
             res /= res.w;
             depth = res.z;
@@ -540,19 +538,19 @@ Background2D::AddTile(  const QGears::Tile& tile )
             depth = 0.9999f;
         }
     }
-    AddTile( tile.destination, tile.width, tile.height, depth, tile.uv, tile.blending );
+    AddTile(tile.destination, tile.width, tile.height, depth, tile.uv, tile.blending);
 }
 
 
 void
-Background2D::AddTile( const Ogre::Vector2& destination, const int width, const int height, const float depth, const Ogre::Vector4& uv, const Blending blending )
+Background2D::AddTile(const Ogre::Vector2& destination, const int width, const int height, const float depth, const Ogre::Vector4& uv, const Blending blending)
 {
-    AddTile( static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, depth, uv.x, uv.y, uv.z, uv.w, blending );
+    AddTile(static_cast<int>(destination.x), static_cast<int>(destination.y), width, height, depth, uv.x, uv.y, uv.z, uv.w, blending);
 }
 
 
 void
-Background2D::virtualScreenToWorldSpace( Ogre::Vector2& pos ) const
+Background2D::virtualScreenToWorldSpace(Ogre::Vector2& pos) const
 {
     pos.x /= m_virtual_screen_size.x / 2;
     pos.y /= m_virtual_screen_size.y / 2;
@@ -563,19 +561,19 @@ Background2D::virtualScreenToWorldSpace( Ogre::Vector2& pos ) const
 
 
 void
-Background2D::AddTile( const int x, const int y, const int width, const int height, const float depth, const float u1, const float v1, const float u2, const float v2, const Blending blending )
+Background2D::AddTile(const int x, const int y, const int width, const int height, const float depth, const float u1, const float v1, const float u2, const float v2, const Blending blending)
 {
     Ogre::RenderOperation render_op;
     Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
     unsigned int max_vertex_count;
 
-    if( blending == QGears::B_ALPHA )
+    if(blending == QGears::B_ALPHA)
     {
         render_op = m_AlphaRenderOp;
         vertex_buffer = m_AlphaVertexBuffer;
         max_vertex_count = m_AlphaMaxVertexCount;
     }
-    else if( blending == QGears::B_ADD )
+    else if(blending == QGears::B_ADD)
     {
         render_op = m_AddRenderOp;
         vertex_buffer = m_AddVertexBuffer;
@@ -583,13 +581,13 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
     }
     else
     {
-        LOG_ERROR( "Unknown blending type." );
+        LOG_ERROR("Unknown blending type.");
         return;
     }
 
-    if( render_op.vertexData->vertexCount + TILE_VERTEX_COUNT > max_vertex_count )
+    if(render_op.vertexData->vertexCount + TILE_VERTEX_COUNT > max_vertex_count)
     {
-        LOG_ERROR( "Max number of tiles reached. Can't create more than " + Ogre::StringConverter::toString( max_vertex_count / TILE_VERTEX_COUNT ) + " tiles." );
+        LOG_ERROR("Max number of tiles reached. Can't create more than " + Ogre::StringConverter::toString( max_vertex_count / TILE_VERTEX_COUNT ) + " tiles.");
         return;
     }
 
@@ -600,18 +598,18 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
     tile.height = height;
     tile.start_vertex_index = render_op.vertexData->vertexCount;
     tile.blending = blending;
-    size_t index( m_Tiles.size() );
-    m_Tiles.push_back( tile );
+    size_t index(m_Tiles.size());
+    m_Tiles.push_back(tile);
 
     Ogre::Vector2   top_left(static_cast<Ogre::Real>(x), static_cast<Ogre::Real>(-y));
     Ogre::Vector2   top_right(static_cast<Ogre::Real>(x + width), static_cast<Ogre::Real>(top_left.y));
     Ogre::Vector2   bottom_right(static_cast<Ogre::Real>(top_right.x), static_cast<Ogre::Real>(-(y + height)));
-    Ogre::Vector2   bottom_left( top_left.x, bottom_right.y );
+    Ogre::Vector2   bottom_left(top_left.x, bottom_right.y);
 
-    virtualScreenToWorldSpace( top_left );
-    virtualScreenToWorldSpace( top_right );
-    virtualScreenToWorldSpace( bottom_right );
-    virtualScreenToWorldSpace( bottom_left );
+    virtualScreenToWorldSpace(top_left);
+    virtualScreenToWorldSpace(top_right);
+    virtualScreenToWorldSpace(bottom_right);
+    virtualScreenToWorldSpace(bottom_left);
 
     float new_x1 = top_left.x;
     float new_y1 = top_left.y;
@@ -625,9 +623,10 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
     float new_x4 = bottom_left.x;
     float new_y4 = bottom_left.y;
 
-    float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     writeIterator += render_op.vertexData->vertexCount * TILE_VERTEX_INDEX_SIZE;
 
+    // TODO: Can use WriteGlyph
     *writeIterator++ = new_x1;
     *writeIterator++ = new_y1;
     *writeIterator++ = depth;
@@ -695,28 +694,28 @@ Background2D::AddTile( const int x, const int y, const int width, const int heig
 
 
 void
-Background2D::UpdateTileUV( const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2 )
+Background2D::UpdateTileUV(const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2)
 {
-    if( tile_id >= m_Tiles.size() )
+    if(tile_id >= m_Tiles.size())
     {
-        LOG_ERROR( "Tile with id " + Ogre::StringConverter::toString( tile_id ) + " doesn't exist." );
+        LOG_ERROR("Tile with id " + Ogre::StringConverter::toString( tile_id ) + " doesn't exist.");
         return;
     }
 
     Ogre::HardwareVertexBufferSharedPtr vertex_buffer;
 
-    if( m_Tiles[ tile_id ].blending == QGears::B_ALPHA )
+    if(m_Tiles[tile_id].blending == QGears::B_ALPHA)
     {
         vertex_buffer = m_AlphaVertexBuffer;
     }
-    else if( m_Tiles[ tile_id ].blending == QGears::B_ADD )
+    else if(m_Tiles[tile_id].blending == QGears::B_ADD)
     {
         vertex_buffer = m_AddVertexBuffer;
     }
 
-    float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
+    float* writeIterator = (float*)vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
 
-    writeIterator += m_Tiles[ tile_id ].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
+    writeIterator += m_Tiles[tile_id].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
 
     writeIterator += 7;
     *writeIterator++ = u1;
@@ -742,72 +741,72 @@ Background2D::UpdateTileUV( const unsigned int tile_id, const float u1, const fl
 
 
 void
-Background2D::AddAnimation( Background2DAnimation* animation )
+Background2D::AddAnimation(Background2DAnimation* animation)
 {
-    m_Animations.push_back( animation );
+    m_Animations.push_back(animation);
 }
 
 
 void
-Background2D::PlayAnimation( const Ogre::String& animation, const Background2DAnimation::State state )
+Background2D::PlayAnimation(const Ogre::String& animation, const Background2DAnimation::State state)
 {
     bool found = false;
 
-    for( unsigned int i = 0; i < m_Animations.size(); ++i )
+    for(unsigned int i = 0; i < m_Animations.size(); ++i)
     {
-        if( m_Animations[ i ]->GetName() == animation )
+        if(m_Animations[i]->GetName() == animation)
         {
             found = true;
-            m_Animations[ i ]->SetTime( 0 );
-            m_Animations[ i ]->AddTime( 0 );
+            m_Animations[i]->SetTime(0);
+            m_Animations[i]->AddTime(0);
         }
     }
 
-    for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
+    for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
     {
-        if( m_AnimationPlayed[ i ].name == animation )
+        if(m_AnimationPlayed[i].name == animation)
         {
-            m_AnimationPlayed.erase( m_AnimationPlayed.begin() + i );
+            m_AnimationPlayed.erase(m_AnimationPlayed.begin() + i);
         }
     }
 
-    if( found == true )
+    if(found == true)
     {
         AnimationPlayed anim;
         anim.name = animation;
         anim.state = state;
-        m_AnimationPlayed.push_back( anim );
+        m_AnimationPlayed.push_back(anim);
     }
     else
     {
-        LOG_ERROR( "Background2D doesn't has animation \"" + animation + "\"." );
+        LOG_ERROR("Background2D doesn't has animation \"" + animation + "\".");
     }
 }
 
 
 void
-Background2D::ScriptPlayAnimationLooped( const char* name )
+Background2D::ScriptPlayAnimationLooped(const char* name)
 {
-    PlayAnimation( Ogre::String( name ), Background2DAnimation::LOOPED );
+    PlayAnimation(Ogre::String(name), Background2DAnimation::LOOPED);
 }
 
 
 void
-Background2D::ScriptPlayAnimationOnce( const char* name )
+Background2D::ScriptPlayAnimationOnce(const char* name)
 {
-    PlayAnimation( Ogre::String( name ), Background2DAnimation::ONCE );
+    PlayAnimation(Ogre::String(name), Background2DAnimation::ONCE);
 }
 
 
 int
-Background2D::ScriptAnimationSync( const char* animation )
+Background2D::ScriptAnimationSync(const char* animation)
 {
-    for( unsigned int i = 0; i < m_AnimationPlayed.size(); ++i )
+    for(unsigned int i = 0; i < m_AnimationPlayed.size(); ++i)
     {
-        if( m_AnimationPlayed[ i ].name == animation )
+        if(m_AnimationPlayed[i].name == animation)
         {
             ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
-            m_AnimationPlayed[ i ].sync.push_back( script );
+            m_AnimationPlayed[i].sync.push_back(script);
             return -1;
         }
     }
@@ -817,37 +816,36 @@ Background2D::ScriptAnimationSync( const char* animation )
 
 
 void
-Background2D::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation )
+Background2D::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
 {
-    if( cv_show_background2d.GetB() == false )
+    if(cv_show_background2d.GetB() == false)
     {
         return;
     }
 
-
-
-    if( queueGroupId == Ogre::RENDER_QUEUE_MAIN )
+    if(queueGroupId == Ogre::RENDER_QUEUE_MAIN)
     {
-        m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
-        m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
+        m_RenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
+        m_RenderSystem->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
 
-        Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+        Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
         float width = static_cast<float>(viewport->getActualWidth());
         float height = static_cast<float>(viewport->getActualHeight());
+
         Ogre::Matrix4 view;
-        view.makeTrans( Ogre::Vector3( m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0 ) );
-        m_RenderSystem->_setViewMatrix( view );
+        view.makeTrans(Ogre::Vector3(m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0));
+        m_RenderSystem->_setViewMatrix(view);
 
-        if( m_AlphaRenderOp.vertexData->vertexCount != 0 )
+        if(m_AlphaRenderOp.vertexData->vertexCount != 0)
         {
-            m_SceneManager->_setPass( m_AlphaMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_AlphaRenderOp );
+            m_SceneManager->_setPass(m_AlphaMaterial->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_AlphaRenderOp);
         }
 
-        if( m_AddRenderOp.vertexData->vertexCount != 0 )
+        if(m_AddRenderOp.vertexData->vertexCount != 0)
         {
-            m_SceneManager->_setPass( m_AddMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
-            m_RenderSystem->_render( m_AddRenderOp );
+            m_SceneManager->_setPass(m_AddMaterial->getTechnique(0)->getPass(0), true, false);
+            m_RenderSystem->_render(m_AddRenderOp);
         }
     }
 }
@@ -863,20 +861,18 @@ Background2D::CreateVertexBuffers()
     Ogre::VertexDeclaration* vDecl = m_AlphaRenderOp.vertexData->vertexDeclaration;
 
     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_AlphaVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AlphaMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_AlphaVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_AlphaMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
-    m_AlphaRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AlphaVertexBuffer );
+    m_AlphaRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_AlphaVertexBuffer);
     m_AlphaRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_AlphaRenderOp.useIndexes = false;
 
-
-
     m_AddMaxVertexCount = 256 * TILE_VERTEX_COUNT;
     m_AddRenderOp.vertexData = new Ogre::VertexData;
     m_AddRenderOp.vertexData->vertexStart = 0;
@@ -884,15 +880,15 @@ Background2D::CreateVertexBuffers()
     vDecl = m_AddRenderOp.vertexData->vertexDeclaration;
 
     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_AddVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AddMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
+    m_AddVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(vDecl->getVertexSize(0), m_AddMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
 
-    m_AddRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AddVertexBuffer );
+    m_AddRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_AddVertexBuffer);
     m_AddRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     m_AddRenderOp.useIndexes = false;
 }
@@ -914,56 +910,56 @@ Background2D::DestroyVertexBuffers()
 
 
 void
-Background2D::load( const QGears::Background2DFilePtr& background )
+Background2D::load(const QGears::Background2DFilePtr& background)
 {
-    assert( !background.isNull() );
+    assert(!background.isNull());
     background->load();
-    SetImage( background->getTextureName() );
+    SetImage(background->getTextureName());
     m_virtual_screen_size = background->getClip();
-    SetRange( background->getRange() );
+    SetRange(background->getRange());
 
-    const Ogre::Vector3& position( background->getPosition() );
-    const Ogre::Quaternion& orientation( background->getOrientation() );
-    const Ogre::Radian& fov( background->getFov() );
-    CameraManager::getSingleton().Set2DCamera( position, orientation, fov );
-    load( background->getTiles() );
+    const Ogre::Vector3& position(background->getPosition());
+    const Ogre::Quaternion& orientation(background->getOrientation());
+    const Ogre::Radian& fov(background->getFov());
+    CameraManager::getSingleton().Set2DCamera(position, orientation, fov);
+    load(background->getTiles());
 }
 
 
 void
-Background2D::load( const QGears::Background2DFile::TileList& tiles )
+Background2D::load(const QGears::Background2DFile::TileList& tiles)
 {
-    QGears::Background2DFile::TileList::const_iterator it( tiles.begin() );
-    QGears::Background2DFile::TileList::const_iterator it_end( tiles.end() );
-    size_t tile_index( 0 );
-    while( it != it_end )
+    QGears::Background2DFile::TileList::const_iterator it(tiles.begin());
+    QGears::Background2DFile::TileList::const_iterator it_end(tiles.end());
+    size_t tile_index(0);
+    while(it != it_end)
     {
-        AddTile( *it );
-        load( tile_index++, it->animations );
+        AddTile(*it);
+        load(tile_index++, it->animations);
         ++it;
     }
 }
 
 
 void
-Background2D::load( const size_t tile_index, const QGears::AnimationMap& animations )
+Background2D::load(const size_t tile_index, const QGears::AnimationMap& animations)
 {
-    QGears::AnimationMap::const_iterator it( animations.begin() );
-    QGears::AnimationMap::const_iterator it_end( animations.end() );
+    QGears::AnimationMap::const_iterator it(animations.begin());
+    QGears::AnimationMap::const_iterator it_end(animations.end());
 
-    while( it != it_end )
+    while(it != it_end)
     {
-        const QGears::String& name( it->first );
-        const QGears::Animation& animation( it->second );
-        Background2DAnimation* anim( new Background2DAnimation( name, this, tile_index ) );
-        anim->SetLength( animation.length );
-        QGears::KeyFrameList::const_iterator itk( animation.key_frames.begin() );
-        QGears::KeyFrameList::const_iterator itk_end( animation.key_frames.end() );
-        while( itk != itk_end )
+        const QGears::String& name(it->first);
+        const QGears::Animation& animation(it->second);
+        Background2DAnimation* anim(new Background2DAnimation(name, this, tile_index));
+        anim->SetLength(animation.length);
+        QGears::KeyFrameList::const_iterator itk(animation.key_frames.begin());
+        QGears::KeyFrameList::const_iterator itk_end(animation.key_frames.end());
+        while(itk != itk_end)
         {
-            anim->AddUVKeyFrame( *(itk++) );
+            anim->AddUVKeyFrame(*(itk++));
         }
-        AddAnimation( anim );
+        AddAnimation(anim);
         ++it;
     }
 }

+ 24 - 22
QGearsMain/src/core/Background2DAnimation.cpp

@@ -5,12 +5,12 @@
 #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)
 {
 }
 
@@ -21,31 +21,33 @@ Background2DAnimation::~Background2DAnimation()
 
 
 void
-Background2DAnimation::AddTime( const float time )
+Background2DAnimation::AddTime(const float time)
 {
     m_Time += time;
-    if( m_Time > m_Length )
+    if(m_Time > m_Length)
     {
         m_Time = m_Length;
     }
 
-    if( m_UV.size() > 0 )
+    if(m_UV.size() > 0)
     {
         int min_id = -1;
         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_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);
         }
     }
 }
@@ -59,7 +61,7 @@ Background2DAnimation::GetName() const
 
 
 void
-Background2DAnimation::SetTime( const float time )
+Background2DAnimation::SetTime(const float time)
 {
     m_Time = time;
 }
@@ -73,7 +75,7 @@ Background2DAnimation::GetTime() const
 
 
 void
-Background2DAnimation::SetLength( const float time )
+Background2DAnimation::SetLength(const float time)
 {
     m_Length = time;
 }
@@ -87,21 +89,21 @@ Background2DAnimation::GetLength() const
 
 
 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
-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
-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;
     uv_key_frame.time = time;
@@ -109,5 +111,5 @@ Background2DAnimation::AddUVKeyFrame( const float time, const float u1, const fl
     uv_key_frame.v1 = v1;
     uv_key_frame.u2 = u2;
     uv_key_frame.v2 = v2;
-    m_UV.push_back( uv_key_frame );
+    m_UV.push_back(uv_key_frame);
 }

+ 63 - 53
QGearsMain/src/core/CameraManager.cpp

@@ -10,79 +10,87 @@
 #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 = NULL;
 
 
 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();
 
-    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()
 {
-    LOG_TRIVIAL( "CameraManager finished." );
+    LOG_TRIVIAL("CameraManager finished.");
 }
 
 
 void
 CameraManager::Input(const QGears::Event& event, Ogre::Real timeSinceLastFrame)
 {
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
         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;
         }
 
         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;
         }
-        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;
         }
-        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));
         }
     }
 }
@@ -97,49 +105,50 @@ CameraManager::Update()
 void
 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
-CameraManager::SetCameraFree( const bool enable )
+CameraManager::SetCameraFree(const bool enable)
 {
     m_CameraFree = enable;
 
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
         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
     {
-        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
-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_2DOrientation = orientation;
     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
-CameraManager::Set2DScroll( const Ogre::Vector2& position )
+CameraManager::Set2DScroll(const Ogre::Vector2& position)
 {
     m_2DScroll = position;
 
-    if( m_CameraFree == true )
+    if(m_CameraFree == true)
     {
         return;
     }
@@ -148,10 +157,11 @@ CameraManager::Set2DScroll( const Ogre::Vector2& position )
     float height = static_cast<float>(m_Viewport->getActualHeight());
     float left, right, top, bottom;
     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);
 }
 
 
@@ -163,7 +173,7 @@ CameraManager::Get2DScroll() const
 
 
 const Ogre::Vector3
-CameraManager::ProjectPointToScreen( const Ogre::Vector3& point )
+CameraManager::ProjectPointToScreen(const Ogre::Vector3& point)
 {
     Ogre::Vector3 view = m_Camera->getViewMatrix() * point;
     float z = view.z;
@@ -196,7 +206,7 @@ CameraManager::getViewport()
 
 void CameraManager::EnableWireFrame(bool)
 {
-    if ( m_Camera )
+    if (m_Camera)
     {
         //m_Camera->setPolygonMode(Ogre::PM_WIREFRAME);
         //    m_Camera->rotate( Ogre::Vector3::UNIT_Z, Ogre::Radian( Ogre::Degree( 180 ) ) );

+ 15 - 15
QGearsMain/src/core/ConfigCmdManager.cpp

@@ -4,7 +4,7 @@
 #include "core/ConfigCmdManagerCommands.h"
 
 
-template<>ConfigCmdManager *Ogre::Singleton< ConfigCmdManager >::msSingleton = NULL;
+template<>ConfigCmdManager *Ogre::Singleton<ConfigCmdManager>::msSingleton = NULL;
 
 
 ConfigCmdManager::ConfigCmdManager()
@@ -20,35 +20,35 @@ ConfigCmdManager::~ConfigCmdManager()
 
 
 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
-    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
-ConfigCmdManager::ExecuteString( const Ogre::String& cmd_string )
+ConfigCmdManager::ExecuteString(const Ogre::String& cmd_string)
 {
 }
 
 
 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;
@@ -63,11 +63,11 @@ ConfigCmdManager::GetConfigCmdNumber()
 
 
 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;

+ 22 - 22
QGearsMain/src/core/ConfigFile.cpp

@@ -5,72 +5,72 @@
 
 
 void
-ConfigFile::Execute( const Ogre::String& name )
+ConfigFile::Execute(const Ogre::String& name)
 {
     // Open the configuration file
     std::ifstream fp;
     // 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
     {
         Ogre::String command = "";
 
-        while( true )
+        while(true)
         {
             char c = fp.get(); // get character from file
-            if( fp.good() == false )
+            if(fp.good() == false)
             {
                 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
-                    ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-                    if( cmd != NULL )
+                    ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+                    if(cmd != NULL)
                     {
-                        cmd->GetHandler()( params );
+                        cmd->GetHandler()(params);
                     }
                     else
                     {
-                        LOG_ERROR( "Can't find command \"" + params[ 0 ] + "\"." );
+                        LOG_ERROR("Can't find command \"" + params[0] + "\".");
                     }
                 }
 
                 command = "";
             }
-            else if( c >= 0 ) // use only ascii characters
+            else if(c >= 0) // use only ascii characters
             {
                 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 != NULL)
                 {
-                    cmd->GetHandler()( params );
+                    cmd->GetHandler()(params);
                 }
                 else
                 {
-                    LOG_ERROR( "Can't find command \"" + params[ 0 ] + "\"." );
+                    LOG_ERROR("Can't find command \"" + params[0] + "\".");
                 }
             }
         }

+ 12 - 12
QGearsMain/src/core/ConfigVarManager.cpp

@@ -1,31 +1,31 @@
 #include "core/ConfigVarManager.h"
 
 
-template<>ConfigVarManager *Ogre::Singleton< ConfigVarManager >::msSingleton = NULL;
+template<>ConfigVarManager *Ogre::Singleton<ConfigVarManager>::msSingleton = NULL;
 
 
 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*
-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];
         }
     }
 
@@ -41,11 +41,11 @@ ConfigVarManager::GetConfigVarNumber() const
 
 
 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;

+ 197 - 199
QGearsMain/src/core/Console.cpp

@@ -12,61 +12,61 @@
 #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 = NULL;
+ConfigVar cv_console_notification("console_notification", "Draw console strings even when console is hided", "false");
 
 
 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
     {
-        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
-    Ogre::RenderTarget *render_target( QGears::Application::getSingleton().getRenderWindow() );
+    Ogre::RenderTarget *render_target(QGears::Application::getSingleton().getRenderWindow());
     m_ConsoleWidth = render_target->getWidth();
     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
-    Ogre::LogManager::getSingleton().getDefaultLog()->addListener( this );
+    Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this);
 }
 
 
 Console::~Console()
 {
     // remove as listner
-    Ogre::LogManager::getSingleton().getDefaultLog()->removeListener( this );
+    Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
 }
 
 
 void
 Console::Input(const QGears::Event& event)
 {
-    if( m_Visible != true )
+    if(m_Visible != true)
     {
         // add console
         if (event.type == QGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
@@ -80,23 +80,23 @@ Console::Input(const QGears::Event& event)
     // input command
     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();
 
         // 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
-                m_InputLine.erase( 0, 1 );
+                m_InputLine.erase(0, 1);
 
-                ExecuteCommand( m_InputLine );
+                ExecuteCommand(m_InputLine);
             }
         }
         else
@@ -120,7 +120,7 @@ Console::Input(const QGears::Event& event)
     // history 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;
             SetInputLineFromHistory();
@@ -129,7 +129,7 @@ Console::Input(const QGears::Event& event)
     // history 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;
             SetInputLineFromHistory();
@@ -138,7 +138,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to previous row
     else if (event.type == QGears::ET_MOUSE_SCROLL && event.param1 > 0)
     {
-        if( m_DisplayLine > 0 )
+        if(m_DisplayLine > 0)
         {
             m_DisplayLine -= 1;
         }
@@ -146,7 +146,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to next row
     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;
         }
@@ -155,7 +155,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to previous row
     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;
         }
@@ -163,7 +163,7 @@ Console::Input(const QGears::Event& event)
     // scroll display to next row
     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;
         }
@@ -171,30 +171,30 @@ Console::Input(const QGears::Event& event)
     // delete character after cursor
     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();
         }
         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
     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();
         }
         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;
             }
         }
@@ -202,13 +202,13 @@ Console::Input(const QGears::Event& event)
     // move cursor to 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();
         }
 
-        if( m_CursorPosition > 0 )
+        if(m_CursorPosition > 0)
         {
             --m_CursorPosition;
         }
@@ -216,13 +216,13 @@ Console::Input(const QGears::Event& event)
     // move cursor to 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();
         }
 
-        if( m_CursorPosition <  m_InputLine.size() )
+        if(m_CursorPosition <  m_InputLine.size())
         {
             ++m_CursorPosition;
         }
@@ -238,18 +238,18 @@ Console::Input(const QGears::Event& event)
     {
         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();
         }
     }
     // move cursor to end of string
     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();
         }
 
@@ -260,12 +260,12 @@ Console::Input(const QGears::Event& event)
     {
         char legalchars[] = "ABCDEFGHIJKLMNOPQRSTUVWXUZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_=+?{[]}|\\;:'\"<>,./? ";
         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;
-                m_InputLine.insert( i, txt );
+                m_InputLine.insert(i, txt);
                 ++m_CursorPosition;
                 ResetAutoCompletion();
                 break;
@@ -280,31 +280,32 @@ Console::Update()
 {
     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;
 
-        if( m_Height >= m_ConsoleHeight )
+        if(m_Height >= 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;
 
-        if( m_Height <= 0 )
+        if(m_Height <= 0)
         {
             m_Height = 0;
             m_Visible = false;
         }
     }
 
-    if( m_Visible == true )
+    if(m_Visible == true)
     {
         UpdateDraw();
     }
-    else if( cv_console_notification.GetB() == true )
+    else if(cv_console_notification.GetB() == true)
     {
         UpdateNotification();
     }
@@ -316,94 +317,92 @@ Console::UpdateDraw()
 {
     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 rows = ( m_ConsoleHeight - 30 ) / 16;
+    int rows = (m_ConsoleHeight - 30) / 16;
     int y = static_cast<int>(-m_ConsoleHeight + m_Height);
     int empty = rows - m_DisplayLine;
-    if( empty > 0 )
+    if(empty > 0)
     {
         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;
         }
     }
-    if( m_DisplayLine != m_OutputLine.size() )
+    if(m_DisplayLine != m_OutputLine.size())
     {
         Ogre::String temp = "";
-        for( unsigned int i = 0; i < m_LineWidth; ++i )
+        for(unsigned int i = 0; i < m_LineWidth; ++i)
         {
             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;
-    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
     {
-        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
 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;
-    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;
     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;
             ++line;
         }
@@ -415,15 +414,15 @@ void
 Console::OnResize()
 {
     // 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_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
-    m_Height = ( m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
+    m_Height = (m_Height > m_ConsoleHeight) ? m_ConsoleHeight : m_Height;
 }
 
 
@@ -450,7 +449,7 @@ Console::IsVisible() const
 
 
 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
     const char* str = text.c_str();
@@ -458,32 +457,32 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
     unsigned int string_size = 0;
     bool indent = false;
     unsigned int c = 0;
-    for( ; c < text.size(); ++c )
+    for(; c < text.size(); ++c)
     {
         // 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;
         }
 
-        if( str[ c ] != '\n' )
+        if(str[c] != '\n')
         {
-            output_line.push_back( str[ c ] );
+            output_line.push_back(str[c]);
             ++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
-            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();
             }
 
-            if( m_OutputLine.size() == m_DisplayLine )
+            if(m_OutputLine.size() == m_DisplayLine)
             {
                 ++m_DisplayLine;
             }
@@ -492,7 +491,7 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
             line.text = output_line;
             line.colour = colour;
             line.time = Timer::getSingleton().GetSystemTimeTotal();
-            m_OutputLine.push_back( line );
+            m_OutputLine.push_back(line);
 
             output_line.clear();
             string_size = 0;
@@ -500,14 +499,14 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
     }
 
     // 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();
         }
 
-        if( m_OutputLine.size() == m_DisplayLine )
+        if(m_OutputLine.size() == m_DisplayLine)
         {
             ++m_DisplayLine;
         }
@@ -516,51 +515,50 @@ Console::AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& col
         line.text = "";
         line.colour = colour;
         line.time = Timer::getSingleton().GetSystemTimeTotal();
-        m_OutputLine.push_back( line );
+        m_OutputLine.push_back(line);
     }
 }
 
 
 void
-Console::ExecuteCommand( const Ogre::String& command )
+Console::ExecuteCommand(const Ogre::String& command)
 {
     bool handled = false;
-
-    Ogre::StringVector params = StringTokenise( command );
+    Ogre::StringVector params = StringTokenise(command);
 
     // is it cvar
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find( params[ 0 ] );
+    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(params[0]);
 
-    if( cvar != NULL )
+    if(cvar != NULL)
     {
         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
         {
-            AddTextToOutput( params[ 0 ] + " = \"" + cvar->GetS() + "\".\n" +
+            AddTextToOutput(params[0] + " = \"" + cvar->GetS() + "\".\n" +
                             " default:\"" + cvar->GetDefaultValue() + "\".\n" +
                             " description: " + cvar->GetDescription() + ".\n" );
         }
     }
 
-    if( handled == false )
+    if(handled == false)
     {
         // handle command
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-        if( cmd != NULL )
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+        if(cmd != NULL)
         {
-            cmd->GetHandler()( params );
+            cmd->GetHandler()(params);
             return;
         }
         else
         {
-            AddTextToOutput( "Can't find command \"" + params[ 0 ] + "\".\n" );
+            AddTextToOutput("Can't find command \"" + params[0] + "\".\n");
         }
     }
 }
@@ -569,7 +567,7 @@ Console::ExecuteCommand( const Ogre::String& command )
 void
 Console::ExecuteScript()
 {
-    ScriptManager::getSingleton().RunString( m_InputLine );
+    ScriptManager::getSingleton().RunString(m_InputLine);
 }
 
 
@@ -578,144 +576,144 @@ Console::CompleteInput()
 {
     bool add_slash = false;
 
-    if( m_AutoCompletition.size() == 0 )
+    if(m_AutoCompletition.size() == 0)
     {
         // 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();
 
-        Ogre::StringVector params = StringTokenise( m_InputLine );
+        Ogre::StringVector params = StringTokenise(m_InputLine);
 
-        if( params.size() == 0 )
+        if(params.size() == 0)
         {
             // add cvars
             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
             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;
         }
-        else if( params.size() == 1 )
+        else if(params.size() == 1)
         {
-            m_InputLine = params[ 0 ];
+            m_InputLine = params[0];
 
             // add cvars
             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;
 
-                    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
             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;
 
-                    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() != NULL)
                     {
                         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
-            ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-            if( cmd != NULL )
+            ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+            if(cmd != NULL)
             {
                 add_slash = true;
 
-                if( cmd->GetCompletion() != NULL )
+                if(cmd->GetCompletion() != NULL)
                 {
                     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( add_slash == true )
+        if(add_slash == true)
         {
             m_InputLine = "/" + m_InputLine;
         }
         m_CursorPosition = m_InputLine.size();
 
         // sort list
-        std::sort( m_AutoCompletition.begin(), m_AutoCompletition.end() );
+        std::sort(m_AutoCompletition.begin(), m_AutoCompletition.end());
         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
     {
-        if( m_AutoCompletitionLine < m_AutoCompletition.size() - 1 )
+        if(m_AutoCompletitionLine < m_AutoCompletition.size() - 1)
         {
             ++m_AutoCompletitionLine;
         }
@@ -738,11 +736,11 @@ Console::ResetAutoCompletion()
 void
 Console::AddInputToHistory()
 {
-    if( m_History.size() >= m_HistorySize )
+    if(m_History.size() >= m_HistorySize)
     {
         m_History.pop_back();
     }
-    m_History.push_front( m_InputLine );
+    m_History.push_front(m_InputLine);
     m_HistoryLine = -1;
 }
 
@@ -752,12 +750,12 @@ Console::SetInputLineFromHistory()
 {
     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();
             break;
         }
@@ -766,13 +764,13 @@ Console::SetInputLineFromHistory()
 
 
 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;
-    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);
 }

+ 147 - 162
QGearsMain/src/core/DebugDraw.cpp

@@ -9,22 +9,22 @@
 #include "core/UiTextArea.h"
 
 
-template<>DebugDraw *Ogre::Singleton< DebugDraw >::msSingleton = NULL;
+template<>DebugDraw *Ogre::Singleton<DebugDraw>::msSingleton = NULL;
 
 
 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();
 
     CreateLineVertexBuffer();
@@ -33,50 +33,50 @@ DebugDraw::DebugDraw():
     CreateQuadVertexBuffer();
     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");
     }
 
     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;
     //mat.exportMaterial( m_Font->getMaterial(), "font.material" );
 
-    m_SceneManager->addRenderQueueListener( this );
+    m_SceneManager->addRenderQueueListener(this);
 }
 
 
 DebugDraw::~DebugDraw()
 {
-    m_SceneManager->removeRenderQueueListener( this );
+    m_SceneManager->removeRenderQueueListener(this);
 
     DestroyLineVertexBuffer();
     DestroyLine3dVertexBuffer();
@@ -87,28 +87,28 @@ DebugDraw::~DebugDraw()
 
 
 void
-DebugDraw::SetColour( const Ogre::ColourValue& colour )
+DebugDraw::SetColour(const Ogre::ColourValue& colour)
 {
     m_Colour = colour;
 }
 
 
 void
-DebugDraw::SetScreenSpace( const bool screen_space )
+DebugDraw::SetScreenSpace(const bool screen_space)
 {
     m_ScreenSpace = screen_space;
 }
 
 
 void
-DebugDraw::SetZ( const float z )
+DebugDraw::SetZ(const float z)
 {
     m_Z = z;
 }
 
 
 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_FadeEndSquare = fade_e * fade_e;
@@ -116,33 +116,34 @@ DebugDraw::SetFadeDistance( const float fade_s, const float fade_e )
 
 
 void
-DebugDraw::SetTextAlignment( TextAlignment alignment )
+DebugDraw::SetTextAlignment(TextAlignment alignment)
 {
     m_TextAlignment = alignment;
 }
 
 
 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;
     }
 
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     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;
 
+    // TODO: This and the method below could be refactored
     *writeIterator++ = new_x1;
     *writeIterator++ = new_y1;
     *writeIterator++ = m_Z;
@@ -166,15 +167,15 @@ DebugDraw::Line( const float x1, const float y1, const float x2, const float y2
 
 
 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;
     }
 
-    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++ = point1.x;
@@ -200,15 +201,15 @@ DebugDraw::Line3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2 )
 
 
 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;
     }
 
-    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++ = point1.x;
@@ -242,28 +243,28 @@ DebugDraw::Triangle3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2,
 
 
 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;
     }
 
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     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++ = new_x1;
@@ -321,29 +322,26 @@ DebugDraw::Quad( const float x1, const float y1, const float x2, const float y2,
 
 
 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 ) + ".");
         return;
     }
 
-    // get a pointer to the vertex buffer and lock buffer
-    float* writeIterator = ( float* ) m_TextVertexBuffer->lock( Ogre::HardwareBuffer::HBL_NORMAL );
-
-    // move the buffer one line forward
+    float* writeIterator = (float*) m_TextVertexBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
     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 height = static_cast<float>(viewport->getActualHeight());
 
     float length = 0;
     if(m_TextAlignment != LEFT)
     {
-        for( auto &c : text )
+        for(auto &c : text)
         {
             length += ((m_Font->getGlyphAspectRatio(c) * m_FontHeight) / width) * 2;
         }
@@ -354,31 +352,18 @@ DebugDraw::Text( const float x, const float y, const Ogre::String& text )
         }
     }
 
-    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;
-    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( auto &c : text )
+    for(auto &c : text)
     {
         // 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;
 
-        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;
-
-
         Ogre::Vector3 coords[4] = {
             Ogre::Vector3(current_x, current_y, m_Z),
             Ogre::Vector3(current_x + char_width, current_y, m_Z),
@@ -396,74 +381,74 @@ DebugDraw::Text( const float x, const float y, const Ogre::String& text )
 
 
 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;
             colour.a = a;
-            SetColour( colour );
-            Text( point2d.x + x, point2d.y + y, text );
+            SetColour(colour);
+            Text(point2d.x + x, point2d.y + y, text);
         }
     }
 }
 
 
 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;
         }
 
-        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;
         }
 
-        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;
         }
     }
-    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;
         }
 
-        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;
         }
     }
@@ -480,13 +465,13 @@ DebugDraw::CreateLineVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_LineRenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }
@@ -512,13 +497,13 @@ DebugDraw::CreateLine3dVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_Line3dRenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }
@@ -544,13 +529,13 @@ DebugDraw::CreateTriangle3dVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_Triangle3dRenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }
@@ -576,13 +561,13 @@ DebugDraw::CreateQuadVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_QuadRenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }
@@ -608,15 +593,15 @@ DebugDraw::CreateTextVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_TextRenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }

+ 224 - 224
QGearsMain/src/core/Entity.cpp

@@ -6,88 +6,88 @@
 #include "core/Logger.h"
 
 
-ConfigVar cv_debug_entity( "debug_entity", "Draw entity debug info", "0" );
-
-
-Entity::Entity( const Ogre::String& name, Ogre::SceneNode* node ):
-    m_Name( name ),
-    m_SceneNode( node ),
-
-    m_Height( 1.0f ),
-
-    m_SolidRadius( 0.24f ),
-    m_Solid( false ),
-
-    m_TalkRadius( 0.45f ),
-    m_Talkable( false ),
-
-    m_State( Entity::NONE ),
-
-    m_MoveAutoSpeed( 0.7f ),
-    m_MoveWalkSpeed( 0.7f ),
-    m_MoveRunSpeed( 0.8f ),
-    m_MovePosition( Ogre::Vector3( 0, 0, 0 ) ),
-    m_MoveEntity( NULL ),
-    m_MoveStopDistance( 0.0f ),
-    m_MoveTriangleId( -1 ),
-    m_MoveAutoRotation( true ),
-    m_MoveAutoAnimation( true ),
-    m_MoveAnimationWalk( "Walk" ),
-    m_MoveAnimationRun( "Run" ),
-
-    m_LinearMovement( LM_UP_TO_DOWN ),
-    m_LinearStart( 0.0f, 0.0f, 0.0f ),
-    m_LinearEnd( 0.0f, 0.0f, 0.0f ),
-
-    m_JumpStart( 0.0f, 0.0f, 0.0f ),
-    m_JumpEnd( 0.0f, 0.0f, 0.0f ),
-    m_JumpSeconds( 0.0f ),
-    m_JumpCurrentSeconds( 0.0f ),
-
-    m_OffsetPositionStart( 0.0f, 0.0f, 0.0f ),
-    m_OffsetPositionEnd( 0.0f, 0.0f, 0.0f ),
-    m_OffsetType( AT_NONE ),
-    m_OffsetSeconds( 0.0f ),
-    m_OffsetCurrentSeconds( 0.0f ),
-
-    m_TurnDirection( TD_CLOSEST ),
-    m_TurnDirectionStart( 0 ),
-    m_TurnDirectionEnd( 0 ),
-    m_TurnEntity( NULL ),
-    m_TurnType( AT_NONE ),
-    m_TurnSeconds( 0.0f ),
-    m_TurnCurrentSeconds( 0.0f ),
-
-    m_AnimationSpeed( 1.0f ),
-    m_AnimationDefault( "Idle" ),
-    m_AnimationCurrentName( "" ),
-    m_AnimationAutoPlay( true )
+ConfigVar cv_debug_entity("debug_entity", "Draw entity debug info", "0");
+
+
+Entity::Entity(const Ogre::String& name, Ogre::SceneNode* node):
+    m_Name(name),
+    m_SceneNode(node),
+
+    m_Height(1.0f),
+
+    m_SolidRadius(0.24f),
+    m_Solid(false),
+
+    m_TalkRadius(0.45f),
+    m_Talkable(false),
+
+    m_State(Entity::NONE),
+
+    m_MoveAutoSpeed(0.7f),
+    m_MoveWalkSpeed(0.7f),
+    m_MoveRunSpeed(0.8f),
+    m_MovePosition(Ogre::Vector3(0, 0, 0)),
+    m_MoveEntity(NULL),
+    m_MoveStopDistance(0.0f),
+    m_MoveTriangleId(-1),
+    m_MoveAutoRotation(true),
+    m_MoveAutoAnimation(true),
+    m_MoveAnimationWalk("Walk"),
+    m_MoveAnimationRun("Run"),
+
+    m_LinearMovement(LM_UP_TO_DOWN),
+    m_LinearStart(0.0f, 0.0f, 0.0f),
+    m_LinearEnd(0.0f, 0.0f, 0.0f),
+
+    m_JumpStart(0.0f, 0.0f, 0.0f),
+    m_JumpEnd(0.0f, 0.0f, 0.0f),
+    m_JumpSeconds(0.0f),
+    m_JumpCurrentSeconds(0.0f),
+
+    m_OffsetPositionStart(0.0f, 0.0f, 0.0f),
+    m_OffsetPositionEnd(0.0f, 0.0f, 0.0f),
+    m_OffsetType(AT_NONE),
+    m_OffsetSeconds(0.0f),
+    m_OffsetCurrentSeconds(0.0f),
+
+    m_TurnDirection(TD_CLOSEST),
+    m_TurnDirectionStart(0),
+    m_TurnDirectionEnd(0),
+    m_TurnEntity(NULL),
+    m_TurnType(AT_NONE),
+    m_TurnSeconds(0.0f),
+    m_TurnCurrentSeconds(0.0f),
+
+    m_AnimationSpeed(1.0f),
+    m_AnimationDefault("Idle"),
+    m_AnimationCurrentName(""),
+    m_AnimationAutoPlay(true)
 {
     m_model_root_node = m_SceneNode->createChildSceneNode();
     m_ModelNode = m_model_root_node->createChildSceneNode();
 
     m_Direction = new EntityDirection();
-    m_Direction->setMaterial( "entity/direction" );
+    m_Direction->setMaterial("entity/direction");
     m_DirectionNode = m_SceneNode->createChildSceneNode();
-    m_DirectionNode->attachObject( m_Direction );
+    m_DirectionNode->attachObject(m_Direction);
 
     m_SolidCollision = new EntityCollision();
-    m_SolidCollision->setMaterial( "entity/solid_collision" );
+    m_SolidCollision->setMaterial("entity/solid_collision");
     m_SolidCollisionNode = m_SceneNode->createChildSceneNode();
-    m_SolidCollisionNode->setScale( m_SolidRadius, m_SolidRadius, m_Height );
-    m_SolidCollisionNode->attachObject( m_SolidCollision );
+    m_SolidCollisionNode->setScale(m_SolidRadius, m_SolidRadius, m_Height);
+    m_SolidCollisionNode->attachObject(m_SolidCollision);
 
     m_TalkCollision = new EntityCollision();
-    m_TalkCollision->setMaterial( "entity/talk_collision" );
+    m_TalkCollision->setMaterial("entity/talk_collision");
     m_TalkCollisionNode = m_SceneNode->createChildSceneNode();
-    m_TalkCollisionNode->setScale( m_TalkRadius, m_TalkRadius, m_Height );
-    m_TalkCollisionNode->attachObject( m_TalkCollision );
+    m_TalkCollisionNode->setScale(m_TalkRadius, m_TalkRadius, m_Height);
+    m_TalkCollisionNode->attachObject(m_TalkCollision);
 
-    m_model_root_node->setPosition( Ogre::Vector3::ZERO );
-    m_ModelNode->setPosition( Ogre::Vector3::ZERO );
-    m_SceneNode->setPosition( Ogre::Vector3::ZERO );
+    m_model_root_node->setPosition(Ogre::Vector3::ZERO);
+    m_ModelNode->setPosition(Ogre::Vector3::ZERO);
+    m_SceneNode->setPosition(Ogre::Vector3::ZERO);
 
-    LOG_TRIVIAL( "Entity \"" + m_Name + "\" created." );
+    LOG_TRIVIAL("Entity \"" + m_Name + "\" created.");
 }
 
 
@@ -98,24 +98,24 @@ Entity::~Entity()
 
     m_SceneNode->removeAndDestroyAllChildren();
 
-    LOG_TRIVIAL( "Entity \"" + m_Name + "\" destroyed." );
+    LOG_TRIVIAL("Entity \"" + m_Name + "\" destroyed.");
 }
 
 
 void
 Entity::Update()
 {
-    if( m_MoveEntity != NULL )
+    if(m_MoveEntity != NULL)
     {
         m_MovePosition = m_MoveEntity->GetPosition();
         m_MoveStopDistance = GetSolidRadius() + m_MoveEntity->GetSolidRadius();
     }
 
-    if( m_TurnEntity != NULL )
+    if(m_TurnEntity != NULL)
     {
-        Ogre::Degree angle = GetDirectionToEntity( m_TurnEntity );
+        Ogre::Degree angle = GetDirectionToEntity(m_TurnEntity);
 
-        angle = CalculateTurnAngle( m_TurnDirectionStart, angle );
+        angle = CalculateTurnAngle(m_TurnDirectionStart, angle);
 
         m_TurnDirectionEnd = angle;
     }
@@ -127,68 +127,68 @@ Entity::UpdateDebug()
 {
     int debug = cv_debug_entity.GetI();
 
-    m_DirectionNode->setVisible( debug > 0 );
-    m_SolidCollisionNode->setVisible( debug > 0 && m_Solid );
-    m_TalkCollisionNode->setVisible( debug > 0 && m_Talkable );
+    m_DirectionNode->setVisible(debug > 0);
+    m_SolidCollisionNode->setVisible(debug > 0 && m_Solid);
+    m_TalkCollisionNode->setVisible(debug > 0 && m_Talkable);
 
     // debug output
-    if( debug > 0 )
+    if(debug > 0)
     {
-        DEBUG_DRAW.SetColour( Ogre::ColourValue::White );
-        DEBUG_DRAW.SetScreenSpace( true );
-        DEBUG_DRAW.SetTextAlignment( DEBUG_DRAW.CENTER );
-        DEBUG_DRAW.SetFadeDistance( 40, 50 );
+        DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
+        DEBUG_DRAW.SetScreenSpace(true);
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.CENTER);
+        DEBUG_DRAW.SetFadeDistance(40, 50);
 
         Ogre::Vector3 entity_pos = GetPosition();
 
-        DEBUG_DRAW.Text( entity_pos, 0, 0, m_Name );
-        DEBUG_DRAW.Text( entity_pos, 0, 12, m_AnimationCurrentName );
+        DEBUG_DRAW.Text(entity_pos, 0, 0, m_Name);
+        DEBUG_DRAW.Text(entity_pos, 0, 12, m_AnimationCurrentName);
 
-        if( debug > 1 )
+        if(debug > 1)
         {
             static Ogre::String move_state_string[] = { "NONE", "WALKMESH", "LINEAR", "JUMP" };
 
-            DEBUG_DRAW.Text( entity_pos, 0, 24, Ogre::StringConverter::toString( entity_pos ) );
-            DEBUG_DRAW.Text( entity_pos, 0, 36, "Triangle: " + Ogre::StringConverter::toString( m_MoveTriangleId ) );
-            DEBUG_DRAW.Text( entity_pos, 0, 48, "Move state: " + move_state_string[ m_State ] );
-            switch( m_State )
+            DEBUG_DRAW.Text(entity_pos, 0, 24, Ogre::StringConverter::toString(entity_pos));
+            DEBUG_DRAW.Text(entity_pos, 0, 36, "Triangle: " + Ogre::StringConverter::toString(m_MoveTriangleId));
+            DEBUG_DRAW.Text(entity_pos, 0, 48, "Move state: " + move_state_string[m_State]);
+            switch(m_State)
             {
                 case Entity::WALKMESH:
                 {
-                    DEBUG_DRAW.Line3d( entity_pos, m_MovePosition );
+                    DEBUG_DRAW.Line3d(entity_pos, m_MovePosition);
                 }
                 break;
 
                 case Entity::LINEAR:
                 {
-                    DEBUG_DRAW.Text( m_LinearStart, 0, 0, "Start: " + Ogre::StringConverter::toString( m_LinearStart ) );
-                    DEBUG_DRAW.Text( m_LinearEnd, 0, 0, "End: " + Ogre::StringConverter::toString( m_LinearEnd ) );
-                    DEBUG_DRAW.Line3d( m_LinearStart, m_LinearEnd );
+                    DEBUG_DRAW.Text(m_LinearStart, 0, 0, "Start: " + Ogre::StringConverter::toString(m_LinearStart));
+                    DEBUG_DRAW.Text(m_LinearEnd, 0, 0, "End: " + Ogre::StringConverter::toString(m_LinearEnd));
+                    DEBUG_DRAW.Line3d(m_LinearStart, m_LinearEnd);
                 }
                 break;
 
                 case Entity::JUMP:
                 {
-                    DEBUG_DRAW.Text( m_JumpStart, 0, 0, "Start: " + Ogre::StringConverter::toString( m_JumpStart ) );
-                    DEBUG_DRAW.Text( m_JumpEnd, 0, 0, "End: " + Ogre::StringConverter::toString( m_JumpEnd ) );
+                    DEBUG_DRAW.Text(m_JumpStart, 0, 0, "Start: " + Ogre::StringConverter::toString(m_JumpStart));
+                    DEBUG_DRAW.Text(m_JumpEnd, 0, 0, "End: " + Ogre::StringConverter::toString(m_JumpEnd));
                     Ogre::Vector3 distance = m_JumpEnd - m_JumpStart;
                     Ogre::Vector3 pos1, pos2, pos3;
                     pos1.x = m_JumpStart.x + distance.x * 0.25f;
                     pos1.y = m_JumpStart.y + distance.y * 0.25f;
                     float current1 = m_JumpSeconds / 4;
-                    pos1.z = current1 * current1 * -13.08f + current1 * ( ( distance.z ) / m_JumpSeconds + m_JumpSeconds * 13.08f ) + m_JumpStart.z;
+                    pos1.z = current1 * current1 * -13.08f + current1 * ((distance.z) / m_JumpSeconds + m_JumpSeconds * 13.08f) + m_JumpStart.z;
                     pos2.x = m_JumpStart.x + distance.x * 0.5f;
                     pos2.y = m_JumpStart.y + distance.y * 0.5f;
                     float current2 = current1 * 2;
-                    pos2.z = current2 * current2 * -13.08f + current2 * ( ( distance.z ) / m_JumpSeconds + m_JumpSeconds * 13.08f ) + m_JumpStart.z;
+                    pos2.z = current2 * current2 * -13.08f + current2 * ((distance.z) / m_JumpSeconds + m_JumpSeconds * 13.08f) + m_JumpStart.z;
                     pos3.x = m_JumpStart.x + distance.x * 0.75f;
                     pos3.y = m_JumpStart.y + distance.y * 0.75f;
                     float current3 = current1 * 3;
-                    pos3.z = current3 * current3 * -13.08f + current3 * ( ( distance.z ) / m_JumpSeconds + m_JumpSeconds * 13.08f ) + m_JumpStart.z;
-                    DEBUG_DRAW.Line3d( m_JumpStart, pos1 );
-                    DEBUG_DRAW.Line3d( pos1, pos2 );
-                    DEBUG_DRAW.Line3d( pos2, pos3 );
-                    DEBUG_DRAW.Line3d( pos3, m_JumpEnd );
+                    pos3.z = current3 * current3 * -13.08f + current3 * ((distance.z) / m_JumpSeconds + m_JumpSeconds * 13.08f) + m_JumpStart.z;
+                    DEBUG_DRAW.Line3d(m_JumpStart, pos1);
+                    DEBUG_DRAW.Line3d(pos1, pos2);
+                    DEBUG_DRAW.Line3d(pos2, pos3);
+                    DEBUG_DRAW.Line3d(pos3, m_JumpEnd);
                 }
                 break;
             }
@@ -205,16 +205,16 @@ Entity::GetName() const
 
 
 void
-Entity::SetPosition( const Ogre::Vector3& position )
+Entity::SetPosition(const Ogre::Vector3& position)
 {
-    m_SceneNode->setPosition( position );
+    m_SceneNode->setPosition(position);
 }
 
 
 void
-Entity::ScriptSetPosition( const float x, const float y, const float z )
+Entity::ScriptSetPosition(const float x, const float y, const float z)
 {
-    SetPosition( Ogre::Vector3( x, y, z ) );
+    SetPosition(Ogre::Vector3(x, y, z));
     // if we set it from script - reset walkmesh triangle to reattach entity to walkmesh again if needed
     m_MoveTriangleId = -1;
 }
@@ -231,62 +231,62 @@ void
 Entity::ScriptGetPosition() const
 {
     Ogre::Vector3 position = m_SceneNode->getPosition();
-    ScriptManager::getSingleton().AddValueToStack( position.x );
-    ScriptManager::getSingleton().AddValueToStack( position.y );
-    ScriptManager::getSingleton().AddValueToStack( position.z );
+    ScriptManager::getSingleton().AddValueToStack(position.x);
+    ScriptManager::getSingleton().AddValueToStack(position.y);
+    ScriptManager::getSingleton().AddValueToStack(position.z);
 }
 
 
 void
-Entity::SetOffset( const Ogre::Vector3& position )
+Entity::SetOffset(const Ogre::Vector3& position)
 {
-    assert( m_model_root_node );
-    m_model_root_node->setPosition( position );
+    assert(m_model_root_node);
+    m_model_root_node->setPosition(position);
 }
 
 
 const Ogre::Vector3
 Entity::GetOffset() const
 {
-    assert( m_model_root_node );
+    assert(m_model_root_node);
     return m_model_root_node->getPosition();
 }
 
 
 void
-Entity::SetRotation( const Ogre::Degree& rotation )
+Entity::SetRotation(const Ogre::Degree& rotation)
 {
-    assert( m_model_root_node );
-    float angle = rotation.valueDegrees() - Ogre::Math::Floor( rotation.valueDegrees() / 360.0f ) * 360.0f;
+    assert(m_model_root_node);
+    float angle = rotation.valueDegrees() - Ogre::Math::Floor(rotation.valueDegrees() / 360.0f) * 360.0f;
 
-    if( angle < 0 )
+    if(angle < 0)
     {
         angle = 360 + angle;
     }
 
     Ogre::Quaternion q;
     Ogre::Vector3 vec = Ogre::Vector3::UNIT_Z;
-    q.FromAngleAxis( Ogre::Radian( Ogre::Degree( angle ) ), vec );
-    m_model_root_node->setOrientation( q );
-    m_DirectionNode->setOrientation( q );
+    q.FromAngleAxis(Ogre::Radian(Ogre::Degree(angle)), vec);
+    m_model_root_node->setOrientation(q);
+    m_DirectionNode->setOrientation(q);
 }
 
 
 void
-Entity::ScriptSetRotation( const float rotation )
+Entity::ScriptSetRotation(const float rotation)
 {
-    SetRotation( Ogre::Degree( rotation ) );
+    SetRotation(Ogre::Degree(rotation));
 }
 
 
 Ogre::Degree
 Entity::GetRotation() const
 {
-    assert( m_model_root_node );
+    assert(m_model_root_node);
     Ogre::Quaternion q = m_model_root_node->getOrientation();
     Ogre::Degree temp;
     Ogre::Vector3 vec = Ogre::Vector3::UNIT_Z;
-    q.ToAngleAxis( temp, vec );
+    q.ToAngleAxis(temp, vec);
 
     return temp;
 }
@@ -302,14 +302,14 @@ Entity::ScriptGetRotation() const
 void Entity::setScale(const Ogre::Vector3 &scale)
 {
     assert(m_model_root_node);
-    m_model_root_node->setScale( scale );
+    m_model_root_node->setScale(scale);
 }
 
 
 void Entity::setRootOrientation(const Ogre::Quaternion &root_orientation)
 {
     assert(m_ModelNode);
-    m_ModelNode->setOrientation( root_orientation );
+    m_ModelNode->setOrientation(root_orientation);
 }
 
 
@@ -321,10 +321,10 @@ Entity::GetHeight() const
 
 
 void
-Entity::SetSolidRadius( const float radius )
+Entity::SetSolidRadius(const float radius)
 {
     m_SolidRadius = radius;
-    m_SolidCollisionNode->setScale( m_SolidRadius, m_SolidRadius, m_Height );
+    m_SolidCollisionNode->setScale(m_SolidRadius, m_SolidRadius, m_Height);
 }
 
 
@@ -336,7 +336,7 @@ Entity::GetSolidRadius() const
 
 
 void
-Entity::SetSolid( const bool solid )
+Entity::SetSolid(const bool solid)
 {
     m_Solid = solid;
 }
@@ -350,10 +350,10 @@ Entity::IsSolid() const
 
 
 void
-Entity::SetTalkRadius( const float radius )
+Entity::SetTalkRadius(const float radius)
 {
     m_TalkRadius = radius;
-    m_TalkCollisionNode->setScale( m_TalkRadius, m_TalkRadius, m_Height );
+    m_TalkCollisionNode->setScale(m_TalkRadius, m_TalkRadius, m_Height);
 }
 
 
@@ -365,7 +365,7 @@ Entity::GetTalkRadius() const
 
 
 void
-Entity::SetTalkable( const bool talkable )
+Entity::SetTalkable(const bool talkable)
 {
     m_Talkable = talkable;
 }
@@ -379,7 +379,7 @@ Entity::IsTalkable() const
 
 
 void
-Entity::SetState( const Entity::State state )
+Entity::SetState(const Entity::State state)
 {
     m_State = state;
 }
@@ -393,7 +393,7 @@ Entity::GetState() const
 
 
 void
-Entity::SetMoveAutoSpeed( const float speed )
+Entity::SetMoveAutoSpeed(const float speed)
 {
     m_MoveAutoSpeed = speed;
 }
@@ -407,7 +407,7 @@ Entity::GetMoveAutoSpeed() const
 
 
 void
-Entity::SetMoveWalkSpeed( const float speed )
+Entity::SetMoveWalkSpeed(const float speed)
 {
     m_MoveWalkSpeed = speed;
 }
@@ -421,7 +421,7 @@ Entity::GetMoveWalkSpeed() const
 
 
 void
-Entity::SetMoveRunSpeed( const float speed )
+Entity::SetMoveRunSpeed(const float speed)
 {
     m_MoveRunSpeed = speed;
 }
@@ -435,7 +435,7 @@ Entity::GetMoveRunSpeed() const
 
 
 void
-Entity::SetMovePosition( const Ogre::Vector3& target )
+Entity::SetMovePosition(const Ogre::Vector3& target)
 {
     m_MovePosition = target;
 }
@@ -456,7 +456,7 @@ Entity::GetMoveStopDistance() const
 
 
 void
-Entity::SetMoveTriangleId( const int triangle )
+Entity::SetMoveTriangleId(const int triangle)
 {
     m_MoveTriangleId = triangle;
 }
@@ -470,7 +470,7 @@ Entity::GetMoveTriangleId() const
 
 
 void
-Entity::SetMoveAutoRotation( const bool rotate )
+Entity::SetMoveAutoRotation(const bool rotate)
 {
     m_MoveAutoRotation = rotate;
 }
@@ -484,7 +484,7 @@ Entity::GetMoveAutoRotation() const
 
 
 void
-Entity::SetMoveAutoAnimation( const bool animate )
+Entity::SetMoveAutoAnimation(const bool animate)
 {
     m_MoveAutoAnimation = animate;
 }
@@ -512,26 +512,26 @@ Entity::GetMoveAnimationRunName() const
 
 
 void
-Entity::ScriptMoveToPosition( const float x, const float y )
+Entity::ScriptMoveToPosition(const float x, const float y)
 {
     m_State = Entity::WALKMESH;
 
-    m_MovePosition = Ogre::Vector3( x, y, 0 );
+    m_MovePosition = Ogre::Vector3(x, y, 0);
     m_MoveEntity = NULL;
     m_MoveStopDistance = 0;
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set move to walkmesh position \"" + Ogre::StringConverter::toString( m_MovePosition ) + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" set move to walkmesh position \"" + Ogre::StringConverter::toString(m_MovePosition) + "\".");
 }
 
 
 void
-Entity::ScriptMoveToEntity( Entity* entity )
+Entity::ScriptMoveToEntity(Entity* entity)
 {
     m_State = Entity::WALKMESH;
 
     m_MovePosition = entity->GetPosition();
     m_MoveEntity = entity;
     m_MoveStopDistance = GetSolidRadius() + entity->GetSolidRadius();
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set move to entity \"" + entity->GetName() + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" set move to entity \"" + entity->GetName() + "\".");
 }
 
 
@@ -540,9 +540,9 @@ Entity::ScriptMoveSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" move for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" move for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_Sync.push_back( script );
+    m_Sync.push_back(script);
     return -1;
 }
 
@@ -555,21 +555,21 @@ Entity::UnsetMove()
     m_MoveEntity = NULL;
     m_MoveStopDistance = 0;
 
-    for( size_t i = 0; i < m_Sync.size(); ++i)
+    for(size_t i = 0; i < m_Sync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_Sync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_Sync[i]);
     }
     m_Sync.clear();
 }
 
 
 void
-Entity::ScriptLinearToPosition( const float x, const float y, const float z, const LinearMovement movement, const char* animation )
+Entity::ScriptLinearToPosition(const float x, const float y, const float z, const LinearMovement movement, const char* animation)
 {
-    Ogre::Vector3 pos = Ogre::Vector3( x, y, z );
-    SetLinear( pos, movement, animation );
+    Ogre::Vector3 pos = Ogre::Vector3(x, y, z);
+    SetLinear(pos, movement, animation);
 
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set linear move to position \"" + Ogre::StringConverter::toString( pos ) + "\" with animation \"" + animation + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" set linear move to position \"" + Ogre::StringConverter::toString(pos) + "\" with animation \"" + animation + "\".");
 }
 
 
@@ -578,15 +578,15 @@ Entity::ScriptLinearSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" linear move for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" linear move for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_Sync.push_back( script );
+    m_Sync.push_back(script);
     return -1;
 }
 
 
 void
-Entity::SetLinear( const Ogre::Vector3& end, const LinearMovement movement, const Ogre::String& animation )
+Entity::SetLinear(const Ogre::Vector3& end, const LinearMovement movement, const Ogre::String& animation)
 {
     m_State = Entity::LINEAR;
     m_LinearMovement = movement;
@@ -595,7 +595,7 @@ Entity::SetLinear( const Ogre::Vector3& end, const LinearMovement movement, cons
 
     // linear animation
     m_AnimationAutoPlay = false;
-    PlayAnimation( animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1 );
+    PlayAnimation(animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
 
     // after move we need reattach entity to walkmesh
     m_MoveTriangleId = -1;
@@ -608,11 +608,11 @@ Entity::UnsetLinear()
     m_State = Entity::NONE;
 
     m_AnimationAutoPlay = true;
-    PlayAnimation( m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1 );
+    PlayAnimation(m_AnimationDefault, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
 
-    for( size_t i = 0; i < m_Sync.size(); ++i)
+    for(size_t i = 0; i < m_Sync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_Sync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_Sync[i]);
     }
     m_Sync.clear();
 }
@@ -640,12 +640,12 @@ Entity::GetLinearEnd() const
 
 
 void
-Entity::ScriptJumpToPosition( const float x, const float y, const float z, const float seconds )
+Entity::ScriptJumpToPosition(const float x, const float y, const float z, const float seconds)
 {
-    Ogre::Vector3 jump_to( x, y, z );
-    SetJump( jump_to, seconds );
+    Ogre::Vector3 jump_to(x, y, z);
+    SetJump(jump_to, seconds);
 
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set jump to position \"" + Ogre::StringConverter::toString( jump_to ) + "\" in " + Ogre::StringConverter::toString( seconds ) + " seconds." );
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" set jump to position \"" + Ogre::StringConverter::toString(jump_to) + "\" in " + Ogre::StringConverter::toString(seconds) + " seconds.");
 }
 
 
@@ -654,15 +654,15 @@ Entity::ScriptJumpSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" jump for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" jump for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_Sync.push_back( script );
+    m_Sync.push_back(script);
     return -1;
 }
 
 
 void
-Entity::SetJump( const Ogre::Vector3& jump_to, const float seconds )
+Entity::SetJump(const Ogre::Vector3& jump_to, const float seconds)
 {
     m_State = Entity::JUMP;
     m_JumpStart = GetPosition();
@@ -680,9 +680,9 @@ Entity::UnsetJump()
 {
     m_State = Entity::NONE;
 
-    for( size_t i = 0; i < m_Sync.size(); ++i)
+    for(size_t i = 0; i < m_Sync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_Sync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_Sync[i]);
     }
     m_Sync.clear();
 }
@@ -710,7 +710,7 @@ Entity::GetJumpSeconds() const
 
 
 void
-Entity::SetJumpCurrentSeconds( const float seconds )
+Entity::SetJumpCurrentSeconds(const float seconds)
 {
     m_JumpCurrentSeconds = seconds;
 }
@@ -724,15 +724,15 @@ Entity::GetJumpCurrentSeconds() const
 
 
 void
-Entity::ScriptOffsetToPosition( const float x, const float y, const float z, const ActionType type, const float seconds )
+Entity::ScriptOffsetToPosition(const float x, const float y, const float z, const ActionType type, const float seconds)
 {
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set offset to position \"" + Ogre::StringConverter::toString( Ogre::Vector3( x, y, z ) ) + "'." );
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" set offset to position \"" + Ogre::StringConverter::toString(Ogre::Vector3(x, y, z)) + "'.");
 
-    Ogre::Vector3 position = Ogre::Vector3( x, y, z );
+    Ogre::Vector3 position = Ogre::Vector3(x, y, z);
 
-    if( type == AT_NONE )
+    if(type == AT_NONE)
     {
-        this->SetOffset( position );
+        this->SetOffset(position);
         return;
     }
 
@@ -749,9 +749,9 @@ Entity::ScriptOffsetSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" offset for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" offset for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_OffsetSync.push_back( script );
+    m_OffsetSync.push_back(script);
     return -1;
 }
 
@@ -761,9 +761,9 @@ Entity::UnsetOffset()
 {
     m_OffsetType = AT_NONE;
 
-    for( unsigned int i = 0; i < m_OffsetSync.size(); ++i )
+    for(unsigned int i = 0; i < m_OffsetSync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_OffsetSync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_OffsetSync[i]);
     }
     m_OffsetSync.clear();
 }
@@ -798,7 +798,7 @@ Entity::GetOffsetSeconds() const
 
 
 void
-Entity::SetOffsetCurrentSeconds( const float seconds )
+Entity::SetOffsetCurrentSeconds(const float seconds)
 {
     m_OffsetCurrentSeconds = seconds;
 }
@@ -812,25 +812,25 @@ Entity::GetOffsetCurrentSeconds() const
 
 
 void
-Entity::ScriptTurnToDirection( const float direction, const TurnDirection turn_direction, const ActionType turn_type, const float seconds )
+Entity::ScriptTurnToDirection(const float direction, const TurnDirection turn_direction, const ActionType turn_type, const float seconds)
 {
-    SetTurn( Ogre::Degree( direction ), NULL, turn_direction, turn_type, seconds );
-    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" turn to angle \"" + Ogre::StringConverter::toString( direction ) + "\".");
+    SetTurn(Ogre::Degree(direction), NULL, turn_direction, turn_type, seconds);
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" turn to angle \"" + Ogre::StringConverter::toString(direction) + "\".");
 }
 
 
 void
-Entity::ScriptTurnToEntity( Entity* entity, const TurnDirection turn_direction, const float seconds )
+Entity::ScriptTurnToEntity(Entity* entity, const TurnDirection turn_direction, const float seconds)
 {
-    if( entity == NULL || entity == this )
+    if(entity == NULL || entity == this)
     {
         LOG_ERROR("[SCRIPT] Turn to entity: Invalid entity pointer (NUUL or this).");
         return;
     }
 
-    Ogre::Degree angle = GetDirectionToEntity( entity );
-    SetTurn( angle, entity, turn_direction, AT_SMOOTH, seconds );
-    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" turn to entity \"" + entity->GetName() + ".");
+    Ogre::Degree angle = GetDirectionToEntity(entity);
+    SetTurn(angle, entity, turn_direction, AT_SMOOTH, seconds);
+    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" turn to entity \"" + entity->GetName() + ".");
 }
 
 
@@ -839,26 +839,26 @@ Entity::ScriptTurnSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" turn for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" turn for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_TurnSync.push_back( script );
+    m_TurnSync.push_back(script);
     return -1;
 }
 
 
 void
-Entity::SetTurn( const Ogre::Degree& direction_to, Entity* entity, const TurnDirection turn_direction, const ActionType turn_type, const float seconds )
+Entity::SetTurn(const Ogre::Degree& direction_to, Entity* entity, const TurnDirection turn_direction, const ActionType turn_type, const float seconds)
 {
-    if( turn_type == AT_NONE )
+    if(turn_type == AT_NONE)
     {
-        SetRotation( direction_to );
+        SetRotation(direction_to);
         return;
     }
 
     m_TurnDirection = turn_direction;
 
     Ogre::Degree angle_start = GetRotation();
-    Ogre::Degree angle_end = CalculateTurnAngle( angle_start, direction_to );
+    Ogre::Degree angle_end = CalculateTurnAngle(angle_start, direction_to);
 
     m_TurnEntity = entity;
     m_TurnDirectionStart = angle_start;
@@ -874,35 +874,35 @@ Entity::UnsetTurn()
 {
     m_TurnType = AT_NONE;
 
-    for( unsigned int i = 0; i < m_TurnSync.size(); ++i )
+    for(unsigned int i = 0; i < m_TurnSync.size(); ++i)
     {
-        ScriptManager::getSingleton().ContinueScriptExecution( m_TurnSync[ i ] );
+        ScriptManager::getSingleton().ContinueScriptExecution(m_TurnSync[i]);
     }
     m_TurnSync.clear();
 }
 
 
 Ogre::Degree
-Entity::CalculateTurnAngle( const Ogre::Degree& start, const Ogre::Degree& end ) const
+Entity::CalculateTurnAngle(const Ogre::Degree& start, const Ogre::Degree& end) const
 {
     Ogre::Degree ret = end;
 
-    switch( m_TurnDirection )
+    switch(m_TurnDirection)
     {
         case TD_CLOCKWISE:
         {
-            if( end <= start )
+            if(end <= start)
             {
-                ret = end + Ogre::Degree( 360 );
+                ret = end + Ogre::Degree(360);
             }
         }
         break;
 
         case TD_ANTICLOCKWISE:
         {
-            if( end >= start )
+            if(end >= start)
             {
-                ret = end - Ogre::Degree( 360 );
+                ret = end - Ogre::Degree(360);
             }
         }
         break;
@@ -911,17 +911,17 @@ Entity::CalculateTurnAngle( const Ogre::Degree& start, const Ogre::Degree& end )
         {
             Ogre::Degree delta = end - start;
 
-            delta = ( delta < Ogre::Degree( 0 ) ) ? -delta : delta;
+            delta = (delta < Ogre::Degree(0)) ? -delta : delta;
 
-            if( delta > Ogre::Degree( 180 ) )
+            if(delta > Ogre::Degree(180))
             {
-                if( start < end )
+                if(start < end)
                 {
-                    ret = end - Ogre::Degree( 360 );
+                    ret = end - Ogre::Degree(360);
                 }
                 else
                 {
-                    ret = end + Ogre::Degree( 360 );
+                    ret = end + Ogre::Degree(360);
                 }
             }
         }
@@ -961,7 +961,7 @@ Entity::GetTurnSeconds() const
 
 
 void
-Entity::SetTurnCurrentSeconds( const float seconds )
+Entity::SetTurnCurrentSeconds(const float seconds)
 {
     m_TurnCurrentSeconds = seconds;
 }
@@ -975,7 +975,7 @@ Entity::GetTurnCurrentSeconds() const
 
 
 void
-Entity::ScriptSetAnimationSpeed( const float speed )
+Entity::ScriptSetAnimationSpeed(const float speed)
 {
     m_AnimationSpeed = speed;
 }
@@ -1003,37 +1003,37 @@ Entity::GetAnimationState() const
 
 
 void
-Entity::ScriptPlayAnimation( const char* name )
+Entity::ScriptPlayAnimation(const char* name)
 {
-    PlayAnimation( Ogre::String( name ), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, 0, -1 );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, 0, -1);
 }
 
 
 void
-Entity::ScriptPlayAnimationStop( const char* name )
+Entity::ScriptPlayAnimationStop(const char* name)
 {
-    PlayAnimation( Ogre::String( name ), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, 0, -1 );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, 0, -1);
 }
 
 
 void
-Entity::ScriptPlayAnimation( const char* name, const float start, const float end )
+Entity::ScriptPlayAnimation(const char* name, const float start, const float end)
 {
-    PlayAnimation( Ogre::String( name ), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, start, end );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, start, end);
 }
 
 
 void
-Entity::ScriptPlayAnimationStop( const char* name, const float start, const float end )
+Entity::ScriptPlayAnimationStop(const char* name, const float start, const float end)
 {
-    PlayAnimation( Ogre::String( name ), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, start, end );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, start, end);
 }
 
 
 void
-Entity::ScriptSetDefaultAnimation( const char* animation )
+Entity::ScriptSetDefaultAnimation(const char* animation)
 {
-    m_AnimationDefault = Ogre::String( animation );
+    m_AnimationDefault = Ogre::String(animation);
 }
 
 
@@ -1042,22 +1042,22 @@ Entity::ScriptAnimationSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
 
-    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" animation for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );
+    LOG_TRIVIAL("[SCRIPT] Wait entity \"" + m_Name + "\" animation for function \"" + script.function + "\" in script entity \"" + script.entity + "\".");
 
-    m_AnimationSync.push_back( script );
+    m_AnimationSync.push_back(script);
     return -1;
 }
 
 
 Ogre::Degree
-Entity::GetDirectionToEntity( Entity* entity ) const
+Entity::GetDirectionToEntity(Entity* entity) const
 {
     Ogre::Vector3 current_point = GetPosition();
     Ogre::Vector3 direction_point = entity->GetPosition();
 
     Ogre::Vector2 up(0.0f, -1.0f);
-    Ogre::Vector2 dir( direction_point.x - current_point.x, direction_point.y - current_point.y );
+    Ogre::Vector2 dir(direction_point.x - current_point.x, direction_point.y - current_point.y);
     // angle between vectors
-    Ogre::Degree angle( Ogre::Radian( acosf( dir.dotProduct( up ) / ( dir.length() * up.length() ) ) ) );
-    return ( dir.x < 0 ) ? Ogre::Degree( 360 ) - angle : angle;
+    Ogre::Degree angle(Ogre::Radian(acosf(dir.dotProduct(up) / (dir.length() * up.length()))));
+    return (dir.x < 0) ? Ogre::Degree(360) - angle : angle;
 }

+ 7 - 7
QGearsMain/src/core/EntityCollision.cpp

@@ -16,14 +16,14 @@ EntityCollision::EntityCollision()
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     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(
-            decl->getVertexSize( 0 ),
+            decl->getVertexSize(0),
             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++ =  1.0f;
@@ -116,7 +116,7 @@ EntityCollision::EntityCollision()
 
     Ogre::AxisAlignedBox aabb;
     aabb.setInfinite();
-    setBoundingBox( aabb );
+    setBoundingBox(aabb);
 }
 
 
@@ -127,7 +127,7 @@ EntityCollision::~EntityCollision()
 
 
 Ogre::Real
-EntityCollision::getSquaredViewDepth( const Ogre::Camera* cam ) const
+EntityCollision::getSquaredViewDepth(const Ogre::Camera* cam) const
 {
     return 0.0f;
 }

+ 7 - 7
QGearsMain/src/core/EntityDirection.cpp

@@ -16,14 +16,14 @@ EntityDirection::EntityDirection()
     Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
     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(
-            decl->getVertexSize( 0 ),
+            decl->getVertexSize(0),
             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++ = -1.0f; *pPos++ = 0.0f;
@@ -32,7 +32,7 @@ EntityDirection::EntityDirection()
 
     Ogre::AxisAlignedBox aabb;
     aabb.setInfinite();
-    setBoundingBox( aabb );
+    setBoundingBox(aabb);
 }
 
 
@@ -43,7 +43,7 @@ EntityDirection::~EntityDirection()
 
 
 Ogre::Real
-EntityDirection::getSquaredViewDepth( const Ogre::Camera* cam ) const
+EntityDirection::getSquaredViewDepth(const Ogre::Camera* cam) const
 {
     return 0.0f;
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 252 - 249
QGearsMain/src/core/EntityManager.cpp


+ 45 - 45
QGearsMain/src/core/EntityModel.cpp

@@ -6,33 +6,33 @@
 #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(NULL)
 {
     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()
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->destroyEntity( m_Model );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(m_Model);
 }
 
 
 void
 EntityModel::Update()
 {
-    if( m_AnimationAutoPlay == true )
+    if(m_AnimationAutoPlay == true)
     {
-        UpdateAnimation( Timer::getSingleton().GetGameTimeDelta() );
+        UpdateAnimation(Timer::getSingleton().GetGameTimeDelta());
     }
 
     Entity::Update();
@@ -40,9 +40,9 @@ EntityModel::Update()
 
 
 void
-EntityModel::SetVisible( const bool visible )
+EntityModel::SetVisible(const bool visible)
 {
-    m_Model->setVisible( visible );
+    m_Model->setVisible(visible);
 }
 
 
@@ -54,79 +54,79 @@ EntityModel::IsVisible() const
 
 
 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 != NULL)
     {
-        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_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_AnimationPlayType = play_type;
     }
     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
-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 == 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
     {
-        PlayAnimation( animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1 );
+        PlayAnimation(animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
     }
 }
 
 
 void
-EntityModel::UpdateAnimation( const float delta )
+EntityModel::UpdateAnimation(const float delta)
 {
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != NULL)
     {
         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();
 
-            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
         {
-            m_AnimationCurrent->addTime( delta_mod );
+            m_AnimationCurrent->addTime(delta_mod);
         }
     }
 }

+ 16 - 16
QGearsMain/src/core/EntityPoint.cpp

@@ -4,13 +4,13 @@
 #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)
 {
 }
 
@@ -23,17 +23,17 @@ EntityPoint::~EntityPoint()
 void
 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;
         point1.z += 0.5f;
         Ogre::Vector3 point2 = m_Position;
         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);
     }
 }
 
@@ -46,7 +46,7 @@ EntityPoint::GetName() const
 
 
 void
-EntityPoint::SetPosition( const Ogre::Vector3& point )
+EntityPoint::SetPosition(const Ogre::Vector3& point)
 {
     m_Position = point;
 
@@ -63,14 +63,14 @@ EntityPoint::GetPosition() const
 void
 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
-EntityPoint::SetRotation( const float rotation )
+EntityPoint::SetRotation(const float rotation)
 {
     m_Rotation = rotation;
 }

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

@@ -1,18 +1,17 @@
-
 #include "core/DebugDraw.h"
 #include "core/Entity.h"
 #include "core/EntityTrigger.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_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)
 {
 }
 
@@ -25,35 +24,35 @@ EntityTrigger::~EntityTrigger()
 void
 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
         {
-            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());
         }
     }
 }
@@ -67,11 +66,11 @@ EntityTrigger::GetName() const
 
 
 void
-EntityTrigger::SetEnabled( const bool enabled )
+EntityTrigger::SetEnabled(const bool enabled)
 {
     m_Enabled = enabled;
 
-    if( enabled == false )
+    if(enabled == false)
     {
         m_Activators.clear();
     }
@@ -86,32 +85,32 @@ EntityTrigger::IsEnabled() const
 
 
 void
-EntityTrigger::AddActivator( Entity* activator )
+EntityTrigger::AddActivator(Entity* activator)
 {
     // add only if this activator don't exist
     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;
         }
     }
-    if( i == m_Activators.size() )
+    if(i == m_Activators.size())
     {
-        m_Activators.push_back( activator );
+        m_Activators.push_back(activator);
     }
 }
 
 
 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;
         }
     }
@@ -119,11 +118,11 @@ EntityTrigger::RemoveActivator( Entity* activator )
 
 
 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;
         }
@@ -134,7 +133,7 @@ EntityTrigger::IsActivator( Entity* activator )
 
 
 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_Point2 = point2;

+ 62 - 62
QGearsMain/src/core/GameFrameListner.cpp

@@ -14,75 +14,75 @@
 #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;
     size_t windowHnd = 0;
     std::ostringstream windowHndStr;
 
-    win->getCustomAttribute( "WINDOW", &windowHnd );
+    win->getCustomAttribute("WINDOW", &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__
-    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
-    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
 
-    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
-    Ogre::WindowEventUtilities::addWindowEventListener( m_Window, this );
+    Ogre::WindowEventUtilities::addWindowEventListener(m_Window, this);
 }
 
 
 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
-    Ogre::WindowEventUtilities::removeWindowEventListener( m_Window, this );
-    windowClosed( m_Window );
+    Ogre::WindowEventUtilities::removeWindowEventListener(m_Window, this);
+    windowClosed(m_Window);
 }
 
 
 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;
     }
 
-    if( m_Keyboard )
+    if(m_Keyboard)
     {
        m_Keyboard->capture();
     }
 
-    if( m_Mouse )
+    if(m_Mouse)
     {
        m_Mouse->capture();
     }
@@ -92,25 +92,25 @@ GameFrameListener::frameStarted( const Ogre::FrameEvent& evt )
     static InputEventArray input_event_array;
     input_event_array.clear();
 
-    InputManager::getSingleton().GetInputEvents( input_event_array );
+    InputManager::getSingleton().GetInputEvents(input_event_array);
 
     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();
 
-    ScriptManager::getSingleton().Update( ScriptManager::SYSTEM );
+    ScriptManager::getSingleton().Update(ScriptManager::SYSTEM);
     UiManager::getSingleton().Update();
     CameraManager::getSingleton().Update();
     EntityManager::getSingleton().Update();
@@ -120,15 +120,15 @@ GameFrameListener::frameStarted( const Ogre::FrameEvent& evt )
 
 
 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();
-        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;
@@ -136,19 +136,19 @@ GameFrameListener::frameEnded( const Ogre::FrameEvent& evt )
 
 
 void
-GameFrameListener::windowMoved( Ogre::RenderWindow* rw )
+GameFrameListener::windowMoved(Ogre::RenderWindow* rw)
 {
 }
 
 
 void
-GameFrameListener::windowResized( Ogre::RenderWindow *rw )
+GameFrameListener::windowResized(Ogre::RenderWindow *rw)
 {
-    if( m_Mouse )
+    if(m_Mouse)
     {
         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();
@@ -159,46 +159,46 @@ GameFrameListener::windowResized( Ogre::RenderWindow *rw )
 
 
 void
-GameFrameListener::windowClosed( Ogre::RenderWindow* rw )
+GameFrameListener::windowClosed(Ogre::RenderWindow* rw)
 {
     QGears::g_ApplicationState = QGears::G_EXIT;
 }
 
 
 void
-GameFrameListener::windowFocusChange( Ogre::RenderWindow* rw )
+GameFrameListener::windowFocusChange(Ogre::RenderWindow* rw)
 {
 }
 
 
 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;
 }
 
 
 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;
 }
 
 
 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
     {
-        InputManager::getSingleton().MouseMoved( e.state.X.rel, e.state.Y.rel );
+        InputManager::getSingleton().MouseMoved(e.state.X.rel, e.state.Y.rel);
     }
 
     return true;
@@ -206,18 +206,18 @@ GameFrameListener::mouseMoved( const OIS::MouseEvent& e )
 
 
 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;
 }
 
 
 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;
 }

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

@@ -6,12 +6,12 @@
 #include "core/Timer.h"
 
 
-template<>InputManager *Ogre::Singleton< InputManager >::msSingleton = NULL;
+template<>InputManager *Ogre::Singleton<InputManager>::msSingleton = NULL;
 
 
 InputManager::InputManager():
-    m_RepeatFirstWait( true ),
-    m_RepeatTimer( 0 )
+    m_RepeatFirstWait(true),
+    m_RepeatTimer(0)
 {
     InitCmd();
 
@@ -27,20 +27,20 @@ InputManager::~InputManager()
 void
 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
-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)));
 
@@ -48,29 +48,29 @@ InputManager::ButtonPressed( int button, char text, bool down )
         m_RepeatTimer = 0;
     }
 
-    if( down == true && Console::getSingleton().IsVisible() != true )
+    if(down == true && Console::getSingleton().IsVisible() != true)
     {
-        ActivateBinds( button );
+        ActivateBinds(button);
     }
 }
 
 
 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));
 }
 
 
 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)));
 }
 
 
 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));
 }
@@ -81,11 +81,11 @@ InputManager::Update()
 {
     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])));
             }
@@ -96,9 +96,9 @@ InputManager::Update()
     }
 
     // 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])));
         }
@@ -107,14 +107,14 @@ InputManager::Update()
 
 
 bool
-InputManager::IsButtonPressed( int button ) const
+InputManager::IsButtonPressed(int button) const
 {
-    return m_ButtonState[ button ];
+    return m_ButtonState[button];
 }
 
 
 void
-InputManager::GetInputEvents( InputEventArray& input_events )
+InputManager::GetInputEvents(InputEventArray& input_events)
 {
     input_events = m_EventQueue;
 
@@ -123,68 +123,68 @@ InputManager::GetInputEvents( InputEventArray& input_events )
 
 
 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
-InputManager::ActivateBinds( int button )
+InputManager::ActivateBinds(int button)
 {
     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( 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;
-            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;
                 }
             }
 
-            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;
     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.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
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params[ 0 ] );
-        if( cmd != NULL )
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+        if(cmd != NULL)
         {
-            cmd->GetHandler()( params );
+            cmd->GetHandler()(params);
         }
         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 + "\".");
         }
     }
 }

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

@@ -10,47 +10,47 @@
 #include "LuaIncludes.h"
 
 
-ConfigVar cv_debug_script( "debug_script", "Debug script flags. 0x01 - System, 0x02 - Entity, 0x04 - Ui.", "0" );
-template<>ScriptManager *Ogre::Singleton< ScriptManager >::msSingleton = NULL;
-Ogre::String script_entity_type[] = { "SYSTEM", "ENTITY", "UI" };
+ConfigVar cv_debug_script("debug_script", "Debug script flags. 0x01 - System, 0x02 - Entity, 0x04 - Ui.", "0");
+template<>ScriptManager *Ogre::Singleton<ScriptManager>::msSingleton = NULL;
+Ogre::String script_entity_type[] = {"SYSTEM", "ENTITY", "UI"};
 
 
 bool
-priority_queue_compare( QueueScript a, QueueScript b )
+priority_queue_compare(QueueScript a, QueueScript b)
 {
     return a.priority < b.priority;
 }
 
 
 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();
-    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();
     InitCmd();
 
-    RunFile( "system/system.lua" );
+    RunFile("system/system.lua");
 
-    XmlScriptsFile scripts( "./data/scripts.xml" );
+    XmlScriptsFile scripts("./data/scripts.xml");
     scripts.LoadScripts();
 }
 
 
 ScriptManager::~ScriptManager()
 {
-    lua_close( m_LuaState );
+    lua_close(m_LuaState);
 
-    LOG_TRIVIAL( "ScriptManager closed." );
+    LOG_TRIVIAL("ScriptManager closed.");
 }
 
 
@@ -67,9 +67,9 @@ ScriptManager::Input(const QGears::Event& event)
                                         event.param1 == OIS::KC_RIGHT ||
                                         event.param1 == OIS::KC_DOWN ||
                                         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 = "";
             if (event.type == QGears::ET_KEY_PRESS)
@@ -80,26 +80,26 @@ ScriptManager::Input(const QGears::Event& event)
             {
                 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
-ScriptManager::Update( const ScriptManager::Type type )
+ScriptManager::Update(const ScriptManager::Type type)
 {
     // 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;
                 }
             }
         }
@@ -107,54 +107,54 @@ ScriptManager::Update( const ScriptManager::Type type )
 
     // draw debug before update. This way it will be posible to see scripts that run once
     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;
 
-        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;
 
-                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 += ": ";
-                            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
                         {
-                            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 += "(" + 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;
                     }
                 }
@@ -162,117 +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;
 
                             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
                             {
-                                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
                         {
-                            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
                     {
-                        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;
 
                         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
-                            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
                         {
-                            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;
                     }
                 }
             }
@@ -282,99 +282,99 @@ ScriptManager::Update( const ScriptManager::Type type )
 
 
 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
-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
-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;
         }
     }
 
-    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;
         script_entity.name = entity_name;
         script_entity.type = type;
 
         // init entity field for model entity
-        if( entity != NULL )
+        if(entity != NULL)
         {
-            table[ "entity" ] = boost::ref( *entity );
+            table["entity"] = boost::ref(*entity);
         }
 
         // check "on_start" script
-        if( luabind::type( table[ "on_start" ] ) == LUA_TFUNCTION )
+        if(luabind::type(table["on_start"]) == LUA_TFUNCTION)
         {
             QueueScript script;
             script.function = "on_start";
             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
-            script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
             script.seconds_to_wait = 0;
             script.wait = false;
             script.yield = false;
-            script_entity.queue.push_back( script );
+            script_entity.queue.push_back(script);
         }
 
         // check "on_update" script
-        if( luabind::type( table[ "on_update" ] ) == LUA_TFUNCTION )
+        if(luabind::type(table["on_update"]) == LUA_TFUNCTION)
         {
             QueueScript script;
             script.function = "on_update";
             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
-            script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
             script.seconds_to_wait = 0;
             script.wait = 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
-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;
         }
@@ -383,47 +383,47 @@ ScriptManager::RemoveEntity( const ScriptManager::Type type, const Ogre::String&
 
 
 void
-ScriptManager::RemoveEntityTopScript( ScriptEntity& entity )
+ScriptManager::RemoveEntityTopScript(ScriptEntity& entity)
 {
-    if( entity.queue.size() > 0 )
+    if(entity.queue.size() > 0)
     {
         // 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
-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
-    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();
     }
 
-    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();
         }
@@ -434,17 +434,17 @@ ScriptManager::GetTableByEntityName( const ScriptManager::Type type, const Ogre:
 
 
 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]);
                 }
             }
 
@@ -457,13 +457,13 @@ ScriptManager::GetScriptByScriptId( const ScriptId& script ) const
 
 
 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]);
         }
     }
 
@@ -479,13 +479,13 @@ ScriptManager::GetCurrentScriptId() const
 
 
 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 == NULL)
     {
-        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;
     }
 
@@ -494,19 +494,19 @@ ScriptManager::ContinueScriptExecution( const ScriptId& script )
 
 
 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 == NULL)
     {
-        LOG_ERROR( "script:wait: Currently no any script running." );
+        LOG_ERROR("script:wait: Currently no any script running.");
         return 1;
     }
 
-    if( seconds == 0 )
+    if(seconds == 0)
     {
         return 1;
     }
@@ -518,45 +518,45 @@ ScriptManager::ScriptWait( const float seconds )
 
 
 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 == NULL)
     {
-        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;
     }
 
-    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
-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 == NULL)
     {
-        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;
     }
 
-    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;
     }
 
@@ -565,23 +565,23 @@ ScriptManager::ScriptRequestStartSync( const Type type, const char* entity, cons
 
 
 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 == NULL)
     {
-        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;
     }
 
-    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;
     }
 
@@ -590,31 +590,31 @@ ScriptManager::ScriptRequestEndSync( const Type type, const char* entity, const
 
 
 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;
         script.function = function;
         script.argument1 = argument1;
         script.argument2 = argument2;
         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
-        script.state_id = luaL_ref( m_LuaState, LUA_REGISTRYINDEX );
+        script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
         script.seconds_to_wait = 0;
         script.wait = false;
         script.yield = false;
-        if( start_sync == true )
+        if(start_sync == true)
         {
             script.paused_script_start = GetCurrentScriptId();
         }
-        if( end_sync == true )
+        if(end_sync == true)
         {
             script.paused_script_end = GetCurrentScriptId();
         }
-        script_entity->queue.push_back( script );
+        script_entity->queue.push_back(script);
         script_entity->resort = true;
 
         return true;
@@ -625,11 +625,11 @@ ScriptManager::ScriptRequest( ScriptEntity* script_entity, const Ogre::String& f
 
 
 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 != NULL)
     {
-        lua_pushnumber( script->state, value );
+        lua_pushnumber(script->state, value);
     }
 }

+ 7 - 7
QGearsMain/src/core/Timer.cpp

@@ -2,15 +2,15 @@
 #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 = NULL;
 
 
 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)
 {
 }
 
@@ -44,7 +44,7 @@ Timer::GetGameTimeDelta()
 
 
 void
-Timer::AddTime( float time )
+Timer::AddTime(float time)
 {
     m_SystemTimeDelta = time;
     m_SystemTimeTotal += m_SystemTimeDelta;

+ 79 - 79
QGearsMain/src/core/UiAnimation.cpp

@@ -4,11 +4,11 @@
 #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)
 {
 }
 
@@ -19,193 +19,193 @@ UiAnimation::~UiAnimation()
 
 
 void
-UiAnimation::AddTime( const float time )
+UiAnimation::AddTime(const float time)
 {
     m_Time += time;
-    if( m_Time > m_Length )
+    if(m_Time > m_Length)
     {
         m_Time = m_Length;
     }
 
     // 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;
         float min = 0;
         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;
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
             value = min_value;
         }
         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;
         float min = 0;
         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;
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
             value = min_value;
         }
         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;
         float min = 0;
         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;
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
             value = min_value;
         }
         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 min = 0;
         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;
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
             value = min_value;
         }
         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 min = 0;
         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;
 
-        if( m_Time == 0 )
+        if(m_Time == 0)
         {
             value = min_value;
         }
         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);
     }
 }
 
@@ -218,7 +218,7 @@ UiAnimation::GetName() const
 
 
 void
-UiAnimation::SetTime( const float time )
+UiAnimation::SetTime(const float time)
 {
     m_Time = time;
 }
@@ -232,7 +232,7 @@ UiAnimation::GetTime() const
 
 
 void
-UiAnimation::SetLength( const float time )
+UiAnimation::SetLength(const float time)
 {
     m_Length = time;
 }
@@ -246,35 +246,35 @@ UiAnimation::GetLength() const
 
 
 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
-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
-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
-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
-UiAnimation::AddAlphaKeyFrame( const UiKeyFrameFloat& key_frame )
+UiAnimation::AddAlphaKeyFrame(const UiKeyFrameFloat& key_frame)
 {
-    m_Alpha.push_back( key_frame );
+    m_Alpha.push_back(key_frame);
 }

+ 15 - 15
QGearsMain/src/core/UiFont.cpp

@@ -2,12 +2,12 @@
 #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)
 {
 }
 
@@ -25,7 +25,7 @@ UiFont::GetName() const
 
 
 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_ImageWidth = width;
@@ -55,7 +55,7 @@ UiFont::GetImageHeight() const
 
 
 void
-UiFont::SetHeight( const int height )
+UiFont::SetHeight(const int height)
 {
     m_Height = height;
 }
@@ -69,24 +69,24 @@ UiFont::GetHeight() const
 
 
 void
-UiFont::AddCharData( const UiCharData& data )
+UiFont::AddCharData(const UiCharData& data)
 {
-    m_CharData.push_back( data );
+    m_CharData.push_back(data);
 }
 
 
 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 = {};
     return ret;
 }

+ 55 - 55
QGearsMain/src/core/UiManager.cpp

@@ -11,29 +11,29 @@
 #include "core/XmlTextsFile.h"
 
 
-template<>UiManager *Ogre::Singleton< UiManager >::msSingleton = NULL;
+template<>UiManager *Ogre::Singleton<UiManager>::msSingleton = NULL;
 
 
 UiManager::UiManager()
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->addRenderQueueListener( this );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->addRenderQueueListener(this);
 }
 
 
 UiManager::~UiManager()
 {
-    Ogre::Root::getSingleton().getSceneManager( "Scene" )->removeRenderQueueListener( this );
+    Ogre::Root::getSingleton().getSceneManager("Scene")->removeRenderQueueListener(this);
 
     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];
     }
 }
 
@@ -41,13 +41,13 @@ UiManager::~UiManager()
 void
 UiManager::Initialise()
 {
-    XmlFontsFile fonts( "./data/fonts.xml" );
+    XmlFontsFile fonts("./data/fonts.xml");
     fonts.LoadFonts();
 
-    XmlPrototypesFile prototypes( "./data/screens/prototypes.xml" );
+    XmlPrototypesFile prototypes("./data/screens/prototypes.xml");
     prototypes.LoadPrototypes();
 
-    XmlScreensFile screens( "./data/screens.xml" );
+    XmlScreensFile screens("./data/screens.xml");
     screens.LoadScreens();
 }
 
@@ -56,10 +56,10 @@ void
 UiManager::Update()
 {
     // 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();
     }
 }
 
@@ -67,52 +67,52 @@ UiManager::Update()
 void
 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
-UiManager::SetLanguage( const Ogre::String& language )
+UiManager::SetLanguage(const Ogre::String& language)
 {
     UnloadTexts();
 
-    XmlTextsFile texts( "./data/texts.xml" );
-    texts.LoadTexts( language );
+    XmlTextsFile texts("./data/texts.xml");
+    texts.LoadTexts(language);
 }
 
 
 void
-UiManager::AddText( const Ogre::String& name, TiXmlNode* text )
+UiManager::AddText(const Ogre::String& name, TiXmlNode* text)
 {
     UiText ui_text;
     ui_text.name = name;
     ui_text.node = text;
-    m_Texts.push_back( ui_text );
+    m_Texts.push_back(ui_text);
 }
 
 
 void
 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();
 }
 
 
 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;
         }
     }
 
@@ -121,20 +121,20 @@ UiManager::GetText( const Ogre::String& name ) const
 
 
 void
-UiManager::AddFont( UiFont* font )
+UiManager::AddFont(UiFont* font)
 {
-    m_Fonts.push_back( font );
+    m_Fonts.push_back(font);
 }
 
 
 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];
         }
     }
 
@@ -143,23 +143,23 @@ UiManager::GetFont( const Ogre::String& name )
 
 
 void
-UiManager::AddPrototype( const Ogre::String& name, TiXmlNode* prototype )
+UiManager::AddPrototype(const Ogre::String& name, TiXmlNode* prototype)
 {
     UiPrototype ui_prototype;
     ui_prototype.name = name;
     ui_prototype.node = prototype;
-    m_Prototypes.push_back( ui_prototype );
+    m_Prototypes.push_back(ui_prototype);
 }
 
 
 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;
         }
     }
 
@@ -168,30 +168,30 @@ UiManager::GetPrototype( const Ogre::String& name ) const
 
 
 void
-UiManager::AddWidget( UiWidget* widget )
+UiManager::AddWidget(UiWidget* widget)
 {
-    m_Widgets.push_back( widget );
+    m_Widgets.push_back(widget);
 }
 
 
 UiWidget*
-UiManager::GetWidget( const Ogre::String& name )
+UiManager::GetWidget(const Ogre::String& name)
 {
     // get real table by name
-    Ogre::StringVector table_path = StringTokenise( name, "." );
+    Ogre::StringVector table_path = StringTokenise(name, ".");
     UiWidget* widget = NULL;
 
-    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 != NULL); ++j)
                 {
-                    widget = widget->GetChild( table_path[ j ] );
+                    widget = widget->GetChild(table_path[j]);
                 }
             }
         }
@@ -202,22 +202,22 @@ UiManager::GetWidget( const Ogre::String& name )
 
 
 UiWidget*
-UiManager::ScriptGetWidget( const char* name )
+UiManager::ScriptGetWidget(const char* name)
 {
-    return GetWidget( Ogre::String( name ) );
+    return GetWidget(Ogre::String(name));
 }
 
 
 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();
         }
     }
 }

+ 67 - 67
QGearsMain/src/core/UiSprite.cpp

@@ -5,15 +5,15 @@
 #include "core/UiSprite.h"
 
 
-UiSprite::UiSprite( const Ogre::String& name ):
-    UiWidget( name )
+UiSprite::UiSprite(const Ogre::String& name):
+    UiWidget(name)
 {
     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();
 }
@@ -28,24 +28,24 @@ UiSprite::~UiSprite()
 void
 UiSprite::Initialise()
 {
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     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();
-    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();
 }
@@ -61,19 +61,19 @@ UiSprite::Update()
 void
 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);
         }
     }
 
@@ -90,28 +90,28 @@ UiSprite::UpdateTransformation()
 
 
 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
-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();
 }
 
 
 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();
 }
 
@@ -128,14 +128,14 @@ UiSprite::UpdateGeometry()
 
     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);
         y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -158,22 +158,22 @@ UiSprite::UpdateGeometry()
         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_y1;
     *writeIterator++ = m_FinalZ;
@@ -249,15 +249,15 @@ UiSprite::CreateVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }

+ 87 - 87
QGearsMain/src/core/UiTextArea.cpp

@@ -7,15 +7,15 @@
 #include "core/UiTextArea.h"
 
 
-UiTextArea::UiTextArea( const Ogre::String& name ):
-    UiWidget( name )
+UiTextArea::UiTextArea(const Ogre::String& name):
+    UiWidget(name)
 {
     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();
 }
@@ -36,7 +36,7 @@ UiTextArea::Initialise()
     m_Text = "";
     m_TextNode = NULL;
 
-    m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
+    m_SceneManager = Ogre::Root::getSingleton().getSceneManager("Scene");
     m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
 
     CreateVertexBuffer();
@@ -53,19 +53,19 @@ UiTextArea::Update()
 void
 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);
         }
     }
 
@@ -82,83 +82,83 @@ UiTextArea::UpdateTransformation()
 
 
 void
-UiTextArea::SetTextAlign( const TextAlign align )
+UiTextArea::SetTextAlign(const TextAlign align)
 {
     m_TextAlign = align;
 }
 
 
 void
-UiTextArea::SetText( const Ogre::UTFString& text )
+UiTextArea::SetText(const Ogre::UTFString& text)
 {
     m_Text = text;
 }
 
 
 void
-UiTextArea::SetText( TiXmlNode* text )
+UiTextArea::SetText(TiXmlNode* text)
 {
     m_TextNode = text;
 }
 
 
 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 == NULL)
     {
-        LOG_ERROR( "Could not find font \"" + font + "\" for \"" + m_PathName + "\"." );
+        LOG_ERROR("Could not find font \"" + font + "\" for \"" + m_PathName + "\".");
         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();
-    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
 UiTextArea::UpdateGeometry()
 {
-    if( m_Font == NULL )
+    if(m_Font == NULL)
     {
-        LOG_ERROR( "Font for \"" + m_PathName + "\" if not set." );
+        LOG_ERROR("Font for \"" + m_PathName + "\" if not set.");
         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;
     }
 
     float length = 0;
-    if( m_TextAlign != LEFT )
+    if(m_TextAlign != LEFT)
     {
-        if( m_TextNode != NULL )
+        if(m_TextNode != NULL)
         {
-            length = GetTextLengthFromNode( m_TextNode );
+            length = GetTextLengthFromNode(m_TextNode);
         }
         else
         {
-            length = GetTextLength( m_Text );
+            length = GetTextLength(m_Text);
         }
 
-        if( m_TextAlign == CENTER )
+        if(m_TextAlign == CENTER)
         {
             length /= 2;
         }
@@ -172,39 +172,39 @@ UiTextArea::UpdateGeometry()
     TextStyle style;
     style.colour = m_Colour1;
 
-    if( m_TextNode != NULL )
+    if(m_TextNode != NULL)
     {
-        SetTextGeometryFromNode( m_TextNode, data, style );
+        SetTextGeometryFromNode(m_TextNode, data, style);
     }
     else
     {
-        SetTextGeometry( m_Text, data, style );
+        SetTextGeometry(m_Text, data, style);
     }
 }
 
 
 float
-UiTextArea::GetTextLengthFromNode( TiXmlNode* node ) const
+UiTextArea::GetTextLengthFromNode(TiXmlNode* node) const
 {
     float length = 0;
 
-    while( node != NULL )
+    while(node != NULL)
     {
-        switch( node->Type() )
+        switch(node->Type())
         {
             case TiXmlNode::TINYXML_TEXT:
             {
                 TiXmlText* childText = node->ToText();
-                if( childText )
+                if(childText)
                 {
-                    length += GetTextLength( childText->Value() );
+                    length += GetTextLength(childText->Value());
                 }
             }
             break;
 
             case TiXmlNode::TINYXML_ELEMENT:
             {
-                length +=GetTextLengthFromNode( node->FirstChild() );
+                length +=GetTextLengthFromNode(node->FirstChild());
             }
             break;
         }
@@ -217,13 +217,13 @@ UiTextArea::GetTextLengthFromNode( TiXmlNode* node ) const
 
 
 float
-UiTextArea::GetTextLength( const Ogre::UTFString& text ) const
+UiTextArea::GetTextLength(const Ogre::UTFString& text) const
 {
     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;
@@ -231,18 +231,18 @@ UiTextArea::GetTextLength( const Ogre::UTFString& text ) const
 
 
 void
-UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const TextStyle& style )
+UiTextArea::SetTextGeometryFromNode(TiXmlNode* node, TextBlockData& data, const TextStyle& style)
 {
-    while( node != NULL )
+    while(node != NULL)
     {
-        switch( node->Type() )
+        switch(node->Type())
         {
             case TiXmlNode::TINYXML_TEXT:
             {
                 TiXmlText* childText = node->ToText();
-                if( childText )
+                if(childText)
                 {
-                    SetTextGeometry( childText->Value(), data, style );
+                    SetTextGeometry(childText->Value(), data, style);
                 }
             }
             break;
@@ -253,13 +253,13 @@ UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const
                 style_child.colour = style.colour;
 
                 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();
-                SetTextGeometryFromNode( node_child, data, style_child );
+                SetTextGeometryFromNode(node_child, data, style_child);
             }
             break;
         }
@@ -270,9 +270,9 @@ UiTextArea::SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const
 
 
 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;
     m_RenderOp.vertexData->vertexCount = data.position * 6;
 
@@ -282,7 +282,7 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
     float x = m_FinalTranslate.x;
     float y = m_FinalTranslate.y;
 
-    for(auto &c : text )
+    for(auto &c : text)
     {
         UiCharData char_data = m_Font->GetCharData(c);
 
@@ -292,10 +292,10 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
 
         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);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -318,23 +318,23 @@ UiTextArea::SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, c
             y4 = static_cast<int>(local_y2 + y);
         }
 
-        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 height = static_cast<float>(m_Font->GetImageHeight());
 
         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)
+            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
-        );
+            (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.
@@ -360,15 +360,15 @@ UiTextArea::CreateVertexBuffer()
     Ogre::VertexDeclaration* vDecl = m_RenderOp.vertexData->vertexDeclaration;
 
     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.useIndexes = false;
 }

+ 136 - 136
QGearsMain/src/core/UiWidget.cpp

@@ -10,22 +10,22 @@
 #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(NULL)
 {
     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();
 }
@@ -33,12 +33,12 @@ UiWidget::UiWidget( const Ogre::String& name, const Ogre::String& path_name, UiW
 
 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();
 }
@@ -47,7 +47,7 @@ UiWidget::~UiWidget()
 void
 UiWidget::Initialise()
 {
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     m_ScreenHeight = static_cast<float>(viewport->getActualHeight());
 
@@ -61,8 +61,8 @@ UiWidget::Initialise()
     m_FinalZ = 0;
     m_FinalOrigin = 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_OriginXPercent = 0;
@@ -78,7 +78,7 @@ UiWidget::Initialise()
     m_Width = 0;
     m_HeightPercent = 100;
     m_Height = 0;
-    m_Scale = Ogre::Vector2( 1.0f, 1.0f );
+    m_Scale = Ogre::Vector2(1.0f, 1.0f);
     m_Rotation = 0.0f;
 
     m_Scissor = false;
@@ -90,71 +90,71 @@ UiWidget::Initialise()
     m_AnimationCurrent = NULL;
     m_AnimationDefault = "";
     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, NULL);
 }
 
 
 void
 UiWidget::Update()
 {
-    if( m_Visible != true )
+    if(m_Visible != true)
     {
         return;
     }
 
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != NULL)
     {
         float delta_time = Timer::getSingleton().GetGameTimeDelta();
         float time = m_AnimationCurrent->GetTime();
 
         // 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();
 
-            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
                 time = time + delta_time - m_AnimationCurrent->GetLength();
-                PlayAnimation( m_AnimationDefault, UiAnimation::DEFAULT, time, -1 );
+                PlayAnimation(m_AnimationDefault, UiAnimation::DEFAULT, time, -1);
             }
         }
         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 == NULL && 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();
     }
 
     // debug output
-    if( cv_debug_ui.GetI() >= 1 )
+    if(cv_debug_ui.GetI() >= 1)
     {
         float local_x1 = -m_FinalOrigin.x;
         float local_y1 = -m_FinalOrigin.y;
@@ -163,16 +163,16 @@ UiWidget::Update()
         float x = m_FinalTranslate.x;
         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;
 
-        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);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -202,24 +202,24 @@ UiWidget::Update()
         DEBUG_DRAW.Line(static_cast<float>(x4), static_cast<float>(y4), static_cast<float>(x1), static_cast<float>(y1));
 
         // 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 != NULL) ? m_Parent->GetFinalOrigin() : Ogre::Vector2::ZERO;
+        Ogre::Vector2 area_translate = (m_Parent != NULL) ? m_Parent->GetFinalTranslate() : Ogre::Vector2::ZERO;
         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 + 12), GetCurrentAnimationName());
         }
 
         // 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));
     }
 }
 
@@ -227,13 +227,13 @@ UiWidget::Update()
 void
 UiWidget::OnResize()
 {
-    Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
+    Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     m_ScreenWidth = static_cast<float>(viewport->getActualWidth());
     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;
@@ -243,18 +243,18 @@ UiWidget::OnResize()
 void
 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
-UiWidget::SetVisible( const bool visible )
+UiWidget::SetVisible(const bool visible)
 {
     m_Visible = visible;
 }
@@ -275,20 +275,20 @@ UiWidget::GetName() const
 
 
 void
-UiWidget::AddChild( UiWidget *widget )
+UiWidget::AddChild(UiWidget *widget)
 {
-    m_Children.push_back( widget );
+    m_Children.push_back(widget);
 }
 
 
 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];
         }
     }
 
@@ -299,25 +299,25 @@ UiWidget::GetChild( const Ogre::String& name )
 void
 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();
 }
 
 
 void
-UiWidget::AddAnimation( UiAnimation* animation )
+UiWidget::AddAnimation(UiAnimation* animation)
 {
-    m_Animations.push_back( animation );
+    m_Animations.push_back(animation);
 }
 
 
 const Ogre::String&
 UiWidget::GetCurrentAnimationName() const
 {
-    if( m_AnimationCurrent != NULL )
+    if(m_AnimationCurrent != NULL)
     {
         return m_AnimationCurrent->GetName();
     }
@@ -327,16 +327,16 @@ UiWidget::GetCurrentAnimationName() const
 
 
 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;
             return;
         }
@@ -345,42 +345,42 @@ UiWidget::PlayAnimation( const Ogre::String& animation, UiAnimation::State state
     // stop current state and animation
     m_AnimationCurrent = NULL;
     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
-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
-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
-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
-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
-UiWidget::ScriptSetDefaultAnimation( const char* animation )
+UiWidget::ScriptSetDefaultAnimation(const char* animation)
 {
-    m_AnimationDefault = Ogre::String( animation );
+    m_AnimationDefault = Ogre::String(animation);
     m_AnimationState = UiAnimation::DEFAULT;
 }
 
@@ -389,7 +389,7 @@ int
 UiWidget::ScriptAnimationSync()
 {
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
-    m_AnimationSync.push_back( script );
+    m_AnimationSync.push_back(script);
     return -1;
 }
 
@@ -397,63 +397,63 @@ UiWidget::ScriptAnimationSync()
 void
 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 != 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;
 
-    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 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;
         y = local_x * sin + local_y * cos;
     }
 
     m_FinalTranslate.x = area_translate.x;
-    if( m_Align == RIGHT )
+    if(m_Align == RIGHT)
     {
         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 += x;
 
     m_FinalTranslate.y = area_translate.y;
-    if( m_VerticalAlign == BOTTOM )
+    if(m_VerticalAlign == BOTTOM)
     {
         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 += y;
 
-    m_FinalZ = ( m_Parent != NULL ) ? m_Parent->GetFinalZ() + m_Z : m_Z;
+    m_FinalZ = (m_Parent != NULL) ? m_Parent->GetFinalZ() + m_Z : m_Z;
     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;
 
     // 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_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);
 
-    if( m_Scissor == true )
+    if(m_Scissor == true)
     {
         float local_x1 = -m_FinalOrigin.x;
         float local_y1 = -m_FinalOrigin.y;
@@ -464,10 +464,10 @@ UiWidget::UpdateTransformation()
 
         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);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
@@ -490,30 +490,30 @@ UiWidget::UpdateTransformation()
             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;
 
-    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
-UiWidget::SetAlign( const UiWidget::Align align )
+UiWidget::SetAlign(const UiWidget::Align align)
 {
     m_Align = align;
 }
 
 
 void
-UiWidget::SetVerticalAlign( const UiWidget::VerticalAlign valign )
+UiWidget::SetVerticalAlign(const UiWidget::VerticalAlign valign)
 {
     m_VerticalAlign = valign;
 }
@@ -562,7 +562,7 @@ UiWidget::GetFinalRotation() const
 
 
 void
-UiWidget::SetOriginX( const float percent, const float x )
+UiWidget::SetOriginX(const float percent, const float x)
 {
     m_OriginXPercent = percent;
     m_OriginX = x;
@@ -571,7 +571,7 @@ UiWidget::SetOriginX( const float percent, const float x )
 
 
 void
-UiWidget::SetOriginY( const float percent, const float y )
+UiWidget::SetOriginY(const float percent, const float y)
 {
     m_OriginYPercent = percent;
     m_OriginY = y;
@@ -580,7 +580,7 @@ UiWidget::SetOriginY( const float percent, const float y )
 
 
 void
-UiWidget::SetX( const float percent, const float x )
+UiWidget::SetX(const float percent, const float x)
 {
     m_XPercent = percent;
     m_X = x;
@@ -589,7 +589,7 @@ UiWidget::SetX( const float percent, const float x )
 
 
 void
-UiWidget::SetY( const float percent, const float y )
+UiWidget::SetY(const float percent, const float y)
 {
     m_YPercent = percent;
     m_Y = y;
@@ -598,7 +598,7 @@ UiWidget::SetY( const float percent, const float y )
 
 
 void
-UiWidget::SetZ( const float z )
+UiWidget::SetZ(const float z)
 {
     m_Z = z;
     m_UpdateTransformation = true;
@@ -606,7 +606,7 @@ UiWidget::SetZ( const float z )
 
 
 void
-UiWidget::SetWidth( const float percent, const float width )
+UiWidget::SetWidth(const float percent, const float width)
 {
     m_WidthPercent = percent;
     m_Width = width;
@@ -615,7 +615,7 @@ UiWidget::SetWidth( const float percent, const float width )
 
 
 void
-UiWidget::SetHeight( const float percent, const float height )
+UiWidget::SetHeight(const float percent, const float height)
 {
     m_HeightPercent = percent;
     m_Height = height;
@@ -624,7 +624,7 @@ UiWidget::SetHeight( const float percent, const float height )
 
 
 void
-UiWidget::SetScale( const Ogre::Vector2& scale )
+UiWidget::SetScale(const Ogre::Vector2& scale)
 {
     m_Scale = scale;
     m_UpdateTransformation = true;
@@ -632,7 +632,7 @@ UiWidget::SetScale( const Ogre::Vector2& scale )
 
 
 void
-UiWidget::SetRotation( const float degree )
+UiWidget::SetRotation(const float degree)
 {
     m_Rotation = degree;
     m_UpdateTransformation = true;
@@ -640,7 +640,7 @@ UiWidget::SetRotation( const float degree )
 
 
 void
-UiWidget::SetScissor( bool scissor )
+UiWidget::SetScissor(bool scissor)
 {
     m_Scissor = scissor;
     m_UpdateTransformation = true;
@@ -676,7 +676,7 @@ UiWidget::GetScissorRight() const
 
 
 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_Colour2.r = r; m_Colour2.g = g; m_Colour2.b = b;
@@ -687,7 +687,7 @@ UiWidget::SetColour( const float r, const float g, const float b )
 
 
 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_Colour2.r = r2; m_Colour2.g = g2; m_Colour2.b = b2;
@@ -698,7 +698,7 @@ UiWidget::SetColours( const float r1, const float g1, const float b1, const floa
 
 
 void
-UiWidget::SetAlpha( const float a )
+UiWidget::SetAlpha(const float a)
 {
     m_Colour1.a = a;
     m_Colour2.a = a;

+ 119 - 119
QGearsMain/src/core/Utilites.cpp

@@ -7,7 +7,7 @@ const Ogre::String
 CreateAutoName(const Ogre::String prefix)
 {
     static int enumerator = 0;
-    return prefix + Ogre::StringConverter::toString( enumerator++ );
+    return prefix + Ogre::StringConverter::toString(enumerator++);
 }
 
 
@@ -20,101 +20,101 @@ struct KeyName
 
 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
-KeyToString( OIS::KeyCode key )
+KeyToString(OIS::KeyCode 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;
         }
@@ -125,17 +125,17 @@ KeyToString( OIS::KeyCode key )
 
 
 OIS::KeyCode
-StringToKey( const Ogre::String& str )
+StringToKey(const Ogre::String& str)
 {
-    if( str == "" )
+    if(str == "")
     {
         return OIS::KC_UNASSIGNED;
     }
 
     // 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;
         }
@@ -146,7 +146,7 @@ StringToKey( const Ogre::String& str )
 
 
 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;
 
@@ -163,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
 
     // for every char in the input-string
-    while( len > pos )
+    while(len > pos)
     {
         // get the character of the string and reset the delimiter buffer
-        ch = str.at( pos );
+        ch = str.at(pos);
         delimiter = 0;
 
         // assume ch isn't a delimiter
@@ -176,16 +176,16 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
 
         // ... if the delimiter is an escaped character
         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
                 ++pos;
-                if( pos < len ) // if there are more chars left
+                if(pos < len) // if there are more chars left
                 {
                     // get the next one
-                    ch = str.at( pos );
+                    ch = str.at(pos);
 
                     // add the escaped character to the token
                     add_char = true;
@@ -202,14 +202,14 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
 
         // ... 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.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
                 // the quote character
-                if( quoted == false )
+                if(quoted == false)
                 {
                     quoted = true;
                     current_quote = ch;
@@ -220,7 +220,7 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
                 else // if quote is open already
                 {
                     // 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
                         quoted = false;
@@ -234,15 +234,15 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
 
         // 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
             // 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
                 // the token is complete
-                if( token.empty() == false )
+                if(token.empty() == false)
                 {
                     token_complete = true;
                 }
@@ -254,14 +254,14 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
 
         // if the delimiter is preserved - add it as a token
         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
             // 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( token.empty() == false )
+                if(token.empty() == false)
                 {
                     token_complete = true;
                 }
@@ -276,17 +276,17 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
 
         // add the character to the token
-        if( add_char == true )
+        if(add_char == true)
         {
             // add the current char
-            token.push_back( ch );
+            token.push_back(ch);
         }
 
         // 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
-            ret.push_back( token );
+            ret.push_back(token);
 
             // clear the contents
             token.clear();
@@ -296,12 +296,12 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
         }
 
         // add the delimiter
-        if( add_delimiter == true )
+        if(add_delimiter == true)
         {
             // the next token is the delimiter
             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
@@ -309,9 +309,9 @@ StringTokenise( const Ogre::String& str, const Ogre::String& delimiters, const O
     }
 
     // add the final token
-    if( token.empty() == false )
+    if(token.empty() == false)
     {
-        ret.push_back( token );
+        ret.push_back(token);
     }
 
     return ret;

+ 58 - 58
QGearsMain/src/core/Walkmesh.cpp

@@ -5,7 +5,7 @@
 #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");
 
 
 
@@ -22,59 +22,59 @@ Walkmesh::~Walkmesh()
 void
 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(unsigned int i = 0; i < m_Triangles.size(); ++i)
         {
-            if( m_Triangles[ i ].access_side[ 0 ] == -1 )
+            if(m_Triangles[i].access_side[0] == -1)
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             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(m_Triangles[i].a, m_Triangles[i].b);
 
-            if( m_Triangles[ i ].access_side[ 1 ] == -1 )
+            if(m_Triangles[i].access_side[1] == -1)
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             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(m_Triangles[i].b, m_Triangles[i].c);
 
-            if( m_Triangles[ i ].access_side[ 2 ] == -1 )
+            if(m_Triangles[i].access_side[2] == -1)
             {
-                DEBUG_DRAW.SetColour( Ogre::ColourValue( 1, 0, 0, 1 ) );
+                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
             }
             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(m_Triangles[i].c, m_Triangles[i].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
             {
-                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 = (m_Triangles[i].a + m_Triangles[i].b + m_Triangles[i].c) / 3;
+            DEBUG_DRAW.Text(triangle_pos, 0, 0, Ogre::StringConverter::toString(i));
         }
     }
 }
@@ -88,67 +88,67 @@ Walkmesh::Clear()
 
 
 void
-Walkmesh::AddTriangle( const WalkmeshTriangle& triangle )
+Walkmesh::AddTriangle(const WalkmeshTriangle& triangle)
 {
-    m_Triangles.push_back( triangle );
+    m_Triangles.push_back(triangle);
 }
 
 
 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;
     }
 
-    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 m_Triangles[ triangle_id ].access_side[ side ];
+    return m_Triangles[triangle_id].access_side[side];
 }
 
 
 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 m_Triangles[ triangle_id ].a;
+    return m_Triangles[triangle_id].a;
 }
 
 
 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 m_Triangles[ triangle_id ].b;
+    return m_Triangles[triangle_id].b;
 }
 
 
 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 m_Triangles[ triangle_id ].c;
+    return m_Triangles[triangle_id].c;
 }
 
 
@@ -160,39 +160,39 @@ Walkmesh::GetNumberOfTriangles() const
 
 
 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;
     }
 
-    m_Triangles[ triangle_id ].locked = lock;
+    m_Triangles[triangle_id].locked = lock;
 }
 
 
 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 m_Triangles[ triangle_id ].locked;
+    return m_Triangles[triangle_id].locked;
 }
 
 
 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 )
+    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)
     {
-        AddTriangle( *it );
+        AddTriangle(*it);
         ++it;
     }
 }

+ 41 - 41
QGearsMain/src/core/XmlBackground2DFile.cpp

@@ -6,8 +6,8 @@
 #include "core/XmlBackground2DFile.h"
 
 
-XmlBackground2DFile::XmlBackground2DFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlBackground2DFile::XmlBackground2DFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -23,79 +23,79 @@ XmlBackground2DFile::Load()
     TiXmlNode* node = m_File.RootElement();
     Background2D* background = EntityManager::getSingleton().GetBackground2D();
 
-    if( node == NULL || node->ValueStr() != "background2d" )
+    if(node == NULL || 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;
     }
 
-    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;
 
         node = node->FirstChild();
-        while( node != NULL )
+        while(node != NULL)
         {
-            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;
                 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();
-                while( node2 != NULL )
+                while(node2 != NULL)
                 {
-                    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);
                         }
                     }
 

+ 59 - 59
QGearsMain/src/core/XmlFile.cpp

@@ -4,15 +4,15 @@
 #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();
 
-    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());
     }
 }
 
@@ -23,16 +23,16 @@ XmlFile::~XmlFile()
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseBool( *string );
+            ret = Ogre::StringConverter::parseBool(*string);
         }
     }
 
@@ -41,16 +41,16 @@ XmlFile::GetBool( TiXmlNode* node, const Ogre::String& tag, bool def ) const
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseInt( *string );
+            ret = Ogre::StringConverter::parseInt(*string);
         }
     }
 
@@ -59,16 +59,16 @@ XmlFile::GetInt( TiXmlNode* node, const Ogre::String& tag, int def ) const
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseReal( *string );
+            ret = Ogre::StringConverter::parseReal(*string);
         }
     }
 
@@ -77,14 +77,14 @@ XmlFile::GetFloat( TiXmlNode* node, const Ogre::String& tag, float def ) const
 
 
 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;
 
-    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 != NULL)
         {
             ret = *string;
         }
@@ -95,16 +95,16 @@ XmlFile::GetString( TiXmlNode* node, const Ogre::String& tag, const Ogre::String
 
 
 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;
 
-    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 != NULL)
         {
-            ret = ( *string ).c_str();
+            ret = (*string).c_str();
         }
     }
 
@@ -113,16 +113,16 @@ XmlFile::GetUTFString( TiXmlNode* node, const Ogre::String& tag, const Ogre::UTF
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseVector2( *string );
+            ret = Ogre::StringConverter::parseVector2(*string);
         }
     }
 
@@ -131,16 +131,16 @@ XmlFile::GetVector2( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseVector3( *string );
+            ret = Ogre::StringConverter::parseVector3(*string);
         }
     }
 
@@ -149,16 +149,16 @@ XmlFile::GetVector3( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseVector4( *string );
+            ret = Ogre::StringConverter::parseVector4(*string);
         }
     }
 
@@ -167,16 +167,16 @@ XmlFile::GetVector4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vecto
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseMatrix4( *string );
+            ret = Ogre::StringConverter::parseMatrix4(*string);
         }
     }
 
@@ -185,16 +185,16 @@ XmlFile::GetMatrix4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Matri
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseQuaternion( *string );
+            ret = Ogre::StringConverter::parseQuaternion(*string);
         }
     }
 
@@ -203,16 +203,16 @@ XmlFile::GetQuaternion( TiXmlNode* node, const Ogre::String& tag, const Ogre::Qu
 
 
 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;
 
-    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 != NULL)
         {
-            ret = Ogre::StringConverter::parseColourValue( *string );
+            ret = Ogre::StringConverter::parseColourValue(*string);
         }
     }
 

+ 25 - 25
QGearsMain/src/core/XmlFontFile.cpp

@@ -4,8 +4,8 @@
 #include "core/XmlFontFile.h"
 
 
-XmlFontFile::XmlFontFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlFontFile::XmlFontFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -20,50 +20,50 @@ XmlFontFile::LoadFont()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "font" )
+    if(node == NULL || 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;
     }
 
-    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();
 
-        while( node != NULL )
+        while(node != NULL)
         {
-            if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char" )
+            if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char")
             {
                 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();
         }
 
-        UiManager::getSingleton().AddFont( font );
+        UiManager::getSingleton().AddFont(font);
     }
 }

+ 7 - 7
QGearsMain/src/core/XmlFontsFile.cpp

@@ -3,8 +3,8 @@
 #include "core/XmlFontsFile.h"
 
 
-XmlFontsFile::XmlFontsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlFontsFile::XmlFontsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,18 +19,18 @@ XmlFontsFile::LoadFonts()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "fonts" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();
         }
         node = node->NextSibling();

+ 60 - 60
QGearsMain/src/core/XmlMapFile.cpp

@@ -8,8 +8,8 @@
 #include "map/QGearsWalkmeshFileManager.h"
 
 
-XmlMapFile::XmlMapFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMapFile::XmlMapFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -24,107 +24,107 @@ XmlMapFile::LoadMap()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "map" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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::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
-                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;
             }
-            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;
             }
 
-            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;
             }
 
-            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;
             }
 
-            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;
             }
 
-            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);
             }
         }
 
@@ -139,22 +139,22 @@ XmlMapFile::GetWalkmeshFileName()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "map" )
+    if(node == NULL || 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 "";
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();
     }
 
-    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 "";
 }

+ 16 - 16
QGearsMain/src/core/XmlMapsFile.cpp

@@ -2,8 +2,8 @@
 #include "core/XmlMapsFile.h"
 
 
-XmlMapsFile::XmlMapsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMapsFile::XmlMapsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -14,51 +14,51 @@ XmlMapsFile::~XmlMapsFile()
 
 
 const Ogre::String
-XmlMapsFile::GetMapFileNameByName( const Ogre::String& name )
+XmlMapsFile::GetMapFileNameByName(const Ogre::String& name)
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "maps" )
+    if(node == NULL || 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 "";
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();
     }
 
-    LOG_WARNING( "Can't find map \"" + name + "\" in " + m_File.ValueStr() + "." );
+    LOG_WARNING("Can't find map \"" + name + "\" in " + m_File.ValueStr() + ".");
     return "";
 }
 
 
 void
-XmlMapsFile::GetMapNames( Ogre::StringVector& complete_params )
+XmlMapsFile::GetMapNames(Ogre::StringVector& complete_params)
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "maps" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();
     }

+ 10 - 10
QGearsMain/src/core/XmlMusicsFile.cpp

@@ -3,8 +3,8 @@
 #include "core/XmlMusicsFile.h"
 
 
-XmlMusicsFile::XmlMusicsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlMusicsFile::XmlMusicsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,23 +19,23 @@ XmlMusicsFile::LoadMusics()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "musics" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "music" )
+        if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "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();

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

@@ -3,8 +3,8 @@
 #include "core/XmlPrototypesFile.h"
 
 
-XmlPrototypesFile::XmlPrototypesFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlPrototypesFile::XmlPrototypesFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,19 +19,19 @@ XmlPrototypesFile::LoadPrototypes()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "prototypes" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();

+ 170 - 170
QGearsMain/src/core/XmlScreenFile.cpp

@@ -7,8 +7,8 @@
 #include "core/XmlScreenFile.h"
 
 
-XmlScreenFile::XmlScreenFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScreenFile::XmlScreenFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -23,340 +23,340 @@ XmlScreenFile::LoadScreen()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "screen" )
+    if(node == NULL || 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;
     }
 
-    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();
-    if( node != NULL )
+    if(node != NULL)
     {
-        LoadScreenRecursive( node, base_name, widget );
+        LoadScreenRecursive(node, base_name, widget);
     }
 
-    UiManager::getSingleton().AddWidget( widget );
+    UiManager::getSingleton().AddWidget(widget);
 }
 
 
 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 != NULL)
     {
         // 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 != NULL)
                     {
                         node2 = node2->FirstChild();
-                        if( node2 != NULL )
+                        if(node2 != NULL)
                         {
-                            LoadScreenRecursive( node2, base_name, widget );
+                            LoadScreenRecursive(node2, base_name, widget);
                         }
                     }
                 }
             }
             else
             {
-                Ogre::String name = GetString( node, "name" );
-                if( name != "" )
+                Ogre::String name = GetString(node, "name");
+                if(name != "")
                 {
                     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
                     {
-                        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
                     {
-                        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 = 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 = 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 = 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 = 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 = 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 = 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();
-                    if( node2 != NULL )
+                    if(node2 != NULL)
                     {
-                        LoadScreenRecursive( node2, base_name + "." + name, widget2 );
+                        LoadScreenRecursive(node2, base_name + "." + name, widget2);
                     }
                 }
                 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
-        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;
-                            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;
-                            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;
-                            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;
-                            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;
-                            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();
@@ -365,25 +365,25 @@ XmlScreenFile::LoadScreenRecursive( TiXmlNode* node, const Ogre::String& base_na
 
 
 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;
     }
     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
         {
             value_percent = 0;
-            value = Ogre::StringConverter::parseReal( string );
+            value = Ogre::StringConverter::parseReal(string);
         }
     }
 }

+ 7 - 7
QGearsMain/src/core/XmlScreensFile.cpp

@@ -3,8 +3,8 @@
 #include "core/XmlScreensFile.h"
 
 
-XmlScreensFile::XmlScreensFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScreensFile::XmlScreensFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,18 +19,18 @@ XmlScreensFile::LoadScreens()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "screens" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();
         }
         node = node->NextSibling();

+ 12 - 12
QGearsMain/src/core/XmlScriptsFile.cpp

@@ -3,8 +3,8 @@
 #include "core/XmlScriptsFile.h"
 
 
-XmlScriptsFile::XmlScriptsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlScriptsFile::XmlScriptsFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,30 +19,30 @@ XmlScriptsFile::LoadScripts()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "scripts" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
     ScriptManager &script_manager(ScriptManager::getSingleton());
-    while( node != NULL )
+    while(node != NULL)
     {
-        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;
             }
 
-            script_manager.AddEntity( ScriptManager::SYSTEM, name, NULL );
+            script_manager.AddEntity(ScriptManager::SYSTEM, name, NULL);
         }
 
         node = node->NextSibling();

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

@@ -3,8 +3,8 @@
 #include "core/XmlTextFile.h"
 
 
-XmlTextFile::XmlTextFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlTextFile::XmlTextFile(const Ogre::String& file):
+    XmlFile(file)
 {
 }
 
@@ -19,19 +19,19 @@ XmlTextFile::LoadText()
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "texts" )
+    if(node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while(node != NULL)
     {
-        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();

+ 14 - 14
QGearsMain/src/core/XmlTextsFile.cpp

@@ -3,8 +3,8 @@
 #include "core/XmlTextsFile.h"
 
 
-XmlTextsFile::XmlTextsFile( const Ogre::String& file ):
-    XmlFile( file )
+XmlTextsFile::XmlTextsFile( const Ogre::String& file):
+    XmlFile( file)
 {
 }
 
@@ -15,37 +15,37 @@ XmlTextsFile::~XmlTextsFile()
 
 
 void
-XmlTextsFile::LoadTexts( const Ogre::String& language )
+XmlTextsFile::LoadTexts( const Ogre::String& language)
 {
     TiXmlNode* node = m_File.RootElement();
 
-    if( node == NULL || node->ValueStr() != "texts" )
+    if( node == NULL || 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;
     }
 
     node = node->FirstChild();
-    while( node != NULL )
+    while( node != NULL)
     {
-        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();
-                while( node2 != NULL )
+                while( node2 != NULL)
                 {
-                    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();
                         }
                         else
                         {
-                            LOG_ERROR( "Empty filename in language " + language + "." );
+                            LOG_ERROR( "Empty filename in language " + language + ".");
                         }
                     }
                     node2 = node2->NextSibling();

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio