[Orxonox-commit 1699] r6417 - in code/trunk: . bin cmake data data/defaultConfig data/gui/layouts data/gui/scripts data/levels data/levels/includes data/levels/old data/levels/templates data/lua data/overlays data/particle doc doc/api src src/external/ceguilua src/external/ceguilua/ceguilua-0.5.0 src/libraries/core src/libraries/core/input src/libraries/network src/libraries/network/packet src/libraries/network/synchronisable src/libraries/tools src/libraries/tools/interfaces src/libraries/util src/modules/objects src/modules/objects/collisionshapes src/modules/objects/eventsystem src/modules/objects/triggers src/modules/overlays src/modules/overlays/hud src/modules/overlays/stats src/modules/pong src/modules/questsystem src/modules/questsystem/notifications src/modules/weapons/projectiles src/modules/weapons/weaponmodes src/orxonox src/orxonox/controllers src/orxonox/gamestates src/orxonox/gametypes src/orxonox/graphics src/orxonox/infos src/orxonox/interfaces src/orxonox/items src/orxonox/overlays src/orxonox/pickup src/orxonox/sound src/orxonox/weaponsystem src/orxonox/worldentities src/orxonox/worldentities/pawns
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Dec 25 22:24:02 CET 2009
Author: rgrieder
Date: 2009-12-25 22:23:58 +0100 (Fri, 25 Dec 2009)
New Revision: 6417
Added:
code/trunk/data/DefaultResources.oxr
code/trunk/data/gui/layouts/AudioMenu.layout
code/trunk/data/gui/layouts/ControlsMenu.layout
code/trunk/data/gui/layouts/CreditsMenu.layout
code/trunk/data/gui/layouts/DecisionPopup.layout
code/trunk/data/gui/layouts/GameplayMenu.layout
code/trunk/data/gui/layouts/GraphicsMenu.layout
code/trunk/data/gui/layouts/InGameMenu.layout
code/trunk/data/gui/layouts/InfoPopup.layout
code/trunk/data/gui/layouts/KeyBindMenu.layout
code/trunk/data/gui/layouts/MainMenuBackground.layout
code/trunk/data/gui/layouts/MouseControlsMenu.layout
code/trunk/data/gui/layouts/MultiplayerMenu.layout
code/trunk/data/gui/layouts/MultiplayerOptionsMenu.layout
code/trunk/data/gui/layouts/SettingsMenu.layout
code/trunk/data/gui/layouts/SingleplayerMenu.layout
code/trunk/data/gui/scripts/AudioMenu.lua
code/trunk/data/gui/scripts/ControlsMenu.lua
code/trunk/data/gui/scripts/CreditsMenu.lua
code/trunk/data/gui/scripts/DecisionPopup.lua
code/trunk/data/gui/scripts/GUITools.lua
code/trunk/data/gui/scripts/GameplayMenu.lua
code/trunk/data/gui/scripts/GraphicsMenu.lua
code/trunk/data/gui/scripts/InGameMenu.lua
code/trunk/data/gui/scripts/InfoPopup.lua
code/trunk/data/gui/scripts/KeyBindMenu.lua
code/trunk/data/gui/scripts/MouseControlsMenu.lua
code/trunk/data/gui/scripts/MultiplayerMenu.lua
code/trunk/data/gui/scripts/MultiplayerOptionsMenu.lua
code/trunk/data/gui/scripts/SettingsMenu.lua
code/trunk/data/gui/scripts/SingleplayerMenu.lua
code/trunk/data/levels/includes/weaponsettings_HXY.oxi
code/trunk/data/levels/includes/weaponsettings_Transporter.oxi
code/trunk/data/levels/presentationHS09.oxw
code/trunk/data/levels/presentationHS09b.oxw
code/trunk/data/levels/sound.oxw
code/trunk/data/levels/templates/spaceship_HXY.oxt
code/trunk/data/levels/templates/spaceship_HXY_SL.oxt
code/trunk/data/levels/templates/spaceship_Transporter.oxt
code/trunk/data/levels/templates/spaceship_Transporter_SL.oxt
code/trunk/data/particle/Steam.particle
code/trunk/data/particle/bigexplosion.particle
code/trunk/data/particle/explosion4.particle
code/trunk/data/particle/laser.particle
code/trunk/data/particle/load.particle
code/trunk/data/particle/particlecanon.particle
code/trunk/data/particle/rocketfire.particle
code/trunk/data/particle/smoke.particle
code/trunk/data/particle/tes3.particle
code/trunk/src/libraries/network/synchronisable/Serialise.h
code/trunk/src/libraries/util/DisplayStringConversions.h
code/trunk/src/modules/weapons/projectiles/Rocket.cc
code/trunk/src/modules/weapons/projectiles/Rocket.h
code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc
code/trunk/src/modules/weapons/weaponmodes/RocketFire.h
code/trunk/src/orxonox/MoodManager.cc
code/trunk/src/orxonox/MoodManager.h
code/trunk/src/orxonox/controllers/NewHumanController.cc
code/trunk/src/orxonox/controllers/NewHumanController.h
code/trunk/src/orxonox/sound/SoundBuffer.cc
code/trunk/src/orxonox/sound/SoundBuffer.h
code/trunk/src/orxonox/sound/SoundStreamer.cc
code/trunk/src/orxonox/sound/SoundStreamer.h
code/trunk/src/orxonox/worldentities/EffectContainer.cc
code/trunk/src/orxonox/worldentities/EffectContainer.h
Removed:
code/trunk/data/resources.oxr
code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc
code/trunk/src/libraries/util/UTFStringConversions.h
code/trunk/src/orxonox/gamestates/GSDedicated.cc
code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc
Modified:
code/trunk/
code/trunk/README
code/trunk/bin/dedicatedClient.bat.in
code/trunk/bin/dedicatedClient.in
code/trunk/cmake/FindLua.cmake
code/trunk/cmake/FindPackageHandleAdvancedArgs.cmake
code/trunk/cmake/LibraryConfig.cmake
code/trunk/cmake/LibraryConfigApple.cmake
code/trunk/cmake/PrecompiledHeaderFiles.cmake
code/trunk/cmake/SourceFileUtilities.cmake
code/trunk/data/DataInstallScript.cmake
code/trunk/data/defaultConfig/keybindings.ini
code/trunk/data/gui/layouts/MainMenu.layout
code/trunk/data/gui/layouts/PickupInventory.layout
code/trunk/data/gui/layouts/QuestGUI.layout
code/trunk/data/gui/scripts/InitialiseGUI.lua
code/trunk/data/gui/scripts/MainMenu.lua
code/trunk/data/gui/scripts/PickupInventory.lua
code/trunk/data/gui/scripts/QuestGUI.lua
code/trunk/data/levels/empty_level.oxw
code/trunk/data/levels/events.oxw
code/trunk/data/levels/gametype_asteroids.oxw
code/trunk/data/levels/includes/weaponsettings3.oxi
code/trunk/data/levels/includes/weaponsettings_ghost.oxi
code/trunk/data/levels/old/physicstest.oxw
code/trunk/data/levels/old/physicstest2.oxw
code/trunk/data/levels/old/presentation_physics.oxw
code/trunk/data/levels/old/princessaeryn.oxw
code/trunk/data/levels/old/questsystem.oxw
code/trunk/data/levels/old/sample4.oxw
code/trunk/data/levels/old/spaceshiptemplates_physics.oxw
code/trunk/data/levels/old/tutorial_hs08.oxw
code/trunk/data/levels/presentation.oxw
code/trunk/data/levels/presentation09.oxw
code/trunk/data/levels/presentation09b.oxw
code/trunk/data/levels/presentation_dm.oxw
code/trunk/data/levels/princessaeryn.oxw
code/trunk/data/levels/questsystem2.oxw
code/trunk/data/levels/teambasematchlevel.oxw
code/trunk/data/levels/templates/spaceship_assff.oxt
code/trunk/data/levels/templates/spaceship_ghost.oxt
code/trunk/data/levels/test_ghost.oxw
code/trunk/data/lua/LuaStateInit.lua
code/trunk/data/overlays/OrxonoxLoading.overlay
code/trunk/data/overlays/debug.oxo
code/trunk/data/overlays/stats.oxo
code/trunk/doc/CMakeLists.txt
code/trunk/doc/api/CMakeLists.txt
code/trunk/doc/api/main.dox
code/trunk/src/Orxonox.cc
code/trunk/src/external/ceguilua/CMakeLists.txt
code/trunk/src/external/ceguilua/ceguilua-0.5.0/CMakeLists.txt
code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc
code/trunk/src/libraries/core/BaseObject.cc
code/trunk/src/libraries/core/BaseObject.h
code/trunk/src/libraries/core/CMakeLists.txt
code/trunk/src/libraries/core/ClassTreeMask.cc
code/trunk/src/libraries/core/CommandEvaluation.cc
code/trunk/src/libraries/core/CommandEvaluation.h
code/trunk/src/libraries/core/CommandExecutor.cc
code/trunk/src/libraries/core/CommandExecutor.h
code/trunk/src/libraries/core/CommandLineParser.cc
code/trunk/src/libraries/core/ConfigFileManager.cc
code/trunk/src/libraries/core/ConfigFileManager.h
code/trunk/src/libraries/core/ConfigValueContainer.h
code/trunk/src/libraries/core/ConfigValueIncludes.h
code/trunk/src/libraries/core/ConsoleCommandCompilation.cc
code/trunk/src/libraries/core/Core.cc
code/trunk/src/libraries/core/Core.h
code/trunk/src/libraries/core/DynLib.cc
code/trunk/src/libraries/core/Event.cc
code/trunk/src/libraries/core/Event.h
code/trunk/src/libraries/core/EventIncludes.h
code/trunk/src/libraries/core/Executor.cc
code/trunk/src/libraries/core/Executor.h
code/trunk/src/libraries/core/Functor.h
code/trunk/src/libraries/core/GUIManager.cc
code/trunk/src/libraries/core/GUIManager.h
code/trunk/src/libraries/core/Game.cc
code/trunk/src/libraries/core/Game.h
code/trunk/src/libraries/core/GameMode.h
code/trunk/src/libraries/core/GameState.cc
code/trunk/src/libraries/core/GraphicsManager.cc
code/trunk/src/libraries/core/GraphicsManager.h
code/trunk/src/libraries/core/IOConsole.cc
code/trunk/src/libraries/core/IOConsole.h
code/trunk/src/libraries/core/IRC.cc
code/trunk/src/libraries/core/Identifier.cc
code/trunk/src/libraries/core/Identifier.h
code/trunk/src/libraries/core/Language.cc
code/trunk/src/libraries/core/Language.h
code/trunk/src/libraries/core/Loader.cc
code/trunk/src/libraries/core/LuaState.cc
code/trunk/src/libraries/core/LuaState.h
code/trunk/src/libraries/core/MemoryArchive.cc
code/trunk/src/libraries/core/MemoryArchive.h
code/trunk/src/libraries/core/Namespace.cc
code/trunk/src/libraries/core/NamespaceNode.cc
code/trunk/src/libraries/core/OrxonoxClass.cc
code/trunk/src/libraries/core/OrxonoxClass.h
code/trunk/src/libraries/core/PathConfig.cc
code/trunk/src/libraries/core/PathConfig.h
code/trunk/src/libraries/core/Resource.cc
code/trunk/src/libraries/core/Resource.h
code/trunk/src/libraries/core/ScopedSingletonManager.h
code/trunk/src/libraries/core/Shell.cc
code/trunk/src/libraries/core/Shell.h
code/trunk/src/libraries/core/SmartPtr.h
code/trunk/src/libraries/core/SubclassIdentifier.h
code/trunk/src/libraries/core/TclBind.cc
code/trunk/src/libraries/core/TclBind.h
code/trunk/src/libraries/core/TclThreadManager.cc
code/trunk/src/libraries/core/TclThreadManager.h
code/trunk/src/libraries/core/Template.cc
code/trunk/src/libraries/core/Template.h
code/trunk/src/libraries/core/Thread.cc
code/trunk/src/libraries/core/Thread.h
code/trunk/src/libraries/core/ThreadPool.cc
code/trunk/src/libraries/core/ThreadPool.h
code/trunk/src/libraries/core/WeakPtr.h
code/trunk/src/libraries/core/XMLFile.h
code/trunk/src/libraries/core/XMLPort.h
code/trunk/src/libraries/core/input/Button.cc
code/trunk/src/libraries/core/input/Button.h
code/trunk/src/libraries/core/input/InputBuffer.cc
code/trunk/src/libraries/core/input/InputBuffer.h
code/trunk/src/libraries/core/input/InputCommands.h
code/trunk/src/libraries/core/input/InputDevice.h
code/trunk/src/libraries/core/input/InputManager.cc
code/trunk/src/libraries/core/input/InputManager.h
code/trunk/src/libraries/core/input/InputPrereqs.h
code/trunk/src/libraries/core/input/InputState.cc
code/trunk/src/libraries/core/input/JoyStick.cc
code/trunk/src/libraries/core/input/JoyStickQuantityListener.h
code/trunk/src/libraries/core/input/KeyBinder.cc
code/trunk/src/libraries/core/input/KeyBinder.h
code/trunk/src/libraries/core/input/KeyBinderManager.cc
code/trunk/src/libraries/core/input/KeyBinderManager.h
code/trunk/src/libraries/core/input/KeyDetector.cc
code/trunk/src/libraries/core/input/KeyDetector.h
code/trunk/src/libraries/core/input/Keyboard.cc
code/trunk/src/libraries/network/Client.cc
code/trunk/src/libraries/network/ClientConnection.cc
code/trunk/src/libraries/network/ClientConnection.h
code/trunk/src/libraries/network/ClientConnectionListener.cc
code/trunk/src/libraries/network/ClientConnectionListener.h
code/trunk/src/libraries/network/ClientInformation.cc
code/trunk/src/libraries/network/Connection.cc
code/trunk/src/libraries/network/Connection.h
code/trunk/src/libraries/network/FunctionCallManager.cc
code/trunk/src/libraries/network/FunctionCallManager.h
code/trunk/src/libraries/network/GamestateClient.cc
code/trunk/src/libraries/network/GamestateHandler.cc
code/trunk/src/libraries/network/GamestateManager.cc
code/trunk/src/libraries/network/NetworkFunction.cc
code/trunk/src/libraries/network/NetworkFunction.h
code/trunk/src/libraries/network/NetworkPrereqs.h
code/trunk/src/libraries/network/Server.cc
code/trunk/src/libraries/network/Server.h
code/trunk/src/libraries/network/ServerConnection.cc
code/trunk/src/libraries/network/ServerConnection.h
code/trunk/src/libraries/network/TrafficControl.cc
code/trunk/src/libraries/network/TrafficControl.h
code/trunk/src/libraries/network/packet/Acknowledgement.cc
code/trunk/src/libraries/network/packet/Chat.cc
code/trunk/src/libraries/network/packet/ClassID.cc
code/trunk/src/libraries/network/packet/ClassID.h
code/trunk/src/libraries/network/packet/DeleteObjects.cc
code/trunk/src/libraries/network/packet/FunctionCalls.cc
code/trunk/src/libraries/network/packet/FunctionIDs.cc
code/trunk/src/libraries/network/packet/FunctionIDs.h
code/trunk/src/libraries/network/packet/Gamestate.cc
code/trunk/src/libraries/network/packet/Packet.cc
code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
code/trunk/src/libraries/network/synchronisable/NetworkCallback.h
code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc
code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
code/trunk/src/libraries/network/synchronisable/Synchronisable.h
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
code/trunk/src/libraries/tools/BillboardSet.cc
code/trunk/src/libraries/tools/CMakeLists.txt
code/trunk/src/libraries/tools/Mesh.cc
code/trunk/src/libraries/tools/ParticleInterface.cc
code/trunk/src/libraries/tools/ResourceLocation.cc
code/trunk/src/libraries/tools/Shader.cc
code/trunk/src/libraries/tools/TextureGenerator.cc
code/trunk/src/libraries/tools/Timer.cc
code/trunk/src/libraries/tools/Timer.h
code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h
code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
code/trunk/src/libraries/util/Clipboard.cc
code/trunk/src/libraries/util/Clock.cc
code/trunk/src/libraries/util/Clock.h
code/trunk/src/libraries/util/Convert.h
code/trunk/src/libraries/util/Debug.h
code/trunk/src/libraries/util/Exception.cc
code/trunk/src/libraries/util/Exception.h
code/trunk/src/libraries/util/ExprParser.cc
code/trunk/src/libraries/util/ExprParser.h
code/trunk/src/libraries/util/Math.cc
code/trunk/src/libraries/util/Math.h
code/trunk/src/libraries/util/MathConvert.h
code/trunk/src/libraries/util/MultiType.h
code/trunk/src/libraries/util/MultiTypeValue.h
code/trunk/src/libraries/util/OutputHandler.cc
code/trunk/src/libraries/util/Serialise.h
code/trunk/src/libraries/util/Singleton.h
code/trunk/src/libraries/util/StringUtils.cc
code/trunk/src/libraries/util/SubString.cc
code/trunk/src/libraries/util/UtilPrereqs.h
code/trunk/src/libraries/util/mbool.h
code/trunk/src/modules/objects/Attacher.cc
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
code/trunk/src/modules/objects/eventsystem/EventFilter.cc
code/trunk/src/modules/objects/eventsystem/EventListener.cc
code/trunk/src/modules/objects/eventsystem/EventTarget.cc
code/trunk/src/modules/objects/eventsystem/EventTarget.h
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
code/trunk/src/modules/objects/triggers/Trigger.cc
code/trunk/src/modules/overlays/GUIOverlay.cc
code/trunk/src/modules/overlays/OverlayText.cc
code/trunk/src/modules/overlays/hud/ChatOverlay.cc
code/trunk/src/modules/overlays/hud/ChatOverlay.h
code/trunk/src/modules/overlays/hud/HUDBar.cc
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
code/trunk/src/modules/overlays/hud/HUDNavigation.h
code/trunk/src/modules/overlays/hud/HUDRadar.cc
code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc
code/trunk/src/modules/overlays/stats/CreateLines.cc
code/trunk/src/modules/pong/Pong.cc
code/trunk/src/modules/pong/PongAI.cc
code/trunk/src/modules/pong/PongBall.cc
code/trunk/src/modules/pong/PongScore.cc
code/trunk/src/modules/questsystem/AddQuestHint.cc
code/trunk/src/modules/questsystem/AddReward.cc
code/trunk/src/modules/questsystem/ChangeQuestStatus.cc
code/trunk/src/modules/questsystem/CompleteQuest.cc
code/trunk/src/modules/questsystem/FailQuest.cc
code/trunk/src/modules/questsystem/GlobalQuest.cc
code/trunk/src/modules/questsystem/LocalQuest.cc
code/trunk/src/modules/questsystem/Quest.cc
code/trunk/src/modules/questsystem/QuestDescription.cc
code/trunk/src/modules/questsystem/QuestEffect.cc
code/trunk/src/modules/questsystem/QuestGUI.cc
code/trunk/src/modules/questsystem/QuestGUI.h
code/trunk/src/modules/questsystem/QuestGUINode.cc
code/trunk/src/modules/questsystem/QuestGUINode.h
code/trunk/src/modules/questsystem/QuestHint.cc
code/trunk/src/modules/questsystem/QuestItem.cc
code/trunk/src/modules/questsystem/QuestListener.cc
code/trunk/src/modules/questsystem/QuestManager.cc
code/trunk/src/modules/questsystem/QuestManager.h
code/trunk/src/modules/questsystem/QuestNotification.cc
code/trunk/src/modules/questsystem/notifications/Notification.cc
code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/Projectile.cc
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
code/trunk/src/modules/weapons/weaponmodes/HsW01.h
code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
code/trunk/src/modules/weapons/weaponmodes/LightningGun.h
code/trunk/src/orxonox/CMakeLists.txt
code/trunk/src/orxonox/CameraManager.cc
code/trunk/src/orxonox/Level.cc
code/trunk/src/orxonox/LevelManager.cc
code/trunk/src/orxonox/LevelManager.h
code/trunk/src/orxonox/OrxonoxPrereqs.h
code/trunk/src/orxonox/PlayerManager.cc
code/trunk/src/orxonox/Radar.cc
code/trunk/src/orxonox/Radar.h
code/trunk/src/orxonox/Scene.cc
code/trunk/src/orxonox/Scene.h
code/trunk/src/orxonox/Test.cc
code/trunk/src/orxonox/Test.h
code/trunk/src/orxonox/controllers/ArtificialController.cc
code/trunk/src/orxonox/controllers/ArtificialController.h
code/trunk/src/orxonox/controllers/CMakeLists.txt
code/trunk/src/orxonox/controllers/Controller.cc
code/trunk/src/orxonox/controllers/Controller.h
code/trunk/src/orxonox/controllers/HumanController.cc
code/trunk/src/orxonox/controllers/HumanController.h
code/trunk/src/orxonox/gamestates/GSGraphics.cc
code/trunk/src/orxonox/gamestates/GSGraphics.h
code/trunk/src/orxonox/gamestates/GSLevel.cc
code/trunk/src/orxonox/gamestates/GSLevel.h
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
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/gametypes/Asteroids.cc
code/trunk/src/orxonox/gametypes/Deathmatch.cc
code/trunk/src/orxonox/gametypes/Gametype.cc
code/trunk/src/orxonox/gametypes/Gametype.h
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
code/trunk/src/orxonox/gametypes/UnderAttack.cc
code/trunk/src/orxonox/graphics/Billboard.cc
code/trunk/src/orxonox/graphics/BlinkingBillboard.cc
code/trunk/src/orxonox/graphics/Camera.cc
code/trunk/src/orxonox/graphics/Camera.h
code/trunk/src/orxonox/infos/Bot.cc
code/trunk/src/orxonox/infos/HumanPlayer.cc
code/trunk/src/orxonox/infos/PlayerInfo.cc
code/trunk/src/orxonox/infos/PlayerInfo.h
code/trunk/src/orxonox/interfaces/RadarViewable.cc
code/trunk/src/orxonox/interfaces/Rewardable.h
code/trunk/src/orxonox/items/Engine.h
code/trunk/src/orxonox/items/MultiStateEngine.cc
code/trunk/src/orxonox/items/MultiStateEngine.h
code/trunk/src/orxonox/overlays/InGameConsole.cc
code/trunk/src/orxonox/overlays/InGameConsole.h
code/trunk/src/orxonox/overlays/Map.cc
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
code/trunk/src/orxonox/overlays/OverlayGroup.cc
code/trunk/src/orxonox/pickup/DroppedItem.cc
code/trunk/src/orxonox/pickup/ModifierPickup.cc
code/trunk/src/orxonox/pickup/ModifierPickup.h
code/trunk/src/orxonox/pickup/PickupCollection.cc
code/trunk/src/orxonox/pickup/PickupInventory.cc
code/trunk/src/orxonox/pickup/PickupSpawner.cc
code/trunk/src/orxonox/pickup/UsableItem.cc
code/trunk/src/orxonox/sound/AmbientSound.cc
code/trunk/src/orxonox/sound/AmbientSound.h
code/trunk/src/orxonox/sound/BaseSound.cc
code/trunk/src/orxonox/sound/BaseSound.h
code/trunk/src/orxonox/sound/CMakeLists.txt
code/trunk/src/orxonox/sound/SoundManager.cc
code/trunk/src/orxonox/sound/SoundManager.h
code/trunk/src/orxonox/sound/WorldSound.cc
code/trunk/src/orxonox/sound/WorldSound.h
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
code/trunk/src/orxonox/weaponsystem/WeaponMode.h
code/trunk/src/orxonox/weaponsystem/WeaponPack.cc
code/trunk/src/orxonox/weaponsystem/WeaponPack.h
code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc
code/trunk/src/orxonox/weaponsystem/WeaponSystem.h
code/trunk/src/orxonox/worldentities/CMakeLists.txt
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
code/trunk/src/orxonox/worldentities/ControllableEntity.h
code/trunk/src/orxonox/worldentities/MovableEntity.cc
code/trunk/src/orxonox/worldentities/MovableEntity.h
code/trunk/src/orxonox/worldentities/StaticEntity.cc
code/trunk/src/orxonox/worldentities/WorldEntity.cc
code/trunk/src/orxonox/worldentities/WorldEntity.h
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
code/trunk/src/orxonox/worldentities/pawns/Spectator.h
Log:
Merged presentation2 branch back to trunk.
Major new features:
- Actual GUI with settings, etc.
- Improved space ship steering (human interaction)
- Rocket fire and more particle effects
- Advanced sound framework
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/resource2:3372-5694
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/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/ingamemenu:6000-6023
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/menu:5941-6146,6148
/code/branches/particles2:6050-6106,6109
/code/branches/presentation2:6106-6416
/code/branches/resource2:3372-5694
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
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/README
===================================================================
--- code/trunk/README 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/README 2009-12-25 21:23:58 UTC (rev 6417)
@@ -2,7 +2,7 @@
We are proud to present you Orxonox - the most ferious 3D space shooter ever to exist.
-This game is free, if you have paid for this, get your money back! The source code of this game is licensed under the GPL (GNU General Public License).
+This game is free, if you have paid for this, get your money back! The source code of this game is licensed under the GPL (GNU General Public License).
The game content is licensed under the Creative Commons Attribution-Sharealike 2.5 license. For more information read LICENSE in the same folder you found this file.
For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running
Property changes on: code/trunk/bin/dedicatedClient.bat.in
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: code/trunk/bin/dedicatedClient.in
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/cmake/FindLua.cmake
===================================================================
--- code/trunk/cmake/FindLua.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/FindLua.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -135,7 +135,7 @@
SET(LUA_5.0_LIBRARIES ${LUA_5.0_LUA_LIBRARY} ${LUA_5.0_LUALIB_LIBRARY})
ENDIF()
ENDIF(${LUA_5.0_LUA_LIBRARY} MATCHES "framework")
-
+
IF(LUA_5.0_LIBRARIES)
SET(LUA_5.0_FOUND TRUE)
ENDIF()
Modified: code/trunk/cmake/FindPackageHandleAdvancedArgs.cmake
===================================================================
--- code/trunk/cmake/FindPackageHandleAdvancedArgs.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/FindPackageHandleAdvancedArgs.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -24,7 +24,7 @@
# This function also checks the version requirements. Also regards the
# EXACT keyword if specified in FIND_PACKAGE(...).
#
-
+
INCLUDE(FindPackageHandleStandardArgs)
INCLUDE(CompareVersionStrings)
Modified: code/trunk/cmake/LibraryConfig.cmake
===================================================================
--- code/trunk/cmake/LibraryConfig.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/LibraryConfig.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -24,7 +24,7 @@
# from the CMake module path are used, but that required some adjustments
# for certain libraries (Boost, OpenAL, TCL)
#
-
+
INCLUDE(CompareVersionStrings)
INCLUDE(FindPackageHandleStandardArgs)
Modified: code/trunk/cmake/LibraryConfigApple.cmake
===================================================================
--- code/trunk/cmake/LibraryConfigApple.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/LibraryConfigApple.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,7 +22,7 @@
# Description:
# Sets necessary library options and paths on Mac.
#
-
+
IF(APPLE)
MESSAGE(STATUS "Running on Apple. Using customized paths and options.")
Modified: code/trunk/cmake/PrecompiledHeaderFiles.cmake
===================================================================
--- code/trunk/cmake/PrecompiledHeaderFiles.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/PrecompiledHeaderFiles.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,7 +22,7 @@
#
INCLUDE(GetGCCCompilerFlags)
-
+
MACRO(PRECOMPILED_HEADER_FILES_PRE_TARGET _target_name _header_file_arg _sourcefile_var)
GET_FILENAME_COMPONENT(_pch_header_file ${_header_file_arg} ABSOLUTE)
@@ -93,7 +93,7 @@
IF(NOT _old_flags)
SET(_old_flags "")
ENDIF()
- SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES COMPILE_FLAGS "${_old_flags} /FI\"${_pch_header_file}\" /Yu\"${_pch_header_file}\" /Fp\"${_pch_file}\"")
+ SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES COMPILE_FLAGS "${_old_flags} /FI\"${_pch_header_file}\" /Yu\"${_pch_header_file}\" /Fp\"${_pch_file}\"")
ENDIF(NOT _is_header)
ENDFOREACH(_file)
@@ -151,7 +151,7 @@
OUTPUT ${_pch_file}
COMMAND ${CMAKE_CXX_COMPILER}
ARGS ${pchsupport_compiler_cxx_arg1} ${_pch_gcc_flags} -c -x c++-header -o ${_pch_file} ${_pch_header_file}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${_pch_dep_helper_file}
IMPLICIT_DEPENDS CXX ${_pch_header_file}
VERBATIM
Modified: code/trunk/cmake/SourceFileUtilities.cmake
===================================================================
--- code/trunk/cmake/SourceFileUtilities.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/cmake/SourceFileUtilities.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -74,7 +74,7 @@
LIST(APPEND _fullpath_sources ${_filepath})
IF(_compile AND NOT DISABLE_COMPILATIONS)
LIST(APPEND _compilation ${_filepath})
- LIST(APPEND _fullpath_sources "H")
+ LIST(APPEND _fullpath_sources "H")
ENDIF()
ENDIF()
ENDFOREACH(_file)
Modified: code/trunk/data/DataInstallScript.cmake
===================================================================
--- code/trunk/data/DataInstallScript.cmake 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/DataInstallScript.cmake 2009-12-25 21:23:58 UTC (rev 6417)
@@ -28,10 +28,10 @@
#
# Write some comment
-FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr "\n\n\n <!-- ---------------------------------------- -->")
-FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr "\n <!-- Content from the external data directory -->")
-FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr "\n <!-- ---------------------------------------- -->\n\n")
+FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr "\n\n\n <!-- ---------------------------------------- -->")
+FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr "\n <!-- Content from the external data directory -->")
+FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr "\n <!-- ---------------------------------------- -->\n\n")
# Append the external file
FILE(READ @EXTERNAL_DATA_DIRECTORY@/resources.oxr _external_file)
-FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr ${_external_file})
+FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr ${_external_file})
Copied: code/trunk/data/DefaultResources.oxr (from rev 6415, code/branches/presentation2/data/DefaultResources.oxr)
===================================================================
--- code/trunk/data/DefaultResources.oxr (rev 0)
+++ code/trunk/data/DefaultResources.oxr 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,14 @@
+<ResourceCollection resourceGroup = "General" >
+ <ResourceLocation path = "levels" />
+ <ResourceLocation path = "lua" />
+ <ResourceLocation path = "overlays" />
+ <ResourceLocation path = "particle" />
+ <ResourceLocation path = "tcl" />
+</ResourceCollection>
+
+<ResourceCollection resourceGroup = "GUI" >
+ <ResourceLocation path = "gui/configs" />
+ <ResourceLocation path = "gui/layouts" />
+ <ResourceLocation path = "gui/schemes" />
+ <ResourceLocation path = "gui/scripts" />
+</ResourceCollection>
Modified: code/trunk/data/defaultConfig/keybindings.ini
===================================================================
--- code/trunk/data/defaultConfig/keybindings.ini 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/defaultConfig/keybindings.ini 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,7 +22,7 @@
KeyE="scale -1 rotateRoll"
KeyEnd=boost
KeyEquals=
-KeyEscape="exit"
+KeyEscape="keyESC"
KeyF="scale -1 moveUpDown"
KeyF1="OverlayGroup toggleVisibility Debug"
KeyF10=
@@ -121,9 +121,9 @@
KeySpace=boost
KeyStop=
KeySystemRequest=
-KeyT=
-KeyTab="cycleNavigationFocus"
-KeyU=
+KeyT="onpress fire 2"
+KeyTab="NewHumanController changeMode"
+KeyU=""
KeyUP="scale 1 moveFrontBack"
KeyUnassigned="openConsole"
KeyUnderline=
@@ -146,20 +146,18 @@
KeyZ=
[MouseButtons]
-MouseButton3=
-MouseButton4=
-MouseButton5=
-MouseButton6=
-MouseButton7=
-MouseLeft="fire 0"
-MouseMiddle=
-MouseRight="fire 1"
-MouseWheel1Down=
-MouseWheel1Up=
-MouseWheel2Down=
-MouseWheel2Up=
+Button3=
+Button4=
+Button5=
+Button6=
+Button7=
Left="fire 0"
-Right="fire 1"
+Middle=
+Right= fire 1 | unfire
+Wheel1Down="NewHumanController decelerate"
+Wheel1Up="NewHumanController accelerate"
+Wheel2Down=
+Wheel2Up=
[MouseAxes]
MouseXNeg="scale 1 rotateYaw"
Copied: code/trunk/data/gui/layouts/AudioMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/AudioMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/AudioMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/AudioMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/AudioBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/AudioWindow" >
+ <Property Name="Text" Value="Audio" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.2875,0},{0.8,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MasterVolume" >
+ <Property Name="Text" Value="Master volume " />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.15,0},{0.5625,0},{0.3525,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/MasterScrollbar" >
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.6,0},{0.71,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="AudioMenu.AudioMasterScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="AudioMenu.AudioMasterScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="AudioMenu.AudioMasterScrollbar_changed" />
+ </Window>
+ <Window Type="TaharezLook/Checkbox" Name="orxonox/MasterCheckbox" >
+ <Property Name="Text" Value="Mute" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.775,0},{0.45,0},{0.96,0},{0.9,0}}" />
+ <Event Name="CheckStateChanged" Function="AudioMenu.AudioMuteMasterCheckbox_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MusicVolume" >
+ <Property Name="Text" Value="Music volume " />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.4335,0},{0.5625,0},{0.636,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/MusicScrollbar" >
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.6,0},{0.71,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="AudioMenu.AudioMusicScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="AudioMenu.AudioMusicScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="AudioMenu.AudioMusicScrollbar_changed" />
+ </Window>
+ <Window Type="TaharezLook/Checkbox" Name="orxonox/MusicCheckbox" >
+ <Property Name="Text" Value="Mute" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.775,0},{0.45,0},{0.96,0},{0.9,0}}" />
+ <Event Name="CheckStateChanged" Function="AudioMenu.AudioMuteMusicCheckbox_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/EffectsVolume" >
+ <Property Name="Text" Value="Effects volume " />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.717,0},{0.5625,0},{0.9195,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/EffectsScrollbar" >
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.6,0},{0.71,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="AudioMenu.AudioEffectsScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="AudioMenu.AudioEffectsScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="AudioMenu.AudioEffectsScrollbar_changed" />
+ </Window>
+ <Window Type="TaharezLook/Checkbox" Name="orxonox/EffectsCheckbox" >
+ <Property Name="Text" Value="Mute" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.775,0},{0.45,0},{0.96,0},{0.9,0}}" />
+ <Event Name="CheckStateChanged" Function="AudioMenu.AudioMuteEffectsCheckbox_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/AudioTheme" >
+ <Property Name="Text" Value="Theme" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.604166,0},{0.15,0},{0.958333,0},{0.636,0}}" />
+ <Window Type="TaharezLook/Listbox" Name="orxonox/AudioThemeListbox" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.225,0},{0.95,0},{0.92,0}}" />
+ <Event Name="ItemSelectionChanged" Function="AudioMenu.AudioThemeListbox_changed" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/AudioInfo" >
+ <Property Name="Text" >Theme changes might take
+up to a minute.</Property>
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.604166,0},{0.717,0},{0.958333,0},{0.9195,0}}" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/AudioBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="AudioMenu.AudioBackButton_clicked" />
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/ControlsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/ControlsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/ControlsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/ControlsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/ControlsBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/ControlsWindow" >
+ <Property Name="Text" Value="Controls" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/Button" Name="orxonox/MouseControlsButton" >
+ <Property Name="Text" Value="Mouse controls" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.318181,0},{0.7,0},{0.5,0}}" />
+ <Event Name="Clicked" Function="ControlsMenu.ControlsMouseControlsButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/KeybindingsButton" >
+ <Property Name="Text" Value="Keybindings" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.590909,0},{0.7,0},{0.772727,0}}" />
+ <Event Name="Clicked" Function="ControlsMenu.ControlsKeyboardControlsButton_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/ControlsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="ControlsMenu.ControlsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/CreditsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/CreditsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/CreditsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/CreditsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/CreditsBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/CreditsWindow" >
+ <Property Name="Text" Value="Credits" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/CreditsText" >
+ <Property Name="Text">Orxonox version 0.0.3
+
+Programming Language: C++ - lua - tcl
+Environment: OpenAL - Ogre - OIS - CEGUI - enet - ODE
+Licence: GNU General Public Licence - Creative Commons
+
+http://www.orxonox.net</Property>
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.2,0},{0.95,0},{0.9,0}}" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/CreditsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="CreditsMenu.CreditsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/DecisionPopup.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/DecisionPopup.layout)
===================================================================
--- code/trunk/data/gui/layouts/DecisionPopup.layout (rev 0)
+++ code/trunk/data/gui/layouts/DecisionPopup.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/DecisionPopup_RootWindow" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/DecisionPopup_Background" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="Alpha" Value="0.6" />
+ <Window Type="TaharezLook/Button" Name="orxonox/DecisionPopup_button_yes" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Yes" />
+ <Property Name="Alpha" Value="0.7" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.5625,0},{0.4875,0},{0.6125,0}}" />
+ <Event Name="Clicked" Function="DecisionPopup.button_yes"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/DecisionPopup_button_no" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="No" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.5625,0},{0.7125,0},{0.6125,0}}" />
+ <Event Name="Clicked" Function="DecisionPopup.button_no"/>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/DecisionPopup_text" >
+ <Property Name="Text" Value="Template text" />
+ <Property Name="HorzFormatting" Value="WordWrapCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.4375,0},{0.75,0},{0.5375,0}}" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="Alpha" Value="0.8" />
+ </Window>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/GameplayMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/GameplayMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/GameplayMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/GameplayMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/GameplayBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/GameplayWindow" >
+ <Property Name="Text" Value="Gameplay" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/Difficulty" >
+ <Property Name="Text" Value="Difficulty" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.2,0},{0.475,0},{0.9,0}}" />
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/DifficultyEasyButton" >
+ <Property Name="Text" Value="Easy" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.325,0},{0.325,0},{0.675,0},{0.45,0}}" />
+ <Event Name="SelectStateChanged" Function="GameplayMenu.GameplayDifficultyEasyButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/DifficultyNormalButton" >
+ <Property Name="Text" Value="Normal" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.325,0},{0.525,0},{0.675,0},{0.65,0}}" />
+ <Event Name="SelectStateChanged" Function="GameplayMenu.GameplayDifficultyNormalButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/DifficultyHardButton" >
+ <Property Name="Text" Value="Hard" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.325,0},{0.725,0},{0.675,0},{0.85,0}}" />
+ <Event Name="SelectStateChanged" Function="GameplayMenu.GameplayDifficultyHardButton_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/Theme" >
+ <Property Name="Text" Value="Theme" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.525,0},{0.2,0},{0.95,0},{0.9,0}}" />
+ <Window Type="TaharezLook/Combobox" Name="orxonox/ThemeCombobox" >
+ <Property Name="AlwaysOnTop" Value="True" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.21,0},{0.95,0},{0.9,0}}" />
+ <Property Name="MaxEditTextLength" Value="1073741823" />
+ <Property Name="ReadOnly" Value="True" />
+ <Event Name="ListSelectionAccepted" Function="GameplayMenu.GameplayThemeCombobox_changed" />
+ </Window>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/GameplayBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="GameplayMenu.GameplayBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/GraphicsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/GraphicsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/GraphicsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/GraphicsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/GraphicsBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/GraphicsWindow" >
+ <Property Name="Text" Value="Graphics" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/Resolution" >
+ <Property Name="Text" Value="Resolution" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.475,0},{0.92,0}}" />
+ <Window Type="TaharezLook/Listbox" Name="orxonox/ResolutionListbox" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.95,0}}" />
+ <Event Name="ItemSelectionChanged" Function="GraphicsMenu.GraphicsResolutionListbox_changed"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/Brightness" >
+ <Property Name="Text" Value="Brightness" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.525,0},{0.15,0},{0.95,0},{0.35,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/BrightnessScrollbar" >
+ <Property Name="Disabled" Value="true" />
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.6,0},{0.95,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="GraphicsMenu.GraphicsBrightnessScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="GraphicsMenu.GraphicsBrightnessScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="GraphicsMenu.GraphicsBrightnessScrollbar_changed" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Checkbox" Name="orxonox/FullscreenCheckbox" >
+ <Property Name="Text" Value="Fullscreen" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.4,0},{0.85,0},{0.475,0}}" />
+ <Event Name="CheckStateChanged" Function="GraphicsMenu.GraphicsFullscreenCheckbox_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/GraphicsInfo" >
+ <Property Name="Text" >
+Changes in graphics
+settings require
+a game restart.</Property>
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.525,0},{0.525,0},{0.95,0},{0.92,0}}" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/GraphicsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="GraphicsMenu.GraphicsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/InGameMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/InGameMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/InGameMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/InGameMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/InGameMenu_RootWindow" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/Button" Name="orxonox/InGameMenu_ReturnButton" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Return to Game" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
+ <Property Name="Alpha" Value="0.7" />
+ <Event Name="Clicked" Function="InGameMenu.button_return_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/InGameMenu_MainMenuButton" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Main Menu" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4625,0},{0.6,0},{0.5125,0}}" />
+ <Property Name="Alpha" Value="0.7" />
+ <Event Name="Clicked" Function="InGameMenu.button_mainmenu_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/InGameMenu_SettingsButton" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Settings" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5625,0},{0.6,0},{0.6125,0}}" />
+ <Property Name="Alpha" Value="0.7" />
+ <Event Name="Clicked" Function="InGameMenu.button_settings_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/InGameMenu_QuitButton" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Quit" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Property Name="Alpha" Value="0.7" />
+ <Event Name="Clicked" Function="InGameMenu.button_quit_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/InfoPopup.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/InfoPopup.layout)
===================================================================
--- code/trunk/data/gui/layouts/InfoPopup.layout (rev 0)
+++ code/trunk/data/gui/layouts/InfoPopup.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/InfoPopup_RootWindow" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/InfoPopup_Background" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="Alpha" Value="0.7" />
+ <Window Type="TaharezLook/Button" Name="orxonox/InfoPopup_close" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Close" />
+ <Property Name="Alpha" Value="0.7" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5,0},{0.6,0},{0.55,0}}" />
+ <Event Name="Clicked" Function="InfoPopup.close"/>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/InfoPopup_text" >
+ <Property Name="Text" Value="Template text" />
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="HorzFormatting" Value="WordWrapCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.375,0},{0.75,0},{0.475,0}}" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="Alpha" Value="0.8" />
+ </Window>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/KeyBindMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/KeyBindMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/KeyBindMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/KeyBindMenu/Background" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindWindow" >
+ <Property Name="Text" Value="Keybindings" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.2125,0},{0.85,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindWrapper" >
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ <Window Type="TaharezLook/ScrollablePane" Name="orxonox/KeyBindPane" >
+ <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
+ <Property Name="HorzStepSize" Value="0.005" />
+ <Property Name="VertStepSize" Value="0.005" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzOverlapSize" Value="0.01" />
+ <Property Name="UnifiedAreaRect" Value="{{0.005,0},{0.01,0},{0.995,0},{0.99,0}}" />
+ <Property Name="VertOverlapSize" Value="0.01" />
+ <Property Name="HorzScrollPosition" Value="0" />
+ <Property Name="VertScrollPosition" Value="0" />
+ </Window>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/KeyBindBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="KeyBindMenu.KeyBindBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Modified: code/trunk/data/gui/layouts/MainMenu.layout
===================================================================
--- code/trunk/data/gui/layouts/MainMenu.layout 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/layouts/MainMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,53 +1,47 @@
-<?xml version="1.0" ?>
-<GUILayout>
- <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
- <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
- <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
- <Property Name="FrameEnabled" Value="set:true"/>
- <Property Name="BackgroundEnabled" Value="set:false"/>
-
- <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
- <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
- <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
- <Property Name="Text" Value="Standalone"/>
- <Property Name="Disabled" Value="true"/>
- <Event Name="Clicked" Function="MainMenu.button_standalone_clicked"/>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/MainMenuBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1.02125,0},{1.02167,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/Button" Name="orxonox/QuickGameTestButton" >
+ <Property Name="Text" Value="Quickstart" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" />
+ <Event Name="Clicked" Function="MainMenu.QuickGameTestButton_clicked"/>
</Window>
-
- <Window Type="TaharezLook/Listbox" Name="orxonox/LevelListbox">
- <Property Name="UnifiedPosition" Value="{{0.4,0},{0.3,0}}"/>
+ <Window Type="TaharezLook/Button" Name="orxonox/SingleplayerButton" >
+ <Property Name="Text" Value="Singleplayer" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedSize" Value="{{0.35,0},{0.33,0}}" />
- <Property Name="Tooltip" Value="Available Levels." />
- <Event Name="ItemSelectionChanged" Function="MainMenu.listbox_level_selectionchanged" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
+ <Event Name="Clicked" Function="MainMenu.SingleplayerButton_clicked"/>
</Window>
-
- <Window Type="TaharezLook/Button" Name="orxonox/DedicatedButton">
- <Property Name="UnifiedPosition" Value="{{0.11,0},{0.376,0}}"/>
- <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
- <Property Name="Text" Value="Dedicated"/>
- <Event Name="Clicked" Function="MainMenu.button_dedicated_clicked"/>
+ <Window Type="TaharezLook/Button" Name="orxonox/MultiplayerButton" >
+ <Property Name="Text" Value="Multiplayer" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4375,0},{0.6,0},{0.4875,0}}" />
+ <Event Name="Clicked" Function="MainMenu.MultiplayerButton_clicked"/>
</Window>
-
- <Window Type="TaharezLook/Button" Name="orxonox/ServerButton">
- <Property Name="UnifiedPosition" Value="{{0.11,0},{0.452,0}}"/>
- <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
- <Property Name="Text" Value="Server"/>
- <Event Name="Clicked" Function="MainMenu.button_server_clicked"/>
+ <Window Type="TaharezLook/Button" Name="orxonox/SettingsButton" >
+ <Property Name="Text" Value="Settings" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5125,0},{0.6,0},{0.5625,0}}" />
+ <Event Name="Clicked" Function="MainMenu.SettingsButton_clicked"/>
</Window>
-
- <Window Type="TaharezLook/Button" Name="orxonox/ClientButton">
- <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/>
- <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
- <Property Name="Text" Value="Client"/>
- <Event Name="Clicked" Function="MainMenu.button_client_clicked"/>
+ <Window Type="TaharezLook/Button" Name="orxonox/CreditsButton" >
+ <Property Name="Text" Value="Credits" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5875,0},{0.6,0},{0.6375,0}}" />
+ <Event Name="Clicked" Function="MainMenu.CreditsButton_clicked"/>
</Window>
-
- <Window Type="TaharezLook/Button" Name="orxonox/QuitButton">
- <Property Name="UnifiedPosition" Value="{{0.11,0},{0.604,0}}"/>
- <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
- <Property Name="Text" Value="Quit"/>
- <Event Name="Clicked" Function="MainMenu.button_quit_clicked"/>
+ <Window Type="TaharezLook/Button" Name="orxonox/ExitButton" >
+ <Property Name="Text" Value="Exit" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MainMenu.ExitButton_clicked"/>
</Window>
</Window>
</GUILayout>
Copied: code/trunk/data/gui/layouts/MainMenuBackground.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/MainMenuBackground.layout)
===================================================================
--- code/trunk/data/gui/layouts/MainMenuBackground.layout (rev 0)
+++ code/trunk/data/gui/layouts/MainMenuBackground.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<GUILayout>
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
+ <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
+ <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
+ <Property Name="FrameEnabled" Value="set:true"/>
+ <Property Name="BackgroundEnabled" Value="set:false"/>
+ <Property Name="InheritsAlpha" Value="False" />
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/MouseControlsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/MouseControlsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/MouseControlsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/MouseControlsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/MouseControlsBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MouseControlsWindow" >
+ <Property Name="Text" Value="Mouse controls" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MouseNormalSensitivity" >
+ <Property Name="Text" Value="Sensitivity (normal mode) " />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.2,0},{0.95,0},{0.45,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/MouseNormalScrollbar" >
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.6,0},{0.565,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="MouseControlsMenu.MouseControlsMouseNormalScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="MouseControlsMenu.MouseControlsMouseNormalScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="MouseControlsMenu.MouseControlsMouseNormalScrollbar_changed" />
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/MouseNormalButton" >
+ <Property Name="Text" Value="Normal mouse input" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.61,0},{0.5,0},{0.975,0},{0.85,0}}" />
+ <Event Name="SelectStateChanged" Function="MouseControlsMenu.MouseNormalButton_clicked" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MouseDeriveSensitivity" >
+ <Property Name="Text" Value="Sensitivity (derive mode) " />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.55,0},{0.95,0},{0.8,0}}" />
+ <Window Type="TaharezLook/HorizontalScrollbar" Name="orxonox/MouseDeriveScrollbar" >
+ <Property Name="PageSize" Value="0" />
+ <Property Name="StepSize" Value="1" />
+ <Property Name="OverlapSize" Value="0" />
+ <Property Name="DocumentSize" Value="1" />
+ <Property Name="ScrollPosition" Value="0" />
+ <Property Name="StepSize" Value="0.1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.6,0},{0.565,0},{0.8,0}}" />
+ <Event Name="ThumbTrackStarted" Function="MouseControlsMenu.MouseControlsMouseDeriveScrollbar_started" />
+ <Event Name="ThumbTrackEnded" Function="MouseControlsMenu.MouseControlsMouseDeriveScrollbar_ended" />
+ <Event Name="ScrollPosChanged" Function="MouseControlsMenu.MouseControlsMouseDeriveScrollbar_changed" />
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/MouseDeriveButton" >
+ <Property Name="Text" Value="Derive mouse input" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.61,0},{0.5,0},{0.975,0},{0.85,0}}" />
+ <Event Name="SelectStateChanged" Function="MouseControlsMenu.MouseDeriveButton_clicked" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Checkbox" Name="orxonox/MouseInvertCheckbox" >
+ <Property Name="Text" Value="Invert mouse" />
+ <Property Name="Disabled" Value="true" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.39,0},{0.85,0},{0.61,0},{0.95,0}}" />
+ <Event Name="CheckStateChanged" Function="MouseControlsMenu.MouseInvertCheckbox_clicked" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/MouseControlsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MouseControlsMenu.MouseControlsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/MultiplayerMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/MultiplayerMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/MultiplayerMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/MultiplayerMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/MultiplayerBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MultiplayerWindow" >
+ <Property Name="Text" Value="Multiplayer" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/Listbox" Name="orxonox/MultiplayerLevelListbox" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" />
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/MultiplayerJoinButton" >
+ <Property Name="Text" Value="Join" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.85,0},{0.3,0},{0.95,0}}" />
+ <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerJoinButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/MultiplayerHostButton" >
+ <Property Name="Text" Value="Host" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.85,0},{0.6,0},{0.95,0}}" />
+ <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerHostButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/RadioButton" Name="orxonox/MultiplayerDedicatedButton" >
+ <Property Name="Text" Value="Dedicated" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.85,0},{0.9,0},{0.95,0}}" />
+ <Event Name="SelectStateChanged" Function="MultiplayerMenu.MultiplayerDedicatedButton_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/MultiplayerStartButton" >
+ <Property Name="Text" Value="Start" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MultiplayerMenu.MultiplayerStartButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/MultiplayerBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="MultiplayerMenu.MultiplayerBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/MultiplayerOptionsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/MultiplayerOptionsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/MultiplayerOptionsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/MultiplayerOptionsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/MultiplayerOptionsBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/MultiplayerOptionsWindow" >
+ <Property Name="Text" Value="Multiplayer options" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/MultiplayerOptionsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.625,0},{0.6,0},{0.675,0}}" />
+ <Event Name="Clicked" Function="MultiplayerOptionsMenu.MultiplayerOptionsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Modified: code/trunk/data/gui/layouts/PickupInventory.layout
===================================================================
--- code/trunk/data/gui/layouts/PickupInventory.layout 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/layouts/PickupInventory.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -14,7 +14,7 @@
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="TabPanePosition" Value="Bottom" />
<Property Name="UnifiedAreaRect" Value="{{0,10},{0,30},{1,-10},{1,-10}}" />
-
+
<Window Type="TaharezLook/ScrollablePane" Name="orxonox/Inventory/TabControl/TabEquipment">
<Property Name="Text" Value="Equipment" />
<Property Name="UnifiedPosition" Value="{{0.0,3},{0.0,3}}"/>
Modified: code/trunk/data/gui/layouts/QuestGUI.layout
===================================================================
--- code/trunk/data/gui/layouts/QuestGUI.layout 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/layouts/QuestGUI.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -5,6 +5,7 @@
<Property Name="Image" Value="set:MainMenuBackground image:Background"/>
<Property Name="FrameEnabled" Value="set:true"/>
<Property Name="BackgroundEnabled" Value="set:false"/>
+ <Property Name="InheritsAlpha" Value="False" />
<Window Type="TaharezLook/Titlebar" Name="orxonox/QuestGUI/Title">
<Property Name="UnifiedPosition" Value="{{0.05,0},{0.05,0}}"/>
Copied: code/trunk/data/gui/layouts/SettingsMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/SettingsMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/SettingsMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/SettingsMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/SettingsBackground" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/SettingsWindow" >
+ <Property Name="Text" Value="Settings" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/Button" Name="orxonox/GameplayButton" >
+ <Property Name="Text" Value="Gameplay" />
+ <Property Name="Disabled" Value="True" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.181818,0},{0.45,0},{0.363636,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsGameplayButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/MultiplayerOptionsButton" >
+ <Property Name="Text" Value="Multiplayer options" />
+ <Property Name="Disabled" Value="True" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.454545,0},{0.45,0},{0.636363,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsMultiplayerOptionsButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/ControlsButton" >
+ <Property Name="Text" Value="Controls" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.727272,0},{0.45,0},{0.909090,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsControlsButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/GraphicsButton" >
+ <Property Name="Text" Value="Graphics" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.181818,0},{0.95,0},{0.363636,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsGraphicsButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/AudioButton" >
+ <Property Name="Text" Value="Audio" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.454545,0},{0.95,0},{0.636363,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsAudioButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/ResetSettingsButton" >
+ <Property Name="Text" Value="Reset settings" />
+ <Property Name="Disabled" Value="True" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.727272,0},{0.95,0},{0.909090,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsResetSettingsButton_clicked"/>
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/SettingsBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="SettingsMenu.SettingsBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/layouts/SingleplayerMenu.layout (from rev 6415, code/branches/presentation2/data/gui/layouts/SingleplayerMenu.layout)
===================================================================
--- code/trunk/data/gui/layouts/SingleplayerMenu.layout (rev 0)
+++ code/trunk/data/gui/layouts/SingleplayerMenu.layout 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/SingleplayerBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="TaharezLook/StaticText" Name="orxonox/SingleplayerWindow" >
+ <Property Name="Text" Value="Singleplayer" />
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
+ <Window Type="TaharezLook/Listbox" Name="orxonox/SingleplayerLevelListbox" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ </Window>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/SingleplayerStartButton" >
+ <Property Name="Text" Value="Start" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerStartButton_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/SingleplayerBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
+ <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
+ </Window>
+ </Window>
+</GUILayout>
Copied: code/trunk/data/gui/scripts/AudioMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/AudioMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/AudioMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/AudioMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,184 @@
+-- AudioMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ AudioMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "AudioMenu"
+P.layoutString = "AudioMenu.layout"
+
+function P:init()
+ soundMgr = orxonox.SoundManager:getInstance()
+ block = false
+ masterscrollbar_active = false
+ musicscrollbar_active = false
+ effectsscrollbar_active = false
+ mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
+ musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
+ effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
+ mastermute = soundMgr:getMute(orxonox.SoundType.All)
+ musicmute = soundMgr:getMute(orxonox.SoundType.Music)
+ effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
+ masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
+ musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
+ effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
+ mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
+ musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
+ effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
+ masterscrollbarwindow:setScrollPosition(mastervolume)
+ musicscrollbarwindow:setScrollPosition(musicvolume)
+ effectsscrollbarwindow:setScrollPosition(effectsvolume)
+ mastermutewindow:setSelected(mastermute)
+ musicmutewindow:setSelected(musicmute)
+ effectsmutewindow:setSelected(effectsmute)
+ choice = "Default"
+ listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
+ local themeList = {}
+ table.insert(themeList, "Default")
+ table.insert(themeList, "Drum n' Bass")
+ for k,v in pairs(themeList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toListbox(listboxwindow):addItem(item)
+ end
+ if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
+ listboxwindow:setItemSelectState(1,true)
+ else
+ listboxwindow:setItemSelectState(0,true)
+ end
+end
+
+function P.AudioMasterScrollbar_changed(e)
+ if mastermute then
+ block = true
+ mastermutewindow:setSelected(false)
+ block = false
+ mastermute = false
+ end
+ if masterscrollbar_active == false then
+ mastervolume = masterscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "soundVolume_", mastervolume)
+ end
+end
+
+function P.AudioMasterScrollbar_started(e)
+ masterscrollbar_active = true
+end
+
+function P.AudioMasterScrollbar_ended(e)
+ mastervolume = masterscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "soundVolume_", mastervolume)
+ masterscrollbar_active = false
+end
+
+function P.AudioMusicScrollbar_changed(e)
+ if musicmute then
+ block = true
+ musicmutewindow:setSelected(false)
+ block = false
+ musicmute = false
+ end
+ if musicscrollbar_active == false then
+ musicvolume = musicscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "ambientVolume_", musicvolume)
+ end
+end
+
+function P.AudioMusicScrollbar_started(e)
+ musicscrollbar_active = true
+end
+
+function P.AudioMusicScrollbar_ended(e)
+ musicmutewindow:setSelected(false)
+ musicvolume = musicscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "ambientVolume_", musicvolume)
+ musicscrollbar_active = false
+end
+
+function P.AudioEffectsScrollbar_changed(e)
+ if effectsmute then
+ block = true
+ effectsmutewindow:setSelected(false)
+ block = false
+ effectsmute = false
+ end
+ if effectsscrollbar_active == false then
+ effectsvolume = effectsscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
+ end
+end
+
+function P.AudioEffectsScrollbar_started(e)
+ effectsscrollbar_active = true
+end
+
+function P.AudioEffectsScrollbar_ended(e)
+ effectsmutewindow:setSelected(false)
+ effectsvolume = effectsscrollbarwindow:getScrollPosition()
+ orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
+ effectsscrollbar_active = false
+end
+
+function P.AudioMuteMasterCheckbox_clicked(e)
+ if block == false then
+ if mastermute then
+ masterscrollbarwindow:setScrollPosition(mastervolume)
+ mastermute = false
+ else
+ temp = masterscrollbarwindow:getScrollPosition()
+ masterscrollbarwindow:setScrollPosition(0)
+ mastervolume = temp
+ mastermute = true
+ end
+ end
+ soundMgr:toggleMute(orxonox.SoundType.All)
+end
+
+function P.AudioMuteMusicCheckbox_clicked(e)
+ if block == false then
+ if musicmute then
+ musicscrollbarwindow:setScrollPosition(musicvolume)
+ musicmute = false
+ else
+ temp = musicscrollbarwindow:getScrollPosition()
+ musicscrollbarwindow:setScrollPosition(0)
+ musicvolume = temp
+ musicmute = true
+ end
+ end
+ soundMgr:toggleMute(orxonox.SoundType.Music)
+end
+
+function P.AudioMuteEffectsCheckbox_clicked(e)
+ if block == false then
+ if effectsmute then
+ effectsscrollbarwindow:setScrollPosition(effectsvolume)
+ effectsmute = false
+ else
+ temp = effectsscrollbarwindow:getScrollPosition()
+ effectsscrollbarwindow:setScrollPosition(0)
+ effectsvolume = temp
+ effectsmute = true
+ end
+ end
+ soundMgr:toggleMute(orxonox.SoundType.Effects)
+end
+
+function P.AudioThemeListbox_changed(e)
+ if listboxwindow:isItemSelected(1) then
+ orxonox.config("MoodManager", "mood_", "dnb")
+ else
+ orxonox.config("MoodManager", "mood_", "default")
+ end
+end
+
+function P.AudioBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/ControlsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/ControlsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/ControlsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/ControlsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,27 @@
+-- ControlsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ ControlsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "ControlsMenu"
+P.layoutString = "ControlsMenu.layout"
+
+function P.ControlsMouseControlsButton_clicked(e)
+ showGUI("MouseControlsMenu", true)
+end
+
+function P.ControlsKeyboardControlsButton_clicked(e)
+ showGUI("KeyBindMenu", true)
+end
+
+function P.ControlsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/CreditsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/CreditsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/CreditsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/CreditsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,19 @@
+-- CreditsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ CreditsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "CreditsMenu"
+P.layoutString = "CreditsMenu.layout"
+
+function P.CreditsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/DecisionPopup.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/DecisionPopup.lua)
===================================================================
--- code/trunk/data/gui/scripts/DecisionPopup.lua (rev 0)
+++ code/trunk/data/gui/scripts/DecisionPopup.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,41 @@
+-- DecisionPopup.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ DecisionPopup = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "DecisionPopup"
+P.layoutString = "DecisionPopup.layout"
+
+function P:init()
+end
+
+function P.setCallback(functionPtr)
+ P.functionPtr = functionPtr
+end
+
+function P.setText( text )
+ winMgr:getWindow("orxonox/DecisionPopup_text"):setText( text )
+end
+
+-- events for ingamemenu
+function P.button_yes(e)
+ if P.functionPtr ~= nil then
+ P.functionPtr(true)
+ end
+ hideGUI("DecisionPopup")
+end
+
+function P.button_no(e)
+ if P.functionPtr ~= nil then
+ P.functionPtr(false)
+ end
+ hideGUI("DecisionPopup")
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/GUITools.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/GUITools.lua)
===================================================================
--- code/trunk/data/gui/scripts/GUITools.lua (rev 0)
+++ code/trunk/data/gui/scripts/GUITools.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,31 @@
+function openDecisionPopup( text, callbackPtr )
+ showGUI("DecisionPopup", false, true)
+ DecisionPopup.setCallback(callbackPtr)
+ DecisionPopup.setText(text)
+end
+
+function openInfoPopup(text, functionPtr, closeButton, arguments)
+ showGUI("InfoPopup", false, true)
+ InfoPopup.execute(functionPtr, arguments)
+ InfoPopup.setText(text)
+ InfoPopup.setCloseButton(closeButton)
+end
+
+function getMinTextSize(window)
+ local size = {}
+
+ local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
+ local height = window:getFont():getLineSpacing() + window:getUnclippedPixelRect():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight()
+ local width = window:getFont():getTextExtent(window:getText()) + window:getUnclippedPixelRect():getWidth() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth()
+
+ table.insert(size, height)
+ table.insert(size, width)
+ return size
+end
+
+function getScrollingStepSize(window)
+ local height = window:getUnclippedPixelRect():getHeight()
+ local maxHeight = CEGUI.System:getSingleton():getGUISheet():getUnclippedPixelRect():getHeight()
+ local ratio = height/maxHeight
+ return 0.008*ratio/0.3204
+end
Copied: code/trunk/data/gui/scripts/GameplayMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/GameplayMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/GameplayMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/GameplayMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,52 @@
+-- GameplayMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ GameplayMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "GameplayMenu"
+P.layoutString = "GameplayMenu.layout"
+
+function P:init()
+ dropdown = winMgr:getWindow("orxonox/ThemeCombobox")
+ local themeList = {}
+ table.insert(themeList, "Theme 1")
+ table.insert(themeList, "Theme 2")
+ table.insert(themeList, "Theme 3")
+ for k,v in pairs(themeList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toCombobox(dropdown):addItem(item)
+ end
+end
+
+function P.GameplayThemeCombobox_changed(e)
+ -- theme
+ debug("event: theme")
+end
+
+function P.GameplayDifficultyEasyButton_clicked(e)
+ -- difficulty easy
+ debug("event: easy")
+end
+
+function P.GameplayDifficultyNormalButton_clicked(e)
+ -- difficulty normal
+ debug("event: normal")
+end
+
+function P.GameplayDifficultyHardButton_clicked(e)
+ -- difficulty hard
+ debug("event: hard")
+end
+
+function P.GameplayBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/GraphicsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/GraphicsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/GraphicsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/GraphicsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,207 @@
+-- GraphicsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ GraphicsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "GraphicsMenu"
+P.layoutString = "GraphicsMenu.layout"
+
+function P:init()
+ block = true
+ file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
+ search_mode = 0
+ f = io.open(file, "r")
+ firstline = f:read("*line")
+ rendersystem = string.sub(firstline, 15)
+ for line in f:lines() do
+ if search_mode == 0 then
+ if string.find(line, rendersystem) ~= nil then
+ search_mode = 1
+ end
+ end
+ if search_mode == 1 then
+ if string.sub(line, 1, 11) == "Full Screen" then
+ if string.sub(line, 13) == "Yes" then
+ fullscreen = true
+ else
+ fullscreen = false
+ end
+ end
+ if string.sub(line, 1, 10) == "Video Mode" then
+ if string.match(line, "@") == "@" then
+ resolution = string.sub(line, 12, string.find(line, "@")-2)
+ else
+ resolution = string.sub(line, 12)
+ end
+ break
+ end
+ end
+ end
+ f:close()
+ local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
+ fullscreenwindow:setSelected(fullscreen)
+ listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
+ local resolutionList = {}
+ table.insert(resolutionList, "640 x 480")
+ table.insert(resolutionList, "720 x 480")
+ table.insert(resolutionList, "720 x 576")
+ table.insert(resolutionList, "800 x 480")
+ table.insert(resolutionList, "800 x 600")
+ table.insert(resolutionList, "1024 x 480")
+ table.insert(resolutionList, "1024 x 600")
+ table.insert(resolutionList, "1024 x 768")
+ table.insert(resolutionList, "1152 x 864")
+ table.insert(resolutionList, "1280 x 720")
+ table.insert(resolutionList, "1280 x 768")
+ table.insert(resolutionList, "1440 x 900")
+ for k,v in pairs(resolutionList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toListbox(listboxwindow):addItem(item)
+ end
+ if resolution == "640 x 480" then
+ listboxwindow:setItemSelectState(0,true)
+ elseif resolution == "720 x 480" then
+ listboxwindow:setItemSelectState(1,true)
+ elseif resolution == "720 x 576" then
+ listboxwindow:setItemSelectState(2,true)
+ elseif resolution == "800 x 480" then
+ listboxwindow:setItemSelectState(3,true)
+ elseif resolution == "800 x 600" then
+ listboxwindow:setItemSelectState(4,true)
+ elseif resolution == "1024 x 480" then
+ listboxwindow:setItemSelectState(5,true)
+ elseif resolution == "1024 x 600" then
+ listboxwindow:setItemSelectState(6,true)
+ elseif resolution == "1024 x 768" then
+ listboxwindow:setItemSelectState(7,true)
+ elseif resolution == "1152 x 864" then
+ listboxwindow:setItemSelectState(8,true)
+ elseif resolution == "1280 x 720" then
+ listboxwindow:setItemSelectState(9,true)
+ elseif resolution == "1280 x 768" then
+ listboxwindow:setItemSelectState(10,true)
+ elseif resolution == "1440 x 900" then
+ listboxwindow:setItemSelectState(11,true)
+ end
+ scrollbar_active = false
+ block = false
+end
+
+function P.GraphicsResolutionListbox_changed(e)
+ if listboxwindow:isItemSelected(0) then
+ resolution = "640 x 480"
+ elseif listboxwindow:isItemSelected(1) then
+ resolution = "720 x 480"
+ elseif listboxwindow:isItemSelected(2) then
+ resolution = "720 x 576"
+ elseif listboxwindow:isItemSelected(3) then
+ resolution = "800 x 480"
+ elseif listboxwindow:isItemSelected(4) then
+ resolution = "800 x 600"
+ elseif listboxwindow:isItemSelected(5) then
+ resolution = "1024 x 480"
+ elseif listboxwindow:isItemSelected(6) then
+ resolution = "1024 x 600"
+ elseif listboxwindow:isItemSelected(7) then
+ resolution = "1024 x 768"
+ elseif listboxwindow:isItemSelected(8) then
+ resolution = "1152 x 864"
+ elseif listboxwindow:isItemSelected(9) then
+ resolution = "1280 x 720"
+ elseif listboxwindow:isItemSelected(10) then
+ resolution = "1280 x 768"
+ elseif listboxwindow:isItemSelected(11) then
+ resolution = "1440 x 900"
+ end
+ search_mode = 0
+ f = io.open(file, "r")
+ firstline = f:read("*line")
+ text = firstline .. "\n"
+ rendersystem = string.sub(firstline, 15)
+ for line in f:lines() do
+ if search_mode == 0 then
+ if string.find(line, rendersystem) ~= nil then
+ search_mode = 1
+ end
+ end
+ if search_mode == 1 then
+ if string.sub(line, 1, 10) == "Video Mode" then
+ if string.match(line, "@") == "@" then
+ line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
+ else
+ line = "Video Mode=" .. resolution
+ end
+ search_mode = 2
+ end
+ end
+ text = text .. line .. "\n"
+ end
+ f:close()
+ f = io.open(file, "w")
+ f:write(text)
+ f:close()
+end
+
+function P.GraphicsBrightnessScrollbar_changed(e)
+ if scrollbar_active == false then
+ -- brightness
+ debug("event: brightness")
+ end
+end
+
+function P.GraphicsBrightnessScrollbar_started(e)
+ scrollbar_active = true
+end
+
+function P.GraphicsBrightnessScrollbar_ended(e)
+ -- brightness
+ debug("event: brightness")
+ scrollbar_active = false
+end
+
+function P.GraphicsFullscreenCheckbox_clicked(e)
+ if block == false then
+ search_mode = 0
+ f = io.open(file, "r")
+ firstline = f:read("*line")
+ text = firstline .. "\n"
+ rendersystem = string.sub(firstline, 15)
+ for line in f:lines() do
+ if search_mode == 0 then
+ if string.find(line, rendersystem) ~= nil then
+ search_mode = 1
+ end
+ end
+ if search_mode == 1 then
+ if string.sub(line, 1, 11) == "Full Screen" then
+ if fullscreen == true then
+ line = "Full Screen=No"
+ fullscreen = false
+ else
+ line = "Full Screen=Yes"
+ fullscreen = true
+ end
+ search_mode = 2
+ end
+ end
+ text = text .. line .. "\n"
+ end
+ f:close()
+ f = io.open(file, "w")
+ f:write(text)
+ f:close()
+ end
+end
+
+function P.GraphicsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/InGameMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/InGameMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/InGameMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/InGameMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,46 @@
+-- InGameMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ InGameMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "InGameMenu"
+P.layoutString = "InGameMenu.layout"
+
+function P:init()
+end
+
+
+-- events for ingamemenu
+function P.button_quit_clicked(e)
+ openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback )
+end
+
+function P.button_mainmenu_clicked(e)
+ orxonox.Game:getInstance():popState()
+ orxonox.Game:getInstance():popState()
+ orxonox.Game:getInstance():requestState("mainmenu")
+ hideGUI("InGameMenu")
+end
+
+function P.button_settings_clicked(e)
+ showGUI("SettingsMenu", true)
+end
+
+function P.button_return_clicked(e)
+ hideGUI("InGameMenu")
+end
+
+function P.callback(doExit)
+ if doExit then
+ hideGUI("InGameMenu")
+ orxonox.execute("exit")
+ end
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/InfoPopup.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/InfoPopup.lua)
===================================================================
--- code/trunk/data/gui/scripts/InfoPopup.lua (rev 0)
+++ code/trunk/data/gui/scripts/InfoPopup.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,47 @@
+-- InfoPopup.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+
+if _REQUIREDNAME == nil then
+ InfoPopup = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "InfoPopup"
+P.layoutString = "InfoPopup.layout"
+
+function P:init()
+end
+
+function P.execute(functionPtr, arguments)
+ if functionPtr ~= nil then
+ if arguments ~= nil then
+ functionPtr(arguments)
+ else
+ functionPtr()
+ end
+ end
+end
+
+function P.setText( text )
+ winMgr:getWindow("orxonox/InfoPopup_text"):setText( text )
+end
+
+function P.setCloseButton(closeButton)
+ close = winMgr:getWindow("orxonox/InfoPopup_close")
+ close:setVisible(closeButton)
+ if(not closeButton) then
+ close:deactivate();
+ else
+ close:activate();
+ end
+end
+
+-- events for ingamemenu
+function P.close(e)
+ hideGUI("InfoPopup")
+end
+
+return P
Modified: code/trunk/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/trunk/data/gui/scripts/InitialiseGUI.lua 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/scripts/InitialiseGUI.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -13,7 +13,16 @@
system:setDefaultTooltip("TaharezLook/Tooltip")
loadedGUIs = {}
+cursorVisibility = {}
+activeSheets = {}
+nrOfActiveSheets = 0
+root = nil
+bShowsCursor = false
+bHidePrevious = {}
+-- Require all tools
+require("GUITools")
+
-- loads the GUI with the specified filename
-- be sure to set the global variable "filename" before calling this function
function loadGUI(filename)
@@ -21,12 +30,14 @@
loadedGui = loadedGUIs[filename]
if loadedGui == nil then
loadedGuiNS = require(filename)
+ if loadedGuiNS == nil then
+ return
+ end
loadedGui = loadedGuiNS:load()
loadedGUIs[filename] = loadedGui
-- if there has no GUI been loaded yet, set new GUI as current
if table.getn(loadedGUIs) == 1 then
current = loadedGUIs[1]
- showing = false
end
-- hide new GUI as we do not want to show it accidentially
loadedGui:hide()
@@ -34,51 +45,183 @@
return loadedGui
end
-function showGUI(filename, ptr)
- gui = showGUI(filename)
+function showGUI(filename, hidePrevious, bCursorVisible, ptr)
+ gui = showGUI(filename, hidePrevious, bCursorVisible)
gui.overlay = ptr
end
-- shows the specified and loads it if not loaded already
-- be sure to set the global variable "filename" before calling this function
-function showGUI(filename)
- if current == nil or current.filename ~= filename then
- current = loadedGUIs[filename]
- if current == nil then
- current = loadGUI(filename)
+function showGUI(filename, hidePrevious, bCursorVisible)
+ if bCursorVisible == nil then
+ if nrOfActiveSheets > 0 then
+ bCursorVisible = cursorVisibility[activeSheets[nrOfActiveSheets]]
+ else
+ bCursorVisible = true
end
- system:setGUISheet(current.window)
end
- current:show()
- showing = true
- return current
-end
-function toggleGUI()
- if showing == true then
- current:hide()
- cursor:hide()
- showing = false
+ if root == nil then
+ setBackground("")
+ end
+
+ local currentGUI = loadedGUIs[filename]
+ if(currentGUI == nil) then
+ currentGUI = loadGUI(filename)
+ end
+
+ if(root:isChild(currentGUI.window)) then
+ root:removeChildWindow(currentGUI.window)
+ end
+ root:addChildWindow(currentGUI.window)
+
+ if bCursorVisible then
+ showCursor()
else
- current:show()
- cursor:show()
- showing = true
+ hideCursor()
end
- return showing
+
+ if find( activeSheets, filename ) ~= nil then
+ table.remove( activeSheets, find( activeSheets, filename ) )
+ nrOfActiveSheets = nrOfActiveSheets - 1
+ else
+ if nrOfActiveSheets == 0 then
+ orxonox.InputManager:getInstance():enterState("guiMouseOnly")
+ orxonox.HumanController:pauseControl()
+ end
+ end
+ nrOfActiveSheets = nrOfActiveSheets + 1
+ table.insert(activeSheets, filename)
+ activeSheets[nrOfActiveSheets] = filename
+ bHidePrevious[filename]=hidePrevious
+ cursorVisibility[filename] = bCursorVisible
+
+ if hidePrevious == true then
+ for i=1,nrOfActiveSheets-1 do
+ loadedGUIs[ activeSheets[i] ]:hide()
+ end
+ end
+ currentGUI:show()
+ return currentGUI
end
function hideCursor()
- cursor:hide()
+ if bShowsCursor==true then
+ bShowsCursor=false
+ cursor:hide()
+ end
end
function showCursor()
- cursor:show()
+ if bShowsCursor==false then
+ bShowsCursor=true
+ cursor:show()
+ end
end
function hideGUI(filename)
- current = loadedGUIs[filename]
- if current ~= nil then
- current:hide()
- showing = false
+ local currentGUI = loadedGUIs[filename]
+ if currentGUI == nil then
+ return
end
+ currentGUI:hide()
+ if bHidePrevious[filename] == true then
+ local i = nrOfActiveSheets-1
+ while i>0 do
+ loadedGUIs[ activeSheets[i] ]:show()
+ if bHidePrevious[filename]==true then
+ break
+ else
+ i=i-1
+ end
+ end
+ end
+ root:removeChildWindow(currentGUI.window)
+ local i=1
+ while activeSheets[i] do
+ if activeSheets[i+1] == nil then
+ if activeSheets[i-1] ~= nil then
+ if cursorVisibility[ activeSheets[i-1] ] == true then
+ showCursor()
+ else
+ hideCursor()
+ end
+ else
+ hideCursor()
+ end
+ end
+ if activeSheets[i] == filename then
+ table.remove( activeSheets, i )
+ nrOfActiveSheets = nrOfActiveSheets-1
+ else
+ i = i+1
+ end
+ end
+ cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
+ bHidePrevious[filename] = nil
+ if nrOfActiveSheets == 0 then
+ orxonox.InputManager:getInstance():leaveState("guiMouseOnly")
+ orxonox.HumanController:resumeControl()
+ hideCursor()
+ end
end
+
+function hideAllGUIs()
+ while nrOfActiveSheets ~= 0 do
+ hideGUI(activeSheets[nrOfActiveSheets])
+ end
+end
+
+function keyESC()
+ if nrOfActiveSheets == 1 and activeSheets[1] == "MainMenu" then
+ orxonox.execute("exit")
+ elseif nrOfActiveSheets > 0 then
+ orxonox.execute("hideGUI "..activeSheets[nrOfActiveSheets])
+ else
+ showGUI("InGameMenu")
+ end
+end
+
+function setBackground(filename)
+ local newroot
+ if root ~= nil then
+ root:rename("oldRootWindow")
+ end
+ if filename ~= "" then
+ newroot = winMgr:loadWindowLayout(filename .. ".layout")
+ newroot:rename("AbsoluteRootWindow")
+ system:setGUISheet(newroot)
+ else
+ newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
+ newroot:setProperty("Alpha", "0.0")
+ newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
+ system:setGUISheet(newroot)
+ end
+ if root ~= nil then
+ local child
+ while root:getChildCount()~=0 do
+ child = root:getChildAtIdx(0)
+ root:removeChildWindow(child)
+ newroot:addChildWindow(child)
+ end
+ winMgr:destroyWindow(root)
+ end
+ newroot:show()
+ root = newroot
+end
+
+function find(table, value)
+ local i=0
+ while table[i] ~= nil do
+ if table[i]==value then
+ return i
+ else
+ i=i+1
+ end
+ end
+ return nil
+end
+
+function test(e)
+ debug(0, "Blubb")
+end
Copied: code/trunk/data/gui/scripts/KeyBindMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/KeyBindMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/KeyBindMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,257 @@
+-- KeyBindMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+
+if _REQUIREDNAME == nil then
+ KeyBindMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "KeyBindMenu"
+P.layoutString = "KeyBindMenu.layout"
+
+function P:init()
+
+ commandList = {}
+ table.insert(commandList, "fire 0")
+ table.insert(commandList, "fire 1 | unfire")
+ table.insert(commandList, "onpress fire 2")
+ table.insert(commandList, "scale 1 moveFrontBack")
+ table.insert(commandList, "scale -1 moveFrontBack")
+ table.insert(commandList, "boost")
+ table.insert(commandList, "scale 1 moveRightLeft")
+ table.insert(commandList, "scale -1 moveRightLeft")
+ table.insert(commandList, "scale 1 moveUpDown")
+ table.insert(commandList, "scale -1 moveUpDown")
+ table.insert(commandList, "scale -1 rotateRoll")
+ table.insert(commandList, "scale 1 rotateRoll")
+ table.insert(commandList, "scale 1 rotateYaw")
+ table.insert(commandList, "scale -1 rotateYaw")
+ table.insert(commandList, "scale 1 rotatePitch")
+ table.insert(commandList, "scale -1 rotatePitch")
+ table.insert(commandList, "NewHumanController changeMode")
+ table.insert(commandList, "switchCamera")
+ table.insert(commandList, "openConsole")
+ table.insert(commandList, "OverlayGroup toggleVisibility Debug")
+ table.insert(commandList, "OverlayGroup toggleVisibility Stats")
+ table.insert(commandList, "mouseLook")
+ table.insert(commandList, "pause")
+
+ nameList = {}
+ table.insert(nameList, "Primary Fire")
+ table.insert(nameList, "Secondary Fire")
+ table.insert(nameList, "Fire Rocket")
+ table.insert(nameList, "Accelerate")
+ table.insert(nameList, "Break")
+ table.insert(nameList, "Boost")
+ table.insert(nameList, "Move Right")
+ table.insert(nameList, "Move Left")
+ table.insert(nameList, "Move Up")
+ table.insert(nameList, "Move Down")
+ table.insert(nameList, "Roll Right")
+ table.insert(nameList, "Roll Left")
+ table.insert(nameList, "Yaw Left")
+ table.insert(nameList, "Yaw Right")
+ table.insert(nameList, "Pitch Up")
+ table.insert(nameList, "Pitch Down")
+ table.insert(nameList, "Switch Input Mode")
+ table.insert(nameList, "Switch Camera")
+ table.insert(nameList, "Open Console")
+ table.insert(nameList, "Show Debug")
+ table.insert(nameList, "Show Stats")
+ table.insert(nameList, "Look Around")
+ table.insert(nameList, "Pause")
+
+ linesList = {}
+
+ --Calculate design parameters:
+ sampleWindow = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/SampleWindow")
+ sampleWindow:setText("SampleText")
+
+ local size = getMinTextSize(sampleWindow)
+ lineHeight = size[1]
+
+ commandWidth = 0
+ for k,v in pairs(commandList) do
+ sampleWindow:setText(nameList[k])
+ size = getMinTextSize(sampleWindow)
+ if size[2] > commandWidth then
+ commandWidth = size[2]
+ end
+ end
+
+ sampleWindow:setText("add")
+ size = getMinTextSize(sampleWindow)
+ addWidth = size[2]
+
+ sampleWindow:setText("X")
+ size = getMinTextSize(sampleWindow)
+ clearWidth = size[2]
+
+ spaceWidth = math.floor(1/14*commandWidth)
+
+ buttonWidth = 145
+
+ P.createLines()
+
+ local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
+ orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
+end
+
+function P.KeyNameNiceifier(key)
+ local name = string.sub(key, string.find(key, '%.(.*)')+1)
+ local group = string.sub(key, string.find(key, '(.*)%.'))
+ group = string.sub(group,1,string.len(group)-1)
+ if( group == "Keys") then
+ return "Key " .. string.sub(name, string.find(name, 'Key(.*)')+3)
+ elseif( group == "MouseButtons") then
+ return "Mouse " .. name
+ elseif( string.find(group, "JoyStickButtons") ~= nil ) then
+ return "Joystick " .. name
+ elseif( string.find(group, "JoyStickAxes") ~= nil ) then
+ return "Joystick Axis" .. string.sub(name, 5, 6) .. string.sub(name, string.find(name, 'Axis%d%d(.*)')+6)
+ elseif( group == "MouseAxes" ) then
+ return "Mouse " .. string.sub(name, string.find(name, '.(.*)')+1) .. " " .. string.sub(name, 1, 1) .. "-Axis"
+ end
+ return key
+end
+
+function P.createLine(k)
+ local offset = 0
+ local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
+ line:setHeight(CEGUI.UDim(0, lineHeight))
+ line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
+
+ local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
+ command:setText(nameList[k])
+ command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0)))
+ command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
+ line:addChildWindow(command)
+ offset = offset + commandWidth + spaceWidth
+
+ local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
+ plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, addWidth), CEGUI.UDim(0.7, 0)))
+ plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
+ plus:setText("add")
+ orxonox.GUIManager:subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
+ line:addChildWindow(plus)
+ offset = offset + addWidth + spaceWidth
+
+ local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
+ for i=0,(numButtons-1) do
+ local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
+ local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
+ name = P.KeyNameNiceifier(name)
+ button:setText(name)
+ sampleWindow:setText(name)
+ local size = getMinTextSize(sampleWindow)
+ local buttonWidth = size[2]
+ button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
+ button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
+ orxonox.GUIManager:subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
+ --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
+ line:addChildWindow(button)
+ offset = offset + buttonWidth
+
+ local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
+ clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
+ clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
+ clear:setText("X")
+ orxonox.GUIManager:subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
+ line:addChildWindow(clear)
+ offset = offset + clearWidth + spaceWidth
+ end
+
+ line:setWidth(CEGUI.UDim(0, offset+clearWidth))
+
+ return line
+end
+
+function P.createLines()
+ local window = winMgr:getWindow("orxonox/KeyBindPane")
+
+ for k,v in pairs(commandList) do
+ local line = P.createLine(k)
+ table.insert(linesList, line)
+ window:addChildWindow(line)
+ end
+
+ pane = tolua.cast(window, "CEGUI::ScrollablePane")
+ pane:setVerticalStepSize(getScrollingStepSize(window))
+end
+
+function P.KeyBindButton_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+
+ local match = string.gmatch(name, "%d+")
+ local commandNr = tonumber(match())
+ local buttonNr = tonumber(match())
+
+ local arguments = {}
+ arguments[1] = commandNr
+ arguments[2] = buttonNr
+ openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
+end
+
+function P.KeyBindPlus_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+
+ local match = string.gmatch(name, "%d+")
+ local commandNr = tonumber(match())
+
+ local arguments = {}
+ arguments[1] = commandNr
+ openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
+end
+
+function P.KeyBindClear_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+
+ local match = string.gmatch(name, "%d+")
+ local commandNr = tonumber(match())
+ local buttonNr = tonumber(match())
+
+ orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
+
+ P.callback()
+end
+
+function P.keybind(arguments)
+ local commandNr = arguments[1]
+ local buttonNr = arguments[2]
+ if buttonNr ~= nil then
+ orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
+ end
+
+ orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
+end
+
+function P.callback()
+ local pane = tolua.cast(winMgr:getWindow("orxonox/KeyBindPane"), "CEGUI::ScrollablePane")
+ local position = pane:getVerticalScrollPosition()
+ while table.getn(linesList) ~= 0 do
+ if linesList[1] ~= nil then
+ winMgr:destroyWindow(linesList[1]:getName())
+ end
+ table.remove(linesList, 1)
+ end
+
+ linesList = {}
+
+ P.createLines()
+ if(InfoPopup ~= nil) then
+ InfoPopup.close()
+ end
+ pane:setVerticalScrollPosition( position )
+end
+
+function P.KeyBindBackButton_clicked(e)
+ hideGUI("KeyBindMenu")
+end
+
+return P
Modified: code/trunk/data/gui/scripts/MainMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MainMenu.lua 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/scripts/MainMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -11,82 +11,30 @@
P.filename = "MainMenu"
P.layoutString = "MainMenu.layout"
-function P:init()
- listbox = winMgr:getWindow("orxonox/LevelListbox")
- preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
- orxonox.LevelManager:getInstance():compileAvailableLevelList()
- local levelList = {}
- local index = 0
- local level = ""
- while true do
- level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
- if level == "" then
- break
- end
- table.insert(levelList, level)
- index = index + 1
- end
- table.sort(levelList)
- for k,v in pairs(levelList) do
- item = CEGUI.createListboxTextItem(v)
- item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
- CEGUI.toListbox(listbox):addItem(item)
- if v .. ".oxw" == preselect then
- listbox:setItemSelectState(item, true)
- end
- end
+-- events for MainMenu
+function P.QuickGameTestButton_clicked(e)
+ orxonox.execute("startGame")
end
-
--- events for mainmenu
-function P.button_quit_clicked(e)
- hideGUI()
- orxonox.CommandExecutor:execute("exit")
+function P.SingleplayerButton_clicked(e)
+ showGUI("SingleplayerMenu", true)
end
-function P.button_standalone_clicked(e)
- choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- orxonox.CommandExecutor:execute("startGame")
- toggleGUI()
- end
+function P.MultiplayerButton_clicked(e)
+ showGUI("MultiplayerMenu", true)
end
-function P.button_server_clicked(e)
- choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- orxonox.CommandExecutor:execute("startServer")
- toggleGUI()
- end
+function P.SettingsButton_clicked(e)
+ showGUI("SettingsMenu", true)
end
-function P.button_dedicated_clicked(e)
- choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- orxonox.CommandExecutor:execute("startDedicated")
- toggleGUI()
- end
+function P.CreditsButton_clicked(e)
+ showGUI("CreditsMenu", true)
end
-function P.button_client_clicked(e)
- choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
- if choice then
- orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
- orxonox.CommandExecutor:execute("startClient")
- toggleGUI()
- end
+function P.ExitButton_clicked(e)
+ orxonox.execute("exit")
end
-function P.listbox_level_selectionchanged(e)
- if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then
- winMgr:getWindow("orxonox/StandaloneButton"):enable()
- else
- winMgr:getWindow("orxonox/StandaloneButton"):disable()
- end
-end
-
return P
Copied: code/trunk/data/gui/scripts/MouseControlsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/MouseControlsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/MouseControlsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/MouseControlsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,110 @@
+-- MouseControlsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ MouseControlsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "MouseControlsMenu"
+P.layoutString = "MouseControlsMenu.layout"
+
+function P:init()
+ block = false
+ mousenormalscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MouseNormalScrollbar"),"CEGUI::Scrollbar")
+ mousederivescrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MouseDeriveScrollbar"),"CEGUI::Scrollbar")
+ normalwindow = tolua.cast(winMgr:getWindow("orxonox/MouseNormalButton"),"CEGUI::RadioButton")
+ derivewindow = tolua.cast(winMgr:getWindow("orxonox/MouseDeriveButton"),"CEGUI::RadioButton")
+ invertwindow = tolua.cast(winMgr:getWindow("orxonox/MouseInvertCheckbox"),"CEGUI::Checkbox")
+ mousenormalscrollbar_active = false
+ mousederivescrollbar_active = false
+ derive_active = orxonox.getConfig("KeyBinder","bDeriveMouseInput_")
+ invert_active = false
+ mousenormalsensitivity = orxonox.getConfig("KeyBinder","mouseSensitivity_")
+ mousederivesensitivity = orxonox.getConfig("KeyBinder","mouseSensitivityDerived_")
+ mousenormalscrollbarwindow:setScrollPosition((math.log(14*mousenormalsensitivity-6))/(6*math.log(2)))
+ mousederivescrollbarwindow:setScrollPosition((math.log(14*mousederivesensitivity-6))/(6*math.log(2)))
+ if derive_active == "true" then
+ normal_active = false
+ derive_active = true
+ derivewindow:setSelected(derive_active)
+ else
+ normal_active = true
+ derive_active = false
+ normalwindow:setSelected(normal_active)
+ end
+ if invert_active == "true" then
+ invert_active = true
+ else
+ invert_active = false
+ end
+end
+
+function P.MouseControlsMouseNormalScrollbar_changed(e)
+ if mousenormalscrollbar_active == false then
+ scrollposition = mousenormalscrollbarwindow:getScrollPosition()
+ mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14
+ orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity)
+ end
+end
+
+function P.MouseControlsMouseNormalScrollbar_started(e)
+ mousenormalscrollbar_active = true
+end
+
+function P.MouseControlsMouseNormalScrollbar_ended(e)
+ scrollposition = mousenormalscrollbarwindow:getScrollPosition()
+ mousenormalsensitivity = (math.pow(64,scrollposition)+6)/14
+ orxonox.config("KeyBinder", "mouseSensitivity_", mousenormalsensitivity)
+ mousenormalscrollbar_active = false
+end
+
+function P.MouseControlsMouseDeriveScrollbar_changed(e)
+ if mousederivescrollbar_active == false then
+ scrollposition = mousederivescrollbarwindow:getScrollPosition()
+ mousederivesensitivity = (math.pow(64,scrollposition)+6)/14
+ orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity)
+ end
+end
+
+function P.MouseControlsMouseDeriveScrollbar_started(e)
+ mousederivescrollbar_active = true
+end
+
+function P.MouseControlsMouseDeriveScrollbar_ended(e)
+ scrollposition = mousederivescrollbarwindow:getScrollPosition()
+ mousederivesensitivity = (math.pow(64,scrollposition)+6)/14
+ orxonox.config("KeyBinder", "mouseSensitivityDerived_", mousederivesensitivity)
+ mousederivescrollbar_active = false
+end
+
+function P.MouseNormalButton_clicked(e)
+ if block == false then
+ block = true
+ derivewindow:setSelected(false)
+ block = false
+ orxonox.config("KeyBinder", "bDeriveMouseInput_", 0)
+ end
+end
+
+function P.MouseDeriveButton_clicked(e)
+ if block == false then
+ block = true
+ normalwindow:setSelected(false)
+ block = false
+ orxonox.config("KeyBinder", "bDeriveMouseInput_", 1)
+ end
+end
+
+function P.MouseInvertCheckbox_clicked(e)
+ -- invert mouse
+end
+
+function P.MouseControlsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/MultiplayerMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/MultiplayerMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/MultiplayerMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/MultiplayerMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,82 @@
+-- MultiplayerMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ MultiplayerMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "MultiplayerMenu"
+P.layoutString = "MultiplayerMenu.layout"
+
+function P:init()
+ listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
+ preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+ orxonox.LevelManager:getInstance():compileAvailableLevelList()
+ local levelList = {}
+ local index = 0
+ local level = ""
+ while true do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level == "" then
+ break
+ end
+ table.insert(levelList, level)
+ index = index + 1
+ end
+ table.sort(levelList)
+ for k,v in pairs(levelList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toListbox(listbox):addItem(item)
+ if v .. ".oxw" == preselect then
+ listbox:setItemSelectState(item, true)
+ end
+ end
+ local multiplayerMode = "startClient"
+ if multiplayerMode == "startClient" then
+ window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
+ button = tolua.cast(window,"CEGUI::RadioButton")
+ button:setSelected(true)
+ end
+ if multiplayerMode == "startServer" then
+ window = winMgr:getWindow("orxonox/MultiplayerHostButton")
+ button = tolua.cast(window,"CEGUI::RadioButton")
+ button:setSelected(true)
+ end
+ if multiplayerMode == "startDedicated" then
+ window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
+ button = tolua.cast(window,"CEGUI::RadioButton")
+ button:setSelected(true)
+ end
+end
+
+function P.MultiplayerJoinButton_clicked(e)
+ multiplayerMode = "startClient"
+end
+
+function P.MultiplayerHostButton_clicked(e)
+ multiplayerMode = "startServer"
+end
+
+function P.MultiplayerDedicatedButton_clicked(e)
+ multiplayerMode = "startDedicated"
+end
+
+function P.MultiplayerStartButton_clicked(e)
+ local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
+ orxonox.execute(multiplayerMode)
+ hideAllGUIs()
+ end
+end
+
+function P.MultiplayerBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/MultiplayerOptionsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/MultiplayerOptionsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/MultiplayerOptionsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/MultiplayerOptionsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,18 @@
+-- MultiplayerOptionsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ MultiplayerOptionsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "MultiplayerOptionsMenu"
+P.layoutString = "MultiplayerOptionsMenu.layout"
+
+function P.MultiplayerOptionsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
Modified: code/trunk/data/gui/scripts/PickupInventory.lua
===================================================================
--- code/trunk/data/gui/scripts/PickupInventory.lua 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/scripts/PickupInventory.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -19,7 +19,7 @@
function P:frmUpdate(e)
local equipCount = orxonox.PickupInventory:getEquipmentCount()
local usableCount = orxonox.PickupInventory:getUsableCount()
-
+
if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
self:updateTabs()
end
@@ -38,11 +38,11 @@
local name = w:getName()
local t = name:sub(25, 27)
local i = name:sub(29)
-
+
if t == "equ" then
-
+
end
-
+
if t == "use" then
if self.currentUsableID_ >= 0 then
winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
@@ -59,7 +59,7 @@
local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
-
+
self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
Modified: code/trunk/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/trunk/data/gui/scripts/QuestGUI.lua 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/gui/scripts/QuestGUI.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -14,7 +14,7 @@
self.visible = true
local questManager = orxonox.QuestManager:getInstance()
-
+
local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList")
local window = questManager:getQuestGUI(P.filename)
Copied: code/trunk/data/gui/scripts/SettingsMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/SettingsMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/SettingsMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/SettingsMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,44 @@
+-- SettingsMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ SettingsMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "SettingsMenu"
+P.layoutString = "SettingsMenu.layout"
+
+function P.SettingsGameplayButton_clicked(e)
+ showGUI("GameplayMenu", true)
+end
+
+function P.SettingsMultiplayerOptionsButton_clicked(e)
+ showGUI("MultiplayerOptionsMenu", true)
+end
+
+function P.SettingsControlsButton_clicked(e)
+ showGUI("ControlsMenu", true)
+end
+
+function P.SettingsGraphicsButton_clicked(e)
+ showGUI("GraphicsMenu", true)
+end
+
+function P.SettingsAudioButton_clicked(e)
+ showGUI("AudioMenu", true)
+end
+
+function P.SettingsResetSettingsButton_clicked(e)
+ -- reset settings
+ debug("event: reset settings")
+end
+
+function P.SettingsBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Copied: code/trunk/data/gui/scripts/SingleplayerMenu.lua (from rev 6415, code/branches/presentation2/data/gui/scripts/SingleplayerMenu.lua)
===================================================================
--- code/trunk/data/gui/scripts/SingleplayerMenu.lua (rev 0)
+++ code/trunk/data/gui/scripts/SingleplayerMenu.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,54 @@
+-- SingleplayerMenu.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ SingleplayerMenu = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "SingleplayerMenu"
+P.layoutString = "SingleplayerMenu.layout"
+
+function P:init()
+ listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
+ preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+ orxonox.LevelManager:getInstance():compileAvailableLevelList()
+ local levelList = {}
+ local index = 0
+ local level = ""
+ while true do
+ level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if level == "" then
+ break
+ end
+ table.insert(levelList, level)
+ index = index + 1
+ end
+ table.sort(levelList)
+ for k,v in pairs(levelList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
+ CEGUI.toListbox(listbox):addItem(item)
+ if v .. ".oxw" == preselect then
+ listbox:setItemSelectState(item, true)
+ end
+ end
+end
+
+function P.SingleplayerStartButton_clicked(e)
+ choice = winMgr:getWindow("orxonox/SingleplayerLevelListbox"):getFirstSelectedItem()
+ if choice then
+ orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
+ orxonox.execute("startGame")
+ hideAllGUIs()
+ end
+end
+
+function P.SingleplayerBackButton_clicked(e)
+ hideGUI(P.filename)
+end
+
+return P
+
Modified: code/trunk/data/levels/empty_level.oxw
===================================================================
--- code/trunk/data/levels/empty_level.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/empty_level.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -16,7 +16,22 @@
ambientlight = "0.8, 0.8, 0.8"
skybox = "Orxonox/Starbox"
>
+
+<!--Rocket position="-10, 3.5,800" velocity="0,0,-100">
+ <attached>
+ <Model pitch=180 position="0,0,0" scale=1.5 mesh="rocket_test.mesh" >
+ <attached>
+ <ParticleEmitter pitch=0 roll=0 position="0,5,0" source="Orxonox/laser" lifetime=2.0 loop=1 startdelay=3.0/>
+ <ParticleEmitter pitch=-90 roll=0 position="0,-5,0" source="Orxonox/particlecanon" lifetime=2.0 loop=1 startdelay=3.0/>
+ <ParticleEmitter pitch=-90 roll=0 position="0,0,-2" source="Orxonox/rocketfire" lifetime=2.0 loop=1 startdelay=3.0 />
+ <ParticleEmitter pitch=-90 roll=0 position="0,0,-2" source="Orxonox/smoke" lifetime=2.0 loop=1 startdelay=3.0 />
+ </attached>
+ </Model>
+ </attached>
+ </Rocket-->
+
+
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
- <SpawnPoint position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshippirate />
+ <SpawnPoint position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
</Scene>
</Level>
Modified: code/trunk/data/levels/events.oxw
===================================================================
--- code/trunk/data/levels/events.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/events.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,223 +1,223 @@
-<?lua
- include("hudtemplates3.oxo")
- include("stats.oxo")
- include("templates/spaceship_assff.oxt")
- include("templates/spaceship_H2.oxt")
-?>
-
-<Level
- name = "Event testing"
- description = "A simple level to test the event-system (with comments)"
->
- <Scene
- ambientlight = "0.5, 0.5, 0.5"
- skybox = "Orxonox/skypanoramagen1"
- >
- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
-
- <SpawnPoint position="0,-100,0" lookat="0,0,0" roll=180 spawnclass=SpaceShip pawndesign=spaceshipassff />
-
- <Billboard position=" 300,100, 0" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
- <Billboard position=" 200,100, 0" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
- <Billboard position=" 200,100,100" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
- <Billboard position=" 100,100, 0" material="Examples/Flare" colour="1.0, 1.0, 0.0" />
- <Billboard position=" 0,100, 0" material="Examples/Flare" colour="0.0, 1.0, 0.0" />
- <Billboard position="-100,100, 0" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
- <Billboard position="-100,100,100" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
- <Billboard position="-200,100, 0" material="Examples/Flare" colour="0.0, 0.0, 1.0" />
- <Billboard position="-300,100, 0" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
-
-
-
- <!--
- Begin of the tutorial section.
- -->
-
-
-
- <!--
- Note:
- All following examples use only one subobject (in nested layouts). But of course you can add more
- objects. They will all follow the same rules (depending on the example receive, send or pipe events).
-
- Some examples address objects by name. Those methods always address ALL objects with this name, no
- matter where they are in the XML-file (before or after the addressing object). Of course this also
- works with all amounts of objects from zero to infinity. In the examples I used two objects each.
- -->
-
-
- <!-- red -->
- <!--
- Standard:
- Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
- Every fired event of the source is mapped to the "visibility" state of the listener.
-
- This is a 1:1 mapping between event-listener and event-source.
- -->
- <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
- <events>
- <visibility>
- <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
- </visibility>
- </events>
- </Billboard>
-
-
- <!-- orange -->
- <!--
- EventListener:
- The EventListener object forwards all events from objects, whose names equal the "event" attribute
- of the EventListener, to the enclosing object (Billboard).
- In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
-
- The EventListener provides an 1:n mapping between one listener and multiple event-sources.
- -->
- <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
- <events>
- <visibility>
- <EventListener event="trigger2" />
- </visibility>
- </events>
- </Billboard>
- <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
- <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
-
-
- <!-- yellow -->
- <!--
- EventTarget:
- The EventTarget object forwards the events, received from objects whithin the "events" subsection,
- to all objects whose names equal the "name" attribute.
- In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
- name "bb3".
-
- The EventTarget provides an n:1 mapping between several listeners and one event-source.
- -->
- <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
- <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
- <EventTarget target="bb3">
- <events>
- <visibility>
- <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
- </visibility>
- </events>
- </EventTarget>
-
-
- <!-- green -->
- <!--
- EventDispatcher:
- The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
- to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
- doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
- subsection.
- In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
- to the Billboard object.
-
- The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
- -->
- <EventDispatcher>
- <targets>
- <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
- </targets>
- <events>
- <visibility>
- <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
- </visibility>
- </events>
- </EventDispatcher>
-
-
- <!-- turquoise -->
- <!--
- Combination:
- By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
- extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
- In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
-
- This combination allows an n:n mapping between event-listeners and event-sources.
- -->
- <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
- <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
- <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
- <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
- <EventDispatcher>
- <targets>
- <EventTarget target="bb5" />
- </targets>
- <events>
- <visibility>
- <EventListener event="trigger5" />
- </visibility>
- </events>
- </EventDispatcher>
-
-
- <!-- blue -->
- <!--
- Mainstate:
- Apart from the standard states (like activity and visibility), each object can have a mainstate.
- You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
- supported states of the object (except states which need the originator as a second argument). If
- the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
- This allows you to hide the actually affected state in the event-listener, while the event-source
- just sends events.
- Note that this example is exactly like the standard case, but the event is sent to the main-state,
- which in turn is set to "visibility".
- -->
- <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
- <events>
- <mainstate>
- <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
- </mainstate>
- </events>
- </Billboard>
-
-
- <!-- violet -->
- <!--
- Event forwarding:
- As a consequence of the mainstate, events can also be sent without any explicit declaration of
- the targets state. This allows us to forward events from an event-source directly to a bunch of
- event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
- have to declare their main-state.
- In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
- This does the same like the example above, but instead of piping events backwards from the source
- into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
- -->
- <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
- <eventlisteners>
- <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
- </eventlisteners>
- </DistanceTrigger>
-
-
-
- <!--
- End of the tutorial section.
- -->
-
-
-
- <!--
- The following example shows again the red (standard layout) and the violet (event forwarding) example,
- but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
- (visibility) in the other examples.
- -->
- <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
- <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
- <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
- <events>
- <spawn>
- <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
- </spawn>
- </events>
- </ParticleSpawner>
- <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
- <eventlisteners>
- <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
- </eventlisteners>
- </DistanceTrigger>
-
- </Scene>
-</Level>
+<?lua
+ include("hudtemplates3.oxo")
+ include("stats.oxo")
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_H2.oxt")
+?>
+
+<Level
+ name = "Event testing"
+ description = "A simple level to test the event-system (with comments)"
+>
+ <Scene
+ ambientlight = "0.5, 0.5, 0.5"
+ skybox = "Orxonox/skypanoramagen1"
+ >
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+
+ <SpawnPoint position="0,-100,0" lookat="0,0,0" roll=180 spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+ <Billboard position=" 300,100, 0" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
+ <Billboard position=" 200,100, 0" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
+ <Billboard position=" 200,100,100" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
+ <Billboard position=" 100,100, 0" material="Examples/Flare" colour="1.0, 1.0, 0.0" />
+ <Billboard position=" 0,100, 0" material="Examples/Flare" colour="0.0, 1.0, 0.0" />
+ <Billboard position="-100,100, 0" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
+ <Billboard position="-100,100,100" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
+ <Billboard position="-200,100, 0" material="Examples/Flare" colour="0.0, 0.0, 1.0" />
+ <Billboard position="-300,100, 0" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
+
+
+
+ <!--
+ Begin of the tutorial section.
+ -->
+
+
+
+ <!--
+ Note:
+ All following examples use only one subobject (in nested layouts). But of course you can add more
+ objects. They will all follow the same rules (depending on the example receive, send or pipe events).
+
+ Some examples address objects by name. Those methods always address ALL objects with this name, no
+ matter where they are in the XML-file (before or after the addressing object). Of course this also
+ works with all amounts of objects from zero to infinity. In the examples I used two objects each.
+ -->
+
+
+ <!-- red -->
+ <!--
+ Standard:
+ Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
+ Every fired event of the source is mapped to the "visibility" state of the listener.
+
+ This is a 1:1 mapping between event-listener and event-source.
+ -->
+ <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
+ <events>
+ <visibility>
+ <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
+ </visibility>
+ </events>
+ </Billboard>
+
+
+ <!-- orange -->
+ <!--
+ EventListener:
+ The EventListener object forwards all events from objects, whose names equal the "event" attribute
+ of the EventListener, to the enclosing object (Billboard).
+ In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
+
+ The EventListener provides an 1:n mapping between one listener and multiple event-sources.
+ -->
+ <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
+ <events>
+ <visibility>
+ <EventListener event="trigger2" />
+ </visibility>
+ </events>
+ </Billboard>
+ <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
+ <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
+
+
+ <!-- yellow -->
+ <!--
+ EventTarget:
+ The EventTarget object forwards the events, received from objects whithin the "events" subsection,
+ to all objects whose names equal the "name" attribute.
+ In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
+ name "bb3".
+
+ The EventTarget provides an n:1 mapping between several listeners and one event-source.
+ -->
+ <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
+ <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
+ <EventTarget target="bb3">
+ <events>
+ <visibility>
+ <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
+ </visibility>
+ </events>
+ </EventTarget>
+
+
+ <!-- green -->
+ <!--
+ EventDispatcher:
+ The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
+ to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
+ doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
+ subsection.
+ In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
+ to the Billboard object.
+
+ The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
+ -->
+ <EventDispatcher>
+ <targets>
+ <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
+ </targets>
+ <events>
+ <visibility>
+ <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
+ </visibility>
+ </events>
+ </EventDispatcher>
+
+
+ <!-- turquoise -->
+ <!--
+ Combination:
+ By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
+ extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
+ In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
+
+ This combination allows an n:n mapping between event-listeners and event-sources.
+ -->
+ <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
+ <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
+ <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
+ <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
+ <EventDispatcher>
+ <targets>
+ <EventTarget target="bb5" />
+ </targets>
+ <events>
+ <visibility>
+ <EventListener event="trigger5" />
+ </visibility>
+ </events>
+ </EventDispatcher>
+
+
+ <!-- blue -->
+ <!--
+ Mainstate:
+ Apart from the standard states (like activity and visibility), each object can have a mainstate.
+ You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
+ supported states of the object (except states which need the originator as a second argument). If
+ the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
+ This allows you to hide the actually affected state in the event-listener, while the event-source
+ just sends events.
+ Note that this example is exactly like the standard case, but the event is sent to the main-state,
+ which in turn is set to "visibility".
+ -->
+ <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
+ <events>
+ <mainstate>
+ <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
+ </mainstate>
+ </events>
+ </Billboard>
+
+
+ <!-- violet -->
+ <!--
+ Event forwarding:
+ As a consequence of the mainstate, events can also be sent without any explicit declaration of
+ the targets state. This allows us to forward events from an event-source directly to a bunch of
+ event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
+ have to declare their main-state.
+ In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
+ This does the same like the example above, but instead of piping events backwards from the source
+ into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
+ -->
+ <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
+ <eventlisteners>
+ <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
+ </eventlisteners>
+ </DistanceTrigger>
+
+
+
+ <!--
+ End of the tutorial section.
+ -->
+
+
+
+ <!--
+ The following example shows again the red (standard layout) and the violet (event forwarding) example,
+ but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
+ (visibility) in the other examples.
+ -->
+ <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
+ <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
+ <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
+ <events>
+ <spawn>
+ <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
+ </spawn>
+ </events>
+ </ParticleSpawner>
+ <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
+ <eventlisteners>
+ <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
+ </eventlisteners>
+ </DistanceTrigger>
+
+ </Scene>
+</Level>
Property changes on: code/trunk/data/levels/events.oxw
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/data/levels/gametype_asteroids.oxw
===================================================================
--- code/trunk/data/levels/gametype_asteroids.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/gametype_asteroids.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -27,11 +27,11 @@
j = math.random()
?>
- <MovableEntity
- position="<?lua print(math.random()* 15000 - 1000) ?>,<?lua print(math.random() * 12000 - 4000) ?>,<?lua print(math.random() * 12000 - 4000) ?>" collisionType=dynamic
+ <MovableEntity
+ position="<?lua print(math.random()* 15000 - 1000) ?>,<?lua print(math.random() * 12000 - 4000) ?>,<?lua print(math.random() * 12000 - 4000) ?>" collisionType=dynamic
linearDamping=0.8
angularDamping=0
- scale=<?lua print(j * 150)?>
+ scale=<?lua print(j * 150)?>
collisiondamage=1
enablecollisiondamage=true>
<attached>
Modified: code/trunk/data/levels/includes/weaponsettings3.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponsettings3.oxi 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/includes/weaponsettings3.oxi 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,17 +1,19 @@
<weaponslots>
<WeaponSlot position="-15.0,-1.5,0" />
<WeaponSlot position=" 15.0,-1.5,0" />
- <WeaponSlot position=" 0.0, 0.0,0" />
+ <WeaponSlot position=" 0, 0,0" />
</weaponslots>
<weaponsets>
<WeaponSet firemode=0 />
<WeaponSet firemode=1 />
+ <WeaponSet firemode=2 />
</weaponsets>
<weapons>
<WeaponPack>
<links>
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+ <DefaultWeaponmodeLink firemode=2 weaponmode=2 />
</links>
<Weapon>
<attached>
@@ -35,13 +37,16 @@
<HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset="-0.7, 1.5, -4.0" />
<LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
+ <Weapon>
+ <RocketFire mode=2 muzzleoffset="0,0,0" />
+ </Weapon>
</WeaponPack>
<WeaponPack>
<links>
<DefaultWeaponmodeLink firemode=1 weaponmode=0 />
</links>
- <Weapon>
- <!-- EnergyDrink mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare"muzzleoffset="2,-0.2,-1" / -->
- </Weapon>
+ <!--Weapon>
+ <EnergyDrink mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare"muzzleoffset="2,-0.2,-1" />
+ </Weapon-->
</WeaponPack>
</weapons>
Copied: code/trunk/data/levels/includes/weaponsettings_HXY.oxi (from rev 6415, code/branches/presentation2/data/levels/includes/weaponsettings_HXY.oxi)
===================================================================
--- code/trunk/data/levels/includes/weaponsettings_HXY.oxi (rev 0)
+++ code/trunk/data/levels/includes/weaponsettings_HXY.oxi 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,26 @@
+ <weaponslots>
+ <WeaponSlot position=" 6,-2,2" />
+ <WeaponSlot position="-6,-2,2" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ <WeaponSet firemode=1 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+ </links>
+ <Weapon>
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.1 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
+ </Weapon>
+ <Weapon>
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.1 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
Copied: code/trunk/data/levels/includes/weaponsettings_Transporter.oxi (from rev 6415, code/branches/presentation2/data/levels/includes/weaponsettings_Transporter.oxi)
===================================================================
--- code/trunk/data/levels/includes/weaponsettings_Transporter.oxi (rev 0)
+++ code/trunk/data/levels/includes/weaponsettings_Transporter.oxi 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,26 @@
+ <weaponslots>
+ <WeaponSlot position=" 55,-10,20" />
+ <WeaponSlot position="-55,-10,20" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ <WeaponSet firemode=1 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+ </links>
+ <Weapon>
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.1 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
+ </Weapon>
+ <Weapon>
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.1 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
Modified: code/trunk/data/levels/includes/weaponsettings_ghost.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponsettings_ghost.oxi 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/includes/weaponsettings_ghost.oxi 2009-12-25 21:23:58 UTC (rev 6417)
@@ -15,10 +15,12 @@
<Weapon>
<HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
<HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
<Weapon>
<HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
<HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
</WeaponPack>
</weapons>
\ No newline at end of file
Property changes on: code/trunk/data/levels/includes/weaponsettings_ghost.oxi
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/data/levels/old/physicstest.oxw
===================================================================
--- code/trunk/data/levels/old/physicstest.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/physicstest.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -11,9 +11,9 @@
<?lua
-for i = 1, 226, 1
+for i = 1, 226, 1
do ?>
<Model position="<?lua print(math.random() * 40000 - 20000)?>, <?lua print(math.random() * 40000 - 20000) ?>, <?lua print(math.random() * 40000 - 20000) ?>" scale="<?lua print(math.random() * 250 + 20) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random() * 30 + 15) ?>" />
-<?lua
+<?lua
end
?>
Modified: code/trunk/data/levels/old/physicstest2.oxw
===================================================================
--- code/trunk/data/levels/old/physicstest2.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/physicstest2.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -20,8 +20,8 @@
<SpawnPoint position="0, 0, -700" yaw =180 spawnclass=SpaceShip pawndesign=spaceshipassff />
<SpawnPoint position="0, 300, -300" pitch=-90 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
- <!-- axes in ogre's origin of coordinate system for phsics engine testing purposes-->
- <StaticEntity
+ <!-- axes in ogre's origin of coordinate system for phsics engine testing purposes-->
+ <StaticEntity
position = "0,0,0"
name = "banana"
collisionType = "static"
@@ -34,21 +34,21 @@
<collisionShapes>
<PlaneCollisionShape name="thePlane" planeNormal="0,1,0" planeOffset=0 />
</collisionShapes>
- </StaticEntity>
+ </StaticEntity>
- <!-- red sphere for phsics engine testing purposes-->
- <!--StaticEntity position="40,0,0">
- <attached>
- <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
- </attached>
- </StaticEntity-->
+ <!-- red sphere for phsics engine testing purposes-->
+ <!--StaticEntity position="40,0,0">
+ <attached>
+ <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
+ </attached>
+ </StaticEntity-->
- <!-- yellow cube for phsics engine testing purposes-->
- <!--StaticEntity position="80,0,0">
+ <!-- yellow cube for phsics engine testing purposes-->
+ <!--StaticEntity position="80,0,0">
<attached>
<Model position="0,0,0" scale=1 mesh="cube.mesh" />
</attached>
- </StaticEntity-->
+ </StaticEntity-->
<MovableEntity
name = "blubb"
Modified: code/trunk/data/levels/old/presentation_physics.oxw
===================================================================
--- code/trunk/data/levels/old/presentation_physics.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/presentation_physics.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -29,9 +29,9 @@
<collisionShapes>
<PlaneCollisionShape planeNormal="0,1,0" planeOffset=0 />
</collisionShapes>
- </StaticEntity>
+ </StaticEntity>
- <MovableEntity
+ <MovableEntity
position = "0,250,500"
rotationaxis = "1, 1, 1"
rotationrate = 360
@@ -63,7 +63,7 @@
<BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
- </MovableEntity>
+ </MovableEntity>
<?lua
for i = -20, 20, 8
Modified: code/trunk/data/levels/old/princessaeryn.oxw
===================================================================
--- code/trunk/data/levels/old/princessaeryn.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/princessaeryn.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -5,13 +5,13 @@
?>
<?lua
- dofile("includes/CuboidSpaceStation.lua")
+ dofile("includes/CuboidSpaceStation.lua")
?>
<NotificationQueue
- name = "notification"
- position = "1.0, 1.0"
- targets = "questsystem"
+ name = "notification"
+ position = "1.0, 1.0"
+ targets = "questsystem"
/>
<Level
Modified: code/trunk/data/levels/old/questsystem.oxw
===================================================================
--- code/trunk/data/levels/old/questsystem.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/questsystem.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -5,9 +5,9 @@
?>
<NotificationQueue
- name = "notification"
- position = "1.0, 1.0"
- targets = "all"
+ name = "notification"
+ position = "1.0, 1.0"
+ targets = "all"
/>
<Level
@@ -28,19 +28,19 @@
</hints>
</GlobalQuest>
- <ParticleSpawner position="0,0,100" source="Orxonox/BigExplosion1part3" lifetime=2.0 loop=0 autostart=0>
- <events>
- <spawn>
- <EventTrigger delay=1>
- <events>
- <trigger>
- <SpawnPoint position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
- </trigger>
- </events>
- </EventTrigger>
- </spawn>
- </events>
- </ParticleSpawner>
+ <ParticleSpawner position="0,0,100" source="Orxonox/BigExplosion1part3" lifetime=2.0 loop=0 autostart=0>
+ <events>
+ <spawn>
+ <EventTrigger delay=1>
+ <events>
+ <trigger>
+ <SpawnPoint position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ </trigger>
+ </events>
+ </EventTrigger>
+ </spawn>
+ </events>
+ </ParticleSpawner>
<QuestEffectBeacon position="0,0,100" times=-1>
<effects>
Modified: code/trunk/data/levels/old/sample4.oxw
===================================================================
--- code/trunk/data/levels/old/sample4.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/sample4.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,10 +22,10 @@
<attached>
<Model position="0,0,0" scale=10 mesh="satellite.mesh" />
<MovableEntity position="-4,0,0" velocity="0,0,0" rotationaxis="0,0,1" rotationrate=50>
- <attached>
+ <attached>
<Model position="4,0,0" scale=10 mesh="satellitedish.mesh"/>
</attached>
- </MovableEntity>
+ </MovableEntity>
<ParticleEmitter pitch=-135 roll=30 position="-14, 3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
<ParticleEmitter pitch=135 roll=30 position="-14, 3.5,-9" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
<ParticleEmitter pitch=-45 roll=30 position="-14,-3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
Modified: code/trunk/data/levels/old/spaceshiptemplates_physics.oxw
===================================================================
--- code/trunk/data/levels/old/spaceshiptemplates_physics.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/spaceshiptemplates_physics.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -9,7 +9,7 @@
primaryThrust = 100;
auxilaryThrust = 30;
rotationThrust = 10;
-
+
collisionType = "dynamic"
mass = 100
linearDamping = 0.7
Modified: code/trunk/data/levels/old/tutorial_hs08.oxw
===================================================================
--- code/trunk/data/levels/old/tutorial_hs08.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/old/tutorial_hs08.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -18,9 +18,9 @@
<!-- Embedded lua code (creates random asteroids) -->
<?lua
-for i = 1, 226, 1
+for i = 1, 226, 1
do ?>
<Model position="<?lua print(math.random() * 40000 - 20000)?>, <?lua print(math.random() * 40000 - 20000) ?>, <?lua print(math.random() * 40000 - 20000) ?>" scale="<?lua print(math.random() * 250 + 20) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random() * 30 + 15) ?>" />
-<?lua
+<?lua
end
?>
Modified: code/trunk/data/levels/presentation.oxw
===================================================================
--- code/trunk/data/levels/presentation.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/presentation.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -19,32 +19,32 @@
<SpawnPoint position="0, 300, -300" pitch=-90 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
- <!-- axes in ogre's origin of coordinate system for phsics engine testing purposes-->
- <!--StaticEntity position="0,0,0">
- <attached>
- <Model position="0,0,0" scale=1 mesh="axes.mesh" />
- </attached>
- </StaticEntity -->
+ <!-- axes in ogre's origin of coordinate system for phsics engine testing purposes-->
+ <!--StaticEntity position="0,0,0">
+ <attached>
+ <Model position="0,0,0" scale=1 mesh="axes.mesh" />
+ </attached>
+ </StaticEntity -->
- <!-- red sphere for phsics engine testing purposes-->
- <!--StaticEntity position="40,0,0">
- <attached>
- <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
- </attached>
- </StaticEntity-->
+ <!-- red sphere for phsics engine testing purposes-->
+ <!--StaticEntity position="40,0,0">
+ <attached>
+ <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
+ </attached>
+ </StaticEntity-->
- <!-- yellow cube for phsics engine testing purposes-->
- <!--StaticEntity position="80,0,0">
- <attached>
- <Model position="0,0,0" scale=1 mesh="cube.mesh" />
- </attached>
- </StaticEntity-->
+ <!-- yellow cube for phsics engine testing purposes-->
+ <!--StaticEntity position="80,0,0">
+ <attached>
+ <Model position="0,0,0" scale=1 mesh="cube.mesh" />
+ </attached>
+ </StaticEntity-->
- <!-- Carrier with guns not implemented yet -->
- <MovableEntity position="-2000,-1000,-2000" pitch="-90" roll="90">
+ <!-- Carrier with guns not implemented yet -->
+ <MovableEntity position="-2000,-1000,-2000" pitch="-90" roll="90">
<attached>
<Model position="0,0,0" scale=10 mesh="Carrier.mesh" />
- <Model position="0,30,20" scale=10 mesh="pirate.mesh" roll="180" />
+ <Model position="0,30,20" scale=10 mesh="pirate.mesh" roll="180" />
<Model position="-80,-30,20" scale=10 mesh="pirate.mesh" roll="180" />
</attached>
</MovableEntity>
@@ -53,10 +53,10 @@
<attached>
<Model position="0,0,0" scale=10 mesh="satellite.mesh" />
<MovableEntity position="-4,0,0" velocity="0,0,0" rotationaxis="0,0,1" rotationrate=50>
- <attached>
+ <attached>
<Model position="4,0,0" scale=10 mesh="satellitedish.mesh"/>
</attached>
- </MovableEntity>
+ </MovableEntity>
<ParticleEmitter pitch=-135 roll=30 position="-14, 3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
<ParticleEmitter pitch=135 roll=30 position="-14, 3.5,-9" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
<ParticleEmitter pitch=-45 roll=30 position="-14,-3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
Modified: code/trunk/data/levels/presentation09.oxw
===================================================================
--- code/trunk/data/levels/presentation09.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/presentation09.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -23,18 +23,18 @@
<?lua
max = 20
for i = 1, max, 1
-do
+do
x = math.sin(i/max*6)*40000
y = math.cos(i/max*6)*40000
z = i*100
?>
<?lua
-for k = 1, 25, 1
+for k = 1, 25, 1
do
j = math.random()
?>
-
- <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+
+ <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
<attached>
<Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
@@ -42,11 +42,11 @@
<SphereCollisionShape radius="<?lua print(j * 70) ?>" />
</collisionShapes> <?lua end ?>
</MovableEntity>
-<?lua
+<?lua
end
?>
<?lua end ?>
<Planet position="0,0,0" scale=10000 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="1,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
-
+
</Scene>
</Level>
Modified: code/trunk/data/levels/presentation09b.oxw
===================================================================
--- code/trunk/data/levels/presentation09b.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/presentation09b.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -85,21 +85,21 @@
<WaypointPatrolController alertnessradius=100 team=0 />
</controller>
</SpaceShip>
-
+
<PickupSpawner item="JumpItem" triggerDistance="20" respawnTime="10000" position="-3800, 2500, 1500">
<attached>
<!--<Model mesh="jumpthrust.mesh" scale="1.0" />
<Billboard material="Examples/Flare" colour="0.5, 1.0, 0.3" scale="0.5" />-->
</attached>
</PickupSpawner>
-
+
<PickupSpawner item="HealthUsableItem" triggerDistance="20" respawnTime="10000" position="-4150,2750,1550">
<attached>
<Model mesh="gwrench.mesh" scale="1.0" />
<Billboard material="Examples/Flare" colour="0.3, 0.8, 1.0" scale="0.5" />
</attached>
</PickupSpawner>
-
+
<PickupSpawner item="HealthImmediateItem" triggerDistance="20" respawnTime="3" position="2300, 4300, 2400">
<attached>
<Model mesh="gwrench.mesh" scale="1.0" />
@@ -120,7 +120,7 @@
</EventDispatcher>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do
?>
<SpaceShip position="<?lua print(5000 + math.random() * 4000 - 2000) ?>,<?lua print(0 + math.random() * 2000 - 1000) ?>,<?lua print(math.random() * 2000 - 1000) ?>">
@@ -135,12 +135,12 @@
</WaypointPatrolController>
</controller>
</SpaceShip>
-<?lua
+<?lua
end
?>
<?lua
-for i = 1, 12, 1
+for i = 1, 12, 1
do
?>
<SpaceShip position="<?lua print(2800 + math.random() * 2000 - 1000) ?>,<?lua print(2500+ math.random() * 1000 - 500) ?>,<?lua print(2500 + math.random() * 1000 - 500) ?>" >
@@ -155,7 +155,7 @@
</WaypointPatrolController>
</controller>
</SpaceShip>
-<?lua
+<?lua
end
?>
@@ -172,7 +172,7 @@
</EventDispatcher>
<?lua
-for i = 1, 12, 1
+for i = 1, 12, 1
do
?>
<SpaceShip position="<?lua print(2500 + math.random() * 500 - 250) ?>,<?lua print(4800 + math.random() * 500 - 250) ?>,<?lua print(2500 + math.random() * 500 - 250) ?>" >
@@ -189,7 +189,7 @@
</WaypointPatrolController>
</controller>
</SpaceShip>
-<?lua
+<?lua
end
?>
@@ -319,7 +319,7 @@
</Destroyer>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do
?>
<SpaceShip position="<?lua print(6200 + math.random() * 2000 - 1000) ?>,<?lua print(-1500 + math.random() * 1000 - 500) ?>,<?lua print(-700 + math.random() * 1000 - 500) ?>" >
@@ -334,25 +334,25 @@
</WaypointPatrolController>
</controller>
</SpaceShip>
-<?lua
+<?lua
end
?>
<?lua
-for i = 1, 200, 1
+for i = 1, 200, 1
do
x = math.random() * 100 + (i-70) * 100
y = math.random() * 3000 - 1500
z = math.random() * 3000 - 1500 + (i-100) * 10
s = math.random() * 60 + 30
?>
-
- <MovableEntity position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 - 15) ?>">
+
+ <MovableEntity position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 - 15) ?>">
<attached>
<Model position="0,0,0" scale=<?lua print(s) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
</MovableEntity>
-<?lua
+<?lua
end
?>
@@ -362,22 +362,22 @@
elements.length = function()
return table.getn(elements)
end
-for i = 1, 150, 1
+for i = 1, 150, 1
do
x = math.random() * 750 - 4500
y = math.random() * 1000 + 2000
z = math.random() * 500 + 1000
e = math.floor(math.random()*elements.length()+1)
?>
-
- <MovableEntity position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 - 15) ?>">
+
+ <MovableEntity position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 - 15) ?>">
<attached>
<Model position="0,0,0" scale="<?lua print(sizes[e]) ?>" mesh="<?lua print( elements[e]) ?>" />
</attached>
</MovableEntity>
-<?lua
+<?lua
end
?>
-
+
</Scene>
</Level>
Copied: code/trunk/data/levels/presentationHS09.oxw (from rev 6415, code/branches/presentation2/data/levels/presentationHS09.oxw)
===================================================================
--- code/trunk/data/levels/presentationHS09.oxw (rev 0)
+++ code/trunk/data/levels/presentationHS09.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,410 @@
+<?lua
+ include("hudtemplates3.oxo")
+ include("stats.oxo")
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_H2.oxt")
+ include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name = "Presentation09"
+ description = "presentation level for Orxonox Convention X"
+ gametype = TeamDeathmatch
+ hasPhysics = true
+>
+ <Scene
+ ambientlight = "0.6, 0.4, 0.4"
+ skybox = "Orxonox/skypanoramagen2"
+ >
+ <Light type=directional position="0,0,0" direction="0.683, 0.289, 0.670" diffuse="0.8, 0.5, 0.5, 1.0" specular="0.8, 0.4, 0.4, 1.0" />
+
+ <Template name="JumpItem" baseclass="Jump">
+ <Jump velocity="0,0,-1000" jumpsAvailable="4" guiImage="jumpturbinepickup.jpg" guiText="Jump" />
+ </Template>
+ <Template name="HealthImmediateItem" baseclass="HealthImmediate">
+ <HealthImmediate recoveredHealth="100" guiImage="decal.jpg" guiText="Health" />
+ </Template>
+ <Template name="HealthUsableItem" baseclass="HealthUsable">
+ <HealthImmediate recoveredHealth="80" guiImage="goldwrenchpickup.jpg" guiText="Health" />
+ </Template>
+
+ <SpawnPoint position="-3800, 2500, 1500" direction="-0.683, -0.289, -0.670" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+
+ <SpaceShip position="-3900,3000,1000">
+ <templates>
+ <Template link=spaceshipHtwo/>
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=100 team=0>
+ <waypoints>
+ <StaticEntity position="-3850,2800,1450" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+
+ <SpaceShip position="-4100,2600,1600">
+ <templates>
+ <Template link=spaceshipHtwo/>
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=100 team=0>
+ <waypoints>
+ <StaticEntity position="-3850,2800,1450" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+
+ <SpaceShip position="-4000,2500,1500">
+ <templates>
+ <Template link=spaceshipHtwo/>
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=100 team=0>
+ <waypoints>
+ <StaticEntity position="-3850,2800,1450" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+
+ <SpaceShip position="-4100,2700,1500">
+ <templates>
+ <Template link=spaceshipHtwo/>
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=100 team=0 />
+ </controller>
+ </SpaceShip>
+
+ <SpaceShip position="-4150,2750,1550">
+ <templates>
+ <Template link=spaceshipHtwo/>
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=100 team=0 />
+ </controller>
+ </SpaceShip>
+
+ <Billboard material="Test/Fog" position="-3800, 2500, 1500" alpha="0.1" color="1, 1, 1, 0.1" scale="0.5" />
+
+ <PickupSpawner item="JumpItem" triggerDistance="20" respawnTime="10000" position="-3800, 2500, 1500">
+ <attached>
+ <!--<Model mesh="jumpthrust.mesh" scale="1.0" />
+ <Billboard material="Examples/Flare" colour="0.5, 1.0, 0.3" scale="0.5" />-->
+ </attached>
+ </PickupSpawner>
+
+ <PickupSpawner item="HealthUsableItem" triggerDistance="20" respawnTime="10000" position="-4150,2750,1550">
+ <attached>
+ <Model mesh="gwrench.mesh" scale="1.0" />
+ <Billboard material="Examples/Flare" colour="0.3, 0.8, 1.0" scale="0.5" />
+ </attached>
+ </PickupSpawner>
+
+ <PickupSpawner item="HealthImmediateItem" triggerDistance="20" respawnTime="3" position="2300, 4300, 2400">
+ <attached>
+ <Model mesh="gwrench.mesh" scale="1.0" />
+ <Billboard material="Examples/Flare" colour="0.9, 1.0, 0.1" scale="0.5" />
+ </attached>
+ </PickupSpawner>
+
+ <Billboard position="-2500, 2400, 1500" material="Examples/Flare" />
+ <EventDispatcher>
+ <targets>
+ <EventTarget target=pirates />
+ </targets>
+ <events>
+ <activity>
+ <DistanceTrigger position="-2500, 2400, 1500" distance=250 target="SpaceShip" stayactive=true />
+ </activity>
+ </events>
+ </EventDispatcher>
+
+<?lua
+for i = 1, 10, 1
+do
+?>
+ <SpaceShip position="<?lua print(5000 + math.random() * 4000 - 2000) ?>,<?lua print(0 + math.random() * 2000 - 1000) ?>,<?lua print(math.random() * 2000 - 1000) ?>">
+ <templates>
+ <Template link=spaceshippirate />
+ </templates>
+ <controller>
+ <WaypointPatrolController name=pirates alertnessradius=1000 team=1 active=false>
+ <waypoints>
+ <StaticEntity position="3100, 2000, 1500" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+
+<?lua
+for i = 1, 12, 1
+do
+?>
+ <SpaceShip position="<?lua print(2800 + math.random() * 2000 - 1000) ?>,<?lua print(2500+ math.random() * 1000 - 500) ?>,<?lua print(2500 + math.random() * 1000 - 500) ?>" >
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=1000 team=0>
+ <waypoints>
+ <StaticEntity position="<?lua print(2800 + math.random() * 1000 - 500) ?>,<?lua print(2500 + math.random() * 1000 - 500) ?>,<?lua print(1500 + math.random() * 1000 - 500) ?>" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+
+ <Billboard position="2300, 4400, 2500" material="Examples/Flare" />
+ <EventDispatcher>
+ <targets>
+ <EventTarget target=attacker />
+ </targets>
+ <events>
+ <activity>
+ <DistanceTrigger position="2300, 4400, 2500" distance=50 target="SpaceShip" stayactive=true />
+ </activity>
+ </events>
+ </EventDispatcher>
+
+<?lua
+for i = 1, 12, 1
+do
+?>
+ <SpaceShip position="<?lua print(2500 + math.random() * 500 - 250) ?>,<?lua print(4800 + math.random() * 500 - 250) ?>,<?lua print(2500 + math.random() * 500 - 250) ?>" >
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WaypointPatrolController name=attacker alertnessradius=<?lua print(math.random() * 2000) ?> team=0 active=false>
+ <waypoints>
+ <StaticEntity position="<?lua print(2800 + math.random() * 500 - 250) ?>,<?lua print(2500 + math.random() * 500 - 250) ?>,<?lua print(1500 + math.random() * 500 - 250) ?>" />
+ <StaticEntity position="<?lua print(5000 + math.random() * 500 - 250) ?>,<?lua print(0 + math.random() * 500 - 250) ?>,<?lua print(0 + math.random() * 500 - 250) ?>" />
+ <StaticEntity position="<?lua print(7500 + math.random() * 500 - 250) ?>,<?lua print(-2500 + math.random() * 500 - 250) ?>,<?lua print(-1500 + math.random() * 500 - 250) ?>" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+
+ <StaticEntity position="2800, 2500, 2500">
+ <attached>
+ <CheckPoint />
+ <Model position="400, 0, 0" scale="40" mesh="DuBall2.mesh"/>
+ <Model position="-400, 0, 0" scale="40" mesh="DuBall1.mesh"/>
+ </attached>
+ </StaticEntity>
+<!--
+ <Destroyer position="6500, -2000, -1000" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=500>
+ <attached>
+ <CheckPoint />
+ <Model position="0,0,0" scale="5" mesh="Carrier.mesh"/>
+ <Backlight
+ mainstate=activity
+ active=false
+ scale=0.4
+ name=bltest
+ position=" 7.6, 0, 6"
+ colour="0.2, 0.65, 1.0, 1.0"
+ width=15
+ length=1500
+ lifetime=2
+ elements=50
+ trailmaterial="Trail/backlighttrail"
+ turnontime=1
+ turnofftime=1
+ material="Flares/ThrusterFlare1"
+ />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="70,0,-25" halfExtents="150, 50, 25" />
+ <BoxCollisionShape position="95,75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="95,-75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="77,47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,-47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,0,50" halfExtents="110, 45, 6" />
+ <BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
+ </collisionShapes>
+ </Destroyer>
+-->
+ <Destroyer
+ position = "6500,-2000,-1000"
+ collisionType = dynamic
+ mass = 100000
+ angularDamping = 0.9999999
+ health = 1000
+ maxhealth = 1000
+ initialhealth = 1000
+ >
+ <controller>
+ <WaypointPatrolController team=1 />
+ </controller>
+ <attached>
+ <Model mesh="Carrier.mesh" scale="5" />
+ <Backlight
+ mainstate=activity
+ active=false
+ scale=0.4
+ name=bltest
+ position=" 7.6, 0, 6"
+ colour="0.2, 0.65, 1.0, 1.0"
+ width=15
+ length=1500
+ lifetime=2
+ elements=50
+ trailmaterial="Trail/backlighttrail"
+ turnontime=1
+ turnofftime=1
+ material="Flares/ThrusterFlare1"
+ />
+ <?lua for i=0,8,1 do ?>
+ <BlinkingBillboard
+ position="<?lua print(200-270/8*i)?> ,15,2"
+ material="Examples/Flare"
+ colour="1.0, 0.5, 0.3"
+ phase=<?lua print(-360/8*i)?>
+ amplitude=0.1
+ frequency=0.5
+ quadratic=1
+ />
+
+ <BlinkingBillboard
+ position="<?lua print(200-270/8*i)?>,-15,2"
+ material="Examples/Flare"
+ colour="1.0, 0.5, 0.3"
+ phase=<?lua print(-360/8*i)?>
+ amplitude=0.1
+ frequency=0.5
+ quadratic=1
+ />
+ <?lua end ?>
+
+ <Backlight
+ scale=1
+ position=" 169, 75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width=40
+ length=1000
+ lifetime=5
+ elements=15
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare"
+ />
+ <Backlight
+ scale=1
+ position=" 169, -75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width=40
+ length=1000
+ lifetime=5
+ elements=15
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="70,0,-25" halfExtents="150, 50, 25" />
+ <BoxCollisionShape position="95,75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="95,-75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="77,47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,-47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,0,50" halfExtents="110, 45, 6" />
+ <BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
+ </collisionShapes>
+ </Destroyer>
+
+<?lua
+for i = 1, 10, 1
+do
+?>
+ <SpaceShip position="<?lua print(6200 + math.random() * 2000 - 1000) ?>,<?lua print(-1500 + math.random() * 1000 - 500) ?>,<?lua print(-700 + math.random() * 1000 - 500) ?>" >
+ <templates>
+ <Template link=spaceshippirate />
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=1000 team=1>
+ <waypoints>
+ <StaticEntity position="<?lua print(6000 + math.random() * 1000 - 500) ?>,<?lua print(-2000 + math.random() * 1000 - 500) ?>,<?lua print(-1000 + math.random() * 1000 - 500) ?>" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+
+<?lua
+elements = {"asteroid_ice.mesh", "asteroid_UV.mesh", "ast1.mesh", "ast2.mesh", "ast3.mesh", "ast4.mesh", "ast5.mesh", "ast6.mesh"}
+elements.length = function()
+ return table.getn(elements)
+end
+for i = 1, 100, 1
+do
+x = math.random() * 100 + (i) * 100
+y = math.random() * 3000 - 1500
+z = math.random() * 3000 - 1500 + (i-100) * 10
+s = math.random() * 60 + 30
+e = math.floor(math.random()*elements.length()+1)
+?>
+
+ <MovableEntity mass=90000 position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
+ <attached>
+ <Model position="0,0,0" scale=<?lua print(s) ?> mesh="<?lua print(elements[e])?>" />
+ </attached>
+ </MovableEntity>
+<?lua
+end
+?>
+
+<?lua
+for i = 1, 100, 1
+do
+x = math.random() * 200 + i*200
+y = math.random() * 3000 - 1500
+z = math.random() * 3000 - 1500 + (i-100) * 10
+s = math.random() * 60 + 30
+?>
+ <ParticleSpawner position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" source="Orxonox/Steam" lifetime=3.0 loop=1 />
+<!-- <Billboard material="Test/Fog" position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" color="1, 1, 1, 0.01" scale="20" />
+-->
+<?lua
+end
+?>
+
+<?lua
+elements = {"BodyDebris1.mesh", "CockpitDebris.mesh", "LightningGun.mesh", "WingDebris1.mesh", "WingDebris2.mesh", "satellitedish.mesh", "Thruster.mesh"}
+sizes = {4, 4, 4, 4, 4, 10, 20}
+elements.length = function()
+ return table.getn(elements)
+end
+for i = 1, 150, 1
+do
+x = math.random() * 750 - 4500
+y = math.random() * 1000 + 2000
+z = math.random() * 500 + 1000
+e = math.floor(math.random()*elements.length()+1)
+?>
+
+ <MovableEntity mass=90000 position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30- 15) ?>">
+ <attached>
+ <Model position="0,0,0" scale="<?lua print(sizes[e]) ?>" mesh="<?lua print( elements[e]) ?>" />
+ </attached>
+ </MovableEntity>
+<?lua
+end
+?>
+<!--
+ <Planet position="1000,0,0" mass=900000 scale=1000 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="1,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
+-->
+</Scene>
+</Level>
Copied: code/trunk/data/levels/presentationHS09b.oxw (from rev 6415, code/branches/presentation2/data/levels/presentationHS09b.oxw)
===================================================================
--- code/trunk/data/levels/presentationHS09b.oxw (rev 0)
+++ code/trunk/data/levels/presentationHS09b.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,270 @@
+<?lua
+ include("stats.oxo")
+ include("hudtemplates3.oxo")
+?>
+
+<?lua
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_pirate.oxt")
+ include("templates/spaceship_ghost.oxt")
+ include("templates/spaceship_HXY.oxt")
+ include("templates/spaceship_Transporter.oxt")
+ include("templates/spaceship_HXY_SL.oxt")
+ include("templates/spaceship_Transporter_SL.oxt")
+?>
+
+<Level
+ name = "Sample"
+ description = "Just a few tests"
+ gametype = TeamDeathmatch
+>
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+
+<AmbientSound ambientSource="Mars.ogg" looping="true" playOnLoad="true" />
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+<?lua
+ for i = 1, 50, 1
+ do
+ x = math.random() * 2000 + 4000
+ y = math.random() * 4000 - 2000
+ z = math.random() * 2000 - 1000
+ s = math.random() * 100
+ ?>
+
+ <MovableEntity collisiontype=dynamic mass=<?lua print(s*10)?> position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
+ <attached>
+ <Model position="0,0,0" scale=<?lua print(s) ?> mesh="asteroid_UV.mesh" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="<?lua print(s*0.9) ?>" />
+ </collisionShapes>
+ </MovableEntity>
+ <ParticleSpawner position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" source="Orxonox/Steam" lifetime=3.0 loop=1 />
+<?lua
+end
+?>
+
+<?lua
+elements = {"BodyDebris1.mesh", "CockpitDebris.mesh", "LightningGun.mesh", "WingDebris1.mesh", "WingDebris2.mesh", "satellitedish.mesh", "Thruster.mesh"}
+sizes = {4, 4, 4, 4, 4, 10, 20}
+elements.length = function()
+ return table.getn(elements)
+end
+for i = 1, 100, 1
+do
+x = math.random() * 750 - 4500
+y = math.random() * 1000 + 2000
+z = math.random() * 500 + 1000
+e = math.floor(math.random()*elements.length()+1)
+?>
+
+ <MovableEntity mass=90000 position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30- 15) ?>">
+ <attached>
+ <Model position="0,0,0" scale="<?lua print(sizes[e]) ?>" mesh="<?lua print( elements[e]) ?>" />
+ </attached>
+ </MovableEntity>
+<?lua
+end
+?>
+<?lua
+for i = 1,12, 1
+do
+?>
+ <SpaceShip position="<?lua print(math.random()*500 + 4500) ?>,<?lua print(-(math.random()*500 -250)) ?>,<?lua print(i*50 - 150) ?>" >
+ <templates>
+ <Template link=spaceshipHXYSL />
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=4000 team=0 active=true>
+ <waypoints>
+ <StaticEntity position="5000,<?lua print(math.random()*50)?> ,<?lua print(i*50 -150) ?>" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+<SpaceShip position="5000,100,100" >
+ <templates>
+ <Template link=spaceshipTransporterSL />
+ </templates>
+ <controller>
+ <WaypointPatrolController name=pirate target=pirate alertnessradius=1000 team=0 active=false>
+ <waypoints>
+ <StaticEntity position="5000,100,1100" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+</SpaceShip>
+ <Destroyer
+ position = "-5000,100 ,100"
+ collisionType = dynamic
+ mass = 100000
+ angularDamping = 0.9999999
+ health = 1000
+ maxhealth = 1000
+ initialhealth = 1000
+ >
+ <controller>
+ <WaypointPatrolController team=1 />
+ </controller>
+ <attached>
+ <Model mesh="Carrier.mesh" scale="5" />
+ <Backlight
+ mainstate=activity
+ active=false
+ scale=0.4
+ name=bltest
+ position=" 7.6, 0, 6"
+ colour="0.2, 0.65, 1.0, 1.0"
+ width=15
+ length=1500
+ lifetime=2
+ elements=50
+ trailmaterial="Trail/backlighttrail"
+ turnontime=1
+ turnofftime=1
+ material="Flares/ThrusterFlare1"
+ />
+ <?lua for i=0,8,1 do ?>
+ <BlinkingBillboard
+ position="<?lua print(200-270/8*i)?> ,15,2"
+ material="Examples/Flare"
+ colour="1.0, 0.5, 0.3"
+ phase=<?lua print(-360/8*i)?>
+ amplitude=0.1
+ frequency=0.5
+ quadratic=1
+ />
+
+ <BlinkingBillboard
+ position="<?lua print(200-270/8*i)?>,-15,2"
+ material="Examples/Flare"
+ colour="1.0, 0.5, 0.3"
+ phase=<?lua print(-360/8*i)?>
+ amplitude=0.1
+ frequency=0.5
+ quadratic=1
+ />
+ <?lua end ?>
+
+ <Backlight
+ scale=1
+ position=" 169, 75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width=40
+ length=1000
+ lifetime=5
+ elements=15
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare"
+ />
+ <Backlight
+ scale=1
+ position=" 169, -75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width=40
+ length=1000
+ lifetime=5
+ elements=15
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="70,0,-25" halfExtents="150, 50, 25" />
+ <BoxCollisionShape position="95,75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="95,-75,-16" halfExtents="70, 10, 12" />
+ <BoxCollisionShape position="77,47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,-47,30" halfExtents="110, 2, 30" />
+ <BoxCollisionShape position="77,0,50" halfExtents="110, 45, 6" />
+ <BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
+ </collisionShapes>
+ </Destroyer>
+
+ <?lua
+ for i = 1, 50, 1
+ do
+ x = -(math.random() * 2000 + 4000)
+ y = math.random() * 4000 - 2000
+ z = math.random() * 2000 - 1000
+ s = math.random() * 100
+ ?>
+
+ <MovableEntity collisiontype=dynamic mass=<?lua print(s*10)?> position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
+ <attached>
+ <Model position="0,0,0" scale=<?lua print(s) ?> mesh="asteroid_ice.mesh" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="<?lua print(s*0.9)?>" />
+ </collisionShapes>
+ </MovableEntity>
+ <ParticleSpawner position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" source="Orxonox/Steam" lifetime=3.0 loop=1 />
+<?lua
+end
+?>
+<!--<EventDispatcher>
+ <targets>
+ <EventTarget target=attack />
+ <EventTarget target=wait />
+ </targets>
+ <events>
+ <activity>
+ <DistanceTrigger position="0, 0, 4500" distance=100 target="SpaceShip" stayactive=true />
+ </activity>
+ </events>
+</EventDispatcher>
+
+<EventDispatcher>
+ <targets>
+ <EventTarget target=wait />
+ </targets>
+ <events>
+ <activity>
+ <DistanceTrigger position="0, 0, 4500" distance=100 target="SpaceShip" stayactive=false />
+ </activity>
+ </events>
+</EventDispatcher>-->
+
+<?lua
+for i = 1,25, 1
+do
+?>
+<SpaceShip position="<?lua print(-(math.random()*500 + 4500)) ?>,<?lua print(-(math.random()*500 -250)) ?>,<?lua print(i*50 - 150) ?>" >
+ <templates>
+ <Template link=spaceshipghost />
+ </templates>
+ <controller>
+
+ <WaypointPatrolController name=attack alertnessradius=15000 team=1 active=false>
+ <events>
+ <activity>
+ <DistanceTrigger position="-5000, 100, 100" distance=2000 target="Camera" stayactive=true />
+ </activity>
+ </events>
+ </WaypointPatrolController>
+
+ </controller>
+ </SpaceShip>
+<?lua
+end
+?>
+
+
+
+ <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="false">
+ <events>
+ <activity>
+ <DistanceTrigger position="2000,0,0" distance=500 target="Camera" />
+ </activity>
+ </events>
+ </AmbientSound>
+
+ <SpawnPoint position="5000,0,2000" spawnclass=SpaceShip pawndesign=spaceshipassff team=0/>
+ </Scene>
+</Level>
Modified: code/trunk/data/levels/presentation_dm.oxw
===================================================================
--- code/trunk/data/levels/presentation_dm.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/presentation_dm.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -17,10 +17,10 @@
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
-<?lua
+<?lua
end
?>
@@ -34,12 +34,12 @@
<?lua
-for i = 1, 100, 1
+for i = 1, 100, 1
do
j = math.random()
?>
-
- <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+
+ <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
<attached>
<Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
@@ -47,7 +47,7 @@
<SphereCollisionShape radius="<?lua print(j * 70) ?>" />
</collisionShapes>
</MovableEntity>
-<?lua
+<?lua
end
?>
Modified: code/trunk/data/levels/princessaeryn.oxw
===================================================================
--- code/trunk/data/levels/princessaeryn.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/princessaeryn.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -5,7 +5,7 @@
?>
<?lua
- dofile("includes/CuboidSpaceStation.lua")
+ dofile("includes/CuboidSpaceStation.lua")
?>
<NotificationQueue
Modified: code/trunk/data/levels/questsystem2.oxw
===================================================================
--- code/trunk/data/levels/questsystem2.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/questsystem2.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,7 +36,7 @@
<QuestHint id="93d0bdcb-9ce1-4f96-bc69-8d04e659fb31">
<QuestDescription title="The super Hint.3" description="Be proud of yourself.3" />
</QuestHint>
- </hints>
+ </hints>
<subquests>
<GlobalQuest id="e17f5245-f95b-44a8-b6cf-402274435ed4">
<QuestDescription title="The Main QUest2" description="This is the main quest hooray. Solve it!" failMessage="You fail. Looser." completeMessage="You Win." />
@@ -214,18 +214,18 @@
<?lua
max = 20
for i = 1, max, 1
-do
+do
x = math.sin(i/max*6)*40000
y = math.cos(i/max*6)*40000
z = i*100
?>
<?lua
-for k = 1, 25, 1
+for k = 1, 25, 1
do
j = math.random()
?>
-
- <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+
+ <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
<attached>
<Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
@@ -233,11 +233,11 @@
<SphereCollisionShape radius="<?lua print(j * 70) ?>" />
</collisionShapes> <?lua end ?>
</MovableEntity>
-<?lua
+<?lua
end
?>
<?lua end ?>
<Planet position="0,0,0" scale=10000 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="1,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
-
+
</Scene>
</Level>
Property changes on: code/trunk/data/levels/questsystem2.oxw
___________________________________________________________________
Added: svn:eol-style
+ native
Copied: code/trunk/data/levels/sound.oxw (from rev 6415, code/branches/presentation2/data/levels/sound.oxw)
===================================================================
--- code/trunk/data/levels/sound.oxw (rev 0)
+++ code/trunk/data/levels/sound.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,48 @@
+<?lua
+ include("stats.oxo")
+ include("hudtemplates3.oxo")
+?>
+
+<?lua
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name = "Sample"
+ description = "Just a few tests"
+>
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="true" />
+ <AmbientSound ambientSource="Mars.ogg" looping="true">
+ <events>
+ <activity>
+ <DistanceTrigger position="400,0,0" distance=200 target="Camera">
+ <attached>
+ <ParticleSpawner position="0,0,0" source="Orxonox/fire3" lifetime=0 loop=0 autostart=1 />
+ </attached>
+ </DistanceTrigger>
+ </activity>
+ </events>
+ </AmbientSound>
+ <AmbientSound ambientSource="Jupiter.ogg" looping="true">
+ <events>
+ <activity>
+ <DistanceTrigger position="400,150,0" distance=200 target="Camera">
+ <attached>
+ <ParticleSpawner position="0,0,0" source="Orxonox/fire3" lifetime=0 loop=0 autostart=1 />
+ </attached>
+ </DistanceTrigger>
+ </activity>
+ </events>
+ </AmbientSound>
+
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+ <SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ </Scene>
+</Level>
Modified: code/trunk/data/levels/teambasematchlevel.oxw
===================================================================
--- code/trunk/data/levels/teambasematchlevel.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/teambasematchlevel.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,12 +40,12 @@
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "-100,0,0"/>
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "100,0,0"/>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
<events><spawn><EventListener event="base 1" /></spawn></events>
</ParticleSpawner>
-<?lua
+<?lua
end
?>
</attached>
@@ -77,12 +77,12 @@
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "-100,0,0"/>
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "100,0,0"/>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
<events><spawn><EventListener event="base 2" /></spawn></events>
</ParticleSpawner>
-<?lua
+<?lua
end
?>
</attached>
@@ -114,12 +114,12 @@
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "-100,0,0"/>
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "100,0,0"/>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
<events><spawn><EventListener event="base 3" /></spawn></events>
</ParticleSpawner>
-<?lua
+<?lua
end
?>
</attached>
@@ -150,12 +150,12 @@
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "-100,0,0"/>
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "100,0,0"/>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
<events><spawn><EventListener event="base 4" /></spawn></events>
</ParticleSpawner>
-<?lua
+<?lua
end
?>
</attached>
@@ -187,12 +187,12 @@
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "-100,0,0"/>
<Billboard scale=7 material="Examples/Flare" colour="0.5,0.5,0.5" position = "100,0,0"/>
<?lua
-for i = 1, 10, 1
+for i = 1, 10, 1
do ?>
<ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
<events><spawn><EventListener event="base 5" /></spawn></events>
</ParticleSpawner>
-<?lua
+<?lua
end
?>
</attached>
Copied: code/trunk/data/levels/templates/spaceship_HXY.oxt (from rev 6415, code/branches/presentation2/data/levels/templates/spaceship_HXY.oxt)
===================================================================
--- code/trunk/data/levels/templates/spaceship_HXY.oxt (rev 0)
+++ code/trunk/data/levels/templates/spaceship_HXY.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,94 @@
+<Template name=spaceshipHXY>
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipHXYcameras
+ engine = spaceshipHXYengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 100
+ maxhealth = 200
+ initialhealth = 100
+
+ primaryThrust = 100;
+ auxilaryThrust = 30;
+ rotationThrust = 25;
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <attached>
+ <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+
+<?lua
+ include("includes/weaponsettings_HXY.oxi")
+?>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipHXYcameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,8, 60" drag=true mouselook=true />
+ <CameraPosition position="0,16, 120" drag=true mouselook=true />
+ <CameraPosition position="0,24,180" drag=true mouselook=true />
+ <CameraPosition position="0,60,10" pitch="-80" drag=true mouselook=true />
+ </camerapositions>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipHXYengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 6
+
+ speedfront = 150
+ speedback = 50
+ speedleftright = 50
+ speedupdown = 50
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 2, 0, 20" colour="1, 0.7, 0.1, 1.0" width=10 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-2, 0, 20" colour="1, 0.7, 0.1, 1.0" width=10 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 2, 0, 20" colour="1, 0.7, 0.1, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-2, 0, 20" colour="1, 0.7, 0.1, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=0.3 position=" 2, 0, 20" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.3 position="-2, 0, 20" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position=" 2, 0, 20" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position="-2, 0, 20" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
Copied: code/trunk/data/levels/templates/spaceship_HXY_SL.oxt (from rev 6415, code/branches/presentation2/data/levels/templates/spaceship_HXY_SL.oxt)
===================================================================
--- code/trunk/data/levels/templates/spaceship_HXY_SL.oxt (rev 0)
+++ code/trunk/data/levels/templates/spaceship_HXY_SL.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,90 @@
+<Template name=spaceshipHXYSL>
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipHXYcameras
+ engine = spaceshipHXYengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 100
+ maxhealth = 200
+ initialhealth = 100
+
+ primaryThrust = 100;
+ auxilaryThrust = 30;
+ rotationThrust = 25;
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <attached>
+ <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+
+<?lua
+ include("includes/weaponsettings_HXY.oxi")
+?>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipHXYcameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,8, 60" drag=true mouselook=true />
+ <CameraPosition position="0,16, 120" drag=true mouselook=true />
+ <CameraPosition position="0,24,180" drag=true mouselook=true />
+ <CameraPosition position="0,60,10" pitch="-80" drag=true mouselook=true />
+ </camerapositions>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipHXYengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 6
+
+ speedfront = 150
+ speedback = 50
+ speedleftright = 50
+ speedupdown = 50
+
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 2, 0, 20" colour="1, 0.7, 0.1, 1.0" width=10 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-2, 0, 20" colour="1, 0.7, 0.1, 1.0" width=10 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 2, 0, 20" colour="1, 0.7, 0.1, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-2, 0, 20" colour="1, 0.7, 0.1, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=0.3 position=" 2, 0, 20" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.3 position="-2, 0, 20" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position=" 2, 0, 20" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.15 position="-2, 0, 20" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
Copied: code/trunk/data/levels/templates/spaceship_Transporter.oxt (from rev 6415, code/branches/presentation2/data/levels/templates/spaceship_Transporter.oxt)
===================================================================
--- code/trunk/data/levels/templates/spaceship_Transporter.oxt (rev 0)
+++ code/trunk/data/levels/templates/spaceship_Transporter.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,94 @@
+<Template name=spaceshipTransporter>
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipTransportercameras
+ engine = spaceshipTransporterengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 1000
+ maxhealth = 1500
+ initialhealth = 1000
+
+ primaryThrust = 50;
+ auxilaryThrust = 10;
+ rotationThrust = 15;
+
+ collisionType = "dynamic"
+ mass = 1000
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <attached>
+ <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+
+<?lua
+ include("includes/weaponsettings_Transporter.oxi")
+?>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipTransportercameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,90,350" drag=true mouselook=true />
+ <CameraPosition position="0,150, 400" drag=true mouselook=true />
+ <CameraPosition position="0,200,550" drag=true mouselook=true />
+ <CameraPosition position="0,120,200" pitch="-80" drag=true mouselook=true />
+ </camerapositions>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipTransporterengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2
+
+ speedfront = 50
+ speedback = 10
+ speedleftright = 10
+ speedupdown = 10
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 20
+ accelerationbrake = 20
+ accelerationback = 10
+ accelerationleftright = 10
+ accelerationupdown = 10
+ >
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=2 name=bltest position=" 22, -10, 87" colour="1, 0.7, 0.1, 1.0" width=10 length=3000 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=2 name=bltest position="-22, -10, 87" colour="1, 0.7, 0.1, 1.0" width=10 length=3000 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=3 name=bltest position=" 22, -10, 87" colour="1, 0.7, 0.1, 0.7" width=25 length=2000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=3 name=bltest position="-22, -10, 87" colour="1, 0.7, 0.1, 0.7" width=25 length=2000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=2 position=" 22, -10, 87" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=2 position="-22, -10, 87" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=1 position="22, -10, 87" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=1 position="-22, -10, 87" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
Copied: code/trunk/data/levels/templates/spaceship_Transporter_SL.oxt (from rev 6415, code/branches/presentation2/data/levels/templates/spaceship_Transporter_SL.oxt)
===================================================================
--- code/trunk/data/levels/templates/spaceship_Transporter_SL.oxt (rev 0)
+++ code/trunk/data/levels/templates/spaceship_Transporter_SL.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,91 @@
+<Template name=spaceshipTransporterSL>
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipTransportercameras
+ engine = spaceshipTransporterengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 1000
+ maxhealth = 1500
+ initialhealth = 1000
+
+ primaryThrust = 50;
+ auxilaryThrust = 10;
+ rotationThrust = 15;
+
+ collisionType = "dynamic"
+ mass = 1000
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <attached>
+ <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+
+<?lua
+ include("includes/weaponsettings_Transporter.oxi")
+?>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipTransportercameras defaults=0>
+ <SpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,90,350" drag=true mouselook=true />
+ <CameraPosition position="0,150, 400" drag=true mouselook=true />
+ <CameraPosition position="0,200,550" drag=true mouselook=true />
+ <CameraPosition position="0,120,200" pitch="-80" drag=true mouselook=true />
+ </camerapositions>
+ </SpaceShip>
+</Template>
+
+<Template name=spaceshipTransporterengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2
+
+ speedfront = 50
+ speedback = 10
+ speedleftright = 10
+ speedupdown = 10
+
+
+ accelerationfront = 20
+ accelerationbrake = 20
+ accelerationback = 10
+ accelerationleftright = 10
+ accelerationupdown = 10
+ >
+ <EffectContainer condition="idle">
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=2 name=bltest position=" 22, -10, 87" colour="1, 0.7, 0.1, 1.0" width=10 length=3000 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=2 name=bltest position="-22, -10, 87" colour="1, 0.7, 0.1, 1.0" width=10 length=3000 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=3 name=bltest position=" 22, -10, 87" colour="1, 0.7, 0.1, 0.7" width=25 length=2000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=3 name=bltest position="-22, -10, 87" colour="1, 0.7, 0.1, 0.7" width=25 length=2000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=2 position=" 22, -10, 87" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=2 position="-22, -10, 87" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=1 position="22, -10, 87" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=1 position="-22, -10, 87" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
Modified: code/trunk/data/levels/templates/spaceship_assff.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceship_assff.oxt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/templates/spaceship_assff.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -63,33 +63,42 @@
speedleftright = 50
speedupdown = 50
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
accelerationfront = 500
accelerationbrake = 500
accelerationback = 125
accelerationleftright = 125
accelerationupdown = 125
>
- <active>
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" loop=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
<FadingBillboard mainstate=activity active=false scale=0.1 position="0, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
<!--
<Light mainstate=visibility position=" 8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
<Light mainstate=visibility position="-8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
-->
- </active>
- <forward>
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
<Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- </forward>
- <boost>
+ </EffectContainer>
+ <EffectContainer condition="boost">
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
<Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- </boost>
- <brake>
+ </EffectContainer>
+ <EffectContainer condition="brake">
<FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.3 position="-8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.15 position=" 8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.15 position="-8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
- </brake>
+ </EffectContainer>
</MultiStateEngine>
</Template>
Modified: code/trunk/data/levels/templates/spaceship_ghost.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceship_ghost.oxt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/templates/spaceship_ghost.oxt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -11,7 +11,7 @@
maxhealth = 200
initialhealth = 100
- primaryThrust = 100;
+ primaryThrust = 600;
auxilaryThrust = 30;
rotationThrust = 25;
@@ -32,7 +32,9 @@
<BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
-
+<?lua
+ include("includes/weaponsettings_ghost.oxi")
+?>
</SpaceShip>
</Template>
@@ -43,11 +45,6 @@
<CameraPosition position="0,40,160" drag=true mouselook=true />
<CameraPosition position="0,50,200" drag=true mouselook=true />
</camerapositions>
-
-<?lua
- include("includes/weaponsettings_ghost.oxi")
-?>
-
</SpaceShip>
</Template>
@@ -55,35 +52,33 @@
<MultiStateEngine
boostfactor = 2
- speedfront = 150
+ speedfront = 600
speedback = 50
speedleftright = 50
speedupdown = 50
- accelerationfront = 300
+ accelerationfront = 700
accelerationbrake = 300
accelerationback = 100
accelerationleftright = 100
accelerationupdown = 100
>
-
-
- <forward>
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.06, 3.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.06, 3.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.06, 5.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.06, 5.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.86, 4.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.86, 4.66, 9.6" colour="1, 1, 1, 0.4" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- </forward>
- <boost>
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.06, 5.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.06, 5.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.06, 3.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.06, 3.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 6.86, 4.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-6.86, 4.66, 11.6" colour="0.5, 0.85, 0.5, 0.1" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
- </boost>
- </MultiStateEngine>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 3, 6" colour="0.0, 0.0, 0.0, 0.5" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 3, 6" colour="0.0, 0.0, 0.0, 0.5" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 3, 6" colour="0.0, 0.0, 0.0, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 3, 6" colour="0.0, 0.0, 0.0, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+ <Backlight mainstate=activity active=false scale=0.4 position="7.6, 3, 6" colour="1, 1, 1, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <Backlight mainstate=activity active=false scale=0.4 position="-7.6, 3, 6" colour="1, 1, 1, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ <EffectContainer condition="brake">
+ <FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.2, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.3 position="-8, 0, 6" colour="0.2, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+</MultiStateEngine>
</Template>
Property changes on: code/trunk/data/levels/templates/spaceship_ghost.oxt
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/data/levels/test_ghost.oxw
===================================================================
--- code/trunk/data/levels/test_ghost.oxw 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/levels/test_ghost.oxw 2009-12-25 21:23:58 UTC (rev 6417)
@@ -23,18 +23,18 @@
<?lua
max = 20
for i = 1, max, 1
-do
+do
x = math.sin(i/max*6)*40000
y = math.cos(i/max*6)*40000
z = i*100
?>
<?lua
-for k = 1, 25, 1
+for k = 1, 25, 1
do
j = math.random()
?>
-
- <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+
+ <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
<attached>
<Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
@@ -42,11 +42,11 @@
<SphereCollisionShape radius="<?lua print(j * 70) ?>" />
</collisionShapes> <?lua end ?>
</MovableEntity>
-<?lua
+<?lua
end
?>
<?lua end ?>
<Planet position="0,0,0" scale=10000 pitch=-90 mesh="iceplanet.mesh" atmosphere="atmosphere1" rotationaxis="1,1,0" rotationrate="1" atmospheresize=224.0f imagesize=1024.0f />
-
+
</Scene>
</Level>
Property changes on: code/trunk/data/levels/test_ghost.oxw
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/data/lua/LuaStateInit.lua
===================================================================
--- code/trunk/data/lua/LuaStateInit.lua 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/lua/LuaStateInit.lua 2009-12-25 21:23:58 UTC (rev 6417)
@@ -14,42 +14,28 @@
end
-- Redirect dofile in order to load with the resource manager
--- Note: The function does not behave exactly like LuaState::doFile because the
--- default argument here for the group is not "General" but
--- "NoResourceGroupProvided". This resolves to the resource group used to
--- do the current file.
-doFile = function(filename, resourceGroup)
- local bSearchOtherPaths = (resourceGroup == nil) or false
- resourceGroup = resourceGroup or "NoResourceGroupProvided"
- luaState:doFile(filename, resourceGroup, bSearchOtherPaths)
+doFile = function(filename)
+ luaState:doFile(filename)
-- Required because the C++ function cannot return whatever might be on the stack
- return LuaStateReturnValue
+ return LuaStateReturnValue -- C-injected global variable
end
original_dofile = dofile
dofile = doFile
-- Create includeFile function that preparses the file according
-- to a function provided to the LuaState constructor (in C++)
--- Note: See the same notes as for doFile
-include = function(filename, resourceGroup)
- local bSearchOtherPaths = (resourceGroup == nil) or false
- resourceGroup = resourceGroup or "NoResourceGroupProvided"
- luaState:includeFile(filename, resourceGroup, bSearchOtherPaths)
+include = function(filename)
+ luaState:includeFile(filename)
-- Required because the C++ function cannot return whatever might be on the stack
- return LuaStateReturnValue
+ return LuaStateReturnValue -- C-injected global variable
end
-- Replace require function with almost similar behaviour
--- The difference is that you need to provide a resource group
--- Default value there is the current one (if present) or else "General"
--- But the loaded modules are then stored with only with the name (where name has no .lua extension)
--- CAUTION: That also means that you need to take care of conflicting filenames among groups
--- Furthermore the moduleName parameters is appended with the .lua extension when looking for the file
+-- The loaded modules are then stored with their names (where name has no .lua extension)
+-- Furthermore the ".lua" extension is appended to the moduleName parameter when looking for the file
old_require = require
-require = function(moduleName, resourceGroup)
- local bSearchOtherPaths = (resourceGroup == nil) or false
- resourceGroup = resourceGroup or "NoResourceGroupProvided"
- if not luaState:fileExists(moduleName .. ".lua", resourceGroup, bSearchOtherPaths) then
+require = function(moduleName)
+ if not luaState:fileExists(moduleName .. ".lua") then
return nil
end
if not _LOADED then
@@ -59,10 +45,15 @@
-- save old value
_REQUIREDNAME_OLD = _REQUIREDNAME
_REQUIREDNAME = moduleName
- luaState:doFile(moduleName .. ".lua", resourceGroup, bSearchOtherPaths)
+ luaState:doFile(moduleName .. ".lua")
_LOADED[moduleName] = LuaStateReturnValue or true
-- restore old value
_REQUIREDNAME = _REQUIREDNAME_OLD
end
return _LOADED[moduleName]
end
+
+-- Convenience function for console commands
+orxonox.execute = function(command)
+ orxonox.CommandExecutor:execute(command)
+end
Modified: code/trunk/data/overlays/OrxonoxLoading.overlay
===================================================================
--- code/trunk/data/overlays/OrxonoxLoading.overlay 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/overlays/OrxonoxLoading.overlay 2009-12-25 21:23:58 UTC (rev 6417)
@@ -10,4 +10,4 @@
height 300
material Orxonox/LoadingScreenSample
}
-}
\ No newline at end of file
+}
\ No newline at end of file
Modified: code/trunk/data/overlays/debug.oxo
===================================================================
--- code/trunk/data/overlays/debug.oxo 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/overlays/debug.oxo 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,7 +34,7 @@
font = "Monofur"
textsize = 0.03
/>
-
+
</OverlayGroup>
<Template name="defaultHUD">
Modified: code/trunk/data/overlays/stats.oxo
===================================================================
--- code/trunk/data/overlays/stats.oxo 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/overlays/stats.oxo 2009-12-25 21:23:58 UTC (rev 6417)
@@ -5,13 +5,13 @@
<!--OverlayText
name = "Title"
position = "0.79, 0.19"
- pickpoint = "1, 1"
+ pickpoint = "1, 1"
font = "Monofur"
caption = "Scoreboard"
colour = "0, 0.75, 0.2, 1"
textsize = 0.04
/-->
-
+
<OverlayText
name = "descr1"
position = "0.1, 0.20"
@@ -24,7 +24,7 @@
<OverlayText
name = "descr2"
position = "0.6, 0.20"
- pickpoint = "0, 1"
+ pickpoint = "0, 1"
font = "Monofur"
caption = "score"
colour = "0, 0.75, 0.2, 1"
@@ -33,13 +33,13 @@
<OverlayText
name = "descr3"
position = "0.8, 0.20"
- pickpoint = "0, 1"
+ pickpoint = "0, 1"
font = "Monofur"
caption = "deaths"
colour = "0, 0.75, 0.2, 1"
textsize = 0.04
/>
-
+
<!--Stats
name = "Statistics"
position = "0.5, 0.7"
Copied: code/trunk/data/particle/Steam.particle (from rev 6415, code/branches/presentation2/data/particle/Steam.particle)
===================================================================
--- code/trunk/data/particle/Steam.particle (rev 0)
+++ code/trunk/data/particle/Steam.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,44 @@
+
+particle_system Orxonox/Steam
+{
+ quota 1
+ material PE/smoke
+ particle_width 2000
+ particle_height 2000
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 0
+ colour 1 1 1 0.1
+ colour_range_start 1 1 1 0.1
+ colour_range_end 1 1 1 0.02
+ direction 0 1 0
+ emission_rate 1
+ position 0 0 0
+ velocity 0
+ velocity_min 0
+ velocity_max 0
+ time_to_live 200
+ time_to_live_min 200
+ time_to_live_max 300
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+}
+
Copied: code/trunk/data/particle/bigexplosion.particle (from rev 6415, code/branches/presentation2/data/particle/bigexplosion.particle)
===================================================================
--- code/trunk/data/particle/bigexplosion.particle (rev 0)
+++ code/trunk/data/particle/bigexplosion.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,72 @@
+particle_system Orxonox/bigexplosion
+{
+ quota 3000
+ material PE/explosion
+ particle_width 100
+ particle_height 100
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type vertex
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 180
+ colour 0 0 0 0
+ colour_range_start 0 0 0 0
+ colour_range_end 0 0 0 0
+ direction 0 1 0
+ emission_rate 2000
+ position 0 0 0
+ velocity 300
+ velocity_min 300
+ velocity_max 300
+ time_to_live 1.4
+ time_to_live_min 1.4
+ time_to_live_max 1.8
+ duration 0.3
+ duration_min 0.3
+ duration_max 0.3
+ repeat_delay 5
+ repeat_delay_min 5
+ repeat_delay_max 5
+ }
+
+ affector Scaler
+ {
+ rate 20
+ }
+
+ affector Rotator
+ {
+ rotation_speed_range_start 0
+ rotation_speed_range_end -7.2
+ rotation_range_start 0
+ rotation_range_end 360
+ }
+
+ affector ColourInterpolator
+ {
+ colour0 0.5 0.5 0.5 0
+ time0 0
+ colour1 0.4 0.4 0.4 0
+ time1 0.1
+ colour2 0.2 0.2 0.2 0
+ time2 0.3
+ colour3 0 0 0 0
+ time3 1.4
+ colour4 0.5 0.5 0.5 0
+ time4 1
+ colour5 0.5 0.5 0.5 0
+ time5 1.5
+ }
+}
+
Copied: code/trunk/data/particle/explosion4.particle (from rev 6415, code/branches/presentation2/data/particle/explosion4.particle)
===================================================================
--- code/trunk/data/particle/explosion4.particle (rev 0)
+++ code/trunk/data/particle/explosion4.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,71 @@
+particle_system Orxonox/explosion4
+{
+ quota 1000
+ material PE/explosion3
+ particle_width 10
+ particle_height 10
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type vertex
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 180
+ colour 0 0 0 0
+ colour_range_start 0 0 0 0
+ colour_range_end 0 0 0 0
+ direction 0 1 0
+ emission_rate 2000
+ position 0 0 0
+ velocity 15
+ velocity_min 15
+ velocity_max 15
+ time_to_live 1
+ time_to_live_min 1
+ time_to_live_max 1.4
+ duration 0.05
+ duration_min 0.05
+ duration_max 0.05
+ repeat_delay 5
+ repeat_delay_min 5
+ repeat_delay_max 5
+ }
+
+ affector Scaler
+ {
+ rate 20
+ }
+
+ affector Rotator
+ {
+ rotation_speed_range_start 0
+ rotation_speed_range_end -7.2
+ rotation_range_start 0
+ rotation_range_end 360
+ }
+
+ affector ColourInterpolator
+ {
+ colour0 0.5 0.5 0.5 0
+ time0 0
+ colour1 0.4 0.4 0.4 0
+ time1 0.2
+ colour2 0.2 0.2 0.2 0
+ time2 0.5
+ colour3 0 0 0 0
+ time3 1
+ colour4 0.5 0.5 0.5 0
+ time4 1
+ colour5 0.5 0.5 0.5 0
+ time5 1
+ }
+}
Copied: code/trunk/data/particle/laser.particle (from rev 6415, code/branches/presentation2/data/particle/laser.particle)
===================================================================
--- code/trunk/data/particle/laser.particle (rev 0)
+++ code/trunk/data/particle/laser.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,47 @@
+particle_system Orxonox/laser
+{
+ quota 200
+ material PE/point_lensflare
+ particle_width 7.08
+ particle_height 7.08
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 180
+ colour 0 1 0.275862 1
+ colour_range_start 0 1 0.275862 1
+ colour_range_end 0 1 0.275862 1
+ direction 0 1 0
+ emission_rate 80
+ position 0 0 0
+ velocity 11
+ velocity_min 11
+ velocity_max 11
+ time_to_live 0.7
+ time_to_live_min 0.7
+ time_to_live_max 1
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 1.6
+ repeat_delay_min 1.6
+ repeat_delay_max 1.6
+ }
+
+ affector Scaler
+ {
+ rate -8.8
+ }
+}
Copied: code/trunk/data/particle/load.particle (from rev 6415, code/branches/presentation2/data/particle/load.particle)
===================================================================
--- code/trunk/data/particle/load.particle (rev 0)
+++ code/trunk/data/particle/load.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,141 @@
+particle_system Orxonox/load
+{
+ quota 50
+ material PE/ringflare
+ particle_width 1
+ particle_height 1.3
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 5
+ colour 1 1 1 1
+ colour_range_start 1 1 1 1
+ colour_range_end 1 1 1 1
+ direction 0 1 0
+ emission_rate 4
+ position 0 -5 0
+ velocity 5
+ velocity_min 5
+ velocity_max 5
+ time_to_live 1
+ time_to_live_min 1
+ time_to_live_max 1
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+
+ emitter Point
+ {
+ angle 5
+ colour 1 1 1 1
+ colour_range_start 1 1 1 1
+ colour_range_end 1 1 1 1
+ direction 1 0 0
+ emission_rate 3
+ position -5 0 0
+ velocity 5
+ velocity_min 5
+ velocity_max 5
+ time_to_live 1
+ time_to_live_min 1
+ time_to_live_max 1
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+
+ emitter Point
+ {
+ angle 5
+ colour 1 1 1 1
+ colour_range_start 1 1 1 1
+ colour_range_end 1 1 1 1
+ direction -1 0 0
+ emission_rate 3
+ position 5 0 0
+ velocity 5
+ velocity_min 5
+ velocity_max 5
+ time_to_live 1
+ time_to_live_min 1
+ time_to_live_max 1
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+
+ emitter Point
+ {
+ angle 5
+ colour 1 1 1 1
+ colour_range_start 1 1 1 1
+ colour_range_end 1 1 1 1
+ direction 0 -1 0
+ emission_rate 4
+ position 0 5 0
+ velocity 5
+ velocity_min 5
+ velocity_max 5
+ time_to_live 1
+ time_to_live_min 1
+ time_to_live_max 1
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+
+ affector Scaler
+ {
+ rate 14.4
+ }
+
+ affector ColourInterpolator
+ {
+ colour0 1 1 0.5 0
+ time0 1
+ colour1 0.5 0.5 0.5 0
+ time1 1
+ colour2 0.5 0.5 0.5 0
+ time2 1
+ colour3 0.5 0.5 0.5 0
+ time3 1
+ colour4 0.5 0.5 0.5 0
+ time4 1
+ colour5 0.5 0.5 0.5 0
+ time5 1
+ }
+
+ affector DirectionRandomiser
+ {
+ randomness 15
+ scope 0.8
+ keep_velocity false
+ }
+
+
+}
Copied: code/trunk/data/particle/particlecanon.particle (from rev 6415, code/branches/presentation2/data/particle/particlecanon.particle)
===================================================================
--- code/trunk/data/particle/particlecanon.particle (rev 0)
+++ code/trunk/data/particle/particlecanon.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,43 @@
+particle_system Orxonox/particlecanon
+{
+ quota 1000
+ material PE/point_lensflare
+ particle_width 6
+ particle_height 6
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Point
+ {
+ angle 1
+ colour 0.965517 0.544828 0 1
+ colour_range_start 0.965517 0.544828 0 1
+ colour_range_end 0.965517 0.544828 0 1
+ direction 0 1 0
+ emission_rate 1220
+ position 0 0 0
+ velocity 300
+ velocity_min 300
+ velocity_max 300
+ time_to_live 0.05
+ time_to_live_min 0.05
+ time_to_live_max 0.05
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ }
+
+}
Copied: code/trunk/data/particle/rocketfire.particle (from rev 6415, code/branches/presentation2/data/particle/rocketfire.particle)
===================================================================
--- code/trunk/data/particle/rocketfire.particle (rev 0)
+++ code/trunk/data/particle/rocketfire.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,50 @@
+particle_system Orxonox/rocketfire
+{
+ quota 300
+ material PE/explosion
+ particle_width 15
+ particle_height 5
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Ellipsoid
+ {
+ angle 2
+ colour 1 0.682759 1 1
+ colour_range_start 1 0.682759 1 1
+ colour_range_end 1 0.682759 1 1
+ direction 0 0 1
+ emission_rate 1200
+ position 0 0 3
+ velocity 10
+ velocity_min 10
+ velocity_max 48
+ time_to_live 0.1
+ time_to_live_min 0.1
+ time_to_live_max 0.2
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ width 1.5
+ height 1.5
+ depth 10
+ }
+
+ affector Scaler
+ {
+ rate -20
+ }
+}
Copied: code/trunk/data/particle/smoke.particle (from rev 6415, code/branches/presentation2/data/particle/smoke.particle)
===================================================================
--- code/trunk/data/particle/smoke.particle (rev 0)
+++ code/trunk/data/particle/smoke.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,45 @@
+particle_system Orxonox/smoke
+{
+ quota 300
+ material PE/explosion
+ particle_width 6.94
+ particle_height 7.93
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Ellipsoid
+ {
+ angle 13
+ colour 0.156897 0.326207 1 1
+ colour_range_start 0.156897 0.326207 1 1
+ colour_range_end 0.156897 0.326207 1 1
+ direction 0 1 0
+ emission_rate 65
+ position 0 0 0
+ velocity 25
+ velocity_min 25
+ velocity_max 25
+ time_to_live 2.2
+ time_to_live_min 2.2
+ time_to_live_max 2.2
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ width 3
+ height 3
+ depth 0
+ }
+}
Copied: code/trunk/data/particle/tes3.particle (from rev 6415, code/branches/presentation2/data/particle/tes3.particle)
===================================================================
--- code/trunk/data/particle/tes3.particle (rev 0)
+++ code/trunk/data/particle/tes3.particle 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,59 @@
+particle_system Orxonox/tes3
+{
+ quota 500
+ material PE/lensflare
+ particle_width 10
+ particle_height 10
+ cull_each true
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type perpendicular_self
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Cylinder
+ {
+ angle 180
+ colour 1 1 1 1
+ colour_range_start 1 1 1 1
+ colour_range_end 1 1 1 1
+ direction 0 -1 0
+ emission_rate 100
+ position 0 100 0
+ velocity 26
+ velocity_min 26
+ velocity_max 26
+ time_to_live 9.6
+ time_to_live_min 9.6
+ time_to_live_max 9.6
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ width 200
+ height 200
+ depth 1
+ }
+
+ affector DeflectorPlane
+ {
+ plane_point 0 0 0
+ plane_normal 0 1 0
+ bounce 2
+ }
+
+ affector DirectionRandomiser
+ {
+ randomness 7
+ scope 1
+ keep_velocity true
+ }
+}
Deleted: code/trunk/data/resources.oxr
===================================================================
--- code/trunk/data/resources.oxr 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/data/resources.oxr 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,14 +0,0 @@
-<ResourceCollection resourceGroup = "General" >
- <ResourceLocation path = "levels" />
- <ResourceLocation path = "lua" />
- <ResourceLocation path = "overlays" />
- <ResourceLocation path = "particle" />
- <ResourceLocation path = "tcl" />
-</ResourceCollection>
-
-<ResourceCollection resourceGroup = "GUI" >
- <ResourceLocation path = "gui/configs" />
- <ResourceLocation path = "gui/layouts" />
- <ResourceLocation path = "gui/schemes" />
- <ResourceLocation path = "gui/scripts" />
-</ResourceCollection>
Modified: code/trunk/doc/CMakeLists.txt
===================================================================
--- code/trunk/doc/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/doc/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,4 +1,4 @@
-# Add a "doc" target with CMake build system.
+# Add a "doc" target with CMake build system.
# And configure doxy.config.in to doxy.config
#
# target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux
Modified: code/trunk/doc/api/CMakeLists.txt
===================================================================
--- code/trunk/doc/api/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/doc/api/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,8 +1,8 @@
-# Add a "doc" target with CMake build system.
+# Add a "doc" target with CMake build system.
# And configure doxy.config.in to doxy.config
#
# target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux
-# Creates .chm windows help file if MS HTML help workshop
+# Creates .chm windows help file if MS HTML help workshop
# (available from http://msdn.microsoft.com/workshop/author/htmlhelp)
# is installed with its DLLs in PATH.
#
@@ -11,7 +11,7 @@
# doxygen, dot, latex, dvips, makeindex, gswin32, etc.
# must be in path.
#
-# Note about Visual Studio Projects:
+# Note about Visual Studio Projects:
# MSVS hast its own path environment which may differ from the shell.
# See "Menu Tools/Options/Projects/VC++ Directories" in VS 7.1
#
@@ -31,7 +31,7 @@
SET(DOXY_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(DOXY_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
+
# we need latex for doxygen because of the formulas
# Orxonox doesn't
#FIND_PACKAGE(LATEX)
@@ -44,7 +44,7 @@
#IF (NOT DVIPS_CONVERTER)
# MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
#ENDIF (NOT DVIPS_CONVERTER)
-
+
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.config @ONLY)
# use (configured) doxy.config from (out of place) BUILD tree:
@@ -53,15 +53,15 @@
ELSE()
MESSAGE(FATAL_ERROR "Warning: Could not find dox.config.in in the root directory.")
ENDIF()
-
+
ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG})
-
+
# create a windows help .chm file using hhc.exe
# HTMLHelp DLL must be in path!
# fallback: use hhw.exe interactively
IF(WIN32)
FIND_PACKAGE(HTMLHelp)
- IF(HTML_HELP_COMPILER)
+ IF(HTML_HELP_COMPILER)
SET(TMP ${DOXY_OUTPUT_DIR}/html/index.hhp)
STRING(REGEX REPLACE "/" "\\\\" HHP_FILE ${TMP})
ADD_CUSTOM_TARGET(doc_chm ${HTML_HELP_COMPILER} ${HHP_FILE})
@@ -69,7 +69,7 @@
# Adding a dependency somehow adds doc target as default build target
SET_TARGET_PROPERTIES(doc doc_chm PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
ENDIF(HTML_HELP_COMPILER)
- ENDIF (WIN32)
+ ENDIF (WIN32)
# Installation
Modified: code/trunk/doc/api/main.dox
===================================================================
--- code/trunk/doc/api/main.dox 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/doc/api/main.dox 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,4 +1,4 @@
-/**
- at mainpage
- Orxonox Doxygen Reference
-*/
+/**
+ at mainpage
+ Orxonox Doxygen Reference
+*/
Property changes on: code/trunk/doc/api/main.dox
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/src/Orxonox.cc
===================================================================
--- code/trunk/src/Orxonox.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/Orxonox.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,7 @@
#ifndef ORXONOX_USE_WINMAIN
std::string strCmdLine;
for (int i = 1; i < argc; ++i)
- strCmdLine += argv[i] + std::string(" ");
+ strCmdLine = strCmdLine + argv[i] + ' ';
#endif
return orxonox::main(strCmdLine);
Modified: code/trunk/src/external/ceguilua/CMakeLists.txt
===================================================================
--- code/trunk/src/external/ceguilua/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/external/ceguilua/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -44,7 +44,7 @@
IF(_compare_result EQUAL 1)
BREAK() # _version > CEGUI_VERSION
ENDIF()
-
+
ADD_SUBDIRECTORY(ceguilua-${_version}) # Sets parent scope variable _package_files
FOREACH(_file ${_package_files})
CONFIGURE_FILE(ceguilua-${_version}/package/${_file} ${CEGUILUA_BINARY_DIR}/${_file} COPYONLY)
Modified: code/trunk/src/external/ceguilua/ceguilua-0.5.0/CMakeLists.txt
===================================================================
--- code/trunk/src/external/ceguilua/ceguilua-0.5.0/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/external/ceguilua/ceguilua-0.5.0/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -19,7 +19,7 @@
elements/ScrolledItemListBase.pkg elements/Slider.pkg elements/Spinner.pkg
elements/TabButton.pkg elements/TabControl.pkg elements/Thumb.pkg
elements/Titlebar.pkg elements/Tooltip.pkg
-
+
falagard/Dimension.pkg falagard/Enums.pkg falagard/FalagardComponentBase.pkg
falagard/FrameComponent.pkg falagard/ImageryComponent.pkg
falagard/ImagerySection.pkg falagard/LayerSpecification.pkg
Modified: code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -71,7 +71,7 @@
#ifdef ORXONOX_PLATFORM_WINDOWS
else
{
- std::string dir = startdirectory.string();
+ const std::string& dir = startdirectory.string();
if (dir.size() > 0 && dir[dir.size() - 1] == ':')
startdirectory = dir + '/';
}
@@ -83,9 +83,9 @@
while (file != end)
{
if (boost::filesystem::is_directory(*file))
- dirlist.push_back(ArgumentCompletionListElement((*file).string() + '/', getLowercase((*file).string()) + '/', (*file).BOOST_LEAF_FUNCTION() + '/'));
+ dirlist.push_back(ArgumentCompletionListElement(file->string() + '/', getLowercase(file->string()) + '/', file->BOOST_LEAF_FUNCTION() + '/'));
else
- filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).BOOST_LEAF_FUNCTION()));
+ filelist.push_back(ArgumentCompletionListElement(file->string(), getLowercase(file->string()), file->BOOST_LEAF_FUNCTION()));
++file;
}
}
@@ -100,8 +100,8 @@
ArgumentCompletionList classlist;
for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
- if ((*it).second->hasConfigValues())
- classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+ if (it->second->hasConfigValues())
+ classlist.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
return classlist;
}
@@ -109,12 +109,12 @@
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
{
ArgumentCompletionList configvalues;
- std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname);
+ std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
- if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues())
+ if (identifier != Identifier::getLowercaseStringIdentifierMapEnd() && identifier->second->hasConfigValues())
{
- for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
- configvalues.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+ for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->second->getConfigValueMapBegin(); it != identifier->second->getConfigValueMapEnd(); ++it)
+ configvalues.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
}
return configvalues;
@@ -126,10 +126,10 @@
std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
{
- std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
- if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+ std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+ if (variable != identifier->second->getLowercaseConfigValueMapEnd())
{
- std::string valuestring = (*variable).second->toString();
+ const std::string& valuestring = variable->second->toString();
oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
}
}
Modified: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/BaseObject.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,7 +35,6 @@
#include <tinyxml/tinyxml.h>
-#include "util/StringUtils.h"
#include "CoreIncludes.h"
#include "Event.h"
#include "EventIncludes.h"
@@ -118,7 +117,7 @@
XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
-
+
Element* events = 0;
if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
events = xmlelement.FirstChildElement("events", false);
@@ -138,7 +137,7 @@
XMLPortEventState(BaseObject, BaseObject, "activity", setActive, xmlelement, mode);
XMLPortEventState(BaseObject, BaseObject, "visibility", setVisible, xmlelement, mode);
XMLPortEventState(BaseObject, BaseObject, "mainstate", setMainState, xmlelement, mode);
-
+
this->bRegisteredEventStates_ = true;
}
@@ -235,7 +234,7 @@
{
if (it->second != state)
continue;
-
+
if (i == index)
return it->first;
++i;
@@ -251,7 +250,7 @@
this->eventListenersXML_.insert(listener);
listener->addEventSource(this, "mainstate");
}
-
+
/**
@brief Returns an event listener with a given index.
*/
@@ -277,7 +276,7 @@
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
if (it != this->eventStates_.end())
{
- COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << std::endl;
delete (it->second);
}
@@ -291,7 +290,7 @@
{
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
if (it != this->eventStates_.end())
- return ((*it).second);
+ return (it->second);
else
return 0;
}
@@ -343,11 +342,11 @@
void BaseObject::processEvent(Event& event)
{
this->registerEventStates();
-
+
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_);
if (it != this->eventStates_.end())
it->second->process(event, this);
- else if (event.statename_ != "")
+ else if (!event.statename_.empty())
COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
else
COUT(2) << "Warning: Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
@@ -355,7 +354,7 @@
/**
@brief Sets the main state of the object to a given boolean value.
-
+
Note: The main state of an object can be set with the @ref setMainStateName function.
It's part of the eventsystem and used for event forwarding (when the target object can't specify a specific state,
the main state is used by default).
@@ -385,10 +384,10 @@
{
this->mainStateFunctor_ = 0;
- if (this->mainStateName_ != "")
+ if (!this->mainStateName_.empty())
{
this->registerEventStates();
-
+
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(this->mainStateName_);
if (it != this->eventStates_.end() && it->second->getFunctor())
{
@@ -401,7 +400,7 @@
COUT(2) << "Warning: \"" << this->mainStateName_ << "\" is not a valid MainState." << std::endl;
}
}
-
+
/**
@brief Calls XMLEventPort with an empty XML-element to register the event states if necessary.
*/
@@ -413,7 +412,7 @@
this->XMLEventPort(xmlelement, XMLPort::NOP);
}
}
-
+
/**
@brief Manually loads all event states, even if the class doesn't officially support them. This is needed by some classes like @ref EventDispatcher or @ref EventTarget.
*/
@@ -436,7 +435,7 @@
// iterate through all states and get the event sources
for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
{
- std::string statename = (*it);
+ const std::string& statename = (*it);
// if the event state is already known, continue with the next state
orxonox::EventState* eventstate = object->getEventState(statename);
@@ -446,8 +445,8 @@
XMLPortClassObjectContainer<BaseObject, BaseObject>* container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(identifier->getXMLPortObjectContainer(statename));
if (!container)
{
- ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + "(" + statename + ")");
- ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + "(" + statename + ")");
+ ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');
+ ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');
setfunctor->setDefaultValue(1, statename);
getfunctor->setDefaultValue(1, statename);
Modified: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/BaseObject.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -156,7 +156,7 @@
void addEventSource(BaseObject* source, const std::string& state);
void removeEventSource(BaseObject* source);
BaseObject* getEventSource(unsigned int index, const std::string& state) const;
-
+
void addEventListener(BaseObject* listener);
BaseObject* getEventListener(unsigned int index) const;
@@ -171,7 +171,7 @@
inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }
/** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
-
+
static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
protected:
@@ -209,7 +209,7 @@
SmartPtr<Gametype> gametype_;
Gametype* oldGametype_;
std::set<Template*> templates_;
-
+
std::map<BaseObject*, std::string> eventSources_; //!< List of objects which send events to this object, mapped to the state which they affect
std::set<BaseObject*> eventListeners_; //!< List of objects which listen to the events of this object
std::set<BaseObject*> eventListenersXML_; //!< List of objects which listen to the events of this object through the "eventlisteners" subsection in XML
Modified: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -85,8 +85,16 @@
FIND_HEADER_FILES
TOLUA_FILES
CommandExecutor.h
+ ConfigFileManager.h
+ Game.h
+ GameMode.h
+ GUIManager.h
Loader.h
LuaState.h
+ PathConfig.h
+ input/InputManager.h
+ input/KeyBinder.h
+ input/KeyBinderManager.h
DEFINE_SYMBOL
"CORE_SHARED_BUILD"
PCH_FILE
Modified: code/trunk/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/trunk/src/libraries/core/ClassTreeMask.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ClassTreeMask.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -290,6 +290,8 @@
*/
void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean)
{
+ if (!subclass)
+ return;
// Check if the given subclass is a child of our root-class
if (subclass->isA(this->root_->getClass()))
{
@@ -319,6 +321,8 @@
*/
void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite)
{
+ if (!subclass)
+ return;
// Check if the current node contains exactly the subclass we want to add
if (subclass == node->getClass())
{
@@ -394,6 +398,8 @@
*/
void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean)
{
+ if (!subclass)
+ return;
for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
this->add(*it, this->isIncluded(*it), false, false);
@@ -427,6 +433,8 @@
*/
bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const
{
+ if (!subclass)
+ return false;
// Check if the searched subclass is of the same type as the class in the current node or a derivative
if (subclass->isA(node->getClass()))
{
@@ -815,12 +823,12 @@
{
// Calculate the prefix: + means included, - means excluded
if (it->isIncluded())
- out << "+";
+ out << '+';
else
- out << "-";
+ out << '-';
// Put the name of the corresponding class on the stream
- out << it->getClass()->getName() << " ";
+ out << it->getClass()->getName() << ' ';
}
return out;
@@ -849,12 +857,12 @@
// If there is a first subclass, move the object-iterator to the first object of this class. Else go to the end
if (this->subclassIterator_ != this->subclasses_.end())
- this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+ this->objectIterator_ = this->subclassIterator_->first->getObjects()->begin();
else
this->objectIterator_ = ObjectList<BaseObject>::end();
// Check if the iterator points on a valid object. If not, go to the next object by calling ++
- if (!this->objectIterator_ || ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first)))
+ if (!this->objectIterator_ || (this->subclassIterator_->second && !this->objectIterator_->isExactlyA(this->subclassIterator_->first)))
this->operator++();
return (*this);
@@ -881,13 +889,13 @@
// Check if there really is a next class. If yes, move the object-iterator to the first object
if (this->subclassIterator_ != this->subclasses_.end())
- this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+ this->objectIterator_ = this->subclassIterator_->first->getObjects()->begin();
else
return (*this);
}
// Repeat this until we reach a valid object or the end
- } while ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first));
+ } while (this->subclassIterator_->second && !this->objectIterator_->isExactlyA(this->subclassIterator_->first));
}
return (*this);
}
Modified: code/trunk/src/libraries/core/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/CommandEvaluation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CommandEvaluation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,7 +49,7 @@
this->command_ = command;
this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
- this->additionalParameter_ = "";
+ this->additionalParameter_.clear();
this->bEvaluatedParams_ = false;
@@ -59,10 +59,10 @@
this->functionclass_ = 0;
this->function_ = 0;
- this->possibleArgument_ = "";
- this->argument_ = "";
+ this->possibleArgument_.clear();
+ this->argument_.clear();
- this->errorMessage_ = "";
+ this->errorMessage_.clear();
this->state_ = CommandState::Empty;
}
@@ -78,7 +78,7 @@
if (this->bEvaluatedParams_ && this->function_)
{
- COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
+ COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
(*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
return true;
}
@@ -97,7 +97,7 @@
return false;
}
- std::string CommandEvaluation::complete()
+ const std::string& CommandEvaluation::complete()
{
if (!this->bNewCommand_)
{
@@ -113,39 +113,39 @@
if (this->function_->getParamCount() == 0)
return (this->command_ = this->function_->getName());
else
- return (this->command_ = this->function_->getName() + " ");
+ return (this->command_ = this->function_->getName() + ' ');
}
else if (this->functionclass_)
- return (this->command_ = this->functionclass_->getName() + " ");
+ return (this->command_ = this->functionclass_->getName() + ' ');
break;
case CommandState::Function:
if (this->function_)
{
if (this->function_->getParamCount() == 0)
- return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName());
+ return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName());
else
- return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
+ return (this->command_ = this->functionclass_->getName() + ' ' + this->function_->getName() + ' ');
}
break;
case CommandState::ParamPreparation:
case CommandState::Params:
{
- if (this->argument_ == "" && this->possibleArgument_ == "")
+ if (this->argument_.empty() && this->possibleArgument_.empty())
break;
unsigned int maxIndex = this->commandTokens_.size();
if (this->command_[this->command_.size() - 1] != ' ')
maxIndex -= 1;
- std::string whitespace = "";
+ std::string whitespace;
- if (this->possibleArgument_ != "")
+ if (!this->possibleArgument_.empty())
{
this->argument_ = this->possibleArgument_;
if (this->function_->getParamCount() > (maxIndex + 1 - this->getStartindex()))
whitespace = " ";
}
- return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
+ return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + ' ' + this->argument_ + whitespace);
break;
}
case CommandState::Finished:
@@ -261,26 +261,26 @@
std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
{
- std::string output = "";
+ std::string output;
for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
{
if (it != list.begin())
- output += " ";
+ output += ' ';
- output += *(*it).second;
+ output += *(it->second);
}
return output;
}
std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
{
- std::string output = "";
+ std::string output;
for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
{
if (it != list.begin())
- output += " ";
+ output += ' ';
- output += (*it).getDisplay();
+ output += it->getDisplay();
}
return output;
}
@@ -294,19 +294,19 @@
for (unsigned int i = 0; i < command->getParamCount(); i++)
{
if (i != 0)
- output += " ";
+ output += ' ';
if (command->defaultValueSet(i))
- output += "[";
+ output += '[';
else
- output += "{";
+ output += '{';
output += command->getTypenameParam(i);
if (command->defaultValueSet(i))
- output += "=" + command->getDefaultValue(i).getString() + "]";
+ output += '=' + command->getDefaultValue(i).getString() + ']';
else
- output += "}";
+ output += '}';
}
return output;
}
Modified: code/trunk/src/libraries/core/CommandEvaluation.h
===================================================================
--- code/trunk/src/libraries/core/CommandEvaluation.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CommandEvaluation.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -65,7 +65,7 @@
void initialize(const std::string& command);
bool execute() const;
- std::string complete();
+ const std::string& complete();
std::string hint() const;
void evaluateParams();
@@ -81,7 +81,7 @@
inline void setAdditionalParameter(const std::string& param)
{ this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
inline std::string getAdditionalParameter() const
- { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
+ { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
void setEvaluatedParameter(unsigned int index, MultiType param);
MultiType getEvaluatedParameter(unsigned int index) const;
Modified: code/trunk/src/libraries/core/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/CommandExecutor.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CommandExecutor.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -58,7 +58,7 @@
std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
{
- COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << '.' << std::endl;
}
// Make sure we can also delete the external ConsoleCommands that don't belong to an Identifier
@@ -81,7 +81,7 @@
{
std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
- return (*it).second;
+ return it->second;
else
return 0;
}
@@ -95,7 +95,7 @@
{
std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
- return (*it).second;
+ return it->second;
else
return 0;
}
@@ -214,7 +214,7 @@
// The first argument is bad
CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
- CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
+ CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.';
return;
}
}
@@ -230,7 +230,7 @@
if (num_functions == 1 && num_identifiers == 0)
{
// It's a shortcut
- std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+ const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
{
@@ -242,7 +242,7 @@
CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
{
- CommandExecutor::getEvaluation().command_ += " ";
+ CommandExecutor::getEvaluation().command_ += ' ';
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
// Move on to next case
@@ -250,7 +250,7 @@
else if (num_identifiers == 1 && num_functions == 0)
{
// It's a classname
- std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;
+ const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first;
CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
{
@@ -259,7 +259,7 @@
}
CommandExecutor::getEvaluation().state_ = CommandState::Function;
CommandExecutor::getEvaluation().function_ = 0;
- CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
+ CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ';
// Move on to next case
}
else if (num_identifiers == 0 && num_functions == 0)
@@ -267,7 +267,7 @@
// No possibilities
CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
- CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
+ CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.';
return;
}
else
@@ -318,7 +318,7 @@
if (num_functions == 1)
{
// It's a function
- std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+ const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
{
@@ -326,10 +326,10 @@
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
- CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+ CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName();
if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
{
- CommandExecutor::getEvaluation().command_ += " ";
+ CommandExecutor::getEvaluation().command_ += ' ';
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
// Move on to next case
@@ -339,13 +339,13 @@
// No possibilities
CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
- CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
+ CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + GetLocalisation("commandexecutorunknownsecondargumentstart") + ' ' + CommandExecutor::getArgument(1) + '.';
return;
}
else
{
// There are several possibilities
- CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
+ CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
CommandExecutor::getEvaluation().bCommandChanged_ = true;
return;
@@ -385,8 +385,8 @@
if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
{
// There is exactly one possible argument
- CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
- CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+ CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
+ CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
return;
}
@@ -450,15 +450,15 @@
return (CommandExecutor::argumentsGiven() > (1 + command->getParamCount()));
}
- std::string CommandExecutor::getArgument(unsigned int index)
+ const std::string& CommandExecutor::getArgument(unsigned int index)
{
if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
return CommandExecutor::getEvaluation().commandTokens_[index];
else
- return "";
+ return BLANKSTRING;
}
- std::string CommandExecutor::getLastArgument()
+ const std::string& CommandExecutor::getLastArgument()
{
return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
}
@@ -466,28 +466,28 @@
void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
{
CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
- std::string lowercase = getLowercase(fragment);
+ const std::string& lowercase = getLowercase(fragment);
for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
- if ((*it).second->hasConsoleCommands())
- if ((*it).first.find(lowercase) == 0 || fragment == "")
- CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+ if (it->second->hasConsoleCommands())
+ if (it->first.find(lowercase) == 0 || fragment.empty())
+ CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
}
void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
{
CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
- std::string lowercase = getLowercase(fragment);
+ const std::string& lowercase = getLowercase(fragment);
if (!identifier)
{
for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
- if ((*it).first.find(lowercase) == 0 || fragment == "")
- CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+ if (it->first.find(lowercase) == 0 || fragment.empty())
+ CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
}
else
{
for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
- if ((*it).first.find(lowercase) == 0 || fragment == "")
- CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+ if (it->first.find(lowercase) == 0 || fragment.empty())
+ CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
}
}
@@ -496,17 +496,17 @@
CommandExecutor::createArgumentCompletionList(command, param);
CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
- std::string lowercase = getLowercase(fragment);
+ const std::string& lowercase = getLowercase(fragment);
for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
{
- if ((*it).lowercaseComparison())
+ if (it->lowercaseComparison())
{
- if ((*it).getComparable().find(lowercase) == 0 || fragment == "")
+ if (it->getComparable().find(lowercase) == 0 || fragment.empty())
CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
}
else
{
- if ((*it).getComparable().find(fragment) == 0 || fragment == "")
+ if (it->getComparable().find(fragment) == 0 || fragment.empty())
CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
}
}
@@ -514,52 +514,52 @@
Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
{
- std::string lowercase = getLowercase(name);
+ const std::string& lowercase = getLowercase(name);
std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
- if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
- return (*it).second;
+ if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands())
+ return it->second;
return 0;
}
ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
{
- std::string lowercase = getLowercase(name);
+ const std::string& lowercase = getLowercase(name);
if (!identifier)
{
std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
- return (*it).second;
+ return it->second;
}
else
{
std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
if (it != identifier->getLowercaseConsoleCommandMapEnd())
- return (*it).second;
+ return it->second;
}
return 0;
}
- std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
+ const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
{
CommandExecutor::createArgumentCompletionList(command, param);
- std::string lowercase = getLowercase(name);
+ const std::string& lowercase = getLowercase(name);
for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
{
- if ((*it).lowercaseComparison())
+ if (it->lowercaseComparison())
{
- if ((*it).getComparable() == lowercase)
- return (*it).getString();
+ if (it->getComparable() == lowercase)
+ return it->getString();
}
else
{
- if ((*it).getComparable() == name)
- return (*it).getString();
+ if (it->getComparable() == name)
+ return it->getString();
}
}
- return "";
+ return BLANKSTRING;
}
void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param)
@@ -588,25 +588,25 @@
}
else if (list.size() == 1)
{
- return ((*(*list.begin()).first) + " ");
+ return ((*list.begin()->first) + ' ');
}
else
{
- std::string output = "";
+ std::string output;
for (unsigned int i = 0; true; i++)
{
char temp = 0;
for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
{
- if ((*(*it).first).size() > i)
+ if (it->first->size() > i)
{
if (it == list.begin())
{
- temp = (*(*it).first)[i];
+ temp = (*it->first)[i];
}
else
{
- if (temp != (*(*it).first)[i])
+ if (temp != (*it->first)[i])
return output;
}
}
@@ -629,27 +629,32 @@
}
else if (list.size() == 1)
{
- return ((*list.begin()).getComparable() + " ");
+ return (list.begin()->getComparable() + ' ');
}
else
{
- std::string output = "";
+ std::string output;
for (unsigned int i = 0; true; i++)
{
+ char tempComparable = 0;
char temp = 0;
for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
{
- std::string argument = (*it).getComparable();
+ const std::string& argumentComparable = it->getComparable();
+ const std::string& argument = it->getString();
if (argument.size() > i)
{
if (it == list.begin())
{
+ tempComparable = argumentComparable[i];
temp = argument[i];
}
else
{
- if (temp != argument[i])
+ if (tempComparable != argumentComparable[i])
return output;
+ else if (temp != argument[i])
+ temp = tempComparable;
}
}
else
Modified: code/trunk/src/libraries/core/CommandExecutor.h
===================================================================
--- code/trunk/src/libraries/core/CommandExecutor.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CommandExecutor.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -89,8 +89,8 @@
static unsigned int argumentsFinished();
static unsigned int argumentsGiven();
static bool enoughArgumentsGiven(ConsoleCommand* command);
- static std::string getArgument(unsigned int index);
- static std::string getLastArgument();
+ static const std::string& getArgument(unsigned int index);
+ static const std::string& getLastArgument();
static void createListOfPossibleIdentifiers(const std::string& fragment);
static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
@@ -98,7 +98,7 @@
static Identifier* getPossibleIdentifier(const std::string& name);
static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
- static std::string getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
+ static const std::string& getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
Modified: code/trunk/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/CommandLineParser.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -62,7 +62,7 @@
this->bHasDefaultValue_ = false;
this->value_ = temp;
}
- else if (value == "")
+ else if (value.empty())
{
this->bHasDefaultValue_ = false;
this->value_ = true;
@@ -139,7 +139,7 @@
{
OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
"Cannot have two command line shortcut with the same name.");
- if (it->second->getShortcut() != "")
+ if (!it->second->getShortcut().empty())
cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
}
bFirstTimeParse_ = false;
@@ -164,7 +164,7 @@
else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
{
// negative number as a value
- value += arguments[i] + " ";
+ value += arguments[i] + ' ';
}
else
{
@@ -172,17 +172,17 @@
// save old data first
value = removeTrailingWhitespaces(value);
- if (name != "")
+ if (!name.empty())
{
checkFullArgument(name, value, bParsingFile);
- name = "";
- assert(shortcut == "");
+ name.clear();
+ assert(shortcut.empty());
}
- else if (shortcut != "")
+ else if (!shortcut.empty())
{
checkShortcut(shortcut, value, bParsingFile);
- shortcut = "";
- assert(name == "");
+ shortcut.clear();
+ assert(name.empty());
}
if (arguments[i][1] == '-')
@@ -197,14 +197,14 @@
}
// reset value string
- value = "";
+ value.clear();
}
}
else
{
// value string
- if (name == "" && shortcut == "")
+ if (name.empty() && shortcut.empty())
{
ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
}
@@ -217,15 +217,15 @@
// parse last argument
value = removeTrailingWhitespaces(value);
- if (name != "")
+ if (!name.empty())
{
checkFullArgument(name, value, bParsingFile);
- assert(shortcut == "");
+ assert(shortcut.empty());
}
- else if (shortcut != "")
+ else if (!shortcut.empty())
{
checkShortcut(shortcut, value, bParsingFile);
- assert(name == "");
+ assert(name.empty());
}
}
catch (const ArgumentException& ex)
@@ -290,11 +290,11 @@
for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
it != inst.cmdLineArgs_.end(); ++it)
{
- if (it->second->getShortcut() != "")
+ if (!it->second->getShortcut().empty())
infoStr << " [-" << it->second->getShortcut() << "] ";
else
infoStr << " ";
- infoStr << "--" << it->second->getName() << " ";
+ infoStr << "--" << it->second->getName() << ' ';
if (it->second->getValue().getType() != MT_Type::Bool)
infoStr << "ARG ";
else
@@ -346,7 +346,7 @@
*/
void CommandLineParser::_parseFile()
{
- std::string filename = CommandLineParser::getValue("optionsFile").getString();
+ const std::string& filename = CommandLineParser::getValue("optionsFile").getString();
// look for additional arguments in given file or start.ini as default
// They will not overwrite the arguments given directly
Modified: code/trunk/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ConfigFileManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,21 +50,26 @@
std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
{
- std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
- if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
- return (*variable).second->set(value);
+ std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+ if (variable != identifier->second->getLowercaseConfigValueMapEnd())
+ return variable->second->set(value);
}
return false;
}
+ std::string getConfig(const std::string& classname, const std::string& varname)
+ {
+ return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true);
+ }
+
bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
{
std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
{
- std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
- if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
- return (*variable).second->tset(value);
+ std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
+ if (variable != identifier->second->getLowercaseConfigValueMapEnd())
+ return variable->second->tset(value);
}
return false;
}
@@ -93,7 +98,7 @@
if (!this->bString_)
this->value_ = value;
else
- this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
+ this->value_ = '"' + addSlashes(stripEnclosingQuotes(value)) + '"';
}
std::string ConfigFileEntryValue::getValue() const
@@ -106,10 +111,10 @@
std::string ConfigFileEntryValue::getFileEntry() const
{
- if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
- return (this->name_ + "=" + this->value_);
+ if (this->additionalComment_.empty())
+ return (this->name_ + '=' + this->value_);
else
- return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
+ return (this->name_ + '=' + this->value_ + " " + this->additionalComment_);
}
@@ -118,10 +123,10 @@
////////////////////////////////
std::string ConfigFileEntryVectorValue::getFileEntry() const
{
- if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
- return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
+ if (this->additionalComment_.empty())
+ return (this->name_ + '[' + multi_cast<std::string>(this->index_) + ']' + '=' + this->value_);
else
- return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
+ return (this->name_ + '[' + multi_cast<std::string>(this->index_) + "]=" + this->value_ + ' ' + this->additionalComment_);
}
@@ -165,10 +170,10 @@
std::string ConfigFileSection::getFileEntry() const
{
- if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
- return ("[" + this->name_ + "]");
+ if (this->additionalComment_.empty())
+ return ('[' + this->name_ + ']');
else
- return ("[" + this->name_ + "] " + this->additionalComment_);
+ return ('[' + this->name_ + "] " + this->additionalComment_);
}
std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString)
@@ -245,7 +250,7 @@
std::string line;
std::getline(file, line);
- std::string temp = getStripped(line);
+ const std::string& temp = getStripped(line);
if (!isEmpty(temp) && !isComment(temp))
{
size_t pos1 = temp.find('[');
@@ -255,7 +260,7 @@
if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1)
{
// New section
- std::string comment = line.substr(pos2 + 1);
+ const std::string& comment = line.substr(pos2 + 1);
if (isComment(comment))
newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
else
@@ -287,7 +292,7 @@
{
commentposition = getNextCommentPosition(line, commentposition + 1);
}
- std::string value = "", comment = "";
+ std::string value, comment;
if (commentposition == std::string::npos)
{
value = removeTrailingWhitespaces(line.substr(pos1 + 1));
@@ -376,15 +381,15 @@
for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
{
std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
- if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())
+ if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues())
{
// The section exists, delete comment
if (bCleanComments)
(*it1)->setComment("");
for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
{
- std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());
- if (it4 != (*it2).second->getConfigValueMapEnd())
+ std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName());
+ if (it4 != it2->second->getConfigValueMapEnd())
{
// The config-value exists, delete comment
if (bCleanComments)
@@ -458,7 +463,7 @@
{
if (it->second->hasConfigValues())
{
- for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)
+ for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2)
it2->second->update();
it->second->updateConfigValues();
Modified: code/trunk/src/libraries/core/ConfigFileManager.h
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ConfigFileManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,8 +39,10 @@
#include "util/OrxEnum.h"
#include "util/Singleton.h"
+// tolua_begin
namespace orxonox
{
+ // tolua_end
// Use int as config file type to have an arbitrary number of files
struct ConfigFileType : OrxEnum<ConfigFileType>
{
@@ -49,11 +51,13 @@
static const int NoType = 0;
static const int Settings = 1;
static const int JoyStickCalibration = 2;
+ static const int CommandHistory = 3;
static const int numberOfReservedTypes = 1024;
};
- _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value);
+ _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value); // tolua_export
+ _CoreExport std::string getConfig(const std::string& classname, const std::string& varname); // tolua_export
_CoreExport bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
_CoreExport void reloadConfig();
_CoreExport void saveConfig();
@@ -84,7 +88,12 @@
class _CoreExport ConfigFileEntryValue : public ConfigFileEntry
{
public:
- inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {}
+ inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "")
+ : name_(name)
+ , value_(value)
+ , bString_(bString)
+ , additionalComment_(additionalComment)
+ {}
inline virtual ~ConfigFileEntryValue() {}
inline virtual const std::string& getName() const
@@ -168,7 +177,11 @@
friend class ConfigFile;
public:
- inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "") : name_(name), additionalComment_(additionalComment), bUpdated_(false) {}
+ inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "")
+ : name_(name)
+ , additionalComment_(additionalComment)
+ , bUpdated_(false)
+ {}
~ConfigFileSection();
inline const std::string& getName() const
@@ -239,12 +252,12 @@
inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
{ this->getSection(section)->setValue(name, value, bString); this->save(); }
inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
- { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
+ { const std::string& output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
{ this->getSection(section)->setValue(name, index, value, bString); this->save(); }
inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
- { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
+ { const std::string& output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
{ this->getSection(section)->deleteVectorEntries(name, startindex); }
@@ -318,6 +331,6 @@
static ConfigFileManager* singletonPtr_s;
};
-}
+} // tolua_export
#endif /* _ConfigFileManager_H__ */
Modified: code/trunk/src/libraries/core/ConfigValueContainer.h
===================================================================
--- code/trunk/src/libraries/core/ConfigValueContainer.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ConfigValueContainer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -120,8 +120,8 @@
@param varname The name of the variable
@param defvalue The default-value
*/
- template <class V>
- ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<V>& defvalue)
+ template <class D, class V>
+ ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
{
this->init(type, identifier, sectionname, varname);
@@ -145,13 +145,11 @@
{
if ((this->callback_ && object) || this->bContainerIsNew_)
{
- if (this->bContainerIsNew_)
- this->bContainerIsNew_ = false;
-
T temp = *value;
this->value_.getValue(value);
- if ((*value) != temp)
+ if (this->bContainerIsNew_ || (*value) != temp)
{
+ this->bContainerIsNew_ = false;
if (this->callback_ && object)
this->callback_->call(object);
else
Modified: code/trunk/src/libraries/core/ConfigValueIncludes.h
===================================================================
--- code/trunk/src/libraries/core/ConfigValueIncludes.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ConfigValueIncludes.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,13 +22,14 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Reto Grieder (functions)
*
*/
/**
- @file
- @brief Definition of macros for config-values.
+ at file
+ at brief
+ Definition of macros and functions for config-values.
*/
#ifndef _ConfigValueIncludes_H__
@@ -40,75 +41,138 @@
#include "ConfigValueContainer.h"
#include "ConfigFileManager.h"
+namespace orxonox
+{
+ /** Sets a runtime configurable value.
+ If the container for the value doesn't yet exist, a new one is created.
+ Also, the @a variable argument will be modified and set to the new value (default or from ini file).
+ @param object
+ Class instance that the config value should belong to (usually just 'this')
+ @param variable
+ Pointer to the variable where the value should be written to
+ @param type
+ Type of the config file, usually ConfigFileType::Settings
+ @param sectionName
+ Name of the section in the ini file (e.g. [MySection])
+ @param entryName
+ Name of the entry in the ini file (e.g. [MySection] myValue)
+ @param defaultValue
+ Value to be used if it cannot be read from the ini file
+ */
+ template <class T, class D, class V>
+ inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
+ {
+ ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
+ if (!container)
+ {
+ container = new ConfigValueContainer(type, object->getIdentifier(), sectionName, entryName, defaultValue, *variable);
+ object->getIdentifier()->addConfigValueContainer(entryName, container);
+ }
+ return container->getValue(variable, object);
+ }
+}
-/**
- @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
- @param varname The name of the variable
- @param defvalue The default-value of the variable
+/** Sets a runtime configurable value (simplified macro version of setConfigValueGeneric)
+ If the container for the value doesn't yet exist, a new one is created.
+ Also, the @a varname argument will be modified and set to the new value (default or from ini file).
+ at param varname
+ Variable name as C++ identifier. It will be used as entry name and as variable pointer
+ at param defaultValue
+ Value to be used if it cannot be read from the ini file
*/
-#define SetConfigValueGeneric(type, varname, entryname, sectionname, defvalue) \
- static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
- orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(entryname); \
- if (!container##varname) \
- { \
- container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, sectionname, entryname, defvalue, varname); \
- identifier##varname->addConfigValueContainer(entryname, container##varname); \
- } \
- container##varname->getValue(&varname, this)
+#define SetConfigValue(varname, defaultValue) \
+ orxonox::setConfigValueGeneric(this, &varname, ConfigFileType::Settings, this->getIdentifier()->getName(), #varname, defaultValue)
-#define SetConfigValue(varname, defvalue) SetConfigValueGeneric(ConfigFileType::Settings, varname, #varname, identifier##varname->getName(), defvalue)
-
-
-/**
- @brief Assigns the vector-values, defined in the config-file, to the vector (or the default-value, if there are no entries in the file).
- @param varname The name of the std::vector
- @param defvalue The default-value
+/** Sets a runtime configurable value (simplified macro version of setConfigValueGeneric)
+ If the container for the value doesn't yet exist, a new one is created.
+ Also, the @a varname argument will be modified and set to the new value (default or from ini file).
+ at param variable
+ Variable name as C++ identifier.
+ at param entryName
+ Name of the entry in the ini file (e.g. [MySection] myValue)
+ at param defaultValue
+ Value to be used if it cannot be read from the ini file
*/
-#define SetConfigValueVectorGeneric(type, varname, defvalue) \
- static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
- orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
- if (!container##varname) \
- { \
- container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
- identifier##varname->addConfigValueContainer(#varname, container##varname); \
- } \
- container##varname->getValue(&varname, this)
+#define SetConfigValueAlias(variable, entryName, defaultValue) \
+ orxonox::setConfigValueGeneric(this, &variable, ConfigFileType::Settings, this->getIdentifier()->getName(), entryName, defaultValue)
-#define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(ConfigFileType::Settings, varname, defvalue)
+namespace orxonox
+{
+ /** Resets a runtime configurable value to its default.
+ If the container for the value doesn't yet exist, a warning is displayed.
+ Also, the @a variable argument will be modified and set to the default value.
+ @param object
+ Class instance that the config value should belong to (usually just 'this')
+ @param variable
+ Pointer to the variable where the value should be written to
+ @param entryName
+ Name of the entry in the ini file (e.g. [MySection] myValue)
+ */
+ template <class T, class V>
+ inline void resetConfigValueGeneric(T* object, V* variable, const std::string& entryName)
+ {
+ ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
+ if (container)
+ {
+ container->reset();
+ container->getValue(variable, object);
+ }
+ else
+ {
+ COUT(2) << "Warning: Couldn't reset config-value '" << entryName << "' in class '"
+ << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;
+ }
+ }
+}
-/**
- @brief Sets the variable and the config-file entry back to the previously defined default-value.
- @param varname The name of the variable
+/** Resets a runtime configurable value to its default (simplified macro version of modifyConfigValueGeneric)
+ If the container for the value doesn't yet exist, a warning is displayed.
+ Also, the @a varname argument will be modified and set to the default value.
+ at param varname
+ Variable name as C++ identifier. It will be used as entry name and as variable pointer
*/
#define ResetConfigValue(varname) \
- orxonox::ConfigValueContainer* container##varname##reset = this->getIdentifier()->getConfigValueContainer(#varname); \
- if (container##varname##reset) \
- { \
- container##varname##reset->reset(); \
- container##varname##reset->getValue(&varname, this); \
- } \
- else \
- { \
- COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
- }
+ orxonox::resetConfigValueGeneric(this, &varname, #varname)
-/**
- @brief Modifies a config-value by using a modifier and some arguments.
- @param varname The name of the config-value
- @param modifier The name of the modifier: set, tset, add, remove, reset, update
+/** Modifies a runtime configurable value by using a modifier and some arguments.
+ If the container for the value doesn't yet exist, a warning is displayed.
+ Also, the @a variable argument will be modified and set to the current value.
+ at param object
+ Class instance that the config value should belong to (usually just 'this')
+ at param variable
+ Pointer to the variable where the value should be written to
+ at param entryName
+ Name of the entry in the ini file (e.g. [MySection] myValue)
+ at param modifier
+ On of these functions: set, tset, add, remove, reset, update
+ at param ...
+ Arguments for the modifier function
*/
-#define ModifyConfigValue(varname, modifier, ...) \
- orxonox::ConfigValueContainer* container##varname##modify##modifier = this->getIdentifier()->getConfigValueContainer(#varname); \
- if (container##varname##modify##modifier) \
+#define ModifyConfigValueGeneric(object, variable, entryName, modifier, ...) \
+ if (orxonox::ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName)) \
{ \
- container##varname##modify##modifier->modifier(__VA_ARGS__); \
- container##varname##modify##modifier->getValue(&varname, this); \
+ container->modifier(__VA_ARGS__); \
+ container->getValue(variable, object); \
} \
else \
{ \
- COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+ COUT(2) << "Warning: Couln't modify config-value '" << entryName << "' in class '" \
+ << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl; \
}
+/** Modifies a runtime configurable value by using a modifier and some arguments.
+ If the container for the value doesn't yet exist, a warning is displayed.
+ Also, the @a varname argument will be modified and set to the current value.
+ at param varname
+ Variable name as C++ identifier. It will be used as entry name and as variable pointer
+ at param modifier
+ On of these functions: set, tset, add, remove, reset, update
+ at param ...
+ Arguments for the modifier function
+*/
+#define ModifyConfigValue(varname, modifier, ...) \
+ ModifyConfigValueGeneric(this, &varname, #varname, modifier, __VA_ARGS__)
+
#endif /* _ConfigValueIncludes_H__ */
Modified: code/trunk/src/libraries/core/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/ConsoleCommandCompilation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ConsoleCommandCompilation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,6 +34,7 @@
#include "util/Debug.h"
#include "util/ExprParser.h"
+#include "util/StringUtils.h"
#include "ConsoleCommand.h"
namespace orxonox
@@ -141,7 +142,7 @@
return "";
}
- std::string output = "";
+ std::string output;
while (file.good() && !file.eof())
{
std::string line;
@@ -157,16 +158,17 @@
float calculate(const std::string& calculation)
{
- ExprParser expr(calculation);
+ ExprParser expr;
+ expr.parse(calculation);
if (expr.getSuccess())
{
if (expr.getResult() == 42.0)
{
COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
}
- if (expr.getRemains() != "")
+ if (!expr.getRemains().empty())
{
- COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << "'" << std::endl;
+ COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
}
return static_cast<float>(expr.getResult());
}
Modified: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Core.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,6 +50,7 @@
#include "util/Clock.h"
#include "util/Debug.h"
#include "util/Exception.h"
+#include "util/Scope.h"
#include "util/SignalHandler.h"
#include "PathConfig.h"
#include "CommandExecutor.h"
@@ -77,90 +78,14 @@
SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
#ifdef ORXONOX_PLATFORM_WINDOWS
- SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one cpu/core (1, 2, 3, etc.). 0 turns it off (default)");
+ SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)");
#endif
- /**
- @brief
- Helper class for the Core singleton: we cannot derive
- Core from OrxonoxClass because we need to handle the Identifier
- destruction in the Core destructor.
- */
- class CoreConfiguration : public OrxonoxClass
- {
- public:
- CoreConfiguration()
- {
- }
-
- void initialise()
- {
- RegisterRootObject(CoreConfiguration);
- this->setConfigValues();
- }
-
- /**
- @brief Function to collect the SetConfigValue-macro calls.
- */
- void setConfigValues()
- {
-#ifdef ORXONOX_RELEASE
- const unsigned int defaultLevelLogFile = 3;
-#else
- const unsigned int defaultLevelLogFile = 4;
-#endif
- SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevelLogFile_, "softDebugLevelLogFile", "OutputHandler", defaultLevelLogFile)
- .description("The maximum level of debug output shown in the log file");
- OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
-
- SetConfigValue(language_, Language::getInstance().defaultLanguage_)
- .description("The language of the in game text")
- .callback(this, &CoreConfiguration::languageChanged);
- SetConfigValue(bInitializeRandomNumberGenerator_, true)
- .description("If true, all random actions are different each time you start the game")
- .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
- }
-
- /**
- @brief Callback function if the language has changed.
- */
- void languageChanged()
- {
- // Read the translation file after the language was configured
- Language::getInstance().readTranslatedLanguageFile();
- }
-
- /**
- @brief Sets the language in the config-file back to the default.
- */
- void resetLanguage()
- {
- ResetConfigValue(language_);
- }
-
- void initializeRandomNumberGenerator()
- {
- static bool bInitialized = false;
- if (!bInitialized && this->bInitializeRandomNumberGenerator_)
- {
- srand(static_cast<unsigned int>(time(0)));
- rand();
- bInitialized = true;
- }
- }
-
- int softDebugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler)
- std::string language_; //!< The language
- bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called
- };
-
-
Core::Core(const std::string& cmdLine)
// Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands)
: identifierDestroyer_(Identifier::destroyAllIdentifiers)
// Cleanup guard for external console commands that don't belong to an Identifier
, consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
- , configuration_(new CoreConfiguration()) // Don't yet create config values!
, bGraphicsLoaded_(false)
{
// Set the hard coded fixed paths
@@ -217,16 +142,17 @@
// Required as well for the config values
this->languageInstance_.reset(new Language());
+ // Do this soon after the ConfigFileManager has been created to open up the
+ // possibility to configure everything below here
+ ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);
+ this->setConfigValues();
+
// create persistent io console
this->ioConsole_.reset(new IOConsole());
// creates the class hierarchy for all classes with factories
Identifier::createClassHierarchy();
- // Do this soon after the ConfigFileManager has been created to open up the
- // possibility to configure everything below here
- this->configuration_->initialise();
-
// Load OGRE excluding the renderer and the render window
this->graphicsManager_.reset(new GraphicsManager(false));
@@ -244,8 +170,48 @@
*/
Core::~Core()
{
+ // Remove us from the object lists again to avoid problems when destroying them
+ this->unregisterObject();
}
+ //! Function to collect the SetConfigValue-macro calls.
+ void Core::setConfigValues()
+ {
+#ifdef ORXONOX_RELEASE
+ const unsigned int defaultLevelLogFile = 3;
+#else
+ const unsigned int defaultLevelLogFile = 4;
+#endif
+ setConfigValueGeneric(this, &this->softDebugLevelLogFile_, ConfigFileType::Settings, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
+ .description("The maximum level of debug output shown in the log file");
+ OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
+
+ SetConfigValue(language_, Language::getInstance().defaultLanguage_)
+ .description("The language of the in game text")
+ .callback(this, &Core::languageChanged);
+ SetConfigValue(bInitRandomNumberGenerator_, true)
+ .description("If true, all random actions are different each time you start the game")
+ .callback(this, &Core::initRandomNumberGenerator);
+ }
+
+ //! Callback function if the language has changed.
+ void Core::languageChanged()
+ {
+ // Read the translation file after the language was configured
+ Language::getInstance().readTranslatedLanguageFile();
+ }
+
+ void Core::initRandomNumberGenerator()
+ {
+ static bool bInitialized = false;
+ if (!bInitialized && this->bInitRandomNumberGenerator_)
+ {
+ srand(static_cast<unsigned int>(time(0)));
+ rand();
+ bInitialized = true;
+ }
+ }
+
void Core::loadGraphics()
{
// Any exception should trigger this, even in upgradeToGraphics (see its remarks)
@@ -295,23 +261,13 @@
GameMode::bShowsGraphics_s = false;
}
- /**
- @brief Returns the configured language.
- */
- /*static*/ const std::string& Core::getLanguage()
+ //! Sets the language in the config-file back to the default.
+ void Core::resetLanguage()
{
- return Core::getInstance().configuration_->language_;
+ ResetConfigValue(language_);
}
/**
- @brief Sets the language in the config-file back to the default.
- */
- /*static*/ void Core::resetLanguage()
- {
- Core::getInstance().configuration_->resetLanguage();
- }
-
- /**
@note
The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
(Object-oriented Graphics Rendering Engine)
@@ -359,29 +315,33 @@
void Core::preUpdate(const Clock& time)
{
- // singletons from other libraries
- ScopedSingletonManager::update<ScopeID::Root>(time);
+ // Update singletons before general ticking
+ ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
if (this->bGraphicsLoaded_)
{
- // process input events
- this->inputManager_->update(time);
- // process gui events
- this->guiManager_->update(time);
- // graphics singletons from other libraries
- ScopedSingletonManager::update<ScopeID::Graphics>(time);
+ // Process input events
+ this->inputManager_->preUpdate(time);
+ // Update GUI
+ this->guiManager_->preUpdate(time);
+ // Update singletons before general ticking
+ ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
}
- // process console text
- this->ioConsole_->update(time);
- // process thread commands
- this->tclThreadManager_->update(time);
+ // Process console events and status line
+ this->ioConsole_->preUpdate(time);
+ // Process thread commands
+ this->tclThreadManager_->preUpdate(time);
}
void Core::postUpdate(const Clock& time)
{
+ // Update singletons just before rendering
+ ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
if (this->bGraphicsLoaded_)
{
+ // Update singletons just before rendering
+ ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
// Render (doesn't throw)
- this->graphicsManager_->update(time);
+ this->graphicsManager_->postUpdate(time);
}
}
}
Modified: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Core.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,23 +33,21 @@
#include "CorePrereqs.h"
#include <cassert>
+#include <string>
#include <boost/scoped_ptr.hpp>
-#include "util/OutputHandler.h"
-#include "util/Scope.h"
#include "util/ScopeGuard.h"
#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
namespace orxonox
{
- class CoreConfiguration;
-
/**
@brief
The Core class is a singleton used to configure the program basics.
@remark
You should only create this singleton once because it destroys the identifiers!
*/
- class _CoreExport Core : public Singleton<Core>
+ class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
{
typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
friend class Singleton<Core>;
@@ -68,12 +66,17 @@
void setConfigValues();
- static const std::string& getLanguage();
- static void resetLanguage();
+ //! Returns the configured language.
+ const std::string& getLanguage()
+ { return this->language_; }
+ void resetLanguage();
private:
Core(const Core&); //!< Don't use (undefined symbol)
+ void languageChanged();
+ void initRandomNumberGenerator();
+
void preUpdate(const Clock& time);
void postUpdate(const Clock& time);
@@ -81,7 +84,7 @@
void unloadGraphics();
void setThreadAffinity(int limitToCPU);
-
+ // MANAGED SINGLETONS/OBJECTS
// Mind the order for the destruction!
scoped_ptr<PathConfig> pathConfig_;
scoped_ptr<DynLibManager> dynLibManager_;
@@ -91,18 +94,21 @@
scoped_ptr<ConfigFileManager> configFileManager_;
scoped_ptr<Language> languageInstance_;
scoped_ptr<IOConsole> ioConsole_;
- scoped_ptr<CoreConfiguration> configuration_;
scoped_ptr<TclBind> tclBind_;
scoped_ptr<TclThreadManager> tclThreadManager_;
+ scoped_ptr<Scope<ScopeID::Root> > rootScope_;
// graphical
scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE
scoped_ptr<InputManager> inputManager_; //!< Interface to OIS
scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI
- scoped_ptr<Scope<ScopeID::Root> > rootScope_;
scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
bool bGraphicsLoaded_;
- static Core* singletonPtr_s;
+ int softDebugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler)
+ std::string language_; //!< The language
+ bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
+
+ static Core* singletonPtr_s;
};
}
Modified: code/trunk/src/libraries/core/DynLib.cc
===================================================================
--- code/trunk/src/libraries/core/DynLib.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/DynLib.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -78,7 +78,7 @@
m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
- if( !m_hInst )
+ if (!m_hInst)
ThrowException(
General,
"Could not load dynamic library " + mName +
@@ -91,7 +91,7 @@
// Log library unload
COUT(4) << "Unloading module " << mName << std::endl;
- if( DYNLIB_UNLOAD( m_hInst ) )
+ if (DYNLIB_UNLOAD( m_hInst ))
{
ThrowException(
General,
@@ -131,7 +131,7 @@
#elif defined(ORXONOX_PLATFORM_APPLE)
return std::string(mac_errorBundle());
#else
- return std::string("");
+ return "";
#endif
}
Modified: code/trunk/src/libraries/core/Event.cc
===================================================================
--- code/trunk/src/libraries/core/Event.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Event.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -44,7 +44,7 @@
/**
@brief Processes an event (calls the set-function if the necessary conditions are met).
-
+
@param event The fired event
@param object The object whose state is affected by the event (only needed for debug output)
*/
@@ -52,7 +52,7 @@
{
if (this->bProcessingEvent_)
{
- COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
+ COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << std::endl;
return;
}
Modified: code/trunk/src/libraries/core/Event.h
===================================================================
--- code/trunk/src/libraries/core/Event.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Event.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,16 +49,16 @@
/**
@brief The EventState contains information about an event state.
-
+
An event state is a state of an object, which can be changed by events.
Event states are changed through functions. Possible functions headers for set event states are:
- memoryless state: function()
- boolean state: function(bool state)
- individual state: function(bool state, SomeClass originator)
-
+
Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes.
The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro.
-
+
The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some
statefunctions may be from child-classes.
*/
@@ -69,7 +69,7 @@
virtual ~EventState();
void process(const Event& event, BaseObject* object);
-
+
Functor* getFunctor() const
{ return this->statefunction_; }
Modified: code/trunk/src/libraries/core/EventIncludes.h
===================================================================
--- code/trunk/src/libraries/core/EventIncludes.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/EventIncludes.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,7 +35,7 @@
/**
@brief Defines a new event state (a state of the object which can be changed by events).
-
+
@param classname The name of this class
@param subclassname Usually BaseObject - if different, only instances of this class can send events to this object
@param statename The name (string) of this state
@@ -65,14 +65,14 @@
XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
- static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
- static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
+ static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
+ static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \
XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
-
+
/**
@brief Defines a new event name for a class. Named events can only have names which were defined with this macro.
-
+
@param classname The name of the class
@param name The name of the event
*/
@@ -81,8 +81,8 @@
/**
@brief This macro is needed to fire an event with this name. The event name must previously be declared with @ref CreateEventName.
-*/
+*/
#define FireEventName(classname, name) \
eventname##classname##name
-
+
#endif /* _EventIncludes_H__ */
Modified: code/trunk/src/libraries/core/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/Executor.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Executor.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -72,8 +72,7 @@
if (paramCount == 1)
{
// only one param: check if there are params given, otherwise try to use default values
- std::string temp = getStripped(params);
- if ((temp != "") && (temp.size() != 0))
+ if (!getStripped(params).empty())
{
param[0] = params;
this->functor_->evaluateParam(0, param[0]);
Modified: code/trunk/src/libraries/core/Executor.h
===================================================================
--- code/trunk/src/libraries/core/Executor.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Executor.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -62,8 +62,8 @@
} \
else if (paramCount == 1) \
{ \
- std::string temp = getStripped(params); \
- if ((temp != "") && (temp.size() != 0)) \
+ const std::string& temp = getStripped(params); \
+ if (!temp.empty()) \
{ \
COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
@@ -186,7 +186,7 @@
inline const std::string& getTypenameReturnvalue() const
{ return this->functor_->getTypenameReturnvalue(); }
- inline void setName(const std::string name)
+ inline void setName(const std::string& name)
{ this->name_ = name; }
inline const std::string& getName() const
{ return this->name_; }
Modified: code/trunk/src/libraries/core/Functor.h
===================================================================
--- code/trunk/src/libraries/core/Functor.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Functor.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,7 +34,6 @@
#include "util/Debug.h"
#include "util/MultiType.h"
-#include "util/StringUtils.h"
namespace orxonox
{
Modified: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GUIManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,6 +39,7 @@
#include <CEGUIMouseCursor.h>
#include <CEGUIResourceProvider.h>
#include <CEGUISystem.h>
+#include <CEGUIWindow.h>
#include <ogreceguirenderer/OgreCEGUIRenderer.h>
#include "SpecialConfig.h" // Configures the macro below
@@ -49,15 +50,22 @@
#endif
#include "util/Clock.h"
+#include "util/Convert.h"
#include "util/Debug.h"
#include "util/Exception.h"
#include "util/OrxAssert.h"
+#include "ConsoleCommand.h"
+#include "Core.h"
#include "LuaState.h"
#include "PathConfig.h"
#include "Resource.h"
namespace orxonox
{
+ static void key_esc()
+ { GUIManager::getInstance().keyESC(); }
+ SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
+
class CEGUILogger : public CEGUI::DefaultLogger
{
public:
@@ -84,6 +92,9 @@
GUIManager* GUIManager::singletonPtr_s = 0;
+ SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
+ SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
+
/**
@brief
Constructs the GUIManager by starting up CEGUI
@@ -100,6 +111,7 @@
: renderWindow_(renderWindow)
, resourceProvider_(0)
, camera_(NULL)
+ , bShowIngameGUI_(false)
{
using namespace CEGUI;
@@ -112,6 +124,9 @@
// setup scripting
luaState_.reset(new LuaState());
+ rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua");
+ // This is necessary to ensure that input events also use the right resource info when triggering lua functions
+ luaState_->setDefaultResourceInfo(this->rootFileInfo_);
scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState()));
// Create our own logger to specify the filepath
@@ -126,8 +141,7 @@
guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get()));
// Initialise the basic Lua code
- rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
- this->luaState_->doFile("InitialiseGUI.lua", "GUI", false);
+ this->luaState_->doFile("InitialiseGUI.lua");
// Align CEGUI mouse with OIS mouse
guiSystem_->injectMousePosition(mousePosition.first, mousePosition.second);
@@ -155,7 +169,7 @@
The elapsed time since the last call is given in the time value provided by the clock.
This time value is then used to provide a fluent animation of the GUI.
*/
- void GUIManager::update(const Clock& time)
+ void GUIManager::preUpdate(const Clock& time)
{
assert(guiSystem_);
guiSystem_->injectTimePulse(time.getDeltaTime());
@@ -202,11 +216,41 @@
The function executes the Lua function with the same name in case the GUIManager is ready.
For more details check out loadGUI_2.lua where the function presides.
*/
- void GUIManager::showGUI(const std::string& name)
+ /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor)
{
- this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_);
+ GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")");
}
+ /**
+ @brief
+ Hack-ish. Needed for GUIOverlay.
+ */
+ void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor)
+ {
+ this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
+ }
+
+ /**
+ @brief
+ Hides specified GUI.
+ @param name
+ The name of the GUI.
+ */
+ /*static*/ void GUIManager::hideGUI(const std::string& name)
+ {
+ GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
+ }
+
+ void GUIManager::keyESC()
+ {
+ this->executeCode("keyESC()");
+ }
+
+ void GUIManager::setBackground(const std::string& name)
+ {
+ this->executeCode("setBackground(\"" + name + "\")");
+ }
+
void GUIManager::keyPressed(const KeyEvent& evt)
{
guiSystem_->injectKeyDown(evt.getKeyCode());
@@ -303,4 +347,9 @@
return CEGUI::NoButton;
}
}
+
+ void GUIManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function)
+ {
+ window->subscribeScriptedEvent(event, function);
+ }
}
Modified: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GUIManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,6 +33,7 @@
#include "CorePrereqs.h"
#include <map>
+#include <set>
#include <string>
#include <CEGUIForwardRefs.h>
#include <boost/scoped_ptr.hpp>
@@ -42,8 +43,8 @@
#include "util/Singleton.h"
#include "input/InputHandler.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
class PlayerInfo; // Forward declaration
/**
@@ -57,17 +58,21 @@
Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
Those input events are then injected into CEGUI in Lua.
*/
- class _CoreExport GUIManager : public Singleton<GUIManager>, public InputHandler
- {
+ class _CoreExport GUIManager // tolua_export
+ : public Singleton<GUIManager>, public InputHandler
+ { // tolua_export
friend class Singleton<GUIManager>;
public:
GUIManager(Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen);
~GUIManager();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
- void showGUI(const std::string& name);
- void executeCode(const std::string& str);
+ static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
+ void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
+ static void hideGUI(const std::string& name);
+ void keyESC();
+ void setBackground(const std::string& name);
void setCamera(Ogre::Camera* camera);
Ogre::Camera* getCamera() { return this->camera_; }
@@ -79,9 +84,14 @@
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; }
+ // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
+ static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
+
private:
GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
+ void executeCode(const std::string& str);
+
// keyHandler functions
void keyPressed (const KeyEvent& evt);
void keyReleased(const KeyEvent& evt);
@@ -104,8 +114,9 @@
Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI
static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
+ bool bShowIngameGUI_;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _GUIManager_H__ */
Modified: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Game.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,6 +50,7 @@
#include "ConfigValueIncludes.h"
#include "GameMode.h"
#include "GameState.h"
+#include "GUIManager.h"
namespace orxonox
{
@@ -66,11 +67,7 @@
std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
Game* Game::singletonPtr_s = 0;
-
- /**
- @brief
- Represents one node of the game state tree.
- */
+ //! Represents one node of the game state tree.
struct GameStateTreeNode
{
std::string name_;
@@ -78,42 +75,6 @@
std::vector<shared_ptr<GameStateTreeNode> > children_;
};
-
- /**
- @brief
- Another helper class for the Game singleton: we cannot derive
- Game from OrxonoxClass because we need to handle the Identifier
- destruction in the Core destructor.
- */
- class GameConfiguration : public OrxonoxClass
- {
- public:
- GameConfiguration()
- {
- RegisterRootObject(GameConfiguration);
- this->setConfigValues();
- }
-
- void setConfigValues()
- {
- SetConfigValue(statisticsRefreshCycle_, 250000)
- .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
- SetConfigValue(statisticsAvgLength_, 1000000)
- .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
- SetConfigValue(fpsLimit_, 50)
- .description("Sets the desired framerate (0 for no limit).");
- }
-
- unsigned int statisticsRefreshCycle_;
- unsigned int statisticsAvgLength_;
- unsigned int fpsLimit_;
- };
-
-
- /**
- @brief
- Non-initialising constructor.
- */
Game::Game(const std::string& cmdLine)
// Destroy factories before the Core!
: gsFactoryDestroyer_(Game::GameStateFactory::getFactories(), &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
@@ -127,6 +88,15 @@
minimumSleepTime_ = 0/*us*/;
#endif
+ // reset statistics
+ this->statisticsStartTime_ = 0;
+ this->statisticsTickTimes_.clear();
+ this->periodTickTime_ = 0;
+ this->periodTime_ = 0;
+ this->avgFPS_ = 0.0f;
+ this->avgTickTime_ = 0.0f;
+ this->excessSleepTime_ = 0;
+
// Create an empty root state
this->declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
@@ -136,6 +106,10 @@
// Create the Core
this->core_.reset(new Core(cmdLine));
+ // Do this after the Core creation!
+ ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);
+ this->setConfigValues();
+
// After the core has been created, we can safely instantiate the GameStates that don't require graphics
for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
it != gameStateDeclarations_s.end(); ++it)
@@ -149,9 +123,6 @@
this->rootStateNode_->name_ = "emptyRootGameState";
this->loadedTopStateNode_ = this->rootStateNode_;
this->loadedStates_.push_back(this->getState(rootStateNode_->name_));
-
- // Do this after the Core creation!
- this->configuration_.reset(new GameConfiguration());
}
/**
@@ -160,8 +131,20 @@
*/
Game::~Game()
{
+ // Remove us from the object lists again to avoid problems when destroying them
+ this->unregisterObject();
}
+ void Game::setConfigValues()
+ {
+ SetConfigValue(statisticsRefreshCycle_, 250000)
+ .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+ SetConfigValue(statisticsAvgLength_, 1000000)
+ .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+ SetConfigValue(fpsLimit_, 50)
+ .description("Sets the desired frame rate (0 for no limit).");
+ }
+
/**
@brief
Main loop of the orxonox game.
@@ -175,15 +158,6 @@
if (this->requestedStateNodes_.empty())
COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
- // reset statistics
- this->statisticsStartTime_ = 0;
- this->statisticsTickTimes_.clear();
- this->periodTickTime_ = 0;
- this->periodTime_ = 0;
- this->avgFPS_ = 0.0f;
- this->avgTickTime_ = 0.0f;
- this->excessSleepTime_ = 0;
-
// START GAME
// first delta time should be about 0 seconds
this->gameClock_->capture();
@@ -203,7 +177,7 @@
// Update the GameState stack if required
this->updateGameStateStack();
- // Core preUpdate (doesn't throw)
+ // Core preUpdate
try
{ this->core_->preUpdate(*this->gameClock_); }
catch (...)
@@ -217,7 +191,7 @@
// Update the GameStates bottom up in the stack
this->updateGameStates();
- // Core postUpdate (doesn't throw)
+ // Core postUpdate
try
{ this->core_->postUpdate(*this->gameClock_); }
catch (...)
@@ -231,7 +205,7 @@
// Evaluate statistics
this->updateStatistics();
- // Limit framerate
+ // Limit frame rate
this->updateFPSLimiter();
}
@@ -311,11 +285,11 @@
uint64_t currentRealTime = gameClock_->getRealMicroseconds();
this->statisticsTickTimes_.back().tickLength += currentRealTime - currentTime;
this->periodTickTime_ += currentRealTime - currentTime;
- if (this->periodTime_ > this->configuration_->statisticsRefreshCycle_)
+ if (this->periodTime_ > this->statisticsRefreshCycle_)
{
std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
assert(it != this->statisticsTickTimes_.end());
- int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
+ int64_t lastTime = currentTime - this->statisticsAvgLength_;
if (static_cast<int64_t>(it->tickTime) < lastTime)
{
do
@@ -329,17 +303,17 @@
}
uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
- this->avgFPS_ = static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
+ // Why minus 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too low
+ this->avgFPS_ = -1 + static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
- this->periodTime_ -= this->configuration_->statisticsRefreshCycle_;
+ this->periodTime_ -= this->statisticsRefreshCycle_;
}
}
void Game::updateFPSLimiter()
{
- // Why configuration_->fpsLimit_ - 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too high
- uint32_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / (configuration_->fpsLimit_ - 1));
+ uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
uint64_t currentRealTime = gameClock_->getRealMicroseconds();
while (currentRealTime < nextTime - minimumSleepTime_)
{
@@ -583,7 +557,7 @@
graphicsUnloader.Dismiss();
shared_ptr<GameState> state = this->getState(name);
- state->activate();
+ state->activateInternal();
if (!this->loadedStates_.empty())
this->loadedStates_.back()->activity_.topState = false;
this->loadedStates_.push_back(state);
@@ -602,7 +576,7 @@
this->loadedStates_.pop_back();
if (!this->loadedStates_.empty())
this->loadedStates_.back()->activity_.topState = true;
- state->deactivate();
+ state->deactivateInternal();
}
catch (...)
{
Modified: code/trunk/src/libraries/core/Game.h
===================================================================
--- code/trunk/src/libraries/core/Game.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Game.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,6 +49,7 @@
#include "util/Debug.h"
#include "util/ScopeGuard.h"
#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
/**
@def
@@ -57,10 +58,10 @@
*/
#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
-
+// tolua_begin
namespace orxonox
{
- class GameConfiguration;
+// tolua_end
//! Helper object required before GameStates are being constructed
struct GameStateInfo
@@ -77,8 +78,11 @@
@remark
You should only create this singleton once because it owns the Core class! (see remark there)
*/
- class _CoreExport Game : public Singleton<Game>
- {
+// tolua_begin
+ class _CoreExport Game
+// tolua_end
+ : public Singleton<Game>, public OrxonoxClass
+ { // tolua_export
friend class Singleton<Game>;
typedef std::vector<shared_ptr<GameState> > GameStateVector;
typedef std::map<std::string, shared_ptr<GameState> > GameStateMap;
@@ -88,16 +92,20 @@
Game(const std::string& cmdLine);
~Game();
+ void setConfigValues();
+
void setStateHierarchy(const std::string& str);
shared_ptr<GameState> getState(const std::string& name);
void run();
void stop();
- void requestState(const std::string& name);
- void requestStates(const std::string& names);
- void popState();
+ static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
+ void requestState(const std::string& name); //tolua_export
+ void requestStates(const std::string& names); //tolua_export
+ void popState(); //tolua_export
+
const Clock& getGameClock() { return *this->gameClock_; }
float getAvgTickTime() { return this->avgTickTime_; }
@@ -159,7 +167,6 @@
scoped_ptr<Clock> gameClock_;
scoped_ptr<Core> core_;
ObjScopeGuard gsFactoryDestroyer_;
- scoped_ptr<GameConfiguration> configuration_;
GameStateMap constructedStates_;
GameStateVector loadedStates_;
@@ -180,9 +187,14 @@
int excessSleepTime_;
unsigned int minimumSleepTime_;
+ // config values
+ unsigned int statisticsRefreshCycle_;
+ unsigned int statisticsAvgLength_;
+ unsigned int fpsLimit_;
+
static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
static Game* singletonPtr_s; //!< Pointer to the Singleton
- };
+ }; //tolua_export
template <class T>
/*static*/ bool Game::declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bGraphicsMode)
@@ -208,6 +220,6 @@
// just a required dummy return value
return true;
}
-}
+} //tolua_export
#endif /* _Game_H__ */
Modified: code/trunk/src/libraries/core/GameMode.h
===================================================================
--- code/trunk/src/libraries/core/GameMode.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GameMode.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,19 +36,23 @@
#include "CorePrereqs.h"
+// tolua_begin
namespace orxonox
{
class _CoreExport GameMode
{
+// tolua_end
friend class Core;
public:
+// tolua_begin
static bool showsGraphics() { return bShowsGraphics_s; }
static bool playsSound() { return bPlaysSound_s; }
static bool hasServer() { return bHasServer_s; }
static bool isClient() { return bIsClient_s; }
static bool isStandalone() { return bIsStandalone_s; }
static bool isMaster() { return bIsMaster_s; }
+// tolua_end
static void setPlaysSound (bool val) { bPlaysSound_s = val; }
static void setHasServer (bool val) { bHasServer_s = val; updateIsMaster(); }
@@ -71,7 +75,7 @@
static bool bIsClient_s;
static bool bIsStandalone_s;
static bool bIsMaster_s;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _GameMode_H__ */
Modified: code/trunk/src/libraries/core/GameState.cc
===================================================================
--- code/trunk/src/libraries/core/GameState.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GameState.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -82,7 +82,7 @@
{
this->activity_.active = false;
this->activity_.deactivating = true;
- this->activate();
+ this->deactivate();
this->activity_.deactivating = false;
this->activity_.suspended = false;
this->activity_.updating = false;
Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GraphicsManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -99,17 +99,17 @@
this->loadOgreRoot();
// At first, add the root paths of the data directories as resource locations
- Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem", "dataRoot", false);
+ Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem");
// Load resources
- resources_.reset(new XMLFile("resources.oxr", "dataRoot"));
+ resources_.reset(new XMLFile("DefaultResources.oxr"));
resources_->setLuaSupport(false);
Loader::open(resources_.get());
// Only for development runs
if (PathConfig::isDevelopmentRun())
{
- Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem", "externalDataRoot", false);
- extResources_.reset(new XMLFile("resources.oxr", "externalDataRoot"));
+ Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem");
+ extResources_.reset(new XMLFile("resources.oxr"));
extResources_->setLuaSupport(false);
Loader::open(extResources_.get());
}
@@ -207,7 +207,7 @@
// Add file to the memory archive
shared_array<char> data(new char[output.str().size()]);
// Debug optimisations
- const std::string outputStr = output.str();
+ const std::string& outputStr = output.str();
char* rawData = data.get();
for (unsigned i = 0; i < outputStr.size(); ++i)
rawData[i] = outputStr[i];
@@ -237,12 +237,12 @@
{
COUT(3) << "Setting up Ogre..." << std::endl;
- if (ogreConfigFile_ == "")
+ if (ogreConfigFile_.empty())
{
COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
}
- if (ogreLogFile_ == "")
+ if (ogreLogFile_.empty())
{
COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
@@ -284,8 +284,8 @@
void GraphicsManager::loadOgrePlugins()
{
// just to make sure the next statement doesn't segfault
- if (ogrePluginsDirectory_ == "")
- ogrePluginsDirectory_ = ".";
+ if (ogrePluginsDirectory_.empty())
+ ogrePluginsDirectory_ = '.';
boost::filesystem::path folder(ogrePluginsDirectory_);
// Do some SubString magic to get the comma separated list of plugins
@@ -340,7 +340,7 @@
as shown that there is probably only one FrameListener that doesn't even
need the time. So we shouldn't run into problems.
*/
- void GraphicsManager::update(const Clock& time)
+ void GraphicsManager::postUpdate(const Clock& time)
{
Ogre::FrameEvent evt;
evt.timeSinceLastFrame = time.getDeltaTime();
@@ -394,22 +394,33 @@
Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
{
int orxonoxLevel;
- switch (lml)
+ std::string introduction;
+ // Do not show caught OGRE exceptions in front
+ if (message.find("EXCEPTION") != std::string::npos)
{
- case Ogre::LML_TRIVIAL:
- orxonoxLevel = this->ogreLogLevelTrivial_;
- break;
- case Ogre::LML_NORMAL:
- orxonoxLevel = this->ogreLogLevelNormal_;
- break;
- case Ogre::LML_CRITICAL:
- orxonoxLevel = this->ogreLogLevelCritical_;
- break;
- default:
- orxonoxLevel = 0;
+ orxonoxLevel = OutputLevel::Debug;
+ introduction = "Ogre, caught exception: ";
}
+ else
+ {
+ switch (lml)
+ {
+ case Ogre::LML_TRIVIAL:
+ orxonoxLevel = this->ogreLogLevelTrivial_;
+ break;
+ case Ogre::LML_NORMAL:
+ orxonoxLevel = this->ogreLogLevelNormal_;
+ break;
+ case Ogre::LML_CRITICAL:
+ orxonoxLevel = this->ogreLogLevelCritical_;
+ break;
+ default:
+ orxonoxLevel = 0;
+ }
+ introduction = "Ogre: ";
+ }
OutputHandler::getOutStream(orxonoxLevel)
- << "Ogre: " << message << std::endl;
+ << introduction << message << std::endl;
}
size_t GraphicsManager::getRenderWindowHandle()
@@ -439,7 +450,6 @@
void GraphicsManager::printScreen()
{
assert(this->renderWindow_);
-
- this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".jpg");
+ this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".png");
}
}
Modified: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/GraphicsManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -62,7 +62,7 @@
void setConfigValues();
- void update(const Clock& time);
+ void postUpdate(const Clock& time);
Ogre::Viewport* getViewport() { return this->viewport_; }
Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
Modified: code/trunk/src/libraries/core/IOConsole.cc
===================================================================
--- code/trunk/src/libraries/core/IOConsole.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/IOConsole.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -31,6 +31,9 @@
#include <iomanip>
#include <iostream>
+
+#include "util/Clock.h"
+#include "util/Math.h"
#include "core/Game.h"
#include "core/input/InputBuffer.h"
@@ -41,30 +44,6 @@
{
IOConsole* IOConsole::singletonPtr_s = NULL;
- int IOConsole::extractLogLevel(std::string* text)
- {
- // Handle line colouring by inspecting the first letter
- char level = 0;
- if (!text->empty())
- {
- level = (*text)[0];
- if (level == -1 || level >= 1 && level <= 6)
- {
- *text = text->substr(1);
- if (level != -1)
- return level;
- }
- }
- return 0;
- }
-
- inline bool IOConsole::willPrintStatusLines()
- {
- return !this->statusLineWidths_.empty()
- && this->terminalWidth_ >= this->statusLineMaxWidth_
- && this->terminalHeight_ >= (this->minOutputLines_ + this->statusLineWidths_.size());
- }
-
// ###############################
// ### ShellListener methods ###
// ###############################
@@ -77,24 +56,10 @@
// is already in std::cout when we start the IOConsole
}
- //! Called if the text in the input-line has changed
- void IOConsole::inputChanged()
- {
- this->printInputLine();
- this->cout_.flush();
- }
-
- //! Called if the position of the cursor in the input-line has changed
- void IOConsole::cursorChanged()
- {
- this->printInputLine();
- this->cout_.flush();
- }
-
//! Called if a command is about to be executed
void IOConsole::executed()
{
- this->shell_->addOutputLine(this->promptString_ + this->shell_->getInput());
+ this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
}
//! Called if the console gets closed
@@ -125,12 +90,12 @@
}
IOConsole::IOConsole()
- : shell_(new Shell("IOConsole", false, true))
+ : shell_(new Shell("IOConsole", false))
, buffer_(shell_->getInputBuffer())
, cout_(std::cout.rdbuf())
+ , promptString_("orxonox # ")
, bStatusPrinted_(false)
- , promptString_("orxonox # ")
- , originalTerminalSettings_(new termios())
+ , originalTerminalSettings_(0)
{
this->setTerminalMode();
this->shell_->registerListener(this);
@@ -150,13 +115,15 @@
std::cout.rdbuf(this->origCout_.rdbuf());
// Make sure we make way for the status lines
- this->update(Game::getInstance().getGameClock());
+ this->preUpdate(Game::getInstance().getGameClock());
}
IOConsole::~IOConsole()
{
- // Empty all buffers
- this->update(Game::getInstance().getGameClock());
+ // Process output written to std::cout in the meantime
+ std::cout.flush();
+ if (!this->origCout_.str().empty())
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
// Erase input and status lines
this->cout_ << "\033[1G\033[J";
// Move cursor to the bottom
@@ -165,7 +132,6 @@
this->cout_ << "\033[" << this->statusLineWidths_.size() << 'T';
resetTerminalMode();
- delete this->originalTerminalSettings_;
this->shell_->destroy();
// Restore this->cout_ redirection
@@ -174,7 +140,7 @@
OutputHandler::getInstance().enableCout();
}
- void IOConsole::update(const Clock& time)
+ void IOConsole::preUpdate(const Clock& time)
{
unsigned char c;
std::string escapeSequence;
@@ -283,7 +249,7 @@
this->bStatusPrinted_ = true;
}
- // We always assume that the cursor is on the inputline.
+ // We always assume that the cursor is on the input line.
// But we cannot always be sure about that, esp. if we scroll the console
this->cout_ << "\033[" << this->statusLineWidths_.size() << 'B';
this->cout_ << "\033[" << this->statusLineWidths_.size() << 'A';
@@ -295,35 +261,33 @@
this->cout_.flush();
// Process output written to std::cout
+ std::cout.flush();
if (!this->origCout_.str().empty())
{
- this->shell_->addOutputLine(this->origCout_.str());
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
this->origCout_.str("");
}
}
- void IOConsole::printLogText(const std::string& text)
+ void IOConsole::printOutputLine(const std::string& text, Shell::LineType type)
{
- std::string output = text;
- /*int level =*/ this->extractLogLevel(&output);
-
/*
// Colour line
- switch (level)
+ switch (type)
{
- case -1: this->cout_ << "\033[37m"; break;
- case 1: this->cout_ << "\033[91m"; break;
- case 2: this->cout_ << "\033[31m"; break;
- case 3: this->cout_ << "\033[34m"; break;
- case 4: this->cout_ << "\033[36m"; break;
- case 5: this->cout_ << "\033[35m"; break;
- case 6: this->cout_ << "\033[37m"; break;
+ case Shell::None: this->cout_ << "\033[37m"; break;
+ case Shell::Error: this->cout_ << "\033[91m"; break;
+ case Shell::Warning: this->cout_ << "\033[31m"; break;
+ case Shell::Info: this->cout_ << "\033[34m"; break;
+ case Shell::Debug: this->cout_ << "\033[36m"; break;
+ case Shell::Verbose: this->cout_ << "\033[35m"; break;
+ case Shell::Ultra: this->cout_ << "\033[37m"; break;
default: break;
}
*/
// Print output line
- this->cout_ << output;
+ this->cout_ << text;
// Reset colour to white
// this->cout_ << "\033[37m";
@@ -342,7 +306,7 @@
// Restore cursor position and move it to the right
this->cout_ << "\033[u";
if (this->buffer_->getCursorPosition() > 0)
- this->cout_ << "\033[" << this->buffer_->getCursorPosition() << "C";
+ this->cout_ << "\033[" << this->buffer_->getCursorPosition() << 'C';
}
void IOConsole::printStatusLines()
@@ -366,6 +330,7 @@
void IOConsole::setTerminalMode()
{
termios new_settings;
+ this->originalTerminalSettings_ = new termios();
tcgetattr(0, this->originalTerminalSettings_);
new_settings = *this->originalTerminalSettings_;
@@ -374,11 +339,17 @@
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VMIN] = 0;
tcsetattr(0, TCSANOW, &new_settings);
+ atexit(&IOConsole::resetTerminalMode);
}
- void IOConsole::resetTerminalMode()
+ /*static*/ void IOConsole::resetTerminalMode()
{
- tcsetattr(0, TCSANOW, IOConsole::originalTerminalSettings_);
+ if(IOConsole::singletonPtr_s && IOConsole::singletonPtr_s->originalTerminalSettings_)
+ {
+ tcsetattr(0, TCSANOW, IOConsole::singletonPtr_s->originalTerminalSettings_);
+ delete IOConsole::singletonPtr_s->originalTerminalSettings_;
+ IOConsole::singletonPtr_s->originalTerminalSettings_ = 0;
+ }
}
void IOConsole::getTerminalSize()
@@ -410,6 +381,13 @@
this->terminalHeight_ = 24;
}
+ inline bool IOConsole::willPrintStatusLines()
+ {
+ return !this->statusLineWidths_.empty()
+ && this->terminalWidth_ >= this->statusLineMaxWidth_
+ && this->terminalHeight_ >= this->minOutputLines_ + (int)this->statusLineWidths_.size();
+ }
+
// ###############################
// ### ShellListener methods ###
// ###############################
@@ -422,7 +400,7 @@
// Erase the line
this->cout_ << "\033[K";
// Reprint the last output line
- this->printLogText(*(this->shell_->getNewestLineIterator()));
+ this->printOutputLine(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second);
// Restore cursor
this->cout_ << "\033[u";
this->cout_.flush();
@@ -431,7 +409,7 @@
//! Called if a new output-line was added
void IOConsole::lineAdded()
{
- int newLines = this->shell_->getNewestLineIterator()->size() / this->terminalWidth_ + 1;
+ int newLines = this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_ + 1;
// Create new lines by scrolling the screen
this->cout_ << "\033[" << newLines << 'S';
// Move cursor to the beginning of the new (last) output line
@@ -440,7 +418,10 @@
this->cout_ << "\033[J";
// Print the new output lines
for (int i = 0; i < newLines; ++i)
- this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
+ {
+ Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+ this->printOutputLine(it->first.substr(i*this->terminalWidth_, this->terminalWidth_), it->second);
+ }
// Move cursor down
this->cout_ << "\033[1B\033[1G";
// Print status and input lines
@@ -448,6 +429,20 @@
this->printStatusLines();
this->cout_.flush();
}
+
+ //! Called if the text in the input-line has changed
+ void IOConsole::inputChanged()
+ {
+ this->printInputLine();
+ this->cout_.flush();
+ }
+
+ //! Called if the position of the cursor in the input-line has changed
+ void IOConsole::cursorChanged()
+ {
+ this->printInputLine();
+ this->cout_.flush();
+ }
}
#elif defined(ORXONOX_PLATFORM_WINDOWS)
@@ -455,107 +450,349 @@
// ### Windows Implementation ###
// ##################################
+#include <windows.h>
+
namespace orxonox
{
+ //! Redirects std::cout, creates the corresponding Shell and changes the terminal mode
IOConsole::IOConsole()
- : shell_(new Shell("IOConsole", false, true))
+ : shell_(new Shell("IOConsole", false))
, buffer_(shell_->getInputBuffer())
, cout_(std::cout.rdbuf())
- , bStatusPrinted_(false)
, promptString_("orxonox # ")
+ , inputLineHeight_(1)
+ , statusLines_(1)
+ , lastOutputLineHeight_(0)
{
+ // Disable standard this->cout_ logging
+ OutputHandler::getInstance().disableCout();
+ // Redirect std::cout to an ostringstream
+ // (Other part is in the initialiser list)
+ std::cout.rdbuf(this->origCout_.rdbuf());
+
+ this->setTerminalMode();
+ CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
+ GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
+ this->terminalWidth_ = screenBufferInfo.dwSize.X;
+ this->terminalHeight_ = screenBufferInfo.dwSize.Y;
+ // Determines where we are in respect to output already written with std::cout
+ this->inputLineRow_ = screenBufferInfo.dwCursorPosition.Y;
/*
- this->setTerminalMode();
- this->shell_->registerListener(this);
+ this->lastTerminalWidth_ = this->terminalWidth_;
+ this->lastTerminalHeight_ = this->terminalHeight_;
+*/
- // Manually set the widths of the individual status lines
- this->statusLineWidths_.push_back(29);
- this->statusLineMaxWidth_ = 29;
+ // Cursor already at the end of the screen buffer?
+ // (assuming the current input line height is 1)
+ if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
+ SetConsoleCursorPosition(this->stdOutHandle_, makeCOORD(0, this->terminalHeight_ - this->statusLines_));
- this->getTerminalSize();
- this->lastTerminalWidth_ = this->terminalWidth_;
- this->lastTerminalHeight_ = this->terminalHeight_;
+ // Prevent input line from overflowing
+ int maxInputLength = (this->terminalHeight_ - this->statusLines_) * this->terminalWidth_ - 1 - this->promptString_.size();
+ // Consider that the echo of a command might include the command plus some other characters (assumed max 80)
+ // Also put a minimum so the config file parser is not overwhelmed with the command history
+ this->buffer_->setMaxLength(std::min(8192, (maxInputLength - 80) / 2));
- // Disable standard this->cout_ logging
- OutputHandler::getInstance().disableCout();
-*/
+ // Print input and status line and position cursor
+ this->inputChanged();
+ this->cursorChanged();
+ this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
+ this->preUpdate(Game::getInstance().getGameClock());
+
+ this->shell_->registerListener(this);
}
+ //! Resets std::cout redirection and restores the terminal mode
IOConsole::~IOConsole()
{
-/*
- resetTerminalMode();
- this->shell_->destroy();
+ // Process output written to std::cout in the meantime
+ std::cout.flush();
+ if (!this->origCout_.str().empty())
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->shell_->unregisterListener(this);
+
+ // Erase input and status lines
+ COORD pos = {0, this->inputLineRow_};
+ this->writeText(std::string((this->inputLineHeight_ + this->statusLines_) * this->terminalWidth_, ' '), pos);
+ // Move cursor to the beginning of the line
+ SetConsoleCursorPosition(stdOutHandle_, pos);
+
+ // Restore this->cout_ redirection
+ std::cout.rdbuf(this->cout_.rdbuf());
// Enable standard this->cout_ logging again
OutputHandler::getInstance().enableCout();
-*/
+
+ resetTerminalMode();
+ this->shell_->destroy();
}
- void IOConsole::update(const Clock& time)
+ //! Processes the pending input key strokes, refreshes the status lines and handles std::cout (redirected)
+ void IOConsole::preUpdate(const Clock& time)
{
-/*
- unsigned char c = 0;
- while (std::cin.good())
+ // Process input
+ while (true)
{
- c = std::cin.get();
- if (std::cin.bad())
+ DWORD count;
+ INPUT_RECORD inrec;
+ PeekConsoleInput(this->stdInHandle_, &inrec, 1, &count);
+ if (count == 0)
break;
+ ReadConsoleInput(this->stdInHandle_, &inrec, 1, &count);
+ if (inrec.EventType == KEY_EVENT && inrec.Event.KeyEvent.bKeyDown)
+ {
+ // Process keyboard modifiers (Ctrl, Alt and Shift)
+ DWORD modifiersIn = inrec.Event.KeyEvent.dwControlKeyState;
+ int modifiersOut = 0;
+ if ((modifiersIn & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) != 0)
+ modifiersOut |= KeyboardModifier::Alt;
+ if ((modifiersIn & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0)
+ modifiersOut |= KeyboardModifier::Ctrl;
+ if ((modifiersIn & SHIFT_PRESSED) != 0)
+ modifiersOut |= KeyboardModifier::Shift;
+
+ // ASCII character (0 for special keys)
+ char asciiChar = inrec.Event.KeyEvent.uChar.AsciiChar;
+
+ // Process special keys and if not found, use Key::A as dummy (InputBuffer uses the ASCII text anyway)
+ switch (inrec.Event.KeyEvent.wVirtualKeyCode)
+ {
+ case VK_BACK: this->buffer_->buttonPressed(KeyEvent(KeyCode::Back, asciiChar, modifiersOut)); break;
+ case VK_TAB: this->buffer_->buttonPressed(KeyEvent(KeyCode::Tab, asciiChar, modifiersOut)); break;
+ case VK_RETURN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Return, asciiChar, modifiersOut)); break;
+ case VK_PAUSE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Pause, asciiChar, modifiersOut)); break;
+ case VK_ESCAPE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, asciiChar, modifiersOut)); break;
+ case VK_SPACE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Space, asciiChar, modifiersOut)); break;
+ case VK_PRIOR: this->buffer_->buttonPressed(KeyEvent(KeyCode::PageUp, asciiChar, modifiersOut)); break;
+ case VK_NEXT: this->buffer_->buttonPressed(KeyEvent(KeyCode::PageDown, asciiChar, modifiersOut)); break;
+ case VK_END: this->buffer_->buttonPressed(KeyEvent(KeyCode::End, asciiChar, modifiersOut)); break;
+ case VK_HOME: this->buffer_->buttonPressed(KeyEvent(KeyCode::Home, asciiChar, modifiersOut)); break;
+ case VK_LEFT: this->buffer_->buttonPressed(KeyEvent(KeyCode::Left, asciiChar, modifiersOut)); break;
+ case VK_UP: this->buffer_->buttonPressed(KeyEvent(KeyCode::Up, asciiChar, modifiersOut)); break;
+ case VK_RIGHT: this->buffer_->buttonPressed(KeyEvent(KeyCode::Right, asciiChar, modifiersOut)); break;
+ case VK_DOWN: this->buffer_->buttonPressed(KeyEvent(KeyCode::Down, asciiChar, modifiersOut)); break;
+ case VK_INSERT: this->buffer_->buttonPressed(KeyEvent(KeyCode::Insert, asciiChar, modifiersOut)); break;
+ case VK_DELETE: this->buffer_->buttonPressed(KeyEvent(KeyCode::Delete, asciiChar, modifiersOut)); break;
+ default: this->buffer_->buttonPressed(KeyEvent(KeyCode::A, asciiChar, modifiersOut));
+ }
+ }
}
- // Reset error flags in std::cin
- std::cin.clear();
- // Determine terminal width and height
+ // TODO: Respect screen buffer size changes
+/*
+ // The user can manually adjust the screen buffer size on Windows
+ // And we don't want to screw the console because of that
this->lastTerminalWidth_ = this->terminalWidth_;
this->lastTerminalHeight_ = this->terminalHeight_;
- this->getTerminalSize();
+ this->getTerminalSize(); // Also sets this->inputLineRow_ according to the cursor position
+ // Is there still enough space below the cursor for the status line(s)?
+ if (this->inputLineRow_ >= this->terminalHeight_ - this->statusLines_)
+ this->moveCursor(0, -this->inputLineRow_ + this->terminalHeight_ - this->statusLines_ - 1);
*/
+
+ // Refresh status line 5 times per second
+ if (time.getMicroseconds() > this->lastRefreshTime_ + 1000000)
+ {
+ this->printStatusLines();
+ this->lastRefreshTime_ = time.getMicroseconds();
+ }
+
+ // Process output written to std::cout
+ std::cout.flush();
+ if (!this->origCout_.str().empty())
+ {
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->origCout_.str("");
+ }
}
- void IOConsole::printLogText(const std::string& text)
+ //! Prints output text. Similar to writeText, but sets the colour according to the output level
+ void IOConsole::printOutputLine(const std::string& text, Shell::LineType type, const COORD& pos)
{
- }
+ // Colour line
+ WORD colour = 0;
+ switch (type)
+ {
+ case Shell::Error: colour = FOREGROUND_INTENSITY | FOREGROUND_RED; break;
+ case Shell::Warning: colour = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED; break;
+ case Shell::Info:
+ case Shell::Debug:
+ case Shell::Verbose:
+ case Shell::Ultra: colour = FOREGROUND_INTENSITY ; break;
+ case Shell::Command: colour = FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+ case Shell::Hint: colour = FOREGROUND_GREEN | FOREGROUND_RED ; break;
+ default: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
+ }
- void IOConsole::printInputLine()
- {
+ // Print output line
+ this->writeText(text, pos, colour);
}
+ //! Prints all status lines with current content
void IOConsole::printStatusLines()
{
-/*
- if (this->willPrintStatusLines())
- {
- this->bStatusPrinted_ = true;
- }
- else
- this->bStatusPrinted_ = false;
-*/
+ // Prepare text to be written
+ std::ostringstream oss;
+ oss << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
+ oss << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+ // Clear rest of the line by inserting spaces
+ oss << std::string(this->terminalWidth_ - oss.str().size(), ' ');
+ this->writeText(oss.str(), makeCOORD(0, this->inputLineRow_ + this->inputLineHeight_), FOREGROUND_GREEN);
}
+ //! Changes the console parameters for unbuffered input
void IOConsole::setTerminalMode()
{
+ // Set the console mode to no-echo, raw input, and no window or mouse events
+ this->stdOutHandle_ = GetStdHandle(STD_OUTPUT_HANDLE);
+ this->stdInHandle_ = GetStdHandle(STD_INPUT_HANDLE);
+ if (this->stdInHandle_ == INVALID_HANDLE_VALUE
+ || !GetConsoleMode(this->stdInHandle_, &this->originalTerminalSettings_)
+ || !SetConsoleMode(this->stdInHandle_, 0))
+ {
+ COUT(1) << "Error: Could not set Windows console settings" << std::endl;
+ return;
+ }
+ FlushConsoleInputBuffer(this->stdInHandle_);
}
+ //! Restores the console parameters
void IOConsole::resetTerminalMode()
{
+ SetConsoleMode(this->stdInHandle_, this->originalTerminalSettings_);
}
+ //! Sets this->terminalWidth_ and this->terminalHeight_
void IOConsole::getTerminalSize()
{
+ CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
+ GetConsoleScreenBufferInfo(this->stdOutHandle_, &screenBufferInfo);
+ this->terminalWidth_ = screenBufferInfo.dwSize.X;
+ this->terminalHeight_ = screenBufferInfo.dwSize.Y;
}
+ //! Writes arbitrary text to the console with a certain colour and screen buffer position
+ void IOConsole::writeText(const std::string& text, const COORD& coord, WORD attributes)
+ {
+ DWORD count;
+ WriteConsoleOutputCharacter(stdOutHandle_, text.c_str(), text.size(), coord, &count);
+ FillConsoleOutputAttribute(stdOutHandle_, attributes, text.size(), coord, &count);
+ }
+
+ /** Scrolls the console screen buffer to create empty lines above the input line.
+ @details
+ If the input and status lines are already at the bottom of the screen buffer
+ the whole output gets scrolled up. In the other case the input and status
+ lines get scrolled down.
+ In any case the status and input lines get scrolled down as far as possible.
+ @param lines
+ Number of lines to be inserted. Behavior for negative values is undefined.
+ */
+ void IOConsole::createNewOutputLines(int lines)
+ {
+ CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+ // Lines to scroll input/status down (if possible)
+ int linesDown = clamp(terminalHeight_ - inputLineRow_ - inputLineHeight_ - statusLines_, 0, lines);
+ if (linesDown > 0)
+ {
+ // Scroll input and status lines down
+ SMALL_RECT oldRect = {0, this->inputLineRow_,
+ this->terminalWidth_ - 1, this->inputLineRow_ + this->inputLineHeight_ + this->statusLines_ - 1};
+ this->inputLineRow_ += linesDown;
+ ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, this->inputLineRow_), &fillChar);
+ // Move cursor down to the new bottom so the user can see the status lines
+ COORD pos = {0, this->inputLineRow_ + this->inputLineHeight_ - 1 + this->statusLines_};
+ SetConsoleCursorPosition(stdOutHandle_, pos);
+ // Get cursor back to the right position
+ this->cursorChanged();
+ }
+ // Check how many lines we still have to scroll up the output
+ if (lines - linesDown > 0)
+ {
+ // Scroll output up
+ SMALL_RECT oldRect = {0, lines - linesDown, this->terminalWidth_ - 1, this->inputLineRow_ - 1};
+ ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, 0), &fillChar);
+ }
+ }
+
// ###############################
// ### ShellListener methods ###
// ###############################
+ //! Called if the text in the input line has changed
+ void IOConsole::inputChanged()
+ {
+ int newInputLineLength = this->promptString_.size() + this->shell_->getInput().size();
+ int newInputLineHeight = 1 + newInputLineLength / this->terminalWidth_;
+ int newLines = newInputLineHeight - this->inputLineHeight_;
+ if (newLines > 0)
+ {
+ // Abuse this function to scroll the console
+ this->createNewOutputLines(newLines);
+ // Either Compensate for side effects (input/status lines scrolled down)
+ // or we have to do this anyway (output scrolled up)
+ this->inputLineRow_ -= newLines;
+ }
+ else if (newLines < 0)
+ {
+ // Scroll status lines up
+ int statusLineRow = this->inputLineRow_ + this->inputLineHeight_;
+ SMALL_RECT oldRect = {0, statusLineRow, this->terminalWidth_ - 1, statusLineRow + this->statusLines_};
+ CHAR_INFO fillChar = {{' '}, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED};
+ ScrollConsoleScreenBuffer(stdOutHandle_, &oldRect, NULL, makeCOORD(0, statusLineRow + newLines), &fillChar);
+ // Clear potential leftovers
+ if (-newLines - this->statusLines_ > 0)
+ {
+ COORD pos = {0, this->inputLineRow_ + newInputLineHeight + this->statusLines_};
+ this->writeText(std::string((-newLines - this->statusLines_) * this->terminalWidth_, ' '), pos);
+ }
+ }
+ this->inputLineHeight_ = newInputLineHeight;
+
+ // Print the whole line, including spaces that erase leftovers
+ std::string inputLine = this->promptString_ + this->shell_->getInput();
+ inputLine += std::string(this->terminalWidth_ - newInputLineLength % this->terminalWidth_, ' ');
+ this->writeText(inputLine, makeCOORD(0, this->inputLineRow_), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+ // If necessary, move cursor
+ if (newLines != 0)
+ this->cursorChanged();
+ }
+
+ //! Called if the position of the cursor in the input-line has changed
+ void IOConsole::cursorChanged()
+ {
+ int rawCursorPos = this->promptString_.size() + this->buffer_->getCursorPosition();
+ // Compensate for cursor further to the right than the terminal width
+ COORD pos;
+ pos.X = rawCursorPos % this->terminalWidth_;
+ pos.Y = this->inputLineRow_ + rawCursorPos / this->terminalWidth_;
+ SetConsoleCursorPosition(stdOutHandle_, pos);
+ }
+
//! Called if only the last output-line has changed
void IOConsole::onlyLastLineChanged()
{
+ int newLineHeight = 1 + this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_;
+ // Compute the number of new lines needed
+ int newLines = newLineHeight - this->lastOutputLineHeight_;
+ this->lastOutputLineHeight_ = newLineHeight;
+ // Scroll console if necessary
+ if (newLines > 0) // newLines < 0 is assumed impossible
+ this->createNewOutputLines(newLines);
+ Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+ this->printOutputLine(it->first, it->second, makeCOORD(0, this->inputLineRow_ - newLineHeight));
}
- //! Called if a new output-line was added
+ //! Called if a new output line was added
void IOConsole::lineAdded()
{
+ Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
+ // Scroll console
+ this->lastOutputLineHeight_ = 1 + it->first.size() / this->terminalWidth_;
+ this->createNewOutputLines(this->lastOutputLineHeight_);
+ // Write the text
+ COORD pos = {0, this->inputLineRow_ - this->lastOutputLineHeight_};
+ this->printOutputLine(it->first, it->second, pos);
}
}
Modified: code/trunk/src/libraries/core/IOConsole.h
===================================================================
--- code/trunk/src/libraries/core/IOConsole.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/IOConsole.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,7 +40,13 @@
#ifdef ORXONOX_PLATFORM_UNIX
struct termios;
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+#define WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
+#define NOMINMAX
#endif
+#include <windows.h>
+#endif
namespace orxonox
{
@@ -52,18 +58,13 @@
IOConsole();
~IOConsole();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
private:
void setTerminalMode();
- void resetTerminalMode();
void getTerminalSize();
- bool willPrintStatusLines();
- int extractLogLevel(std::string* text);
-
- void printLogText(const std::string& line);
- void printInputLine();
void printStatusLines();
+ static int extractLogLevel(std::string* text);
// Methods from ShellListener
void linesChanged();
@@ -73,23 +74,51 @@
void cursorChanged();
void executed();
void exit();
+
Shell* shell_;
InputBuffer* buffer_;
std::ostream cout_;
std::ostringstream origCout_;
- unsigned int terminalWidth_;
- unsigned int terminalHeight_;
- unsigned int lastTerminalWidth_;
- unsigned int lastTerminalHeight_;
- bool bPrintStatusLine_;
- bool bStatusPrinted_;
- std::vector<unsigned> statusLineWidths_;
- unsigned int statusLineMaxWidth_;
+ int terminalWidth_;
+ int terminalHeight_;
+ int lastTerminalWidth_;
+ int lastTerminalHeight_;
const std::string promptString_;
- static const unsigned minOutputLines_ = 3;
#ifdef ORXONOX_PLATFORM_UNIX
+ bool willPrintStatusLines();
+ void printInputLine();
+ void printOutputLine(const std::string& line, Shell::LineType type);
+ static void resetTerminalMode();
+
+ bool bPrintStatusLine_;
+ bool bStatusPrinted_;
+ std::vector<int> statusLineWidths_;
+ int statusLineMaxWidth_;
+ static const int minOutputLines_ = 3;
termios* originalTerminalSettings_;
+
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+ void resetTerminalMode();
+ void moveCursor(int dx, int dy);
+ void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
+ void createNewOutputLines(int lines);
+ void printOutputLine(const std::string& line, Shell::LineType type, const COORD& pos);
+
+ static inline COORD makeCOORD(int x, int y)
+ {
+ COORD val = {x, y};
+ return val;
+ }
+
+ DWORD originalTerminalSettings_;
+ HANDLE stdInHandle_;
+ HANDLE stdOutHandle_;
+ int inputLineRow_;
+ int inputLineHeight_;
+ const int statusLines_;
+ int lastOutputLineHeight_;
+ uint64_t lastRefreshTime_;
#endif
static IOConsole* singletonPtr_s;
Modified: code/trunk/src/libraries/core/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/IRC.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/IRC.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,6 +32,7 @@
#include "util/Convert.h"
#include "util/Exception.h"
+#include "util/StringUtils.h"
#include "ConsoleCommand.h"
#include "CoreIncludes.h"
#include "TclThreadManager.h"
@@ -102,13 +103,13 @@
void IRC::say(const std::string& message)
{
- if (IRC::eval("irk::say $conn #orxonox {" + message + "}"))
+ if (IRC::eval("irk::say $conn #orxonox {" + message + '}'))
IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
}
void IRC::msg(const std::string& channel, const std::string& message)
{
- if (IRC::eval("irk::say $conn " + channel + " {" + message + "}"))
+ if (IRC::eval("irk::say $conn " + channel + " {" + message + '}'))
IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
}
@@ -130,7 +131,7 @@
void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
{
- COUT(0) << "IRC> * " << nick.get() << " " << stripEnclosingBraces(args.get()) << std::endl;
+ COUT(0) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << std::endl;
}
void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
Modified: code/trunk/src/libraries/core/Identifier.cc
===================================================================
--- code/trunk/src/libraries/core/Identifier.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Identifier.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -409,7 +409,7 @@
std::map<std::string, ConfigValueContainer*>::const_iterator it = this->configValues_.find(varname);
if (it != this->configValues_.end())
{
- COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << std::endl;
delete (it->second);
}
@@ -457,7 +457,7 @@
std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());
if (it != this->consoleCommands_.end())
{
- COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << '.' << std::endl;
delete (it->second);
}
@@ -523,7 +523,7 @@
std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
if (it != this->xmlportParamContainers_.end())
{
- COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << '.' << std::endl;
delete (it->second);
}
@@ -554,7 +554,7 @@
std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
if (it != this->xmlportObjectContainers_.end())
{
- COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;
+ COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << std::endl;
delete (it->second);
}
@@ -572,7 +572,7 @@
for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it)
{
if (it != list.begin())
- out << " ";
+ out << ' ';
out << (*it)->getName();
}
Modified: code/trunk/src/libraries/core/Identifier.h
===================================================================
--- code/trunk/src/libraries/core/Identifier.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Identifier.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -410,7 +410,7 @@
void ClassIdentifier<T>::initialiseIdentifier()
{
// Get the name of the class
- std::string name = typeid(T).name();
+ const std::string& name = typeid(T).name();
// create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
Modified: code/trunk/src/libraries/core/Language.cc
===================================================================
--- code/trunk/src/libraries/core/Language.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Language.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,7 @@
void LanguageEntry::setLocalisation(const std::string& localisation)
{
// Check if the translation is more than just an empty string
- if ((localisation != "") && (localisation.size() > 0))
+ if (!localisation.empty())
{
this->localisedEntry_ = localisation;
this->bLocalisationSet_ = true;
@@ -129,7 +129,7 @@
return newEntry;
}
- COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << "!" << std::endl;
+ COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << std::endl;
return it->second;
}
@@ -198,7 +198,7 @@
{
COUT(4) << "Read default language file." << std::endl;
- std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+ const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
// This creates the file if it's not existing
std::ofstream createFile;
@@ -223,7 +223,7 @@
std::getline(file, lineString);
// Check if the line is empty
- if ((lineString != "") && (lineString.size() > 0))
+ if (!lineString.empty())
{
size_t pos = lineString.find('=');
@@ -245,9 +245,9 @@
*/
void Language::readTranslatedLanguageFile()
{
- COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
+ COUT(4) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << std::endl;
- std::string filepath = PathConfig::getConfigPathString() + getFilename(Core::getLanguage());
+ const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage());
// Open the file
std::ifstream file;
@@ -256,9 +256,9 @@
if (!file.is_open())
{
COUT(1) << "An error occurred in Language.cc:" << std::endl;
- COUT(1) << "Error: Couldn't open file " << getFilename(Core::getLanguage()) << " to read the translated language entries!" << std::endl;
- Core::resetLanguage();
- COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
+ COUT(1) << "Error: Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << std::endl;
+ Core::getInstance().resetLanguage();
+ COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << '.' << std::endl;
return;
}
@@ -269,7 +269,7 @@
std::getline(file, lineString);
// Check if the line is empty
- if ((lineString != "") && (lineString.size() > 0))
+ if (!lineString.empty())
{
size_t pos = lineString.find('=');
@@ -286,7 +286,7 @@
}
else
{
- COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getLanguage()) << std::endl;
+ COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << std::endl;
}
}
}
@@ -301,7 +301,7 @@
{
COUT(4) << "Language: Write default language file." << std::endl;
- std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+ const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
// Open the file
std::ofstream file;
@@ -317,7 +317,7 @@
// Iterate through the list an write the lines into the file
for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
{
- file << (*it).second->getLabel() << "=" << (*it).second->getDefault() << std::endl;
+ file << it->second->getLabel() << '=' << it->second->getDefault() << std::endl;
}
file.close();
Modified: code/trunk/src/libraries/core/Language.h
===================================================================
--- code/trunk/src/libraries/core/Language.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Language.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -115,7 +115,7 @@
class _CoreExport Language : public Singleton<Language>
{
friend class Singleton<Language>;
- friend class CoreConfiguration;
+ friend class Core;
public:
Language();
Modified: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Loader.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -79,7 +79,7 @@
return;
for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
{
- if ((*it).first == file)
+ if (it->first == file)
{
Loader::files_s.erase(it);
break;
@@ -91,7 +91,7 @@
{
bool success = true;
for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
- if (!Loader::load((*it).first, (*it).second * mask))
+ if (!Loader::load(it->first, it->second * mask))
success = false;
return success;
@@ -127,18 +127,18 @@
// Use the LuaState to replace the XML tags (calls our function)
scoped_ptr<LuaState> luaState(new LuaState());
luaState->setIncludeParser(&Loader::replaceLuaTags);
- luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
+ luaState->includeFile(file->getFilename());
xmlInput = luaState->getOutput().str();
}
else
{
- shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename(), file->getResourceGroup());
+ shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());
if (info == NULL)
{
COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;
return false;
}
- xmlInput = Resource::open(file->getFilename(), file->getResourceGroup())->getAsString();
+ xmlInput = Resource::open(file->getFilename())->getAsString();
}
try
@@ -164,7 +164,7 @@
rootNamespace->setRoot(true);
rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
- COUT(0) << "Finished loading " << file->getFilename() << "." << std::endl;
+ COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl;
@@ -173,7 +173,7 @@
catch (ticpp::Exception& ex)
{
COUT(1) << std::endl;
- COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+ COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
COUT(1) << ex.what() << std::endl;
COUT(1) << "Loading aborted." << std::endl;
return false;
@@ -181,7 +181,7 @@
catch (Exception& ex)
{
COUT(1) << std::endl;
- COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+ COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
COUT(1) << ex.what() << std::endl;
COUT(1) << "Loading aborted." << std::endl;
return false;
@@ -189,7 +189,7 @@
catch (...)
{
COUT(1) << std::endl;
- COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl;
+ COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
COUT(1) << Exception::handleMessage() << std::endl;
COUT(1) << "Loading aborted." << std::endl;
return false;
@@ -217,7 +217,7 @@
std::string Loader::replaceLuaTags(const std::string& text)
{
- // chreate map with all Lua tags
+ // create map with all Lua tags
std::map<size_t, bool> luaTags;
{
size_t pos = 0;
@@ -290,7 +290,7 @@
do
{
if (it != luaTags.end())
- end = (*(it++)).first;
+ end = (it++)->first;
else
end = std::string::npos;
@@ -299,7 +299,7 @@
if (bInPrintFunction)
{
// count ['='[ and ]'='] and replace tags with print([[ and ]])
- std::string temp = text.substr(start, end - start);
+ const std::string& temp = text.substr(start, end - start);
{
size_t pos = 0;
while ((pos = temp.find('[', pos)) != std::string::npos)
@@ -344,12 +344,12 @@
equalSignCounter = tempCounter;
}
}
- std::string equalSigns = "";
+ std::string equalSigns;
for(unsigned int i = 0; i < equalSignCounter; i++)
{
- equalSigns += "=";
+ equalSigns += '=';
}
- output << "print([" + equalSigns + "[" + temp + "]" + equalSigns +"])";
+ output << "print([" + equalSigns + '[' + temp + ']' + equalSigns +"])";
start = end + 5;
}
else
Modified: code/trunk/src/libraries/core/LuaState.cc
===================================================================
--- code/trunk/src/libraries/core/LuaState.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/LuaState.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -85,37 +85,26 @@
lua_close(luaState_);
}
- shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
+ shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)
{
- shared_ptr<ResourceInfo> sourceInfo;
- if (resourceGroup != "NoResourceGroupProvided")
- sourceInfo = Resource::getInfo(filename, resourceGroup);
-
- // Continue search if not explicitely forbidden
- if (bSearchOtherPaths && sourceInfo == NULL)
- {
- // Call might be relative to the file currently being processed
- sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename, sourceFileInfo_->group);
- if (sourceInfo == NULL)
- {
- // Maybe find something in the same group but in the root path
- sourceInfo = Resource::getInfo(filename, sourceFileInfo_->group);
- }
- }
+ // Look in the current directory first
+ shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);
+ // Continue search in root directories
+ if (sourceInfo == NULL && !sourceFileInfo_->path.empty())
+ sourceInfo = Resource::getInfo(filename);
return sourceInfo;
}
- void LuaState::includeFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
+ void LuaState::includeFile(const std::string& filename)
{
- shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+ shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
if (sourceInfo != NULL)
- this->includeString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
+ this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
else
- COUT(2) << "LuaState: Cannot include file '" << filename << "' in resource group '"
- << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
+ COUT(2) << "LuaState: Cannot include file '" << filename << "'." << std::endl;
}
- void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
+ void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
{
// Parse string with provided include parser (otherwise don't preparse at all)
std::string luaInput;
@@ -127,19 +116,18 @@
this->doString(luaInput, sourceFileInfo);
}
- void LuaState::doFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
+ void LuaState::doFile(const std::string& filename)
{
- shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+ shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
if (sourceInfo != NULL)
- this->doString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
+ this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
else
- COUT(2) << "LuaState: Cannot do file '" << filename << "' in resource group '"
- << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
+ COUT(2) << "LuaState: Cannot do file '" << filename << "'." << std::endl;
}
- void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
+ void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
{
- // Save the oold source file info
+ // Save the old source file info
shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;
// Only override if sourceFileInfo provides useful information
if (sourceFileInfo != NULL)
@@ -163,7 +151,7 @@
std::string origin;
if (sourceFileInfo != NULL)
origin = " originating from " + sourceFileInfo_->filename;
- COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
+ COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
// return value is nil
lua_pushnil(luaState_);
}
@@ -184,9 +172,9 @@
OutputHandler::getOutStream(level) << message << std::endl;
}
- bool LuaState::fileExists(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
+ bool LuaState::fileExists(const std::string& filename)
{
- shared_ptr<ResourceInfo> info = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
+ shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
if (info == NULL)
return false;
else
@@ -262,4 +250,16 @@
lua_setglobal(state, it->first.c_str());
}
}
+
+
+ LuaFunctor::LuaFunctor(const std::string& code, LuaState* luaState)
+ {
+ this->code_ = code;
+ this->lua_ = luaState;
+ }
+
+ void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+ {
+ lua_->doString(this->code_);
+ }
}
Modified: code/trunk/src/libraries/core/LuaState.h
===================================================================
--- code/trunk/src/libraries/core/LuaState.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/LuaState.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,31 +39,46 @@
#include <boost/shared_ptr.hpp>
#include "util/ScopeGuard.h"
+#include "core/Functor.h"
#include "ToluaInterface.h"
-// tolua_begin
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
+ class Functor; // tolua_export
+
+ //! Functor subclass that simply executes code with 0 arguments.
+ class _CoreExport LuaFunctor : public Functor
+ {
+ public:
+ LuaFunctor(const std::string& code, LuaState* luaState);
+ void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
+ void evaluateParam(unsigned int index, MultiType& param) const {}
+
+ private:
+ std::string code_;
+ LuaState* lua_;
+ };
+
+
/**
@brief
Representation of an interface to lua
*/
- class _CoreExport LuaState
- {
-// tolua_end
+ class _CoreExport LuaState // tolua_export
+ { // tolua_export
public:
LuaState();
~LuaState();
- void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
- void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+ void doFile(const std::string& filename); // tolua_export
+ void doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
- void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
- void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+ void includeFile(const std::string& filename); // tolua_export
+ void includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
void luaPrint(const std::string& str); // tolua_export
void luaLog(unsigned int level, const std::string& message); // tolua_export
- bool fileExists(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
+ bool fileExists(const std::string& filename); // tolua_export
const std::stringstream& getOutput() const { return output_; }
void clearOutput() { output_.clear(); } // tolua_export
@@ -71,13 +86,18 @@
void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; }
lua_State* getInternalLuaState() { return luaState_; }
+ void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
+ const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
+
+ Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
+
static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
static bool removeToluaInterface(const std::string& name);
static void openToluaInterfaces(lua_State* state);
static void closeToluaInterfaces(lua_State* state);
private:
- shared_ptr<ResourceInfo> getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths);
+ shared_ptr<ResourceInfo> getFileInfo(const std::string& filename);
#if LUA_VERSION_NUM != 501
struct LoadS
Modified: code/trunk/src/libraries/core/MemoryArchive.cc
===================================================================
--- code/trunk/src/libraries/core/MemoryArchive.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/MemoryArchive.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -63,7 +63,7 @@
return MemoryDataStreamPtr(new MemoryDataStream(itFile->second.first.get(), itFile->second.second));
}
- void MemoryArchive::findFiles(const String& pattern, bool bRecursive,
+ void MemoryArchive::findFiles(const String& pattern, bool bRecursive,
bool bDirs, StringVector* simpleList, FileInfoList* detailList)
{
const FileMap& files = archives_s[this->getName()];
@@ -117,7 +117,7 @@
return ret;
}
- FileInfoListPtr MemoryArchive::findFileInfo(const String& pattern,
+ FileInfoListPtr MemoryArchive::findFileInfo(const String& pattern,
bool recursive, bool dirs)
{
FileInfoListPtr ret(new FileInfoList());
Modified: code/trunk/src/libraries/core/MemoryArchive.h
===================================================================
--- code/trunk/src/libraries/core/MemoryArchive.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/MemoryArchive.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -78,7 +78,7 @@
{ archives_s[archiveName][filename] = std::make_pair(content, size); }
private:
- void findFiles(const Ogre::String& pattern, bool bRecursive,
+ void findFiles(const Ogre::String& pattern, bool bRecursive,
bool bDirs, Ogre::StringVector* simpleList, Ogre::FileInfoList* detailList);
typedef std::map<std::string, std::pair<shared_array<char>, size_t> > FileMap;
Modified: code/trunk/src/libraries/core/Namespace.cc
===================================================================
--- code/trunk/src/libraries/core/Namespace.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Namespace.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -172,7 +172,7 @@
for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
{
if (i > 0)
- output += "\n";
+ output += '\n';
output += (*it)->toString(indentation);
}
Modified: code/trunk/src/libraries/core/NamespaceNode.cc
===================================================================
--- code/trunk/src/libraries/core/NamespaceNode.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/NamespaceNode.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,14 +42,14 @@
NamespaceNode::~NamespaceNode()
{
for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
- delete ((*(it++)).second);
+ delete (it++)->second;
}
std::set<NamespaceNode*> NamespaceNode::getNodeRelative(const std::string& name)
{
std::set<NamespaceNode*> nodes;
- if ((name.size() == 0) || (name == ""))
+ if (name.empty())
{
nodes.insert(this);
}
@@ -88,14 +88,14 @@
if (it == this->subnodes_.end())
it = this->subnodes_.insert(this->subnodes_.begin(), std::pair<std::string, NamespaceNode*>(firstPart, new NamespaceNode(firstPart, this)));
- if ((*it).second->isHidden())
+ if (it->second->isHidden())
{
COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
nodes.insert(this);
}
else
{
- nodes = (*it).second->getNodeRelative(secondPart);
+ nodes = it->second->getNodeRelative(secondPart);
}
}
else
@@ -104,9 +104,9 @@
for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
{
- if ((*it).first.find(firstPart) == ((*it).first.size() - firstPart.size()))
+ if (it->first.find(firstPart) == (it->first.size() - firstPart.size()))
{
- std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart);
+ std::set<NamespaceNode*> temp2 = it->second->getNodeRelative(secondPart);
nodes.insert(temp2.begin(), temp2.end());
bFoundMatchingNamespace = true;
}
@@ -132,7 +132,7 @@
else
{
for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
- if ((*it).second->includes(ns))
+ if (it->second->includes(ns))
return true;
}
@@ -153,10 +153,10 @@
if (i > 0)
output += ", ";
- output += (*it).second->toString();
+ output += it->second->toString();
}
- output += ")";
+ output += ')';
}
return output;
@@ -164,10 +164,10 @@
std::string NamespaceNode::toString(const std::string& indentation) const
{
- std::string output = (indentation + this->name_ + "\n");
+ std::string output = (indentation + this->name_ + '\n');
for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
- output += (*it).second->toString(indentation + " ");
+ output += it->second->toString(indentation + " ");
return output;
}
Modified: code/trunk/src/libraries/core/OrxonoxClass.cc
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/OrxonoxClass.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,22 +48,24 @@
this->metaList_ = new MetaObjectList();
this->referenceCount_ = 0;
this->requestedDestruction_ = false;
+ // Optimisation
+ this->objectPointers_.reserve(6);
}
/** @brief Destructor: Deletes, if existing, the list of the parents. */
OrxonoxClass::~OrxonoxClass()
{
// if (!this->requestedDestruction_)
-// COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl;
+// COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << std::endl;
assert(this->referenceCount_ <= 0);
- delete this->metaList_;
+ this->unregisterObject();
// parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
if (this->parents_)
delete this->parents_;
-
+
// reset all weak pointers pointing to this object
for (std::set<WeakPtr<OrxonoxClass>*>::iterator it = this->weakPointers_.begin(); it != this->weakPointers_.end(); )
(*(it++))->objectDeleted();
@@ -75,9 +77,20 @@
assert(this); // Just in case someone tries to delete a NULL pointer
this->requestedDestruction_ = true;
if (this->referenceCount_ == 0)
- delete this;
+ {
+ this->preDestroy();
+ if (this->referenceCount_ == 0)
+ delete this;
+ }
}
+ void OrxonoxClass::unregisterObject()
+ {
+ if (this->metaList_)
+ delete this->metaList_;
+ this->metaList_ = 0;
+ }
+
/** @brief Returns true if the objects class is of the given type or a derivative. */
bool OrxonoxClass::isA(const Identifier* identifier)
{ return this->getIdentifier()->isA(identifier); }
Modified: code/trunk/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/OrxonoxClass.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -72,6 +72,7 @@
virtual ~OrxonoxClass();
void destroy();
+ void unregisterObject();
/** @brief Function to collect the SetConfigValue-macro calls. */
void setConfigValues() {};
@@ -133,14 +134,21 @@
template <class T> FORCEINLINE const T* getDerivedPointer(unsigned int classID) const
{ return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID); }
+ protected:
+ virtual void preDestroy() {}
+
private:
/** @brief Increments the reference counter (for smart pointers). */
inline void incrementReferenceCount()
{ ++this->referenceCount_; }
/** @brief Decrements the reference counter (for smart pointers). */
inline void decrementReferenceCount()
- { --this->referenceCount_; if (this->referenceCount_ == 0 && this->requestedDestruction_) { delete this; } }
-
+ {
+ --this->referenceCount_;
+ if (this->referenceCount_ == 0 && this->requestedDestruction_)
+ this->destroy();
+ }
+
/** @brief Register a weak pointer which points to this object. */
template <class T>
inline void registerWeakPtr(WeakPtr<T>* pointer)
Modified: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/PathConfig.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -225,7 +225,7 @@
// Option to put all the config and log files in a separate folder
if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
{
- std::string directory(CommandLineParser::getValue("writingPathSuffix").getString());
+ const std::string& directory(CommandLineParser::getValue("writingPathSuffix").getString());
configPath_ = configPath_ / directory;
logPath_ = logPath_ / directory;
}
@@ -255,12 +255,12 @@
std::vector<std::string> modulePaths;
// We search for helper files with the following extension
- std::string moduleextension = specialConfig::moduleExtension;
+ const std::string& moduleextension = specialConfig::moduleExtension;
size_t moduleextensionlength = moduleextension.size();
// 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 + ";" + modulePath_.string()).c_str()));
+ std::string pathVariable(getenv("PATH"));
+ putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));
// Make sure the path exists, otherwise don't load modules
if (!boost::filesystem::exists(modulePath_))
@@ -272,7 +272,7 @@
// Iterate through all files
while (file != end)
{
- std::string filename = file->BOOST_LEAF_FUNCTION();
+ const std::string& filename = file->BOOST_LEAF_FUNCTION();
// Check if the file ends with the exension in question
if (filename.size() > moduleextensionlength)
@@ -280,7 +280,7 @@
if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
{
// We've found a helper file
- std::string library = filename.substr(0, filename.size() - moduleextensionlength);
+ const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
modulePaths.push_back((modulePath_ / library).file_string());
}
}
Modified: code/trunk/src/libraries/core/PathConfig.h
===================================================================
--- code/trunk/src/libraries/core/PathConfig.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/PathConfig.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,8 +35,10 @@
#include <vector>
#include "util/Singleton.h"
+//tolua_begin
namespace orxonox
{
+//tolua_end
/**
@brief
The PathConfig class is a singleton used to configure different paths.
@@ -49,8 +51,9 @@
- root only when installed copyable
- externalData only for development builds in the build tree
*/
- class _CoreExport PathConfig : public Singleton<PathConfig>
- {
+ class _CoreExport PathConfig //tolua_export
+ : public Singleton<PathConfig>
+ { //tolua_export
friend class Singleton<PathConfig>;
friend class Core;
@@ -98,7 +101,7 @@
//! Returns the path to the external data files as std::string
static std::string getExternalDataPathString();
//! Returns the path to the config files as std::string
- static std::string getConfigPathString();
+ static std::string getConfigPathString(); //tolua_export
//! Returns the path to the log files as std::string
static std::string getLogPathString();
//! Returns the path to the modules as std::string
@@ -131,7 +134,7 @@
bool bDevRun_; //!< True for runs in the build directory (not installed)
static PathConfig* singletonPtr_s;
- };
-}
+ }; //tolua_export
+} //tolua_export
#endif /* _PathConfig_H__ */
Modified: code/trunk/src/libraries/core/Resource.cc
===================================================================
--- code/trunk/src/libraries/core/Resource.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Resource.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -27,29 +27,56 @@
*/
#include "Resource.h"
+
+#include <OgreException.h>
#include <OgreResourceGroupManager.h>
namespace orxonox
{
std::string Resource::DEFAULT_GROUP(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- DataStreamPtr Resource::open(const std::string& name, const std::string& group, bool bSearchGroupsIfNotFound)
+ DataStreamPtr Resource::open(const std::string& name)
{
- return Ogre::ResourceGroupManager::getSingleton().openResource(name, group, bSearchGroupsIfNotFound);
+ return Ogre::ResourceGroupManager::getSingleton().openResource(name,
+ Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
}
- DataStreamListPtr Resource::openMulti(const std::string& pattern, const std::string& group)
+ DataStreamListPtr Resource::openMulti(const std::string& pattern)
{
- return Ogre::ResourceGroupManager::getSingleton().openResources(pattern, group);
+ DataStreamListPtr resources(new Ogre::DataStreamList());
+ const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+ for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+ {
+ DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, *it);
+ resources->insert(resources->end(), temp->begin(), temp->end());
+ }
+ return resources;
}
- bool Resource::exists(const std::string& name, const std::string& group)
+ bool Resource::exists(const std::string& name)
{
- return Ogre::ResourceGroupManager::getSingleton().resourceExists(group, name);
+ try
+ {
+ Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name);
+ return true;
+ }
+ catch (const Ogre::Exception&)
+ {
+ return false;
+ }
}
- shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name, const std::string& group)
+ shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name)
{
+ std::string group;
+ try
+ {
+ group = Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name);
+ }
+ catch (const Ogre::Exception&)
+ {
+ return shared_ptr<ResourceInfo>();
+ }
Ogre::FileInfoListPtr infos = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(group, name);
for (std::vector<Ogre::FileInfo>::const_iterator it = infos->begin(); it != infos->end(); ++it)
{
@@ -66,4 +93,16 @@
}
return shared_ptr<ResourceInfo>();
}
+
+ StringVectorPtr Resource::findResourceNames(const std::string& pattern)
+ {
+ StringVectorPtr resourceNames(new Ogre::StringVector());
+ const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+ for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it)
+ {
+ StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(*it, pattern);
+ resourceNames->insert(resourceNames->end(), temp->begin(), temp->end());
+ }
+ return resourceNames;
+ }
}
Modified: code/trunk/src/libraries/core/Resource.h
===================================================================
--- code/trunk/src/libraries/core/Resource.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Resource.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,12 +33,15 @@
#include <boost/shared_ptr.hpp>
#include <OgreDataStream.h>
+#include <OgreStringVector.h>
namespace orxonox
{
// Import the Ogre::DataStreamList
using Ogre::DataStreamList;
using Ogre::DataStreamListPtr;
+ using Ogre::StringVector;
+ using Ogre::StringVectorPtr;
//! Stores basic information about a Resource from Ogre
struct ResourceInfo
@@ -55,9 +58,8 @@
size_t size;
};
- /**
- @brief
- Provides simple functions to easily access the Ogre::ResourceGroupManager
+ /** Provides simple functions to easily access the Ogre::ResourceGroupManager.
+ The wrapper functions also avoid having to deal with resource groups.
*/
class _CoreExport Resource
{
@@ -71,56 +73,56 @@
The name of the resource to locate.
Even if resource locations are added recursively, you
must provide a fully qualified name to this method.
- @param groupName
- The name of the resource group; this determines which
- locations are searched.
- @param searchGroupsIfNotFound
- If true, if the resource is not found in
- the group specified, other groups will be searched.
@return
Shared pointer to data stream containing the data. Will be
destroyed automatically when no longer referenced.
*/
- static DataStreamPtr open(const std::string& name,
- const std::string& group = Resource::DEFAULT_GROUP,
- bool bSearchGroupsIfNotFound = false);
+ static DataStreamPtr open(const std::string& name);
+ //! Similar to open(string, string, bool), but with a fileInfo struct
+ static DataStreamPtr open(shared_ptr<ResourceInfo> fileInfo)
+ {
+ return open(fileInfo->filename);
+ }
+
/**
@brief
Open all resources matching a given pattern (which can contain
- the character '*' as a wildcard), and return a collection of
+ the character '*' as a wildcard), and return a collection of
DataStream objects on them.
@param pattern
The pattern to look for. If resource locations have been
added recursively, subdirectories will be searched too so this
does not need to be fully qualified.
- @param groupName
- The resource group; this determines which locations
- are searched.
@return
Shared pointer to a data stream list , will be
destroyed automatically when no longer referenced
*/
- static DataStreamListPtr openMulti(const std::string& pattern, const std::string& group = Resource::DEFAULT_GROUP);
+ static DataStreamListPtr openMulti(const std::string& pattern);
/**
- Find out if the named file exists in a group.
+ Find out if the named file exists.
@param filename
Fully qualified name of the file to test for
- @param group
- The name of the resource group
*/
- static bool exists(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
+ static bool exists(const std::string& name);
/**
- Get struct with information about group, path and size.
+ Get struct with information about path and size.
@param filename
Fully qualified name of the file to test for
- @param group
- The name of the resource group
*/
- static shared_ptr<ResourceInfo> getInfo(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
+ static shared_ptr<ResourceInfo> getInfo(const std::string& name);
+ /**
+ Retrieves a list with all resources matching a certain pattern.
+ @param pattern
+ The pattern to look for. If resource locations have been
+ added recursively, subdirectories will be searched too so this
+ does not need to be fully qualified.
+ */
+ static StringVectorPtr findResourceNames(const std::string& pattern);
+
//! Name of the default resource group (usually "General")
static std::string DEFAULT_GROUP;
Modified: code/trunk/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/core/ScopedSingletonManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ScopedSingletonManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,6 +38,7 @@
#include "util/Singleton.h"
#define ManageScopedSingleton(className, scope, allowedToFail) \
+ className* className::singletonPtr_s = NULL; \
static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
namespace orxonox
@@ -53,13 +54,21 @@
static void addManager(ScopedSingletonManager* manager);
template<ScopeID::Value scope>
- static void update(const Clock& time)
+ static void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
- it->second->update(time);
+ it->second->preUpdate(time);
}
- virtual void update(const Clock& time) = 0;
+ virtual void preUpdate(const Clock& time) = 0;
+ template<ScopeID::Value scope>
+ static void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+ it->second->postUpdate(time);
+ }
+ virtual void postUpdate(const Clock& time) = 0;
static std::map<std::string, ScopedSingletonManager*>& getManagers();
typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
@@ -111,13 +120,21 @@
}
//! Called every frame by the ScopedSingletonManager
- void update(const Clock& time)
+ void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
// assuming T inherits Singleton<T>
- singletonPtr_->updateSingleton(time);
+ singletonPtr_->preUpdateSingleton(time);
}
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
private:
T* singletonPtr_;
};
@@ -144,6 +161,8 @@
assert(singletonPtr_ == NULL);
try
{ singletonPtr_ = new T(); }
+ catch (const InitialisationAbortedException& ex)
+ { COUT(3) << ex.getDescription() << std::endl; }
catch (...)
{ COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
}
@@ -168,14 +187,23 @@
}
//! Called every frame by the ScopedSingletonManager
- void update(const Clock& time)
+ void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
// assuming T inherits Singleton<T>
if (singletonPtr_ != NULL)
- singletonPtr_->updateSingleton(time);
+ singletonPtr_->preUpdateSingleton(time);
}
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ if (singletonPtr_ != NULL)
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
private:
T* singletonPtr_;
};
Modified: code/trunk/src/libraries/core/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/Shell.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Shell.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -44,11 +44,10 @@
SetConsoleCommandShortcut(OutputHandler, info);
SetConsoleCommandShortcut(OutputHandler, debug);
- Shell::Shell(const std::string& consoleName, bool bScrollable, bool bPrependOutputLevel)
+ Shell::Shell(const std::string& consoleName, bool bScrollable)
: OutputListener(consoleName)
, inputBuffer_(new InputBuffer())
, consoleName_(consoleName)
- , bPrependOutputLevel_(bPrependOutputLevel)
, bScrollable_(bScrollable)
{
RegisterRootObject(Shell);
@@ -62,11 +61,10 @@
this->clearOutput();
this->configureInputBuffer();
- // Get a config file for the command history
- this->commandHistoryConfigFileType_ = ConfigFileManager::getInstance().getNewConfigFileType();
- ConfigFileManager::getInstance().setFilename(this->commandHistoryConfigFileType_, "commandHistory.ini");
+ // Specify file for the command history
+ ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
- // Use a stringstream object to buffer the output and get it line by line in update()
+ // Use a stringstream object to buffer the output
this->outputStream_ = &this->outputBuffer_;
this->setConfigValues();
@@ -98,14 +96,14 @@
.callback(this, &Shell::commandHistoryLengthChanged);
SetConfigValue(historyOffset_, 0)
.callback(this, &Shell::commandHistoryOffsetChanged);
- SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
+ setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
#ifdef ORXONOX_RELEASE
const unsigned int defaultLevel = 1;
#else
const unsigned int defaultLevel = 3;
#endif
- SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevel" + this->consoleName_, "OutputHandler", defaultLevel)
+ setConfigValueGeneric(this, &softDebugLevel_, ConfigFileType::Settings, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
.description("The maximal level of debug output shown in the Shell");
this->setSoftDebugLevel(this->softDebugLevel_);
}
@@ -162,9 +160,9 @@
Shell& instance = Shell::getInstance();
for (unsigned int i = instance.historyOffset_; i < instance.commandHistory_.size(); ++i)
- instance.addOutputLine(instance.commandHistory_[i], -1);
+ instance.addOutput(instance.commandHistory_[i] + '\n', -1);
for (unsigned int i = 0; i < instance.historyOffset_; ++i)
- instance.addOutputLine(instance.commandHistory_[i], -1);
+ instance.addOutput(instance.commandHistory_[i] + '\n', -1);
}
*/
@@ -190,16 +188,10 @@
this->updateListeners<&ShellListener::cursorChanged>();
}
- void Shell::addOutputLine(const std::string& line, int level)
+ void Shell::addOutput(const std::string& text, LineType type)
{
- // Make sure we really only have one line per line (no new lines!)
- SubString lines(line, '\n');
- for (unsigned i = 0; i < lines.size(); ++i)
- {
- if (level <= this->softDebugLevel_)
- this->outputLines_.push_front(lines[i]);
- this->updateListeners<&ShellListener::lineAdded>();
- }
+ this->outputBuffer_ << text;
+ this->outputChanged(type);
}
void Shell::clearOutput()
@@ -213,7 +205,7 @@
this->updateListeners<&ShellListener::linesChanged>();
}
- std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
+ Shell::LineList::const_iterator Shell::getNewestLineIterator() const
{
if (this->scrollPosition_)
return this->scrollIterator_;
@@ -221,7 +213,7 @@
return this->outputLines_.begin();
}
- std::list<std::string>::const_iterator Shell::getEndIterator() const
+ Shell::LineList::const_iterator Shell::getEndIterator() const
{
return this->outputLines_.end();
}
@@ -233,16 +225,16 @@
ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_);
}
- std::string Shell::getFromHistory() const
+ const std::string& Shell::getFromHistory() const
{
unsigned int index = mod(static_cast<int>(this->historyOffset_) - static_cast<int>(this->historyPosition_), this->maxHistoryLength_);
if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
return this->commandHistory_[index];
else
- return "";
+ return BLANKSTRING;
}
- void Shell::outputChanged(int level)
+ void Shell::outputChanged(int lineType)
{
bool newline = false;
do
@@ -258,16 +250,13 @@
this->outputBuffer_.clear();
newline = (!eof && !fail);
- if (!newline && output == "")
+ if (!newline && output.empty())
break;
if (this->bFinishedLastLine_)
{
- if (this->bPrependOutputLevel_)
- output.insert(0, 1, static_cast<char>(level));
+ this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
- this->outputLines_.push_front(output);
-
if (this->scrollPosition_)
this->scrollPosition_++;
else
@@ -276,16 +265,15 @@
this->bFinishedLastLine_ = newline;
if (!this->scrollPosition_)
- {
this->updateListeners<&ShellListener::lineAdded>();
- }
}
else
{
- (*this->outputLines_.begin()) += output;
+ this->outputLines_.front().first += output;
this->bFinishedLastLine_ = newline;
this->updateListeners<&ShellListener::onlyLastLineChanged>();
}
+ this->bFinishedLastLine_ = newline;
} while (newline);
}
@@ -319,7 +307,10 @@
this->updateListeners<&ShellListener::executed>();
if (!CommandExecutor::execute(this->inputBuffer_->get()))
- this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
+ {
+ this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
+ this->outputChanged(Error);
+ }
this->clearInput();
}
@@ -327,7 +318,8 @@
void Shell::hintAndComplete()
{
this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
- this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
+ this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
+ this->outputChanged(Hint);
this->inputChanged();
}
@@ -407,7 +399,7 @@
if (this->historyPosition_ == this->historyOffset_)
return;
unsigned int cursorPosition = this->getCursorPosition();
- std::string input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning of the inputline until the cursor position
+ const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning of the inputline until the cursor position
for (unsigned int newPos = this->historyPosition_ + 1; newPos <= this->historyOffset_; newPos++)
{
if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) // search case insensitive
@@ -425,7 +417,7 @@
if (this->historyPosition_ == 0)
return;
unsigned int cursorPosition = this->getCursorPosition();
- std::string input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning
+ const std::string& input_str(this->getInput().substr(0, cursorPosition)); // only search for the expression from the beginning
for (unsigned int newPos = this->historyPosition_ - 1; newPos > 0; newPos--)
{
if (getLowercase(this->commandHistory_[this->historyOffset_ - newPos]).find(getLowercase(input_str)) == 0) // sear$
Modified: code/trunk/src/libraries/core/Shell.h
===================================================================
--- code/trunk/src/libraries/core/Shell.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Shell.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -64,7 +64,21 @@
class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
{
public:
- Shell(const std::string& consoleName, bool bScrollable, bool bPrependOutputLevel = false);
+ enum LineType
+ {
+ None = OutputLevel::None,
+ Warning = OutputLevel::Warning,
+ Error = OutputLevel::Error,
+ Info = OutputLevel::Info,
+ Debug = OutputLevel::Debug,
+ Verbose = OutputLevel::Verbose,
+ Ultra = OutputLevel::Ultra,
+ Input,
+ Command,
+ Hint
+ };
+
+ Shell(const std::string& consoleName, bool bScrollable);
~Shell();
void setConfigValues();
@@ -81,13 +95,14 @@
inline unsigned int getCursorPosition() const
{ return this->inputBuffer_->getCursorPosition(); }
- inline std::string getInput() const
+ inline const std::string& getInput() const
{ return this->inputBuffer_->get(); }
- std::list<std::string>::const_iterator getNewestLineIterator() const;
- std::list<std::string>::const_iterator getEndIterator() const;
+ typedef std::list<std::pair<std::string, LineType> > LineList;
+ LineList::const_iterator getNewestLineIterator() const;
+ LineList::const_iterator getEndIterator() const;
- void addOutputLine(const std::string& line, int level = 0);
+ void addOutput(const std::string& text, LineType type = None);
void clearOutput();
inline unsigned int getNumLines() const
@@ -102,7 +117,7 @@
Shell(const Shell& other);
void addToHistory(const std::string& command);
- std::string getFromHistory() const;
+ const std::string& getFromHistory() const;
void clearInput();
// OutputListener
void outputChanged(int level);
@@ -138,15 +153,13 @@
InputBuffer* inputBuffer_;
std::stringstream outputBuffer_;
bool bFinishedLastLine_;
- std::list<std::string> outputLines_;
- std::list<std::string>::const_iterator scrollIterator_;
+ LineList outputLines_;
+ LineList::const_iterator scrollIterator_;
unsigned int scrollPosition_;
unsigned int historyPosition_;
- ConfigFileType commandHistoryConfigFileType_;
std::string promptPrefix_;
const std::string consoleName_;
- const bool bPrependOutputLevel_;
const bool bScrollable_;
// Config values
Modified: code/trunk/src/libraries/core/SmartPtr.h
===================================================================
--- code/trunk/src/libraries/core/SmartPtr.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/SmartPtr.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -83,7 +83,7 @@
if (this->base_)
this->base_->decrementReferenceCount();
}
-
+
inline const SmartPtr& operator=(int)
{
SmartPtr(0).swap(*this);
Modified: code/trunk/src/libraries/core/SubclassIdentifier.h
===================================================================
--- code/trunk/src/libraries/core/SubclassIdentifier.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/SubclassIdentifier.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -97,7 +97,7 @@
COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
if (identifier)
{
- COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+ COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
}
else
@@ -165,7 +165,7 @@
if (this->identifier_)
{
COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
- COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+ COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
}
else
Modified: code/trunk/src/libraries/core/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/TclBind.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/TclBind.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -100,12 +100,12 @@
Tcl::interpreter* TclBind::createTclInterpreter()
{
Tcl::interpreter* interpreter = new Tcl::interpreter();
- std::string libpath = TclBind::getTclLibraryPath();
+ const std::string& libpath = TclBind::getTclLibraryPath();
try
{
- if (libpath != "")
- interpreter->eval("set tcl_library \"" + libpath + "\"");
+ if (!libpath.empty())
+ interpreter->eval("set tcl_library \"" + libpath + '"');
Tcl_Init(interpreter->get());
@@ -135,7 +135,7 @@
{
COUT(4) << "Tcl_query: " << args.get() << std::endl;
- std::string command = stripEnclosingBraces(args.get());
+ const std::string& command = stripEnclosingBraces(args.get());
if (!CommandExecutor::execute(command, false))
{
@@ -151,7 +151,7 @@
void TclBind::tcl_execute(Tcl::object const &args)
{
COUT(4) << "Tcl_execute: " << args.get() << std::endl;
- std::string command = stripEnclosingBraces(args.get());
+ const std::string& command = stripEnclosingBraces(args.get());
if (!CommandExecutor::execute(command, false))
{
@@ -165,8 +165,8 @@
{
try
{
- std::string output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
- if (output != "")
+ const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
+ if (!output.empty())
{
COUT(0) << "tcl> " << output << std::endl;
}
@@ -181,7 +181,7 @@
return "";
}
- void TclBind::bgerror(std::string error)
+ void TclBind::bgerror(const std::string& error)
{
COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
}
Modified: code/trunk/src/libraries/core/TclBind.h
===================================================================
--- code/trunk/src/libraries/core/TclBind.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/TclBind.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -45,7 +45,7 @@
~TclBind();
static std::string tcl(const std::string& tclcode);
- static void bgerror(std::string error);
+ static void bgerror(const std::string& error);
void setDataPath(const std::string& datapath);
const std::string& getTclDataPath() const { return this->tclDataPath_; }
Modified: code/trunk/src/libraries/core/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/TclThreadManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/TclThreadManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,6 +38,7 @@
#include "util/Clock.h"
#include "util/Convert.h"
#include "util/Exception.h"
+#include "util/StringUtils.h"
#include "CommandExecutor.h"
#include "ConsoleCommand.h"
#include "CoreIncludes.h"
@@ -121,7 +122,7 @@
/**
@brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
*/
- void TclThreadManager::update(const Clock& time)
+ void TclThreadManager::preUpdate(const Clock& time)
{
// Get the bundle of the main interpreter (0)
TclInterpreterBundle* bundle = this->getInterpreterBundle(0);
@@ -251,7 +252,7 @@
void TclThreadManager::initialize(TclInterpreterBundle* bundle)
{
- std::string id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
+ const std::string& id_string = getConvertedValue<unsigned int, std::string>(bundle->id_);
// Initialize the new interpreter
try
@@ -402,10 +403,10 @@
if ((source_bundle->id_ == target_bundle->id_) || source_bundle->queriers_.is_in(target_bundle->id_))
{
// This query would lead to a deadlock - return with an error
- TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + " " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) \
+ TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + getConvertedValue<unsigned int, std::string>(source_bundle->id_) \
+ " -> " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) \
+ "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target_bundle->id_) \
- + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) + ".");
+ + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(source_bundle->id_) + '.');
}
else
{
@@ -523,11 +524,11 @@
*/
std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
{
- std::string output = "";
+ std::string output;
for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
{
if (it != list.begin())
- output += " ";
+ output += ' ';
output += getConvertedValue<unsigned int, std::string>(*it);
}
@@ -599,7 +600,7 @@
@param bundle The interpreter bundle containing all necessary variables
@param command the Command to execute
*/
- void tclThread(TclInterpreterBundle* bundle, std::string command)
+ void tclThread(TclInterpreterBundle* bundle, const std::string& command)
{
TclThreadManager::debug("TclThread_execute: " + command);
@@ -612,7 +613,7 @@
@brief The main function of a non-interactive source thread. Executes the file.
@param file The name of the file that should be executed by the non-interactive interpreter.
*/
- void sourceThread(std::string file)
+ void sourceThread(const std::string& file)
{
TclThreadManager::debug("TclThread_source: " + file);
@@ -650,9 +651,9 @@
bundle->interpreter_ = new Tcl::interpreter(interp, true);
// Initialize the non-interactive interpreter (like in @ref TclBind::createTclInterpreter but exception safe)
- std::string libpath = TclBind::getTclLibraryPath();
- if (libpath != "")
- TclThreadManager::eval(bundle, "set tcl_library \"" + libpath + "\"", "source");
+ const std::string& libpath = TclBind::getTclLibraryPath();
+ if (!libpath.empty())
+ TclThreadManager::eval(bundle, "set tcl_library \"" + libpath + '"', "source");
int cc = Tcl_Init(interp);
TclThreadManager::eval(bundle, "source \"" + TclBind::getInstance().getTclDataPath() + "/init.tcl\"", "source");
Modified: code/trunk/src/libraries/core/TclThreadManager.h
===================================================================
--- code/trunk/src/libraries/core/TclThreadManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/TclThreadManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -47,8 +47,8 @@
{
friend class Singleton<TclThreadManager>;
friend class TclBind;
- friend _CoreExport void tclThread(TclInterpreterBundle* bundle, std::string command);
- friend _CoreExport void sourceThread(std::string file);
+ friend _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
+ friend _CoreExport void sourceThread(const std::string& file);
friend _CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
public:
@@ -65,7 +65,7 @@
static void error(const std::string& error);
static void debug(const std::string& error);
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
std::list<unsigned int> getThreadList() const;
@@ -94,8 +94,8 @@
boost::mutex* mainInterpreterMutex_; ///< A mutex to synchronize queries to the main interpreter
};
- _CoreExport void tclThread(TclInterpreterBundle* bundle, std::string command);
- _CoreExport void sourceThread(std::string file);
+ _CoreExport void tclThread(TclInterpreterBundle* bundle, const std::string& command);
+ _CoreExport void sourceThread(const std::string& file);
_CoreExport int Tcl_OrxonoxAppInit(Tcl_Interp* interp);
}
Modified: code/trunk/src/libraries/core/Template.cc
===================================================================
--- code/trunk/src/libraries/core/Template.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Template.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -78,7 +78,7 @@
{
SUPER(Template, changedName);
- if (this->getName() != "")
+ if (!this->getName().empty())
{
std::map<std::string, Template*>::iterator it;
it = Template::getTemplateMap().find(this->getOldName());
Modified: code/trunk/src/libraries/core/Template.h
===================================================================
--- code/trunk/src/libraries/core/Template.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Template.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -47,7 +47,7 @@
virtual void changedName();
inline void setLink(const std::string& link)
- { this->link_ = link; this->bIsLink_ = (link != ""); }
+ { this->link_ = link; this->bIsLink_ = !link.empty(); }
inline const std::string& getLink() const
{ return this->link_; }
Modified: code/trunk/src/libraries/core/Thread.cc
===================================================================
--- code/trunk/src/libraries/core/Thread.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Thread.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,8 +40,8 @@
namespace orxonox
{
boost::posix_time::millisec THREAD_WAIT_BEFORE_DETACH(1000);
-
-
+
+
Thread::Thread():
executor_(0),
isWorking_(false),
@@ -52,7 +52,7 @@
this->stopThreadMutex_ = new boost::mutex;
this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );
}
-
+
Thread::~Thread()
{
this->stopThreadMutex_->lock();
@@ -65,7 +65,7 @@
delete this->stopThreadMutex_;
delete this->isWorkingMutex_;
}
-
+
bool Thread::isWorking()
{
this->isWorkingMutex_->lock();
@@ -73,7 +73,7 @@
this->isWorkingMutex_->unlock();
return isWorking;
}
-
+
bool Thread::evaluateExecutor( Executor* executor )
{
this->isWorkingMutex_->lock();
@@ -84,7 +84,7 @@
this->executorMutex_->unlock();
return true;
}
-
+
void Thread::threadLoop()
{
bool stopThread = false;
@@ -113,7 +113,7 @@
//this->stopThreadMutex_->unlock();
}
}
-
+
void Thread::waitUntilFinished()
{
bool stillWorking = true;
Modified: code/trunk/src/libraries/core/Thread.h
===================================================================
--- code/trunk/src/libraries/core/Thread.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/Thread.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,7 +49,7 @@
private:
void threadLoop();
-
+
Executor* executor_;
bool isWorking_;
bool stopThread_;
Modified: code/trunk/src/libraries/core/ThreadPool.cc
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ThreadPool.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,13 +36,13 @@
ThreadPool::ThreadPool()
{
}
-
+
ThreadPool::~ThreadPool()
{
unsigned int a = this->setNrOfThreads(0);
assert(a == 0);
}
-
+
void ThreadPool::addThreads( unsigned int nr )
{
for( unsigned int i=0; i<nr; i++ )
@@ -79,7 +79,7 @@
return nr;
}
}
-
+
bool ThreadPool::passFunction( Executor* executor, bool addThread )
{
std::vector<Thread*>::iterator it;
@@ -102,7 +102,7 @@
else
return false;
}
-
+
void ThreadPool::synchronise()
{
std::vector<Thread*>::iterator it;
Modified: code/trunk/src/libraries/core/ThreadPool.h
===================================================================
--- code/trunk/src/libraries/core/ThreadPool.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/ThreadPool.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,17 +40,17 @@
public:
ThreadPool();
virtual ~ThreadPool();
-
+
void addThreads( unsigned int nr );
unsigned int removeThreads( unsigned int nr );
unsigned int setNrOfThreads( unsigned int nr );
-
+
bool passFunction( Executor* executor, bool addThread=false );
void synchronise();
-
+
private:
std::vector<Thread*> threadPool_;
-
+
};
}
Modified: code/trunk/src/libraries/core/WeakPtr.h
===================================================================
--- code/trunk/src/libraries/core/WeakPtr.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/WeakPtr.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -43,7 +43,7 @@
class WeakPtr
{
friend class OrxonoxClass;
-
+
public:
inline WeakPtr() : pointer_(0), base_(0), callback_(0)
{
@@ -78,9 +78,9 @@
this->base_->unregisterWeakPtr(this);
if (this->callback_)
delete this->callback_;
-
+
}
-
+
inline const WeakPtr& operator=(int)
{
WeakPtr(0).swap(*this);
@@ -144,7 +144,7 @@
this->base_->unregisterWeakPtr(this);
if (other.base_)
other.base_->unregisterWeakPtr(&other);
-
+
{
T* temp = this->pointer_;
this->pointer_ = other.pointer_;
@@ -166,12 +166,12 @@
{
WeakPtr().swap(*this);
}
-
+
inline void setCallback(Functor* callback)
{
this->callback_ = callback;
}
-
+
inline Functor* getFunctor() const
{
return this->callback_;
@@ -185,7 +185,7 @@
if (this->callback_)
(*this->callback_)();
}
-
+
T* pointer_;
OrxonoxClass* base_;
Functor* callback_;
Modified: code/trunk/src/libraries/core/XMLFile.h
===================================================================
--- code/trunk/src/libraries/core/XMLFile.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/XMLFile.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,14 +39,12 @@
class _CoreExport XMLFile
{
public:
- XMLFile(const std::string& filename, const std::string& resourceGroup = "General")
+ XMLFile(const std::string& filename)
: filename_(filename)
- , group_(resourceGroup)
, bLuaSupport_(true)
{ }
- XMLFile(const ClassTreeMask& mask, const std::string& filename, const std::string& resourceGroup = "General")
+ XMLFile(const ClassTreeMask& mask, const std::string& filename)
: filename_(filename)
- , group_(resourceGroup)
, mask_(mask)
, bLuaSupport_(true)
{ }
@@ -54,13 +52,11 @@
void setLuaSupport(bool val) { bLuaSupport_ = val; }
const std::string& getFilename() const { return this->filename_; }
- const std::string& getResourceGroup() const { return this->group_; }
const ClassTreeMask& getMask() const { return this->mask_; }
bool getLuaSupport() const { return this->bLuaSupport_; }
private:
std::string filename_;
- std::string group_;
ClassTreeMask mask_;
bool bLuaSupport_; // Default is true
};
Modified: code/trunk/src/libraries/core/XMLPort.h
===================================================================
--- code/trunk/src/libraries/core/XMLPort.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/XMLPort.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,6 +50,7 @@
#include "util/Exception.h"
#include "util/MultiType.h"
#include "util/OrxAssert.h"
+#include "util/StringUtils.h"
#include "Identifier.h"
#include "Executor.h"
#include "BaseObject.h"
@@ -183,7 +184,7 @@
containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \
ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
} \
- containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
+ containername->port(dynamic_cast<BaseObject*>(this), object, xmlelement, mode)
// --------------------
// XMLPortObjectExtended
@@ -315,7 +316,7 @@
inline const std::string& getName() const
{ return this->paramname_; }
- virtual XMLPortParamContainer& description(const std::string description) = 0;
+ virtual XMLPortParamContainer& description(const std::string& description) = 0;
virtual const std::string& getDescription() = 0;
virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
@@ -343,7 +344,7 @@
};
public:
- XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+ XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
{
this->paramname_ = paramname;
this->identifier_ = identifier;
@@ -384,7 +385,7 @@
this->owner_->lastLoadedXMLElement_ = &xmlelement;
}
std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_));
- std::string attributeValue("");
+ std::string attributeValue;
if (it != this->owner_->xmlAttributes_.end())
attributeValue = it->second;
@@ -406,7 +407,7 @@
catch (ticpp::Exception& ex)
{
COUT(1) << std::endl;
- COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ":" << std::endl;
+ COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << std::endl;
COUT(1) << ex.what() << std::endl;
}
}
@@ -434,7 +435,7 @@
return (*this);
}
- virtual XMLPortParamContainer& description(const std::string description)
+ virtual XMLPortParamContainer& description(const std::string& description)
{ this->loadexecutor_->setDescription(description); return (*this); }
virtual const std::string& getDescription()
{ return this->loadexecutor_->getDescription(); }
@@ -496,7 +497,7 @@
inline const std::string& getName() const
{ return this->sectionname_; }
- virtual XMLPortObjectContainer& description(const std::string description) = 0;
+ virtual XMLPortObjectContainer& description(const std::string& description) = 0;
virtual const std::string& getDescription() = 0;
bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
@@ -512,7 +513,7 @@
class XMLPortClassObjectContainer : public XMLPortObjectContainer
{
public:
- XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
+ XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
{
this->sectionname_ = sectionname;
this->identifier_ = identifier;
@@ -537,7 +538,7 @@
try
{
Element* xmlsubelement;
- if ((this->sectionname_ != "") && (this->sectionname_.size() > 0))
+ if (!this->sectionname_.empty())
xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
else
xmlsubelement = &xmlelement;
@@ -569,11 +570,11 @@
if (this->bLoadBefore_)
{
newObject->XMLPort(*child, XMLPort::LoadObject);
- COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
+ COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
}
else
{
- COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ")" << std::endl;
+ COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
}
COUT(5) << object->getLoaderIndentation();
@@ -608,7 +609,7 @@
}
else
{
- if (this->sectionname_ != "")
+ if (!this->sectionname_.empty())
{
COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
}
@@ -623,7 +624,7 @@
catch (ticpp::Exception& ex)
{
COUT(1) << std::endl;
- COUT(1) << "An error occurred in XMLPort.h while loading a '" << ClassIdentifier<O>::getIdentifier()->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ":" << std::endl;
+ COUT(1) << "An error occurred in XMLPort.h while loading a '" << ClassIdentifier<O>::getIdentifier()->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;
COUT(1) << ex.what() << std::endl;
}
}
@@ -634,7 +635,7 @@
return (*this);
}
- virtual XMLPortObjectContainer& description(const std::string description)
+ virtual XMLPortObjectContainer& description(const std::string& description)
{ this->loadexecutor_->setDescription(description); return (*this); }
virtual const std::string& getDescription()
{ return this->loadexecutor_->getDescription(); }
Modified: code/trunk/src/libraries/core/input/Button.cc
===================================================================
--- code/trunk/src/libraries/core/input/Button.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/Button.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -115,18 +115,18 @@
for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
{
- if (commandStrings[iCommand] != "")
+ if (!commandStrings[iCommand].empty())
{
SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
'\\', false, '"', false, '(', ')', false, '\0');
KeybindMode::Value mode = KeybindMode::None;
float paramModifier = 1.0f;
- std::string commandStr = "";
+ std::string commandStr;
for (unsigned int iToken = 0; iToken < tokens.size(); ++iToken)
{
- std::string token = getLowercase(tokens[iToken]);
+ const std::string& token = getLowercase(tokens[iToken]);
if (token == "onpress")
mode = KeybindMode::OnPress;
@@ -158,11 +158,11 @@
// no input related argument
// we interpret everything from here as a command string
while (iToken != tokens.size())
- commandStr += tokens[iToken++] + " ";
+ commandStr += tokens[iToken++] + ' ';
}
}
- if (commandStr == "")
+ if (commandStr.empty())
{
parseError("No command string given.", false);
continue;
@@ -241,7 +241,7 @@
}
}
- inline void Button::parseError(std::string message, bool serious)
+ inline void Button::parseError(const std::string& message, bool serious)
{
if (serious)
{
Modified: code/trunk/src/libraries/core/input/Button.h
===================================================================
--- code/trunk/src/libraries/core/input/Button.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/Button.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -75,7 +75,7 @@
std::vector<BufferedParamCommand*>* paramCommandBuffer_;
private:
- void parseError(std::string message, bool serious);
+ void parseError(const std::string& message, bool serious);
};
inline bool Button::execute(KeybindMode::Value mode, float abs, float rel)
Modified: code/trunk/src/libraries/core/input/InputBuffer.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputBuffer.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputBuffer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,8 +38,8 @@
{
RegisterRootObject(InputBuffer);
- this->buffer_ = "";
this->cursor_ = 0;
+ this->maxLength_ = 1024;
this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
ABCDEFGHIJKLMNOPQRSTUVWXYZ \
äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
@@ -58,8 +58,8 @@
{
RegisterRootObject(InputBuffer);
+ this->maxLength_ = 1024;
this->allowedChars_ = allowedChars;
- this->buffer_ = "";
this->cursor_ = 0;
this->lastKey_ = KeyCode::Unassigned;
@@ -92,6 +92,13 @@
}
}
+ void InputBuffer::setMaxLength(unsigned int length)
+ {
+ this->maxLength_ = length;
+ if (this->buffer_.size() > length)
+ this->buffer_.resize(length);
+ }
+
void InputBuffer::set(const std::string& input, bool update)
{
this->clear(false);
@@ -116,6 +123,8 @@
{
if (this->charIsAllowed(input))
{
+ if (this->buffer_.size() >= this->maxLength_)
+ return;
this->buffer_.insert(this->cursor_, 1, input);
++this->cursor_;
}
@@ -126,7 +135,7 @@
void InputBuffer::clear(bool update)
{
- this->buffer_ = "";
+ this->buffer_.clear();
this->cursor_ = 0;
if (update)
@@ -176,7 +185,7 @@
bool InputBuffer::charIsAllowed(const char& input)
{
- if (this->allowedChars_ == "")
+ if (this->allowedChars_.empty())
return true;
else
return (this->allowedChars_.find(input) != std::string::npos);
Modified: code/trunk/src/libraries/core/input/InputBuffer.h
===================================================================
--- code/trunk/src/libraries/core/input/InputBuffer.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputBuffer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -82,6 +82,9 @@
void setConfigValues();
+ unsigned int getMaxLength() const { return this->maxLength_; }
+ void setMaxLength(unsigned int length);
+
template <class T>
void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
{
@@ -174,6 +177,7 @@
std::string buffer_;
std::list<BaseInputBufferListenerTuple*> listeners_;
std::string allowedChars_;
+ unsigned int maxLength_;
unsigned int cursor_;
KeyCode::ByEnum lastKey_;
Modified: code/trunk/src/libraries/core/input/InputCommands.h
===================================================================
--- code/trunk/src/libraries/core/input/InputCommands.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputCommands.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,7 +70,7 @@
/**
@brief
Executes a simple command with no additional paramters.
- @return
+ @return
True if command execution was successful, false otherwise.
*/
inline bool SimpleCommand::execute(float abs, float rel)
Modified: code/trunk/src/libraries/core/input/InputDevice.h
===================================================================
--- code/trunk/src/libraries/core/input/InputDevice.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputDevice.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -202,14 +202,18 @@
FORCEINLINE void buttonReleased(ButtonTypeParam button)
{
// remove the button from the pressedButtons_ list
+ bool found = false;
for (unsigned int iButton = 0; iButton < pressedButtons_.size(); iButton++)
{
if (pressedButtons_[iButton] == button)
{
pressedButtons_.erase(pressedButtons_.begin() + iButton);
+ found = true;
break;
}
}
+ if (!found)
+ return; // We ignore release strokes when the press was not captured
// Call states
for (unsigned int i = 0; i < inputStates_.size(); ++i)
Modified: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -274,7 +274,7 @@
// destroy all user InputStates
while (statesByName_.size() > 0)
- this->destroyStateInternal((*statesByName_.rbegin()).second);
+ this->destroyStateInternal(statesByName_.rbegin()->second);
if (!(internalState_ & Bad))
this->destroyDevices();
@@ -296,7 +296,7 @@
{
if (device == NULL)
continue;
- std::string className = device->getClassName();
+ const std::string& className = device->getClassName();
try
{
delete device;
@@ -365,7 +365,7 @@
// ########## ##########
// ############################################################
- void InputManager::update(const Clock& time)
+ void InputManager::preUpdate(const Clock& time)
{
if (internalState_ & Bad)
ThrowException(General, "InputManager was not correctly reloaded.");
@@ -465,7 +465,7 @@
/**
@brief
Updates the currently active states (according to activeStates_) for each device.
- Also, a list of all active states (no duplicates!) is compiled for the general update().
+ Also, a list of all active states (no duplicates!) is compiled for the general preUpdate().
*/
void InputManager::updateActiveStates()
{
@@ -507,7 +507,7 @@
std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
if (mouseStates.empty())
requestedMode = MouseMode::Nonexclusive;
- else
+ else
requestedMode = mouseStates.front()->getMouseMode();
if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)
{
@@ -553,7 +553,7 @@
COUT(0) << "Calibration has been stored." << std::endl;
}
- //! Gets called by WindowEventListener upon focus change --> clear buffers
+ //! Gets called by WindowEventListener upon focus change --> clear buffers
void InputManager::windowFocusChanged()
{
this->clearBuffers();
@@ -578,7 +578,7 @@
InputState* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
{
- if (name == "")
+ if (name.empty())
return 0;
if (statesByName_.find(name) == statesByName_.end())
{
@@ -630,11 +630,16 @@
if (stateDestroyRequests_.find(it->second) == stateDestroyRequests_.end())
{
// not scheduled for destruction
- // prevents a state being added multiple times
+ // prevents a state from being added multiple times
stateEnterRequests_.insert(it->second);
return true;
}
}
+ else if (this->stateLeaveRequests_.find(it->second) != this->stateLeaveRequests_.end())
+ {
+ // State already scheduled for leaving --> cancel
+ this->stateLeaveRequests_.erase(this->stateLeaveRequests_.find(it->second));
+ }
}
return false;
}
@@ -657,6 +662,11 @@
stateLeaveRequests_.insert(it->second);
return true;
}
+ else if (this->stateEnterRequests_.find(it->second) != this->stateEnterRequests_.end())
+ {
+ // State already scheduled for entering --> cancel
+ this->stateEnterRequests_.erase(this->stateEnterRequests_.find(it->second));
+ }
}
return false;
}
Modified: code/trunk/src/libraries/core/input/InputManager.h
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,6 +40,7 @@
#include "core/WindowEventListener.h"
#include "InputState.h"
+// tolua_begin
namespace orxonox
{
/**
@@ -62,8 +63,10 @@
- Keyboard construction is mandatory , mouse and joy sticks are not.
If the OIS::InputManager or the Keyboard fail, an exception is thrown.
*/
- class _CoreExport InputManager : public Singleton<InputManager>, public WindowEventListener
- {
+ class _CoreExport InputManager
+// tolua_end
+ : public Singleton<InputManager>, public WindowEventListener
+ { // tolua_export
friend class Singleton<InputManager>;
public:
//! Represents internal states of the InputManager.
@@ -79,7 +82,7 @@
/**
@brief
Loads the devices and initialises the KeyDetector and the Calibrator.
-
+
If either the OIS input system and/or the keyboard could not be created,
the constructor fails with an std::exception.
*/
@@ -95,7 +98,7 @@
Any InpuStates changes (destroy, enter, leave) and happens here. If a reload request
was submitted while updating, the request will be postponed until the next update call.
*/
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
//! Clears all input device buffers. This usually only includes the pressed button list.
void clearBuffers();
//! Starts joy stick calibration.
@@ -104,7 +107,7 @@
@brief
Reloads all the input devices. Use this method to initialise new joy sticks.
@note
- Only reloads immediately if the call stack doesn't include the update() method.
+ Only reloads immediately if the call stack doesn't include the preUpdate() method.
*/
void reload();
@@ -138,14 +141,14 @@
@return
False if name was not found, true otherwise.
*/
- bool enterState(const std::string& name);
+ bool enterState(const std::string& name); // tolua_export
/**
@brief
Deactivates a specific input state.
@return
False if name was not found, true otherwise.
*/
- bool leaveState(const std::string& name);
+ bool leaveState(const std::string& name); // tolua_export
/**
@brief
Removes and destroys an input state.
@@ -153,7 +156,7 @@
True if removal was successful, false if name was not found.
@remarks
- You can't remove the internal states "empty", "calibrator" and "detector".
- - The removal process is being postponed if InputManager::update() is currently running.
+ - The removal process is being postponed if InputManager::preUpdate() is currently running.
*/
bool destroyState(const std::string& name);
@@ -167,6 +170,8 @@
OIS::InputManager* getOISInputManager() { return this->oisInputManager_; }
std::pair<int, int> getMousePosition() const;
+ static InputManager& getInstance() { return Singleton<InputManager>::getInstance(); } // tolua_export
+
private: // functions
// don't mess with a Singleton
InputManager(const InputManager&);
@@ -206,7 +211,7 @@
std::set<InputState*> stateDestroyRequests_; //!< Requests to destroy a state
static InputManager* singletonPtr_s; //!< Pointer reference to the singleton
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _InputManager_H__ */
Modified: code/trunk/src/libraries/core/input/InputPrereqs.h
===================================================================
--- code/trunk/src/libraries/core/input/InputPrereqs.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputPrereqs.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -201,7 +201,7 @@
Mail = OIS::KC_MAIL, // Mail
MediaSelect = OIS::KC_MEDIASELECT // Media Select
};
-
+
//! Key codes as strings
const char* const ByString[] =
{
Modified: code/trunk/src/libraries/core/input/InputState.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputState.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/InputState.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -101,7 +101,7 @@
{
if (enterFunctor_)
(*enterFunctor_)();
-
+
}
void InputState::left()
Modified: code/trunk/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStick.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/JoyStick.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,6 +32,7 @@
#include <ois/OISJoyStick.h>
#include <boost/foreach.hpp>
+#include "util/StringUtils.h"
#include "core/ConfigFileManager.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
@@ -60,11 +61,11 @@
{
std::string name = oisDevice_->vendor();
replaceCharacters(name, ' ', '_');
- deviceName_ = name + "_";
+ deviceName_ = name + '_';
}
- deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button)) + "_";
- deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis)) + "_";
- deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider)) + "_";
+ deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button)) + '_';
+ deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis)) + '_';
+ deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider)) + '_';
deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_POV));
//deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Vector3));
@@ -73,7 +74,7 @@
if (deviceName_ == idString)
{
// Make the ID unique for this execution time.
- deviceName_ += "_" + multi_cast<std::string>(this->getDeviceName());
+ deviceName_ += '_' + multi_cast<std::string>(this->getDeviceName());
break;
}
}
Modified: code/trunk/src/libraries/core/input/JoyStickQuantityListener.h
===================================================================
--- code/trunk/src/libraries/core/input/JoyStickQuantityListener.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/JoyStickQuantityListener.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -28,7 +28,7 @@
/**
@file
- at brief
+ at brief
*/
#ifndef _JoyStickQuantityListener_H__
Modified: code/trunk/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyBinder.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -28,6 +28,8 @@
#include "KeyBinder.h"
+#include <algorithm>
+#include <sstream>
#include "util/Convert.h"
#include "util/Debug.h"
#include "util/Exception.h"
@@ -49,8 +51,8 @@
{
mouseRelative_[0] = 0;
mouseRelative_[1] = 0;
- mousePosition_[0] = 0;
- mousePosition_[1] = 0;
+ mousePosition_[0] = 0.0;
+ mousePosition_[1] = 0.0;
RegisterRootObject(KeyBinder);
@@ -58,11 +60,11 @@
// keys
for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
{
- std::string keyname = KeyCode::ByString[i];
+ const std::string& keyname = KeyCode::ByString[i];
if (!keyname.empty())
keys_[i].name_ = std::string("Key") + keyname;
else
- keys_[i].name_ = "";
+ keys_[i].name_.clear();
keys_[i].paramCommandBuffer_ = ¶mCommandBuffer_;
keys_[i].groupName_ = "Keys";
}
@@ -125,8 +127,9 @@
.description("Threshold for analog axes until which the state is 0.");
SetConfigValue(bFilterAnalogNoise_, false)
.description("Specifies whether to filter small analog values like joy stick fluctuations.");
- SetConfigValue(mouseSensitivity_, 1.0f)
+ SetConfigValue(mouseSensitivity_, 3.0f)
.description("Mouse sensitivity.");
+ this->totalMouseSensitivity_ = this->mouseSensitivity_ / this->mouseClippingSize_;
SetConfigValue(bDeriveMouseInput_, false)
.description("Whether or not to derive moues movement for the absolute value.");
SetConfigValue(derivePeriod_, 0.05f)
@@ -184,10 +187,10 @@
this->joyStickAxes_.resize(joySticks_.size());
this->joyStickButtons_.resize(joySticks_.size());
- // reinitialise all joy stick binings (doesn't overwrite the old ones)
+ // reinitialise all joy stick bindings (doesn't overwrite the old ones)
for (unsigned int iDev = 0; iDev < joySticks_.size(); iDev++)
{
- std::string deviceName = joySticks_[iDev]->getDeviceName();
+ const std::string& deviceName = joySticks_[iDev]->getDeviceName();
// joy stick buttons
for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
{
@@ -217,21 +220,21 @@
// Note: Don't include the dummy keys which don't actually exist in OIS but have a number
for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
if (!keys_[i].name_.empty())
- allButtons_[keys_[i].groupName_ + "." + keys_[i].name_] = keys_ + i;
+ allButtons_[keys_[i].groupName_ + '.' + keys_[i].name_] = keys_ + i;
for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
- allButtons_[mouseButtons_[i].groupName_ + "." + mouseButtons_[i].name_] = mouseButtons_ + i;
+ allButtons_[mouseButtons_[i].groupName_ + '.' + mouseButtons_[i].name_] = mouseButtons_ + i;
for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
{
- allButtons_[mouseAxes_[i].groupName_ + "." + mouseAxes_[i].name_] = mouseAxes_ + i;
+ allButtons_[mouseAxes_[i].groupName_ + '.' + mouseAxes_[i].name_] = mouseAxes_ + i;
allHalfAxes_.push_back(mouseAxes_ + i);
}
for (unsigned int iDev = 0; iDev < joySticks_.size(); iDev++)
{
for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
- allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + "." + (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]);
+ allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + '.' + (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]);
for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
{
- allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + "." + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]);
+ allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + '.' + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]);
allHalfAxes_.push_back(&((*joyStickAxes_[iDev])[i]));
}
}
@@ -252,7 +255,10 @@
// Parse bindings and create the ConfigValueContainers if necessary
for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
+ {
it->second->readConfigValue(this->configFile_);
+ addButtonToCommand(it->second->bindingString_, it->second);
+ }
COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
}
@@ -262,6 +268,7 @@
std::map<std::string, Button*>::iterator it = allButtons_.find(name);
if (it != allButtons_.end())
{
+ addButtonToCommand(binding, it->second);
if (bTemporary)
it->second->configContainer_->tset(binding);
else
@@ -276,8 +283,86 @@
}
}
+ void KeyBinder::addButtonToCommand(const std::string& command, Button* button)
+ {
+ std::ostringstream stream;
+ stream << button->groupName_ << '.' << button->name_;
+
+ std::vector<std::string>& oldKeynames = this->allCommands_[button->bindingString_];
+ std::vector<std::string>::iterator it = std::find(oldKeynames.begin(), oldKeynames.end(), stream.str());
+ if(it != oldKeynames.end())
+ {
+ oldKeynames.erase(it);
+ }
+
+ if (!command.empty())
+ {
+ std::vector<std::string>& keynames = this->allCommands_[command];
+ if( std::find(keynames.begin(), keynames.end(), stream.str()) == keynames.end())
+ {
+ this->allCommands_[command].push_back(stream.str());
+ }
+ }
+ }
+
/**
@brief
+ Return the first key name for a specific command
+ */
+ const std::string& KeyBinder::getBinding(const std::string& commandName)
+ {
+ if( this->allCommands_.find(commandName) != this->allCommands_.end())
+ {
+ std::vector<std::string>& keynames = this->allCommands_[commandName];
+ return keynames.front();
+ }
+
+ return BLANKSTRING;
+ }
+
+ /**
+ @brief
+ Return the key name for a specific command at a given index.
+ @param commandName
+ The command name the key name is returned for.
+ @param index
+ The index at which the key name is returned for.
+ */
+ const std::string& KeyBinder::getBinding(const std::string& commandName, unsigned int index)
+ {
+ if( this->allCommands_.find(commandName) != this->allCommands_.end())
+ {
+ std::vector<std::string>& keynames = this->allCommands_[commandName];
+ if(index < keynames.size())
+ {
+ return keynames[index];
+ }
+
+ return BLANKSTRING;
+ }
+
+ return BLANKSTRING;
+ }
+
+ /**
+ @brief
+ Get the number of different key bindings of a specific command.
+ @param commandName
+ The command.
+ */
+ unsigned int KeyBinder::getNumberOfBindings(const std::string& commandName)
+ {
+ if( this->allCommands_.find(commandName) != this->allCommands_.end())
+ {
+ std::vector<std::string>& keynames = this->allCommands_[commandName];
+ return keynames.size();
+ }
+
+ return 0;
+ }
+
+ /**
+ @brief
Overwrites all bindings with ""
*/
void KeyBinder::clearBindings()
@@ -394,10 +479,7 @@
}
// these are the actually useful axis bindings for analog input
- if (!bFilterAnalogNoise_ || halfAxis.relVal_ > analogThreshold_ || halfAxis.absVal_ > analogThreshold_)
- {
- halfAxis.execute();
- }
+ halfAxis.execute();
}
/**
@@ -425,23 +507,23 @@
// write absolute values
mouseAxes_[2*i + 0].hasChanged_ = true;
mouseAxes_[2*i + 1].hasChanged_ = true;
- mousePosition_[i] += rel[i];
+ mousePosition_[i] += rel[i] * totalMouseSensitivity_;
// clip absolute position
- if (mousePosition_[i] > mouseClippingSize_)
- mousePosition_[i] = mouseClippingSize_;
- if (mousePosition_[i] < -mouseClippingSize_)
- mousePosition_[i] = -mouseClippingSize_;
+ if (mousePosition_[i] > 1.0)
+ mousePosition_[i] = 1.0;
+ if (mousePosition_[i] < -1.0)
+ mousePosition_[i] = -1.0;
- if (mousePosition_[i] < 0)
+ if (mousePosition_[i] < 0.0)
{
- mouseAxes_[2*i + 0].absVal_ = -mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+ mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i];
mouseAxes_[2*i + 1].absVal_ = 0.0f;
}
else
{
mouseAxes_[2*i + 0].absVal_ = 0.0f;
- mouseAxes_[2*i + 1].absVal_ = mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+ mouseAxes_[2*i + 1].absVal_ = mousePosition_[i];
}
}
}
@@ -451,9 +533,9 @@
for (int i = 0; i < 2; i++)
{
if (rel[i] < 0)
- mouseAxes_[0 + 2*i].relVal_ = -mouseSensitivity_ * rel[i] / mouseClippingSize_;
+ mouseAxes_[0 + 2*i].relVal_ = -rel[i] * totalMouseSensitivity_;
else
- mouseAxes_[1 + 2*i].relVal_ = mouseSensitivity_ * rel[i] / mouseClippingSize_;
+ mouseAxes_[1 + 2*i].relVal_ = rel[i] * totalMouseSensitivity_;
}
}
@@ -473,6 +555,9 @@
void KeyBinder::axisMoved(unsigned int device, unsigned int axisID, float value)
{
+ // Filter analog noise
+ if (this->bFilterAnalogNoise_ && std::abs(value) < this->analogThreshold_)
+ value = 0.0;
int i = axisID * 2;
JoyStickAxisVector& axis = *joyStickAxes_[device];
if (value < 0)
Modified: code/trunk/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyBinder.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,6 +34,7 @@
#include <cassert>
#include <string>
#include <vector>
+#include <map>
#include <boost/shared_ptr.hpp>
#include "InputHandler.h"
@@ -42,8 +43,10 @@
#include "InputCommands.h"
#include "JoyStickQuantityListener.h"
+// tolua_begin
namespace orxonox
{
+ // tolua_end
/**
@brief
Maps mouse, keyboard and joy stick input to command strings and executes them.
@@ -53,14 +56,19 @@
You cannot change the filename because the KeyBinderManager maps these filenames to the
KeyBinders. If you need to load other bindings, just create a new one.
*/
- class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener
- {
+ class _CoreExport KeyBinder // tolua_export
+ : public InputHandler, public JoyStickQuantityListener
+ { // tolua_export
public:
KeyBinder (const std::string& filename);
virtual ~KeyBinder();
void clearBindings();
bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
+ const std::string& getBinding(const std::string& commandName); //tolua_export
+ const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
+ unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
+
const std::string& getBindingsFilename()
{ return this->filename_; }
void setConfigValues();
@@ -129,6 +137,8 @@
std::map<std::string, Button*> allButtons_;
//! Pointer list with all half axes
std::vector<HalfAxis*> allHalfAxes_;
+ //! Maps input commands to all Button names, including half axes
+ std::map< std::string, std::vector<std::string> > allCommands_;
/**
@brief
@@ -137,8 +147,8 @@
*/
std::vector<BufferedParamCommand*> paramCommandBuffer_;
- //! Keeps track of the absolute mouse value (incl. scroll wheel)
- int mousePosition_[2];
+ //! Keeps track of the absolute mouse value
+ float mousePosition_[2];
//! Used to derive mouse input if requested
int mouseRelative_[2];
float deriveTime_;
@@ -149,6 +159,8 @@
ConfigFileType configFile_;
private:
+ void addButtonToCommand(const std::string& command, Button* button);
+
//##### ConfigValues #####
//! Whether to filter small value analog input
bool bFilterAnalogNoise_;
@@ -164,13 +176,16 @@
float mouseSensitivity_;
//! mouse sensitivity if mouse input is derived
float mouseSensitivityDerived_;
- //! Equals one step of the mousewheel
+ //! Equals one step of the mouse wheel
int mouseWheelStepSize_;
+ //! Multiplication of mouse sensitivity and clipping size
+ float totalMouseSensitivity_;
+
//##### Constant config variables #####
// Use some value at about 1000. This can be configured with mouseSensitivity_ anyway.
static const int mouseClippingSize_ = 1024;
- };
+ };// tolua_export
inline void KeyBinder::buttonPressed (const KeyEvent& evt)
@@ -215,6 +230,6 @@
for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
mouseAxes_[i].relVal_ = 0.0f;
}
-}
+}// tolua_export
#endif /* _KeyBinder_H__ */
Modified: code/trunk/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,7 +39,6 @@
namespace orxonox
{
- KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;
ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
KeyBinderManager::KeyBinderManager()
@@ -47,8 +46,6 @@
, bDefaultFileLoaded_(true)
, bBinding_(false)
{
- this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);
-
RegisterObject(KeyBinderManager);
this->setConfigValues();
@@ -57,6 +54,10 @@
.defaultValues("");
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind"))
.defaultValues("");
+ CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind"))
+ .defaultValues("");
+ CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind"))
+ .defaultValues("");
// Load default key binder
this->setCurrent(defaultFilename_);
@@ -67,7 +68,6 @@
// Delete all remaining KeyBinders
for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
delete it->second;
- delete this->callbackFunction_;
}
void KeyBinderManager::setConfigValues()
@@ -92,6 +92,16 @@
this->bDefaultFileLoaded_ = false;
}
+ inline void KeyBinderManager::unbind(const std::string& binding)
+ {
+ this->currentBinder_->setBinding("", binding, false);
+ }
+
+ inline void KeyBinderManager::tunbind(const std::string& binding)
+ {
+ this->currentBinder_->setBinding("", binding, true);
+ }
+
void KeyBinderManager::load(const std::string& filename)
{
std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.find(filename);
@@ -145,7 +155,7 @@
if (!this->bBinding_)
{
COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
- KeyDetector::getInstance().setCallback(callbackFunction_);
+ KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
InputManager::getInstance().enterState("detector");
this->command_ = command;
this->bTemporary_ = bTemporary;
@@ -155,13 +165,23 @@
}
// Gets called by the KeyDetector (registered with a Functor)
- void KeyBinderManager::callback(const std::string& keyName)
+ void KeyBinderManager::keybindKeyPressed(const std::string& keyName)
{
if (this->bBinding_)
{
- COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
- this->currentBinder_->setBinding(command_, keyName, bTemporary_);
+ if (keyName == "Keys.KeyEscape")
+ {
+ COUT(0) << "Keybinding aborted." << std::endl;
+ }
+ else
+ {
+ COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
+ this->currentBinder_->setBinding(command_, keyName, bTemporary_);
+ }
InputManager::getInstance().leaveState("detector");
+ // inform whatever was calling the command
+ if (this->callbackFunction_)
+ (*this->callbackFunction_)();
this->bBinding_ = false;
}
// else: A key was probably pressed within the same tick, ignore it.
Modified: code/trunk/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,11 +33,13 @@
#include <map>
#include <string>
+#include <boost/shared_ptr.hpp>
+
#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
-namespace orxonox
-{
+namespace orxonox //tolua_export
+{ //tolua_export
/**
@brief
Handles the KeyBinders and supplies them throughout the game.
@@ -45,29 +47,30 @@
This interface merely serves to provide a static "keybind" command that always
maps to the currently active KeyBinder. You can set that with setCurrent().
There is also a default one, retrieved with getDefault(). The idea is that
- mostly the default KeyBinder is active except for special situtations (mini-game for inst).
+ mostly the default KeyBinder is active except for special situations (mini-game for inst).
@remarks
You are not forced to use the KeyBinder imposed by getCurrent(). But be aware that "keybind"
will not work as expected!
*/
- class _CoreExport KeyBinderManager : public Singleton<KeyBinderManager>, public OrxonoxClass
- {
+ class _CoreExport KeyBinderManager //tolua_export
+ : public Singleton<KeyBinderManager>, public OrxonoxClass
+ { //tolua_export
friend class Singleton<KeyBinderManager>;
public:
KeyBinderManager();
~KeyBinderManager();
void setConfigValues();
+ static KeyBinderManager& getInstance() { return Singleton<KeyBinderManager>::getInstance(); } //tolua_export
//! Returns the currently selected KeyBinder
- KeyBinder* getCurrent()
- { return this->currentBinder_; }
+ KeyBinder* getCurrent() { return this->currentBinder_; } //tolua_export
//! Like getCurrent(), but returns it as InputHandler* (so you don't have to include KeyBinder.h)
InputHandler* getCurrentAsHandler();
//! Selects the current KeyBinder and creates it if not yet loaded.
void setCurrent(const std::string& filename);
//! Returns the default KeyBinder
- KeyBinder* getDefault()
+ KeyBinder* getDefault()
{ return binders_[this->defaultFilename_]; }
//! Returns the default KeyBinder as InputHandler* (so you don't have to include KeyBinder.h)
InputHandler* getDefaultAsHandler();
@@ -79,26 +82,28 @@
{ this->setCurrent(this->defaultFilename_); }
//! Returns a pointer to a KeyBinder (creates it if not yet loaded)
- KeyBinder* get(const std::string& name);
+ KeyBinder* get(const std::string& name);
//! Like get() but return value is of type InputHandler* (so you don't have to include KeyBinder.h)
InputHandler* getAsHandler(const std::string& name);
//! Loads a KeyBinder by creating it (no different from get() except for the return value)
- void load (const std::string& filename);
+ void load(const std::string& filename);
//! Destroys a KeyBinder completely (does nothing if not yet loaded)
void unload(const std::string& filename);
//! Bind 'command' to any key pressed after this call (use with care!)
- inline void keybind(const std::string& command)
- { this->keybindInternal(command, false); }
+ inline void keybind(const std::string& command) { this->keybindInternal(command, false); } //tolua_export
//! Bind 'command' to any key pressed after this call (use with care!), but temporarily (no file save)
inline void tkeybind(const std::string& command)
{ this->keybindInternal(command, true); }
+ void unbind(const std::string& binding); //tolua_export
+ void tunbind(const std::string& binding);
+ inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export
private:
KeyBinderManager(const KeyBinderManager&);
void keybindInternal(const std::string& command, bool bTemporary);
- void callback(const std::string& keyName);
+ void keybindKeyPressed(const std::string& keyName);
void defaultFilenameChanged();
// KeyBinder management
@@ -108,13 +113,13 @@
std::string defaultFilename_; //! Name of the file with the default key bindings
// keybind command related
- Functor* callbackFunction_; //! Function to be called when key was pressed after "keybind" command
+ shared_ptr<Functor> callbackFunction_; //! Function to be called when key was pressed after "keybind" command
bool bBinding_; //! Tells whether a key binding process is active
bool bTemporary_; //! Stores tkeybind/keybind value
std::string command_; //! Stores the command received by (t)keybind
static KeyBinderManager* singletonPtr_s;
- };
-}
+ }; //tolua_export
+} //tolua_export
#endif /* _KeyBinderManager_H__ */
Modified: code/trunk/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyDetector.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,7 +38,6 @@
namespace orxonox
{
std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
- KeyDetector* KeyDetector::singletonPtr_s = 0;
ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
KeyDetector::KeyDetector()
@@ -67,7 +66,7 @@
clearBindings();
for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
{
- it->second->bindingString_ = callbackCommand_s + " " + it->second->groupName_ + "." + it->second->name_;
+ it->second->bindingString_ = callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_;
it->second->parse();
}
}
Modified: code/trunk/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/KeyDetector.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -31,6 +31,7 @@
#include "InputPrereqs.h"
+#include <boost/shared_ptr.hpp>
#include "util/Singleton.h"
#include "KeyBinder.h"
@@ -44,7 +45,7 @@
KeyDetector();
~KeyDetector();
- void setCallback(Functor* function) { this->callbackFunction_ = function; }
+ void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
private:
KeyDetector(const KeyDetector&);
@@ -53,7 +54,7 @@
void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
void assignCommands();
- Functor* callbackFunction_;
+ shared_ptr<Functor> callbackFunction_;
InputState* inputState_;
static std::string callbackCommand_s;
static KeyDetector* singletonPtr_s;
Modified: code/trunk/src/libraries/core/input/Keyboard.cc
===================================================================
--- code/trunk/src/libraries/core/input/Keyboard.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/core/input/Keyboard.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,6 +42,10 @@
if(arg.key == OIS::KC_RSHIFT || arg.key == OIS::KC_LSHIFT)
modifiers_ |= KeyboardModifier::Shift; // shift key
+ // Do not distribute the alt+tab event (messes with the operating system)
+ if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB)
+ return true;
+
KeyEvent evt(arg);
super::buttonPressed(evt);
return true;
Modified: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/Client.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,8 @@
*/
Client::Client():
isSynched_(false),
- gameStateFailure_(false)
+ gameStateFailure_(false),
+ timeSinceLastUpdate_(0)
{
}
@@ -72,7 +73,8 @@
*/
Client::Client(const std::string& address, int port):
isSynched_(false),
- gameStateFailure_(false)
+ gameStateFailure_(false),
+ timeSinceLastUpdate_(0)
{
setPort( port );
setServerAddress( address );
@@ -110,7 +112,7 @@
// COUT(1) << "Player " << playerID << ": " << message << std::endl;
return true;
}
-
+
void Client::printRTT(){
COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
}
@@ -136,7 +138,7 @@
if(timeSinceLastUpdate_>=NETWORK_PERIOD)
{
timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
- // COUT(3) << ".";
+ // COUT(3) << '.';
if ( isConnected() && isSynched_ )
{
COUT(4) << "popping partial gamestate: " << std::endl;
@@ -152,7 +154,7 @@
}
}
sendPackets(); // flush the enet queue
-
+
Connection::processQueue();
if(gamestate.processGamestates())
{
@@ -164,7 +166,7 @@
return;
}
-
+
void Client::connectionClosed()
{
ObjectList<Synchronisable>::iterator it;
Modified: code/trunk/src/libraries/network/ClientConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnection.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ClientConnection.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,7 +68,7 @@
bool ClientConnection::establishConnection()
{
ENetEvent event;
-
+
this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
if ( this->host_ == NULL )
{
@@ -98,7 +98,7 @@
bool ClientConnection::closeConnection() {
ENetEvent event;
-
+
if ( !this->established_ )
return true;
this->established_ = false;
@@ -145,9 +145,9 @@
// server closed the connection
this->connectionClosed();
}
-
+
uint32_t ClientConnection::getRTT()
- {
+ {
assert(server_);
return server_->roundTripTime;
}
Modified: code/trunk/src/libraries/network/ClientConnection.h
===================================================================
--- code/trunk/src/libraries/network/ClientConnection.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ClientConnection.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
#ifndef _ClientConnection_H__
#define _ClientConnection_H__
@@ -39,10 +39,10 @@
public:
ClientConnection();
virtual ~ClientConnection();
-
+
void setServerAddress( const std::string& serverAddress );
void setPort( unsigned int port );
-
+
ENetEvent *getEvent();
// check wheter the packet queue is empty
bool queueEmpty();
@@ -58,7 +58,7 @@
private:
virtual void addPeer(ENetEvent* event);
virtual void removePeer(ENetEvent* event);
-
+
bool disconnectConnection();
// enet stuff
ENetAddress *serverAddress_;
Modified: code/trunk/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnectionListener.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ClientConnectionListener.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,8 +35,8 @@
namespace orxonox
{
ClientConnectionListener::ClientConnectionListener()
- {
- RegisterRootObject(ClientConnectionListener);
+ {
+ RegisterRootObject(ClientConnectionListener);
}
void ClientConnectionListener::broadcastClientConnected(unsigned int clientID)
@@ -44,7 +44,7 @@
for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
it->clientConnected(clientID);
}
-
+
void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
{
for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
Modified: code/trunk/src/libraries/network/ClientConnectionListener.h
===================================================================
--- code/trunk/src/libraries/network/ClientConnectionListener.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ClientConnectionListener.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,7 +39,7 @@
public:
ClientConnectionListener();
virtual ~ClientConnectionListener() {}
-
+
static void broadcastClientConnected(unsigned int clientID);
static void broadcastClientDisconnected(unsigned int clientID);
Modified: code/trunk/src/libraries/network/ClientInformation.cc
===================================================================
--- code/trunk/src/libraries/network/ClientInformation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ClientInformation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -45,8 +45,8 @@
namespace orxonox
{
-
+
ClientInformation *ClientInformation::head_=0;
ClientInformation::ClientInformation() {
Modified: code/trunk/src/libraries/network/Connection.cc
===================================================================
--- code/trunk/src/libraries/network/Connection.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/Connection.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -74,7 +74,7 @@
void Connection::processQueue() {
ENetEvent event;
-
+
assert(this->host_);
while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
Modified: code/trunk/src/libraries/network/Connection.h
===================================================================
--- code/trunk/src/libraries/network/Connection.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/Connection.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -53,7 +53,7 @@
class _NetworkExport Connection{
public:
virtual ~Connection();
-
+
static bool addPacket(ENetPacket *packet, ENetPeer *peer);
bool sendPackets();
ENetHost* getHost(){ return this->host_; }
@@ -61,15 +61,15 @@
protected:
Connection();
static Connection* getInstance(){ return Connection::instance_; }
-
+
int service(ENetEvent* event);
virtual void disconnectPeer(ENetPeer *peer);
-
+
void processQueue();
virtual void addPeer(ENetEvent* event)=0;
virtual void removePeer(ENetEvent* event)=0;
virtual bool processPacket(ENetEvent* event);
-
+
ENetHost *host_;
private:
ENetAddress *bindAddress_;
Modified: code/trunk/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/FunctionCallManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -30,63 +30,63 @@
#include "packet/FunctionCalls.h"
namespace orxonox {
-
+
std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_;
// Static calls
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallStatic(functionID);
}
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1);
}
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
}
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
}
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
}
void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
}
@@ -94,57 +94,57 @@
// MemberCalls
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID);
}
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
}
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
}
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
}
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
}
void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
- if(clientMap_.find(clientID)==clientMap_.end())
+{
+ if(clientMap_.find(clientID)==clientMap_.end())
{
- FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
- }
+ FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls;
+ FunctionCallManager::clientMap_[clientID]->setClientID(clientID);
+ }
FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
}
Modified: code/trunk/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/FunctionCallManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,16 +48,16 @@
static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-
+
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID);
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1);
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-
+
static void sendCalls();
-
+
static std::map<uint32_t, packet::FunctionCalls*> clientMap_;
protected:
FunctionCallManager();
Modified: code/trunk/src/libraries/network/GamestateClient.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateClient.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/GamestateClient.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -53,7 +53,7 @@
GamestateClient::~GamestateClient() {
std::map<unsigned int, packet::Gamestate *>::iterator it;
for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it )
- delete (*it).second;
+ delete it->second;
if( this->tempGamestate_ )
delete this->tempGamestate_;
}
@@ -80,10 +80,10 @@
int id = GAMESTATEID_INITIAL;
packet::Gamestate *processed = processGamestate(tempGamestate_);
assert(processed);
-
+
//now call the queued callbacks
NetworkCallbackManager::callCallbacks();
-
+
if (!processed){
sendAck(0);
return false;
@@ -125,7 +125,7 @@
if(it->first>=last_diff_)
break;
// otherwise delete that stuff
- delete (*it).second;
+ delete it->second;
temp=it++;
gamestateMap_.erase(temp);
}
@@ -136,7 +136,7 @@
std::map<unsigned int, packet::Gamestate*>::iterator it;
COUT(4) << "gamestates: ";
for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
- COUT(4) << it->first << ":" << it->second << "|";
+ COUT(4) << it->first << ':' << it->second << '|';
}
COUT(4) << std::endl;
Modified: code/trunk/src/libraries/network/GamestateHandler.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateHandler.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/GamestateHandler.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,7 +32,7 @@
namespace orxonox {
GamestateHandler *GamestateHandler::instance_=0;
-
+
GamestateHandler::GamestateHandler()
{
assert(instance_==0);
Modified: code/trunk/src/libraries/network/GamestateManager.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/GamestateManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,13 +68,13 @@
if( this->reference )
delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it;
for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
- delete (*it).second;
+ delete it->second;
std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1;
std::map<unsigned int, packet::Gamestate*>::iterator it2;
for( it1 = gamestateMap_.begin(); it1 != gamestateMap_.end(); ++it1 )
{
for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
- delete (*it2).second;
+ delete it2->second;
}
this->trafficControl_->destroy();
// delete this->threadMutex_;
@@ -125,7 +125,7 @@
}
return true;
}
-
+
void GamestateManager::sendGamestates()
{
ClientInformation *temp = ClientInformation::getBegin();
@@ -141,11 +141,11 @@
COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
int cid = temp->getID(); //get client id
-
+
unsigned int gID = temp->getGamestateID();
if(!reference)
return;
-
+
packet::Gamestate *client=0;
if(gID != GAMESTATEID_INITIAL){
assert(gamestateMap_.find(cid)!=gamestateMap_.end());
@@ -155,21 +155,21 @@
client = it->second;
}
}
-
+
clientGamestates.push(0);
finishGamestate( cid, &clientGamestates.back(), client, reference );
- //FunctorMember<GamestateManager>* functor =
+ //FunctorMember<GamestateManager>* functor =
// ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
// executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
// (*static_cast<Executor*>(executor))();
// this->threadPool_->passFunction( executor, true );
// (*functor)( cid, &(clientGamestates.back()), client, reference );
-
+
temp = temp->next();
}
-
+
// threadPool_->synchronise();
-
+
while( !clientGamestates.empty() )
{
if(clientGamestates.front())
@@ -184,7 +184,7 @@
//Server::sendGameState?
// save the (undiffed) gamestate in the clients gamestate map
//chose wheather the next gamestate is the first or not
-
+
packet::Gamestate *gs = gamestate->doSelection(clientID, 20000);
// packet::Gamestate *gs = new packet::Gamestate(*gamestate);
// packet::Gamestate *gs = new packet::Gamestate();
@@ -192,10 +192,10 @@
// this->threadMutex_->lock();
gamestateMap_[clientID][gamestate->getID()]=gs;
// this->threadMutex_->unlock();
-
+
if(base)
{
-
+
// COUT(3) << "diffing" << std::endl;
// packet::Gamestate* gs1 = gs;
packet::Gamestate *diffed = gs->diff(base);
@@ -209,8 +209,8 @@
else{
gs = new packet::Gamestate(*gs);
}
-
-
+
+
bool b = gs->compressData();
assert(b);
// COUT(4) << "sending gamestate with id " << gs->getID();
Modified: code/trunk/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/NetworkFunction.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -31,67 +31,82 @@
namespace orxonox
{
- std::map<std::string, NetworkFunctionBase*> NetworkFunctionBase::nameMap_;
std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
-
- std::map<NetworkFunctionPointer, NetworkFunctionStatic*> NetworkFunctionStatic::functorMap_;
- std::map<uint32_t, NetworkFunctionStatic*> NetworkFunctionStatic::idMap_;
-
+
std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
{
RegisterRootObject(NetworkFunctionBase);
-
+
static uint32_t networkID = 0;
this->networkID_ = networkID++;
-
+
this->name_ = name;
- nameMap_[name] = this;
+ NetworkFunctionBase::getNameMap()[name] = this;
}
NetworkFunctionBase::~NetworkFunctionBase()
{
}
-
-
+
+
void NetworkFunctionBase::destroyAllNetworkFunctions()
{
+ std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
std::map<std::string, NetworkFunctionBase*>::iterator it;
- for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it )
+ for( it=map.begin(); it!=map.end(); ++it )
it->second->destroy();
}
-
-
+
+
+ /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
+ {
+ static std::map<std::string, NetworkFunctionBase*> nameMap_;
+ return nameMap_;
+ }
+
+
NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
NetworkFunctionBase(name)
{
RegisterObject(NetworkFunctionStatic);
-
+
this->functor_ = functor;
- functorMap_[p] = this;
- idMap_[ this->getNetworkID() ] = this;
+ NetworkFunctionStatic::getFunctorMap()[p] = this;
+ NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
}
-
+
NetworkFunctionStatic::~NetworkFunctionStatic()
{
delete this->functor_;
}
-
-
-
+
+ /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
+ {
+ static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
+ return functorMap_;
+ }
+
+ /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
+ {
+ static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
+ return idMap_;
+ }
+
+
NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
NetworkFunctionBase(name)
{
RegisterObject(NetworkMemberFunctionBase);
-
- functorMap_[p] = this;
- idMap_[ this->getNetworkID() ] = this;
+
+ this->functorMap_[p] = this;
+ this->idMap_[ this->getNetworkID() ] = this;
}
-
+
NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
{
}
-
+
}
Modified: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/NetworkFunction.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -73,24 +73,29 @@
public:
NetworkFunctionBase(const std::string& name);
~NetworkFunctionBase();
-
+
virtual void setNetworkID(uint32_t id) { this->networkID_ = id; }
inline uint32_t getNetworkID() const { return this->networkID_; }
inline const std::string& getName() const { return name_; }
static inline bool isStatic( uint32_t networkID ) { return isStaticMap_[networkID]; }
-
- static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); }
-
+
+ static inline void setNetworkID(const std::string& name, uint32_t id)
+ {
+ std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
+ assert( map.find(name)!=map.end() );
+ map[name]->setNetworkID(id);
+ }
+
static void destroyAllNetworkFunctions();
-
+
protected:
static std::map<uint32_t, bool> isStaticMap_;
-
+
private:
- static std::map<std::string, NetworkFunctionBase*> nameMap_;
+ static std::map<std::string, NetworkFunctionBase*>& getNameMap();
uint32_t networkID_;
std::string name_;
-
+
};
@@ -98,25 +103,28 @@
public:
NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
~NetworkFunctionStatic();
-
+
inline void call(){ (*this->functor_)(); }
inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
-
- virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
- static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
- static NetworkFunctionStatic* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
- static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-
+
+ virtual void setNetworkID( uint32_t id )
+ { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
+ static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
+ { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
+ static NetworkFunctionStatic* getFunction( uint32_t id )
+ { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
+ static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
+ { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
+
private:
- static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
- static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
-
+ static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
+ static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
FunctorStatic* functor_;
-
+
};
@@ -124,20 +132,20 @@
public:
NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
~NetworkMemberFunctionBase();
-
+
virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-
- //
+
+ //
virtual void call(uint32_t objectID)=0;
virtual void call(uint32_t objectID, const MultiType& mt1)=0;
virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
virtual void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
-
+
private:
static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
@@ -148,38 +156,38 @@
public:
NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
~NetworkMemberFunction();
-
+
inline void call(uint32_t objectID)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)));
}
inline void call(uint32_t objectID, const MultiType& mt1)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
}
inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
}
inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
}
inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
}
inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
- {
+ {
if ( Synchronisable::getSynchronisable(objectID)!=0 )
(*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
}
-
+
private:
FunctorMember<T>* functor_;
};
Modified: code/trunk/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrereqs.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/NetworkPrereqs.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -143,6 +143,8 @@
// synchronisable
template <class T>
class NetworkCallback;
+ template <class T, class U>
+ class NetworkCallbackNotify;
class NetworkCallbackBase;
class NetworkCallbackManager;
class Synchronisable;
Modified: code/trunk/src/libraries/network/Server.cc
===================================================================
--- code/trunk/src/libraries/network/Server.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/Server.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -136,15 +136,15 @@
void Server::update(const Clock& time) {
// receive incoming packets
Connection::processQueue();
-
+
if ( ClientInformation::hasClients() )
{
// process incoming gamestates
GamestateManager::processGamestates();
-
+
// send function calls to clients
FunctionCallManager::sendCalls();
-
+
//this steers our network frequency
timeSinceLastUpdate_+=time.getDeltaTime();
if(timeSinceLastUpdate_>=NETWORK_PERIOD)
@@ -159,15 +159,15 @@
bool Server::queuePacket(ENetPacket *packet, int clientID){
return ServerConnection::addPacket(packet, clientID);
}
-
+
/**
- * @brief: returns ping time to client in milliseconds
+ * @brief: returns ping time to client in milliseconds
*/
unsigned int Server::getRTT(unsigned int clientID){
assert(ClientInformation::findClient(clientID));
return ClientInformation::findClient(clientID)->getRTT();
}
-
+
void Server::printRTT()
{
for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() )
@@ -316,16 +316,16 @@
return false;
}
COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
-
+
// synchronise class ids
syncClassid(temp->getID());
-
+
// now synchronise functionIDs
packet::FunctionIDs *fIDs = new packet::FunctionIDs();
fIDs->setClientID(clientID);
bool b = fIDs->send();
assert(b);
-
+
temp->setSynched(true);
COUT(4) << "sending welcome" << std::endl;
packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
@@ -343,7 +343,7 @@
assert(b);
return true;
}
-
+
void Server::disconnectClient( ClientInformation *client ){
ServerConnection::disconnectClient( client );
GamestateManager::removeClient(client);
Modified: code/trunk/src/libraries/network/Server.h
===================================================================
--- code/trunk/src/libraries/network/Server.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/Server.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -65,10 +65,10 @@
virtual bool isServer_(){return true;}
unsigned int shipID(){return 0;}
unsigned int playerID(){return 0;}
-
+
void addPeer(ENetEvent *event);
void removePeer(ENetEvent *event);
-
+
bool createClient(int clientID);
void disconnectClient( ClientInformation *client);
bool processPacket( ENetPacket *packet, ENetPeer *peer );
Modified: code/trunk/src/libraries/network/ServerConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ServerConnection.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ServerConnection.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -98,12 +98,12 @@
enet_host_broadcast( Connection::getInstance()->getHost(), 0, packet);
return true;
}
-
+
void ServerConnection::disconnectClient(ClientInformation *client)
{
Connection::disconnectPeer( client->getPeer() );
}
-
+
void ServerConnection::disconnectClient(int clientID){
ClientInformation *client = ClientInformation::findClient(clientID);
if(client)
Modified: code/trunk/src/libraries/network/ServerConnection.h
===================================================================
--- code/trunk/src/libraries/network/ServerConnection.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/ServerConnection.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,10 +49,10 @@
class _NetworkExport ServerConnection : public Connection{
public:
~ServerConnection();
-
+
void setBindAddress( const std::string& bindAddress );
void setPort( unsigned int port );
-
+
bool openListener();
bool closeListener();
static bool addPacket(ENetPacket *packet, unsigned int ID);
Modified: code/trunk/src/libraries/network/TrafficControl.cc
===================================================================
--- code/trunk/src/libraries/network/TrafficControl.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/TrafficControl.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -144,25 +144,25 @@
assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
-
+
// shortcut for maps
std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
{
- if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
+ if(objectListPerm.find(itvec->objID) != objectListPerm.end()) // check whether the obj already exists in our lists
{
- objectListPerm[(*itvec).objID].objCurGS = gamestateID;
- objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
+ objectListPerm[itvec->objID].objCurGS = gamestateID;
+ objectListPerm[itvec->objID].objValueSched = 0; //set scheduling value back
}
else
{
assert(0);
- objectListPerm[(*itvec).objID].objCurGS = gamestateID;
- objectListPerm[(*itvec).objID].objID = (*itvec).objID;
- objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
- objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
+ objectListPerm[itvec->objID].objCurGS = gamestateID;
+ objectListPerm[itvec->objID].objID = itvec->objID;
+ objectListPerm[itvec->objID].objCreatorID = itvec->objCreatorID;
+ objectListPerm[itvec->objID].objSize = itvec->objSize;
}
}
// remove temporary list (with acked objects) from the map
@@ -204,15 +204,15 @@
assert(!list.empty());
for(itvec = list.begin(); itvec != list.end();)
{
- assert( (*itvec).objSize < 1000);
- if ( ( size + (*itvec).objSize ) < targetsize )
+ assert( itvec->objSize < 1000);
+ if ( ( size + itvec->objSize ) < targetsize )
{
- size += (*itvec).objSize;//objSize is given in bytes
+ size += itvec->objSize;//objSize is given in bytes
++itvec;
}
else
{
- clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
+ clientListPerm_[currentClientID][itvec->objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
list.erase(itvec, list.end());
break;
}
@@ -235,16 +235,16 @@
//compare listToProcess vs clientListPerm
//if listToProcess contains new Objects, add them to clientListPerm
std::list<obj>::iterator itvec;
-
+
std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
-
+
for( itvec=list.begin(); itvec != list.end(); itvec++)
{
- if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
+ if ( objectListPerm.find( itvec->objID) != objectListPerm.end() )
{
// we already have the object in our map
//obj bleibt in liste und permanente prio wird berechnet
- objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
+ objectListPerm[itvec->objID].objDiffGS = currentGamestateID - objectListPerm[itvec->objID].objCurGS;
continue;//check next objId
}
else
@@ -255,12 +255,12 @@
}
}
//end compare listToProcess vs clientListPerm
-
+
//sort copied list according to priorities
// use boost bind here because we need to pass a memberfunction to stl sort
// sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
-
+
// list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
//now we check, that the creator of an object always exists on a client
@@ -276,7 +276,7 @@
//now sort again after objDataOffset
// sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
-
+
//diese Funktion updateClientList muss noch gemacht werden
updateClientListTemp(list);
//end of sorting
@@ -288,19 +288,19 @@
std::list<obj>::iterator it;
COUT(0) << "=========== Objectlist ===========" << endl;
for( it=list.begin(); it!=list.end(); it++)
- COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
+ COUT(0) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;
}
void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
{
- if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
+ if ( it1->objCreatorID == OBJECTID_UNKNOWN )
return;
- if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
+ if( clientListPerm_[clientID][it1->objCreatorID].objCurGS != GAMESTATEID_INITIAL )
return;
std::list<obj>::iterator it2, it3=it1;
for( it2 = ++it3; it2 != list.end(); it2++ )
{
- if( (*it2).objID == (*it1).objCreatorID )
+ if( it2->objID == it1->objCreatorID )
{
it3 = list.insert(it1, *it2); //insert creator before it1
list.erase(it2);
Modified: code/trunk/src/libraries/network/TrafficControl.h
===================================================================
--- code/trunk/src/libraries/network/TrafficControl.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/TrafficControl.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,10 +68,10 @@
obj();
obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset );
};
-
+
/**
*
*/
@@ -96,22 +96,22 @@
unsigned int currentClientID;
unsigned int targetSize;
bool bActive_;
-
+
void insertinClientListPerm(unsigned int clientID, obj objinf);
-
+
void cut(std::list<obj>& list, unsigned int targetsize);
void updateClientListTemp(std::list<obj>& list);//done
/**
*evaluates Data given (list) and produces result(->Data to be updated)
*/
- void evaluateList(unsigned int clientID, std::list<obj>& list);//done
+ void evaluateList(unsigned int clientID, std::list<obj>& list);//done
void ack(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client
-
+
//ClientConnectionListener functions
virtual void clientConnected(unsigned int clientID){};
virtual void clientDisconnected(unsigned int clientID);
-
+
protected:
static TrafficControl *instance_;
@@ -120,7 +120,7 @@
virtual ~TrafficControl();
/**
*is being used by GSManager from Server:
- *list contains: ObjIds, CreatorIds, Size (in this order) from Client XY
+ *list contains: ObjIds, CreatorIds, Size (in this order) from Client XY
*Elements of list are accessed by *list[i]
*Elements of struct i are therefore: *list[i].objID
*/
@@ -130,7 +130,7 @@
static void processAck(unsigned int clientID, unsigned int gamestateID)
{ return instance_->ack(clientID, gamestateID); }
void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps)
-
+
bool prioritySort(uint32_t clientID, obj i, obj j);
bool dataSort(obj i, obj j);
void printList(std::list<obj>& list, unsigned int clientID);
Modified: code/trunk/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Acknowledgement.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/Acknowledgement.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -37,7 +37,7 @@
#define PACKET_FLAGS_ACK 0
#define _PACKETID 0
#define _ACKID _PACKETID + sizeof(packet::Type::Value)
-
+
Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
: Packet()
{
Modified: code/trunk/src/libraries/network/packet/Chat.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Chat.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/Chat.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,7 +34,7 @@
namespace orxonox {
namespace packet {
-
+
#define PACKET_FLAGS_CHAT PacketFlag::Reliable
#define _PACKETID 0
const int _PLAYERID = _PACKETID + sizeof(Type::Value);
Modified: code/trunk/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/trunk/src/libraries/network/packet/ClassID.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/ClassID.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -47,7 +47,6 @@
ClassID::ClassID( ) : Packet(){
Identifier *id;
- std::string classname;
unsigned int nrOfClasses=0;
unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
uint32_t network_id;
@@ -57,10 +56,10 @@
//calculate total needed size (for all strings and integers)
std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin();
for(;it != Identifier::getStringIdentifierMapEnd();++it){
- id = (*it).second;
+ id = it->second;
if(id == NULL || !id->hasFactory())
continue;
- classname = id->getName();
+ const std::string& classname = id->getName();
network_id = id->getNetworkID();
// now push the network id and the classname to the stack
tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
Modified: code/trunk/src/libraries/network/packet/ClassID.h
===================================================================
--- code/trunk/src/libraries/network/packet/ClassID.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/ClassID.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,7 +35,7 @@
namespace orxonox {
namespace packet {
-
+
/**
@author
*/
Modified: code/trunk/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/trunk/src/libraries/network/packet/DeleteObjects.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/DeleteObjects.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,7 +40,7 @@
#define _PACKETID 0
#define _QUANTITY _PACKETID + sizeof(Type::Value)
#define _OBJECTIDS _QUANTITY + sizeof(uint32_t)
-
+
DeleteObjects::DeleteObjects()
: Packet()
{
@@ -70,9 +70,8 @@
tdata += sizeof(uint32_t);
for(unsigned int i=0; i<number; i++){
unsigned int temp = Synchronisable::popDeletedObject();
-// assert(temp<10000); //ugly hack
*reinterpret_cast<uint32_t*>(tdata) = temp;
- COUT(4) << temp << " ";
+ COUT(4) << temp << ' ';
tdata += sizeof(uint32_t);
}
COUT(4) << std::endl;
Modified: code/trunk/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,11 +35,11 @@
namespace orxonox {
namespace packet {
-
+
#define PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable
#define _PACKETID 0
const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
-
+
FunctionCalls::FunctionCalls()
: Packet()
{
@@ -170,7 +170,7 @@
void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
assert(!isDataENetAllocated());
-
+
// first determine the size that has to be reserved for this call
uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
uint32_t nrOfArguments = 0;
@@ -199,7 +199,7 @@
}
}
}
-
+
// now allocated mem if neccessary
if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
{
@@ -209,7 +209,7 @@
delete[] data_;
data_ = temp;
}
-
+
// now serialise the mt values and copy the function id and isStatic
uint8_t* temp = data_+currentSize_;
*(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
@@ -239,12 +239,12 @@
}
//currentSize_ += callsize;
currentSize_ = temp-data_;
-
+
}
void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
assert(!isDataENetAllocated());
-
+
// first determine the size that has to be reserved for this call
uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID
uint32_t nrOfArguments = 0;
@@ -273,7 +273,7 @@
}
}
}
-
+
// now allocated mem if neccessary
if( currentSize_ + callsize > currentMemBlocks_*FUNCTIONCALLS_MEM_ALLOCATION )
{
@@ -283,7 +283,7 @@
delete[] data_;
data_ = temp;
}
-
+
// now serialise the mt values and copy the function id
uint8_t* temp = data_+currentSize_;
*(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls
@@ -313,7 +313,7 @@
}
}
currentSize_ += callsize;
-
+
}
Modified: code/trunk/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionIDs.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/FunctionIDs.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -46,34 +46,33 @@
FunctionIDs::FunctionIDs( ) : Packet(){
- std::string functionname;
- unsigned int nrOfFunctions=0;
+ unsigned int nrOfFunctions=0;
unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nroffunctions
uint32_t networkID;
flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS;
std::queue<std::pair<uint32_t, std::string> > tempQueue;
-
+
//calculate total needed size (for all strings and integers)
ObjectList<NetworkFunctionBase>::iterator it;
for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it){
- functionname = it->getName();
+ const std::string& functionname = it->getName();
networkID = it->getNetworkID();
// now push the network id and the classname to the stack
tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
++nrOfFunctions;
packetSize += (functionname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); // reserver size for the functionname string, the functionname length and the networkID
}
-
+
this->data_=new uint8_t[ packetSize ];
//set the appropriate packet id
assert(this->data_);
*(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs;
-
+
uint8_t *temp=data_+sizeof(uint32_t);
// save the number of all classes
*(uint32_t*)temp = nrOfFunctions;
temp += sizeof(uint32_t);
-
+
// now save all classids and classnames
std::pair<uint32_t, std::string> tempPair;
while( !tempQueue.empty() ){
@@ -84,9 +83,9 @@
memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
}
-
+
COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
-
+
}
FunctionIDs::FunctionIDs( uint8_t* data, unsigned int clientID )
@@ -105,7 +104,7 @@
uint32_t nrOfFunctions = *(uint32_t*)temp;
temp += sizeof(uint32_t);
totalsize += sizeof(uint32_t); // storage size for nr of all classes
-
+
for(unsigned int i=0; i<nrOfFunctions; i++){
totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); // for each network function add size for id, sizeof(string) and length of string itself to totalsize
temp += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
@@ -120,13 +119,13 @@
uint32_t networkID;
uint32_t stringsize;
unsigned char *functionname;
-
+
COUT(4) << "=== processing functionids: " << endl;
std::pair<uint32_t, std::string> tempPair;
// read the total number of classes
nrOfFunctions = *(uint32_t*)temp;
temp += sizeof(uint32_t);
-
+
for( int i=0; i<nrOfFunctions; i++){
networkID = *(uint32_t*)temp;
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
Modified: code/trunk/src/libraries/network/packet/FunctionIDs.h
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionIDs.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/FunctionIDs.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,7 +35,7 @@
namespace orxonox {
namespace packet {
-
+
/**
@author
*/
Modified: code/trunk/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Gamestate.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/Gamestate.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -94,7 +94,7 @@
COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
return false;
}
-
+
// create the header object
assert( header_ == 0 );
header_ = new GamestateHeader(data_);
@@ -104,13 +104,13 @@
mem += GamestateHeader::getSize();
ObjectList<Synchronisable>::iterator it;
for(it = ObjectList<Synchronisable>::begin(); it; ++it){
-
+
// tempsize=it->getSize(id, mode);
tempsize = it->getData(mem, id, mode);
if ( tempsize != 0 )
dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
-
+
#ifndef NDEBUG
if(currentsize+tempsize > size){
assert(0); // if we don't use multithreading this part shouldn't be neccessary
@@ -361,17 +361,17 @@
assert(this && base); assert(data_ && base->data_);
assert(!header_->isCompressed() && !base->header_->isCompressed());
assert(!header_->isDiffed());
-
+
uint8_t *basep = GAMESTATE_START(base->data_);
uint8_t *gs = GAMESTATE_START(this->data_);
uint32_t dest_length = header_->getDataSize();
-
+
if(dest_length==0)
return NULL;
-
+
uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
uint8_t *dest = GAMESTATE_START(ndata);
-
+
rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() );
#ifndef NDEBUG
uint8_t *dest2 = new uint8_t[dest_length];
@@ -397,19 +397,19 @@
assert(this && base); assert(data_ && base->data_);
assert(!header_->isCompressed() && !base->header_->isCompressed());
assert(header_->isDiffed());
-
+
uint8_t *basep = GAMESTATE_START(base->data_);
uint8_t *gs = GAMESTATE_START(this->data_);
uint32_t dest_length = header_->getDataSize();
-
+
if(dest_length==0)
return NULL;
-
+
uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
uint8_t *dest = ndata + GamestateHeader::getSize();
-
+
rawDiff( dest, gs, basep, header_->getDataSize(), base->header_->getDataSize() );
-
+
Gamestate *g = new Gamestate(ndata, getClientID());
assert(g->header_);
*(g->header_) = *header_;
@@ -436,8 +436,8 @@
// return NULL;
// uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
// uint8_t *dest = ndata + GamestateHeader::getSize();
-//
-//
+//
+//
// // LOOP-UNROLLED DIFFING
// uint32_t *dest32 = (uint32_t*)dest, *base32 = (uint32_t*)basep, *gs32 = (uint32_t*)gs;
// // diff in 4-byte steps
@@ -464,7 +464,7 @@
// *(dest+4*of+of2)=*(gs+4*of+of2); // same as 0 ^ *(gs32+of)
// }
// }
-//
+//
// Gamestate *g = new Gamestate(ndata, getClientID());
// *(g->header_) = *header_;
// g->header_->setDiffed( true );
@@ -480,7 +480,7 @@
uint64_t* gd = (uint64_t*)data;
uint64_t* bd = (uint64_t*)basedata;
uint64_t* nd = (uint64_t*)newdata;
-
+
unsigned int i;
for( i=0; i<datalength/8; i++ )
{
@@ -528,19 +528,19 @@
// std::list<obj>::iterator itt;
// COUT(0) << "myvector contains:";
// for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
-// COUT(0) << " " << (*itt).objID;
+// COUT(0) << ' ' << (*itt).objID;
// COUT(0) << endl;
for(it=dataVector_.begin(); it!=dataVector_.end();){
SynchronisableHeader oldobjectheader(origdata);
SynchronisableHeader newobjectheader(newdata);
- if ( (*it).objSize == 0 )
+ if ( it->objSize == 0 )
{
++it;
continue;
}
objectsize = oldobjectheader.getDataSize();
objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
- if ( (*it).objID == oldobjectheader.getObjectID() ){
+ if ( it->objID == oldobjectheader.getObjectID() ){
memcpy(newdata, origdata, objectsize);
assert(newobjectheader.isDataAvailable()==true);
++it;
Modified: code/trunk/src/libraries/network/packet/Packet.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Packet.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/packet/Packet.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -100,8 +100,8 @@
/**
@brief
Destroys a packet completely.
-
- That also means destroying the ENetPacket if one exists. There
+
+ That also means destroying the ENetPacket if one exists. There
*/
Packet::~Packet(){
// Deallocate data_ memory if necessary.
Modified: code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/synchronisable/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,7 +1,6 @@
ADD_SOURCE_FILES(NETWORK_SRC_FILES
NetworkCallbackManager.cc
Synchronisable.cc
- SynchronisableSpecialisations.cc
SynchronisableVariable.cc
)
Modified: code/trunk/src/libraries/network/synchronisable/NetworkCallback.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallback.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallback.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,9 +32,12 @@
#include "network/NetworkPrereqs.h"
#include "NetworkCallbackManager.h"
+// #include "util/MultiType.h"
namespace orxonox{
-
+
+ struct EmptyType{};
+
class _NetworkExport NetworkCallbackBase
{
public:
@@ -57,6 +60,22 @@
void (T::*function_) (void);
};
+ template <class T, class U>
+ class NetworkCallbackNotify: public NetworkCallbackBase
+ {
+ public:
+ NetworkCallbackNotify(T* object, void (T::*function) (const U&)) : object_(object), function_(function) {}
+ NetworkCallbackNotify() {}
+ virtual ~NetworkCallbackNotify() {}
+ virtual void call()
+ { (this->object_->*function_)( this->oldValue_ ); }
+ void setOldValue(const U& value){ this->oldValue_ = value; }
+ private:
+ T* object_;
+ U oldValue_;
+ void (T::*function_) (const U&);
+ };
+
}
Modified: code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,18 +25,18 @@
* ...
*
*/
-
+
#include "NetworkCallbackManager.h"
#include "NetworkCallback.h"
namespace orxonox{
-
+
std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
-
+
void NetworkCallbackManager::registerCallback(NetworkCallbackBase *cb)
- {
- callbackSet_.insert(cb);
+ {
+ callbackSet_.insert(cb);
}
void NetworkCallbackManager::deleteCallback(NetworkCallbackBase *cb)
{
@@ -47,7 +47,7 @@
delete cb;
}
}
-
+
void NetworkCallbackManager::triggerCallback(NetworkCallbackBase *cb)
{
if (triggeredCallbacks_.empty() || triggeredCallbacks_.front() != cb)
Modified: code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,7 +36,7 @@
#include <queue>
namespace orxonox{
-
+
class _NetworkExport NetworkCallbackManager{
public:
static void registerCallback(NetworkCallbackBase *cb);
@@ -47,8 +47,8 @@
static std::set<NetworkCallbackBase*> callbackSet_;
static std::queue<NetworkCallbackBase*> triggeredCallbacks_;
};
-
+
}
Copied: code/trunk/src/libraries/network/synchronisable/Serialise.h (from rev 6415, code/branches/presentation2/src/libraries/network/synchronisable/Serialise.h)
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h (rev 0)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,79 @@
+/*
+ * 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:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Functions to serialise pointers to objects that inherit from Synchronisable
+*/
+
+#ifndef _NetworkSerialise_H__
+#define _NetworkSerialise_H__
+
+#include "util/Serialise.h"
+#include "util/TypeTraits.h"
+#include "core/CorePrereqs.h"
+
+namespace orxonox{
+
+ // These functions implement loading / saving / etc. for pointer types
+
+ /** @brief returns the size of the objectID needed to synchronise the pointer */
+ template <class T> inline uint32_t returnSize( T*& variable )
+ {
+ return sizeof(uint32_t);
+ }
+
+ /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
+ template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem )
+ {
+ *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
+ mem += returnSize( variable );
+ }
+
+ /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
+ template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem )
+ {
+ if ( variable )
+ *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
+ else
+ *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
+ mem += returnSize( variable );
+ }
+
+ /** @brief checks whether the objectID of the variable is the same as in the bytestream */
+ template <class T> inline bool checkEquality( T*& variable, uint8_t* mem )
+ {
+ if ( variable )
+ return *(uint32_t*)(mem) == variable->getObjectID();
+ else
+ return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
+ }
+}
+
+
+#endif
Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,7 @@
objectID_=OBJECTID_UNKNOWN;
}
classID_ = static_cast<uint32_t>(-1);
-
+
// set dataSize to 0
this->dataSize_ = 0;
// set standard priority
@@ -276,14 +276,14 @@
tempsize += (*i)->getData( mem, mode );
//tempsize += (*i)->getSize( mode );
}
-
+
tempsize += SynchronisableHeader::getSize();
header.setObjectID( this->objectID_ );
header.setCreatorID( this->creatorID_ );
header.setClassID( this->classID_ );
header.setDataAvailable( true );
header.setDataSize( tempsize );
-
+
#ifndef NDEBUG
uint32_t size;
size=getSize(id, mode);
@@ -389,5 +389,16 @@
this->objectMode_=mode;
}
+ template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+ {
+ SynchronisableVariableBase* sv;
+ if (bidirectional)
+ sv = new SynchronisableVariableBidirectional<std::string>(variable, mode, cb);
+ else
+ sv = new SynchronisableVariable<std::string>(variable, mode, cb);
+ syncList.push_back(sv);
+ stringList.push_back(sv);
+ }
+
}
Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -65,8 +65,8 @@
}
/**
- * @brief: stores information about a Synchronisable
- *
+ * @brief: stores information about a Synchronisable
+ *
* This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
* in an emulated bitset.
* Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
@@ -131,13 +131,13 @@
inline uint32_t getClassID() const {return this->classID_;}
inline unsigned int getPriority() const { return this->objectFrequency_;}
inline uint8_t getSyncMode() const { return this->objectMode_; }
-
+
void setSyncMode(uint8_t mode);
protected:
Synchronisable(BaseObject* creator);
template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
- //template <class T> void unregisterVariable(T& var);
+
void setPriority(unsigned int freq){ objectFrequency_ = freq; }
@@ -147,7 +147,7 @@
bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
bool isMyData(uint8_t* mem);
bool doSync(int32_t id, uint8_t mode=0x0);
-
+
inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
inline void setClassID(uint32_t id){ this->classID_ = id; }
@@ -166,56 +166,24 @@
static std::queue<uint32_t> deletedObjects_;
};
- // ================= Specialisation declarations
-
-// template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
- template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-
template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
{
if (bidirectional)
{
- syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
+ syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb));
this->dataSize_ += syncList.back()->getSize(state_);
}
else
{
- syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+ syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb));
if ( this->state_ == mode )
this->dataSize_ += syncList.back()->getSize(state_);
}
}
-
+ template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
-// template <class T> void Synchronisable::unregisterVariable(T& var){
-// std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
-// while(it!=syncList.end()){
-// if( ((*it)->getReference()) == &var ){
-// delete (*it);
-// syncList.erase(it);
-// return;
-// }
-// else
-// it++;
-// }
-// bool unregistered_nonexistent_variable = false;
-// assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
-// // the variable has not been registered before
-// }
-
}
#endif /* _Synchronisable_H__ */
Deleted: code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,111 +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:
- * Dumeni Manatschal, (C) 2007
- * Oliver Scheuss, (C) 2007
- * Co-authors:
- * ...
- *
- */
-
-#include <string>
-#include "util/Math.h"
-#include "Synchronisable.h"
-#include "SynchronisableVariable.h"
-
-// ================ template spezialisation
-
-
-namespace orxonox{
-
- template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
- {
- SynchronisableVariableBase* sv;
- if (bidirectional)
- sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
- else
- sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
- syncList.push_back(sv);
- stringList.push_back(sv);
- }
-
- template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.r, mode, cb, bidirectional);
- registerVariable(variable.g, mode, cb, bidirectional);
- registerVariable(variable.b, mode, cb, bidirectional);
- registerVariable(variable.a, mode, cb, bidirectional);
- }
- template <> void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- return Synchronisable::registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
- }
-
- template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.x, mode, cb, bidirectional);
- registerVariable(variable.y, mode, cb, bidirectional);
- }
-
- template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.x, mode, cb, bidirectional);
- registerVariable(variable.y, mode, cb, bidirectional);
- registerVariable(variable.z, mode, cb, bidirectional);
- }
- template <> void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable( (const Vector3&)variable, mode, cb, bidirectional);
- }
-
- template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.x, mode, cb, bidirectional);
- registerVariable(variable.y, mode, cb, bidirectional);
- registerVariable(variable.z, mode, cb, bidirectional);
- registerVariable(variable.w, mode, cb, bidirectional);
- }
- template <> void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable( (const Vector4&)variable, mode, cb, bidirectional);
- }
-
- template <> void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.getMemory(), mode, cb, bidirectional);
- }
-
- template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable(variable.x, mode, cb, bidirectional);
- registerVariable(variable.y, mode, cb, bidirectional);
- registerVariable(variable.z, mode, cb, bidirectional);
- registerVariable(variable.w, mode, cb, bidirectional);
- }
- template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
- {
- registerVariable( (const Quaternion&)variable, mode, cb, bidirectional);
- }
-
-
-
-} //namespace
Modified: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,13 +34,13 @@
#include <cassert>
#include <cstring>
-#include "util/Serialise.h"
+#include "Serialise.h"
#include "util/TypeTraits.h"
#include "core/GameMode.h"
#include "network/synchronisable/NetworkCallbackManager.h"
namespace orxonox{
-
+
namespace VariableDirection{
enum Value{
ToClient=0x1,
@@ -53,7 +53,7 @@
ClientMaster=0x2
};
}
-
+
class _NetworkExport SynchronisableVariableBase
{
public:
@@ -80,19 +80,18 @@
virtual inline uint32_t getSize(uint8_t mode);
virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
protected:
-
- T& variable_;
- uint8_t mode_;
- NetworkCallbackBase *callback_;
+ T& variable_;
+ uint8_t mode_;
+ NetworkCallbackBase *callback_;
};
-
+
template <class T>
class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
{
public:
SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
virtual ~SynchronisableVariableBidirectional();
-
+
virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
@@ -112,10 +111,10 @@
state_ = GameMode::isMaster() ? 0x1 : 0x2; // set the appropriate mode here
}
}
-
+
template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
{
- if (this->callback_ != 0)
+ if (this->callback_)
{
NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
// this is neccessary because for example for a Vector3 all 3 components of the vector use the same callback
@@ -140,16 +139,17 @@
if ( mode == this->mode_ ) //don't do anything
return;
// check whether we need to consider a callback
- if ( this->callback_ != 0 )
+ if ( this->callback_ )
{
- if( forceCallback || !checkEquality( this->variable_, mem ) )
- callback = true;
+ callback = forceCallback || !checkEquality( this->variable_, mem );
}
- // write the data
- loadAndIncrease( this->variable_, mem );
// now do a callback if neccessary
if ( callback )
+ {
NetworkCallbackManager::triggerCallback( this->callback_ );
+ }
+ // write the data
+ loadAndIncrease( this->variable_, mem );
}
template <class T> inline uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
@@ -215,7 +215,7 @@
{
mem += sizeof(varReference_);
memcpy(static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->varBuffer_)), &this->variable_, sizeof(T));
- if ( this->callback_ != 0 )
+ if ( this->callback_ )
callback = true;
}
}
@@ -234,24 +234,26 @@
if ( checkEquality( this->variable_, mem ) == false )
{
// value changed so remark for callback
- if ( this->callback_ != 0 )
+ if ( this->callback_ )
callback = true;
}
}
}
- // now write the data
- loadAndIncrease(this->variable_, mem);
// now do a callback if neccessary
if ( callback )
+ {
NetworkCallbackManager::triggerCallback( this->callback_ );
+ }
+ // now write the data
+ loadAndIncrease(this->variable_, mem);
}
template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
{
return returnSize( this->variable_ ) + sizeof(varReference_);
}
-
+
}
Modified: code/trunk/src/libraries/tools/BillboardSet.cc
===================================================================
--- code/trunk/src/libraries/tools/BillboardSet.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/BillboardSet.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -37,7 +37,6 @@
#include "util/Convert.h"
#include "util/Math.h"
-#include "util/StringUtils.h"
#include "core/GameMode.h"
namespace orxonox
@@ -80,7 +79,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+ COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
this->billboardSet_ = 0;
}
@@ -103,7 +102,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
+ COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
this->billboardSet_ = 0;
}
Modified: code/trunk/src/libraries/tools/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/tools/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -22,5 +22,6 @@
"TOOLS_SHARED_BUILD"
LINK_LIBRARIES
core
+ network
SOURCE_FILES ${TOOLS_SRC_FILES}
)
Modified: code/trunk/src/libraries/tools/Mesh.cc
===================================================================
--- code/trunk/src/libraries/tools/Mesh.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/Mesh.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,7 +35,6 @@
#include <OgreSceneManager.h>
#include "util/Convert.h"
-#include "util/StringUtils.h"
#include "core/GameMode.h"
namespace orxonox
@@ -83,7 +82,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
+ COUT(1) << "Error: Couln't load mesh \"" << meshsource << '"' << std::endl;
this->entity_ = 0;
}
}
Modified: code/trunk/src/libraries/tools/ParticleInterface.cc
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/ParticleInterface.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -64,6 +64,10 @@
this->bAllowedByLOD_ = true;
this->speedFactor_ = 1.0f;
+ this->setDetailLevel(static_cast<unsigned int>(detaillevel));
+
+ this->setConfigValues();
+
if (GameMode::showsGraphics())
{
try
@@ -73,12 +77,10 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load particle system \"" << templateName << "\"" << std::endl;
+ COUT(1) << "Error: Couln't load particle system \"" << templateName << '"' << std::endl;
this->particleSystem_ = 0;
}
}
-
- this->setDetailLevel(static_cast<unsigned int>(detaillevel));
}
ParticleInterface::~ParticleInterface()
Modified: code/trunk/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceLocation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/ResourceLocation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -91,7 +91,7 @@
void ResourceLocation::unload()
{
// Remove from Ogre paths
- resourceGroup_.erase();
+ resourceGroup_.clear();
try
{
Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(
Modified: code/trunk/src/libraries/tools/Shader.cc
===================================================================
--- code/trunk/src/libraries/tools/Shader.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/Shader.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -56,8 +56,6 @@
this->bVisible_ = true;
this->bLoadCompositor_ = GameMode::showsGraphics();
this->bViewportInitialized_ = false;
- this->compositor_ = "";
- this->oldcompositor_ = "";
if (this->bLoadCompositor_ && Ogre::Root::getSingletonPtr())
{
@@ -78,8 +76,7 @@
Shader::~Shader()
{
-
- if (this->bLoadCompositor_ && this->compositorInstance_)
+ if (this->compositorInstance_ && this->bLoadCompositor_)
{
Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
assert(viewport);
@@ -111,12 +108,12 @@
{
Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
assert(viewport);
- if (this->oldcompositor_ != "")
+ if (!this->oldcompositor_.empty())
{
Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositor_);
this->compositorInstance_ = 0;
}
- if (this->compositor_ != "")
+ if (!this->compositor_.empty())
{
this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositor_);
if (!this->compositorInstance_)
@@ -298,7 +295,7 @@
if (!pass_pointer)
continue;
- if (pass_pointer->getFragmentProgramName() != "")
+ if (!pass_pointer->getFragmentProgramName().empty())
{
Ogre::GpuProgramParameters* parameter_pointer = pass_pointer->getFragmentProgramParameters().get();
if (!parameter_pointer)
Modified: code/trunk/src/libraries/tools/TextureGenerator.cc
===================================================================
--- code/trunk/src/libraries/tools/TextureGenerator.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/TextureGenerator.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -71,7 +71,7 @@
if (it == colourMap.end())
{
- std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
+ const std::string& materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialName, "General"));
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
@@ -81,7 +81,7 @@
}
else
{
- return (*it).second;
+ return it->second;
}
}
}
Modified: code/trunk/src/libraries/tools/Timer.cc
===================================================================
--- code/trunk/src/libraries/tools/Timer.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/Timer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -111,7 +111,7 @@
{
this->deleteExecutor();
}
-
+
/**
@brief Initializes the Timer
*/
Modified: code/trunk/src/libraries/tools/Timer.h
===================================================================
--- code/trunk/src/libraries/tools/Timer.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/Timer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -139,7 +139,7 @@
private:
void init();
-
+
Executor* executor_; //!< The executor of the function that should be called when the time expires
long long interval_; //!< The time-interval in micro seconds
Modified: code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h
===================================================================
--- code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/interfaces/TimeFactorListener.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,16 +36,16 @@
{
class _ToolsExport TimeFactorListener : virtual public OrxonoxClass
{
- friend class GSRoot;
-
public:
TimeFactorListener();
virtual ~TimeFactorListener() {}
+ static void setTimeFactor( float factor );
+ static void setTimeFactorInternal( float factor );
+ static inline float getTimeFactor(){ return TimeFactorListener::timefactor_s; }
+
protected:
virtual void changedTimeFactor(float factor_new, float factor_old) {}
- inline float getTimeFactor() const
- { return TimeFactorListener::timefactor_s; }
private:
static float timefactor_s;
Modified: code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,12 +36,16 @@
#include "TimeFactorListener.h"
#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "network/NetworkFunction.h"
namespace orxonox
{
//----------------------------
// TimeFactorListener
//----------------------------
+ registerStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal );
+
float TimeFactorListener::timefactor_s = 1.0f;
TimeFactorListener::TimeFactorListener()
@@ -49,6 +53,21 @@
RegisterRootObject(TimeFactorListener);
}
+ /*static*/ void TimeFactorListener::setTimeFactor( float factor )
+ {
+ if ( !GameMode::isStandalone() )
+ callStaticNetworkFunction( &TimeFactorListener::setTimeFactorInternal, CLIENTID_UNKNOWN, factor );
+ TimeFactorListener::setTimeFactorInternal(factor);
+ }
+
+ /*static*/ void TimeFactorListener::setTimeFactorInternal( float factor )
+ {
+ float oldFactor = TimeFactorListener::timefactor_s;
+ TimeFactorListener::timefactor_s = factor;
+ for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
+ it->changedTimeFactor(factor, oldFactor);
+ }
+
//----------------------------
// Tickable
//----------------------------
Modified: code/trunk/src/libraries/util/Clipboard.cc
===================================================================
--- code/trunk/src/libraries/util/Clipboard.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Clipboard.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -77,7 +77,7 @@
catch (...)
{
COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
- COUT(1) << " \"" << text << "\"" << std::endl;
+ COUT(1) << " \"" << text << '"' << std::endl;
}
return false;
}
@@ -95,7 +95,7 @@
HANDLE hData = GetClipboardData(CF_TEXT);
if (hData == NULL)
return "";
- std::string output = static_cast<char*>(GlobalLock(hData));
+ std::string output(static_cast<char*>(GlobalLock(hData)));
GlobalUnlock(hData);
CloseClipboard();
@@ -118,7 +118,7 @@
namespace orxonox
{
- static std::string clipboard = ""; //!< Keeps the text of our internal clipboard
+ static std::string clipboard; //!< Keeps the text of our internal clipboard
/**
@brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
Modified: code/trunk/src/libraries/util/Clock.cc
===================================================================
--- code/trunk/src/libraries/util/Clock.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Clock.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,11 +33,9 @@
{
Clock::Clock()
: timer_(new Ogre::Timer())
- , storedTime_(0)
, tickTime_(0)
, tickDt_(0)
, tickDtFloat_(0.0f)
- , lastTimersTime_(0)
{
}
@@ -45,29 +43,25 @@
{
delete timer_;
}
-
+
+ /**
+ @remarks
+ Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned
+ long, which will eventually overflow. But if you use the subtraction of
+ the current time minus the last time the timer gave us and sum these up to
+ a 64 bit integer, we get the desired result.
+ Also mind that we don't have to store the last timer's time as unsigned long
+ as well because (unsigned long)tickTime_ will do exactly that.
+ */
void Clock::capture()
{
- unsigned long timersTime = timer_->getMicroseconds();
- tickTime_ = storedTime_ + timersTime;
- tickDt_ = timersTime - lastTimersTime_;
+ tickDt_ = timer_->getMicroseconds() - (unsigned long)tickTime_;
+ tickTime_ += tickDt_;
tickDtFloat_ = static_cast<float>(tickDt_) / 1000000.0f;
-
- if (timersTime > 0xFFFFFFFF/4)
- {
- // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit
- storedTime_ += timersTime;
- lastTimersTime_ = 0;
- timer_->reset();
- }
- else
- {
- lastTimersTime_ = timersTime;
- }
}
unsigned long long Clock::getRealMicroseconds() const
{
- return this->timer_->getMicroseconds() + this->storedTime_;
+ return tickTime_ + (timer_->getMicroseconds() - (unsigned long)tickTime_);
}
}
Modified: code/trunk/src/libraries/util/Clock.h
===================================================================
--- code/trunk/src/libraries/util/Clock.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Clock.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -56,11 +56,9 @@
Clock(const Clock& instance);
Ogre::Timer* timer_;
- unsigned long long storedTime_;
unsigned long long tickTime_;
long tickDt_;
float tickDtFloat_;
- unsigned long lastTimersTime_;
};
}
Modified: code/trunk/src/libraries/util/Convert.h
===================================================================
--- code/trunk/src/libraries/util/Convert.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Convert.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,7 +42,6 @@
#include <typeinfo>
#include "Debug.h"
-#include "StringUtils.h"
#include "TemplateUtils.h"
////////////////////////////////////
@@ -335,7 +334,7 @@
{
FORCEINLINE static bool convert(std::string* output, const char input)
{
- *output = std::string(1, input);
+ *output = input;
return true;
}
};
@@ -344,16 +343,16 @@
{
FORCEINLINE static bool convert(std::string* output, const unsigned char input)
{
- *output = std::string(1, input);
+ *output = input;
return true;
}
};
template <>
struct ConverterExplicit<std::string, char>
{
- FORCEINLINE static bool convert(char* output, const std::string input)
+ FORCEINLINE static bool convert(char* output, const std::string& input)
{
- if (input != "")
+ if (!input.empty())
*output = input[0];
else
*output = '\0';
@@ -363,9 +362,9 @@
template <>
struct ConverterExplicit<std::string, unsigned char>
{
- FORCEINLINE static bool convert(unsigned char* output, const std::string input)
+ FORCEINLINE static bool convert(unsigned char* output, const std::string& input)
{
- if (input != "")
+ if (!input.empty())
*output = input[0];
else
*output = '\0';
@@ -388,22 +387,26 @@
}
};
+ // Declarations to avoid StringUtils.h include
+ _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+ _UtilExport std::string getLowercase(const std::string& str);
+
// std::string to bool
template <>
struct ConverterExplicit<std::string, bool>
{
static bool convert(bool* output, const std::string& input)
{
- std::string stripped = getLowercase(removeTrailingWhitespaces(input));
+ const std::string& stripped = getLowercase(removeTrailingWhitespaces(input));
if (stripped == "true" || stripped == "on" || stripped == "yes")
{
- *output = true;
- return true;
+ *output = true;
+ return true;
}
else if (stripped == "false" || stripped == "off" || stripped == "no")
{
- *output = false;
- return true;
+ *output = false;
+ return true;
}
std::istringstream iss(input);
Modified: code/trunk/src/libraries/util/Debug.h
===================================================================
--- code/trunk/src/libraries/util/Debug.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Debug.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,14 +70,31 @@
// Just for convenience
using std::endl;
- //! Adjust to discard certain output with level > hardDebugLevel at compile time
+ // Adjust this to discard certain output with level > hardDebugLevel at compile time already
+#ifdef ORXONOX_RELEASE
+ const int hardDebugLevel = OutputLevel::Verbose
+#elif defined(NDEBUG)
const int hardDebugLevel = OutputLevel::Verbose;
+#else
+ //! Maximum level for debug output that should be even processed at run time
+ const int hardDebugLevel = OutputLevel::Ultra;
+#endif
+
+ //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
+ inline int debugDummyFunction()
+ {
+ return 0;
+ }
}
/**
@brief
Logs text output: use exactly like std::cout, but specify an output
level as argument.
+ at details
+ (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text"))
+ where (a > b ? 0 : ) stands for COUT(x). This should explain how
+ this macro magic can possibly even work ;)
@example
COUT(3) << "Some info" << std::endl;
@note
@@ -87,10 +104,10 @@
*/
#define COUT(level) \
/*if*/ (level > orxonox::hardDebugLevel) ? \
- 0 \
+ orxonox::debugDummyFunction() \
/*else*/ : \
/*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
- 0 \
+ orxonox::debugDummyFunction() \
/*else*/ : \
orxonox::OutputHandler::getOutStream(level)
Copied: code/trunk/src/libraries/util/DisplayStringConversions.h (from rev 6415, code/branches/presentation2/src/libraries/util/DisplayStringConversions.h)
===================================================================
--- code/trunk/src/libraries/util/DisplayStringConversions.h (rev 0)
+++ code/trunk/src/libraries/util/DisplayStringConversions.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ */
+
+/**
+ at file
+ at brief
+ std::sring to Ogre::UTFString conversion functions
+*/
+
+#ifndef _DisplayStringConversions_H__
+#define _DisplayStringConversions_H__
+
+#include "UtilPrereqs.h"
+#include <OgreOverlayElement.h>
+
+#if OGRE_UNICODE_SUPPORT
+ #include <OgreUTFString.h>
+
+ namespace orxonox
+ {
+ template <>
+ struct ConverterExplicit<std::string, Ogre::DisplayString>
+ {
+ //! Converts an std::string into an Ogre::UTFString
+ inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+ {
+ Ogre::UTFString::code_point cp;
+ for (unsigned int i = 0; i < input.size(); ++i)
+ {
+ cp = input[i];
+ cp &= 0xFF;
+ output->append(1, cp);
+ }
+ return true;
+ }
+ };
+ }
+#else
+ namespace orxonox
+ {
+ template <>
+ struct ConverterExplicit<std::string, Ogre::DisplayString>
+ {
+ //! Converts an std::string into an Ogre::String
+ inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+ {
+ *output = input;
+ return true;
+ }
+ };
+ }
+#endif
+
+#endif /* _DisplayStringConversions_H__ */
Modified: code/trunk/src/libraries/util/Exception.cc
===================================================================
--- code/trunk/src/libraries/util/Exception.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Exception.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,8 +48,6 @@
Exception::Exception(const std::string& description)
: description_(description)
, lineNumber_(0)
- , functionName_("")
- , filename_("")
{ }
/**
@@ -60,29 +58,29 @@
*/
const std::string& Exception::getFullDescription() const
{
- if (fullDescription_ == "")
+ if (fullDescription_.empty())
{
std::ostringstream fullDesc;
fullDesc << this->getTypeName() << "Exception";
- if (this->filename_ != "")
+ if (!this->filename_.empty())
{
fullDesc << " in " << this->filename_;
if (this->lineNumber_)
- fullDesc << "(" << this->lineNumber_ << ")";
+ fullDesc << '(' << this->lineNumber_ << ')';
}
- if (this->functionName_ != "")
- fullDesc << " in function '" << this->functionName_ << "'";
+ if (!this->functionName_.empty())
+ fullDesc << " in function '" << this->functionName_ << '\'';
fullDesc << ": ";
- if (this->description_ != "")
+ if (!this->description_.empty())
fullDesc << this->description_;
else
fullDesc << "No description available.";
- this->fullDescription_ = std::string(fullDesc.str());
+ this->fullDescription_ = fullDesc.str();
}
return fullDescription_;
Modified: code/trunk/src/libraries/util/Exception.h
===================================================================
--- code/trunk/src/libraries/util/Exception.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Exception.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -130,6 +130,7 @@
CREATE_ORXONOX_EXCEPTION(ParseError);
CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
+ CREATE_ORXONOX_EXCEPTION(InitialisationAborted);
CREATE_ORXONOX_EXCEPTION(NotImplemented);
CREATE_ORXONOX_EXCEPTION(GameState);
CREATE_ORXONOX_EXCEPTION(NoGraphics);
Modified: code/trunk/src/libraries/util/ExprParser.cc
===================================================================
--- code/trunk/src/libraries/util/ExprParser.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/ExprParser.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -46,9 +46,20 @@
namespace orxonox
{
- ExprParser::ExprParser(const std::string& str)
+ ExprParser::ExprParser()
{
this->failed_ = false;
+ this->variables_["pi"] = 3.1415926535897932;
+ this->variables_["e"] = 2.7182818284590452;
+ }
+
+ void ExprParser::setVariable(const std::string& varname, double value)
+ {
+ this->variables_[varname] = value;
+ }
+
+ void ExprParser::parse(const std::string& str)
+ {
this->reading_stream = str.c_str();
if (str.size() == 0 || *reading_stream == '\0')
{
@@ -342,12 +353,10 @@
}
else
{
-#define SWITCH word
- CASE_1("pi")
- value = 3.1415926535897932;
- CASE("e")
- value = 2.7182818284590452;
- CASE_ELSE
+ std::map<std::string, double>::const_iterator it = this->variables_.find(word);
+ if (it != this->variables_.end())
+ value = it->second;
+ else
{
this->failed_ = true;
delete[] word;
@@ -357,7 +366,7 @@
delete[] word;
}
else if (*reading_stream == 40)
- { // expresion in paranthesis
+ { // expression in parenthesis
++reading_stream;
value = parse_last_argument();
}
Modified: code/trunk/src/libraries/util/ExprParser.h
===================================================================
--- code/trunk/src/libraries/util/ExprParser.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/ExprParser.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,6 +35,8 @@
#define _FloatParser_H__
#include "UtilPrereqs.h"
+
+#include <map>
#include <string>
namespace orxonox
@@ -70,11 +72,14 @@
};
- ExprParser(const std::string& str);
+ ExprParser();
+ void parse(const std::string& str);
const std::string& getRemains() { return this->remains_; }
double getResult() { return this->result_; }
bool getSuccess() { return !this->failed_; }
+ void setVariable(const std::string& varname, double value);
+
private:
double parse_expr_1();
double parse_expr_2();
@@ -96,7 +101,7 @@
bool failed_;
double result_;
std::string remains_;
-
+ std::map<std::string, double> variables_;
};
//Endzeichen für float expression: ')', '}', ']', ',', ';'
Modified: code/trunk/src/libraries/util/Math.cc
===================================================================
--- code/trunk/src/libraries/util/Math.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Math.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,6 +42,7 @@
namespace orxonox
{
+#if OGRE_VERSION < 0x010603
/**
@brief Function for writing a Radian to a stream.
*/
@@ -52,6 +53,16 @@
}
/**
+ @brief Function for writing a Degree to a stream.
+ */
+ std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+ {
+ out << degree.valueDegrees();
+ return out;
+ }
+#endif
+
+ /**
@brief Function for reading a Radian from a stream.
*/
std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
@@ -63,15 +74,6 @@
}
/**
- @brief Function for writing a Degree to a stream.
- */
- std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
- {
- out << degree.valueDegrees();
- return out;
- }
-
- /**
@brief Function for reading a Degree from a stream.
*/
std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
@@ -135,10 +137,10 @@
else
return orxonox::Vector2(0, 1);
}
-
+
float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
float sin_value = sqrt( 1 - cos_value*cos_value );
-
+
if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
return orxonox::Vector2( sin_value, cos_value );
else
@@ -176,7 +178,7 @@
return orxonox::Vector2(0, 1);
}
//float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
-
+
float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
float sin_value = sqrt( 1 - cos_value*cos_value );
Modified: code/trunk/src/libraries/util/Math.h
===================================================================
--- code/trunk/src/libraries/util/Math.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Math.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -58,9 +58,11 @@
namespace orxonox
{
+#if OGRE_VERSION < 0x010603
_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
+ _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
+#endif
_UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
- _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
_UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
_UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
@@ -162,7 +164,7 @@
template <> inline long double zeroise<long double>() { return 0; }
template <> inline bool zeroise<bool>() { return 0; }
template <> inline void* zeroise<void*>() { return 0; }
- template <> inline std::string zeroise<std::string>() { return ""; }
+ template <> inline std::string zeroise<std::string>() { return std::string(); }
template <> inline orxonox::Radian zeroise<orxonox::Radian>() { return orxonox::Radian(0.0f); }
template <> inline orxonox::Degree zeroise<orxonox::Degree>() { return orxonox::Degree(0.0f); }
template <> inline orxonox::Vector2 zeroise<orxonox::Vector2>() { return orxonox::Vector2 (0, 0) ; }
Modified: code/trunk/src/libraries/util/MathConvert.h
===================================================================
--- code/trunk/src/libraries/util/MathConvert.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/MathConvert.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -52,7 +52,7 @@
FORCEINLINE static bool convert(std::string* output, const orxonox::Vector2& input)
{
std::ostringstream ostream;
- if (ostream << input.x << "," << input.y)
+ if (ostream << input.x << ',' << input.y)
{
(*output) = ostream.str();
return true;
@@ -68,7 +68,7 @@
FORCEINLINE static bool convert(std::string* output, const orxonox::Vector3& input)
{
std::ostringstream ostream;
- if (ostream << input.x << "," << input.y << "," << input.z)
+ if (ostream << input.x << ',' << input.y << ',' << input.z)
{
(*output) = ostream.str();
return true;
@@ -84,7 +84,7 @@
FORCEINLINE static bool convert(std::string* output, const orxonox::Vector4& input)
{
std::ostringstream ostream;
- if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
+ if (ostream << input.x << ',' << input.y << ',' << input.z << ',' << input.w)
{
(*output) = ostream.str();
return true;
@@ -100,7 +100,7 @@
FORCEINLINE static bool convert(std::string* output, const orxonox::Quaternion& input)
{
std::ostringstream ostream;
- if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
+ if (ostream << input.w << ',' << input.x << ',' << input.y << ',' << input.z)
{
(*output) = ostream.str();
return true;
@@ -116,7 +116,7 @@
FORCEINLINE static bool convert(std::string* output, const orxonox::ColourValue& input)
{
std::ostringstream ostream;
- if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
+ if (ostream << input.r << ',' << input.g << ',' << input.b << ',' << input.a)
{
(*output) = ostream.str();
return true;
Modified: code/trunk/src/libraries/util/MultiType.h
===================================================================
--- code/trunk/src/libraries/util/MultiType.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/MultiType.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -231,7 +231,7 @@
virtual operator orxonox::Degree() const = 0;
virtual void toString(std::ostream& outstream) const = 0;
-
+
virtual void importData( uint8_t*& mem )=0;
virtual void exportData( uint8_t*& mem ) const=0;
virtual uint8_t getSize() const=0;
@@ -338,7 +338,7 @@
/** @brief Returns true if the current type is T. */
template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below
std::string getTypename() const;
-
+
/** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
/** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
Modified: code/trunk/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/trunk/src/libraries/util/MultiTypeValue.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/MultiTypeValue.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -149,7 +149,7 @@
/** @brief Puts the current value on the stream */
inline void toString(std::ostream& outstream) const { outstream << this->value_; }
-
+
/** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
/** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */
@@ -159,7 +159,7 @@
T value_; //!< The stored value
};
-
+
// Import / Export specialisation
// ColourValue
template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem )
Modified: code/trunk/src/libraries/util/OutputHandler.cc
===================================================================
--- code/trunk/src/libraries/util/OutputHandler.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/OutputHandler.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,6 +38,7 @@
#include <ctime>
#include <cstdlib>
#include <fstream>
+#include <iostream>
#include <sstream>
#include "Debug.h"
@@ -75,7 +76,7 @@
// Get path for a temporary file
#ifdef ORXONOX_PLATFORM_WINDOWS
char* pTempDir = getenv("TEMP");
- this->logFilename_ = std::string(pTempDir) + "/" + logFileBaseName_g;
+ this->logFilename_ = std::string(pTempDir) + '/' + logFileBaseName_g;
#else
this->logFilename_ = std::string("/tmp/") + logFileBaseName_g;
#endif
@@ -173,10 +174,13 @@
//! Pushed the just written output to the internal array
void outputChanged(int level)
{
- // Read ostringstream and store it
- this->output_.push_back(std::make_pair(level, this->buffer_.str()));
- // Clear content and flags
- this->buffer_.str(std::string());
+ if (!this->buffer_.str().empty())
+ {
+ // Read ostringstream and store it
+ this->output_.push_back(std::make_pair(level, this->buffer_.str()));
+ // Clear content and flags
+ this->buffer_.str(std::string());
+ }
this->buffer_.clear();
}
@@ -213,7 +217,7 @@
this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
this->registerOutputListener(this->consoleWriter_);
- this->output_ = new MemoryLogWriter();
+ this->output_ = new MemoryLogWriter();
// We capture as much input as the listener with the highest level
this->output_->softDebugLevel_ = getSoftDebugLevel();
this->registerOutputListener(this->output_);
@@ -223,6 +227,7 @@
OutputHandler::~OutputHandler()
{
delete this->logFile_;
+ delete this->consoleWriter_;
delete this->output_;
}
Modified: code/trunk/src/libraries/util/Serialise.h
===================================================================
--- code/trunk/src/libraries/util/Serialise.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Serialise.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,19 +36,18 @@
#include <cstring>
#include "util/Math.h"
+#include "util/mbool.h"
namespace orxonox{
-
-// general template declaration
-
+
/** @brief returns the size of the variable in a datastream */
- template <class T> inline uint32_t returnSize( const T& );
+ template <class T> inline uint32_t returnSize( const T& variable );
/** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
- template <class T> inline void loadAndIncrease( const T&, uint8_t*& );
+ template <class T> inline void loadAndIncrease( const T& variable, uint8_t*& mem );
/** @brief saves the value of a variable into the bytestream and increases the mem pointer */
- template <class T> inline void saveAndIncrease( const T&, uint8_t*& );
+ template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem );
/** @brief checks whether the variable of type T is the same as in the bytestream */
- template <class T> inline bool checkEquality( const T&, uint8_t* );
+ template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
// =================== Template specialisation stuff =============
@@ -202,7 +201,7 @@
{
return sizeof(uint32_t);
}
-
+
template <> inline void loadAndIncrease( const unsigned int& variable, uint8_t*& mem )
{
*(unsigned int*)( &variable ) = *(uint32_t*)(mem);
@@ -375,7 +374,7 @@
{
double temp;
memcpy(&temp, mem, sizeof(uint64_t));
- *(long double*)( &variable ) = static_cast<const long double>(temp);
+ *(long double*)( &variable ) = static_cast<long double>(temp);
mem += returnSize( variable );
}
@@ -470,8 +469,169 @@
Ogre::Real* r = (Ogre::Real*)mem;
return variable==Degree(*r);
}
-
-
+
+ // =========== Vector2
+
+ template <> inline uint32_t returnSize( const Vector2& variable )
+ {
+ return returnSize( variable.x )+returnSize( variable.y );
+ }
+
+ template <> inline void saveAndIncrease( const Vector2& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( variable.x, mem );
+ saveAndIncrease( variable.y, mem );
+ }
+
+ template <> inline void loadAndIncrease( const Vector2& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( variable.x, mem );
+ loadAndIncrease( variable.y, mem );
+ }
+
+ template <> inline bool checkEquality( const Vector2& variable, uint8_t* mem )
+ {
+ return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x));
+ }
+
+ // =========== Vector3
+
+ template <> inline uint32_t returnSize( const Vector3& variable )
+ {
+ return returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+ }
+
+ template <> inline void saveAndIncrease( const Vector3& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( variable.x, mem );
+ saveAndIncrease( variable.y, mem );
+ saveAndIncrease( variable.z, mem );
+ }
+
+ template <> inline void loadAndIncrease( const Vector3& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( variable.x, mem );
+ loadAndIncrease( variable.y, mem );
+ loadAndIncrease( variable.z, mem );
+ }
+
+ template <> inline bool checkEquality( const Vector3& variable, uint8_t* mem )
+ {
+ return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x)) &&
+ checkEquality(variable.z, mem+returnSize(variable.x)+returnSize(variable.y));
+ }
+
+ // =========== Vector4
+
+ template <> inline uint32_t returnSize( const Vector4& variable )
+ {
+ return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+ }
+
+ template <> inline void saveAndIncrease( const Vector4& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( variable.w, mem );
+ saveAndIncrease( variable.x, mem );
+ saveAndIncrease( variable.y, mem );
+ saveAndIncrease( variable.z, mem );
+ }
+
+ template <> inline void loadAndIncrease( const Vector4& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( variable.w, mem );
+ loadAndIncrease( variable.x, mem );
+ loadAndIncrease( variable.y, mem );
+ loadAndIncrease( variable.z, mem );
+ }
+
+ template <> inline bool checkEquality( const Vector4& variable, uint8_t* mem )
+ {
+ return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+ checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+ checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+ }
+
+ // =========== Quaternion
+
+ template <> inline uint32_t returnSize( const Quaternion& variable )
+ {
+ return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+ }
+
+ template <> inline void saveAndIncrease( const Quaternion& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( variable.w, mem );
+ saveAndIncrease( variable.x, mem );
+ saveAndIncrease( variable.y, mem );
+ saveAndIncrease( variable.z, mem );
+ }
+
+ template <> inline void loadAndIncrease( const Quaternion& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( variable.w, mem );
+ loadAndIncrease( variable.x, mem );
+ loadAndIncrease( variable.y, mem );
+ loadAndIncrease( variable.z, mem );
+ }
+
+ template <> inline bool checkEquality( const Quaternion& variable, uint8_t* mem )
+ {
+ return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+ checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+ checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+ }
+
+ // =========== ColourValue
+
+ template <> inline uint32_t returnSize( const ColourValue& variable )
+ {
+ return returnSize( variable.r )+returnSize( variable.g )+returnSize( variable.b )+returnSize( variable.a );
+ }
+
+ template <> inline void saveAndIncrease( const ColourValue& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( variable.r, mem );
+ saveAndIncrease( variable.g, mem );
+ saveAndIncrease( variable.b, mem );
+ saveAndIncrease( variable.a, mem );
+ }
+
+ template <> inline void loadAndIncrease( const ColourValue& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( variable.r, mem );
+ loadAndIncrease( variable.g, mem );
+ loadAndIncrease( variable.b, mem );
+ loadAndIncrease( variable.a, mem );
+ }
+
+ template <> inline bool checkEquality( const ColourValue& variable, uint8_t* mem )
+ {
+ return checkEquality(variable.r, mem) && checkEquality(variable.g, mem+returnSize(variable.r)) &&
+ checkEquality(variable.b, mem+returnSize(variable.r)+returnSize(variable.g)) &&
+ checkEquality(variable.a, mem+returnSize(variable.r)+returnSize(variable.g)+returnSize(variable.b));
+ }
+
+ // =========== mbool
+
+ template <> inline uint32_t returnSize( const mbool& variable )
+ {
+ return returnSize( (unsigned char&)((mbool&)variable).getMemory() );
+ }
+
+ template <> inline void saveAndIncrease( const mbool& variable, uint8_t*& mem )
+ {
+ saveAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+ }
+
+ template <> inline void loadAndIncrease( const mbool& variable, uint8_t*& mem )
+ {
+ loadAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+ }
+
+ template <> inline bool checkEquality( const mbool& variable, uint8_t* mem )
+ {
+ return checkEquality( (unsigned char&)((mbool&)variable).getMemory(), mem );
+ }
}
Modified: code/trunk/src/libraries/util/Singleton.h
===================================================================
--- code/trunk/src/libraries/util/Singleton.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/Singleton.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -55,9 +55,13 @@
}
//! Update method called by ClassSingletonManager (if used)
- void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
+ void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
//! Empty update method for the static polymorphism
- void update(const Clock& time) { }
+ void preUpdate(const Clock& time) { }
+ //! Update method called by ClassSingletonManager (if used)
+ void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
+ //! Empty update method for the static polymorphism
+ void postUpdate(const Clock& time) { }
protected:
//! Constructor sets the singleton instance pointer
Modified: code/trunk/src/libraries/util/StringUtils.cc
===================================================================
--- code/trunk/src/libraries/util/StringUtils.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/StringUtils.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,7 +39,7 @@
namespace orxonox
{
- std::string BLANKSTRING("");
+ std::string BLANKSTRING;
std::string getUniqueNumberString()
{
@@ -53,12 +53,12 @@
void strip(std::string* str)
{
size_t pos;
- while ((pos = (*str).find(" ")) < (*str).length())
- (*str).erase(pos, 1);
- while ((pos = (*str).find("\t")) < (*str).length())
- (*str).erase(pos, 1);
- while ((pos = (*str).find("\n")) < (*str).length())
- (*str).erase(pos, 1);
+ while ((pos = str->find(' ')) < str->length())
+ str->erase(pos, 1);
+ while ((pos = str->find('\t')) < str->length())
+ str->erase(pos, 1);
+ while ((pos = str->find('\n')) < str->length())
+ str->erase(pos, 1);
}
/**
@@ -68,7 +68,7 @@
*/
std::string getStripped(const std::string& str)
{
- std::string output = std::string(str);
+ std::string output(str);
strip(&output);
return output;
}
@@ -97,7 +97,7 @@
{
size_t quote = start - 1;
- while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+ while ((quote = str.find('"', quote + 1)) != std::string::npos)
{
size_t backslash = quote;
size_t numbackslashes = 0;
@@ -230,7 +230,7 @@
bool isComment(const std::string& str)
{
// Strip the line, whitespaces are disturbing
- std::string teststring = getStripped(str);
+ const std::string& teststring = getStripped(str);
// There are four possible comment-symbols:
// 1) #comment in script-language style
@@ -258,8 +258,7 @@
*/
bool isEmpty(const std::string& str)
{
- std::string temp = getStripped(str);
- return ((temp == "") || (temp.size() == 0));
+ return getStripped(str).empty();
}
/**
@@ -302,7 +301,7 @@
for (size_t pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\r"); }
for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
- for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+ for (size_t pos = 0; (pos = output.find('"' , pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
return output;
@@ -318,7 +317,7 @@
if (str.size() <= 1)
return str;
- std::string output = "";
+ std::string output;
for (size_t pos = 0; pos < str.size() - 1; )
{
if (str[pos] == '\\')
@@ -362,7 +361,7 @@
*/
std::string getLowercase(const std::string& str)
{
- std::string output = std::string(str);
+ std::string output(str);
lowercase(&output);
return output;
}
@@ -386,7 +385,7 @@
*/
std::string getUppercase(const std::string& str)
{
- std::string output = std::string(str);
+ std::string output(str);
uppercase(&output);
return output;
}
Modified: code/trunk/src/libraries/util/SubString.cc
===================================================================
--- code/trunk/src/libraries/util/SubString.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/SubString.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -269,10 +269,7 @@
return retVal;
}
else
- {
- static std::string empty;
- return empty;
- }
+ return "";
}
Deleted: code/trunk/src/libraries/util/UTFStringConversions.h
===================================================================
--- code/trunk/src/libraries/util/UTFStringConversions.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/UTFStringConversions.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,61 +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
- * Reto Grieder
- * Co-authors:
- * ...
- */
-
-/**
- at file
- at brief
- std::sring to Ogre::UTFString conversion functions
-*/
-
-#ifndef _UTFStringConversions_H__
-#define _UTFStringConversions_H__
-
-#include "UtilPrereqs.h"
-#include <OgreUTFString.h>
-
-namespace orxonox
-{
- template <>
- struct ConverterExplicit<std::string, Ogre::UTFString>
- {
- //! Converts an std::string into an Ogre::UTFString
- inline static bool convert(Ogre::UTFString* output, const std::string& input)
- {
- Ogre::UTFString::code_point cp;
- for (unsigned int i = 0; i < input.size(); ++i)
- {
- cp = input[i];
- cp &= 0xFF;
- output->append(1, cp);
- }
- return true;
- }
- };
-}
-
-#endif /* _UTFStringConversions_H__ */
Modified: code/trunk/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/trunk/src/libraries/util/UtilPrereqs.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/UtilPrereqs.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -130,4 +130,11 @@
typedef const ScopeGuardImplBase& ScopeGuard;
}
+// Just so you don't have to include StringUtils.h everywhere just for this
+namespace orxonox
+{
+ extern _UtilExport std::string BLANKSTRING;
+}
+
+
#endif /* _UtilPrereqs_H__ */
Modified: code/trunk/src/libraries/util/mbool.h
===================================================================
--- code/trunk/src/libraries/util/mbool.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/libraries/util/mbool.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -66,7 +66,7 @@
inline bool operator!() const
{ return (!this->value_.bool_); }
-
+
inline unsigned char& getMemory(){ return value_.memory_; }
private:
Modified: code/trunk/src/modules/objects/Attacher.cc
===================================================================
--- code/trunk/src/modules/objects/Attacher.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/Attacher.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -97,7 +97,7 @@
this->targetname_ = target;
this->target_ = 0;
- if (this->targetname_ == "")
+ if (this->targetname_.empty())
return;
for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
@@ -112,7 +112,7 @@
void Attacher::loadedNewXMLName(BaseObject* object)
{
- if (this->target_ || this->targetname_ == "")
+ if (this->target_ || this->targetname_.empty())
return;
WorldEntity* entity = orxonox_cast<WorldEntity*>(object);
Modified: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -65,8 +65,8 @@
XMLPortParam(BoxCollisionShape, "halfExtents", setHalfExtents, getHalfExtents, xmlelement, mode);
XMLPortParamLoadOnly(BoxCollisionShape, "width", setWidth, xmlelement, mode);
- XMLPortParamLoadOnly(BoxCollisionShape, "height", setHeight, xmlelement, mode);
- XMLPortParamLoadOnly(BoxCollisionShape, "length", setLength, xmlelement, mode);
+ XMLPortParamLoadOnly(BoxCollisionShape, "height", setHeight, xmlelement, mode);
+ XMLPortParamLoadOnly(BoxCollisionShape, "length", setLength, xmlelement, mode);
}
btCollisionShape* BoxCollisionShape::createNewShape() const
Modified: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -65,7 +65,7 @@
SUPER(ConeCollisionShape, XMLPort, xmlelement, mode);
XMLPortParam(ConeCollisionShape, "radius", setRadius, getRadius, xmlelement, mode);
- XMLPortParam(ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);
+ XMLPortParam(ConeCollisionShape, "height", setHeight, getHeight, xmlelement, mode);
}
btCollisionShape* ConeCollisionShape::createNewShape() const
Modified: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -66,7 +66,7 @@
SUPER(PlaneCollisionShape, XMLPort, xmlelement, mode);
XMLPortParam(PlaneCollisionShape, "normal", setNormal, getNormal, xmlelement, mode);
- XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);
+ XMLPortParam(PlaneCollisionShape, "offset", setOffset, getOffset, xmlelement, mode);
}
btCollisionShape* PlaneCollisionShape::createNewShape() const
Modified: code/trunk/src/modules/objects/eventsystem/EventFilter.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventFilter.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/eventsystem/EventFilter.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,7 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventFilter \"" << this->getName() << "\"" << std::endl;
+ COUT(2) << "Warning: Detected Event loop in EventFilter \"" << this->getName() << '"' << std::endl;
return;
}
Modified: code/trunk/src/modules/objects/eventsystem/EventListener.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventListener.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/eventsystem/EventListener.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -57,7 +57,7 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << "\"" << std::endl;
+ COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << '"' << std::endl;
return;
}
@@ -70,7 +70,7 @@
{
this->eventName_ = eventname;
- if (this->eventName_ == "")
+ if (this->eventName_.empty())
return;
for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
@@ -80,7 +80,7 @@
void EventListener::loadedNewXMLName(BaseObject* object)
{
- if (this->eventName_ == "")
+ if (this->eventName_.empty())
return;
if (object->getName() == this->eventName_)
Modified: code/trunk/src/modules/objects/eventsystem/EventTarget.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventTarget.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/eventsystem/EventTarget.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -44,7 +44,7 @@
EventTarget::~EventTarget()
{
}
-
+
void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(EventTarget, XMLPort, xmlelement, mode);
@@ -59,7 +59,7 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl;
+ COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << '"' << std::endl;
return;
}
@@ -71,7 +71,7 @@
void EventTarget::setTargetName(const std::string& name)
{
this->target_ = name;
-
+
for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
if (it->getName() == this->target_)
this->addEventTarget(*it);
@@ -79,7 +79,7 @@
void EventTarget::loadedNewXMLName(BaseObject* object)
{
- if (this->target_ == "")
+ if (this->target_.empty())
return;
if (object->getName() == this->target_)
Modified: code/trunk/src/modules/objects/eventsystem/EventTarget.h
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventTarget.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/eventsystem/EventTarget.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,9 +41,9 @@
public:
EventTarget(BaseObject* creator);
virtual ~EventTarget();
-
+
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
+
virtual void processEvent(Event& event);
void setTargetName(const std::string& name);
@@ -53,7 +53,7 @@
private:
virtual void loadedNewXMLName(BaseObject* object);
void addEventTarget(BaseObject* object);
-
+
std::string target_;
bool bActive_;
};
Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -91,7 +91,7 @@
if (!targetId)
{
- COUT(1) << "Error: \"" << targets << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
+ COUT(1) << "Error: \"" << targets << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << std::endl;
return;
}
Modified: code/trunk/src/modules/objects/triggers/Trigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/Trigger.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/objects/triggers/Trigger.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -279,13 +279,13 @@
std::string Trigger::getModeString() const
{
if (this->mode_ == TriggerMode::EventTriggerAND)
- return std::string("and");
+ return "and";
else if (this->mode_ == TriggerMode::EventTriggerOR)
- return std::string("or");
+ return "or";
else if (this->mode_ == TriggerMode::EventTriggerXOR)
- return std::string("xor");
+ return "xor";
else
- return std::string("and");
+ return "and";
}
void Trigger::addTrigger(Trigger* trigger)
Modified: code/trunk/src/modules/overlays/GUIOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/GUIOverlay.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/GUIOverlay.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,28 +61,24 @@
void GUIOverlay::changedVisibility()
{
SUPER(GUIOverlay, changedVisibility);
-
+
//Setting player now.
if( this->getOwner() )
GUIManager::getInstance().setPlayer(this->guiName_, (orxonox_cast<ControllableEntity*>(this->getOwner()))->getPlayer());
if (this->isVisible())
{
- std::string str;
- std::stringstream out;
+ std::ostringstream out;
out << reinterpret_cast<long>(this);
- str = out.str();
- GUIManager::getInstance().executeCode("showCursor()");
- InputManager::getInstance().enterState("guiMouseOnly");
- GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")");
+ const std::string& str = out.str();
+ COUT(1) << "GUIManager ptr: " << str << std::endl;
+ GUIManager::getInstance().showGUIExtra(this->guiName_, str);
COUT(3) << "Showing GUI " << this->guiName_ << std::endl;
}
else
{
- GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")");
- GUIManager::getInstance().executeCode("hideCursor()");
- InputManager::getInstance().leaveState("guiMouseOnly");
+ GUIManager::hideGUI(this->guiName_);
COUT(3) << "Hiding GUI " << this->guiName_ << std::endl;
}
}
Modified: code/trunk/src/modules/overlays/OverlayText.cc
===================================================================
--- code/trunk/src/modules/overlays/OverlayText.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/OverlayText.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -133,7 +133,7 @@
void OverlayText::setFont(const std::string& font)
{
- if (font != "")
+ if (!font.empty())
this->text_->setFontName(font);
}
const std::string& OverlayText::getFont() const
Modified: code/trunk/src/modules/overlays/hud/ChatOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,7 +32,7 @@
#include <OgreTextAreaOverlayElement.h>
#include "util/Convert.h"
-#include "util/UTFStringConversions.h"
+#include "util/DisplayStringConversions.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/Executor.h"
@@ -85,7 +85,7 @@
text = message;
}
- this->messages_.push_back(multi_cast<Ogre::UTFString>(text));
+ this->messages_.push_back(multi_cast<Ogre::DisplayString>(text));
COUT(0) << "Chat: " << text << std::endl;
Timer* timer = new Timer();
@@ -109,7 +109,7 @@
{
this->text_->setCaption("");
- for (std::list<Ogre::UTFString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it)
+ for (std::list<Ogre::DisplayString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it)
{
this->text_->setCaption(this->text_->getCaption() + "\n" + (*it));
}
Modified: code/trunk/src/modules/overlays/hud/ChatOverlay.h
===================================================================
--- code/trunk/src/modules/overlays/hud/ChatOverlay.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/ChatOverlay.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,7 +32,7 @@
#include "overlays/OverlaysPrereqs.h"
#include <list>
-#include <OgreUTFString.h>
+#include <OgreOverlayElement.h>
#include "network/ChatListener.h"
#include "overlays/OverlayText.h"
@@ -50,7 +50,7 @@
protected:
virtual void incomingChat(const std::string& message, unsigned int senderID);
- std::list<Ogre::UTFString> messages_;
+ std::list<Ogre::DisplayString> messages_;
private:
void updateOverlayText();
Modified: code/trunk/src/modules/overlays/hud/HUDBar.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDBar.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/HUDBar.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -66,12 +66,12 @@
unsigned int HUDBar::materialcount_s = 0;
HUDBar::HUDBar(BaseObject* creator)
- : OrxonoxOverlay(creator)
+ : OrxonoxOverlay(creator), right2Left_(false), autoColour_(false)
{
RegisterObject(HUDBar);
// create new material
- std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
+ const std::string& materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General"));
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
@@ -84,9 +84,9 @@
this->bar_->setMaterialName(materialname);
this->value_ = 1.0f; // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
+ this->setAutoColour(true);
this->setValue(0.0f); // <--
this->setRightToLeft(false);
- this->setAutoColour(true);
this->currentColour_ = ColourValue::White;
this->background_->addChild(bar_);
@@ -121,15 +121,15 @@
if (this->colours_.size() > 0)
{
ColourValue colour1(0, 0, 0, 1);
- ColourValue colour2 = (*this->colours_.rbegin()).second;
+ ColourValue colour2 = this->colours_.rbegin()->second;
float value1(0);
- float value2 = (*this->colours_.rbegin()).first;
+ float value2 = this->colours_.rbegin()->first;
for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
{
colour1 = colour2;
value1 = value2;
- colour2 = (*it).second;
- value2 = (*it).first;
+ colour2 = it->second;
+ value2 = it->first;
if (value2 < this->value_)
break;
Modified: code/trunk/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDHealthBar.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/HUDHealthBar.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -52,7 +52,7 @@
virtual void changedName();
inline void setTextFont(const std::string& font)
- { if (font != "") { this->textoverlay_->setFont(font); } }
+ { if (!font.empty()) { this->textoverlay_->setFont(font); } }
inline const std::string& getTextFont() const
{ return this->textoverlay_->getFont(); }
Modified: code/trunk/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -29,17 +29,21 @@
#include "HUDNavigation.h"
#include <string>
+#include <OgreCamera.h>
#include <OgreOverlayManager.h>
#include <OgreTextAreaOverlayElement.h>
#include <OgrePanelOverlayElement.h>
#include "util/Math.h"
-#include "util/StringUtils.h"
#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "CameraManager.h"
#include "Scene.h"
#include "Radar.h"
+#include "graphics/Camera.h"
+#include "controllers/HumanController.h"
+#include "worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -59,6 +63,7 @@
.createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
navMarker_->setMaterialName("Orxonox/NavArrows");
+/*
// create aim marker
aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
.createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
@@ -69,9 +74,10 @@
setTextSize(0.05f);
setNavMarkerSize(0.05f);
setAimMarkerSize(0.04f);
+*/
background_->addChild(navMarker_);
- background_->addChild(aimMarker_);
+// background_->addChild(aimMarker_);
background_->addChild(navText_);
// hide at first
@@ -84,7 +90,7 @@
{
Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+// Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
}
}
@@ -95,12 +101,12 @@
XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode);
XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
- XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
+// XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
}
void HUDNavigation::setFont(const std::string& font)
{
- if (this->navText_ && font != "")
+ if (this->navText_ && !font.empty())
this->navText_->setFontName(font);
}
@@ -148,12 +154,12 @@
navText_->setCaption(multi_cast<std::string>(dist));
float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3;
-/*
- Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
- Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
-*/
+ orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera();
+ if (!cam)
+ return;
+ const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
// transform to screen coordinates
- Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();
+ Vector3 pos = transform * radar->getFocus()->getRVWorldPosition();
bool outOfView;
if (pos.z > 1.0)
@@ -171,7 +177,7 @@
if (outOfView)
{
// object is not in view
- aimMarker_->hide();
+// aimMarker_->hide();
if (!wasOutOfView_)
{
@@ -226,7 +232,7 @@
{
// object is in view
/*
- Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
+ Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
*/
if (wasOutOfView_)
@@ -240,8 +246,8 @@
navMarker_->setLeft((pos.x + 1.0 - navMarker_->getWidth()) * 0.5);
navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5);
+/*
aimMarker_->show();
-/*
aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
*/
@@ -252,11 +258,10 @@
float HUDNavigation::getDist2Focus() const
{
-/*
- if (Radar::getInstance().getFocus())
- return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+ Radar* radar = this->getOwner()->getScene()->getRadar();
+ if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn())
+ return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
else
-*/
return 0;
}
@@ -266,13 +271,15 @@
*/
void HUDNavigation::sizeChanged()
{
- // use size to compensate for apspect ratio if enabled.
+ // use size to compensate for aspect ratio if enabled.
float xScale = this->getActualSize().x;
float yScale = this->getActualSize().y;
if (this->navMarker_)
navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+/*
if (this->aimMarker_)
aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
+*/
if (this->navText_)
navText_->setCharHeight(navText_->getCharHeight() * yScale);
}
Modified: code/trunk/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -55,8 +55,10 @@
void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); }
float getNavMarkerSize() const { return this->navMarkerSize_; }
+/*
void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }
float getAimMarkerSize() const { return this->aimMarkerSize_; }
+*/
void setTextSize(float size);
float getTextSize() const;
@@ -70,8 +72,10 @@
Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker
float navMarkerSize_; //!< One paramter size of the navigation marker
+/*
Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker
float aimMarkerSize_; //!< One paramter size of the aim marker
+*/
Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance
bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap
};
Modified: code/trunk/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDRadar.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/HUDRadar.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -125,7 +125,7 @@
{
panel = *itRadarDots_;
++itRadarDots_;
- std::string materialName = TextureGenerator::getMaterialName(
+ const std::string& materialName = TextureGenerator::getMaterialName(
shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
if (materialName != panel->getMaterialName())
panel->setMaterialName(materialName);
Modified: code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,11 +70,11 @@
if (this->owner_)
{
- std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";
- std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";
+ const std::string& bases1 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ')';
+ const std::string& bases2 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ')';
- std::string score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
- std::string score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
+ const std::string& score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
+ const std::string& score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
std::string output1;
if (this->bShowLeftTeam_)
@@ -98,11 +98,11 @@
output2 = bases2;
}
- std::string output = "";
+ std::string output;
if (this->bShowBases_ || this->bShowScore_)
{
if (this->bShowLeftTeam_ && this->bShowRightTeam_)
- output = output1 + ":" + output2;
+ output = output1 + ':' + output2;
else if (this->bShowLeftTeam_ || this->bShowRightTeam_)
output = output1 + output2;
}
Modified: code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -93,11 +93,11 @@
}
}
}
-
+
void UnderAttackHealthBar::changedOverlayGroup()
{
SUPER(UnderAttackHealthBar, changedOverlayGroup);
-
+
this->getOverlayGroup()->addElement(this->text_.get());
}
Modified: code/trunk/src/modules/overlays/stats/CreateLines.cc
===================================================================
--- code/trunk/src/modules/overlays/stats/CreateLines.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/overlays/stats/CreateLines.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -93,7 +93,7 @@
this->playerNameText_->changedVisibility();
this->background_->changedVisibility();
}
-
+
void CreateLines::setOverlayGroup( OverlayGroup* group )
{
this->scoreText_->setOverlayGroup( group );
Modified: code/trunk/src/modules/pong/Pong.cc
===================================================================
--- code/trunk/src/modules/pong/Pong.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/pong/Pong.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,7 +41,7 @@
{
CreateEventName(PongCenterpoint, right);
CreateEventName(PongCenterpoint, left);
-
+
CreateUnloadableFactory(Pong);
Pong::Pong(BaseObject* creator) : Deathmatch(creator)
@@ -163,7 +163,7 @@
this->center_->fireEvent(FireEventName(PongCenterpoint, right));
else if (player == this->getLeftPlayer())
this->center_->fireEvent(FireEventName(PongCenterpoint, left));
-
+
if (player)
this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
}
Modified: code/trunk/src/modules/pong/PongAI.cc
===================================================================
--- code/trunk/src/modules/pong/PongAI.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/pong/PongAI.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -61,7 +61,7 @@
PongAI::~PongAI()
{
for (std::list<std::pair<Timer*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
- (*it).first->destroy();
+ it->first->destroy();
}
void PongAI::setConfigValues()
@@ -130,7 +130,7 @@
delay = true;
this->bOscillationAvoidanceActive_ = false;
}
-
+
// If the ball is close enough, calculate another random offset to accelerate the ball
if (!this->bChangedRandomOffset_)
{
@@ -205,11 +205,11 @@
{
// calculate the time until the ball reaches the other side
float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x;
-
+
// calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2)
float bouncetime = totaltime;
bool bUpperWall = false;
-
+
if (acceleration.z == 0)
{
if (velocity.z > 0)
@@ -269,7 +269,7 @@
// ball bounces after <bouncetime> seconds, update the position and continue
velocity.z = velocity.z + acceleration.z * bouncetime;
-
+
if (bUpperWall)
{
position.z = dimension.y / 2;
@@ -280,7 +280,7 @@
position.z = -dimension.y / 2;
velocity.z = fabs(velocity.z) - fabs(randomErrorZ);
}
-
+
position.x = position.x + velocity.x * bouncetime + randomErrorX;
this->ballEndPosition_ = position.z;
}
Modified: code/trunk/src/modules/pong/PongBall.cc
===================================================================
--- code/trunk/src/modules/pong/PongBall.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/pong/PongBall.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -104,7 +104,7 @@
velocity.x = -velocity.x;
velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
-
+
this->fireEvent();
}
else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
Modified: code/trunk/src/modules/pong/PongScore.cc
===================================================================
--- code/trunk/src/modules/pong/PongScore.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/pong/PongScore.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -76,8 +76,8 @@
std::string name1;
std::string name2;
- std::string score1 = "0";
- std::string score2 = "0";
+ std::string score1("0");
+ std::string score2("0");
if (player1)
{
@@ -113,11 +113,11 @@
output2 = name2;
}
- std::string output = "PONG";
+ std::string output("PONG");
if (this->bShowName_ || this->bShowScore_)
{
if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
- output = output1 + ":" + output2;
+ output = output1 + ':' + output2;
else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
output = output1 + output2;
}
Modified: code/trunk/src/modules/questsystem/AddQuestHint.cc
===================================================================
--- code/trunk/src/modules/questsystem/AddQuestHint.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/AddQuestHint.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,7 +70,7 @@
SUPER(AddQuestHint, XMLPort, xmlelement, mode);
XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
-
+
COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
}
@@ -89,7 +89,7 @@
COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
return false;
}
-
+
this->hintId_ = id;
return true;
}
Modified: code/trunk/src/modules/questsystem/AddReward.cc
===================================================================
--- code/trunk/src/modules/questsystem/AddReward.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/AddReward.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -66,7 +66,7 @@
SUPER(AddReward, XMLPort, xmlelement, mode);
XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
-
+
COUT(3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;
}
@@ -103,13 +103,13 @@
bool AddReward::invoke(PlayerInfo* player)
{
COUT(3) << "AddReward on player: " << player << " ." << std::endl;
-
+
bool check = true;
for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
{
check = check && (*reward)->reward(player);
}
-
+
COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl;
return check;
Modified: code/trunk/src/modules/questsystem/ChangeQuestStatus.cc
===================================================================
--- code/trunk/src/modules/questsystem/ChangeQuestStatus.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/ChangeQuestStatus.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -82,7 +82,7 @@
COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
return false;
}
-
+
this->questId_ = id;
return true;
}
Modified: code/trunk/src/modules/questsystem/CompleteQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/CompleteQuest.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/CompleteQuest.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the CompleteQuest class.
@@ -66,7 +66,7 @@
void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(CompleteQuest, XMLPort, xmlelement, mode);
-
+
COUT(3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
}
Modified: code/trunk/src/modules/questsystem/FailQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/FailQuest.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/FailQuest.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the FailQuest class.
@@ -66,7 +66,7 @@
void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(FailQuest, XMLPort, xmlelement, mode);
-
+
COUT(3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
}
@@ -102,7 +102,7 @@
COUT(2) << e.getFullDescription() << std::endl;
return false;
}
-
+
COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/GlobalQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/GlobalQuest.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/GlobalQuest.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the GlobalQuest class.
@@ -58,7 +58,7 @@
{
}
-
+
/**
@brief
Method for creating a GlobalQuest object through XML.
@@ -66,12 +66,12 @@
void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(GlobalQuest, XMLPort, xmlelement, mode);
-
+
XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode);
COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
}
-
+
/**
@brief
Fails the Quest for all players.
@@ -88,9 +88,9 @@
COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
return false;
}
-
+
Quest::fail(player);
-
+
//! Iterate through all players possessing this Quest.
for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
{
@@ -117,15 +117,15 @@
COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
return false;
}
-
+
//! Iterate through all players possessing the Quest.
for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
{
QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
}
-
+
Quest::complete(player);
-
+
QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
return true;
}
@@ -229,11 +229,11 @@
{
this->players_.insert(player); //!< Add the player to the set.
}
-
+
this->status_ = status; //!< Set the status, which is global, remember...?
return true;
}
-
+
/**
@brief
Adds a reward QuestEffect to the list of reward QuestEffects.
@@ -255,7 +255,7 @@
COUT(3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;
return true;
}
-
+
/**
@brief
Returns the reward QuestEffect at the given index.
Modified: code/trunk/src/modules/questsystem/LocalQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/LocalQuest.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/LocalQuest.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -86,9 +86,9 @@
COUT(4) << "A non-failable quest was trying to be failed." << std::endl;
return false;
}
-
+
Quest::fail(player);
-
+
QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
return true;
}
@@ -109,9 +109,9 @@
COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
return false;
}
-
+
Quest::complete(player);
-
+
QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
return true;
}
@@ -187,7 +187,7 @@
{
return it->second;
}
-
+
return QuestStatus::Inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
}
@@ -208,7 +208,7 @@
{
return false;
}
-
+
this->playerStatus_[player] = status;
return true;
}
Modified: code/trunk/src/modules/questsystem/Quest.cc
===================================================================
--- code/trunk/src/modules/questsystem/Quest.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/Quest.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the Quest class.
@@ -203,7 +203,7 @@
const Quest* Quest::getSubQuest(unsigned int index) const
{
int i = index;
-
+
//! Iterate through all subquests.
for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest)
{
@@ -213,7 +213,7 @@
}
i--;
}
-
+
return NULL; //!< If the index is greater than the number of elements in the list.
}
@@ -228,7 +228,7 @@
const QuestHint* Quest::getHint(unsigned int index) const
{
int i = index;
-
+
//! Iterate through all QuestHints.
for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint)
{
@@ -252,7 +252,7 @@
const QuestEffect* Quest::getFailEffect(unsigned int index) const
{
int i = index;
-
+
//! Iterate through all fail QuestEffects.
for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect)
{
@@ -276,7 +276,7 @@
const QuestEffect* Quest::getCompleteEffect(unsigned int index) const
{
int i = index;
-
+
//! Iterate through all complete QuestEffects.
for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect)
{
@@ -349,7 +349,7 @@
{
return this->getStatus(player) == QuestStatus::Completed;
}
-
+
/**
@brief
Fails the Quest for an input player.
@@ -362,13 +362,13 @@
{
QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
this->setStatus(player, QuestStatus::Failed);
-
+
COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
-
+
this->getDescription()->sendFailQuestNotification();
return true;
}
-
+
/**
@brief
Completes the Quest for an input player.
@@ -381,9 +381,9 @@
{
QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
this->setStatus(player, QuestStatus::Completed);
-
+
COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
-
+
this->getDescription()->sendCompleteQuestNotification();
return true;
}
@@ -403,17 +403,17 @@
COUT(4) << "A non-startable quest was trying to be started." << std::endl;
return false;
}
-
+
COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl;
-
+
QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active.
-
+
this->setStatus(player, QuestStatus::Active);
-
+
this->getDescription()->sendAddQuestNotification();
return true;
}
-
+
/**
@brief
Adds a QuestListener to the list of QuestListeners listening to this Quest.
@@ -429,7 +429,7 @@
COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl;
return false;
}
-
+
this->listeners_.push_back(listener);
return true;
}
Modified: code/trunk/src/modules/questsystem/QuestDescription.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestDescription.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestDescription.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,9 +49,6 @@
QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator)
{
RegisterObject(QuestDescription);
-
- this->title_ = "";
- this->description_ = "";
}
/**
@@ -78,7 +75,7 @@
COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
}
-
+
/**
@brief
This method is a helper for sending QuestDescriptions as Notifications.
@@ -93,24 +90,24 @@
*/
bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
{
- std::string message = "";
+ std::string message;
if(item == "hint")
{
- message = "You received a hint: '" + this->title_ + "'";
+ message = "You received a hint: '" + this->title_ + '\'';
}
else if(item == "quest")
{
if(status == "start")
{
- message = "You received a new quest: '" + this->title_ + "'";
+ message = "You received a new quest: '" + this->title_ + '\'';
}
else if(status == "fail")
{
- message = "You failed the quest: '" + this->title_ + "'";
+ message = "You failed the quest: '" + this->title_ + '\'';
}
else if(status == "complete")
{
- message = "You successfully completed the quest: '" + this->title_ + "'";
+ message = "You successfully completed the quest: '" + this->title_ + '\'';
}
else
{
@@ -123,7 +120,7 @@
COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
return false;
}
-
+
QuestNotification* notification = new QuestNotification(message);
notification->send();
return true;
Modified: code/trunk/src/modules/questsystem/QuestEffect.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffect.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestEffect.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,7 +68,7 @@
/*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
{
bool check = true;
-
+
COUT(4) << "Invoking QuestEffects on player: " << player << " ." << std::endl;
for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
Modified: code/trunk/src/modules/questsystem/QuestGUI.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUI.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestGUI.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -76,7 +76,7 @@
(*it)->destroy();
}
this->windows_.clear();
-
+
if(this->root_ != NULL)
this->root_->destroy();
}
@@ -103,7 +103,7 @@
COUT(3) << "Updating QuestGUI..." << std::endl;
this->clear(); //!< Clear the GUI.
-
+
int depth = 0;
int index = 0;
@@ -115,7 +115,7 @@
std::map<std::string, Quest*> quests = QuestManager::getInstance().getQuests();
for(std::map<std::string, Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
{
- Quest* quest = (*it).second;
+ Quest* quest = it->second;
if(quest->getParentQuest() == NULL && !quest->isInactive(this->player_)) //!< If the Quest isn't inactive and a root Quest (meaning it has no parent.), create a Node.
{
index = createNode(this->root_, quest, depth, index);
@@ -135,7 +135,7 @@
//! Clear all nodes.
for(std::map<CEGUI::Window*, QuestGUINode*>::iterator it = this->nodes_.begin(); it != this->nodes_.end(); it++)
{
- QuestGUINode* node = (*it).second;
+ QuestGUINode* node = it->second;
if(node == NULL)
{
COUT(1) << "Node is NULL!";
@@ -208,7 +208,7 @@
{
for(std::map<PlayerInfo*, QuestGUI*>::iterator it = QuestManager::getInstance().questGUIs_.begin(); it != QuestManager::getInstance().questGUIs_.end(); it++)
{
- QuestGUI* gui = (*it).second;
+ QuestGUI* gui = it->second;
std::map<CEGUI::Window*, QuestGUINode*>::iterator node = gui->nodes_.find(window);
if(node != gui->nodes_.end()) return node->second;
}
@@ -234,7 +234,7 @@
QuestGUINode* node = new QuestGUINode(this, parent, item, depth, index); //!< Create a new QuestGUINode.
this->nodes_.insert(std::pair<CEGUI::Window*, QuestGUINode*>(node->getWindow(),node)); //!< Insert the node and its window in the nodes_ map.
-
+
index++;
//! Check if the QuestItem is a Quest, if not (it's a QuestHint) it just returns.
@@ -267,7 +267,7 @@
}
index = tempIndex; //!< Reset the index to the original level.
- return index;
+ return index;
}
}
Modified: code/trunk/src/modules/questsystem/QuestGUI.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUI.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestGUI.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -55,7 +55,7 @@
{
public:
-
+
QuestGUI(PlayerInfo* player);
virtual ~QuestGUI();
@@ -85,9 +85,9 @@
*/
inline PlayerInfo* getPlayer(void)
{ return this->player_; }
-
+
private:
-
+
int createNode(QuestGUINode* parent, QuestItem* item, int depth, int index); //!< Recursive method to create Nodes for all Quests an Hints the given Quest is a parent to.
void clear(void); //!< Clear the QuestGUI.
Modified: code/trunk/src/modules/questsystem/QuestGUINode.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUINode.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestGUINode.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,7 +70,7 @@
*/
QuestGUINode::QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index)
{
- this->initialize();
+ this->initialize();
this->gui_ = gui;
this->parent_ = parent;
@@ -118,7 +118,7 @@
void QuestGUINode::toggleVisibility(void)
{
-
+
}
/**
@@ -133,11 +133,11 @@
{
if(this->window_ != NULL)
{
- buffer = (std::string)(this->window_->getName().c_str());
+ buffer = this->window_->getName().c_str();
}
else
{
- buffer = "";
+ buffer.erase();
}
}
@@ -153,7 +153,7 @@
{
if(this->details_ == NULL) //!< If the details window was not already created.
- {
+ {
std::ostringstream stream;
//! Create the main window for the details.
@@ -186,7 +186,7 @@
stream << this->details_->getName() << "/Status";
CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
window->addChildWindow(statusWindow);
- std::string status = "";
+ std::string status;
if(quest->isActive(this->gui_->getPlayer()))
{
status = "This quest is active.";
@@ -208,7 +208,7 @@
offset += height;
}
-
+
//! Create title pane for the description.
stream.str("");
stream << this->details_->getName() << "/Description";
@@ -281,7 +281,7 @@
bool QuestGUINode::openDetails(const CEGUI::EventArgs& e)
{
COUT(3) << "Open QuestItem..." << std::endl;
-
+
//CEGUI::Window* window = this->gui_->getRootWindow();
CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
@@ -296,7 +296,7 @@
Close the details window.
*/
bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e)
- {
+ {
//CEGUI::Window* window = this->gui_->getRootWindow();
CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
window->removeChildWindow(this->details_);
@@ -343,7 +343,7 @@
//! Set the height to the window.
window->setHeight(CEGUI::UDim(0, height));
-
+
//Debug
const CEGUI::Rect newArea = getStaticTextArea(window);
@@ -367,7 +367,7 @@
void QuestGUINode::createWindow(void)
{
Quest* quest = dynamic_cast<Quest*>(this->item_);
-
+
this->window_ = this->gui_->getWindow();
std::ostringstream stream;
stream << "QuestGUI/Quests/";
@@ -376,7 +376,7 @@
stream << this->parent_->index_ << "/Hints/";
}
stream << this->index_;
-
+
this->window_->rename(stream.str());
this->window_->setText(this->item_->getDescription()->getTitle());
Modified: code/trunk/src/modules/questsystem/QuestGUINode.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUINode.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestGUINode.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -43,17 +43,17 @@
{
public:
-
+
QuestGUINode(void);
QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index);
virtual ~QuestGUINode(void);
-
+
void toggleVisibility(void);
void getName(std::string & buffer); //!< Sets the input buffer to the name of the node.
/**
@brief Retreive the window of this node.
- @return The CEGUI Window of this node.
+ @return The CEGUI Window of this node.
*/
inline CEGUI::Window* getWindow(void)
{ return this->window_; }
Modified: code/trunk/src/modules/questsystem/QuestHint.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestHint.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestHint.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the QuestHint class.
@@ -70,7 +70,7 @@
SUPER(QuestHint, XMLPort, xmlelement, mode);
QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager.
-
+
COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
}
@@ -99,7 +99,7 @@
{
return it->second;
}
-
+
return QuestStatus::Inactive;
}
@@ -118,7 +118,7 @@
if(!(this->isActive(player))) //!< If the hint is already active, activation is pointless.
{
this->playerStatus_[player] = QuestHintStatus::Active;
-
+
this->getDescription()->sendAddHintNotification();
return true;
}
@@ -128,7 +128,7 @@
return false;
}
}
-
+
COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
return false;
}
Modified: code/trunk/src/modules/questsystem/QuestItem.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestItem.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestItem.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of the QuestItem class.
@@ -46,8 +46,6 @@
QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator)
{
RegisterObject(QuestItem);
-
- this->id_ = "";
}
/**
@@ -85,7 +83,7 @@
COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
return;
}
-
+
this->id_ = id;
}
Modified: code/trunk/src/modules/questsystem/QuestListener.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestListener.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestListener.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,11 +49,11 @@
QuestListener::QuestListener(BaseObject* creator) : BaseObject(creator)
{
RegisterObject(QuestListener);
-
+
this->mode_ = QuestListenerMode::All;
this->quest_ = NULL;
}
-
+
/**
@brief
Destructor.
@@ -61,7 +61,7 @@
QuestListener::~QuestListener()
{
}
-
+
/**
@brief
Method for creating a Quest object through XML.
@@ -74,10 +74,10 @@
XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode);
this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners.
-
+
COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl;
}
-
+
/**
@brief
Makes all QuestListener in the list aware that a certain status change has occurred and executes them if the status change affects them.
@@ -97,7 +97,7 @@
}
}
}
-
+
/**
@brief
Sets the questId of the Quest the QuestListener reacts to.
@@ -109,16 +109,16 @@
bool QuestListener::setQuestId(const std::string & id)
{
this->quest_ = QuestManager::getInstance().findQuest(id); //!< Find the Quest corresponding to the given questId.
-
+
if(this->quest_ == NULL) //!< If there is no such Quest.
{
ThrowException(Argument, "This is bad! The QuestListener has not found a Quest with a corresponding id..");
return false;
}
-
+
return true;
}
-
+
/**
@brief
Sets the mode of the QuestListener.
@@ -151,10 +151,10 @@
this->mode_ = QuestListenerMode::All;
return false;
}
-
+
return true;
}
-
+
/**
@brief
Get the mode of the QuestListener.
@@ -182,7 +182,7 @@
else
{
COUT(1) << "An unforseen, never to happen, Error has occurred. This is impossible!" << std::endl;
- return "";
+ return "";
}
}
@@ -192,7 +192,7 @@
@return
Returns the questId of the Quest the QuestListener reacts to.
*/
- const std::string & QuestListener::getQuestId(void)
+ const std::string & QuestListener::getQuestId(void)
{
return this->quest_->getId();
}
Modified: code/trunk/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -54,8 +54,6 @@
// Register tolua_open function when loading the library
DeclareToluaInterface(Questsystem);
- //! Pointer to the current (and single) instance of this class.
- /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
ManageScopedSingleton(QuestManager, ScopeID::Root, false);
/**
@@ -77,7 +75,7 @@
{
for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++)
{
- (*it).second->destroy();
+ it->second->destroy();
}
this->questGUIs_.clear();
}
Modified: code/trunk/src/modules/questsystem/QuestManager.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -71,7 +71,7 @@
//! Returns a reference to the single instance of the Quest Manager.
static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
- //! Retreive the main window for the GUI.
+ //! Retreive the main window for the GUI.
CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export
bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
Modified: code/trunk/src/modules/questsystem/QuestNotification.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestNotification.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/QuestNotification.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -31,21 +31,21 @@
namespace orxonox {
- const std::string QuestNotification::SENDER = "questsystem";
+ const std::string QuestNotification::SENDER("questsystem");
QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator)
{
this->initialize();
}
-
+
QuestNotification::QuestNotification(const std::string & message) : Notification(message)
{
this->initialize();
}
-
+
QuestNotification::~QuestNotification()
{
-
+
}
bool QuestNotification::send(void)
Modified: code/trunk/src/modules/questsystem/notifications/Notification.cc
===================================================================
--- code/trunk/src/modules/questsystem/notifications/Notification.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/notifications/Notification.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,7 +48,7 @@
RegisterObject(Notification);
this->initialize();
}
-
+
/**
@brief
Constructor. Creates a Notification with the input message.
@@ -59,7 +59,7 @@
{
this->message_ = message;
}
-
+
/**
@brief
Destructor.
@@ -67,18 +67,18 @@
Notification::~Notification()
{
}
-
+
/**
@brief
Registers the object and sets some default values.
*/
void Notification::initialize(void)
{
- this->message_ = "";
+ this->message_.clear();
this->sender_ = NotificationManager::NONE;
this->sent_ = false;
}
-
+
/**
@brief
Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
@@ -89,7 +89,7 @@
{
return this->send(NotificationManager::NONE);
}
-
+
/**
@brief
Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
@@ -105,12 +105,12 @@
if(!successful)
return false;
this->sent_ = true;
-
+
COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
-
+
return true;
}
-
+
/**
@brief
Sets the message of the notification.
Modified: code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/notifications/NotificationManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/notifications/NotificationManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -43,10 +43,9 @@
namespace orxonox
{
- const std::string NotificationManager::ALL = "all";
- const std::string NotificationManager::NONE = "none";
+ const std::string NotificationManager::ALL("all");
+ const std::string NotificationManager::NONE("none");
- NotificationManager* NotificationManager::singletonPtr_s = NULL;
ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
/**
Modified: code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
===================================================================
--- code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -45,9 +45,9 @@
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;
+ const std::string NotificationQueue::DEFAULT_FONT("VeraMono");
+ const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0);
+ const float NotificationQueue::DEFAULT_FONT_SIZE = 0.025f;
/**
@brief
@@ -270,7 +270,7 @@
{
if(!first)
{
- *string += ",";
+ *string += ',';
}
else
{
@@ -299,7 +299,7 @@
unsigned int index = 0;
while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
{
- pTemp = new std::string("");
+ pTemp = new std::string();
while(index < targets.size() && targets[index] != ',' && targets[index] != ' ')
{
*pTemp += targets[index];
@@ -398,7 +398,7 @@
timeString.erase(timeString.length()-1);
std::ostringstream stream;
stream << reinterpret_cast<unsigned long>(notification);
- std::string addressString = stream.str() ;
+ const std::string& addressString = stream.str();
container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
this->containers_.insert(container);
Modified: code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -3,4 +3,5 @@
ParticleProjectile.cc
Projectile.cc
LightningGunProjectile.cc
+ Rocket.cc
)
Modified: code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,19 +42,19 @@
this->textureIndex_ = 1;
this->maxTextureIndex_ = 8;
this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
-
+
registerVariables();
}
-
+
void LightningGunProjectile::registerVariables()
{
registerVariable(this->materialBase_);
}
-
+
void LightningGunProjectile::setMaterial(const std::string& material)
{
- this->materialBase_ = material;
-
+ this->materialBase_ = material;
+
BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
}
@@ -63,7 +63,7 @@
this->textureIndex_++;
if (this->textureIndex_ > this->maxTextureIndex_)
this->textureIndex_ = 1;
-
+
this->setMaterial(this->materialBase_);
}
}
Modified: code/trunk/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Projectile.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/projectiles/Projectile.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -47,11 +47,13 @@
this->setConfigValues();
this->bDestroy_ = false;
this->owner_ = 0;
+ this->damage_ = 15;
// Get notification about collisions
if (GameMode::isMaster())
{
+ this->setMass(1.0);
this->enableCollisionCallback();
this->setCollisionResponse(false);
this->setCollisionType(Kinematic);
@@ -70,7 +72,6 @@
void Projectile::setConfigValues()
{
- SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
}
@@ -127,7 +128,7 @@
Pawn* victim = orxonox_cast<Pawn*>(otherObject);
if (victim)
- victim->damage(dmg, this->owner_);
+ victim->hit(this->owner_, contactPoint, dmg);
}
return false;
}
Copied: code/trunk/src/modules/weapons/projectiles/Rocket.cc (from rev 6415, code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc)
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Rocket.cc (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/Rocket.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,293 @@
+/*
+ * 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:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "Rocket.h"
+
+#include <BulletDynamics/Dynamics/btRigidBody.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "worldentities/CameraPosition.h"
+#include "worldentities/pawns/Pawn.h"
+#include "graphics/ParticleSpawner.h"
+#include "graphics/Model.h"
+#include "objects/collisionshapes/ConeCollisionShape.h"
+#include "infos/PlayerInfo.h"
+#include "controllers/Controller.h"
+#include "sound/WorldSound.h"
+
+namespace orxonox
+{
+ CreateFactory(Rocket);
+ // create the factory for the Rocket
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator)
+ {
+ RegisterObject(Rocket);// - register the Rocket class to the core
+
+ this->localAngularVelocity_ = 0;
+ this->bDestroy_ = false;
+ this->lifetime_ = 100;
+
+ if (GameMode::isMaster())
+ {
+ this->setCollisionType(WorldEntity::Kinematic);
+ this->setVelocity(0,0,-100);
+
+ Model* model = new Model(this);
+ model->setMeshSource("rocket.mesh");
+ model->scale(0.7);
+ this->attach(model);
+ ParticleEmitter* fire = new ParticleEmitter(this);
+ this->attach(fire);
+ fire->setOrientation(this->getOrientation());
+ fire->setSource("Orxonox/rocketfire");
+
+ this->enableCollisionCallback();
+ this->setCollisionResponse(false);
+ this->setCollisionType(Kinematic);
+
+ ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
+ collisionShape->setRadius(3);
+ collisionShape->setHeight(500);
+ this->attachCollisionShape(collisionShape);
+
+ this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Rocket::destroyObject, this)));
+
+ this->defSndWpnEngine_ = new WorldSound(this);
+ this->defSndWpnEngine_->setLooping(true);
+ this->defSndWpnEngine_->setSource("sounds/Rocket_engine.ogg");
+ this->attach(defSndWpnEngine_);
+
+ this->defSndWpnLaunch_ = new WorldSound(this);
+ this->defSndWpnLaunch_->setLooping(false);
+ this->defSndWpnLaunch_->setSource("sounds/Rocket_launch.ogg");
+ this->attach(defSndWpnLaunch_);
+ }
+ else
+ {
+ this->defSndWpnEngine_ = 0;
+ this->defSndWpnLaunch_ = 0;
+ }
+
+ CameraPosition* camPosition = new CameraPosition(this);
+ camPosition->setPosition(0,4,15);
+ camPosition->setAllowMouseLook(true);
+ this->addCameraPosition(camPosition);
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present and kills sounds, if playing.
+ */
+ Rocket::~Rocket()
+ {
+ if(this->isInitialized())
+ {
+ if (GameMode::isMaster() && this->player_)
+ this->player_->stopTemporaryControl();
+
+ if ( this->defSndWpnEngine_ )
+ this->defSndWpnEngine_->destroy();
+
+ if ( this->defSndWpnLaunch_ )
+ this->defSndWpnLaunch_->destroy();
+ }
+ }
+
+ /**
+ @brief
+ Method for creating a Rocket through XML.
+ */
+ void Rocket::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // this calls the XMLPort function of the parent class
+ SUPER(Rocket, XMLPort, xmlelement, mode);
+ }
+
+ void Rocket::setOwner(Pawn* owner)
+ {
+ this->owner_ = owner;
+ this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
+ this->player_ = this->owner_->getPlayer();
+ this->owner_->getPlayer()->startTemporaryControl(this);
+
+ if( GameMode::isMaster() )
+ {
+ this->defSndWpnEngine_->play();
+ this->defSndWpnLaunch_->play();
+ }
+ }
+
+ /**
+ @brief
+ Defines which actions the Rocket has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void Rocket::tick(float dt)
+ {
+ SUPER(Rocket, tick, dt);
+
+ if( this->hasLocalController() )
+ {
+ this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
+ this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
+ this->localAngularVelocity_ = 0;
+
+ if( this->bDestroy_ )
+ this->destroy();
+ }
+ }
+
+ bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ if (!this->bDestroy_ && GameMode::isMaster())
+ {
+ if (otherObject == this->owner_)
+ return false;
+
+ this->bDestroy_ = true;
+
+ if (this->owner_)
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion4");
+ effect->setLifetime(2.0f);
+ }
+
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ }
+
+ float dmg = this->damage_;
+ if (this->owner_)
+ dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+
+ Pawn* victim = orxonox_cast<Pawn*>(otherObject);
+ if (victim)
+ victim->hit(this->owner_, contactPoint, dmg);
+// this->destroy();
+ }
+ return false;
+ }
+
+ void Rocket::destroyObject()
+ {
+ if (GameMode::isMaster())
+ {
+ if(this->defSndWpnEngine_->isPlaying())
+ {
+ this->defSndWpnEngine_->stop();
+ }
+ this->destroy();
+ }
+ }
+
+ void Rocket::fired(unsigned int firemode)
+ {
+ if (this->owner_)
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion4");
+ effect->setLifetime(2.0f);
+ }
+
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ this->destroy();
+ }
+ }
+
+ /**
+ @brief
+ Rotates the Rocket around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Rocket::rotateYaw(const Vector2& value)
+ {
+ ControllableEntity::rotateYaw(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.y += value.x;
+ }
+
+ /**
+ @brief
+ Rotates the Rocket around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Rocket::rotatePitch(const Vector2& value)
+ {
+ ControllableEntity::rotatePitch(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.x += value.x;
+ }
+
+ /**
+ @brief
+ Rotates the Rocket around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Rocket::rotateRoll(const Vector2& value)
+ {
+ ControllableEntity::rotateRoll(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.z += value.x;
+ }
+
+}
Copied: code/trunk/src/modules/weapons/projectiles/Rocket.h (from rev 6415, code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h)
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Rocket.h (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/Rocket.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,133 @@
+/*
+ * 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:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Rocket_H__
+#define _Rocket_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+ class ConeCollisionShape;
+
+ /**
+ @brief
+ Rocket, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _WeaponsExport Rocket : public ControllableEntity
+ {
+ public:
+ Rocket(BaseObject* creator);
+ virtual ~Rocket();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Rocket through XML.
+ virtual void tick(float dt); //!< Defines which actions the Rocket has to take in each tick.
+
+ virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+ void destroyObject();
+
+ virtual void moveFrontBack(const Vector2& value){}
+ virtual void moveRightLeft(const Vector2& value){}
+ virtual void moveUpDown(const Vector2& value){}
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+ /**
+ @brief Moves the Rocket in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the Rocket is to be moved.
+ */
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Rocket in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the Rocket is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Rocket in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the Rocket is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Rocket around the y-axis by the specifed amount.
+ @param value The amount by which the Rocket is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Rocket around the x-axis by the specifed amount.
+ @param value The amount by which the Rocket is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Rocket around the z-axis by the specifed amount.
+ @param value The amount by which the Rocket is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ void setOwner(Pawn* owner);
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+
+ inline void setDamage(float damage)
+ { this->damage_ = damage; }
+ inline float getDamage() const
+ { return this->damage_; }
+ virtual void fired(unsigned int firemode);
+
+ private:
+ WeakPtr<Pawn> owner_;
+ Vector3 localAngularVelocity_;
+ float damage_;
+ bool bDestroy_;
+ ControllableEntity* originalControllableEntity_;
+
+ WeakPtr<PlayerInfo> player_;
+ Timer destroyTimer_;
+ float lifetime_;
+
+ WorldSound* defSndWpnEngine_;
+ WorldSound* defSndWpnLaunch_;
+ };
+
+}
+
+#endif /* _Rocket_H__ */
Modified: code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -4,4 +4,5 @@
LaserFire.cc
HsW01.cc
LightningGun.cc
+ RocketFire.cc
)
Modified: code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/HsW01.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/weaponmodes/HsW01.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,6 +38,8 @@
#include "weaponsystem/Weapon.h"
#include "weaponsystem/WeaponPack.h"
#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -55,8 +57,14 @@
this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
this->delayTimer_.stopTimer();
+
+ this->setDefaultSound("sounds/Weapon_HsW01.ogg");
}
+ HsW01::~HsW01()
+ {
+ }
+
void HsW01::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(HsW01, XMLPort, xmlelement, mode);
@@ -102,6 +110,7 @@
void HsW01::shot()
{
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
Projectile* projectile = new Projectile(this);
Model* model = new Model(projectile);
model->setMeshSource("laserbeam.mesh");
@@ -109,6 +118,7 @@
projectile->attach(model);
model->setScale(5);
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
projectile->setOrientation(this->getMuzzleOrientation());
projectile->setPosition(this->getMuzzlePosition());
projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
Modified: code/trunk/src/modules/weapons/weaponmodes/HsW01.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/HsW01.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/weaponmodes/HsW01.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -40,7 +40,7 @@
{
public:
HsW01(BaseObject* creator);
- virtual ~HsW01() {}
+ virtual ~HsW01();
virtual void fire();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,6 +33,7 @@
#include "weaponsystem/Weapon.h"
#include "weaponsystem/WeaponPack.h"
#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -47,6 +48,7 @@
this->speed_ = 150;
this->setMunitionName("LaserMunition");
+ this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
}
LightningGun::~LightningGun()
@@ -58,6 +60,7 @@
LightningGunProjectile* projectile = new LightningGunProjectile(this);
projectile->setMaterial("Flares/LightningBall_");
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
projectile->setOrientation(this->getMuzzleOrientation());
projectile->setPosition(this->getMuzzlePosition());
projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
Modified: code/trunk/src/modules/weapons/weaponmodes/LightningGun.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/LightningGun.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/modules/weapons/weaponmodes/LightningGun.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,6 +41,7 @@
virtual ~LightningGun();
virtual void fire();
+
private:
float speed_;
};
Copied: code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc (from rev 6415, code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc)
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,74 @@
+/*
+ * 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:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "RocketFire.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "weapons/projectiles/Rocket.h"
+
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(RocketFire);
+
+ RocketFire::RocketFire(BaseObject* creator) : WeaponMode(creator)
+ {
+ RegisterObject(RocketFire);
+
+ this->reloadTime_ = 0.20;
+ this->bParallelReload_ = false;
+ this->damage_ = 100;
+ this->speed_ = 500;
+
+ this->setMunitionName("LaserMunition");
+ // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
+ }
+
+ RocketFire::~RocketFire()
+ {
+ }
+
+ void RocketFire::fire()
+ {
+ Rocket* rocket = new Rocket(this);
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ rocket->setOrientation(this->getMuzzleOrientation());
+ rocket->setPosition(this->getMuzzlePosition());
+ rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
+ rocket->scale(2);
+
+ rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ rocket->setDamage(this->getDamage());
+ }
+}
Copied: code/trunk/src/modules/weapons/weaponmodes/RocketFire.h (from rev 6415, code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h)
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/RocketFire.h (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/RocketFire.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,50 @@
+/*
+ * 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:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _RocketFire_H__
+#define _RocketFire_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+ class _WeaponsExport RocketFire : public WeaponMode
+ {
+ public:
+ RocketFire(BaseObject* creator);
+ virtual ~RocketFire();
+
+ virtual void fire();
+
+ private:
+ float speed_;
+ };
+}
+
+#endif /* _RocketFire_H__ */
Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -27,6 +27,7 @@
Level.cc
LevelManager.cc
Main.cc
+ MoodManager.cc
PawnManager.cc
PlayerManager.cc
Radar.cc
@@ -54,8 +55,11 @@
FIND_HEADER_FILES
TOLUA_FILES
LevelManager.h
+ MoodManager.h
+ controllers/HumanController.h
pickup/BaseItem.h
pickup/PickupInventory.h
+ sound/SoundManager.h
DEFINE_SYMBOL
"ORXONOX_SHARED_BUILD"
PCH_FILE
Modified: code/trunk/src/orxonox/CameraManager.cc
===================================================================
--- code/trunk/src/orxonox/CameraManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/CameraManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -44,7 +44,6 @@
namespace orxonox
{
- CameraManager* CameraManager::singletonPtr_s = 0;
ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
CameraManager::CameraManager()
Modified: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Level.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -140,13 +140,13 @@
void Level::playerEntered(PlayerInfo* player)
{
- COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
+ COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
player->setGametype(this->getGametype());
}
void Level::playerLeft(PlayerInfo* player)
{
- COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
+ COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
player->setGametype(0);
}
}
Modified: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/LevelManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -29,12 +29,12 @@
#include "LevelManager.h"
#include <map>
-#include <OgreResourceGroupManager.h>
#include "core/CommandLineParser.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
#include "core/Loader.h"
+#include "core/Resource.h"
#include "core/ScopedSingletonManager.h"
#include "PlayerManager.h"
#include "Level.h"
@@ -43,7 +43,6 @@
{
SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
- LevelManager* LevelManager::singletonPtr_s = 0;
ManageScopedSingleton(LevelManager, ScopeID::Root, false);
LevelManager::LevelManager()
@@ -65,7 +64,7 @@
void LevelManager::setConfigValues()
{
SetConfigValue(defaultLevelName_, "presentation_dm.oxw")
- .description("Sets the preselection of the level in the main menu.");
+ .description("Sets the pre selection of the level in the main menu.");
}
void LevelManager::requestActivity(Level* level)
@@ -122,21 +121,17 @@
return defaultLevelName_;
}
- std::string LevelManager::getAvailableLevelListItem(unsigned int index) const
+ const std::string& LevelManager::getAvailableLevelListItem(unsigned int index) const
{
if (index >= availableLevels_.size())
- return std::string();
+ return BLANKSTRING;
else
return availableLevels_[index];
}
void LevelManager::compileAvailableLevelList()
{
- availableLevels_.clear();
-
- availableLevels_ = *Ogre::ResourceGroupManager::getSingleton().findResourceNames(
- Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "*.oxw");
-
+ availableLevels_ = *Resource::findResourceNames("*.oxw");
for (std::vector<std::string>::iterator it = availableLevels_.begin(); it != availableLevels_.end();)
if (it->find("old/") == 0)
it = availableLevels_.erase(it);
Modified: code/trunk/src/orxonox/LevelManager.h
===================================================================
--- code/trunk/src/orxonox/LevelManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/LevelManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -59,7 +59,7 @@
void setDefaultLevel(const std::string& levelName); //tolua_export
const std::string& getDefaultLevel() const; //tolua_export
void compileAvailableLevelList(); //tolua_export
- std::string getAvailableLevelListItem(unsigned int index) const; //tolua_export
+ const std::string& getAvailableLevelListItem(unsigned int index) const; //tolua_export
static LevelManager* getInstancePtr() { return singletonPtr_s; }
static LevelManager& getInstance() { return Singleton<LevelManager>::getInstance(); } // tolua_export
Copied: code/trunk/src/orxonox/MoodManager.cc (from rev 6415, code/branches/presentation2/src/orxonox/MoodManager.cc)
===================================================================
--- code/trunk/src/orxonox/MoodManager.cc (rev 0)
+++ code/trunk/src/orxonox/MoodManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,89 @@
+/*
+ * 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:
+ * Kevin 'youngk' Young
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "MoodManager.h"
+
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
+
+namespace orxonox
+{
+ ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+
+ MoodManager::MoodManager()
+ {
+ RegisterRootObject(MoodManager);
+ this->setConfigValues();
+ }
+
+ void MoodManager::setConfigValues()
+ {
+ SetConfigValue(mood_, "default")
+ .description("Sets the mood for the current level.")
+ .callback(this, &MoodManager::checkMoodValidity);
+ }
+
+ /** Sets the mood
+ @note
+ TODO: Inform dependent classes of mood change
+ */
+ void MoodManager::setMood(const std::string& mood)
+ {
+ ModifyConfigValue(mood_, set, mood);
+ }
+
+ void MoodManager::checkMoodValidity()
+ {
+ // TODO: Insert new moods here & make this generic
+ if (mood_ != "default" && mood_ != "dnb")
+ {
+ ResetConfigValue(mood_);
+ }
+ else
+ {
+ COUT(3) << "Mood changed to " << mood_ << std::endl;
+ MoodListener::changedMood(mood_);
+ }
+ }
+
+
+ std::string MoodListener::mood_s;
+
+ MoodListener::MoodListener()
+ {
+ RegisterRootObject(MoodListener);
+ }
+
+ /*static*/ void MoodListener::changedMood(const std::string& mood)
+ {
+ mood_s = mood;
+ for (ObjectList<MoodListener>::iterator it = ObjectList<MoodListener>::begin(); it; ++it)
+ it->moodChanged(mood_s);
+ }
+}
Copied: code/trunk/src/orxonox/MoodManager.h (from rev 6415, code/branches/presentation2/src/orxonox/MoodManager.h)
===================================================================
--- code/trunk/src/orxonox/MoodManager.h (rev 0)
+++ code/trunk/src/orxonox/MoodManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -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:
+ * Kevin 'youngk' Young
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _MoodManager_H__
+#define _MoodManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport MoodListener : virtual public OrxonoxClass
+ {
+ friend class MoodManager;
+
+ protected:
+ MoodListener();
+ virtual ~MoodListener() {}
+
+ const std::string& getMood() const { return mood_s; }
+
+ private:
+ virtual void moodChanged(const std::string& mood) = 0;
+
+ static void changedMood(const std::string& mood);
+ static std::string mood_s;
+ };
+
+ class _OrxonoxExport MoodManager : public Singleton<MoodManager>, public OrxonoxClass
+ {
+ friend class Singleton<MoodManager>;
+ public:
+ MoodManager();
+
+ void setConfigValues();
+
+ void setMood(const std::string& mood);
+ inline const std::string& getMood() const { return this->mood_; }
+
+ static MoodManager& getInstance() { return Singleton<MoodManager>::getInstance(); }
+
+ private:
+ ~MoodManager() {}
+ void checkMoodValidity();
+
+ // config values
+ std::string mood_;
+
+ static MoodManager* singletonPtr_s;
+ };
+}
+
+#endif /* _MoodManager_H__ */
Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -151,7 +151,9 @@
//sound
class AmbientSound;
class BaseSound;
+ class SoundBuffer;
class SoundManager;
+ class SoundStreamer;
class WorldSound;
// weaponsystem
@@ -168,6 +170,7 @@
class BigExplosion;
class CameraPosition;
class ControllableEntity;
+ class EffectContainer;
class ExplosionChunk;
class MobileEntity;
class MovableEntity;
@@ -175,6 +178,7 @@
class StaticEntity;
class TeamSpawnPoint;
class WorldEntity;
+ class Rocket;
// worldentities, pawns
class Destroyer;
class Pawn;
@@ -208,5 +212,6 @@
typedef struct ALCdevice_struct ALCdevice;
typedef unsigned int ALuint;
typedef int ALint;
+typedef int ALenum;
#endif /* _OrxonoxPrereqs_H__ */
Modified: code/trunk/src/orxonox/PlayerManager.cc
===================================================================
--- code/trunk/src/orxonox/PlayerManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/PlayerManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -37,7 +37,6 @@
namespace orxonox
{
- PlayerManager* PlayerManager::singletonPtr_s = 0;
ManageScopedSingleton(PlayerManager, ScopeID::Root, false);
PlayerManager::PlayerManager()
@@ -90,7 +89,7 @@
player->destroy();
}
}
-
+
void PlayerManager::disconnectAllClients()
{
for( std::map<unsigned int, PlayerInfo*>::iterator it = this->clients_.begin(); it != this->clients_.end(); )
Modified: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Radar.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -39,12 +39,15 @@
#include "core/ConsoleCommand.h"
#include "core/ObjectList.h"
#include "interfaces/RadarListener.h"
+#include "controllers/HumanController.h"
+#include "worldentities/pawns/Pawn.h"
namespace orxonox
{
Radar::Radar()
- : focus_(0)
+ : itFocus_(0)
+ , focus_(0)
, objectTypeCounter_(0)
{
// TODO: make this mapping configurable. Maybe there's a possibility with self configured
@@ -81,7 +84,7 @@
return 0;
}
- RadarViewable::Shape Radar::addObjectDescription(const std::string name)
+ RadarViewable::Shape Radar::addObjectDescription(const std::string& name)
{
std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name);
if (it == this->objectTypes_.end())
@@ -117,21 +120,21 @@
void Radar::cycleFocus()
{
- if (ObjectList<RadarViewable>::begin() == 0)
+ if (ObjectList<RadarViewable>::begin() == ObjectList<RadarViewable>::end())
{
// list is empty
this->itFocus_ = 0;
this->focus_ = 0;
}
-/*
- else if (this->owner_)
+
+ else if (HumanController::getLocalControllerEntityAsPawn())
{
- Vector3 localPosition = this->owner_->getPosition();
+ Vector3 localPosition = HumanController::getLocalControllerEntityAsPawn()->getWorldPosition();
Vector3 targetPosition = localPosition;
- if (*(this->itFocus_))
+ if (this->itFocus_ && *(this->itFocus_))
targetPosition = this->itFocus_->getRVWorldPosition();
- // find the closed object further away than targetPosition
+ // find the closest object further away than targetPosition
float currentDistance = localPosition.squaredDistance(targetPosition);
float nextDistance = FLT_MAX;
float minimumDistance = FLT_MAX;
@@ -139,7 +142,7 @@
for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
{
- if (*it == static_cast<RadarViewable*>(this)->owner_)
+ if (*it == static_cast<RadarViewable*>(HumanController::getLocalControllerEntityAsPawn()))
continue;
float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition());
@@ -166,7 +169,6 @@
this->focus_ = *(this->itFocus_);
}
}
-*/
}
void Radar::releaseFocus()
Modified: code/trunk/src/orxonox/Radar.h
===================================================================
--- code/trunk/src/orxonox/Radar.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Radar.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -54,7 +54,7 @@
virtual void tick(float dt);
const RadarViewable* getFocus();
- RadarViewable::Shape addObjectDescription(const std::string name);
+ RadarViewable::Shape addObjectDescription(const std::string& name);
void listObjects() const;
Modified: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Scene.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -57,6 +57,7 @@
this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
this->bShadows_ = true;
+ this->soundReferenceDistance_ = 20.0;
if (GameMode::showsGraphics())
{
@@ -112,6 +113,7 @@
XMLPortParam(Scene, "skybox", setSkybox, getSkybox, xmlelement, mode);
XMLPortParam(Scene, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2f, 0.2f, 0.2f, 1.0f));
XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
+ XMLPortParam(Scene, "soundReferenceDistance", setSoundReferenceDistance, getSoundReferenceDistance, xmlelement, mode);
XMLPortParam(Scene, "gravity", setGravity, getGravity, xmlelement, mode);
XMLPortParam(Scene, "negativeWorldRange", setNegativeWorldRange, getNegativeWorldRange, xmlelement, mode);
@@ -333,10 +335,8 @@
int index0, const btCollisionObject* colObj1, int partId1, int index1)
{
// get the WorldEntity pointers
- WorldEntity* object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
- assert(orxonox_cast<WorldEntity*>(object0));
- WorldEntity* object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
- assert(orxonox_cast<WorldEntity*>(object1));
+ SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
+ SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
// false means that bullet will assume we didn't modify the contact
bool modified = false;
Modified: code/trunk/src/orxonox/Scene.h
===================================================================
--- code/trunk/src/orxonox/Scene.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Scene.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -70,9 +70,14 @@
inline bool getShadow() const
{ return this->bShadows_; }
+ inline void setSoundReferenceDistance(float distance)
+ { this->soundReferenceDistance_ = distance; }
+ inline float getSoundReferenceDistance() const
+ { return this->soundReferenceDistance_; }
+
inline Radar* getRadar()
{ return this->radar_; }
-
+
inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
virtual void tick(float dt);
@@ -95,6 +100,7 @@
ColourValue ambientLight_;
std::list<BaseObject*> objects_;
bool bShadows_;
+ float soundReferenceDistance_;
Radar* radar_;
Modified: code/trunk/src/orxonox/Test.cc
===================================================================
--- code/trunk/src/orxonox/Test.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Test.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -37,109 +37,114 @@
{
CreateFactory ( Test );
- SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
+ SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
//void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
//void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
// NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
- registerStaticNetworkFunction( &Test::printV1 );
- registerMemberNetworkFunction( Test, checkU1 );
- registerMemberNetworkFunction( Test, printBlaBla );
+ registerStaticNetworkFunction( &Test::printV1 );
+ registerMemberNetworkFunction( Test, checkU1 );
+ registerMemberNetworkFunction( Test, printBlaBla );
- Test* Test::instance_ = 0;
+ Test* Test::instance_ = 0;
Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
{
- assert(instance_==0);
- instance_=this;
+ assert(instance_==0);
+ instance_=this;
RegisterObject ( Test );
- setConfigValues();
- registerVariables();
+ setConfigValues();
+ registerVariables();
setSyncMode(0x3);
+ this->pointer_ = 0;
}
Test::~Test()
{
- instance_=0;
+ instance_=0;
}
void Test::setConfigValues()
{
SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/;
- SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
- SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
- SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+ SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+ SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+ SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
- SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
- SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
- SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
- SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+ SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
+ SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+ SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+ SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
}
- void Test::registerVariables()
- {
- registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
- registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
- registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
- registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
+ void Test::registerVariables()
+ {
+ registerVariable ( u1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
+ registerVariable ( u2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkU2 ));
+ registerVariable ( u3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
+ registerVariable ( u4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
- registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
- registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
- registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
- registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
- }
+ registerVariable ( s1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
+ registerVariable ( s2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkS2 ));
+ registerVariable ( s3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
+ registerVariable ( s4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
+
+ registerVariable ( pointer_, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::printPointer ) );
+ }
void Test::call(unsigned int clientID)
- {
- callStaticNetworkFunction( &Test::printV1, clientID );
- callStaticNetworkFunction( &Test::printV1, clientID );
- }
+ {
+ callStaticNetworkFunction( &Test::printV1, clientID );
+ callStaticNetworkFunction( &Test::printV1, clientID );
+ }
- void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
- {
- callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
- }
+ void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
+ {
+ callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+ }
- void Test::tick(float dt)
- {
-// std::string str1 = "blub";
-// //MultiType mt1(std::string("blub"));
-// MultiType mt1(str1);
-// uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
-// uint8_t* temp = mem;
-// mt1.exportData( temp );
-// assert( temp-mem == mt1.getNetworkSize() );
-// MultiType mt2;
-// temp = mem;
-// mt2.importData( temp );
-// assert( temp-mem == mt1.getNetworkSize() );
-// COUT(0) << mt2 << endl;
- if(!Core::isMaster())
- call2(0, "bal", "a", "n", "ce");
-// callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
- }
-
- void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
- {
- COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
- }
-
- void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
- void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
- void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
- void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
+ void Test::tick(float dt)
+ {
+ // std::string str1 = "blub";
+ // //MultiType mt1(std::string("blub"));
+ // MultiType mt1(str1);
+ // uint8_t* mem = new uint8_t[mt1.getNetworkSize()];
+ // uint8_t* temp = mem;
+ // mt1.exportData( temp );
+ // assert( temp-mem == mt1.getNetworkSize() );
+ // MultiType mt2;
+ // temp = mem;
+ // mt2.importData( temp );
+ // assert( temp-mem == mt1.getNetworkSize() );
+ // COUT(0) << mt2 << endl;
+ // if(!Core::isMaster())
+ // call2(0, "bal", "a", "n", "ce");
+ // callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+ }
+
+ void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
+ {
+ COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+ }
+
+ void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
+ void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
+ void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
+ void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
- void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
- void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
- void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
- void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
+ void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
+ void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
+ void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
+ void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
+
+ void Test::printPointer(){ CCOUT(1) << "pointer: " << this->pointer_ << endl; }
}
Modified: code/trunk/src/orxonox/Test.h
===================================================================
--- code/trunk/src/orxonox/Test.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/Test.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -75,6 +75,8 @@
void checkS3();
void checkS4();
+ void printPointer();
+
static void printV1(){ instance_->checkU1(); }
static void printV2(){ instance_->checkU2(); }
static void printV3(){ instance_->checkU3(); }
@@ -93,6 +95,8 @@
TYPE s3;
TYPE s4;
+ Test* pointer_;
+
static Test* instance_;
};
}
Modified: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -45,7 +45,7 @@
this->bShooting_ = false;
this->bHasTargetPosition_ = false;
this->targetPosition_ = Vector3::ZERO;
-
+
this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
}
@@ -142,6 +142,10 @@
this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
+
+ Pawn* pawn = dynamic_cast<Pawn*>(this->getControllableEntity());
+ if (pawn)
+ pawn->setAimPosition(this->targetPosition_);
}
bool ArtificialController::isCloseAtTarget(float distance) const
Modified: code/trunk/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/ArtificialController.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,7 +41,7 @@
public:
ArtificialController(BaseObject* creator);
virtual ~ArtificialController();
-
+
void abandonTarget(Pawn* target);
protected:
Modified: code/trunk/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/controllers/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,6 +1,7 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
Controller.cc
HumanController.cc
+ NewHumanController.cc
ArtificialController.cc
AIController.cc
ScriptController.cc
Modified: code/trunk/src/orxonox/controllers/Controller.cc
===================================================================
--- code/trunk/src/orxonox/controllers/Controller.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/Controller.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -28,6 +28,7 @@
#include "Controller.h"
#include "core/CoreIncludes.h"
+#include "worldentities/ControllableEntity.h"
namespace orxonox
{
@@ -39,6 +40,7 @@
this->player_ = 0;
this->controllableEntity_ = 0;
+ this->bGodMode_ = false;
}
Controller::~Controller()
Modified: code/trunk/src/orxonox/controllers/Controller.h
===================================================================
--- code/trunk/src/orxonox/controllers/Controller.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/Controller.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -36,6 +36,10 @@
{
class _OrxonoxExport Controller : public BaseObject
{
+ // set friend classes to access setControllableEntity
+ friend class PlayerInfo;
+ friend class ControllableEntity;
+
public:
Controller(BaseObject* creator);
virtual ~Controller();
@@ -45,6 +49,17 @@
inline PlayerInfo* getPlayer() const
{ return this->player_; }
+ virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
+
+ void setGodMode( bool mode ){ this->bGodMode_ = mode; }
+ bool getGodMode(){ return this->bGodMode_; }
+
+ inline ControllableEntity* getControllableEntity() const
+ { return this->controllableEntity_; }
+ virtual void changedControllableEntity() {}
+
+ protected:
+ // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do)
inline void setControllableEntity(ControllableEntity* entity)
{
if (entity != this->controllableEntity_)
@@ -53,13 +68,12 @@
this->changedControllableEntity();
}
}
- inline ControllableEntity* getControllableEntity() const
- { return this->controllableEntity_; }
- virtual void changedControllableEntity() {}
protected:
PlayerInfo* player_;
ControllableEntity* controllableEntity_;
+ private:
+ bool bGodMode_;
};
}
Modified: code/trunk/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/HumanController.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,8 +35,6 @@
#include "gametypes/Gametype.h"
#include "infos/PlayerInfo.h"
#include "overlays/Map.h"
-#include "graphics/Camera.h"
-#include "sound/SoundManager.h"
#include "Radar.h"
#include "Scene.h"
@@ -55,6 +53,7 @@
SetConsoleCommand(HumanController, switchCamera, true);
SetConsoleCommand(HumanController, mouseLook, true);
SetConsoleCommand(HumanController, suicide, true);
+ SetConsoleCommand(HumanController, toggleGodMode, true);
SetConsoleCommand(HumanController, addBots, true).defaultValues(1);
SetConsoleCommand(HumanController, killBots, true).defaultValues(0);
SetConsoleCommand(HumanController, dropItems, true);
@@ -70,6 +69,8 @@
{
RegisterObject(HumanController);
+ controlPaused_ = false;
+
HumanController::localController_s = this;
}
@@ -82,20 +83,20 @@
{
if (GameMode::playsSound() && HumanController::localController_s && HumanController::localController_s->controllableEntity_)
{
- // Update sound listener
Camera* camera = HumanController::localController_s->controllableEntity_->getCamera();
- if (camera)
- {
- SoundManager::getInstance().setListenerPosition(camera->getWorldPosition());
- SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation());
- }
- else
+ if (!camera)
COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
}
}
void HumanController::moveFrontBack(const Vector2& value)
{
+ if (HumanController::localController_s)
+ HumanController::localController_s->frontback(value);
+ }
+
+ void HumanController::frontback(const Vector2& value)
+ {
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->moveFrontBack(value);
}
@@ -112,7 +113,7 @@
HumanController::localController_s->controllableEntity_->moveUpDown(value);
}
- void HumanController::rotateYaw(const Vector2& value)
+ void HumanController::yaw(const Vector2& value)
{
//Hack to enable mouselook in map
if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
@@ -124,7 +125,7 @@
HumanController::localController_s->controllableEntity_->rotateYaw(value);
}
- void HumanController::rotatePitch(const Vector2& value)
+ void HumanController::pitch(const Vector2& value)
{
//Hack to enable mouselook in map
if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
@@ -136,6 +137,18 @@
HumanController::localController_s->controllableEntity_->rotatePitch(value);
}
+ void HumanController::rotateYaw(const Vector2& value)
+ {
+ if (HumanController::localController_s)
+ HumanController::localController_s->yaw(value);
+ }
+
+ void HumanController::rotatePitch(const Vector2& value)
+ {
+ if (HumanController::localController_s)
+ HumanController::localController_s->pitch(value);
+ }
+
void HumanController::rotateRoll(const Vector2& value)
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
@@ -144,6 +157,12 @@
void HumanController::fire(unsigned int firemode)
{
+ if (HumanController::localController_s)
+ HumanController::localController_s->doFire(firemode);
+ }
+
+ void HumanController::doFire(unsigned int firemode)
+ {
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->fire(firemode);
}
@@ -190,6 +209,11 @@
}
}
+ void HumanController::toggleGodMode()
+ {
+ HumanController::getLocalControllerSingleton()->setGodMode( !HumanController::getLocalControllerSingleton()->getGodMode() );
+ }
+
void HumanController::useItem()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
@@ -233,4 +257,16 @@
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus();
}
+
+ void HumanController::pauseControl()
+ {
+ if (HumanController::localController_s)
+ HumanController::localController_s->doPauseControl();
+ }
+
+ void HumanController::resumeControl()
+ {
+ if (HumanController::localController_s)
+ HumanController::localController_s->doResumeControl();
+ }
}
Modified: code/trunk/src/orxonox/controllers/HumanController.h
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/controllers/HumanController.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,10 +34,13 @@
#include "tools/interfaces/Tickable.h"
#include "Controller.h"
+// tolua_begin
namespace orxonox
{
- class _OrxonoxExport HumanController : public Controller, public Tickable
- {
+ class _OrxonoxExport HumanController
+// tolua_end
+ : public Controller, public Tickable
+ { // tolua_export
public:
HumanController(BaseObject* creator);
virtual ~HumanController();
@@ -52,7 +55,12 @@
static void rotatePitch(const Vector2& value);
static void rotateRoll(const Vector2& value);
+ virtual void frontback(const Vector2& value);
+ virtual void yaw(const Vector2& value);
+ virtual void pitch(const Vector2& value);
+
static void fire(unsigned int firemode);
+ virtual void doFire(unsigned int firemode);
static void reload();
static void boost();
@@ -65,19 +73,26 @@
static void releaseNavigationFocus();
static void suicide();
+ static void toggleGodMode();
static void addBots(unsigned int amount);
static void killBots(unsigned int amount = 0);
+ static void pauseControl(); // tolua_export
+ static void resumeControl(); // tolua_export
+ virtual void doPauseControl() {};
+ virtual void doResumeControl() {};
+
static inline HumanController* getLocalControllerSingleton()
{ return HumanController::localController_s; }
static Pawn* getLocalControllerEntityAsPawn();
//friend class, for mouselook
friend class Map;
- private:
+ protected:
static HumanController* localController_s;
- };
-}
+ bool controlPaused_;
+ }; // tolua_export
+} // tolua_export
#endif /* _HumanController_H__ */
Copied: code/trunk/src/orxonox/controllers/NewHumanController.cc (from rev 6415, code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc)
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc (rev 0)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,576 @@
+/*
+ * 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:
+ * Michael Wirth
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "NewHumanController.h"
+
+#include <cmath>
+#include <OgreRay.h>
+#include <OgreSceneQuery.h>
+#include <OgreCamera.h>
+#include <OgreSceneManager.h>
+#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
+#include "infos/PlayerInfo.h"
+#include "overlays/OrxonoxOverlay.h"
+#include "graphics/Camera.h"
+#include "sound/SoundManager.h"
+#include "tools/BulletConversions.h"
+#include "Scene.h"
+
+namespace orxonox
+{
+ SetConsoleCommand(NewHumanController, changeMode, false).keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand(NewHumanController, accelerate, false).keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand(NewHumanController, decelerate, false).keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand(NewHumanController, unfire, true).keybindMode(KeybindMode::OnRelease);
+
+ CreateUnloadableFactory(NewHumanController);
+
+ NewHumanController* NewHumanController::localController_s = 0;
+
+ NewHumanController::NewHumanController(BaseObject* creator)
+ : HumanController(creator)
+ , crossHairOverlay_(NULL)
+ , centerOverlay_(NULL)
+ , damageOverlayTop_(NULL)
+ , damageOverlayRight_(NULL)
+ , damageOverlayBottom_(NULL)
+ , damageOverlayLeft_(NULL)
+ , damageOverlayTT_(0)
+ , arrowsOverlay1_(NULL)
+ , arrowsOverlay2_(NULL)
+ , arrowsOverlay3_(NULL)
+ , arrowsOverlay4_(NULL)
+ {
+ RegisterObject(NewHumanController);
+
+ overlaySize_ = 0.08;
+ arrowsSize_ = 0.4;
+
+ damageOverlayTime_ = 0.6;
+
+ controlMode_ = 0;
+ acceleration_ = 0;
+ accelerating_ = false;
+ firemode_ = -1;
+
+ showArrows_ = true;
+ showOverlays_ = false;
+ showDamageOverlay_ = true;
+
+ //currentPitch_ = 1;
+ //currentYaw_ = 1;
+
+ if (GameMode::showsGraphics())
+ {
+ crossHairOverlay_ = new OrxonoxOverlay(this);
+ crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
+ crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
+ crossHairOverlay_->hide();
+ //crossHairOverlay_->setAspectCorrection(true); not working
+
+ centerOverlay_ = new OrxonoxOverlay(this);
+ centerOverlay_->setBackgroundMaterial("Orxonox/CenterOverlay");
+ centerOverlay_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+ centerOverlay_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));
+ centerOverlay_->hide();
+
+ if (showDamageOverlay_)
+ {
+ damageOverlayTop_ = new OrxonoxOverlay(this);
+ damageOverlayTop_->setBackgroundMaterial("Orxonox/DamageOverlayTop");
+ damageOverlayTop_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+ damageOverlayTop_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));
+ damageOverlayTop_->hide();
+
+ damageOverlayRight_ = new OrxonoxOverlay(this);
+ damageOverlayRight_->setBackgroundMaterial("Orxonox/DamageOverlayRight");
+ damageOverlayRight_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+ damageOverlayRight_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));
+ damageOverlayRight_->hide();
+
+ damageOverlayBottom_ = new OrxonoxOverlay(this);
+ damageOverlayBottom_->setBackgroundMaterial("Orxonox/DamageOverlayBottom");
+ damageOverlayBottom_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+ damageOverlayBottom_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));
+ damageOverlayBottom_->hide();
+
+ damageOverlayLeft_ = new OrxonoxOverlay(this);
+ damageOverlayLeft_->setBackgroundMaterial("Orxonox/DamageOverlayLeft");
+ damageOverlayLeft_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+ damageOverlayLeft_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));
+ damageOverlayLeft_->hide();
+ }
+
+ if (showArrows_)
+ {
+ arrowsOverlay1_ = new OrxonoxOverlay(this);
+ arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1");
+ arrowsOverlay1_->setSize(Vector2(0.02727, 0.36 * arrowsSize_));
+ arrowsOverlay1_->setPickPoint(Vector2(0.5, 0.5));
+ arrowsOverlay1_->setPosition(Vector2(0.5, 0.5));
+ arrowsOverlay1_->hide();
+
+ arrowsOverlay2_ = new OrxonoxOverlay(this);
+ arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2");
+ arrowsOverlay2_->setSize(Vector2(0.02727, 0.59 * arrowsSize_));
+ arrowsOverlay2_->setPickPoint(Vector2(0.5, 0.5));
+ arrowsOverlay2_->setPosition(Vector2(0.5, 0.5));
+ arrowsOverlay2_->hide();
+
+ arrowsOverlay3_ = new OrxonoxOverlay(this);
+ arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3");
+ arrowsOverlay3_->setSize(Vector2(0.02727, 0.77 * arrowsSize_));
+ arrowsOverlay3_->setPickPoint(Vector2(0.5, 0.5));
+ arrowsOverlay3_->setPosition(Vector2(0.5, 0.5));
+ arrowsOverlay3_->hide();
+
+ arrowsOverlay4_ = new OrxonoxOverlay(this);
+ arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4");
+ arrowsOverlay4_->setSize(Vector2(0.02727, arrowsSize_));
+ arrowsOverlay4_->setPickPoint(Vector2(0.5, 0.5));
+ arrowsOverlay4_->setPosition(Vector2(0.5, 0.5));
+ arrowsOverlay4_->hide();
+ }
+ }
+
+ // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
+ this->targetMask_.exclude(ClassByString("BaseObject"));
+ this->targetMask_.include(ClassByString("WorldEntity"));
+ this->targetMask_.exclude(ClassByString("Projectile"));
+
+ NewHumanController::localController_s = this;
+
+ controlPaused_ = false;
+
+ //HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
+ }
+
+ NewHumanController::~NewHumanController()
+ {
+ if (this->isInitialized())
+ {
+ if (this->crossHairOverlay_)
+ this->crossHairOverlay_->destroy();
+ if (this->centerOverlay_)
+ this->centerOverlay_->destroy();
+
+ if (showArrows_)
+ {
+ if (this->arrowsOverlay1_)
+ this->arrowsOverlay1_->destroy();
+ if (this->arrowsOverlay2_)
+ this->arrowsOverlay2_->destroy();
+ if (this->arrowsOverlay3_)
+ this->arrowsOverlay3_->destroy();
+ if (this->arrowsOverlay4_)
+ this->arrowsOverlay4_->destroy();
+ }
+ }
+ }
+
+ void NewHumanController::tick(float dt)
+ {
+ if (GameMode::showsGraphics())
+ {
+
+ if (this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
+ {
+ this->updateTarget();
+
+ if (!controlPaused_ )
+ {
+ if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
+ this->showOverlays();
+
+ this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
+
+ if (this->controlMode_ == 0 || (this->controlMode_ == 1 && this->firemode_ == 1))
+ {
+ if (this->showOverlays_ && this->showArrows_)
+ alignArrows();
+ }
+ else
+ hideArrows();
+
+ if (this->showDamageOverlay_ && (this->damageOverlayTT_ > 0 || this->damageOverlayTR_ > 0 || this->damageOverlayTB_ > 0 || this->damageOverlayTL_ > 0))
+ {
+ this->damageOverlayTT_ -= dt;
+ this->damageOverlayTR_ -= dt;
+ this->damageOverlayTB_ -= dt;
+ this->damageOverlayTL_ -= dt;
+ if (this->damageOverlayTT_ <= 0)
+ this->damageOverlayTop_->hide();
+ if (this->damageOverlayTR_ <= 0)
+ this->damageOverlayRight_->hide();
+ if (this->damageOverlayTB_ <= 0)
+ this->damageOverlayBottom_->hide();
+ if (this->damageOverlayTL_ <= 0)
+ this->damageOverlayLeft_->hide();
+ }
+ }
+ }
+ else
+ this->hideOverlays();
+
+ if (this->acceleration_ > 0)
+ {
+ if (this->accelerating_)
+ HumanController::moveFrontBack(Vector2(1, 0));
+ else
+ HumanController::moveFrontBack(Vector2(this->acceleration_, 0));
+ this->accelerating_ = false;
+ //HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
+ }
+ }
+
+ // Reset pitch and yaw rates
+ // TODO: Reactivate this to fix the game pad problem with 0 input
+ //this->currentPitch_ = 0;
+ //this->currentYaw_ = 0;
+
+ HumanController::tick(dt);
+ }
+
+ void NewHumanController::doFire(unsigned int firemode)
+ {
+ if (!this->controllableEntity_)
+ return;
+
+ this->firemode_ = firemode;
+
+ if (firemode == 1 && this->controlMode_ == 1)
+ {
+ //unlocked steering, steer on right mouse click
+ HumanController::yaw(Vector2(this->currentYaw_, 0));
+ HumanController::pitch(Vector2(this->currentPitch_, 0));
+ }
+ else
+ HumanController::localController_s->getControllableEntity()->fire(firemode);
+
+ }
+
+ void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
+ {
+ if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
+ {
+ Vector3 posA;
+ if (originator)
+ posA = originator->getWorldPosition();
+ else
+ posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
+ //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
+ //posA and posB are almost identical
+
+ Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation().UnitInverse() * (this->getControllableEntity()->getWorldPosition() - posA);
+
+ //back is z positive
+ //x is left positive
+ //y is down positive
+ relativeHit.normalise();
+
+ float threshold = 0.3;
+ if (relativeHit.x > threshold) // Left
+ {
+ this->damageOverlayLeft_->show();
+ this->damageOverlayTL_ = this->damageOverlayTime_;
+ //this->damageOverlayLeft_->setBackgroundAlpha(0.3);
+ }
+ if (relativeHit.x < -threshold) //Right
+ {
+ this->damageOverlayRight_->show();
+ this->damageOverlayTR_ = this->damageOverlayTime_;
+ //this->damageOverlayRight_->setBackgroundAlpha(0.3);
+ }
+ if (relativeHit.y > threshold) //Top
+ {
+ this->damageOverlayBottom_->show();
+ this->damageOverlayTB_ = this->damageOverlayTime_;
+ //this->damageOverlayTop_->setBackgroundAlpha(0.3);
+ }
+ if (relativeHit.y < -threshold) //Bottom
+ {
+ this->damageOverlayTop_->show();
+ this->damageOverlayTT_ = this->damageOverlayTime_;
+ //this->damageOverlayBottom_->setBackgroundAlpha(0.3);
+ }
+ }
+ }
+
+ void NewHumanController::unfire()
+ {
+ if (NewHumanController::localController_s)
+ NewHumanController::localController_s->doUnfire();
+ }
+
+ void NewHumanController::doUnfire()
+ {
+ this->firemode_ = -1;
+ hideArrows();
+ }
+
+ void NewHumanController::updateTarget()
+ {
+ Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
+
+ Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5);
+
+ rsq->setRay(mouseRay);
+ rsq->setSortByDistance(true);
+
+ /*
+ Distance of objects:
+ ignore everything under 200 maybe even take 1000 as min distance to shoot at
+
+ shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
+ they vanish only after a distance of 10'000
+ */
+
+
+ Ogre::RaySceneQueryResult& result = rsq->execute();
+ Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
+
+ Ogre::RaySceneQueryResult::iterator itr;
+ for (itr = result.begin(); itr != result.end(); ++itr)
+ {
+ if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
+ {
+ // Try to cast the user pointer
+ WorldEntity* wePtr = dynamic_cast<WorldEntity*>(itr->movable->getUserObject());
+ if (wePtr)
+ {
+ // go through all parents of object and look whether they are sightable or not
+ bool isSightable = false;
+ WorldEntity* parent = wePtr->getParent();
+ while (parent)
+ {
+ if (this->targetMask_.isExcluded(parent->getIdentifier()))
+ {
+ parent = parent->getParent();
+ continue;
+ }
+ else
+ {
+ isSightable = true;
+ break;
+ }
+ }
+ if (!isSightable)
+ continue;
+ }
+
+ if (this->getControllableEntity() && this->getControllableEntity()->getTarget() != wePtr)
+ this->getControllableEntity()->setTarget(wePtr);
+
+ if (pawn)
+ pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance );
+
+ //itr->movable->getParentSceneNode()->showBoundingBox(true);
+ //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
+ return;
+ }
+ }
+
+ if (pawn)
+ pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
+
+ if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != 0 )
+ this->getControllableEntity()->setTarget( 0 );
+
+ //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
+ //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
+ }
+
+ void NewHumanController::frontback(const Vector2& value)
+ {
+ this->accelerating_ = true;
+
+ //if (this->acceleration_ == 0)
+ HumanController::frontback(value);
+ }
+
+ void NewHumanController::yaw(const Vector2& value)
+ {
+ //SUPER(NewHumanController, yaw, value);
+ if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
+ HumanController::yaw(value);
+
+ this->currentYaw_ = value.x;
+ }
+
+ void NewHumanController::pitch(const Vector2& value)
+ {
+ //SUPER(NewHumanController, pitch, value);
+ if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
+ HumanController::pitch(value);
+
+ this->currentPitch_ = value.x;
+ }
+
+ void NewHumanController::changeMode()
+ {
+ if (NewHumanController::localController_s)
+ {
+ if (NewHumanController::localController_s->controlMode_ == 0)
+ {
+ NewHumanController::localController_s->controlMode_ = 1;
+ NewHumanController::localController_s->hideArrows();
+ }
+ else
+ NewHumanController::localController_s->controlMode_ = 0;
+ }
+ }
+
+ void NewHumanController::changedControllableEntity()
+ {
+ this->controlMode_ = 0;
+ this->currentYaw_ = 0;
+ this->currentPitch_ = 0;
+ if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
+ {
+ this->showOverlays_ = true;
+ if (!this->controlPaused_)
+ {
+ this->showOverlays();
+ this->alignArrows();
+ }
+ }
+ else
+ {
+ this->showOverlays_ = false;
+ this->hideOverlays();
+ }
+ }
+
+ void NewHumanController::accelerate()
+ {
+ if (NewHumanController::localController_s)
+ NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.2f, 0.00f, 1.0f);
+ }
+
+ void NewHumanController::decelerate()
+ {
+ if (NewHumanController::localController_s)
+ NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.1f, 0.0f, 1.0f);
+ }
+
+ void NewHumanController::doResumeControl()
+ {
+ this->controlPaused_ = false;
+ if (this->showOverlays_)
+ this->showOverlays();
+ }
+
+ void NewHumanController::doPauseControl()
+ {
+ this->controlPaused_ = true;
+ this->hideOverlays();
+ }
+
+ void NewHumanController::alignArrows()
+ {
+ if (showArrows_)
+ {
+ hideArrows();
+
+ float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2));
+
+ if (distance > 0.04 && distance <= 0.59 * arrowsSize_ / 2.0 )
+ {
+ this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
+ this->arrowsOverlay1_->show();
+ }
+ else if (distance > 0.59 * arrowsSize_ / 2.0 && distance <= 0.77 * arrowsSize_ / 2.0 )
+ {
+ this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
+ this->arrowsOverlay2_->show();
+ }
+ else if (distance > 0.77 * arrowsSize_ / 2.0 && distance <= arrowsSize_ / 2.0)
+ {
+ this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
+ this->arrowsOverlay3_->show();
+ }
+ else if (distance > arrowsSize_ / 2.0)
+ {
+ this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0 * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));
+ this->arrowsOverlay4_->show();
+ }
+ }
+ }
+
+ void NewHumanController::showOverlays()
+ {
+ if (!GameMode::showsGraphics())
+ return;
+ this->crossHairOverlay_->show();
+ this->centerOverlay_->show();
+
+ if (showArrows_)
+ {
+ this->arrowsOverlay1_->show();
+ this->arrowsOverlay2_->show();
+ this->arrowsOverlay3_->show();
+ this->arrowsOverlay4_->show();
+ }
+ }
+
+ void NewHumanController::hideOverlays()
+ {
+ if (!GameMode::showsGraphics())
+ return;
+ this->crossHairOverlay_->hide();
+ this->centerOverlay_->hide();
+
+ if (showDamageOverlay_)
+ {
+ this->damageOverlayTop_->hide();
+ this->damageOverlayRight_->hide();
+ this->damageOverlayBottom_->hide();
+ this->damageOverlayLeft_->hide();
+ }
+
+ this->hideArrows();
+ }
+
+ void NewHumanController::hideArrows()
+ {
+ if(!GameMode::showsGraphics())
+ return;
+ if (showArrows_)
+ {
+ this->arrowsOverlay1_->hide();
+ this->arrowsOverlay2_->hide();
+ this->arrowsOverlay3_->hide();
+ this->arrowsOverlay4_->hide();
+ }
+ }
+}
Copied: code/trunk/src/orxonox/controllers/NewHumanController.h (from rev 6415, code/branches/presentation2/src/orxonox/controllers/NewHumanController.h)
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.h (rev 0)
+++ code/trunk/src/orxonox/controllers/NewHumanController.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,112 @@
+/*
+ * 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:
+ * Michael Wirth
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _NewNewHumanController_H__
+#define _NewNewHumanController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "util/Math.h"
+
+#include "core/ClassTreeMask.h"
+#include "HumanController.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport NewHumanController : public HumanController
+ {
+ public:
+ NewHumanController(BaseObject* creator);
+ virtual ~NewHumanController();
+
+ virtual void tick(float dt);
+
+ virtual void frontback(const Vector2& value);
+ virtual void yaw(const Vector2& value);
+ virtual void pitch(const Vector2& value);
+
+ static void accelerate();
+ static void decelerate();
+
+ virtual void doFire(unsigned int firemode);
+
+ virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
+
+ static void unfire();
+ virtual void doUnfire();
+
+ static void changeMode();
+
+ virtual void changedControllableEntity();
+ virtual void doPauseControl();
+ virtual void doResumeControl();
+
+ protected:
+ void updateTarget();
+ void alignArrows();
+ void showOverlays();
+ void hideOverlays();
+ void hideArrows();
+
+ unsigned int controlMode_;
+ static NewHumanController* localController_s;
+
+ private:
+ float currentYaw_;
+ float currentPitch_;
+ OrxonoxOverlay* crossHairOverlay_;
+ OrxonoxOverlay* centerOverlay_;
+
+ OrxonoxOverlay* damageOverlayTop_;
+ OrxonoxOverlay* damageOverlayRight_;
+ OrxonoxOverlay* damageOverlayBottom_;
+ OrxonoxOverlay* damageOverlayLeft_;
+ float damageOverlayTime_;
+ float damageOverlayTT_;
+ float damageOverlayTR_;
+ float damageOverlayTB_;
+ float damageOverlayTL_;
+
+ OrxonoxOverlay* arrowsOverlay1_;
+ OrxonoxOverlay* arrowsOverlay2_;
+ OrxonoxOverlay* arrowsOverlay3_;
+ OrxonoxOverlay* arrowsOverlay4_;
+
+ float overlaySize_;
+ float arrowsSize_;
+ bool accelerating_;
+ float acceleration_;
+ int firemode_;
+ bool showArrows_;
+ bool showDamageOverlay_;
+ bool showOverlays_;
+ ClassTreeMask targetMask_;
+ };
+}
+
+#endif /* _NewHumanController_H__ */
Deleted: code/trunk/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSDedicated.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSDedicated.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,301 +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:
- * Fabian 'x3n' Landau
- *
- */
-
-#include "GSDedicated.h"
-
-#include <iomanip>
-#include <iostream>
-#include <boost/bind.hpp>
-
-#include "util/Clock.h"
-#include "util/Debug.h"
-#include "util/Sleep.h"
-#include "core/CommandLineParser.h"
-#include "core/CommandExecutor.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
-#include "network/Server.h"
-
-#ifdef ORXONOX_PLATFORM_UNIX
-#include <termios.h>
-#endif
-
-
-namespace orxonox
-{
- const unsigned int MAX_COMMAND_LENGTH = 255;
-
- DeclareGameState(GSDedicated, "dedicated", false, false);
-
- termios* GSDedicated::originalTerminalSettings_;
-
- GSDedicated::GSDedicated(const GameStateInfo& info)
- : GameState(info)
- , server_(0)
- , closeThread_(false)
- , cleanLine_(true)
- , inputIterator_(0)
- , cursorX_(0)
- , cursorY_(0)
- {
- }
-
- GSDedicated::~GSDedicated()
- {
- }
-
- void GSDedicated::activate()
- {
- GameMode::setHasServer(true);
-
- this->inputThread_ = new boost::thread(boost::bind(&GSDedicated::inputThread, this));
-
-#ifndef ORXONOX_PLATFORM_WINDOWS
- this->originalTerminalSettings_ = new termios;
- this->setTerminalMode();
-#endif
-
- this->server_ = new Server(CommandLineParser::getValue("port"));
- COUT(0) << "Loading scene in server mode" << std::endl;
-
- server_->open();
- }
-
- void GSDedicated::deactivate()
- {
- this->server_->close();
- delete this->server_;
-
- closeThread_ = true;
-#ifdef ORXONOX_PLATFORM_UNIX
- std::cout << "\033[0G\033[K";
- std::cout.flush();
- resetTerminalMode();
- delete this->originalTerminalSettings_;
-#else
- COUT(0) << "Press enter to end the game..." << std::endl;
-#endif
- inputThread_->join();
- delete this->inputThread_;
-
- GameMode::setHasServer(false);
- }
-
- void GSDedicated::update(const Clock& time)
- {
- server_->update(time);
- processQueue();
- printLine();
- }
-
- void GSDedicated::inputThread()
- {
- this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH];
-// memset( this->commandLine_, 0, MAX_COMMAND_LENGTH );
- unsigned char c;
- unsigned int escapeChar=0;
- while(!closeThread_)
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- size_t count = read(STDIN_FILENO, &c, 1);
- if (count == 1)
-#else
- c = getchar();
-#endif
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- if ( inputIterator_>=MAX_COMMAND_LENGTH-1 && c!='\n' )
- continue;
- if( escapeChar > 0 )
- {
- if( c == '[' )
- {
- escapeChar = 2;
- continue;
-}
- else if ( escapeChar == 2 )
- {
- switch (c)
- {
- case 'A': //keyup
-
- break;
- case 'B': //keydown
-
- break;
- case 'C': //keyright
- if(cursorX_<inputIterator_)
- ++cursorX_;
- break;
- case 'D': //keyleft
- if(cursorX_>0)
- --cursorX_;
- break;
- default: //not supported...
-// std::cout << endl << c << endl;
- break;
- }
- escapeChar = 0;
- }
- }
- else // not in escape sequence mode
- {
- switch (c)
- {
- case '\n':
- this->cleanLine_ = true;
- {
- boost::recursive_mutex::scoped_lock(this->inputQueueMutex_);
- boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- this->commandQueue_.push( std::string((const char*)this->commandLine_,inputIterator_) );
- }
- memset( this->commandLine_, 0, inputIterator_ );
- inputIterator_ = 0;
- this->cursorX_ = 0;
- this->cursorY_ = 0;
- std::cout << endl;
- break;
- case 127: // backspace
- case '\b':
- deleteCharacter( this->cursorX_ );
- break;
- case '\t':
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- std::cout << endl << CommandExecutor::hint( std::string((const char*)this->commandLine_,inputIterator_) ) << endl;
- strncpy(reinterpret_cast<char*>(this->commandLine_), CommandExecutor::complete( std::string(reinterpret_cast<char*>(this->commandLine_),inputIterator_) ).c_str(), MAX_COMMAND_LENGTH);
- this->inputIterator_ = strlen((const char*)this->commandLine_);
- this->cursorX_ = this->inputIterator_;
- break;
- }
- case '\033': // 1. escape character
- escapeChar = 1;
- break;
- default:
- insertCharacter( this->cursorX_, c );
- break;
- }
- }
- }
- }
-
- delete[] this->commandLine_;
- }
-
- void GSDedicated::printLine()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- // set cursor to the begining of the line and erase the line
- std::cout << "\033[0G\033[K";
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- // print status line
- std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # ";
- //save cursor position
- std::cout << "\033[s";
- //print commandLine buffer
- std::cout << std::string((const char*)this->commandLine_, inputIterator_);
- //restore cursor position and move it cursorX_ to the right
- std::cout << "\033[u";
- if( this->cursorX_ > 0 )
- std::cout << "\033[" << this->cursorX_ << "C";
- std::cout.flush();
-#endif
- }
-
- void GSDedicated::processQueue()
- {
- std::string tempstr;
- {
- boost::recursive_mutex::scoped_lock lock1(this->inputQueueMutex_);
- while(true)
- {
- if ( !this->commandQueue_.empty() )
- {
- tempstr = this->commandQueue_.front();
- this->commandQueue_.pop();
- lock1.unlock();
- }
- else
- break;
- CommandExecutor::execute(tempstr, true);
- }
- }
- }
-
- void GSDedicated::setTerminalMode()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- termios new_settings;
-
- tcgetattr(0,this->originalTerminalSettings_);
- new_settings = *this->originalTerminalSettings_;
- new_settings.c_lflag &= ~( ICANON | ECHO );
-// new_settings.c_lflag |= ( ISIG | IEXTEN );
- new_settings.c_cc[VTIME] = 1;
- new_settings.c_cc[VMIN] = 0;
- tcsetattr(0,TCSANOW,&new_settings);
- COUT(0) << endl;
-// atexit(&GSDedicated::resetTerminalMode);
-#endif
- }
-
- void GSDedicated::resetTerminalMode()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- tcsetattr(0, TCSANOW, GSDedicated::originalTerminalSettings_);
-#endif
- }
-
- void GSDedicated::insertCharacter( unsigned int position, char c )
- {
-// std::cout << endl << static_cast<unsigned int>(c) << endl;
- // check that we do not exceed MAX_COMMAND_LENGTH
- if( inputIterator_+1 < MAX_COMMAND_LENGTH )
- {
- // if cursor not at end of line then move the rest of the line
- if( position != this->inputIterator_ )
- memmove( this->commandLine_+position+1, this->commandLine_+position, this->inputIterator_-position);
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- this->commandLine_[position] = c;
- ++this->cursorX_;
- ++this->inputIterator_;
- }
- }
- void GSDedicated::deleteCharacter( unsigned int position )
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- if ( this->inputIterator_>0 && position>0 )
- {
- if ( position != this->inputIterator_ )
- memmove( this->commandLine_+position-1, this->commandLine_+position, this->inputIterator_-position);
- --this->cursorX_;
- --this->inputIterator_;
- }
- }
-
-}
Deleted: code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,306 +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:
- * Oliver Scheuss
- *
- */
-
-#include "GSDedicatedClient.h"
-
-#include <iomanip>
-#include <iostream>
-#include <boost/bind.hpp>
-
-#include "util/Clock.h"
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "util/Sleep.h"
-#include "core/CommandLineParser.h"
-#include "core/CommandExecutor.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
-#include "network/Client.h"
-
-#ifdef ORXONOX_PLATFORM_UNIX
-#include <termios.h>
-#endif
-
-
-namespace orxonox
-{
- const unsigned int MAX_COMMAND_LENGTH = 255;
-
- DeclareGameState(GSDedicatedClient, "dedicatedClient", false, false);
-
- termios* GSDedicatedClient::originalTerminalSettings_;
-
- GSDedicatedClient::GSDedicatedClient(const GameStateInfo& info)
- : GameState(info)
- , client_(0)
- , closeThread_(false)
- , cleanLine_(true)
- , inputIterator_(0)
- , cursorX_(0)
- , cursorY_(0)
- {
- }
-
- GSDedicatedClient::~GSDedicatedClient()
- {
- }
-
- void GSDedicatedClient::activate()
- {
- this->inputThread_ = new boost::thread(boost::bind(&GSDedicatedClient::inputThread, this));
-
-#ifndef ORXONOX_PLATFORM_WINDOWS
- this->originalTerminalSettings_ = new termios;
- this->setTerminalMode();
-#endif
-
- this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLineParser::getValue("port"));
- COUT(0) << "Loading scene in client mode" << std::endl;
-
- if( !client_->establishConnection() )
- ThrowException(InitialisationFailed, "Could not establish connection with server.");
-
- client_->update(Game::getInstance().getGameClock());
-
-
- }
-
- void GSDedicatedClient::deactivate()
- {
- if (this->client_)
- {
- this->client_->closeConnection();
- delete this->client_;
- }
-
- closeThread_ = true;
-#ifdef ORXONOX_PLATFORM_UNIX
- std::cout << "\033[0G\033[K";
- std::cout.flush();
- resetTerminalMode();
- delete this->originalTerminalSettings_;
-#else
- COUT(0) << "Press enter to end the game..." << std::endl;
-#endif
- inputThread_->join();
- delete this->inputThread_;
- }
-
- void GSDedicatedClient::update(const Clock& time)
- {
- client_->update(time);
- processQueue();
- printLine();
- }
-
- void GSDedicatedClient::inputThread()
- {
- this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH];
-// memset( this->commandLine_, 0, MAX_COMMAND_LENGTH );
- unsigned char c;
- unsigned int escapeChar=0;
- while(!closeThread_)
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- size_t count = read(STDIN_FILENO, &c, 1);
- if (count == 1)
-#else
- c = getchar();
-#endif
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- if ( inputIterator_>=MAX_COMMAND_LENGTH-1 && c!='\n' )
- continue;
- if( escapeChar > 0 )
- {
- if( c == '[' )
- {
- escapeChar = 2;
- continue;
-}
- else if ( escapeChar == 2 )
- {
- switch (c)
- {
- case 'A': //keyup
-
- break;
- case 'B': //keydown
-
- break;
- case 'C': //keyright
- if(cursorX_<inputIterator_)
- ++cursorX_;
- break;
- case 'D': //keyleft
- if(cursorX_>0)
- --cursorX_;
- break;
- default: //not supported...
-// std::cout << endl << c << endl;
- break;
- }
- escapeChar = 0;
- }
- }
- else // not in escape sequence mode
- {
- switch (c)
- {
- case '\n':
- this->cleanLine_ = true;
- {
- boost::recursive_mutex::scoped_lock(this->inputQueueMutex_);
- boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- this->commandQueue_.push( std::string((const char*)this->commandLine_,inputIterator_) );
- }
- memset( this->commandLine_, 0, inputIterator_ );
- inputIterator_ = 0;
- this->cursorX_ = 0;
- this->cursorY_ = 0;
- std::cout << endl;
- break;
- case 127: // backspace
- case '\b':
- deleteCharacter( this->cursorX_ );
- break;
- case '\t':
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- std::cout << endl << CommandExecutor::hint( std::string((const char*)this->commandLine_,inputIterator_) ) << endl;
- strncpy(reinterpret_cast<char*>(this->commandLine_), CommandExecutor::complete( std::string(reinterpret_cast<char*>(this->commandLine_),inputIterator_) ).c_str(), MAX_COMMAND_LENGTH);
- this->inputIterator_ = strlen((const char*)this->commandLine_);
- this->cursorX_ = this->inputIterator_;
- break;
- }
- case '\033': // 1. escape character
- escapeChar = 1;
- break;
- default:
- insertCharacter( this->cursorX_, c );
- break;
- }
- }
- }
- }
-
- delete[] this->commandLine_;
- }
-
- void GSDedicatedClient::printLine()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- // set cursor to the begining of the line and erase the line
- std::cout << "\033[0G\033[K";
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- // print status line
- std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # ";
- //save cursor position
- std::cout << "\033[s";
- //print commandLine buffer
- std::cout << std::string((const char*)this->commandLine_, inputIterator_);
- //restore cursor position and move it cursorX_ to the right
- std::cout << "\033[u";
- if( this->cursorX_ > 0 )
- std::cout << "\033[" << this->cursorX_ << "C";
- std::cout.flush();
-#endif
- }
-
- void GSDedicatedClient::processQueue()
- {
- std::string tempstr;
- {
- boost::recursive_mutex::scoped_lock lock1(this->inputQueueMutex_);
- while(true)
- {
- if ( !this->commandQueue_.empty() )
- {
- tempstr = this->commandQueue_.front();
- this->commandQueue_.pop();
- lock1.unlock();
- }
- else
- break;
- CommandExecutor::execute(tempstr, true);
- }
- }
- }
-
- void GSDedicatedClient::setTerminalMode()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- termios new_settings;
-
- tcgetattr(0,this->originalTerminalSettings_);
- new_settings = *this->originalTerminalSettings_;
- new_settings.c_lflag &= ~( ICANON | ECHO );
-// new_settings.c_lflag |= ( ISIG | IEXTEN );
- new_settings.c_cc[VTIME] = 1;
- new_settings.c_cc[VMIN] = 0;
- tcsetattr(0,TCSANOW,&new_settings);
- COUT(0) << endl;
-// atexit(&GSDedicatedClient::resetTerminalMode);
-#endif
- }
-
- void GSDedicatedClient::resetTerminalMode()
- {
-#ifdef ORXONOX_PLATFORM_UNIX
- tcsetattr(0, TCSANOW, GSDedicatedClient::originalTerminalSettings_);
-#endif
- }
-
- void GSDedicatedClient::insertCharacter( unsigned int position, char c )
- {
-// std::cout << endl << static_cast<unsigned int>(c) << endl;
- // check that we do not exceed MAX_COMMAND_LENGTH
- if( inputIterator_+1 < MAX_COMMAND_LENGTH )
- {
- // if cursor not at end of line then move the rest of the line
- if( position != this->inputIterator_ )
- memmove( this->commandLine_+position+1, this->commandLine_+position, this->inputIterator_-position);
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- this->commandLine_[position] = c;
- ++this->cursorX_;
- ++this->inputIterator_;
- }
- }
- void GSDedicatedClient::deleteCharacter( unsigned int position )
- {
-// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
- if ( this->inputIterator_>0 && position>0 )
- {
- if ( position != this->inputIterator_ )
- memmove( this->commandLine_+position-1, this->commandLine_+position, this->inputIterator_-position);
- --this->cursorX_;
- --this->inputIterator_;
- }
- }
-
-}
Modified: code/trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -63,8 +63,7 @@
*/
void GSGraphics::activate()
{
- // add console command to toggle GUI
- CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI"));
+
}
/**
@@ -77,18 +76,6 @@
Map::hackDestroyMap();
}
- /**
- @brief
- Toggles the visibility of the current GUI
-
- This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
- For more details on this function check out the Lua code.
- */
- void GSGraphics::toggleGUI()
- {
- GUIManager::getInstance().executeCode("toggleGUI()");
- }
-
void GSGraphics::update(const Clock& time)
{
if (this->getActivity().topState)
Modified: code/trunk/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -56,8 +56,6 @@
void deactivate();
void update(const Clock& time);
- void toggleGUI();
-
private:
};
}
Modified: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -55,6 +55,7 @@
, guiMouseOnlyInputState_(0)
, guiKeysOnlyInputState_(0)
, startFile_(0)
+ , bShowIngameGUI_(false)
{
}
@@ -77,8 +78,6 @@
guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
-
- CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSLevel::showIngameGUI, this), "showIngameGUI"));
}
if (GameMode::isMaster())
@@ -90,28 +89,12 @@
{
// level is loaded: we can start capturing the input
InputManager::getInstance().enterState("game");
-
+
// connect the HumanPlayer to the game
PlayerManager::getInstance().clientConnected(0);
}
}
- void GSLevel::showIngameGUI(bool show)
- {
- if (show)
- {
- GUIManager::getInstance().showGUI("inGameTest");
- GUIManager::getInstance().executeCode("showCursor()");
- InputManager::getInstance().enterState("guiMouseOnly");
- }
- else
- {
- GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
- GUIManager::getInstance().executeCode("hideCursor()");
- InputManager::getInstance().leaveState("guiMouseOnly");
- }
- }
-
void GSLevel::deactivate()
{
if (GameMode::showsGraphics())
@@ -121,7 +104,7 @@
InputManager::getInstance().leaveState("game");
}
-
+
// disconnect all HumanPlayers
PlayerManager::getInstance().disconnectAllClients();
@@ -151,7 +134,7 @@
{
for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
this->staticObjects_.insert(*it);
-
+
// call the loader
COUT(0) << "Loading level..." << std::endl;
startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
@@ -170,7 +153,7 @@
std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(*it);
if (find == this->staticObjects_.end())
{
- COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ")" << std::endl;
+ COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ')' << std::endl;
}
}
COUT(3) << i << " objects remaining.";
Modified: code/trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSLevel.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -51,7 +51,6 @@
protected:
void loadLevel();
void unloadLevel();
- void showIngameGUI(bool show);
InputState* gameInputState_; //!< input state for normal ingame playing
InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI
@@ -59,6 +58,7 @@
XMLFile* startFile_;
std::set<BaseObject*> staticObjects_;
+ bool bShowIngameGUI_;
};
}
Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,6 +35,8 @@
#include "core/input/KeyBinderManager.h"
#include "core/Game.h"
#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
#include "core/GraphicsManager.h"
#include "core/GUIManager.h"
#include "Scene.h"
@@ -48,6 +50,7 @@
: GameState(info)
, inputState_(0)
{
+ RegisterRootObject(GSMainMenu);
inputState_ = InputManager::getInstance().createInputState("mainMenu");
inputState_->setMouseMode(MouseMode::Nonexclusive);
inputState_->setHandler(GUIManager::getInstancePtr());
@@ -63,14 +66,14 @@
{
// Load sound
this->ambient_ = new AmbientSound(0);
- this->ambient_->setSource("ambient/mainmenu.wav");
+ this->ambient_->setSyncMode(0x0);
}
}
GSMainMenu::~GSMainMenu()
{
if (GameMode::playsSound())
- delete this->ambient_;
+ this->ambient_->destroy();
InputManager::getInstance().destroyState("mainMenu");
@@ -81,8 +84,10 @@
void GSMainMenu::activate()
{
// show main menu
- GUIManager::getInstance().showGUI("MainMenu");
+ GUIManager::getInstance().showGUI("MainMenu", true, GraphicsManager::getInstance().isFullScreen());
GUIManager::getInstance().setCamera(this->camera_);
+ GUIManager::getInstance().setBackground("MainMenuBackground");
+// GUIManager::getInstance().setBackground("");
GraphicsManager::getInstance().setCamera(this->camera_);
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startStandalone), "startGame"));
@@ -91,13 +96,18 @@
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
+ // create command to change sound path
+ CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
+
KeyBinderManager::getInstance().setToDefault();
InputManager::getInstance().enterState("mainMenu");
+ this->setConfigValues();
+
if (GameMode::playsSound())
{
- this->ambient_->setLoop(true);
- this->ambient_->play();
+ this->ambient_->setLooping(true);
+ this->ambient_->play(); // works without source
}
}
@@ -111,6 +121,8 @@
InputManager::getInstance().leaveState("mainMenu");
GUIManager::getInstance().setCamera(0);
+ GUIManager::getInstance().setBackground("");
+ GUIManager::hideGUI("MainMenu");
GraphicsManager::getInstance().setCamera(0);
}
@@ -118,6 +130,31 @@
{
}
+ void GSMainMenu::setConfigValues()
+ {
+ SetConfigValue(soundPathMain_, "mainmenu.ogg")
+ .description("Contains the path to the main menu sound file.")
+ .callback(this, &GSMainMenu::reloadSound);
+ }
+
+ void GSMainMenu::reloadSound()
+ {
+ if (GameMode::playsSound())
+ {
+ this->ambient_->setAmbientSource(soundPathMain_);
+ }
+ }
+
+ const std::string& GSMainMenu::getMainMenuSoundPath()
+ {
+ return soundPathMain_;
+ }
+
+ void GSMainMenu::setMainMenuSoundPath(const std::string& path)
+ {
+ ModifyConfigValue(soundPathMain_, set, path);
+ }
+
void GSMainMenu::startStandalone()
{
// HACK - HACK
Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,10 +33,11 @@
#include "util/OgreForwardRefs.h"
#include "core/GameState.h"
+#include "core/OrxonoxClass.h"
namespace orxonox
{
- class _OrxonoxExport GSMainMenu : public GameState
+ class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass
{
public:
GSMainMenu(const GameStateInfo& info);
@@ -46,6 +47,11 @@
void deactivate();
void update(const Clock& time);
+ void setConfigValues();
+ void reloadSound();
+ const std::string& getMainMenuSoundPath();
+ void setMainMenuSoundPath(const std::string& path);
+
static void startStandalone();
static void startServer();
static void startClient();
@@ -60,6 +66,7 @@
// ambient sound for the main menu
AmbientSound* ambient_;
+ std::string soundPathMain_;
};
}
Modified: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -29,6 +29,7 @@
#include "GSRoot.h"
#include "util/Clock.h"
+#include "core/BaseObject.h"
#include "core/ConsoleCommand.h"
#include "core/Game.h"
#include "core/GameMode.h"
@@ -44,7 +45,6 @@
GSRoot::GSRoot(const GameStateInfo& info)
: GameState(info)
- , timeFactor_(1.0f)
, bPaused_(false)
, timeFactorPauseBackup_(1.0f)
{
@@ -54,25 +54,25 @@
{
NetworkFunctionBase::destroyAllNetworkFunctions();
}
-
+
void GSRoot::printObjects()
{
unsigned int nr=0;
- for(ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it){
- if( dynamic_cast<Synchronisable*>(*it) )
+ for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)
+ {
+ if (dynamic_cast<Synchronisable*>(*it))
COUT(0) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << std::endl;
else
COUT(0) << "object: " << it->getIdentifier()->getName() << std::endl;
nr++;
}
COUT(0) << "currently got " << nr << " objects" << std::endl;
-
}
void GSRoot::activate()
{
// reset game speed to normal
- this->timeFactor_ = 1.0f;
+ TimeFactorListener::setTimeFactor(1.0f);
// time factor console command
ConsoleCommand* command = createConsoleCommand(createFunctor(&GSRoot::setTimeFactor, this), "setTimeFactor");
@@ -90,7 +90,11 @@
void GSRoot::update(const Clock& time)
{
for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
- (it++)->tick(time);
+ {
+ Timer* object = *it;
+ ++it;
+ object->tick(time);
+ }
/*** HACK *** HACK ***/
// Call the Tickable objects
@@ -100,8 +104,13 @@
// just loaded
leveldt = 0.0f;
}
+ float realdt = leveldt * TimeFactorListener::getTimeFactor();
for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; )
- (it++)->tick(leveldt * this->timeFactor_);
+ {
+ Tickable* object = *it;
+ ++it;
+ object->tick(realdt);
+ }
/*** HACK *** HACK ***/
}
@@ -118,12 +127,7 @@
{
if (!this->bPaused_)
{
- TimeFactorListener::timefactor_s = factor;
-
- for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
- it->changedTimeFactor(factor, this->timeFactor_);
-
- this->timeFactor_ = factor;
+ TimeFactorListener::setTimeFactor(factor);
}
else
this->timeFactorPauseBackup_ = factor;
@@ -136,7 +140,7 @@
{
if (!this->bPaused_)
{
- this->timeFactorPauseBackup_ = this->timeFactor_;
+ this->timeFactorPauseBackup_ = TimeFactorListener::getTimeFactor();
this->setTimeFactor(0.0f);
this->bPaused_ = true;
}
@@ -147,4 +151,9 @@
}
}
}
+
+ float GSRoot::getTimeFactor()
+ {
+ return TimeFactorListener::getTimeFactor();
+ }
}
Modified: code/trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gamestates/GSRoot.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,10 +50,9 @@
// when taking the function address.
void setTimeFactor(float factor);
void pause();
- float getTimeFactor() { return this->timeFactor_; }
+ float getTimeFactor();
private:
- float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.
bool bPaused_;
float timeFactorPauseBackup_;
};
Modified: code/trunk/src/orxonox/gametypes/Asteroids.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Asteroids.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/Asteroids.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -71,7 +71,7 @@
{
Gametype::start();
- std::string message = "The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...";
+ std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -80,7 +80,7 @@
{
Gametype::end();
- std::string message = "The match has ended.";
+ std::string message("The match has ended.");
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
Modified: code/trunk/src/orxonox/gametypes/Deathmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Deathmatch.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/Deathmatch.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -46,7 +46,7 @@
{
Gametype::start();
- std::string message = "The match has started!";
+ std::string message("The match has started!");
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -55,7 +55,7 @@
{
Gametype::end();
- std::string message = "The match has ended.";
+ std::string message("The match has ended.");
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -64,7 +64,7 @@
{
Gametype::playerEntered(player);
- std::string message = player->getName() + " entered the game";
+ const std::string& message = player->getName() + " entered the game";
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -75,7 +75,7 @@
if (valid_player)
{
- std::string message = player->getName() + " left the game";
+ const std::string& message = player->getName() + " left the game";
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -89,7 +89,7 @@
if (valid_player)
{
- std::string message = player->getOldName() + " changed name to " + player->getName();
+ const std::string& message = player->getOldName() + " changed name to " + player->getName();
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
@@ -125,7 +125,7 @@
if (player)
{
- std::string message = player->getName() + " scores!";
+ const std::string& message = player->getName() + " scores!";
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
Modified: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,7 +50,7 @@
Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
{
RegisterObject(Gametype);
-
+
this->gtinfo_ = new GametypeInfo(creator);
this->setGametype(SmartPtr<Gametype>(this, false));
@@ -70,7 +70,7 @@
this->setConfigValues();
// load the corresponding score board
- if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
+ if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
{
this->scoreboard_ = new OverlayGroup(this);
this->scoreboard_->addTemplate(this->scoreboardTemplate_);
@@ -78,7 +78,7 @@
}
else
this->scoreboard_ = 0;
-
+
/* HACK HACK HACK */
this->hackAddBots_ = createConsoleCommand( createFunctor(&Gametype::addBots, this), "hackAddBots");
this->hackKillBots_ = createConsoleCommand( createFunctor(&Gametype::killBots, this), "hackKillBots");
@@ -86,7 +86,7 @@
CommandExecutor::addConsoleCommandShortcut( this->hackKillBots_ );
/* HACK HACK HACK */
}
-
+
Gametype::~Gametype()
{
if (this->isInitialized())
Modified: code/trunk/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/Gametype.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -183,7 +183,7 @@
// Config Values
std::string scoreboardTemplate_;
-
+
/* HACK HACK HACK */
ConsoleCommand* hackAddBots_;
ConsoleCommand* hackKillBots_;
Modified: code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -60,7 +60,7 @@
};
static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
- SetConfigValueVector(teamcolours_, defaultcolours);
+ SetConfigValue(teamcolours_, defaultcolours);
}
void TeamDeathmatch::playerEntered(PlayerInfo* player)
Modified: code/trunk/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/UnderAttack.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/gametypes/UnderAttack.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,7 +68,7 @@
void UnderAttack::killedDestroyer()
{
this->end(); //end gametype
- std::string message = "Ship destroyed! Team 0 has won!";
+ std::string message("Ship destroyed! Team 0 has won!");
COUT(0) << message << std::endl;
Host::Broadcast(message);
this->gameEnded_ = true;
@@ -151,7 +151,7 @@
{
this->gameEnded_ = true;
this->end();
- std::string message = "Time is up! Team 1 has won!";
+ std::string message("Time is up! Team 1 has won!");
COUT(0) << message << std::endl;
Host::Broadcast(message);
@@ -170,7 +170,7 @@
//prints gametime
if ( gameTime_ <= timesequence_ && gameTime_ > 0)
{
- std::string message = multi_cast<std::string>(timesequence_) + " seconds left!";
+ const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
/*
COUT(0) << message << std::endl;
Host::Broadcast(message);
Modified: code/trunk/src/orxonox/graphics/Billboard.cc
===================================================================
--- code/trunk/src/orxonox/graphics/Billboard.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/graphics/Billboard.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,7 +41,6 @@
{
RegisterObject(Billboard);
- this->material_ = "";
this->colour_ = ColourValue::White;
// this->rotation_ = 0;
@@ -75,7 +74,7 @@
void Billboard::changedMaterial()
{
- if (this->material_ == "")
+ if (this->material_.empty())
return;
if (!this->billboard_.getBillboardSet())
@@ -98,7 +97,7 @@
if (!this->billboard_.getBillboardSet())
{
/*
- if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
+ if (this->getScene() && GameMode::showsGraphics() && !this->material_.empty())
{
this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
if (this->billboard_.getBillboardSet())
Modified: code/trunk/src/orxonox/graphics/BlinkingBillboard.cc
===================================================================
--- code/trunk/src/orxonox/graphics/BlinkingBillboard.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/graphics/BlinkingBillboard.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -80,7 +80,7 @@
if (this->bQuadratic_)
this->setScale(this->amplitude_ * static_cast<float>(square(sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_))));
else
- this->setScale(this->amplitude_ * static_cast<float>(sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_)));
+ this->setScale(this->amplitude_ * static_cast<float>(fabs(sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_))));
}
}
}
Modified: code/trunk/src/orxonox/graphics/Camera.cc
===================================================================
--- code/trunk/src/orxonox/graphics/Camera.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/graphics/Camera.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,6 +41,7 @@
#include "core/GUIManager.h"
#include "Scene.h"
#include "CameraManager.h"
+#include "sound/SoundManager.h"
namespace orxonox
{
@@ -60,6 +61,7 @@
ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given.");
this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+ this->camera_->setUserObject(this);
this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
this->attachNode(this->cameraNode_);
this->cameraNode_->attachObject(this->camera_);
@@ -67,6 +69,7 @@
this->bHasFocus_ = false;
this->bDrag_ = false;
this->nearClipDistance_ = 1;
+ this->lastDtLagged_ = false;
this->setSyncMode(0x0);
@@ -110,14 +113,42 @@
if (this->bDrag_)
{
// this stuff here may need some adjustments
- float coeff = std::min(1.0f, 15.0f * dt);
+ float poscoeff = 15.0f * dt / this->getTimeFactor();
+ float anglecoeff = 7.0f * dt / this->getTimeFactor();
+ // Only clamp if fps rate is actually falling. Occasional high dts should
+ // not be clamped to reducing lagging effects.
+ if (poscoeff > 1.0f)
+ {
+ if (this->lastDtLagged_)
+ poscoeff = 1.0f;
+ else
+ this->lastDtLagged_ = true;
+ }
+ else
+ this->lastDtLagged_ = false;
+ if (anglecoeff > 1.0f)
+ {
+ if (this->lastDtLagged_)
+ anglecoeff = 1.0f;
+ else
+ this->lastDtLagged_ = true;
+ }
+ else
+ this->lastDtLagged_ = false;
+
Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
- this->cameraNode_->translate(coeff * offset);
+ this->cameraNode_->translate(poscoeff * offset);
- this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
- //this->cameraNode_->setOrientation(this->getWorldOrientation());
+ this->cameraNode_->setOrientation(Quaternion::Slerp(anglecoeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
}
+
+ // Update sound listener transformation
+ if (GameMode::playsSound() && this->bHasFocus_)
+ {
+ SoundManager::getInstance().setListenerPosition(this->getWorldPosition());
+ SoundManager::getInstance().setListenerOrientation(this->getWorldOrientation());
+ }
}
void Camera::requestFocus()
Modified: code/trunk/src/orxonox/graphics/Camera.h
===================================================================
--- code/trunk/src/orxonox/graphics/Camera.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/graphics/Camera.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -33,11 +33,12 @@
#include "util/OgreForwardRefs.h"
#include "tools/interfaces/Tickable.h"
+#include "tools/interfaces/TimeFactorListener.h"
#include "worldentities/StaticEntity.h"
namespace orxonox
{
- class _OrxonoxExport Camera : public StaticEntity, public Tickable
+ class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener
{
friend class CameraManager;
@@ -51,6 +52,9 @@
void requestFocus();
void releaseFocus();
+ inline Ogre::Camera* getOgreCamera()
+ { return this->camera_; }
+
inline bool hasFocus()
{ return this->bHasFocus_; }
@@ -68,6 +72,7 @@
float nearClipDistance_;
bool bHasFocus_;
bool bDrag_;
+ bool lastDtLagged_;
};
}
Modified: code/trunk/src/orxonox/infos/Bot.cc
===================================================================
--- code/trunk/src/orxonox/infos/Bot.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/infos/Bot.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -93,6 +93,6 @@
};
static std::vector<std::string> defaultnames(names, names + sizeof(names) / sizeof(std::string));
- SetConfigValueVector(names_, defaultnames);
+ SetConfigValue(names_, defaultnames);
}
}
Modified: code/trunk/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/trunk/src/orxonox/infos/HumanPlayer.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/infos/HumanPlayer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,6 +34,7 @@
#include "network/ClientInformation.h"
#include "network/Host.h"
#include "controllers/HumanController.h"
+#include "controllers/NewHumanController.h"
#include "gametypes/Gametype.h"
#include "overlays/OverlayGroup.h"
@@ -49,7 +50,7 @@
this->client_initialized_ = false;
this->bHumanPlayer_ = true;
- this->defaultController_ = Class(HumanController);
+ this->defaultController_ = Class(NewHumanController);
this->humanHud_ = 0;
this->gametypeHud_ = 0;
@@ -162,7 +163,7 @@
if (this->isInitialized() && this->isLocalPlayer())
{
- if (this->getGametype() && this->getGametype()->getHUDTemplate() != "")
+ if (this->getGametype() && !this->getGametype()->getHUDTemplate().empty())
this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
else
this->setGametypeHUDTemplate("");
@@ -177,7 +178,7 @@
this->humanHud_ = 0;
}
- if (this->isLocalPlayer() && this->humanHudTemplate_ != "" && GameMode::showsGraphics())
+ if (this->isLocalPlayer() && !this->humanHudTemplate_.empty() && GameMode::showsGraphics())
{
this->humanHud_ = new OverlayGroup(this);
this->humanHud_->addTemplate(this->humanHudTemplate_);
@@ -193,7 +194,7 @@
this->gametypeHud_ = 0;
}
- if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
+ if (this->isLocalPlayer() && !this->gametypeHudTemplate_.empty())
{
this->gametypeHud_ = new OverlayGroup(this);
this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
Modified: code/trunk/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/infos/PlayerInfo.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -49,7 +49,8 @@
this->bSetUnreadyAfterSpawn_ = true;
this->controller_ = 0;
this->controllableEntity_ = 0;
- this->controllableEntityID_ = CLIENTID_UNKNOWN;
+ this->controllableEntityID_ = OBJECTID_UNKNOWN;
+ this->oldControllableEntity_ = 0;
this->gtinfo_ = 0;
this->gtinfoID_ = OBJECTID_UNKNOWN;
@@ -79,7 +80,6 @@
{
registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
- registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);
registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
}
@@ -138,7 +138,10 @@
assert(this->controller_);
this->controller_->setPlayer(this);
if (this->controllableEntity_)
+ {
this->controller_->setControllableEntity(this->controllableEntity_);
+ this->controllableEntity_->setController(this->controller_);
+ }
this->changedController();
}
@@ -147,6 +150,8 @@
if (!entity || entity == this->controllableEntity_)
return;
+ if (this->oldControllableEntity_)
+ this->stopTemporaryControl();
if (this->controllableEntity_)
this->stopControl();
@@ -158,29 +163,77 @@
this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
if (this->controller_)
+ {
this->controller_->setControllableEntity(entity);
+ this->controllableEntity_->setController(this->controller_);
+ }
this->changedControllableEntity();
}
+ void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
+ {
+ if (!entity)
+ return;
+
+// assert( this->temporaryControllableEntity_==0 );
+
+ this->oldControllableEntity_ = this->controllableEntity_;
+ this->controllableEntity_ = entity;
+ this->controllableEntityID_ = entity->getObjectID();
+
+ entity->setPlayer(this);
+
+ if (this->controller_)
+ this->controller_->setControllableEntity(entity);
+
+ this->changedControllableEntity();
+ }
+
void PlayerInfo::stopControl()
{
+ if ( this->oldControllableEntity_ )
+ this->stopTemporaryControl();
+
ControllableEntity* entity = this->controllableEntity_;
if (!entity)
return;
+ this->controllableEntity_->setController(0);
this->controllableEntity_ = 0;
this->controllableEntityID_ = OBJECTID_UNKNOWN;
if (this->controller_)
this->controller_->setControllableEntity(0);
- entity->removePlayer();
+ if ( GameMode::isMaster() )
+ entity->removePlayer();
this->changedControllableEntity();
}
+ void PlayerInfo::stopTemporaryControl()
+ {
+ ControllableEntity* entity = this->controllableEntity_;
+
+ assert( this->controllableEntity_ && this->oldControllableEntity_ );
+ if( !entity || !this->oldControllableEntity_ )
+ return;
+
+ this->controllableEntity_ = this->oldControllableEntity_;
+ this->controllableEntityID_ = this->controllableEntity_->getObjectID();
+ this->oldControllableEntity_ = 0;
+
+ if ( this->controllableEntity_ && this->controller_)
+ this->controller_->setControllableEntity(this->controllableEntity_);
+
+ if ( GameMode::isMaster() )
+ entity->removePlayer();
+
+ this->changedControllableEntity();
+ }
+
void PlayerInfo::networkcallback_changedcontrollableentityID()
{
if (this->controllableEntityID_ != OBJECTID_UNKNOWN)
@@ -195,6 +248,7 @@
}
}
+
void PlayerInfo::networkcallback_changedgtinfoID()
{
if (this->gtinfoID_ != OBJECTID_UNKNOWN)
Modified: code/trunk/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/infos/PlayerInfo.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,6 +68,8 @@
void startControl(ControllableEntity* entity);
void stopControl();
+ void startTemporaryControl(ControllableEntity* entity);
+ void stopTemporaryControl();
inline ControllableEntity* getControllableEntity() const
{ return this->controllableEntity_; }
@@ -95,6 +97,7 @@
bool bReadyToSpawn_;
Controller* controller_;
ControllableEntity* controllableEntity_;
+ ControllableEntity* oldControllableEntity_;
unsigned int controllableEntityID_;
const GametypeInfo* gtinfo_;
Modified: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -50,15 +50,14 @@
, MapEntity_(NULL)
, line_(NULL)
, LineNode_(NULL)
+ , isHumanShip_(false)
+ , bVisibility_(true)
, radarObjectCamouflage_(0.0f)
, radarObjectShape_(Dot)
, radarObjectDescription_("staticObject")
{
RegisterRootObject(RadarViewable);
- this->bVisibility_ = true;
- this->isHumanShip_ = false;
-
this->uniqueId_=getUniqueNumberString();
/*
if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
@@ -163,7 +162,7 @@
{
if (!object)
{
- COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
+ COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
assert(0);
}
}
Modified: code/trunk/src/orxonox/interfaces/Rewardable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/Rewardable.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/interfaces/Rewardable.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -42,7 +42,7 @@
/**
@brief
Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects. (With the AddReward effect.)
-
+
It just needs to inherit form Rewardable, and implement the reward() method.
@author
Damian 'Mozork' Frick
Modified: code/trunk/src/orxonox/items/Engine.h
===================================================================
--- code/trunk/src/orxonox/items/Engine.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/items/Engine.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -105,8 +105,6 @@
virtual const Vector3& getDirection() const;
- void loadSound(const std::string filename);
-
private:
void networkcallback_shipID();
Modified: code/trunk/src/orxonox/items/MultiStateEngine.cc
===================================================================
--- code/trunk/src/orxonox/items/MultiStateEngine.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/items/MultiStateEngine.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -21,6 +21,7 @@
*
* Author:
* Fabian 'x3n' Landau
+ * Reto Grieder
* Co-authors:
* ...
*
@@ -28,55 +29,78 @@
#include "MultiStateEngine.h"
+extern "C" {
+#include <lua.h>
+}
+
+#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
+#include "core/LuaState.h"
#include "core/XMLPort.h"
+#include "worldentities/EffectContainer.h"
#include "worldentities/pawns/SpaceShip.h"
+#include "sound/WorldSound.h"
namespace orxonox
{
- static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 20;
+ static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 0;
+ static const float MAX_VELOCITY_NORMAL = 111;
+ static const float MAX_VELOCITY_BOOST = 221;
- static const unsigned char STATE_ACTIVE = 1;
- static const unsigned char STATE_FORWARD = 2;
- static const unsigned char STATE_BOOST = 4;
- static const unsigned char STATE_BRAKE = 8;
-
CreateFactory(MultiStateEngine);
MultiStateEngine::MultiStateEngine(BaseObject* creator) : Engine(creator)
{
RegisterObject(MultiStateEngine);
+ if (GameMode::isMaster())
+ {
+ this->defEngineSndNormal_ = new WorldSound(this);
+ this->defEngineSndBoost_ = new WorldSound(this);
+ this->defEngineSndNormal_->setLooping(true);
+ this->defEngineSndBoost_->setLooping(true);
+ this->lua_ = new LuaState();
+ }
+ else
+ {
+ this->defEngineSndBoost_ = 0;
+ this->defEngineSndNormal_ = 0;
+ this->lua_ = 0;
+ }
this->state_ = 0;
+ this->oldState_ = 0;
+ this->setSyncMode(ObjectDirection::Bidirectional);
this->registerVariables();
}
MultiStateEngine::~MultiStateEngine()
{
- if (this->isInitialized() && !this->getShip())
+ if (this->isInitialized())
{
- // We have no ship, so the effects are not attached and won't be destroyed automatically
- for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
- (*it)->destroy();
- for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it)
- (*it)->destroy();
- for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it)
- (*it)->destroy();
- for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it)
- (*it)->destroy();
+ if (!this->getShip())
+ {
+ // We have no ship, so the effects are not attached and won't be destroyed automatically
+ for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
+ for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsBegin(); ++it2)
+ (*it2)->destroy();
+ if (this->defEngineSndNormal_)
+ this->defEngineSndNormal_->destroy();
+ if (this->defEngineSndBoost_)
+ this->defEngineSndBoost_->destroy();
+ }
+ if (this->lua_)
+ delete this->lua_;
}
}
void MultiStateEngine::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(MultiStateEngine, XMLPort, xmlelement, mode);
-
- XMLPortObject(MultiStateEngine, WorldEntity, "active", addActiveEffect, getActiveEffect, xmlelement, mode);
- XMLPortObject(MultiStateEngine, WorldEntity, "forward", addForwardEffect, getForwardEffect, xmlelement, mode);
- XMLPortObject(MultiStateEngine, WorldEntity, "boost", addBoostEffect, getBoostEffect, xmlelement, mode);
- XMLPortObject(MultiStateEngine, WorldEntity, "brake", addBrakeEffect, getBrakeEffect, xmlelement, mode);
+ XMLPortObject(MultiStateEngine, EffectContainer, "", addEffectContainer, getEffectContainer, xmlelement, mode);
+ XMLPortParam(MultiStateEngine, "defEngineSndNormal", setDefEngSndNormal, getDefEngSndNormal, xmlelement, mode);
+ XMLPortParam(MultiStateEngine, "defEngineSndBoost", setDefEngSndBoost, getDefEngSndBoost, xmlelement, mode);
}
void MultiStateEngine::registerVariables()
@@ -88,49 +112,68 @@
{
if (this->getShip())
{
+ const Vector3& velocity = this->getShip()->getLocalVelocity();
+
if (this->getShip()->hasLocalController())
{
- this->setSyncMode(ObjectDirection::Bidirectional);
-
const Vector3& direction = this->getDirection();
- const Vector3& velocity = this->getShip()->getLocalVelocity();
+ bool forward = (direction.z < 0.0 && velocity.z < -FORWARD_EFFECT_VELOCITY_THRESHOLD);
- bool forward = (direction.z < 0 && velocity.z < -FORWARD_EFFECT_VELOCITY_THRESHOLD);
- bool boost = (this->getShip()->getBoost() && forward);
- bool brake = (direction.z > 0 && velocity.z < 0);
- bool active = (direction != Vector3::ZERO && !brake);
-
- if (active)
- this->state_ |= STATE_ACTIVE;
+ this->state_ = 0;
+ if (this->getShip()->getBoost() && forward)
+ this->state_ = Boost;
+ else if (forward && !this->state_) // this->state_ == Boost
+ this->state_ = Normal;
+ else if (direction.z > 0.0 && velocity.z < 0.0)
+ this->state_ = Brake;
else
- this->state_ &= ~STATE_ACTIVE;
+ this->state_ = Idle;
+ }
- if (forward)
- this->state_ |= STATE_FORWARD;
- else
- this->state_ &= ~STATE_FORWARD;
+ if (GameMode::isMaster())
+ {
+ int changes = this->state_ | this->oldState_;
- if (boost)
- this->state_ |= STATE_BOOST;
- else
- this->state_ &= ~STATE_BOOST;
+ float pitch = velocity.length();
+ if (this->state_ & Normal)
+ defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f));
+ if (this->state_ & Boost)
+ defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f));
- if (brake)
- this->state_ |= STATE_BRAKE;
- else
- this->state_ &= ~STATE_BRAKE;
- }
+ if (changes & Idle)
+ {
+ lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Idle);
+ lua_setglobal(this->lua_->getInternalLuaState(), "idle");
+ }
+ if (changes & Normal)
+ {
+ lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Normal);
+ lua_setglobal(this->lua_->getInternalLuaState(), "normal");
+ if (this->state_ & Normal)
+ defEngineSndNormal_->play();
+ else
+ defEngineSndNormal_->stop();
+ }
+ if (changes & Brake)
+ {
+ lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Brake);
+ lua_setglobal(this->lua_->getInternalLuaState(), "brake");
+ }
+ if (changes & Boost)
+ {
+ lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Boost);
+ lua_setglobal(this->lua_->getInternalLuaState(), "boost");
+ if (this->state_ & Boost)
+ defEngineSndBoost_->play();
+ else
+ defEngineSndBoost_->stop();
+ }
- if (GameMode::isMaster())
- {
- for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
- (*it)->setMainState(this->state_ & STATE_ACTIVE);
- for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it)
- (*it)->setMainState(this->state_ & STATE_FORWARD);
- for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it)
- (*it)->setMainState(this->state_ & STATE_BOOST);
- for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it)
- (*it)->setMainState(this->state_ & STATE_BRAKE);
+ this->oldState_ = this->state_;
+
+ // Update all effect conditions
+ for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
+ (*it)->updateCondition();
}
}
@@ -144,89 +187,71 @@
if (!ship)
return;
- for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
- ship->attach(*it);
- for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it)
- ship->attach(*it);
- for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it)
- ship->attach(*it);
- for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it)
- ship->attach(*it);
- }
+ if( this->defEngineSndNormal_ )
+ this->getShip()->attach(defEngineSndNormal_);
+ if( this->defEngineSndBoost_ )
+ this->getShip()->attach(defEngineSndBoost_);
- void MultiStateEngine::addActiveEffect(WorldEntity* effect)
- {
- this->activeEffects_.push_back(effect);
- if (this->getShip())
- this->getShip()->attach(effect);
+ for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
+ for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsEnd(); ++it2)
+ this->getShip()->attach(*it2);
}
- void MultiStateEngine::addForwardEffect(WorldEntity* effect)
+ void MultiStateEngine::addEffectContainer(EffectContainer* effect)
{
- this->forwardEffects_.push_back(effect);
+ if (effect == NULL)
+ return;
+ effect->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size()));
+ this->effectContainers_.push_back(effect);
if (this->getShip())
- this->getShip()->attach(effect);
+ {
+ for (std::vector<WorldEntity*>::const_iterator it = effect->getEffectsBegin(); it != effect->getEffectsBegin(); ++it)
+ this->getShip()->attach(*it);
+ }
}
- void MultiStateEngine::addBoostEffect(WorldEntity* effect)
+ EffectContainer* MultiStateEngine::getEffectContainer(unsigned int index) const
{
- this->boostEffects_.push_back(effect);
- if (this->getShip())
- this->getShip()->attach(effect);
- }
-
- void MultiStateEngine::addBrakeEffect(WorldEntity* effect)
- {
- this->brakeEffects_.push_back(effect);
- if (this->getShip())
- this->getShip()->attach(effect);
- }
-
- WorldEntity* MultiStateEngine::getActiveEffect(unsigned int index) const
- {
unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
+ for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
{
if (i == index)
return (*it);
- ++i;
}
- return 0;
+ return NULL;
}
- WorldEntity* MultiStateEngine::getForwardEffect(unsigned int index) const
+ void MultiStateEngine::setDefEngSndNormal(const std::string &engineSound)
{
- unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it)
- {
- if (i == index)
- return (*it);
- ++i;
- }
- return 0;
+ if( defEngineSndNormal_ )
+ defEngineSndNormal_->setSource(engineSound);
+ else
+ assert(0); // This should never happen, because soundpointer is only available on master
}
- WorldEntity* MultiStateEngine::getBoostEffect(unsigned int index) const
+ const std::string& MultiStateEngine::getDefEngSndNormal()
{
- unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it)
- {
- if (i == index)
- return (*it);
- ++i;
- }
- return 0;
+ if( defEngineSndNormal_ )
+ return defEngineSndNormal_->getSource();
+ else
+ assert(0);
+ return BLANKSTRING;
}
- WorldEntity* MultiStateEngine::getBrakeEffect(unsigned int index) const
+ void MultiStateEngine::setDefEngSndBoost(const std::string &engineSound)
{
- unsigned int i = 0;
- for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it)
- {
- if (i == index)
- return (*it);
- ++i;
- }
- return 0;
+ if( defEngineSndBoost_ )
+ defEngineSndBoost_->setSource(engineSound);
+ else
+ assert(0);
}
+
+ const std::string& MultiStateEngine::getDefEngSndBoost()
+ {
+ if( this->defEngineSndBoost_ )
+ return defEngineSndBoost_->getSource();
+ else
+ assert(0);
+ return BLANKSTRING;
+ }
}
Modified: code/trunk/src/orxonox/items/MultiStateEngine.h
===================================================================
--- code/trunk/src/orxonox/items/MultiStateEngine.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/items/MultiStateEngine.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -21,6 +21,7 @@
*
* Author:
* Fabian 'x3n' Landau
+ * Reto Grieder
* Co-authors:
* ...
*
@@ -31,7 +32,7 @@
#include "OrxonoxPrereqs.h"
-#include <list>
+#include <vector>
#include "Engine.h"
namespace orxonox
@@ -39,6 +40,14 @@
class _OrxonoxExport MultiStateEngine : public Engine
{
public:
+ enum EngineState
+ {
+ Idle = 1,
+ Normal = 2,
+ Brake = 4,
+ Boost = 8
+ };
+
MultiStateEngine(BaseObject* creator);
virtual ~MultiStateEngine();
@@ -49,22 +58,21 @@
virtual void addToSpaceShip(SpaceShip* ship);
- void addActiveEffect(WorldEntity* effect);
- void addForwardEffect(WorldEntity* effect);
- void addBoostEffect(WorldEntity* effect);
- void addBrakeEffect(WorldEntity* effect);
+ void addEffectContainer(EffectContainer* effect);
+ EffectContainer* getEffectContainer(unsigned int index) const;
- WorldEntity* getActiveEffect(unsigned int index) const;
- WorldEntity* getForwardEffect(unsigned int index) const;
- WorldEntity* getBoostEffect(unsigned int index) const;
- WorldEntity* getBrakeEffect(unsigned int index) const;
+ void setDefEngSndNormal(const std::string& engineSound);
+ const std::string& getDefEngSndNormal();
+ void setDefEngSndBoost(const std::string& engineSound);
+ const std::string& getDefEngSndBoost();
private:
- unsigned char state_;
- std::list<WorldEntity*> activeEffects_;
- std::list<WorldEntity*> forwardEffects_;
- std::list<WorldEntity*> boostEffects_;
- std::list<WorldEntity*> brakeEffects_;
+ int state_;
+ int oldState_;
+ LuaState* lua_;
+ std::vector<EffectContainer*> effectContainers_;
+ WorldSound* defEngineSndNormal_;
+ WorldSound* defEngineSndBoost_;
};
}
Modified: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -43,7 +43,7 @@
#include "util/Clock.h"
#include "util/Convert.h"
#include "util/Math.h"
-#include "util/UTFStringConversions.h"
+#include "util/DisplayStringConversions.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/ConsoleCommand.h"
@@ -60,14 +60,14 @@
SetConsoleCommand(InGameConsole, openConsole, true);
SetConsoleCommand(InGameConsole, closeConsole, true);
- InGameConsole* InGameConsole::singletonPtr_s = 0;
ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
/**
@brief Constructor: Creates and initializes the InGameConsole.
*/
InGameConsole::InGameConsole()
- : shell_(new Shell("InGameConsole", true, true))
+ : shell_(new Shell("InGameConsole", true))
+ , bShowCursor_(false)
, consoleOverlay_(0)
, consoleOverlayContainer_(0)
, consoleOverlayNoise_(0)
@@ -217,6 +217,14 @@
font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
+ // 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->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_);
+
// create the text lines
this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
for (int i = 0; i < LINES; i++)
@@ -228,7 +236,7 @@
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]);
+ this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]);
}
// create cursor (also a text area overlay element)
@@ -239,16 +247,8 @@
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_);
+ this->consoleOverlayNoise_->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
@@ -267,7 +267,7 @@
*/
void InGameConsole::linesChanged()
{
- std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();
+ Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
int max = 0;
for (int i = 1; i < LINES; ++i)
{
@@ -281,12 +281,12 @@
}
for (int i = LINES - 1; i > max; --i)
- this->print("", i, true);
+ this->print("", Shell::None, i, true);
for (int i = max; i >= 1; --i)
{
--it;
- this->print(*it, i, true);
+ this->print(it->first, it->second, i, true);
}
}
@@ -296,7 +296,7 @@
void InGameConsole::onlyLastLineChanged()
{
if (LINES > 1)
- this->print(*this->shell_->getNewestLineIterator(), 1);
+ this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
}
/**
@@ -315,9 +315,9 @@
void InGameConsole::inputChanged()
{
if (LINES > 0)
- this->print(this->shell_->getInput(), 0);
+ this->print(this->shell_->getInput(), Shell::Input, 0);
- if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
+ if (this->shell_->getInput().empty())
this->inputWindowStart_ = 0;
}
@@ -339,7 +339,7 @@
*/
void InGameConsole::executed()
{
- this->shell_->addOutputLine(this->shell_->getInput());
+ this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
}
/**
@@ -357,7 +357,7 @@
/**
@brief Used to control the actual scrolling and the cursor.
*/
- void InGameConsole::update(const Clock& time)
+ void InGameConsole::preUpdate(const Clock& time)
{
if (this->scroll_ != 0)
{
@@ -455,20 +455,12 @@
@brief Prints string to bottom line.
@param s String to be printed
*/
- void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+ void InGameConsole::print(const std::string& text, Shell::LineType type, 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);
+ this->colourLine(type, index);
if (index > 0)
{
@@ -476,14 +468,14 @@
while (output.size() > this->maxCharsPerLine_)
{
++linesUsed;
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(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->colourLine(type, index);
}
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
this->displayedText_ = output;
this->numLinesShifted_ = linesUsed;
}
@@ -501,7 +493,7 @@
else
this->inputWindowStart_ = 0;
this->displayedText_ = output;
- this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
+ this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output));
}
}
}
@@ -558,43 +550,41 @@
}
}
- void InGameConsole::colourLine(int colourcode, int index)
+ void InGameConsole::colourLine(Shell::LineType type, int index)
{
- if (colourcode == -1)
+ ColourValue colourTop, colourBottom;
+ switch (type)
{
- 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));
+ case Shell::Error: colourTop = ColourValue(0.95, 0.25, 0.25, 1.00);
+ colourBottom = ColourValue(1.00, 0.50, 0.50, 1.00); break;
+
+ case Shell::Warning: colourTop = ColourValue(0.95, 0.50, 0.20, 1.00);
+ colourBottom = ColourValue(1.00, 0.70, 0.50, 1.00); break;
+
+ case Shell::Info: colourTop = ColourValue(0.50, 0.50, 0.95, 1.00);
+ colourBottom = ColourValue(0.80, 0.80, 1.00, 1.00); break;
+
+ case Shell::Debug: colourTop = ColourValue(0.65, 0.48, 0.44, 1.00);
+ colourBottom = ColourValue(1.00, 0.90, 0.90, 1.00); break;
+
+ case Shell::Verbose: colourTop = ColourValue(0.40, 0.20, 0.40, 1.00);
+ colourBottom = ColourValue(0.80, 0.60, 0.80, 1.00); break;
+
+ case Shell::Ultra: colourTop = ColourValue(0.21, 0.69, 0.21, 1.00);
+ colourBottom = ColourValue(0.80, 1.00, 0.80, 1.00); break;
+
+ case Shell::Command: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
+ colourBottom = ColourValue(0.90, 0.90, 0.90, 0.90); break;
+
+ case Shell::Hint: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00);
+ colourBottom = ColourValue(0.90, 0.90, 0.90, 1.00); break;
+
+ default: colourTop = ColourValue(0.90, 0.90, 0.90, 1.00);
+ colourBottom = ColourValue(1.00, 1.00, 1.00, 1.00); break;
}
- 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));
- }
+
+ this->consoleOverlayTextAreas_[index]->setColourTop (colourTop);
+ this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
}
// ################################
Modified: code/trunk/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/InGameConsole.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -51,7 +51,7 @@
void initialise();
void setConfigValues();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
static void openConsole();
static void closeConsole();
@@ -71,9 +71,9 @@
void exit();
void shiftLines();
- void colourLine(int colourcode, int index);
+ void colourLine(Shell::LineType type, int index);
void setCursorPosition(unsigned int pos);
- void print(const std::string& text, int index, bool alwaysShift = false);
+ void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false);
void windowResized(unsigned int newWidth, unsigned int newHeight);
Modified: code/trunk/src/orxonox/overlays/Map.cc
===================================================================
--- code/trunk/src/orxonox/overlays/Map.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/Map.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,6 +48,7 @@
#include <OgreTextureManager.h>
#include <OgreViewport.h>
+#include "util/StringUtils.h"
#include "core/ConsoleCommand.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -93,11 +94,8 @@
Map::singletonMap_s=this;
//Getting Scene Manager (Hack)
- if( !sManager_ )
- {
- ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
- this->sManager_ = it->getSceneManager();
- }
+ ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+ this->sManager_ = it->getSceneManager();
if( !Map::getMapSceneManager() )
{
Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
Modified: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -38,10 +38,12 @@
#include <OgreOverlayManager.h>
#include <OgrePanelOverlayElement.h>
#include <OgreRenderWindow.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include <OgrePass.h>
#include "util/Convert.h"
#include "util/Exception.h"
-#include "util/StringUtils.h"
#include "core/GameMode.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -82,15 +84,15 @@
// Get aspect ratio from the render window. Later on, we get informed automatically
this->windowAspectRatio_ = static_cast<float>(this->getWindowWidth()) / this->getWindowHeight();
- this->sizeCorrectionChanged();
- this->changedVisibility();
+ this->size_ = Vector2(1.0f, 1.0f);
+ this->pickPoint_= Vector2(0.0f, 0.0f);
+ this->position_ = Vector2(0.0f, 0.0f);
+ this->angle_ = Degree(0.0);
+ this->bCorrectAspect_ = false;
+ this->rotState_ = Horizontal;
+ this->angleChanged(); // updates all other values as well
- setSize(Vector2(1.0f, 1.0f));
- setPickPoint(Vector2(0.0f, 0.0f));
- setPosition(Vector2(0.0f, 0.0f));
- setRotation(Degree(0.0));
- setAspectCorrection(false);
setBackgroundMaterial("");
}
@@ -142,7 +144,7 @@
OrxonoxOverlay::overlays_s.erase(this->getOldName());
if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
- COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
+ COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
OrxonoxOverlay::overlays_s[this->getName()] = this;
}
@@ -150,7 +152,7 @@
//! Only sets the background material name if not ""
void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
{
- if (this->background_ && material != "")
+ if (this->background_ && !material.empty())
this->background_->setMaterialName(material);
}
@@ -167,7 +169,7 @@
void OrxonoxOverlay::changedVisibility()
{
SUPER( OrxonoxOverlay, changedVisibility );
-
+
if (!this->overlay_)
return;
@@ -308,7 +310,7 @@
{
std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
if (it != overlays_s.end())
- (*it).second->scale(Vector2(scale, scale));
+ it->second->scale(Vector2(scale, scale));
}
/**
@@ -323,7 +325,7 @@
std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
if (it != overlays_s.end())
{
- OrxonoxOverlay* overlay= (*it).second;
+ OrxonoxOverlay* overlay= it->second;
if(overlay->isVisible())
overlay->hide();
else
@@ -342,7 +344,7 @@
{
std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
if (it != overlays_s.end())
- (*it).second->scroll(scroll);
+ it->second->scroll(scroll);
}
/**
@@ -356,7 +358,7 @@
{
std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
if (it != overlays_s.end())
- (*it).second->rotate(angle);
+ it->second->rotate(angle);
}
void OrxonoxOverlay::setOverlayGroup(OverlayGroup* group)
@@ -369,4 +371,10 @@
this->changedOverlayGroup();
}
}
+
+ void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
+ Ogre::MaterialPtr ptr = this->background_->getMaterial();
+ Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
+ tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
+ }
}
Modified: code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -154,6 +154,11 @@
//! ConsoleCommand: Accesses the overlay by its name and rotates it.
static void rotateOverlay(const std::string& name, const Degree& angle);
+ void setBackgroundMaterial(const std::string& material);
+ const std::string& getBackgroundMaterial() const;
+
+ void setBackgroundAlpha(float alpha);
+
virtual void changedVisibility();
inline void setOwner(BaseObject* owner)
@@ -171,7 +176,7 @@
void setOverlayGroup(OverlayGroup* group);
inline OverlayGroup* getOverlayGroup() const
{ return this->group_; }
- virtual void changedOverlayGroup()
+ virtual void changedOverlayGroup()
{ this->changedVisibility(); }
protected:
@@ -180,9 +185,6 @@
virtual void sizeChanged();
virtual void positionChanged();
- void setBackgroundMaterial(const std::string& material);
- const std::string& getBackgroundMaterial() const;
-
Ogre::Overlay* overlay_; //!< The overlay the entire class is about.
Ogre::PanelOverlayElement* background_; //!< Background image (blank per default).
@@ -204,6 +206,7 @@
static std::map<std::string, OrxonoxOverlay*> overlays_s;
BaseObject* owner_;
OverlayGroup* group_;
+ Ogre::Pass* backgroundAlphaPass_;
};
SUPER_FUNCTION(6, OrxonoxOverlay, changedOwner, false);
Modified: code/trunk/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayGroup.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/overlays/OverlayGroup.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -143,7 +143,7 @@
void OverlayGroup::changedVisibility()
{
SUPER( OverlayGroup, changedVisibility );
-
+
for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
(*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
}
Modified: code/trunk/src/orxonox/pickup/DroppedItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/DroppedItem.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/DroppedItem.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -82,7 +82,7 @@
{
if (this->item_)
{
- COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl;
+ COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << '\'' << std::endl;
this->item_->destroy();
}
@@ -111,7 +111,7 @@
drop->setTimeToLive(timeToLive);
drop->createTimer();
- COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
+ COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << ',' << position.y << ',' << position.z << ")." << std::endl;
return drop;
}
Modified: code/trunk/src/orxonox/pickup/ModifierPickup.cc
===================================================================
--- code/trunk/src/orxonox/pickup/ModifierPickup.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/ModifierPickup.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -90,12 +90,12 @@
for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
{
- pawn->getPickups().addAdditiveModifier((*it).first, (*it).second);
+ pawn->getPickups().addAdditiveModifier(it->first, it->second);
}
for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
{
- pawn->getPickups().addMultiplicativeModifier((*it).first, (*it).second);
+ pawn->getPickups().addMultiplicativeModifier(it->first, it->second);
}
if (this->duration_ > 0.0f)
@@ -127,12 +127,12 @@
for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
{
- pawn->getPickups().removeAdditiveModifier((*it).first, (*it).second);
+ pawn->getPickups().removeAdditiveModifier(it->first, it->second);
}
for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
{
- pawn->getPickups().removeMultiplicativeModifier((*it).first, (*it).second);
+ pawn->getPickups().removeMultiplicativeModifier(it->first, it->second);
}
if (this->timer_.getRemainingTime() > 0.0f)
@@ -161,7 +161,7 @@
{
std::map<ModifierType::Value, float>::const_iterator it = this->additiveModifiers_.find(type);
if (it != this->additiveModifiers_.end())
- return (*it).second;
+ return it->second;
else
return 0.0f;
}
@@ -174,7 +174,7 @@
{
std::map<ModifierType::Value, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
if (it != this->multiplicativeModifiers_.end())
- return (*it).second;
+ return it->second;
else
return 1.0f;
}
Modified: code/trunk/src/orxonox/pickup/ModifierPickup.h
===================================================================
--- code/trunk/src/orxonox/pickup/ModifierPickup.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/ModifierPickup.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -128,7 +128,7 @@
{ this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
void timerCallback(Pawn* pawn); //!< Method called when the timer runs out.
-
+
private:
float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType.
float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType.
Modified: code/trunk/src/orxonox/pickup/PickupCollection.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupCollection.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/PickupCollection.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -99,8 +99,8 @@
this->bBlockRemovals_ = true;
for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
{
- if((*it).second && (*it).second->getOwner())
- (*it).second->dropped((*it).second->getOwner());
+ if(it->second && it->second->getOwner())
+ it->second->dropped(it->second->getOwner());
}
this->currentUsable_ = NULL;
this->items_.clear();
@@ -123,7 +123,7 @@
item_range bounds = this->items_.equal_range(item->getPickupIdentifier());
for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
{
- if ((*it).second == item)
+ if (it->second == item)
{
return true;
}
@@ -175,7 +175,7 @@
item_range bounds = this->items_.equal_range(item->getPickupIdentifier());
for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
{
- if ((*it).second == item)
+ if (it->second == item)
{
this->items_.erase(it);
break;
@@ -216,7 +216,7 @@
for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
{
- v += (*it).second;
+ v += it->second;
}
return v;
@@ -231,7 +231,7 @@
modifier_range range = this->additiveModifiers_.equal_range(type);
for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
{
- if ((*it).second == value)
+ if (it->second == value)
{
this->additiveModifiers_.erase(it);
return;
@@ -259,7 +259,7 @@
modifier_range range = this->multiplicativeModifiers_.equal_range(type);
for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
{
- v *= (*it).second;
+ v *= it->second;
}
return v;
@@ -274,7 +274,7 @@
modifier_range range = this->multiplicativeModifiers_.equal_range(type);
for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
{
- if ((*it).second == value)
+ if (it->second == value)
{
this->multiplicativeModifiers_.erase(it);
return;
@@ -334,8 +334,8 @@
for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
{
- if ((*it).second->isA(ident))
- ret.push_back(orxonox_cast<EquipmentItem*>((*it).second));
+ if (it->second->isA(ident))
+ ret.push_back(orxonox_cast<EquipmentItem*>(it->second));
}
return ret;
@@ -351,8 +351,8 @@
for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
{
- if ((*it).second->isA(ident))
- ret.push_back(orxonox_cast<PassiveItem*>((*it).second));
+ if (it->second->isA(ident))
+ ret.push_back(orxonox_cast<PassiveItem*>(it->second));
}
return ret;
@@ -368,8 +368,8 @@
for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
{
- if ((*it).second->isA(ident))
- ret.push_back(orxonox_cast<UsableItem*>((*it).second));
+ if (it->second->isA(ident))
+ ret.push_back(orxonox_cast<UsableItem*>(it->second));
}
return ret;
Modified: code/trunk/src/orxonox/pickup/PickupInventory.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupInventory.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/PickupInventory.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -85,15 +85,11 @@
void PickupInventory::toggleInventory()
{
if(PickupInventory::getSingleton()->isVisible()) {
- GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
- GUIManager::getInstance().executeCode("hideCursor()");
- InputManager::getInstance().leaveState("guiMouseOnly");
+ GUIManager::hideGUI("PickupInventory");
}
else
{
- GUIManager::getInstance().showGUI("PickupInventory");
- GUIManager::getInstance().executeCode("showCursor()");
- InputManager::getInstance().enterState("guiMouseOnly");
+ GUIManager::showGUI("PickupInventory");
}
PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
}
@@ -199,14 +195,14 @@
if(!item)
return "";
- std::string name = "pickup_" + item->getGUIImage();
+ const std::string& name = "pickup_" + item->getGUIImage();
if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
{
CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "");
}
- return "set:" + name + " image:full_image";
+ return ("set:" + name + " image:full_image");
}
void PickupInventory::clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane)
@@ -335,9 +331,9 @@
txt->setVisible(true);
txt->setProperty("Text", item->getGUIText());
- txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour + "");
+ txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour);
- std::string image = PickupInventory::getImageForItem(item);
+ const std::string& image = PickupInventory::getImageForItem(item);
btn->setVisible(true);
btn->setProperty("NormalImage", image);
btn->setProperty("HoverImage", image);
Modified: code/trunk/src/orxonox/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupSpawner.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/PickupSpawner.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -95,8 +95,8 @@
// & load the GUI itself too, along with some empty windows
// = even less delays
- GUIManager::getInstance().showGUI("PickupInventory");
- GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
+ GUIManager::showGUI("PickupInventory");
+ GUIManager::hideGUI("PickupInventory");
PickupInventory::getSingleton();
}
/**
Modified: code/trunk/src/orxonox/pickup/UsableItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/UsableItem.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/pickup/UsableItem.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@file
@brief Implementation of UsableItem.
@@ -40,7 +40,7 @@
@brief Constructor. Registers the UsableItem.
@param creator Pointer to the object which created this item.
*/
- UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator)
+ UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator)
{
RegisterObject(UsableItem);
}
Modified: code/trunk/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/AmbientSound.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -30,7 +30,10 @@
#include "core/CoreIncludes.h"
#include "core/EventIncludes.h"
+#include "core/GameMode.h"
+#include "core/Resource.h"
#include "core/XMLPort.h"
+#include "SoundManager.h"
namespace orxonox
{
@@ -38,20 +41,39 @@
AmbientSound::AmbientSound(BaseObject* creator)
: BaseObject(creator)
+ , Synchronisable(creator)
+ , bPlayOnLoad_(false)
{
RegisterObject(AmbientSound);
+
+ // Ambient sounds always fade in
+ this->setVolume(0);
+ this->registerVariables();
}
- AmbientSound::~AmbientSound()
+ void AmbientSound::preDestroy()
{
+ if (GameMode::playsSound())
+ {
+ // Smoothly fade out by keeping a SmartPtr
+ SoundManager::getInstance().unregisterAmbientSound(this);
+ }
}
+ void AmbientSound::registerVariables()
+ {
+ registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged));
+ registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
+ registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
+ registerVariable(bPlayOnLoad_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged));
+ }
+
void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(AmbientSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
+ BaseSound::XMLPortExtern(xmlelement, mode);
+ XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode);
+ XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
}
void AmbientSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -59,4 +81,63 @@
SUPER(AmbientSound, XMLEventPort, xmlelement, mode);
XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode);
}
+
+ void AmbientSound::play()
+ {
+ if (GameMode::playsSound())
+ SoundManager::getInstance().registerAmbientSound(this);
+ }
+
+ void AmbientSound::stop()
+ {
+ if (GameMode::playsSound())
+ SoundManager::getInstance().unregisterAmbientSound(this);
+ }
+
+ void AmbientSound::pause()
+ {
+ if (GameMode::playsSound())
+ SoundManager::getInstance().pauseAmbientSound(this);
+ }
+
+ float AmbientSound::getRealVolume()
+ {
+ assert(GameMode::playsSound());
+ return SoundManager::getInstance().getRealVolume(SoundType::Music);
+ }
+
+ void AmbientSound::setAmbientSource(const std::string& source)
+ {
+ this->ambientSource_ = source;
+ this->moodChanged(this->getMood());
+ }
+
+ void AmbientSound::moodChanged(const std::string& mood)
+ {
+ if (GameMode::playsSound())
+ {
+ const std::string& path = "ambient/" + MoodManager::getInstance().getMood() + '/' + this->ambientSource_;
+ shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
+ if (fileInfo != NULL)
+ this->setSource(path);
+ else
+ COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl;
+ }
+ }
+
+ void AmbientSound::setPlayOnLoad(bool val)
+ {
+ this->bPlayOnLoad_ = val;
+ if (val)
+ this->play();
+ }
+
+ void AmbientSound::changedActivity()
+ {
+ SUPER(AmbientSound, changedActivity);
+ if (this->isActive())
+ this->play();
+ else
+ this->stop();
+ }
}
Modified: code/trunk/src/orxonox/sound/AmbientSound.h
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/AmbientSound.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -21,17 +21,21 @@
*
* Author:
* Reto Grieder
+ * Kevin Young
* Co-authors:
* ...
*
*/
+
#ifndef _AmbientSound_H__
#define _AmbientSound_H__
#include "OrxonoxPrereqs.h"
#include "core/BaseObject.h"
-#include "sound/BaseSound.h"
+#include "network/synchronisable/Synchronisable.h"
+#include "BaseSound.h"
+#include "MoodManager.h"
namespace orxonox
{
@@ -40,16 +44,44 @@
* It server as main interface to the OpenAL library.
*
*/
- class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject
+ class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject, public Synchronisable, public MoodListener
{
+ friend class SoundManager;
+
public:
AmbientSound(BaseObject* creator);
- virtual ~AmbientSound();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ void changedActivity();
+ void play();
+ void stop();
+ void pause();
+
+ void setAmbientSource(const std::string& source);
+ inline const std::string& getAmbientSource() const
+ { return this->ambientSource_; }
+
+ void setPlayOnLoad(bool val);
+ bool getPlayOnLoad() const
+ { return this->bPlayOnLoad_; }
+
+ protected:
+ ~AmbientSound() { }
+
private:
+ void preDestroy();
+ void registerVariables();
+ float getRealVolume();
+ void moodChanged(const std::string& mood);
+ inline void ambientSourceChanged()
+ { this->setAmbientSource(this->ambientSource_); }
+ inline void playOnLoadChanged()
+ { this->setPlayOnLoad(this->bPlayOnLoad_); }
+
+ std::string ambientSource_; //!< Analogous to source_, but mood independent
+ bool bPlayOnLoad_; //!< Play the sound immediately when loaded
};
}
Modified: code/trunk/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/BaseSound.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -28,235 +28,250 @@
#include "BaseSound.h"
+#include <cassert>
#include <vector>
-#include <AL/alut.h>
-#include <vorbis/vorbisfile.h>
+#include <al.h>
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/Resource.h"
+#include "core/XMLPort.h"
+#include "SoundBuffer.h"
+#include "SoundManager.h"
namespace orxonox
{
BaseSound::BaseSound()
- : audioSource_(0)
- , audioBuffer_(0)
- , bPlayOnLoad_(false)
- , bLoop_(false)
+ : bPooling_(false)
+ , volume_(1.0)
+ , bLooping_(false)
+ , state_(Stopped)
+ , pitch_ (1.0)
{
RegisterRootObject(BaseSound);
+
+ // Initialise audioSource_ to a value that is not a source
+ // 0 is unfortunately not guaranteed to be no source ID.
+ this->audioSource_ = 123456789;
+ while (alIsSource(++this->audioSource_));
}
BaseSound::~BaseSound()
{
- this->setSource("");
+ this->stop();
+ // Release buffer
+ if (this->soundBuffer_ != NULL)
+ {
+ assert(GameMode::playsSound());
+ SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_);
+ }
}
- void BaseSound::play()
+ void BaseSound::XMLPortExtern(Element& xmlelement, XMLPort::Mode mode)
{
- if (alIsSource(this->audioSource_))
+ XMLPortParam(BaseSound, "volume", setVolume, getVolume, xmlelement, mode);
+ XMLPortParam(BaseSound, "looping", setLooping, getLooping, xmlelement, mode);
+ XMLPortParam(BaseSound, "pitch", setPitch, getPitch, xmlelement, mode);
+ XMLPortParam(BaseSound, "source", setSource, getSource, xmlelement, mode);
+ }
+
+ void BaseSound::doPlay()
+ {
+ this->state_ = Playing;
+ if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING && this->soundBuffer_ != NULL)
{
- if (this->bLoop_)
- alSourcei(this->audioSource_, AL_LOOPING, AL_TRUE);
- else
- alSourcei(this->audioSource_, AL_LOOPING, AL_FALSE);
- alSourcePlay(this->audioSource_);
-
- if (alGetError() != AL_NO_ERROR)
+ if (!alIsSource(this->audioSource_))
{
- COUT(2) << "Sound: OpenAL: Error playin sound " << this->audioSource_ << std::endl;
+ this->audioSource_ = SoundManager::getInstance().getSoundSource(this);
+ if (!alIsSource(this->audioSource_))
+ return;
+ this->initialiseSource();
}
+
+ alSourcePlay(this->audioSource_);
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
}
}
- void BaseSound::stop()
+ void BaseSound::doStop()
{
+ this->state_ = Stopped;
if (alIsSource(this->audioSource_))
+ {
alSourceStop(this->audioSource_);
+ // Release buffer
+ alSourcei(this->audioSource_, AL_BUFFER, AL_NONE);
+ // Release source again
+ SoundManager::getInstance().releaseSoundSource(this->audioSource_);
+ // Get a no source ID
+ this->audioSource_ += 123455;
+ while (alIsSource(++this->audioSource_));
+ }
}
- void BaseSound::pause()
+ void BaseSound::doPause()
{
+ if (this->isStopped())
+ return;
+ this->state_ = Paused;
if (alIsSource(this->audioSource_))
alSourcePause(this->audioSource_);
}
- bool BaseSound::isPlaying()
+ ALint BaseSound::getSourceState() const
{
if (alIsSource(this->audioSource_))
- return getSourceState() == AL_PLAYING;
- return false;
+ {
+ ALint state;
+ alGetSourcei(this->audioSource_, AL_SOURCE_STATE, &state);
+ return state;
+ }
+ else
+ return AL_INITIAL;
}
- bool BaseSound::isPaused()
+ void BaseSound::initialiseSource()
{
+ this->updateVolume();
+ this->setPitch(this->getPitch());
+ this->setLooping(this->getLooping());
+ alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0);
+ alSource3f(this->audioSource_, AL_VELOCITY, 0, 0, 0);
+ alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
+ if (ALint error = alGetError())
+ COUT(2) << "Sound Warning: Setting source parameters to 0 failed: "
+ << SoundManager::getALErrorString(error) << std::endl;
+ assert(this->soundBuffer_ != NULL);
+ alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
+ if (ALuint error = alGetError())
+ COUT(1) << "Sound Error: Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << std::endl;
+ }
+
+ void BaseSound::setVolume(float vol)
+ {
+ this->volume_ = clamp(vol, 0.0f, 1.0f);
+ if (this->volume_ != vol)
+ COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
+ this->updateVolume();
+ }
+
+ void BaseSound::updateVolume()
+ {
if (alIsSource(this->audioSource_))
- return getSourceState() == AL_PAUSED;
- return true;
+ {
+ float volume = this->volume_ * this->getRealVolume();
+ alSourcef(this->audioSource_, AL_GAIN, volume);
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error setting volume to " << volume
+ << ": " << SoundManager::getALErrorString(error) << std::endl;
+ }
}
- bool BaseSound::isStopped()
+ void BaseSound::setLooping(bool val)
{
+ this->bLooping_ = val;
if (alIsSource(this->audioSource_))
- return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED;
- return true;
+ alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE));
}
- void BaseSound::setPlayOnLoad(bool val)
+ void BaseSound::setPitch(float pitch)
{
- this->bPlayOnLoad_ = true;
- this->play();
+ if (pitch > 2 || pitch < 0.5)
+ {
+ COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
+ pitch = pitch > 2 ? 2 : pitch;
+ pitch = pitch < 0.5 ? 0.5 : pitch;
+ }
+ this->pitch_ = pitch;
+ if (alIsSource(this->audioSource_))
+ {
+ alSourcef(this->audioSource_, AL_PITCH, pitch);
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error setting pitch: " << SoundManager::getALErrorString(error) << std::endl;
+ }
}
void BaseSound::setSource(const std::string& source)
{
- this->source_ = source;
if (!GameMode::playsSound())
- return;
-
- if (source.empty() && alIsSource(this->audioSource_))
{
- // Unload sound
- alSourcei(this->audioSource_, AL_BUFFER, 0);
- alDeleteSources(1, &this->audioSource_);
- alDeleteBuffers(1, &this->audioBuffer_);
+ this->source_ = source;
return;
}
- COUT(3) << "Sound: OpenAL ALUT: loading file " << source << std::endl;
- // Get DataStream from the resources
- shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(source);
- if (fileInfo == NULL)
+ if (this->soundBuffer_ != NULL)
{
- COUT(2) << "Warning: Sound file '" << source << "' not found" << std::endl;
- return;
- }
- dataStream_ = Resource::open(source);
- // Read everything into a temporary buffer
- char* buffer = new char[fileInfo->size];
- dataStream_->read(buffer, fileInfo->size);
- dataStream_->seek(0);
-
- this->audioBuffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
- delete[] buffer;
-
- if (this->audioBuffer_ == AL_NONE)
- {
- COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
- if (source.find("ogg", 0) != std::string::npos)
+ if (this->soundBuffer_->getFilename() == source)
{
- COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
- this->audioBuffer_ = loadOggFile();
+ assert(this->source_ == source_);
+ return;
}
-
- if (this->audioBuffer_ == AL_NONE)
+ // Stopping is imperative here!
+ if (alIsSource(this->audioSource_))
{
- COUT(2) << "Sound: fallback ogg loader failed: " << alutGetErrorString(alutGetError()) << std::endl;
- return;
+ alSourceStop(this->audioSource_);
+ alSourcei(this->audioSource_, AL_BUFFER, AL_NONE);
}
+ SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_);
+ this->soundBuffer_.reset();
}
- alGenSources(1, &this->audioSource_);
- alSourcei(this->audioSource_, AL_BUFFER, this->audioBuffer_);
- if (alGetError() != AL_NO_ERROR)
- {
- COUT(2) << "Sound: OpenAL: Error loading sample file: " << source << std::endl;
+ this->source_ = source;
+ // Don't load ""
+ if (source_.empty())
return;
- }
- alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0);
+ // Get new sound buffer
+ this->soundBuffer_ = SoundManager::getInstance().getSoundBuffer(this->source_);
+ if (this->soundBuffer_ == NULL)
+ return;
- if (this->bPlayOnLoad_)
- this->play();
- }
+ if (alIsSource(this->audioSource_)) // already playing or paused
+ {
+ // Set new buffer
+ alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
+ if (ALuint error = alGetError())
+ {
+ COUT(1) << "Sound Error: Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << std::endl;
+ return;
+ }
- ALint BaseSound::getSourceState()
- {
- ALint state;
- alGetSourcei(this->audioSource_, AL_SOURCE_STATE, &state);
- return state;
- }
-
- size_t readVorbis(void* ptr, size_t size, size_t nmemb, void* datasource)
- {
- return static_cast<Ogre::DataStream*>(datasource)->read(ptr, size * nmemb);
- }
-
- int seekVorbis(void* datasource, ogg_int64_t offset, int whence)
- {
- Ogre::DataStream* stream = static_cast<Ogre::DataStream*>(datasource);
- int offset_beg = offset;
- if (whence == SEEK_CUR)
- offset_beg = stream->tell() + offset;
- else if (whence == SEEK_END)
- offset_beg = stream->size() + offset;
- else if (whence != SEEK_SET)
- return -1;
- stream->seek(offset_beg);
- return 0;
- }
-
- long tellVorbis(void* datasource)
- {
- return static_cast<long>(static_cast<Ogre::DataStream*>(datasource)->tell());
- }
-
- ALuint BaseSound::loadOggFile()
- {
- char inbuffer[4096];
- std::vector<char> outbuffer;
- OggVorbis_File vf;
- vorbis_info* vorbisInfo;
- int eof = false;
- int current_section;
- ALuint buffer;
- ALenum format;
-
- // Open file with custom streaming
- ov_callbacks vorbisCallbacks;
- vorbisCallbacks.read_func = &readVorbis;
- vorbisCallbacks.seek_func = &seekVorbis;
- vorbisCallbacks.tell_func = &tellVorbis;
- vorbisCallbacks.close_func = NULL;
-
- int ret = ov_open_callbacks(dataStream_.get(), &vf, NULL, 0, vorbisCallbacks);
- if (ret < 0)
- {
- COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
- ov_clear(&vf);
- return AL_NONE;
+ // Sound was already playing or paused because there was a source acquired
+ assert(this->isPlaying() || this->isPaused());
+ alSourcePlay(this->audioSource_);
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
+ if (this->isPaused())
+ alSourcePause(this->audioSource_);
}
-
- while (!eof)
+ else // No source acquired so far, but might be set to playing or paused
{
- long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section);
- if (ret == 0)
+ State state = this->state_; // save
+ if (this->isPlaying() || this->isPaused())
+ doPlay();
+ if (state == Paused)
{
- eof = true;
+ this->state_ = Paused;
+ doPause();
}
- else if (ret < 0)
- {
- COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
- ov_clear(&vf);
- return AL_NONE;
- }
- else
- {
- outbuffer.insert(outbuffer.end(), inbuffer, inbuffer + sizeof(inbuffer));
- }
}
+ }
- vorbisInfo = ov_info(&vf, -1);
- if (vorbisInfo->channels == 1)
- format = AL_FORMAT_MONO16;
- else
- format = AL_FORMAT_STEREO16;
-
- alGenBuffers(1, &buffer);
- alBufferData(buffer, format, &outbuffer[0], outbuffer.size(), vorbisInfo->rate);
- ov_clear(&vf);
-
- return buffer;
+ void BaseSound::stateChanged()
+ {
+ switch (this->state_)
+ {
+ case Playing:
+ this->play();
+ break;
+ case Paused:
+ this->pause();
+ break;
+ case Stopped:
+ default:
+ this->stop();
+ break;
+ }
}
-
-} // namespace: orxonox
+}
Modified: code/trunk/src/orxonox/sound/BaseSound.h
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/BaseSound.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,13 +25,14 @@
* Reto Grieder
*
*/
+
#ifndef _BaseSound_H__
#define _BaseSound_H__
#include "OrxonoxPrereqs.h"
#include <string>
-#include <OgreSharedPtr.h>
+#include <boost/shared_ptr.hpp>
#include <OgreDataStream.h>
#include "core/OrxonoxClass.h"
@@ -46,37 +47,75 @@
{
public:
BaseSound();
- virtual ~BaseSound();
- void play();
- void stop();
- void pause();
+ void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode);
- bool isPlaying();
- bool isPaused();
- bool isStopped();
+ virtual void play() { this->doPlay(); }
+ virtual void stop() { this->doStop(); }
+ virtual void pause() { this->doPause(); }
- void setSource(const std::string& source);
- const std::string& getSource() { return this->source_; }
+ bool isPlaying() const { return this->state_ == Playing; }
+ bool isPaused() const { return this->state_ == Paused; }
+ bool isStopped() const { return this->state_ == Stopped; }
- bool getPlayOnLoad() { return this->bPlayOnLoad_; }
- void setPlayOnLoad(bool val);
+ virtual void setSource(const std::string& source);
+ virtual const std::string& getSource() const
+ { return this->source_; }
- bool getLoop() { return this->bLoop_; }
- void setLoop(bool val) { this->bLoop_ = val; }
+ void setVolume(float vol);
+ float getVolume() const
+ { return this->volume_; }
+ void updateVolume();
+ bool getLooping() const
+ { return this->bLooping_; }
+ void setLooping(bool val);
+
+ float getPitch() const
+ { return this->pitch_; }
+ void setPitch(float pitch);
+
protected:
- ALuint loadOggFile();
- ALint getSourceState();
+ enum State
+ {
+ Stopped,
+ Playing,
+ Paused
+ };
- ALuint audioSource_;
- ALuint audioBuffer_;
+ virtual ~BaseSound();
+ void doPlay();
+ void doStop();
+ void doPause();
+
+ // network callbacks
+ inline void pitchChanged()
+ { this->setPitch(this->pitch_); }
+ inline void loopingChanged()
+ { this->setLooping(this->bLooping_); }
+ inline void volumeChanged()
+ { this->setVolume(this->volume_); }
+ inline void sourceChanged()
+ { this->setSource(this->source_); }
+ void stateChanged();
+
+ virtual void initialiseSource();
+ ALint getSourceState() const;
+
+ virtual float getRealVolume() = 0;
+
+ ALuint audioSource_;
+ bool bPooling_;
+ shared_ptr<SoundBuffer> soundBuffer_;
+ std::string source_;
+ float volume_;
+ bool bLooping_;
+ State state_;
+ float pitch_;
+
private:
- std::string source_;
- bool bPlayOnLoad_;
- bool bLoop_;
- DataStreamPtr dataStream_;
+ DataStreamPtr dataStream_;
};
}
Modified: code/trunk/src/orxonox/sound/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/sound/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -1,7 +1,9 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
AmbientSound.cc
BaseSound.cc
+ SoundBuffer.cc
SoundManager.cc
WorldSound.cc
+ SoundStreamer.cc
)
Copied: code/trunk/src/orxonox/sound/SoundBuffer.cc (from rev 6415, code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc)
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.cc (rev 0)
+++ code/trunk/src/orxonox/sound/SoundBuffer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,187 @@
+/*
+ * 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
+ * Erwin 'vaiursch' Herrsche
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "SoundBuffer.h"
+
+#include <AL/alut.h>
+#include <vorbis/vorbisfile.h>
+
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "sound/SoundManager.h"
+
+namespace orxonox
+{
+ SoundBuffer::SoundBuffer(const std::string& filename, std::list<shared_ptr<SoundBuffer> >::iterator poolIterator)
+ : filename_(filename)
+ , audioBuffer_(AL_NONE)
+ , poolIterator_(poolIterator)
+ {
+ if (this->filename_.empty())
+ ThrowException(General, "SoundBuffer construction: fileInfo was NULL");
+
+ // Get resource info
+ shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename);
+ if (fileInfo == NULL)
+ {
+ COUT(2) << "Sound: Warning: Sound file '" << filename << "' not found" << std::endl;
+ return;
+ }
+ // Open data stream
+ DataStreamPtr dataStream = Resource::open(fileInfo);
+
+ const std::string& extension = this->filename_.substr(this->filename_.find_last_of('.') + 1);
+ if (getLowercase(extension) == "ogg")
+ {
+ // Try ogg loader
+ this->loadOgg(fileInfo, dataStream);
+ }
+ else
+ {
+ // Try standard OpenAL loader
+ this->loadStandard(fileInfo, dataStream);
+ }
+ }
+
+ SoundBuffer::~SoundBuffer()
+ {
+ // Destroy buffer
+ alDeleteBuffers(1, &this->audioBuffer_);
+ }
+
+ unsigned int SoundBuffer::getSize() const
+ {
+ ALint size;
+ alGetBufferi(this->audioBuffer_, AL_SIZE, &size);
+ return alGetError() ? 0 : size;
+ }
+
+ void SoundBuffer::loadStandard(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream)
+ {
+ // Read everything into a temporary buffer
+ char* buffer = new char[fileInfo->size];
+ dataStream->read(buffer, fileInfo->size);
+ dataStream->seek(0);
+
+ this->audioBuffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
+ delete[] buffer;
+
+ if (!alIsBuffer(this->audioBuffer_))
+ ThrowException(General, "Sound Error: Standard file loader failed: " << alutGetErrorString(alutGetError()));
+ }
+
+ size_t readVorbis(void* ptr, size_t size, size_t nmemb, void* datasource)
+ {
+ return static_cast<Ogre::DataStream*>(datasource)->read(ptr, size * nmemb);
+ }
+
+ int seekVorbis(void* datasource, ogg_int64_t offset, int whence)
+ {
+ Ogre::DataStream* stream = static_cast<Ogre::DataStream*>(datasource);
+ switch (whence)
+ {
+ case SEEK_SET:
+ stream->seek(offset);
+ break;
+ case SEEK_CUR:
+ stream->skip(offset);
+ break;
+ case SEEK_END:
+ stream->seek(stream->size() + offset);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+ }
+
+ long tellVorbis(void* datasource)
+ {
+ return static_cast<long>(static_cast<Ogre::DataStream*>(datasource)->tell());
+ }
+
+ void SoundBuffer::loadOgg(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream)
+ {
+ char inbuffer[256*1024];
+ std::vector<char> outbuffer;
+ outbuffer.reserve(80*1024*1024);
+
+ // Open file with custom streaming
+ ov_callbacks vorbisCallbacks;
+ vorbisCallbacks.read_func = &readVorbis;
+ vorbisCallbacks.seek_func = &seekVorbis;
+ vorbisCallbacks.tell_func = &tellVorbis;
+ vorbisCallbacks.close_func = NULL;
+
+ OggVorbis_File vf;
+ int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);
+ if (ret < 0)
+ {
+ COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+ ov_clear(&vf);
+ ThrowException(General, "Sound Error: Ogg file loader failed when opening the bitstream");
+ }
+
+ int current_section;
+ int eof = false;
+ while (!eof)
+ {
+ long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section);
+ if (ret == 0)
+ {
+ eof = true;
+ }
+ else if (ret < 0)
+ {
+ COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ ov_clear(&vf);
+ ThrowException(General, "Sound Error: Ogg file loader failed when decoding the file");
+ }
+ else
+ {
+ outbuffer.insert(outbuffer.end(), inbuffer, inbuffer + ret);
+ }
+ }
+
+ vorbis_info* vorbisInfo;
+ vorbisInfo = ov_info(&vf, -1);
+ ALenum format;
+ if (vorbisInfo->channels == 1)
+ format = AL_FORMAT_MONO16;
+ else
+ format = AL_FORMAT_STEREO16;
+
+ alGenBuffers(1, &this->audioBuffer_);
+ alBufferData(this->audioBuffer_, format, &outbuffer[0], outbuffer.size(), vorbisInfo->rate);
+ ov_clear(&vf);
+
+ if (!alIsBuffer(this->audioBuffer_))
+ ThrowException(General, "Sound: Ogg file loader failed when creating the buffer.");
+ }
+}
Copied: code/trunk/src/orxonox/sound/SoundBuffer.h (from rev 6415, code/branches/presentation2/src/orxonox/sound/SoundBuffer.h)
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.h (rev 0)
+++ code/trunk/src/orxonox/sound/SoundBuffer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,72 @@
+/*
+ * 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 _SoundBuffer_H__
+#define _SoundBuffer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <boost/shared_ptr.hpp>
+#include "core/Resource.h"
+
+namespace orxonox
+{
+ /*
+ @brief
+ The SoundBuffer class is to be used for sounds with position and orientation.
+ */
+ class _OrxonoxExport SoundBuffer
+ {
+ friend class SoundManager;
+ // Make sure nobody deletes an instance (using smart pointers)
+ template <class T>
+ friend void boost::checked_delete(T*);
+
+ public:
+ inline ALuint getBuffer()
+ { return this->audioBuffer_; }
+
+ unsigned int getSize() const;
+
+ const std::string& getFilename() const
+ { return this->filename_; }
+
+ private:
+ SoundBuffer(const std::string& filename, std::list<shared_ptr<SoundBuffer> >::iterator poolIterator);
+ ~SoundBuffer();
+ void loadStandard(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream);
+ void loadOgg(const shared_ptr<ResourceInfo>& fileInfo, DataStreamPtr dataStream);
+
+ std::string filename_;
+ ALuint audioBuffer_;
+ std::list<shared_ptr<SoundBuffer> >::iterator poolIterator_;
+ };
+}
+
+#endif /* _SoundBuffer_H__ */
Modified: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/SoundManager.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -21,6 +21,8 @@
*
* Author:
* Erwin 'vaiursch' Herrsche
+ * Kevin Young
+ * Reto Grieder
* Co-authors:
* ...
*
@@ -29,68 +31,293 @@
#include "SoundManager.h"
#include <AL/alut.h>
+#include <utility>
#include "util/Exception.h"
#include "util/Math.h"
#include "util/ScopeGuard.h"
+#include "util/Clock.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/ScopedSingletonManager.h"
+#include "core/Resource.h"
+#include "SoundBuffer.h"
+#include "BaseSound.h"
+#include "AmbientSound.h"
+#include "WorldSound.h"
namespace orxonox
{
- SoundManager* SoundManager::singletonPtr_s = NULL;
ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
+ std::string SoundManager::getALErrorString(ALenum code)
+ {
+ switch (code)
+ {
+ case AL_NO_ERROR: return "No error";
+ case AL_INVALID_NAME: return "Invalid AL parameter name";
+ case AL_INVALID_ENUM: return "Invalid AL enum";
+ case AL_INVALID_VALUE: return "Invalid AL value";
+ case AL_INVALID_OPERATION: return "Invalid AL operation";
+ case AL_OUT_OF_MEMORY: return "AL reports out of memory";
+ default: return "Unknown AL error";
+ }
+ }
+
SoundManager::SoundManager()
+ : effectsPoolSize_(0)
{
- if (!alutInitWithoutContext(NULL,NULL))
- ThrowException(InitialisationFailed, "OpenAL ALUT error: " << alutGetErrorString(alutGetError()));
+ RegisterRootObject(SoundManager);
+
+ // See whether we even want to load
+ bool bDisableSound_ = false;
+ SetConfigValue(bDisableSound_, false);
+ if (bDisableSound_)
+ ThrowException(InitialisationAborted, "Sound: Not loading at all");
+
+ if (!alutInitWithoutContext(NULL, NULL))
+ ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
- COUT(3) << "OpenAL: Opening sound device..." << std::endl;
+/*
+ // Get list of available sound devices and display them
+ const char* devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
+ char* device = new char[strlen(devices)+1];
+ strcpy(device, devices);
+ std::string renderDevice;
+ SetConfigValue(renderDevice, std::string(device)).description("Sound device used for rendering");
+ COUT(4) << "Sound: Available devices: ";
+ while (true)
+ {
+ this->deviceNames_.push_back(devices);
+ COUT(4) << '"' << devices << "\", ";
+ devices += strlen(devices) + 1;
+ if (*devices == '\0')
+ break;
+ }
+ COUT(4) << std::endl;
+
+ // Open the selected device
+ COUT(3) << "Sound: Opening device \"" << renderDevice << '\' << std::endl;
+ this->device_ = alcOpenDevice(renderDevice.c_str());
+*/
this->device_ = alcOpenDevice(NULL);
if (this->device_ == NULL)
{
- COUT(0) << "OpenaAL: Could not open sound device. Have you installed OpenAL?" << std::endl;
+ COUT(1) << "Sound: Could not open sound device. Have you installed OpenAL?" << std::endl;
#ifdef ORXONOX_PLATFORM_WINDOWS
- COUT(0) << "Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
+ COUT(1) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
#endif
- ThrowException(InitialisationFailed, "OpenAL error: Could not open sound device.");
+ ThrowException(InitialisationFailed, "Sound Error: Could not open sound device.");
}
Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
- COUT(3) << "OpenAL: Sound device opened" << std::endl;
+ // Create sound context and make it the currently used one
this->context_ = alcCreateContext(this->device_, NULL);
if (this->context_ == NULL)
- ThrowException(InitialisationFailed, "OpenAL error: Could not create sound context");
+ ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context");
Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
+ if (!alcMakeContextCurrent(this->context_))
+ ThrowException(InitialisationFailed, "Sound Error: Could not use ALC context");
- if (alcMakeContextCurrent(this->context_) == AL_TRUE)
- COUT(3) << "OpenAL: Context " << this->context_ << " loaded" << std::endl;
+ GameMode::setPlaysSound(true);
+ Loki::ScopeGuard resetPlaysSoundGuard = Loki::MakeGuard(&GameMode::setPlaysSound, false);
- COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
+ // Get some information about the sound
+ if (const char* version = alGetString(AL_VERSION))
+ COUT(4) << "Sound: --- OpenAL Version: " << version << std::endl;
+ if (const char* vendor = alGetString(AL_VENDOR))
+ COUT(4) << "Sound: --- OpenAL Vendor : " << vendor << std::endl;
+ if (const char* types = alutGetMIMETypes(ALUT_LOADER_BUFFER))
+ COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
+ else
+ COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
- const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER);
- if (str == NULL)
- COUT(2) << "OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl;
+ this->mute_[SoundType::All] = 1.0f;
+ this->mute_[SoundType::Music] = 1.0f;
+ this->mute_[SoundType::Effects] = 1.0f;
+
+ this->setConfigValues();
+
+ // Try to get at least one source
+ ALuint source;
+ alGenSources(1, &source);
+ if (!alGetError() && alIsSource(source))
+ this->availableSoundSources_.push_back(source);
else
- COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl;
+ ThrowException(InitialisationFailed, "Sound Error: Could not create even a single source");
+ // Create a few initial sources
+ this->createSoundSources(this->minSources_ - 1);
- GameMode::setPlaysSound(true);
// Disarm guards
alutExitGuard.Dismiss();
closeDeviceGuard.Dismiss();
desroyContextGuard.Dismiss();
+ resetPlaysSoundGuard.Dismiss();
+
+ COUT(4) << "Sound: Initialisation complete" << std::endl;
}
SoundManager::~SoundManager()
{
+ // Erase fade lists because of the smart pointers
+ this->fadeInList_.clear();
+ this->fadeOutList_.clear();
+
+ // If there are still used buffers around, well, that's just very bad...
+ if (this->soundBuffers_.size() != this->effectsPool_.size())
+ COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ // Empty buffer pool and buffer list
+ this->effectsPool_.clear();
+ this->soundBuffers_.clear();
+
+ // There should not be any sources in use anymore
+ if (!this->usedSoundSources_.empty())
+ COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ while (!this->availableSoundSources_.empty())
+ {
+ alDeleteSources(1, &this->availableSoundSources_.back());
+ this->availableSoundSources_.pop_back();
+ }
+
GameMode::setPlaysSound(false);
+
+ // Relieve context to destroy it
+ if (!alcMakeContextCurrent(NULL))
+ COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
alcDestroyContext(this->context_);
+ if (ALCenum error = alcGetError(this->device_))
+ {
+ if (error == AL_INVALID_OPERATION)
+ COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
+ else
+ COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
+ }
+#ifdef AL_VERSION_1_1
+ if (!alcCloseDevice(this->device_))
+ COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
+#else
alcCloseDevice(this->device_);
- alutExit();
+#endif
+ if (!alutExit())
+ COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
}
+ void SoundManager::setConfigValues()
+ {
+ SetConfigValue(crossFadeStep_, 0.2f)
+ .description("Determines how fast sounds should fade, per second.")
+ .callback(this, &SoundManager::checkFadeStepValidity);
+
+ SetConfigValueAlias(volume_[SoundType::All], "soundVolume_", 1.0f)
+ .description("Defines the overall volume.")
+ .callback(this, &SoundManager::checkSoundVolumeValidity);
+ SetConfigValueAlias(volume_[SoundType::Music], "ambientVolume_", 1.0f)
+ .description("Defines the ambient volume.")
+ .callback(this, &SoundManager::checkAmbientVolumeValidity);
+ SetConfigValueAlias(volume_[SoundType::Effects], "effectsVolume_", 1.0f)
+ .description("Defines the effects volume.")
+ .callback(this, &SoundManager::checkEffectsVolumeValidity);
+
+ SetConfigValue(minSources_, 16)
+ .description("Minimum number of sources being generated (if possible)");
+ SetConfigValue(maxSources_, 1024)
+ .description("Maximum number of sources to be made available");
+ }
+
+ void SoundManager::preUpdate(const Clock& time)
+ {
+ this->processCrossFading(time.getDeltaTime());
+
+ // Check whether a sound object has stopped playing
+ for (unsigned int i = 0; i < this->usedSoundSources_.size(); ++i)
+ {
+ ALint state;
+ alGetSourcei(this->usedSoundSources_[i].first, AL_SOURCE_STATE, &state);
+ if (state == AL_STOPPED)
+ {
+ this->usedSoundSources_[i].second->stop();
+ --i;
+ }
+ }
+ }
+
+ void SoundManager::checkFadeStepValidity()
+ {
+ if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
+ {
+ COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
+ ResetConfigValue(crossFadeStep_);
+ }
+ }
+
+ void SoundManager::checkVolumeValidity(SoundType::Value type)
+ {
+ float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
+ if (clampedVolume != this->volume_[type])
+ COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
+ this->updateVolume(type);
+ }
+
+ void SoundManager::setVolume(float vol, SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return;
+ this->volume_[type] = vol;
+ this->checkVolumeValidity(type);
+ }
+
+ float SoundManager::getVolume(SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return 0.0f;
+ return this->volume_[type];
+ }
+
+ float SoundManager::getRealVolume(SoundType::Value type)
+ {
+ if (type != SoundType::Music && type != SoundType::Effects)
+ return 0.0f;
+ return this->volume_[SoundType::All] * this->mute_[SoundType::All] * this->volume_[type] * this->mute_[type];
+ }
+
+ void SoundManager::updateVolume(SoundType::Value type)
+ {
+ switch(type)
+ {
+ case SoundType::All:
+ for (ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ case SoundType::Music:
+ for (ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ case SoundType::Effects:
+ for (ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ default:
+ assert(false);
+ }
+ }
+
+ void SoundManager::toggleMute(SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return;
+ this->mute_[type] = (this->mute_[type] == 0) ? 1.0f : 0.0f;
+ this->updateVolume(type);
+ }
+
+ bool SoundManager::getMute(SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return true;
+ return (this->mute_[type] == 0);
+ }
+
void SoundManager::setListenerPosition(const Vector3& position)
{
alListener3f(AL_POSITION, position.x, position.y, position.z);
@@ -102,15 +329,311 @@
void SoundManager::setListenerOrientation(const Quaternion& orientation)
{
// update listener orientation
- Vector3 up = orientation.xAxis(); // just a wild guess
- Vector3 at = orientation.zAxis();
+ const Vector3& direction = -orientation.zAxis();
+ const Vector3& up = orientation.yAxis();
- ALfloat orient[6] = { at.x, at.y, at.z,
- up.x, up.y, up.z };
+ ALfloat orient[6] = { direction.x, direction.y, direction.z, up.x, up.y, up.z };
- alListenerfv(AL_POSITION, orient);
+ alListenerfv(AL_ORIENTATION, orient);
ALenum error = alGetError();
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
}
+
+ void SoundManager::registerAmbientSound(AmbientSound* newAmbient)
+ {
+ if (newAmbient != NULL)
+ {
+ for (AmbientList::const_iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == newAmbient)
+ {
+ COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
+ return;
+ }
+ }
+
+ if (!this->ambientSounds_.empty())
+ {
+ this->fadeOut(ambientSounds_.front().first);
+ }
+ this->ambientSounds_.push_front(std::make_pair(newAmbient, false));
+ newAmbient->doPlay();
+ this->fadeIn(newAmbient);
+ }
+ }
+
+ void SoundManager::unregisterAmbientSound(AmbientSound* oldAmbient)
+ {
+ if (oldAmbient == NULL || ambientSounds_.empty())
+ return;
+
+ if (this->ambientSounds_.front().first == oldAmbient)
+ {
+ this->fadeOut(oldAmbient);
+ this->ambientSounds_.pop_front();
+ if (!this->ambientSounds_.empty())
+ {
+ if (!this->ambientSounds_.front().second) // Not paused before
+ {
+ this->ambientSounds_.front().first->doPlay();
+ }
+ this->fadeIn(this->ambientSounds_.front().first);
+ }
+ }
+ else
+ {
+ for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == oldAmbient)
+ {
+ this->fadeOut(oldAmbient);
+ this->ambientSounds_.erase(it);
+ break;
+ }
+ }
+ }
+ }
+
+ void SoundManager::pauseAmbientSound(AmbientSound* ambient)
+ {
+ if (ambient != NULL)
+ {
+ for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == ambient)
+ {
+ it->second = true;
+ this->fadeOut(it->first);
+ return;
+ }
+ }
+ }
+ }
+
+ void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound)
+ {
+ // If we're already fading out --> remove that
+ for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
+ {
+ if (*it == sound)
+ {
+ this->fadeOutList_.erase(it);
+ break;
+ }
+ }
+ // No duplicate entries
+ if (std::find(this->fadeInList_.begin(), this->fadeInList_.end(), sound) == this->fadeInList_.end())
+ this->fadeInList_.push_back(sound);
+ }
+
+ void SoundManager::fadeOut(const SmartPtr<AmbientSound>& sound)
+ {
+ // If we're already fading in --> remove that
+ for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
+ {
+ if (*it == sound)
+ {
+ this->fadeInList_.erase(it);
+ break;
+ }
+ }
+ // No duplicate entries
+ if (std::find(this->fadeOutList_.begin(), this->fadeOutList_.end(), sound) == this->fadeOutList_.end())
+ this->fadeOutList_.push_back(sound);
+ }
+
+ void SoundManager::processCrossFading(float dt)
+ {
+
+ // Hacky solution to the fade delay while loading a level.
+ if(dt > 0.2)
+ {
+ return;
+ }
+
+ // FADE IN
+ for (std::list<SmartPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
+ {
+ if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
+ {
+ (*it)->setVolume(1.0f);
+ this->fadeInList_.erase(it++);
+ }
+ else
+ {
+ (*it)->setVolume((*it)->getVolume() + this->crossFadeStep_*dt);
+ ++it;
+ }
+ }
+
+ // FADE OUT
+ for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
+ {
+ if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
+ {
+ (*it)->setVolume(0.0f);
+
+ // If sound is in the ambient list --> pause
+ for (AmbientList::const_iterator it2 = this->ambientSounds_.begin(); it2 != this->ambientSounds_.end(); ++it2)
+ {
+ if (it2->first == *it)
+ {
+ (*it)->doPause();
+ break;
+ }
+ }
+ // If not pause (by loop above for instance) --> stop
+ if (!(*it)->isPaused())
+ (*it)->doStop();
+
+ this->fadeOutList_.erase(it++);
+ }
+ else
+ {
+ (*it)->setVolume((*it)->getVolume() - this->crossFadeStep_*dt);
+ ++it;
+ }
+ }
+ }
+
+ shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename)
+ {
+ shared_ptr<SoundBuffer> buffer;
+ // Check active or pooled buffers
+ SoundBufferMap::const_iterator it = this->soundBuffers_.find(filename);
+ if (it != this->soundBuffers_.end())
+ {
+ buffer = it->second;
+
+ // Remove from effects pool if not active used before
+ if (buffer->poolIterator_ != this->effectsPool_.end())
+ {
+ this->effectsPoolSize_ -= buffer->getSize();
+ this->effectsPool_.erase(buffer->poolIterator_);
+ buffer->poolIterator_ = this->effectsPool_.end();
+ }
+ }
+ else
+ {
+ try
+ {
+ buffer.reset(new SoundBuffer(filename, this->effectsPool_.end()));
+ }
+ catch (...)
+ {
+ COUT(1) << Exception::handleMessage() << std::endl;
+ return buffer;
+ }
+ this->soundBuffers_[filename] = buffer;
+ }
+ return buffer;
+ }
+
+ void SoundManager::releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)
+ {
+ // Check if others are still using the buffer
+ if (buffer.use_count() != 2)
+ return;
+ SoundBufferMap::iterator it = this->soundBuffers_.find(buffer->getFilename());
+ if (it != this->soundBuffers_.end())
+ {
+ if (bPoolBuffer)
+ {
+ // Pool already too large?
+ while (this->effectsPoolSize_ + it->second->getSize() > this->maxEffectsPoolSize_s && !this->effectsPool_.empty())
+ {
+ shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();
+ this->effectsPoolSize_ -= bufferDel->getSize();
+ bufferDel->poolIterator_ = this->effectsPool_.end();
+ this->effectsPool_.pop_back();
+ // Remove from buffer map too
+ SoundBufferMap::iterator itDel = this->soundBuffers_.find(bufferDel->getFilename());
+ if (itDel != this->soundBuffers_.end())
+ this->soundBuffers_.erase(itDel);
+ }
+ // Put buffer into the pool
+ this->effectsPoolSize_ += it->second->getSize();
+ this->effectsPool_.push_front(it->second);
+ it->second->poolIterator_ = this->effectsPool_.begin();
+ }
+ else
+ this->soundBuffers_.erase(it);
+ }
+ }
+
+ ALuint SoundManager::getSoundSource(BaseSound* object)
+ {
+ if (!this->availableSoundSources_.empty())
+ {
+ ALuint source = this->availableSoundSources_.back();
+ this->availableSoundSources_.pop_back();
+ this->usedSoundSources_.push_back(std::make_pair(source, object));
+ return source;
+ }
+ else
+ {
+ if (this->usedSoundSources_.size() < this->maxSources_)
+ {
+ ALuint source;
+ alGenSources(1, &source);
+ // Try to create new sources (50% more, but at least one)
+ if (alIsSource(source) && !alGetError())
+ {
+ this->usedSoundSources_.push_back(std::make_pair(source, object));
+ return source;
+ }
+ }
+ // Return no source ID
+ ALuint source = 123456789;
+ while (alIsSource(++source));
+ return source;
+ }
+ }
+
+ void SoundManager::releaseSoundSource(ALuint source)
+ {
+#ifndef NDEBUG
+ for (std::vector<ALuint>::const_iterator it = this->availableSoundSources_.begin(); it != this->availableSoundSources_.end(); ++it)
+ assert((*it) != source);
+#endif
+ this->availableSoundSources_.push_back(source);
+ for (std::vector<std::pair<ALuint, BaseSound*> >::iterator it = this->usedSoundSources_.begin();
+ it != this->usedSoundSources_.end(); ++it)
+ {
+ if (it->first == source)
+ {
+ this->usedSoundSources_.erase(it);
+ break;
+ }
+ }
+ int used = std::max((unsigned int)(this->usedSoundSources_.size()), this->minSources_);
+ // Subtract those we added in the statement above trough std::max
+ int available = (int)this->availableSoundSources_.size() - (used - (int)this->usedSoundSources_.size());
+ // Delete sources again to free resources if appropriate (more than 50% more available than used)
+ int toDelete = available - used / 2;
+ while (toDelete-- > 0)
+ {
+ alDeleteSources(1, &this->availableSoundSources_.back());
+ if (alGetError())
+ COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
+ this->availableSoundSources_.pop_back();
+ }
+ }
+
+ unsigned int SoundManager::createSoundSources(unsigned int n)
+ {
+ unsigned int count = this->availableSoundSources_.size() + this->usedSoundSources_.size();
+ while (count < this->maxSources_ && count <= n)
+ {
+ ALuint source;
+ alGenSources(1, &source);
+ if (alIsSource(source) && !alGetError())
+ this->availableSoundSources_.push_back(source);
+ else
+ break;
+ ++count;
+ }
+ return count - this->availableSoundSources_.size() - this->usedSoundSources_.size();
+ }
}
Modified: code/trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/SoundManager.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -21,42 +21,133 @@
*
* Author:
* Erwin 'vaiursch' Herrsche
+ * Kevin Young
+ * Reto Grieder
* Co-authors:
* ...
*/
+
#ifndef _SoundManager_H__
#define _SoundManager_H__
#include "OrxonoxPrereqs.h"
-#include <cassert>
#include <list>
+#include <map>
+#include <string>
+#include <boost/shared_ptr.hpp>
+
#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
+#include "core/OrxonoxClass.h"
+#include "core/SmartPtr.h"
+// tolua_begin
namespace orxonox
{
- /**
- * The SoundManager class manages the OpenAL device, context and listener
- * position. It is a singleton.
- *
- */
- class _OrxonoxExport SoundManager : public Singleton<SoundManager>
+ //! Enum for the sound type.
+ namespace SoundType
{
+ enum Value
+ {
+ All = 0,
+ Music = 1,
+ Effects = 2
+ };
+ }
+
+ //! The SoundManager class manages the OpenAL device, context and listener position.
+ class _OrxonoxExport SoundManager
+ // tolua_end
+ : public Singleton<SoundManager>, public OrxonoxClass
+ { // tolua_export
friend class Singleton<SoundManager>;
+
public:
SoundManager();
~SoundManager();
+ void preUpdate(const Clock& time);
+ void setConfigValues();
+
+ // tolua_begin
+ static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); }
+
+ std::string getDeviceName(unsigned int index) const
+ { return index < this->deviceNames_.size() ? this->deviceNames_[index] : std::string(); }
+ // tolua_end
+
void setListenerPosition(const Vector3& position);
void setListenerOrientation(const Quaternion& orientation);
+ void registerAmbientSound(AmbientSound* newAmbient);
+ void unregisterAmbientSound(AmbientSound* oldAmbient);
+ void pauseAmbientSound(AmbientSound* ambient);
+
+ // tolua_begin
+ void setVolume(float vol, SoundType::Value type);
+ float getVolume(SoundType::Value type);
+ float getRealVolume(SoundType::Value type);
+
+ void toggleMute(SoundType::Value type);
+ bool getMute(SoundType::Value type);
+ // tolua_end
+
+ shared_ptr<SoundBuffer> getSoundBuffer(const std::string& filename);
+ void releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer);
+
+ ALuint getSoundSource(BaseSound* object);
+ void releaseSoundSource(ALuint source);
+
+ static std::string getALErrorString(ALenum error);
+
private:
+ void processCrossFading(float dt);
+ void fadeIn(const SmartPtr<AmbientSound>& sound);
+ void fadeOut(const SmartPtr<AmbientSound>& sound);
+
+ void checkFadeStepValidity();
+
+ void checkVolumeValidity(SoundType::Value type);
+ void checkSoundVolumeValidity() { this->checkVolumeValidity(SoundType::All); }
+ void checkAmbientVolumeValidity() { this->checkVolumeValidity(SoundType::Music); }
+ void checkEffectsVolumeValidity() { this->checkVolumeValidity(SoundType::Effects); }
+ void updateVolume(SoundType::Value type);
+
+ unsigned int createSoundSources(unsigned int n);
+
+ // OpenAL device/context related
+ std::vector<std::string> deviceNames_;
ALCdevice* device_;
ALCcontext* context_;
+ // Ambient sound related
+ typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
+ AmbientList ambientSounds_;
+ //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
+ float crossFadeStep_;
+ std::list<SmartPtr<AmbientSound> > fadeInList_;
+ std::list<SmartPtr<AmbientSound> > fadeOutList_;
+
+ // Volume related
+ float volume_[3];
+ float mute_[3];
+
+ // Sound buffer related
+ static const unsigned int maxEffectsPoolSize_s = 40 * 1024 * 1024;
+ unsigned int effectsPoolSize_;
+ typedef std::list<shared_ptr<SoundBuffer> > EffectsPoolList;
+ EffectsPoolList effectsPool_;
+ typedef std::map<std::string, shared_ptr<SoundBuffer> > SoundBufferMap;
+ SoundBufferMap soundBuffers_;
+
+ // Sound source related
+ unsigned int minSources_;
+ unsigned int maxSources_;
+ std::vector<ALuint> availableSoundSources_;
+ std::vector<std::pair<ALuint, BaseSound*> > usedSoundSources_;
+
static SoundManager* singletonPtr_s;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _SoundManager_H__ */
Copied: code/trunk/src/orxonox/sound/SoundStreamer.cc (from rev 6415, code/branches/presentation2/src/orxonox/sound/SoundStreamer.cc)
===================================================================
--- code/trunk/src/orxonox/sound/SoundStreamer.cc (rev 0)
+++ code/trunk/src/orxonox/sound/SoundStreamer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,128 @@
+/*
+ * 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:
+ * Erwin 'vaiursch' Herrsche
+ * Co-authors:
+ *
+ */
+#include "SoundStreamer.h"
+
+#include <al.h>
+#include <vorbis/vorbisfile.h>
+#include "SoundManager.h"
+
+namespace orxonox
+{
+ // vorbis callbacks
+ size_t readVorbis(void* ptr, size_t size, size_t nmemb, void* datasource);
+ int seekVorbis(void* datasource, ogg_int64_t offset, int whence);
+ long tellVorbis(void* datasource);
+
+ void orxonox::SoundStreamer::operator()(ALuint audioSource, DataStreamPtr dataStream)
+ {
+ // Open file with custom streaming
+ ov_callbacks vorbisCallbacks;
+ vorbisCallbacks.read_func = &readVorbis;
+ vorbisCallbacks.seek_func = &seekVorbis;
+ vorbisCallbacks.tell_func = &tellVorbis;
+ vorbisCallbacks.close_func = NULL;
+
+ OggVorbis_File vf;
+ int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);
+ if (ret < 0)
+ {
+ COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+ ov_clear(&vf);
+ return;
+ }
+ vorbis_info* vorbisInfo;
+ vorbisInfo = ov_info(&vf, -1);
+ ALenum format;
+ if (vorbisInfo->channels == 1)
+ format = AL_FORMAT_MONO16;
+ else
+ format = AL_FORMAT_STEREO16;
+
+ char inbuffer[256*1024];
+ ALuint initbuffers[4];
+ alGenBuffers(4, initbuffers);
+ int current_section;
+
+ for(int i = 0; i < 4; i++)
+ {
+ long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section);
+ if (ret == 0)
+ {
+ return;
+ }
+ else if (ret < 0)
+ {
+ COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ ov_clear(&vf);
+ return;
+ }
+
+ alBufferData(initbuffers[i], format, &inbuffer, ret, vorbisInfo->rate);
+ }
+ alSourceQueueBuffers(audioSource, 4, initbuffers);
+
+ while(true) // Stream forever, control through thread control
+ {
+ int processed;
+ alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
+ if (ALint error = alGetError())
+ COUT(2) << "Sound Warning: Couldn't get number of processed buffers: "
+ << SoundManager::getALErrorString(error) << std::endl;
+
+ if(processed > 0)
+ {
+ ALuint* buffers = new ALuint[processed];
+ alSourceUnqueueBuffers(audioSource, processed, buffers);
+ if (ALint error = alGetError())
+ COUT(2) << "Sound Warning: Couldn't unqueue buffers: "
+ << SoundManager::getALErrorString(error) << std::endl;
+
+ for(int i = 0; i < processed; i++)
+ {
+ long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section);
+ if (ret == 0)
+ {
+ return;
+ }
+ else if (ret < 0)
+ {
+ COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ ov_clear(&vf);
+ return;
+ }
+
+ alBufferData(buffers[i], format, &inbuffer, ret, vorbisInfo->rate);
+ }
+
+ alSourceQueueBuffers(audioSource, processed, buffers);
+ if (ALint error = alGetError())
+ COUT(2) << "Sound Warning: Couldn't queue buffers: "
+ << SoundManager::getALErrorString(error) << std::endl;
+ }
+ }
+ }
+}
Copied: code/trunk/src/orxonox/sound/SoundStreamer.h (from rev 6415, code/branches/presentation2/src/orxonox/sound/SoundStreamer.h)
===================================================================
--- code/trunk/src/orxonox/sound/SoundStreamer.h (rev 0)
+++ code/trunk/src/orxonox/sound/SoundStreamer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,46 @@
+/*
+ * 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:
+ * Erwin 'vaiursch' Herrsche
+ * Co-authors:
+ *
+ */
+
+#ifndef _SoundStreamer_H__
+#define _SoundStreamer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreDataStream.h>
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport SoundStreamer // class for stream threads
+ {
+ public:
+ void operator()(ALuint audioSource, DataStreamPtr dataStream);
+ };
+}
+
+#endif /* _SoundStreamer_H__ */
Modified: code/trunk/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/WorldSound.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/WorldSound.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -34,6 +34,9 @@
#include "core/CoreIncludes.h"
#include "core/EventIncludes.h"
#include "core/XMLPort.h"
+#include "Scene.h"
+#include "SoundManager.h"
+#include <core/ConsoleCommandCompilation.h>
namespace orxonox
{
@@ -43,18 +46,24 @@
: StaticEntity(creator)
{
RegisterObject(WorldSound);
+ // WorldSound buffers should be pooled when they're not used anymore
+ this->bPooling_ = true;
+ this->registerVariables();
}
- WorldSound::~WorldSound()
+ void WorldSound::registerVariables()
{
+ registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::volumeChanged));
+ registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::sourceChanged));
+ registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::loopingChanged));
+ registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged));
+ registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged));
}
void WorldSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(WorldSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
+ BaseSound::XMLPortExtern(xmlelement, mode);
}
void WorldSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -63,6 +72,19 @@
XMLPortEventState(WorldSound, BaseObject, "play", play, xmlelement, mode);
}
+ void WorldSound::initialiseSource()
+ {
+ BaseSound::initialiseSource();
+ if (this->getScene())
+ {
+ float refDist = this->getScene()->getSoundReferenceDistance();
+ alSourcef(this->audioSource_, AL_REFERENCE_DISTANCE, refDist);
+ // TODO: 500 is very magical here. Derive something better
+ alSourcef(this->audioSource_, AL_MAX_DISTANCE, refDist * 500);
+ }
+ this->tick(0); // update position, orientation and velocity
+ }
+
void WorldSound::tick(float dt)
{
if (alIsSource(this->audioSource_))
@@ -79,13 +101,26 @@
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
- const Quaternion& orient = this->getWorldOrientation();
- Vector3 at = orient.zAxis();
- alSource3f(this->audioSource_, AL_DIRECTION, at.x, at.y, at.z);
+ const Vector3& direction = -this->getWorldOrientation().zAxis();
+ alSource3f(this->audioSource_, AL_DIRECTION, direction.x, direction.y, direction.z);
error = alGetError();
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
}
}
+ void WorldSound::changedActivity()
+ {
+ SUPER(WorldSound, changedActivity);
+ if (this->isActive())
+ this->play();
+ else
+ this->stop();
+ }
+
+ float WorldSound::getRealVolume()
+ {
+ assert(GameMode::playsSound());
+ return SoundManager::getInstance().getRealVolume(SoundType::Effects);
+ }
}
Modified: code/trunk/src/orxonox/sound/WorldSound.h
===================================================================
--- code/trunk/src/orxonox/sound/WorldSound.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/sound/WorldSound.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -25,6 +25,7 @@
* ...
*
*/
+
#ifndef _WorldSound_H__
#define _WorldSound_H__
@@ -44,14 +45,20 @@
{
public:
WorldSound(BaseObject* creator);
- virtual ~WorldSound();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ void changedActivity();
- virtual void tick(float dt);
+ void tick(float dt);
+ protected:
+ ~WorldSound() {}
+
private:
+ void registerVariables();
+ void initialiseSource();
+ float getRealVolume();
};
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -31,12 +31,17 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "controllers/Controller.h"
+#include "worldentities/pawns/Pawn.h"
#include "Munition.h"
#include "Weapon.h"
#include "WeaponPack.h"
#include "WeaponSystem.h"
+#include "WeaponSlot.h"
+#include "sound/WorldSound.h"
+
namespace orxonox
{
WeaponMode::WeaponMode(BaseObject* creator) : BaseObject(creator)
@@ -60,11 +65,28 @@
this->reloadTimer_.stopTimer();
this->damage_ = 0;
+
this->muzzleOffset_ = Vector3::ZERO;
+ this->muzzlePosition_ = Vector3::ZERO;
+ this->muzzleOrientation_ = Quaternion::IDENTITY;
+
+ if( GameMode::isMaster() )
+ {
+ this->defSndWpnFire_ = new WorldSound(this);
+ this->defSndWpnFire_->setLooping(false);
+ this->bSoundAttached_ = false;
+ }
+ else
+ this->defSndWpnFire_ = 0;
}
WeaponMode::~WeaponMode()
{
+ if (this->isInitialized())
+ {
+ if (this->defSndWpnFire_)
+ this->defSndWpnFire_->destroy();
+ }
}
void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -89,6 +111,12 @@
bool WeaponMode::fire(float* reloadTime)
{
(*reloadTime) = this->reloadTime_;
+ if( !this->bSoundAttached_ && GameMode::isMaster() )
+ {
+ assert(this->getWeapon());
+ this->getWeapon()->attach(this->defSndWpnFire_);
+ this->bSoundAttached_ = true;
+ }
if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
{
@@ -107,6 +135,11 @@
this->reloadTimer_.setInterval(reloadtime);
this->reloadTimer_.startTimer();
+ if( this->defSndWpnFire_ && !(this->defSndWpnFire_->isPlaying()))
+ {
+ this->defSndWpnFire_->play();
+ }
+
this->fire();
return true;
@@ -144,7 +177,11 @@
void WeaponMode::setMunitionName(const std::string& munitionname)
{
this->munitionname_ = munitionname;
- this->munitiontype_ = ClassByString(this->munitionname_);
+ Identifier* identifier = ClassByString(this->munitionname_);
+ if (identifier)
+ this->munitiontype_ = identifier;
+ else
+ COUT(2) << "Warning: No munition class defined in WeaponMode " << this->getName() << std::endl;
this->updateMunition();
}
@@ -190,30 +227,50 @@
void WeaponMode::reloaded()
{
+ if( this->defSndWpnFire_ && this->defSndWpnFire_->isPlaying())
+ {
+ this->defSndWpnFire_->stop();
+ }
this->bReloading_ = false;
}
- Vector3 WeaponMode::getMuzzlePosition() const
+ void WeaponMode::computeMuzzleParameters(const Vector3& target)
{
if (this->weapon_)
- return (this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_);
+ {
+ this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_;
+
+ Vector3 muzzleDirection;
+ muzzleDirection = target - this->muzzlePosition_;
+// COUT(0) << "muzzleDirection " << muzzleDirection << endl;
+ this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
+ }
else
- return this->muzzleOffset_;
+ {
+ this->muzzlePosition_ = this->muzzleOffset_;
+ this->muzzleOrientation_ = Quaternion::IDENTITY;
+ }
}
- const Quaternion& WeaponMode::getMuzzleOrientation() const
+ Vector3 WeaponMode::getMuzzleDirection() const
{
if (this->weapon_)
- return this->weapon_->getWorldOrientation();
+ return (this->getMuzzleOrientation() * WorldEntity::FRONT);
else
- return Quaternion::IDENTITY;
+ return WorldEntity::FRONT;
}
- Vector3 WeaponMode::getMuzzleDirection() const
+ void WeaponMode::setDefaultSound(const std::string& soundPath)
{
- if (this->weapon_)
- return (this->weapon_->getWorldOrientation() * WorldEntity::FRONT);
+ if( this->defSndWpnFire_ )
+ this->defSndWpnFire_->setSource(soundPath);
+ }
+
+ const std::string& WeaponMode::getDefaultSound()
+ {
+ if( this->defSndWpnFire_ )
+ return this->defSndWpnFire_->getSource();
else
- return WorldEntity::FRONT;
+ return BLANKSTRING;
}
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -51,7 +51,11 @@
bool fire(float* reloadTime);
bool reload();
+ // Interacting with the default Firing sound
+ void setDefaultSound(const std::string& soundPath);
+ const std::string& getDefaultSound();
+
// Munition
inline Munition* getMunition() const
{ return this->munition_; }
@@ -108,8 +112,11 @@
inline const Vector3& getMuzzleOffset() const
{ return this->muzzleOffset_; }
- Vector3 getMuzzlePosition() const;
- const Quaternion& getMuzzleOrientation() const;
+ void computeMuzzleParameters(const Vector3& target);
+ const Vector3& getMuzzlePosition() const
+ { return this->muzzlePosition_; }
+ const Quaternion& getMuzzleOrientation() const
+ { return this->muzzleOrientation_; }
Vector3 getMuzzleDirection() const;
@@ -124,6 +131,8 @@
inline unsigned int getMode() const
{ return this->mode_; }
+ Vector3 getTarget();
+
protected:
virtual void fire() = 0;
@@ -151,6 +160,12 @@
Timer reloadTimer_;
bool bReloading_;
+
+ Vector3 muzzlePosition_;
+ Quaternion muzzleOrientation_;
+
+ WorldSound* defSndWpnFire_;
+ bool bSoundAttached_;
};
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponPack.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponPack.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponPack.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -48,9 +48,10 @@
WeaponPack::~WeaponPack()
{
- if (this->isInitialized() && this->weaponSystem_)
+ if (this->isInitialized())
{
- this->weaponSystem_->removeWeaponPack(this);
+ if( this->weaponSystem_ )
+ this->weaponSystem_->removeWeaponPack(this);
while (!this->weapons_.empty())
(*this->weapons_.begin())->destroy();
@@ -70,13 +71,13 @@
void WeaponPack::fire(unsigned int weaponmode)
{
- for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
(*it)->fire(weaponmode);
}
void WeaponPack::reload()
{
- for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
(*it)->reload();
}
@@ -85,7 +86,7 @@
if (!weapon)
return;
- this->weapons_.insert(weapon);
+ this->weapons_.push_back(weapon);
weapon->setWeaponPack(this);
}
@@ -94,7 +95,9 @@
if (!weapon)
return;
- this->weapons_.erase(weapon);
+ std::vector<Weapon*>::iterator it = std::find(this->weapons_.begin(), this->weapons_.end(), weapon);
+ assert(it != this->weapons_.end());
+ this->weapons_.erase(it);
weapon->setWeaponPack(0);
}
@@ -102,7 +105,7 @@
{
unsigned int i = 0;
- for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
{
if (i == index)
return (*it);
@@ -141,7 +144,7 @@
void WeaponPack::notifyWeapons()
{
- for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
(*it)->setWeaponPack(this);
}
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponPack.h
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponPack.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponPack.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -68,7 +68,7 @@
private:
void notifyWeapons();
- std::set<Weapon *> weapons_;
+ std::vector<Weapon *> weapons_;
std::set<DefaultWeaponmodeLink *> links_;
WeaponSystem * weaponSystem_;
};
Modified: code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -201,7 +201,7 @@
it->second->setWeaponmodeLink(wPack, weaponmode);
}
- this->weaponPacks_.insert(wPack);
+ this->weaponPacks_.push_back(wPack);
wPack->setWeaponSystem(this);
return true;
@@ -220,13 +220,15 @@
it->second->removeWeaponmodeLink(wPack);
// Remove the WeaponPack from the WeaponSystem
- this->weaponPacks_.erase(wPack);
+ std::vector<WeaponPack*>::iterator it = std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(), wPack);
+ assert(it !=this->weaponPacks_.end());
+ this->weaponPacks_.erase(it);
}
WeaponPack * WeaponSystem::getWeaponPack(unsigned int index) const
{
unsigned int i = 0;
- for (std::set<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
+ for (std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
{
++i;
if (i > index)
@@ -257,7 +259,7 @@
return;
// Check if the WeaponPack belongs to this WeaponSystem
- std::set<WeaponPack *>::iterator it1 = this->weaponPacks_.find(wPack);
+ std::vector<WeaponPack *>::iterator it1 = std::find( this->weaponPacks_.begin(), this->weaponPacks_.end(), wPack );
if (it1 == this->weaponPacks_.end())
return;
Modified: code/trunk/src/orxonox/weaponsystem/WeaponSystem.h
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponSystem.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/weaponsystem/WeaponSystem.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -91,7 +91,7 @@
private:
std::map<unsigned int, WeaponSet *> weaponSets_;
std::vector<WeaponSlot *> weaponSlots_;
- std::set<WeaponPack *> weaponPacks_;
+ std::vector<WeaponPack *> weaponPacks_;
std::map<Identifier *, Munition *> munitions_;
Pawn * pawn_;
};
Modified: code/trunk/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/worldentities/CMakeLists.txt 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/CMakeLists.txt 2009-12-25 21:23:58 UTC (rev 6417)
@@ -6,6 +6,7 @@
ControllableEntity.cc
BigExplosion.cc
+ EffectContainer.cc
ExplosionChunk.cc
CameraPosition.cc
SpawnPoint.cc
Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -35,6 +35,7 @@
#include "core/ConfigValueIncludes.h"
#include "core/GameMode.h"
#include "core/XMLPort.h"
+#include "network/NetworkFunction.h"
#include "Scene.h"
#include "infos/PlayerInfo.h"
@@ -47,6 +48,9 @@
{
CreateFactory(ControllableEntity);
+ registerMemberNetworkFunction( ControllableEntity, fire );
+ registerMemberNetworkFunction( ControllableEntity, setTargetInternal );
+
ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
{
RegisterObject(ControllableEntity);
@@ -61,9 +65,11 @@
this->hud_ = 0;
this->camera_ = 0;
this->xmlcontroller_ = 0;
+ this->controller_ = 0;
this->reverseCamera_ = 0;
this->bDestroyWhenPlayerLeft_ = false;
this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
+ this->currentCameraPosition_ = 0;
this->bMouseLook_ = false;
this->mouseLookSpeed_ = 200;
@@ -168,6 +174,7 @@
if (this->camera_->getParent() == this && this->cameraPositions_.size() > 0)
{
this->cameraPositions_.front()->attachCamera(this->camera_);
+ this->currentCameraPosition_ = this->cameraPositions_.front().get();
}
else if (this->cameraPositions_.size() > 0)
{
@@ -177,9 +184,15 @@
{
++it;
if (it != this->cameraPositions_.end())
+ {
(*it)->attachCamera(this->camera_);
+ this->currentCameraPosition_ = *it;
+ }
else
+ {
(*this->cameraPositions_.begin())->attachCamera(this->camera_);
+ this->currentCameraPosition_ = *this->cameraPositions_.begin();
+ }
break;
}
}
@@ -187,6 +200,7 @@
else
{
this->camera_->attachToNode(this->cameraPositionRootNode_);
+ this->currentCameraPosition_ = 0;
}
}
}
@@ -197,6 +211,13 @@
if (!this->bMouseLook_)
this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
+ if (this->getCamera())
+ {
+ if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag())
+ this->getCamera()->setDrag(true);
+ else
+ this->getCamera()->setDrag(false);
+ }
}
void ControllableEntity::rotateYaw(const Vector2& value)
@@ -217,6 +238,39 @@
this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
}
+ void ControllableEntity::fire(unsigned int firemode)
+ {
+ if(GameMode::isMaster())
+ {
+ this->fired(firemode);
+ }
+ else
+ {
+ callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
+ }
+ }
+
+ void ControllableEntity::setTarget( WorldEntity* target )
+ {
+ this->target_ = target;
+ if ( !GameMode::isMaster() )
+ {
+ if ( target != 0 )
+ {
+ callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
+ }
+ else
+ {
+ callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
+ }
+ }
+ }
+
+ void ControllableEntity::setTargetInternal( uint32_t targetID )
+ {
+ this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) );
+ }
+
void ControllableEntity::setPlayer(PlayerInfo* player)
{
if (!player)
@@ -278,17 +332,23 @@
{
this->camera_ = new Camera(this);
this->camera_->requestFocus();
- if (this->cameraPositionTemplate_ != "")
+ if (!this->cameraPositionTemplate_.empty())
this->addTemplate(this->cameraPositionTemplate_);
if (this->cameraPositions_.size() > 0)
+ {
this->cameraPositions_.front()->attachCamera(this->camera_);
+ this->currentCameraPosition_ = this->cameraPositions_.front();
+ }
else
+ {
this->camera_->attachToNode(this->cameraPositionRootNode_);
+ this->currentCameraPosition_ = 0;
+ }
}
if (!this->hud_ && GameMode::showsGraphics())
{
- if (this->hudtemplate_ != "")
+ if (!this->hudtemplate_.empty())
{
this->hud_ = new OverlayGroup(this);
this->hud_->addTemplate(this->hudtemplate_);
Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -83,7 +83,8 @@
inline void rotateRoll(float value)
{ this->rotateRoll(Vector2(value, 0)); }
- virtual void fire(unsigned int firemode) {}
+ void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode) {}
virtual void reload() {}
virtual void boost() {}
@@ -139,6 +140,16 @@
inline Controller* getXMLController() const
{ return this->xmlcontroller_; }
+ inline Controller* getController() const
+ { return this->controller_; }
+ inline void setController(Controller* val)
+ { this->controller_ = val; }
+
+ virtual void setTarget( WorldEntity* target );
+ virtual WorldEntity* getTarget()
+ { return this->target_.get(); }
+ void setTargetInternal( uint32_t targetID );
+
protected:
virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead
virtual void removePlayer(); // don't call this directly, use friend class PlayerInfo instead
@@ -198,9 +209,12 @@
float mouseLookSpeed_;
Ogre::SceneNode* cameraPositionRootNode_;
std::list<SmartPtr<CameraPosition> > cameraPositions_;
+ CameraPosition* currentCameraPosition_;
std::string cameraPositionTemplate_;
Controller* xmlcontroller_;
+ Controller* controller_;
CameraPosition* reverseCamera_;
+ WeakPtr<WorldEntity> target_;
};
}
Copied: code/trunk/src/orxonox/worldentities/EffectContainer.cc (from rev 6415, code/branches/presentation2/src/orxonox/worldentities/EffectContainer.cc)
===================================================================
--- code/trunk/src/orxonox/worldentities/EffectContainer.cc (rev 0)
+++ code/trunk/src/orxonox/worldentities/EffectContainer.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,111 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#include "EffectContainer.h"
+
+extern "C" {
+#include <lua.h>
+}
+
+#include "core/CoreIncludes.h"
+#include "core/LuaState.h"
+#include "core/XMLPort.h"
+#include "worldentities/WorldEntity.h"
+
+namespace orxonox
+{
+ CreateFactory(EffectContainer);
+
+ EffectContainer::EffectContainer(BaseObject* creator)
+ : BaseObject(creator)
+ , lua_(NULL)
+ {
+ RegisterObject(EffectContainer);
+ }
+
+ EffectContainer::~EffectContainer()
+ {
+ }
+
+ void EffectContainer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(EffectContainer, XMLPort, xmlelement, mode);
+ XMLPortParam(EffectContainer, "condition", setCondition, getCondition, xmlelement, mode);
+ XMLPortObject(EffectContainer, WorldEntity, "", addEffect, getEffect, xmlelement, mode);
+ }
+
+ void EffectContainer::setCondition(const std::string& condition)
+ {
+ // TODO: Watch out for code injection!
+ this->condition_ = condition;
+ if (this->lua_)
+ {
+ this->lua_->doString(
+ this->functionName_ + " = function() \n"
+ " return (" + condition + ") \n"
+ "end"
+ );
+ }
+ }
+
+ void EffectContainer::setLuaState(LuaState* state, const std::string& functionName)
+ {
+ this->functionName_ = functionName;
+ this->lua_ = state;
+ this->setCondition(this->condition_);
+ }
+
+ void EffectContainer::addEffect(WorldEntity* effect)
+ {
+ this->effects_.push_back(effect);
+ }
+
+ WorldEntity* EffectContainer::getEffect(unsigned int index) const
+ {
+ unsigned int i = 0;
+ for (std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)
+ if (i == index)
+ return (*it);
+ return NULL;
+ }
+
+ void EffectContainer::updateCondition()
+ {
+ if (this->lua_)
+ {
+ lua_getglobal(this->lua_->getInternalLuaState(), this->functionName_.c_str());
+ lua_call(this->lua_->getInternalLuaState(), 0, 1);
+ bool result = (bool)lua_toboolean(this->lua_->getInternalLuaState(), -1);
+ lua_pop(this->lua_->getInternalLuaState(), 1);
+ for (std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)
+ {
+ (*it)->setMainState(result);
+ }
+ }
+ }
+}
Copied: code/trunk/src/orxonox/worldentities/EffectContainer.h (from rev 6415, code/branches/presentation2/src/orxonox/worldentities/EffectContainer.h)
===================================================================
--- code/trunk/src/orxonox/worldentities/EffectContainer.h (rev 0)
+++ code/trunk/src/orxonox/worldentities/EffectContainer.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -0,0 +1,71 @@
+/*
+ * 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 _EffectContainer_H__
+#define _EffectContainer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <vector>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport EffectContainer : public BaseObject
+ {
+ public:
+ EffectContainer(BaseObject* creator);
+ virtual ~EffectContainer();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ void setLuaState(LuaState* state, const std::string& functionName);
+
+ void setCondition(const std::string& condition);
+ inline const std::string& getCondition() const
+ { return this->condition_; }
+
+ void addEffect(WorldEntity* effect);
+ WorldEntity* getEffect(unsigned int index) const;
+
+ inline std::vector<WorldEntity*>::const_iterator getEffectsBegin()
+ { return this->effects_.begin(); }
+ inline std::vector<WorldEntity*>::const_iterator getEffectsEnd()
+ { return this->effects_.end(); }
+
+ void updateCondition();
+
+ private:
+ std::string condition_;
+ std::string functionName_;
+ LuaState* lua_;
+ std::vector<WorldEntity*> effects_;
+ };
+}
+
+#endif /* _EffectContainer_H__ */
Modified: code/trunk/src/orxonox/worldentities/MovableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/MovableEntity.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/MovableEntity.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -78,7 +78,8 @@
Pawn* victim = orxonox_cast<Pawn*>(otherObject);
if (victim)
{
- victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
+ float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
+ victim->hit(0, contactPoint, damage);
}
}
Modified: code/trunk/src/orxonox/worldentities/MovableEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/MovableEntity.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/MovableEntity.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -69,10 +69,10 @@
{ return this->collisionDamage_; }
inline void setEnableCollisionDamage(bool c)
- {
- this->enableCollisionDamage_ = c;
+ {
+ this->enableCollisionDamage_ = c;
this->enableCollisionCallback();
- }
+ }
inline bool getEnableCollisionDamage()
{ return this->enableCollisionDamage_; }
Modified: code/trunk/src/orxonox/worldentities/StaticEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/StaticEntity.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/StaticEntity.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -41,7 +41,7 @@
StaticEntity::StaticEntity(BaseObject* creator) : WorldEntity(creator)
{
RegisterObject(StaticEntity);
-
+
this->setPriority(Priority::VeryLow);
this->registerVariables();
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -471,27 +471,35 @@
//! Attaches an Ogre::MovableObject to this WorldEntity.
void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
- { this->node_->attachObject(object); }
+ {
+ this->node_->attachObject(object);
+ object->setUserObject(this);
+ }
+
void WorldEntity::attachOgreObject(Ogre::BillboardSet* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::Camera* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::Entity* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
//! Detaches an Ogre::MovableObject from this WorldEntity.
void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
- { this->node_->detachObject(object); }
+ {
+ object->setUserObject(NULL);
+ this->node_->detachObject(object);
+ }
+
void WorldEntity::detachOgreObject(Ogre::BillboardSet* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::Camera* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::Entity* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
//! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
@@ -645,7 +653,7 @@
/**
@brief
- Makes this WorldEntity look a specific target location.
+ Makes this WorldEntity look at a specific target location.
@param relativeTo
@see WorldEntity::TransformSpace
@param localDirectionVector
@@ -805,7 +813,7 @@
//! Sets the CollisionType by string (used for the XMLPort)
void WorldEntity::setCollisionTypeStr(const std::string& typeStr)
{
- std::string typeStrLower = getLowercase(typeStr);
+ const std::string& typeStrLower = getLowercase(typeStr);
CollisionType type;
if (typeStrLower == "dynamic")
type = Dynamic;
@@ -912,7 +920,7 @@
}
}
- //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
+ //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body.
void WorldEntity::internalSetPhysicsProps()
{
if (this->hasPhysics())
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -32,6 +32,7 @@
#include "OrxonoxPrereqs.h"
+#include <OgreUserDefinedObject.h>
#ifdef ORXONOX_RELEASE
# include <OgreSceneNode.h>
#endif
@@ -54,7 +55,7 @@
as more advanced ones.
The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
- to create an entire hierarchy of derivated objects.
+ to create an entire hierarchy of derived objects.
It is also the basis for the physics interface to the Bullet physics engine.
Every WorldEntity can have a specific collision type: @see CollisionType
This would then imply that every scene object could have any collision type. To limit this, you can always
@@ -62,13 +63,13 @@
for a specific object.
There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
of both objects simply get merged into one larger shape (for static collision type).
- The phyiscal body that is internally stored and administrated has the following supported properties:
- - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
+ The physical body that is internally stored and administrated has the following supported properties:
+ - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape.
You can get more information at the corresponding set function.
Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
*/
- class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
+ class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject
{
friend class Scene;
@@ -317,7 +318,7 @@
@brief
Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
- Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
+ Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player
character that should not rotate when hit sideways, you can set the angular factor to 0.
*/
inline void setAngularFactor(float angularFactor)
@@ -393,7 +394,7 @@
You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
- in its constructor and override this method. But be careful that a derived classe's virtual functions
+ in its constructor and override this method. But be careful that a derived class's virtual functions
don't yet exist in the constructor if a base class.
*/
virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -37,6 +37,7 @@
#include "PawnManager.h"
#include "infos/PlayerInfo.h"
+#include "controllers/Controller.h"
#include "gametypes/Gametype.h"
#include "graphics/ParticleSpawner.h"
#include "worldentities/ExplosionChunk.h"
@@ -51,8 +52,6 @@
{
CreateFactory(Pawn);
- registerMemberNetworkFunction( Pawn, doFire );
-
Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
{
RegisterObject(Pawn);
@@ -69,6 +68,8 @@
this->spawnparticleduration_ = 3.0f;
+ this->aimPosition_ = Vector3::ZERO;
+
this->getPickups().setOwner(this);
if (GameMode::isMaster())
@@ -109,7 +110,7 @@
XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
- XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
+ XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
}
void Pawn::registerVariables()
@@ -118,6 +119,7 @@
registerVariable(this->health_, VariableDirection::ToClient);
registerVariable(this->initialHealth_, VariableDirection::ToClient);
registerVariable(this->bReload_, VariableDirection::ToServer);
+ registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true);
}
void Pawn::tick(float dt)
@@ -165,7 +167,7 @@
void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
{
- if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
+ if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
{
this->damage(damage, originator);
this->setVelocity(this->getVelocity() + force);
@@ -174,6 +176,19 @@
}
}
+ void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
+ {
+ if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
+ {
+ this->damage(damage, originator);
+
+ if ( this->getController() )
+ this->getController()->hit(originator, contactpoint, damage);
+
+ // play hit effect
+ }
+ }
+
void Pawn::kill()
{
this->damage(this->health_);
@@ -183,7 +198,7 @@
void Pawn::spawneffect()
{
// play spawn effect
- if (this->spawnparticlesource_ != "")
+ if (!this->spawnparticlesource_.empty())
{
ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
effect->setPosition(this->getPosition());
@@ -262,26 +277,12 @@
}
}
- void Pawn::fire(unsigned int firemode)
+ void Pawn::fired(unsigned int firemode)
{
- this->doFire(firemode);
+ if (this->weaponSystem_)
+ this->weaponSystem_->fire(firemode);
}
- void Pawn::doFire(uint8_t firemode)
- {
- if(GameMode::isMaster())
- {
- if (this->weaponSystem_)
- this->weaponSystem_->fire(firemode);
- }
- else
- {
- callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
- if (this->weaponSystem_)
- this->weaponSystem_->fire(firemode);
- }
- }
-
void Pawn::reload()
{
this->bReload_ = true;
@@ -340,6 +341,13 @@
this->weaponSystem_->addWeaponPack(wPack);
}
+ void Pawn::addWeaponPackXML(WeaponPack * wPack)
+ {
+ if (this->weaponSystem_)
+ if (!this->weaponSystem_->addWeaponPack(wPack))
+ wPack->destroy();
+ }
+
WeaponPack * Pawn::getWeaponPack(unsigned int index) const
{
if (this->weaponSystem_)
Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -74,13 +74,12 @@
inline ControllableEntity* getLastHitOriginator() const
{ return this->lastHitOriginator_; }
- virtual void damage(float damage, Pawn* originator = 0);
virtual void hit(Pawn* originator, const Vector3& force, float damage);
+ virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
virtual void kill();
- virtual void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
virtual void reload();
- virtual void doFire(uint8_t firemode);
virtual void postSpawn();
void addWeaponSlot(WeaponSlot * wSlot);
@@ -88,6 +87,7 @@
void addWeaponSet(WeaponSet * wSet);
WeaponSet * getWeaponSet(unsigned int index) const;
void addWeaponPack(WeaponPack * wPack);
+ void addWeaponPackXML(WeaponPack * wPack);
WeaponPack * getWeaponPack(unsigned int index) const;
inline const WorldEntity* getWorldEntity() const
@@ -116,6 +116,11 @@
virtual void startLocalHumanControl();
+ void setAimPosition( Vector3 position )
+ { this->aimPosition_ = position; }
+ Vector3 getAimPosition()
+ { return this->aimPosition_; }
+
protected:
virtual void setPlayer(PlayerInfo* player);
virtual void removePlayer();
@@ -125,6 +130,8 @@
virtual void deatheffect();
virtual void spawneffect();
+ virtual void damage(float damage, Pawn* originator = 0);
+
bool bAlive_;
PickupCollection pickups_;
@@ -145,6 +152,8 @@
private:
inline void setWeaponSystem(WeaponSystem* weaponsystem)
{ this->weaponSystem_ = weaponsystem; }
+
+ Vector3 aimPosition_;
};
}
Modified: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -186,7 +186,7 @@
void SpaceShip::loadEngineTemplate()
{
- if (this->enginetemplate_ != "")
+ if (!this->enginetemplate_.empty())
{
Template* temp = Template::getTemplate(this->enginetemplate_);
Modified: code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.cc 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.cc 2009-12-25 21:23:58 UTC (rev 6417)
@@ -188,7 +188,7 @@
ControllableEntity::rotateRoll(value);
}
- void Spectator::fire(unsigned int firemode)
+ void Spectator::fired(unsigned int firemode)
{
if (this->getPlayer())
this->getPlayer()->setReadyToSpawn(true);
Modified: code/trunk/src/orxonox/worldentities/pawns/Spectator.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.h 2009-12-25 20:47:45 UTC (rev 6416)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.h 2009-12-25 21:23:58 UTC (rev 6417)
@@ -54,7 +54,7 @@
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
- virtual void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
virtual void greet();
protected:
More information about the Orxonox-commit
mailing list