Browse Source

Re-created repository with all dependencies removed, all history collapsed and all data removed. This will become subrepos. The history compression also removes senstive data and reduces the size by 99% due to many binaries being checked in previously. Reference.lgp had to be removed due to its size (46MB), along with reference.map (3MB)

Paul 11 years ago
commit
15cbbcc3c6
100 changed files with 6737 additions and 0 deletions
  1. 15 0
      .hgignore
  2. 32 0
      .travis.yml
  3. 88 0
      CMake/FindOggVorbis.cmake
  4. 88 0
      CMake/FindOpenAL.cmake
  5. 163 0
      CMakeLists.txt
  6. 339 0
      COPYING.txt
  7. 3 0
      PlugIns/CMakeLists.txt
  8. 100 0
      PlugIns/Data/CMakeLists.txt
  9. 174 0
      PlugIns/Data/DataPlugin.cbp
  10. 72 0
      PlugIns/Data/include/QGearsDataPlugin.h
  11. 4 0
      PlugIns/Data/misc/QGearsData.def
  12. 83 0
      PlugIns/Data/src/QGearsDataPlugin.cpp
  13. 53 0
      PlugIns/Data/src/QGearsDataPluginDll.cpp
  14. 168 0
      PlugIns/Data/test/tex_file_info.cpp
  15. 170 0
      PlugIns/Data/test/tex_file_test.cpp
  16. 360 0
      QGearsMain/CMakeLists.txt
  17. 120 0
      QGearsMain/Makefile
  18. 17 0
      QGearsMain/include/QGearsGameState.h
  19. 44 0
      QGearsMain/include/QGearsPrerequisites.h
  20. 38 0
      QGearsMain/include/common/File.h
  21. 17 0
      QGearsMain/include/common/FileSystem.h
  22. 30 0
      QGearsMain/include/common/LzsFile.h
  23. 78 0
      QGearsMain/include/common/QGearsApplication.h
  24. 105 0
      QGearsMain/include/common/QGearsManualObject.h
  25. 61 0
      QGearsMain/include/common/QGearsResource.h
  26. 42 0
      QGearsMain/include/common/QGearsStringUtil.h
  27. 71 0
      QGearsMain/include/common/TypeDefine.h
  28. 17 0
      QGearsMain/include/common/make_unique.h
  29. 12 0
      QGearsMain/include/core/Assert.h
  30. 99 0
      QGearsMain/include/core/AudioManager.h
  31. 152 0
      QGearsMain/include/core/Background2D.h
  32. 62 0
      QGearsMain/include/core/Background2DAnimation.h
  33. 56 0
      QGearsMain/include/core/CameraManager.h
  34. 36 0
      QGearsMain/include/core/CameraManagerCommands.h
  35. 45 0
      QGearsMain/include/core/ConfigCmd.h
  36. 38 0
      QGearsMain/include/core/ConfigCmdManager.h
  37. 439 0
      QGearsMain/include/core/ConfigCmdManagerCommands.h
  38. 16 0
      QGearsMain/include/core/ConfigFile.h
  39. 54 0
      QGearsMain/include/core/ConfigVar.h
  40. 26 0
      QGearsMain/include/core/ConfigVarManager.h
  41. 75 0
      QGearsMain/include/core/Console.h
  42. 98 0
      QGearsMain/include/core/DebugDraw.h
  43. 282 0
      QGearsMain/include/core/Entity.h
  44. 21 0
      QGearsMain/include/core/EntityCollision.h
  45. 21 0
      QGearsMain/include/core/EntityDirection.h
  46. 89 0
      QGearsMain/include/core/EntityManager.h
  47. 35 0
      QGearsMain/include/core/EntityModel.h
  48. 34 0
      QGearsMain/include/core/EntityPoint.h
  49. 44 0
      QGearsMain/include/core/EntityTrigger.h
  50. 54 0
      QGearsMain/include/core/Event.h
  51. 42 0
      QGearsMain/include/core/GameFrameListner.h
  52. 66 0
      QGearsMain/include/core/InputManager.h
  53. 51 0
      QGearsMain/include/core/InputManagerCommands.h
  54. 22 0
      QGearsMain/include/core/Logger.h
  55. 37 0
      QGearsMain/include/core/Module.h
  56. 133 0
      QGearsMain/include/core/ScriptManager.h
  57. 218 0
      QGearsMain/include/core/ScriptManagerBinds.h
  58. 39 0
      QGearsMain/include/core/ScriptManagerCommands.h
  59. 29 0
      QGearsMain/include/core/Timer.h
  60. 74 0
      QGearsMain/include/core/UiAnimation.h
  61. 52 0
      QGearsMain/include/core/UiFont.h
  62. 60 0
      QGearsMain/include/core/UiManager.h
  63. 45 0
      QGearsMain/include/core/UiSprite.h
  64. 81 0
      QGearsMain/include/core/UiTextArea.h
  65. 153 0
      QGearsMain/include/core/UiWidget.h
  66. 30 0
      QGearsMain/include/core/Utilites.h
  67. 60 0
      QGearsMain/include/core/Walkmesh.h
  68. 19 0
      QGearsMain/include/core/XmlBackground2DFile.h
  69. 42 0
      QGearsMain/include/core/XmlFile.h
  70. 20 0
      QGearsMain/include/core/XmlFontFile.h
  71. 19 0
      QGearsMain/include/core/XmlFontsFile.h
  72. 20 0
      QGearsMain/include/core/XmlMapFile.h
  73. 22 0
      QGearsMain/include/core/XmlMapsFile.h
  74. 19 0
      QGearsMain/include/core/XmlMusicsFile.h
  75. 19 0
      QGearsMain/include/core/XmlPrototypesFile.h
  76. 22 0
      QGearsMain/include/core/XmlScreenFile.h
  77. 19 0
      QGearsMain/include/core/XmlScreensFile.h
  78. 19 0
      QGearsMain/include/core/XmlScriptsFile.h
  79. 19 0
      QGearsMain/include/core/XmlTextFile.h
  80. 19 0
      QGearsMain/include/core/XmlTextsFile.h
  81. 19 0
      QGearsMain/include/core/XmlWalkmeshFile.h
  82. 60 0
      QGearsMain/include/core/particles/Particle.h
  83. 13 0
      QGearsMain/include/core/particles/ParticleAdditionalData.h
  84. 74 0
      QGearsMain/include/core/particles/ParticleEmitter.h
  85. 34 0
      QGearsMain/include/core/particles/ParticleEmitterDictionary.h
  86. 38 0
      QGearsMain/include/core/particles/ParticleEmitterFactory.h
  87. 17 0
      QGearsMain/include/core/particles/ParticleEmitterTranslator.h
  88. 140 0
      QGearsMain/include/core/particles/ParticlePool.h
  89. 150 0
      QGearsMain/include/core/particles/ParticlePoolMap.h
  90. 43 0
      QGearsMain/include/core/particles/ParticleRenderer.h
  91. 38 0
      QGearsMain/include/core/particles/ParticleRendererFactory.h
  92. 17 0
      QGearsMain/include/core/particles/ParticleRendererTranslator.h
  93. 37 0
      QGearsMain/include/core/particles/ParticleSystem.h
  94. 26 0
      QGearsMain/include/core/particles/ParticleSystemFactory.h
  95. 72 0
      QGearsMain/include/core/particles/ParticleSystemManager.h
  96. 17 0
      QGearsMain/include/core/particles/ParticleSystemTranslator.h
  97. 31 0
      QGearsMain/include/core/particles/ParticleSystemTranslatorManager.h
  98. 65 0
      QGearsMain/include/core/particles/ParticleTechnique.h
  99. 17 0
      QGearsMain/include/core/particles/ParticleTechniqueTranslator.h
  100. 19 0
      QGearsMain/include/core/particles/ParticleVisual.h

