Pārlūkot izejas kodu

Initial commit. Minor modifications over QGears

Project and executable names chanfed to V-Gears.
Adapted to Ogre 1.12
Adapted to Qt5
Project structure slightly changed.
Removed internal dependency TinyXml.
SUDM, Cotire, LuaJIT and LuaBind are now part of the project, not external modules.
References to QGeras changed to VGears in Makefiles (not in code).
Some code documentation and reformatting.
Added doc folder.
Updated readme.
Minor changes in the data installer.
Iñigo Valentin 4 gadi atpakaļ
revīzija
7b7ad59a2c
100 mainītis faili ar 7020 papildinājumiem un 0 dzēšanām
  1. 20 0
      .gitignore
  2. 15 0
      AUTHORS.md
  3. 13 0
      CIBuild/linux/dependencies.sh
  4. 29 0
      CIBuild/osx/dependencies.sh
  5. 58 0
      CIBuild/osx/fix_lib_paths.sh
  6. 19 0
      CIBuild/windows/build.bat
  7. 21 0
      CIBuild/windows/build64.bat
  8. 16 0
      CIBuild/windows/build64_init.bat
  9. 16 0
      CIBuild/windows/build_init.bat
  10. 408 0
      CMakeLists.txt
  11. 339 0
      COPYING.txt
  12. 3 0
      PlugIns/CMakeLists.txt
  13. 59 0
      PlugIns/Data/CMakeLists.txt
  14. 72 0
      PlugIns/Data/include/QGearsDataPlugin.h
  15. 4 0
      PlugIns/Data/misc/QGearsData.def
  16. 83 0
      PlugIns/Data/src/QGearsDataPlugin.cpp
  17. 53 0
      PlugIns/Data/src/QGearsDataPluginDll.cpp
  18. 168 0
      PlugIns/Data/test/tex_file_info.cpp
  19. 170 0
      PlugIns/Data/test/tex_file_test.cpp
  20. 423 0
      QGearsMain/CMakeLists.txt
  21. 25 0
      QGearsMain/include/LuaIncludes.h
  22. 15 0
      QGearsMain/include/QGearsGameState.h
  23. 44 0
      QGearsMain/include/QGearsPrerequisites.h
  24. 38 0
      QGearsMain/include/common/File.h
  25. 17 0
      QGearsMain/include/common/FileSystem.h
  26. 30 0
      QGearsMain/include/common/LzsFile.h
  27. 84 0
      QGearsMain/include/common/QGearsApplication.h
  28. 104 0
      QGearsMain/include/common/QGearsManualObject.h
  29. 62 0
      QGearsMain/include/common/QGearsResource.h
  30. 42 0
      QGearsMain/include/common/QGearsStringUtil.h
  31. 71 0
      QGearsMain/include/common/TypeDefine.h
  32. 17 0
      QGearsMain/include/common/make_unique.h
  33. 12 0
      QGearsMain/include/core/Assert.h
  34. 99 0
      QGearsMain/include/core/AudioManager.h
  35. 158 0
      QGearsMain/include/core/Background2D.h
  36. 62 0
      QGearsMain/include/core/Background2DAnimation.h
  37. 56 0
      QGearsMain/include/core/CameraManager.h
  38. 36 0
      QGearsMain/include/core/CameraManagerCommands.h
  39. 45 0
      QGearsMain/include/core/ConfigCmd.h
  40. 38 0
      QGearsMain/include/core/ConfigCmdManager.h
  41. 439 0
      QGearsMain/include/core/ConfigCmdManagerCommands.h
  42. 16 0
      QGearsMain/include/core/ConfigFile.h
  43. 54 0
      QGearsMain/include/core/ConfigVar.h
  44. 26 0
      QGearsMain/include/core/ConfigVarManager.h
  45. 80 0
      QGearsMain/include/core/Console.h
  46. 98 0
      QGearsMain/include/core/DebugDraw.h
  47. 125 0
      QGearsMain/include/core/DialogsManager.h
  48. 282 0
      QGearsMain/include/core/Entity.h
  49. 21 0
      QGearsMain/include/core/EntityCollision.h
  50. 21 0
      QGearsMain/include/core/EntityDirection.h
  51. 135 0
      QGearsMain/include/core/EntityManager.h
  52. 35 0
      QGearsMain/include/core/EntityModel.h
  53. 34 0
      QGearsMain/include/core/EntityPoint.h
  54. 44 0
      QGearsMain/include/core/EntityTrigger.h
  55. 53 0
      QGearsMain/include/core/Event.h
  56. 42 0
      QGearsMain/include/core/GameFrameListner.h
  57. 73 0
      QGearsMain/include/core/InputManager.h
  58. 92 0
      QGearsMain/include/core/InputManagerCommands.h
  59. 23 0
      QGearsMain/include/core/Logger.h
  60. 37 0
      QGearsMain/include/core/Module.h
  61. 128 0
      QGearsMain/include/core/ScriptManager.h
  62. 299 0
      QGearsMain/include/core/ScriptManagerBinds.h
  63. 39 0
      QGearsMain/include/core/ScriptManagerCommands.h
  64. 49 0
      QGearsMain/include/core/TextManager.h
  65. 36 0
      QGearsMain/include/core/TextManagerCommands.h
  66. 34 0
      QGearsMain/include/core/Timer.h
  67. 87 0
      QGearsMain/include/core/UiAnimation.h
  68. 54 0
      QGearsMain/include/core/UiFont.h
  69. 50 0
      QGearsMain/include/core/UiManager.h
  70. 45 0
      QGearsMain/include/core/UiSprite.h
  71. 192 0
      QGearsMain/include/core/UiTextArea.h
  72. 167 0
      QGearsMain/include/core/UiWidget.h
  73. 51 0
      QGearsMain/include/core/Utilites.h
  74. 60 0
      QGearsMain/include/core/Walkmesh.h
  75. 19 0
      QGearsMain/include/core/XmlBackground2DFile.h
  76. 40 0
      QGearsMain/include/core/XmlFile.h
  77. 20 0
      QGearsMain/include/core/XmlFontFile.h
  78. 19 0
      QGearsMain/include/core/XmlFontsFile.h
  79. 20 0
      QGearsMain/include/core/XmlMapFile.h
  80. 22 0
      QGearsMain/include/core/XmlMapsFile.h
  81. 19 0
      QGearsMain/include/core/XmlMusicsFile.h
  82. 19 0
      QGearsMain/include/core/XmlPrototypesFile.h
  83. 21 0
      QGearsMain/include/core/XmlScreenFile.h
  84. 19 0
      QGearsMain/include/core/XmlScreensFile.h
  85. 19 0
      QGearsMain/include/core/XmlScriptsFile.h
  86. 19 0
      QGearsMain/include/core/XmlTextFile.h
  87. 19 0
      QGearsMain/include/core/XmlTextsFile.h
  88. 19 0
      QGearsMain/include/core/XmlWalkmeshFile.h
  89. 60 0
      QGearsMain/include/core/particles/Particle.h
  90. 13 0
      QGearsMain/include/core/particles/ParticleAdditionalData.h
  91. 74 0
      QGearsMain/include/core/particles/ParticleEmitter.h
  92. 34 0
      QGearsMain/include/core/particles/ParticleEmitterDictionary.h
  93. 38 0
      QGearsMain/include/core/particles/ParticleEmitterFactory.h
  94. 17 0
      QGearsMain/include/core/particles/ParticleEmitterTranslator.h
  95. 140 0
      QGearsMain/include/core/particles/ParticlePool.h
  96. 150 0
      QGearsMain/include/core/particles/ParticlePoolMap.h
  97. 43 0
      QGearsMain/include/core/particles/ParticleRenderer.h
  98. 38 0
      QGearsMain/include/core/particles/ParticleRendererFactory.h
  99. 17 0
      QGearsMain/include/core/particles/ParticleRendererTranslator.h
  100. 37 0
      QGearsMain/include/core/particles/ParticleSystem.h

+ 20 - 0
.gitignore

@@ -0,0 +1,20 @@
+*.suo
+*.exe
+*.dll
+*.obj
+*.o
+*.vcxproj
+*.sln
+*.filters
+*.lib
+*.cmake
+*.log
+**/ogre.cfg
+**/Makefile
+**/CMakeCache.txt
+build/
+output/share
+output/include
+output/lib
+CMakeLists.txt.user
+

+ 15 - 0
AUTHORS.md

@@ -0,0 +1,15 @@
+# Authors
+
+Admin@microsof-be3e4f.mshome.net <Admin@microsof-be3e4f.mshome.net>
+Admin@microsof-be3e4f <Admin@microsof-be3e4f>
+Admin@MICROSOF-BE3E4F <Admin@MICROSOF-BE3E4F>
+andrei_antonov@AKARI.targem.local <andrei_antonov@AKARI.targem.local>
+andrei_antonov@test.targem.local <andrei_antonov@test.targem.local>
+bakari@test.targem.local <bakari@test.targem.local>
+bdulaney88 <draygera@gmail.com>
+cloudef <none@none>
+Gennadiy Brich <gennadiy.brich@gmail.com>
+paul <paul@desktop>
+paulsapps <github@paulsapps.com>
+sithlord48 <sithlord48@gmail.com>
+Tobias Peters <tobias.peters@kreativeffekt.at>

+ 13 - 0
CIBuild/linux/dependencies.sh

@@ -0,0 +1,13 @@
+sudo apt-get install boost1.55
+sudo apt-get install libvorbis-dev
+sudo apt-get install libalut-dev
+sudo apt-get install libfreetype6-dev
+sudo apt-get install libfreeimage-dev
+sudo apt-get install zlib1g-dev
+sudo apt-get install libzzip-dev
+sudo apt-get install libois-dev
+sudo apt-get install libglu-dev
+sudo apt-get install libqt4-dev
+sudo apt-get install libpng
+wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/ogre-build_1.9.0-1_amd64.deb
+sudo dpkg -i ogre-build_1.9.0-1_amd64.deb

+ 29 - 0
CIBuild/osx/dependencies.sh

@@ -0,0 +1,29 @@
+brew update
+# brew doctor
+# brew outdated wget || brew upgrade wget
+echo "Download deps"
+brew install qt
+wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/OgreDependencies_OSX_libc._20130610.zip
+wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/NVIDIA_Cg.tgz
+wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/OgreSDK.zip
+echo "Install deps"
+unzip OgreSDK.zip >> OgreSDK_extract.log
+sudo tar xfzC NVIDIA_Cg.tgz /
+unzip OgreDependencies_OSX_libc._20130610.zip >> extract.log
+echo "Setup env vars"
+#export OGRE_HOME="${PWD}/../OgreSDK"
+#export OGRE_SDK="${PWD}/../OgreSDK"
+export OGRE_HOME="/Users/travis/build/q-gears/q-gears/OgreSDK"
+export OGRE_SDK="/Users/travis/build/q-gears/q-gears/OgreSDK"
+export OIS_HOME="/Users/travis/build/q-gears/q-gears/Dependencies"
+
+# /Users/travis/build/q-gears/q-gears/Dependencies;
+# /Users/travis/build/q-gears/q-gears/../Dependencies
+
+echo "Env vars are $OGRE_SDK and $OIS_HOME"
+# Overwrite broken symlink with actual file
+ls
+ls ./Dependencies
+
+cp ${PWD}/OgreSDK/lib/macosx/Release/Ogre.framework/Versions/1.9.0/Ogre ${PWD}/OgreSDK/lib/macosx/Release/Ogre.framework/Ogre
+cp ${PWD}/OgreSDK/lib/macosx/Release/OgreOverlay.framework/Versions/1.9.0/OgreOverlay ${PWD}/OgreSDK/lib/macosx/Release/OgreOverlay.framework/OgreOverlay

+ 58 - 0
CIBuild/osx/fix_lib_paths.sh

@@ -0,0 +1,58 @@
+# fix permissions on anything already there
+for file in $1/*
+do
+    chmod +rwx "$file" 
+done
+
+# Copy required dylibs
+cp "${OGRE_SDK}/lib/macosx/Release/Ogre.framework/Ogre" ./bin_release
+cp "${OGRE_SDK}/lib/macosx/Release/RenderSystem_GL.framework/Versions/1.9.0/RenderSystem_GL" ./bin_release/
+cp "${OGRE_SDK}/lib/macosx/Release/OgreOverlay.framework/Versions/1.9.0/OgreOverlay" ./bin_release/
+cp /usr/local/lib/libboost_thread-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_date_time-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_system-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_atomic-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_chrono-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_program_options-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_filesystem-mt.dylib ./bin_release/
+cp /usr/local/lib/libboost_unit_test_framework-mt.dylib ./bin_release/
+cp /usr/local/lib/QtCore.framework/Versions/4/QtCore ./bin_release/
+cp /usr/local/lib/QtGui.framework/Versions/4/QtGui ./bin_release/
+
+# fix permissions on anything we just copied
+for file in $1/*
+do
+    chmod +rwx "$file" 
+done
+
+# Update dylib paths in all binaries
+for file in $1/*
+do
+   install_name_tool "$file" -change @executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre @executable_path/Ogre
+   install_name_tool "$file" -change @executable_path/../Frameworks/OgreOverlay.framework/Versions/1.9.0/OgreOverlay @executable_path/OgreOverlay
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_thread-mt.dylib @executable_path/libboost_thread-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_date_time-mt.dylib @executable_path/libboost_date_time-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_system-mt.dylib @executable_path/libboost_system-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_atomic-mt.dylib @executable_path/libboost_atomic-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_chrono-mt.dylib @executable_path/libboost_chrono-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_program_options-mt.dylib @executable_path/libboost_program_options-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_filesystem-mt.dylib @executable_path/libboost_filesystem-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_unit_test_framework-mt.dylib @executable_path/libboost_unit_test_framework-mt.dylib
+   install_name_tool "$file" -change @@HOMEBREW_PREFIX@@/lib/libboost_chrono-mt.dylib @executable_path/libboost_chrono-mt.dylib
+   
+   install_name_tool "$file" -change /usr/local/lib/libboost_thread-mt.dylib @executable_path/libboost_thread-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_date_time-mt.dylib @executable_path/libboost_date_time-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_system-mt.dylib @executable_path/libboost_system-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_atomic-mt.dylib @executable_path/libboost_atomic-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_chrono-mt.dylib @executable_path/libboost_chrono-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_program_options-mt.dylib @executable_path/libboost_program_options-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_filesystem-mt.dylib @executable_path/libboost_filesystem-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_unit_test_framework-mt.dylib @executable_path/libboost_unit_test_framework-mt.dylib
+   install_name_tool "$file" -change /usr/local/lib/libboost_chrono-mt.dylib @executable_path/libboost_chrono-mt.dylib
+   
+   
+   install_name_tool "$file" -change ${PWD}/bin_release/liblua.dylib  @executable_path/liblua.dylib
+   install_name_tool "$file" -change /usr/local/lib/QtCore.framework/Versions/4/QtCore @executable_path/QtCore
+   install_name_tool "$file" -change /usr/local/lib/QtGui.framework/Versions/4/QtGui @executable_path/QtGui
+   otool "$file" -L
+done

+ 19 - 0
CIBuild/windows/build.bat

@@ -0,0 +1,19 @@
+msbuild /m QGears.sln /p:Configuration=Release
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+cpack -C "Release"
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+set path=%path%;C:\boost_1_55_0_32\lib32-msvc-12.0;C:\qt-everywhere-opensource-src-4.8.6_32\bin\release;C:\Ogre\Build\bin\relwithdebinfo
+ctest -C "Release" --verbose
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+cd ..
+cd ..
+mkdir %CURRENT%
+cd %CURRENT%
+mkdir windows
+cd .. 
+dir
+move q-gears\build\*.msi %CURRENT%\windows
+upload %CURRENT%

+ 21 - 0
CIBuild/windows/build64.bat

@@ -0,0 +1,21 @@
+msbuild /m QGears.sln /p:Configuration=Release
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+cpack -C "Release"
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+set path=%path%;C:\boost_1_55_0_64\lib64-msvc-12.0;C:\qt-everywhere-opensource-src-4.8.6_64\bin\release;C:\Ogre64\Build\bin\relwithdebinfo
+ctest -C "Release" --verbose
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+cd ..
+cd ..
+mkdir %CURRENT%
+cd %CURRENT%
+mkdir windows
+cd .. 
+dir
+move q-gears\build\*.msi %CURRENT%\windows
+upload %CURRENT%
+
+

+ 16 - 0
CIBuild/windows/build64_init.bat

@@ -0,0 +1,16 @@
+git rev-parse HEAD>current_version.txt
+set /P CURRENT=<current_version.txt
+echo %CURRENT%
+
+mkdir build
+::if %errorlevel% neq 0 exit /b %errorlevel%
+
+cd build
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+set QTDIR=C:\qt-everywhere-opensource-src-4.8.6_64
+set OGRE_HOME=C:\Ogre64\Build\sdk
+call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
+
+cmake .. -G"Visual Studio 12 2013 Win64" -T v120_xp -DZLIB_INCLUDE_DIR=C:/zlib-1.2.8 -DBOOST_ROOT=C:\boost_1_55_0_64 -DBOOST_LIBRARYDIR=C:\boost_1_55_0_64\lib64-msvc-12.0 -DOGRE_DIR=C:\Ogre64\Build\sdk -DOIS_HOME=C:\Ogre64\Dependencies\Build\ogredeps -DZLIB_LIBRARY=C:/zlib-1.2.8/contrib/vstudio/vc11/x64/ZlibDllReleaseWithoutAsm/zlibwapi.lib
+if %errorlevel% neq 0 exit /b %errorlevel%

+ 16 - 0
CIBuild/windows/build_init.bat

@@ -0,0 +1,16 @@
+git rev-parse HEAD>current_version.txt
+set /P CURRENT=<current_version.txt
+echo %CURRENT%
+
+mkdir build
+::if %errorlevel% neq 0 exit /b %errorlevel%
+
+cd build
+if %errorlevel% neq 0 exit /b %errorlevel%
+
+set QTDIR=C:\qt-everywhere-opensource-src-4.8.6_32
+set OGRE_HOME=C:\Ogre\Build\sdk
+call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
+
+cmake .. -T v120_xp -DZLIB_INCLUDE_DIR=C:/zlib-1.2.8 -DBOOST_ROOT=C:\boost_1_55_0_32 -DBOOST_LIBRARYDIR=C:\boost_1_55_0_32\lib32-msvc-12.0 -DOGRE_DIR=C:\Ogre\Build\sdk -DOIS_HOME=C:\Ogre\Dependencies\Build\ogredeps -DZLIB_LIBRARY=C:/zlib-1.2.8/contrib/vstudio/vc11/x86/ZlibDllReleaseWithoutAsm/zlibwapi.lib
+if %errorlevel% neq 0 exit /b %errorlevel%

+ 408 - 0
CMakeLists.txt

@@ -0,0 +1,408 @@
+cmake_minimum_required(VERSION 2.8)
+
+# on / off for verbose build.
+set(CMAKE_VERBOSE_MAKEFILE off)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cotire/CMake")
+include(cotire)
+
+# Project Information.
+project(V-Gears)
+set(CMAKE_PACKAGE_ICON v-gears.png)
+set(VGears_VERSION__MAJOR 0)
+set(VGears_VERSION__MINOR 1)
+set(VGears_VERSION__PATCH 0)
+
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
+  # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
+  # differentiation between debug and release builds.
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
+  message("CMAKE_BUILD_TYPE was empty defaulting to Release")
+endif ()
+
+message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE} CMAKE_BINARY_DIR is ${CMAKE_BINARY_DIR}")
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug)
+
+# Generate header containing window title/version information
+set(VGEARS_VERSION "V-Gears v${VGears_VERSION__MAJOR}.${VGears_VERSION__MINOR}.${VGears_VERSION__PATCH}")
+configure_file(configure_version_file.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/configure_version_file.cmake @ONLY)
+
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vgears_version.h
+  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/configure_version_file.cmake
+  DEPENDS
+    ${CMAKE_CURRENT_BINARY_DIR}/configure_version_file.cmake
+    ${CMAKE_CURRENT_SOURCE_DIR}/QGearsMain/include/vgears_version.h.in
+  COMMENT "Configuring vgears_version.h"
+  VERBATIM)
+add_custom_target(configure_vgears_version ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vgears_version.h)
+
+# Enable Visual Studio solution "folders"
+SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) 
+
+#if (APPLE)
+#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
+#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
+#endif()
+
+set(CMAKE_FRAMEWORK_PATH
+      ${CMAKE_FRAMEWORK_PATH}
+      ${CMAKE_CURRENT_SOURCE_DIR}/OgreSDK/lib/macosx/Release
+      ${CMAKE_CURRENT_SOURCE_DIR}/OgreSDK/lib/macosx/Debug
+   )
+
+set(OGRE_FRAMEWORK_INCLUDES
+      ${CMAKE_CURRENT_SOURCE_DIR}/OgreSDK/include
+)
+
+option(VGears_BUILD_PLUGINS     "Build the plugins"     TRUE)
+option(VGears_BUILD_UTILITIES   "Build the utilities"   TRUE)
+option(VGears_BUILD_TESTS       "Build the unit tests"  FALSE)
+option(VGears_MULTITHREADING    "Enable multithreading" FALSE)
+option(VGears_SOUND             "Enable Sound"          TRUE)
+
+find_path(OGRE_CMAKE_MODULE_PATH FindOGRE.cmake
+    HINTS
+    "$ENV{OGRE_HOME}/CMake/"
+    "/usr/local/lib/OGRE/cmake"
+    "/usr/lib/OGRE/cmake"
+    "/usr/share/OGRE/cmake/modules"
+    "${CMAKE_CURRENT_SOURCE_DIR}/OgreSDK/CMake"
+)
+if(OGRE_CMAKE_MODULE_PATH-NOTFOUND)
+    message(SEND_ERROR "Failed to find OGRE module path.")
+else()
+    set(CMAKE_MODULE_PATH "${OGRE_CMAKE_MODULE_PATH};${CMAKE_MODULE_PATH}")
+endif()
+
+set(VGears_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+
+message("QGears_SOURCE_DIR ${QGears_SOURCE_DIR}")
+message("VGears_SOURCE_DIR ${VGears_SOURCE_DIR}")
+
+set(CMAKE_MODULE_PATH "${OGRE_CMAKE_MODULE_PATH};${CMAKE_MODULE_PATH}")
+set(CMAKE_MODULE_PATH 
+  "${CMAKE_MODULE_PATH}"
+  "${CMAKE_SOURCE_DIR}/CMake"
+)
+
+set(CMAKE_DEBUG_POSTFIX "_d")
+
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+  set(CMAKE_INSTALL_PREFIX
+    "${VGears_SOURCE_DIR}/output" CACHE PATH "V-Gears install prefix" FORCE
+  )
+endif()
+
+find_package(Qt5Widgets REQUIRED)
+find_package(ZLIB REQUIRED)
+find_package(OGRE REQUIRED)
+find_package(OIS REQUIRED)
+
+
+#if(NOT OIS_FOUND)
+#        message(SEND_ERROR "Failed to find OIS.")
+#endif()
+
+# Find Boost
+if (NOT OGRE_BUILD_PLATFORM_IPHONE)
+        if (WIN32)
+                set(Boost_USE_STATIC_LIBS TRUE)
+        else ()
+                # Statically linking boost to a dynamic Ogre build doesn't work on Linux 64bit
+                set(Boost_USE_STATIC_LIBS ${OGRE_STATIC})
+        endif ()
+        if (MINGW)
+                # this is probably a bug in CMake: the boost find module tries to look for
+                # boost libraries with name libboost_*, but CMake already prefixes library
+                # search names with "lib". This is the workaround.
+                set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
+        endif ()
+
+        set(Boost_ADDITIONAL_VERSIONS "1.55" "1.55.0" "1.53" "1.53.0" "1.52" "1.52.0" "1.51" "1.51.0" "1.50" "1.50.0" "1.49" "1.49.0" "1.48" "1.48.0" "1.47" "1.47.0" "1.46" "1.46.0" "1.45" "1.45.0" "1.44" "1.44.0" "1.42" "1.42.0" "1.41.0" "1.41" "1.40.0" "1.40")
+        # Components that need linking (NB does not include header-only components like bind)
+        set(OGRE_BOOST_COMPONENTS thread date_time)
+        find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
+        if (NOT Boost_FOUND)
+                set(Boost_USE_STATIC_LIBS NOT ${Boost_USE_STATIC_LIBS})
+                find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
+        endif()
+
+        if(Boost_FOUND AND Boost_VERSION GREATER 104900)
+                set(OGRE_BOOST_COMPONENTS thread date_time system chrono)
+                find_package(Boost COMPONENTS ${OGRE_BOOST_COMPONENTS} QUIET)
+        endif()
+
+        # Set up referencing of Boost
+        include_directories(${Boost_INCLUDE_DIR})
+    if (NOT APPLE)        
+    add_definitions(-DBOOST_ALL_NO_LIB)
+    endif()
+
+        set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
+
+        find_package(Boost COMPONENTS program_options filesystem QUIET)
+        set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
+        set(VGears_LIBRARIES ${OGRE_LIBRARIES})
+        
+        if(VGears_SOUND)
+            find_package(OpenAL REQUIRED)
+            find_package(OggVorbis REQUIRED)
+            add_definitions(-DVGears_SOUND)
+            set(VGears_LIBRARIES
+                ${VGears_LIBRARIES}
+                ${OPENAL_LIBRARY}
+                ${OGGVORBIS_LIBRARIES}
+            )
+        endif()
+
+        if(VGears_MULTITHREADING)
+            # Find Threads
+            find_package (Threads REQUIRED)
+            set(VGears_LIBRARIES
+                ${VGears_LIBRARIES}
+                ${CMAKE_THREAD_LIBS_INIT}
+            )
+        endif()
+
+        if(VGears_BUILD_TESTS)
+        message(STATUS "Looking for boost unit test..")
+            find_package(Boost COMPONENTS unit_test_framework REQUIRED)
+            set(VGears_TEST_LIBRARIES
+                ${OGRE_LIBRARIES}
+                ${Boost_LIBRARIES}
+            )
+            message(STATUS "Test libs = ${VGears_TEST_LIBRARIES}")
+            # enable CTest
+            enable_testing()
+        endif()
+endif()
+
+set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_Overlay_LIBRARIES})
+
+find_package(Boost COMPONENTS unit_test_framework REQUIRED)
+
+if (Boost_LIBRARIES STREQUAL "")
+message(SEND_ERROR "Boost_LIBRARIES is not set")
+endif()
+
+set(VGears_INCLUDE_DIRS
+    ${VGears_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/QGearsMain/include/
+    ${OIS_INCLUDE_DIRS}
+    #/usr/include/luabind # TODO: Autofind
+    #/usr/include/lua5.2
+    ${OGRE_Overlay_INCLUDE_DIRS}
+    ${OGRE_SAMPLES_INCLUDEPATH}
+    #${LUABIND_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib
+    ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luajit/src
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib/luabind/luabind/detail
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib/tinyxml
+	${CMAKE_CURRENT_SOURCE_DIR}/lib/SUDM
+)
+
+
+if (MSVC)
+# Build cpp files on all cores, up virtual mem for PCH's as cotire really makes the compiler scream
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zm193")
+# Shut up about insecure functions, as this is cross platform code we can't use the Win32 specifc functions
+add_definitions( -D_CRT_SECURE_NO_WARNINGS )
+else()
+# Enable C++11, you may need to use -std=c++0x if using an older gcc compiler
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
+endif()
+
+
+if (UNIX AND $ENV{COVERAGE}==1)
+      message("Setting coverage compiler options")
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") # debug, no optimisation
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") # enabling coverage
+endif()
+
+add_definitions(-DTIXML_USE_STL)
+add_subdirectory(lib)
+add_subdirectory(QGearsMain)
+add_subdirectory(SupportedGames)
+
+if(VGears_BUILD_PLUGINS)
+    add_subdirectory(PlugIns)
+endif()
+
+if(VGears_BUILD_UTILITIES)
+    add_subdirectory(utilities)
+endif()
+
+if(VGears_BUILD_TESTS)
+    add_subdirectory(Tests)
+endif()
+
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output)
+
+# Set generic CPack properties
+# DO NOT include on win32 - causes CRT dlls to be included
+#INCLUDE(InstallRequiredSystemLibraries)
+
+set(CPACK_PACKAGE_NAME "v-gears")
+SET(CPACK_PACKAGE_VERSION ${VGears_VERSION__MAJOR}.${VGears_VERSION__MINOR}.${VGears_VERSION__PATCH})
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Free Final Fantasy VII Engine")
+SET(CPACK_PACKAGE_VENDOR "V-Gears team")
+# TODO: Need to set these up properly, installing build instructions is a bit strange :)
+SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING.txt")
+#SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/readme.md")
+
+MESSAGE( STATUS "CMAKE_BUILD_TYPE:         " ${CMAKE_BUILD_TYPE} )
+MESSAGE( STATUS "BOOST_ROOT:         " ${BOOST_ROOT} )
+
+INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/output/field_models_and_animation_metadata.xml" DESTINATION ".")
+
+#OS SPECIFIC 
+if(WIN32)
+    # On Windows generate MSI packages
+    SET(CPACK_GENERATOR "WIX")
+    SET(CPACK_WIX_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/wix.template.in")
+    SET(CPACK_WIX_UPGRADE_GUID 8fbb893f-5622-4f6d-a7f6-c221f7be5d52)
+
+    # TODO: Set MSI banner image, copyright info etc, also include startmenu/desktop shortcuts
+    #set the name of the installer default formating is name-version-os
+
+    # If empty assume release
+    if ("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+        message("RELEASE installer build")
+        install(FILES ${PROJECT_SOURCE_DIR}/output/resources.cfg DESTINATION ./)
+        install(FILES ${PROJECT_SOURCE_DIR}/output/plugins.cfg DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/release/OgreMain.dll DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/release/RenderSystem_GL.dll DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/release/OGREOVERLAY.DLL DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/release/OIS.DLL DESTINATION ./)
+        install(FILES ${QT_PLUGINS_DIR}/../bin/QtCore4.dll DESTINATION ./)
+        install(FILES ${QT_PLUGINS_DIR}/../bin/QtGui4.dll DESTINATION ./)
+    else()
+        message("DEBUG installer build")
+        install(FILES ${PROJECT_SOURCE_DIR}/output/resources_d.cfg DESTINATION ./)
+        install(FILES ${PROJECT_SOURCE_DIR}/output/plugins_d.cfg DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/debug/OgreMain_d.dll DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/debug/RenderSystem_GL_d.dll DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/debug/OGREOVERLAY_D.DLL DESTINATION ./)
+        install(FILES ${OGRE_CMAKE_MODULE_PATH}/../bin/debug/OIS_D.DLL DESTINATION ./)
+        install(FILES ${QT_PLUGINS_DIR}/../bin/QtCored4.dll DESTINATION ./)
+        install(FILES ${QT_PLUGINS_DIR}/../bin/QtGuid4.dll DESTINATION ./)
+    endif()
+elseif(APPLE)
+    # APPLE is also UNIX, so must check for APPLE before UNIX
+    SET(CPACK_GENERATOR "DragNDrop")
+    if ("${CMAKE_BUILD_TYPE}" STREQUAL "" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+       set(OSX_BIN_DIR "${CMAKE_BINARY_DIR}/bin_release")
+       message("DEBUG installer build, CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} OSX_BIN_DIR=${OSX_BIN_DIR}")
+    else()
+       set(OSX_BIN_DIR "${CMAKE_BINARY_DIR}/bin_debug")
+       message("RELEASE installer build, CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} OSX_BIN_DIR=${OSX_BIN_DIR}")
+    endif()
+    install(FILES ${PROJECT_SOURCE_DIR}/output/resources.cfg DESTINATION ./)
+    install(FILES ${PROJECT_SOURCE_DIR}/output/plugins.cfg DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/Ogre DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/RenderSystem_GL DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/OgreOverlay DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_thread-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_date_time-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_system-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_atomic-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_chrono-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_program_options-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_filesystem-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/libboost_filesystem-mt.dylib DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/QtCore DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/QtGui DESTINATION ./)
+    install(FILES ${OSX_BIN_DIR}/liblua.dylib DESTINATION ./)
+elseif(UNIX)
+    # On Linux generate TAR.GZ,DEB and RPM packages
+    #Find out what architecture are we running on and set the package architecture 
+    
+    # set the generic files needing to be installed
+    install( FILES ${PROJECT_SOURCE_DIR}/v-gears.png DESTINATION ./share/pixmaps/ )
+    install( FILES ${PROJECT_SOURCE_DIR}/v-gears.desktop DESTINATION ./share/applications/ )
+    install( FILES ${PROJECT_SOURCE_DIR}/debian/menu DESTINATION share/menu/ RENAME v-gears )
+    install( FILES ${PROJECT_SOURCE_DIR}/output/plugins.cfg_linux DESTINATION share/v-gears/ RENAME plugins.cfg PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_WRITE WORLD_READ)
+    install( FILES ${PROJECT_SOURCE_DIR}/output/resources.cfg_linux DESTINATION share/v-gears/ RENAME resources.cfg PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_WRITE WORLD_READ)
+    install( FILES ${PROJECT_SOURCE_DIR}/output/v-gears.cfg_linux DESTINATION share/v-gears/ RENAME v-gears.cfg PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_WRITE WORLD_READ)
+        
+    if(EXISTS "/usr/lib/x86_64-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0")
+      install( FILES /usr/lib/x86_64-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0 DESTINATION lib/v-gears/plugins/ )
+    elseif(EXISTS "/usr/lib/i386-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0")
+      install( FILES /usr/lib/i386-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0 DESTINATION lib/v-gears/plugins/ )
+    endif()
+        
+    SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
+    SET(CPACK_GENERATOR "TGZ")
+    #detect Distro Family DEB , RPM 
+    if(EXISTS "/etc/lsb-release")
+        set(DistroType DEB)
+    elseif(EXISTS "/etc/debian_release")
+        set(DistroType DEB)
+    elseif(EXISTS "/etc/fedora-release")
+        set(DistroType RPM)
+    endif()
+    message(STATUS "Distro Detected: ${DistroType} ")
+
+    if(DistroType MATCHES "DEB")
+      # Setup DEB package properties
+      MESSAGE(STATUS "DEB ADDED TO GENERATION LIST")
+      SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
+    endif()
+    if(EXISTS "/usr/bin/rpmbuild")
+      MESSAGE(STATUS "RPM ADDED TO GENERATION LIST (RPM IS DISABLED IN CMAKELISTS)")
+    #  Uncomment to allow for rpm files to be built.   
+    #  SET(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
+    endif()
+    
+    # Setup DEB package properties
+    SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Chris Rizzitello <sithlord48@gmail.com>")
+    
+    
+    #Set DEBIAN INFO
+    SET(CPACK_DEBIAN_PACKAGE_SECTION games)
+    SET(CPACK_DEBIAN_PACKAGE_PRIORITY extra)
+    #SET(CPACK_PACKAGE_EXECUTABLE )
+    EXECUTE_PROCESS(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+    MESSAGE (STATUS "Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+    #we should need no longer need postinst since we have added extra install steps to what it would.
+    #SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/debian/postinst )
+    #set the name to be debian package like.
+    SET(CPACK_PACKAGE_FILE_NAME "v-gears_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+    #SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.9, libois,libboost-program-options,libboost-filesystem,libvorbis,libopenal,libboost-test,zlib1g")
+    SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.9.0, libois-1.3.0,libboost-program-options1.54.0,libboost-filesystem1.54.0,libvorbis0a,libvorbisfile3,libvorbisenc2,libopenal1,libboost-test1.54.0,zlib1g,liblua5.1-0")
+
+    #Set RPM info
+      SET(CPACK_RPM_PACKAGE_SUMMARY CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+      SET(CPACK_RPM_PACKAGE_NAME CPACK_PACKAGE_NAME)
+      SET(CPACK_RPM_PACKAGE_VERSION CPACK_PACKAGE_VERSION)
+      SET(CPACK_RPM_PACKAGE_RELEASE 1)
+      SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3+")
+      SET(CPACK_RPM_PACKAGE_GROUP games)
+      SET(CPACK_RPM_PACKAGE_VENDOR)
+      SET(CPACK_RPM_PACKAGE_DESCRIPTION)
+      #REQUIREMENTS NEED TO BE CHECKED USING FEDORA.
+      #SET(CPACK_RPM_PACKAGE_REQUIRES "ogre,ois,boost,vorbis,lua,zlib1g")
+
+endif()
+
+#SET_PROPERTY(TARGET liblua PROPERTY FOLDER "3rdparty")
+#SET_PROPERTY(TARGET buildvm PROPERTY FOLDER "3rdparty")
+SET_PROPERTY(TARGET LuaBind PROPERTY FOLDER "3rdparty")
+#SET_PROPERTY(TARGET luajit PROPERTY FOLDER "3rdparty")
+#SET_PROPERTY(TARGET minilua PROPERTY FOLDER "3rdparty")
+#SET_PROPERTY(TARGET TinyXml PROPERTY FOLDER "3rdparty")
+SET_PROPERTY(TARGET Sudm_Lib PROPERTY FOLDER "v-gears")
+
+
+INCLUDE(CPack)
+#End of install instructions

+ 339 - 0
COPYING.txt

@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

+ 3 - 0
PlugIns/CMakeLists.txt

@@ -0,0 +1,3 @@
+set(PLUGIN_PREFIX Plugin_)
+
+add_subdirectory(Data)

+ 59 - 0
PlugIns/Data/CMakeLists.txt

@@ -0,0 +1,59 @@
+set(QGearsMain_SOURCE_DIR ../../QGearsMain)
+
+# define header and source files for the library
+set(HEADER_FILES
+  ${QGearsMain_SOURCE_DIR}/include/QGearsPrerequisites.h
+  ${QGearsMain_SOURCE_DIR}/include/common/QGearsManualObject.h
+  ${QGearsMain_SOURCE_DIR}/include/common/QGearsStringUtil.h
+  ${QGearsMain_SOURCE_DIR}/include/common/TypeDefine.h
+  include/QGearsDataPlugin.h
+)
+set(SOURCE_FILES
+  ${QGearsMain_SOURCE_DIR}/src/common/QGearsManualObject.cpp
+  ${QGearsMain_SOURCE_DIR}/src/common/QGearsStringUtil.cpp
+  ${QGearsMain_SOURCE_DIR}/src/common/TypeDefine.cpp
+  src/QGearsDataPlugin.cpp
+  src/QGearsDataPluginDll.cpp
+)
+
+include_directories(
+    ${OIS_INCLUDE_DIRS}
+    ${OGRE_INCLUDE_DIRS}
+    ${OGRE_SAMPLES_INCLUDEPATH}
+    ${QGearsMain_SOURCE_DIR}/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../lib
+)
+
+#defines
+#add_definitions(-DBOOST_ALL_DYN_LINK)
+
+add_library(DataPlugin MODULE
+  ${HEADER_FILES}
+  ${SOURCE_FILES}
+)
+SET_PROPERTY(TARGET DataPlugin PROPERTY FOLDER "v-gears")
+
+set_target_properties(DataPlugin PROPERTIES
+  PREFIX ${PLUGIN_PREFIX}
+  OUTPUT_NAME Data
+)
+
+set(LIBRARIES
+  ${OGRE_LIBRARIES} 
+  FinalFantasy7
+  v-gears-data
+)
+
+target_link_libraries(DataPlugin ${LIBRARIES})
+
+if(NOT QGEARS_STATIC)
+  set_target_properties(DataPlugin PROPERTIES
+    COMPILE_DEFINITIONS QGEARS_DATAPLUGIN_EXPORTS
+  )
+    if(WIN32 OR APPLE)
+      install(TARGETS DataPlugin LIBRARY DESTINATION .)
+    else()
+      install(TARGETS DataPlugin LIBRARY DESTINATION ./lib/q-gears/plugins/ )
+    endif()
+endif()

+ 72 - 0
PlugIns/Data/include/QGearsDataPlugin.h

@@ -0,0 +1,72 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-30 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsTexPlugin_H__
+#define __QGearsTexPlugin_H__
+
+#include <OgrePlugin.h>
+
+#include "data/QGearsBackgroundFileManager.h"
+#include "data/QGearsPaletteFileManager.h"
+#include "data/QGearsPFileManager.h"
+#include "data/QGearsHRCFileManager.h"
+#include "data/QGearsRSDFileManager.h"
+#include "data/QGearsTexCodec.h"
+
+namespace QGears {
+
+	/** Plugin instance for various FFVII Data Formats */
+    class DataPlugin : public Ogre::Plugin
+    {
+    public:
+        DataPlugin();
+
+        /// @copydoc Ogre::Plugin::getName
+        const Ogre::String& getName() const;
+
+        /// @copydoc Ogre::Plugin::install
+        void install();
+
+        /// @copydoc Ogre::Plugin::initialise
+        void initialise();
+
+        /// @copydoc Ogre::Plugin::shutdown
+        void shutdown();
+
+        /// @copydoc Ogre::Plugin::uninstall
+        void uninstall();
+
+        static const Ogre::String ms_plugin_name;
+
+    private:
+        PFileManager           *p_manager;
+        HRCFileManager         *hrc_manager;
+        RSDFileManager         *rsd_manager;
+        PaletteFileManager     *palette_manager;
+        BackgroundFileManager  *background_manager;
+
+    };
+}
+#endif // __QGearsTexPlugin_H__

