[Orxonox-commit 970] r5693 - in code/trunk: . cmake src src/core src/network src/orxonox src/orxonox/gamestates src/orxonox/interfaces src/orxonox/objects src/orxonox/objects/controllers src/orxonox/objects/gametypes src/orxonox/objects/items src/orxonox/objects/pickup src/orxonox/objects/quest src/orxonox/objects/quest/notifications src/orxonox/objects/weaponsystem src/orxonox/objects/weaponsystem/munitions src/orxonox/objects/weaponsystem/projectiles src/orxonox/objects/weaponsystem/weaponmodes src/orxonox/objects/worldentities src/orxonox/objects/worldentities/triggers src/orxonox/overlays src/orxonox/overlays/debug src/orxonox/overlays/hud src/orxonox/overlays/stats src/orxonox/sound src/orxonox/tools src/orxonox/tools/interfaces src/util
landauf at orxonox.net
landauf at orxonox.net
Sat Aug 29 22:19:40 CEST 2009
Author: landauf
Date: 2009-08-29 22:19:38 +0200 (Sat, 29 Aug 2009)
New Revision: 5693
Added:
code/trunk/src/core/DynLib.cc
code/trunk/src/core/DynLib.h
code/trunk/src/core/DynLibManager.cc
code/trunk/src/core/DynLibManager.h
code/trunk/src/orxonox/InGameConsole.cc
code/trunk/src/orxonox/InGameConsole.h
code/trunk/src/orxonox/Main.h
code/trunk/src/orxonox/Map.cc
code/trunk/src/orxonox/Map.h
code/trunk/src/orxonox/Orxonox.cc
code/trunk/src/orxonox/gamestates/GameStatesPrereqs.h
code/trunk/src/orxonox/interfaces/NotificationListener.h
code/trunk/src/orxonox/objects/quest/QuestPrereqs.h
code/trunk/src/orxonox/objects/quest/notifications/
code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt
code/trunk/src/orxonox/objects/quest/notifications/Notification.cc
code/trunk/src/orxonox/objects/quest/notifications/Notification.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h
code/trunk/src/orxonox/objects/weaponsystem/WeaponsystemPrereqs.h
code/trunk/src/orxonox/orxonox-main.vcproj.user.in
code/trunk/src/orxonox/overlays/OverlaysPrereqs.h
code/trunk/src/orxonox/tools/ToolsPrereqs.h
code/trunk/src/orxonox/tools/interfaces/
code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt
code/trunk/src/orxonox/tools/interfaces/Tickable.h
code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h
code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc
code/trunk/src/util/Scope.cc
code/trunk/src/util/Scope.h
code/trunk/src/util/ScopedSingleton.h
Removed:
code/trunk/src/orxonox/interfaces/Tickable.h
code/trunk/src/orxonox/interfaces/TimeFactorListener.h
code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt
code/trunk/src/orxonox/objects/quest/notifications/Notification.cc
code/trunk/src/orxonox/objects/quest/notifications/Notification.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h
code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc
code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h
code/trunk/src/orxonox/orxonox.vcproj.user.in
code/trunk/src/orxonox/overlays/console/
code/trunk/src/orxonox/overlays/map/
code/trunk/src/orxonox/overlays/notifications/
code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt
code/trunk/src/orxonox/tools/interfaces/Tickable.h
code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h
code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc
Modified:
code/trunk/
code/trunk/cmake/BuildConfig.cmake
code/trunk/cmake/TargetUtilities.cmake
code/trunk/src/SpecialConfig.h.in
code/trunk/src/core/CMakeLists.txt
code/trunk/src/core/Core.cc
code/trunk/src/core/Core.h
code/trunk/src/core/CorePrereqs.h
code/trunk/src/core/GUIManager.h
code/trunk/src/core/Game.cc
code/trunk/src/core/Game.h
code/trunk/src/core/TclThreadList.h
code/trunk/src/core/Thread.cc
code/trunk/src/core/Thread.h
code/trunk/src/core/ThreadPool.cc
code/trunk/src/core/ThreadPool.h
code/trunk/src/network/TODO
code/trunk/src/orxonox/CMakeLists.txt
code/trunk/src/orxonox/Main.cc
code/trunk/src/orxonox/OrxonoxPrereqs.h
code/trunk/src/orxonox/PawnManager.h
code/trunk/src/orxonox/gamestates/CMakeLists.txt
code/trunk/src/orxonox/gamestates/GSClient.cc
code/trunk/src/orxonox/gamestates/GSClient.h
code/trunk/src/orxonox/gamestates/GSDedicated.h
code/trunk/src/orxonox/gamestates/GSGraphics.cc
code/trunk/src/orxonox/gamestates/GSGraphics.h
code/trunk/src/orxonox/gamestates/GSIOConsole.h
code/trunk/src/orxonox/gamestates/GSLevel.cc
code/trunk/src/orxonox/gamestates/GSLevel.h
code/trunk/src/orxonox/gamestates/GSMainMenu.h
code/trunk/src/orxonox/gamestates/GSRoot.cc
code/trunk/src/orxonox/gamestates/GSRoot.h
code/trunk/src/orxonox/gamestates/GSServer.h
code/trunk/src/orxonox/gamestates/GSStandalone.h
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
code/trunk/src/orxonox/interfaces/RadarViewable.cc
code/trunk/src/orxonox/objects/Radar.h
code/trunk/src/orxonox/objects/Scene.h
code/trunk/src/orxonox/objects/Test.h
code/trunk/src/orxonox/objects/controllers/AIController.h
code/trunk/src/orxonox/objects/controllers/HumanController.cc
code/trunk/src/orxonox/objects/controllers/PongAI.h
code/trunk/src/orxonox/objects/controllers/WaypointController.h
code/trunk/src/orxonox/objects/gametypes/Gametype.h
code/trunk/src/orxonox/objects/items/Engine.h
code/trunk/src/orxonox/objects/pickup/DroppedItem.h
code/trunk/src/orxonox/objects/pickup/PickupSpawner.h
code/trunk/src/orxonox/objects/quest/AddQuest.h
code/trunk/src/orxonox/objects/quest/AddQuestHint.h
code/trunk/src/orxonox/objects/quest/AddReward.h
code/trunk/src/orxonox/objects/quest/CMakeLists.txt
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
code/trunk/src/orxonox/objects/quest/CompleteQuest.h
code/trunk/src/orxonox/objects/quest/FailQuest.h
code/trunk/src/orxonox/objects/quest/GlobalQuest.h
code/trunk/src/orxonox/objects/quest/LocalQuest.h
code/trunk/src/orxonox/objects/quest/Quest.h
code/trunk/src/orxonox/objects/quest/QuestDescription.h
code/trunk/src/orxonox/objects/quest/QuestEffect.h
code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
code/trunk/src/orxonox/objects/quest/QuestHint.h
code/trunk/src/orxonox/objects/quest/QuestItem.h
code/trunk/src/orxonox/objects/quest/QuestListener.h
code/trunk/src/orxonox/objects/quest/QuestManager.cc
code/trunk/src/orxonox/objects/quest/QuestManager.h
code/trunk/src/orxonox/objects/quest/QuestNotification.h
code/trunk/src/orxonox/objects/weaponsystem/CMakeLists.txt
code/trunk/src/orxonox/objects/weaponsystem/MuzzleFlash.h
code/trunk/src/orxonox/objects/weaponsystem/munitions/CMakeLists.txt
code/trunk/src/orxonox/objects/weaponsystem/munitions/FusionMunition.h
code/trunk/src/orxonox/objects/weaponsystem/munitions/LaserMunition.h
code/trunk/src/orxonox/objects/weaponsystem/munitions/ReplenishingMunition.h
code/trunk/src/orxonox/objects/weaponsystem/projectiles/BillboardProjectile.h
code/trunk/src/orxonox/objects/weaponsystem/projectiles/CMakeLists.txt
code/trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.h
code/trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.h
code/trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.h
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/EnergyDrink.h
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/FusionFire.h
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LaserFire.h
code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LightningGun.h
code/trunk/src/orxonox/objects/worldentities/Backlight.h
code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.h
code/trunk/src/orxonox/objects/worldentities/Camera.h
code/trunk/src/orxonox/objects/worldentities/FadingBillboard.h
code/trunk/src/orxonox/objects/worldentities/ForceField.h
code/trunk/src/orxonox/objects/worldentities/MobileEntity.h
code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
code/trunk/src/orxonox/overlays/CMakeLists.txt
code/trunk/src/orxonox/overlays/FadeoutText.h
code/trunk/src/orxonox/overlays/GUIOverlay.cc
code/trunk/src/orxonox/overlays/GUIOverlay.h
code/trunk/src/orxonox/overlays/OverlayText.h
code/trunk/src/orxonox/overlays/debug/CMakeLists.txt
code/trunk/src/orxonox/overlays/debug/DebugFPSText.h
code/trunk/src/orxonox/overlays/debug/DebugRTRText.h
code/trunk/src/orxonox/overlays/hud/AnnounceMessage.h
code/trunk/src/orxonox/overlays/hud/CMakeLists.txt
code/trunk/src/orxonox/overlays/hud/ChatOverlay.h
code/trunk/src/orxonox/overlays/hud/DeathMessage.h
code/trunk/src/orxonox/overlays/hud/GametypeStatus.h
code/trunk/src/orxonox/overlays/hud/HUDBar.h
code/trunk/src/orxonox/overlays/hud/HUDHealthBar.h
code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
code/trunk/src/orxonox/overlays/hud/HUDRadar.h
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
code/trunk/src/orxonox/overlays/hud/HUDTimer.h
code/trunk/src/orxonox/overlays/hud/KillMessage.h
code/trunk/src/orxonox/overlays/hud/PongScore.h
code/trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h
code/trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h
code/trunk/src/orxonox/overlays/stats/CMakeLists.txt
code/trunk/src/orxonox/overlays/stats/CreateLines.h
code/trunk/src/orxonox/overlays/stats/Scoreboard.h
code/trunk/src/orxonox/overlays/stats/Stats.h
code/trunk/src/orxonox/sound/SoundBase.h
code/trunk/src/orxonox/sound/SoundManager.h
code/trunk/src/orxonox/tools/BillboardSet.h
code/trunk/src/orxonox/tools/BulletConversions.h
code/trunk/src/orxonox/tools/CMakeLists.txt
code/trunk/src/orxonox/tools/DynamicLines.h
code/trunk/src/orxonox/tools/DynamicRenderable.h
code/trunk/src/orxonox/tools/Mesh.h
code/trunk/src/orxonox/tools/ParticleInterface.h
code/trunk/src/orxonox/tools/Shader.h
code/trunk/src/orxonox/tools/TextureGenerator.h
code/trunk/src/orxonox/tools/Timer.h
code/trunk/src/util/CMakeLists.txt
Log:
merged libraries branch back to trunk
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
+ /code/branches/libraries:5612-5692
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
Modified: code/trunk/cmake/BuildConfig.cmake
===================================================================
--- code/trunk/cmake/BuildConfig.cmake 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/cmake/BuildConfig.cmake 2009-08-29 20:19:38 UTC (rev 5693)
@@ -30,6 +30,7 @@
SET(DEFAULT_RUNTIME_PATH bin)
SET(DEFAULT_LIBRARY_PATH lib)
SET(DEFAULT_ARCHIVE_PATH lib/static)
+SET(DEFAULT_MODULE_PATH lib/modules)
SET(DEFAULT_DOC_PATH doc)
SET(DEFAULT_MEDIA_PATH media)
SET(DEFAULT_CONFIG_PATH config)
@@ -39,6 +40,7 @@
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
+SET(CMAKE_MODULE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH})
# Do not set doc and media, rather check in the two subdirectories
# whether they concur with the DEFAULT_..._PATH
SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
@@ -69,6 +71,8 @@
MARK_AS_ADVANCED(CMAKE_BUILD_TYPE)
ENDIF()
+# Set the extension of the dynamic modules
+SET(ORXONOX_MODULE_EXTENSION ".module")
################# OGRE Plugins ##################
@@ -131,6 +135,7 @@
SET(ORXONOX_RUNTIME_INSTALL_PATH ${DEFAULT_RUNTIME_PATH})
SET(ORXONOX_LIBRARY_INSTALL_PATH ${DEFAULT_LIBRARY_PATH})
SET(ORXONOX_ARCHIVE_INSTALL_PATH ${DEFAULT_ARCHIVE_PATH})
+ SET(ORXONOX_MODULE_INSTALL_PATH ${DEFAULT_MODULE_PATH})
SET(ORXONOX_DOC_INSTALL_PATH ${DEFAULT_DOC_PATH})
SET(ORXONOX_MEDIA_INSTALL_PATH ${DEFAULT_MEDIA_PATH})
SET(ORXONOX_CONFIG_INSTALL_PATH ${DEFAULT_CONFIG_PATH})
@@ -141,6 +146,7 @@
SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
+ SET(ORXONOX_MODULE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/modules)
SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/orxonox)
# These two paths are user and therefore runtime dependent --> only set relatively
@@ -151,6 +157,7 @@
SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH})
SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
+ SET(ORXONOX_MODULE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MODULE_PATH})
SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH})
# Leave empty because it is user and therefore runtime dependent
@@ -166,7 +173,7 @@
# when building, don't use the install RPATH already
# (but later on when installing)
-SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH to be used when installing
SET(CMAKE_INSTALL_RPATH ${ORXONOX_LIBRARY_INSTALL_PATH})
Modified: code/trunk/cmake/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/TargetUtilities.cmake 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/cmake/TargetUtilities.cmake 2009-08-29 20:19:38 UTC (rev 5693)
@@ -23,6 +23,8 @@
# Adds a library or an executable like ADD_LIBRARY/ADD_EXECUTABLE, but
# accepts a lot more input information. Simply supply the keywords
# described below in any order you wish.
+ # The output is then stored in "_arg_ARGNAME" where ARGNAME is the the
+ # name of the switch or list.
#
# Switches: (when given --> TRUE, FALSE otherwise)
# FIND_HEADER_FILES: Searches the current directory for all header files
@@ -32,9 +34,12 @@
# NO_DLL_INTERFACE: Link statically with MSVC
# NO_SOURCE_GROUPS: Don't create msvc source groups
# STATIC/SHARED: Inherited from ADD_LIBRARY
+ # MODULE: For dynamic module libraries
# WIN32: Inherited from ADD_EXECUTABLE
# PCH_NO_DEFAULT: Do not make precompiled header files default if
# specified with PCH_FILE
+ # NO_INSTALL: Do not install the target at all
+ #
# Lists:
# LINK_LIBRARIES: Redirects to TARGET_LINK_LIBRARIES
# VERSION: Set version to the binary
@@ -43,6 +48,7 @@
# TOLUA_FILES: Files with tolua interface
# PCH_FILE: Precompiled header file
# PCH_EXCLUDE: Source files to be excluded from PCH support
+ # OUTPUT_NAME: If you want a different name than the target name
# Note:
# This function also installs the target!
# Prerequisistes:
@@ -74,9 +80,9 @@
# Specify all possible options (either switch or with add. arguments)
SET(_switches FIND_HEADER_FILES EXCLUDE_FROM_ALL ORXONOX_EXTERNAL
NO_DLL_INTERFACE NO_SOURCE_GROUPS ${_additional_switches}
- PCH_NO_DEFAULT NO_INSTALL)
+ PCH_NO_DEFAULT NO_INSTALL MODULE)
SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES DEFINE_SYMBOL
- TOLUA_FILES PCH_FILE PCH_EXCLUDE)
+ TOLUA_FILES PCH_FILE PCH_EXCLUDE OUTPUT_NAME)
PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
@@ -141,6 +147,13 @@
ENDIF()
ENDIF()
+ # MODULE A
+ # Always create shared libraries
+ IF(_arg_MODULE)
+ SET(_arg_SHARED SHARED)
+ SET(_arg_STATIC)
+ ENDIF()
+
# Add the library/executable
IF("${_target_type}" STREQUAL "LIBRARY")
ADD_LIBRARY(${_target_name} ${_arg_STATIC} ${_arg_SHARED}
@@ -150,6 +163,15 @@
${_${_target_name}_files})
ENDIF()
+ # MODULE B
+ IF (_arg_MODULE)
+ SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Windows
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix
+ )
+ ADD_MODULE(${_target_name})
+ ENDIF()
+
# LINK_LIBRARIES
IF(_arg_LINK_LIBRARIES)
TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBRARIES})
@@ -167,17 +189,63 @@
SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${ORXONOX_VERSION})
ENDIF()
+ # OUTPUT_NAME
+ IF(_arg_OUTPUT_NAME)
+ SET_TARGET_PROPERTIES(${_target_name} PROPERTIES OUTPUT_NAME ${_arg_OUTPUT_NAME})
+ ENDIF()
+
# Second part of precompiled header files
IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE)
PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE})
ENDIF()
IF(NOT _arg_STATIC AND NOT _arg_NO_INSTALL)
- INSTALL(TARGETS ${_target_name}
- RUNTIME DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH}
- LIBRARY DESTINATION ${ORXONOX_LIBRARY_INSTALL_PATH}
- #ARCHIVE DESTINATION ${ORXONOX_ARCHIVE_INSTALL_PATH}
- )
+ IF(_arg_MODULE)
+ INSTALL(TARGETS ${_target_name}
+ RUNTIME DESTINATION ${ORXONOX_MODULE_INSTALL_PATH}
+ LIBRARY DESTINATION ${ORXONOX_MODULE_INSTALL_PATH}
+ )
+ ELSE()
+ INSTALL(TARGETS ${_target_name}
+ RUNTIME DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH}
+ LIBRARY DESTINATION ${ORXONOX_LIBRARY_INSTALL_PATH}
+ )
+ ENDIF()
ENDIF()
ENDFUNCTION(TU_ADD_TARGET)
+
+
+# Creates a helper file with name <name_of_the_library>.module
+# This helps finding dynamically loadable modules at runtime
+
+FUNCTION(ADD_MODULE _target)
+ # We use the properties to get the name because the librarys name may differ from
+ # the target name (for example orxonox <-> liborxonox)
+
+ GET_TARGET_PROPERTY(_target_loc ${_target} LOCATION)
+ GET_FILENAME_COMPONENT(_target_name ${_target_loc} NAME_WE)
+
+ IF(CMAKE_CONFIGURATION_TYPES)
+ FOREACH(_config ${CMAKE_CONFIGURATION_TYPES})
+ SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_config}/${_target_name}${ORXONOX_MODULE_EXTENSION})
+
+ FILE(WRITE ${_module_filename})
+
+ INSTALL(
+ FILES ${_module_filename}
+ DESTINATION ${ORXONOX_MODULE_INSTALL_PATH}
+ CONFIGURATIONS ${_config}
+ )
+ ENDFOREACH()
+ ELSE()
+ SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_target_name}${ORXONOX_MODULE_EXTENSION})
+
+ FILE(WRITE ${_module_filename})
+
+ INSTALL(
+ FILES ${_module_filename}
+ DESTINATION ${ORXONOX_MODULE_INSTALL_PATH}
+ )
+ ENDIF()
+ENDFUNCTION(ADD_MODULE)
Modified: code/trunk/src/SpecialConfig.h.in
===================================================================
--- code/trunk/src/SpecialConfig.h.in 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/SpecialConfig.h.in 2009-08-29 20:19:38 UTC (rev 5693)
@@ -73,6 +73,7 @@
{
// INSTALLATION PATHS
const char ORXONOX_RUNTIME_INSTALL_PATH[] = "@ORXONOX_RUNTIME_INSTALL_PATH@";
+ const char ORXONOX_MODULE_INSTALL_PATH[] = "@ORXONOX_MODULE_INSTALL_PATH@";
const char ORXONOX_MEDIA_INSTALL_PATH[] = "@ORXONOX_MEDIA_INSTALL_PATH@";
/* Config and Log path might be relative because they could be user and therefore runtime dependent */
const char ORXONOX_CONFIG_INSTALL_PATH[] = "@ORXONOX_CONFIG_INSTALL_PATH@";
@@ -81,9 +82,11 @@
// DEVELOPMENT RUN PATHS
const char ORXONOX_MEDIA_DEV_PATH[] = "@CMAKE_MEDIA_OUTPUT_DIRECTORY@";
#ifdef CMAKE_CONFIGURATION_TYPES
+ const char ORXONOX_MODULE_DEV_PATH[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
const char ORXONOX_CONFIG_DEV_PATH[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
const char ORXONOX_LOG_DEV_PATH[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
#else
+ const char ORXONOX_MODULE_DEV_PATH[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";
const char ORXONOX_CONFIG_DEV_PATH[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
const char ORXONOX_LOG_DEV_PATH[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
#endif
@@ -91,6 +94,9 @@
const char ORXONOX_DEP_LIB_PATH[] = "@DEP_LIBRARY_DIR@";
#endif
+ // Module extension
+ const char ORXONOX_MODULE_EXTENSION[] = "@ORXONOX_MODULE_EXTENSION@";
+
// OGRE PLUGINS
#ifdef NDEBUG
const char ORXONOX_OGRE_PLUGINS[] = "@OGRE_PLUGINS_RELEASE@";
Modified: code/trunk/src/core/CMakeLists.txt
===================================================================
--- code/trunk/src/core/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -22,6 +22,8 @@
ConfigFileManager.cc
ConfigValueContainer.cc
Core.cc
+ DynLib.cc
+ DynLibManager.cc
Event.cc
Game.cc
GameMode.cc
Modified: code/trunk/src/core/Core.cc
===================================================================
--- code/trunk/src/core/Core.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/Core.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -39,6 +39,7 @@
#include <fstream>
#include <cstdlib>
#include <cstdio>
+#include <boost/version.hpp>
#include <boost/filesystem.hpp>
#include <OgreRenderWindow.h>
@@ -67,6 +68,7 @@
#include "ConfigFileManager.h"
#include "ConfigValueIncludes.h"
#include "CoreIncludes.h"
+#include "DynLibManager.h"
#include "Factory.h"
#include "GameMode.h"
#include "GraphicsManager.h"
@@ -79,6 +81,13 @@
#include "TclThreadManager.h"
#include "input/InputManager.h"
+// Boost 1.36 has some issues with deprecated functions that have been omitted
+#if (BOOST_VERSION == 103600)
+# define BOOST_LEAF_FUNCTION filename
+#else
+# define BOOST_LEAF_FUNCTION leaf
+#endif
+
namespace orxonox
{
//! Static pointer to the singleton
@@ -240,6 +249,7 @@
//! Path to the parent directory of the ones above if program was installed with relativ pahts
boost::filesystem::path rootPath_;
boost::filesystem::path executablePath_; //!< Path to the executable
+ boost::filesystem::path modulePath_; //!< Path to the modules
boost::filesystem::path mediaPath_; //!< Path to the media file folder
boost::filesystem::path configPath_; //!< Path to the config file folder
boost::filesystem::path logPath_; //!< Path to the log file folder
@@ -255,19 +265,76 @@
, bDevRun_(false)
, bGraphicsLoaded_(false)
{
- // Parse command line arguments first
- CommandLine::parseCommandLine(cmdLine);
+ // Set the hard coded fixed paths
+ this->setFixedPaths();
- // Determine and set the location of the executable
- setExecutablePath();
+ // Create a new dynamic library manager
+ this->dynLibManager_.reset(new DynLibManager());
- // Determine whether we have an installed or a binary dir run
- // The latter occurs when simply running from the build directory
- checkDevBuild();
+ // Load modules
+ try
+ {
+ // We search for helper files with the following extension
+ std::string moduleextension = ORXONOX_MODULE_EXTENSION;
+ size_t moduleextensionlength = moduleextension.size();
- // Make sure the directories we write in exist or else make them
- createDirectories();
+ // Search in the directory of our executable
+ boost::filesystem::path searchpath = this->configuration_->modulePath_;
+ // Add that path to the PATH variable in case a module depends on another one
+ std::string pathVariable = getenv("PATH");
+ putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + configuration_->modulePath_.string()).c_str()));
+
+ boost::filesystem::directory_iterator file(searchpath);
+ boost::filesystem::directory_iterator end;
+
+ // Iterate through all files
+ while (file != end)
+ {
+ std::string filename = file->BOOST_LEAF_FUNCTION();
+
+ // Check if the file ends with the exension in question
+ if (filename.size() > moduleextensionlength)
+ {
+ if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
+ {
+ // We've found a helper file - now load the library with the same name
+ std::string library = filename.substr(0, filename.size() - moduleextensionlength);
+ boost::filesystem::path librarypath = searchpath / library;
+
+ try
+ {
+ DynLibManager::getInstance().load(librarypath.string());
+ }
+ catch (const std::exception& e)
+ {
+ COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << e.what() << std::endl;
+ }
+ catch (...)
+ {
+ COUT(1) << "Couldn't load module \"" << librarypath.string() << "\"" << std::endl;
+ }
+ }
+ }
+
+ ++file;
+ }
+ }
+ catch (const std::exception& e)
+ {
+ COUT(1) << "An error occurred while loading modules: " << e.what() << std::endl;
+ }
+ catch (...)
+ {
+ COUT(1) << "An error occurred while loading modules." << std::endl;
+ }
+
+ // Parse command line arguments AFTER the modules have been loaded (static code!)
+ CommandLine::parseCommandLine(cmdLine);
+
+ // Set configurable paths like log, config and media
+ this->setConfigurablePaths();
+
// create a signal handler (only active for linux)
// This call is placed as soon as possible, but after the directories are set
this->signalHandler_.reset(new SignalHandler());
@@ -506,10 +573,19 @@
/**
@brief
- Compares the executable path with the working directory
+ Retrievs the executable path and sets all hard coded fixed path (currently only the module path)
+ Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
+ If found it means that this is not an installed run, hence we
+ don't write the logs and config files to ~/.orxonox
+ @throw
+ GeneralException
*/
- void Core::setExecutablePath()
+ void Core::setFixedPaths()
{
+ //////////////////////////
+ // FIND EXECUTABLE PATH //
+ //////////////////////////
+
#ifdef ORXONOX_PLATFORM_WINDOWS
// get executable module
TCHAR buffer[1024];
@@ -552,29 +628,22 @@
#ifndef ORXONOX_PLATFORM_APPLE
configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name
#endif
- }
- /**
- @brief
- Checks for "orxonox_dev_build.keep_me" in the executable diretory.
- If found it means that this is not an installed run, hence we
- don't write the logs and config files to ~/.orxonox
- @throws
- GeneralException
- */
- void Core::checkDevBuild()
- {
+ /////////////////////
+ // SET MODULE PATH //
+ /////////////////////
+
if (boost::filesystem::exists(configuration_->executablePath_ / "orxonox_dev_build.keep_me"))
{
COUT(1) << "Running from the build tree." << std::endl;
Core::bDevRun_ = true;
- configuration_->mediaPath_ = ORXONOX_MEDIA_DEV_PATH;
- configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
- configuration_->logPath_ = ORXONOX_LOG_DEV_PATH;
+ configuration_->modulePath_ = ORXONOX_MODULE_DEV_PATH;
}
else
{
+
#ifdef INSTALL_COPYABLE // --> relative paths
+
// Also set the root path
boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
configuration_->rootPath_ = configuration_->executablePath_;
@@ -584,12 +653,44 @@
if (configuration_->rootPath_.empty())
ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
+ // Module path is fixed as well
+ configuration_->modulePath_ = configuration_->rootPath_ / ORXONOX_MODULE_INSTALL_PATH;
+
+#else
+
+ // There is no root path, so don't set it at all
+ // Module path is fixed as well
+ configuration_->modulePath_ = ORXONOX_MODULE_INSTALL_PATH;
+
+#endif
+ }
+ }
+
+ /**
+ @brief
+ Sets config, log and media path and creates folders if necessary.
+ @throws
+ GeneralException
+ */
+ void Core::setConfigurablePaths()
+ {
+ if (Core::isDevelopmentRun())
+ {
+ configuration_->mediaPath_ = ORXONOX_MEDIA_DEV_PATH;
+ configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
+ configuration_->logPath_ = ORXONOX_LOG_DEV_PATH;
+ }
+ else
+ {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
// Using paths relative to the install prefix, complete them
configuration_->mediaPath_ = configuration_->rootPath_ / ORXONOX_MEDIA_INSTALL_PATH;
configuration_->configPath_ = configuration_->rootPath_ / ORXONOX_CONFIG_INSTALL_PATH;
configuration_->logPath_ = configuration_->rootPath_ / ORXONOX_LOG_INSTALL_PATH;
+
#else
- // There is no root path, so don't set it at all
configuration_->mediaPath_ = ORXONOX_MEDIA_INSTALL_PATH;
@@ -606,7 +707,9 @@
configuration_->configPath_ = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
configuration_->logPath_ = userDataPath / ORXONOX_LOG_INSTALL_PATH;
+
#endif
+
}
// Option to put all the config and log files in a separate folder
@@ -616,17 +719,8 @@
configuration_->configPath_ = configuration_->configPath_ / directory;
configuration_->logPath_ = configuration_->logPath_ / directory;
}
- }
- /*
- @brief
- Checks for the log and the config directory and creates them
- if necessary. Otherwise me might have problems opening those files.
- @throws
- orxonox::GeneralException if the directory to be created is a file.
- */
- void Core::createDirectories()
- {
+ // Create directories to avoid problems when opening files in non existent folders.
std::vector<std::pair<boost::filesystem::path, std::string> > directories;
directories.push_back(std::make_pair(boost::filesystem::path(configuration_->configPath_), "config"));
directories.push_back(std::make_pair(boost::filesystem::path(configuration_->logPath_), "log"));
Modified: code/trunk/src/core/Core.h
===================================================================
--- code/trunk/src/core/Core.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/Core.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -113,12 +113,12 @@
private:
Core(const Core&); //!< Don't use (undefined symbol)
- void checkDevBuild();
- void setExecutablePath();
- void createDirectories();
+ void setFixedPaths();
+ void setConfigurablePaths();
void setThreadAffinity(int limitToCPU);
// Mind the order for the destruction!
+ scoped_ptr<DynLibManager> dynLibManager_;
scoped_ptr<SignalHandler> signalHandler_;
SimpleScopeGuard identifierDestroyer_;
SimpleScopeGuard consoleCommandDestroyer_;
Modified: code/trunk/src/core/CorePrereqs.h
===================================================================
--- code/trunk/src/core/CorePrereqs.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/CorePrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -111,6 +111,8 @@
class ConfigValueContainer;
class ConsoleCommand;
class Core;
+ class DynLib;
+ class DynLibManager;
struct Event;
class EventContainer;
class Executor;
Copied: code/trunk/src/core/DynLib.cc (from rev 5692, code/branches/libraries/src/core/DynLib.cc)
===================================================================
--- code/trunk/src/core/DynLib.cc (rev 0)
+++ code/trunk/src/core/DynLib.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,134 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLib.h"
+
+#include "util/Exception.h"
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+# define WIN32_LEAN_AND_MEAN
+# ifndef NOMINMAX
+# define NOMINMAX // required to stop windows.h messing up std::min
+# endif
+# include <windows.h>
+#endif
+
+#ifdef ORXONOX_PLATFORM_APPLE
+# include "macPlugins.h"
+#endif
+
+namespace orxonox
+{
+ //-----------------------------------------------------------------------
+ DynLib::DynLib( const std::string& name )
+ {
+ mName = name;
+ m_hInst = NULL;
+ }
+
+ //-----------------------------------------------------------------------
+ DynLib::~DynLib()
+ {
+ }
+
+ //-----------------------------------------------------------------------
+ void DynLib::load()
+ {
+ // Log library load
+ COUT(2) << "Loading module " << mName << std::endl;
+
+ std::string name = mName;
+#ifdef ORXONOX_PLATFORM_LINUX
+ // dlopen() does not add .so to the filename, like windows does for .dll
+ if (name.substr(name.length() - 3, 3) != ".so")
+ name += ".so";
+#endif
+
+ m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
+
+ if( !m_hInst )
+ ThrowException(
+ General,
+ "Could not load dynamic library " + mName +
+ ". System Error: " + dynlibError());
+ }
+
+ //-----------------------------------------------------------------------
+ void DynLib::unload()
+ {
+ // Log library unload
+ COUT(4) << "Unloading module " << mName << std::endl;
+
+ if( DYNLIB_UNLOAD( m_hInst ) )
+ {
+ ThrowException(
+ General,
+ "Could not unload dynamic library " + mName +
+ ". System Error: " + dynlibError());
+ }
+
+ }
+
+ //-----------------------------------------------------------------------
+ void* DynLib::getSymbol( const std::string& strName ) const throw()
+ {
+ return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
+ }
+ //-----------------------------------------------------------------------
+ std::string DynLib::dynlibError( void )
+ {
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+ std::string ret = (char*)lpMsgBuf;
+ // Free the buffer.
+ LocalFree( lpMsgBuf );
+ return ret;
+#elif defined(ORXONOX_PLATFORM_LINUX)
+ return std::string(dlerror());
+#elif defined(ORXONOX_PLATFORM_APPLE)
+ return std::string(mac_errorBundle());
+#else
+ return std::string("");
+#endif
+ }
+
+}
Copied: code/trunk/src/core/DynLib.h (from rev 5692, code/branches/libraries/src/core/DynLib.h)
===================================================================
--- code/trunk/src/core/DynLib.h (rev 0)
+++ code/trunk/src/core/DynLib.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,121 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#ifndef _Core_DynLib_H__
+#define _Core_DynLib_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+# define DYNLIB_HANDLE hInstance
+# define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
+# define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
+# define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
+
+struct HINSTANCE__;
+typedef struct HINSTANCE__* hInstance;
+
+#elif defined(ORXONOX_PLATFORM_LINUX)
+# define DYNLIB_HANDLE void*
+# define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
+# define DYNLIB_GETSYM( a, b ) dlsym( a, b )
+# define DYNLIB_UNLOAD( a ) dlclose( a )
+
+#elif defined(ORXONOX_PLATFORM_APPLE)
+# define DYNLIB_HANDLE CFBundleRef
+# define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
+# define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
+# define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
+#endif
+
+namespace orxonox
+{
+ /** Resource holding data about a dynamic library.
+ @remarks
+ This class holds the data required to get symbols from
+ libraries loaded at run-time (i.e. from DLL's for so's)
+ @author
+ Adrian Cearnãu (cearny at cearny.ro)
+ @since
+ 27 January 2002
+ @see
+ Resource
+ */
+ class _CoreExport DynLib
+ {
+ protected:
+ std::string mName;
+ /// Gets the last loading error
+ std::string dynlibError(void);
+ public:
+ /** Default constructor - used by DynLibManager.
+ @warning
+ Do not call directly
+ */
+ DynLib( const std::string& name );
+
+ /** Default destructor.
+ */
+ ~DynLib();
+
+ /** Load the library
+ */
+ void load();
+ /** Unload the library
+ */
+ void unload();
+ /// Get the name of the library
+ const std::string& getName(void) const { return mName; }
+
+ /**
+ Returns the address of the given symbol from the loaded library.
+ @param
+ strName The name of the symbol to search for
+ @returns
+ If the function succeeds, the returned value is a handle to
+ the symbol.
+ @par
+ If the function fails, the returned value is <b>NULL</b>.
+
+ */
+ void* getSymbol( const std::string& strName ) const throw();
+
+ protected:
+
+ /// Handle to the loaded library.
+ DYNLIB_HANDLE m_hInst;
+ };
+
+}
+
+#endif /* _Core_DynLib_H__ */
Copied: code/trunk/src/core/DynLibManager.cc (from rev 5692, code/branches/libraries/src/core/DynLibManager.cc)
===================================================================
--- code/trunk/src/core/DynLibManager.cc (rev 0)
+++ code/trunk/src/core/DynLibManager.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,86 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLibManager.h"
+
+#include "DynLib.h"
+
+namespace orxonox
+{
+ //-----------------------------------------------------------------------
+ //! Static pointer to the singleton
+ DynLibManager* DynLibManager::singletonPtr_s = 0;
+
+ //-----------------------------------------------------------------------
+ DynLibManager::DynLibManager()
+ {
+ }
+ //-----------------------------------------------------------------------
+ DynLib* DynLibManager::load( const std::string& filename)
+ {
+ DynLibList::iterator i = mLibList.find(filename);
+ if (i != mLibList.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ DynLib* pLib = new DynLib(filename);
+ pLib->load();
+ mLibList[filename] = pLib;
+ return pLib;
+ }
+ }
+ //-----------------------------------------------------------------------
+ void DynLibManager::unload(DynLib* lib)
+ {
+ DynLibList::iterator i = mLibList.find(lib->getName());
+ if (i != mLibList.end())
+ {
+ mLibList.erase(i);
+ }
+ lib->unload();
+ delete lib;
+ }
+ //-----------------------------------------------------------------------
+ DynLibManager::~DynLibManager()
+ {
+ // Unload & delete resources in turn
+ for( DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it )
+ {
+ it->second->unload();
+ delete it->second;
+ }
+
+ // Empty the list
+ mLibList.clear();
+ }
+}
Copied: code/trunk/src/core/DynLibManager.h (from rev 5692, code/branches/libraries/src/core/DynLibManager.h)
===================================================================
--- code/trunk/src/core/DynLibManager.h (rev 0)
+++ code/trunk/src/core/DynLibManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,87 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+ (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#ifndef _Core_DynLibManager_H__
+#define _Core_DynLibManager_H__
+
+#include "CorePrereqs.h"
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+ /** Manager for Dynamic-loading Libraries.
+ @remarks
+ This manager keeps a track of all the open dynamic-loading
+ libraries, opens them and returns references to already-open
+ libraries.
+ */
+ class _CoreExport DynLibManager: public Singleton<DynLibManager>
+ {
+ friend class Singleton<DynLibManager>;
+
+ protected:
+ typedef std::map<std::string, DynLib*> DynLibList;
+ DynLibList mLibList;
+
+ public:
+ /** Default constructor.
+ @note
+ <br>Should never be called as the singleton is automatically
+ created during the creation of the Root object.
+ @see
+ Root::Root
+ */
+ DynLibManager();
+
+ /** Default destructor.
+ @see
+ Root::~Root
+ */
+ virtual ~DynLibManager();
+
+ /** Loads the passed library.
+ @param
+ filename The name of the library. The extension can be omitted
+ */
+ DynLib* load(const std::string& filename);
+
+ /** Unloads the passed library.
+ @param
+ filename The name of the library. The extension can be omitted
+ */
+ void unload(DynLib* lib);
+
+ private:
+ static DynLibManager* singletonPtr_s;
+ };
+}
+
+#endif /* _Core_DynLibManager_H__ */
Modified: code/trunk/src/core/GUIManager.h
===================================================================
--- code/trunk/src/core/GUIManager.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/GUIManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -49,6 +49,8 @@
namespace orxonox
{
+ class PlayerInfo; // Forward declaration
+
/**
@class GUIManager
@brief
@@ -76,6 +78,11 @@
static GUIManager* getInstancePtr() { return singletonPtr_s; }
+ inline void setPlayer(const std::string& guiname, PlayerInfo* player)
+ { this->players_[guiname] = player; }
+ inline PlayerInfo* getPlayer(const std::string& guiname) const
+ { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
+
private:
GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
@@ -91,15 +98,16 @@
void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
void mouseScrolled (int abs, int rel);
- boost::scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine
- boost::scoped_ptr<CEGUI::LuaScriptModule> scriptModule_; //!< CEGUI's script module to use Lua
- boost::scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system
- Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it
- CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
- CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
- lua_State* luaState_; //!< Lua state, access point to the Lua engine
+ boost::scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine
+ boost::scoped_ptr<CEGUI::LuaScriptModule> scriptModule_; //!< CEGUI's script module to use Lua
+ boost::scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system
+ Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it
+ CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
+ CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
+ lua_State* luaState_; //!< Lua state, access point to the Lua engine
+ std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui
- static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
+ static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
};
}
Modified: code/trunk/src/core/Game.cc
===================================================================
--- code/trunk/src/core/Game.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/Game.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -112,6 +112,8 @@
Non-initialising constructor.
*/
Game::Game(const std::string& cmdLine)
+ // Destroy factories before the Core!
+ : gsFactoryDestroyer_(Game::GameStateFactory::factories_s, &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
{
this->bAbort_ = false;
bChangingState_ = false;
Modified: code/trunk/src/core/Game.h
===================================================================
--- code/trunk/src/core/Game.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/Game.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -47,6 +47,7 @@
#include <boost/preprocessor/cat.hpp>
#include "util/Debug.h"
+#include "util/ScopeGuard.h"
#include "util/Singleton.h"
/**
@@ -84,6 +85,7 @@
typedef std::vector<shared_ptr<GameState> > GameStateVector;
typedef std::map<std::string, shared_ptr<GameState> > GameStateMap;
typedef boost::shared_ptr<GameStateTreeNode> GameStateTreeNodePtr;
+
public:
Game(const std::string& cmdLine);
~Game();
@@ -117,7 +119,7 @@
template <class T>
static void createFactory(const std::string& className)
{ factories_s[className].reset(new TemplateGameStateFactory<T>()); }
- private:
+
virtual shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;
static std::map<std::string, shared_ptr<GameStateFactory> > factories_s;
};
@@ -128,6 +130,8 @@
shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
{ return shared_ptr<GameState>(new T(info)); }
};
+ // For the factory destruction
+ typedef Loki::ObjScopeGuardImpl0<std::map<std::string, shared_ptr<GameStateFactory> >, void (std::map<std::string, shared_ptr<GameStateFactory> >::*)()> ObjScopeGuard;
struct StatisticsTickInfo
{
@@ -155,6 +159,7 @@
scoped_ptr<Clock> gameClock_;
scoped_ptr<Core> core_;
+ ObjScopeGuard gsFactoryDestroyer_;
scoped_ptr<GameConfiguration> configuration_;
GameStateMap constructedStates_;
Modified: code/trunk/src/core/TclThreadList.h
===================================================================
--- code/trunk/src/core/TclThreadList.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/core/TclThreadList.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,263 +1,263 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TclThreadList_H__
-#define _TclThreadList_H__
-
-#include "CorePrereqs.h"
-
-#include <list>
-
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/thread/locks.hpp>
-
-namespace orxonox
-{
- template <class T>
- class TclThreadList
- {
- public:
- void push_front(const T& value);
- void push_back(const T& value);
- template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
-
- void wait_and_pop_front(T* value);
- void wait_and_pop_back(T* value);
- bool try_pop_front(T* value);
- bool try_pop_back(T* value);
- void clear();
-
- size_t size() const;
- bool empty() const;
- bool is_in(const T& value) const;
-
- /**
- @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
- */
- inline std::list<T>& getList()
- { return this->list_; }
-
- /**
- @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
- */
- inline const std::list<T>& getList() const
- { return this->list_; }
-
- /**
- @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
- */
- inline boost::shared_mutex& getMutex() const
- { return this->mutex_; }
-
- private:
- std::list<T> list_; ///< A standard list for type T
- mutable boost::shared_mutex mutex_; ///< A mutex to grant exclusive access to the list
- boost::condition_variable_any condition_; ///< A condition variable to wake threads waiting for the mutex to become ready
- };
-
- /**
- @brief Pushes a new element to the front of the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::push_front(const T& value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.push_front(value);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Pushes a new element to the back of the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::push_back(const T& value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.push_back(value);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Inserts new elements into the list. A unique_lock is needed.
- */
- template <class T>
- template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.insert(position, begin, end);
- lock.unlock(); // unlock the mutex...
- this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
- }
-
- /**
- @brief Waits until the list contains at least one element and then pops and returns the front element.
- @param value The front value will be stored in the variable referenced by this pointer.
- */
- template <class T>
- void TclThreadList<T>::wait_and_pop_front(T* value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
- while (this->list_.empty()) // check if there's an element in the list
- this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
- *value = this->list_.front();
- this->list_.pop_front();
- }
-
- /**
- @brief Waits until the list contains at least one element and then pops and returns the back element.
- @param value The back value will be stored in the variable referenced by this pointer.
- */
- template <class T>
- void TclThreadList<T>::wait_and_pop_back(T* value)
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
-
- while (this->list_.empty()) // check if there's an element in the list
- this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
-
- *value = this->list_.back();
- this->list_.pop_back();
- }
-
- /**
- @brief Pops and returns the front element if there's at least one element in the list.
- @param value The front value will be stored in the variable referenced by this pointer.
- @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
- Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
- */
- template <class T>
- bool TclThreadList<T>::try_pop_front(T* value)
- {
- boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
- if (this->list_.empty())
- {
- // No elements - return immediately
- return false;
- }
- else
- {
- // At least one element - write it into the passed variable and pop it from the list
- boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
- *value = this->list_.front();
- this->list_.pop_front();
- }
- return true;
- }
-
- /**
- @brief Pops and returns the back element if there's at least one element in the list.
- @param value The back value will be stored in the variable referenced by this pointer.
- @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
-
- Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
- */
- template <class T>
- bool TclThreadList<T>::try_pop_back(T* value)
- {
- boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
-
- if (this->list_.empty())
- {
- // No elements - return immediately
- return false;
- }
- else
- {
- // At least one element - write it into the passed variable and pop it from the list
- boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
- *value = this->list_.back();
- this->list_.pop_back();
- }
- return true;
- }
-
- /**
- @brief Clears the list. A unique_lock is needed.
- */
- template <class T>
- void TclThreadList<T>::clear()
- {
- boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
- this->list_.clear();
- }
-
- /**
- @brief Returns the size of the list. A shared_lock is needed.
-
- Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
- beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
- just the size of the list.
- */
- template <class T>
- size_t TclThreadList<T>::size() const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
- return this->list_.size();
- }
-
- /**
- @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
-
- Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
- beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
- just if the list is empty or not.
- */
- template <class T>
- bool TclThreadList<T>::empty() const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
- return this->list_.empty();
- }
-
- /**
- @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
-
- Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
- about a temporary snapshot and don't change the list based on the result of this function.
- */
- template <class T>
- bool TclThreadList<T>::is_in(const T& value) const
- {
- boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
-
- for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
- if (*it == value)
- return true;
-
- return false;
- }
-}
-
-#endif /* _TclThreadList_H__ */
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TclThreadList_H__
+#define _TclThreadList_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/locks.hpp>
+
+namespace orxonox
+{
+ template <class T>
+ class TclThreadList
+ {
+ public:
+ void push_front(const T& value);
+ void push_back(const T& value);
+ template <class InputIterator> void insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end);
+
+ void wait_and_pop_front(T* value);
+ void wait_and_pop_back(T* value);
+ bool try_pop_front(T* value);
+ bool try_pop_back(T* value);
+ void clear();
+
+ size_t size() const;
+ bool empty() const;
+ bool is_in(const T& value) const;
+
+ /**
+ @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+ */
+ inline std::list<T>& getList()
+ { return this->list_; }
+
+ /**
+ @brief Returns a reference to the list. Don't forget to lock the mutex (see @ref getMutex).
+ */
+ inline const std::list<T>& getList() const
+ { return this->list_; }
+
+ /**
+ @brief Returns a reference to the mutex which might be useful if you want to iterate through the list (see @ref begin and @ref end).
+ */
+ inline boost::shared_mutex& getMutex() const
+ { return this->mutex_; }
+
+ private:
+ std::list<T> list_; ///< A standard list for type T
+ mutable boost::shared_mutex mutex_; ///< A mutex to grant exclusive access to the list
+ boost::condition_variable_any condition_; ///< A condition variable to wake threads waiting for the mutex to become ready
+ };
+
+ /**
+ @brief Pushes a new element to the front of the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::push_front(const T& value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.push_front(value);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Pushes a new element to the back of the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::push_back(const T& value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.push_back(value);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Inserts new elements into the list. A unique_lock is needed.
+ */
+ template <class T>
+ template <class InputIterator> void TclThreadList<T>::insert(typename std::list<T>::iterator position, InputIterator begin, InputIterator end)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.insert(position, begin, end);
+ lock.unlock(); // unlock the mutex...
+ this->condition_.notify_all(); // ...then call notify_all to wake threads waiting in wait_and_pop_front/back
+ }
+
+ /**
+ @brief Waits until the list contains at least one element and then pops and returns the front element.
+ @param value The front value will be stored in the variable referenced by this pointer.
+ */
+ template <class T>
+ void TclThreadList<T>::wait_and_pop_front(T* value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+ while (this->list_.empty()) // check if there's an element in the list
+ this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+ *value = this->list_.front();
+ this->list_.pop_front();
+ }
+
+ /**
+ @brief Waits until the list contains at least one element and then pops and returns the back element.
+ @param value The back value will be stored in the variable referenced by this pointer.
+ */
+ template <class T>
+ void TclThreadList<T>::wait_and_pop_back(T* value)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+
+ while (this->list_.empty()) // check if there's an element in the list
+ this->condition_.wait(lock); // wait until the condition becomes true (a notification comes from push_front, push_back or insert
+
+ *value = this->list_.back();
+ this->list_.pop_back();
+ }
+
+ /**
+ @brief Pops and returns the front element if there's at least one element in the list.
+ @param value The front value will be stored in the variable referenced by this pointer.
+ @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+ Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+ */
+ template <class T>
+ bool TclThreadList<T>::try_pop_front(T* value)
+ {
+ boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+ if (this->list_.empty())
+ {
+ // No elements - return immediately
+ return false;
+ }
+ else
+ {
+ // At least one element - write it into the passed variable and pop it from the list
+ boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+ *value = this->list_.front();
+ this->list_.pop_front();
+ }
+ return true;
+ }
+
+ /**
+ @brief Pops and returns the back element if there's at least one element in the list.
+ @param value The back value will be stored in the variable referenced by this pointer.
+ @return Returns true if there was at least one element in the list (which got poped). If the list was empty, false is returned immediately.
+
+ Needs a unique_lock if there's an element to pop. If not, shared_lock is sufficient.
+ */
+ template <class T>
+ bool TclThreadList<T>::try_pop_back(T* value)
+ {
+ boost::upgrade_lock<boost::shared_mutex> lock(this->mutex_); // gain shared lock
+
+ if (this->list_.empty())
+ {
+ // No elements - return immediately
+ return false;
+ }
+ else
+ {
+ // At least one element - write it into the passed variable and pop it from the list
+ boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock); // upgrade to unique lock to modify the list
+ *value = this->list_.back();
+ this->list_.pop_back();
+ }
+ return true;
+ }
+
+ /**
+ @brief Clears the list. A unique_lock is needed.
+ */
+ template <class T>
+ void TclThreadList<T>::clear()
+ {
+ boost::unique_lock<boost::shared_mutex> lock(this->mutex_);
+ this->list_.clear();
+ }
+
+ /**
+ @brief Returns the size of the list. A shared_lock is needed.
+
+ Warning: Don't change the list based on the result of size(). Use an atomic function instead. Other threads may change the list
+ beween your call to size() and your further actions, so be careful and use this function only if you really want nothing else than
+ just the size of the list.
+ */
+ template <class T>
+ size_t TclThreadList<T>::size() const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+ return this->list_.size();
+ }
+
+ /**
+ @brief Returns true if the list is empty, false otherwise. A shared_lock is needed.
+
+ Warning: Don't change the list based on the result of empty(). Use an atomic function instead. Other threads may change the list
+ beween your call to empty() and your further actions, so be careful and use this function only if you really want nothing else than
+ just if the list is empty or not.
+ */
+ template <class T>
+ bool TclThreadList<T>::empty() const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+ return this->list_.empty();
+ }
+
+ /**
+ @brief Returns true if a given element is in the list, false otherwise. A shared_lock is needed.
+
+ Warning: The result of this function might be wrong just one instruction after the call. Use this function just to get information
+ about a temporary snapshot and don't change the list based on the result of this function.
+ */
+ template <class T>
+ bool TclThreadList<T>::is_in(const T& value) const
+ {
+ boost::shared_lock<boost::shared_mutex> lock(this->mutex_);
+
+ for (typename std::list<T>::const_iterator it = this->list_.begin(); it != this->list_.end(); ++it)
+ if (*it == value)
+ return true;
+
+ return false;
+ }
+}
+
+#endif /* _TclThreadList_H__ */
Property changes on: code/trunk/src/core/TclThreadList.h
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/src/core/Thread.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/src/core/Thread.h
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/src/core/ThreadPool.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/src/core/ThreadPool.h
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/src/network/TODO
___________________________________________________________________
Modified: svn:mergeinfo
- code/branches/buildsystem/TODO:1874-2276,2278-2400
code/branches/buildsystem2/TODO:2506-2658
code/branches/buildsystem3/TODO:2662-2708
code/branches/ceguilua/TODO:1802-1808
code/branches/core3/TODO:1572-1739
code/branches/core4/TODO:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes/TODO:2826-3031
code/branches/gcc43/TODO:1580
code/branches/gui/TODO:1635-1723,2795-2894
code/branches/input/TODO:1629-1636
code/branches/lodfinal/TODO:2372-2411
code/branches/map/TODO:2801-3086,3089
code/branches/miniprojects/TODO:2754-2824
code/branches/netp2/TODO:2835-2988
code/branches/netp3/TODO:2988-3082
code/branches/netp6/TODO:3214-3302
code/branches/network/TODO:2356
code/branches/network64/TODO:2210-2355
code/branches/objecthierarchy/TODO:1911-2085,2100,2110-2169
code/branches/objecthierarchy2/TODO:2171-2479
code/branches/overlay/TODO:2117-2385
code/branches/particles/TODO:2829-3085
code/branches/pch/TODO:3113-3194
code/branches/physics/TODO:1912-2055,2107-2439
code/branches/physics_merge/TODO:2436-2457
code/branches/pickups/TODO:1926-2086,2127,2827-2915
code/branches/pickups2/TODO:2107-2497,2915-3071
code/branches/presentation/TODO:2369-2652,2654-2660
code/branches/questsystem/TODO:1894-2088
code/branches/questsystem2/TODO:2107-2259
code/branches/questsystem5/TODO:2776-2905
code/branches/resource/TODO:3327-3366
code/branches/script_trigger/TODO:1295-1953,1955
code/branches/sound/TODO:2829-3010
code/branches/weapon/TODO:1925-2094
code/branches/weapon2/TODO:2107-2488
code/branches/weapons/TODO:2897-3051
code/branches/weaponsystem/TODO:2742-2890
+ /code/branches/libraries/src/network/TODO:5612-5692
code/branches/buildsystem/TODO:1874-2276,2278-2400
code/branches/buildsystem2/TODO:2506-2658
code/branches/buildsystem3/TODO:2662-2708
code/branches/ceguilua/TODO:1802-1808
code/branches/core3/TODO:1572-1739
code/branches/core4/TODO:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes/TODO:2826-3031
code/branches/gcc43/TODO:1580
code/branches/gui/TODO:1635-1723,2795-2894
code/branches/input/TODO:1629-1636
code/branches/lodfinal/TODO:2372-2411
code/branches/map/TODO:2801-3086,3089
code/branches/miniprojects/TODO:2754-2824
code/branches/netp2/TODO:2835-2988
code/branches/netp3/TODO:2988-3082
code/branches/netp6/TODO:3214-3302
code/branches/network/TODO:2356
code/branches/network64/TODO:2210-2355
code/branches/objecthierarchy/TODO:1911-2085,2100,2110-2169
code/branches/objecthierarchy2/TODO:2171-2479
code/branches/overlay/TODO:2117-2385
code/branches/particles/TODO:2829-3085
code/branches/pch/TODO:3113-3194
code/branches/physics/TODO:1912-2055,2107-2439
code/branches/physics_merge/TODO:2436-2457
code/branches/pickups/TODO:1926-2086,2127,2827-2915
code/branches/pickups2/TODO:2107-2497,2915-3071
code/branches/presentation/TODO:2369-2652,2654-2660
code/branches/questsystem/TODO:1894-2088
code/branches/questsystem2/TODO:2107-2259
code/branches/questsystem5/TODO:2776-2905
code/branches/resource/TODO:3327-3366
code/branches/script_trigger/TODO:1295-1953,1955
code/branches/sound/TODO:2829-3010
code/branches/weapon/TODO:1925-2094
code/branches/weapon2/TODO:2107-2488
code/branches/weapons/TODO:2897-3051
code/branches/weaponsystem/TODO:2742-2890
Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -18,16 +18,20 @@
#
SET_SOURCE_FILES(ORXONOX_SRC_FILES
+ Main.cc
+
CameraManager.cc
LevelManager.cc
- Main.cc
PawnManager.cc
PlayerManager.cc
+
+ InGameConsole.cc
+ Map.cc
)
ADD_SUBDIRECTORY(gamestates)
ADD_SUBDIRECTORY(interfaces)
+ADD_SUBDIRECTORY(overlays)
ADD_SUBDIRECTORY(objects)
-ADD_SUBDIRECTORY(overlays)
ADD_SUBDIRECTORY(sound)
ADD_SUBDIRECTORY(tools)
@@ -36,18 +40,16 @@
SET(ORXONOX_WIN32 WIN32)
ENDIF()
-ORXONOX_ADD_EXECUTABLE(orxonox
+ORXONOX_ADD_LIBRARY(orxonox
FIND_HEADER_FILES
TOLUA_FILES
LevelManager.h
objects/pickup/BaseItem.h
objects/pickup/PickupInventory.h
- objects/quest/QuestDescription.h
- objects/quest/QuestManager.h
+ DEFINE_SYMBOL
+ "ORXONOX_SHARED_BUILD"
PCH_FILE
OrxonoxPrecompiledHeaders.h
- # When defined as WIN32 this removes the console window on Windows
- ${ORXONOX_WIN32}
LINK_LIBRARIES
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} # Filesystem dependency
@@ -65,10 +67,21 @@
util
core
network
+ tools
SOURCE_FILES ${ORXONOX_SRC_FILES}
)
-GET_TARGET_PROPERTY(_exec_loc orxonox LOCATION)
+ORXONOX_ADD_EXECUTABLE(orxonox-main
+ # When defined as WIN32 this removes the console window on Windows
+ ${ORXONOX_WIN32}
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES
+ Orxonox.cc
+ OUTPUT_NAME orxonox
+)
+
+GET_TARGET_PROPERTY(_exec_loc orxonox-main LOCATION)
GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME)
SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "")
@@ -88,5 +101,5 @@
ENDIF()
STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?) .*$" "\\1"
VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}")
- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox.vcproj.user")
+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcproj.user")
ENDIF(MSVC)
Copied: code/trunk/src/orxonox/InGameConsole.cc (from rev 5692, code/branches/libraries/src/orxonox/InGameConsole.cc)
===================================================================
--- code/trunk/src/orxonox/InGameConsole.cc (rev 0)
+++ code/trunk/src/orxonox/InGameConsole.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,606 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+
+#include "InGameConsole.h"
+
+#include <algorithm>
+#include <string>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgreFontManager.h>
+#include <OgreFont.h>
+
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "util/UTFStringConversions.h"
+#include "core/Clock.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+#include "core/input/InputBuffer.h"
+
+namespace orxonox
+{
+ const int LINES = 30;
+ const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+
+ SetConsoleCommand(InGameConsole, openConsole, true);
+ SetConsoleCommand(InGameConsole, closeConsole, true);
+
+ InGameConsole* InGameConsole::singletonPtr_s = 0;
+
+ /**
+ @brief Constructor: Creates and initializes the InGameConsole.
+ */
+ InGameConsole::InGameConsole()
+ : consoleOverlay_(0)
+ , consoleOverlayContainer_(0)
+ , consoleOverlayNoise_(0)
+ , consoleOverlayCursor_(0)
+ , consoleOverlayBorder_(0)
+ , consoleOverlayTextAreas_(0)
+ , inputState_(0)
+ {
+ RegisterObject(InGameConsole);
+
+ this->bActive_ = false;
+ this->cursor_ = 0.0f;
+ this->cursorSymbol_ = '|';
+ this->inputWindowStart_ = 0;
+ this->numLinesShifted_ = LINES - 1;
+ // for the beginning, don't scroll
+ this->scroll_ = 0;
+
+ this->setConfigValues();
+ }
+
+ /**
+ @brief Destructor: Destroys the TextAreas.
+ */
+ InGameConsole::~InGameConsole()
+ {
+ this->deactivate();
+
+ // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
+ InputManager::getInstance().destroyState("console");
+
+ Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+ if (ovMan)
+ {
+ if (this->consoleOverlayNoise_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+ if (this->consoleOverlayCursor_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+ Ogre::FontManager::getSingleton().remove("MonofurConsole");
+ if (this->consoleOverlayBorder_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+ if (this->consoleOverlayTextAreas_)
+ {
+ for (int i = 0; i < LINES; i++)
+ {
+ if (this->consoleOverlayTextAreas_[i])
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+ this->consoleOverlayTextAreas_[i] = 0;
+ }
+
+ }
+ if (this->consoleOverlayContainer_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+ }
+ if (this->consoleOverlayTextAreas_)
+ {
+ delete[] this->consoleOverlayTextAreas_;
+ this->consoleOverlayTextAreas_ = 0;
+ }
+
+ if (this->consoleOverlay_)
+ Ogre::OverlayManager::getSingleton().destroy(consoleOverlay_);
+ }
+
+ /**
+ @brief Sets the config values, describing the size of the console.
+ */
+ void InGameConsole::setConfigValues()
+ {
+ SetConfigValue(relativeWidth, 0.8);
+ SetConfigValue(relativeHeight, 0.4);
+ SetConfigValue(blinkTime, 0.5);
+ SetConfigValue(scrollSpeed_, 3.0f);
+ SetConfigValue(noiseSize_, 1.0f);
+ SetConfigValue(cursorSymbol_, '|');
+ SetConfigValue(bHidesAllInput_, false).callback(this, &InGameConsole::bHidesAllInputChanged);
+ }
+
+ /**
+ @brief Called whenever bHidesAllInput_ changes.
+ */
+ void InGameConsole::bHidesAllInputChanged()
+ {
+ if (inputState_)
+ {
+ if (bHidesAllInput_)
+ {
+ inputState_->setMouseHandler(&InputHandler::EMPTY);
+ inputState_->setJoyStickHandler(&InputHandler::EMPTY);
+ }
+ else
+ {
+ inputState_->setMouseHandler(0);
+ inputState_->setJoyStickHandler(0);
+ }
+ }
+ }
+
+ /**
+ @brief Initializes the InGameConsole.
+ */
+ void InGameConsole::initialise()
+ {
+ // create the corresponding input state
+ inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
+ inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
+ bHidesAllInputChanged();
+
+ // create overlay and elements
+ Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+ // create actual overlay
+ this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
+
+ // create a container
+ this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
+ this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+ this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+ this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+ this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+
+ // create BorderPanel
+ this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+ this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+ this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
+ this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
+ this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+ this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+ this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+ this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+ this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+
+ // create a new font to match the requested size exactly
+ Ogre::FontPtr font = static_cast<Ogre::FontPtr>
+ (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
+ font->setType(Ogre::FT_TRUETYPE);
+ font->setSource("Monofur.ttf");
+ font->setTrueTypeSize(18);
+ // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
+ font->setTrueTypeResolution(192);
+ font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
+ font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
+
+ // create the text lines
+ this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
+ for (int i = 0; i < LINES; i++)
+ {
+ this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
+ this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
+ this->consoleOverlayTextAreas_[i]->setCharHeight(18);
+ this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
+ this->consoleOverlayTextAreas_[i]->setLeft(8);
+ this->consoleOverlayTextAreas_[i]->setCaption("");
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+ }
+
+ // create cursor (also a text area overlay element)
+ this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
+ this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayCursor_->setFontName("MonofurConsole");
+ this->consoleOverlayCursor_->setCharHeight(18);
+ this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+ this->consoleOverlayCursor_->setLeft(7);
+ this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+
+ // create noise
+ this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+ this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+ this->consoleOverlayNoise_->setPosition(5,0);
+ this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+ // comment following line to disable noise
+ this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+
+ this->windowResized(this->getWindowWidth(), this->getWindowWidth());
+
+ // move overlay "above" the top edge of the screen
+ // we take -1.2 because the border makes the panel bigger
+ this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+ Shell::getInstance().addOutputLevel(true);
+
+ COUT(4) << "Info: InGameConsole initialized" << std::endl;
+ }
+
+ // ###############################
+ // ### ShellListener methods ###
+ // ###############################
+
+ /**
+ @brief Called if all output-lines have to be redrawn.
+ */
+ void InGameConsole::linesChanged()
+ {
+ std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+ int max = 0;
+ for (int i = 1; i < LINES; ++i)
+ {
+ if (it != Shell::getInstance().getEndIterator())
+ {
+ ++it;
+ max = i;
+ }
+ else
+ break;
+ }
+
+ for (int i = LINES - 1; i > max; --i)
+ this->print("", i, true);
+
+ for (int i = max; i >= 1; --i)
+ {
+ --it;
+ this->print(*it, i, true);
+ }
+ }
+
+ /**
+ @brief Called if only the last output-line has changed.
+ */
+ void InGameConsole::onlyLastLineChanged()
+ {
+ if (LINES > 1)
+ this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+ }
+
+ /**
+ @brief Called if a new output-line was added.
+ */
+ void InGameConsole::lineAdded()
+ {
+ this->numLinesShifted_ = 0;
+ this->shiftLines();
+ this->onlyLastLineChanged();
+ }
+
+ /**
+ @brief Called if the text in the input-line has changed.
+ */
+ void InGameConsole::inputChanged()
+ {
+ if (LINES > 0)
+ this->print(Shell::getInstance().getInput(), 0);
+
+ if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+ this->inputWindowStart_ = 0;
+ }
+
+ /**
+ @brief Called if the position of the cursor in the input-line has changed.
+ */
+ void InGameConsole::cursorChanged()
+ {
+ unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+ if (pos > maxCharsPerLine_)
+ pos = maxCharsPerLine_;
+
+ this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+ this->consoleOverlayCursor_->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24);
+ }
+
+ /**
+ @brief Called if the console gets closed.
+ */
+ void InGameConsole::exit()
+ {
+ this->deactivate();
+ }
+
+ // ###############################
+ // ### other external calls ###
+ // ###############################
+
+ /**
+ @brief Used to control the actual scrolling and the cursor.
+ */
+ void InGameConsole::update(const Clock& time)
+ {
+ if (this->scroll_ != 0)
+ {
+ float oldTop = this->consoleOverlayContainer_->getTop();
+
+ if (this->scroll_ > 0)
+ {
+ // scrolling down
+ // enlarge oldTop a little bit so that this exponential function
+ // reaches 0 before infinite time has passed...
+ float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
+ if (oldTop - deltaScroll >= 0)
+ {
+ // window has completely scrolled down
+ this->consoleOverlayContainer_->setTop(0);
+ this->scroll_ = 0;
+ }
+ else
+ this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+ }
+
+ else
+ {
+ // scrolling up
+ // note: +0.01 for the same reason as when scrolling down
+ float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
+ if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+ {
+ // window has completely scrolled up
+ this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+ this->scroll_ = 0;
+ this->consoleOverlay_->hide();
+ }
+ else
+ this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+ }
+ }
+
+ if (this->bActive_)
+ {
+ this->cursor_ += time.getDeltaTime();
+ if (this->cursor_ >= this->blinkTime)
+ {
+ this->cursor_ = 0;
+ bShowCursor_ = !bShowCursor_;
+ if (bShowCursor_)
+ this->consoleOverlayCursor_->show();
+ else
+ this->consoleOverlayCursor_->hide();
+ }
+
+ // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+ float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+ float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+ this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+ }
+ }
+
+ /**
+ @brief Resizes the console elements. Call if window size changes.
+ */
+ void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
+ {
+ this->windowW_ = newWidth;
+ this->windowH_ = newHeight;
+ this->consoleOverlayBorder_->setWidth(static_cast<int>(this->windowW_* this->relativeWidth));
+ this->consoleOverlayBorder_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight));
+ this->consoleOverlayNoise_->setWidth(static_cast<int>(this->windowW_ * this->relativeWidth) - 10);
+ this->consoleOverlayNoise_->setHeight(static_cast<int>(this->windowH_ * this->relativeHeight) - 5);
+ this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
+
+ // now adjust the text lines...
+ this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
+
+ if (LINES > 0)
+ this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
+ else
+ this->maxCharsPerLine_ = 10;
+
+ for (int i = 0; i < LINES; i++)
+ {
+ this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+ this->consoleOverlayTextAreas_[i]->setTop(static_cast<int>(this->windowH_ * this->relativeHeight) - 24 - 14*i);
+ }
+
+ this->linesChanged();
+ this->cursorChanged();
+ }
+
+ // ###############################
+ // ### internal methods ###
+ // ###############################
+
+ /**
+ @brief Prints string to bottom line.
+ @param s String to be printed
+ */
+ void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+ {
+ char level = 0;
+ if (text.size() > 0)
+ level = text[0];
+
+ std::string output = text;
+
+ if (level >= -1 && level <= 5)
+ output.erase(0, 1);
+
+ if (LINES > index)
+ {
+ this->colourLine(level, index);
+
+ if (index > 0)
+ {
+ unsigned int linesUsed = 1;
+ while (output.size() > this->maxCharsPerLine_)
+ {
+ ++linesUsed;
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
+ output.erase(0, this->maxCharsPerLine_);
+ output.insert(0, 1, ' ');
+ if (linesUsed > numLinesShifted_ || alwaysShift)
+ this->shiftLines();
+ this->colourLine(level, index);
+ }
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ this->displayedText_ = output;
+ this->numLinesShifted_ = linesUsed;
+ }
+ else
+ {
+ if (output.size() > this->maxCharsPerLine_)
+ {
+ if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+ this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
+ else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+ this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
+
+ output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
+ }
+ else
+ this->inputWindowStart_ = 0;
+ this->displayedText_ = output;
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ }
+ }
+ }
+
+ /**
+ @brief Shows the InGameConsole.
+ */
+ void InGameConsole::activate()
+ {
+ if (!this->bActive_)
+ {
+ this->bActive_ = true;
+ InputManager::getInstance().enterState("console");
+ Shell::getInstance().registerListener(this);
+
+ this->windowResized(this->windowW_, this->windowH_);
+ this->linesChanged();
+ this->cursorChanged();
+ this->consoleOverlay_->show();
+
+ // scroll down
+ this->scroll_ = 1;
+ // the rest is done by tick
+ }
+ }
+
+ /**
+ @brief Hides the InGameConsole.
+ */
+ void InGameConsole::deactivate()
+ {
+ if (this->bActive_)
+ {
+ this->bActive_ = false;
+ InputManager::getInstance().leaveState("console");
+ Shell::getInstance().unregisterListener(this);
+
+ // scroll up
+ this->scroll_ = -1;
+ // the rest is done by tick
+ }
+ }
+
+ /**
+ @brief Shifts all output lines one line up
+ */
+ void InGameConsole::shiftLines()
+ {
+ for (unsigned int i = LINES - 1; i > 1; --i)
+ {
+ this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+ this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+ this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+ }
+ }
+
+ void InGameConsole::colourLine(int colourcode, int index)
+ {
+ if (colourcode == -1)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.90, 0.90, 0.90, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
+ }
+ else if (colourcode == 1)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.25, 0.25, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
+ }
+ else if (colourcode == 2)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.50, 0.20, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
+ }
+ else if (colourcode == 3)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.50, 0.50, 0.95, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
+ }
+ else if (colourcode == 4)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.65, 0.48, 0.44, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
+ }
+ else if (colourcode == 5)
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.40, 0.20, 0.40, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
+ }
+ else
+ {
+ this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.21, 0.69, 0.21, 1.00));
+ this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
+ }
+ }
+
+ // ###############################
+ // ### satic methods ###
+ // ###############################
+
+ /**
+ @brief Activates the console.
+ */
+ /*static*/ void InGameConsole::openConsole()
+ {
+ InGameConsole::getInstance().activate();
+ }
+
+ /**
+ @brief Deactivates the console.
+ */
+ /*static*/ void InGameConsole::closeConsole()
+ {
+ InGameConsole::getInstance().deactivate();
+ }
+}
Copied: code/trunk/src/orxonox/InGameConsole.h (from rev 5692, code/branches/libraries/src/orxonox/InGameConsole.h)
===================================================================
--- code/trunk/src/orxonox/InGameConsole.h (rev 0)
+++ code/trunk/src/orxonox/InGameConsole.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,118 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _InGameConsole_H__
+#define _InGameConsole_H__
+
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "util/OgreForwardRefs.h"
+#include "util/Singleton.h"
+#include "core/Shell.h"
+#include "core/WindowEventListener.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
+ {
+ friend class Singleton<InGameConsole>;
+ public: // functions
+ InGameConsole();
+ ~InGameConsole();
+
+ void initialise();
+ void destroy();
+ void setConfigValues();
+
+ void update(const Clock& time);
+
+ static void openConsole();
+ static void closeConsole();
+
+ private: // functions
+ InGameConsole(const InGameConsole& other);
+
+ void activate();
+ void deactivate();
+
+ void linesChanged();
+ void onlyLastLineChanged();
+ void lineAdded();
+ void inputChanged();
+ void cursorChanged();
+ void exit();
+
+ void shiftLines();
+ void colourLine(int colourcode, int index);
+ void setCursorPosition(unsigned int pos);
+ void print(const std::string& text, int index, bool alwaysShift = false);
+
+ void windowResized(unsigned int newWidth, unsigned int newHeight);
+
+ // config value related
+ void bHidesAllInputChanged();
+
+ private: // variables
+ bool bActive_;
+ int windowW_;
+ int windowH_;
+ int desiredTextWidth_;
+ unsigned int maxCharsPerLine_;
+ unsigned int numLinesShifted_;
+ int scroll_;
+ float cursor_;
+ unsigned int inputWindowStart_;
+ bool bShowCursor_;
+ std::string displayedText_;
+ Ogre::Overlay* consoleOverlay_;
+ Ogre::OverlayContainer* consoleOverlayContainer_;
+ Ogre::PanelOverlayElement* consoleOverlayNoise_;
+ Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
+ Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+ Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+ // input related
+ InputState* inputState_;
+
+ // config values
+ float relativeWidth;
+ float relativeHeight;
+ float blinkTime;
+ float scrollSpeed_;
+ float noiseSize_;
+ char cursorSymbol_;
+ bool bHidesAllInput_;
+
+ static InGameConsole* singletonPtr_s;
+ };
+}
+
+#endif /* _InGameConsole_H__ */
Modified: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/Main.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -26,27 +26,20 @@
* ...
*
*/
-
+
/**
@file
@brief
- Entry point of the program.
+ The main function of Orxonox.
*/
#include "OrxonoxPrereqs.h"
#include "SpecialConfig.h"
-#ifdef ORXONOX_USE_WINMAIN
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
-#include <windows.h>
-#endif
-
-#include "util/Debug.h"
#include "util/Exception.h"
#include "core/CommandLine.h"
#include "core/Game.h"
+#include "Main.h"
SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
// Shortcuts for easy direct loading
@@ -55,27 +48,15 @@
SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
SetCommandLineSwitch(standalone).information("Start in standalone mode");
-/*
- at brief
- Main method. Game starts here (except for static initialisations).
-*/
-#ifdef ORXONOX_USE_WINMAIN
-INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
-#else
-int main(int argc, char** argv)
-#endif
+namespace orxonox
{
- using namespace orxonox;
-
- Game* game = 0;
- try
+ /**
+ @brief
+ Main method. Game starts here (except for static initialisations).
+ */
+ int main(const std::string& strCmdLine)
{
-#ifndef ORXONOX_USE_WINMAIN
- std::string strCmdLine;
- for (int i = 1; i < argc; ++i)
- strCmdLine += argv[i] + std::string(" ");
-#endif
- game = new Game(strCmdLine);
+ Game* game = new Game(strCmdLine);
game->setStateHierarchy(
"root"
@@ -107,22 +88,10 @@
Game::getInstance().requestStates("ioConsole");
else
Game::getInstance().requestStates("graphics, mainMenu");
- }
- catch (const std::exception& ex)
- {
- COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
- COUT(0) << "Terminating program." << std::endl;
- return 1;
- }
- catch (...)
- {
- COUT(0) << "Orxonox failed to initialise: " << std::endl;
- COUT(0) << "Terminating program." << std::endl;
- return 1;
- }
- game->run();
- delete game;
+ game->run();
+ delete game;
- return 0;
+ return 0;
+ }
}
Copied: code/trunk/src/orxonox/Main.h (from rev 5692, code/branches/libraries/src/orxonox/Main.h)
===================================================================
--- code/trunk/src/orxonox/Main.h (rev 0)
+++ code/trunk/src/orxonox/Main.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,40 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Main_H__
+#define _Main_H__
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+ _OrxonoxExport int main(const std::string& strCmdLine);
+}
+
+#endif /* _Main_H__ */
Copied: code/trunk/src/orxonox/Map.cc (from rev 5692, code/branches/libraries/src/orxonox/Map.cc)
===================================================================
--- code/trunk/src/orxonox/Map.cc (rev 0)
+++ code/trunk/src/orxonox/Map.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,456 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Si Sun
+ *
+ */
+
+#include "Map.h"
+
+#include <string>
+
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreCamera.h>
+#include <OgreEntity.h>
+#include <OgreHardwarePixelBuffer.h>
+#include <OgreMaterialManager.h>
+#include <OgreMovablePlane.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayContainer.h>
+#include <OgreOverlayManager.h>
+#include <OgrePass.h>
+#include <OgreRenderTexture.h>
+#include <OgreResourceGroupManager.h>
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreTechnique.h>
+#include <OgreTexture.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "interfaces/RadarViewable.h"
+#include "objects/Scene.h"
+#include "objects/controllers/HumanController.h"
+#include "objects/worldentities/CameraPosition.h"
+#include "objects/worldentities/ControllableEntity.h"
+
+ namespace orxonox
+ {
+ CreateFactory(Map);
+ SetConsoleCommand(Map, openMap, true);
+ //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
+ //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
+ SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
+
+
+ Map* Map::singletonMap_s = 0;
+ Ogre::SceneManager* Map::mapSceneM_s = 0;
+ Ogre::Camera* Map::Cam_ = 0;
+ Ogre::SceneNode* Map::CamNode_ = 0;
+ Ogre::MaterialPtr Map::OverlayMaterial_;// = init();
+ Ogre::Overlay* Map::overlay_ = 0;
+/*
+Ogre::MaterialPtr Map::init()
+{
+ Ogre::MaterialPtr tmp;
+ tmp.setNull();
+ return tmp;
+}
+*/
+
+ //int Map::mouseLookSpeed_ = 200;
+ //Ogre::SceneNode* Map::playerShipNode_ = 0;
+
+ const int PITCH=-30;
+ const int DISTANCE=200;
+
+ Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
+ {
+ RegisterObject(Map);
+ Map::singletonMap_s=this;
+
+ //Getting Scene Manager (Hack)
+ if( !sManager_ )
+ {
+ ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+ this->sManager_ = it->getSceneManager();
+ }
+ if( !Map::getMapSceneManager() )
+ {
+ Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
+ }
+
+ this->playerShipNode_ = 0;
+ //this->sNode_ = new Ogre::SceneNode(sManager_);
+ //oManager_ = Ogre::OverlayManager::getSingletonPtr();
+ //overlay_ = oManager_->create("Map");
+ //overlay_ is member of OrxonoxOverlay
+
+ //Not Showing the map as default
+ //this->isVisible_=false;
+ //overlay_->hide();
+ this->mouseLookSpeed_ = 200;
+
+ //TestEntity
+ //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
+
+ //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
+ /*sNode_->setPosition(0,0,-50);
+ overlay_->add3D(sNode_);
+ */
+
+
+
+
+
+ // Alter the camera aspect ratio to match the viewport
+ //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
+ if(!Map::Cam_)
+ Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
+ //Cam_->setPosition(200,170, -160);
+ //Cam_->lookAt(0,0,0);
+ Cam_->setAspectRatio(1);
+ //Cam_->setRenderingDistance(0);
+ if(!Map::CamNode_)
+ CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
+
+
+ //Create overlay material
+ if(Map::OverlayMaterial_.isNull())
+ Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat");
+/*
+ Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+ Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+ renderTexture->addViewport(Cam_);
+ renderTexture->getViewport(0)->setClearEveryFrame(true);
+ renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+ renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+ Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Ogre::Technique *technique = material->createTechnique();
+ technique->createPass();
+ material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+ material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
+*/
+
+
+ // create overlay
+/*
+ Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
+
+ // Create a panel with RenderToTexture texture
+ Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+ m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+ m_pOverlayPanel->setPosition(10, 10);
+ m_pOverlayPanel->setDimensions(500, 300);
+ // Give overlay a texture
+ m_pOverlayPanel->setMaterialName(camMat_id);
+ pOverlay->add2D(m_pOverlayPanel);
+ pOverlay->show();
+*/
+ if(!this->overlay_)
+ {
+ this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
+ Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+ //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+ //m_pOverlayPanel->setPosition(10, 10);
+ //m_pOverlayPanel->setDimensions(600, 400);
+ m_pOverlayPanel->setPosition(0.01, 0.003);
+ m_pOverlayPanel->setDimensions(0.5, 0.4);
+ // Give overlay a texture
+ m_pOverlayPanel->setMaterialName("RttMat");
+ overlay_->add2D(m_pOverlayPanel);
+
+ //Add Borders
+ Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
+ oBorder->setBorderSize( 0.003, 0.003 );
+ oBorder->setDimensions(0.5, 0.4);
+ oBorder->setBorderMaterialName("StatsBorder");
+ oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
+ oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
+ oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
+ oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+ oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+ oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+ oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+ oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+ //overlay_->add2D(oBorder);
+ m_pOverlayPanel->addChild(oBorder);
+ }
+
+
+ //Not Showing the map as default
+ this->isVisible_=false;
+ overlay_->hide();
+
+ //Create plane to show gridTypeError: blimport() takes no keyword arguments
+/* Ogre::Entity* plane_ent;
+ if(Map::getMapSceneManager()->hasEntity("MapPlane"))
+ plane_ent = Map::getMapSceneManager()->getEntity("MapPlane");
+ else
+ plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
+*/
+ this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
+ this->movablePlane_->normalise();
+
+ if(!Map::getMapSceneManager()->hasEntity("MapPlane"))
+ {
+ Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
+ planeNode_ = Map::getMapSceneManager()->createSceneNode();
+ //Create plane for calculations
+
+
+ //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
+ //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
+ //plane_ent->setMaterialName("mapgrid");
+ plane_ent->setMaterialName("Map/Grid");
+ planeNode_->attachObject(plane_ent);
+
+ planeNode_->scale(160,1,160);
+// planeNode_->attachObject(movablePlane_);
+ //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
+
+
+ //ToDo create material script
+ Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
+ myManualObjectMaterial->setReceiveShadows(false);
+ myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
+ myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
+ }
+ }
+
+ Map::~Map()
+ {
+ this->singletonMap_s = 0;
+ //delete this->overlay_;
+ /*if (this->isInitialized())
+ {
+ //delete sManager_;
+ //delete Map::getMapSceneManager()->getRootSceneNode();
+ //delete oManager_;
+ //delete CamNode_;
+ //delete Cam_;
+ //delete mapSceneM_s;
+ //Map::getMapSceneManager()->destroyAllEntities();
+ //Map::getMapSceneManager()->destroyAllCameras();
+ delete Map::getMapSceneManager();
+ }*/
+ }
+
+ Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, const std::string& matName)
+ {
+ Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+ Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+ renderTexture->addViewport(cam);
+ renderTexture->getViewport(0)->setClearEveryFrame(true);
+ renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+ renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+ Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Ogre::Technique *technique = material->createTechnique();
+ technique->createPass();
+ material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+ material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex");
+ return material;
+ }
+
+ void Map::updatePositions()
+ {
+
+//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
+ for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
+ it!=ObjectList<orxonox::RadarViewable>::end();
+ it++)
+ {
+ //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
+ //Ogre::SceneNode node = it->getMapNode();
+ //Ogre::Entity ent = it->getMapEntity();
+ if( !(it->MapNode_) )
+ {
+ it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
+ //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
+ /*if(it->getRadarObjectShape() == RadarViewable::Dot)
+ {
+ //if( !(it->MapEntity_) )//check wether the entity is already attached
+ //{
+ //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
+ //it->addEntity();
+ //it->MapNode_->attachObject( it->MapEntity_ );
+ //it->MapNode_->attachObject( it->line_ );
+ // }
+ }*/
+ it->addMapEntity();
+ }
+ if(it->isHumanShip_)
+ {
+ this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+ if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
+ {
+ this->playerShipNode_ = it->MapNode_;
+ if(planeNode_ && this->planeNode_->getParent())
+ this->planeNode_->getParent()->removeChild(this->planeNode_);
+ this->playerShipNode_->addChild(this->planeNode_);
+ //Movable Plane needs to be attached direcly for calculations
+ //this->movablePlane_->detatchFromParent();
+ //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_);
+ //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+ //it->MapNode_->attachObject(this->movablePlane_);
+ if(planeNode_ && this->CamNode_->getParent())
+ this->CamNode_->getParent()->removeChild(this->CamNode_);
+ this->playerShipNode_->addChild(this->CamNode_);
+ this->CamNode_->attachObject(this->Cam_);
+ //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
+ //this->CamNodeHelper_->attachObject(this->Cam_);
+ this->Cam_->setPosition(0, 0, DISTANCE);
+ this->Cam_->pitch( static_cast<Degree>(PITCH) );
+ this->Cam_->lookAt(this->playerShipNode_->getPosition());
+ //this->Cam_->setAutoTracking(true, this->playerShipNode_);
+ }
+ }
+ it->updateMapPosition();
+
+
+
+
+
+
+ }
+ }
+
+
+
+ void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+ {
+ SUPER(Map, XMLPort, xmlElement, mode);
+ }
+
+ void Map::changedOwner()
+ {
+ SUPER(Map, changedOwner);
+ //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
+
+ ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
+ if(entity && entity->getReverseCamera())
+ {
+ //COUT(0) << "foo";
+ entity->getReverseCamera()->attachCamera(this->Cam_);
+ }
+ }
+
+
+ void Map::toggleVisibility()
+ {
+ if (!(this->isVisible_))
+ {
+ this->overlay_->show();
+ this->isVisible_=1;
+ //set mouselook when showing map
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
+ HumanController::localController_s->controllableEntity_->mouseLook();
+ }
+ else
+ {
+ this->overlay_->hide();
+ this->isVisible_=0;
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
+ HumanController::localController_s->controllableEntity_->mouseLook();
+ }
+ }
+
+ //Static function to toggle visibility of the map
+ void Map::openMap()
+ {
+ for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
+ it!=ObjectList<orxonox::Map>::end();
+ it++)
+ {
+ //Map * m = it->getMap();
+ //COUT(0) << it->isVisible_ << std::endl;
+ it->toggleVisibility();
+ //it->updatePositions();
+ }
+ }
+
+ // HACK!
+ void Map::hackDestroyMap()
+ {
+ Map::OverlayMaterial_.setNull();
+ }
+
+ void Map::tick(float dt)
+ {
+ //Debug
+ //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl;
+ //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl;
+ //COUT(0) << "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl;
+ if( this->isVisible_ )
+ updatePositions();
+ //Cam_->roll(Degree(1));
+
+ }
+
+ void Map::rotateYaw(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+
+/*
+ singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
+
+ Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+ Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+ singletonMap_s->CamNode_->yaw( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
+ }
+
+ void Map::rotatePitch(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+ //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
+/* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
+
+ Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+ Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+ singletonMap_s->CamNode_->pitch( static_cast<Degree>(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
+
+ }
+
+ void Map::Zoom(const Vector2& value)
+ {
+ if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+ return;
+ //COUT(0) << value.y << std::endl;
+ Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
+ }
+ }
Copied: code/trunk/src/orxonox/Map.h (from rev 5692, code/branches/libraries/src/orxonox/Map.h)
===================================================================
--- code/trunk/src/orxonox/Map.h (rev 0)
+++ code/trunk/src/orxonox/Map.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,118 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Si Sun
+ *
+ */
+
+#ifndef _Map_H__
+#define _Map_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreMaterial.h>
+
+#include "util/UtilPrereqs.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OrxonoxOverlay.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Map : public OrxonoxOverlay, public Tickable
+ {
+
+ public: // functions
+ Map(BaseObject* creator);
+ virtual ~Map();
+
+ virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+ virtual void changedOwner();
+
+ static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, const std::string& matName);
+
+ static void openMap();
+ // HACK!
+ static void hackDestroyMap();
+
+//Not yet implemented
+ static const int maxRange_s=1000;
+
+ static void rotateYaw(const Vector2& value);
+ static void rotatePitch(const Vector2& value);
+ static void Zoom(const Vector2& value);
+ // variables
+
+
+ bool inline getVisibility()
+ { return this->isVisible_; };
+
+ static inline Ogre::SceneManager* getMapSceneManagerPtr()
+ {
+ return Map::singletonMap_s->mapSceneM_s;
+ }
+ static inline Map* getSingletonPtr()
+ {
+ return Map::singletonMap_s;
+ }
+
+ static inline Ogre::SceneManager* getMapSceneManager()
+ {
+ return Map::mapSceneM_s;
+ }
+
+
+
+ private: // functions
+
+ void toggleVisibility();
+ void updatePositions();
+// void changedPlayerNode();
+ static inline void setMapSceneManager( Ogre::SceneManager * sm)
+ {
+ Map::mapSceneM_s = sm;
+ }
+ //static Ogre::MaterialPtr init();
+
+ private: // variables
+ static Map* singletonMap_s;
+
+ Ogre::SceneManager* sManager_;
+ Ogre::OverlayManager * oManager_;
+
+ static Ogre::SceneManager* mapSceneM_s;
+ static Ogre::SceneNode* CamNode_;
+ static Ogre::Camera* Cam_;
+ static Ogre::MaterialPtr OverlayMaterial_;
+ static Ogre::Overlay* overlay_;
+ //Ogre::SceneNode* CamNodeHelper_;
+ Ogre::SceneNode* playerShipNode_;
+ Ogre::SceneNode* planeNode_;
+ Ogre::MovablePlane* movablePlane_;
+ int mouseLookSpeed_;
+ bool isVisible_;
+
+ friend class RadarViewable;
+ };
+}
+
+#endif /* _Map_H__ */
Copied: code/trunk/src/orxonox/Orxonox.cc (from rev 5692, code/branches/libraries/src/orxonox/Orxonox.cc)
===================================================================
--- code/trunk/src/orxonox/Orxonox.cc (rev 0)
+++ code/trunk/src/orxonox/Orxonox.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,81 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Entry point of the program.
+*/
+
+#include "OrxonoxPrereqs.h"
+#include "SpecialConfig.h"
+
+#ifdef ORXONOX_USE_WINMAIN
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+#include <windows.h>
+#endif
+
+#include "util/Debug.h"
+#include "Main.h"
+
+/*
+ at brief
+ Main method. Game starts here (except for static initialisations).
+*/
+#ifdef ORXONOX_USE_WINMAIN
+INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
+#else
+int main(int argc, char** argv)
+#endif
+{
+ try
+ {
+#ifndef ORXONOX_USE_WINMAIN
+ std::string strCmdLine;
+ for (int i = 1; i < argc; ++i)
+ strCmdLine += argv[i] + std::string(" ");
+
+ return orxonox::main(strCmdLine);
+#endif
+ }
+ catch (const std::exception& ex)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
+}
Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -36,11 +36,12 @@
#include "OrxonoxConfig.h"
+#include "tools/ToolsPrereqs.h"
+
//-----------------------------------------------------------------------
// Shared library settings
//-----------------------------------------------------------------------
-#define ORXONOX_NO_EXPORTS // This is an executable that needs no exports
-#if defined(ORXONOX_PLATFORM_WINDOWS) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
# ifdef ORXONOX_SHARED_BUILD
# define _OrxonoxExport __declspec(dllexport)
# else
@@ -62,61 +63,34 @@
namespace orxonox
{
- namespace LODParticle
- {
- enum Value
- {
- Off = 0,
- Low = 1,
- Normal = 2,
- High = 3
- };
- }
-
- class RadarViewable;
- class Radar;
- class RadarListener;
-
- class Teamcolourable;
-
+ // manager
class CameraManager;
class LevelManager;
class PawnManager;
class PlayerManager;
+ // interfaces
+ class GametypeMessageListener;
+ class NotificationListener;
+ class PawnListener;
+ class RadarListener;
+ class RadarViewable;
+ class Rewardable;
+ class Teamcolourable;
+
// objects
class Level;
class Scene;
class Tickable;
- class AddQuest;
- class AddQuestHint;
- class AddReward;
- class ChangeQuestStatus;
- class CompleteQuest;
- class FailQuest;
- class GlobalQuest;
- class LocalQuest;
- class Quest;
- class QuestDescription;
- class QuestEffect;
- class QuestEffectBeacon;
- class QuestHint;
- class QuestItem;
- class QuestListener;
- class QuestManager;
- class QuestNotification;
- class Rewardable;
-
+ // worldentities
class WorldEntity;
class StaticEntity;
class MobileEntity;
class ControllableEntity;
class MovableEntity;
- class Sublevel;
- class ForceField;
- class Attacher;
+ // graphics
class Model;
class Billboard;
class BlinkingBillboard;
@@ -128,23 +102,45 @@
class Backlight;
class ParticleEmitter;
class ParticleSpawner;
+ class Camera;
+ // mixed
class PongCenterpoint;
class PongBall;
class PongBat;
- class Camera;
- class CameraPosition;
+ class EventListener;
+ class EventDispatcher;
+ class EventTarget;
+
class SpawnPoint;
class TeamSpawnPoint;
+
+ class Attacher;
+ class CameraPosition;
+ class Sublevel;
+ class ForceField;
+ class Radar;
+
class Test;
+ // pawns
class Spectator;
class Pawn;
class SpaceShip;
class TeamBaseMatchBase;
class Destroyer;
+ // gametypes
+ class Gametype;
+ class Deathmatch;
+ class TeamDeathmatch;
+ class Asteroids;
+ class TeamBaseMatch;
+ class UnderAttack;
+ class Pong;
+
+ // pickups
class BaseItem;
class DroppedItem;
class EquipmentItem;
@@ -159,17 +155,20 @@
class HealthUsable;
class PassiveItem;
+ // items
class Item;
class Engine;
class MultiStateEngine;
class RotatingEngine;
+ // trigger
class Trigger;
class DistanceTrigger;
class EventTrigger;
class PlayerTrigger;
class CheckPoint;
+ // weaponsystem
class WeaponSystem;
class WeaponSet;
class WeaponSlot;
@@ -177,28 +176,9 @@
class Weapon;
class WeaponMode;
class DefaultWeaponmodeLink;
- class MuzzleFlash;
-
- class LaserFire;
- class FusionFire;
- class HsW01;
- class LightningGun;
- class EnergyDrink;
-
- class ReplenishingMunition;
class Munition;
- class LaserMunition;
- class FusionMunition;
- class Projectile;
- class BillboardProjectile;
- class ParticleProjectile;
- class LightningGunProjectile;
-
- class EventListener;
- class EventDispatcher;
- class EventTarget;
-
+ // controller
class Controller;
class HumanController;
class ArtificialController;
@@ -208,6 +188,7 @@
class WaypointPatrolController;
class PongAI;
+ // infos
class Info;
class PlayerInfo;
class HumanPlayer;
@@ -215,19 +196,6 @@
class PongBot;
class GametypeInfo;
- class Gametype;
- class Deathmatch;
- class TeamDeathmatch;
- class Asteroids;
- class TeamBaseMatch;
- class UnderAttack;
- class Pong;
-
- class Scores;
- class CreateLines;
- class Scoreboard;
- class Stats;
-
// collision
class CollisionShape;
class SphereCollisionShape;
@@ -235,41 +203,12 @@
class PlaneCollisionShape;
class WorldEntityCollisionShape;
- // tools
- class BillboardSet;
- class Light;
- class Mesh;
- class ParticleInterface;
- class Shader;
- template <class T>
- class Timer;
-
// overlays
- class BarColour;
- class DebugFPSText;
- class DebugRTRText;
- class GUIOverlay;
- class HUDBar;
- class HUDNavigation;
- class HUDRadar;
- class HUDSpeedBar;
- class HUDHealthBar;
- class HUDTimer;
- class InGameConsole;
+ class OverlayGroup;
+ class OrxonoxOverlay;
class Notification;
class NotificationManager;
- class NotificationOverlay;
- class NotificationQueue;
- class OrxonoxOverlay;
- class OverlayGroup;
- class OverlayText;
- class FadeoutText;
- class GametypeStatus;
- class AnnounceMessage;
- class KillMessage;
- class DeathMessage;
- class CreateLines;
- class Scoreboard;
+ class InGameConsole;
class Map;
//sound
@@ -278,13 +217,6 @@
class SoundMainMenu;
}
-namespace Ogre
-{
- // OGRE Wiki adapted code
- class DynamicLines;
- class DynamicRenderable;
-}
-
// Bullet Physics Engine
class btTransform;
class btVector3;
Modified: code/trunk/src/orxonox/PawnManager.h
===================================================================
--- code/trunk/src/orxonox/PawnManager.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/PawnManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "util/Singleton.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/gamestates/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/gamestates/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+SET_SOURCE_FILES(GAMESTATES_SRC_FILES
GSClient.cc
GSDedicated.cc
GSGraphics.cc
@@ -9,3 +9,12 @@
GSServer.cc
GSStandalone.cc
)
+
+ORXONOX_ADD_LIBRARY(gamestates
+ MODULE
+ DEFINE_SYMBOL
+ "GAMESTATES_SHARED_BUILD"
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${GAMESTATES_SRC_FILES}
+)
Modified: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -39,7 +39,7 @@
{
DeclareGameState(GSClient, "client", false, true);
- SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#");
+ SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as string in the form #.#.#.#");
GSClient::GSClient(const GameStateInfo& info)
: GameState(info)
Modified: code/trunk/src/orxonox/gamestates/GSClient.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSClient.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _GSClient_H__
#define _GSClient_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
#include "network/NetworkPrereqs.h"
namespace orxonox
{
- class _OrxonoxExport GSClient : public GameState
+ class _GameStatesExport GSClient : public GameState
{
public:
GSClient(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSDedicated.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSDedicated.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _GSDedicated_H__
#define _GSDedicated_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
#include "network/NetworkPrereqs.h"
@@ -43,8 +43,8 @@
namespace orxonox
{
-
- class _OrxonoxExport GSDedicated : public GameState
+
+ class _GameStatesExport GSDedicated : public GameState
{
public:
GSDedicated(const GameStateInfo& info);
@@ -60,12 +60,12 @@
void processQueue();
void setTerminalMode();
static void resetTerminalMode();
-
+
void insertCharacter( unsigned int position, char c );
void deleteCharacter( unsigned int position );
-
+
Server* server_;
-
+
boost::thread *inputThread_;
boost::recursive_mutex inputLineMutex_;
boost::recursive_mutex inputQueueMutex_;
@@ -75,7 +75,7 @@
unsigned int inputIterator_;
std::queue<std::string> commandQueue_;
static termios* originalTerminalSettings_;
-
+
unsigned int cursorX_;
unsigned int cursorY_;
};
Modified: code/trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -46,11 +46,11 @@
#include "core/input/InputState.h"
#include "core/Loader.h"
#include "core/XMLFile.h"
-#include "overlays/console/InGameConsole.h"
+#include "InGameConsole.h"
#include "sound/SoundManager.h"
// HACK:
-#include "overlays/map/Map.h"
+#include "Map.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -35,7 +35,7 @@
#ifndef _GSGraphics_H__
#define _GSGraphics_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
namespace orxonox
@@ -46,7 +46,7 @@
This game state is only left out if we start a dedicated server where no graphics are present.
*/
- class _OrxonoxExport GSGraphics : public GameState
+ class _GameStatesExport GSGraphics : public GameState
{
public:
GSGraphics(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSIOConsole.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSIOConsole.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _GSIOConsole_H__
#define _GSIOConsole_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
namespace orxonox
{
- class _OrxonoxExport GSIOConsole : public GameState
+ class _GameStatesExport GSIOConsole : public GameState
{
public:
GSIOConsole(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -44,10 +44,8 @@
#include "core/Loader.h"
#include "core/XMLFile.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/Radar.h"
-#include "objects/quest/QuestManager.h"
-#include "overlays/notifications/NotificationManager.h"
#include "CameraManager.h"
#include "LevelManager.h"
#include "PlayerManager.h"
@@ -109,10 +107,8 @@
this->playerManager_ = new PlayerManager();
- this->questManager_ = new QuestManager();
+ this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>();
- this->notificationManager_ = new NotificationManager();
-
if (GameMode::isMaster())
{
this->loadLevel();
@@ -200,18 +196,12 @@
this->playerManager_ = 0;
}
- if (this->questManager_)
+ if (this->scope_GSLevel_)
{
- delete this->questManager_;
- this->questManager_ = NULL;
+ delete this->scope_GSLevel_;
+ this->scope_GSLevel_ = NULL;
}
- if (this->notificationManager_)
- {
- delete this->notificationManager_;
- this->notificationManager_ = NULL;
- }
-
if (GameMode::showsGraphics())
{
gameInputState_->setHandler(0);
Modified: code/trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSLevel.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,15 +29,16 @@
#ifndef _GSLevel_H__
#define _GSLevel_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include <string>
+#include "util/Scope.h"
#include "core/OrxonoxClass.h"
#include "core/GameState.h"
namespace orxonox
{
- class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
+ class _GameStatesExport GSLevel : public GameState, public OrxonoxClass
{
public:
GSLevel(const GameStateInfo& info);
@@ -61,15 +62,14 @@
void tkeybind(const std::string& command);
void keybindInternal(const std::string& command, bool bTemporary);
- KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings
- InputState* gameInputState_; //!< input state for normal ingame playing
- InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI
- InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI
- Radar* radar_; //!< represents the Radar (not the HUD part)
- CameraManager* cameraManager_; //!< camera manager for this level
- PlayerManager* playerManager_; //!< player manager for this level
- QuestManager* questManager_;
- NotificationManager* notificationManager_;
+ KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings
+ InputState* gameInputState_; //!< input state for normal ingame playing
+ InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI
+ InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI
+ Radar* radar_; //!< represents the Radar (not the HUD part)
+ CameraManager* cameraManager_; //!< camera manager for this level
+ PlayerManager* playerManager_; //!< player manager for this level
+ Scope<ScopeID::GSLevel>* scope_GSLevel_;
//##### ConfigValues #####
std::string keyDetectorCallbackCode_;
Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _GSMainMenu_H__
#define _GSMainMenu_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "util/OgreForwardRefs.h"
#include "core/GameState.h"
namespace orxonox
{
- class _OrxonoxExport GSMainMenu : public GameState
+ class _GameStatesExport GSMainMenu : public GameState
{
public:
GSMainMenu(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -37,8 +37,8 @@
#include "ToluaBindCore.h"
#include "ToluaBindOrxonox.h"
#include "tools/Timer.h"
-#include "interfaces/TimeFactorListener.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/TimeFactorListener.h"
+#include "tools/interfaces/Tickable.h"
#include "LevelManager.h"
namespace orxonox
Modified: code/trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSRoot.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _GSRoot_H__
#define _GSRoot_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
namespace orxonox
{
- class _OrxonoxExport GSRoot : public GameState
+ class _GameStatesExport GSRoot : public GameState
{
public:
GSRoot(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSServer.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSServer.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _GSServer_H__
#define _GSServer_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
#include "network/NetworkPrereqs.h"
namespace orxonox
{
- class _OrxonoxExport GSServer : public GameState
+ class _GameStatesExport GSServer : public GameState
{
public:
GSServer(const GameStateInfo& info);
Modified: code/trunk/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSStandalone.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/gamestates/GSStandalone.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _GSStandalone_H__
#define _GSStandalone_H__
-#include "OrxonoxPrereqs.h"
+#include "gamestates/GameStatesPrereqs.h"
#include "core/GameState.h"
namespace orxonox
{
- class _OrxonoxExport GSStandalone : public GameState
+ class _GameStatesExport GSStandalone : public GameState
{
public:
GSStandalone(const GameStateInfo& info);
Copied: code/trunk/src/orxonox/gamestates/GameStatesPrereqs.h (from rev 5692, code/branches/libraries/src/orxonox/gamestates/GameStatesPrereqs.h)
===================================================================
--- code/trunk/src/orxonox/gamestates/GameStatesPrereqs.h (rev 0)
+++ code/trunk/src/orxonox/gamestates/GameStatesPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,60 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _GameStatesPrereqs_H__
+#define _GameStatesPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef GAMESTATES_SHARED_BUILD
+# define _GameStatesExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _GameStatesExport
+# else
+# define _GameStatesExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _GameStatesExport __attribute__ ((visibility("default")))
+#else
+# define _GameStatesExport
+#endif
+
+#endif /* _GameStatesPrereqs_H__ */
Modified: code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
/**
@file
@brief
- Compiles all the interfaces (except RadarViewable) with mostly just a constructor.
+ Compiles all the interfaces in the orxonox library with mostly just a constructor.
*/
#include "GametypeMessageListener.h"
@@ -37,8 +37,7 @@
#include "RadarListener.h"
#include "Rewardable.h"
#include "TeamColourable.h"
-#include "Tickable.h"
-#include "TimeFactorListener.h"
+#include "NotificationListener.h"
#include "core/CoreIncludes.h"
@@ -80,31 +79,18 @@
}
//----------------------------
- // TimeFactorListener
+ // Rewardable
//----------------------------
- float TimeFactorListener::timefactor_s = 1.0f;
-
- TimeFactorListener::TimeFactorListener()
+ Rewardable::Rewardable()
{
- RegisterRootObject(TimeFactorListener);
+ RegisterObject(Rewardable);
}
//----------------------------
- // Tickable
+ // NotificationListener
//----------------------------
- /**
- @brief Constructor: Registers the object in the Tickable-list
- */
- Tickable::Tickable()
+ NotificationListener::NotificationListener()
{
- RegisterRootObject(Tickable);
+ RegisterObject(NotificationListener);
}
-
- //----------------------------
- // Rewardable
- //----------------------------
- Rewardable::Rewardable()
- {
- RegisterObject(Rewardable);
- }
}
Copied: code/trunk/src/orxonox/interfaces/NotificationListener.h (from rev 5692, code/branches/libraries/src/orxonox/interfaces/NotificationListener.h)
===================================================================
--- code/trunk/src/orxonox/interfaces/NotificationListener.h (rev 0)
+++ code/trunk/src/orxonox/interfaces/NotificationListener.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,59 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationListener class.
+*/
+
+#ifndef _NotificationListener_H__
+#define _NotificationListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <ctime>
+#include <set>
+#include <string>
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
+ {
+ public:
+ NotificationListener();
+ virtual ~NotificationListener() {}
+
+ virtual const std::set<std::string> & getTargetsSet() = 0;
+ virtual void update(void) = 0;
+ virtual void update(Notification* notification, const std::time_t & time) = 0;
+ };
+}
+
+#endif /* _NotificationListener_H__ */
Modified: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -37,7 +37,7 @@
#include "tools/DynamicLines.h"
#include "objects/worldentities/WorldEntity.h"
#include "objects/Radar.h"
-#include "overlays/map/Map.h"
+#include "Map.h"
namespace orxonox
{
Deleted: code/trunk/src/orxonox/interfaces/Tickable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/Tickable.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/interfaces/Tickable.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,68 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/*!
- @file
- @brief Declaration of the Tickable interface.
-
- The Tickable interface provides a tick(dt) function, that gets called every frame.
- float dt is the time since the last frame in seconds.
-
- Attention:
- Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
- parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
-*/
-
-#ifndef _Tickable_H__
-#define _Tickable_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "core/OrxonoxClass.h"
-#include "core/Super.h"
-
-namespace orxonox
-{
- //! The Tickable interface provides a tick(dt) function, that gets called every frame.
- class _OrxonoxExport Tickable : virtual public OrxonoxClass
- {
- public:
- /**
- @brief Gets called every frame.
- @param dt The time since the last frame in seconds
- */
- virtual void tick(float dt) { }
-
- protected:
- Tickable();
- };
-
- SUPER_FUNCTION(1, Tickable, tick, true);
-}
-
-#endif /* _Tickable_H__ */
Deleted: code/trunk/src/orxonox/interfaces/TimeFactorListener.h
===================================================================
--- code/trunk/src/orxonox/interfaces/TimeFactorListener.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/interfaces/TimeFactorListener.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,55 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TimeFactorListener_H__
-#define _TimeFactorListener_H__
-
-#include "OrxonoxPrereqs.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
- class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
- {
- friend class GSRoot;
-
- public:
- TimeFactorListener();
- virtual ~TimeFactorListener() {}
-
- protected:
- virtual void changedTimeFactor(float factor_new, float factor_old) {}
- inline float getTimeFactor() const
- { return TimeFactorListener::timefactor_s; }
-
- private:
- static float timefactor_s;
- };
-}
-
-#endif /* _TimeFactorListener_H__ */
Modified: code/trunk/src/orxonox/objects/Radar.h
===================================================================
--- code/trunk/src/orxonox/objects/Radar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/Radar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -41,7 +41,7 @@
#include "core/ObjectListIterator.h"
#include "interfaces/RadarViewable.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/objects/Scene.h
===================================================================
--- code/trunk/src/orxonox/objects/Scene.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/Scene.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -40,7 +40,7 @@
#include "util/OgreForwardRefs.h"
#include "core/BaseObject.h"
#include "network/synchronisable/Synchronisable.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/objects/Test.h
===================================================================
--- code/trunk/src/orxonox/objects/Test.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/Test.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "core/BaseObject.h"
#include "network/synchronisable/Synchronisable.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
typedef int TYPE;
@@ -49,7 +49,7 @@
void setConfigValues();
void registerVariables();
-
+
static void call(unsigned int clientID);
void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4);
virtual void tick(float dt);
@@ -64,7 +64,7 @@
void checkU2();
void checkU3();
void checkU4();
-
+
//signed functions
void setS1(TYPE value){ s1 = value; }
void setS2(TYPE value){ s2 = value; }
@@ -74,12 +74,12 @@
void checkS2();
void checkS3();
void checkS4();
-
+
static void printV1(){ instance_->checkU1(); }
static void printV2(){ instance_->checkU2(); }
static void printV3(){ instance_->checkU3(); }
static void printV4(){ instance_->checkU4(); }
-
+
void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5);
private:
@@ -87,12 +87,12 @@
UTYPE u2;
UTYPE u3;
UTYPE u4;
-
+
TYPE s1;
TYPE s2;
TYPE s3;
TYPE s4;
-
+
static Test* instance_;
};
}
Modified: code/trunk/src/orxonox/objects/controllers/AIController.h
===================================================================
--- code/trunk/src/orxonox/objects/controllers/AIController.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/controllers/AIController.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "tools/Timer.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "ArtificialController.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/objects/controllers/HumanController.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/controllers/HumanController.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#include "objects/worldentities/pawns/Pawn.h"
#include "objects/gametypes/Gametype.h"
#include "objects/infos/PlayerInfo.h"
-#include "overlays/map/Map.h"
+#include "Map.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/objects/controllers/PongAI.h
===================================================================
--- code/trunk/src/orxonox/objects/controllers/PongAI.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/controllers/PongAI.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -33,7 +33,7 @@
#include <list>
#include "util/Math.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "Controller.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/controllers/WaypointController.h
===================================================================
--- code/trunk/src/orxonox/objects/controllers/WaypointController.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/controllers/WaypointController.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include <vector>
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "ArtificialController.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/objects/gametypes/Gametype.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/gametypes/Gametype.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -37,7 +37,7 @@
#include "core/BaseObject.h"
#include "core/Identifier.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/infos/GametypeInfo.h"
namespace orxonox
@@ -132,7 +132,7 @@
virtual void removeTime(float t);
inline void startTimer()
- {
+ {
this->time_ = this->timeLimit_;
this->timerIsActive_ = true;
}
Modified: code/trunk/src/orxonox/objects/items/Engine.h
===================================================================
--- code/trunk/src/orxonox/objects/items/Engine.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/items/Engine.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -31,7 +31,7 @@
#include "OrxonoxPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "Item.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/pickup/DroppedItem.h
===================================================================
--- code/trunk/src/orxonox/objects/pickup/DroppedItem.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/pickup/DroppedItem.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -37,7 +37,7 @@
#include "OrxonoxPrereqs.h"
#include "tools/Timer.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/worldentities/StaticEntity.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/pickup/PickupSpawner.h
===================================================================
--- code/trunk/src/orxonox/objects/pickup/PickupSpawner.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/pickup/PickupSpawner.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -38,7 +38,7 @@
#include <string>
#include "tools/Timer.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/worldentities/StaticEntity.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/quest/AddQuest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/AddQuest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/AddQuest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _AddQuest_H__
#define _AddQuest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include "ChangeQuestStatus.h"
namespace orxonox
@@ -42,21 +42,21 @@
/**
@brief
Adds a Quest, resp. changes the quests status to active for the player invoking the Quest.
-
+
Creating a AddQuest through XML goes as follows:
-
+
<AddQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport AddQuest : public ChangeQuestStatus
+ class _QuestExport AddQuest : public ChangeQuestStatus
{
public:
AddQuest(BaseObject* creator);
virtual ~AddQuest();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
-
+
virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
};
Modified: code/trunk/src/orxonox/objects/quest/AddQuestHint.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/AddQuestHint.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/AddQuestHint.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _AddQuestHint_H__
#define _AddQuestHint_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
#include "QuestEffect.h"
@@ -44,14 +44,14 @@
/**
@brief
Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on.
-
+
Creating a AddQuestHint through XML goes as follows:
-
+
<AddQuestHint hintId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added.
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport AddQuestHint : public QuestEffect
+ class _QuestExport AddQuestHint : public QuestEffect
{
public:
AddQuestHint(BaseObject* creator);
@@ -70,7 +70,7 @@
*/
inline const std::string & getHintId(void) const
{ return this->hintId_; }
-
+
bool setHintId(const std::string & id); //!< Sets the id of the QuestHint.
};
Modified: code/trunk/src/orxonox/objects/quest/AddReward.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/AddReward.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/AddReward.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _AddReward_H__
#define _AddReward_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include "QuestEffect.h"
@@ -44,9 +44,9 @@
/**
@brief
Adds a list of Rewardables to a player.
-
+
Creating a AddReward through XML goes as follows:
-
+
<AddReward>
<Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
...
@@ -55,7 +55,7 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport AddReward : public QuestEffect
+ class _QuestExport AddReward : public QuestEffect
{
public:
AddReward(BaseObject* creator);
@@ -74,7 +74,7 @@
*/
inline void addRewardable(Rewardable* reward)
{ this->rewards_.push_back(reward); }
-
+
const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index.
};
Modified: code/trunk/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/objects/quest/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+SET_SOURCE_FILES(QUEST_SRC_FILES
AddQuest.cc
AddQuestHint.cc
AddReward.cc
@@ -17,3 +17,21 @@
QuestManager.cc
QuestNotification.cc
)
+
+ADD_SUBDIRECTORY(notifications)
+
+# add the parent directory for tolua (TODO: remove this if the quest module is moved somewhere else)
+INCLUDE_DIRECTORIES(..)
+
+ORXONOX_ADD_LIBRARY(quest
+ MODULE
+ TOLUA_FILES
+ QuestDescription.h
+ QuestManager.h
+ DEFINE_SYMBOL
+ "QUEST_SHARED_BUILD"
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ SOURCE_FILES ${QUEST_SRC_FILES}
+)
Modified: code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _ChangeQuestStatus_H__
#define _ChangeQuestStatus_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
#include "QuestEffect.h"
@@ -47,7 +47,7 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport ChangeQuestStatus : public QuestEffect
+ class _QuestExport ChangeQuestStatus : public QuestEffect
{
public:
ChangeQuestStatus(BaseObject* creator);
@@ -67,7 +67,7 @@
private:
std::string questId_; //!< The id of the Quest the status should be changed of.
-
+
bool setQuestId(const std::string & id); //!< Sets the id of the Quest.
};
Modified: code/trunk/src/orxonox/objects/quest/CompleteQuest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/CompleteQuest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/CompleteQuest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _CompleteQuest_H__
#define _CompleteQuest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include "ChangeQuestStatus.h"
namespace orxonox
@@ -42,14 +42,14 @@
/**
@brief
Completes a Quest (with a specified id) for the player invoking the QuestEffect.
-
+
Creating a CompleteQuest through XML goes as follows:
-
+
<CompleteQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed.
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport CompleteQuest : public ChangeQuestStatus
+ class _QuestExport CompleteQuest : public ChangeQuestStatus
{
public:
CompleteQuest(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/quest/FailQuest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/FailQuest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/FailQuest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _FailQuest_H__
#define _FailQuest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include "ChangeQuestStatus.h"
namespace orxonox
@@ -42,14 +42,14 @@
/**
@brief
Fails a quest (with a specified id) for the player invoking the QuestEffect.
-
+
Creating a FailQuest through XML goes as follows:
-
+
<FailQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed.
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport FailQuest : public ChangeQuestStatus
+ class _QuestExport FailQuest : public ChangeQuestStatus
{
public:
FailQuest(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/quest/GlobalQuest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/GlobalQuest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/GlobalQuest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the GlobalQuest class.
@@ -34,7 +34,7 @@
#ifndef _GlobalQuest_H__
#define _GlobalQuest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include <set>
@@ -46,9 +46,9 @@
@brief
GlobalQuests are Quests, that have the same status for all players.
This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it.
-
+
Creating a GlobalQuest through XML goes as follows:
-
+
<GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
<QuestDescription title="Title" description="Description." /> //The description of the quest.
<subquests>
@@ -80,14 +80,14 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport GlobalQuest : public Quest
+ class _QuestExport GlobalQuest : public Quest
{
public:
GlobalQuest(BaseObject* creator);
virtual ~GlobalQuest();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a GlobalQuest object through XML.
-
+
virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
@@ -97,14 +97,14 @@
virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
-
+
virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
private:
std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
QuestStatus::Value status_; //!< The status of this Quest.
std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
-
+
bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects.
const QuestEffect* getRewardEffects(unsigned int index) const; //!< Returns the reward QuestEffect at the given index.
Modified: code/trunk/src/orxonox/objects/quest/LocalQuest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/LocalQuest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/LocalQuest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the LocalQuest class.
@@ -34,7 +34,7 @@
#ifndef _LocalQuest_H__
#define _LocalQuest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <map>
#include "Quest.h"
@@ -45,9 +45,9 @@
@brief
Handles Quests which have different states for different players.
LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest.
-
+
Creating a LocalQuest through XML goes as follows:
-
+
<LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
<QuestDescription title="Title" description="Description." /> //The description of the quest.
<subquests>
@@ -74,14 +74,14 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport LocalQuest : public Quest
+ class _QuestExport LocalQuest : public Quest
{
public:
LocalQuest(BaseObject* creator);
virtual ~LocalQuest();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a LocalQuest object through XML.
-
+
virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
Modified: code/trunk/src/orxonox/objects/quest/Quest.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/Quest.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/Quest.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,17 +25,17 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the Quest class.
The Quest is the parent class of LocalQuest and GlobalQuest.
*/
-
+
#ifndef _Quest_H__
#define _Quest_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include "QuestItem.h"
@@ -61,12 +61,12 @@
Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player.
A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest.
A Quest has a list of QuestEffects that are invoked when the quest is failed and also a list of QuestEffects that are invoked, when the Quest is completed.
-
+
Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better.
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport Quest : public QuestItem
+ class _QuestExport Quest : public QuestItem
{
public:
Quest(BaseObject* creator);
@@ -80,7 +80,7 @@
*/
inline Quest* getParentQuest(void) const
{ return this->parentQuest_; }
-
+
/**
@brief Returns the list of subquests.
@return Returns a reference to the list of subquests of the quest.
@@ -94,16 +94,16 @@
*/
inline const std::list<QuestHint*> & getHintsList(void) const
{ return this->hints_; }
-
+
bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
-
+
bool start(PlayerInfo* player); //!< Sets a Quest to active.
virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
-
+
bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
protected:
@@ -115,14 +115,14 @@
const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index.
const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index.
const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the complete QuestEffect at the given index.
-
+
/**
@brief Returns the list of fail QuestEffects.
@return Returns a reference to the list of fail QuestEffects.
*/
inline std::list<QuestEffect*> & getFailEffectList(void)
{ return this->failEffects_; }
-
+
/**
@brief Returns the list of complete QuestEffects.
@return Returns a reference to the list of complete QuestEffects.
@@ -132,7 +132,7 @@
virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
-
+
private:
Quest* parentQuest_; //!< Pointer to the parentquest.
std::list<Quest*> subQuests_; //!< List of all the subquests.
@@ -141,9 +141,9 @@
std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed.
std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed.
-
+
std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest.
-
+
bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest.
bool addSubQuest(Quest* quest); //!< Adds a subquest to the Quest.
bool addHint(QuestHint* hint); //!< Add a QuestHint to the list of QuestHints.
Modified: code/trunk/src/orxonox/objects/quest/QuestDescription.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestDescription.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestDescription.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _QuestDescription_H__
#define _QuestDescription_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
#include "core/BaseObject.h"
@@ -46,14 +46,14 @@
@brief
This class is a description of a QuestItem.
It holds a title and a description.
-
+
Creating a QuestDescription through XML goes as follows:
-
+
<QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" />
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestDescription : public BaseObject
+ class _QuestExport QuestDescription : public BaseObject
{
// tolua_end
public:
@@ -69,7 +69,7 @@
*/
inline const std::string & getTitle(void) const
{ return this->title_; }
-
+
/**
@brief Returns the description text.
@return Returns a string containing the description text of the QuestDescription.
@@ -77,42 +77,42 @@
inline const std::string & getDescription(void) const
{ return this->description_; }
// tolua_end
-
+
/**
@brief Returns the fail message.
@return Returns a string containing the fail message of the QuestDescription.
*/
inline const std::string & getFailMessage(void) const
{ return this->failMessage_; }
-
+
/**
@brief Returns the complete message.
@return Returns a string containing the complete message of the QuestDescription.
*/
inline const std::string & getCompleteMessage(void) const
{ return this->completeMessage_; }
-
+
/**
@brief Sends a Notification displaying that a QuestHint was added.
@return Returns true if successful.
*/
inline bool sendAddHintNotification(void) const
{ return notificationHelper("hint", ""); }
-
+
/**
@brief Sends a Notification displaying that a Quest was added.
@return Returns true if successful.
*/
inline bool sendAddQuestNotification(void) const
{ return notificationHelper("quest", "start"); }
-
+
/**
@brief Sends a Notification displaying that a Quest was failed.
@return Returns true if successful.
*/
inline bool sendFailQuestNotification(void) const
{ return notificationHelper("quest", "fail"); }
-
+
/**
@brief Sends a Notification displaying that a Quest was completed.
@return Returns true if successful.
@@ -134,7 +134,7 @@
*/
inline void setTitle(const std::string & title)
{ this->title_ = title; }
-
+
/**
@brief Sets the description text.
@param description The description text to be set.
@@ -148,7 +148,7 @@
*/
inline void setFailMessage(const std::string & message)
{ this->failMessage_ = message; }
-
+
/**
@brief Sets the complete message.
@param message The complete message to be set.
Modified: code/trunk/src/orxonox/objects/quest/QuestEffect.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestEffect.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestEffect.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the QuestEffect class.
@@ -34,7 +34,7 @@
#ifndef _QuestEffect_H__
#define _QuestEffect_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include "core/BaseObject.h"
@@ -48,7 +48,7 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestEffect : public BaseObject
+ class _QuestExport QuestEffect : public BaseObject
{
public:
QuestEffect(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _QuestEffectBeacon_H__
#define _QuestEffectBeacon_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include "orxonox/objects/worldentities/StaticEntity.h"
@@ -57,9 +57,9 @@
The conditions under which the QuestEffects are invoked on the player are defined by Triggers.
A QuestEffectBeacon can be executed a defined number of times.
A QuestEffectBeacon can be inactive or active.
-
+
Creating a QuestEffectBeacon through XML goes as follows:
-
+
<QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
<effects>
<QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
@@ -78,49 +78,49 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestEffectBeacon : public StaticEntity
+ class _QuestExport QuestEffectBeacon : public StaticEntity
{
public:
QuestEffectBeacon(BaseObject* creator);
virtual ~QuestEffectBeacon();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
-
+
virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
-
+
bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
-
+
/**
@brief Tests whether the QuestEffectBeacon is active.
@return Returns true if the QuestEffectBeacon is active, fals if not.
*/
inline bool isActive(void)
{ return this->status_ == QuestEffectBeaconStatus::Active; }
-
+
bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
-
+
protected:
bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
-
+
/**
@brief Returns the number of times the QUestEffectBeacon can still be executed.
@return Returns the number of times the QUestEffectBeacon can still be executed.
*/
inline const int & getTimes(void) const
{ return this->times_; }
-
+
private:
static const int INFINITE_TIME = -1; //!< Constant to avoid using magic numbers.
-
+
std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
int times_; //!< Number of times the beacon can be exectued.
QuestEffectBeaconStatus::Value status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
-
+
bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
-
+
const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
-
+
};
}
Modified: code/trunk/src/orxonox/objects/quest/QuestHint.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestHint.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestHint.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the QuestHint class.
@@ -34,7 +34,7 @@
#ifndef _QuestHint_H__
#define _QuestHint_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <map>
#include "QuestItem.h"
@@ -56,16 +56,16 @@
Represents a hint in the game towards completing a Quest.
Consists of title and description (which is stored in a QuestDescription object) in textual form and must belong to a quest.
A QuestHint has a defined status (inactive or active, where inactive is default) for each player, which means each a QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them.
-
+
Creating a QuestHint through XML goes as follows:
-
+
<QuestHint id="hintId"> //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
<QuestDesctription title="" description="" />
</QuestHint>
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestHint : public QuestItem
+ class _QuestExport QuestHint : public QuestItem
{
public:
Modified: code/trunk/src/orxonox/objects/quest/QuestItem.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestItem.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestItem.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Definition of the QuestItem class.
@@ -36,7 +36,7 @@
#ifndef _QuestItem_H__
#define _QuestItem_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
#include "core/BaseObject.h"
@@ -50,7 +50,7 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestItem : public BaseObject
+ class _QuestExport QuestItem : public BaseObject
{
public:
@@ -65,7 +65,7 @@
*/
inline const std::string & getId(void) const
{ return this->id_; }
-
+
/**
@brief Returns the QuestDescription of the QuestItem.
@return Returns a pointer to the QuestDescription object of the QuestItem.
@@ -77,7 +77,7 @@
protected:
void setId(const std::string & id); //!< Sets the id of the QuestItem.
-
+
/**
@brief Sets the description of the QuestItem.
@param description The QuestDescription to be set.
Modified: code/trunk/src/orxonox/objects/quest/QuestListener.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestListener.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestListener.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _QuestListener_H__
#define _QuestListener_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
#include <list>
@@ -57,13 +57,13 @@
/**
@brief
Provides a way to react to the starting, completing and failing of Quests.
-
+
The XML representation goes as follows:
You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.
-
+
<BaseObject> // The object that should react to the status change of a Quest.
<events>
- <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity.
+ <function> // Where function is the method of the object that should be executed. Normally this would be visibility or activity.
<QuestListener questId="someQuestId" mode="someMode" /> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail).
</function>
</events>
@@ -71,28 +71,28 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestListener : public BaseObject
+ class _QuestExport QuestListener : public BaseObject
{
public:
QuestListener(BaseObject* creator);
virtual ~QuestListener();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML.
-
+
static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured.
-
+
bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to.
bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener.
-
+
std::string getMode(void); //!< Get the mode of the QuestListener.
-
- const std::string & getQuestId(void);
+
+ const std::string & getQuestId(void);
bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
-
+
private:
QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
-
+
};
}
Modified: code/trunk/src/orxonox/objects/quest/QuestManager.cc
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestManager.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestManager.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -35,10 +35,9 @@
#include "util/Exception.h"
#include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
#include "objects/infos/PlayerInfo.h"
-#include "objects/infos/PlayerInfo.h"
-#include "overlays/GUIOverlay.h"
#include "Quest.h"
#include "QuestHint.h"
#include "QuestItem.h"
@@ -65,7 +64,6 @@
*/
QuestManager::~QuestManager()
{
-
}
/**
@@ -202,37 +200,25 @@
/**
@brief
-
+
@param name
@return
*/
QuestContainer* QuestManager::getQuestTree(std::string & name)
{
- GUIOverlay* gui = NULL;
- for (ObjectList<GUIOverlay>::iterator it = ObjectList<GUIOverlay>::begin(); it != ObjectList<GUIOverlay>::end(); ++it)
- if (it->getGUIName() == name)
- gui = *it;
-
- PlayerInfo* player;
- if(gui == NULL)
+ PlayerInfo* player = GUIManager::getInstance().getPlayer(name);
+ if(player == NULL)
{
- COUT(1) << "Error: No GUIOverlay with the given name '" << name << "' present." << std::endl;
+ COUT(1) << "Error: GUIOverlay with name '" << name << "' has no player." << std::endl;
return NULL;
}
- BaseObject* obj = gui->getOwner();
- if(obj == NULL)
- {
- COUT(1) << "Error: GUIOverlay has no owner. " << std::endl;
- return NULL;
- }
- player = orxonox_cast<PlayerInfo*>(obj);
-
+
QuestContainer* root = NULL;
QuestContainer* current = NULL;
-
+
std::list<Quest*>* rootQuests = new std::list<Quest*>();
getRootQuests(player, *rootQuests);
-
+
for(std::list<Quest*>::iterator it = rootQuests->begin(); it != rootQuests->end(); it++)
{
QuestContainer* container = addSubQuest(*it, player);
@@ -245,7 +231,7 @@
{
current->next = container;
}
-
+
current = container;
}
@@ -259,7 +245,7 @@
/**
@brief
-
+
@param player
@param list
@return
@@ -278,7 +264,7 @@
/**
@brief
-
+
@param quest
@param player
@return
@@ -309,7 +295,7 @@
container->status = "";
COUT(1) << "An error occurred. A Quest of un-specified status wanted to be displayed." << std::endl;
}
-
+
std::list<Quest*> quests = quest->getSubQuestList();
QuestContainer* current = NULL;
QuestContainer* first = NULL;
@@ -328,20 +314,20 @@
{
current->next = subContainer;
}
-
+
current = subContainer;
}
}
if(current != NULL)
current->next = NULL;
container->subQuests = first;
-
+
return container;
}
/**
@brief
-
+
@param quest
@param player
@return
@@ -367,7 +353,7 @@
{
current->next = hint;
}
-
+
current = hint;
}
}
Modified: code/trunk/src/orxonox/objects/quest/QuestManager.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestManager.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,13 +34,13 @@
#ifndef _QuestManager_H__
#define _QuestManager_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <list>
#include <map>
#include <string>
-#include "util/Singleton.h"
+#include "util/ScopedSingleton.h"
#include "core/OrxonoxClass.h"
// tolua_begin
@@ -65,6 +65,8 @@
HintContainer* next;
};
+ typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua
+
/**
@brief
Is a Singleton and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).
@@ -72,16 +74,16 @@
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestManager : public Singleton<QuestManager>, public orxonox::OrxonoxClass
+ class _QuestExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass
{
// tolua_end
- friend class Singleton<QuestManager>;
+ friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
public:
QuestManager();
virtual ~QuestManager();
//! Returns a reference to the single instance of the Quest Manager.
- static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
+ static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export
bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
Modified: code/trunk/src/orxonox/objects/quest/QuestNotification.h
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestNotification.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/QuestNotification.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -25,37 +25,37 @@
* ...
*
*/
-
+
#ifndef _QuestNotification_H__
#define _QuestNotification_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
#include <string>
-#include "overlays/notifications/Notification.h"
+#include "notifications/Notification.h"
namespace orxonox {
/**
@brief
-
+
@author
Damian 'Mozork' Frick
*/
- class _OrxonoxExport QuestNotification : public Notification
+ class _QuestExport QuestNotification : public Notification
{
public:
QuestNotification(BaseObject* creator);
QuestNotification(const std::string & message);
virtual ~QuestNotification();
-
+
bool send(void);
-
+
private:
static const std::string SENDER;
-
+
void initialize(void);
-
+
};
}
Copied: code/trunk/src/orxonox/objects/quest/QuestPrereqs.h (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/QuestPrereqs.h)
===================================================================
--- code/trunk/src/orxonox/objects/quest/QuestPrereqs.h (rev 0)
+++ code/trunk/src/orxonox/objects/quest/QuestPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,92 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _QuestsystemPrereqs_H__
+#define _QuestsystemPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef QUEST_SHARED_BUILD
+# define _QuestExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _QuestExport
+# else
+# define _QuestExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _QuestExport __attribute__ ((visibility("default")))
+#else
+# define _QuestExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class AddQuest;
+ class AddQuestHint;
+ class AddReward;
+ class ChangeQuestStatus;
+ class CompleteQuest;
+ class FailQuest;
+ class GlobalQuest;
+ class LocalQuest;
+ class Quest;
+ class QuestDescription;
+ class QuestEffect;
+ class QuestEffectBeacon;
+ class QuestHint;
+ class QuestItem;
+ class QuestListener;
+ class QuestManager;
+ class QuestNotification;
+ class Rewardable;
+
+ class Notification;
+ class NotificationListener;
+ class NotificationManager;
+ class NotificationOverlay;
+ class NotificationQueue;
+}
+
+#endif /* _QuestsystemPrereqs_H__ */
Deleted: code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,6 +0,0 @@
-ADD_SOURCE_FILES(QUEST_SRC_FILES
- Notification.cc
- NotificationManager.cc
- NotificationOverlay.cc
- NotificationQueue.cc
-)
Copied: code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,6 @@
+ADD_SOURCE_FILES(QUEST_SRC_FILES
+ Notification.cc
+ NotificationManager.cc
+ NotificationOverlay.cc
+ NotificationQueue.cc
+)
Deleted: code/trunk/src/orxonox/objects/quest/notifications/Notification.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/Notification.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,130 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thes
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the Notification class.
-*/
-
-#include "Notification.h"
-
-#include "core/CoreIncludes.h"
-#include "NotificationManager.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- Default constructor. Initializes the object.
- */
- Notification::Notification(BaseObject* creator) : BaseObject(creator)
- {
- RegisterObject(Notification);
- this->initialize();
- }
-
- /**
- @brief
- Constructor. Creates a Notification with the input message.
- @param message
- The message of the Notification.
- */
- Notification::Notification(const std::string & message) : BaseObject(NULL)
- {
- this->message_ = message;
- }
-
- /**
- @brief
- Destructor.
- */
- Notification::~Notification()
- {
- }
-
- /**
- @brief
- Registers the object and sets some default values.
- */
- void Notification::initialize(void)
- {
- this->message_ = "";
- this->sender_ = NotificationManager::NONE;
- this->sent_ = false;
- }
-
- /**
- @brief
- Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
- @return
- Returns true if successful.
- */
- bool Notification::send(void)
- {
- return this->send(NotificationManager::NONE);
- }
-
- /**
- @brief
- Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
- @param sender
- The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
- @return
- Returns true if successful.
- */
- bool Notification::send(const std::string & sender)
- {
- this->sender_ = sender;
- bool successful = NotificationManager::getInstance().registerNotification(this);
- if(!successful)
- return false;
- this->sent_ = true;
-
- COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Sets the message of the notification.
- @param message
- The message to be set.
- @return
- Returns true if successful.
- */
- bool Notification::setMessage(const std::string & message)
- {
- if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
- return false;
- this->message_ = message;
- return true;
- }
-
-}
Copied: code/trunk/src/orxonox/objects/quest/notifications/Notification.cc (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/Notification.cc (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/Notification.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,130 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thes
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the Notification class.
+*/
+
+#include "Notification.h"
+
+#include "core/CoreIncludes.h"
+#include "NotificationManager.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Default constructor. Initializes the object.
+ */
+ Notification::Notification(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(Notification);
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Constructor. Creates a Notification with the input message.
+ @param message
+ The message of the Notification.
+ */
+ Notification::Notification(const std::string & message) : BaseObject(NULL)
+ {
+ this->message_ = message;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ Notification::~Notification()
+ {
+ }
+
+ /**
+ @brief
+ Registers the object and sets some default values.
+ */
+ void Notification::initialize(void)
+ {
+ this->message_ = "";
+ this->sender_ = NotificationManager::NONE;
+ this->sent_ = false;
+ }
+
+ /**
+ @brief
+ Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::send(void)
+ {
+ return this->send(NotificationManager::NONE);
+ }
+
+ /**
+ @brief
+ Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
+ @param sender
+ The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::send(const std::string & sender)
+ {
+ this->sender_ = sender;
+ bool successful = NotificationManager::getInstance().registerNotification(this);
+ if(!successful)
+ return false;
+ this->sent_ = true;
+
+ COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the message of the notification.
+ @param message
+ The message to be set.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::setMessage(const std::string & message)
+ {
+ if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
+ return false;
+ this->message_ = message;
+ return true;
+ }
+
+}
Deleted: code/trunk/src/orxonox/objects/quest/notifications/Notification.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/Notification.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,90 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the Notification class.
-*/
-
-#ifndef _Notification_H__
-#define _Notification_H__
-
-#include "objects/quest/QuestPrereqs.h"
-
-#include <string>
-#include "core/BaseObject.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper NotificationQueue (depending on which senders the specific NotificationQueue accepts).
- @author
- Damian 'Mozork' Frick
- */
- class _QuestExport Notification : public BaseObject
- {
- public:
- Notification(BaseObject* creator);
- Notification(const std::string & message);
- virtual ~Notification();
-
- bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
- bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.
-
- /**
- @brief Checks whether the Notification was sent.
- @return Returns true if the Notification was sent already.
- */
- inline bool isSent(void) const
- { return this->sent_; }
- /**
- @brief Returns the message of the Notification.
- @return Returns the message of the Notification.
- */
- inline const std::string & getMessage(void) const
- { return this->message_; }
-
- inline const std::string & getSender(void) const
- { return this->sender_; }
-
- bool setMessage(const std::string & message); //!< Sets the message of the notification.
-
- private:
- std::string message_; //!< The Notification message.
- std::string sender_; //!< The sender of the notification.
- bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
-
- void initialize(void);
-
- };
-
-}
-
-#endif /* _Notification_H__ */
Copied: code/trunk/src/orxonox/objects/quest/notifications/Notification.h (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/Notification.h (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/Notification.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,90 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the Notification class.
+*/
+
+#ifndef _Notification_H__
+#define _Notification_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <string>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper NotificationQueue (depending on which senders the specific NotificationQueue accepts).
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _QuestExport Notification : public BaseObject
+ {
+ public:
+ Notification(BaseObject* creator);
+ Notification(const std::string & message);
+ virtual ~Notification();
+
+ bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
+ bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.
+
+ /**
+ @brief Checks whether the Notification was sent.
+ @return Returns true if the Notification was sent already.
+ */
+ inline bool isSent(void) const
+ { return this->sent_; }
+ /**
+ @brief Returns the message of the Notification.
+ @return Returns the message of the Notification.
+ */
+ inline const std::string & getMessage(void) const
+ { return this->message_; }
+
+ inline const std::string & getSender(void) const
+ { return this->sender_; }
+
+ bool setMessage(const std::string & message); //!< Sets the message of the notification.
+
+ private:
+ std::string message_; //!< The Notification message.
+ std::string sender_; //!< The sender of the notification.
+ bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
+
+ void initialize(void);
+
+ };
+
+}
+
+#endif /* _Notification_H__ */
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,190 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the NotificationManager class.
-*/
-
-#include "NotificationManager.h"
-
-#include <set>
-
-#include "core/CoreIncludes.h"
-#include "Notification.h"
-#include "interfaces/NotificationListener.h"
-
-namespace orxonox
-{
-
- const std::string NotificationManager::ALL = "all";
- const std::string NotificationManager::NONE = "none";
-
- NotificationManager* NotificationManager::singletonPtr_s = NULL;
-
- /**
- @brief
- Constructor. Registers the Object.
- */
- NotificationManager::NotificationManager()
- {
- RegisterRootObject(NotificationManager);
-
- this->highestIndex_ = 0;
- }
-
- /**
- @brief
- Destructor.
- */
- NotificationManager::~NotificationManager()
- {
- }
-
- /**
- @brief
- Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
- @param notification
- The Notification to be registered.
- @return
- Returns true if successful.
- */
- bool NotificationManager::registerNotification(Notification* notification)
- {
-
- if(notification == NULL) //!< A NULL-Notification cannot be registered.
- return false;
-
- std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time.
-
- this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
-
- if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications.
- return true;
-
- bool all = false;
- if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationListener.
- all = true;
-
- //!< Insert the notification in all listeners that have its sender as target.
- for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) //!< Iterate through all listeners.
- {
- std::set<std::string> set = it->first->getTargetsSet();
- if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works.
- {
- this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener.
- it->first->update(notification, time); //!< Update the listener.
- }
- }
-
- COUT(3) << "Notification registered with the NotificationManager." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Registers a NotificationListener within the NotificationManager.
- @param listener
- The NotificationListener to be registered.
- @return
- Returns true if successful.
- */
- bool NotificationManager::registerListener(NotificationListener* listener)
- {
- this->highestIndex_ += 1;
- int index = this->highestIndex_;
-
- this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners.
-
- std::set<std::string> set = listener->getTargetsSet(); //TDO: Works this?
-
- //! If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
- if(set.find(ALL) != set.end())
- {
- this->notificationLists_[index] = &this->allNotificationsList_;
- COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
- return true;
- }
-
- this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
- std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
-
- //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
- for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
- {
- if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
- {
- map.insert(std::pair<std::time_t,Notification*>(it->first, it->second));
- }
- }
-
- listener->update(); //!< Update the listener.
-
- COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Fetches the Notifications for a specific NotificationListener in a specified timeframe.
- @param listener
- The NotificationListener the Notifications are fetched for.
- @param map
- A multimap, in which the notifications are stored.
- @param timeFrameStart
- The start time of the timeframe.
- @param timeFrameEnd
- The end time of the timeframe.
- @return
- Returns true if successful.
- */
- bool NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
- {
- if(listener == NULL || map == NULL)
- return false;
-
- std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; //!< The Notifications for the input NotificationListener.
-
- if(notifications == NULL) //!< Returns NULL, if there are no Notifications.
- return true;
-
- std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
- itLowest = notifications->lower_bound(timeFrameStart);
- itHighest = notifications->upper_bound(timeFrameStart);
-
- for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it.
- {
- map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map.
- }
-
- return true;
- }
-
-}
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,190 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the NotificationManager class.
+*/
+
+#include "NotificationManager.h"
+
+#include <set>
+
+#include "core/CoreIncludes.h"
+#include "Notification.h"
+#include "interfaces/NotificationListener.h"
+
+namespace orxonox
+{
+
+ const std::string NotificationManager::ALL = "all";
+ const std::string NotificationManager::NONE = "none";
+
+ NotificationManager* NotificationManager::singletonPtr_s = NULL;
+
+ /**
+ @brief
+ Constructor. Registers the Object.
+ */
+ NotificationManager::NotificationManager()
+ {
+ RegisterRootObject(NotificationManager);
+
+ this->highestIndex_ = 0;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ NotificationManager::~NotificationManager()
+ {
+ }
+
+ /**
+ @brief
+ Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
+ @param notification
+ The Notification to be registered.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::registerNotification(Notification* notification)
+ {
+
+ if(notification == NULL) //!< A NULL-Notification cannot be registered.
+ return false;
+
+ std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time.
+
+ this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
+
+ if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications.
+ return true;
+
+ bool all = false;
+ if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationListener.
+ all = true;
+
+ //!< Insert the notification in all listeners that have its sender as target.
+ for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) //!< Iterate through all listeners.
+ {
+ std::set<std::string> set = it->first->getTargetsSet();
+ if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works.
+ {
+ this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener.
+ it->first->update(notification, time); //!< Update the listener.
+ }
+ }
+
+ COUT(3) << "Notification registered with the NotificationManager." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Registers a NotificationListener within the NotificationManager.
+ @param listener
+ The NotificationListener to be registered.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::registerListener(NotificationListener* listener)
+ {
+ this->highestIndex_ += 1;
+ int index = this->highestIndex_;
+
+ this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners.
+
+ std::set<std::string> set = listener->getTargetsSet(); //TDO: Works this?
+
+ //! If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
+ if(set.find(ALL) != set.end())
+ {
+ this->notificationLists_[index] = &this->allNotificationsList_;
+ COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
+ return true;
+ }
+
+ this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
+ std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
+
+ //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
+ for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
+ {
+ if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
+ {
+ map.insert(std::pair<std::time_t,Notification*>(it->first, it->second));
+ }
+ }
+
+ listener->update(); //!< Update the listener.
+
+ COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Fetches the Notifications for a specific NotificationListener in a specified timeframe.
+ @param listener
+ The NotificationListener the Notifications are fetched for.
+ @param map
+ A multimap, in which the notifications are stored.
+ @param timeFrameStart
+ The start time of the timeframe.
+ @param timeFrameEnd
+ The end time of the timeframe.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
+ {
+ if(listener == NULL || map == NULL)
+ return false;
+
+ std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; //!< The Notifications for the input NotificationListener.
+
+ if(notifications == NULL) //!< Returns NULL, if there are no Notifications.
+ return true;
+
+ std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
+ itLowest = notifications->lower_bound(timeFrameStart);
+ itHighest = notifications->upper_bound(timeFrameStart);
+
+ for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it.
+ {
+ map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map.
+ }
+
+ return true;
+ }
+
+}
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,104 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the NotificationManager class.
-*/
-
-#ifndef _NotificationManager_H__
-#define _NotificationManager_H__
-
-#include "objects/quest/QuestPrereqs.h"
-
-#include <ctime>
-#include <map>
-#include <string>
-
-#include "util/ScopedSingleton.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners.
- It receives, organizes Notifications and the redistributes them to the specific NotificationListeners.
- @author
- Damian 'Mozork' Frick
- */
- class _QuestExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass
- {
- friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>;
- public:
- NotificationManager();
- virtual ~NotificationManager();
-
- static const std::string ALL;
- static const std::string NONE;
-
- bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
- bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
-
- bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe.
-
- /**
- @brief Fetches the Notifications for a specific NotificationListener starting at a specified time.
- @param listener The NotificationListener the Notifications are fetched for.
- @param map A multimap, in which the notifications are stored.
- @param timeFrameStart The start time the Notifications are fetched from.
- @return Returns true if successful.
- */
- bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
- { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); }
- /**
- @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
- @param listener The NotificationListener the Notifications are fetched for.
- @param map A multimap, in which the notifications are stored.
- @param timeDelay The timespan.
- @return Returns true if successful.
- */
- bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
- { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
-
- private:
- static NotificationManager* singletonPtr_s;
-
- int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
-
- std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).
- std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
- std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
-
-
- };
-
-}
-
-#endif /* _NotificationManager_H__ */
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,104 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationManager class.
+*/
+
+#ifndef _NotificationManager_H__
+#define _NotificationManager_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <ctime>
+#include <map>
+#include <string>
+
+#include "util/ScopedSingleton.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners.
+ It receives, organizes Notifications and the redistributes them to the specific NotificationListeners.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _QuestExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass
+ {
+ friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>;
+ public:
+ NotificationManager();
+ virtual ~NotificationManager();
+
+ static const std::string ALL;
+ static const std::string NONE;
+
+ bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
+ bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
+
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe.
+
+ /**
+ @brief Fetches the Notifications for a specific NotificationListener starting at a specified time.
+ @param listener The NotificationListener the Notifications are fetched for.
+ @param map A multimap, in which the notifications are stored.
+ @param timeFrameStart The start time the Notifications are fetched from.
+ @return Returns true if successful.
+ */
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
+ { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); }
+ /**
+ @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
+ @param listener The NotificationListener the Notifications are fetched for.
+ @param map A multimap, in which the notifications are stored.
+ @param timeDelay The timespan.
+ @return Returns true if successful.
+ */
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
+ { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
+
+ private:
+ static NotificationManager* singletonPtr_s;
+
+ int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
+
+ std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).
+ std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
+ std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
+
+
+ };
+
+}
+
+#endif /* _NotificationManager_H__ */
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,136 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the NotificationOverlay class.
-*/
-
-#include "NotificationOverlay.h"
-
-#include "util/Exception.h"
-#include "core/CoreIncludes.h"
-#include "objects/quest/notifications/Notification.h"
-#include "NotificationQueue.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- Constructor. Intializes the class.
- */
- NotificationOverlay::NotificationOverlay(BaseObject* creator) : OverlayText(creator)
- {
- RegisterObject(NotificationOverlay);
- this->initialize();
- }
-
- /**
- @brief
- Constructor. Initializes the class creates a graphical representation of the input Notification for the input Queue.
- @param queue
- A pointer to the queue the NotificatonOverlay belongs to.
- @param notification
- A pointer to the Notification represented by this overlay.
- @throws Argument
- Throws an Argument-Exception if either no Notification or no NotificationQueue were input.
- */
- NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OverlayText(NULL)
- {
- this->initialize();
-
- if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown.
- {
- ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
- }
-
- this->queue_ = queue;
- this->defineOverlay();
-
- this->processNotification(notification);
- }
-
- /**
- @brief
- Initializes and Registers the object.
- */
- void NotificationOverlay::initialize(void)
- {
- this->queue_ = NULL;
- }
-
- /**
- @brief
- Set some Overlay-specific values.
- */
- void NotificationOverlay::defineOverlay(void)
- {
- this->setFont(this->queue_->getFont());
- this->setTextSize(this->queue_->getFontSize());
-
- this->setPosition(this->queue_->getPosition());
- }
-
- /**
- @brief
- Destructor.
- */
- NotificationOverlay::~NotificationOverlay()
- {
- }
-
- /**
- @brief
- Processes the input notification, resp. sees to it. that the NotificationOverlay displays the Notification message.
- @param notification
- A pointer to the notification that should be processed.
- @return
- Returns true if successful.
- */
- bool NotificationOverlay::processNotification(Notification* notification)
- {
- if(notification == NULL)
- return false;
- this->setCaption(clipMessage(notification->getMessage()));
- this->notification_ = notification;
- return true;
- }
-
- /**
- @brief
- Clips the input message so that it meets the requirements for the maximal length of Notifications given by the NotificationQueue.
- */
- std::string NotificationOverlay::clipMessage(const std::string & message)
- {
- if(message.length() <= static_cast<unsigned int>(this->queue_->getNotificationLength())) //!< If the message is not too long.
- return message;
- return message.substr(0, this->queue_->getNotificationLength());
- }
-
-}
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.cc)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,136 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the NotificationOverlay class.
+*/
+
+#include "NotificationOverlay.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "objects/quest/notifications/Notification.h"
+#include "NotificationQueue.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Constructor. Intializes the class.
+ */
+ NotificationOverlay::NotificationOverlay(BaseObject* creator) : OverlayText(creator)
+ {
+ RegisterObject(NotificationOverlay);
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Constructor. Initializes the class creates a graphical representation of the input Notification for the input Queue.
+ @param queue
+ A pointer to the queue the NotificatonOverlay belongs to.
+ @param notification
+ A pointer to the Notification represented by this overlay.
+ @throws Argument
+ Throws an Argument-Exception if either no Notification or no NotificationQueue were input.
+ */
+ NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OverlayText(NULL)
+ {
+ this->initialize();
+
+ if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown.
+ {
+ ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
+ }
+
+ this->queue_ = queue;
+ this->defineOverlay();
+
+ this->processNotification(notification);
+ }
+
+ /**
+ @brief
+ Initializes and Registers the object.
+ */
+ void NotificationOverlay::initialize(void)
+ {
+ this->queue_ = NULL;
+ }
+
+ /**
+ @brief
+ Set some Overlay-specific values.
+ */
+ void NotificationOverlay::defineOverlay(void)
+ {
+ this->setFont(this->queue_->getFont());
+ this->setTextSize(this->queue_->getFontSize());
+
+ this->setPosition(this->queue_->getPosition());
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ NotificationOverlay::~NotificationOverlay()
+ {
+ }
+
+ /**
+ @brief
+ Processes the input notification, resp. sees to it. that the NotificationOverlay displays the Notification message.
+ @param notification
+ A pointer to the notification that should be processed.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationOverlay::processNotification(Notification* notification)
+ {
+ if(notification == NULL)
+ return false;
+ this->setCaption(clipMessage(notification->getMessage()));
+ this->notification_ = notification;
+ return true;
+ }
+
+ /**
+ @brief
+ Clips the input message so that it meets the requirements for the maximal length of Notifications given by the NotificationQueue.
+ */
+ std::string NotificationOverlay::clipMessage(const std::string & message)
+ {
+ if(message.length() <= static_cast<unsigned int>(this->queue_->getNotificationLength())) //!< If the message is not too long.
+ return message;
+ return message.substr(0, this->queue_->getNotificationLength());
+ }
+
+}
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,83 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the NotificationOverlay class.
-*/
-
-
-#ifndef _NotificationOverlay_H__
-#define _NotificationOverlay_H__
-
-#include "objects/quest/QuestPrereqs.h"
-
-#include <string>
-#include "orxonox/overlays/OverlayText.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The NotificationOverlay is used to display single Notifications, then bundled in a NotificationQUeue.
- @author
- Damian 'Mozork' Frick
- */
- class _QuestExport NotificationOverlay : public OverlayText
- {
-
- public:
- NotificationOverlay(BaseObject* creator);
- NotificationOverlay(NotificationQueue* queue, Notification* notification);
- virtual ~NotificationOverlay();
-
- bool processNotification(Notification* notification); //!< Processes the input Notification.
-
- /**
- @brief Sets the font size of this overlay's text.
- @param size The font size.
- */
- inline void setFontSize(float size)
- { this->setTextSize(size); }
-
- protected:
- std::string clipMessage(const std::string & message); //!< Clips the input message if too long.
-
- private:
- NotificationQueue* queue_; //!< The NotificationQeue this overlay belongs to.
- Notification* notification_; //!< The Notification this overlay displays.
-
- void initialize(void); //!< Initializes the object.
- void defineOverlay(void); //!< Sets some overlay-specific values.
-
- };
-
-}
-
-#endif /* _NotificationOverlay_H__ */
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.h)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationOverlay.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,83 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationOverlay class.
+*/
+
+
+#ifndef _NotificationOverlay_H__
+#define _NotificationOverlay_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <string>
+#include "orxonox/overlays/OverlayText.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The NotificationOverlay is used to display single Notifications, then bundled in a NotificationQUeue.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _QuestExport NotificationOverlay : public OverlayText
+ {
+
+ public:
+ NotificationOverlay(BaseObject* creator);
+ NotificationOverlay(NotificationQueue* queue, Notification* notification);
+ virtual ~NotificationOverlay();
+
+ bool processNotification(Notification* notification); //!< Processes the input Notification.
+
+ /**
+ @brief Sets the font size of this overlay's text.
+ @param size The font size.
+ */
+ inline void setFontSize(float size)
+ { this->setTextSize(size); }
+
+ protected:
+ std::string clipMessage(const std::string & message); //!< Clips the input message if too long.
+
+ private:
+ NotificationQueue* queue_; //!< The NotificationQeue this overlay belongs to.
+ Notification* notification_; //!< The Notification this overlay displays.
+
+ void initialize(void); //!< Initializes the object.
+ void defineOverlay(void); //!< Sets some overlay-specific values.
+
+ };
+
+}
+
+#endif /* _NotificationOverlay_H__ */
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,449 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the NotificationQueue class.
-*/
-
-#include "NotificationQueue.h"
-
-#include <sstream>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "NotificationOverlay.h"
-#include "objects/quest/notifications/NotificationManager.h"
-
-namespace orxonox
-{
-
- CreateFactory(NotificationQueue);
-
- const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";
- const Vector2 NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0);
- const float NotificationQueue::DEFAULT_FONT_SIZE = 0.025f;
-
- /**
- @brief
- Constructor. Creates and initializes the object.
- */
- NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
- {
- RegisterObject(NotificationQueue);
- this->initialize();
- }
-
- /**
- @brief
- Destructor.
- */
- NotificationQueue::~NotificationQueue()
- {
- this->targets_.clear();
- this->clear();
- }
-
- /**
- @brief
- Initializes the object.
- Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager.
- */
- void NotificationQueue::initialize(void)
- {
- this->size_ = 0;
- this->tickTime_ = 0.0;
-
- NotificationManager::getInstance().registerListener(this);
- }
-
- /**
- @brief
- Sets the defaults.
- */
- void NotificationQueue::setDefaults(void)
- {
- this->setMaxSize(DEFAULT_SIZE);
- this->setNotificationLength(DEFAULT_LENGTH);
- this->setDisplayTime(DEFAULT_DISPLAY_TIME);
- this->setPosition(DEFAULT_POSITION);
-
- this->setTargets(NotificationManager::ALL);
-
- this->setFontSize(DEFAULT_FONT_SIZE);
- this->setFont(DEFAULT_FONT);
- }
-
- /**
- @brief
- Method for creating a NotificationQueue object through XML.
- */
- void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode)
- {
- SUPER(NotificationQueue, XMLPort, xmlElement, mode);
-
- this->setDefaults();
-
- XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode);
- XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode);
- XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlElement, mode);
- XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlElement, mode);
- XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlElement, mode);
- XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode);
- XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
-
- COUT(3) << "NotificationQueue created." << std::endl;
- }
-
- /**
- @brief
- Updates the queue from time to time.
- @param dt
- The time interval that has passed since the last tick.
- */
- void NotificationQueue::tick(float dt)
- {
- this->tickTime_ += dt; //!< Add the time interval that has passed to the time counter.
- if(this->tickTime_ >= 1.0) //!< If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
- {
- this->timeLimit_.time = std::time(0)-this->displayTime_; //!< Container containig the current time.
-
- std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
- it = this->containers_.begin();
- while(it != this->containers_.upper_bound(&this->timeLimit_)) //!< Iterate through all elements whose creation time is smaller than the current time minus the display time.
- {
- this->removeContainer(*it);
- this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
- it = this->containers_.begin(); //TDO: Needed?
- }
-
- this->tickTime_ = 0.0; //!< Reset time counter.
- }
- }
-
- /**
- @brief
- Updates the NotificationQueue.
- Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting the in the queue.
- */
- void NotificationQueue::update(void)
- {
- this->clear();
-
- std::multimap<std::time_t,Notification*>* notifications = new std::multimap<std::time_t,Notification*>;
- if(!NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_)) //!< Get the Notifications sent in the interval form now to minus the display time.
- {
- COUT(1) << "NotificationQueue update failed due to undetermined cause." << std::endl;
- return;
- }
-
- if(notifications->empty())
- return;
-
- for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) //!> Add all Notifications.
- {
- this->addNotification(it->second, it->first);
- }
-
- delete notifications;
-
- COUT(3) << "NotificationQueue updated." << std::endl;
- }
-
- /**
- @brief
- Updates the NotificationQueue by adding an new Notification.
- @param notification
- Pointer to the Notification.
- @param time
- The time the Notification was sent.
- */
- void NotificationQueue::update(Notification* notification, const std::time_t & time)
- {
- this->addNotification(notification, time);
-
- std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
- while(this->getSize() > this->getMaxSize())
- {
- it = this->containers_.begin();
- this->removeContainer(*it);
- this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
- }
-
- COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
- }
-
- /**
- @brief
- Sets the maximum number of displayed Notifications.
- @param size
- The size to be set.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setMaxSize(int size)
- {
- if(size < 0)
- return false;
- this->maxSize_ = size;
- this->update();
- return true;
- }
-
- /**
- @brief
- Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
- @param length
- The length to be set.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setNotificationLength(int length)
- {
- if(length < 0)
- return false;
- this->notificationLength_ = length;
- this->update();
- return true;
- }
-
- /**
- @brief
- Sets the maximum number of seconds a Notification is displayed.
- @param time
- The number of seconds the Notifications is displayed.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setDisplayTime(int time)
- {
- if(time < 0)
- return false;
- this->displayTime_ = time;
- this->update();
- return true;
- }
-
- /**
- @brief
- Produces all targets concatinated as string, with kommas (',') as seperators.
- @param string
- Pointer to a string which will be used by the method to fill with the concatination of the targets.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::getTargets(std::string* string) const
- {
- if(string == NULL)
- {
- COUT(4) << "Input string must have memory allocated." << std::endl;
- return false;
- }
- string->clear();
- bool first = true;
- for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets.
- {
- if(!first)
- {
- *string += ",";
- }
- else
- {
- first = false;
- }
- *string += *it;
- }
-
- return true;
- }
-
- /**
- @brief
- Sets the targets of the queue.
- The targets are the senders whose Notifications are displayed in this queue.
- @param targets
- Accepts a string of targets, each seperated by commas (','), spaces are ignored.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setTargets(const std::string & targets)
- {
- this->targets_.clear();
-
- std::string* pTemp;
- unsigned int index = 0;
- while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
- {
- pTemp = new std::string("");
- while(index < targets.size() && targets[index] != ',' && targets[index] != ' ')
- {
- *pTemp += targets[index];
- index++;
- }
- index++;
- this->targets_.insert(*pTemp);
- }
-
- return true;
- }
-
- /**
- @brief
- Sets the font size.
- @param size
- The font size.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setFontSize(float size)
- {
- if(size <= 0)
- return false;
- this->fontSize_ = size;
- for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font size for each overlay.
- {
- it->second->overlay->setFontSize(size);
- }
- return true;
- }
-
- /**
- @brief
- Sets the font.
- @param font
- The font.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::setFont(const std::string & font)
- {
- this->font_ = font;
- for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font for each overlay.
- {
- it->second->overlay->setFont(font);
- }
- return true;
- }
-
- /**
- @brief
- Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
- @param pos
- The vector the NotificationQueue is scrolled.
- */
- void NotificationQueue::scroll(const Vector2 pos)
- {
- for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Scroll each overlay.
- {
- it->second->overlay->scroll(pos);
- }
- }
-
- /**
- @brief
- Aligns all the Notifications to the position of the NotificationQueue.
- */
- void NotificationQueue::positionChanged(void)
- {
- int counter = 0;
- for (std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin(); it != this->containers_.end(); it++) //!< Set the position for each overlay.
- {
- (*it)->overlay->setPosition(this->getPosition());
- (*it)->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*counter));
- counter++;
- }
- }
-
- /**
- @brief
- Adds a Notification, to the queue.
- It inserts it into the storage containers, creates an corresponding overlay and a container.
- @param notification
- The Notification.
- @param time
- The time.
- */
- void NotificationQueue::addNotification(Notification* notification, const std::time_t & time)
- {
- NotificationOverlayContainer* container = new NotificationOverlayContainer;
- container->overlay = new NotificationOverlay(this, notification);
- container->notification = notification;
- container->time = time;
- std::string timeString = std::ctime(&time);
- timeString.erase(timeString.length()-1);
- std::ostringstream stream;
- stream << reinterpret_cast<unsigned long>(notification);
- std::string addressString = stream.str() ;
- container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
-
- this->containers_.insert(container);
- this->overlays_[notification] = container;
- this->addElement(container->overlay);
- this->size_= this->size_+1;
-
- container->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*(this->getSize()-1)));
- }
-
- /**
- @brief
- Removes a container from the queue.
- @param container
- A pointer to the container.
- @return
- Returns true if successful.
- */
- bool NotificationQueue::removeContainer(NotificationOverlayContainer* container)
- {
- if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
- return false;
-
- this->removeElement(container->overlay);
- this->containers_.erase(container);
- this->overlays_.erase(container->notification);
- delete container->overlay;
- delete container;
- this->size_= this->size_-1;
-
- return true;
- }
-
- /**
- @brief
- Clears the queue by removing all containers.
- */
- void NotificationQueue::clear(void)
- {
- std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin();
- while(it != this->containers_.end())
- {
- this->removeContainer(*it);
- it = this->containers_.begin(); //TDO: Needed?
- }
- }
-
-}
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.cc)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,449 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the NotificationQueue class.
+*/
+
+#include "NotificationQueue.h"
+
+#include <sstream>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "NotificationOverlay.h"
+#include "objects/quest/notifications/NotificationManager.h"
+
+namespace orxonox
+{
+
+ CreateFactory(NotificationQueue);
+
+ const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";
+ const Vector2 NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0);
+ const float NotificationQueue::DEFAULT_FONT_SIZE = 0.025f;
+
+ /**
+ @brief
+ Constructor. Creates and initializes the object.
+ */
+ NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
+ {
+ RegisterObject(NotificationQueue);
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ NotificationQueue::~NotificationQueue()
+ {
+ this->targets_.clear();
+ this->clear();
+ }
+
+ /**
+ @brief
+ Initializes the object.
+ Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager.
+ */
+ void NotificationQueue::initialize(void)
+ {
+ this->size_ = 0;
+ this->tickTime_ = 0.0;
+
+ NotificationManager::getInstance().registerListener(this);
+ }
+
+ /**
+ @brief
+ Sets the defaults.
+ */
+ void NotificationQueue::setDefaults(void)
+ {
+ this->setMaxSize(DEFAULT_SIZE);
+ this->setNotificationLength(DEFAULT_LENGTH);
+ this->setDisplayTime(DEFAULT_DISPLAY_TIME);
+ this->setPosition(DEFAULT_POSITION);
+
+ this->setTargets(NotificationManager::ALL);
+
+ this->setFontSize(DEFAULT_FONT_SIZE);
+ this->setFont(DEFAULT_FONT);
+ }
+
+ /**
+ @brief
+ Method for creating a NotificationQueue object through XML.
+ */
+ void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+ {
+ SUPER(NotificationQueue, XMLPort, xmlElement, mode);
+
+ this->setDefaults();
+
+ XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode);
+ XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
+
+ COUT(3) << "NotificationQueue created." << std::endl;
+ }
+
+ /**
+ @brief
+ Updates the queue from time to time.
+ @param dt
+ The time interval that has passed since the last tick.
+ */
+ void NotificationQueue::tick(float dt)
+ {
+ this->tickTime_ += dt; //!< Add the time interval that has passed to the time counter.
+ if(this->tickTime_ >= 1.0) //!< If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
+ {
+ this->timeLimit_.time = std::time(0)-this->displayTime_; //!< Container containig the current time.
+
+ std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
+ it = this->containers_.begin();
+ while(it != this->containers_.upper_bound(&this->timeLimit_)) //!< Iterate through all elements whose creation time is smaller than the current time minus the display time.
+ {
+ this->removeContainer(*it);
+ this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
+ it = this->containers_.begin(); //TDO: Needed?
+ }
+
+ this->tickTime_ = 0.0; //!< Reset time counter.
+ }
+ }
+
+ /**
+ @brief
+ Updates the NotificationQueue.
+ Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting the in the queue.
+ */
+ void NotificationQueue::update(void)
+ {
+ this->clear();
+
+ std::multimap<std::time_t,Notification*>* notifications = new std::multimap<std::time_t,Notification*>;
+ if(!NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_)) //!< Get the Notifications sent in the interval form now to minus the display time.
+ {
+ COUT(1) << "NotificationQueue update failed due to undetermined cause." << std::endl;
+ return;
+ }
+
+ if(notifications->empty())
+ return;
+
+ for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) //!> Add all Notifications.
+ {
+ this->addNotification(it->second, it->first);
+ }
+
+ delete notifications;
+
+ COUT(3) << "NotificationQueue updated." << std::endl;
+ }
+
+ /**
+ @brief
+ Updates the NotificationQueue by adding an new Notification.
+ @param notification
+ Pointer to the Notification.
+ @param time
+ The time the Notification was sent.
+ */
+ void NotificationQueue::update(Notification* notification, const std::time_t & time)
+ {
+ this->addNotification(notification, time);
+
+ std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
+ while(this->getSize() > this->getMaxSize())
+ {
+ it = this->containers_.begin();
+ this->removeContainer(*it);
+ this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
+ }
+
+ COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
+ }
+
+ /**
+ @brief
+ Sets the maximum number of displayed Notifications.
+ @param size
+ The size to be set.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setMaxSize(int size)
+ {
+ if(size < 0)
+ return false;
+ this->maxSize_ = size;
+ this->update();
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
+ @param length
+ The length to be set.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setNotificationLength(int length)
+ {
+ if(length < 0)
+ return false;
+ this->notificationLength_ = length;
+ this->update();
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the maximum number of seconds a Notification is displayed.
+ @param time
+ The number of seconds the Notifications is displayed.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setDisplayTime(int time)
+ {
+ if(time < 0)
+ return false;
+ this->displayTime_ = time;
+ this->update();
+ return true;
+ }
+
+ /**
+ @brief
+ Produces all targets concatinated as string, with kommas (',') as seperators.
+ @param string
+ Pointer to a string which will be used by the method to fill with the concatination of the targets.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::getTargets(std::string* string) const
+ {
+ if(string == NULL)
+ {
+ COUT(4) << "Input string must have memory allocated." << std::endl;
+ return false;
+ }
+ string->clear();
+ bool first = true;
+ for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets.
+ {
+ if(!first)
+ {
+ *string += ",";
+ }
+ else
+ {
+ first = false;
+ }
+ *string += *it;
+ }
+
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the targets of the queue.
+ The targets are the senders whose Notifications are displayed in this queue.
+ @param targets
+ Accepts a string of targets, each seperated by commas (','), spaces are ignored.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setTargets(const std::string & targets)
+ {
+ this->targets_.clear();
+
+ std::string* pTemp;
+ unsigned int index = 0;
+ while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
+ {
+ pTemp = new std::string("");
+ while(index < targets.size() && targets[index] != ',' && targets[index] != ' ')
+ {
+ *pTemp += targets[index];
+ index++;
+ }
+ index++;
+ this->targets_.insert(*pTemp);
+ }
+
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the font size.
+ @param size
+ The font size.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setFontSize(float size)
+ {
+ if(size <= 0)
+ return false;
+ this->fontSize_ = size;
+ for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font size for each overlay.
+ {
+ it->second->overlay->setFontSize(size);
+ }
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the font.
+ @param font
+ The font.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::setFont(const std::string & font)
+ {
+ this->font_ = font;
+ for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font for each overlay.
+ {
+ it->second->overlay->setFont(font);
+ }
+ return true;
+ }
+
+ /**
+ @brief
+ Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
+ @param pos
+ The vector the NotificationQueue is scrolled.
+ */
+ void NotificationQueue::scroll(const Vector2 pos)
+ {
+ for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Scroll each overlay.
+ {
+ it->second->overlay->scroll(pos);
+ }
+ }
+
+ /**
+ @brief
+ Aligns all the Notifications to the position of the NotificationQueue.
+ */
+ void NotificationQueue::positionChanged(void)
+ {
+ int counter = 0;
+ for (std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin(); it != this->containers_.end(); it++) //!< Set the position for each overlay.
+ {
+ (*it)->overlay->setPosition(this->getPosition());
+ (*it)->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*counter));
+ counter++;
+ }
+ }
+
+ /**
+ @brief
+ Adds a Notification, to the queue.
+ It inserts it into the storage containers, creates an corresponding overlay and a container.
+ @param notification
+ The Notification.
+ @param time
+ The time.
+ */
+ void NotificationQueue::addNotification(Notification* notification, const std::time_t & time)
+ {
+ NotificationOverlayContainer* container = new NotificationOverlayContainer;
+ container->overlay = new NotificationOverlay(this, notification);
+ container->notification = notification;
+ container->time = time;
+ std::string timeString = std::ctime(&time);
+ timeString.erase(timeString.length()-1);
+ std::ostringstream stream;
+ stream << reinterpret_cast<unsigned long>(notification);
+ std::string addressString = stream.str() ;
+ container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
+
+ this->containers_.insert(container);
+ this->overlays_[notification] = container;
+ this->addElement(container->overlay);
+ this->size_= this->size_+1;
+
+ container->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*(this->getSize()-1)));
+ }
+
+ /**
+ @brief
+ Removes a container from the queue.
+ @param container
+ A pointer to the container.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationQueue::removeContainer(NotificationOverlayContainer* container)
+ {
+ if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
+ return false;
+
+ this->removeElement(container->overlay);
+ this->containers_.erase(container);
+ this->overlays_.erase(container->notification);
+ delete container->overlay;
+ delete container;
+ this->size_= this->size_-1;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Clears the queue by removing all containers.
+ */
+ void NotificationQueue::clear(void)
+ {
+ std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin();
+ while(it != this->containers_.end())
+ {
+ this->removeContainer(*it);
+ it = this->containers_.begin(); //TDO: Needed?
+ }
+ }
+
+}
Deleted: code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,210 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the NotificationQueue class.
-*/
-
-#ifndef _NotificationOueue_H__
-#define _NotificationOueue_H__
-
-#include "objects/quest/QuestPrereqs.h"
-
-#include <ctime>
-#include <map>
-#include <set>
-#include <string>
-
-#include "util/Math.h"
-#include "tools/interfaces/Tickable.h"
-#include "overlays/OverlayGroup.h"
-#include "interfaces/NotificationListener.h"
-
-namespace orxonox
-{
-
- //! Container to allow easy handling.
- struct NotificationOverlayContainer
- {
- NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
- Notification* notification; //!< The Notification displayed by the overlay.
- time_t time; //!< The time the Notification was sent and thus first displayed.
- std::string name; //!< The name of the overlay.
- };
-
- //! Struct to allow ordering of NotificationOverlayContainers.
- struct NotificationOverlayContainerCompare {
- bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
- { return a->time < b->time; } //!< Ordered by time.
- };
-
- /**
- @brief
- Displays Notifications from specific senders.
- Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
-
- Creating a NotificationQueue through XML goes as follows:
- <NotificationQueue
- name = "SuperQueue" //Name of your OverlayQueue.
- maxSize = "5" //The maximum size of Notifications displayed.
- notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 5)
- displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30)
- targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.)
- font = "VeraMono" //The font (Default is VeraMono)
- fontSize = '0.4' //The font size. (Default is 0.025)
- position = "0.0, .0.0" //The position of the NotificationQueue. (Default is 0.0,0.0)
- />
- @author
- Damian 'Mozork' Frick
- */
-
- class _QuestExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
- {
-
- public:
- NotificationQueue(BaseObject* creator);
- virtual ~NotificationQueue();
-
- virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
-
- virtual void tick(float dt); //!< To update from time to time.
-
- void update(void); //!< Updates the queue.
- void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
-
- /**
- @brief Returns the maximum number of Notifications displayed.
- @return Returns maximum size.
- */
- inline int getMaxSize() const
- { return this->maxSize_; }
- /**
- @brief Returns the current number of Notifications displayed.
- @return Returns the size of the queue.
- */
- inline int getSize() const
- { return this->size_; }
- /**
- @brief Returns the maximum length in characters a Notification message is allowed to have.
- @return Returns the maximum Notification length.
- */
- inline int getNotificationLength() const
- { return this->notificationLength_; }
- /**
- @brief Returns the time interval the Notification is displayed.
- @return Returns the display time.
- */
- inline int getDisplayTime() const
- { return this->displayTime_; }
- /**
- @brief Returns the position of the NotificationQueue.
- @return Returns the position.
- */
- inline const Vector2 & getPosition() const
- { return this->position_; }
- /**
- @brief Returns the font size used to display the Notifications.
- @return Returns the font size.
- */
- inline float getFontSize() const
- { return this->fontSize_; }
- /**
- @brief Returns the font used to display the Notifications.
- @return Returns the font.
- */
- inline const std::string & getFont() const
- { return this->font_; }
-
- /**
- @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
- @return Retuns a set of string holding the different targets.
- */
- inline const std::set<std::string> & getTargetsSet()
- { return this->targets_; }
- bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
-
- /**
- @brief Sets the position of the NotificationQueue.
- @param pos The position.
- */
- inline void setPosition(Vector2 pos)
- { this->position_ = pos; this->positionChanged(); }
-
- void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
-
- private:
- static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
- static const int DEFAULT_LENGTH = 64; //!< The default maximum number of Notifications displayed.
- static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
- static const float DEFAULT_FONT_SIZE; //!< The default font size.
-
- static const std::string DEFAULT_FONT; //!< The default font.
- static const Vector2 DEFAULT_POSITION; //!< the default position.
-
- int maxSize_; //!< The maximal number of Notifications displayed.
- int size_; //!< The number of Notifications displayed.
- int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
- int displayTime_; //!< The time a Notification is displayed.
- Vector2 position_; //!< The position of the NotificationQueue.
-
- std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
-
- float fontSize_; //!< The font size.
- std::string font_; //!< The font.
-
- std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
- std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
-
- float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
- NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
-
- void initialize(void); //!< Initializes the object.
- void setDefaults(void); //!< Helper method to set the default values.
-
- bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
- bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
- bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
-
- bool setTargets(const std::string & targets); //!< Set the targets of this queue.
-
- bool setFontSize(float size); //!< Set the font size.
- bool setFont(const std::string & font); //!< Set the font.
-
- void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
-
- void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
- bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
-
- void clear(void); //!< Clear the queue.
-
- };
-
-}
-
-#endif /* _NotificationOverlay_H__ */
Copied: code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h (from rev 5692, code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.h)
===================================================================
--- code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h (rev 0)
+++ code/trunk/src/orxonox/objects/quest/notifications/NotificationQueue.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,210 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationQueue class.
+*/
+
+#ifndef _NotificationOueue_H__
+#define _NotificationOueue_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <ctime>
+#include <map>
+#include <set>
+#include <string>
+
+#include "util/Math.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayGroup.h"
+#include "interfaces/NotificationListener.h"
+
+namespace orxonox
+{
+
+ //! Container to allow easy handling.
+ struct NotificationOverlayContainer
+ {
+ NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
+ Notification* notification; //!< The Notification displayed by the overlay.
+ time_t time; //!< The time the Notification was sent and thus first displayed.
+ std::string name; //!< The name of the overlay.
+ };
+
+ //! Struct to allow ordering of NotificationOverlayContainers.
+ struct NotificationOverlayContainerCompare {
+ bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
+ { return a->time < b->time; } //!< Ordered by time.
+ };
+
+ /**
+ @brief
+ Displays Notifications from specific senders.
+ Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
+
+ Creating a NotificationQueue through XML goes as follows:
+ <NotificationQueue
+ name = "SuperQueue" //Name of your OverlayQueue.
+ maxSize = "5" //The maximum size of Notifications displayed.
+ notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 5)
+ displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30)
+ targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.)
+ font = "VeraMono" //The font (Default is VeraMono)
+ fontSize = '0.4' //The font size. (Default is 0.025)
+ position = "0.0, .0.0" //The position of the NotificationQueue. (Default is 0.0,0.0)
+ />
+ @author
+ Damian 'Mozork' Frick
+ */
+
+ class _QuestExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
+ {
+
+ public:
+ NotificationQueue(BaseObject* creator);
+ virtual ~NotificationQueue();
+
+ virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
+
+ virtual void tick(float dt); //!< To update from time to time.
+
+ void update(void); //!< Updates the queue.
+ void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
+
+ /**
+ @brief Returns the maximum number of Notifications displayed.
+ @return Returns maximum size.
+ */
+ inline int getMaxSize() const
+ { return this->maxSize_; }
+ /**
+ @brief Returns the current number of Notifications displayed.
+ @return Returns the size of the queue.
+ */
+ inline int getSize() const
+ { return this->size_; }
+ /**
+ @brief Returns the maximum length in characters a Notification message is allowed to have.
+ @return Returns the maximum Notification length.
+ */
+ inline int getNotificationLength() const
+ { return this->notificationLength_; }
+ /**
+ @brief Returns the time interval the Notification is displayed.
+ @return Returns the display time.
+ */
+ inline int getDisplayTime() const
+ { return this->displayTime_; }
+ /**
+ @brief Returns the position of the NotificationQueue.
+ @return Returns the position.
+ */
+ inline const Vector2 & getPosition() const
+ { return this->position_; }
+ /**
+ @brief Returns the font size used to display the Notifications.
+ @return Returns the font size.
+ */
+ inline float getFontSize() const
+ { return this->fontSize_; }
+ /**
+ @brief Returns the font used to display the Notifications.
+ @return Returns the font.
+ */
+ inline const std::string & getFont() const
+ { return this->font_; }
+
+ /**
+ @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
+ @return Retuns a set of string holding the different targets.
+ */
+ inline const std::set<std::string> & getTargetsSet()
+ { return this->targets_; }
+ bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
+
+ /**
+ @brief Sets the position of the NotificationQueue.
+ @param pos The position.
+ */
+ inline void setPosition(Vector2 pos)
+ { this->position_ = pos; this->positionChanged(); }
+
+ void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
+
+ private:
+ static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
+ static const int DEFAULT_LENGTH = 64; //!< The default maximum number of Notifications displayed.
+ static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
+ static const float DEFAULT_FONT_SIZE; //!< The default font size.
+
+ static const std::string DEFAULT_FONT; //!< The default font.
+ static const Vector2 DEFAULT_POSITION; //!< the default position.
+
+ int maxSize_; //!< The maximal number of Notifications displayed.
+ int size_; //!< The number of Notifications displayed.
+ int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
+ int displayTime_; //!< The time a Notification is displayed.
+ Vector2 position_; //!< The position of the NotificationQueue.
+
+ std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
+
+ float fontSize_; //!< The font size.
+ std::string font_; //!< The font.
+
+ std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
+ std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
+
+ float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
+ NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
+
+ void initialize(void); //!< Initializes the object.
+ void setDefaults(void); //!< Helper method to set the default values.
+
+ bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
+ bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
+ bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
+
+ bool setTargets(const std::string & targets); //!< Set the targets of this queue.
+
+ bool setFontSize(float size); //!< Set the font size.
+ bool setFont(const std::string & font); //!< Set the font.
+
+ void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
+
+ void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
+ bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
+
+ void clear(void); //!< Clear the queue.
+
+ };
+
+}
+
+#endif /* _NotificationOverlay_H__ */
Modified: code/trunk/src/orxonox/objects/weaponsystem/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -7,9 +7,21 @@
WeaponSlot.cc
WeaponSystem.cc
DefaultWeaponmodeLink.cc
+)
+
+SET_SOURCE_FILES(WEAPONSYSTEM_SRC_FILES
MuzzleFlash.cc
)
ADD_SUBDIRECTORY(munitions)
ADD_SUBDIRECTORY(projectiles)
ADD_SUBDIRECTORY(weaponmodes)
+
+ORXONOX_ADD_LIBRARY(weaponsystem
+ MODULE
+ DEFINE_SYMBOL
+ "WEAPONSYSTEM_SHARED_BUILD"
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${WEAPONSYSTEM_SRC_FILES}
+)
Modified: code/trunk/src/orxonox/objects/weaponsystem/MuzzleFlash.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/MuzzleFlash.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/MuzzleFlash.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _MuzzleFlash_H__
#define _MuzzleFlash_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "tools/Timer.h"
#include "objects/worldentities/Billboard.h"
namespace orxonox
{
- class _OrxonoxExport MuzzleFlash : public Billboard
+ class _WeaponsystemExport MuzzleFlash : public Billboard
{
public:
MuzzleFlash(BaseObject* creator);
Copied: code/trunk/src/orxonox/objects/weaponsystem/WeaponsystemPrereqs.h (from rev 5692, code/branches/libraries/src/orxonox/objects/weaponsystem/WeaponsystemPrereqs.h)
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/WeaponsystemPrereqs.h (rev 0)
+++ code/trunk/src/orxonox/objects/weaponsystem/WeaponsystemPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,84 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _WeaponsystemPrereqs_H__
+#define _WeaponsystemPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef WEAPONSYSTEM_SHARED_BUILD
+# define _WeaponsystemExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _WeaponsystemExport
+# else
+# define _WeaponsystemExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _WeaponsystemExport __attribute__ ((visibility("default")))
+#else
+# define _WeaponsystemExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class LaserFire;
+ class FusionFire;
+ class HsW01;
+ class LightningGun;
+ class EnergyDrink;
+
+ class Projectile;
+ class BillboardProjectile;
+ class ParticleProjectile;
+ class LightningGunProjectile;
+
+ class ReplenishingMunition;
+ class LaserMunition;
+ class FusionMunition;
+
+ class MuzzleFlash;
+}
+
+#endif /* _WeaponsystemPrereqs_H__ */
Modified: code/trunk/src/orxonox/objects/weaponsystem/munitions/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/munitions/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/munitions/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(WEAPONSYSTEM_SRC_FILES
ReplenishingMunition.cc
LaserMunition.cc
FusionMunition.cc
Modified: code/trunk/src/orxonox/objects/weaponsystem/munitions/FusionMunition.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/munitions/FusionMunition.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/munitions/FusionMunition.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _FusionMunition_H__
#define _FusionMunition_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "objects/weaponsystem/Munition.h"
namespace orxonox
{
- class _OrxonoxExport FusionMunition : public Munition
+ class _WeaponsystemExport FusionMunition : public Munition
{
public:
FusionMunition(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/munitions/LaserMunition.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/munitions/LaserMunition.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/munitions/LaserMunition.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _LaserMunition_H__
#define _LaserMunition_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "ReplenishingMunition.h"
namespace orxonox
{
- class _OrxonoxExport LaserMunition : public ReplenishingMunition
+ class _WeaponsystemExport LaserMunition : public ReplenishingMunition
{
public:
LaserMunition(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/munitions/ReplenishingMunition.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/munitions/ReplenishingMunition.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/munitions/ReplenishingMunition.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _ReplenishingMunition_H__
#define _ReplenishingMunition_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "tools/Timer.h"
#include "objects/weaponsystem/Munition.h"
namespace orxonox
{
- class _OrxonoxExport ReplenishingMunition : public Munition
+ class _WeaponsystemExport ReplenishingMunition : public Munition
{
public:
ReplenishingMunition(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/projectiles/BillboardProjectile.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/projectiles/BillboardProjectile.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/projectiles/BillboardProjectile.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _BillboardProjectile_H__
#define _BillboardProjectile_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "util/Math.h"
#include "tools/BillboardSet.h"
@@ -37,7 +37,7 @@
namespace orxonox
{
- class _OrxonoxExport BillboardProjectile : public Projectile
+ class _WeaponsystemExport BillboardProjectile : public Projectile
{
public:
BillboardProjectile(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/projectiles/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/projectiles/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/projectiles/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(WEAPONSYSTEM_SRC_FILES
BillboardProjectile.cc
ParticleProjectile.cc
Projectile.cc
Modified: code/trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _LightningGunProjectile_H__
#define _LightningGunProjectile_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include <string>
#include "tools/Timer.h"
@@ -37,16 +37,16 @@
namespace orxonox
{
- class _OrxonoxExport LightningGunProjectile : public BillboardProjectile
+ class _WeaponsystemExport LightningGunProjectile : public BillboardProjectile
{
public:
LightningGunProjectile(BaseObject* creator);
virtual ~LightningGunProjectile() {}
-
+
virtual void setMaterial(const std::string& material);
protected:
- void changeTexture();
+ void changeTexture();
unsigned int textureIndex_;
unsigned int maxTextureIndex_;
Timer<LightningGunProjectile> textureTimer_;
Modified: code/trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _ParticleProjectile_H__
#define _ParticleProjectile_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "BillboardProjectile.h"
namespace orxonox
{
- class _OrxonoxExport ParticleProjectile : public BillboardProjectile
+ class _WeaponsystemExport ParticleProjectile : public BillboardProjectile
{
public:
ParticleProjectile(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _Projectile_H__
#define _Projectile_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "tools/Timer.h"
#include "interfaces/PawnListener.h"
@@ -37,7 +37,7 @@
namespace orxonox
{
- class _OrxonoxExport Projectile : public MovableEntity, public PawnListener
+ class _WeaponsystemExport Projectile : public MovableEntity, public PawnListener
{
public:
Projectile(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(WEAPONSYSTEM_SRC_FILES
EnergyDrink.cc
FusionFire.cc
LaserFire.cc
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/EnergyDrink.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/EnergyDrink.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/EnergyDrink.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _EnergyDrink_H__
#define _EnergyDrink_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include <string>
#include "tools/Timer.h"
@@ -37,7 +37,7 @@
namespace orxonox
{
- class _OrxonoxExport EnergyDrink : public WeaponMode
+ class _WeaponsystemExport EnergyDrink : public WeaponMode
{
public:
EnergyDrink(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/FusionFire.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/FusionFire.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/FusionFire.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _FusionFire_H__
#define _FusionFire_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "objects/weaponsystem/WeaponMode.h"
namespace orxonox
{
- class _OrxonoxExport FusionFire : public WeaponMode
+ class _WeaponsystemExport FusionFire : public WeaponMode
{
public:
FusionFire(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _HsW01_H__
#define _HsW01_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "tools/Timer.h"
#include "objects/weaponsystem/WeaponMode.h"
namespace orxonox
{
- class _OrxonoxExport HsW01 : public WeaponMode
+ class _WeaponsystemExport HsW01 : public WeaponMode
{
public:
HsW01(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LaserFire.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LaserFire.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LaserFire.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _LaserFire_H__
#define _LaserFire_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "objects/weaponsystem/WeaponMode.h"
namespace orxonox
{
- class _OrxonoxExport LaserFire : public WeaponMode
+ class _WeaponsystemExport LaserFire : public WeaponMode
{
public:
LaserFire(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LightningGun.h
===================================================================
--- code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LightningGun.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/weaponsystem/weaponmodes/LightningGun.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _LightningGun_H__
#define _LightningGun_H__
-#include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponsystemPrereqs.h"
#include "objects/weaponsystem/WeaponMode.h"
namespace orxonox
{
- class _OrxonoxExport LightningGun : public WeaponMode
+ class _WeaponsystemExport LightningGun : public WeaponMode
{
public:
LightningGun(BaseObject* creator);
Modified: code/trunk/src/orxonox/objects/worldentities/Backlight.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/Backlight.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/Backlight.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include <string>
-#include "interfaces/TimeFactorListener.h"
+#include "tools/interfaces/TimeFactorListener.h"
#include "FadingBillboard.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "util/Math.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "Billboard.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/worldentities/Camera.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/Camera.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/Camera.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "util/OgreForwardRefs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/worldentities/StaticEntity.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/worldentities/FadingBillboard.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/FadingBillboard.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/FadingBillboard.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -33,7 +33,7 @@
#include "util/Math.h"
#include "tools/Timer.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "Billboard.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/worldentities/ForceField.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/ForceField.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/ForceField.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "StaticEntity.h"
namespace orxonox
@@ -42,21 +42,21 @@
public:
ForceField(BaseObject* creator);
virtual ~ForceField();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CheckPoint object through XML.
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void tick(float dt);
inline void setVelocity(float vel)
{ this->velocity_ = vel; }
-
+
inline float getVelocity()
{ return velocity_; }
-
+
inline void setDiameter(float diam)
{ this->diameter_ = diam; }
inline float getDiameter()
{ return diameter_; }
-
+
inline void setLength(float l)
{ this->length_ = l; }
Modified: code/trunk/src/orxonox/objects/worldentities/MobileEntity.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/MobileEntity.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/MobileEntity.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include "OrxonoxPrereqs.h"
#include "util/Math.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "WorldEntity.h"
namespace orxonox
Modified: code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -51,26 +51,26 @@
public:
PlayerTrigger(BaseObject* creator);
virtual ~PlayerTrigger();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML.
-
+
/**
@brief Returns the player that triggered the PlayerTrigger.
@return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
*/
inline Pawn* getTriggeringPlayer(void) const
{ return this->player_; }
-
+
/**
@brief Checks whether the PlayerTrigger normally returns a ControllableEntity.
@return Returns true if the PlayerTrigger normally returns a ControllableEntity.
*/
inline bool isForPlayer(void) const
{ return this->isForPlayer_; }
-
+
protected:
virtual bool isTriggered(TriggerMode::Value mode) = 0;
-
+
/**
@brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
@param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
@@ -80,15 +80,15 @@
/**
@brief Set whether the PlayerTrigger normally is triggered by ControllableEntities.
- @param isForPlayer Should be true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities, false if not.
+ @param isForPlayer Should be true when the PlayerTrigger should be set to normally be triggered by ControllableEntities, false if not.
*/
inline void setForPlayer(bool isForPlayer)
{ this->isForPlayer_ = isForPlayer; }
-
+
private:
Pawn* player_; //!< The player that triggered the PlayerTrigger.
- bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
-
+ bool isForPlayer_; //!< Is true when the PlayerTrigger should be set to normally be triggered by ControllableEntities.
+
};
}
Modified: code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -35,7 +35,7 @@
#include <queue>
#include "tools/BillboardSet.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "objects/worldentities/StaticEntity.h"
namespace orxonox
Copied: code/trunk/src/orxonox/orxonox-main.vcproj.user.in (from rev 5692, code/branches/libraries/src/orxonox/orxonox-main.vcproj.user.in)
===================================================================
--- code/trunk/src/orxonox/orxonox-main.vcproj.user.in (rev 0)
+++ code/trunk/src/orxonox/orxonox-main.vcproj.user.in 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="MinSizeRel|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="RelWithDebInfo|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
Deleted: code/trunk/src/orxonox/orxonox.vcproj.user.in
===================================================================
--- code/trunk/src/orxonox/orxonox.vcproj.user.in 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/orxonox.vcproj.user.in 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="Debug|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="Release|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="MinSizeRel|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="RelWithDebInfo|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="Path=${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}"
- EnvironmentMerge="true"
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>
Modified: code/trunk/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,15 +1,26 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
OrxonoxOverlay.cc
OverlayGroup.cc
+)
+
+SET_SOURCE_FILES(OVERLAYS_SRC_FILES
OverlayText.cc
FadeoutText.cc
GUIOverlay.cc
)
-ADD_SUBDIRECTORY(console)
ADD_SUBDIRECTORY(debug)
ADD_SUBDIRECTORY(hud)
-ADD_SUBDIRECTORY(map)
-ADD_SUBDIRECTORY(notifications)
ADD_SUBDIRECTORY(stats)
+ORXONOX_ADD_LIBRARY(overlays
+ MODULE
+ FIND_HEADER_FILES
+ DEFINE_SYMBOL
+ "OVERLAYS_SHARED_BUILD"
+ PCH_FILE
+ ../OrxonoxPrecompiledHeaders.h
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${OVERLAYS_SRC_FILES}
+)
Modified: code/trunk/src/orxonox/overlays/FadeoutText.h
===================================================================
--- code/trunk/src/orxonox/overlays/FadeoutText.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/FadeoutText.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,15 +29,15 @@
#ifndef _FadeoutText_H__
#define _FadeoutText_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "tools/Timer.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport FadeoutText : public OverlayText, public Tickable
+ class _OverlaysExport FadeoutText : public OverlayText, public Tickable
{
public:
FadeoutText(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/GUIOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/GUIOverlay.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/GUIOverlay.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -35,6 +35,7 @@
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
#include "core/XMLPort.h"
+#include "objects/infos/PlayerInfo.h"
namespace orxonox
{
@@ -78,4 +79,9 @@
}
}
+ void GUIOverlay::setGUIName(const std::string& name)
+ {
+ this->guiName_ = name;
+ GUIManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner()));
+ }
}
Modified: code/trunk/src/orxonox/overlays/GUIOverlay.h
===================================================================
--- code/trunk/src/orxonox/overlays/GUIOverlay.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/GUIOverlay.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _GUIOverlay_H__
#define _GUIOverlay_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <string>
#include "OrxonoxOverlay.h"
namespace orxonox
{
- class _OrxonoxExport GUIOverlay : public OrxonoxOverlay
+ class _OverlaysExport GUIOverlay : public OrxonoxOverlay
{
public:
@@ -45,7 +45,7 @@
virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
- inline void setGUIName(const std::string& name) { this->guiName_ = name; }
+ void setGUIName(const std::string& name);
inline const std::string& getGUIName() const { return this->guiName_; }
virtual void changedVisibility();
Modified: code/trunk/src/orxonox/overlays/OverlayText.h
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayText.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/OverlayText.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _OverlayText_H__
#define _OverlayText_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <string>
#include "util/Math.h"
@@ -38,7 +38,7 @@
namespace orxonox
{
- class _OrxonoxExport OverlayText : public OrxonoxOverlay
+ class _OverlaysExport OverlayText : public OrxonoxOverlay
{
public:
enum Alignment
Copied: code/trunk/src/orxonox/overlays/OverlaysPrereqs.h (from rev 5692, code/branches/libraries/src/orxonox/overlays/OverlaysPrereqs.h)
===================================================================
--- code/trunk/src/orxonox/overlays/OverlaysPrereqs.h (rev 0)
+++ code/trunk/src/orxonox/overlays/OverlaysPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,88 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _OverlaysPrereqs_H__
+#define _OverlaysPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef OVERLAYS_SHARED_BUILD
+# define _OverlaysExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _OverlaysExport
+# else
+# define _OverlaysExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _OverlaysExport __attribute__ ((visibility("default")))
+#else
+# define _OverlaysExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class BarColour;
+ class DebugFPSText;
+ class DebugRTRText;
+ class GUIOverlay;
+ class HUDBar;
+ class HUDNavigation;
+ class HUDRadar;
+ class HUDSpeedBar;
+ class HUDHealthBar;
+ class HUDTimer;
+ class OrxonoxOverlay;
+ class OverlayGroup;
+ class OverlayText;
+ class FadeoutText;
+ class GametypeStatus;
+ class AnnounceMessage;
+ class KillMessage;
+ class DeathMessage;
+
+ class CreateLines;
+ class Scoreboard;
+ class Stats;
+}
+
+#endif /* _OverlaysPrereqs_H__ */
Modified: code/trunk/src/orxonox/overlays/debug/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/debug/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/debug/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(OVERLAYS_SRC_FILES
DebugFPSText.cc
DebugRTRText.cc
)
Modified: code/trunk/src/orxonox/overlays/debug/DebugFPSText.h
===================================================================
--- code/trunk/src/orxonox/overlays/debug/DebugFPSText.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/debug/DebugFPSText.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _DebugFPSText_H__
#define _DebugFPSText_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport DebugFPSText : public OverlayText, public Tickable
+ class _OverlaysExport DebugFPSText : public OverlayText, public Tickable
{
public:
DebugFPSText(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/debug/DebugRTRText.h
===================================================================
--- code/trunk/src/orxonox/overlays/debug/DebugRTRText.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/debug/DebugRTRText.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _DebugRTRText_H__
#define _DebugRTRText_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport DebugRTRText : public OverlayText, public Tickable
+ class _OverlaysExport DebugRTRText : public OverlayText, public Tickable
{
public:
DebugRTRText(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/AnnounceMessage.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/AnnounceMessage.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/AnnounceMessage.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _AnnounceMessage_H__
#define _AnnounceMessage_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "interfaces/GametypeMessageListener.h"
#include "overlays/FadeoutText.h"
namespace orxonox
{
- class _OrxonoxExport AnnounceMessage : public FadeoutText, public GametypeMessageListener
+ class _OverlaysExport AnnounceMessage : public FadeoutText, public GametypeMessageListener
{
public:
AnnounceMessage(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(OVERLAYS_SRC_FILES
HUDBar.cc
HUDNavigation.cc
HUDRadar.cc
Modified: code/trunk/src/orxonox/overlays/hud/ChatOverlay.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/ChatOverlay.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/ChatOverlay.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _ChatOverlay_H__
#define _ChatOverlay_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <list>
#include <OgreUTFString.h>
@@ -39,7 +39,7 @@
namespace orxonox
{
- class _OrxonoxExport ChatOverlay : public OverlayText, public ChatListener
+ class _OverlaysExport ChatOverlay : public OverlayText, public ChatListener
{
public:
ChatOverlay(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/DeathMessage.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/DeathMessage.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/DeathMessage.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _DeathMessage_H__
#define _DeathMessage_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "interfaces/GametypeMessageListener.h"
#include "overlays/FadeoutText.h"
namespace orxonox
{
- class _OrxonoxExport DeathMessage : public FadeoutText, public GametypeMessageListener
+ class _OverlaysExport DeathMessage : public FadeoutText, public GametypeMessageListener
{
public:
DeathMessage(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/GametypeStatus.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/GametypeStatus.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/GametypeStatus.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _GametypeStatus_H__
#define _GametypeStatus_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport GametypeStatus : public OverlayText, public Tickable
+ class _OverlaysExport GametypeStatus : public OverlayText, public Tickable
{
public:
GametypeStatus(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDBar.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDBar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDBar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -31,7 +31,7 @@
#ifndef _HUDBar_H__
#define _HUDBar_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <map>
#include <vector>
@@ -43,7 +43,7 @@
namespace orxonox
{
- class _OrxonoxExport BarColour : public BaseObject
+ class _OverlaysExport BarColour : public BaseObject
{
public:
BarColour(BaseObject* creator);
@@ -63,7 +63,7 @@
};
- class _OrxonoxExport HUDBar : public OrxonoxOverlay
+ class _OverlaysExport HUDBar : public OrxonoxOverlay
{
public:
HUDBar(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDHealthBar.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDHealthBar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDHealthBar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,16 +29,16 @@
#ifndef _HUDHealthBar_H__
#define _HUDHealthBar_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "util/Math.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
#include "HUDBar.h"
namespace orxonox
{
- class _OrxonoxExport HUDHealthBar : public HUDBar, public Tickable
+ class _OverlaysExport HUDHealthBar : public HUDBar, public Tickable
{
public:
HUDHealthBar(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDNavigation.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDNavigation.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,15 +29,15 @@
#ifndef _HUDNavigation_H__
#define _HUDNavigation_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "util/OgreForwardRefs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OrxonoxOverlay.h"
namespace orxonox
{
- class _OrxonoxExport HUDNavigation : public OrxonoxOverlay, public Tickable
+ class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable
{
public:
HUDNavigation(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDRadar.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDRadar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDRadar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -30,7 +30,7 @@
#ifndef _HUDRadar_H__
#define _HUDRadar_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <map>
#include <vector>
@@ -42,7 +42,7 @@
namespace orxonox
{
- class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener
+ class _OverlaysExport HUDRadar : public OrxonoxOverlay, public RadarListener
{
public:
HUDRadar(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -30,14 +30,14 @@
#ifndef _HUDSpeedBar_H__
#define _HUDSpeedBar_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "HUDBar.h"
namespace orxonox
{
- class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable
+ class _OverlaysExport HUDSpeedBar : public HUDBar, public Tickable
{
public:
HUDSpeedBar(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/HUDTimer.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDTimer.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/HUDTimer.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _HUDTimer_H__
#define _HUDTimer_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport HUDTimer : public OverlayText, public Tickable
+ class _OverlaysExport HUDTimer : public OverlayText, public Tickable
{
public:
HUDTimer(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/KillMessage.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/KillMessage.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/KillMessage.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _KillMessage_H__
#define _KillMessage_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "interfaces/GametypeMessageListener.h"
#include "overlays/FadeoutText.h"
namespace orxonox
{
- class _OrxonoxExport KillMessage : public FadeoutText, public GametypeMessageListener
+ class _OverlaysExport KillMessage : public FadeoutText, public GametypeMessageListener
{
public:
KillMessage(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/PongScore.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/PongScore.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/PongScore.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _PongScore_H__
#define _PongScore_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport PongScore : public OverlayText, public Tickable
+ class _OverlaysExport PongScore : public OverlayText, public Tickable
{
public:
PongScore(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _TeamBaseMatchScore_H__
#define _TeamBaseMatchScore_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OverlayText.h"
namespace orxonox
{
- class _OrxonoxExport TeamBaseMatchScore : public OverlayText, public Tickable
+ class _OverlaysExport TeamBaseMatchScore : public OverlayText, public Tickable
{
public:
TeamBaseMatchScore(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h
===================================================================
--- code/trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _UnderAttackHealthBar_H__
#define _UnderAttackHealthBar_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "util/Math.h"
#include "tools/Timer.h"
@@ -37,7 +37,7 @@
namespace orxonox
{
- class _OrxonoxExport UnderAttackHealthBar : public HUDHealthBar
+ class _OverlaysExport UnderAttackHealthBar : public HUDHealthBar
{
public:
UnderAttackHealthBar(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/stats/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/stats/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/stats/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(OVERLAYS_SRC_FILES
CreateLines.cc
Scoreboard.cc
Stats.cc
Modified: code/trunk/src/orxonox/overlays/stats/CreateLines.h
===================================================================
--- code/trunk/src/orxonox/overlays/stats/CreateLines.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/stats/CreateLines.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -27,11 +27,11 @@
#ifndef _CreateLines_H__
#define _CreateLines_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
namespace orxonox
{
- class _OrxonoxExport CreateLines
+ class _OverlaysExport CreateLines
{
public: // functions
Modified: code/trunk/src/orxonox/overlays/stats/Scoreboard.h
===================================================================
--- code/trunk/src/orxonox/overlays/stats/Scoreboard.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/stats/Scoreboard.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -28,16 +28,16 @@
#define _Scoreboard_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include <string>
#include <vector>
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OrxonoxOverlay.h"
namespace orxonox
{
- class _OrxonoxExport Scoreboard : public OrxonoxOverlay, public Tickable
+ class _OverlaysExport Scoreboard : public OrxonoxOverlay, public Tickable
{
public: // functions
Scoreboard(BaseObject* creator);
Modified: code/trunk/src/orxonox/overlays/stats/Stats.h
===================================================================
--- code/trunk/src/orxonox/overlays/stats/Stats.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/overlays/stats/Stats.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,15 +29,15 @@
#ifndef _Stats_H__
#define _Stats_H__
-#include "OrxonoxPrereqs.h"
+#include "overlays/OverlaysPrereqs.h"
#include "util/OgreForwardRefs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
#include "overlays/OrxonoxOverlay.h"
namespace orxonox
{
- class _OrxonoxExport Stats : public OrxonoxOverlay, public Tickable
+ class _OverlaysExport Stats : public OrxonoxOverlay, public Tickable
{
public: // functions
Stats(BaseObject* creator);
Modified: code/trunk/src/orxonox/sound/SoundBase.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundBase.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/sound/SoundBase.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
namespace orxonox
{
/**
- * The SoudBase class is the base class for all sound file loader classes.
+ * The SoundBase class is the base class for all sound file loader classes.
* It server as main interface to the OpenAL library.
*
*/
Modified: code/trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/sound/SoundManager.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -32,7 +32,7 @@
#include <cassert>
#include <list>
#include "util/Singleton.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
namespace orxonox
{
Modified: code/trunk/src/orxonox/tools/BillboardSet.h
===================================================================
--- code/trunk/src/orxonox/tools/BillboardSet.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/BillboardSet.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _BillboardSet_H__
#define _BillboardSet_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include "util/OgreForwardRefs.h"
namespace orxonox
{
- class _OrxonoxExport BillboardSet
+ class _ToolsExport BillboardSet
{
public:
BillboardSet();
Modified: code/trunk/src/orxonox/tools/BulletConversions.h
===================================================================
--- code/trunk/src/orxonox/tools/BulletConversions.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/BulletConversions.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,7 +29,7 @@
#ifndef _BulletConversions_H__
#define _BulletConversions_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include "util/Convert.h"
#include "util/Math.h"
Modified: code/trunk/src/orxonox/tools/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/tools/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,4 +1,4 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(TOOLS_SRC_FILES
BillboardSet.cc
DynamicLines.cc
DynamicRenderable.cc
@@ -8,3 +8,12 @@
TextureGenerator.cc
Timer.cc
)
+ADD_SUBDIRECTORY(interfaces)
+
+ORXONOX_ADD_LIBRARY(tools
+ DEFINE_SYMBOL
+ "TOOLS_SHARED_BUILD"
+ LINK_LIBRARIES
+ core
+ SOURCE_FILES ${TOOLS_SRC_FILES}
+)
Modified: code/trunk/src/orxonox/tools/DynamicLines.h
===================================================================
--- code/trunk/src/orxonox/tools/DynamicLines.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/DynamicLines.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _DynamicLines_H__
#define _DynamicLines_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include <vector>
#include "DynamicRenderable.h"
namespace Ogre
{
- class DynamicLines : public DynamicRenderable
+ class _ToolsExport DynamicLines : public DynamicRenderable
{
typedef RenderOperation::OperationType OperationType;
Modified: code/trunk/src/orxonox/tools/DynamicRenderable.h
===================================================================
--- code/trunk/src/orxonox/tools/DynamicRenderable.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/DynamicRenderable.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,14 +29,14 @@
#ifndef _DynamicRenderable_H__
#define _DynamicRenderable_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include <OgreSimpleRenderable.h>
namespace Ogre
{
/// Abstract base class providing mechanisms for dynamically growing hardware buffers.
- class DynamicRenderable : public SimpleRenderable
+ class _ToolsExport DynamicRenderable : public SimpleRenderable
{
public:
/// Constructor
Modified: code/trunk/src/orxonox/tools/Mesh.h
===================================================================
--- code/trunk/src/orxonox/tools/Mesh.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/Mesh.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,12 +29,12 @@
#ifndef _Mesh_H__
#define _Mesh_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include "util/OgreForwardRefs.h"
namespace orxonox
{
- class _OrxonoxExport Mesh
+ class _ToolsExport Mesh
{
public:
Mesh();
Modified: code/trunk/src/orxonox/tools/ParticleInterface.h
===================================================================
--- code/trunk/src/orxonox/tools/ParticleInterface.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/ParticleInterface.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,10 +29,10 @@
#ifndef _ParticleInterface_H__
#define _ParticleInterface_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include "util/OgreForwardRefs.h"
-#include "interfaces/TimeFactorListener.h"
+#include "tools/interfaces/TimeFactorListener.h"
#define getAllEmitters() \
storeThisAsCurrentParticleInterface(); \
@@ -41,7 +41,7 @@
namespace orxonox
{
- class _OrxonoxExport ParticleInterface : public TimeFactorListener
+ class _ToolsExport ParticleInterface : public TimeFactorListener
{
public:
ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel);
Modified: code/trunk/src/orxonox/tools/Shader.h
===================================================================
--- code/trunk/src/orxonox/tools/Shader.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/Shader.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -29,18 +29,18 @@
#ifndef _Shader_H__
#define _Shader_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include <map>
#include <string>
#include <vector>
#include "util/OgreForwardRefs.h"
-#include "interfaces/Tickable.h"
+#include "tools/interfaces/Tickable.h"
namespace orxonox
{
- class _OrxonoxExport Shader : public Tickable
+ class _ToolsExport Shader : public Tickable
{
typedef std::pair<bool, void*> ParameterPointer;
typedef std::map<std::string, ParameterPointer> ParameterMap;
Modified: code/trunk/src/orxonox/tools/TextureGenerator.h
===================================================================
--- code/trunk/src/orxonox/tools/TextureGenerator.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/TextureGenerator.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -34,7 +34,7 @@
#ifndef _TextureGenerator_H__
#define _TextureGenerator_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include <map>
#include <string>
@@ -42,7 +42,7 @@
namespace orxonox
{
- class _OrxonoxExport TextureGenerator
+ class _ToolsExport TextureGenerator
{
public:
static const std::string& getMaterialName(const std::string& textureName, const ColourValue& colour);
Modified: code/trunk/src/orxonox/tools/Timer.h
===================================================================
--- code/trunk/src/orxonox/tools/Timer.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/Timer.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -60,11 +60,11 @@
#ifndef _Timer_H__
#define _Timer_H__
-#include "OrxonoxPrereqs.h"
+#include "tools/ToolsPrereqs.h"
#include "core/Executor.h"
#include "core/OrxonoxClass.h"
-#include "interfaces/TimeFactorListener.h"
+#include "tools/interfaces/TimeFactorListener.h"
namespace orxonox
{
@@ -74,7 +74,7 @@
void executeDelayedCommand(StaticTimer* timer, const std::string& command);
//! TimerBase is the parent of the Timer class.
- class _OrxonoxExport TimerBase : public TimeFactorListener
+ class _ToolsExport TimerBase : public TimeFactorListener
{
public:
~TimerBase();
@@ -170,7 +170,7 @@
};
//! The StaticTimer is a callback-object, calling a static function after a given time-interval.
- class StaticTimer : public TimerBase
+ class _ToolsExport StaticTimer : public TimerBase
{
public:
StaticTimer() {}
Copied: code/trunk/src/orxonox/tools/ToolsPrereqs.h (from rev 5692, code/branches/libraries/src/orxonox/tools/ToolsPrereqs.h)
===================================================================
--- code/trunk/src/orxonox/tools/ToolsPrereqs.h (rev 0)
+++ code/trunk/src/orxonox/tools/ToolsPrereqs.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,91 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _ToolsPrereqs_H__
+#define _ToolsPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef TOOLS_SHARED_BUILD
+# define _ToolsExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _ToolsExport
+# else
+# define _ToolsExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _ToolsExport __attribute__ ((visibility("default")))
+#else
+# define _ToolsExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ namespace LODParticle
+ {
+ enum Value
+ {
+ Off = 0,
+ Low = 1,
+ Normal = 2,
+ High = 3
+ };
+ }
+
+ class BillboardSet;
+ class Mesh;
+ class ParticleInterface;
+ class Shader;
+ template <class T>
+ class Timer;
+ class StaticTimer;
+}
+
+namespace Ogre
+{
+ // OGRE Wiki adapted code
+ class DynamicLines;
+ class DynamicRenderable;
+}
+
+#endif /* _ToolsPrereqs_H__ */
Deleted: code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/tools/interfaces/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,3 +0,0 @@
-ADD_SOURCE_FILES(TOOLS_SRC_FILES
- ToolsInterfaceCompilation.cc
-)
Copied: code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt (from rev 5692, code/branches/libraries/src/orxonox/tools/interfaces/CMakeLists.txt)
===================================================================
--- code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt (rev 0)
+++ code/trunk/src/orxonox/tools/interfaces/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,3 @@
+ADD_SOURCE_FILES(TOOLS_SRC_FILES
+ ToolsInterfaceCompilation.cc
+)
Deleted: code/trunk/src/orxonox/tools/interfaces/Tickable.h
===================================================================
--- code/branches/libraries/src/orxonox/tools/interfaces/Tickable.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/interfaces/Tickable.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,68 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/*!
- @file
- @brief Declaration of the Tickable interface.
-
- The Tickable interface provides a tick(dt) function, that gets called every frame.
- float dt is the time since the last frame in seconds.
-
- Attention:
- Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
- parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
-*/
-
-#ifndef _Tickable_H__
-#define _Tickable_H__
-
-#include "tools/ToolsPrereqs.h"
-
-#include "core/OrxonoxClass.h"
-#include "core/Super.h"
-
-namespace orxonox
-{
- //! The Tickable interface provides a tick(dt) function, that gets called every frame.
- class _ToolsExport Tickable : virtual public OrxonoxClass
- {
- public:
- /**
- @brief Gets called every frame.
- @param dt The time since the last frame in seconds
- */
- virtual void tick(float dt) { }
-
- protected:
- Tickable();
- };
-
- SUPER_FUNCTION(1, Tickable, tick, true);
-}
-
-#endif /* _Tickable_H__ */
Copied: code/trunk/src/orxonox/tools/interfaces/Tickable.h (from rev 5692, code/branches/libraries/src/orxonox/tools/interfaces/Tickable.h)
===================================================================
--- code/trunk/src/orxonox/tools/interfaces/Tickable.h (rev 0)
+++ code/trunk/src/orxonox/tools/interfaces/Tickable.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,68 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/*!
+ @file
+ @brief Declaration of the Tickable interface.
+
+ The Tickable interface provides a tick(dt) function, that gets called every frame.
+ float dt is the time since the last frame in seconds.
+
+ Attention:
+ Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
+ parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
+*/
+
+#ifndef _Tickable_H__
+#define _Tickable_H__
+
+#include "tools/ToolsPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+#include "core/Super.h"
+
+namespace orxonox
+{
+ //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+ class _ToolsExport Tickable : virtual public OrxonoxClass
+ {
+ public:
+ /**
+ @brief Gets called every frame.
+ @param dt The time since the last frame in seconds
+ */
+ virtual void tick(float dt) { }
+
+ protected:
+ Tickable();
+ };
+
+ SUPER_FUNCTION(1, Tickable, tick, true);
+}
+
+#endif /* _Tickable_H__ */
Deleted: code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h
===================================================================
--- code/branches/libraries/src/orxonox/tools/interfaces/TimeFactorListener.h 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,55 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _TimeFactorListener_H__
-#define _TimeFactorListener_H__
-
-#include "tools/ToolsPrereqs.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
- class _ToolsExport TimeFactorListener : virtual public OrxonoxClass
- {
- friend class GSRoot;
-
- public:
- TimeFactorListener();
- virtual ~TimeFactorListener() {}
-
- protected:
- virtual void changedTimeFactor(float factor_new, float factor_old) {}
- inline float getTimeFactor() const
- { return TimeFactorListener::timefactor_s; }
-
- private:
- static float timefactor_s;
- };
-}
-
-#endif /* _TimeFactorListener_H__ */
Copied: code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h (from rev 5692, code/branches/libraries/src/orxonox/tools/interfaces/TimeFactorListener.h)
===================================================================
--- code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h (rev 0)
+++ code/trunk/src/orxonox/tools/interfaces/TimeFactorListener.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,55 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TimeFactorListener_H__
+#define _TimeFactorListener_H__
+
+#include "tools/ToolsPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _ToolsExport TimeFactorListener : virtual public OrxonoxClass
+ {
+ friend class GSRoot;
+
+ public:
+ TimeFactorListener();
+ virtual ~TimeFactorListener() {}
+
+ protected:
+ virtual void changedTimeFactor(float factor_new, float factor_old) {}
+ inline float getTimeFactor() const
+ { return TimeFactorListener::timefactor_s; }
+
+ private:
+ static float timefactor_s;
+ };
+}
+
+#endif /* _TimeFactorListener_H__ */
Deleted: code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/branches/libraries/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -1,62 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-/**
- at file
- at brief
- Compiles all the interfaces in the tools library with mostly just a constructor.
-*/
-
-#include "Tickable.h"
-#include "TimeFactorListener.h"
-
-#include "core/CoreIncludes.h"
-
-namespace orxonox
-{
- //----------------------------
- // TimeFactorListener
- //----------------------------
- float TimeFactorListener::timefactor_s = 1.0f;
-
- TimeFactorListener::TimeFactorListener()
- {
- RegisterRootObject(TimeFactorListener);
- }
-
- //----------------------------
- // Tickable
- //----------------------------
- /**
- @brief Constructor: Registers the object in the Tickable-list
- */
- Tickable::Tickable()
- {
- RegisterRootObject(Tickable);
- }
-}
Copied: code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc (from rev 5692, code/branches/libraries/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc)
===================================================================
--- code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc (rev 0)
+++ code/trunk/src/orxonox/tools/interfaces/ToolsInterfaceCompilation.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,62 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Compiles all the interfaces in the tools library with mostly just a constructor.
+*/
+
+#include "Tickable.h"
+#include "TimeFactorListener.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ //----------------------------
+ // TimeFactorListener
+ //----------------------------
+ float TimeFactorListener::timefactor_s = 1.0f;
+
+ TimeFactorListener::TimeFactorListener()
+ {
+ RegisterRootObject(TimeFactorListener);
+ }
+
+ //----------------------------
+ // Tickable
+ //----------------------------
+ /**
+ @brief Constructor: Registers the object in the Tickable-list
+ */
+ Tickable::Tickable()
+ {
+ RegisterRootObject(Tickable);
+ }
+}
Modified: code/trunk/src/util/CMakeLists.txt
===================================================================
--- code/trunk/src/util/CMakeLists.txt 2009-08-29 20:10:53 UTC (rev 5692)
+++ code/trunk/src/util/CMakeLists.txt 2009-08-29 20:19:38 UTC (rev 5693)
@@ -26,6 +26,7 @@
MultiType.cc
OutputBuffer.cc
OutputHandler.cc
+ Scope.cc
SignalHandler.cc
Sleep.cc
StringUtils.cc
Copied: code/trunk/src/util/Scope.cc (from rev 5692, code/branches/libraries/src/util/Scope.cc)
===================================================================
--- code/trunk/src/util/Scope.cc (rev 0)
+++ code/trunk/src/util/Scope.cc 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,35 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "Scope.h"
+
+namespace orxonox
+{
+ std::map<ScopeID::Value, int> ScopeManager::instanceCounts_s;
+ std::map<ScopeID::Value, std::set<ScopeListener*> > ScopeManager::listeners_s;
+}
Copied: code/trunk/src/util/Scope.h (from rev 5692, code/branches/libraries/src/util/Scope.h)
===================================================================
--- code/trunk/src/util/Scope.h (rev 0)
+++ code/trunk/src/util/Scope.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,141 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef __Util_Scope_H__
+#define __Util_Scope_H__
+
+#include "UtilPrereqs.h"
+#include <cassert>
+#include <set>
+#include <map>
+#include "Debug.h"
+
+namespace orxonox
+{
+ namespace ScopeID
+ {
+ /**
+ @brief A list of available scopes for the Scope template.
+ */
+ enum Value
+ {
+ GSRoot,
+ GSGraphics,
+ GSLevel
+ };
+ }
+
+ class ScopeListener; // Forward declaration
+
+ /**
+ @brief The ScopeManager stores the variables of the scope templates in a statically linked context.
+ */
+ class _UtilExport ScopeManager
+ {
+ template <ScopeID::Value scope>
+ friend class Scope;
+ friend class ScopeListener;
+
+ private:
+ static std::map<ScopeID::Value, int> instanceCounts_s; //!< Counts the number of active instances (>0 means active) for a scope
+ static std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_s; //!< Stores all listeners for a scope
+ };
+
+ /**
+ @brief ScopeListeners register themselves in the corresponding scope and wait for notifications.
+ */
+ class _UtilExport ScopeListener
+ {
+ template <ScopeID::Value scope>
+ friend class Scope;
+
+ protected:
+ //! Constructor: Registers the instance.
+ ScopeListener(ScopeID::Value scope) : scope_(scope)
+ { ScopeManager::listeners_s[this->scope_].insert(this); }
+ //! Destructor: Unregisters the instance.
+ virtual ~ScopeListener()
+ { ScopeManager::listeners_s[this->scope_].erase(this); }
+
+ //! Gets called if the scope is activated
+ virtual void activated() = 0;
+ //! Gets called if the scope is deactivated
+ virtual void deactivated() = 0;
+
+ private:
+ ScopeID::Value scope_; //!< Store the scope to unregister on destruction
+ };
+
+ /**
+ @brief A scope for a given template argument is either active or not.
+
+ Objects inheriting from a ScopeListener are registered in a list (different for each scope).
+ If the scope gets activated or deactivated, all objects in this list are notified.
+ */
+ template <ScopeID::Value scope>
+ class Scope
+ {
+ public:
+ //! Constructor: Increases the instance counter and activates the scope if the count went from 0 to 1. Counts >1 don't change anything.
+ Scope()
+ {
+ ScopeManager::instanceCounts_s[scope]++;
+ assert(ScopeManager::instanceCounts_s[scope] > 0);
+ if (ScopeManager::instanceCounts_s[scope] == 1)
+ {
+ for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
+ (*(it++))->activated();
+ }
+ }
+
+ //! Destructor: Decreases the instance counter and deactivates the scope if the count went from 1 to 0. Counts >0 don't change anything.
+ ~Scope()
+ {
+ ScopeManager::instanceCounts_s[scope]--;
+
+ // This shouldn't happen but just to be sure: check if the count is positive
+ assert(ScopeManager::instanceCounts_s[scope] >= 0);
+ if (ScopeManager::instanceCounts_s[scope] < 0)
+ ScopeManager::instanceCounts_s[scope] = 0;
+
+ if (ScopeManager::instanceCounts_s[scope] == 0)
+ {
+ for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
+ (*(it++))->deactivated();
+ }
+ }
+
+ //! Returns true if the scope is active.
+ static bool isActive()
+ {
+ return (ScopeManager::instanceCounts_s[scope] > 0);
+ }
+ };
+}
+
+#endif /* __Util_Scope_H__ */
Copied: code/trunk/src/util/ScopedSingleton.h (from rev 5692, code/branches/libraries/src/util/ScopedSingleton.h)
===================================================================
--- code/trunk/src/util/ScopedSingleton.h (rev 0)
+++ code/trunk/src/util/ScopedSingleton.h 2009-08-29 20:19:38 UTC (rev 5693)
@@ -0,0 +1,102 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef __Util_ScopedSingleton_H__
+#define __Util_ScopedSingleton_H__
+
+#include "UtilPrereqs.h"
+#include <cassert>
+
+#include "Scope.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Base for scoped singleton classes.
+ A Scoped singleton creates itself if the scope is active and getInstance() is called.
+ Destroys itself if the scope is deactivated.
+
+ Usage:
+ Inherit publicly from ScopedSingleton<MyClass, scope> and provide access to
+ MyClass::singletonPtr_s.
+ This can easily be done with a friend declaration.
+
+ See @ref UtilPrereqs.h for a list of scopes (ScopeID::Value).
+ */
+ template <class T, ScopeID::Value scope>
+ class ScopedSingleton : public ScopeListener
+ {
+ public:
+ //! Returns a reference to the singleton instance
+ static T& getInstance()
+ {
+ assert(Scope<scope>::isActive());
+
+ if (!T::singletonPtr_s && Scope<scope>::isActive())
+ T::singletonPtr_s = new T();
+
+ return *T::singletonPtr_s;
+ }
+
+ protected:
+ //! Constructor sets the singleton instance pointer
+ ScopedSingleton() : ScopeListener(scope)
+ {
+ assert(T::singletonPtr_s == 0);
+ T::singletonPtr_s = static_cast<T*>(this);
+ }
+
+ //! Constructor resets the singleton instance pointer
+ ~ScopedSingleton()
+ {
+ assert(T::singletonPtr_s != 0);
+ T::singletonPtr_s = 0;
+ }
+
+ private:
+ //! Called if the Scope of this Singleton gets active (no instance should be active then)
+ void activated()
+ {
+ // The ScopedSingleton shouldn't be active bevor the scope is activated -> always assertion failed
+ assert(T::singletonPtr_s == 0 && false);
+ }
+
+ //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+ void deactivated()
+ {
+ if (T::singletonPtr_s)
+ {
+ delete T::singletonPtr_s;
+ T::singletonPtr_s = 0;
+ }
+ }
+ };
+}
+
+#endif /* __Util_ScopedSingleton_H__ */
More information about the Orxonox-commit
mailing list