+ 15 - 0
.hgignore

@@ -0,0 +1,15 @@
+syntax: glob
+src/compile/
+*.log
+src/compile_d/
+**/bin/**
+**/obj/**
+**.cbTemp
+**/ogre.cfg
+**.depend
+**.layout
+output/**
+**/output/**
+**/compile/**
+build
+*.user*

+ 32 - 0
.travis.yml

@@ -0,0 +1,32 @@
+language: cpp
+
+before_install:
+  - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
+  - sudo add-apt-repository ppa:boost-latest/ppa -y
+  - sudo apt-get update
+  - sudo apt-get install boost1.55
+  - sudo apt-get install gcc-4.9
+  - sudo apt-get install g++-4.9
+  - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
+  - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
+  - sudo update-alternatives --config gcc
+  - sudo update-alternatives --config g++
+  - 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
+  - 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
+compiler:
+  - gcc
+
+before_script:
+  - mkdir build_qgears
+  - cd build_qgears
+  - cmake ..
+
+script: make -j2

+ 88 - 0
CMake/FindOggVorbis.cmake

@@ -0,0 +1,88 @@
+# - Try to find the OggVorbis libraries
+# Once done this will define
+#
+#  OGGVORBIS_FOUND - system has OggVorbis
+#  OGGVORBIS_VERSION - set either to 1 or 2
+#  OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
+#  OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
+#  OGG_LIBRARY         - The Ogg library
+#  VORBIS_LIBRARY      - The Vorbis library
+#  VORBISFILE_LIBRARY  - The VorbisFile library
+#  VORBISENC_LIBRARY   - The VorbisEnc library
+
+# Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+include (CheckLibraryExists)
+
+find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
+find_path(OGG_INCLUDE_DIR ogg/ogg.h)
+
+find_library(OGG_LIBRARY NAMES ogg)
+find_library(VORBIS_LIBRARY NAMES vorbis)
+find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
+find_library(VORBISENC_LIBRARY NAMES vorbisenc)
+
+mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR
+                 OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
+
+
+if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
+   set(OGGVORBIS_FOUND TRUE)
+
+   set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
+
+   set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
+   set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
+   check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
+   set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
+
+   if (HAVE_LIBVORBISENC2)
+      set (OGGVORBIS_VERSION 2)
+   else (HAVE_LIBVORBISENC2)
+      set (OGGVORBIS_VERSION 1)
+   endif (HAVE_LIBVORBISENC2)
+
+else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
+   set (OGGVORBIS_VERSION)
+   set(OGGVORBIS_FOUND FALSE)
+endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
+
+
+if (OGGVORBIS_FOUND)
+   if (NOT OggVorbis_FIND_QUIETLY)
+      message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
+   endif (NOT OggVorbis_FIND_QUIETLY)
+else (OGGVORBIS_FOUND)
+   if (OggVorbis_FIND_REQUIRED)
+      message(FATAL_ERROR "Could NOT find OggVorbis libraries")
+   endif (OggVorbis_FIND_REQUIRED)
+   if (NOT OggVorbis_FIND_QUITELY)
+      message(STATUS "Could NOT find OggVorbis libraries")
+   endif (NOT OggVorbis_FIND_QUITELY)
+endif (OGGVORBIS_FOUND)
+
+#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
+#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
+#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
+#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
+#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
+#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
+
+#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
+#    message(STATUS "Ogg/Vorbis found")
+#    set (VORBIS_LIBS "-lvorbis -logg")
+#    set (VORBISFILE_LIBS "-lvorbisfile")
+#    set (VORBISENC_LIBS "-lvorbisenc")
+#    set (OGGVORBIS_FOUND TRUE)
+#    if (HAVE_LIBVORBISENC2)
+#        set (HAVE_VORBIS 2)
+#    else (HAVE_LIBVORBISENC2)
+#        set (HAVE_VORBIS 1)
+#    endif (HAVE_LIBVORBISENC2)
+#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
+#    message(STATUS "Ogg/Vorbis not found")
+#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)

+ 88 - 0
CMake/FindOpenAL.cmake

@@ -0,0 +1,88 @@
+# - Locate OpenAL
+# This module defines
+#  OPENAL_LIBRARY
+#  OPENAL_FOUND, if false, do not try to link to OpenAL
+#  OPENAL_INCLUDE_DIR, where to find the headers
+#
+# $OPENALDIR is an environment variable that would
+# correspond to the ./configure --prefix=$OPENALDIR
+# used in building OpenAL.
+#
+
+# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# OPENAL_LIBRARY to override this selection.
+# Tiger will include OpenAL as part of the System.
+# But for now, we have to look around.
+# Other (Unix) systems should be able to utilize the non-framework paths.
+FIND_PATH(OPENAL_INCLUDE_DIR AL/al.h
+  $ENV{OPENALDIR}/include
+  ~/Library/Frameworks/OpenAL.framework/Headers
+  /Library/Frameworks/OpenAL.framework/Headers
+  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
+  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
+  /usr/local/include/
+  /usr/local/include/OpenAL
+  /usr/local/include
+  /usr/include/
+  /usr/include/OpenAL
+  /usr/include
+  /sw/include # Fink
+  /sw/include/OpenAL
+  /sw/include
+  /opt/local/include # DarwinPorts
+  /opt/local/include/OpenAL
+  /opt/local/include
+  /opt/csw/include # Blastwave
+  /opt/csw/include/OpenAL
+  /opt/csw/include
+  /opt/include
+  /opt/include/OpenAL
+  /opt/include
+  ../libs/openal-0.0.8/common/include
+  )
+# I'm not sure if I should do a special casing for Apple. It is
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?),
+# do they want the -framework option also?
+IF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" OPENAL_FRAMEWORK_PATH_TMP ${OPENAL_INCLUDE_DIR})
+  IF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(OPENAL_LIBRARY "-F${OPENAL_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+    OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(OPENAL_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
+
+ELSE(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(OPENAL_LIBRARY
+    NAMES openal al OpenAL32
+    PATHS
+    $ENV{OPENALDIR}/lib
+    $ENV{OPENALDIR}/libs
+    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    ../libs/openal-0.0.8/src/.libs
+    )
+ENDIF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+
+SET(OPENAL_FOUND "NO")
+IF(OPENAL_LIBRARY)
+  SET(OPENAL_FOUND "YES")
+	MESSAGE(STATUS "OpenAL was found. ${OPENAL_LIBRARY}")
+ENDIF(OPENAL_LIBRARY)

+ 163 - 0
CMakeLists.txt

@@ -0,0 +1,163 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(QGears)
+
+# The version number.
+set(QGears_VERSION_MAJOR 0)
+set(QGears_VERSION_MINOR 22)
+
+option(QGears_BUILD_PLUGINS     "Build the plugins"     TRUE)
+option(QGears_BUILD_UTILITIES   "Build the utilities"   TRUE)
+option(QGears_BUILD_TESTS       "Build the unit tests"  TRUE)
+option(QGears_MULTITHREADING    "Enable multithreading" FALSE)
+option(QGears_SOUND             "Enable Sound"          FALSE)
+
+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"
+)
+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(CMAKE_MODULE_PATH "${OGRE_CMAKE_MODULE_PATH};${CMAKE_MODULE_PATH}")
+set(CMAKE_MODULE_PATH 
+  "${CMAKE_MODULE_PATH}"
+  "${QGears_SOURCE_DIR}/CMake" 
+)
+
+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)
+endif ()
+
+set(CMAKE_DEBUG_POSTFIX "_d")
+
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+  set(CMAKE_INSTALL_PREFIX
+    "${QGears_SOURCE_DIR}/output" CACHE PATH "Q-Gears install prefix" FORCE
+  )
+endif()
+
+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 OR APPLE)
+                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.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})
+        add_definitions(-DBOOST_ALL_NO_LIB)
+        set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
+
+        find_package(Boost COMPONENTS program_options filesystem QUIET)
+        set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES})
+        set(QGears_LIBRARIES ${OGRE_LIBRARIES})
+        if(QGears_SOUND)
+            find_package(OpenAL REQUIRED)
+            find_package(OggVorbis REQUIRED)
+            add_definitions(-DQGears_SOUND)
+            set(QGears_LIBRARIES
+                ${QGears_LIBRARIES}
+                ${OPENAL_LIBRARY}
+                ${OGGVORBIS_LIBRARIES}
+            )
+        endif()
+
+        if(QGears_MULTITHREADING)
+            # Find Threads
+            find_package (Threads REQUIRED)
+            set(QGears_LIBRARIES
+                ${QGears_LIBRARIES}
+                ${CMAKE_THREAD_LIBS_INIT}
+            )
+        endif()
+
+        if(QGears_BUILD_TESTS)
+            find_package(Boost COMPONENTS unit_test_framework QUIET)
+            set(QGears_TEST_LIBRARIES
+                ${OGRE_LIBRARIES}
+                ${Boost_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(QGears_INCLUDE_DIRS
+    ${OIS_INCLUDE_DIRS}
+    ${OGRE_INCLUDE_DIRS}
+    ${OGRE_Overlay_INCLUDE_DIRS}
+    ${OGRE_SAMPLES_INCLUDEPATH}
+    ${CMAKE_CURRENT_SOURCE_DIR}/dependencies
+)
+
+# Enable C++11, you may need to use -std=c++0x if using an older compiler
+if (MSVC)
+else()
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
+endif()
+
+add_definitions(-DTIXML_USE_STL)
+add_subdirectory(dependencies)
+add_subdirectory(QGearsMain)
+add_subdirectory(SupportedGames)
+
+if(QGears_BUILD_PLUGINS)
+    add_subdirectory(PlugIns)
+endif()
+
+if(QGears_BUILD_UTILITIES)
+    add_subdirectory(utilities)
+endif()
+
+if(QGears_BUILD_TESTS)
+    add_subdirectory(Tests)
+endif()

+ 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)

+ 100 - 0
PlugIns/Data/CMakeLists.txt

@@ -0,0 +1,100 @@
+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
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsAFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsAFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsBackgroundFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsBackgroundFileManager.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsBackgroundFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsHRCFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsHRCFileManager.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsHRCFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsHRCMeshLoader.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsHRCSkeletonLoader.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsLZSDataStream.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPFileManager.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPaletteFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPaletteFileManager.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsPaletteFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsRSDFile.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsRSDFileManager.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsRSDFileSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsSerializer.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsTexCodec.h
+  ${QGearsMain_SOURCE_DIR}/include/data/QGearsTexFile.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
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsAFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsAFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsBackgroundFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsBackgroundFileManager.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsBackgroundFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsHRCFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsHRCFileManager.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsHRCFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsHRCMeshLoader.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsHRCSkeletonLoader.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsLZSDataStream.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPFileManager.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPaletteFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPaletteFileManager.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsPaletteFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsRSDFile.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsRSDFileManager.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsRSDFileSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsSerializer.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsTexCodec.cpp
+  ${QGearsMain_SOURCE_DIR}/src/data/QGearsTexFile.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
+)
+
+#defines
+#add_definitions(-DBOOST_ALL_DYN_LINK)
+
+add_library(DataPlugin MODULE
+  ${HEADER_FILES}
+  ${SOURCE_FILES}
+)
+
+set_target_properties(DataPlugin PROPERTIES
+  PREFIX ${PLUGIN_PREFIX}
+  OUTPUT_NAME Data
+)
+
+set(LIBRARIES
+  ${OGRE_LIBRARIES} FinalFantasy7
+
+)
+
+target_link_libraries(DataPlugin ${LIBRARIES})
+
+if(NOT QGEARS_STATIC)
+  set_target_properties(DataPlugin PROPERTIES
+    COMPILE_DEFINITIONS QGEARS_DATAPLUGIN_EXPORTS
+  )
+  install(TARGETS DataPlugin
+    LIBRARY DESTINATION /usr/lib/q-gears/plugins/
+  )
+endif()

+ 174 - 0
PlugIns/Data/DataPlugin.cbp

@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="DataPlugin" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="Debug">
+				<Option output="../../output/Plugin_Data_d" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Debug/" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-g" />
+				</Compiler>
+				<Linker>
+					<Add library="OgreMain_d" />
+					<Add library="boost_system-mt-d" />
+				</Linker>
+			</Target>
+			<Target title="Release">
+				<Option output="../../output/Plugin_Data" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release/" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-O2" />
+				</Compiler>
+				<Linker>
+					<Add option="-s" />
+					<Add library="OgreMain" />
+					<Add library="boost_system-mt" />
+				</Linker>
+			</Target>
+			<Target title="Test">
+				<Option output="bin/test/test_tex_file" prefix_auto="1" extension_auto="1" />
+				<Option working_dir="$(TARGET_OUTPUT_DIR)" />
+				<Option object_output="obj/Test/" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-g" />
+				</Compiler>
+				<Linker>
+					<Add library="OgreMain_d" />
+					<Add library="boost_system-mt-d" />
+					<Add library="boost_unit_test_framework-mt-d" />
+				</Linker>
+			</Target>
+			<Target title="TexInfo">
+				<Option output="../../output/tool/tex_info" prefix_auto="1" extension_auto="1" />
+				<Option working_dir="$(TARGET_OUTPUT_DIR)" />
+				<Option object_output="obj/TexInfo/" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Linker>
+					<Add library="OgreMain" />
+					<Add library="boost_system-mt" />
+					<Add library="boost_program_options-mt" />
+					<Add library="boost_filesystem-mt" />
+				</Linker>
+			</Target>
+		</Build>
+		<VirtualTargets>
+			<Add alias="all" targets="Debug;Release;" />
+		</VirtualTargets>
+		<Compiler>
+			<Add option="-Wall" />
+			<Add option="-fexceptions" />
+			<Add option="-DBOOST_ALL_DYN_LINK" />
+			<Add directory="$(BOOST_INCLUDE_DIR)" />
+			<Add directory="$(OGRE_HOME)/include/OGRE" />
+			<Add directory="$(OGRE_HOME)/include/OIS" />
+			<Add directory="../../utilities" />
+			<Add directory="../../QGearsMain/include" />
+			<Add directory="include" />
+		</Compiler>
+		<Linker>
+			<Add directory="$(BOOST_LIB_DIR)" />
+			<Add directory="$(OGRE_HOME)/lib" />
+			<Add directory="$(OGRE_HOME)/lib/opt" />
+			<Add directory="$(OGRE_HOME)/lib/release" />
+			<Add directory="$(OGRE_HOME)/lib/release/opt" />
+			<Add directory="$(OGRE_HOME)/lib/debug" />
+			<Add directory="$(OGRE_HOME)/lib/debug/opt" />
+		</Linker>
+		<Unit filename="../../QGearsMain/include/QGearsPrerequisites.h" />
+		<Unit filename="../../QGearsMain/include/common/QGearsManualObject.h" />
+		<Unit filename="../../QGearsMain/include/common/QGearsStringUtil.h" />
+		<Unit filename="../../QGearsMain/include/common/TypeDefine.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsAFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsAFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsBackgroundFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsBackgroundFileManager.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsBackgroundFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsHRCFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsHRCFileManager.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsHRCFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsHRCMeshLoader.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsHRCSkeletonLoader.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsLZSDataStream.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPFileManager.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPaletteFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPaletteFileManager.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsPaletteFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsRSDFile.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsRSDFileManager.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsRSDFileSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsSerializer.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsTexCodec.h" />
+		<Unit filename="../../QGearsMain/include/data/QGearsTexFile.h" />
+		<Unit filename="../../QGearsMain/src/common/QGearsManualObject.cpp" />
+		<Unit filename="../../QGearsMain/src/common/QGearsStringUtil.cpp" />
+		<Unit filename="../../QGearsMain/src/common/TypeDefine.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsAFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsAFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsBackgroundFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsBackgroundFileManager.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsBackgroundFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsHRCFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsHRCFileManager.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsHRCFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsHRCMeshLoader.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsHRCSkeletonLoader.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsLZSDataStream.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPFileManager.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPaletteFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPaletteFileManager.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsPaletteFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsRSDFile.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsRSDFileManager.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsRSDFileSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsSerializer.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsTexCodec.cpp" />
+		<Unit filename="../../QGearsMain/src/data/QGearsTexFile.cpp" />
+		<Unit filename="include/QGearsDataPlugin.h">
+			<Option target="Debug" />
+			<Option target="Release" />
+		</Unit>
+		<Unit filename="src/QGearsDataPlugin.cpp">
+			<Option target="Debug" />
+			<Option target="Release" />
+		</Unit>
+		<Unit filename="src/QGearsDataPluginDll.cpp">
+			<Option target="Debug" />
+			<Option target="Release" />
+		</Unit>
+		<Unit filename="test/tex_file_info.cpp">
+			<Option target="TexInfo" />
+		</Unit>
+		<Unit filename="test/tex_file_test.cpp">
+			<Option target="Test" />
+		</Unit>
+		<Extensions>
+			<code_completion />
+			<envvars />
+			<debugger />
+			<DoxyBlocks>
+				<comment_style block="0" line="0" />
+				<doxyfile_project />
+				<doxyfile_build />
+				<doxyfile_warnings />
+				<doxyfile_output />
+				<doxyfile_dot />
+				<general />
+			</DoxyBlocks>
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>

+ 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 );
+}

+ 360 - 0
QGearsMain/CMakeLists.txt

@@ -0,0 +1,360 @@
+# define header and source files for the library
+set(HEADER_FILES
+  include/modules/worldmap/WorldMapModule.h
+  include/common/QGearsApplication.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/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/QGearsXMLSerializer.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/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/viewer/ViewerModule.h
+)
+set(SOURCE_FILES
+  src/modules/worldmap/WorldMapModule.cpp
+  src/common/QGearsApplication.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/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/QGearsXMLSerializer.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
+)
+if(QGears_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()
+
+include_directories(
+    ${QGears_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/include
+
+    # TODO: remove dependency on ff7 related code
+    ${QGears_SOURCE_DIR}/SupportedGames/FinalFantasy7/include
+    ${CMAKE_CURRENT_SOURCE_DIR}/SupportedGames/FinalFantasy7/include
+
+)
+
+#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}
+)
+
+add_executable(q-gears
+  src/Main.cpp
+)
+
+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()
+
+set(LIBRARIES
+    ${QGears_LIBRARIES}
+    LuaBind
+    TinyXml
+    FinalFantasy7
+)
+if(QGears_SOUND)
+    find_package(OpenAL REQUIRED)
+    find_package(OggVorbis REQUIRED)
+endif()
+
+
+target_link_libraries(QGearsMain ${LIBRARIES} )
+
+set(LIBRARIES
+    QGearsMain
+	${Boost_LIBRARIES}
+)
+target_link_libraries(q-gears ${LIBRARIES})
+
+install(TARGETS q-gears
+    DESTINATION ./
+)

+ 120 - 0
QGearsMain/Makefile

@@ -0,0 +1,120 @@
+####################################################################
+#                                                                  #
+#		Q-Gears		                                                 #
+#                                                                  #
+#		Depends 	: OGRE, OIS, openal, vorbisfile                     #
+#		Internal : lua, luabind, tinyxml										 #
+#                                                                  #
+#		make DEBUG=1 - Debug                                         #
+#		make			 - Release													 #
+#                 		                                           #
+####################################################################
+
+# Useful stuff, for eg. cross-compiling
+INCLUDE_DIR  := /usr/include
+OGRE_INCLUDE := ${INCLUDE_DIR}/OGRE
+OIS_INCLUDE  := ${INCLUDE_DIR}/OIS
+CFLAGS		 := `pkg-config OGRE OIS openal vorbisfile --cflags`
+CXXFLAGS		 := `pkg-config OGRE OIS openal vorbisfile --cflags`
+LIBS			 := `pkg-config OGRE OIS openal vorbisfile --libs`
+DEBUG			 := 0
+
+# ---- Q-GEARS Specific ----
+CORE_DIR 	 := core
+VIEWER_DIR   := viewer
+QGEARS_BIN	 := QGears
+BUILD_DIR	 := ../output
+
+# ATM there is no intelligent render system selection,
+# so put your rendersystem path here and it gets copied to build dir
+# with name "RenderSystem_GL.so" or "RenderSystem_GL_d.so" in debug mode
+OGRE_RENDERER			:= /usr/lib/OGRE/RenderSystem_GL.so
+
+# ---- Libs that come with Q-Gears ---
+INTERNAL_LIB_DIR 		:= ${CORE_DIR}/library
+LUA_DIR 					:= ${INTERNAL_LIB_DIR}/lua
+LUABIND_DIR 			:= ${INTERNAL_LIB_DIR}/luabind
+TINYXML_DIR 			:= ${INTERNAL_LIB_DIR}/tinyxml
+
+# If you set these to 0, we will try to use system libs instead
+BUILD_INTERNAL_LUA		:= 1
+BUILD_INTERNAL_LUABIND 	:= 1
+BUILD_INTERNAL_TINYXML	:= 1
+
+# Define libs for these if you don't want to build them
+# Default values are just a guess, there is no quarntee all of them come with pkg-configs
+LUA_LIB 		= `pkg-config lua --libs`
+LUABIND_LIB = `pkg-config luabind --libs`
+TINYXML_LIB	= `pkg-config tinyxml --libs`
+
+# ---- A.I ----
+# Intenal libs should be build before anything else.
+ifeq (${BUILD_INTERNAL_LUA},1)
+	SOURCE += $(patsubst %.c,%,$(wildcard ${LUA_DIR}/*.c))
+else
+	LIBS 	 	+= ${LUA_LIB}
+	INCLUDES	+= -I${LUA_DIR}
+endif
+
+ifeq (${BUILD_INTERNAL_LUABIND},1)
+	SOURCE += $(patsubst %.cpp,%,$(wildcard ${LUABIND_DIR}/*.cpp))
+else
+	LIBS   	+= ${LUABIND_LIB}
+	INCLUDES += -I${LUABIND_DIR}
+endif
+
+ifeq (${BUILD_INTERNAL_TINYXML},1)
+	SOURCE += $(patsubst %.cpp,%,$(wildcard ${TINYXML_DIR}/*.cpp))
+else
+	LIBS   	+= ${TINYXML_LIB}
+	INCLUDES += -I${TINYXML_DIR}
+endif
+
+ifeq (${DEBUG},1)
+	DEFINES += -D_DEBUG
+	CFLAGS   = -g -O0
+	CXXFLAGS = -g -O0
+endif
+
+# ---- Build defines ----
+SOURCE	  += 	Main.cpp																			\
+					$(patsubst %.cpp,%,$(wildcard core/*.cpp))    						\
+            	$(patsubst %.cpp,%,$(wildcard core/particles/*.cpp)) 				\
+					$(patsubst %.cpp,%,$(wildcard core/particles/emitters/*.cpp)) 	\
+					$(patsubst %.cpp,%,$(wildcard core/particles/renderer/*.cpp))
+DEFINES	  += -DTIXML_USE_STL
+INCLUDES	  += -I. -I${VIEWER_DIR} -I${CORE_DIR} -I${INCLUDE_DIR} -I${OGRE_INCLUDE} -I${OIS_INCLUDE} -I${INTERNAL_LIB_DIR}
+TARGET		= ${BUILD_DIR}/${QGEARS_BIN}
+OBJ			= $(addsuffix .o, $(basename $(SOURCE)))
+
+all: ${TARGET}
+	@true
+
+# Ugly CPP
+%.o : %.cpp
+	${CXX} ${CXXFLAGS} ${DEFINES} ${INCLUDES} -c $^ -o $@
+
+# Good old C
+%.o : %.c
+	${CC} ${CFLAGS} ${DEFINES} ${INCLUDES} -c $^ -o $@
+
+# Link, create build dir if does not exist
+${TARGET}: ${OBJ}
+	mkdir -p "${BUILD_DIR}"
+	${CXX} $^ ${LIBS} -o "${TARGET}"
+
+ifeq (${DEBUG},1)
+		cp "${OGRE_RENDERER}" "${BUILD_DIR}/RenderSystem_GL_d.so"
+else
+		cp "${OGRE_RENDERER}" "${BUILD_DIR}/RenderSystem_GL.so"
+endif
+
+# Note: Don't clean ${BUILD_DIR} it's generally non good idea for deveploment
+clean:
+	${RM}  ${OBJ}
+	${RM}  "${TARGET}"
+
+# TO-DO
+# Note: Use ${PREFIX} for install location
+install:
+	echo "Not yet implented"

+ 17 - 0
QGearsMain/include/QGearsGameState.h

@@ -0,0 +1,17 @@
+#ifndef __QGearsGameState_H__
+#define __QGearsGameState_H__
+
+#define QG_VERSION_NAME "Q-Gears v0.21 (3rd alpha Run Wild)"
+
+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

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

@@ -0,0 +1,78 @@
+/*
+-----------------------------------------------------------------------------
+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 <Overlay/OgreOverlaySystem.h>
+
+#include "TypeDefine.h"
+
+namespace QGears
+{
+    class Application : public Ogre::Singleton<Application>
+    {
+    public:
+        Application( int argc, char *argv[] );
+        virtual ~Application();
+        bool                initOgre( void );
+        Ogre::Root*         getRoot( void );
+        Ogre::RenderWindow* getRenderWindow( void );
+        const String&       getResourcesFilename( void );
+    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;
+
+        Application();
+
+        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;
+    };
+}
+
+#endif // __QGearsApplication_H__

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

@@ -0,0 +1,105 @@
+/*
+-----------------------------------------------------------------------------
+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 <OgreVector2.h>
+#include <OgreVector3.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__

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

@@ -0,0 +1,61 @@
+/*
+-----------------------------------------------------------------------------
+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:
+        Ogre::DataStreamPtr openResource()
+        {
+            return Ogre::ResourceGroupManager::getSingleton().openResource(mName, mGroup, true, this);
+        }
+
+    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_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

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

@@ -0,0 +1,152 @@
+#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 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;
+
+    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 <OgreVector2.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 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

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

@@ -0,0 +1,75 @@
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include <OgreColourValue.h>
+#include <OgreLog.h>
+#include <OgreSingleton.h>
+#include <OgreStringVector.h>
+#include <OIS.h>
+#include <list>
+#include <vector>
+
+#include "Event.h"
+
+
+
+class Console : public Ogre::Singleton< Console >, public Ogre::LogListener
+{
+public:
+    Console();
+    ~Console();
+
+    void Input( const 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:
+    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_HistoryLine;
+    unsigned int                  m_HistorySize;
+
+    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 <Overlay/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

+ 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

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

@@ -0,0 +1,89 @@
+#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 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 );
+
+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 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;
+
+    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;
+};
+
+
+
+#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

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

@@ -0,0 +1,54 @@
+#ifndef EVENT_H
+#define EVENT_H
+
+// add this include because this is only common file between everything that uses Input fucntion
+#include <OIS.h>
+
+
+
+enum EventType
+{
+    ET_NULL = 0,
+    ET_KEY_PRESS,
+    ET_KEY_REPEAT,
+    ET_KEY_IMPULSE,
+    ET_KEY_RELEASE,
+    ET_MOUSE_PRESS,
+    ET_MOUSE_RELEASE,
+    ET_MOUSE_MOVE,
+    ET_MOUSE_SCROLL
+};
+
+
+
+struct Event
+{
+    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;
+};
+
+
+
+#endif // EVENT_H

+ 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.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

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

@@ -0,0 +1,66 @@
+#ifndef INPUT_FILTER_H
+#define INPUT_FILTER_H
+
+#include <OgreSingleton.h>
+#include <OgreString.h>
+#include <OIS.h>
+#include <vector>
+
+#include "Event.h"
+
+
+
+typedef std::vector< Event > InputEventArray;
+typedef std::vector< int > ButtonList;
+
+
+
+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( const Ogre::String& cmd, const ButtonList& buttons );
+    void                ActivateBinds( int button );
+
+private:
+    struct BindInfo
+    {
+        BindInfo( const Ogre::String& _cmd, const ButtonList& _key_set ):
+            cmd( _cmd ),
+            key_set( _key_set )
+        {}
+
+        ButtonList      key_set;
+        Ogre::String    cmd;
+    };
+
+    bool                    m_ButtonState[ 256 ];
+    char                    m_ButtonText[ 256 ];
+
+    bool                    m_RepeatFirstWait;
+    float                   m_RepeatTimer;
+
+    InputEventArray         m_EventQueue;
+
+    // binds
+    std::vector< BindInfo > m_Binds;
+};
+
+
+
+#endif // INPUT_FILTER_H

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

@@ -0,0 +1,51 @@
+#include <OgreStringConverter.h>
+
+#include "Console.h"
+#include "ConfigCmdManager.h"
+#include "ConfigVarManager.h"
+#include "Logger.h"
+#include "Utilites.h"
+
+
+
+void
+CmdBind( const Ogre::StringVector& params )
+{
+    if( params.size() < 3 || params.size() > 4 )
+    {
+        Console::getSingleton().AddTextToOutput( "Usage: /bind <key1>+[key2]+[key3] \"<command line>\"" );
+        return;
+    }
+
+    Ogre::StringVector keys = Ogre::StringUtil::split( params[ 1 ], "+" );
+    ButtonList key_codes;
+
+    for( size_t i = 0; i < keys.size(); ++i )
+    {
+        key_codes.push_back( StringToKey( keys[ i ] ) );
+    }
+
+    bool fail = false;
+    for( size_t i = 0; i < key_codes.size(); ++i )
+    {
+        if( key_codes[ i ] == OIS::KC_UNASSIGNED )
+        {
+            LOG_ERROR( "Failed to bind \"" + params[ 1 ] + "\" to command \"" + params[ 2 ] + "\". Can't recognize key " + Ogre::StringConverter::toString( i ) );
+            fail = true;
+        }
+    }
+
+    if( fail == false )
+    {
+        InputManager::getSingleton().BindCommand( params[ 2 ], key_codes );
+        LOG_TRIVIAL( "Bind \"" + params[ 1 ] + "\" to command \"" + params[ 2 ] + "\"." );
+    }
+}
+
+
+
+void
+InputManager::InitCmd()
+{
+    ConfigCmdManager::getSingleton().AddCommand( "bind", "Bind command to keys", "", CmdBind, NULL );
+}

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

@@ -0,0 +1,22 @@
+#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 )
+
+#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.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

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

@@ -0,0 +1,133 @@
+#ifndef SCRIPT_MANAGER_H
+#define SCRIPT_MANAGER_H
+
+#include <OgreSingleton.h>
+#include <OgreString.h>
+
+#include "Event.h"
+extern "C"
+{
+    #include <lua/lua.h>
+}
+#include <luabind/luabind.hpp>
+
+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
+    };
+
+    ScriptManager();
+    virtual ~ScriptManager();
+
+    void Input( const 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

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

@@ -0,0 +1,218 @@
+#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 "modules/worldmap/WorldMapModule.h"
+
+void
+ScriptPrint( const char* text )
+{
+    Console::getSingleton().AddTextToOutput( text );
+}
+
+
+
+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();
+}
+
+
+
+void
+ScriptConsole( const char* text )
+{
+    Console::getSingleton().ExecuteCommand( text );
+}
+
+
+
+void
+ScriptManager::InitBinds()
+{
+    // globals
+    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 )
+    ];
+
+    // entity access
+    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 )
+            .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 )
+            ]
+    ];
+
+    // game access
+    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 )
+    ];
+
+    // game access
+    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 )
+    ];
+
+    // 2d background access
+    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 )
+            ]
+    ];
+
+    // ui widget access
+    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_z", ( void( UiWidget::* )( const float ) ) &UiWidget::SetZ )
+    ];
+
+    // ui access
+    luabind::module( m_LuaState )
+    [
+        luabind::class_< UiManager >( "UiManager" )
+            .def( "get_widget", ( UiWidget*( UiManager::* )( const char* ) ) &UiManager::ScriptGetWidget )
+    ];
+
+    // timer access
+    luabind::module( m_LuaState )
+    [
+        luabind::class_< Timer >( "Timer" )
+            .def( "get_game_time_total", ( float( Timer::* )() ) &Timer::GetGameTimeTotal )
+    ];
+
+    // script access
+    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 )
+            ]
+    ];
+
+    luabind::module( m_LuaState )
+    [
+        luabind::class_< QGears::WorldMapModule >( "world_map_module" )
+            .def( "init", ( void( QGears::WorldMapModule::* )() ) &QGears::WorldMapModule::Init )
+    ];
+
+    luabind::globals( m_LuaState )[ "entity_manager" ] = boost::ref( *( EntityManager::getSingletonPtr() ) );
+    luabind::globals( m_LuaState )[ "background2d" ] = boost::ref( *( EntityManager::getSingletonPtr()->GetBackground2D() ) );
+    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 );
+
+
+
+}

+ 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 );
+}

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

@@ -0,0 +1,29 @@
+#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( float time );
+
+private:
+    float m_SystemTimeTotal;
+    float m_SystemTimeDelta;
+    float m_GameTimeTotal;
+    float m_GameTimeDelta;
+};
+
+
+
+#endif // TIMER_H

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

@@ -0,0 +1,74 @@
+#ifndef UI_ANIMATION_H
+#define UI_ANIMATION_H
+
+#include <OgreString.h>
+#include <OgreVector2.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 AddRotationKeyFrame( const UiKeyFrameFloat& key_frame );
+    void AddAlphaKeyFrame( const UiKeyFrameFloat& key_frame );
+
+private:
+    UiAnimation();
+
+    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< UiKeyFrameFloat >   m_Rotation;
+    std::vector< UiKeyFrameFloat >   m_Alpha;
+};
+
+
+
+#endif // UI_ANIMATION_H

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

@@ -0,0 +1,52 @@
+#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 );
+    virtual ~UiFont();
+
+    const Ogre::String& GetName() 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_ImageName;
+    int                       m_ImageWidth;
+    int                       m_ImageHeight;
+    int                       m_Height;
+    std::vector< UiCharData > m_CharData;
+};
+
+
+
+#endif // UI_FONT_H

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

@@ -0,0 +1,60 @@
+#ifndef UI_MANAGER_H
+#define UI_MANAGER_H
+
+#include <OgreRenderQueueListener.h>
+#include <OgreSingleton.h>
+#include <OgreUTFString.h>
+#include <tinyxml/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 SetLanguage( const Ogre::String& language );
+    void AddText( const Ogre::String& name, TiXmlNode* text );
+    void UnloadTexts();
+    TiXmlNode* GetText( const Ogre::String& name ) const;
+
+    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:
+    struct UiText
+    {
+        Ogre::String name;
+        TiXmlNode* node;
+    };
+    std::vector< UiText > m_Texts;
+    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

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

@@ -0,0 +1,81 @@
+#ifndef UI_TEXT_AREA_H
+#define UI_TEXT_AREA_H
+
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreRoot.h>
+#include <OgreUTFString.h>
+#include <tinyxml/tinyxml.h>
+
+#include "UiFont.h"
+#include "UiWidget.h"
+
+
+
+struct TextStyle
+{
+    Ogre::ColourValue colour;
+};
+
+
+
+struct TextBlockData
+{
+    float local_x1;
+    float local_y1;
+    int position;
+};
+
+
+
+class UiTextArea : public UiWidget
+{
+public:
+    UiTextArea( const Ogre::String& name );
+    UiTextArea( const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent );
+    virtual ~UiTextArea();
+
+    void Initialise();
+    virtual void Update();
+    virtual void Render();
+    virtual void UpdateTransformation();
+
+    enum TextAlign
+    {
+        LEFT,
+        RIGHT,
+        CENTER
+    };
+    void SetTextAlign( const TextAlign align );
+    void SetText( const Ogre::UTFString& text );
+    void SetText( TiXmlNode* text );
+    void SetFont( const Ogre::String& font );
+    void UpdateGeometry();
+    float GetTextLengthFromNode( TiXmlNode* node ) const;
+    float GetTextLength( const Ogre::UTFString& text ) const;
+    void SetTextGeometryFromNode( TiXmlNode* node, TextBlockData& data, const TextStyle& style );
+    void SetTextGeometry( const Ogre::UTFString& text, TextBlockData& data, const TextStyle& style );
+
+private:
+    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;
+    Ogre::UTFString                     m_Text;
+    TiXmlNode*                          m_TextNode;
+};
+
+
+
+#endif // UI_TEXT_AREA_H

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

@@ -0,0 +1,153 @@
+#ifndef UI_WIDGET_H
+#define UI_WIDGET_H
+
+#include <OgreColourValue.h>
+#include <OgreString.h>
+#include <OgreVector2.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 );
+    void RemoveAllChildren();
+
+    // animation related
+    void AddAnimation( UiAnimation* animation );
+    const Ogre::String& GetCurrentAnimationName() 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();
+
+    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;
+    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 SetY( const float percent, const float y );
+    void SetZ( const float z );
+    void SetWidth( const float percent, const float width );
+    void SetHeight( const float percent, const float height );
+    void SetScale( const Ogre::Vector2& scale );
+    void SetRotation( const float degree );
+
+    void SetScissor( bool scissor );
+    int GetScissorTop() const;
+    int GetScissorBottom() const;
+    int GetScissorLeft() const;
+    int GetScissorRight() const;
+
+    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;
+    int                      m_ScissorTop;
+    int                      m_ScissorBottom;
+    int                      m_ScissorLeft;
+    int                      m_ScissorRight;
+
+    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

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

@@ -0,0 +1,30 @@
+#ifndef UTILITES_H
+#define UTILITES_H
+
+#include <OgreString.h>
+#include <OgreStringVector.h>
+#include <OIS.h>
+
+
+
+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 <OgreVector3.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

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

@@ -0,0 +1,42 @@
+#ifndef XML_FILE_H
+#define XML_FILE_H
+
+#include <OgreColourValue.h>
+#include <OgreMatrix4.h>
+#include <OgreString.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector4.h>
+#include <OgreUTFString.h>
+
+#include <tinyxml/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

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

@@ -0,0 +1,22 @@
+#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 );
+    void ParsePersent( float& value_percent, float& value, const Ogre::String& string );
+};
+
+
+
+#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 LoadText();
+};
+
+
+
+#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"
+
+
+
+class XmlTextsFile : public XmlFile
+{
+public:
+    XmlTextsFile( const Ogre::String& file );
+    virtual ~XmlTextsFile();
+
+    void LoadTexts( const Ogre::String& language );
+};
+
+
+
+#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 <OgreVector3.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

+ 26 - 0
QGearsMain/include/core/particles/ParticleSystemFactory.h

@@ -0,0 +1,26 @@
+#ifndef PARTICLE_SYSTEM_FACTORY_H
+#define PARTICLE_SYSTEM_FACTORY_H
+
+#include <OgreMovableObject.h>
+
+
+
+class ParticleSystemFactory : public Ogre::MovableObjectFactory
+{
+public:
+    ParticleSystemFactory() {};
+    ~ParticleSystemFactory() {};
+
+    static Ogre::String FACTORY_TYPE_NAME;
+
+    const Ogre::String& getType() const;
+
+    void destroyInstance(Ogre::MovableObject* obj);
+
+private:
+    Ogre::MovableObject* createInstanceImpl(const Ogre::String& name, const Ogre::NameValuePairList* params);
+};
+
+
+
+#endif // PARTICLE_SYSTEM_FACTORY_H

+ 72 - 0
QGearsMain/include/core/particles/ParticleSystemManager.h

@@ -0,0 +1,72 @@
+#ifndef PARTICLE_SYSTEM_MANAGER_H
+#define PARTICLE_SYSTEM_MANAGER_H
+
+#include <OgreSingleton.h>
+
+#include "ParticleEmitter.h"
+#include "ParticleEmitterFactory.h"
+#include "ParticleRendererFactory.h"
+#include "ParticleSystem.h"
+#include "ParticleSystemFactory.h"
+#include "ParticleTechnique.h"
+#include "ParticleSystemTranslatorManager.h"
+
+
+
+class ParticleSystemManager: public Ogre::Singleton<ParticleSystemManager>
+{
+public:
+    ParticleSystemManager();
+    ~ParticleSystemManager();
+
+    // ParticleSystemTemplate
+    ParticleSystem* CreateParticleSystemTemplate(const Ogre::String& name);
+    ParticleSystem* GetParticleSystemTemplate(const Ogre::String& templateName);
+    void ParticleSystemTemplateNames(std::vector<Ogre::String>& v);
+
+    // ParticleSystem
+    ParticleSystem* CreateParticleSystem(const Ogre::String& name, const Ogre::String& template_name);
+    void DestroyParticleSystem(ParticleSystem* particle_system);
+
+    // ParticleTechnique.
+    ParticleTechnique* CreateTechnique();
+    ParticleTechnique* CloneTechnique(ParticleTechnique* technique);
+    void DestroyTechnique(ParticleTechnique* technique);
+
+    // ParticleEmitter
+    ParticleEmitter* CreateEmitter(const Ogre::String& emitter_type);
+    ParticleEmitter* CloneEmitter(ParticleEmitter* emitter);
+    void DestroyEmitter(ParticleEmitter* emitter);
+
+    // ParticleRenderer
+    ParticleRenderer* CreateRenderer(const Ogre::String& renderer_type);
+    ParticleRenderer* CloneRenderer(ParticleRenderer* renderer);
+    void DestroyRenderer(ParticleRenderer* renderer);
+
+private:
+    // factories
+    void AddEmitterFactory(ParticleEmitterFactory* factory);
+    void AddRendererFactory(ParticleRendererFactory* factory);
+
+
+private:
+    ParticleSystemFactory*           m_ParticleSystemFactory;
+
+    ParticleSystemTranslatorManager* m_TranslatorManager;
+
+    // ParticleSystemTemplate
+    typedef std::map<Ogre::String, ParticleSystem*> ParticleSystemTemplateMap;
+    ParticleSystemTemplateMap m_ParticleSystemTemplates;
+
+    // Emitter Factories
+    typedef std::map<Ogre::String, ParticleEmitterFactory*> EmitterFactoryMap;
+    EmitterFactoryMap m_EmitterFactories;
+
+    // Renderer Factories
+    typedef std::map<Ogre::String, ParticleRendererFactory*> RendererFactoryMap;
+    RendererFactoryMap m_RendererFactories;
+};
+
+
+
+#endif // PARTICLE_SYSTEM_MANAGER_H

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

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

+ 31 - 0
QGearsMain/include/core/particles/ParticleSystemTranslatorManager.h

@@ -0,0 +1,31 @@
+#ifndef PARTICLE_SYSTEM_TRANSLATOR_MANAGER_H
+#define PARTICLE_SYSTEM_TRANSLATOR_MANAGER_H
+
+#include <OgreScriptTranslator.h>
+#include <OgreSingleton.h>
+
+#include "ParticleEmitterTranslator.h"
+#include "ParticleRendererTranslator.h"
+#include "ParticleSystemTranslator.h"
+#include "ParticleTechniqueTranslator.h"
+
+
+
+class ParticleSystemTranslatorManager : public Ogre::ScriptTranslatorManager
+{
+public:
+    size_t getNumTranslators() const;
+
+    Ogre::ScriptTranslator *getTranslator(const Ogre::AbstractNodePtr &node);
+
+private:
+    ParticleEmitterTranslator   m_EmitterTranslator;
+    ParticleRendererTranslator  m_RendererTranslator;
+    ParticleSystemTranslator    m_ParticleSystemTranslator;
+    ParticleTechniqueTranslator m_TechniqueTranslator;
+};
+
+
+
+
+#endif // PARTICLE_SYSTEM_TRANSLATOR_MANAGER_H

+ 65 - 0
QGearsMain/include/core/particles/ParticleTechnique.h

@@ -0,0 +1,65 @@
+#ifndef PARTICLE_TECHNIQUE_H
+#define PARTICLE_TECHNIQUE_H
+
+#include "ParticleEmitter.h"
+#include "ParticleRenderer.h"
+#include "ParticlePool.h"
+#include "ParticlePoolMap.h"
+
+
+
+class ParticleSystem;
+
+
+
+class ParticleTechnique
+{
+public:
+    ParticleTechnique();
+    virtual ~ParticleTechnique();
+
+    void CopyAttributesTo(ParticleTechnique* technique);
+
+    void SetParentSystem(ParticleSystem* parentSystem) {m_ParentSystem = parentSystem;};
+    ParticleSystem* GetParentSystem() const {return m_ParentSystem;};
+
+    // this fucntion called from ParticleSystem which implements _updateRenderQueue from movable objects
+    void UpdateRenderQueue(Ogre::RenderQueue* queue);
+
+    void Initialize();
+    void Update(Ogre::Real time_elapsed);
+
+    ParticleRenderer* CreateRenderer(const Ogre::String& renderer_type);
+    void SetRenderer(ParticleRenderer* renderer);
+    void DestroyRenderer();
+
+    ParticleEmitter* CreateEmitter(const Ogre::String& emitter_type);
+    void AddEmitter(ParticleEmitter* emitter);
+    void DestroyAllEmitters();
+    int GetNumEmittableEmitters() const;
+
+    void EmissionChange();
+
+    int GetVisualParticlesQuota() const {return m_VisualParticleQuota;};
+    void ExecuteEmitParticles(ParticleEmitter* emitter, int requested, Ogre::Real time_elapsed);
+    void ResetVisualParticles();
+
+private:
+    ParticleSystem*                     m_ParentSystem;
+
+    ParticleRenderer*                   m_Renderer;
+
+    int                                 m_VisualParticleQuota;
+    bool                                m_VisualParticlePoolIncreased;
+    ParticlePool<VisualParticle>        m_VisualParticlesPool;
+    std::vector<VisualParticle*>        m_VisualParticles;
+
+    int                                 m_EmittedEmitterQuota;
+    bool                                m_ParticleEmitterPoolIncreased;
+    ParticlePoolMap<ParticleEmitter>    m_ParticleEmitterPool;
+    std::vector<ParticleEmitter*>       m_Emitters;
+};
+
+
+
+#endif // PARTICLE_TECHNIQUE_H

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

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

+ 19 - 0
QGearsMain/include/core/particles/ParticleVisual.h

@@ -0,0 +1,19 @@
+#ifndef VISUAL_PARTICLE_H
+#define VISUAL_PARTICLE_H
+
+#include "Particle.h"
+
+
+
+class VisualParticle : public Particle
+{
+public:
+    VisualParticle();
+    virtual ~VisualParticle() {};
+
+    virtual void InitForExpiration();
+};
+
+
+
+#endif // VISUAL_PARTICLE_H

Some files were not shown because too many files changed in this diff