+ 4 - 0
PlugIns/Data/misc/QGearsData.def

@@ -0,0 +1,4 @@
+LIBRARY Plugin_Data
+EXPORTS	
+	dllStartPlugin
+	dllStopPlugin

+ 83 - 0
PlugIns/Data/src/QGearsDataPlugin.cpp

@@ -0,0 +1,83 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-30 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#include "QGearsDataPlugin.h"
+
+#include "data/QGearsTexCodec.h"
+
+using Ogre::String;
+
+namespace QGears {
+    const String DataPlugin::ms_plugin_name( "Plugin for Various FFVII File Formats" );
+
+    //---------------------------------------------------------------------
+    DataPlugin::DataPlugin()
+    {
+    }
+
+    //---------------------------------------------------------------------
+    const String& DataPlugin::getName() const
+    {
+        return ms_plugin_name;
+    }
+
+    //---------------------------------------------------------------------
+    void DataPlugin::install()
+    {
+        //install called - create stuff here
+        TexCodec::install();
+    }
+
+    //---------------------------------------------------------------------
+    void DataPlugin::initialise()
+    {
+        //intialise called - register stuff here
+        TexCodec::initialise();
+        p_manager           = new PFileManager();
+        hrc_manager         = new HRCFileManager();
+        rsd_manager         = new RSDFileManager();
+        //palette_manager     = new PaletteFileManager();
+        //background_manager  = new BackgroundFileManager();
+    }
+
+    //---------------------------------------------------------------------
+    void DataPlugin::shutdown()
+    {
+        //shutdown called - unregister stuff here
+        TexCodec::shutdown();
+        delete p_manager;
+        delete hrc_manager;
+        delete rsd_manager;
+        //delete palette_manager;
+        //delete background_manager;
+    }
+
+    //---------------------------------------------------------------------
+    void DataPlugin::uninstall()
+    {
+        //uninstall called - delete stuff here
+        TexCodec::uninstall();
+    }
+}

+ 53 - 0
PlugIns/Data/src/QGearsDataPluginDll.cpp

@@ -0,0 +1,53 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-30 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#include <OgreRoot.h>
+
+#include "QGearsDataPlugin.h"
+
+#ifndef QGEARS_STATIC_LIB
+
+namespace QGears
+{
+    DataPlugin* data_plugin( NULL );
+
+    extern "C" void _QGearsExport dllStartPlugin( void )
+    {
+        // Create new scene manager
+        data_plugin = new DataPlugin();
+
+        // Register
+        Ogre::Root::getSingleton().installPlugin( data_plugin );
+
+    }
+    extern "C" void _QGearsExport dllStopPlugin( void )
+    {
+	    Ogre::Root::getSingleton().uninstallPlugin( data_plugin );
+	    delete data_plugin;
+	    data_plugin = NULL;
+    }
+}
+
+#endif

+ 168 - 0
PlugIns/Data/test/tex_file_info.cpp

@@ -0,0 +1,168 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-31 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#include <algorithm>
+#include <cstdio>
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/fstream.hpp>
+#include <boost/program_options.hpp>
+
+#include <OgreDataStream.h>
+
+#include "data/QGearsTexFile.h"
+
+using std::back_inserter;
+using std::copy;
+using std::cout;
+using std::ifstream;
+using std::endl;
+using std::vector;
+using std::string;
+
+namespace bfs = boost::filesystem;
+namespace bpo = boost::program_options;
+
+void pintFileInfo( const bfs::path &tex_path )
+{
+    cout << endl << "TX Image File Info"
+         << endl << " filename: " << tex_path.filename().string();
+
+    bfs::ifstream *ifs(  OGRE_NEW_T( bfs::ifstream, Ogre::MEMCATEGORY_GENERAL )( tex_path, bfs::ifstream::binary ) );
+    Ogre::FileStreamDataStream *stream( OGRE_NEW Ogre::FileStreamDataStream( ifs ) );
+    Ogre::DataStreamPtr input( stream );
+
+    QGears::TexFile tex;
+    tex.readHeader( input );
+
+    cout << endl << " size: "
+         << tex.m_header.image_data.width
+         << "x" << tex.m_header.image_data.height
+         << "x" << tex.m_header.image_data.bit_depth
+         << endl << " pitch: " << tex.m_header.image_data.pitch
+         << endl << " color_key_flag: " << tex.m_header.color_key_flag
+         << endl << "Palette:"
+         << endl << " type              : " << tex.m_header.palette_type
+         << endl << " count             : " << tex.m_header.palette_count
+         << endl << " index_bits        : " << tex.m_header.palette_data.index_bits
+         << endl << " flag              : " << tex.m_header.palette_data.flag
+         << endl << " total_color_count : " << tex.m_header.palette_total_color_count
+         << endl << " total_color_count : " << tex.m_header.palette_data.total_color_count
+         << endl << " colors_per_palette: " << tex.m_header.palette_data.colors_per_palette
+         << endl << " unknown_CC        : " << tex.m_header.unknown_0xCC
+         ;
+    if ( tex.m_header.palette_data.flag )
+    {
+    cout << endl << " mask_red   : " << tex.m_header.pixel_format.bit_mask.red
+         << endl << " mask_green : " << tex.m_header.pixel_format.bit_mask.green
+         << endl << " mask_blue  : " << tex.m_header.pixel_format.bit_mask.blue
+         << endl << " mask_alpha : " << tex.m_header.pixel_format.bit_mask.alpha
+         ;
+    }
+    cout << endl;
+}
+
+int
+main(int ac, char *av[])
+{
+    const char* PO_HELP( "help" );
+    const char* PO_INPUT_PATHS( "input-paths" );
+    const string TEX_EXT( ".tex" );
+
+    typedef vector<bfs::path> t_InputPaths;
+
+    try {
+        bpo::options_description generic("Generic options");
+        generic.add_options()
+            ( PO_HELP, "produce help message" )
+            ;
+
+        // Hidden options, will be allowed both on command line and
+        // in config file, but will not be shown to the user.
+        bpo::options_description hidden("Hidden options");
+        hidden.add_options()
+            ( PO_INPUT_PATHS, bpo::value< t_InputPaths >()->required(), "input paths to files or directories" )
+            ;
+
+        bpo::positional_options_description p;
+        p.add( PO_INPUT_PATHS, -1 );
+
+        bpo::options_description cmdline_options;
+        cmdline_options.add( generic ).add( hidden );
+        bpo::variables_map vm;
+        bpo::store( bpo::command_line_parser( ac, av ).options( cmdline_options ).positional( p ).run(), vm );
+
+        if ( vm.count( PO_HELP ) )
+        {
+            bfs::path self( av[0] );
+            cout << "Usage: " << self.stem().string() << " [options] file|path...\n";
+            cout << generic << "\n";
+            return 0;
+        }
+
+        bpo::notify( vm );
+
+        if ( vm.count( PO_INPUT_PATHS ) )
+        {
+            t_InputPaths input( vm[ PO_INPUT_PATHS ].as< t_InputPaths >() );
+            t_InputPaths paths;
+
+            for ( t_InputPaths::const_iterator it( input.begin() ); it != input.end(); ++it )
+            {
+                if( bfs::exists( *it ) )
+                {
+                    if( bfs::is_directory( *it ) )
+                    {
+                        copy( bfs::recursive_directory_iterator( *it ), bfs::recursive_directory_iterator(), back_inserter( paths ) );
+                    }
+                    else
+                    {
+                        paths.push_back( *it );
+                    }
+                }
+            }
+
+            for ( t_InputPaths::const_iterator it( paths.begin() ); it != paths.end(); ++it )
+            {
+                if( bfs::is_regular_file( *it ) )
+                {
+                    string ext( it->extension().string() );
+                    if( boost::iequals( ext, TEX_EXT ) )
+                    {
+                        pintFileInfo( *it );
+                    }
+                }
+            }
+        }
+
+    }
+    catch( const bfs::filesystem_error& e )
+    {
+        cout << e.what() << endl;
+        return 1;
+    }
+    return 0;
+}

+ 170 - 0
PlugIns/Data/test/tex_file_test.cpp

@@ -0,0 +1,170 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-31 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+
+#include <fstream>
+
+#include <OgreDataStream.h>
+
+#include "data/QGearsTexFile.h"
+
+#define BOOST_TEST_MODULE QGearsTexFile
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE( header_size )
+{
+    BOOST_CHECK_EQUAL( 0x18, sizeof( QGears::TexFile::BitData     ) );
+    BOOST_CHECK_EQUAL( 0x10, sizeof( QGears::TexFile::ImageData   ) );
+    BOOST_CHECK_EQUAL( 0x14, sizeof( QGears::TexFile::PaletteData ) );
+    BOOST_CHECK_EQUAL( 0x10, sizeof( QGears::TexFile::RGBAData    ) );
+    BOOST_CHECK_EQUAL( 0x58, sizeof( QGears::TexFile::PixelFormat ) );
+    BOOST_CHECK_EQUAL( 0xEC, sizeof( QGears::TexFile::Header      ) );
+
+    QGears::TexFile::Header header;
+    BOOST_CHECK_EQUAL( sizeof( QGears::TexFile::Header ), sizeof( header ) );
+}
+
+BOOST_AUTO_TEST_CASE( bit_data_offset )
+{
+    BOOST_CHECK_EQUAL( 0x00, offsetof( QGears::TexFile::BitData, color_min ) );
+    BOOST_CHECK_EQUAL( 0x04, offsetof( QGears::TexFile::BitData, color_max ) );
+    BOOST_CHECK_EQUAL( 0x08, offsetof( QGears::TexFile::BitData, alpha_min ) );
+    BOOST_CHECK_EQUAL( 0x0C, offsetof( QGears::TexFile::BitData, alpha_max ) );
+    BOOST_CHECK_EQUAL( 0x10, offsetof( QGears::TexFile::BitData, pixel_min ) );
+    BOOST_CHECK_EQUAL( 0x14, offsetof( QGears::TexFile::BitData, pixel_max ) );
+}
+
+BOOST_AUTO_TEST_CASE( palette_data_offset )
+{
+    BOOST_CHECK_EQUAL( 0x00, offsetof( QGears::TexFile::PaletteData, flag        ) );
+    BOOST_CHECK_EQUAL( 0x04, offsetof( QGears::TexFile::PaletteData, index_bits  ) );
+    BOOST_CHECK_EQUAL( 0x08, offsetof( QGears::TexFile::PaletteData, index_8bit  ) );
+    BOOST_CHECK_EQUAL( 0x0C, offsetof( QGears::TexFile::PaletteData, total_color_count ) );
+    BOOST_CHECK_EQUAL( 0x10, offsetof( QGears::TexFile::PaletteData, colors_per_palette ) );
+}
+
+BOOST_AUTO_TEST_CASE( image_data_offset )
+{
+    BOOST_CHECK_EQUAL( 0x0, offsetof( QGears::TexFile::ImageData, bit_depth  ) );
+    BOOST_CHECK_EQUAL( 0x4, offsetof( QGears::TexFile::ImageData, width  ) );
+    BOOST_CHECK_EQUAL( 0x8, offsetof( QGears::TexFile::ImageData, height ) );
+    BOOST_CHECK_EQUAL( 0xC, offsetof( QGears::TexFile::ImageData, pitch  ) );
+}
+
+BOOST_AUTO_TEST_CASE( rgba_data_offset )
+{
+    BOOST_CHECK_EQUAL( 0x0, offsetof( QGears::TexFile::RGBAData, red   ) );
+    BOOST_CHECK_EQUAL( 0x4, offsetof( QGears::TexFile::RGBAData, green ) );
+    BOOST_CHECK_EQUAL( 0x8, offsetof( QGears::TexFile::RGBAData, blue  ) );
+    BOOST_CHECK_EQUAL( 0xC, offsetof( QGears::TexFile::RGBAData, alpha ) );
+}
+
+BOOST_AUTO_TEST_CASE( pixel_format_offset )
+{
+    BOOST_CHECK_EQUAL( 0x00, offsetof( QGears::TexFile::PixelFormat, bits_per_pixel   ) );
+    BOOST_CHECK_EQUAL( 0x04, offsetof( QGears::TexFile::PixelFormat, bytes_per_pixel  ) );
+    BOOST_CHECK_EQUAL( 0x08, offsetof( QGears::TexFile::PixelFormat, bit_count        ) );
+    BOOST_CHECK_EQUAL( 0x18, offsetof( QGears::TexFile::PixelFormat, bit_mask         ) );
+    BOOST_CHECK_EQUAL( 0x28, offsetof( QGears::TexFile::PixelFormat, bit_shift        ) );
+    BOOST_CHECK_EQUAL( 0x38, offsetof( QGears::TexFile::PixelFormat, bit_count_unused ) );
+    BOOST_CHECK_EQUAL( 0x48, offsetof( QGears::TexFile::PixelFormat, shades           ) );
+}
+
+BOOST_AUTO_TEST_CASE( header_offset )
+{
+    BOOST_CHECK_EQUAL( 0x00, offsetof( QGears::TexFile::Header, version              ) );
+    BOOST_CHECK_EQUAL( 0x08, offsetof( QGears::TexFile::Header, color_key_flag       ) );
+    BOOST_CHECK_EQUAL( 0x14, offsetof( QGears::TexFile::Header, bit_data             ) );
+    BOOST_CHECK_EQUAL( 0x30, offsetof( QGears::TexFile::Header, palette_count        ) );
+    BOOST_CHECK_EQUAL( 0x34, offsetof( QGears::TexFile::Header, palette_total_color_count  ) );
+    BOOST_CHECK_EQUAL( 0x38, offsetof( QGears::TexFile::Header, image_data           ) );
+    BOOST_CHECK_EQUAL( 0x4C, offsetof( QGears::TexFile::Header, palette_data         ) );
+    BOOST_CHECK_EQUAL( 0x64, offsetof( QGears::TexFile::Header, pixel_format         ) );
+    BOOST_CHECK_EQUAL( 0xBC, offsetof( QGears::TexFile::Header, color_key_array_flag ) );
+    BOOST_CHECK_EQUAL( 0xC4, offsetof( QGears::TexFile::Header, reference_alpha      ) );
+    BOOST_CHECK_EQUAL( 0xCC, offsetof( QGears::TexFile::Header, unknown_0xCC         ) );
+}
+
+BOOST_AUTO_TEST_CASE( color_offset )
+{
+    BOOST_CHECK_EQUAL( 0x0, offsetof( QGears::TexFile::Color, all        ) );
+    BOOST_CHECK_EQUAL( 0x0, offsetof( QGears::TexFile::Color, comp       ) );
+    BOOST_CHECK_EQUAL( 0x3, offsetof( QGears::TexFile::Color, comp.alpha ) );
+    BOOST_CHECK_EQUAL( 0x2, offsetof( QGears::TexFile::Color, comp.red   ) );
+    BOOST_CHECK_EQUAL( 0x1, offsetof( QGears::TexFile::Color, comp.green ) );
+    BOOST_CHECK_EQUAL( 0x0, offsetof( QGears::TexFile::Color, comp.blue  ) );
+}
+
+BOOST_AUTO_TEST_CASE( read_file )
+{
+    const char* file_name( "../../../../output/data_orig/menu/menu_gm/barre.tex" );
+    std::ifstream *ifs(  OGRE_NEW_T( std::ifstream, Ogre::MEMCATEGORY_GENERAL )( file_name, std::ifstream::binary ) );
+    BOOST_REQUIRE( ifs->is_open() );
+    Ogre::FileStreamDataStream *stream( OGRE_NEW Ogre::FileStreamDataStream( ifs ) );
+    Ogre::DataStreamPtr input( stream );
+
+    BOOST_REQUIRE( input->isReadable() );
+
+    QGears::TexFile tex;
+    tex.read( input );
+
+    BOOST_CHECK_EQUAL( 0x80, tex.m_header.image_data.width );
+    BOOST_CHECK_EQUAL( 0x80, tex.m_header.image_data.height );
+    BOOST_CHECK_EQUAL(    8, tex.m_header.image_data.bit_depth );
+
+    BOOST_CHECK_EQUAL(     1, tex.m_header.palette_count );
+    BOOST_CHECK_EQUAL(     1, tex.m_header.palette_data.flag );
+    BOOST_CHECK_EQUAL( 0x100, tex.m_header.palette_data.total_color_count );
+    BOOST_CHECK_EQUAL( 0x80 * 0x80, tex.m_image_data.size() );
+
+    for( size_t i(0); i < 39; ++i )
+    {
+        BOOST_TEST_MESSAGE( "checking color i: " << i );
+        BOOST_CHECK_EQUAL( 0xFFFFFFFF, tex.m_image_data[i].all );
+    }
+    BOOST_CHECK_EQUAL( 0xFFF6FFF6, tex.m_image_data[39].all );
+    BOOST_CHECK_EQUAL( 0xF6, tex.m_image_data[39].comp.red );
+    BOOST_CHECK_EQUAL( 0xFF, tex.m_image_data[39].comp.green );
+    BOOST_CHECK_EQUAL( 0xF6, tex.m_image_data[39].comp.blue );
+    BOOST_CHECK_EQUAL( 0xFF, tex.m_image_data[39].comp.alpha );
+
+    BOOST_CHECK_EQUAL( 0x7B, tex.m_image_data[40].comp.red );
+    BOOST_CHECK_EQUAL( 0xA4, tex.m_image_data[40].comp.green );
+    BOOST_CHECK_EQUAL( 0xA4, tex.m_image_data[40].comp.blue );
+    BOOST_CHECK_EQUAL( 0xFF, tex.m_image_data[40].comp.alpha );
+
+
+	Ogre::MemoryDataStreamPtr pixel_data( tex.getPixelData() );
+    BOOST_CHECK_EQUAL( tex.m_image_data.size() * 4, pixel_data->size() );
+
+	Ogre::SharedPtr<Ogre::ImageCodec::ImageData> img_data( tex.getImageData() );
+    BOOST_CHECK_EQUAL( img_data->width , tex.m_header.image_data.width );
+    BOOST_CHECK_EQUAL( img_data->height, tex.m_header.image_data.height );
+    BOOST_CHECK_EQUAL( Ogre::PF_A8R8G8B8, img_data->format );
+    BOOST_CHECK_EQUAL( 1, img_data->depth );
+    BOOST_CHECK_EQUAL( 0, img_data->flags );
+    BOOST_CHECK_EQUAL( 0, img_data->num_mipmaps );
+    BOOST_CHECK_EQUAL( pixel_data->size(), img_data->size );
+}

