Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7421


Ignore:
Timestamp:
Sep 12, 2010, 12:47:30 AM (14 years ago)
Author:
rgrieder
Message:

Basic stuff up and running for the Qt sandbox.
No GUI support yet.

Location:
sandbox_qt
Files:
2 deleted
37 edited
4 copied

Legend:

Unmodified
Added
Removed
  • sandbox_qt/CMakeLists.txt

    r7383 r7421  
    5252SET(DEFAULT_LIBRARY_PATH lib)
    5353SET(DEFAULT_ARCHIVE_PATH lib/static)
    54 SET(DEFAULT_MODULE_PATH  lib/modules)
    5554SET(DEFAULT_DOC_PATH     doc)
    5655SET(DEFAULT_DATA_PATH    data)
     
    6261SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
    6362SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
    64 SET(CMAKE_MODULE_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH})
    6563SET(CMAKE_DOC_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH})
    6664# Data directories are only inputs, no delclaration here
    6765SET(CMAKE_CONFIG_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
    6866SET(CMAKE_LOG_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH})
    69 
    70 # Set the extension of the dynamic modules
    71 SET(ORXONOX_MODULE_EXTENSION ".module")
    7267
    7368# Sets where to find the external libraries like OgreMain.dll at runtime
  • sandbox_qt/INSTALL

    r7248 r7421  
    66************** Libraries ****************
    77
    8 In order to compile Orxonox you will need the following libraries:
    9 (for windows there are already precompiled packages on the website)
    10 
    11 OGRE 3D Graphics Engine          1.4 - 1.7
    12 CEGUI (Crazy Eddie's GUI System) 0.5 - 0.6
    13 Boost libraries                  1.35 -
    14 ENet (Network library)           1.1 - 1.2
    15 Lua (scripting language)         5.0 - 5.1
    16 Tcl (shell script language)      8.4 - 8.5
    17 OpenAL (audio)                   (no version requirements specified yet)
    18 ALUT (audio)                     (no version requirements specified yet)
    19 LibOgg                           (no version requirements specified yet)
    20 LibVorbis                        (no version requirements specified yet)
    21 ZLib (compression)               (no version requirements specified yet)
    22 
    23 OGRE supports both OpenGL and DirectX9 rendering. You will also need OGRE for the dedicated server!
    24 
    25 Further information about installing and running this application can be found on
    26 http://www.orxonox.net/wiki/Running
     8In order to compile this Orxonox sandbox you will need to install Qt 4.6
  • sandbox_qt/README

    r7163 r7421  
    1 Hi there,
     1This is a fork of the Orxonox trunk used to quickly set up some arbitrary test program.
    22
    3 We are proud to present you Orxonox - the most ferious 3D space shooter ever to exist.
    4 
    5 This game is free, if you have paid for this, get your money back! The source code of this game is licensed under the GPL (GNU General Public License).
    6 The game content is licensed under the Creative Commons Attribution-Sharealike 3.0 license. For more information read LICENSE in the same folder you found this file.
    7 
    8 For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running
    9 
    10 This application uses the Ogre Graphics Engine (http://www.ogre3d.org), if you haven't already downloaded a precompiled version of Ogre with this package. Visit our webpage to get your Orxonox compatible version of the Ogre libraries.
    11 
    12 This is an open source game. If you want to contribute check out http://www.orxonox.net/wiki/development to find more information how you could help us making the game better. We are always looking for programmers and content designers, who like to contribute.
    13 
    14 We hope you have fun playing the game. Check out http://www.orxonox.net for news and newer versions of the game.
    15 
    16 Please contact us in our forum ( http://forum.orxonox.net ) or check out our contact page ( http://www.orxonox.net/wiki/about#Contact ). We hope to hear from you and are looking forward to your feedback.
    17 
    18 
    19 Cheers,
    20 The Orxonox Development Team
     3To make life easier you work with the Qt framework and even do some UI stuff.
  • sandbox_qt/bin/CMakeLists.txt

    r5929 r7421  
    2626
    2727# Create run scripts for Windows to manually add the DLL path when executing
    28 SET(RUN_SCRIPTS run standalone client1 client2 server dedicated dedicatedClient)
     28SET(RUN_SCRIPTS run)
    2929IF(WIN32)
    3030  FOREACH(_script ${RUN_SCRIPTS})
  • sandbox_qt/bin/vld.ini.in

    r5929 r7421  
    5656;   Default: None.
    5757;
    58 ForceIncludeModules = boost_date_time-vc80-mt-gd-1_39.dll, boost_filesystem-vc80-mt-gd-1_39.dll, boost_system-vc80-mt-gd-1_39.dll, boost_thread-vc80-mt-gd-1_39.dll, enet_d.dll, lua_d.dll, ogg_d.dll, vorbis_d.dll, vorbifile_d.dll
     58ForceIncludeModules =
    5959
    6060; Maximum number of data bytes to display for each leaked block. If zero, then
  • sandbox_qt/cmake/CompilerConfigGCC.cmake

    r7416 r7421  
    3737)
    3838
    39 # Complain about incompatibilities
    40 COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.4.0" _compare_result)
    41 IF(NOT _compare_result LESS 0)
    42   IF(${Boost_VERSION} LESS 103700)
    43     MESSAGE(STATUS "Warning: Boost versions earlier than 1.37 may not compile with GCC 4.4 or later!")
    44   ENDIF()
    45 ENDIF()
    46 
    4739# GCC may not support #pragma GCC system_header correctly when using
    4840# templates. According to Bugzilla, it was fixed March 07 but tests
     
    8173# For GCC older than version 4, do not display sign compare warnings
    8274# because of boost::filesystem (which creates about a hundred per include)
    83 ADD_COMPILER_FLAGS("-Wno-sign-compare" GCC_NO_SYSTEM_HEADER_SUPPORT CACHE)
     75#ADD_COMPILER_FLAGS("-Wno-sign-compare" GCC_NO_SYSTEM_HEADER_SUPPORT CACHE)
    8476
    8577# For newer GCC (4.3 and above), don't display hundreds of annoying deprecated
  • sandbox_qt/cmake/InstallConfig.cmake

    r7163 r7421  
    4343SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
    4444SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
    45 SET(MODULE_INSTALL_DIRECTORY  ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MODULE_PATH})
    4645SET(DOC_INSTALL_DIRECTORY     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
    4746SET(DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DATA_PATH})
     
    5554    SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox)
    5655    SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox/static)
    57     SET(MODULE_INSTALL_DIRECTORY  ${CMAKE_INSTALL_PREFIX}/lib/games/orxonox/modules)
    5856    SET(DOC_INSTALL_DIRECTORY     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
    5957    SET(DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_PREFIX}/share/games/orxonox)
  • sandbox_qt/cmake/LibraryConfig.cmake

    r7243 r7421  
    4040# On Windows using a package causes way less problems
    4141SET(_option_msg "Set this to true to use precompiled dependecy archives")
    42 IF(WIN32)
    43   OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" ON)
    44 ELSE(WIN32)
    45   OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE)
    46 ENDIF(WIN32)
     42OPTION(DEPENDENCY_PACKAGE_ENABLE "${_option_msg}" FALSE)
    4743
    4844# Scripts for specific library and CMake config
    4945INCLUDE(LibraryConfigTardis)
    50 INCLUDE(LibraryConfigApple)
    5146
    5247IF(DEPENDENCY_PACKAGE_ENABLE)
     
    9388# Performs the search and sets the variables    #
    9489
    95 FIND_PACKAGE(OGRE  1.4       REQUIRED)
    96 FIND_PACKAGE(ENet  1.1       REQUIRED)
    97 FIND_PACKAGE(Ogg             REQUIRED)
    98 FIND_PACKAGE(Vorbis          REQUIRED)
    99 FIND_PACKAGE(ALUT            REQUIRED)
    100 FIND_PACKAGE(ZLIB            REQUIRED)
    101 IF(POCO_REQUIRED)
    102   FIND_PACKAGE(POCO          REQUIRED)
    103 ENDIF()
    104 IF(WIN32)
    105   FIND_PACKAGE(DirectX       REQUIRED)
    106 ENDIF()
    107 
    108 ##### CEGUI #####
    109 # We make use of the CEGUI script module called CEGUILua.
    110 # However there is a small issue with that: We use Tolua, a C++ binding
    111 # generator ourselves. And we also have to use our bindings in the same
    112 # lua state is CEGUILua's. Unfortunately this implies that both lua runtime
    113 # version are equal or else you get segmentation faults.
    114 # In order to match the Lua versions we decided to ship CEGUILua in our
    115 # repository, mainly because there is no way to determine which version of
    116 # Lua CEGUILua was linked against (you'd have to specify yourself) and secondly
    117 # because we can then choose the Lua version. Future plans might involve only
    118 # accepting Lua 5.1.
    119 
    120 # Insert all internally supported CEGUILua versions here
    121 SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)
    122 OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)
    123 FIND_PACKAGE(CEGUI 0.5 REQUIRED)
    124 
    125 ##### Lua #####
    126 IF(CEGUILUA_USE_EXTERNAL_LIBRARY)
    127   COMPARE_VERSION_STRINGS(${CEGUI_VERSION} "0.6" _version_comparison)
    128   IF(version_comparison LESS 0)
    129     SET(LUA_VERSION_REQUEST 5.0)
    130   ELSE()
    131     SET(LUA_VERSION_REQUEST 5.1)
    132   ENDIF()
    133 ELSE()
    134   SET(LUA_VERSION_REQUEST 5)
    135 ENDIF()
    136 FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED)
    137 
    138 ##### OpenAL #####
    139 FIND_PACKAGE(OpenAL REQUIRED)
    140 # Also use parent include dir (without AL/) for ALUT
    141 IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")
    142   GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)
    143 ENDIF()
    144 SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})
    145 # Notfiy user
    146 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
    147 # Hide variables created by the script
    148 MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
    149 
    150 ##### Tcl #####
    151 # We only require Tcl, so avoid confusing user about other Tcl stuff by
    152 # applying a little workaround
    153 SET(Tclsh_FIND_QUIETLY TRUE)
    154 FIND_PACKAGE(TCL QUIET)
    155 # Display messages separately
    156 SET(TCL_FIND_QUIETLY FALSE)
    157 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
    158 
    159 ##### Boost #####
    160 # Expand the next statement if newer boost versions than 1.36.1 are released
    161 SET(Boost_ADDITIONAL_VERSIONS 1.37 1.37.0 1.38 1.38.0 1.39 1.39.0 1.40 1.40.0
    162                               1.41 1.41.0 1.42 1.42.0 1.43 1.43.0 1.44 1.44.0)
    163 IF( NOT TARDIS )
    164   FIND_PACKAGE(Boost 1.35 REQUIRED thread filesystem system date_time)
    165 ENDIF()
    166 # No auto linking, so this option is useless anyway
    167 MARK_AS_ADVANCED(Boost_LIB_DIAGNOSTIC_DEFINITIONS)
     90FIND_PACKAGE(QT4 COMPONENTS QtCore QtGui REQUIRED)
    16891
    16992
     
    17497# Note: Default option in the libraries vary, but our default option is dynamic
    17598IF(WIN32)
    176   OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE)
    177   OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)
    178   OPTION(LINK_ENET_DYNAMIC  "Link ENet dynamically on Windows" TRUE)
    179   OPTION(LINK_OGRE_DYNAMIC  "Link OGRE dynamically on Windows" TRUE)
    180   OPTION(LINK_TCL_DYNAMIC   "Link TCL dynamically on Windows" TRUE)
    181   OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
    182   COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison)
    183   IF(_version_comparison LESS 0)
    184     OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" FALSE)
    185   ELSE(_version_comparison LESS 0)
    186     OPTION(LINK_LUA_DYNAMIC "Link Lua dynamically on Windows" TRUE)
    187   ENDIF(_version_comparison LESS 0)
     99    #OPTION(LINK_ZLIB_DYNAMIC  "Link ZLib dynamically on Windows" TRUE)
    188100
    189101  IF(DEPENDENCY_PACKAGE_ENABLE)
    190     MARK_AS_ADVANCED(
    191       LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC LINK_ENET_DYNAMIC
    192       LINK_OGRE_DYNAMIC  LINK_TCL_DYNAMIC   LINK_ZLIB_DYNAMIC
    193       LINK_LUA_DYNAMIC
    194     )
     102    #MARK_AS_ADVANCED(
     103      #LINK_ZLIB_DYNAMIC
     104    #)
    195105  ENDIF()
    196106ENDIF(WIN32)
    197 
    198 
    199 ################# OGRE Plugins ##################
    200 
    201 # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager
    202 SET(OGRE_PLUGINS_INT Plugin_ParticleFX)
    203 IF(WIN32)
    204   # CG program manager is probably DirectX related (not available under unix)
    205   LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)
    206 ENDIF(WIN32)
    207 SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING
    208    "Specify which OGRE plugins to load. Existance check is performed.")
    209 
    210 # Check the plugins and determine the plugin folder
    211 # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}
    212 INCLUDE(CheckOGREPlugins)
    213 CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})
    214 
  • sandbox_qt/cmake/LibraryConfigTardis.cmake

    r7418 r7421  
    2121 #    Adrian Friedli
    2222 #  Description:
    23  #    Sets the correct find script paths on the ETH Tardis workstations.
    24  #    Also sets the TARDIS variable.
     23 #    Sets the TARDIS variable.
    2524 #
    2625
     
    3332  ENDIF()
    3433ENDIF()
    35 
    36 IF(TARDIS)
    37   MESSAGE(STATUS "Running on D-ITET isg.ee Tardis Computer. Using customized paths.")
    38 
    39 #  SET(CMAKE_C_COMPILER "gcc-4.1.1")
    40 #  SET(CMAKE_CXX_COMPILER "g++-4.1.1")
    41 
    42   # Note: When setting ENV${} variables, make sure to use quotes when
    43   #       having multiple directories.
    44   #SET(BOOST_INCLUDEDIR "/usr/pack/boost-1.42.0-bs/include")
    45   #SET(BOOST_LIBRARYDIR "/usr/pack/boost-1.42.0-bs/i686-debian-linux4.0/lib")
    46   SET(Boost_VERSION 104200)
    47   SET(Boost_INCLUDE_DIRS "/usr/pack/boost-1.42.0-bs/include" CACHE PATH "")
    48   SET(Boost_SYSTEM_LIBRARY_RELEASE "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_system.so" CACHE PATH "")
    49   SET(Boost_SYSTEM_LIBRARY_DEBUG "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_system-d.so" CACHE PATH "")
    50   SET(Boost_DATE_TIME_LIBRARY_RELEASE "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_date_time.so" CACHE PATH "")
    51   SET(Boost_DATE_TIME_LIBRARY_DEBUG "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_date_time-d.so" CACHE PATH "")
    52   SET(Boost_FILESYSTEM_LIBRARY_RELEASE "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_filesystem.so" CACHE PATH "")
    53   SET(Boost_FILESYSTEM_LIBRARY_DEBUG "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_filesystem-d.so" CACHE PATH "")
    54   SET(Boost_THREAD_LIBRARY_RELEASE "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_thread-mt.so" CACHE PATH "")
    55   SET(Boost_THREAD_LIBRARY_DEBUG "/usr/pack/boost-1.42.0-bs/i686-debian-linux5.0/lib/libboost_thread-mt-d.so" CACHE PATH "")
    56 
    57   SET(Boost_SYSTEM_LIBRARY "debug;${Boost_SYSTEM_LIBRARY_DEBUG};optimized;${Boost_SYSTEM_LIBRARY_RELEASE}" CACHE PATH "" FORCE)
    58   SET(Boost_DATE_TIME_LIBRARY "debug;${Boost_DATE_TIME_LIBRARY_DEBUG};optimized;${Boost_DATE_TIME_LIBRARY_RELEASE}" CACHE PATH "" FORCE)
    59   SET(Boost_FILESYSTEM_LIBRARY "debug;${Boost_FILESYSTEM_LIBRARY_DEBUG};optimized;${Boost_FILESYSTEM_LIBRARY_RELEASE}" CACHE PATH "" FORCE)
    60   SET(Boost_THREAD_LIBRARY "debug;${Boost_THREAD_LIBRARY_DEBUG};optimized;${Boost_THREAD_LIBRARY_RELEASE}" CACHE PATH "" FORCE)
    61 
    62   MARK_AS_ADVANCED( Boost_INCLUDE_DIRS )
    63   MARK_AS_ADVANCED( Boost_SYSTEM_LIBRARY Boost_SYSTEM_LIBRARY_RELEASE Boost_SYSTEM_LIBRARY_DEBUG )
    64   MARK_AS_ADVANCED( Boost_DATE_TIME_LIBRARY Boost_DATE_TIME_LIBRARY_RELEASE Boost_DATE_TIME_LIBRARY_DEBUG )
    65   MARK_AS_ADVANCED( Boost_FILESYSTEM_LIBRARY Boost_FILESYSTEM_LIBRARY_RELEASE Boost_FILESYSTEM_LIBRARY_DEBUG )
    66   MARK_AS_ADVANCED( Boost_THREAD_LIBRARY Boost_THREAD_LIBRARY_RELEASE Boost_THREAD_LIBRARY_DEBUG )
    67 
    68 
    69   LIST(APPEND CMAKE_INCLUDE_PATH "/usr/pack/cegui-0.6.2-sd")
    70   LIST(APPEND CMAKE_LIBRARY_PATH "/usr/pack/cegui-0.6.2-sd/i686-debian-linux5.0")
    71   LIST(APPEND CMAKE_INCLUDE_PATH "/usr/pack/ogre-1.6.1-sd")
    72   LIST(APPEND CMAKE_LIBRARY_PATH "/usr/pack/ogre-1.6.1-sd/i686-debian-linux5.0")
    73 
    74   #SET(ENV{CEGUIDIR}    "/usr/pack/cegui-0.6.2-sd;/usr/pack/cegui-0.6.2-sd/i686-debian-linux5.0")
    75   #SET(ENV{ENETDIR}     "/usr/pack/enet-1.2-sd;/usr/pack/enet-1.2-sd/i686-debian-linux4.0")
    76   #SET(ENV{ALUTDIR}     "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")
    77   #SET(ENV{OGGDIR}      "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
    78   #SET(ENV{VORBISDIR}   "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")
    79   #SET(ENV{LUA_DIR}     "/usr/pack/lua-5.1.4-sd;/usr/pack/lua-5.1.4-sd/i686-debian-linux4.0")
    80   #SET(ENV{OGRE_HOME}   "/usr/pack/ogre-1.4.9-sd;/usr/pack/ogre-1.4.9-sd/i686-debian-linux4.0")
    81   #SET(ENV{OPENALDIR}   "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")
    82   #SET(TCL_INCLUDE_PATH "/usr/pack/tcltk-8.4.9.linux-mo/include")
    83 ENDIF(TARDIS)
  • sandbox_qt/cmake/PackageConfig.cmake

    r7418 r7421  
    2525 #
    2626
    27 # Check package version info
    28 # MAJOR: Breaking change
    29 # MINOR: No breaking changes by the dependency package
    30 #        For example any code running on 3.0 should still run on 3.1
    31 #        But you can specify that the code only runs on 3.1 and higher
    32 #        or 4.0 and higher (so both 3.1 and 4.0 will work).
    33 SET(ALLOWED_MINIMUM_VERSIONS 3.1 4.0 5.0)
    34 
    35 IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
    36   SET(DEPENDENCY_VERSION 1.0)
    37 ELSE()
    38   # Get version from file
    39   FILE(READ ${DEPENDENCY_PACKAGE_DIR}/version.txt _file_content)
    40   SET(_match)
    41   STRING(REGEX MATCH "([0-9]+.[0-9]+)" _match ${_file_content})
    42   IF(_match)
    43     SET(DEPENDENCY_VERSION ${_match})
    44   ELSE()
    45     MESSAGE(FATAL_ERROR "The version.txt file in the dependency file has corrupt version information.")
    46   ENDIF()
    47 ENDIF()
    48 
    49 INCLUDE(CompareVersionStrings)
    50 SET(_version_match FALSE)
    51 FOREACH(_version ${ALLOWED_MINIMUM_VERSIONS})
    52   # Get major version
    53   STRING(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _major_version "${_version}")
    54   COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_major_version} _result TRUE)
    55   IF(_result EQUAL 0)
    56     COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_version} _result FALSE)
    57     IF(NOT _result LESS 0)
    58       SET(_version_match TRUE)
    59     ENDIF()
    60   ENDIF()
    61 ENDFOREACH(_version)
    62 IF(NOT _version_match)
    63   MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
    64           "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n"
    65           "You can get a new version from www.orxonox.net")
    66 ENDIF()
    67 
    6827IF(NOT _INTERNAL_PACKAGE_MESSAGE)
    6928  MESSAGE(STATUS "Using library package for the dependencies.")
     
    7130ENDIF()
    7231
    73 # Ogre versions >= 1.7 require the POCO library on Windows with MSVC for threading
    74 COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} 5 _result TRUE)
    75 IF(NOT _result EQUAL -1 AND NOT MINGW)
    76     SET(POCO_REQUIRED TRUE)
    77 ENDIF()
    78 
    7932# Include paths and other special treatments
    80 SET(ENV{ALUTDIR}               ${DEP_INCLUDE_DIR}/freealut)
    81 SET(ENV{BOOST_ROOT}            ${DEP_INCLUDE_DIR}/boost)
    82 SET(ENV{CEGUIDIR}              ${DEP_INCLUDE_DIR}/cegui)
    83 SET(ENV{DXSDK_DIR}             ${DEP_INCLUDE_DIR}/directx)
    84 SET(ENV{ENETDIR}               ${DEP_INCLUDE_DIR}/enet)
    85 SET(ENV{LUA_DIR}               ${DEP_INCLUDE_DIR}/lua)
    86 SET(ENV{OGGDIR}                ${DEP_INCLUDE_DIR}/libogg)
    87 SET(ENV{VORBISDIR}             ${DEP_INCLUDE_DIR}/libvorbis)
    88 SET(ENV{OGRE_HOME}             ${DEP_INCLUDE_DIR}/ogre)
    89 SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
    90 SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal)
    91 SET(ENV{POCODIR}               ${DEP_INCLUDE_DIR}/poco)
    92 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl/include)
    93 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib/include)
     33#SET(ENV{ALUTDIR}               ${DEP_INCLUDE_DIR}/freealut)
     34#LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl/include)
    9435
    9536### INSTALL ###
    96 
    97 # Tcl script library
    98 INSTALL(
    99   DIRECTORY ${DEP_LIBRARY_DIR}/tcl/
    100   DESTINATION lib/tcl
    101 )
    10237
    10338# On Windows, DLLs have to be in the executable folder, install them
  • sandbox_qt/cmake/PackageConfigMSVC.cmake

    r7418 r7421  
    5454  # Certain find scripts don't behave as ecpected to we have
    5555  # to specify the libraries ourselves.
    56   SET(TCL_LIBRARY  ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
    57   SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib  CACHE FILEPATH "")
     56  #SET(TCL_LIBRARY  ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
    5857
    5958  # Visual Leak Detector
  • sandbox_qt/cmake/PackageConfigMinGW.cmake

    r7418 r7421  
    4747  # Certain find scripts don't behave as ecpected to we have
    4848  # to specify the libraries ourselves.
    49   SET(TCL_LIBRARY  ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")
    50   SET(ZLIB_LIBRARY ${DEP_BINARY_DIR}/zlib1.dll CACHE FILEPATH "")
     49  #SET(TCL_LIBRARY  ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")
    5150
    5251ENDIF(MINGW)
  • sandbox_qt/cmake/tools/TargetUtilities.cmake

    r7416 r7421  
    3434 #      NO_DLL_INTERFACE:  Link statically with MSVC
    3535 #      NO_SOURCE_GROUPS:  Don't create msvc source groups
    36  #      MODULE:            For dynamic module libraries (libraries only)
    3736 #      WIN32:             Inherited from ADD_EXECUTABLE (executables only)
    3837 #      PCH_NO_DEFAULT:    Do not make precompiled header files default if
     
    4645 #      SOURCE_FILES:      Source files for the target
    4746 #      DEFINE_SYMBOL:     Sets the DEFINE_SYMBOL target property
    48  #      TOLUA_FILES:       Files with tolua interface
    4947 #      PCH_FILE:          Precompiled header file
    5048 #      PCH_EXCLUDE:       Source files to be excluded from PCH support
    5149 #      OUTPUT_NAME:       If you want a different name than the target name
     50 #      QT_MOC_FILES:      List of files to be processed by Qt MOC
     51 #      QT_UIC_FILES:      List of files to be processed by Qt UIC
    5252 #  Note:
    5353 #    This function also installs the target!
     
    6060INCLUDE(CMakeDependentOption)
    6161INCLUDE(CapitaliseName)
    62 INCLUDE(GenerateToluaBindings)
    6362INCLUDE(ParseMacroArguments)
    6463INCLUDE(SourceFileUtilities)
     
    6867
    6968MACRO(ORXONOX_ADD_LIBRARY _target_name)
    70   TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN})
     69  TU_ADD_TARGET(${_target_name} LIBRARY "" ${ARGN})
    7170ENDMACRO(ORXONOX_ADD_LIBRARY)
    7271
     
    8584                  NO_INSTALL         NO_VERSION        ${_additional_switches})
    8685  SET(_list_names LINK_LIBRARIES     VERSION           SOURCE_FILES
    87                   DEFINE_SYMBOL      TOLUA_FILES       PCH_FILE
    88                   PCH_EXCLUDE        OUTPUT_NAME)
     86                  DEFINE_SYMBOL      PCH_FILE          PCH_EXCLUDE
     87                  OUTPUT_NAME        QT_MOC_FILES      QT_UIC_FILES)
    8988
    9089  PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
     
    107106  ENDIF()
    108107
    109   # Combine source and header files
     108  # Combine source, header and QT designer files
    110109  SET(_${_target_name}_files
    111110    ${_${_target_name}_header_files}
    112111    ${_${_target_name}_source_files}
     112    ${_arg_QT_UIC_FILES}
    113113  )
    114114  # Remove potential duplicates
    115115  LIST(REMOVE_DUPLICATES _${_target_name}_files)
    116116
    117   # TOLUA_FILES
    118   IF(_arg_TOLUA_FILES)
    119     GENERATE_TOLUA_BINDINGS(${_target_name_capitalised} _${_target_name}_files
    120                             INPUTFILES ${_arg_TOLUA_FILES})
     117  # QT MOC and UIC preprocessing
     118  IF(_arg_QT_MOC_FILES)
     119      QT4_WRAP_CPP(_${_target_name}_files ${_arg_QT_MOC_FILES})
     120  ENDIF()
     121  IF(_arg_QT_UIC_FILES)
     122      QT4_WRAP_UI(_${_target_name}_files ${_arg_QT_UIC_FILES})
    121123  ENDIF()
    122124
     
    208210  ENDIF()
    209211
    210   # Configure modules
    211   IF (_arg_MODULE)
    212     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
    213       RUNTIME_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Windows
    214       LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix
    215     )
    216     ADD_MODULE(${_target_name})
    217     # Ensure that the main program depends on the module
    218     SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE STRING "" FORCE)
    219   ENDIF()
    220 
    221212  # LINK_LIBRARIES
    222213  IF(_arg_LINK_LIBRARIES)
     
    251242  # Install all targets except for static ones (executables also have SHARED in _link_mode)
    252243  IF(${_link_mode} STREQUAL "SHARED" AND NOT _arg_NO_INSTALL)
    253     IF(_arg_MODULE)
    254       INSTALL(TARGETS ${_target_name}
    255         RUNTIME DESTINATION ${MODULE_INSTALL_DIRECTORY}
    256         LIBRARY DESTINATION ${MODULE_INSTALL_DIRECTORY}
    257       )
    258     ELSE()
    259       INSTALL(TARGETS ${_target_name}
    260         RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY}
    261         LIBRARY DESTINATION ${LIBRARY_INSTALL_DIRECTORY}
    262       )
    263     ENDIF()
     244    INSTALL(TARGETS ${_target_name}
     245      RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY}
     246      LIBRARY DESTINATION ${LIBRARY_INSTALL_DIRECTORY}
     247    )
    264248  ENDIF()
    265249
    266250ENDMACRO(TU_ADD_TARGET)
    267 
    268 
    269 # Creates a helper file with name <name_of_the_library>${ORXONOX_MODULE_EXTENSION}
    270 # This helps finding dynamically loadable modules at runtime
    271 
    272 FUNCTION(ADD_MODULE _target)
    273   # We use the properties to get the name because the librarys name may differ from
    274   # the target name (for example orxonox <-> liborxonox)
    275 
    276   GET_TARGET_PROPERTY(_target_loc ${_target} LOCATION)
    277   GET_FILENAME_COMPONENT(_target_name ${_target_loc} NAME_WE)
    278 
    279   IF(CMAKE_CONFIGURATION_TYPES)
    280     FOREACH(_config ${CMAKE_CONFIGURATION_TYPES})
    281       SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_config}/${_target_name}${ORXONOX_MODULE_EXTENSION})
    282 
    283       FILE(WRITE ${_module_filename})
    284 
    285       INSTALL(
    286         FILES ${_module_filename}
    287         DESTINATION ${MODULE_INSTALL_DIRECTORY}
    288         CONFIGURATIONS ${_config}
    289       )
    290     ENDFOREACH()
    291   ELSE()
    292     SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_target_name}${ORXONOX_MODULE_EXTENSION})
    293 
    294     FILE(WRITE ${_module_filename})
    295 
    296     INSTALL(
    297       FILES ${_module_filename}
    298       DESTINATION ${MODULE_INSTALL_DIRECTORY}
    299     )
    300   ENDIF()
    301 ENDFUNCTION(ADD_MODULE)
  • sandbox_qt/data/CMakeLists.txt

    r7163 r7421  
    3030SET(DATA_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
    3131
    32 # Specify data directory
    33 GET_FILENAME_COMPONENT(_search_path_1 ${CMAKE_SOURCE_DIR}/../data_extern ABSOLUTE)
    34 FIND_PATH(EXTERNAL_DATA_DIRECTORY resources.oxr
    35   PATHS
    36     ${CMAKE_SOURCE_DIR}/data_extern
    37     ${_search_path_1}
    38   NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH
    39 )
    40 
    41 IF(NOT EXTERNAL_DATA_DIRECTORY)
    42   MESSAGE(STATUS "Warning: External data directory not found. If you want to compile while downloading the data files, you will have to recompile about four files afterwards and relink everything.")
    43   MESSAGE(STATUS "You can specify your own folder with the EXTERNAL_DATA_DIRECTORY variable. Default location for the path is orxonox_root/data_extern")
    44   # Temporary override to the default location.
    45   SET(EXTERNAL_DATA_DIRECTORY ${CMAKE_SOURCE_DIR}/data_extern)
    46 ENDIF()
    47 
    48 
    4932################ Installation #################
    5033
    51 # Internal directory
    5234INSTALL(
    5335  DIRECTORY ${DATA_DIRECTORY}/
     
    5537  REGEX "\\.svn$|_svn$|CMakeLists.txt|InstallScript.cmake" EXCLUDE
    5638)
    57 # External directory
    58 INSTALL(
    59   DIRECTORY ${EXTERNAL_DATA_DIRECTORY}/
    60   DESTINATION ${DATA_INSTALL_DIRECTORY}
    61   REGEX "\\.svn$|_svn$|resources\\.oxr|AUTHORS|LICENSE" EXCLUDE
    62 )
    63 # Configure the install scripts (variables not available during installation)
    64 CONFIGURE_FILE(DataInstallScript.cmake ${CMAKE_CURRENT_BINARY_DIR}/DataInstallScript.cmake @ONLY)
    65 # Join both resources.oxr files
    66 INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/DataInstallScript.cmake)
  • sandbox_qt/doc/api/Groups.dox

    r7401 r7421  
    4444
    4545/**
    46     @defgroup Class Class management
    47     @ingroup Core
    48 */
    49 
    50 /**
    51     @defgroup Object Object management
    52     @ingroup Core
    53 */
    54 
    55 /**
    56     @defgroup Command Command
    57     @ingroup Core
    58 */
    59 
    60 /**
    6146    @defgroup Config Config
    6247    @ingroup Core
    6348*/
    64 
    65 /**
    66     @defgroup Input Input
    67     @ingroup Core
    68 */
    69 
    70 /**
    71     @defgroup Management Management
    72     @ingroup Core
    73 */
    74 
    75 /**
    76     @defgroup XML XML
    77     @ingroup Core
    78 */
    79 
    80 /**
    81     @defgroup Network Network
    82 
    83     The network library is used to connect clients and server, to synchronize objects and variables, and
    84     to transmit network function calls. It contains the central @ref orxonox::Server "Server" and
    85     @ref orxonox::Client "Client" classes as well as several functions and macros for
    86     @ref orxonox::Synchronisable "synchronisable" classes.
    87 */
    88 
    89 /**
    90     @defgroup Tools Tools
    91 
    92     The tools are a bunch of utilities that belong to the Orxonox library, but are independent of other
    93     features.
    94 */
    95 
    96 /**
    97     @defgroup Orxonox Orxonox
    98 
    99     The Orxonox library contains the central and most important classes of the game. Managers, interfaces,
    100     base-classes, and more are located in Orxonox. More specialized classes that inherit of the base-classes
    101     in Orxonox are often sourced out to the modules.
    102 */
    103 
    104 /**
    105     @defgroup Modules Modules
    106 
    107     The modules are libraries that depend on the Orxonox library and that are loaded dynamically on runtime
    108     (in contrast to statically loaded libraries like util and core). Each module contains some classes that
    109     are usually connected to each other, but they are independent of other modules. However modules can still
    110     link to other modules, but only in a hierarchical order, no circular dependencies.
    111 */
    112 
    113 /**
    114     @defgroup Designtools Designtools
    115     @ingroup Modules
    116 */
    117 
    118 /**
    119     @defgroup Notifications Notifications
    120     @ingroup Modules
    121 */
    122 
    123 /**
    124     @defgroup Objects Objects
    125     @ingroup Modules
    126 */
    127 
    128 /**
    129     @defgroup Overlays Overlays
    130     @ingroup Modules
    131 */
    132 
    133 /**
    134     @defgroup Pickup Pickup
    135     @ingroup Modules
    136 */
    137 
    138 /**
    139     @defgroup Pong Pong
    140     @ingroup Modules
    141 */
    142 
    143 /**
    144     @defgroup Questsystem Questsystem
    145     @ingroup Modules
    146 */
    147 
    148 /**
    149     @defgroup Weapons Weapons
    150     @ingroup Modules
    151 */
  • sandbox_qt/doc/api/doxy.config.in

    r7401 r7421  
    624624# subdirectory from a directory tree whose root is specified with the INPUT tag.
    625625
    626 EXCLUDE                = @CMAKE_SOURCE_DIR@/src/external/bullet/ \
    627                          @CMAKE_SOURCE_DIR@/src/external/cpptcl/ \
    628                          @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.5.0 \
    629                          @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.6.0 \
    630                          @CMAKE_SOURCE_DIR@/src/external/ceguilua/ceguilua-0.6.1 \
    631                          @CMAKE_SOURCE_DIR@/src/libraries/core/command/IOConsoleWindows.h \
    632                          @CMAKE_SOURCE_DIR@/src/libraries/core/command/IOConsoleWindows.cc \
    633                          @CMAKE_SOURCE_DIR@/src/libraries/tools/bsp \
     626EXCLUDE                =
    634627
    635628# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
  • sandbox_qt/doc/api/main.dox

    r7401 r7421  
    22    @mainpage
    33
    4     @image html orxonox.jpg
    5 
    6     This is the documentation of Orxonox. It contains descriptions of our classes and functions and
    7     explains their usage with several examples and background information. Because Orxonox is so big,
    8     we can't document all of our code - sorry for that! But we do your best to document the most
    9     important parts of it, namely the @ref Core "core" and @ref Util "util" libraries, as well as the
    10     central classes in the @ref Orxonox "orxonox" main library and some @ref Modules "modules".
    11 
    12     To understand the connection between different classes in Orxonox, have a look at the
    13     <a href="modules.html"><b>Modules section</b></a>. It contains a list of the most important topics
    14     and groups files that contribute to the same feature.
     4    This is the documentation of some test project. It has not yet been written though...
    155*/
  • sandbox_qt/src/CMakeLists.txt

    r7401 r7421  
    3333####### Library Behaviour (dependencies) ########
    3434
    35 # Disable Boost auto linking completely
    36 ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
    37 
    3835# If no defines are specified, these libs get linked statically
    39 ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC)
    40 ADD_COMPILER_FLAGS("-DENET_DLL"           WIN32 LINK_ENET_DYNAMIC)
    41 ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL"   WIN32 LINK_LUA_DYNAMIC)
    42 ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
     36#ADD_COMPILER_FLAGS("-DZLIB_DLL"           WIN32 LINK_ZLIB_DYNAMIC)
    4337# If no defines are specified, these libs get linked dynamically
    44 ADD_COMPILER_FLAGS("-DCEGUI_STATIC"       WIN32 NOT LINK_CEGUI_DYNAMIC)
    45 ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB"    WIN32 NOT LINK_OGRE_DYNAMIC)
    46 ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
     38#ADD_COMPILER_FLAGS("-DSTATIC_BUILD"       WIN32 NOT LINK_TCL_DYNAMIC)
    4739
    4840######### Library Behaviour (external) ##########
    49 
    50 # Use TinyXML++
    51 ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP")
    5241
    5342# Default linking for externals is SHARED
     
    6049ENDIF()
    6150# If no defines are specified, these libs get linked dynamically
    62 ADD_COMPILER_FLAGS("-DCEGUILUA_STATIC"             WIN32 NOT _external_shared_link)
    63 ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link)
    64 ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB"              WIN32 NOT _external_shared_link)
    65 ADD_COMPILER_FLAGS("-DTOLUA_STATIC_BUILD"          WIN32 NOT _external_shared_link)
     51#ADD_COMPILER_FLAGS("-DTOLUA_STATIC_BUILD"          WIN32 NOT _external_shared_link)
    6652
    6753############## Include Directories ##############
     
    7056INCLUDE_DIRECTORIES(
    7157  # External
    72   ${OGRE_INCLUDE_DIR}
    73   ${CEGUI_INCLUDE_DIR}
    74   ${ENET_INCLUDE_DIR}
    75   ${Boost_INCLUDE_DIRS}
    76   ${POCO_INCLUDE_DIR}
    77   ${OPENAL_INCLUDE_DIRS}
    78   ${ALUT_INCLUDE_DIR}
    79   ${VORBIS_INCLUDE_DIR}
    80   ${OGG_INCLUDE_DIR}
    81   ${LUA_INCLUDE_DIR}
    82   ${TCL_INCLUDE_PATH}
    83   ${DIRECTX_INCLUDE_DIR}
    84   ${ZLIB_INCLUDE_DIR}
    8558  ${VLD_INCLUDE_DIR}
    8659
     
    8962  ${CMAKE_CURRENT_SOURCE_DIR}/external
    9063  # Include directories needed even if only included by Orxonox
    91   ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet
    92   ${CMAKE_CURRENT_SOURCE_DIR}/external/ois
     64  #${CMAKE_CURRENT_SOURCE_DIR}/external/bullet
    9365
    9466  # OrxonoxConfig.h
     
    9668)
    9769
    98 IF(CEGUILUA_USE_INTERNAL_LIBRARY)
    99   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/external/ceguilua/ceguilua-${CEGUI_VERSION})
    100 ENDIF()
     70###################### Qt4 ######################
    10171
    102 ################### Tolua Bind ##################
    103 
    104 # Create directory because the tolua application doesn't work otherwise
    105 IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
    106   FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
    107 ENDIF()
    108 
    109 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
     72INCLUDE(${QT_USE_FILE})
    11073
    11174################ Sub Directories ################
     
    11477ADD_SUBDIRECTORY(libraries)
    11578ADD_SUBDIRECTORY(orxonox)
    116 ADD_SUBDIRECTORY(modules)
    11779
    11880################## Executable ###################
     
    13799  OUTPUT_NAME orxonox
    138100)
    139 # Main executable should depend on all modules
    140 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES})
    141101
    142102# Get name to configure the run scripts
     
    170130# core/XMLPort.h instead of src/core/XMLPort.h
    171131
    172 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/modules)
    173132GET_DIRECTORY_PROPERTY(_temp INCLUDE_DIRECTORIES)
    174133# Replace ';' by spaces
  • sandbox_qt/src/OrxonoxConfig.h.in

    r7401 r7421  
    194194}
    195195
    196 // Import general purpose smart pointers
    197 namespace boost
    198 {
    199     template<class T> class scoped_ptr;
    200     template<class T> class shared_ptr;
    201     template<class T> class weak_ptr;
    202     template<class T> class intrusive_ptr;
    203     template<class T> class shared_array;
    204     template<class T> class scoped_array;
    205 }
    206 namespace orxonox
    207 {
    208     using boost::scoped_ptr;
    209     using boost::shared_ptr;
    210     using boost::weak_ptr;
    211     using boost::intrusive_ptr;
    212     using boost::shared_array;
    213     using boost::scoped_array;
    214 }
    215196
    216197#endif /* _OrxonoxConfig_H__ */
  • sandbox_qt/src/SpecialConfig.h.in

    r7401 r7421  
    4242#include "OrxonoxConfig.h"
    4343
    44 #cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY  ///< Set whether we must suffix "ceguilua/" for the CEGUILua.h include
    45 
    4644#cmakedefine DEPENDENCY_PACKAGE_ENABLE      ///< Defined if a precompiled depdency package was used. We then copy all libraries too when installing.
    4745
     
    5755    const char defaultLibraryPath[] = "@DEFAULT_LIBRARY_PATH@";
    5856    const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@";
    59     const char defaultModulePath[]  = "@DEFAULT_MODULE_PATH@";
    6057    const char defaultDocPath[]     = "@DEFAULT_DOC_PATH@";
    6158    const char defaultDataPath[]    = "@DEFAULT_DATA_PATH@";
     
    6663    // INSTALLATION PATHS
    6764    const char dataInstallDirectory[]       = "@DATA_INSTALL_DIRECTORY@";
    68     const char moduleInstallDirectory[]     = "@MODULE_INSTALL_DIRECTORY@";
    6965#endif
    7066
    7167    // DEVELOPMENT RUN PATHS
    7268    const char dataDevDirectory[]           = "@DATA_DIRECTORY@";
    73     const char externalDataDevDirectory[]   = "@EXTERNAL_DATA_DIRECTORY@";
    7469#ifdef CMAKE_CONFIGURATION_TYPES
    75     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
    7670    const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
    7771    const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    CMAKE_INTDIR;
    7872#else
    79     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";
    8073    const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
    8174    const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
     
    8578    const char dependencyLibraryDirectory[] = "@DEP_LIBRARY_DIR@";
    8679#endif
    87 
    88     // Module extension
    89     const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";
    90 
    91     // OGRE PLUGINS
    92 #ifdef NDEBUG
    93     const char ogrePlugins[] = "@OGRE_PLUGINS_RELEASE@";
    94 #  ifdef DEPENDENCY_PACKAGE_ENABLE
    95     const char ogrePluginsDirectory[] = ".";
    96 #  else
    97     const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_RELEASE@";
    98 #  endif
    99 #else
    100     const char ogrePlugins[] = "@OGRE_PLUGINS_DEBUG@";
    101 #  ifdef DEPENDENCY_PACKAGE_ENABLE
    102     const char ogrePluginsDirectory[] = ".";
    103 #  else
    104     const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";
    105 #  endif
    106 #endif
    10780} }
    10881
  • sandbox_qt/src/external/CMakeLists.txt

    r7266 r7421  
    2020################ Sub Directories ################
    2121
    22 ADD_SUBDIRECTORY(tolua)
    23 
    24 # Include CEGUILua if not requested otherwise
    25 IF(CEGUILUA_USE_INTERNAL_LIBRARY)
    26   IF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})
    27     MESSAGE(FATAL_ERROR "CEGUILua version not found in src folder. Update list of supported versions in LibraryConfig.cmake!")
    28   ENDIF()
    29 
    30   ADD_SUBDIRECTORY(ceguilua)
    31   SET(CEGUILUA_LIBRARY ${CEGUILUA_LIBRARY} PARENT_SCOPE)
    32 ENDIF()
    33 
    34 ADD_SUBDIRECTORY(bullet)
    35 ADD_SUBDIRECTORY(cpptcl)
    3622ADD_SUBDIRECTORY(loki)
    37 ADD_SUBDIRECTORY(ogreceguirenderer)
    38 ADD_SUBDIRECTORY(ois)
    39 ADD_SUBDIRECTORY(tinyxml)
  • sandbox_qt/src/libraries/CMakeLists.txt

    r7401 r7421  
    2424ADD_SUBDIRECTORY(util)
    2525ADD_SUBDIRECTORY(core)
    26 ADD_SUBDIRECTORY(network)
    27 ADD_SUBDIRECTORY(tools)
  • sandbox_qt/src/libraries/core/CMakeLists.txt

    r7284 r7421  
    1919
    2020SET_SOURCE_FILES(CORE_SRC_FILES
    21   CommandLineParser.cc
    22   ConfigValueContainer.cc
    2321  Core.cc
    24   DynLib.cc
    25   DynLibManager.cc
    26   Event.cc
    2722  Game.cc
    28   GameMode.cc
    29   GameState.cc
    30   GraphicsManager.cc
    31   GUIManager.cc
    32   Language.cc
    33   LuaState.cc
    34   ObjectListBase.cc
    35   OrxonoxClass.cc
    36   Resource.cc
    37   WindowEventListener.cc
    38 
    39   # hierarchy
    40   Identifier.cc
    41   MetaObjectList.cc
    42 
    43   # level
    44   BaseObject.cc
    45   ClassTreeMask.cc
    46   Loader.cc
    47   Namespace.cc
    48   NamespaceNode.cc
    49   Template.cc
    50   XMLPort.cc
    51   XMLNameListener.cc
    52 
    53 COMPILATION_BEGIN FilesystemCompilation.cc
    54   command/ArgumentCompletionFunctions.cc
    55   ConfigFileManager.cc
    56   MemoryArchive.cc
    5723  PathConfig.cc
    58 COMPILATION_END
    59 
    60   # multithreading
    61   ThreadPool.cc
    62 COMPILATION_BEGIN ThreadCompilation.cc
    63   command/TclThreadManager.cc
    64   Thread.cc
    65 COMPILATION_END
    6624)
    67 
    68 ADD_SUBDIRECTORY(command)
    69 ADD_SUBDIRECTORY(input)
    7025
    7126ORXONOX_ADD_LIBRARY(core
    7227  FIND_HEADER_FILES
    73   TOLUA_FILES
    74     command/CommandExecutor.h
    75     ConfigFileManager.h
    76     Game.h
    77     GameMode.h
    78     GUIManager.h
    79     Loader.h
    80     LuaState.h
    81     PathConfig.h
    82     input/InputManager.h
    83     input/KeyBinder.h
    84     input/KeyBinderManager.h
    85   PCH_FILE
    86     CorePrecompiledHeaders.h
    8728  LINK_LIBRARIES
    88     ${OGRE_LIBRARY}
    89     ${Boost_FILESYSTEM_LIBRARY}
    90     ${Boost_SYSTEM_LIBRARY} # Filesystem dependency
    91     ${Boost_THREAD_LIBRARY}
    92     ${Boost_DATE_TIME_LIBRARY} # Thread dependency
    93     ${CEGUI_LIBRARY}
    94     ${CEGUILUA_LIBRARY}
    95     ${LUA_LIBRARIES}
    96     cpptcl_orxonox
    97     ogreceguirenderer_orxonox
    98     ois_orxonox
    99     tinyxml_orxonox
    100     tolua_orxonox
     29    ${QT_QTCORE_LIBRARY}
    10130    util
    10231  SOURCE_FILES
  • sandbox_qt/src/libraries/core/Core.cc

    r7401 r7421  
    3131@file
    3232@brief
    33     Implementation of the Core singleton with its global variables (avoids boost include)
     33    Implementation of the Core singleton
    3434*/
    3535
     
    3737
    3838#include <cassert>
     39#include <ctime>
    3940#include <fstream>
    4041#include <vector>
     
    4950#endif
    5051
    51 #include "util/Clock.h"
    5252#include "util/Debug.h"
    5353#include "util/Exception.h"
    54 #include "util/Scope.h"
    55 #include "util/ScopedSingletonManager.h"
    56 #include "util/SignalHandler.h"
    5754#include "PathConfig.h"
    58 #include "CommandLineParser.h"
    59 #include "ConfigFileManager.h"
    60 #include "ConfigValueIncludes.h"
    61 #include "CoreIncludes.h"
    62 #include "DynLibManager.h"
    63 #include "GameMode.h"
    64 #include "GraphicsManager.h"
    65 #include "GUIManager.h"
    66 #include "Identifier.h"
    67 #include "Language.h"
    68 #include "LuaState.h"
    69 #include "command/ConsoleCommand.h"
    70 #include "command/IOConsole.h"
    71 #include "command/TclBind.h"
    72 #include "command/TclThreadManager.h"
    73 #include "input/InputManager.h"
    7455
    7556namespace orxonox
     
    7859    Core* Core::singletonPtr_s  = 0;
    7960
    80     SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
    81     SetCommandLineSwitch(noIOConsole).information("Use this if you don't want to use the IOConsole (for instance for Lua debugging)");
    82 
    83 #ifdef ORXONOX_PLATFORM_WINDOWS
    84     SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)");
    85 #endif
    86 
    8761    Core::Core(const std::string& cmdLine)
    88         // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands)
    89         : identifierDestroyer_(Identifier::destroyAllIdentifiers)
    90         // Cleanup guard for external console commands that don't belong to an Identifier
    91         , consoleCommandDestroyer_(ConsoleCommand::destroyAll)
    92         , bGraphicsLoaded_(false)
    93         , bStartIOConsole_(true)
    9462    {
    9563        // Set the hard coded fixed paths
    9664        this->pathConfig_.reset(new PathConfig());
    9765
    98         // Create a new dynamic library manager
    99         this->dynLibManager_.reset(new DynLibManager());
    100 
    101         // Load modules
    102         const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();
    103         for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
    104         {
    105             try
    106             {
    107                 this->dynLibManager_->load(*it);
    108             }
    109             catch (...)
    110             {
    111                 COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;
    112             }
    113         }
    114 
    115         // Parse command line arguments AFTER the modules have been loaded (static code!)
    116         CommandLineParser::parseCommandLine(cmdLine);
    117 
    11866        // Set configurable paths like log, config and media
    11967        this->pathConfig_->setConfigurablePaths();
    120 
    121         // create a signal handler (only active for Linux)
    122         // This call is placed as soon as possible, but after the directories are set
    123         this->signalHandler_.reset(new SignalHandler());
    124         this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
    12568
    12669        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
    12770        OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
    12871
    129         // Parse additional options file now that we know its path
    130         CommandLineParser::parseFile();
    131 
    13272#ifdef ORXONOX_PLATFORM_WINDOWS
    13373        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    134         // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    135         // the timer though).
    136         int limitToCPU = CommandLineParser::getValue("limitToCPU");
     74        int limitToCPU = 0;//CommandLineParser::getValue("limitToCPU");
    13775        if (limitToCPU > 0)
    13876            setThreadAffinity(static_cast<unsigned int>(limitToCPU));
    13977#endif
    14078
    141         // Manage ini files and set the default settings file (usually orxonox.ini)
    142         this->configFileManager_.reset(new ConfigFileManager());
    143         this->configFileManager_->setFilename(ConfigFileType::Settings,
    144             CommandLineParser::getValue("settingsFile").getString());
    145 
    146         // Required as well for the config values
    147         this->languageInstance_.reset(new Language());
    148 
    149         // Do this soon after the ConfigFileManager has been created to open up the
    150         // possibility to configure everything below here
    151         ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);
    152         this->setConfigValues();
    153 
    154         // create persistent io console
    155         if (CommandLineParser::getValue("noIOConsole").getBool())
    156         {
    157             ModifyConfigValue(bStartIOConsole_, tset, false);
    158         }
    159         if (this->bStartIOConsole_)
    160             this->ioConsole_.reset(new IOConsole());
    161 
    162         // creates the class hierarchy for all classes with factories
    163         Identifier::createClassHierarchy();
    164 
    165         // Load OGRE excluding the renderer and the render window
    166         this->graphicsManager_.reset(new GraphicsManager(false));
    167 
    168         // initialise Tcl
    169         this->tclBind_.reset(new TclBind(PathConfig::getDataPathString()));
    170         this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));
    171 
    172         // Create singletons that always exist (in other libraries)
    173         this->rootScope_.reset(new Scope<ScopeID::Root>());
    174 
    17579        // Generate documentation instead of normal run?
    17680        std::string docFilename;
    177         CommandLineParser::getValue("generateDoc", &docFilename);
     81        //CommandLineParser::getValue("generateDoc", &docFilename);
    17882        if (!docFilename.empty())
    17983        {
     
    18185            if (docFile.is_open())
    18286            {
    183                 CommandLineParser::generateDoc(docFile);
     87                //CommandLineParser::generateDoc(docFile);
    18488                docFile.close();
    18589            }
     
    19195    /**
    19296    @brief
    193         All destruction code is handled by scoped_ptrs and ScopeGuards.
     97        All destruction code is handled by QScopedPointers
    19498    */
    19599    Core::~Core()
    196100    {
    197         // Remove us from the object lists again to avoid problems when destroying them
    198         this->unregisterObject();
    199101    }
    200102
     
    207109        const unsigned int defaultLevelLogFile = 4;
    208110#endif
     111        /*
    209112        SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
    210113            .description("The maximum level of debug output shown in the log file");
     
    219122        SetConfigValue(bStartIOConsole_, true)
    220123            .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
    221     }
    222 
    223     //! Callback function if the language has changed.
    224     void Core::languageChanged()
    225     {
    226         // Read the translation file after the language was configured
    227         Language::getInstance().readTranslatedLanguageFile();
     124        */
    228125    }
    229126
     
    237134            bInitialized = true;
    238135        }
    239     }
    240 
    241     void Core::loadGraphics()
    242     {
    243         // Any exception should trigger this, even in upgradeToGraphics (see its remarks)
    244         Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);
    245 
    246         // Upgrade OGRE to receive a render window
    247         try
    248         {
    249             graphicsManager_->upgradeToGraphics();
    250         }
    251         catch (...)
    252         {
    253             // Recovery from this is very difficult. It requires to completely
    254             // destroy Ogre related objects and load again (without graphics).
    255             // However since Ogre 1.7 there seems to be a problem when Ogre
    256             // throws an exception and the graphics engine then gets destroyed
    257             // and reloaded between throw and catch (access violation in MSVC).
    258             // That's why we abort completely and only display the exception.
    259             COUT(0) << "An exception occurred during upgrade to graphics. "
    260                     << "That is unrecoverable. The message was:" << endl
    261                     << Exception::handleMessage() << endl;
    262             abort();
    263         }
    264 
    265         // Calls the InputManager which sets up the input devices.
    266         inputManager_.reset(new InputManager());
    267 
    268         // Load the CEGUI interface
    269         guiManager_.reset(new GUIManager(inputManager_->getMousePosition()));
    270 
    271         bGraphicsLoaded_ = true;
    272         GameMode::bShowsGraphics_s = true;
    273 
    274         // Load some sort of a debug overlay (only denoted by its name, "debug.oxo")
    275         graphicsManager_->loadDebugOverlay();
    276 
    277         // Create singletons associated with graphics (in other libraries)
    278         graphicsScope_.reset(new Scope<ScopeID::Graphics>());
    279 
    280         unloader.Dismiss();
    281     }
    282 
    283     void Core::unloadGraphics()
    284     {
    285         this->graphicsScope_.reset();
    286         this->guiManager_.reset();
    287         this->inputManager_.reset();
    288         this->graphicsManager_.reset();
    289 
    290         // Load Ogre::Root again, but without the render system
    291         try
    292             { this->graphicsManager_.reset(new GraphicsManager(false)); }
    293         catch (...)
    294         {
    295             COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl
    296                     << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl
    297                     << "Terminating the program." << std::endl;
    298             abort();
    299         }
    300 
    301         bGraphicsLoaded_ = false;
    302         GameMode::bShowsGraphics_s = false;
    303     }
    304 
    305     //! Sets the language in the config-file back to the default.
    306     void Core::resetLanguage()
    307     {
    308         ResetConfigValue(language_);
    309136    }
    310137
     
    354181#endif
    355182    }
    356 
    357     void Core::preUpdate(const Clock& time)
    358     {
    359         // Update singletons before general ticking
    360         ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
    361         if (this->bGraphicsLoaded_)
    362         {
    363             // Process input events
    364             this->inputManager_->preUpdate(time);
    365             // Update GUI
    366             this->guiManager_->preUpdate(time);
    367             // Update singletons before general ticking
    368             ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
    369         }
    370         // Process console events and status line
    371         if (this->ioConsole_ != NULL)
    372             this->ioConsole_->preUpdate(time);
    373         // Process thread commands
    374         this->tclThreadManager_->preUpdate(time);
    375     }
    376 
    377     void Core::postUpdate(const Clock& time)
    378     {
    379         // Update singletons just before rendering
    380         ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
    381         if (this->bGraphicsLoaded_)
    382         {
    383             // Update singletons just before rendering
    384             ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
    385             // Render (doesn't throw)
    386             this->graphicsManager_->postUpdate(time);
    387         }
    388     }
    389183}
  • sandbox_qt/src/libraries/core/Core.h

    r7401 r7421  
    4545
    4646#include <string>
    47 #include <boost/scoped_ptr.hpp>
     47#include <QScopedPointer>
    4848#include <loki/ScopeGuard.h>
    4949
    5050#include "util/Singleton.h"
    51 #include "OrxonoxClass.h"
     51#include "PathConfig.h"
    5252
    5353namespace orxonox
     
    5959        You should only create this singleton once because it destroys the identifiers!
    6060    */
    61     class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
     61    class _CoreExport Core : public Singleton<Core>
    6262    {
    6363        typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
     
    7878            void setConfigValues();
    7979
    80             //! Returns the configured language.
    81             const std::string& getLanguage()
    82                 { return this->language_; }
    83             void resetLanguage();
    84 
    8580        private:
    8681            Core(const Core&); //!< Don't use (undefined symbol)
    8782
    88             void languageChanged();
    8983            void initRandomNumberGenerator();
    9084
    91             void preUpdate(const Clock& time);
    92             void postUpdate(const Clock& time);
    93 
    94             void loadGraphics();
    95             void unloadGraphics();
     85            void update() {}
    9686
    9787            void setThreadAffinity(int limitToCPU);
    9888            // MANAGED SINGLETONS/OBJECTS
    9989            // Mind the order for the destruction!
    100             scoped_ptr<PathConfig>        pathConfig_;
    101             scoped_ptr<DynLibManager>     dynLibManager_;
    102             scoped_ptr<SignalHandler>     signalHandler_;
    103             SimpleScopeGuard              identifierDestroyer_;
    104             SimpleScopeGuard              consoleCommandDestroyer_;
    105             scoped_ptr<ConfigFileManager> configFileManager_;
    106             scoped_ptr<Language>          languageInstance_;
    107             scoped_ptr<IOConsole>         ioConsole_;
    108             scoped_ptr<TclBind>           tclBind_;
    109             scoped_ptr<TclThreadManager>  tclThreadManager_;
    110             scoped_ptr<Scope<ScopeID::Root> > rootScope_;
    111             // graphical
    112             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
    113             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
    114             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
    115             scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
     90            QScopedPointer<PathConfig>    pathConfig_;
    11691
    117             bool                          bGraphicsLoaded_;
    11892            int                           softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
    119             std::string                   language_;                   //!< The language
    12093            bool                          bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
    121             bool                          bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
    12294
    12395            static Core*                  singletonPtr_s;
  • sandbox_qt/src/libraries/core/CorePrereqs.h

    r7284 r7421  
    3737
    3838#include "OrxonoxConfig.h"
    39 #include <boost/version.hpp>
    4039
    4140//-----------------------------------------------------------------------
     
    6362//-----------------------------------------------------------------------
    6463
    65 namespace orxonox
    66 {
    67     static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
    68 }
    69 
    7064//-----------------------------------------------------------------------
    7165// Enums
    7266//-----------------------------------------------------------------------
    73 
    74 namespace orxonox
    75 {
    76     namespace XMLPort
    77     {
    78         enum Mode
    79         {
    80             NOP,
    81             LoadObject,
    82             SaveObject,
    83             ExpandObject
    84         };
    85     }
    86 
    87     namespace ConfigFileType
    88     {
    89         enum Value
    90         {
    91             Settings,
    92             JoyStickCalibration,
    93             CommandHistory
    94             // Don't forget to adjust the array size in the ConfigFileManager when adding a new entry here!
    95         };
    96     }
    97 
    98     namespace KeybindMode
    99     {
    100         enum Value
    101         {
    102             OnPress,
    103             OnHold,
    104             OnRelease,
    105             None
    106         };
    107     };
    108 }
    10967
    11068//-----------------------------------------------------------------------
     
    11472namespace orxonox
    11573{
    116     typedef std::string LanguageEntryLabel;
    117 
    118     template <class T, class U>
    119     T orxonox_cast(U*);
    120 
    121     class BaseObject;
    122     template <class T>
    123     class ClassFactory;
    124     template <class T>
    125     class ClassIdentifier;
    126     class ClassTreeMask;
    127     class ClassTreeMaskIterator;
    128     class ClassTreeMaskNode;
    129     class ClassTreeMaskObjectIterator;
    130     class CommandLineParser;
    131     class CommandLineArgument;
    132     class ConfigFile;
    133     class ConfigFileEntry;
    134     class ConfigFileEntryComment;
    135     class ConfigFileEntryValue;
    136     class ConfigFileManager;
    137     class ConfigFileSection;
    138     class ConfigValueContainer;
    13974    class Core;
    140     class DynLib;
    141     class DynLibManager;
    142     struct Event;
    143     class EventState;
    144     class Factory;
    14575    class Game;
    146     class GameState;
    147     struct GameStateInfo;
    148     struct GameStateTreeNode;
    149     class GraphicsManager;
    150     class GUIManager;
    151     class Identifier;
    152     template <class T>
    153     class Iterator;
    154     class Language;
    155     class LuaFunctor;
    156     class LuaState;
    157     class MemoryArchive;
    158     class MemoryArchiveFactory;
    159     class MetaObjectList;
    160     class MetaObjectListElement;
    161     class Namespace;
    162     class NamespaceNode;
    163     template <class T>
    164     class ObjectList;
    165     class ObjectListBase;
    166     class ObjectListBaseElement;
    167     template <class T>
    168     class ObjectListElement;
    169     template <class T>
    170     class ObjectListIterator;
    171     class OgreWindowEventListener;
    172     class OrxonoxClass;
    17376    class PathConfig;
    174     struct ResourceInfo;
    175     class SettingsConfigFile;
    176     template <class T>
    177     class SmartPtr;
    178     template <class T>
    179     class SubclassIdentifier;
    180     class Template;
    181     class Thread;
    182     class ThreadPool;
    183     template <class T>
    184     class WeakPtr;
    185     class WindowEventListener;
    186     class XMLFile;
    187     class XMLNameListener;
    188     template <class T, class O>
    189     class XMLPortClassObjectContainer;
    190     template <class T>
    191     class XMLPortClassParamContainer;
    192     class XMLPortObjectContainer;
    193     class XMLPortParamContainer;
    194 
    195     // Command
    196     class ArgumentCompleter;
    197     class ArgumentCompletionListElement;
    198     class CommandEvaluation;
    199     class ConsoleCommand;
    200     class Executor;
    201     template <class T>
    202     class ExecutorMember;
    203     class ExecutorStatic;
    204     class Functor;
    205     template <class O>
    206     class FunctorMember;
    207     typedef FunctorMember<void> FunctorStatic;
    208     template <class F, class O>
    209     class FunctorPointer;
    210     class IOConsole;
    211     class IRC;
    212     class Shell;
    213     class ShellListener;
    214     class TclBind;
    215     struct TclInterpreterBundle;
    216     template <class T>
    217     class TclThreadList;
    218     class TclThreadManager;
    219 
    220     // Input
    221     class BaseCommand;
    222     class BufferedParamCommand;
    223     class Button;
    224     class HalfAxis;
    225     class InputBuffer;
    226     class InputDevice;
    227     template <class Traits>
    228     class InputDeviceTemplated;
    229     class InputHandler;
    230     class InputManager;
    231     class InputState;
    232     struct InputStatePriority;
    233     class JoyStickQuantityListener;
    234     class JoyStick;
    235     class KeyBinder;
    236     class KeyBinderManager;
    237     class Keyboard;
    238     class KeyDetector;
    239     class KeyEvent;
    240     class Mouse;
    241     class ParamCommand;
    242     class SimpleCommand;
    243 }
    244 
    245 #include "command/FunctorPtr.h"
    246 #include "command/ExecutorPtr.h"
    247 
    248 // CppTcl
    249 namespace Tcl
    250 {
    251     class interpreter;
    252     class object;
    253 }
    254 
    255 // Boost
    256 namespace boost
    257 {
    258 #if (BOOST_VERSION < 104400)
    259     namespace filesystem
    260     {
    261         struct path_traits;
    262         template <class String, class Traits> class basic_path;
    263         typedef basic_path<std::string, path_traits> path;
    264     }
    265 #else
    266     namespace filesystem2
    267     {
    268         struct path_traits;
    269         template <class String, class Traits> class basic_path;
    270         typedef basic_path<std::string, path_traits> path;
    271     }
    272     namespace filesystem
    273     {
    274         using filesystem2::basic_path;
    275         using filesystem2::path_traits;
    276         using filesystem2::path;
    277     }
    278 #endif
    279     class thread;
    280     class mutex;
    281     class shared_mutex;
    282     class condition_variable;
    283 }
    284 
    285 // Ogre
    286 namespace Ogre
    287 {
    288     class DataStream;
    289     template <class T> class SharedPtr;
    290     typedef SharedPtr<DataStream> DataStreamPtr;
    291 }
    292 namespace orxonox
    293 {
    294     // Import the Ogre::DataStream
    295     using Ogre::DataStream;
    296     using Ogre::DataStreamPtr;
    297 }
    298 
    299 // CEGUI
    300 namespace CEGUI
    301 {
    302     class DefaultLogger;
    303     class Logger;
    304     class LuaScriptModule;
    305 
    306     class OgreCEGUIRenderer;
    307     class OgreCEGUIResourceProvider;
    308     class OgreCEGUITexture;
    309 }
    310 
    311 // Lua
    312 struct lua_State;
    313 
    314 // TinyXML and TinyXML++
    315 class TiXmlString;
    316 class TiXmlOutStream;
    317 class TiXmlNode;
    318 class TiXmlHandle;
    319 class TiXmlDocument;
    320 class TiXmlElement;
    321 class TiXmlComment;
    322 class TiXmlUnknown;
    323 class TiXmlAttribute;
    324 class TiXmlText;
    325 class TiXmlDeclaration;
    326 class TiXmlParsingData;
    327 namespace ticpp
    328 {
    329     class Document;
    330     class Element;
    331     class Declaration;
    332     class StylesheetReference;
    333     class Text;
    334     class Comment;
    335     class Attribute;
    336 }
    337 namespace orxonox
    338 {
    339     using ticpp::Element;
    34077}
    34178
  • sandbox_qt/src/libraries/core/Game.cc

    r7284 r7421  
    3636
    3737#include <exception>
    38 #include <boost/weak_ptr.hpp>
    39 #include <loki/ScopeGuard.h>
    4038
    41 #include "util/Clock.h"
    4239#include "util/Debug.h"
    4340#include "util/Exception.h"
    4441#include "util/Sleep.h"
    45 #include "util/SubString.h"
    46 #include "CommandLineParser.h"
    4742#include "Core.h"
    48 #include "CoreIncludes.h"
    49 #include "ConfigValueIncludes.h"
    50 #include "GameMode.h"
    51 #include "GameState.h"
    52 #include "GUIManager.h"
    53 #include "command/ConsoleCommand.h"
    5443
    5544namespace orxonox
    5645{
    57     static void stop_game()
    58         { Game::getInstance().stop(); }
    59     SetConsoleCommand("exit", &stop_game);
    60     static void printFPS()
    61         { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
    62     SetConsoleCommand("printFPS", &printFPS);
    63     static void printTickTime()
    64         { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
    65     SetConsoleCommand("printTickTime", &printTickTime);
    66 
    67     std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
    6846    Game* Game::singletonPtr_s = 0;
    6947
    70     //! Represents one node of the game state tree.
    71     struct GameStateTreeNode
    72     {
    73         std::string name_;
    74         weak_ptr<GameStateTreeNode> parent_;
    75         std::vector<shared_ptr<GameStateTreeNode> > children_;
    76     };
    77 
    7848    Game::Game(const std::string& cmdLine)
    79         // Destroy factories before the Core!
    80         : gsFactoryDestroyer_(Game::GameStateFactory::getFactories(), &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
    8149    {
    8250        this->bAbort_ = false;
    83         bChangingState_ = false;
    84 
    85 #ifdef ORXONOX_PLATFORM_WINDOWS
    86         minimumSleepTime_ = 1000/*us*/;
    87 #else
    88         minimumSleepTime_ = 0/*us*/;
    89 #endif
    90 
    91         // reset statistics
    92         this->statisticsStartTime_ = 0;
    93         this->statisticsTickTimes_.clear();
    94         this->periodTickTime_ = 0;
    95         this->periodTime_ = 0;
    96         this->avgFPS_ = 0.0f;
    97         this->avgTickTime_ = 0.0f;
    98         this->excessSleepTime_ = 0;
    99 
    100         // Create an empty root state
    101         this->declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
    102 
    103         // Set up a basic clock to keep time
    104         this->gameClock_.reset(new Clock());
    10551
    10652        // Create the Core
    10753        this->core_.reset(new Core(cmdLine));
    108 
    109         // Do this after the Core creation!
    110         ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);
    111         this->setConfigValues();
    112 
    113         // After the core has been created, we can safely instantiate the GameStates that don't require graphics
    114         for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
    115             it != gameStateDeclarations_s.end(); ++it)
    116         {
    117             if (!it->second.bGraphicsMode)
    118                 constructedStates_[it->second.stateName] = GameStateFactory::fabricate(it->second);
    119         }
    120 
    121         // The empty root state is ALWAYS loaded!
    122         this->rootStateNode_ = shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
    123         this->rootStateNode_->name_ = "emptyRootGameState";
    124         this->loadedTopStateNode_ = this->rootStateNode_;
    125         this->loadedStates_.push_back(this->getState(rootStateNode_->name_));
    12654    }
    12755
    12856    /**
    12957    @brief
    130         All destruction code is handled by scoped_ptrs and SimpleScopeGuards.
     58        All destruction code is handled by QScopedPointers.
    13159    */
    13260    Game::~Game()
    13361    {
    134         // Remove us from the object lists again to avoid problems when destroying them
    135         this->unregisterObject();
    13662    }
    13763
    13864    void Game::setConfigValues()
    13965    {
     66        /*
    14067        SetConfigValue(statisticsRefreshCycle_, 250000)
    14168            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     
    14471        SetConfigValue(fpsLimit_, 50)
    14572            .description("Sets the desired frame rate (0 for no limit).");
     73        */
    14674    }
    14775
     
    14977    @brief
    15078        Main loop of the orxonox game.
    151     @note
    152         We use the Ogre::Timer to measure time since it uses the most precise
    153         method an any platform (however the windows timer lacks time when under
    154         heavy kernel load!).
    15579    */
    15680    void Game::run()
    15781    {
    158         if (this->requestedStateNodes_.empty())
    159             COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
    160 
    161         // START GAME
    162         // first delta time should be about 0 seconds
    163         this->gameClock_->capture();
    164         // A first item is required for the fps limiter
    165         StatisticsTickInfo tickInfo = {0, 0};
    166         statisticsTickTimes_.push_back(tickInfo);
    167         while (!this->bAbort_ && (!this->loadedStates_.empty() || this->requestedStateNodes_.size() > 0))
     82        while (!this->bAbort_)
    16883        {
    169             // Generate the dt
    170             this->gameClock_->capture();
    171 
    172             // Statistics init
    173             StatisticsTickInfo tickInfo = {gameClock_->getMicroseconds(), 0};
    174             statisticsTickTimes_.push_back(tickInfo);
    175             this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
    176 
    177             // Update the GameState stack if required
    178             this->updateGameStateStack();
    179 
    180             // Core preUpdate
    18184            try
    182                 { this->core_->preUpdate(*this->gameClock_); }
    183             catch (...)
    184             {
    185                 COUT(0) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << std::endl;
    186                 COUT(0) << "This should really never happen! Closing the program." << std::endl;
    187                 this->stop();
    188                 break;
    189             }
    190 
    191             // Update the GameStates bottom up in the stack
    192             this->updateGameStates();
    193 
    194             // Core postUpdate
    195             try
    196                 { this->core_->postUpdate(*this->gameClock_); }
     85                { this->core_->update(); }
    19786            catch (...)
    19887            {
     
    20291                break;
    20392            }
    204 
    205             // Evaluate statistics
    206             this->updateStatistics();
    207 
    208             // Limit frame rate
    209             this->updateFPSLimiter();
    21093        }
    211 
    212         // UNLOAD all remaining states
    213         while (this->loadedStates_.size() > 1)
    214             this->unloadState(this->loadedStates_.back()->getName());
    215         this->loadedTopStateNode_ = this->rootStateNode_;
    216         this->requestedStateNodes_.clear();
    217     }
    218 
    219     void Game::updateGameStateStack()
    220     {
    221         while (this->requestedStateNodes_.size() > 0)
    222         {
    223             shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
    224             assert(this->loadedTopStateNode_);
    225             if (!this->loadedTopStateNode_->parent_.expired() && requestedStateNode == this->loadedTopStateNode_->parent_.lock())
    226                 this->unloadState(loadedTopStateNode_->name_);
    227             else // has to be child
    228             {
    229                 try
    230                 {
    231                     this->loadState(requestedStateNode->name_);
    232                 }
    233                 catch (...)
    234                 {
    235                     COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << std::endl;
    236                     // All scheduled operations have now been rendered inert --> flush them and issue a warning
    237                     if (this->requestedStateNodes_.size() > 1)
    238                         COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
    239                     this->requestedStateNodes_.clear();
    240                     break;
    241                 }
    242             }
    243             this->loadedTopStateNode_ = requestedStateNode;
    244             this->requestedStateNodes_.erase(this->requestedStateNodes_.begin());
    245         }
    246     }
    247 
    248     void Game::updateGameStates()
    249     {
    250         // Note: The first element is the empty root state, which doesn't need ticking
    251         for (GameStateVector::const_iterator it = this->loadedStates_.begin() + 1;
    252             it != this->loadedStates_.end(); ++it)
    253         {
    254             try
    255             {
    256                 // Add tick time for most of the states
    257                 uint64_t timeBeforeTick = 0;
    258                 if ((*it)->getInfo().bIgnoreTickTime)
    259                     timeBeforeTick = this->gameClock_->getRealMicroseconds();
    260                 (*it)->update(*this->gameClock_);
    261                 if ((*it)->getInfo().bIgnoreTickTime)
    262                     this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
    263             }
    264             catch (...)
    265             {
    266                 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << std::endl;
    267                 COUT(1) << "This should really never happen!" << std::endl;
    268                 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
    269                 shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;
    270                 while (current->name_ != (*it)->getName() && current)
    271                     current = current->parent_.lock();
    272                 if (current && current->parent_.lock())
    273                     this->requestState(current->parent_.lock()->name_);
    274                 else
    275                     this->stop();
    276                 break;
    277             }
    278         }
    279     }
    280 
    281     void Game::updateStatistics()
    282     {
    283         // Add the tick time of this frame (rendering time has already been subtracted)
    284         uint64_t currentTime = gameClock_->getMicroseconds();
    285         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
    286         this->statisticsTickTimes_.back().tickLength += (uint32_t)(currentRealTime - currentTime);
    287         this->periodTickTime_ += (uint32_t)(currentRealTime - currentTime);
    288         if (this->periodTime_ > this->statisticsRefreshCycle_)
    289         {
    290             std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
    291             assert(it != this->statisticsTickTimes_.end());
    292             int64_t lastTime = currentTime - this->statisticsAvgLength_;
    293             if (static_cast<int64_t>(it->tickTime) < lastTime)
    294             {
    295                 do
    296                 {
    297                     assert(this->periodTickTime_ >= it->tickLength);
    298                     this->periodTickTime_ -= it->tickLength;
    299                     ++it;
    300                     assert(it != this->statisticsTickTimes_.end());
    301                 } while (static_cast<int64_t>(it->tickTime) < lastTime);
    302                 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
    303             }
    304 
    305             uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
    306             // Why minus 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too low
    307             this->avgFPS_ = -1 + static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
    308             this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
    309 
    310             this->periodTime_ -= this->statisticsRefreshCycle_;
    311         }
    312     }
    313 
    314     void Game::updateFPSLimiter()
    315     {
    316         uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
    317         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
    318         while (currentRealTime < nextTime - minimumSleepTime_)
    319         {
    320             usleep((unsigned long)(nextTime - currentRealTime));
    321             currentRealTime = gameClock_->getRealMicroseconds();
    322         }
    323         // Integrate excess to avoid steady state error
    324         excessSleepTime_ = (int)(currentRealTime - nextTime);
    325         // Anti windup
    326         if (excessSleepTime_ > 50000) // 20ms is about the maximum time Windows would sleep for too long
    327             excessSleepTime_ = 50000;
    32894    }
    32995
     
    33298        this->bAbort_ = true;
    33399    }
    334 
    335     void Game::subtractTickTime(int32_t length)
    336     {
    337         assert(!this->statisticsTickTimes_.empty());
    338         this->statisticsTickTimes_.back().tickLength -= length;
    339         this->periodTickTime_ -= length;
    340     }
    341 
    342 
    343     /***** GameState related *****/
    344 
    345     void Game::requestState(const std::string& name)
    346     {
    347         if (!this->checkState(name))
    348         {
    349             COUT(2) << "Warning: GameState named '" << name << "' doesn't exist!" << std::endl;
    350             return;
    351         }
    352 
    353         if (this->bChangingState_)
    354         {
    355             COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
    356             return;
    357         }
    358 
    359         shared_ptr<GameStateTreeNode> lastRequestedNode;
    360         if (this->requestedStateNodes_.empty())
    361             lastRequestedNode = this->loadedTopStateNode_;
    362         else
    363             lastRequestedNode = this->requestedStateNodes_.back();
    364         if (name == lastRequestedNode->name_)
    365         {
    366             COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;
    367             return;
    368         }
    369 
    370         // Check children first
    371         std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
    372         for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
    373         {
    374             if (lastRequestedNode->children_[i]->name_ == name)
    375             {
    376                 requestedNodes.push_back(lastRequestedNode->children_[i]);
    377                 break;
    378             }
    379         }
    380 
    381         if (requestedNodes.empty())
    382         {
    383             // Check parent and all its grand parents
    384             shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
    385             while (currentNode != NULL)
    386             {
    387                 if (currentNode->name_ == name)
    388                     break;
    389                 currentNode = currentNode->parent_.lock();
    390                 requestedNodes.push_back(currentNode);
    391             }
    392             if (currentNode == NULL)
    393                 requestedNodes.clear();
    394         }
    395 
    396         if (requestedNodes.empty())
    397             COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
    398         else
    399             this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
    400     }
    401 
    402     void Game::requestStates(const std::string& names)
    403     {
    404         SubString tokens(names, ",;", " ");
    405         for (unsigned int i = 0; i < tokens.size(); ++i)
    406             this->requestState(tokens[i]);
    407     }
    408 
    409     void Game::popState()
    410     {
    411         shared_ptr<GameStateTreeNode> lastRequestedNode;
    412         if (this->requestedStateNodes_.empty())
    413             lastRequestedNode = this->loadedTopStateNode_;
    414         else
    415             lastRequestedNode = this->requestedStateNodes_.back();
    416         if (lastRequestedNode != this->rootStateNode_)
    417             this->requestState(lastRequestedNode->parent_.lock()->name_);
    418         else
    419             COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;
    420     }
    421 
    422     shared_ptr<GameState> Game::getState(const std::string& name)
    423     {
    424         GameStateMap::const_iterator it = constructedStates_.find(name);
    425         if (it != constructedStates_.end())
    426             return it->second;
    427         else
    428         {
    429             std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name);
    430             if (it != gameStateDeclarations_s.end())
    431                 COUT(1) << "Error: GameState '" << name << "' has not yet been loaded." << std::endl;
    432             else
    433                 COUT(1) << "Error: Could not find GameState '" << name << "'." << std::endl;
    434             return shared_ptr<GameState>();
    435         }
    436     }
    437 
    438     void Game::setStateHierarchy(const std::string& str)
    439     {
    440         // Split string into pieces of the form whitespacesText
    441         std::vector<std::pair<std::string, int> > stateStrings;
    442         size_t pos = 0;
    443         size_t startPos = 0;
    444         while (pos < str.size())
    445         {
    446             int indentation = 0;
    447             while (pos < str.size() && str[pos] == ' ')
    448                 ++indentation, ++pos;
    449             startPos = pos;
    450             while (pos < str.size() && str[pos] != ' ')
    451                 ++pos;
    452             stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
    453         }
    454         if (stateStrings.empty())
    455             ThrowException(GameState, "Emtpy GameState hierarchy provided, terminating.");
    456         // Add element with large identation to detect the last with just an iterator
    457         stateStrings.push_back(std::make_pair("", -1));
    458 
    459         // Parse elements recursively
    460         std::vector<std::pair<std::string, int> >::const_iterator begin = stateStrings.begin();
    461         parseStates(begin, this->rootStateNode_);
    462     }
    463 
    464     /*** Internal ***/
    465 
    466     void Game::parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode)
    467     {
    468         SubString tokens(it->first, ",");
    469         std::vector<std::pair<std::string, int> >::const_iterator startIt = it;
    470 
    471         for (unsigned int i = 0; i < tokens.size(); ++i)
    472         {
    473             it = startIt; // Reset iterator to the beginning of the sub tree
    474             if (!this->checkState(tokens[i]))
    475                 ThrowException(GameState, "GameState with name '" << tokens[i] << "' not found!");
    476             if (tokens[i] == this->rootStateNode_->name_)
    477                 ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
    478             shared_ptr<GameStateTreeNode> node(new GameStateTreeNode());
    479             node->name_ = tokens[i];
    480             node->parent_ = currentNode;
    481             currentNode->children_.push_back(node);
    482 
    483             int currentLevel = it->second;
    484             ++it;
    485             while (it->second != -1)
    486             {
    487                 if (it->second <= currentLevel)
    488                     break;
    489                 else if (it->second == currentLevel + 1)
    490                     parseStates(it, node);
    491                 else
    492                     ThrowException(GameState, "Indentation error while parsing the hierarchy.");
    493             }
    494         }
    495     }
    496 
    497     void Game::loadGraphics()
    498     {
    499         if (!GameMode::showsGraphics())
    500         {
    501             core_->loadGraphics();
    502             Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
    503 
    504             // Construct all the GameStates that require graphics
    505             for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
    506                 it != gameStateDeclarations_s.end(); ++it)
    507             {
    508                 if (it->second.bGraphicsMode)
    509                 {
    510                     // Game state loading failure is serious --> don't catch
    511                     shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);
    512                     if (!constructedStates_.insert(std::make_pair(
    513                         it->second.stateName, gameState)).second)
    514                         assert(false); // GameState was already created!
    515                 }
    516             }
    517             graphicsUnloader.Dismiss();
    518         }
    519     }
    520 
    521     void Game::unloadGraphics()
    522     {
    523         if (GameMode::showsGraphics())
    524         {
    525             // Destroy all the GameStates that require graphics
    526             for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)
    527             {
    528                 if (it->second->getInfo().bGraphicsMode)
    529                     constructedStates_.erase(it++);
    530                 else
    531                     ++it;
    532             }
    533 
    534             core_->unloadGraphics();
    535         }
    536     }
    537 
    538     bool Game::checkState(const std::string& name) const
    539     {
    540         std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name);
    541         if (it == gameStateDeclarations_s.end())
    542             return false;
    543         else
    544             return true;
    545     }
    546 
    547     void Game::loadState(const std::string& name)
    548     {
    549         this->bChangingState_ = true;
    550         LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState);
    551 
    552         // If state requires graphics, load it
    553         Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
    554         if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
    555             this->loadGraphics();
    556         else
    557             graphicsUnloader.Dismiss();
    558 
    559         shared_ptr<GameState> state = this->getState(name);
    560         state->activateInternal();
    561         if (!this->loadedStates_.empty())
    562             this->loadedStates_.back()->activity_.topState = false;
    563         this->loadedStates_.push_back(state);
    564         state->activity_.topState = true;
    565 
    566         graphicsUnloader.Dismiss();
    567     }
    568 
    569     void Game::unloadState(const std::string& name)
    570     {
    571         this->bChangingState_ = true;
    572         try
    573         {
    574             shared_ptr<GameState> state = this->getState(name);
    575             state->activity_.topState = false;
    576             this->loadedStates_.pop_back();
    577             if (!this->loadedStates_.empty())
    578                 this->loadedStates_.back()->activity_.topState = true;
    579             state->deactivateInternal();
    580         }
    581         catch (...)
    582         {
    583             COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << std::endl;
    584             COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
    585         }
    586         // Check if graphics is still required
    587         if (!bAbort_)
    588         {
    589             bool graphicsRequired = false;
    590             for (unsigned i = 0; i < loadedStates_.size(); ++i)
    591                 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
    592             if (!graphicsRequired)
    593                 this->unloadGraphics();
    594         }
    595         this->bChangingState_ = false;
    596     }
    597 
    598     /*static*/ std::map<std::string, shared_ptr<Game::GameStateFactory> >& Game::GameStateFactory::getFactories()
    599     {
    600         static std::map<std::string, shared_ptr<GameStateFactory> > factories;
    601         return factories;
    602     }
    603 
    604     /*static*/ shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info)
    605     {
    606         std::map<std::string, shared_ptr<Game::GameStateFactory> >::const_iterator it = getFactories().find(info.className);
    607         assert(it != getFactories().end());
    608         return it->second->fabricateInternal(info);
    609     }
    610100}
  • sandbox_qt/src/libraries/core/Game.h

    r7401 r7421  
    3939#include "CorePrereqs.h"
    4040
    41 #include <cassert>
    42 #include <list>
    43 #include <map>
    4441#include <string>
    45 #include <vector>
    46 #include <boost/shared_ptr.hpp>
    47 #include <boost/scoped_ptr.hpp>
    48 #include <boost/preprocessor/cat.hpp>
    49 #include <loki/ScopeGuard.h>
     42#include <QScopedPointer>
     43#include "util/Singleton.h"
    5044
    51 #include "util/Debug.h"
    52 #include "util/Singleton.h"
    53 #include "OrxonoxClass.h"
    54 
    55 /**
    56 @brief
    57     Adds a new GameState to the Game. The second parameter is the name as string
    58     and every following paramter is a constructor argument (which is usually non existent)
    59 */
    60 #define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
    61     static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
    62 // tolua_begin
    6345namespace orxonox
    6446{
    65 // tolua_end
    66 
    67     //! Helper object required before GameStates are being constructed
    68     struct GameStateInfo
    69     {
    70         std::string stateName;
    71         std::string className;
    72         bool bIgnoreTickTime;
    73         bool bGraphicsMode;
    74     };
    75 
    7647    /**
    7748    @brief
     
    8051        You should only create this singleton once because it owns the Core class! (see remark there)
    8152    */
    82 // tolua_begin
    83     class _CoreExport Game
    84 // tolua_end
    85         : public Singleton<Game>, public OrxonoxClass
    86     { // tolua_export
     53    class _CoreExport Game : public Singleton<Game>
     54    {
    8755        friend class Singleton<Game>;
    88         typedef std::vector<shared_ptr<GameState> > GameStateVector;
    89         typedef std::map<std::string, shared_ptr<GameState> > GameStateMap;
    90         typedef shared_ptr<GameStateTreeNode> GameStateTreeNodePtr;
    9156
    9257    public:
     
    9661        void setConfigValues();
    9762
    98         void setStateHierarchy(const std::string& str);
    99         shared_ptr<GameState> getState(const std::string& name);
    100 
    10163        void run();
    10264        void stop();
    10365
    104         static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
    105 
    106         void requestState(const std::string& name); //tolua_export
    107         void requestStates(const std::string& names); //tolua_export
    108         void popState(); //tolua_export
    109 
    110         const Clock& getGameClock() { return *this->gameClock_; }
    111 
    112         float getAvgTickTime() { return this->avgTickTime_; }
    113         float getAvgFPS()      { return this->avgFPS_; }
    114 
    115         void subtractTickTime(int32_t length);
    116 
    117         template <class T>
    118         static bool declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bConsoleMode);
    119 
    12066    private:
    121         class _CoreExport GameStateFactory
    122         {
    123         public:
    124             virtual ~GameStateFactory() { }
    125             static shared_ptr<GameState> fabricate(const GameStateInfo& info);
    126             template <class T>
    127             static void createFactory(const std::string& className)
    128                 { getFactories()[className].reset(new TemplateGameStateFactory<T>()); }
    129 
    130             virtual shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;
    131             static std::map<std::string, shared_ptr<GameStateFactory> >& getFactories();
    132         };
    133         template <class T>
    134         class TemplateGameStateFactory : public GameStateFactory
    135         {
    136         public:
    137             shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
    138                 { return shared_ptr<GameState>(new T(info)); }
    139         };
    140         // For the factory destruction
    141         typedef Loki::ObjScopeGuardImpl0<std::map<std::string, shared_ptr<GameStateFactory> >, void (std::map<std::string, shared_ptr<GameStateFactory> >::*)()> ObjScopeGuard;
    142 
    143         struct StatisticsTickInfo
    144         {
    145             uint64_t    tickTime;
    146             uint32_t    tickLength;
    147         };
    148 
    14967        Game(Game&); // don't mess with singletons
    15068
    151         void loadGraphics();
    152         void unloadGraphics();
    153 
    154         void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
    155         bool checkState(const std::string& name) const;
    156         void loadState(const std::string& name);
    157         void unloadState(const std::string& name);
    158 
    159         // Main loop structuring
    160         void updateGameStateStack();
    161         void updateGameStates();
    162         void updateStatistics();
    163         void updateFPSLimiter();
    164 
    165         // ScopeGuard helper function
    166         void resetChangingState() { this->bChangingState_ = false; }
    167 
    168         scoped_ptr<Clock>                  gameClock_;
    169         scoped_ptr<Core>                   core_;
    170         ObjScopeGuard                      gsFactoryDestroyer_;
    171 
    172         GameStateMap                       constructedStates_;
    173         GameStateVector                    loadedStates_;
    174         GameStateTreeNodePtr               rootStateNode_;
    175         GameStateTreeNodePtr               loadedTopStateNode_;
    176         std::vector<GameStateTreeNodePtr>  requestedStateNodes_;
    177 
    178         bool                               bChangingState_;
     69        QScopedPointer<Core>               core_;
    17970        bool                               bAbort_;
    18071
    181         // variables for time statistics
    182         uint64_t                           statisticsStartTime_;
    183         std::list<StatisticsTickInfo>      statisticsTickTimes_;
    184         uint32_t                           periodTime_;
    185         uint32_t                           periodTickTime_;
    186         float                              avgFPS_;
    187         float                              avgTickTime_;
    188         int                                excessSleepTime_;
    189         unsigned int                       minimumSleepTime_;
    190 
    191         // config values
    192         unsigned int                       statisticsRefreshCycle_;
    193         unsigned int                       statisticsAvgLength_;
    194         unsigned int                       fpsLimit_;
    195 
    196         static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
    19772        static Game* singletonPtr_s;        //!< Pointer to the Singleton
    198     }; //tolua_export
    199 
    200     template <class T>
    201     /*static*/ bool Game::declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bGraphicsMode)
    202     {
    203         std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(stateName);
    204         if (it == gameStateDeclarations_s.end())
    205         {
    206             GameStateInfo& info = gameStateDeclarations_s[stateName];
    207             info.stateName = stateName;
    208             info.className = className;
    209             info.bIgnoreTickTime = bIgnoreTickTime;
    210             info.bGraphicsMode = bGraphicsMode;
    211         }
    212         else
    213         {
    214             COUT(0) << "Error: Cannot declare two GameStates with the same name." << std::endl;
    215             COUT(0) << "       Ignoring second one ('" << stateName << "')." << std::endl;
    216         }
    217 
    218         // Create a factory to delay GameState creation
    219         GameStateFactory::createFactory<T>(className);
    220 
    221         // just a required dummy return value
    222         return true;
    223     }
    224 } //tolua_export
     73    };
     74}
    22575
    22676#endif /* _Game_H__ */
  • sandbox_qt/src/libraries/core/PathConfig.cc

    r6417 r7421  
    3333#include <cstdio>
    3434#include <vector>
    35 #include <boost/version.hpp>
    36 #include <boost/filesystem.hpp>
    3735
    3836#ifdef ORXONOX_PLATFORM_WINDOWS
     
    5452#include "util/Debug.h"
    5553#include "util/Exception.h"
    56 #include "CommandLineParser.h"
    57 
    58 // Boost 1.36 has some issues with deprecated functions that have been omitted
    59 #if (BOOST_VERSION == 103600)
    60 #  define BOOST_LEAF_FUNCTION filename
    61 #else
    62 #  define BOOST_LEAF_FUNCTION leaf
    63 #endif
    6454
    6555namespace orxonox
    6656{
    67     namespace bf = boost::filesystem;
    68 
    6957    //! Static pointer to the singleton
    7058    PathConfig* PathConfig::singletonPtr_s  = 0;
    7159
    72     SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
    73     SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    74 
    7560    PathConfig::PathConfig()
    76         : rootPath_(*(new bf::path()))
    77         , executablePath_(*(new bf::path()))
    78         , modulePath_(*(new bf::path()))
    79         , dataPath_(*(new bf::path()))
    80         , externalDataPath_(*(new bf::path()))
    81         , configPath_(*(new bf::path()))
    82         , logPath_(*(new bf::path()))
    83         , bDevRun_(false)
    8461    {
    8562        //////////////////////////
     
    125102#endif
    126103
    127         executablePath_ = bf::path(buffer);
     104        executablePath_ = QDir(buffer);
    128105#ifndef ORXONOX_PLATFORM_APPLE
    129         executablePath_ = executablePath_.branch_path(); // remove executable name
    130 #endif
    131 
    132         /////////////////////
    133         // SET MODULE PATH //
    134         /////////////////////
    135 
    136         if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
     106        executablePath_.cdUp(); // remove executable name
     107#endif
     108
     109        if (executablePath_.exists("orxonox_dev_build.keep_me"))
    137110        {
    138111            COUT(1) << "Running from the build tree." << std::endl;
    139112            PathConfig::bDevRun_ = true;
    140             modulePath_ = specialConfig::moduleDevDirectory;
    141113        }
    142114        else
     
    146118
    147119            // Also set the root path
    148             bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);
     120            QDir relativeExecutablePath(specialConfig::defaultRuntimePath);
    149121            rootPath_ = executablePath_;
    150             while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())
    151                 rootPath_ = rootPath_.branch_path();
    152             if (rootPath_.empty())
    153                 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    154 
    155             // Module path is fixed as well
    156             modulePath_ = rootPath_ / specialConfig::defaultModulePath;
     122            while (rootPath_ / relativeExecutablePath != executablePath_)
     123            {
     124                if (!rootPath_.cdUp())
     125                    ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
     126            }
    157127
    158128#else
    159129
    160130            // There is no root path, so don't set it at all
    161             // Module path is fixed as well
    162             modulePath_ = specialConfig::moduleInstallDirectory;
    163131
    164132#endif
     
    168136    PathConfig::~PathConfig()
    169137    {
    170         delete &rootPath_;
    171         delete &executablePath_;
    172         delete &modulePath_;
    173         delete &dataPath_;
    174         delete &externalDataPath_;
    175         delete &configPath_;
    176         delete &logPath_;
    177138    }
    178139
     
    184145            configPath_       = specialConfig::configDevDirectory;
    185146            logPath_          = specialConfig::logDevDirectory;
    186 
    187             // Check for data path override by the command line
    188             if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
    189                 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
    190             else
    191                 externalDataPath_ = specialConfig::externalDataDevDirectory;
    192147        }
    193148        else
     
    213168            if (userDataPathPtr == NULL)
    214169                ThrowException(General, "Could not retrieve user data path.");
    215             bf::path userDataPath(userDataPathPtr);
     170            QDir userDataPath(userDataPathPtr);
    216171            userDataPath /= ".orxonox";
    217172
     
    223178        }
    224179
    225         // Option to put all the config and log files in a separate folder
    226         if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
    227         {
    228             const std::string& directory(CommandLineParser::getValue("writingPathSuffix").getString());
    229             configPath_ = configPath_ / directory;
    230             logPath_    = logPath_    / directory;
    231         }
    232 
    233180        // Create directories to avoid problems when opening files in non existent folders.
    234         std::vector<std::pair<bf::path, std::string> > directories;
    235         directories.push_back(std::make_pair(bf::path(configPath_), "config"));
    236         directories.push_back(std::make_pair(bf::path(logPath_), "log"));
    237 
    238         for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin();
     181        std::vector<std::pair<QDir, std::string> > directories;
     182        directories.push_back(std::make_pair(QDir(configPath_), "config"));
     183        directories.push_back(std::make_pair(QDir(logPath_), "log"));
     184
     185        for (std::vector<std::pair<QDir, std::string> >::iterator it = directories.begin();
    239186            it != directories.end(); ++it)
    240187        {
    241             if (bf::exists(it->first) && !bf::is_directory(it->first))
     188            if (!it->first.exists())
    242189            {
    243                 ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
    244                                          Please remove " + it->first.string());
    245             }
    246             if (bf::create_directories(it->first)) // function may not return true at all (bug?)
    247             {
     190                if (!it->first.mkpath("."))
     191                    ThrowException(General, std::string("The ") + it->second + " directory could not be created.");
    248192                COUT(4) << "Created " << it->second << " directory" << std::endl;
    249193            }
     
    251195    }
    252196
    253     std::vector<std::string> PathConfig::getModulePaths()
    254     {
    255         std::vector<std::string> modulePaths;
    256 
    257         // We search for helper files with the following extension
    258         const std::string& moduleextension = specialConfig::moduleExtension;
    259         size_t moduleextensionlength = moduleextension.size();
    260 
    261         // Add that path to the PATH variable in case a module depends on another one
    262         std::string pathVariable(getenv("PATH"));
    263         putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));
    264 
    265         // Make sure the path exists, otherwise don't load modules
    266         if (!boost::filesystem::exists(modulePath_))
    267             return modulePaths;
    268 
    269         boost::filesystem::directory_iterator file(modulePath_);
    270         boost::filesystem::directory_iterator end;
    271 
    272         // Iterate through all files
    273         while (file != end)
    274         {
    275             const std::string& filename = file->BOOST_LEAF_FUNCTION();
    276 
    277             // Check if the file ends with the exension in question
    278             if (filename.size() > moduleextensionlength)
    279             {
    280                 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
    281                 {
    282                     // We've found a helper file
    283                     const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
    284                     modulePaths.push_back((modulePath_ / library).file_string());
    285                 }
    286             }
    287             ++file;
    288         }
    289 
    290         return modulePaths;
    291     }
    292 
    293197    /*static*/ std::string PathConfig::getRootPathString()
    294198    {
    295         return getInstance().rootPath_.string() + '/';
     199        return getInstance().rootPath_.path().toStdString() + '/';
    296200    }
    297201
    298202    /*static*/ std::string PathConfig::getExecutablePathString()
    299203    {
    300         return getInstance().executablePath_.string() + '/';
     204        return getInstance().executablePath_.path().toStdString() + '/';
    301205    }
    302206
    303207    /*static*/ std::string PathConfig::getDataPathString()
    304208    {
    305         return getInstance().dataPath_.string() + '/';
    306     }
    307 
    308     /*static*/ std::string PathConfig::getExternalDataPathString()
    309     {
    310         return getInstance().externalDataPath_.string() + '/';
     209        return getInstance().dataPath_.path().toStdString() + '/';
    311210    }
    312211
    313212    /*static*/ std::string PathConfig::getConfigPathString()
    314213    {
    315         return getInstance().configPath_.string() + '/';
     214        return getInstance().configPath_.path().toStdString() + '/';
    316215    }
    317216
    318217    /*static*/ std::string PathConfig::getLogPathString()
    319218    {
    320         return getInstance().logPath_.string() + '/';
    321     }
    322 
    323     /*static*/ std::string PathConfig::getModulePathString()
    324     {
    325         return getInstance().modulePath_.string() + '/';
     219        return getInstance().logPath_.path().toStdString() + '/';
    326220    }
    327221}
  • sandbox_qt/src/libraries/core/PathConfig.h

    r7401 r7421  
    3939#include <string>
    4040#include <vector>
     41#include <QDir>
    4142#include "util/Singleton.h"
    4243
    43 //tolua_begin
    4444namespace orxonox
    4545{
    46 //tolua_end
    4746    /**
    4847    @brief
    4948        The PathConfig class is a singleton used to configure different paths.
    5049    @details
    51         The class provides information about the data, config, log, executable,
    52         root and module path.
     50        The class provides information about the data, config, log, executable
     51        and root path.
    5352        It determines those by the use of platform specific functions.
    5453    @remarks
    5554        Not all paths are always available:
    5655        - root only when installed copyable
    57         - externalData only for development builds in the build tree
    5856    */
    59     class _CoreExport PathConfig //tolua_export
    60         : public Singleton<PathConfig>
    61     { //tolua_export
     57    class _CoreExport PathConfig : public Singleton<PathConfig>
     58    {
    6259        friend class Singleton<PathConfig>;
    6360        friend class Core;
     
    6663            /**
    6764            @brief
    68                 Retrievs the executable path and sets all hard coded fixed paths (currently only the module path)
     65                Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
    6966                Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
    7067                If found it means that this is not an installed run, hence we
     
    7673            ~PathConfig();
    7774
    78             //! Returns the path to the root folder as boost::filesystem::path
    79             static const boost::filesystem::path& getRootPath()
     75            //! Returns the path to the root folder as QDir
     76            static const QDir& getRootPath()
    8077                { return getInstance().rootPath_; }
    81             //! Returns the path to the executable folder as boost::filesystem::path
    82             static const boost::filesystem::path& getExecutablePath()
     78            //! Returns the path to the executable folder as QDir
     79            static const QDir& getExecutablePath()
    8380                { return getInstance().executablePath_; }
    84             //! Returns the path to the data files as boost::filesystem::path
    85             static const boost::filesystem::path& getDataPath()
     81            //! Returns the path to the data files as QDir
     82            static const QDir& getDataPath()
    8683                { return getInstance().dataPath_; }
    87             //! Returns the path to the external data files as boost::filesystem::path
    88             static const boost::filesystem::path& getExternalDataPath()
    89                 { return getInstance().externalDataPath_; }
    90             //! Returns the path to the config files as boost::filesystem::path
    91             static const boost::filesystem::path& getConfigPath()
     84            //! Returns the path to the config files as QDir
     85            static const QDir& getConfigPath()
    9286                { return getInstance().configPath_; }
    93             //! Returns the path to the log files as boost::filesystem::path
    94             static const boost::filesystem::path& getLogPath()
     87            //! Returns the path to the log files as QDir
     88            static const QDir& getLogPath()
    9589                { return getInstance().logPath_; }
    96             //! Returns the path to the modules as boost::filesystem::path
    97             static const boost::filesystem::path& getModulePath()
    98                 { return getInstance().modulePath_; }
    9990
    10091            //! Returns the path to the root folder as std::string
     
    10495            //! Returns the path to the data files as std::string
    10596            static std::string getDataPathString();
    106             //! Returns the path to the external data files as std::string
    107             static std::string getExternalDataPathString();
    10897            //! Returns the path to the config files as std::string
    10998            static std::string getConfigPathString(); //tolua_export
    11099            //! Returns the path to the log files as std::string
    111100            static std::string getLogPathString();
    112             //! Returns the path to the modules as std::string
    113             static std::string getModulePathString();
    114101
    115102            //! Return trrue for runs in the build directory (not installed)
     
    126113            */
    127114            void setConfigurablePaths();
    128             //! Returns a list with all modules declared by a *.module file in the module folder.
    129             std::vector<std::string> getModulePaths();
    130115
    131116            //! Path to the parent directory of the ones above if program was installed with relativ paths
    132             boost::filesystem::path& rootPath_;
    133             boost::filesystem::path& executablePath_;        //!< Path to the executable
    134             boost::filesystem::path& modulePath_;            //!< Path to the modules
    135             boost::filesystem::path& dataPath_;              //!< Path to the data files folder
    136             boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
    137             boost::filesystem::path& configPath_;            //!< Path to the config files folder
    138             boost::filesystem::path& logPath_;               //!< Path to the log files folder
     117            QDir               rootPath_;
     118            QDir               executablePath_;        //!< Path to the executable
     119            QDir               dataPath_;              //!< Path to the data files folder
     120            QDir               configPath_;            //!< Path to the config files folder
     121            QDir               logPath_;               //!< Path to the log files folder
    139122
    140             bool                     bDevRun_;               //!< True for runs in the build directory (not installed)
     123            bool               bDevRun_;               //!< True for runs in the build directory (not installed)
    141124            static PathConfig* singletonPtr_s;
    142125    }; //tolua_export
  • sandbox_qt/src/libraries/util/CMakeLists.txt

    r7284 r7421  
    1919
    2020SET_SOURCE_FILES(UTIL_SRC_FILES
    21   Clock.cc
    2221  Exception.cc
    23   ExprParser.cc
    2422  Math.cc
    25   MultiType.cc
    26   Scope.cc
    2723  StringUtils.cc
    2824COMPILATION_BEGIN StableCompilation.cc
    29   Clipboard.cc
    3025  Convert.cc
    31   CRC32.cc
    3226  OutputHandler.cc
    33   ScopedSingletonManager.cc
    34   SharedPtr.cc
    35   SignalHandler.cc
    3627  Sleep.cc
    37   SmallObjectAllocator.cc
    3828  SubString.cc
    3929COMPILATION_END
    4030)
    4131
    42 IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
    43   # Get around displaying a few hundred lines of warning code
    44   SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w")
    45 ENDIF()
    46 IF(MSVC)
    47   # Simply using #pragma warning(disable:4244) doesn't really disable it
    48   # if the warning occurs in a template in another file
    49   # Hence promote it manually to a higher warning level (4)
    50   SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w44244")
    51 ENDIF()
    52 
    5332ORXONOX_ADD_LIBRARY(util
    5433  FIND_HEADER_FILES
    5534  LINK_LIBRARIES
    56     ${CEGUI_LIBRARY}
    57     ${OGRE_LIBRARY}
     35    ${QT_QTCORE_LIBRARY}
    5836  SOURCE_FILES
    5937    ${UTIL_SRC_FILES}
  • sandbox_qt/src/libraries/util/Exception.cc

    r7401 r7421  
    3535#include "Exception.h"
    3636
    37 #include <CEGUIExceptions.h>
    3837#include "Debug.h"
    3938
     
    9998            return ex.what();
    10099        }
    101         catch (const CEGUI::Exception& ex)
    102         {
    103 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
    104             return GeneralException(ex.getMessage().c_str()).getDescription();
    105 #else
    106             return GeneralException(ex.getMessage().c_str(), ex.getLine(),
    107                 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();
    108 #endif
    109         }
    110100        catch (...)
    111101        {
  • sandbox_qt/src/libraries/util/Math.cc

    r7401 r7421  
    3434#include "Math.h"
    3535
    36 #include <OgrePlane.h>
    37 
    38 #include "MathConvert.h"
    39 #include "SubString.h"
    40 // Do not remove this include, it avoids linker errors.
    41 #include "mbool.h"
    42 
    4336namespace orxonox
    4437{
    45 #if OGRE_VERSION < 0x010603
    46     /**
    47         @brief Function for writing a Radian to a stream.
    48     */
    49     std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian)
    50     {
    51         out << radian.valueRadians();
    52         return out;
    53     }
    54 
    55     /**
    56         @brief Function for writing a Degree to a stream.
    57     */
    58     std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
    59     {
    60         out << degree.valueDegrees();
    61         return out;
    62     }
    63 #endif
    64 
    65     /**
    66         @brief Function for reading a Radian from a stream.
    67     */
    68     std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
    69     {
    70         float temp;
    71         in >> temp;
    72         radian = temp;
    73         return in;
    74     }
    75 
    76     /**
    77         @brief Function for reading a Degree from a stream.
    78     */
    79     std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
    80     {
    81         float temp;
    82         in >> temp;
    83         degree = temp;
    84         return in;
    85     }
    86 
    87 
    88     /**
    89         @brief Gets the angle between my viewing direction and the direction to the position of the other object.
    90         @param myposition My position
    91         @param mydirection My viewing direction
    92         @param otherposition The position of the other object
    93         @return The angle in radian
    94 
    95         Examples:
    96          - If the other object is exactly in front of me, the function returns 0.
    97          - If the other object is exactly behind me, the function returns pi.
    98          - If the other object is exactly right/left to me (or above/below), the function returns pi/2.
    99     */
    100     float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
    101     {
    102         orxonox::Vector3 distance = otherposition - myposition;
    103         float distancelength = distance.length();
    104         if (distancelength == 0)
    105             return 0;
    106         else
    107             return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1));
    108     }
    109 
    110     /**
    111         @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object.
    112         @param myposition My position
    113         @param mydirection My viewing direction
    114         @param myorthonormal My orthonormalvector (pointing upwards through my head)
    115         @param otherposition The position of the other object
    116         @return The viewing direction
    117 
    118         Examples:
    119          - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
    120          - If the other object is exactly at my left, the function returns <tt>Vector2(-1, 0)</tt>.
    121          - If the other object is exactly at my right, the function returns <tt>Vector2(1, 0)</tt>.
    122          - If the other object is only a bit at my right, the function still returns <tt>Vector2(1, 0)</tt>.
    123          - If the other object is exactly above me, the function returns <tt>Vector2(0, 1)</tt>.
    124     */
    125     orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
    126     {
    127         orxonox::Vector3 distance = otherposition - myposition;
    128 
    129         // project difference vector on our plane
    130         orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
    131 
    132         float projectionlength = projection.length();
    133         if (projectionlength == 0)
    134         {
    135             if (myposition.dotProduct(otherposition) >= 0)
    136                 return orxonox::Vector2(0, 0);
    137             else
    138                 return orxonox::Vector2(0, 1);
    139         }
    140 
    141         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
    142         float sin_value = sqrt( 1 - cos_value*cos_value );
    143 
    144         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
    145             return orxonox::Vector2( sin_value, cos_value );
    146         else
    147             return orxonox::Vector2( -sin_value, cos_value );
    148     }
    149 
    150     /**
    151         @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1).
    152         @param myposition My position
    153         @param mydirection My viewing direction
    154         @param myorthonormal My orthonormalvector (pointing upwards through my head)
    155         @param otherposition The position of the other object
    156         @return The viewing direction
    157 
    158         Examples:
    159          - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
    160          - If the other object is exactly at my left, the function returns <tt>Vector2(-0.5, 0)</tt>.
    161          - If the other object is exactly at my right, the function returns <tt>Vector2(0.5, 0)</tt>.
    162          - If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>.
    163          - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>.
    164     */
    165     orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
    166     {
    167         orxonox::Vector3 distance = otherposition - myposition;
    168 
    169         // project difference vector on our plane
    170         orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
    171 
    172         float projectionlength = projection.length();
    173         if (projectionlength == 0)
    174         {
    175             if (myposition.dotProduct(otherposition) >= 0)
    176                 return orxonox::Vector2(0, 0);
    177             else
    178                 return orxonox::Vector2(0, 1);
    179         }
    180         //float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
    181 
    182         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
    183         float sin_value = sqrt( 1 - cos_value*cos_value );
    184 
    185         float distancelength = distance.length();
    186         if (distancelength == 0) return orxonox::Vector2(0, 0);
    187         float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / math::pi;
    188 
    189         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
    190             return orxonox::Vector2( sin_value * radius, cos_value * radius);
    191         else
    192             return orxonox::Vector2( -sin_value * radius, cos_value * radius);
    193     }
    194 
    195     /**
    196         @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.
    197         @param myposition My position
    198         @param projectilespeed The speed of my projectile
    199         @param targetposition The position of my target
    200         @param targetvelocity The velocity of my target
    201         @return The predicted position
    202 
    203         The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss.
    204     */
    205     orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity)
    206     {
    207         float squaredProjectilespeed = projectilespeed * projectilespeed;
    208         orxonox::Vector3 distance = targetposition - myposition;
    209         float a = distance.squaredLength();
    210         float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z);
    211         float c = targetvelocity.squaredLength();
    212 
    213         float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c;
    214         if (temp < 0)
    215             return orxonox::Vector3::ZERO;
    216 
    217         temp = sqrt(temp);
    218         float time = (temp + a) / (2 * (squaredProjectilespeed - b));
    219         return (targetposition + targetvelocity * time);
    220     }
    221 
    22238    /**
    22339        @brief Returns a unique number. This function will never return the same value twice.
     
    22844        return aNumber++;
    22945    }
    230 
    231 
    232     //////////////////////////
    233     // Conversion functions //
    234     //////////////////////////
    235 
    236     // std::string to Vector2
    237     bool ConverterFallback<std::string, orxonox::Vector2>::convert(orxonox::Vector2* output, const std::string& input)
    238     {
    239         size_t opening_parenthesis, closing_parenthesis = input.find('}');
    240         if ((opening_parenthesis = input.find('{')) == std::string::npos)
    241             opening_parenthesis = 0;
    242         else
    243             opening_parenthesis++;
    244 
    245         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
    246                          ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    247         if (tokens.size() >= 2)
    248         {
    249             if (!convertValue(&(output->x), tokens[0]))
    250                 return false;
    251             if (!convertValue(&(output->y), tokens[1]))
    252                 return false;
    253 
    254             return true;
    255         }
    256         return false;
    257     }
    258 
    259     // std::string to Vector3
    260     bool ConverterFallback<std::string, orxonox::Vector3>::convert(orxonox::Vector3* output, const std::string& input)
    261     {
    262         size_t opening_parenthesis, closing_parenthesis = input.find('}');
    263         if ((opening_parenthesis = input.find('{')) == std::string::npos)
    264             opening_parenthesis = 0;
    265         else
    266             opening_parenthesis++;
    267 
    268         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
    269                          ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    270         if (tokens.size() >= 3)
    271         {
    272             if (!convertValue(&(output->x), tokens[0]))
    273                 return false;
    274             if (!convertValue(&(output->y), tokens[1]))
    275                 return false;
    276             if (!convertValue(&(output->z), tokens[2]))
    277                 return false;
    278 
    279             return true;
    280         }
    281         return false;
    282     }
    283 
    284     // std::string to Vector4
    285     bool ConverterFallback<std::string, orxonox::Vector4>::convert(orxonox::Vector4* output, const std::string& input)
    286     {
    287         size_t opening_parenthesis, closing_parenthesis = input.find('}');
    288         if ((opening_parenthesis = input.find('{')) == std::string::npos)
    289             opening_parenthesis = 0;
    290         else
    291             opening_parenthesis++;
    292 
    293         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis),
    294                          ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    295         if (tokens.size() >= 4)
    296         {
    297             if (!convertValue(&(output->x), tokens[0]))
    298                 return false;
    299             if (!convertValue(&(output->y), tokens[1]))
    300                 return false;
    301             if (!convertValue(&(output->z), tokens[2]))
    302                 return false;
    303             if (!convertValue(&(output->w), tokens[3]))
    304                 return false;
    305 
    306             return true;
    307         }
    308         return false;
    309     }
    310 
    311     // std::string to Quaternion
    312     bool ConverterFallback<std::string, orxonox::Quaternion>::convert(orxonox::Quaternion* output, const std::string& input)
    313     {
    314         size_t opening_parenthesis, closing_parenthesis = input.find('}');
    315         if ((opening_parenthesis = input.find('{')) == std::string::npos)
    316             opening_parenthesis = 0;
    317         else
    318             opening_parenthesis++;
    319 
    320         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    321         if (tokens.size() >= 4)
    322         {
    323             if (!convertValue(&(output->w), tokens[0]))
    324                 return false;
    325             if (!convertValue(&(output->x), tokens[1]))
    326                 return false;
    327             if (!convertValue(&(output->y), tokens[2]))
    328                 return false;
    329             if (!convertValue(&(output->z), tokens[3]))
    330                 return false;
    331 
    332             return true;
    333         }
    334         return false;
    335     }
    336 
    337     // std::string to ColourValue
    338     bool ConverterFallback<std::string, orxonox::ColourValue>::convert(orxonox::ColourValue* output, const std::string& input)
    339     {
    340         size_t opening_parenthesis, closing_parenthesis = input.find('}');
    341         if ((opening_parenthesis = input.find('{')) == std::string::npos)
    342             opening_parenthesis = 0;
    343         else
    344             opening_parenthesis++;
    345 
    346         SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
    347         if (tokens.size() >= 3)
    348         {
    349             if (!convertValue(&(output->r), tokens[0]))
    350                 return false;
    351             if (!convertValue(&(output->g), tokens[1]))
    352                 return false;
    353             if (!convertValue(&(output->b), tokens[2]))
    354                 return false;
    355             if (tokens.size() >= 4)
    356             {
    357                 if (!convertValue(&(output->a), tokens[3]))
    358                     return false;
    359             }
    360             else
    361                 output->a = 1.0;
    362 
    363             return true;
    364         }
    365         return false;
    366     }
    36746}
  • sandbox_qt/src/libraries/util/Math.h

    r7401 r7421  
    3535    @file
    3636    @ingroup Math
    37     @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
     37    @brief Declaration and implementation of several math-functions.
    3838*/
    3939
     
    4545#include <string>
    4646#include <cmath>
    47 
    48 #include <OgreMath.h>
    49 #include <OgreVector2.h>
    50 #include <OgreVector3.h>
    51 #include <OgreVector4.h>
    52 #include <OgreQuaternion.h>
    53 #include <OgreColourValue.h>
    5447
    5548// Certain headers might define unwanted macros...
     
    8376    }
    8477
    85 #if OGRE_VERSION < 0x010603
    86     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
    87     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
    88 #endif
    89     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
    90     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
    91 
    92     _UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
    93     _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
    94     _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
    95     _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
    96 
    9778    /**
    9879        @brief Returns the sign of the given value.
     
    177158            return ((x % max) + max);
    178159    }
    179 
    180     /**
    181         @brief Returns a "zero" value for the given type.
    182         @note This is the default template of the zeroise() function. The template is spezialized for each supported type.
    183 
    184         The exact return value of the function depends on the type. For @c int this is 0,
    185         for @c float it's 0.0f. For a @c std::string the function returns "" and for
    186         @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
    187     */
    188     template <typename T>
    189     inline T zeroise()
    190     {
    191         // Default, raise a compiler error without including large boost header cascade.
    192         T temp();
    193         *********temp; // If you reach this code, you abused zeroise()!
    194         return temp;
    195     }
    196 
    197     template <> inline char                 zeroise<char>()                 { return 0; }
    198     template <> inline unsigned char        zeroise<unsigned char>()        { return 0; }
    199     template <> inline short                zeroise<short>()                { return 0; }
    200     template <> inline unsigned short       zeroise<unsigned short>()       { return 0; }
    201     template <> inline int                  zeroise<int>()                  { return 0; }
    202     template <> inline unsigned int         zeroise<unsigned int>()         { return 0; }
    203     template <> inline long                 zeroise<long>()                 { return 0; }
    204     template <> inline unsigned long        zeroise<unsigned long>()        { return 0; }
    205     template <> inline long long            zeroise<long long>()            { return 0; }
    206     template <> inline unsigned long long   zeroise<unsigned long long>()   { return 0; }
    207     template <> inline float                zeroise<float>()                { return 0; }
    208     template <> inline double               zeroise<double>()               { return 0; }
    209     template <> inline long double          zeroise<long double>()          { return 0; }
    210     template <> inline bool                 zeroise<bool>()                 { return 0; }
    211     template <> inline void*                zeroise<void*>()                { return 0; }
    212     template <> inline std::string          zeroise<std::string>()          { return std::string(); }
    213     template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
    214     template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
    215     template <> inline orxonox::Vector2     zeroise<orxonox::Vector2>()     { return orxonox::Vector2    (0, 0)      ; }
    216     template <> inline orxonox::Vector3     zeroise<orxonox::Vector3>()     { return orxonox::Vector3    (0, 0, 0)   ; }
    217     template <> inline orxonox::Vector4     zeroise<orxonox::Vector4>()     { return orxonox::Vector4    (0, 0, 0, 0); }
    218     template <> inline orxonox::ColourValue zeroise<orxonox::ColourValue>() { return orxonox::ColourValue(0, 0, 0, 0); }
    219     template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
    220 
    221     /**
    222         @brief Provides zero value symbols that can be returned as reference
    223         @see zeroise()
    224     */
    225     template <typename T>
    226     struct NilValue
    227     {
    228         inline operator const T&() const
    229         {
    230             return value;
    231         }
    232         static T value;
    233     };
    234     template <typename T>
    235     T NilValue<T>::value = zeroise<T>();
    236160
    237161    /**
     
    297221
    298222    _UtilExport unsigned long getUniqueNumber();
    299 
    300     /**
    301         @brief A Vector class containing two integers @a x and @a y.
    302     */
    303     class IntVector2
    304     {
    305     public:
    306         IntVector2() : x(0), y(0) { }
    307         IntVector2(int _x, int _y) : x(_x), y(_y) { }
    308         int x;
    309         int y;
    310     };
    311 
    312     /**
    313         @brief A Vector class containing three integers @a x, @a y, and @a z.
    314     */
    315     class IntVector3
    316     {
    317     public:
    318         IntVector3() : x(0), y(0), z(0) { }
    319         IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
    320         int x;
    321         int y;
    322         int z;
    323     };
    324223}
    325224
  • sandbox_qt/src/libraries/util/Singleton.h

    r7401 r7421  
    145145
    146146        //! Update method called by ClassSingletonManager (if used)
    147         void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
     147        void preUpdateSingleton() { static_cast<T*>(T::singletonPtr_s)->preUpdate(); }
    148148        //! Empty update method for the static polymorphism
    149         void preUpdate(const Clock& time) { }
     149        void preUpdate() { }
    150150        //! Update method called by ClassSingletonManager (if used)
    151         void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
     151        void postUpdateSingleton() { static_cast<T*>(T::singletonPtr_s)->postUpdate(); }
    152152        //! Empty update method for the static polymorphism
    153         void postUpdate(const Clock& time) { }
     153        void postUpdate() { }
    154154
    155155    protected:
  • sandbox_qt/src/libraries/util/StringUtils.cc

    r7401 r7421  
    3535
    3636#include <cctype>
    37 #include <boost/scoped_array.hpp>
     37#include <QVarLengthArray>
     38#include <QDir>
     39
    3840#include "Convert.h"
    3941#include "Math.h"
     
    493495        size_t cols = str1.size() + 1;
    494496        size_t rows = str2.size() + 1;
    495         boost::scoped_array<int> matrix(new int[rows * cols]);
     497        QVarLengthArray<int> matrix(rows * cols);
    496498
    497499        for (size_t r = 0; r < rows; ++r)
     
    516518        return matrix[(rows-1)*cols + cols-1];
    517519    }
     520
     521    QDir& operator/=(QDir& lhs, const QDir& rhs)
     522    {
     523        lhs.setPath(lhs.path() + QDir::separator() + rhs.path());
     524        return lhs;
     525    }
     526
     527    QDir& operator/=(QDir& lhs, const QString& rhs)
     528    {
     529        return operator/=(lhs, QDir(rhs));
     530    }
     531
     532    QDir operator/(const QDir& lhs, const QDir& rhs)
     533    {
     534        return (QDir(lhs) /= rhs);
     535    }
     536
     537    QDir operator/(const QDir& lhs, const QString& rhs)
     538    {
     539        return operator/(lhs, QDir(rhs));
     540    }
    518541}
  • sandbox_qt/src/libraries/util/UtilPrereqs.h

    r6417 r7421  
    5959
    6060//-----------------------------------------------------------------------
    61 // Enums
    62 //-----------------------------------------------------------------------
    63 
    64 namespace orxonox
    65 {
    66     namespace ScopeID
    67     {
    68         //!A list of available scopes for the Scope template.
    69         enum Value
    70         {
    71             Root,
    72             Graphics
    73         };
    74     }
    75 }
    76 
    77 //-----------------------------------------------------------------------
    7861// Forward declarations
    7962//-----------------------------------------------------------------------
     
    8164namespace orxonox
    8265{
    83     class Clock;
    8466    class Exception;
    85     class ExprParser;
    86     class IntVector2;
    87     class IntVector3;
    88     class MultiType;
    8967    class OutputHandler;
    9068    class OutputListener;
    91     template <ScopeID::Value>
    92     class Scope;
    93     template <class, ScopeID::Value>
    94     class ScopedSingleton;
    95     class ScopeListener;
    96     class SignalHandler;
    9769    template <class T>
    9870    class Singleton;
    9971    class SubString;
    100 }
    101 
    102 namespace Ogre
    103 {
    104     class Radian;
    105     class Degree;
    106     class Vector2;
    107     class Vector3;
    108     class Vector4;
    109     class Matrix3;
    110     class Matrix4;
    111     class Quaternion;
    112     class ColourValue;
    113 }
    114 namespace orxonox
    115 {
    116     using Ogre::Radian;
    117     using Ogre::Degree;
    118     using Ogre::Vector2;
    119     using Ogre::Vector3;
    120     using Ogre::Vector4;
    121     using Ogre::Matrix3;
    122     using Ogre::Matrix4;
    123     using Ogre::Quaternion;
    124     using Ogre::ColourValue;
    12572}
    12673
     
    13178}
    13279
     80class QDir;
     81class QString;
     82
    13383// Just so you don't have to include StringUtils.h everywhere just for this
    13484namespace orxonox
     
    13787}
    13888
     89//-----------------------------------------------------------------------
     90// Functions (implementations in StringUtils.cc)
     91//-----------------------------------------------------------------------
     92
     93namespace orxonox
     94{
     95    _UtilExport QDir& operator/=(QDir& lhs, const QDir& rhs);
     96    _UtilExport QDir& operator/=(QDir& lhs, const QString& rhs);
     97    _UtilExport QDir operator/(const QDir& lhs, const QDir& rhs);
     98    _UtilExport QDir operator/(const QDir& lhs, const QString& rhs);
     99}
    139100
    140101#endif /* _UtilPrereqs_H__ */
  • sandbox_qt/src/orxonox-main.vcproj.user.in

    r5744 r7421  
    1111                        <DebugSettings
    1212                                WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
    13                                 Environment="Path=${RUNTIME_LIBRARY_DIRECTORY}"
     13                                Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
    1414                                EnvironmentMerge="true"
    1515                        />
     
    2020                        <DebugSettings
    2121                                WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
    22                                 Environment="Path=${RUNTIME_LIBRARY_DIRECTORY}"
     22                                Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
    2323                                EnvironmentMerge="true"
    2424                        />
     
    2929                        <DebugSettings
    3030                                WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
    31                                 Environment="Path=${RUNTIME_LIBRARY_DIRECTORY}"
     31                                Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
    3232                                EnvironmentMerge="true"
    3333                        />
     
    3838                        <DebugSettings
    3939                                WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
    40                                 Environment="Path=${RUNTIME_LIBRARY_DIRECTORY}"
     40                                Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
    4141                                EnvironmentMerge="true"
    4242                        />
  • sandbox_qt/src/orxonox/CMakeLists.txt

    r7401 r7421  
    2424
    2525SET_SOURCE_FILES(ORXONOX_SRC_FILES
    26   Level.cc
    27   LevelManager.cc
    2826  Main.cc
    29   MoodManager.cc
    30   PawnManager.cc
    31   PlayerManager.cc
    32   Radar.cc
    33   ChatHistory.cc
    34   ChatInputHandler.cc
    35 #  Test.cc
    36 COMPILATION_BEGIN SceneCompilation.cc
    37   CameraManager.cc
    38   Scene.cc
    39 COMPILATION_END
    4027)
    4128
    42 ADD_SUBDIRECTORY(collisionshapes)
    43 ADD_SUBDIRECTORY(controllers)
    44 ADD_SUBDIRECTORY(gamestates)
    45 ADD_SUBDIRECTORY(gametypes)
    46 ADD_SUBDIRECTORY(graphics)
    47 ADD_SUBDIRECTORY(infos)
    48 ADD_SUBDIRECTORY(interfaces)
    49 ADD_SUBDIRECTORY(items)
    50 ADD_SUBDIRECTORY(overlays)
    51 ADD_SUBDIRECTORY(pickup)
    52 ADD_SUBDIRECTORY(sound)
    53 ADD_SUBDIRECTORY(weaponsystem)
    54 ADD_SUBDIRECTORY(worldentities)
     29#ADD_SUBDIRECTORY(subdir)
    5530
    5631ORXONOX_ADD_LIBRARY(orxonox
    5732  FIND_HEADER_FILES
    58   TOLUA_FILES
    59     ChatInputHandler.h
    60     LevelManager.h
    61     MoodManager.h
    62     controllers/HumanController.h
    63     interfaces/Pickupable.h
    64     infos/PlayerInfo.h
    65     sound/SoundManager.h
    66   PCH_FILE
    67     OrxonoxPrecompiledHeaders.h
    6833  LINK_LIBRARIES
    69     ${Boost_FILESYSTEM_LIBRARY}
    70     ${Boost_SYSTEM_LIBRARY} # Filesystem dependency
    71     ${Boost_THREAD_LIBRARY}
    72     ${Boost_DATE_TIME_LIBRARY} # Thread dependency
    73     ${OGRE_LIBRARY}
    74     ${OPENAL_LIBRARY}
    75     ${ALUT_LIBRARY}
    76     ${VORBISFILE_LIBRARY}
    77     ${VORBIS_LIBRARY}
    78     ${OGG_LIBRARY}
    79     tinyxml_orxonox
    80     tolua_orxonox
    81     bullet_orxonox
     34    ${QT_QTCORE_LIBRARY}
    8235    util
    8336    core
    84     network
    85     tools
    8637  SOURCE_FILES ${ORXONOX_SRC_FILES}
    8738)
  • sandbox_qt/src/orxonox/Main.cc

    r7401 r7421  
    3636#include "OrxonoxPrereqs.h"
    3737
    38 #include "core/CommandLineParser.h"
    3938#include "core/Game.h"
    40 #include "core/LuaState.h"
    41 #include "ToluaBindOrxonox.h"
    42 #include "ToluaBindNetwork.h"
    4339#include "Main.h"
    44 
    45 DeclareToluaInterface(Orxonox);
    46 DeclareToluaInterface(Network);
    4740
    4841namespace orxonox
    4942{
    50     SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
    51     SetCommandLineSwitch(server).information("Start in server mode");
    52     SetCommandLineSwitch(client).information("Start in client mode");
    53     SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
    54     SetCommandLineSwitch(standalone).information("Start in standalone mode");
    55     SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode");
    56 
    57     SetCommandLineArgument(generateDoc, "")
    58         .information("Generates a Doxygen file from things like SetConsoleCommand");
    59 
    6043    /**
    6144    @brief
     
    6649        Game* game = new Game(strCmdLine);
    6750
    68         if (CommandLineParser::getValue("generateDoc").getString().empty())
    69         {
    70             game->setStateHierarchy(
    71             "root"
    72             " graphics"
    73             "  mainMenu"
    74             "  standalone,server,client"
    75             "   level"
    76             " server,client"
    77             "  level"
    78             );
    79 
    80             game->requestState("root");
    81 
    82             // Some development hacks (not really, but in the future, these calls won't make sense anymore)
    83             if (CommandLineParser::getValue("standalone").getBool())
    84                 Game::getInstance().requestStates("graphics, standalone, level");
    85             else if (CommandLineParser::getValue("server").getBool())
    86                 Game::getInstance().requestStates("graphics, server, level");
    87             else if (CommandLineParser::getValue("client").getBool())
    88                 Game::getInstance().requestStates("graphics, client, level");
    89             else if (CommandLineParser::getValue("dedicated").getBool())
    90                 Game::getInstance().requestStates("server, level");
    91             else if (CommandLineParser::getValue("dedicatedClient").getBool())
    92                 Game::getInstance().requestStates("client, level");
    93             else
    94             {
    95                 if (!CommandLineParser::getValue("console").getBool())
    96                     Game::getInstance().requestStates("graphics, mainMenu");
    97             }
    98 
    99             game->run();
    100         }
     51        //if (CommandLineParser::getValue("generateDoc").getString().empty())
     52        //    game->run();
    10153
    10254        delete game;
  • sandbox_qt/src/orxonox/OrxonoxPrereqs.h

    r7163 r7421  
    3737
    3838#include "OrxonoxConfig.h"
    39 #include "tools/ToolsPrereqs.h"
    4039
    4140//-----------------------------------------------------------------------
     
    6564namespace orxonox
    6665{
    67     class CameraManager;
    68     class Level;
    69     class LevelManager;
    70     class PawnManager;
    71     class PlayerManager;
    72     class Radar;
    73     class Scene;
    74 
    75     // collisionshapes
    76     class CollisionShape;
    77     class CompoundCollisionShape;
    78     class WorldEntityCollisionShape;
    79 
    80     // controllers
    81     class AIController;
    82     class ArtificialController;
    83     class Controller;
    84     class DroneController;
    85     class HumanController;
    86     class ScriptController;
    87     class WaypointController;
    88     class WaypointPatrolController;
    89 
    90     // gametypes
    91     class Asteroids;
    92     class Deathmatch;
    93     class Dynamicmatch;
    94     class Gametype;
    95     class TeamBaseMatch;
    96     class TeamDeathmatch;
    97     class UnderAttack;
    98 
    99     // graphics
    100     class Backlight;
    101     class Billboard;
    102     class BlinkingBillboard;
    103     class Camera;
    104     class FadingBillboard;
    105     class GlobalShader;
    106     class Light;
    107     class Model;
    108     class ParticleEmitter;
    109     class ParticleSpawner;
    110 
    111     // infos
    112     class Bot;
    113     class GametypeInfo;
    114     class HumanPlayer;
    115     class Info;
    116     class PlayerInfo;
    117 
    118     // interfaces
    119     class GametypeMessageListener;
    120     class NotificationListener;
    121     class Pickupable;
    122     class PickupCarrier;
    123     class PlayerTrigger;
    124     class RadarListener;
    125     class RadarViewable;
    126     class Rewardable;
    127     class TeamColourable;
    128 
    129     // items
    130     class Engine;
    131     class Item;
    132     class MultiStateEngine;
    133 
    134     // overlays
    135     class InGameConsole;
    136     class Map;
    137     class OrxonoxOverlay;
    138     class OverlayGroup;
    139 
    140     // pickup
    141     class PickupIdentifier;
    142 
    143     //sound
    144     class AmbientSound;
    145     class BaseSound;
    146     class SoundBuffer;
    147     class SoundManager;
    148     class SoundStreamer;
    149     class WorldSound;
    150 
    151     // weaponsystem
    152     class DefaultWeaponmodeLink;
    153     class Munition;
    154     class Weapon;
    155     class WeaponMode;
    156     class WeaponPack;
    157     class WeaponSet;
    158     class WeaponSlot;
    159     class WeaponSystem;
    160 
    161     // worldentities
    162     class BigExplosion;
    163     class CameraPosition;
    164     class ControllableEntity;
    165     class Drone;
    166     class EffectContainer;
    167     class ExplosionChunk;
    168     class MobileEntity;
    169     class MovableEntity;
    170     class SpawnPoint;
    171     class StaticEntity;
    172     class TeamSpawnPoint;
    173     class WorldEntity;
    174     class Rocket;
    175     // worldentities, pawns
    176     class Destroyer;
    177     class Pawn;
    178     class SpaceShip;
    179     class Spectator;
    180     class TeamBaseMatchBase;
    18166}
    18267
    183 // Bullet Physics Engine
    184 class btTransform;
    185 class btVector3;
    186 
    187 class btRigidBody;
    188 class btCollisionObject;
    189 class btGhostObject;
    190 class btManifoldPoint;
    191 
    192 class btCollisionShape;
    193 class btSphereShape;
    194 class btCompoundShape;
    195 class btStaticPlaneShape;
    196 
    197 class btDiscreteDynamicsWorld;
    198 class bt32BitAxisSweep3;
    199 class btDefaultCollisionConfiguration;
    200 class btCollisionDispatcher;
    201 class btSequentialImpulseConstraintSolver;
    202 
    203 // ALUT
    204 typedef struct ALCcontext_struct ALCcontext;
    205 typedef struct ALCdevice_struct ALCdevice;
    206 typedef unsigned int ALuint;
    207 typedef int ALint;
    208 typedef int ALenum;
    209 
    21068#endif /* _OrxonoxPrereqs_H__ */
Note: See TracChangeset for help on using the changeset viewer.