+ 423 - 0
QGearsMain/CMakeLists.txt

@@ -0,0 +1,423 @@
+# define header and source files for the library
+set(HEADER_FILES
+  include/modules/worldmap/WorldMapModule.h
+
+  include/common/QGearsManualObject.h
+  include/common/QGearsResource.h
+  include/common/QGearsStringUtil.h
+  include/common/TypeDefine.h
+  include/common/LzsFile.h
+  include/common/File.h
+  include/common/FileSystem.h
+  include/common/make_unique.h
+  include/map/QGearsBackground2DFile.h
+  include/map/QGearsBackground2DFileManager.h
+  include/map/QGearsBackground2DFileXMLSerializer.h
+  include/map/QGearsTile.h
+  include/map/QGearsMapFile.h
+  include/map/QGearsMapFileManager.h
+  include/map/QGearsMapFileXMLSerializer.h
+  include/map/QGearsWalkmeshFile.h
+  include/map/QGearsWalkmeshFileManager.h
+  include/map/QGearsWalkmeshFileXMLSerializer.h
+  include/LuaIncludes.h
+  include/QGearsGameState.h
+  include/QGearsPrerequisites.h
+  include/core/particles/emitters/ParticlePointEmitter.h
+  include/core/particles/emitters/ParticlePointEmitterFactory.h
+  include/core/particles/renderer/ParticleEntityAdditionalData.h
+  include/core/particles/renderer/ParticleEntityRenderer.h
+  include/core/particles/renderer/ParticleEntityRendererDictionary.h
+  include/core/particles/renderer/ParticleEntityRendererFactory.h
+  include/core/particles/Particle.h
+  include/core/particles/ParticleAdditionalData.h
+  include/core/particles/ParticleEmitter.h
+  include/core/particles/ParticleEmitterDictionary.h
+  include/core/particles/ParticleEmitterFactory.h
+  include/core/particles/ParticleEmitterTranslator.h
+  include/core/particles/ParticlePool.h
+  include/core/particles/ParticlePoolMap.h
+  include/core/particles/ParticleRenderer.h
+  include/core/particles/ParticleRendererFactory.h
+  include/core/particles/ParticleRendererTranslator.h
+  include/core/particles/ParticleSystem.h
+  include/core/particles/ParticleSystemFactory.h
+  include/core/particles/ParticleSystemManager.h
+  include/core/particles/ParticleSystemTranslator.h
+  include/core/particles/ParticleSystemTranslatorManager.h
+  include/core/particles/ParticleTechnique.h
+  include/core/particles/ParticleTechniqueTranslator.h
+  include/core/particles/ParticleVisual.h
+  include/core/Assert.h
+  include/core/Background2D.h
+  include/core/Background2DAnimation.h
+  include/core/CameraManager.h
+  include/core/CameraManagerCommands.h
+  include/core/ConfigCmd.h
+  include/core/ConfigCmdManager.h
+  include/core/ConfigCmdManagerCommands.h
+  include/core/ConfigFile.h
+  include/core/ConfigVar.h
+  include/core/ConfigVarManager.h
+  include/core/Console.h
+  include/core/DebugDraw.h
+  include/core/Entity.h
+  include/core/EntityCollision.h
+  include/core/EntityDirection.h
+  include/core/EntityManager.h
+  include/core/EntityModel.h
+  include/core/EntityPoint.h
+  include/core/EntityTrigger.h
+  include/core/Event.h
+  include/core/GameFrameListner.h
+  include/core/InputManager.h
+  include/core/InputManagerCommands.h
+  include/core/Logger.h
+  include/core/Module.h
+  include/core/ScriptManager.h
+  include/core/ScriptManagerBinds.h
+  include/core/ScriptManagerCommands.h
+  include/core/Timer.h
+  include/core/UiAnimation.h
+  include/core/UiFont.h
+  include/core/UiManager.h
+  include/core/UiSprite.h
+  include/core/UiTextArea.h
+  include/core/UiWidget.h
+  include/core/Utilites.h
+  include/core/Walkmesh.h
+  include/core/XmlBackground2DFile.h
+  include/core/XmlFile.h
+  include/core/XmlFontFile.h
+  include/core/XmlFontsFile.h
+  include/core/XmlMapFile.h
+  #include/core/XmlMapsFile.h
+  include/core/XmlPrototypesFile.h
+  include/core/XmlScreenFile.h
+  include/core/XmlScreensFile.h
+  include/core/XmlScriptsFile.h
+  include/core/XmlTextFile.h
+  include/core/XmlTextsFile.h
+  include/core/DialogsManager.h
+  include/core/ScriptManagerBinds.h
+  include/core/TextManager.h
+  include/core/TextManagerCommands.h
+  #include/viewer/ViewerModule.h
+  include/data/QGearsXMLSerializer.h
+)
+
+set(HEADER_FILES_DATA
+  include/common/QGearsApplication.h
+include/data/worldmap/MapFile.h
+  include/data/worldmap/MapFileManager.h
+  include/data/worldmap/MapFileSerializer.h
+  include/data/worldmap/TxzFile.h
+  include/data/worldmap/TxzFileManager.h
+  include/data/worldmap/TxzFileSerializer.h
+  include/data/QGearsAFile.h
+  include/data/QGearsAFileManager.h
+  include/data/QGearsAFileSerializer.h
+  include/data/QGearsBackgroundFile.h
+  include/data/QGearsBackgroundFileManager.h
+  include/data/QGearsBackgroundFileSerializer.h
+  include/data/QGearsBackgroundTextureLoader.h
+  include/data/QGearsCameraMatrixFile.h
+  include/data/QGearsCameraMatrixFileManager.h
+  include/data/QGearsCameraMatrixFileSerializer.h
+  include/data/QGearsFLevelBackground2DLoader.h
+  include/data/QGearsFLevelFile.h
+  include/data/QGearsFLevelFileManager.h
+  include/data/QGearsFLevelFileSerializer.h
+  include/data/QGearsFLevelTextureLoader.h
+  include/data/QGearsHRCFile.h
+  include/data/QGearsHRCFileManager.h
+  include/data/QGearsHRCFileSerializer.h
+  include/data/QGearsHRCMeshLoader.h
+  include/data/QGearsHRCSkeletonLoader.h
+  include/data/QGearsLGPArchive.h
+  include/data/QGearsLGPArchiveFactory.h
+  include/data/QGearsLGPArchiveSerializer.h
+  include/data/QGearsLZSDataStream.h
+  include/data/QGearsLZSFLevelFile.h
+  include/data/QGearsLZSFLevelFileManager.h
+  include/data/QGearsPaletteFile.h
+  include/data/QGearsPaletteFileManager.h
+  include/data/QGearsPaletteFileSerializer.h
+  include/data/QGearsPFile.h
+  include/data/QGearsPFileManager.h
+  include/data/QGearsPFileSerializer.h
+  include/data/QGearsRSDFile.h
+  include/data/QGearsRSDFileManager.h
+  include/data/QGearsRSDFileSerializer.h
+  include/data/QGearsSerializer.h
+  include/data/QGearsTexCodec.h
+  include/data/QGearsTexFile.h
+  include/data/QGearsTriggersFile.h
+  include/data/QGearsMapListFile.h
+)
+
+set(SOURCE_FILES_DATA
+  src/common/QGearsApplication.cpp
+  src/data/QGearsAFile.cpp
+  src/data/QGearsAFileManager.cpp
+  src/data/QGearsAFileSerializer.cpp
+  src/data/worldmap/MapFile.cpp
+  src/data/worldmap/MapFileManager.cpp
+  src/data/worldmap/MapFileSerializer.cpp
+  src/data/worldmap/TxzFile.cpp
+  src/data/worldmap/TxzFileManager.cpp
+  src/data/worldmap/TxzFileSerializer.cpp
+  src/data/QGearsBackgroundFile.cpp
+  src/data/QGearsBackgroundFileManager.cpp
+  src/data/QGearsBackgroundFileSerializer.cpp
+  src/data/QGearsBackgroundTextureLoader.cpp
+  src/data/QGearsCameraMatrixFile.cpp
+  src/data/QGearsCameraMatrixFileManager.cpp
+  src/data/QGearsCameraMatrixFileSerializer.cpp
+  src/data/QGearsFLevelBackground2DLoader.cpp
+  src/data/QGearsFLevelFile.cpp
+  src/data/QGearsFLevelFileManager.cpp
+  src/data/QGearsFLevelFileSerializer.cpp
+  src/data/QGearsFLevelTextureLoader.cpp
+  src/data/QGearsHRCFile.cpp
+  src/data/QGearsHRCFileManager.cpp
+  src/data/QGearsHRCFileSerializer.cpp
+  src/data/QGearsHRCMeshLoader.cpp
+  src/data/QGearsHRCSkeletonLoader.cpp
+  src/data/QGearsLGPArchive.cpp
+  src/data/QGearsLGPArchiveFactory.cpp
+  src/data/QGearsLGPArchiveSerializer.cpp
+  src/data/QGearsLZSDataStream.cpp
+  src/data/QGearsLZSFLevelFile.cpp
+  src/data/QGearsLZSFLevelFileManager.cpp
+  src/data/QGearsPaletteFile.cpp
+  src/data/QGearsPaletteFileManager.cpp
+  src/data/QGearsPaletteFileSerializer.cpp
+  src/data/QGearsPFile.cpp
+  src/data/QGearsPFileManager.cpp
+  src/data/QGearsPFileSerializer.cpp
+  src/data/QGearsRSDFile.cpp
+  src/data/QGearsRSDFileManager.cpp
+  src/data/QGearsRSDFileSerializer.cpp
+  src/data/QGearsSerializer.cpp
+  src/data/QGearsTexCodec.cpp
+  src/data/QGearsTexFile.cpp
+  src/data/QGearsTriggersFile.cpp
+  src/data/QGearsMapListFile.cpp
+)
+
+set(SOURCE_FILES
+  src/modules/worldmap/WorldMapModule.cpp
+
+  src/common/QGearsManualObject.cpp
+  src/common/QGearsResource.cpp
+  src/common/QGearsStringUtil.cpp
+  src/common/TypeDefine.cpp
+  src/common/LzsFile.cpp
+  src/common/File.cpp
+  src/common/FileSystem.cpp
+  src/core/particles/emitters/ParticlePointEmitter.cpp
+  src/core/particles/Particle.cpp
+  src/core/particles/ParticleEmitter.cpp
+  src/core/particles/ParticleEmitterDictionary.cpp
+  src/core/particles/ParticleEmitterTranslator.cpp
+  src/core/particles/ParticleRenderer.cpp
+  src/core/particles/ParticleRendererTranslator.cpp
+  src/core/particles/ParticleSystem.cpp
+  src/core/particles/ParticleSystemFactory.cpp
+  src/core/particles/ParticleSystemManager.cpp
+  src/core/particles/ParticleSystemTranslator.cpp
+  src/core/particles/ParticleSystemTranslatorManager.cpp
+  src/core/particles/ParticleTechnique.cpp
+  src/core/particles/ParticleTechniqueTranslator.cpp
+  src/core/particles/ParticleVisual.cpp
+  src/core/particles/renderer/ParticleEntityRenderer.cpp
+  src/core/particles/renderer/ParticleEntityRendererDictionary.cpp
+  src/core/Background2D.cpp
+  src/core/Background2DAnimation.cpp
+  src/core/CameraManager.cpp
+  src/core/ConfigCmd.cpp
+  src/core/ConfigCmdManager.cpp
+  src/core/ConfigFile.cpp
+  src/core/ConfigVar.cpp
+  src/core/ConfigVarManager.cpp
+  src/core/Console.cpp
+  src/core/DebugDraw.cpp
+  src/core/Entity.cpp
+  src/core/EntityCollision.cpp
+  src/core/EntityDirection.cpp
+  src/core/EntityManager.cpp
+  src/core/EntityModel.cpp
+  src/core/EntityPoint.cpp
+  src/core/EntityTrigger.cpp
+  src/core/GameFrameListner.cpp
+  src/core/InputManager.cpp
+  src/core/ScriptManager.cpp
+  src/core/Timer.cpp
+  src/core/UiAnimation.cpp
+  src/core/UiFont.cpp
+  src/core/UiManager.cpp
+  src/core/UiSprite.cpp
+  src/core/UiTextArea.cpp
+  src/core/UiWidget.cpp
+  src/core/Utilites.cpp
+  src/core/Walkmesh.cpp
+  src/core/XmlBackground2DFile.cpp
+  src/core/XmlFile.cpp
+  src/core/XmlFontFile.cpp
+  src/core/XmlFontsFile.cpp
+  src/core/XmlMapFile.cpp
+  src/core/XmlMapsFile.cpp
+  src/core/XmlPrototypesFile.cpp
+  src/core/XmlScreenFile.cpp
+  src/core/XmlScreensFile.cpp
+  src/core/XmlScriptsFile.cpp
+  src/core/XmlTextFile.cpp
+  src/core/XmlTextsFile.cpp
+  src/core/DialogsManager.cpp
+  src/core/TextManager.cpp
+  src/map/QGearsBackground2DFile.cpp
+  src/map/QGearsBackground2DFileManager.cpp
+  src/map/QGearsBackground2DFileXMLSerializer.cpp
+  src/map/QGearsMapFile.cpp
+  src/map/QGearsMapFileManager.cpp
+  src/map/QGearsMapFileXMLSerializer.cpp
+  src/map/QGearsWalkmeshFile.cpp
+  src/map/QGearsWalkmeshFileManager.cpp
+  src/map/QGearsWalkmeshFileXMLSerializer.cpp
+  #src/viewer/ViewerModule.cpp
+  src/QGearsGameState.cpp
+  src/data/QGearsXMLSerializer.cpp
+)
+if(VGears_SOUND)
+    set(HEADER_FILES
+        ${HEADER_FILES}
+        include/core/AudioManager.h
+        include/core/XmlMusicsFile.h
+    )
+    set(SOURCE_FILES
+        ${SOURCE_FILES}
+        src/core/AudioManager.cpp
+        src/core/XmlMusicsFile.cpp
+    )
+endif()
+
+set(ois_lib "/usr/lib/x86_64-linux-gnu/libOIS.so")
+
+#set(luabind_lib "/usr/lib/x86_64-linux-gnu/libluabind.a")
+#set(luabind_lib "${VGears_SOURCE_DIR}/lib/libluabind.a")
+#set(luabind_lib "/usr/lib/x86_64-linux-gnu/libluabind.so.0.9.1d1")
+#set(lua_lib "/usr/lib/x86_64-linux-gnu/liblua5.1.so.0")
+
+include_directories(
+    ${VGears_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/include
+
+    # TODO: remove dependency on ff7 related code
+    ${VGears_SOURCE_DIR}/SupportedGames/FinalFantasy7/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/SupportedGames/FinalFantasy7/include
+    /usr/include/OIS/
+
+)
+
+#compiler options
+if (MSVC)
+else()
+if(WIN32)
+    add_definitions(
+      -W
+      -mthreads
+      -fmessage-length=0
+      -fexceptions
+      -fident
+    )
+
+    #linker options
+    add_definitions(
+      -Wl,--enable-runtime-pseudo-reloc
+      -Wl,--enable-auto-image-base
+      -Wl,--add-stdcall-alias
+    )
+endif()
+endif()
+
+#defines
+if(WIN32)
+  #check usage and remove if uneccessary
+  add_definitions(-DWIN32 -D__WIN32__ -D_WINDOWS)
+endif()
+
+add_library(QGearsMain STATIC
+  ${HEADER_FILES}
+  ${SOURCE_FILES}
+  /usr/include/OIS/
+)
+
+# Coverage uses more memory, combined with PCH can cause OOM/ICE
+#if ($ENV{COVERAGE}!=1)
+cotire(QGearsMain)
+#endif()
+SET_PROPERTY(TARGET QGearsMain PROPERTY FOLDER "v-gears")
+
+add_library(v-gears-data STATIC
+ ${HEADER_FILES_DATA}
+ ${SOURCE_FILES_DATA}
+ )
+add_dependencies(v-gears-data configure_vgears_version)
+# Coverage uses more memory, combined with PCH can cause OOM/ICE
+if ($ENV{COVERAGE}!=1)
+cotire(v-gears-data)
+endif()
+SET_PROPERTY(TARGET v-gears-data PROPERTY FOLDER "v-gears")
+
+
+add_executable(v-gears
+  src/Main.cpp
+)
+SET_PROPERTY(TARGET v-gears PROPERTY FOLDER "v-gears")
+set(CPACK_PACKAGE_EXECUTABLES v-gears "v-gears")
+set(CPACK_WIX_PROGRAM_MENU_FOLDER "VGears")
+
+if (APPLE)
+target_link_libraries(q-gears "-framework CoreFoundation -framework Cocoa -framework IOKit" ${ois_lib})
+endif()
+
+if( WIN32 AND NOT (CMAKE_BUILD_TYPE MATCHES "Debug") )
+    set_target_properties( q-gears PROPERTIES WIN32_EXECUTABLE ON )
+	if (MSVC)
+        set_target_properties(q-gears PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
+    endif()
+endif()
+
+target_link_libraries(QGearsMain 
+    ${VGears_LIBRARIES}
+    #lua5.2
+    LuaBind
+    liblua
+    tinyxml
+    FinalFantasy7
+    ${ois_lib}
+    #${lua_lib}
+    #${luabind_lib}
+)
+
+target_link_libraries(v-gears 
+	QGearsMain
+	${Boost_LIBRARIES}
+    v-gears-data
+    ${ois_lib}
+    #${luabind_lib}
+    #luabind
+)
+
+target_link_libraries(v-gears-data
+    QGearsMain
+    ${ois_lib}
+    #${luabind_lib}
+)
+
+if(WIN32 OR APPLE)
+  install(TARGETS v-gears DESTINATION .)
+else()
+  install(TARGETS v-gears RUNTIME DESTINATION ./games)
+endif()

+ 25 - 0
QGearsMain/include/LuaIncludes.h

@@ -0,0 +1,25 @@
+#pragma once
+
+// Wraps the LUA includes for platform specific build workarounds
+#ifdef __APPLE__
+// Something in the Apple headers seems to #define nil as __NULL 
+// this then causes a build error in luabind:
+// luabind/nil.hpp:36:40: error: expected unqualified-id
+// extern LUABIND_API detail::nil_type nil;
+#undef nil
+
+// Causes a build error, usually an ICE on g++
+#undef check
+#endif
+
+#include <luabind/luabind.hpp>
+#include <luabind/yield_policy.hpp>
+
+
+extern "C"
+{
+    #include "lua.h"
+    #include <lualib.h>
+    #include <lauxlib.h>
+}
+

+ 15 - 0
QGearsMain/include/QGearsGameState.h

@@ -0,0 +1,15 @@
+#ifndef __QGearsGameState_H__
+#define __QGearsGameState_H__
+
+namespace QGears
+{
+    enum GAME_STATE
+    {
+        G_EXIT,
+        G_GAME
+    };
+
+    extern GAME_STATE g_ApplicationState;
+}
+
+#endif // __QGearsGameState_H__

+ 44 - 0
QGearsMain/include/QGearsPrerequisites.h

@@ -0,0 +1,44 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-07-30 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsPrerequisites_H__
+#define __QGearsPrerequisites_H__
+
+#include <OgrePrerequisites.h>
+
+#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 ) && !defined(_MSC_VER) && !defined(QGEARS_STATIC_LIB)
+#   ifdef QGEARS_EXPORTS
+#       define _QGearsExport __declspec(dllexport)
+#   else
+#       define _QGearsExport __declspec(dllimport)
+#   endif
+#elif defined ( OGRE_GCC_VISIBILITY )
+#   define _QGearsExport  __attribute__ ((visibility("default")))
+#else
+#   define _QGearsExport
+#endif
+
+
+#endif // __QGearsPrerequisites_H__

+ 38 - 0
QGearsMain/include/common/File.h

@@ -0,0 +1,38 @@
+#ifndef FILE_H
+#define FILE_H
+
+#include <OgreString.h>
+
+#include "common/TypeDefine.h"
+
+
+class File
+{
+public:
+    File( const Ogre::String& file );
+    File( const File* pFile );
+    File( const File* pFile, u32 offset, u32 length );
+    File( const u8* pBuffer, u32 offset, u32 length );
+    virtual ~File();
+
+    void WriteFile( const Ogre::String& file ) const;
+    const Ogre::String& GetFileName() const;
+    u32 GetFileSize() const;
+    void GetFileBuffer( u8* pBuffer, const u32 &start, const u32 &length ) const;
+    u8 GetU8( u32 offset ) const;
+    u16 GetU16LE( u32 offset ) const;
+    u32 GetU32LE( u32 offset ) const;
+    u8 readU8();
+    u16 readU16LE();
+    u32 readU32LE();
+
+protected:
+    Ogre::String m_FileName;
+    u32 m_offset;
+    u8* m_Buffer;
+    u32 m_BufferSize;
+};
+
+
+
+#endif // FILE_H

+ 17 - 0
QGearsMain/include/common/FileSystem.h

@@ -0,0 +1,17 @@
+#ifndef FILESYSTEM_H
+#define FILESYSTEM_H
+
+#include <OgreString.h>
+
+class FileSystem
+{
+public:
+    FileSystem() = delete;
+    static unsigned int GetFileSize(const Ogre::String& path);
+    static bool         ReadFile(const Ogre::String &path, void* buffer, const unsigned int start, const unsigned int length);
+    static bool         WriteFile(const Ogre::String &path, const void* buffer, const unsigned int length);
+    static bool         WriteNewFile(const Ogre::String &path, const void* buffer, const unsigned int length);
+    static bool         RemoveFile(const Ogre::String &path);
+};
+
+#endif // FILESYSTEM_H

+ 30 - 0
QGearsMain/include/common/LzsFile.h

@@ -0,0 +1,30 @@
+#ifndef LZS_FILE_H
+#define LZS_FILE_H
+
+#include "common/File.h"
+#include "common/TypeDefine.h"
+#include <vector>
+
+class LzsFile : public File
+{
+public:
+    LzsFile(const Ogre::String& file);
+    LzsFile(File* pFile);
+    LzsFile(File* pFile, u32 offset, u32 length);
+    LzsFile(const u8* pBuffer, u32 offset, u32 length);
+    virtual ~LzsFile();
+
+private:
+    void ExtractLzs();
+    friend class LzsBuffer;
+};
+
+class LzsBuffer
+{
+public:
+    LzsBuffer() = delete;
+    static std::vector<QGears::uint8> Decompress(const std::vector<QGears::uint8>& buffer);
+};
+
+
+#endif // LZS_FILE_H

+ 84 - 0
QGearsMain/include/common/QGearsApplication.h

@@ -0,0 +1,84 @@
+/*
+-----------------------------------------------------------------------------
+Copyright (c) 19.10.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+This file is part of Q-Gears
+
+Q-Gears is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.0 (GPLv2) of the License.
+
+Q-Gears is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsApplication_H__
+#define __QGearsApplication_H__
+
+#include <OgreRoot.h>
+#include <OgreOverlaySystem.h>
+#include <memory>
+#include "TypeDefine.h"
+
+namespace QGears
+{
+    class Application : public Ogre::Singleton<Application>
+    {
+    public:
+        Application(Ogre::String pluginsFileName, Ogre::String resourcesFile, Ogre::String logFileName)
+            : m_plugins_filename(pluginsFileName), m_resources_filename(resourcesFile), m_log_filename(logFileName)
+        {
+
+        }
+        Application( int argc, char *argv[] );
+        virtual ~Application();
+        bool                initOgre( bool hideWindow = false );
+        Ogre::Root*         getRoot( void );
+        Ogre::RenderWindow* getRenderWindow( void );
+        const String&       getResourcesFilename( void );
+        Ogre::ResourceGroupManager* ResMgr() { return mResMgr; }
+    protected:
+        String  getWindowTitle( void ) const;
+        bool    processCommandLine( int argc, char *argv[] );
+        void    registerArchiveFactories( void );
+        void    loadResourcesConfig( void );
+        void    initComponents( void );
+        void    destroyComponents( void );
+        void    createResourceManagers( void );
+        void    destroyResourceManagers( void );
+
+    private:
+        typedef std::vector<std::shared_ptr<Ogre::ResourceManager>> ResourceManagerVector;
+
+
+        static const char*      CLI_SECTION_GENERIC;
+        static const char*      CLI_HELP;
+        static const char*      CLI_HELP_DESCRIPTION;
+        static const char*      CLI_CONFIG_FILE;
+        static const char*      CLI_CONFIG_FILE_DESCRIPTION;
+        static const char*      CLI_LOG_FILE;
+        static const char*      CLI_LOG_FILE_DESCRIPTION;
+        static const char*      CLI_PLUGINS_FILE;
+        static const char*      CLI_PLUGINS_FILE_DESCRIPTION;
+        static const char*      CLI_RESOURCES_FILE;
+        static const char*      CLI_RESOURCES_FILE_DESCRIPTION;
+
+        int     m_argc = 0;
+        char  **m_argv = nullptr;
+        String  m_config_filename;
+        String  m_log_filename;
+        String  m_plugins_filename;
+        String  m_resources_filename;
+
+        bool m_initialized = false;
+        std::unique_ptr<Ogre::Root> m_root;
+        std::unique_ptr<Ogre::OverlaySystem> m_overlay_system;
+        Ogre::RenderWindow* m_render_window = nullptr; // Not owned
+        ResourceManagerVector m_resource_managers;
+        Ogre::ResourceGroupManager* mResMgr = nullptr; // Not owned
+    };
+}
+
+#endif // __QGearsApplication_H__

+ 104 - 0
QGearsMain/include/common/QGearsManualObject.h

@@ -0,0 +1,104 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-08-14 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsManualObject_H__
+#define __QGearsManualObject_H__
+
+#include <OgreColourValue.h>
+#include <OgreMesh.h>
+#include <OgreSubMesh.h>
+#include <Ogre.h>
+
+#include "common/TypeDefine.h"
+
+namespace QGears
+{
+    /*
+     * When parsing files this is used to create the rendering engine object, e.g when we see a bone
+     * in the file we are parsing then call bone() to add one.
+     */
+    class ManualObject
+    {
+        public:
+            explicit ManualObject( Ogre::Mesh *mesh );
+            virtual ~ManualObject();
+
+            enum BufferBinding
+            {
+                BB_POSITION
+              , BB_NORMAL
+              , BB_COLOUR
+              , BB_TEXTURE
+              , BINDING_COUNT
+            };
+
+            virtual void begin( const String &name, const String &material_name
+                               ,size_t vertex_count, size_t index_count );
+
+            virtual void position( const Ogre::Vector3 &position );
+            virtual void normal( const Ogre::Vector3 &normal );
+            virtual void colour( const Ogre::ColourValue &colour );
+            virtual void textureCoord( const Ogre::Vector2 &texture_coordinate );
+            virtual void index( const uint32 idx );
+            virtual void bone( const uint32 idx, const uint16 bone_handle
+                              ,const Ogre::Real weight = 1 );
+
+            virtual void end();
+
+        protected:
+            template<typename BufferType>
+            BufferType*     createBuffer( const BufferBinding binding, Ogre::VertexElementType type, Ogre::VertexElementSemantic semantic);
+            virtual void    createPositionBuffer();
+            virtual void    createNormalBuffer();
+            virtual void    createColourBuffer();
+            virtual void    createTextureCoordinateBuffer();
+            virtual void    createIndexBuffer();
+            virtual void    resetBuffers();
+
+            template<typename BufferSharedPtr>
+                    void    resetBuffer( BufferSharedPtr &buffer ) const;
+
+        private:
+            Ogre::Mesh     *m_mesh;
+            Ogre::SubMesh  *m_section;
+
+            Ogre::AxisAlignedBox    m_bbox;
+            Ogre::Real              m_radius;
+
+            typedef Ogre::HardwareVertexBufferSharedPtr VertexBuffer;
+            typedef Ogre::HardwareIndexBufferSharedPtr  IndexBuffer;
+            VertexBuffer    m_vertex_buffers[BINDING_COUNT];
+            IndexBuffer     m_index_buffer;
+            Ogre::Vector3  *m_position;
+            Ogre::Vector3  *m_normal;
+            uint32         *m_colour;
+            Ogre::Vector2  *m_texture_coordinate;
+            uint16         *m_index;
+
+            const Ogre::VertexElementType colour_type;
+    };
+}
+
+#endif // __QGearsManualObject_H__

+ 62 - 0
QGearsMain/include/common/QGearsResource.h

@@ -0,0 +1,62 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-08-26 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsResource_H__
+#define __QGearsResource_H__
+
+#include <OgreDataStream.h>
+#include <OgreResource.h>
+#include <OgreResourceGroupManager.h>
+
+#include "common/TypeDefine.h"
+#include "QGearsPrerequisites.h"
+
+namespace QGears
+{
+    class _QGearsExport Resource : public Ogre::Resource
+    {
+    public:
+        Resource(Ogre::ResourceManager *creator
+            , const String &name, Ogre::ResourceHandle handle
+            , const String &group, bool isManual
+            , Ogre::ManualResourceLoader *loader) :
+            Ogre::Resource(creator, name, handle, group, isManual, loader)
+        {
+        }
+
+        virtual ~Resource() = default;
+
+    protected:
+        virtual Ogre::DataStreamPtr openResource()
+        {
+            // LAst parameter to true to throw an exception. Change when ready.
+            return Ogre::ResourceGroupManager::getSingleton().openResource(mName, mGroup, this, false);
+        }
+
+    private:
+    };
+}
+
+#endif // __QGearsResource_H__

+ 42 - 0
QGearsMain/include/common/QGearsStringUtil.h

@@ -0,0 +1,42 @@
+/*
+-----------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2013-08-17 Tobias Peters <tobias.peters@kreativeffekt.at>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+#ifndef __QGearsStringUtil_H__
+#define __QGearsStringUtil_H__
+
+#include "common/TypeDefine.h"
+
+namespace QGears
+{
+    class StringUtil : public Ogre::StringUtil
+    {
+    public:
+        static void splitPath( const String &qualifiedName, String &outPath );
+        static void splitBase( const String &qualifiedName, String &outBasename );
+        static void splitFull( const String &qualifiedName, String &outBasename );
+    };
+}
+
+#endif // __QGearsStringUtil_H__

+ 71 - 0
QGearsMain/include/common/TypeDefine.h

@@ -0,0 +1,71 @@
+#ifndef TYPE_DEFINE_H
+#define TYPE_DEFINE_H
+
+#include <OgrePlatform.h>
+#include <OgreString.h>
+
+typedef Ogre::uint8  u8;
+typedef Ogre::uint16 u16;
+typedef Ogre::uint32 u32;
+
+typedef Ogre::int8  s8;
+typedef Ogre::int16 s16;
+typedef Ogre::int32 s32;
+
+#define BEGIN_QGEARS namespace QGears {
+#define END_QGEARS }
+
+namespace QGears
+{
+    typedef Ogre::uchar  uchar;
+    typedef Ogre::uint8  uint8;
+    typedef Ogre::uint16 uint16;
+    typedef Ogre::uint32 uint32;
+
+    typedef Ogre::int8  sint8;
+    typedef Ogre::int16 sint16;
+    typedef Ogre::int32 sint32;
+
+    typedef Ogre::String String;
+
+    struct ColorComponents
+    {
+        uint8 blue;
+        uint8 green;
+        uint8 red;
+        uint8 alpha;
+    };
+
+    union ColorA8R8G8B8
+    {
+        ColorComponents comp;
+        uint32 all;
+    };
+
+    struct Pixel
+    {
+        sint16 x;
+        sint16 y;
+    };
+
+    extern const String    EXT_MATERIAL;
+    extern const String    EXT_MESH;
+    extern const String    EXT_SKELETON;
+    extern const String    EXT_CONFIG;
+    extern const String    EXT_LOG;
+
+    extern const String    EXT_P;
+    extern const String    EXT_PLY;
+    extern const String    EXT_RSD;
+    extern const String    EXT_TIM;
+    extern const String    EXT_TEX;
+
+    extern const String    EXT_TRIGGERS;
+    extern const String    EXT_BACKGROUND;
+    extern const String    EXT_CAMERA_MATRIX;
+    extern const String    EXT_MODEL_LIST;
+    extern const String    EXT_PALETTE;
+    extern const String    EXT_WALKMESH;
+}
+
+#endif // TYPE_DEFINE_H

+ 17 - 0
QGearsMain/include/common/make_unique.h

@@ -0,0 +1,17 @@
+#ifndef _MAKE_UNIQUE_
+#define _MAKE_UNIQUE_
+
+#include <memory>
+
+#ifndef _MSC_VER
+namespace std
+{
+    template<typename T, typename ...Args>
+    std::unique_ptr<T> make_unique( Args&& ...args )
+    {
+        return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
+    }
+}
+#endif
+
+#endif // _MAKE_UNIQUE_

+ 12 - 0
QGearsMain/include/core/Assert.h

@@ -0,0 +1,12 @@
+#ifndef ASSERT_H
+#define ASSERT_H
+
+#include <cassert>
+
+
+
+#define QGEARS_ASSERT( exp, text ) assert( exp && text )
+
+
+
+#endif // ASSERT_H

+ 99 - 0
QGearsMain/include/core/AudioManager.h

@@ -0,0 +1,99 @@
+#ifndef AUDIO_MANAGER_H
+#define AUDIO_MANAGER_H
+
+#include <OgreSingleton.h>
+#include <boost/thread.hpp>
+#include <vorbis/vorbisfile.h>
+
+// Include OpenAL
+#if defined(__WIN32__) || defined(_WIN32)
+    #include <al.h>
+    #include <alc.h>
+#else
+    #include <AL/al.h>
+    #include <AL/alc.h>
+#endif
+
+
+
+class AudioManager : public Ogre::Singleton< AudioManager >
+{
+public:
+    AudioManager();
+    virtual ~AudioManager();
+
+    // boost uses this
+    void operator()();
+
+    void Update();
+    void MusicPause();
+    void MusicPlay( const Ogre::String& name );
+    void MusicStop();
+
+    struct Music
+    {
+        Ogre::String name;
+        Ogre::String file;
+        float        loop;
+    };
+    void AddMusic( const AudioManager::Music& music );
+    AudioManager::Music* GetMusic( const Ogre::String& name );
+
+private:
+    const bool Init();
+    const char* ALError();
+    const char* ALCError( const ALCdevice* device );
+
+    class Player
+    {
+    public:
+        Player( boost::recursive_mutex* mutex );
+        ~Player();
+
+        void Pause();
+        void Play( const Ogre::String& file );
+        void Stop();
+
+        void SetLoop( const float loop );
+
+        void Update();
+        float GetPosition();
+
+    private:
+        boost::recursive_mutex* m_UpdateMutex;
+        float                   m_Loop;
+        OggVorbis_File          m_VorbisFile;
+        vorbis_info*            m_VorbisInfo;
+        int                     m_VorbisSection;
+        bool                    m_StreamFinished;
+        ALuint                  m_Source;
+
+        ALsizei FillBuffer();
+    };
+
+
+
+private:
+    bool                   m_Initialized;
+
+    ALCdevice*             m_ALDevice;
+    ALCcontext*            m_ALContext;
+    char*                  m_Buffer;
+
+    boost::recursive_mutex m_UpdateMutex;
+    boost::thread*         m_UpdateThread;
+    bool                   m_ThreadContinue;
+
+    AudioManager::Player             m_Music;
+    std::list< AudioManager::Music > m_MusicList;
+
+    // allocate for every new player two 96Kb buffer chunks
+    // every chunk would buffer ~0.5 seconds of 44100Hz stereo 16-bit data
+    // in that case we can sleep updating buffers for 250ms
+    static ALsizei m_ChannelBufferSize;
+    static int m_ChannelBufferNumber;
+};
+
+
+
+#endif // AUDIO_MANAGER_H

+ 158 - 0
QGearsMain/include/core/Background2D.h

@@ -0,0 +1,158 @@
+#ifndef BACKGROUND_2D_H
+#define BACKGROUND_2D_H
+
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreRoot.h>
+
+#include "map/QGearsBackground2DFile.h"
+
+#include "Background2DAnimation.h"
+#include "Entity.h"
+#include "ScriptManager.h"
+
+
+class Background2D : public Ogre::RenderQueueListener
+{
+public:
+
+    typedef QGears::Blending  Blending;
+
+    enum ScrollType
+    {
+        NONE,
+        LINEAR,
+        SMOOTH
+    };
+
+    Background2D();
+    virtual ~Background2D();
+
+    void InputDebug(const QGears::Event& event);
+    void Update();
+    void UpdateDebug();
+    void OnResize();
+
+    void Clear();
+
+    void ScriptAutoScrollToEntity( Entity* entity );
+    Entity* GetAutoScrollEntity() const;
+    void ScriptScrollToPosition( const float x, const float y, const ScrollType type, const float seconds );
+    int ScriptScrollSync();
+    void UnsetScroll();
+    const Ogre::Vector2& GetScrollPositionStart() const;
+    const Ogre::Vector2& GetScrollPositionEnd() const;
+    ScrollType GetScrollType() const;
+    float GetScrollSeconds() const;
+    void SetScrollCurrentSeconds( const float seconds );
+    float GetScrollCurrentSeconds() const;
+
+    // Scroll position in screen coordinates
+    void SetScreenScroll( const Ogre::Vector2& position );
+    const Ogre::Vector2 GetScreenScroll() const;
+    // scroll in game internal screen coordinates
+    void SetScroll( const Ogre::Vector2& position );
+    const Ogre::Vector2& GetScroll() const;
+
+
+    void SetImage( const Ogre::String& image );
+
+    void SetRange( const int min_x, const int min_y, const int max_x, const int max_y );
+    void SetRange( const Ogre::Vector4& range );
+
+    void 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 );
+    void AddTile( const Ogre::Vector2& destination, const int width, const int height, const float depth, const Ogre::Vector4& uv, const Blending blending );
+    void AddTile( const QGears::Tile& tile );
+
+    void UpdateTileUV( const unsigned int tile_id, const float u1, const float v1, const float u2, const float v2 );
+
+    void AddAnimation( Background2DAnimation* animation );
+    void PlayAnimation( const Ogre::String& animation, const Background2DAnimation::State state );
+    void ScriptPlayAnimationLooped( const char* name );
+    void ScriptPlayAnimationOnce( const char* name );
+    int ScriptAnimationSync( const char* name );
+
+    void renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation );
+
+    struct Tile
+    {
+        int x;
+        int y;
+        int width;
+        int height;
+        size_t start_vertex_index;
+        Blending blending;
+    };
+    typedef std::vector< Tile > TileList;
+
+    virtual void load( const QGears::Background2DFilePtr &background );
+
+protected:
+    virtual void load( const QGears::Background2DFile::TileList &tiles );
+    virtual void load( const size_t tile_index, const QGears::AnimationMap &animations );
+    virtual void applyScroll( void );
+    virtual void calculateScreenScale( void );
+    virtual void virtualScreenToWorldSpace( Ogre::Vector2 &pos ) const;
+
+    enum
+    {
+        TILE_VERTEX_COUNT = 6
+       ,TILE_VERTEX_INDEX_SIZE = TILE_VERTEX_COUNT + 3
+    };
+
+private:
+    void CreateVertexBuffers();
+    void DestroyVertexBuffers();
+
+private:
+    Ogre::SceneManager*                   m_SceneManager;
+    Ogre::RenderSystem*                   m_RenderSystem;
+
+    TileList                              m_Tiles;
+
+    // alpha blended
+    Ogre::RenderOperation                 m_AlphaRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr   m_AlphaVertexBuffer;
+    unsigned int                          m_AlphaMaxVertexCount;
+    Ogre::MaterialPtr                     m_AlphaMaterial;
+
+    // add blended
+    Ogre::RenderOperation                 m_AddRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr   m_AddVertexBuffer;
+    unsigned int                          m_AddMaxVertexCount;
+    Ogre::MaterialPtr                     m_AddMaterial;
+
+    // subtract blended
+    Ogre::RenderOperation                 m_SubtractRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr   m_SubtractVertexBuffer;
+    unsigned int                          m_SubtractMaxVertexCount;
+    Ogre::MaterialPtr                     m_SubtractMaterial;
+
+    Entity*                               m_ScrollEntity;
+    Ogre::Vector2                         m_ScrollPositionStart;
+    Ogre::Vector2                         m_ScrollPositionEnd;
+    ScrollType                            m_ScrollType;
+    float                                 m_ScrollSeconds;
+    float                                 m_ScrollCurrentSeconds;
+    std::vector< ScriptId >               m_ScrollSync;
+    Ogre::Vector2                         m_Position;
+    Ogre::Vector2                         m_PositionReal;
+
+    Ogre::Real                            m_screen_scale;
+    Ogre::Vector2                         m_screen_proportion;
+    Ogre::Vector2                         m_virtual_screen_size;
+    Ogre::AxisAlignedBox                  m_range;
+
+    struct AnimationPlayed
+    {
+        Ogre::String                 name;
+        std::vector< ScriptId >      sync;
+        Background2DAnimation::State state;
+    };
+    std::vector< AnimationPlayed >        m_AnimationPlayed;
+    std::vector< Background2DAnimation* > m_Animations;
+};
+
+
+
+#endif // BACKGROUND_2D_H

+ 62 - 0
QGearsMain/include/core/Background2DAnimation.h

@@ -0,0 +1,62 @@
+#ifndef BACKGROUND_2D_ANIMATION_H
+#define BACKGROUND_2D_ANIMATION_H
+
+#include <OgreString.h>
+#include <Ogre.h>
+#include <vector>
+
+#include "map/QGearsTile.h"
+
+class Background2D;
+
+
+
+class Background2DAnimation
+{
+public:
+    Background2DAnimation( const Ogre::String& name, Background2D* background, const int tile_index );
+    virtual ~Background2DAnimation();
+
+    enum State
+    {
+        ONCE,
+        LOOPED
+    };
+
+    void  AddTime( const float time );
+
+    const Ogre::String& GetName() const;
+
+    void  SetTime( const float time );
+    float GetTime() const;
+    void  SetLength( const float time );
+    float GetLength() const;
+
+    virtual void AddUVKeyFrame( const QGears::KeyFrame key_frame );
+    virtual void AddUVKeyFrame( const float time, const Ogre::Vector4& uv );
+    virtual void AddUVKeyFrame( const float time, const float u1, const float v1, const float u2, const float v2 );
+
+private:
+    Background2DAnimation();
+
+    Ogre::String  m_Name;
+    Background2D* m_Background;
+    int           m_TileIndex;
+
+    float         m_Time;
+    float         m_Length;
+
+    struct Background2DKeyFrameUV
+    {
+        float time;
+        float u1;
+        float v1;
+        float u2;
+        float v2;
+    };
+    std::vector< Background2DKeyFrameUV > m_UV;
+};
+
+
+
+#endif // BACKGROUND_2D_ANIMATION_H

+ 56 - 0
QGearsMain/include/core/CameraManager.h

@@ -0,0 +1,56 @@
+#ifndef CAMERA_MANAGER_H
+#define CAMERA_MANAGER_H
+
+#include <OgreCamera.h>
+#include <OgreSingleton.h>
+
+#include "Event.h"
+
+
+
+class CameraManager : public Ogre::Singleton< CameraManager >
+{
+public:
+    CameraManager();
+    virtual ~CameraManager();
+
+    void Input(const QGears::Event& event , Ogre::Real timeSinceLastFrame);
+    void Update();
+    void OnResize();
+
+    // camera free related
+    void SetCameraFree( const bool enable );
+
+    // camera 2D related
+    void Set2DCamera( const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov );
+    void Set2DScroll( const Ogre::Vector2& position );
+    const Ogre::Vector2& Get2DScroll() const;
+
+    const Ogre::Vector3 ProjectPointToScreen( const Ogre::Vector3& point );
+
+    Ogre::Camera*   GetCurrentCamera();
+    Ogre::Viewport* getViewport();
+
+    void EnableWireFrame(bool);
+private:
+
+    void InitCommands();
+
+private:
+    Ogre::Camera   *m_Camera;
+    Ogre::Viewport *m_Viewport;
+
+    // camera free related
+    bool m_CameraFree;
+    bool m_CameraFreeRotate;
+
+    // camera 2D related
+    Ogre::Vector3 m_2DPosition;
+    Ogre::Quaternion m_2DOrientation;
+    Ogre::Radian m_2DFOV;
+    Ogre::Vector2 m_2DScroll;
+};
+
+
+
+#endif // CAMERA_MANAGER_H

+ 36 - 0
QGearsMain/include/core/CameraManagerCommands.h

@@ -0,0 +1,36 @@
+#include <OgreStringConverter.h>
+
+#include "CameraManager.h"
+#include "ConfigCmdManager.h"
+#include "Console.h"
+
+
+
+void
+CommandCameraFree( const Ogre::StringVector& params )
+{
+    if( params.size() < 1 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /camera_free <enable>" );
+        return;
+    }
+
+    CameraManager::getSingleton().SetCameraFree( Ogre::StringConverter::parseBool( params[ 1 ] ) );
+}
+
+
+
+void
+CommandCameraFreeCompletition( Ogre::StringVector& complete_params )
+{
+    complete_params.push_back( "true" );
+    complete_params.push_back( "false" );
+}
+
+
+
+void
+CameraManager::InitCommands()
+{
+    ConfigCmdManager::getSingleton().AddCommand( "camera_free", "Enable or disable free camera", "", CommandCameraFree, CommandCameraFreeCompletition );
+}

+ 45 - 0
QGearsMain/include/core/ConfigCmd.h

@@ -0,0 +1,45 @@
+#ifndef CONFIG_CMD_H
+#define CONFIG_CMD_H
+
+#include <OgreString.h>
+#include <OgreStringVector.h>
+
+
+
+class ConfigCmdManager;
+
+typedef void ( *ConfigCmdHandler )( const Ogre::StringVector& params );
+typedef void ( *ConfigCmdCompletion )( Ogre::StringVector& complete_params );
+
+
+
+class ConfigCmd
+{
+    friend class ConfigCmdManager;
+
+public:
+    const Ogre::String&     GetName() const;
+    const Ogre::String&     GetDescription() const;
+    const Ogre::String&     GetParamsDescription() const;
+
+    ConfigCmdHandler        GetHandler() const;
+    ConfigCmdCompletion     GetCompletion() const;
+
+
+    // ConfigCmd could be created only by ConfigCmdManager
+    ConfigCmd(const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion);
+private:
+    // forbid copy
+    ConfigCmd(const ConfigCmd& rhs) = delete;
+    ConfigCmd& operator =(const ConfigCmd& rhs) = delete;
+
+    Ogre::String            m_Name;
+    Ogre::String            m_Description;
+    Ogre::String            m_ParamsDescription;
+    ConfigCmdHandler        m_Handler;
+    ConfigCmdCompletion     m_Completion;
+};
+
+
+
+#endif // CONFIG_CMD_H

+ 38 - 0
QGearsMain/include/core/ConfigCmdManager.h

@@ -0,0 +1,38 @@
+#ifndef CONFIG_CMD_MANAGER_H
+#define CONFIG_CMD_MANAGER_H
+
+#include <OgreSingleton.h>
+#include <vector>
+#include <memory>
+#include "ConfigCmd.h"
+
+
+
+class ConfigCmdManager : public Ogre::Singleton< ConfigCmdManager >
+{
+public:
+    ConfigCmdManager();
+    ~ConfigCmdManager();
+
+    void AddCommand( const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description, ConfigCmdHandler handler, ConfigCmdCompletion completion );
+
+    void ExecuteString( const Ogre::String& cmd_string );
+
+    // return command with specified name
+    ConfigCmd* Find( const Ogre::String& name ) const;
+    int GetConfigCmdNumber();
+    ConfigCmd* GetConfigCmd( unsigned int i ) const;
+
+private:
+    // forbid copy
+    ConfigCmdManager( const ConfigCmdManager& rhs ) = delete;
+    ConfigCmdManager operator =( const ConfigCmdManager& rhs ) = delete;
+
+    void InitCmd();
+
+    std::vector< std::unique_ptr<ConfigCmd> > m_Commands;
+};
+
+
+
+#endif // CONFIG_CMD_MANAGER_H

+ 439 - 0
QGearsMain/include/core/ConfigCmdManagerCommands.h

@@ -0,0 +1,439 @@
+#include <OgreRenderWindow.h>
+#include <OgreRoot.h>
+#include <OgreStringConverter.h>
+
+#include "Console.h"
+#include "ConfigCmdManager.h"
+#include "ConfigVarManager.h"
+#include "EntityManager.h"
+#include "Logger.h"
+#include "XmlMapFile.h"
+#include "XmlMapsFile.h"
+
+#include "QGearsGameState.h"
+#include "common/QGearsApplication.h"
+
+
+void
+CmdQuit( const Ogre::StringVector& params )
+{
+    QGears::g_ApplicationState = QGears::G_EXIT;
+}
+
+
+
+void
+CmdEcho( const Ogre::StringVector& params )
+{
+    if( params.size() < 1 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /echo <string to output>" );
+        return;
+    }
+
+    Ogre::String text = "";
+
+    for( size_t i = 1; i < params.size(); ++i )
+    {
+        if( i != 1 )
+        {
+            text += " ";
+        }
+        text += params[ i ];
+    }
+
+    Console::getSingleton().AddTextToOutput( text + "\n" );
+}
+
+
+
+void
+CmdConfigVarList( const Ogre::StringVector& params )
+{
+    if( params.size() > 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /config_var_list [search string]" );
+        return;
+    }
+
+    int number = 0;
+    int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
+    for( int i = 0; i < num_vars; ++i )
+    {
+        ConfigVar* var = ConfigVarManager::getSingleton().GetConfigVar( i );
+        Ogre::String name = var->GetName();
+
+        if( params.size() > 1 )
+        {
+            int found = name.find( params[ 1 ] );
+            if( found == 0 )
+            {
+                Console::getSingleton().AddTextToOutput( var->GetName() + " = \"" + var->GetS() + "\"" );
+                ++number;
+            }
+        }
+        else
+        {
+            Console::getSingleton().AddTextToOutput( var->GetName() + " = \"" + var->GetS() + "\"" );
+            ++number;
+        }
+    }
+
+    Console::getSingleton().AddTextToOutput( Ogre::StringConverter::toString(number) + " config variables.\n" );
+}
+
+
+
+void
+CmdConfigCmdList( const Ogre::StringVector& params )
+{
+    if( params.size() > 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /config_cmd_list [search string]" );
+        return;
+    }
+
+    int number = 0;
+    int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+    for( int i = 0; i < num_cmds; ++i )
+    {
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().GetConfigCmd( i );
+        Ogre::String name = cmd->GetName();
+
+        if( params.size() > 1 )
+        {
+            int found = name.find( params[ 1 ] );
+
+            if( found == 0 )
+            {
+                Console::getSingleton().AddTextToOutput( cmd->GetName() );
+                ++number;
+            }
+        }
+        else
+        {
+            Console::getSingleton().AddTextToOutput( cmd->GetName() );
+            ++number;
+        }
+    }
+
+    Console::getSingleton().AddTextToOutput( Ogre::StringConverter::toString( number ) + " config commands.\n" );
+}
+
+
+
+// set cvar value
+void
+CmdSetConfigVar( const Ogre::StringVector& params )
+{
+    if( params.size() < 2 || params.size() > 3 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /set <config variable> [value]" );
+        return;
+    }
+
+    Ogre::String name = params[ 1 ];
+
+    ConfigVar* cvar = ConfigVarManager::getSingleton().Find( name );
+    if( cvar == NULL )
+    {
+        LOG_ERROR( "Config variable \"" + name + "\" not found." );
+        return;
+    }
+
+    if( params.size() == 3 )
+    {
+        cvar->SetS( params[ 2 ] );
+
+        Console* console = Console::getSingletonPtr();
+        if( console != NULL )
+        {
+            LOG_TRIVIAL( params[ 1 ] + " changed to \"" + params[ 2 ] + "\"." );
+        }
+    }
+    else
+    {
+        // reset to default
+        cvar->SetS( cvar->GetDefaultValue() );
+        LOG_TRIVIAL( params[ 1 ] + " changed to default \"" + cvar->GetDefaultValue() + "\"." );
+    }
+}
+
+
+
+// toggle cvar value
+void
+CmdToggleConfigVar( const Ogre::StringVector& params )
+{
+    if( params.size() < 4 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /toggle <config variable> [value1] [value2] ..." );
+        return;
+    }
+
+    Ogre::String name = params[ 1 ];
+
+    ConfigVar* cvar = ConfigVarManager::getSingleton().Find( name );
+    if( cvar == NULL )
+    {
+        LOG_ERROR( "Config variable \"" + name + "\" not found." );
+        return;
+    }
+
+    // sequentially trigger values
+    int number_of_values = params.size() - 2;
+    Ogre::String value = cvar->GetS();
+    int i = 0;
+
+    for( ; i < number_of_values; ++i )
+    {
+        if( value == params[ i + 2 ] )
+        {
+            ++i;
+            break;
+        }
+    }
+
+    if( i == number_of_values )
+    {
+        i = 0;
+    }
+
+    cvar->SetS( params[ i + 2 ] );
+}
+
+
+
+// increment cvar value
+void
+CmdIncrementConfigVar( const Ogre::StringVector& params )
+{
+    if( params.size() != 5 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /increment <cvar name> [value min] [value max] [step]" );
+        return;
+    }
+
+    Ogre::String name = params[ 1 ];
+
+    ConfigVar* cvar = ConfigVarManager::getSingleton().Find( name );
+    if( cvar == NULL )
+    {
+        LOG_ERROR( "Config variable \"" + name + "\" not found." );
+        return;
+    }
+
+    float start_value = Ogre::StringConverter::parseReal( params[ 2 ] );
+    float end_value = Ogre::StringConverter::parseReal( params[ 3 ] );
+    float step = Ogre::StringConverter::parseReal( params[ 4 ] );
+
+    float new_value = cvar->GetF() + step;
+    if( new_value > end_value )
+    {
+        new_value = end_value;
+    }
+    else if( new_value < start_value )
+    {
+        new_value = start_value;
+    }
+
+    cvar->SetF( new_value );
+}
+
+
+
+void
+CmdSetLogLevel( const Ogre::StringVector& params )
+{
+    if( params.size() != 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /log_level <level: 1 - only errors, 2 - errors and warnings, 3 - all>" );
+        return;
+    }
+
+    int value = Ogre::StringConverter::parseInt( params[ 1 ] );
+    if( value > 0 && value < 4 )
+    {
+        Ogre::LogManager::getSingletonPtr()->getDefaultLog()->setLogDetail( ( Ogre::LoggingLevel )value );
+
+        switch( value )
+        {
+            case 1: Console::getSingleton().AddTextToOutput( "Logger level changed to \"only errors\".\n" ); break;
+            case 2: Console::getSingleton().AddTextToOutput( "Logger level changed to \"errors and warnings\".\n" ); break;
+            case 3: Console::getSingleton().AddTextToOutput( "Logger level changed to \"all\".\n" ); break;
+        }
+    }
+    else
+    {
+        Console::getSingleton().AddTextToOutput( "Logger level can't be changed. Value \"" + params[ 1 ] + "\" isn't supported.\n" );
+    }
+}
+
+
+
+void
+CmdMap( const Ogre::StringVector& params )
+{
+    if( params.size() != 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /map [map_id]" );
+        return;
+    }
+
+    EntityManager::getSingleton().Clear();
+
+    XmlMapsFile xml( "./data/maps.xml" );
+    Ogre::String file_name = xml.GetMapFileNameByName( params[ 1 ] );
+
+    XmlMapFile xml_map( "./data/" + file_name );
+    xml_map.LoadMap();
+}
+
+
+
+void
+CmdMapCompletion( Ogre::StringVector& complete_params )
+{
+    XmlMapsFile xml( "./data/maps.xml" );
+    xml.GetMapNames( complete_params );
+}
+
+
+
+void
+CmdResolution( const Ogre::StringVector& params )
+{
+    if( params.size() < 3 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /resolution <width> <height> [full screen]" );
+        return;
+    }
+
+    Ogre::RenderWindow* window = QGears::Application::getSingleton().getRenderWindow();
+
+    if( params.size() >= 4 )
+    {
+        window->setFullscreen( Ogre::StringConverter::parseBool( params[ 3 ] ), Ogre::StringConverter::parseInt( params[ 1 ] ), Ogre::StringConverter::parseInt( params[ 2 ] ) );
+    }
+    else
+    {
+        window->resize( Ogre::StringConverter::parseInt( params[ 1 ] ), Ogre::StringConverter::parseInt( params[ 2 ] ) );
+    }
+}
+
+
+
+void
+CmdResolutionCompletition( Ogre::StringVector& complete_params )
+{
+    complete_params.push_back( "640 480 0" );
+    complete_params.push_back( "640 480 1" );
+    complete_params.push_back( "800 600 0" );
+    complete_params.push_back( "800 600 1" );
+    complete_params.push_back( "1024 768 0" );
+    complete_params.push_back( "1024 768 1" );
+    complete_params.push_back( "1280 720 0" );
+    complete_params.push_back( "1280 720 1" );
+    complete_params.push_back( "1280 1024 0" );
+    complete_params.push_back( "1280 1024 1" );
+}
+
+
+
+void
+CmdScreenshot( const Ogre::StringVector& params )
+{
+    Ogre::RenderWindow* window = QGears::Application::getSingleton().getRenderWindow();
+    Ogre::String ret = window->writeContentsToTimestampedFile( "screenshot_", ".tga" );
+    Console::getSingleton().AddTextToOutput( "Screenshot " + ret + " saved." );
+}
+
+
+
+/*
+void
+CmdViewer( const Ogre::StringVector& params )
+{
+    if( params.size() == 2 || params.size() > 3 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /viewer [type_of_thing_to_view] [path_to_resource]" );
+        return;
+    }
+
+    ModuleManager::getSingleton().RunViewer();
+
+    if( params.size() == 3 )
+    {
+        ViewerModule* module = ( ViewerModule* )( ModuleManager::getSingleton().GetTopModule() );
+
+        if( params[ 1 ] == "walkmesh" )
+        {
+            module->SetWalkmeshToLoad( params[ 2 ] );
+        }
+        else if( params[ 1 ] == "model" )
+        {
+            module->SetModelToLoad( params[ 2 ] );
+        }
+        else
+        {
+            LOG_ERROR( "Unsupported type \"" + params[ 1 ] + "\" in viewer command." );
+        }
+    }
+}
+
+
+
+void
+CmdViewerCompletion( Ogre::StringVector& complete_params )
+{
+    // models
+    complete_params.push_back( "model" );
+
+    Ogre::FileInfoListPtr resources = Ogre::ResourceGroupManager::getSingleton().listResourceFileInfo( "Game" );
+    Ogre::FileInfoList resource_names = *resources;
+
+    Ogre::FileInfoList::iterator i = resource_names.begin();
+    for( ; i != resource_names.end(); ++i )
+    {
+        Ogre::String name;
+        Ogre::String ext;
+        Ogre::StringUtil::splitBaseFilename( i->filename, name, ext );
+        if( ext == "mesh" )
+        {
+            complete_params.push_back( "model " + i->filename );
+        }
+    }
+
+    // walkmeshes
+    complete_params.push_back( "walkmesh" );
+    XmlMapsFile xml( "./data/game_data/maps.xml" );
+    Ogre::StringVector tmp;
+    xml.GetMapNames( tmp );
+    for( int i = 0; i < tmp.size(); ++i )
+    {
+        complete_params.push_back( "walkmesh " + tmp[ i ] );
+    }
+}
+*/
+
+
+void
+ConfigCmdManager::InitCmd()
+{
+    AddCommand( "quit", "Stops application and quit", "", CmdQuit, NULL );
+    AddCommand( "echo", "Print command parameters", "", CmdEcho, NULL );
+    AddCommand( "config_var_list", "List of registered config variables", "[<filter substring>]", CmdConfigVarList, NULL );
+    AddCommand( "config_cmd_list", "List of registered config commands", "[<filter substring>]", CmdConfigCmdList, NULL );
+    AddCommand( "set", "Set cvar value", "<cvar name> [value]", CmdSetConfigVar, NULL );
+    AddCommand( "toggle", "Toggle cvar value", "<cvar name> [value1] [value2] ...", CmdToggleConfigVar, NULL );
+    AddCommand( "increment", "Increment cvar value", "<cvar name> [value min] [value max] [step]", CmdIncrementConfigVar, NULL );
+
+    AddCommand( "set_log_level", "Set log messages level", "", CmdSetLogLevel, NULL );
+
+    AddCommand( "map", "Run game module", "", CmdMap, CmdMapCompletion );
+
+    AddCommand( "resolution", "Change resolution", "", CmdResolution, CmdResolutionCompletition );
+    AddCommand( "screenshot", "Capture current screen content", "", CmdScreenshot, NULL );
+
+    //AddCommand( "viewer", "Run viewer module", "", CmdViewer, CmdViewerCompletion );
+}

+ 16 - 0
QGearsMain/include/core/ConfigFile.h

@@ -0,0 +1,16 @@
+#ifndef CONFIG_FILE_H
+#define CONFIG_FILE_H
+
+#include <OgreString.h>
+
+
+
+class ConfigFile
+{
+public:
+    void            Execute(const Ogre::String& name);
+};
+
+
+
+#endif // CONFIG_FILE_H

+ 54 - 0
QGearsMain/include/core/ConfigVar.h

@@ -0,0 +1,54 @@
+#ifndef CONFIG_VAR_H
+#define CONFIG_VAR_H
+
+#include <OgreString.h>
+
+
+
+class ConfigVarManager;
+
+
+
+class ConfigVar
+{
+    friend class ConfigVarManager;
+
+public:
+                        ConfigVar(const Ogre::String& name, const Ogre::String& description, const Ogre::String& default_value);
+
+    int                 GetI() const;
+    float               GetF() const;
+    bool                GetB() const;
+    Ogre::String        GetS() const;
+
+    void                SetI(int value);
+    void                SetF(float value);
+    void                SetB(bool value);
+    void                SetS(const Ogre::String& value);
+
+    const Ogre::String& GetName() const;
+    const Ogre::String& GetDescription() const;
+    const Ogre::String& GetDefaultValue() const;
+
+    void                UpdateVariables();
+
+private:
+    // forbid copy
+    ConfigVar(const ConfigVar&) = delete;
+    ConfigVar&operator=(const ConfigVar&) = delete;
+
+    Ogre::String    m_Name;
+    Ogre::String    m_Description;
+    Ogre::String    m_DefaultValue;
+    int             m_ValueI;
+    float           m_ValueF;
+    bool            m_ValueB;
+    Ogre::String    m_ValueS;
+
+    ConfigVar*          m_Previous;
+    static ConfigVar*   m_StaticConfigVarList;
+};
+
+
+
+#endif // CONFIG_VAR_H

+ 26 - 0
QGearsMain/include/core/ConfigVarManager.h

@@ -0,0 +1,26 @@
+#ifndef CONFIG_VAR_MANAGER_H
+#define CONFIG_VAR_MANAGER_H
+
+#include <OgreSingleton.h>
+#include <vector>
+
+#include "ConfigVar.h"
+
+
+
+class ConfigVarManager : public Ogre::Singleton< ConfigVarManager >
+{
+public:
+    ConfigVarManager();
+
+    ConfigVar*   Find( const Ogre::String& name ) const;
+    unsigned int GetConfigVarNumber() const;
+    ConfigVar*   GetConfigVar( const unsigned int i ) const;
+
+private:
+    std::vector< ConfigVar* > m_ConfigVars;
+};
+
+
+
+#endif // CONFIG_VAR_MANAGER_H

+ 80 - 0
QGearsMain/include/core/Console.h

@@ -0,0 +1,80 @@
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include <OgreColourValue.h>
+#include <OgreLog.h>
+#include <OgreSingleton.h>
+#include <OgreStringVector.h>
+#include <OIS/OIS.h>
+#include <list>
+#include <vector>
+
+#include "Event.h"
+
+
+
+class Console : public Ogre::Singleton< Console >, public Ogre::LogListener
+{
+public:
+    Console();
+    ~Console();
+
+    void Input(const QGears::Event& event);
+    void Update();
+    void UpdateDraw();
+    void UpdateNotification();
+    void OnResize();
+
+    void SetToVisible();
+    void SetToHide();
+    bool IsVisible() const;
+
+    void AddTextToOutput( const Ogre::String& text, const Ogre::ColourValue& colour = Ogre::ColourValue::White );
+    void ExecuteCommand( const Ogre::String& command );
+    void ExecuteScript();
+    void CompleteInput();
+    void ResetAutoCompletion();
+    void AddInputToHistory();
+    void SetInputLineFromHistory();
+
+    virtual void messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool& skipThisMessage );
+
+private:
+    void LoadHistory();
+    void SaveHistory();
+    void AddToHistory(const Ogre::String& history);
+    char TranslateNumpad(const QGears::Event& event);
+
+    int                           m_ConsoleWidth;
+    int                           m_ConsoleHeight;
+    unsigned int                  m_LineWidth;
+    int                           m_LetterWidth;
+
+    bool                          m_ToVisible;
+    bool                          m_Visible;
+    float                         m_Height;
+
+    struct OutputLine
+    {
+        Ogre::String text;
+        Ogre::ColourValue colour;
+        float time;
+    };
+    std::list< OutputLine >       m_OutputLine;
+    unsigned int                  m_MaxOutputLine; // max number of lines in output list
+    unsigned int                  m_DisplayLine;   // bottom of console displays this line
+    Ogre::String                  m_InputLine;
+    unsigned int                  m_CursorPosition;
+    float                         m_CursorBlinkTime;
+
+    std::list< Ogre::String >     m_History;
+    int                           m_HistoryLineCycleIndex;
+    unsigned int                  m_MaxHistorySize;
+
+    Ogre::StringVector            m_AutoCompletition;
+    unsigned int                  m_AutoCompletitionLine;
+};
+
+
+
+#endif // CONSOLE_H

+ 98 - 0
QGearsMain/include/core/DebugDraw.h

@@ -0,0 +1,98 @@
+#ifndef DEBUG_DRAW_H
+#define DEBUG_DRAW_H
+
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreRoot.h>
+#include <OgreSingleton.h>
+#include <OgreFont.h>
+
+
+class DebugDraw : public Ogre::RenderQueueListener, public Ogre::Singleton< DebugDraw >
+{
+public:
+    DebugDraw();
+    virtual ~DebugDraw();
+
+    void SetColour( const Ogre::ColourValue& colour );
+    void SetScreenSpace( const bool screen_space );
+    void SetZ( const float z );
+    void SetFadeDistance( const float fade_s, const float fade_e );
+
+    enum TextAlignment
+    {
+        LEFT,
+        RIGHT,
+        CENTER
+    };
+    void SetTextAlignment( TextAlignment alignment );
+
+    void Line( const float x1, const float y1, const float x2, const float y2 );
+    void Line3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2 );
+    void Triangle3d( const Ogre::Vector3& point1, const Ogre::Vector3& point2, const Ogre::Vector3& point3 );
+    void 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 );
+    void Text( const float x1, const float y1, const Ogre::String& text );
+    void Text( const Ogre::Vector3& point, const float x, const float y, const Ogre::String& text );
+
+    void renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation );
+
+private:
+    void CreateLineVertexBuffer();
+    void DestroyLineVertexBuffer();
+    void CreateLine3dVertexBuffer();
+    void DestroyLine3dVertexBuffer();
+    void CreateTriangle3dVertexBuffer();
+    void DestroyTriangle3dVertexBuffer();
+    void CreateQuadVertexBuffer();
+    void DestroyQuadVertexBuffer();
+    void CreateTextVertexBuffer();
+    void DestroyTextVertexBuffer();
+
+private:
+    Ogre::SceneManager* m_SceneManager;
+    Ogre::RenderSystem* m_RenderSystem;
+
+    // line
+    Ogre::RenderOperation               m_LineRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_LineVertexBuffer;
+    unsigned int                        m_LineMaxVertexCount;
+
+    // line3d
+    Ogre::RenderOperation               m_Line3dRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_Line3dVertexBuffer;
+    unsigned int                        m_Line3dMaxVertexCount;
+
+    // triangle3d
+    Ogre::RenderOperation               m_Triangle3dRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_Triangle3dVertexBuffer;
+    unsigned int                        m_Triangle3dMaxVertexCount;
+
+    // quad
+    Ogre::RenderOperation               m_QuadRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_QuadVertexBuffer;
+    unsigned int                        m_QuadMaxVertexCount;
+
+    // text
+    Ogre::RenderOperation               m_TextRenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_TextVertexBuffer;
+    unsigned int                        m_TextMaxVertexCount;
+    Ogre::FontPtr                       m_Font;
+    int                                 m_FontHeight;
+    TextAlignment                       m_TextAlignment;
+
+    Ogre::MaterialPtr                   m_Material;
+    Ogre::MaterialPtr                   m_Material3d;
+    Ogre::ColourValue                   m_Colour;
+    bool                                m_ScreenSpace;
+    float                               m_Z;
+    float                               m_FadeStartSquare; // text start fading from this distance
+    float                               m_FadeEndSquare; // text fully faded from this distance
+};
+
+
+
+#define DEBUG_DRAW DebugDraw::getSingleton()
+
+
+
+#endif // DEBUG_DRAW_H

+ 125 - 0
QGearsMain/include/core/DialogsManager.h

@@ -0,0 +1,125 @@
+#ifndef DIALOGS_MANAGER_h
+#define DIALOGS_MANAGER_h
+
+#include <OgreSingleton.h>
+
+#include "UiManager.h"
+#include "UiTextArea.h"
+
+
+
+enum MessageState
+{
+    MS_CLOSED,
+    MS_SHOW_WINDOW,
+    MS_SHOW_TEXT,
+    MS_OPENED,
+    MS_HIDE_WINDOW
+};
+
+
+
+enum MessageStyle
+{
+    MSL_SOLID,
+    MSL_TRANSPARENT,
+    MSL_NONE
+};
+
+
+
+struct MessageData
+{
+    MessageData():
+        widget( NULL ),
+        window( NULL ),
+        scissor( NULL ),
+        text_area( NULL ),
+        cursor( NULL ),
+
+        state( MS_CLOSED ),
+
+        clickable( true ),
+        show_window( true ),
+        show_cursor( false ),
+        auto_close( false ),
+
+        cursor_percent_y( 0 ),
+        cursor_y( 0 ),
+        cursor_row_selected( 0 ),
+        cursor_row_current( 0 ),
+        cursor_row_first( 0 ),
+        cursor_row_last( 0 )
+    {
+    }
+
+    UiWidget* widget;
+    UiWidget* window;
+    UiWidget* scissor;
+    UiTextArea* text_area;
+    UiWidget* cursor;
+
+    MessageState state;
+    int x = 0;
+    int y = 0;
+    int w = 0;
+    int h = 0;
+
+    std::vector< ScriptId > sync;
+
+    bool clickable;
+    bool show_window;
+    bool show_cursor;
+    bool auto_close;
+
+    float cursor_percent_y;
+    float cursor_y;
+    int cursor_row_selected;
+    int cursor_row_current;
+    int cursor_row_first;
+    int cursor_row_last;
+};
+
+
+
+class DialogsManager : public Ogre::Singleton< DialogsManager >
+{
+public:
+    DialogsManager();
+    virtual ~DialogsManager();
+
+    void Initialise();
+    void Input( const QGears::Event& event );
+    void Update();
+    void Clear();
+
+    void OpenDialog(const char* d_name, int x, int y, int w, int h); // aka dialog_open
+    void SetText( const char* d_name, const char* text ); // aka dialog_set_text
+    int Sync( const char* d_name ); // aka dialog_wait_for_close
+    void Hide(const char* d_name); // aka dialog_close
+
+    void SetVariable( const char* d_name, const char* name, const char* value );
+
+    void SetClickable( const char* d_name, const bool clickable );
+    void SetCursor( const char* d_name, const int first_row, const int last_row );
+    int GetCursor( const char* d_name ) const;
+
+private:
+    void ShowMessage( const int id, const int x, const int y, const int width, const int height );
+    void HideMessage( const int id );
+    int GetMessageId( const char* d_name ) const;
+    bool AutoCloseCheck( const unsigned int id );
+
+private:
+    UiWidget* m_LimitArea;
+    std::vector< MessageData* > m_Messages;
+
+    bool m_NextPressed;
+    bool m_NextRepeated;
+    bool m_UpPressed;
+    bool m_DownPressed;
+};
+
+
+
+#endif // DIALOGS_MANAGER_H

+ 282 - 0
QGearsMain/include/core/Entity.h

@@ -0,0 +1,282 @@
+#ifndef ENTITY_H
+#define ENTITY_H
+
+#include <OgreString.h>
+
+#include "EntityCollision.h"
+#include "EntityDirection.h"
+#include "ScriptManager.h"
+
+
+
+enum ActionType
+{
+    AT_NONE,
+    AT_LINEAR,
+    AT_SMOOTH
+};
+
+
+
+enum TurnDirection
+{
+    TD_CLOCKWISE,
+    TD_ANTICLOCKWISE,
+    TD_CLOSEST
+};
+
+
+
+enum LinearMovement
+{
+    LM_UP_TO_DOWN,
+    LM_DOWN_TO_UP,
+    LM_LEFT_TO_RIGHT,
+    LM_RIGHT_TO_LEFT
+};
+
+
+
+class Entity
+{
+public:
+    enum AnimationState
+    {
+        REQUESTED_ANIMATION,
+        AUTO_ANIMATION
+    };
+
+    enum AnimationPlayType
+    {
+        PLAY_DEFAULT,
+        PLAY_ONCE,
+        PLAY_LOOPED
+    };
+
+    enum State
+    {
+        NONE,
+        WALKMESH,
+        LINEAR,
+        JUMP
+    };
+
+                         Entity( const Ogre::String& name, Ogre::SceneNode* node );
+    virtual              ~Entity();
+
+    virtual void         Update();
+    virtual void         UpdateDebug();
+
+    const Ogre::String&  GetName() const;
+
+    void                 SetPosition( const Ogre::Vector3& position );
+    void                 ScriptSetPosition( const float x, const float y, const float z );
+    const Ogre::Vector3  GetPosition() const;
+    void                 ScriptGetPosition() const;
+
+    void                 SetOffset( const Ogre::Vector3& position );
+    const Ogre::Vector3  GetOffset() const;
+
+    void                 SetRotation( const Ogre::Degree& rotation );
+    void                 ScriptSetRotation( const float rotation );
+    Ogre::Degree         GetRotation() const;
+    float                ScriptGetRotation() const;
+
+    virtual void         setScale( const Ogre::Vector3 &scale );
+    virtual void         setRootOrientation( const Ogre::Quaternion &root_orientation );
+
+    // height related
+    float                GetHeight() const;
+
+    // solid related
+    void                 SetSolidRadius( const float radius );
+    float                GetSolidRadius() const;
+    void                 SetSolid( const bool solid );
+    bool                 IsSolid() const;
+
+    // talk related
+    void                 SetTalkRadius( const float radius );
+    float                GetTalkRadius() const;
+    void                 SetTalkable( const bool talkable );
+    bool                 IsTalkable() const;
+
+    // model related
+    virtual void         SetVisible( const bool visible ) = 0;
+    virtual bool         IsVisible() const = 0;
+
+    // different type of movement state related
+    void                 SetState( const State state );
+    State                GetState() const;
+
+    // movement related
+    void                 SetMoveAutoSpeed( const float speed );
+    float                GetMoveAutoSpeed() const;
+    void                 SetMoveWalkSpeed( const float speed );
+    float                GetMoveWalkSpeed() const;
+    void                 SetMoveRunSpeed( const float speed );
+    float                GetMoveRunSpeed() const;
+    void                 SetMovePosition( const Ogre::Vector3& target );
+    const Ogre::Vector3& GetMovePosition() const;
+    float                GetMoveStopDistance() const;
+    void                 SetMoveTriangleId( const int triangle );
+    int                  GetMoveTriangleId() const;
+    void                 SetMoveAutoRotation( const bool rotate );
+    bool                 GetMoveAutoRotation() const;
+    void                 SetMoveAutoAnimation( const bool animate );
+    bool                 GetMoveAutoAnimation() const;
+    const Ogre::String&  GetMoveAnimationWalkName() const;
+    const Ogre::String&  GetMoveAnimationRunName() const;
+    void                 ScriptMoveToPosition( const float x, const float y );
+    void                 ScriptMoveToEntity( Entity* entity );
+    int                  ScriptMoveSync();
+    void                 UnsetMove();
+
+    // linear related
+    void                 ScriptLinearToPosition( const float x, const float y, const float z, const LinearMovement movement, const char* animation );
+    int                  ScriptLinearSync();
+    void                 SetLinear( const Ogre::Vector3& end, const LinearMovement movement, const Ogre::String& animation );
+    void                 UnsetLinear();
+    LinearMovement       GetLinearMovement() const;
+    const Ogre::Vector3& GetLinearStart() const;
+    const Ogre::Vector3& GetLinearEnd() const;
+
+    // jump related
+    void                 ScriptJumpToPosition( const float x, const float y, const float z,const float seconds );
+    int                  ScriptJumpSync();
+    void                 SetJump( const Ogre::Vector3& jump_to, const float seconds );
+    void                 UnsetJump();
+    const Ogre::Vector3& GetJumpStart() const;
+    const Ogre::Vector3& GetJumpEnd() const;
+    float                GetJumpSeconds() const;
+    void                 SetJumpCurrentSeconds( const float seconds );
+    float                GetJumpCurrentSeconds() const;
+
+    // offset related
+    void                 ScriptOffsetToPosition( const float x, const float y, const float z, const ActionType type, const float seconds );
+    int                  ScriptOffsetSync();
+    void                 UnsetOffset();
+    const Ogre::Vector3& GetOffsetPositionStart() const;
+    const Ogre::Vector3& GetOffsetPositionEnd() const;
+    ActionType           GetOffsetType() const;
+    float                GetOffsetSeconds() const;
+    void                 SetOffsetCurrentSeconds( const float seconds );
+    float                GetOffsetCurrentSeconds() const;
+
+    // turn related
+    void                 ScriptTurnToDirection( const float direction, const TurnDirection turn_direction, const ActionType turn_type, const float seconds );
+    void                 ScriptTurnToEntity( Entity* entity, const TurnDirection turn_direction, const float seconds );
+    int                  ScriptTurnSync();
+    void                 SetTurn( const Ogre::Degree& direction_to, Entity* entity, const TurnDirection turn_direction, const ActionType turn_type, const float seconds );
+    void                 UnsetTurn();
+    Ogre::Degree         CalculateTurnAngle( const Ogre::Degree& start, const Ogre::Degree& end ) const;
+    Ogre::Degree         GetTurnDirectionStart() const;
+    Ogre::Degree         GetTurnDirectionEnd() const;
+    ActionType           GetTurnType() const;
+    float                GetTurnSeconds() const;
+    void                 SetTurnCurrentSeconds( const float seconds );
+    float                GetTurnCurrentSeconds() const;
+
+    // animation related
+    void                 ScriptSetAnimationSpeed( const float speed );
+    const Ogre::String&  GetDefaultAnimationName() const;
+    const Ogre::String&  GetCurrentAnimationName() const;
+    AnimationState       GetAnimationState() const;
+    virtual void         PlayAnimation( const Ogre::String& animation, AnimationState state, AnimationPlayType play_type, const float start, const float end ) = 0;
+    virtual void         PlayAnimationContinue( const Ogre::String& animation ) = 0;
+    virtual void         UpdateAnimation( const float delta ) = 0;
+    void                 ScriptPlayAnimation( const char* name );
+    void                 ScriptPlayAnimationStop( const char* name );
+    void                 ScriptPlayAnimation( const char* name, const float start, const float end );
+    void                 ScriptPlayAnimationStop( const char* name, const float start, const float end );
+    void                 ScriptSetDefaultAnimation( const char* animation );
+    int                  ScriptAnimationSync();
+
+private:
+    Entity();
+    Ogre::Degree         GetDirectionToEntity( Entity* entity ) const;
+
+protected:
+    Ogre::String            m_Name;
+
+    Ogre::SceneNode*        m_SceneNode;
+    Ogre::SceneNode*        m_ModelNode;
+    Ogre::SceneNode*        m_model_root_node;
+
+    // height related
+    float                   m_Height;
+
+    Ogre::SceneNode*        m_DirectionNode;
+    EntityDirection*        m_Direction;
+
+    // collision related
+    Ogre::SceneNode*        m_SolidCollisionNode;
+    EntityCollision*        m_SolidCollision;
+    float                   m_SolidRadius;
+    bool                    m_Solid;
+
+    // talk related
+    Ogre::SceneNode*        m_TalkCollisionNode;
+    EntityCollision*        m_TalkCollision;
+    float                   m_TalkRadius;
+    bool                    m_Talkable;
+
+    // move state related
+    State                   m_State;
+    std::vector< ScriptId > m_Sync;
+
+    // move related
+    float                   m_MoveAutoSpeed;
+    float                   m_MoveWalkSpeed;
+    float                   m_MoveRunSpeed;
+    Ogre::Vector3           m_MovePosition;
+    Entity*                 m_MoveEntity;
+    float                   m_MoveStopDistance;
+    int                     m_MoveTriangleId;
+    bool                    m_MoveAutoRotation;
+    bool                    m_MoveAutoAnimation;
+    Ogre::String            m_MoveAnimationWalk;
+    Ogre::String            m_MoveAnimationRun;
+
+    // linear movement related
+    LinearMovement          m_LinearMovement;
+    Ogre::Vector3           m_LinearStart;
+    Ogre::Vector3           m_LinearEnd;
+
+    // jump related
+    Ogre::Vector3           m_JumpStart;
+    Ogre::Vector3           m_JumpEnd;
+    float                   m_JumpSeconds;
+    float                   m_JumpCurrentSeconds;
+
+    // offset related
+    Ogre::Vector3           m_OffsetPositionStart;
+    Ogre::Vector3           m_OffsetPositionEnd;
+    ActionType              m_OffsetType;
+    float                   m_OffsetSeconds;
+    float                   m_OffsetCurrentSeconds;
+    std::vector< ScriptId > m_OffsetSync;
+
+    // turn related
+    TurnDirection           m_TurnDirection;
+    Ogre::Degree            m_TurnDirectionStart;
+    Ogre::Degree            m_TurnDirectionEnd;
+    Entity*                 m_TurnEntity;
+    ActionType              m_TurnType;
+    float                   m_TurnSeconds;
+    float                   m_TurnCurrentSeconds;
+    std::vector< ScriptId > m_TurnSync;
+
+    // animation
+    float                   m_AnimationSpeed;
+    Ogre::String            m_AnimationCurrentName;
+    std::vector< ScriptId > m_AnimationSync;
+    AnimationState          m_AnimationState;
+    AnimationPlayType       m_AnimationPlayType;
+    Ogre::String            m_AnimationDefault;
+    float                   m_AnimationEndTime;
+    bool                    m_AnimationAutoPlay;
+};
+
+
+
+#endif // ENTITY_H

+ 21 - 0
QGearsMain/include/core/EntityCollision.h

@@ -0,0 +1,21 @@
+#ifndef ENTITY_COLLISION_H
+#define ENTITY_COLLISION_H
+
+#include <OgreCamera.h>
+#include <OgreSimpleRenderable.h>
+
+
+
+class EntityCollision : public Ogre::SimpleRenderable
+{
+public:
+    EntityCollision();
+    virtual ~EntityCollision();
+
+    Ogre::Real getSquaredViewDepth( const Ogre::Camera* cam ) const;
+    Ogre::Real getBoundingRadius() const;
+};
+
+
+
+#endif // ENTITY_COLLISION_H

+ 21 - 0
QGearsMain/include/core/EntityDirection.h

@@ -0,0 +1,21 @@
+#ifndef ENTITY_DIRECTION_H
+#define ENTITY_DIRECTION_H
+
+#include <OgreCamera.h>
+#include <OgreSimpleRenderable.h>
+
+
+
+class EntityDirection : public Ogre::SimpleRenderable
+{
+public:
+    EntityDirection();
+    virtual ~EntityDirection();
+
+    Ogre::Real getSquaredViewDepth( const Ogre::Camera* cam ) const;
+    Ogre::Real getBoundingRadius() const;
+};
+
+
+
+#endif // ENTITY_DIRECTION_H

+ 135 - 0
QGearsMain/include/core/EntityManager.h

@@ -0,0 +1,135 @@
+#ifndef ENTITY_MANAGER_H
+#define ENTITY_MANAGER_H
+
+#include <OgreSingleton.h>
+
+#include "Background2D.h"
+#include "Entity.h"
+#include "EntityPoint.h"
+#include "EntityTrigger.h"
+#include "Event.h"
+#include "Walkmesh.h"
+
+
+
+class EntityManager : public Ogre::Singleton< EntityManager >
+{
+public:
+    EntityManager();
+    virtual ~EntityManager();
+
+    void Input(const QGears::Event& event);
+    void Update();
+    void UpdateDebug();
+    void OnResize();
+
+    void Clear();
+
+    void ScriptSetPaused( const bool paused );
+
+    Walkmesh* GetWalkmesh();
+    Background2D* GetBackground2D();
+    void AddEntity( const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position, const Ogre::Degree& direction );
+    void AddEntity( const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position, const Ogre::Degree& rotation, const Ogre::Vector3& scale, const Ogre::Quaternion& root_orientation );
+    void ScriptAddEntity( const char* name, const char* file_name, const float x, const float y, const float z, const float direction );
+    void AddEntityTrigger( const Ogre::String& name, const Ogre::Vector3& point1, const Ogre::Vector3& point2, const bool enabled );
+    void AddEntityPoint( const Ogre::String& name, const Ogre::Vector3& position, const float rotation );
+    void AddEntityScript( const Ogre::String& name );
+    void ScriptAddEntityScript( const char* name );
+
+    Entity* GetEntity( const Ogre::String& name ) const;
+    Entity* ScriptGetEntity( const char* name ) const;
+    EntityPoint* ScriptGetEntityPoint( const char* name ) const;
+
+    void ScriptSetPlayerEntity( const char* name );
+    void ScriptUnsetPlayerEntity();
+    void ScriptPlayerLock( const bool lock );
+    void SetPlayerMoveRotation( const Ogre::Radian rotation );
+
+    /**
+     * Checks if random battle encounters are active in the field.
+     *
+     * @return True random battles can occur, false otherwise.
+     */
+    bool GetRandomEncounters();
+
+    /**
+     * Enables or disables random encounters in the field.
+     *
+     * @param active[in] True to enable encounters, false to deactivate
+     * them.
+     */
+    void SetRandomEncounters(bool active);
+
+    /**
+     * Get the encounter rate for the field.
+     *
+     * @return The encounter rate, between 0 and 1 (both included).
+     */
+    float GetEncounterRate();
+
+    /**
+     * Sets the battle encounter rate.
+     *
+     * @param rate[in] The encounter rate (max. 1).
+     */
+    void SetEncounterRate(float rate);
+
+    /**
+     * Starts a battle.
+     *
+     * @TODO
+     * @param formation[in] The enemy formation to fight.
+     * @return True if the battle victory conditions are met, false\
+     * otherwise.
+     */
+    //bool StartBattle(unsigned int formation);
+    void StartBattle(unsigned int formation);
+
+private:
+    // movement
+    bool SetEntityOnWalkmesh( Entity* entity );
+    bool PerformWalkmeshMove( Entity* entity, const float speed );
+    bool WalkmeshBorderCross( Entity* entity, Ogre::Vector3& position, const Ogre::Vector2& move_vector );
+    bool CheckSolidCollisions( Entity* entity, Ogre::Vector3& position );
+    void SetEntityDirectionByVector( Entity* entity, const Ogre::Vector2& vector );
+    void CheckTriggers( Entity* entity, Ogre::Vector3& position );
+    void CheckEntityInteract();
+
+    void SetNextOffsetStep( Entity* entity );
+    void SetNextTurnStep( Entity* entity );
+    void SetNextLinearStep( Entity* entity );
+    void SetNextJumpStep( Entity* entity );
+    void SetNextScrollStep();
+
+private:
+    bool                          m_Paused;
+
+    Walkmesh                      m_Walkmesh;
+    Background2D                  m_Background2D;
+
+    Ogre::String                  m_EntityTableName;
+    std::vector< Entity* >        m_Entity;
+    Entity*                       m_PlayerEntity;
+    Ogre::Vector3                 m_PlayerMove;
+    Ogre::Radian                  m_PlayerMoveRotation;
+    bool                          m_PlayerLock;
+    bool                          m_PlayerRun;
+
+    std::vector< EntityTrigger* > m_EntityTriggers;
+    std::vector< EntityPoint* >   m_EntityPoints;
+    std::vector< Ogre::String >   m_EntityScripts;
+
+    Ogre::SceneNode*              m_SceneNode;
+
+    Ogre::Entity*                 m_Grid;
+    Ogre::Entity*                 m_Axis;
+
+    // TODO battle formations
+    bool random_encounters_;
+    float encounter_rate_;
+};
+
+
+
+#endif // ENTITY_MANAGER_H

+ 35 - 0
QGearsMain/include/core/EntityModel.h

@@ -0,0 +1,35 @@
+#ifndef ENTITY_MODEL_H
+#define ENTITY_MODEL_H
+
+#include "Entity.h"
+
+
+
+class EntityModel : public Entity
+{
+public:
+                        EntityModel( const Ogre::String& name, const Ogre::String file_name, Ogre::SceneNode* node );
+    virtual             ~EntityModel();
+
+    virtual void        Update();
+
+    // model related
+    virtual void        SetVisible( const bool visible );
+    virtual bool        IsVisible() const;
+
+    // animation related
+    virtual void        PlayAnimation( const Ogre::String& animation, AnimationState state, AnimationPlayType play_type, const float start, const float end );
+    virtual void        PlayAnimationContinue( const Ogre::String& animation );
+    virtual void        UpdateAnimation( const float delta );
+
+private:
+    EntityModel();
+
+private:
+    Ogre::Entity* m_Model;
+    Ogre::AnimationState* m_AnimationCurrent;
+};
+
+
+
+#endif // ENTITY_MODEL_H

+ 34 - 0
QGearsMain/include/core/EntityPoint.h

@@ -0,0 +1,34 @@
+#ifndef ENTITY_POINT_H
+#define ENTITY_POINT_H
+
+#include <OgreRoot.h>
+
+
+
+class EntityPoint
+{
+public:
+    EntityPoint( const Ogre::String& name );
+    virtual ~EntityPoint();
+
+    void UpdateDebug();
+
+    const Ogre::String& GetName() const;
+
+    void SetPosition( const Ogre::Vector3& point );
+    const Ogre::Vector3& GetPosition() const;
+    void ScriptGetPosition() const;
+
+    void SetRotation( const float rotation );
+    float GetRotation() const;
+    float ScriptGetRotation() const;
+
+protected:
+    Ogre::String m_Name;
+    Ogre::Vector3 m_Position;
+    float m_Rotation;
+};
+
+
+
+#endif // ENTITY_POINT_H

+ 44 - 0
QGearsMain/include/core/EntityTrigger.h

@@ -0,0 +1,44 @@
+#ifndef ENTITY_TRIGGER_H
+#define ENTITY_TRIGGER_H
+
+#include <OgreRoot.h>
+
+class Entity;
+
+
+
+class EntityTrigger
+{
+public:
+    EntityTrigger( const Ogre::String& name );
+    virtual ~EntityTrigger();
+
+    void UpdateDebug();
+
+    const Ogre::String& GetName() const;
+
+    void SetEnabled( const bool enabled );
+    bool IsEnabled() const;
+
+    void AddActivator( Entity* activator );
+    void RemoveActivator( Entity* activator );
+    bool IsActivator( Entity* activator );
+
+    void SetPoints( const Ogre::Vector3& point1, const Ogre::Vector3& point2 );
+    const Ogre::Vector3& GetPoint1() const;
+    const Ogre::Vector3& GetPoint2() const;
+
+protected:
+    Ogre::String m_Name;
+
+    bool m_Enabled;
+
+    std::vector< Entity* > m_Activators;
+
+    Ogre::Vector3 m_Point1;
+    Ogre::Vector3 m_Point2;
+};
+
+
+
+#endif // ENTITY_TRIGGER_H

+ 53 - 0
QGearsMain/include/core/Event.h

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

+ 42 - 0
QGearsMain/include/core/GameFrameListner.h

@@ -0,0 +1,42 @@
+#ifndef GAME_FRAME_LISTENER_H
+#define GAME_FRAME_LISTENER_H
+
+#include <OgreFrameListener.h>
+#include <OgreRenderWindow.h>
+#include <OgreWindowEventUtilities.h>
+#include <OIS/OIS.h>
+
+
+
+class GameFrameListener : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener
+{
+public:
+                 GameFrameListener( Ogre::RenderWindow* win );
+    virtual     ~GameFrameListener();
+
+    bool         frameStarted( const Ogre::FrameEvent& evt );
+    bool         frameEnded( const Ogre::FrameEvent& evt );
+
+    virtual void windowMoved( Ogre::RenderWindow *rw );
+    virtual void windowResized( Ogre::RenderWindow *rw );
+    virtual void windowClosed( Ogre::RenderWindow* rw );
+    virtual void windowFocusChange( Ogre::RenderWindow *rw );
+
+    bool         keyPressed( const OIS::KeyEvent& e );
+    bool         keyReleased( const OIS::KeyEvent& e );
+
+    bool         mouseMoved( const OIS::MouseEvent &e );
+    bool         mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
+    bool         mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );
+
+protected:
+    Ogre::RenderWindow* m_Window;
+
+    OIS::InputManager*  m_InputManager;
+    OIS::Keyboard*      m_Keyboard;
+    OIS::Mouse*         m_Mouse;
+};
+
+
+
+#endif // GAME_FRAME_LISTENER_H

+ 73 - 0
QGearsMain/include/core/InputManager.h

@@ -0,0 +1,73 @@
+#ifndef INPUT_FILTER_H
+#define INPUT_FILTER_H
+
+#include <OgreSingleton.h>
+#include <OgreString.h>
+#include <OIS/OIS.h>
+#include <vector>
+
+#include "Event.h"
+
+
+
+typedef std::vector< QGears::Event > InputEventArray;
+typedef std::vector< int > ButtonList;
+
+class ConfigCmd;
+
+class InputManager : public Ogre::Singleton< InputManager >
+{
+public:
+                        InputManager();
+    virtual             ~InputManager();
+
+    void                ButtonPressed( int button, char text, bool down );
+    void                MousePressed( int button, bool down );
+    void                MouseMoved( int x, int y );
+    void                MouseScrolled( int value );
+    void                Reset();
+    void                Update();
+
+    bool                IsButtonPressed( int button ) const;
+
+    void                GetInputEvents( InputEventArray& input_events );
+
+    // binds
+    void                InitCmd();
+    void                BindCommand( ConfigCmd* cmd, const Ogre::StringVector& params, const ButtonList& buttons );
+    void                BindGameEvent( const Ogre::String& event, const ButtonList& buttons );
+    void                ActivateBinds( const int button );
+    void                AddGameEvents( const int button, const QGears::EventType type );
+
+private:
+    bool                    m_ButtonState[ 256 ];
+    char                    m_ButtonText[ 256 ];
+
+    bool                    m_RepeatFirstWait;
+    float                   m_RepeatTimer;
+
+    InputEventArray         m_EventQueue;
+
+    // binds
+    struct BindInfo
+    {
+        BindInfo():
+            cmd( NULL )
+        {}
+
+        ConfigCmd* cmd;
+        Ogre::StringVector params;
+        ButtonList buttons;
+    };
+    std::vector< BindInfo > m_Binds;
+    struct BindGameEventInfo
+    {
+        Ogre::String event;
+        ButtonList buttons;
+    };
+    std::vector< BindGameEventInfo > m_BindGameEvents;
+};
+
+
+
+#endif // INPUT_FILTER_H

+ 92 - 0
QGearsMain/include/core/InputManagerCommands.h

@@ -0,0 +1,92 @@
+#include <OgreStringConverter.h>
+
+#include "Console.h"
+#include "ConfigCmdManager.h"
+#include "ConfigVarManager.h"
+#include "Logger.h"
+#include "Utilites.h"
+
+
+
+bool
+ParseKeys( const Ogre::String& string, ButtonList& key_codes )
+{
+    Ogre::StringVector keys = Ogre::StringUtil::split( string, "+" );
+
+    for( unsigned int i = 0; i < keys.size(); ++i )
+    {
+        key_codes.push_back( StringToKey( keys[ i ] ) );
+    }
+
+    bool fail = false;
+    for( unsigned int i = 0; i < key_codes.size(); ++i )
+    {
+        if( key_codes[ i ] == OIS::KC_UNASSIGNED )
+        {
+            LOG_ERROR( "Failed to parse key string \"" + string + "\". Can't recognize key " + Ogre::StringConverter::toString( i ) );
+            fail = true;
+        }
+    }
+
+    return fail;
+}
+
+
+
+void
+CmdBind( const Ogre::StringVector& params )
+{
+    if( params.size() != 3 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /bind <key1>+[key2]+[key3] \"<command line>\"" );
+        return;
+    }
+
+    ButtonList key_codes;
+
+    if( ParseKeys( params[ 1 ], key_codes ) == false )
+    {
+        Ogre::StringVector params_cmd = StringTokenise( params[ 2 ] );
+
+        // handle command
+        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find( params_cmd[ 0 ] );
+        if( cmd != NULL )
+        {
+            InputManager::getSingleton().BindCommand( cmd, params_cmd, key_codes );
+            LOG_TRIVIAL( "Bind \"" + params[ 1 ] + "\" to command \"" + params[ 2 ] + "\"." );
+        }
+        else
+        {
+            LOG_ERROR( "Can't find command \"" + params_cmd[ 0 ] + "\" in bind command \"" + params[ 2 ] + "\"." );
+        }
+    }
+}
+
+
+
+void
+CmdBindGameEvent( const Ogre::StringVector& params )
+{
+    if( params.size() != 3 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /game_bind <key1>+[key2]+[key3] \"<game event>\"" );
+        return;
+    }
+
+    ButtonList key_codes;
+
+    if( ParseKeys( params[ 1 ], key_codes ) == false )
+    {
+        InputManager::getSingleton().BindGameEvent( params[ 2 ], key_codes );
+        LOG_TRIVIAL( "Bind \"" + params[ 1 ] + "\" to game event \"" + params[ 2 ] + "\"." );
+    }
+}
+
+
+
+void
+InputManager::InitCmd()
+{
+    ConfigCmdManager::getSingleton().AddCommand( "bind", "Bind command to keys", "", CmdBind, NULL );
+    ConfigCmdManager::getSingleton().AddCommand( "bind_game_event", "Bind game event to keys", "", CmdBindGameEvent, NULL );
+}

+ 23 - 0
QGearsMain/include/core/Logger.h

@@ -0,0 +1,23 @@
+#ifndef LOGGER_H
+#define LOGGER_H
+
+#include <OgreLogManager.h>
+#include <OgreString.h>
+#include <OgreStringConverter.h>
+#include <string>
+
+
+#define LOG_ERROR( message ) Ogre::LogManager::getSingleton().logMessage( "[ERROR] " + Ogre::String( __FILE__ ) + " " + Ogre::StringConverter::toString( __LINE__ ) + ": " + message, Ogre::LML_CRITICAL )
+#define LOG_WARNING( message ) Ogre::LogManager::getSingleton().logMessage( "[WARNING] " + Ogre::String( __FILE__ ) + " " + Ogre::StringConverter::toString( __LINE__ ) + ": " + message, Ogre::LML_NORMAL )
+#define LOG_TRIVIAL( message ) Ogre::LogManager::getSingleton().logMessage( message, Ogre::LML_TRIVIAL )
+#define LOG_CONSOLE( message) Ogre::LogManager::getSingleton().logMessage( message, Ogre::LML_NORMAL )
+
+#ifdef _MSC_VER
+#define LOG_DEBUG_EX( message ) Ogre::LogManager::getSingleton().logMessage( "[DEBUG] (" +  __FILE__ + " " + Ogre::StringConverter::toString( __LINE__ ) + ")(" + std::string( __FUNCTION__ ) + "): " + message, Ogre::LML_CRITICAL )
+#define LOG_DEBUG( message ) Ogre::LogManager::getSingleton().logMessage( "[DEBUG] (" + std::string( __FUNCTION__ ) + "): " + message, Ogre::LML_CRITICAL )
+#else
+#define LOG_DEBUG_EX( message ) Ogre::LogManager::getSingleton().logMessage( "[DEBUG] (" +  __FILE__ + " " + Ogre::StringConverter::toString( __LINE__ ) + ")(" + std::string( __PRETTY_FUNCTION__ ) + "): " + message, Ogre::LML_CRITICAL )
+#define LOG_DEBUG( message ) Ogre::LogManager::getSingleton().logMessage( "[DEBUG] (" + std::string( __PRETTY_FUNCTION__ ) + "): " + message, Ogre::LML_CRITICAL )
+#endif
+
+#endif // LOGGER_H

+ 37 - 0
QGearsMain/include/core/Module.h

@@ -0,0 +1,37 @@
+#ifndef MODULE_H
+#define MODULE_H
+
+#include <OIS/OIS.h>
+#include "Event.h"
+
+
+
+enum MODULE_STATE
+{
+    MODULE_START,
+    MODULE_RUN,
+    MODULE_FINISH,
+    MODULE_STOP,
+    MODULE_PAUSE
+};
+
+
+
+class Module
+{
+public:
+    virtual ~Module(){};
+
+    virtual void Input(const Event& event) = 0;
+    virtual void Update() = 0;
+
+    void SetState(const MODULE_STATE state) {m_State = state;};
+    const MODULE_STATE GetState() const {return m_State;};
+
+private:
+    MODULE_STATE m_State;
+};
+
+
+
+#endif // MODULE_H

+ 128 - 0
QGearsMain/include/core/ScriptManager.h

@@ -0,0 +1,128 @@
+#ifndef SCRIPT_MANAGER_H
+#define SCRIPT_MANAGER_H
+
+#include <OgreSingleton.h>
+#include <OgreString.h>
+
+#include "Event.h"
+#include "LuaIncludes.h"
+
+class Entity;
+
+struct ScriptId
+{
+    ScriptId(): entity( "" ), function( "" ){}
+
+    Ogre::String entity;
+    Ogre::String function;
+};
+
+
+
+struct ScriptEntity;
+
+
+
+struct QueueScript
+{
+    QueueScript():
+        function( "" ),
+        argument1( "" ),
+        argument2( "" ),
+        priority( 0 ),
+        state( NULL ),
+        seconds_to_wait( 0 ),
+        wait( false ),
+        yield( false )
+    {}
+
+    Ogre::String function;
+    Ogre::String argument1;
+    Ogre::String argument2;
+    int priority;
+    lua_State* state;
+    int state_id; // for storing and deleating thread
+    float seconds_to_wait;
+    bool wait;
+    bool yield;
+    ScriptId paused_script_start; // script paused by call of this script.
+    ScriptId paused_script_end; // script paused by call of this script.
+};
+
+
+
+class ScriptManager : public Ogre::Singleton< ScriptManager >
+{
+public:
+    enum Type
+    {
+        SYSTEM,
+        ENTITY,
+        UI,
+        FIELD
+    };
+
+    ScriptManager();
+    virtual ~ScriptManager();
+
+    void Input(const QGears::Event& event);
+    void Update( const Type type );
+
+    void RunString( const Ogre::String& lua );
+    void RunFile( const Ogre::String& file );
+
+    // binds
+    void InitBinds();
+    void InitCmd();
+
+    void AddEntity( const Type type, const Ogre::String& entity_name, Entity* entity );
+    void RemoveEntity( const Type type, const Ogre::String& entity_name );
+    void AddEntityScript( const Ogre::String& entity_name, const Ogre::String& function_name, int priority );
+    void RemoveEntityTopScript( ScriptEntity& entity );
+
+    luabind::object GetTableByEntityName( const ScriptManager::Type type, const Ogre::String& name, lua_State* state ) const;
+    QueueScript* GetScriptByScriptId( const ScriptId& script ) const;
+    ScriptEntity* GetScriptEntityByName( const Type type, const Ogre::String& entity_name ) const;
+    const ScriptId GetCurrentScriptId() const;
+    void ContinueScriptExecution( const ScriptId& script );
+
+    int ScriptWait( const float seconds );
+    void ScriptRequest( const Type type, const char* entity, const char* function, const int priority );
+    int ScriptRequestStartSync( const Type type, const char* entity, const char* function, const int priority );
+    int ScriptRequestEndSync( const Type type, const char* entity, const char* function, const int priority );
+    bool 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 );
+
+    void AddValueToStack( const float value );
+
+private:
+    lua_State* m_LuaState;
+
+    Ogre::String m_SystemTableName;
+    Ogre::String m_EntityTableName;
+    Ogre::String m_UiTableName;
+
+    std::vector< ScriptEntity > m_ScriptEntity;
+
+    ScriptId m_CurrentScriptId;
+};
+
+
+
+struct ScriptEntity
+{
+    ScriptEntity():
+        name( "" ),
+        type( ScriptManager::SYSTEM ),
+        resort( false )
+    {
+    }
+
+    Ogre::String name;
+    ScriptManager::Type type;
+    std::vector< QueueScript > queue;
+    bool resort;
+};
+
+
+
+#endif // SCRIPT_MANAGER_H

+ 299 - 0
QGearsMain/include/core/ScriptManagerBinds.h

@@ -0,0 +1,299 @@
+/*
+ * Q-Gears
+ * Copyright (C) 2022 Q-Gears Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <iostream>
+#include "Console.h"
+#include "Logger.h"
+#include "Entity.h"
+#include "EntityManager.h"
+#include "Timer.h"
+#include "UiManager.h"
+#include "UiWidget.h"
+#include "XmlMapFile.h"
+#include "XmlMapsFile.h"
+#include "DialogsManager.h"
+#include "modules/worldmap/WorldMapModule.h"
+
+/**
+ * Prints to the game console.
+ *
+ * @param text[in] The text to be printed.
+ */
+void ScriptPrint(const char* text){
+    Console::getSingleton().AddTextToOutput(text);
+}
+
+/**
+ * Changes the current map.
+ *
+ * Reads the data for the next map, initializes all it's entities, scripts, etc
+ * and loads it.
+ *
+ * @param text The new map name.
+ */
+void ScriptMap(const char* text){
+    EntityManager::getSingleton().Clear();
+    XmlMapsFile xml("./data/maps.xml");
+    Ogre::String file_name = xml.GetMapFileNameByName(text);
+    XmlMapFile xml_map("./data/" + file_name);
+    xml_map.LoadMap();
+}
+
+/**
+ * Executes a script in the game console.
+ *
+ * It should not be related to the game itself. The script output will be
+ * written to the game console.
+ *
+ * @param text[in] The script command to execute.
+ */
+void ScriptConsole(const char* text){
+    Console::getSingleton().ExecuteCommand(text);
+}
+
+/**
+ * Initializes the lua command binds
+ *
+ * It relates the command available in the field maps to C++ functions
+ */
+void ScriptManager::InitBinds(){
+
+    std::cout << "[INIT BINDS] Begin " << std::endl;
+
+    // Global functions.
+    luabind::module(m_LuaState)[
+        luabind::def("print", (void(*)(const char*)) &ScriptPrint),
+        luabind::def("map", (void(*)(const char*)) &ScriptMap),
+        luabind::def("console", (void(*)(const char*)) &ScriptConsole)
+    ];
+
+    std::cout << "[INIT BINDS] 1 " << std::endl;
+
+    // Individual entity commands.
+    luabind::module(m_LuaState)[
+        luabind::class_< Entity >("Entity")
+          .def("set_position", (void(Entity::*)(const float, const float, const float)) &Entity::ScriptSetPosition)
+          .def("get_position", (void(Entity::*)()) &Entity::ScriptGetPosition) // return 3 values internaly
+          .def("set_rotation", (void(Entity::*)(const float)) &Entity::ScriptSetRotation)
+          .def("get_rotation", (float(Entity::*)()) &Entity::ScriptGetRotation)
+          .def("set_solid_radius", (void(Entity::*)(const float)) &Entity::SetSolidRadius)
+          .def("get_solid_radius", (float(Entity::*)()) &Entity::GetSolidRadius)
+          .def("set_solid", (void(Entity::*)(const bool)) &Entity::SetSolid)
+          .def("is_solid", (bool(Entity::*)()) &Entity::IsSolid)
+          .def("set_talk_radius", (void(Entity::*)(const float)) &Entity::SetTalkRadius)
+          .def("get_talk_radius", (float(Entity::*)()) &Entity::GetTalkRadius)
+          // Some old test script use this, its just an alias for SetTalkable
+          .def("set_interactable", (void(Entity::*)(const bool)) &Entity::SetTalkable)
+          .def("set_talkable", (void(Entity::*)(const bool)) &Entity::SetTalkable)
+          .def("is_talkable", (bool(Entity::*)()) &Entity::IsTalkable)
+          .def("set_visible", (void(Entity::*)(const bool)) &Entity::SetVisible)
+          .def("is_visible", (bool(Entity::*)()) &Entity::IsVisible)
+          .def("set_move_auto_speed", (void(Entity::*)(const float)) &Entity::SetMoveAutoSpeed)
+          .def("get_move_auto_speed", (float(Entity::*)()) &Entity::GetMoveAutoSpeed)
+          .def("get_move_triangle_id", (int(Entity::*)()) &Entity::GetMoveTriangleId)
+          .def("move_auto_rotation", (void(Entity::*)(const bool)) &Entity::SetMoveAutoRotation)
+          .def("move_auto_animation", (void(Entity::*)(const bool)) &Entity::SetMoveAutoAnimation)
+          .def("move_to_position", (void(Entity::*)(const float, const float)) &Entity::ScriptMoveToPosition)
+          .def("move_to_entity", (void(Entity::*)(Entity*)) &Entity::ScriptMoveToEntity)
+          .def("move_sync", (int(Entity::*)()) &Entity::ScriptMoveSync, luabind::yield)
+          .def("linear_to_position", (void(Entity::*)(const float, const float, const float, const LinearMovement, const char*)) &Entity::ScriptLinearToPosition)
+          .def("linear_sync", (int(Entity::*)()) &Entity::ScriptLinearSync, luabind::yield)
+          .def("jump_to_position", (void(Entity::*)(const float, const float, const float, const float))&Entity::ScriptJumpToPosition)
+          .def("jump_sync", (int(Entity::*)()) &Entity::ScriptJumpSync, luabind::yield)
+          .def("offset_to_position", (void(Entity::*)(const float, const float, const float, const ActionType, const float)) &Entity::ScriptOffsetToPosition)
+          .def("offset_sync", (int(Entity::*)()) &Entity::ScriptOffsetSync, luabind::yield)
+          .def("turn_to_entity", (void(Entity::*)(Entity*, const TurnDirection, const float))&Entity::ScriptTurnToEntity)
+          .def("turn_to_direction", (void(Entity::*)(const float, const TurnDirection, const ActionType, const float))&Entity::ScriptTurnToDirection)
+          .def("turn_sync", (int(Entity::*)()) &Entity::ScriptTurnSync, luabind::yield)
+          .def("set_animation_speed", (void(Entity::*)(const float)) &Entity::ScriptSetAnimationSpeed)
+          .def("play_animation", (void(Entity::*)(const char*)) &Entity::ScriptPlayAnimation)
+          .def("play_animation_stop", (void(Entity::*)(const char*)) &Entity::ScriptPlayAnimationStop)
+          .def("play_animation", (void(Entity::*)(const char*, const float, const float)) &Entity::ScriptPlayAnimation)
+          .def("play_animation_stop", (void(Entity::*)(const char*, const float, const float)) &Entity::ScriptPlayAnimationStop)
+          .def("set_default_animation", (void(Entity::*)(const char*)) &Entity::ScriptSetDefaultAnimation)
+          .def("animation_sync", (int(Entity::*)()) &Entity::ScriptAnimationSync, luabind::yield)
+          .enum_("constants")[
+             luabind::value("NONE", AT_NONE),
+             luabind::value("LINEAR", AT_LINEAR),
+             luabind::value("SMOOTH", AT_SMOOTH),
+             luabind::value("CLOCKWISE", TD_CLOCKWISE),
+             luabind::value("ANTICLOCKWISE", TD_ANTICLOCKWISE),
+             luabind::value("CLOSEST", TD_CLOSEST),
+             luabind::value("UP_TO_DOWN", LM_UP_TO_DOWN),
+             luabind::value("DOWN_TO_UP", LM_DOWN_TO_UP),
+             luabind::value("LEFT_TO_RIGHT", LM_LEFT_TO_RIGHT),
+             luabind::value("RIGHT_TO_LEFT", LM_RIGHT_TO_LEFT)
+           ]
+    ];
+
+    std::cout << "[INIT BINDS] 1 " << std::endl;
+
+    // Field commands.
+    // TODO: Duplicated in group EntityManager, this can probably be deleted
+    luabind::module(m_LuaState)[
+        luabind::class_< EntityManager >("Field")
+          .def("random_encounters_on", (float(EntityManager::*)(bool)) &EntityManager::SetRandomEncounters)
+          .def("start_battle", (void(EntityManager::*)(unsigned int)) &EntityManager::StartBattle)
+          // TODO: Run? Set battle flags
+          .def("battle_run", (void(EntityManager::*)(unsigned int)) &EntityManager::StartBattle)
+    ];
+
+    // Entity individual point commands
+    luabind::module(m_LuaState)[
+        luabind::class_< EntityPoint >("EntityPoint")
+          .def("get_position", (void(EntityPoint::*)()) &EntityPoint::ScriptGetPosition) // return 3 values internaly
+          .def("get_rotation", (float(EntityPoint::*)()) &EntityPoint::ScriptGetRotation)
+    ];
+
+    // Commands for the entity manager, not related to any particular entity.
+    luabind::module(m_LuaState)[
+        luabind::class_< EntityManager >("EntityManager")
+          .def("set_paused", (void(EntityManager::*)(const bool)) &EntityManager::ScriptSetPaused)
+          .def("add_entity", (void(EntityManager::*)(const char*, const char*, const float, const float, const float, const float)) &EntityManager::ScriptAddEntity)
+          .def("add_entity_script", (void(EntityManager::*)(const char*)) &EntityManager::ScriptAddEntityScript)
+          .def("get_entity", (Entity*(EntityManager::*)(const char*)) &EntityManager::ScriptGetEntity)
+          .def("get_entity_point", (EntityPoint*(EntityManager::*)(const char*)) &EntityManager::ScriptGetEntityPoint)
+          .def("set_player_entity", (void(EntityManager::*)(const char*)) &EntityManager::ScriptSetPlayerEntity)
+          .def("unset_player_entity", (void(EntityManager::*)()) &EntityManager::ScriptUnsetPlayerEntity)
+          .def("player_lock", (void(EntityManager::*)(const bool)) &EntityManager::ScriptPlayerLock)
+          .def("random_encounters_on", (float(EntityManager::*)(bool)) &EntityManager::SetRandomEncounters)
+          .def("start_battle", (void(EntityManager::*)(unsigned int)) &EntityManager::StartBattle)
+          // TODO: Run? Set battle flags
+          .def("battle_run", (void(EntityManager::*)(unsigned int)) &EntityManager::StartBattle)
+    ];
+
+    // 2D background and camera commands
+    luabind::module(m_LuaState)[
+        luabind::class_< Background2D >("Background2D")
+          .def("autoscroll_to_entity", (void(Background2D::*)(Entity*)) &Background2D::ScriptAutoScrollToEntity)
+          .def("scroll_to_position", (void(Background2D::*)(const float, const float, const Background2D::ScrollType, const float)) &Background2D::ScriptScrollToPosition)
+          .def("scroll_sync", (int(Background2D::*)()) &Background2D::ScriptScrollSync, luabind::yield)
+          .def("play_animation_looped", (void(Background2D::*)(const char*)) &Background2D::ScriptPlayAnimationLooped)
+          .def("play_animation_once", (void(Background2D::*)(const char*)) &Background2D::ScriptPlayAnimationOnce)
+          .def("animation_sync", (int(Background2D::*)(const char*)) &Background2D::ScriptAnimationSync, luabind::yield)
+          .enum_("constants")[
+            luabind::value("NONE", AT_NONE),
+            luabind::value("LINEAR", AT_LINEAR),
+            luabind::value("SMOOTH", AT_SMOOTH)
+          ]
+    ];
+
+    // Walkmesh commands
+    luabind::module(m_LuaState)[
+        luabind::class_< Walkmesh >("Walkmesh")
+          .def("lock_walkmesh", (void(Walkmesh ::*)(unsigned int, bool)) &Walkmesh ::LockWalkmesh)
+          .def("is_locked", (bool(Walkmesh ::*)(unsigned int)) &Walkmesh ::IsLocked)
+    ];
+
+    // Dialog commands
+    luabind::module(m_LuaState)[
+        luabind::class_< DialogsManager >("Dialog")
+          .def("dialog_open", (void(DialogsManager::*)(const char*, int, int, int, int)) &DialogsManager::OpenDialog)
+          .def("dialog_set_text", (void(DialogsManager::*)(const char*, const char*)) &DialogsManager::SetText)
+          .def("dialog_wait_for_close", (int(DialogsManager::*)(const char*)) &DialogsManager::Sync, luabind::yield)
+          .def("dialog_close", (void(DialogsManager::*)(const char*)) &DialogsManager::Hide)
+          .def("set_variable", (void(DialogsManager::*)(const char*, const char*, const char*)) &DialogsManager::SetVariable)
+          .def("set_clickable", (void(DialogsManager::*)(const char*, const bool)) &DialogsManager::SetClickable)
+          .def("set_cursor", (void(DialogsManager::*)(const char*, const int, const int)) &DialogsManager::SetCursor)
+          .def("get_cursor", (int(DialogsManager::*)(const char*)) &DialogsManager::GetCursor)
+          .enum_("constants")[
+            luabind::value("SOLID", MSL_SOLID),
+            luabind::value("TRANSPARENT", MSL_TRANSPARENT),
+            luabind::value("NONE", MSL_NONE)
+          ]
+    ];
+
+    // UI widget commands
+    luabind::module(m_LuaState)[
+        luabind::class_< UiWidget >("UiWidget")
+          .def("set_visible", (void(UiWidget::*)(const bool)) &UiWidget::SetVisible)
+          .def("is_visible", (bool(UiWidget::*)()) &UiWidget::IsVisible)
+          .def("play_animation", (void(UiWidget::*)(const char*)) &UiWidget::ScriptPlayAnimation)
+          .def("play_animation_stop", (void(UiWidget::*)(const char*)) &UiWidget::ScriptPlayAnimationStop)
+          .def("play_animation", (void(UiWidget::*)(const char*, const float, const float)) &UiWidget::ScriptPlayAnimation)
+          .def("play_animation_stop", (void(UiWidget::*)(const char*, const float, const float)) &UiWidget::ScriptPlayAnimationStop)
+          .def("set_default_animation", (void(UiWidget::*)(const char*)) &UiWidget::ScriptSetDefaultAnimation)
+          .def("animation_sync", (int(UiWidget::*)()) &UiWidget::ScriptAnimationSync, luabind::yield)
+          .def("set_colour", (void(UiWidget::*)(const float, const float, const float)) &UiWidget::SetColour)
+          .def("set_alpha", (void(UiWidget::*)(const float)) &UiWidget::SetAlpha)
+          .def("set_x", (void(UiWidget::*)(const float, const float)) &UiWidget::SetX)
+          .def("set_y", (void(UiWidget::*)(const float, const float)) &UiWidget::SetY)
+          .def("set_z", (void(UiWidget::*)(const float)) &UiWidget::SetZ)
+          .def("set_width", (void(UiWidget::*)(const float, const float)) &UiWidget::SetWidth)
+          .def("set_height", (void(UiWidget::*)(const float, const float)) &UiWidget::SetHeight)
+    ];
+
+    // UI manager commands. Use to get a specific widget.
+    luabind::module(m_LuaState)[
+        luabind::class_< UiManager >("UiManager")
+          .def("get_widget", (UiWidget*(UiManager::*)(const char*)) &UiManager::ScriptGetWidget)
+    ];
+
+    // Timer command. To show a in-game timer.
+    luabind::module(m_LuaState)[
+        luabind::class_< Timer >("Timer")
+          .def("get_game_time_total", (float(Timer::*)()) &Timer::GetGameTimeTotal)
+          .def("set_timer", (float(Timer::*)(const float)) &Timer::SetGameTimer)
+          .def("get_timer", (int(Timer::*)()) &Timer::GetGameTimer)
+    ];
+
+    // Commands that control script execution
+    luabind::module(m_LuaState)[
+        luabind::class_< ScriptManager >("Script")
+          .def("wait", (int(ScriptManager::*)(const float)) &ScriptManager::ScriptWait, luabind::yield)
+          .def("request", (void(ScriptManager::*)(const ScriptManager::Type, const char*, const char*, const int)) &ScriptManager::ScriptRequest)
+          .def("request_start_sync", (int(ScriptManager::*)(const ScriptManager::Type, const char*, const char*, const int)) &ScriptManager::ScriptRequestStartSync, luabind::yield)
+          .def("request_end_sync", (int(ScriptManager::*)(const ScriptManager::Type, const char*, const char*, const int)) &ScriptManager::ScriptRequestEndSync, luabind::yield)
+          .enum_("constants")[
+            luabind::value("SYSTEM", ScriptManager::SYSTEM),
+            luabind::value("ENTITY", ScriptManager::ENTITY),
+            luabind::value("UI", ScriptManager::UI)
+          ]
+    ];
+
+    // Commnds to initiate modules
+    luabind::module(m_LuaState)[
+        luabind::class_< QGears::WorldMapModule >("world_map_module")
+          .def("init", (void(QGears::WorldMapModule::*)()) &QGears::WorldMapModule::Init)
+    ];
+
+    std::cout << "[INIT BINDS] REGISTER " << std::endl;
+
+    // Register all command handlers
+    auto a = boost::ref(*(EntityManager::getSingletonPtr()));
+    std::cout << "[INIT BINDS] REGISTER 0" << std::endl;
+    luabind::globals(m_LuaState);
+    std::cout << "[INIT BINDS] REGISTER 0.5" << std::endl;
+    /*auto b = luabind::globals(m_LuaState)["entity_manager"];
+    if (b == NULL){
+        std::cout << "[INIT BINDS] B NULL" << std::endl;
+    }*/
+    std::cout << "[INIT BINDS] REGISTER 0.6" << std::endl;
+    luabind::globals(m_LuaState)["entity_manager"] = boost::ref(*(EntityManager::getSingletonPtr()));
+    std::cout << "[INIT BINDS] REGISTER 1" << std::endl;
+    luabind::globals(m_LuaState)["background2d"] = boost::ref(*(EntityManager::getSingletonPtr()->GetBackground2D()));
+    luabind::globals(m_LuaState)["walkmesh"] = boost::ref(*(EntityManager::getSingletonPtr()->GetWalkmesh()));
+    luabind::globals(m_LuaState)["dialog"] = boost::ref(*(DialogsManager::getSingletonPtr()));
+    luabind::globals(m_LuaState)["ui_manager"] = boost::ref(*(UiManager::getSingletonPtr()));
+    luabind::globals(m_LuaState)["world_map_module"] = boost::ref(*(QGears::WorldMapModule::getSingletonPtr()));
+    luabind::globals(m_LuaState)["timer"] = boost::ref(*(Timer::getSingletonPtr()));
+    luabind::globals(m_LuaState)["script"] = boost::ref(*this);
+
+    std::cout << "[INIT BINDS] END " << std::endl;
+
+}

+ 39 - 0
QGearsMain/include/core/ScriptManagerCommands.h

@@ -0,0 +1,39 @@
+#include "ConfigCmdManager.h"
+#include "Console.h"
+
+
+
+void
+CmdScriptRunString( const Ogre::StringVector& params )
+{
+    if( params.size() < 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /script_run_string <string>" );
+        return;
+    }
+
+    ScriptManager::getSingleton().RunString( params[ 1 ] );
+}
+
+
+
+void
+CmdScriptRunFile( const Ogre::StringVector& params )
+{
+    if( params.size() < 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /script_run_file <file name>" );
+        return;
+    }
+
+    ScriptManager::getSingleton().RunFile( params[ 1 ] );
+}
+
+
+
+void
+ScriptManager::InitCmd()
+{
+    ConfigCmdManager::getSingleton().AddCommand( "script_run_string", "Run script string", "", CmdScriptRunString, NULL );
+    ConfigCmdManager::getSingleton().AddCommand( "script_run_file", "Run script file", "", CmdScriptRunFile, NULL );
+}

+ 49 - 0
QGearsMain/include/core/TextManager.h

@@ -0,0 +1,49 @@
+#ifndef TEXT_MANAGER_H
+#define TEXT_MANAGER_H
+
+#include <OgreString.h>
+#include <OgreSingleton.h>
+
+#include <tinyxml.h>
+
+
+
+class TextManager : public Ogre::Singleton< TextManager >
+{
+public:
+    TextManager();
+    virtual ~TextManager();
+
+    void InitCmd();
+
+    void SetLanguage( const Ogre::String& language );
+    const Ogre::String& GetLanguage();
+    void AddText( const Ogre::String& name, TiXmlNode* node );
+    void AddDialog( const Ogre::String& name, TiXmlNode* node, const float width, const float height );
+    TiXmlNode* GetText( const Ogre::String& name ) const;
+    TiXmlNode* GetDialog( const Ogre::String& name, float &width, float& height ) const;
+    void UnloadTexts();
+
+private:
+    Ogre::String m_Language;
+
+    struct Text
+    {
+        Ogre::String name;
+        TiXmlNode* node;
+    };
+    std::vector< Text > m_Texts;
+
+    struct Dialog
+    {
+        Ogre::String name;
+        TiXmlNode* node;
+        float width;
+        float height;
+    };
+     std::vector< Dialog > m_Dialogs;
+};
+
+
+
+#endif // TEXT_MANAGER_H

+ 36 - 0
QGearsMain/include/core/TextManagerCommands.h

@@ -0,0 +1,36 @@
+#include "ConfigCmdManager.h"
+#include "Console.h"
+#include "Logger.h"
+#include "XmlTextsFile.h"
+
+
+
+void
+CmdSetLanguage( const Ogre::StringVector& params )
+{
+    if( params.size() < 2 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /set_language <language>" );
+        return;
+    }
+
+    TextManager::getSingleton().SetLanguage( params[ 1 ] );
+    LOG_TRIVIAL( "Set game language to \"" + params[ 1 ] + "\"." );
+}
+
+
+
+void
+CmdSetLanguageCompletition( Ogre::StringVector& complete_params )
+{
+    XmlTextsFile texts( "./data/texts.xml" );
+    texts.GetAvailableLanguages( complete_params );
+}
+
+
+
+void
+TextManager::InitCmd()
+{
+    ConfigCmdManager::getSingleton().AddCommand( "set_language", "Change language of texts and dialogs", "", CmdSetLanguage, CmdSetLanguageCompletition );
+}

+ 34 - 0
QGearsMain/include/core/Timer.h

@@ -0,0 +1,34 @@
+#ifndef TIMER_H
+#define TIMER_H
+
+#include <OgreSingleton.h>
+
+
+
+class Timer : public Ogre::Singleton< Timer >
+{
+public:
+    Timer();
+
+    float GetSystemTimeTotal();
+    float GetSystemTimeDelta();
+    float GetGameTimeTotal();
+    float GetGameTimeDelta();
+
+    void AddTime( const float time );
+
+    void SetGameTimer( const float timer );
+    int GetGameTimer() const;
+
+private:
+    float m_SystemTimeTotal;
+    float m_SystemTimeDelta;
+    float m_GameTimeTotal;
+    float m_GameTimeDelta;
+
+    float m_GameTimer;
+};
+
+
+
+#endif // TIMER_H

+ 87 - 0
QGearsMain/include/core/UiAnimation.h

@@ -0,0 +1,87 @@
+#ifndef UI_ANIMATION_H
+#define UI_ANIMATION_H
+
+#include <OgreString.h>
+#include <Ogre.h>
+#include <vector>
+
+
+
+class UiWidget;
+
+
+
+struct UiKeyFrameFloat
+{
+    float time;
+    float value;
+};
+
+
+
+struct UiKeyFrameVector2
+{
+    float time;
+    Ogre::Vector2 value;
+};
+
+
+
+class UiAnimation
+{
+public:
+    UiAnimation( const Ogre::String& name, UiWidget* widget );
+    virtual ~UiAnimation();
+
+    enum State
+    {
+        DEFAULT,
+        ONCE
+    };
+
+    void AddTime( const float time );
+
+    const Ogre::String& GetName() const;
+
+    void SetTime( const float time );
+    float GetTime() const;
+    void SetLength( const float time );
+    float GetLength() const;
+    void AddScaleKeyFrame( const UiKeyFrameVector2& key_frame );
+    void AddXKeyFrame( const UiKeyFrameVector2& key_frame );
+    void AddYKeyFrame( const UiKeyFrameVector2& key_frame );
+    void AddWidthKeyFrame( const UiKeyFrameVector2& key_frame );
+    void AddHeightKeyFrame( const UiKeyFrameVector2& key_frame );
+    void AddRotationKeyFrame( const UiKeyFrameFloat& key_frame );
+    void AddAlphaKeyFrame( const UiKeyFrameFloat& key_frame );
+    void AddScissorKeyFrame( const UiKeyFrameVector2& x1, const UiKeyFrameVector2& y1, const UiKeyFrameVector2& x2, const UiKeyFrameVector2& y2 );
+
+private:
+    UiAnimation();
+
+    float KeyFrameGetValue( std::vector< UiKeyFrameFloat >& data );
+    Ogre::Vector2 KeyFrameGetValue( std::vector< UiKeyFrameVector2 >& data );
+
+    Ogre::String m_Name;
+    UiWidget*    m_Widget;
+
+    float        m_Time;
+    float        m_Length;
+
+    std::vector< UiKeyFrameVector2 > m_Scale;
+    std::vector< UiKeyFrameVector2 > m_X;
+    std::vector< UiKeyFrameVector2 > m_Y;
+    std::vector< UiKeyFrameVector2 > m_Width;
+    std::vector< UiKeyFrameVector2 > m_Height;
+    std::vector< UiKeyFrameFloat >   m_Rotation;
+    std::vector< UiKeyFrameFloat >   m_Alpha;
+
+    std::vector< UiKeyFrameVector2 > m_ScissorXTop;
+    std::vector< UiKeyFrameVector2 > m_ScissorYLeft;
+    std::vector< UiKeyFrameVector2 > m_ScissorXBottom;
+    std::vector< UiKeyFrameVector2 > m_ScissorYRight;
+};
+
+
+
+#endif // UI_ANIMATION_H

+ 54 - 0
QGearsMain/include/core/UiFont.h

@@ -0,0 +1,54 @@
+#ifndef UI_FONT_H
+#define UI_FONT_H
+
+#include <OgreString.h>
+
+
+
+struct UiCharData
+{
+    int char_code;
+    int x;
+    int y;
+    int width;
+    int height;
+    int pre;
+    int post;
+};
+
+
+
+class UiFont
+{
+public:
+    UiFont( const Ogre::String& name, const Ogre::String& language );
+    virtual ~UiFont();
+
+    const Ogre::String& GetName() const;
+    const Ogre::String& GetLanguage() const;
+
+    void SetImage( const Ogre::String& image, const int width, const int height );
+    const Ogre::String& GetImageName() const;
+    int GetImageWidth() const;
+    int GetImageHeight() const;
+
+    void SetHeight( const int height );
+    int GetHeight() const;
+
+    void AddCharData( const UiCharData& data );
+    UiCharData GetCharData( const int char_code ) const;
+
+private:
+    Ogre::String              m_Name;
+    Ogre::String              m_Language;
+
+    Ogre::String              m_ImageName;
+    int                       m_ImageWidth;
+    int                       m_ImageHeight;
+    int                       m_Height;
+    std::vector< UiCharData > m_CharData;
+};
+
+
+
+#endif // UI_FONT_H

+ 50 - 0
QGearsMain/include/core/UiManager.h

@@ -0,0 +1,50 @@
+#ifndef UI_MANAGER_H
+#define UI_MANAGER_H
+
+#include <OgreRenderQueueListener.h>
+#include <OgreSingleton.h>
+#include <OgreUTFString.h>
+#include <tinyxml.h>
+
+#include "UiFont.h"
+#include "UiWidget.h"
+
+
+
+class UiManager : public Ogre::RenderQueueListener, public Ogre::Singleton< UiManager >
+{
+public:
+    UiManager();
+    virtual ~UiManager();
+
+    void Initialise();
+    void Update();
+    void OnResize();
+
+
+    void AddFont( UiFont* font );
+    UiFont* GetFont( const Ogre::String& name );
+
+    void AddPrototype( const Ogre::String& name, TiXmlNode* prototype );
+    TiXmlNode* GetPrototype( const Ogre::String& name ) const;
+
+    void AddWidget( UiWidget* widget );
+    UiWidget* GetWidget( const Ogre::String& name );
+    UiWidget* ScriptGetWidget( const char* name );
+
+    void renderQueueStarted( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation );
+
+private:
+    std::vector< UiFont* > m_Fonts;
+    struct UiPrototype
+    {
+        Ogre::String name;
+        TiXmlNode* node;
+    };
+    std::vector< UiPrototype > m_Prototypes;
+    std::vector< UiWidget* > m_Widgets;
+};
+
+
+
+#endif // UI_MANAGER_H

+ 45 - 0
QGearsMain/include/core/UiSprite.h

@@ -0,0 +1,45 @@
+#ifndef UI_SPRITE_H
+#define UI_SPRITE_H
+
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreRoot.h>
+
+#include "UiWidget.h"
+
+
+
+class UiSprite : public UiWidget
+{
+public:
+    UiSprite( const Ogre::String& name );
+    UiSprite( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent );
+    virtual ~UiSprite();
+
+    void Initialise();
+    virtual void Update();
+    virtual void Render();
+    virtual void UpdateTransformation();
+
+    void SetImage( const Ogre::String& image );
+    void SetVertexShader( const Ogre::String& shader );
+    void SetFragmentShader( const Ogre::String& shader );
+    void UpdateGeometry();
+
+private:
+    UiSprite();
+    void CreateVertexBuffer();
+    void DestroyVertexBuffer();
+
+private:
+    Ogre::MaterialPtr                   m_Material;
+    Ogre::SceneManager*                 m_SceneManager;
+    Ogre::RenderSystem*                 m_RenderSystem;
+
+    Ogre::RenderOperation               m_RenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_VertexBuffer;
+};
+
+
+
+#endif // UI_SPRITE_H

+ 192 - 0
QGearsMain/include/core/UiTextArea.h

@@ -0,0 +1,192 @@
+#ifndef UI_TEXT_AREA_H
+#define UI_TEXT_AREA_H
+
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreRoot.h>
+#include <Overlay/OgreUTFString.h>
+#include <tinyxml.h>
+
+#include "UiFont.h"
+#include "UiWidget.h"
+
+class UiSprite;
+
+enum TextState
+{
+    TS_SHOW_TEXT,
+    TS_SCROLL_TEXT,
+    TS_PAUSE_OK,
+    TS_PAUSE_TIME,
+    TS_DONE,
+    TS_OVERFLOW,
+    TS_NEXT_PAGE,
+};
+
+
+
+struct TextChar
+{
+    TextChar():
+        char_code( 0 ),
+        colour( Ogre::ColourValue::White ),
+        skip( false ),
+        variable( "" ),
+        variable_len( 0 ),
+        pause_ok( false ),
+        pause_time( 0.0f ),
+        next_page( false ),
+        sprite( NULL ),
+        sprite_y( 0 )
+    {
+    }
+
+    int char_code;
+    Ogre::ColourValue colour;
+    bool skip;
+    Ogre::String variable;
+    unsigned int variable_len;
+    bool pause_ok;
+    float pause_time;
+    bool next_page;
+    UiSprite* sprite;
+    float sprite_y;
+};
+
+
+
+struct TextVariable
+{
+    Ogre::String name;
+    Ogre::UTFString value;
+};
+
+
+/**
+ * An ingame textarea.
+ *
+ * It may be any window used to represent text: a diaog window, a menu panel,
+ * a choice selection...
+ */
+class UiTextArea : public UiWidget
+{
+public:
+
+    /**
+     * Creates a UiTextArea.
+     *
+     * @param name[name] Name for the textarea.
+     */
+    UiTextArea( const Ogre::String& name );
+
+    /**
+     * Creates a UiTextArea.
+     *
+     * @param name[in] Name for the textarea.
+     * @param path_name[in] Path for the widget.
+     * @param parent[in] Poinbter to the widget that will parent the UiTextArea.
+     */
+    UiTextArea( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent );
+
+    /**
+     * Destroys the UiTextArea.
+     */
+    virtual ~UiTextArea();
+
+    /**
+     * Sets default values for the UiTextArea.
+     *
+     * It's automatically called when the UiTextArea is created.
+     */
+    void Initialise();
+
+    /**
+     * Updates the UiTextArea.
+     */
+    virtual void Update();
+
+    /**
+     * Renders the UiTextArea on the screen.
+     */
+    virtual void Render();
+
+    /**
+     *
+     */
+    virtual void UpdateTransformation();
+
+    void UpdateGeometry();
+
+    void InputPressed();
+    void InputRepeated();
+
+    enum TextAlign
+    {
+        LEFT,
+        RIGHT,
+        CENTER
+    };
+    void SetTextAlign( const TextAlign align );
+    void SetPadding( const float top, const float right, const float bottom, const float left );
+    void SetText( const Ogre::UTFString& text );
+    void SetText( TiXmlNode* text );
+    void TextClear();
+    void RemoveSpritesFromText( const unsigned int end );
+    void SetFont( const Ogre::String& font );
+    const UiFont* GetFont() const;
+    void SetTextPrintSpeed( const float speed );
+    void SetTextScrollTime( const float time );
+    void SetVariable( const Ogre::String& name, const Ogre::UTFString& value );
+    Ogre::UTFString GetVariable( const Ogre::String& name ) const;
+    TextState GetTextState() const;
+    float GetTextLimit() const;
+    unsigned int GetTextSize() const;
+    float GetPauseTime() const;
+
+private:
+    float GetTextWidth() const;
+    void PrepareTextFromNode( TiXmlNode* node, const Ogre::ColourValue& colour );
+    void PrepareTextFromText( const Ogre::UTFString& text, const Ogre::ColourValue& colour );
+
+    UiTextArea();
+    void CreateVertexBuffer();
+    void DestroyVertexBuffer();
+
+private:
+    Ogre::MaterialPtr                   m_Material;
+    Ogre::SceneManager*                 m_SceneManager;
+    Ogre::RenderSystem*                 m_RenderSystem;
+
+    unsigned int                        m_MaxLetters;
+    Ogre::RenderOperation               m_RenderOp;
+    Ogre::HardwareVertexBufferSharedPtr m_VertexBuffer;
+
+    UiFont*                             m_Font;
+    TextAlign                           m_TextAlign;
+
+    std::vector< TextChar >             m_Text;
+    float                               m_TextLimit;
+    float                               m_TextPrintSpeed;
+    float                               m_TextPrintSpeedMod;
+    TextState                           m_TextState;
+    std::vector< TextVariable >         m_TextVariable;
+
+    float                               m_TextScrollTime;
+    float                               m_TextYOffset;
+    float                               m_TextYOffsetTarget;
+    float                               m_PauseTime;
+    unsigned int                        m_NextPageStart;
+
+    bool                                m_NextPressed;
+    bool                                m_NextRepeated;
+
+    float                               m_PaddingTop;
+    float                               m_PaddingRight;
+    float                               m_PaddingBottom;
+    float                               m_PaddingLeft;
+
+    bool                                m_Timer;
+    int                                 m_TimerTime;
+};
+
+#endif // UI_TEXT_AREA_H

+ 167 - 0
QGearsMain/include/core/UiWidget.h

@@ -0,0 +1,167 @@
+#ifndef UI_WIDGET_H
+#define UI_WIDGET_H
+
+#include <OgreColourValue.h>
+#include <OgreString.h>
+#include <Ogre.h>
+#include <vector>
+
+#include "ScriptManager.h"
+#include "UiAnimation.h"
+
+
+
+class UiWidget
+{
+public:
+    UiWidget( const Ogre::String& name );
+    UiWidget( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent );
+    virtual ~UiWidget();
+
+    void Initialise();
+    virtual void Update();
+    void OnResize();
+    virtual void Render();
+
+    void SetVisible( const bool visible );
+    bool IsVisible() const;
+
+    const Ogre::String& GetName() const;
+
+    void AddChild( UiWidget* widget );
+    UiWidget* GetChild( const Ogre::String& name );
+    UiWidget* GetChild( const unsigned int id );
+    unsigned int GetNumberOfChildren();
+    void RemoveAllChildren();
+
+    // animation related
+    void AddAnimation( UiAnimation* animation );
+    const Ogre::String& GetCurrentAnimationName() const;
+    UiAnimation::State GetAnimationState() const;
+    void PlayAnimation( const Ogre::String& animation, UiAnimation::State state, const float start, const float end );
+    void ScriptPlayAnimation( const char* name );
+    void ScriptPlayAnimationStop( const char* name );
+    void ScriptPlayAnimation( const char* name, const float start, const float end );
+    void ScriptPlayAnimationStop( const char* name, const float start, const float end );
+    void ScriptSetDefaultAnimation( const char* animation );
+    int ScriptAnimationSync();
+
+    void SetUpdateTransformation();
+    virtual void UpdateTransformation();
+
+    enum Align
+    {
+        LEFT,
+        RIGHT,
+        CENTER
+    };
+    enum VerticalAlign
+    {
+        TOP,
+        BOTTOM,
+        MIDDLE
+    };
+    void SetAlign( const UiWidget::Align align );
+    void SetVerticalAlign( const UiWidget::VerticalAlign valign );
+
+    float GetFinalZ() const;
+    Ogre::Vector2 GetFinalOrigin() const;
+    Ogre::Vector2 GetFinalTranslate() const;
+    Ogre::Vector2 GetFinalSize() const;
+    Ogre::Vector2 GetFinalScale() const;
+    Ogre::Vector4 GetFinalScissor( bool& scissor ) const;
+    float GetFinalRotation() const;
+
+    void SetOriginX( const float percent, const float x );
+    void SetOriginY( const float percent, const float y );
+    void SetX( const float percent, const float x );
+    void GetX( float& percent, float& x );
+    void SetY( const float percent, const float y );
+    void GetY( float& percent, float& y );
+    void SetZ( const float z );
+    void SetWidth( const float percent, const float width );
+    void GetWidth( float& percent, float& width );
+    void SetHeight( const float percent, const float height );
+    void GetHeight( float& percent, float& height );
+    void SetScale( const Ogre::Vector2& scale );
+    void SetRotation( const float degree );
+    void SetScissorArea( const float percent_x1, const float x1, const float percent_y1, const float y1, const float percent_x2, const float x2, const float percent_y2, const float y2 );
+    void SetGlobalScissor( const bool global );
+    void SetColour( const float r, const float g, const float b );
+    void 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 );
+    void SetAlpha( const float a );
+
+private:
+    UiWidget();
+
+protected:
+    Ogre::String             m_Name;
+    Ogre::String             m_PathName;
+
+    UiWidget*                m_Parent;
+    std::vector< UiWidget* > m_Children;
+
+    float                    m_ScreenWidth;
+    float                    m_ScreenHeight;
+
+    bool                     m_Visible;
+    Ogre::ColourValue        m_Colour1;
+    Ogre::ColourValue        m_Colour2;
+    Ogre::ColourValue        m_Colour3;
+    Ogre::ColourValue        m_Colour4;
+
+    Align                    m_Align;
+    VerticalAlign            m_VerticalAlign;
+
+    bool                     m_UpdateTransformation;
+
+    Ogre::Vector2            m_FinalOrigin;
+    Ogre::Vector2            m_FinalTranslate;
+    float                    m_FinalZ;
+    Ogre::Vector2            m_FinalSize;
+    Ogre::Vector2            m_FinalScale;
+    float                    m_FinalRotation;
+
+    float                    m_OriginXPercent;
+    float                    m_OriginX;
+    float                    m_OriginYPercent;
+    float                    m_OriginY;
+    float                    m_XPercent;
+    float                    m_X;
+    float                    m_YPercent;
+    float                    m_Y;
+    float                    m_Z;
+    float                    m_WidthPercent;
+    float                    m_Width;
+    float                    m_HeightPercent;
+    float                    m_Height;
+    Ogre::Vector2            m_Scale;
+    float                    m_Rotation;
+
+    bool                     m_Scissor;
+    bool                     m_LocalScissor;
+    bool                     m_GlobalScissor;
+    int                      m_ScissorTop;
+    float                    m_ScissorXPercentTop;
+    float                    m_ScissorXTop;
+    int                      m_ScissorBottom;
+    float                    m_ScissorXPercentBottom;
+    float                    m_ScissorXBottom;
+    int                      m_ScissorLeft;
+    float                    m_ScissorYPercentLeft;
+    float                    m_ScissorYLeft;
+    int                      m_ScissorRight;
+    float                    m_ScissorYPercentRight;
+    float                    m_ScissorYRight;
+
+    UiAnimation*                m_AnimationCurrent;
+    std::vector< ScriptId >     m_AnimationSync;
+    UiAnimation::State          m_AnimationState;
+    Ogre::String                m_AnimationDefault;
+    float                       m_AnimationEndTime;
+    std::vector< UiAnimation* > m_Animations;
+};
+
+
+
+#endif // UI_WIDGET_H

+ 51 - 0
QGearsMain/include/core/Utilites.h

@@ -0,0 +1,51 @@
+#ifndef UTILITES_H
+#define UTILITES_H
+
+#include <OgreColourValue.h>
+#include <OgreMatrix4.h>
+#include <OgreString.h>
+#include <OgreStringVector.h>
+#include <Ogre.h>
+#include <Overlay/OgreUTFString.h>
+#include <OIS/OIS.h>
+
+#include <tinyxml.h>
+
+bool                      GetBool( TiXmlNode* node, const Ogre::String& tag, bool def = false );
+int                       GetInt( TiXmlNode* node, const Ogre::String& tag, int def = 0 );
+float                     GetFloat( TiXmlNode* node, const Ogre::String& tag, float def = 0.0f );
+const Ogre::String        GetString( TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def = "" );
+const Ogre::UTFString     GetUTFString( TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def = "" );
+const Ogre::Vector2       GetVector2( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def = Ogre::Vector2::ZERO );
+const Ogre::Vector3       GetVector3( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def = Ogre::Vector3::ZERO );
+const Ogre::Vector4       GetVector4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def = Ogre::Vector4::ZERO );
+const Ogre::Matrix4       GetMatrix4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY );
+const Ogre::Quaternion    GetQuaternion( TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY );
+const Ogre::ColourValue   GetColourValue( TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def = Ogre::ColourValue::ZERO );
+
+void                      ParsePersent( float& value_percent, float& value, const Ogre::String& string );
+float                     ParseKeyFrameTime( const float length, const Ogre::String& string );
+
+
+
+const Ogre::String
+CreateAutoName( const Ogre::String prefix );
+
+
+
+Ogre::String
+KeyToString( OIS::KeyCode key );
+
+
+
+OIS::KeyCode
+StringToKey( const Ogre::String& str );
+
+
+
+Ogre::StringVector
+StringTokenise( const Ogre::String& str, const Ogre::String& delimiters = "\t\n ", const Ogre::String& delimiters_preserve = "", const Ogre::String& quote = "\"", const Ogre::String& esc = "\\" );
+
+
+
+#endif // UTILITES_H

+ 60 - 0
QGearsMain/include/core/Walkmesh.h

@@ -0,0 +1,60 @@
+#ifndef WALKMESH_H
+#define WALKMESH_H
+
+#include <Ogre.h>
+#include <vector>
+
+struct WalkmeshTriangle
+{
+    WalkmeshTriangle():
+        a( 0, 0, 0 ),
+        b( 0, 0, 0 ),
+        c( 0, 0, 0 ),
+        locked( false )
+    {
+        access_side[ 0 ] = -1;
+        access_side[ 1 ] = -1;
+        access_side[ 2 ] = -1;
+    }
+
+    Ogre::Vector3 a;
+    Ogre::Vector3 b;
+    Ogre::Vector3 c;
+
+    int           access_side[ 3 ];
+    bool          locked;
+};
+
+namespace QGears
+{
+    typedef Ogre::SharedPtr<class WalkmeshFile> WalkmeshFilePtr;
+}
+
+class Walkmesh
+{
+public:
+    Walkmesh();
+    virtual ~Walkmesh();
+
+    void UpdateDebug();
+    void Clear();
+
+    void AddTriangle( const WalkmeshTriangle& triangle );
+
+    int GetAccessSide( unsigned int triangle_id, unsigned char side ) const;
+    const Ogre::Vector3& GetA( unsigned int triangle_id ) const;
+    const Ogre::Vector3& GetB( unsigned int triangle_id ) const;
+    const Ogre::Vector3& GetC( unsigned int triangle_id ) const;
+    int GetNumberOfTriangles() const;
+    void LockWalkmesh( unsigned int triangle_id, bool lock );
+    bool IsLocked( unsigned int triangle_id ) const;
+
+    virtual void load( const QGears::WalkmeshFilePtr &walkmesh );
+
+private:
+    std::vector< WalkmeshTriangle > m_Triangles;
+};
+
+
+
+#endif // WALKMESH_H

+ 19 - 0
QGearsMain/include/core/XmlBackground2DFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_BACKGROUND_2D_FILE_H
+#define XML_BACKGROUND_2D_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlBackground2DFile : public XmlFile
+{
+public:
+    XmlBackground2DFile( const Ogre::String& file );
+    virtual ~XmlBackground2DFile();
+
+    void Load();
+};
+
+
+
+#endif // XML_BACKGROUND_2D_FILE_H

+ 40 - 0
QGearsMain/include/core/XmlFile.h

@@ -0,0 +1,40 @@
+#ifndef XML_FILE_H
+#define XML_FILE_H
+
+#include <OgreColourValue.h>
+#include <OgreMatrix4.h>
+#include <OgreString.h>
+#include <Ogre.h>
+#include <Overlay/OgreUTFString.h>
+
+#include <tinyxml.h>
+
+
+
+class XmlFile
+{
+public:
+    XmlFile( const Ogre::String& file );
+    virtual ~XmlFile();
+
+    bool                      GetBool( TiXmlNode* node, const Ogre::String& tag, bool def = false ) const;
+    int                       GetInt( TiXmlNode* node, const Ogre::String& tag, int def = 0 ) const;
+    float                     GetFloat( TiXmlNode* node, const Ogre::String& tag, float def = 0.0f ) const;
+    const Ogre::String        GetString( TiXmlNode* node, const Ogre::String& tag, const Ogre::String& def = "" ) const;
+    const Ogre::UTFString     GetUTFString( TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def = "" ) const;
+    const Ogre::Vector2       GetVector2( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def = Ogre::Vector2::ZERO ) const;
+    const Ogre::Vector3       GetVector3( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def = Ogre::Vector3::ZERO  ) const;
+    const Ogre::Vector4       GetVector4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def = Ogre::Vector4::ZERO  ) const;
+    const Ogre::Matrix4       GetMatrix4( TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY ) const;
+    const Ogre::Quaternion    GetQuaternion( TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY ) const;
+    const Ogre::ColourValue   GetColourValue( TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def = Ogre::ColourValue::ZERO ) const;
+
+protected:
+    bool m_NormalFile;
+
+    TiXmlDocument m_File;
+};
+
+
+
+#endif // XML_FILE_H

+ 20 - 0
QGearsMain/include/core/XmlFontFile.h

@@ -0,0 +1,20 @@
+#ifndef XML_FONT_FILE_H
+#define XML_FONT_FILE_H
+
+#include "UiWidget.h"
+#include "XmlFile.h"
+
+
+
+class XmlFontFile : public XmlFile
+{
+public:
+    explicit XmlFontFile( const Ogre::String& file );
+    virtual ~XmlFontFile();
+
+    void LoadFont();
+};
+
+
+
+#endif // XML_FONT_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlFontsFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_FONTS_FILE_H
+#define XML_FONTS_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlFontsFile : public XmlFile
+{
+public:
+    XmlFontsFile( const Ogre::String& file );
+    virtual ~XmlFontsFile();
+
+    void LoadFonts();
+};
+
+
+
+#endif // XML_FONTS_FILE_H

+ 20 - 0
QGearsMain/include/core/XmlMapFile.h

@@ -0,0 +1,20 @@
+#ifndef XML_MAP_FILE_H
+#define XML_MAP_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlMapFile : public XmlFile
+{
+public:
+    explicit XmlMapFile( const Ogre::String& file );
+    virtual ~XmlMapFile();
+
+    void LoadMap();
+    const Ogre::String GetWalkmeshFileName();
+};
+
+
+
+#endif // XML_MAP_FILE_H

+ 22 - 0
QGearsMain/include/core/XmlMapsFile.h

@@ -0,0 +1,22 @@
+#ifndef XML_MAPS_FILE_H
+#define XML_MAPS_FILE_H
+
+#include <OgreStringVector.h>
+
+#include "XmlFile.h"
+
+
+
+class XmlMapsFile : public XmlFile
+{
+public:
+    XmlMapsFile( const Ogre::String& file );
+    virtual ~XmlMapsFile();
+
+    const Ogre::String GetMapFileNameByName( const Ogre::String& name );
+    void GetMapNames( Ogre::StringVector& complete_params );
+};
+
+
+
+#endif // XML_FIELD_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlMusicsFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_MUSICS_FILE_H
+#define XML_MUSICS_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlMusicsFile : public XmlFile
+{
+public:
+    XmlMusicsFile( const Ogre::String& file );
+    virtual ~XmlMusicsFile();
+
+    void LoadMusics();
+};
+
+
+
+#endif // XML_MUSICS_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlPrototypesFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_PROTOTYPES_FILE_H
+#define XML_PROTOTYPES_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlPrototypesFile : public XmlFile
+{
+public:
+    XmlPrototypesFile( const Ogre::String& file );
+    virtual ~XmlPrototypesFile();
+
+    void LoadPrototypes();
+};
+
+
+
+#endif // XML_PROTOTYPES_FILE_H

+ 21 - 0
QGearsMain/include/core/XmlScreenFile.h

@@ -0,0 +1,21 @@
+#ifndef XML_SCREEN_FILE_H
+#define XML_SCREEN_FILE_H
+
+#include "UiWidget.h"
+#include "XmlFile.h"
+
+
+
+class XmlScreenFile : public XmlFile
+{
+public:
+    explicit XmlScreenFile( const Ogre::String& file );
+    virtual ~XmlScreenFile();
+
+    void LoadScreen();
+    void LoadScreenRecursive( TiXmlNode* node, const Ogre::String& base_name, UiWidget* widget );
+};
+
+
+
+#endif // XML_SCREEN_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlScreensFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_SCREENS_FILE_H
+#define XML_SCREENS_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlScreensFile : public XmlFile
+{
+public:
+    XmlScreensFile( const Ogre::String& file );
+    virtual ~XmlScreensFile();
+
+    void LoadScreens();
+};
+
+
+
+#endif // XML_SCREENS_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlScriptsFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_SCRIPTS_FILE_H
+#define XML_SCRIPTS_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlScriptsFile : public XmlFile
+{
+public:
+    XmlScriptsFile( const Ogre::String& file );
+    virtual ~XmlScriptsFile();
+
+    void LoadScripts();
+};
+
+
+
+#endif // XML_SCRIPTS_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlTextFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_TEXT_FILE_H
+#define XML_TEXT_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlTextFile : public XmlFile
+{
+public:
+    XmlTextFile( const Ogre::String& file );
+    virtual ~XmlTextFile();
+
+    void LoadTexts();
+};
+
+
+
+#endif // XML_TEXT_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlTextsFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_TEXTS_FILE_H
+#define XML_TEXTS_FILE_H
+
+#include "XmlFile.h"
+
+#include <OgreStringVector.h>
+
+
+class XmlTextsFile : public XmlFile
+{
+public:
+    XmlTextsFile( const Ogre::String& file );
+    virtual ~XmlTextsFile();
+
+    void GetAvailableLanguages( Ogre::StringVector& languages );
+    void LoadTexts();
+};
+
+#endif // XML_TEXTS_FILE_H

+ 19 - 0
QGearsMain/include/core/XmlWalkmeshFile.h

@@ -0,0 +1,19 @@
+#ifndef XML_WALKMESH_FILE_H
+#define XML_WALKMESH_FILE_H
+
+#include "XmlFile.h"
+
+
+
+class XmlWalkmeshFile : public XmlFile
+{
+public:
+    XmlWalkmeshFile( const Ogre::String& file );
+    virtual ~XmlWalkmeshFile();
+
+    void Load();
+};
+
+
+
+#endif // XML_WALKMESH_FILE_H

+ 60 - 0
QGearsMain/include/core/particles/Particle.h

@@ -0,0 +1,60 @@
+#ifndef PARTICLE_H
+#define PARTICLE_H
+
+#include <OgrePrerequisites.h>
+#include <Ogre.h>
+
+#include "ParticleAdditionalData.h"
+
+
+
+class ParticleEmitter;
+
+
+
+class Particle
+{
+public:
+    enum ParticleType
+    {
+        PT_VISUAL,
+        PT_EMITTER
+    };
+
+    Particle();
+    virtual ~Particle() = 0;
+
+    virtual void InitForEmission() {};
+    virtual void InitForExpiration() {};
+
+    virtual void Update(Ogre::Real time_elapsed);
+
+    virtual void CopyAttributesTo(Particle* particle);
+
+    ParticleType GetParticleType() const {return m_ParticleType;};
+
+    void SetParentEmitter(ParticleEmitter* parent_emitter) {m_ParentEmitter = parent_emitter;};
+    ParticleEmitter* GetParentEmitter() const {return m_ParentEmitter;};
+
+    void SetEnabled(bool enabled) {m_Enabled = enabled;};
+    bool IsEnabled() const {return m_Enabled;};
+
+    void SetEmittable(bool emittable) {m_Emittable = emittable;};
+    bool IsEmittable() const {return m_Emittable;};
+
+    ParticleAdditionalData* additional_data;
+    Ogre::Vector3           position;
+    Ogre::Vector3           direction;
+    float                   time_to_live;
+    float                   total_time_to_live;
+
+protected:
+    ParticleEmitter*    m_ParentEmitter;
+    ParticleType        m_ParticleType;
+    bool                m_Enabled;
+    bool                m_Emittable;
+};
+
+
+
+#endif // PARTICLE_H

+ 13 - 0
QGearsMain/include/core/particles/ParticleAdditionalData.h

@@ -0,0 +1,13 @@
+#ifndef PARTICLE_ADDITIONAL_DATA_H
+#define PARTICLE_ADDITIONAL_DATA_H
+
+
+
+struct ParticleAdditionalData
+{
+    virtual void SetVisible(bool visible) = 0;
+};
+
+
+
+#endif // PARTICLE_ADDITIONAL_DATA_H

+ 74 - 0
QGearsMain/include/core/particles/ParticleEmitter.h

@@ -0,0 +1,74 @@
+#ifndef PARTICLE_EMITTER_H
+#define PARTICLE_EMITTER_H
+
+#include <OgreStringInterface.h>
+
+#include "Particle.h"
+#include "ParticleEmitterDictionary.h"
+
+
+
+class ParticleTechnique;
+
+
+
+class ParticleEmitter : public Ogre::StringInterface, public Particle
+{
+public:
+    ParticleEmitter();
+    virtual ~ParticleEmitter();
+
+    virtual void CopyAttributesTo(ParticleEmitter* emitter);
+
+    virtual void InitForEmission();
+
+    virtual int CalculateRequestedParticles(Ogre::Real time_elapsed);
+    virtual void InitParticleForEmission(Particle* particle);
+
+    void SetParentTechnique(ParticleTechnique* tech) {m_ParentTechnique = tech;};
+    ParticleTechnique* GetParentTechnique() const {return m_ParentTechnique;};
+
+    void SetName(const Ogre::String& name) {m_Name = name;};
+    const Ogre::String& GetName() const {return m_Name;};
+
+    void SetEmitterType(const Ogre::String& emitter_type) {m_EmitterType = emitter_type;};
+    const Ogre::String& GetEmitterType() const {return m_EmitterType;};
+
+    void SetEmitsName(const Ogre::String& emitsName);
+    const Ogre::String& GetEmitsName() const {return m_EmitsName;};
+
+    void SetEmitsType(ParticleType emits_type) {m_EmitsType = emits_type;};
+    ParticleType GetEmitsType() const {return m_EmitsType;};
+
+    void SetEmissionRate(int rate) {m_EmissionRate = rate;};
+    int GetEmissionRate() const {return m_EmissionRate;};
+
+
+
+    // EMIT PARTICLE SETTINGS
+    void SetEmitDirection(const Ogre::Vector3& dir) {m_EmitDirection1 = dir; m_EmitDirection2 = dir;};
+    void SetEmitDirectionRange(const Ogre::Vector3& dir1, const Ogre::Vector3& dir2) {m_EmitDirection1 = dir1; m_EmitDirection2 = dir2;};
+    void SetEmitTotalTimeToLive(float time) {m_EmitTotalTimeToLive = time;};
+
+protected:
+    ParticleTechnique*                                  m_ParentTechnique;
+
+    Ogre::String                                        m_Name;
+    Ogre::String                                        m_EmitterType;
+
+    Ogre::String                                        m_EmitsName;
+    ParticleType                                        m_EmitsType;
+    static ParticleEmitterDictionary::EmissionRate      m_EmissionRateDictionary;
+    int                                                 m_EmissionRate;
+    Ogre::Real                                          m_EmissionRemainder;
+
+    static ParticleEmitterDictionary::Direction         m_DirectionDictionary;
+    Ogre::Vector3                                       m_EmitDirection1;
+    Ogre::Vector3                                       m_EmitDirection2;
+    static ParticleEmitterDictionary::TotalTimeToLive   m_TotalTimeToLiveDictionary;
+    float                                               m_EmitTotalTimeToLive;
+};
+
+
+
+#endif // PARTICLE_EMITTER_H

+ 34 - 0
QGearsMain/include/core/particles/ParticleEmitterDictionary.h

@@ -0,0 +1,34 @@
+#ifndef PARTICLE_EMITTER_DICTIONARY_H
+#define PARTICLE_EMITTER_DICTIONARY_H
+
+#include <OgreStringInterface.h>
+
+
+
+namespace ParticleEmitterDictionary
+{
+    class EmissionRate : public Ogre::ParamCommand
+    {
+    public:
+        Ogre::String doGet(const void* target) const {return "";};
+        void doSet(void* target, const Ogre::String& val);
+    };
+
+    class TotalTimeToLive : public Ogre::ParamCommand
+    {
+    public:
+        Ogre::String doGet(const void* target) const {return "";};
+        void doSet(void* target, const Ogre::String& val);
+    };
+
+    class Direction : public Ogre::ParamCommand
+    {
+    public:
+        Ogre::String doGet(const void* target) const {return "";};
+        void doSet(void* target, const Ogre::String& val);
+    };
+}
+
+
+
+#endif // PARTICLE_EMITTER_DICTIONARY_H

+ 38 - 0
QGearsMain/include/core/particles/ParticleEmitterFactory.h

@@ -0,0 +1,38 @@
+#ifndef PARTICLE_EMITTER_FACTORY_H
+#define PARTICLE_EMITTER_FACTORY_H
+
+#include "ParticleEmitter.h"
+
+
+
+class ParticleEmitterFactory
+{
+public:
+    ParticleEmitterFactory(){};
+    virtual ~ParticleEmitterFactory(){};
+
+    virtual Ogre::String GetEmitterType() const = 0;
+
+    virtual ParticleEmitter* CreateEmitter() = 0;
+
+    void DestroyEmitter(ParticleEmitter* emitter)
+    {
+        if (emitter != NULL)
+        {
+            delete emitter;
+        }
+    };
+
+protected:
+    template <class T>
+    ParticleEmitter* _createEmitter()
+    {
+        ParticleEmitter* particle_emitter = new T();
+        particle_emitter->SetEmitterType(GetEmitterType());
+        return particle_emitter;
+    };
+};
+
+
+
+#endif // PARTICLE_EMITTER_FACTORY_H

+ 17 - 0
QGearsMain/include/core/particles/ParticleEmitterTranslator.h

@@ -0,0 +1,17 @@
+#ifndef PARTICLE_EMITTER_TRANSLATOR_H
+#define PARTICLE_EMITTER_TRANSLATOR_H
+
+#include <OgreScriptTranslator.h>
+#include <OgreSingleton.h>
+
+
+
+class ParticleEmitterTranslator : public Ogre::ScriptTranslator
+{
+public:
+    void translate(Ogre::ScriptCompiler *compiler, const Ogre::AbstractNodePtr &node);
+};
+
+
+
+#endif // PARTICLE_EMITTER_TRANSLATOR_H

+ 140 - 0
QGearsMain/include/core/particles/ParticlePool.h

@@ -0,0 +1,140 @@
+#ifndef PARTICLE_POOL_H
+#define PARTICLE_POOL_H
+
+#include <list>
+
+
+
+template <typename T>
+class ParticlePool
+{
+public:
+    typedef std::list<T*> PoolList;
+    typedef typename PoolList::iterator PoolIterator; // The 'typename' MUST be added, since T is not a fixed type
+
+    ParticlePool() {};
+    virtual ~ParticlePool() {};
+
+    bool
+    IsEmpty()
+    {
+        return m_Released.empty();
+    };
+
+    size_t
+    GetSize()
+    {
+        return m_Released.size();
+    };
+
+    void
+    ResetIterator()
+    {
+        m_PoolIterator = m_Released.begin();
+    };
+
+    T*
+    GetFirst()
+    {
+        ResetIterator();
+        if (End())
+        {
+            return NULL;
+        }
+
+        T* t = *m_PoolIterator;
+        return t;
+    };
+
+    T*
+    GetNext()
+    {
+        if (End())
+        {
+            return NULL;
+        }
+
+        ++m_PoolIterator;
+        if (End())
+        {
+            return NULL;
+        }
+
+        T* t = *m_PoolIterator;
+        return t;
+    };
+
+    bool
+    End()
+    {
+        return m_PoolIterator == m_Released.end();
+    };
+
+    void
+    Clear()
+    {
+        m_Locked.clear();
+        m_Released.clear();
+    };
+
+    void
+    AddElement(T* element)
+    {
+        m_Locked.push_back(element);
+    };
+
+    T*
+    ReleaseElement()
+    {
+        // Return with 0 if no elements left
+        if (m_Locked.empty())
+        {
+            return 0;
+        }
+
+        // Move element from locked elements to released elements and return it
+        T* t = m_Locked.front();
+        m_Released.splice(m_Released.end(), m_Locked, m_Locked.begin());
+        return t;
+    };
+
+    void
+    ReleaseAllElements()
+    {
+        // Move all elements from locked elements to released elements
+        m_Released.splice(m_Released.end(), m_Locked);
+        ResetIterator();
+    };
+
+    void
+    LockLatestElement()
+    {
+        if (End() == false)
+        {
+            m_Locked.push_back(*m_PoolIterator);
+            m_PoolIterator = m_Released.erase(m_PoolIterator);
+        }
+    };
+
+    void LockAllElements()
+    {
+        // Move all elements from released elements to locked elements
+        m_Locked.splice(m_Locked.end(), m_Released);
+        ResetIterator();
+    };
+
+    std::list<T*>&
+    GetActiveElementsList()
+    {
+        return m_Released;
+    };
+
+protected:
+    PoolList        m_Released; // List with precreated 'released' elements
+    PoolList        m_Locked; // List with precreated 'locked' elements
+    PoolIterator    m_PoolIterator;
+};
+
+
+
+#endif // PARTICLE_POOL_H

+ 150 - 0
QGearsMain/include/core/particles/ParticlePoolMap.h

@@ -0,0 +1,150 @@
+#ifndef PARTICLE_POOL_MAP_H
+#define PARTICLE_POOL_MAP_H
+
+
+
+template <typename T>
+class ParticlePoolMap
+{
+public:
+    typedef std::multimap<Ogre::String, T*> PoolMapMap;
+    typedef typename PoolMapMap::iterator PoolMapIterator; // The 'typename' MUST be added, since T is not a fixed type
+
+    ParticlePoolMap () {};
+    virtual ~ParticlePoolMap() {};
+
+    bool
+    IsEmpty()
+    {
+        return m_Released.empty();
+    };
+
+    size_t
+    GetSize()
+    {
+        return m_Released.size();
+    };
+
+    void
+    ResetIterator()
+    {
+        m_PoolMapIterator = m_Released.begin();
+    };
+
+    T*
+    GetFirst()
+    {
+        ResetIterator();
+        if (End())
+        {
+            return NULL;
+        }
+
+        T* t = m_PoolMapIterator->second;
+        return t;
+    };
+
+    T*
+    GetNext()
+    {
+        if (End())
+        {
+            return NULL;
+        }
+
+        ++m_PoolMapIterator;
+        if (End())
+        {
+            return NULL;
+        }
+
+        T* t = m_PoolMapIterator->second;
+        return t;
+    };
+
+    bool
+    End()
+    {
+        return m_PoolMapIterator == m_Released.end();
+    };
+
+    void
+    Clear()
+    {
+        m_Locked.clear();
+        m_Released.clear();
+    };
+
+    void
+    AddElement(const Ogre::String& key, T* element)
+    {
+        m_Locked.insert(make_pair(key, element));
+    };
+
+    T*
+    ReleaseElement(const Ogre::String& key)
+    {
+        // Return with 0 if no elements left
+        if (m_Locked.empty())
+        {
+            return NULL;
+        }
+
+        // Return the first element that is encountered
+        T* t = 0;
+        PoolMapIterator it;
+        it = m_Locked.find(key);
+        if (it != m_Locked.end())
+        {
+            // Get the element and move it to the released elements list
+            t = it->second;
+            m_Released.insert(make_pair(key, t));
+            m_Locked.erase(it);
+        }
+
+        return t;
+    };
+
+    void
+    ReleaseAllElements()
+    {
+        // Move all elements from locked elements to released elements
+        PoolMapIterator it;
+        for (it = m_Locked.begin(); it != m_Locked.end(); ++it)
+        {
+            m_Released.insert(make_pair(it->first, it->second));
+        }
+        m_Locked.clear();
+        ResetIterator();
+    };
+
+    void
+    LockLatestElement()
+    {
+        // Move element pointed by iterator from released elements to locked elements
+        m_Locked.insert(make_pair(m_PoolMapIterator->first, m_PoolMapIterator->second));
+        m_Released.erase(m_PoolMapIterator++); // Watch the ++ at the end to set mPoolMapIterator to the next element
+    };
+
+    void
+    LockAllElements()
+    {
+        // Move all elements from release elements to locked elements
+        PoolMapIterator it;
+        for (it = m_Released.begin(); it != m_Released.end(); ++it)
+        {
+            m_Locked.insert(make_pair(it->first, it->second));
+        }
+        m_Released.clear();
+        ResetIterator();
+    };
+
+protected:
+    PoolMapMap m_Released;
+    PoolMapMap m_Locked;
+    PoolMapIterator m_PoolMapIterator;
+};
+
+
+
+#endif // PARTICLE_POOL_MAP_H

+ 43 - 0
QGearsMain/include/core/particles/ParticleRenderer.h

@@ -0,0 +1,43 @@
+#ifndef PARTICLE_RENDERER_H
+#define PARTICLE_RENDERER_H
+
+#include <OgreString.h>
+#include <OgreStringInterface.h>
+
+#include "ParticlePool.h"
+
+class ParticleTechnique;
+class VisualParticle;
+
+
+
+class ParticleRenderer : public Ogre::StringInterface
+{
+public:
+    ParticleRenderer();
+    virtual ~ParticleRenderer();
+
+    virtual void CopyAttributesTo(ParticleRenderer* renderer);
+
+    void SetRendererInitialised(bool renderer_initialised);
+    bool IsRendererInitialised() const;
+
+    void SetRendererType(Ogre::String renderer_type);
+    const Ogre::String& GetRendererType() const;
+
+    void SetParentTechnique(ParticleTechnique* parent_technique);
+    const ParticleTechnique* GetParentTechnique() const;
+
+    virtual void SetVisible(bool visible = true) = 0;
+    virtual void Initialize() = 0;
+    virtual void UpdateRenderQueue(Ogre::RenderQueue* queue, ParticlePool<VisualParticle>& pool) = 0;
+
+protected:
+    bool                m_RendererInitialised;
+    Ogre::String        m_RendererType;
+    ParticleTechnique*  m_ParentTechnique;
+};
+
+
+
+#endif // PARTICLE_RENDERER_H

+ 38 - 0
QGearsMain/include/core/particles/ParticleRendererFactory.h

@@ -0,0 +1,38 @@
+#ifndef PARTICLE_RENDERER_FACTORY_H
+#define PARTICLE_RENDERER_FACTORY_H
+
+#include "ParticleRenderer.h"
+
+
+
+class ParticleRendererFactory
+{
+public:
+    ParticleRendererFactory(){};
+    virtual ~ParticleRendererFactory(){};
+
+    virtual Ogre::String GetRendererType() const = 0;
+
+    virtual ParticleRenderer* CreateRenderer() = 0;
+
+    void DestroyRenderer (ParticleRenderer* renderer)
+    {
+        if (renderer != NULL)
+        {
+            delete renderer;
+        }
+    };
+
+protected:
+    template <class T>
+    ParticleRenderer* _createRenderer()
+    {
+        ParticleRenderer* particle_renderer = new T();
+        particle_renderer->SetRendererType(GetRendererType());
+        return particle_renderer;
+    };
+};
+
+
+
+#endif // PARTICLE_RENDERER_FACTORY_H

+ 17 - 0
QGearsMain/include/core/particles/ParticleRendererTranslator.h

@@ -0,0 +1,17 @@
+#ifndef PARTICLE_RENDERER_TRANSLATOR_H
+#define PARTICLE_RENDERER_TRANSLATOR_H
+
+#include <OgreScriptTranslator.h>
+#include <OgreSingleton.h>
+
+
+
+class ParticleRendererTranslator : public Ogre::ScriptTranslator
+{
+public:
+    void translate(Ogre::ScriptCompiler *compiler, const Ogre::AbstractNodePtr &node);
+};
+
+
+
+#endif // PARTICLE_RENDERER_TRANSLATOR_H

+ 37 - 0
QGearsMain/include/core/particles/ParticleSystem.h

@@ -0,0 +1,37 @@
+#ifndef PARTICLE_SYSTEM_H
+#define PARTICLE_SYSTEM_H
+
+#include <OgreMovableObject.h>
+
+#include "ParticleTechnique.h"
+
+
+
+class ParticleSystem : public Ogre::MovableObject
+{
+public:
+    ParticleSystem(const Ogre::String& name);
+    virtual ~ParticleSystem();
+    void CopyAttributesTo(ParticleSystem* ps);
+
+    // realization of Ogre::MovableObject
+    const Ogre::String& getMovableType() const;
+    const Ogre::AxisAlignedBox& getBoundingBox() const;
+    Ogre::Real getBoundingRadius() const;
+    void _updateRenderQueue(Ogre::RenderQueue* queue);
+    void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false) {};
+
+    void Update(Ogre::Real time_elapsed);
+
+    // technique
+    ParticleTechnique* CreateTechnique();
+    void AddTechnique(ParticleTechnique* technique);
+    void DestroyAllTechniques();
+
+private:
+    std::vector<ParticleTechnique*> m_Techniques;
+};
+
+
+
+#endif // PARTICLE_SYSTEM_H

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