Changeset 7163 for code/trunk/src/modules
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 4 deleted
- 100 edited
- 25 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/CMakeLists.txt
r6524 r7163 33 33 ADD_SUBDIRECTORY(questsystem) 34 34 ADD_SUBDIRECTORY(weapons) 35 ADD_SUBDIRECTORY(designtools) -
code/trunk/src/modules/objects/CMakeLists.txt
r5781 r7163 15 15 PCH_FILE 16 16 ObjectsPrecompiledHeaders.h 17 DEFINE_SYMBOL18 "OBJECTS_SHARED_BUILD"19 17 LINK_LIBRARIES 20 18 orxonox -
code/trunk/src/modules/objects/ObjectsPrereqs.h
r6906 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(O RXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(OBJECTS_STATIC_BUILD) 46 46 # ifdef OBJECTS_SHARED_BUILD 47 47 # define _ObjectsExport __declspec(dllexport) -
code/trunk/src/modules/objects/Planet.cc
r6501 r7163 70 70 { 71 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 72 if (activeCamera )72 if (activeCamera && this->billboard_.getBillboardSet()) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); … … 89 89 void Planet::init() 90 90 { 91 float scaleFactor = this->getScale();92 93 #if OGRE_VERSION >= 0x01070094 Ogre::Mesh::LodValueList distList;95 #else96 Ogre::Mesh::LodDistanceList distList;97 #endif98 99 distList.push_back(10.0f*scaleFactor);100 distList.push_back(19.0f*scaleFactor);101 distList.push_back(27.0f*scaleFactor);102 distList.push_back(34.0f*scaleFactor);103 distList.push_back(40.0f*scaleFactor);104 distList.push_back(45.0f*scaleFactor);105 distList.push_back(49.0f*scaleFactor);106 distList.push_back(52.0f*scaleFactor);107 distList.push_back(54.0f*scaleFactor);108 distList.push_back(55.0f*scaleFactor);109 110 float reductionValue = 0.2f;111 112 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);113 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));114 115 this->attachOgreObject(this->billboard_.getBillboardSet());116 this->billboard_.getBillboardSet()->setUseAccurateFacing(true);117 this->setCastShadows(true);118 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());119 this->mesh_.setCastShadows(true);120 91 } 121 92 122 93 void Planet::changedMesh() 123 94 { 124 if (this->mesh_.getEntity()) 125 this->detachOgreObject(this->mesh_.getEntity()); 95 if( GameMode::showsGraphics() ) 96 { 97 if (this->mesh_.getEntity()) 98 this->detachOgreObject(this->mesh_.getEntity()); 126 99 127 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);100 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 128 101 129 if (this->mesh_.getEntity()) 130 { 131 this->attachOgreObject(this->mesh_.getEntity()); 132 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 133 this->mesh_.setVisible(this->isVisible()); 102 if (this->mesh_.getEntity()) 103 { 104 this->attachOgreObject(this->mesh_.getEntity()); 105 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 106 this->mesh_.setVisible(this->isVisible()); 107 108 float scaleFactor = this->getScale(); 109 110 #if OGRE_VERSION >= 0x010700 111 Ogre::Mesh::LodValueList distList; 112 #else 113 Ogre::Mesh::LodDistanceList distList; 114 #endif 115 116 distList.push_back(10.0f*scaleFactor); 117 distList.push_back(19.0f*scaleFactor); 118 distList.push_back(27.0f*scaleFactor); 119 distList.push_back(34.0f*scaleFactor); 120 distList.push_back(40.0f*scaleFactor); 121 distList.push_back(45.0f*scaleFactor); 122 distList.push_back(49.0f*scaleFactor); 123 distList.push_back(52.0f*scaleFactor); 124 distList.push_back(54.0f*scaleFactor); 125 distList.push_back(55.0f*scaleFactor); 126 127 float reductionValue = 0.2f; 128 129 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 130 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 131 132 this->attachOgreObject(this->billboard_.getBillboardSet()); 133 this->billboard_.getBillboardSet()->setUseAccurateFacing(true); 134 this->setCastShadows(true); 135 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup()); 136 this->mesh_.setCastShadows(true); 137 } 134 138 } 135 this->init();136 139 } 137 140 … … 151 154 SUPER(Planet, XMLPort, xmlelement, mode); 152 155 153 if (GameMode::showsGraphics()) 154 { 155 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 156 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 157 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 158 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 159 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 160 } 156 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 157 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 158 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 159 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 160 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 161 161 } 162 162 … … 164 164 { 165 165 registerVariable(this->atmosphere_, VariableDirection::ToClient); 166 registerVariable(this->atmosphereSize, VariableDirection::ToClient); 167 registerVariable(this->imageSize, VariableDirection::ToClient); 168 // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards 166 169 registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh)); 167 170 registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows)); 168 registerVariable(this->atmosphereSize, VariableDirection::ToClient);169 registerVariable(this->imageSize, VariableDirection::ToClient);170 171 } 171 172 -
code/trunk/src/modules/objects/Planet.h
r6501 r7163 94 94 95 95 protected: 96 void registerVariables();97 96 98 97 private: 98 void registerVariables(); 99 99 100 100 void changedMesh(); -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
r5781 r7163 43 43 virtual ~BoxCollisionShape(); 44 44 45 void registerVariables();46 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 46 … … 67 66 68 67 private: 68 void registerVariables(); 69 69 70 btCollisionShape* createNewShape() const; 70 71 -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
r5781 r7163 41 41 virtual ~ConeCollisionShape(); 42 42 43 void registerVariables();44 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 44 … … 55 54 56 55 private: 56 void registerVariables(); 57 57 58 btCollisionShape* createNewShape() const; 58 59 -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
r5781 r7163 43 43 virtual ~PlaneCollisionShape(); 44 44 45 void registerVariables();46 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 46 … … 57 56 58 57 private: 58 void registerVariables(); 59 59 60 btCollisionShape* createNewShape()const; 60 61 -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
r5781 r7163 41 41 virtual ~SphereCollisionShape(); 42 42 43 void registerVariables();44 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 44 … … 50 49 51 50 private: 51 void registerVariables(); 52 52 53 btCollisionShape* createNewShape() const; 53 54 -
code/trunk/src/modules/objects/eventsystem/EventListener.cc
r6856 r7163 61 61 return; 62 62 } 63 63 64 64 COUT(4) << "EventListener, processing event: originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << ")" << ", activate: " << event.activate_ << ", name: " << event.name_ << std::endl; 65 65 -
code/trunk/src/modules/objects/triggers/CheckPoint.cc
r5929 r7163 38 38 CreateFactory(CheckPoint); 39 39 40 CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator) 40 CheckPoint::CheckPoint(BaseObject* creator) 41 : DistanceTrigger(creator) 42 , RadarViewable(creator, static_cast<WorldEntity*>(this)) 41 43 { 42 44 RegisterObject(CheckPoint); -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
- Property svn:eol-style set to native
r6906 r7163 40 40 namespace orxonox 41 41 { 42 42 43 43 CreateFactory(DistanceMultiTrigger); 44 44 45 45 /** 46 46 @brief 47 Default Constructor. Registers the object and initializes default values. 47 Default Constructor. Registers the object and initializes default values. 48 48 */ 49 49 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) 50 50 { 51 51 RegisterObject(DistanceMultiTrigger); 52 52 53 53 this->distance_ = 100.0f; 54 54 this->targetName_ = BLANKSTRING; … … 98 98 continue; 99 99 } 100 100 101 101 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 102 102 // If the object is no longer in range. … … 154 154 if(this->singleTargetMode_) 155 155 entity = entity->getParent(); 156 156 157 157 // If no queue has been created, yet. 158 158 if(queue == NULL) … … 166 166 } 167 167 } 168 168 169 169 return queue; 170 170 } 171 171 172 172 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
- Property svn:eol-style set to native
r6906 r7163 56 56 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 57 57 { 58 58 59 59 public: 60 60 DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values. 61 61 ~DistanceMultiTrigger(); //!< Destructor. 62 62 63 63 void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML. 64 64 … … 75 75 inline const std::string& getTargetName(void) 76 76 { return this->targetName_; } 77 77 78 78 /** 79 79 @brief Set the distance at which the DistanceMultiTrigger triggers. … … 88 88 inline float getDistance() const 89 89 { return this->distance_; } 90 90 91 91 protected: 92 92 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. … … 106 106 inline bool removeFromRange(WorldEntity* entity) 107 107 { WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; bool erased = this->range_.erase(entity) > 0; if(erased) delete weakptr; return erased; } 108 108 109 109 private: 110 110 float distance_; //!< The distance at which the DistanceMultiTrigger triggers. 111 111 std::string targetName_; //!< The target name, used in singleTargetMode. 112 112 bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in single-target-mode. 113 113 114 114 std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger. 115 115 116 116 }; 117 117 118 118 } 119 119 -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r6906 r7163 136 136 continue; 137 137 } 138 138 139 139 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 140 140 if (distanceVec.length() < this->distance_) … … 155 155 } 156 156 } 157 157 158 return false; 158 159 } -
code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc
- Property svn:eol-style set to native
r6906 r7163 35 35 36 36 CreateFactory(DistanceTriggerBeacon); 37 37 38 38 DistanceTriggerBeacon::DistanceTriggerBeacon(BaseObject* creator) : StaticEntity(creator) 39 39 { 40 40 RegisterObject(DistanceTriggerBeacon); 41 41 } 42 42 43 43 } -
code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h
- Property svn:eol-style set to native
r6906 r7163 39 39 class _ObjectsExport DistanceTriggerBeacon : public StaticEntity 40 40 { 41 41 42 42 public: 43 43 -
code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc
- Property svn:eol-style set to native
r6864 r7163 52 52 EventMultiTrigger::~EventMultiTrigger() 53 53 { 54 54 55 55 } 56 56 … … 61 61 this->setBroadcast(true); 62 62 } 63 63 64 64 void EventMultiTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 65 65 { -
code/trunk/src/modules/objects/triggers/EventMultiTrigger.h
- Property svn:eol-style set to native
r6864 r7163 44 44 class _ObjectsExport EventMultiTrigger : public MultiTrigger 45 45 { 46 46 47 47 public: 48 48 EventMultiTrigger(BaseObject* creator); -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
- Property svn:eol-style set to native
r6864 r7163 47 47 /*static*/ const std::string MultiTrigger::or_s = "or"; 48 48 /*static*/ const std::string MultiTrigger::xor_s = "xor"; 49 49 50 50 CreateFactory(MultiTrigger); 51 51 … … 65 65 this->bSwitch_ = false; 66 66 this->bStayActive_ = false; 67 67 68 68 this->remainingActivations_ = INF_s; 69 69 this->maxNumSimultaniousTriggerers_ = INF_s; … … 75 75 76 76 this->parentTrigger_ = NULL; 77 77 78 78 this->targetMask_.exclude(Class(BaseObject)); 79 79 80 80 this->setSyncMode(0x0); 81 81 } 82 82 83 83 /** 84 84 @brief … … 95 95 } 96 96 } 97 97 98 98 /** 99 99 @brief … … 117 117 //TODO: Maybe nicer with explicit subgroup, e.g. triggers 118 118 XMLPortObject(MultiTrigger, MultiTrigger, "", addTrigger, getTrigger, xmlelement, mode); 119 119 120 120 COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") created." << std::endl; 121 121 } 122 122 123 123 124 124 /** … … 131 131 { 132 132 // If this is the first tick. 133 //TODO: Determine need for this, else kick it out. 133 //TODO: Determine need for this, else kick it out. 134 134 if(this->bFirstTick_) 135 135 { … … 174 174 delete state; 175 175 } 176 176 177 177 queue->pop(); 178 178 } … … 185 185 MultiTriggerState* state; 186 186 float timeRemaining; 187 187 188 188 // Go through all pending states. 189 189 for(int size = this->stateQueue_.size(); size >= 1; size--) … … 212 212 this->triggered_.erase(state->originator); 213 213 } 214 214 215 215 bStateChanged = true; 216 216 } … … 229 229 230 230 bool bFire = true; 231 231 232 232 // Add the originator to the objects activating this MultiTrigger. 233 233 if(bActive == true) … … 266 266 else 267 267 this->fire(bActive, state->originator); 268 268 269 269 bStateChanged = true; 270 270 } … … 289 289 } 290 290 } 291 291 292 292 // Remove the state from the state queue. 293 293 this->stateQueue_.pop_front(); … … 509 509 return returnVal; 510 510 } 511 511 512 512 return true; 513 513 } 514 514 515 515 /** 516 516 @brief … … 547 547 return; 548 548 } 549 549 550 550 MultiTriggerContainer* container = new MultiTriggerContainer(this, this, originator); 551 551 this->fireEvent(status, container); … … 563 563 { 564 564 ClassTreeMask& targetMask = this->getTargetMask(); 565 565 566 566 for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it) 567 567 { … … 580 580 { 581 581 assert(state); 582 582 583 583 // If the originator is no target of this MultiTrigger. 584 584 if(!this->isTarget(state->originator)) 585 585 return false; 586 586 587 587 // Add it ot the state queue. 588 588 this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->delay_, state)); -
code/trunk/src/modules/objects/triggers/MultiTrigger.h
- Property svn:eol-style set to native
r6864 r7163 94 94 MultiTrigger(BaseObject* creator); //!< Constructor. Registers the objects and initializes default values. 95 95 ~MultiTrigger(); //!< Destructor. 96 96 97 97 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a MultiTrigger object through XML. 98 98 virtual void tick(float dt); //!< A method that is executed each tick. 99 99 100 100 bool isActive(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is active for a given object. 101 101 … … 215 215 void addTargets(const std::string& targets); //!< Add some target to the MultiTrigger. 216 216 void removeTargets(const std::string& targets); //!< Remove some target from the MultiTrigger. 217 217 218 218 void addTrigger(MultiTrigger* trigger); //!< Adds a MultiTrigger as a sub-trigger to the trigger. 219 219 const MultiTrigger* getTrigger(unsigned int index) const; //!< Get the sub-trigger of this MultiTrigger at the given index. 220 220 221 221 protected: 222 222 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. 223 223 224 224 void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator. 225 225 226 226 bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers. 227 227 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object. … … 236 236 inline void addParentTrigger(MultiTrigger* parent) 237 237 { this->parentTrigger_ = parent; } 238 238 239 239 /** 240 240 @brief Get the target mask used to identify the targets of this MultiTrigger. … … 248 248 //TODO: Check if something mus be done here. 249 249 virtual void notifyMaskUpdate(void) {} 250 250 251 251 private: 252 252 static const int INF_s; //!< Magic number for infinity. … … 257 257 258 258 void subTrigggerActivityChanged(BaseObject* originator); //!< This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger. 259 259 260 260 bool addState(MultiTriggerState* state); //!< Helper method. Adds a state to the state queue, where the state will wait to become active. 261 261 262 262 bool checkAnd(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'and' mode for a given object. 263 263 bool checkOr(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'or' mode for a given object. … … 276 276 bool bSwitch_; //!< Bool for the switch-mode, if true the MultiTrigger behaves like a switch. 277 277 bool bStayActive_; //!< Bool for the stay-active-mode, if true the MultiTrigger stays active after its last activation.; 278 278 279 279 int remainingActivations_; //!< The remaining activations of this MultiTrigger. 280 280 int maxNumSimultaniousTriggerers_; //!< The maximum number of objects simultaniously trigggering this MultiTrigger. … … 287 287 MultiTrigger* parentTrigger_; 288 288 std::set<MultiTrigger*> subTriggers_; //!< The sub-triggers of this MultiTrigger. 289 289 290 290 std::set<BaseObject*> active_; //!< The set of all objects the MultiTrigger is active for. 291 291 std::set<BaseObject*> triggered_; //!< The set of all objects the MultiTrigger is triggered for. 292 292 293 293 std::deque< std::pair<float, MultiTriggerState*> > stateQueue_; //!< The queue of states waiting to become active. 294 294 295 295 ClassTreeMask targetMask_; //!< The target mask, masking all objects that can trigger this MultiTrigger. 296 296 297 297 }; 298 298 -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
- Property svn:eol-style set to native
r6859 r7163 40 40 41 41 CreateUnloadableFactory(MultiTriggerContainer); 42 42 43 43 /** 44 44 @brief … … 73 73 MultiTriggerContainer::~MultiTriggerContainer() 74 74 { 75 75 76 76 } 77 77 -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.h
- Property svn:eol-style set to native
r6856 r7163 50 50 class _ObjectsExport MultiTriggerContainer : public BaseObject 51 51 { 52 52 53 53 public: 54 54 MultiTriggerContainer(BaseObject* creator); //!< Default constructor. Registers the object and creates an empty container. … … 68 68 inline BaseObject* getData(void) 69 69 { return this->data_; } 70 70 71 71 private: 72 72 MultiTrigger* originator_; //!< The originator. 73 73 BaseObject* data_; //!< The data. 74 74 }; 75 75 76 76 } 77 77 -
code/trunk/src/modules/overlays/CMakeLists.txt
r5781 r7163 14 14 PCH_FILE 15 15 OverlaysPrecompiledHeaders.h 16 DEFINE_SYMBOL17 "OVERLAYS_SHARED_BUILD"18 16 LINK_LIBRARIES 19 17 orxonox -
code/trunk/src/modules/overlays/GUIOverlay.cc
r6799 r7163 30 30 31 31 #include <string> 32 #include <sstream>33 32 33 #include "util/Convert.h" 34 34 #include "core/input/InputManager.h" 35 35 #include "core/CoreIncludes.h" … … 73 73 if (this->isVisible()) 74 74 { 75 std::ostringstream out; 76 out << reinterpret_cast<long>(this); 77 const std::string& str = out.str(); 75 const std::string& str = multi_cast<std::string>(reinterpret_cast<long>(this)); 78 76 GUIManager::getInstance().showGUIExtra(this->guiName_, str); 79 77 -
code/trunk/src/modules/overlays/OverlaysPrereqs.h
r5929 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(O RXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(OVERLAYS_STATIC_BUILD) 46 46 # ifdef OVERLAYS_SHARED_BUILD 47 47 # define _OverlaysExport __declspec(dllexport) … … 78 78 class ChatOverlay; 79 79 class DeathMessage; 80 class GametypeFadingMessage; 81 class GametypeStaticMessage; 80 82 class GametypeStatus; 81 83 class HUDBar; -
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r5781 r7163 13 13 UnderAttackHealthBar.cc 14 14 TeamBaseMatchScore.cc 15 GametypeStaticMessage.cc 16 GametypeFadingMessage.cc 15 17 ) -
code/trunk/src/modules/overlays/hud/GametypeStatus.cc
r5781 r7163 30 30 31 31 #include "util/Convert.h" 32 #include "core/ConsoleCommand.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "infos/GametypeInfo.h" … … 39 40 { 40 41 CreateFactory(GametypeStatus); 42 43 /*static*/ bool GametypeStatus::noCaption_s = false; 44 SetConsoleCommand(GametypeStatus, setGametypeStatus, true); 41 45 42 46 GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator) … … 59 63 const GametypeInfo* gtinfo = this->owner_->getGametypeInfo(); 60 64 ControllableEntity* ce = this->owner_->getControllableEntity(); 65 66 if(GametypeStatus::noCaption_s) // No captions are displayed. 67 { 68 this->setCaption(""); 69 return; 70 } 61 71 62 72 if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning()) … … 88 98 this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner()); 89 99 } 100 101 /** 102 @brief 103 Sets whether the gametype status is displayed. 104 @param bValue 105 If true captions are displayed, if false, not. 106 */ 107 /*static*/ void GametypeStatus::setGametypeStatus(bool bValue) 108 { 109 GametypeStatus::noCaption_s = !bValue; 110 } 111 90 112 } -
code/trunk/src/modules/overlays/hud/GametypeStatus.h
r5781 r7163 46 46 virtual void changedOwner(); 47 47 48 static void setGametypeStatus(bool bValue); //!< Toggles whether the gametype status is displayed. 49 48 50 private: 49 51 PlayerInfo* owner_; 52 static bool noCaption_s; 53 50 54 }; 51 55 } -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r6502 r7163 29 29 #include "HUDNavigation.h" 30 30 31 #include <string>32 31 #include <OgreCamera.h> 32 #include <OgreFontManager.h> 33 33 #include <OgreOverlayManager.h> 34 34 #include <OgreTextAreaOverlayElement.h> … … 45 45 #include "controllers/HumanController.h" 46 46 #include "worldentities/pawns/Pawn.h" 47 #include "worldentities/WorldEntity.h" 48 #include "core/ConfigValueIncludes.h" 49 #include "tools/TextureGenerator.h" 50 // #include <boost/bind/bind_template.hpp> 51 47 52 48 53 namespace orxonox 49 54 { 50 CreateFactory(HUDNavigation); 51 52 HUDNavigation::HUDNavigation(BaseObject* creator) 53 : OrxonoxOverlay(creator) 54 { 55 RegisterObject(HUDNavigation); 56 57 // create nav text 58 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 59 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 60 61 // create nav marker 62 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 63 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 64 navMarker_->setMaterialName("Orxonox/NavArrows"); 65 66 /* 67 // create aim marker 68 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 69 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString())); 70 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 71 this->wasOutOfView_ = true; // Ensure the material is changed right the first time.. 72 73 setFont("Monofur"); 74 setTextSize(0.05f); 75 setNavMarkerSize(0.05f); 76 setAimMarkerSize(0.04f); 77 */ 78 79 background_->addChild(navMarker_); 80 // background_->addChild(aimMarker_); 81 background_->addChild(navText_); 82 83 // hide at first 84 this->setVisible(false); 85 } 86 87 HUDNavigation::~HUDNavigation() 88 { 89 if (this->isInitialized()) 55 bool compareDistance ( std::pair<RadarViewable*, unsigned int > a, std::pair<RadarViewable*, unsigned int > b ) 56 { 57 return a.second<b.second; 58 59 } 60 61 void HUDNavigation::setConfigValues() 62 { 63 SetConfigValue(markerLimit_, 3); 64 } 65 66 CreateFactory ( HUDNavigation ); 67 68 HUDNavigation::HUDNavigation ( BaseObject* creator ) 69 : OrxonoxOverlay ( creator ) 70 { 71 RegisterObject ( HUDNavigation ); 72 this->setConfigValues(); 73 74 // Set default values 75 setFont ( "Monofur" ); 76 setTextSize ( 0.05f ); 77 setNavMarkerSize ( 0.05f ); 78 } 79 80 HUDNavigation::~HUDNavigation() 81 { 82 if ( this->isInitialized() ) 83 { 84 for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ) 85 removeObject ( ( it++ )->first ); 86 87 } 88 89 sortedObjectList_.clear(); 90 } 91 92 void HUDNavigation::XMLPort ( Element& xmlElement, XMLPort::Mode mode ) 93 { 94 SUPER ( HUDNavigation, XMLPort, xmlElement, mode ); 95 96 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlElement, mode ); 97 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode ); 98 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode ); 99 } 100 101 void HUDNavigation::setFont ( const std::string& font ) 102 { 103 const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName ( font ); 104 if ( fontPtr.isNull() ) 105 { 106 COUT ( 2 ) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl; 107 return; 108 } 109 fontName_ = font; 110 for ( ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it ) 111 { 112 if ( it->second.text_ != NULL ) 113 it->second.text_->setFontName ( fontName_ ); 114 } 115 } 116 117 const std::string& HUDNavigation::getFont() const 118 { 119 return fontName_; 120 } 121 122 void HUDNavigation::setTextSize ( float size ) 123 { 124 if ( size <= 0.0f ) 125 { 126 COUT ( 2 ) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl; 127 return; 128 } 129 textSize_ = size; 130 for ( ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it ) 131 { 132 if ( it->second.text_ ) 133 it->second.text_->setCharHeight ( size ); 134 } 135 } 136 137 float HUDNavigation::getTextSize() const 138 { 139 return textSize_; 140 } 141 142 143 144 void HUDNavigation::tick ( float dt ) 145 { 146 SUPER ( HUDNavigation, tick, dt ); 147 148 Camera* cam = CameraManager::getInstance().getActiveCamera(); 149 if ( cam == NULL ) 150 return; 151 const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 152 153 154 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt ) 155 { 156 listIt->second = ( int ) ( ( listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition() ).length() + 0.5f ); 157 } 158 159 sortedObjectList_.sort ( compareDistance ); 160 161 unsigned int markerCount_ = 0; 162 163 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 164 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) 165 { 166 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 167 168 if ( markerCount_ < markerLimit_ ) 90 169 { 91 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 92 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 93 // Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 94 } 95 } 96 97 void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode) 98 { 99 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 100 101 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 102 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 103 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 104 // XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 105 } 106 107 void HUDNavigation::setFont(const std::string& font) 108 { 109 if (this->navText_ && !font.empty()) 110 this->navText_->setFontName(font); 111 } 112 113 const std::string& HUDNavigation::getFont() const 114 { 115 if (this->navText_) 116 return this->navText_->getFontName(); 117 else 118 return BLANKSTRING; 119 } 120 121 void HUDNavigation::setTextSize(float size) 122 { 123 if (this->navText_ && size >= 0.0f) 124 this->navText_->setCharHeight(size); 125 } 126 127 float HUDNavigation::getTextSize() const 128 { 129 if (this->navText_) 130 return this->navText_->getCharHeight(); 131 else 132 return 0.0f; 133 } 134 135 void HUDNavigation::tick(float dt) 136 { 137 SUPER(HUDNavigation, tick, dt); 138 139 // Get radar 140 Radar* radar = this->getOwner()->getScene()->getRadar(); 141 142 if (!radar->getFocus()) 143 { 144 this->overlay_->hide(); 145 return; 146 } 147 else 148 { 149 this->overlay_->show(); 150 } 151 152 // set text 153 int dist = static_cast<int>(getDist2Focus()); 154 navText_->setCaption(multi_cast<std::string>(dist)); 155 float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3f; 156 157 orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera(); 158 if (!cam) 159 return; 160 const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 161 // transform to screen coordinates 162 Vector3 pos = transform * radar->getFocus()->getRVWorldPosition(); 163 164 bool outOfView; 165 if (pos.z > 1.0) 166 { 167 // z > 1.0 means that the object is behind the camera 168 outOfView = true; 169 // we have to switch all coordinates (if you don't know why, 170 // try linear algebra lectures, because I can't explain..) 171 pos.x = -pos.x; 172 pos.y = -pos.y; 173 } 174 else 175 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 176 177 if (outOfView) 178 { 179 // object is not in view 180 // aimMarker_->hide(); 181 182 if (!wasOutOfView_) 170 171 172 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 173 int dist = listIt->second; 174 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 175 float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 176 177 // Transform to screen coordinates 178 Vector3 pos = camTransform * it->first->getRVWorldPosition(); 179 180 bool outOfView = true; 181 if ( pos.z > 1.0 ) 183 182 { 184 navMarker_->setMaterialName("Orxonox/NavArrows"); 185 wasOutOfView_ = true; 183 // z > 1.0 means that the object is behind the camera 184 outOfView = true; 185 // we have to switch all coordinates (if you don't know why, 186 // try linear algebra lectures, because I can't explain..) 187 pos.x = -pos.x; 188 pos.y = -pos.y; 186 189 } 187 188 if (pos.x < pos.y) 190 else 191 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 192 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 193 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 194 195 if ( outOfView ) 189 196 { 190 if (pos.y > -pos.x) 197 // Object is not in view 198 199 // Change material only if outOfView changed 200 if ( !it->second.wasOutOfView_ ) 191 201 { 192 // up 193 float position = pos.x / pos.y + 1.0f; 194 navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5f, 0.0f); 195 navMarker_->setUV(0.5f, 0.0f, 1.0f, 0.5f); 196 navText_->setLeft((position - textLength) * 0.5f); 197 navText_->setTop(navMarker_->getHeight()); 202 it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "arrows.tga", it->first->getRadarObjectColour()) ); 203 it->second.wasOutOfView_ = true; 198 204 } 205 206 // Switch between top, bottom, left and right position of the arrow at the screen border 207 if ( pos.x < pos.y ) 208 { 209 if ( pos.y > -pos.x ) 210 { 211 // Top 212 float position = pos.x / pos.y + 1.0f; 213 it->second.panel_->setPosition ( ( position - it->second.panel_->getWidth() ) * 0.5f, 0.0f ); 214 it->second.panel_->setUV ( 0.5f, 0.0f, 1.0f, 0.5f ); 215 it->second.text_->setLeft ( ( position - textLength ) * 0.5f ); 216 it->second.text_->setTop ( it->second.panel_->getHeight() ); 217 } 218 else 219 { 220 // Left 221 float position = pos.y / pos.x + 1.0f; 222 it->second.panel_->setPosition ( 0.0f, ( position - it->second.panel_->getWidth() ) * 0.5f ); 223 it->second.panel_->setUV ( 0.0f, 0.0f, 0.5f, 0.5f ); 224 it->second.text_->setLeft ( it->second.panel_->getWidth() + 0.01f ); 225 it->second.text_->setTop ( ( position - it->second.text_->getCharHeight() ) * 0.5f ); 226 } 227 } 228 199 229 else 200 230 { 201 // left 202 float position = pos.y / pos.x + 1.0f; 203 navMarker_->setPosition(0.0f, (position - navMarker_->getWidth()) * 0.5f); 204 navMarker_->setUV(0.0f, 0.0f, 0.5f, 0.5f); 205 navText_->setLeft(navMarker_->getWidth() + 0.01f); 206 navText_->setTop((position - navText_->getCharHeight()) * 0.5f); 231 232 if ( pos.y < -pos.x ) 233 { 234 // Bottom 235 float position = -pos.x / pos.y + 1.0f; 236 it->second.panel_->setPosition ( ( position - it->second.panel_->getWidth() ) * 0.5f, 1.0f - it->second.panel_->getHeight() ); 237 it->second.panel_->setUV ( 0.0f, 0.5f, 0.5f, 1.0f ); 238 it->second.text_->setLeft ( ( position - textLength ) * 0.5f ); 239 it->second.text_->setTop ( 1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight() ); 240 } 241 else 242 { 243 // Right 244 float position = -pos.y / pos.x + 1.0f; 245 it->second.panel_->setPosition ( 1.0f - it->second.panel_->getWidth(), ( position - it->second.panel_->getHeight() ) * 0.5f ); 246 it->second.panel_->setUV ( 0.5f, 0.5f, 1.0f, 1.0f ); 247 it->second.text_->setLeft ( 1.0f - it->second.panel_->getWidth() - textLength - 0.01f ); 248 it->second.text_->setTop ( ( position - it->second.text_->getCharHeight() ) * 0.5f ); 249 } 207 250 } 208 251 } 209 252 else 210 253 { 211 if (pos.y < -pos.x) 254 // Object is in view 255 256 // Change material only if outOfView changed 257 if ( it->second.wasOutOfView_ ) 212 258 { 213 // down 214 float position = -pos.x / pos.y + 1.0f; 215 navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5f, 1.0f - navMarker_->getHeight()); 216 navMarker_->setUV(0.0f, 0.5f, 0.5f, 1.0f); 217 navText_->setLeft((position - textLength) * 0.5f); 218 navText_->setTop(1.0f - navMarker_->getHeight() - navText_->getCharHeight()); 259 //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" ); 260 it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.tga", it->first->getRadarObjectColour()) ); 261 it->second.wasOutOfView_ = false; 219 262 } 220 else 221 {222 // right223 float position = -pos.y / pos.x + 1.0f;224 navMarker_->setPosition(1.0f - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5f);225 navMarker_->setUV(0.5f, 0.5f, 1.0f, 1.0f); 226 navText_->setLeft(1.0f - navMarker_->getWidth() - textLength - 0.01f);227 navText_->setTop((position - navText_->getCharHeight()) * 0.5f);228 }263 264 // Position marker 265 it->second.panel_->setUV ( 0.0f, 0.0f, 1.0f, 1.0f ); 266 it->second.panel_->setLeft ( ( pos.x + 1.0f - it->second.panel_->getWidth() ) * 0.5f ); 267 it->second.panel_->setTop ( ( -pos.y + 1.0f - it->second.panel_->getHeight() ) * 0.5f ); 268 269 // Position text 270 it->second.text_->setLeft ( ( pos.x + 1.0f + it->second.panel_->getWidth() ) * 0.5f ); 271 it->second.text_->setTop ( ( -pos.y + 1.0f + it->second.panel_->getHeight() ) * 0.5f ); 229 272 } 273 274 // Make sure the overlays are shown 275 it->second.panel_->show(); 276 it->second.text_->show(); 230 277 } 231 278 else 232 279 { 233 // object is in view 234 /* 235 Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 236 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 280 it->second.panel_->hide(); 281 it->second.text_->hide(); 282 } 283 284 } 285 } 286 287 288 /** Overridden method of OrxonoxOverlay. 289 @details 290 Usually the entire overlay scales with scale(). 291 Here we obviously have to adjust this. 237 292 */ 238 if (wasOutOfView_) 239 { 240 navMarker_->setMaterialName("Orxonox/NavTDC"); 241 wasOutOfView_ = false; 242 } 243 244 // object is in view 245 navMarker_->setUV(0.0f, 0.0f, 1.0f, 1.0f); 246 navMarker_->setLeft((pos.x + 1.0f - navMarker_->getWidth()) * 0.5f); 247 navMarker_->setTop((-pos.y + 1.0f - navMarker_->getHeight()) * 0.5f); 248 249 /* 250 aimMarker_->show(); 251 aimMarker_->setLeft((aimpos.x + 1.0f - aimMarker_->getWidth()) * 0.5f); 252 aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f); 253 */ 254 navText_->setLeft((pos.x + 1.0f + navMarker_->getWidth()) * 0.5f); 255 navText_->setTop((-pos.y + 1.0f + navMarker_->getHeight()) * 0.5f); 293 void HUDNavigation::sizeChanged() 294 { 295 // Use size to compensate for aspect ratio if enabled. 296 float xScale = this->getActualSize().x; 297 float yScale = this->getActualSize().y; 298 299 for ( ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it ) 300 { 301 if ( it->second.panel_ != NULL ) 302 it->second.panel_->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale ); 303 if ( it->second.text_ != NULL ) 304 it->second.text_->setCharHeight ( it->second.text_->getCharHeight() * yScale ); 305 } 306 } 307 308 void HUDNavigation::addObject ( RadarViewable* object ) 309 { 310 if( showObject(object)==false ) 311 return; 312 313 if ( activeObjectList_.size() >= markerLimit_ ) 314 if ( object == NULL ) 315 return; 316 317 // Object hasn't been added yet (we know that) 318 assert ( this->activeObjectList_.find ( object ) == this->activeObjectList_.end() ); 319 320 // Scales used for dimensions and text size 321 float xScale = this->getActualSize().x; 322 float yScale = this->getActualSize().y; 323 324 // Create everything needed to display the object on the radar and add it to the map 325 326 // Create arrow/marker 327 Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*> ( Ogre::OverlayManager::getSingleton() 328 .createOverlayElement ( "Panel", "HUDNavigation_navMarker_" + getUniqueNumberString() ) ); 329 // panel->setMaterialName ( "Orxonox/NavTDC" ); 330 panel->setMaterialName( TextureGenerator::getMaterialName( "tdc.tga", object->getRadarObjectColour()) ); 331 panel->setDimensions ( navMarkerSize_ * xScale, navMarkerSize_ * yScale ); 332 // panel->setColour( object->getRadarObjectColour() ); 333 334 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*> ( Ogre::OverlayManager::getSingleton() 335 .createOverlayElement ( "TextArea", "HUDNavigation_navText_" + getUniqueNumberString() ) ); 336 text->setFontName ( this->fontName_ ); 337 text->setCharHeight ( text->getCharHeight() * yScale ); 338 text->setColour( object->getRadarObjectColour() ); 339 340 panel->hide(); 341 text->hide(); 342 343 ObjectInfo tempStruct = {panel, text, false}; 344 activeObjectList_[object] = tempStruct; 345 346 this->background_->addChild ( panel ); 347 this->background_->addChild ( text ); 348 349 sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) ); 350 351 352 } 353 354 void HUDNavigation::removeObject ( RadarViewable* viewable ) 355 { 356 ObjectMap::iterator it = activeObjectList_.find ( viewable ); 357 358 if ( activeObjectList_.find ( viewable ) != activeObjectList_.end() ) 359 { 360 // Detach overlays 361 this->background_->removeChild ( it->second.panel_->getName() ); 362 this->background_->removeChild ( it->second.text_->getName() ); 363 // Properly destroy the overlay elements (do not use delete!) 364 Ogre::OverlayManager::getSingleton().destroyOverlayElement ( it->second.panel_ ); 365 Ogre::OverlayManager::getSingleton().destroyOverlayElement ( it->second.text_ ); 366 // Remove from the list 367 activeObjectList_.erase ( viewable ); 368 369 370 } 371 372 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt ) 373 { 374 if ( (listIt->first) == viewable ) 375 { 376 sortedObjectList_.erase ( listIt ); 377 break; 256 378 } 257 } 258 259 float HUDNavigation::getDist2Focus() const 260 { 261 Radar* radar = this->getOwner()->getScene()->getRadar(); 262 if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn()) 263 return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length(); 264 else 265 return 0; 266 } 267 268 /** 269 @brief Overridden method of OrxonoxOverlay. Usually the entire overlay 270 scales with scale(). Here we obviously have to adjust this. 271 */ 272 void HUDNavigation::sizeChanged() 273 { 274 // use size to compensate for aspect ratio if enabled. 275 float xScale = this->getActualSize().x; 276 float yScale = this->getActualSize().y; 277 if (this->navMarker_) 278 navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale); 279 /* 280 if (this->aimMarker_) 281 aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale); 282 */ 283 if (this->navText_) 284 navText_->setCharHeight(navText_->getCharHeight() * yScale); 285 } 286 } 379 380 } 381 382 } 383 384 void HUDNavigation::objectChanged(RadarViewable* viewable) 385 { 386 // TODO: niceification neccessary ;) 387 removeObject(viewable); 388 addObject(viewable); 389 } 390 391 392 bool HUDNavigation::showObject(RadarViewable* rv) 393 { 394 if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) ) 395 return false; 396 assert( rv->getWorldEntity() ); 397 if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false ) 398 return false; 399 return true; 400 } 401 402 void HUDNavigation::changedOwner() 403 { 404 405 const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects(); 406 for ( std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it ) 407 { 408 if ( ! ( *it )->isHumanShip_ ) 409 this->addObject ( *it ); 410 } 411 } 412 } -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r6417 r7163 32 32 #include "overlays/OverlaysPrereqs.h" 33 33 34 #include <map> 35 #include <string> 36 37 34 38 #include "util/OgreForwardRefs.h" 35 39 #include "tools/interfaces/Tickable.h" 40 #include "interfaces/RadarListener.h" 36 41 #include "overlays/OrxonoxOverlay.h" 37 42 38 43 namespace orxonox 39 44 { 40 class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable 45 class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener 46 { 47 public: 48 HUDNavigation ( BaseObject* creator ); 49 virtual ~HUDNavigation(); 50 51 void setConfigValues(); 52 53 virtual void XMLPort ( Element& xmlElement, XMLPort::Mode mode ); 54 virtual void tick ( float dt ); 55 56 virtual void addObject ( RadarViewable* object ); 57 virtual void removeObject ( RadarViewable* viewable ); 58 virtual void objectChanged ( RadarViewable* viewable ); 59 60 virtual void changedOwner(); 61 virtual void sizeChanged(); 62 virtual void angleChanged() { } 63 virtual void positionChanged() { } 64 virtual void radarTick ( float dt ) {} 65 66 inline float getRadarSensitivity() const 67 { return 1.0f; } 68 69 private: 70 struct ObjectInfo 41 71 { 42 public: 43 HUDNavigation(BaseObject* creator); 44 virtual ~HUDNavigation(); 72 Ogre::PanelOverlayElement* panel_; 73 Ogre::TextAreaOverlayElement* text_; 74 bool outOfView_; 75 bool wasOutOfView_; 45 76 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 virtual void tick(float dt); 77 }; 48 78 49 private: 50 void sizeChanged(); 51 void angleChanged() { } 52 void positionChanged() { } 79 bool showObject( RadarViewable* rv ); 53 80 54 // XMLPort accessors 55 void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); } 56 float getNavMarkerSize() const { return this->navMarkerSize_; } 81 // XMLPort accessors 82 void setNavMarkerSize ( float size ) 83 { navMarkerSize_ = size; this->sizeChanged(); } 84 float getNavMarkerSize() const 85 { return navMarkerSize_; } 57 86 58 /* 59 void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); } 60 float getAimMarkerSize() const { return this->aimMarkerSize_; } 61 */ 87 void setTextSize ( float size ); 88 float getTextSize() const; 62 89 63 void setTextSize(float size);64 float getTextSize() const;90 void setFont ( const std::string& font ); 91 const std::string& getFont() const; 65 92 66 void setFont(const std::string& font);67 const std::string& getFont() const;93 typedef std::map<RadarViewable*, ObjectInfo > ObjectMap; 94 ObjectMap activeObjectList_; 68 95 69 void updateMarker(); 70 void updateFocus(); 71 float getDist2Focus() const; 96 typedef std::list < std::pair<RadarViewable*, unsigned int > > sortedList; 97 sortedList sortedObjectList_; 72 98 73 Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker 74 float navMarkerSize_; //!< One paramter size of the navigation marker75 /* 76 Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker77 float aimMarkerSize_; //!< One paramter size of the aim marker 78 */ 79 Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance 80 bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap 81 99 100 float navMarkerSize_; 101 std::string fontName_; 102 float textSize_; 103 104 unsigned int markerLimit_;; //TODO: is it possible to set this over the console and/or the IG-Setting 105 106 107 }; 82 108 } 83 109 -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r6502 r7163 40 40 #include "worldentities/WorldEntity.h" 41 41 #include "worldentities/pawns/Pawn.h" 42 #include "Scene.h" 43 #include "Radar.h" 42 44 43 45 namespace orxonox … … 72 74 { 73 75 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 74 for (std:: vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();75 it != this->radar Dots_.end(); ++it)76 for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin(); 77 it != this->radarObjects_.end(); ++it) 76 78 { 77 Ogre::OverlayManager::getSingleton().destroyOverlayElement( *it);79 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second); 78 80 } 79 81 } … … 89 91 } 90 92 91 void HUDRadar:: displayObject(RadarViewable* object, bool bIsMarked)93 void HUDRadar::addObject(RadarViewable* object) 92 94 { 93 if (object == static_cast<RadarViewable*>(this->owner_))95 if (object == dynamic_cast<RadarViewable*>(this->owner_)) 94 96 return; 95 97 96 const WorldEntity* wePointer = object->getWorldEntity(); 98 // Make sure the object hasn't been added yet 99 assert( this->radarObjects_.find(object) == this->radarObjects_.end() ); 97 100 98 // Just to be sure that we actually have a WorldEntity. 99 // We could do a dynamic_cast, but that would be a lot slower. 100 if (!wePointer || !this->owner_) 101 // Create everything needed to display the object on the radar and add it to the map 102 Ogre::PanelOverlayElement* panel; 103 panel = static_cast<Ogre::PanelOverlayElement*>( 104 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString())); 105 this->overlay_->add2D(panel); 106 // get right material 107 panel->setMaterialName(TextureGenerator::getMaterialName( 108 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour())); 109 this->radarObjects_[object] = panel; 110 } 111 112 void HUDRadar::removeObject(RadarViewable* object) 113 { 114 // If object was added at all then remove it 115 std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it; 116 it = this->radarObjects_.find( object ); 117 if( it != this->radarObjects_.end() ) 101 118 { 102 if (!wePointer) 103 CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 104 if (!this->owner_) 105 CCOUT(2) << "No owner defined" << std::endl; 119 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second); 120 this->radarObjects_.erase(it); 121 } 122 } 123 124 void HUDRadar::objectChanged( RadarViewable* rv ) 125 { 126 if (rv == dynamic_cast<RadarViewable*>(this->owner_)) 106 127 return; 107 } 128 assert( this->radarObjects_.find(rv) != this->radarObjects_.end() ); 129 Ogre::PanelOverlayElement* panel = this->radarObjects_[rv]; 130 panel->setMaterialName(TextureGenerator::getMaterialName( 131 shapeMaterials_[rv->getRadarObjectShape()], rv->getRadarObjectColour())); 132 } 108 133 109 // try to find a panel already created 110 Ogre::PanelOverlayElement* panel; 111 //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object); 112 if (itRadarDots_ == this->radarDots_.end()) 113 { 114 // we have to create a new entry 115 panel = static_cast<Ogre::PanelOverlayElement*>( 116 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString())); 117 radarDots_.push_back(panel); 118 // get right material 119 panel->setMaterialName(TextureGenerator::getMaterialName( 120 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour())); 121 this->overlay_->add2D(panel); 122 this->itRadarDots_ = this->radarDots_.end(); 123 } 124 else 125 { 126 panel = *itRadarDots_; 127 ++itRadarDots_; 128 const std::string& materialName = TextureGenerator::getMaterialName( 129 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()); 130 if (materialName != panel->getMaterialName()) 131 panel->setMaterialName(materialName); 132 } 133 panel->show(); 134 135 // set size to fit distance... 136 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 137 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 138 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance); 139 panel->setDimensions(size, size); 140 141 // calc position on radar... 142 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 143 coord *= Ogre::Math::PI / 3.5f; // small adjustment to make it fit the texture 144 panel->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 145 146 if (bIsMarked) 147 { 148 this->marker_->show(); 149 this->marker_->setDimensions(size * 1.5f, size * 1.5f); 150 this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f); 151 } 134 void HUDRadar::gatherObjects() 135 { 136 const std::set<RadarViewable*>& objectSet = this->getCreator()->getScene()->getRadar()->getRadarObjects(); 137 std::set<RadarViewable*>::const_iterator it; 138 for( it=objectSet.begin(); it!=objectSet.end(); ++it ) 139 this->addObject(*it); 152 140 } 153 141 154 142 void HUDRadar::radarTick(float dt) 155 143 { 156 for (itRadarDots_ = radarDots_.begin(); itRadarDots_ != radarDots_.end(); ++itRadarDots_) 157 (*itRadarDots_)->hide(); 158 this->itRadarDots_ = this->radarDots_.begin(); 159 this->marker_->hide(); 144 // Make sure the owner of the radar was defined 145 if( !this->owner_ ) 146 { 147 CCOUT(0) << "No owner defined" << std::endl; 148 assert(0); 149 } 150 151 this->marker_->hide(); // in case that no object is in focus 152 // get the focus object 153 Radar* radar = this->getOwner()->getScene()->getRadar(); 154 const RadarViewable* focusObject = radar->getFocus(); 155 156 // update the distances for all objects 157 std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it; 158 for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it ) 159 { 160 // Make sure the object really is a WorldEntity 161 const WorldEntity* wePointer = it->first->getWorldEntity(); 162 if( !wePointer ) 163 { 164 CCOUT(0) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 165 assert(0); 166 } 167 bool isFocus = (it->first == focusObject); 168 // set size to fit distance... 169 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 170 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 171 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance); 172 it->second->setDimensions(size, size); 173 174 // calc position on radar... 175 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 176 coord *= Ogre::Math::PI / 3.5f; // small adjustment to make it fit the texture 177 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 178 it->second->show(); 179 180 // if this object is in focus, then set the focus marker 181 if (isFocus) 182 { 183 this->marker_->setDimensions(size * 1.5f, size * 1.5f); 184 this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f); 185 this->marker_->show(); 186 } 187 } 160 188 } 161 189 162 190 void HUDRadar::changedOwner() 163 191 { 164 192 SUPER(HUDRadar, changedOwner); 165 193 166 this->owner_ = orxonox_cast<Pawn*>(this->getOwner()); 167 } 194 this->owner_ = orxonox_cast<Pawn*>(this->getOwner()); 195 assert(this->radarObjects_.size()==0); 196 this->gatherObjects(); 168 197 } 198 } -
code/trunk/src/modules/overlays/hud/HUDRadar.h
r5781 r7163 65 65 66 66 // RadarListener interface 67 void displayObject(RadarViewable* viewable, bool bIsMarked); 67 virtual void addObject(RadarViewable* viewable); 68 virtual void removeObject(RadarViewable* viewable); 69 virtual void objectChanged( RadarViewable* rv ); 68 70 void radarTick(float dt); 71 72 void gatherObjects(); 69 73 70 74 std::map<RadarViewable::Shape, std::string> shapeMaterials_; 71 75 72 std::vector<Ogre::PanelOverlayElement*> radarDots_; 73 std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_; 76 // std::vector<Ogre::PanelOverlayElement*> radarDots_; 77 // std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_; 78 std::map<RadarViewable*, Ogre::PanelOverlayElement*> radarObjects_; 74 79 Ogre::PanelOverlayElement* marker_; 75 80 -
code/trunk/src/modules/pickup/CMakeLists.txt
r6711 r7163 1 1 SET_SOURCE_FILES(PICKUP_SRC_FILES 2 CollectiblePickup.cc 2 3 DroppedPickup.cc 3 4 Pickup.cc … … 17 18 PickupManager.h 18 19 PickupRepresentation.h 19 DEFINE_SYMBOL20 "PICKUP_SHARED_BUILD"21 20 PCH_FILE 22 21 PickupPrecompiledHeaders.h -
code/trunk/src/modules/pickup/DroppedPickup.cc
r6540 r7163 41 41 namespace orxonox 42 42 { 43 43 44 44 CreateFactory(DroppedPickup); 45 45 46 46 /** 47 47 @brief … … 51 51 { 52 52 RegisterObject(DroppedPickup); 53 53 54 54 } 55 55 … … 67 67 */ 68 68 DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 5, 1) 69 { 69 { 70 70 RegisterObject(DroppedPickup); 71 71 72 72 this->setPosition(carrier->getCarrierPosition()); 73 73 this->setActive(false); 74 74 75 75 //TODO: Do more elegantly. 76 76 this->startRespawnTimer(); -
code/trunk/src/modules/pickup/DroppedPickup.h
r6540 r7163 41 41 namespace orxonox 42 42 { 43 43 44 44 /** 45 45 @brief -
code/trunk/src/modules/pickup/Pickup.cc
- Property svn:eol-style set to native
r6709 r7163 48 48 /*static*/ const std::string Pickup::durationTypeOnce_s = "once"; 49 49 /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous"; 50 51 CreateUnloadableFactory(Pickup); 50 52 51 53 Pickup::Pickup(BaseObject* creator) : BaseObject(creator) … … 146 148 void Pickup::setActivationType(const std::string& type) 147 149 { 148 if( type == activationTypeImmediate_s)150 if(Pickup::activationTypeImmediate_s.compare(type) == 0) 149 151 { 150 152 this->activationType_ = pickupActivationType::immediate; 151 153 } 152 else if( type == activationTypeOnUse_s)154 else if(Pickup::activationTypeOnUse_s.compare(type) == 0) 153 155 { 154 156 this->activationType_ = pickupActivationType::onUse; … … 168 170 void Pickup::setDurationType(const std::string& type) 169 171 { 170 if( type == durationTypeOnce_s)172 if(Pickup::durationTypeOnce_s.compare(type) == 0) 171 173 { 172 174 this->durationType_ = pickupDurationType::once; 173 175 } 174 else if( type == durationTypeContinuous_s)176 else if(Pickup::durationTypeContinuous_s.compare(type) == 0) 175 177 { 176 178 this->durationType_ = pickupDurationType::continuous; … … 192 194 193 195 //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up. 194 if(this-> getCarrier() != NULL && this->isPickedUp() && this->isImmediate())196 if(this->isPickedUp() && this->isImmediate()) 195 197 { 196 198 this->setUsed(true); -
code/trunk/src/modules/pickup/Pickup.h
- Property svn:eol-style set to native
r6728 r7163 40 40 #include "core/XMLPort.h" 41 41 42 #include " interfaces/Pickupable.h"42 #include "CollectiblePickup.h" 43 43 44 44 #include "tools/Timer.h" … … 74 74 Damian 'Mozork' Frick 75 75 */ 76 class _PickupExport Pickup : public Pickupable, public BaseObject76 class _PickupExport Pickup : public CollectiblePickup, public BaseObject 77 77 { 78 78 79 p rotected:79 public: 80 80 Pickup(BaseObject* creator); //!< Constructor. 81 82 public:83 81 virtual ~Pickup(); //!< Destructor. 84 82 … … 167 165 private: 168 166 void initialize(void); //!< Initializes the member variables. 169 167 170 168 //TODO: Problems, when there are more Timers needed? Solutions? 171 169 Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup. -
code/trunk/src/modules/pickup/PickupCollection.cc
r6901 r7163 35 35 #include "core/XMLPort.h" 36 36 #include "interfaces/PickupCarrier.h" 37 #include "CollectiblePickup.h" 37 38 #include "DroppedPickup.h" 38 39 #include "PickupCollectionIdentifier.h" … … 42 43 namespace orxonox 43 44 { 44 45 45 46 CreateFactory(PickupCollection); 46 47 … … 52 53 { 53 54 RegisterObject(PickupCollection); 54 55 55 56 this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this); 56 } 57 57 this->usedCounter_ = 0; 58 this->pickedUpCounter_ = 0; 59 this->disabledCounter_ = 0; 60 this->processingUsed_ = false; 61 this->processingPickedUp_ = false; 62 } 63 58 64 /** 59 65 @brief … … 62 68 PickupCollection::~PickupCollection() 63 69 { 64 //! Destroy all Pickupables constructing this PickupCollection. 65 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 66 { 67 if((*it).get() != NULL) 68 (*it).get()->destroy(); 69 } 70 } 71 70 // Destroy all Pickupables constructing this PickupCollection. 71 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 72 { 73 (*it)->removeFromCollection(); 74 (*it)->destroy(); 75 } 76 this->pickups_.clear(); 77 } 78 72 79 /** 73 80 @brief … … 77 84 { 78 85 SUPER(PickupCollection, XMLPort, xmlelement, mode); 79 80 XMLPortObject(PickupCollection, Pickupable, "pickupables", addPickupable, getPickupable, xmlelement, mode);81 86 87 XMLPortObject(PickupCollection, CollectiblePickup, "pickupables", addPickupable, getPickupable, xmlelement, mode); 88 82 89 this->initializeIdentifier(); 83 90 } 84 91 85 92 /** 86 93 @brief … … 89 96 void PickupCollection::initializeIdentifier(void) 90 97 { 91 for(std::vector< WeakPtr<Pickupable>>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)92 { 93 this->pickupCollectionIdentifier_->addPickup((*it) .get()->getPickupIdentifier());94 } 95 } 96 98 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 99 { 100 this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier()); 101 } 102 } 103 97 104 /** 98 105 @brief … … 103 110 { 104 111 SUPER(PickupCollection, changedUsed); 105 106 //! Change used for all Pickupables this PickupCollection consists of. 107 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 108 { 109 (*it).get()->setUsed(this->isUsed()); 110 } 111 } 112 112 113 this->processingUsed_ = true; 114 // Change used for all Pickupables this PickupCollection consists of. 115 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 116 { 117 (*it)->setUsed(this->isUsed()); 118 } 119 this->processingUsed_ = false; 120 121 this->changedUsedAction(); 122 } 123 124 /** 125 @brief 126 Helper method. 127 Checks whether due to changes in the used status of the pickups of this PickupCollection the used status of this PickupCollection has to change as well. 128 */ 129 void PickupCollection::changedUsedAction(void) 130 { 131 if(this->processingUsed_) 132 return; 133 134 // If all the pickups are not in use but the PickupCollection is. 135 if(this->usedCounter_ == 0 && this->isUsed()) 136 this->setUsed(false); 137 138 // If all the enabled pickups are in use but the PickupCollection is not. 139 if(this->usedCounter_ != 0 && this->usedCounter_ == this->pickups_.size()-this->disabledCounter_ && !this->isUsed()) 140 this->setUsed(true); 141 } 142 113 143 /** 114 144 @brief … … 119 149 { 120 150 SUPER(PickupCollection, changedCarrier); 121 122 //! Change the PickupCarrier for all Pickupables this PickupCollection consists of. 123 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 124 { 125 (*it).get()->setCarrier(this->getCarrier()->getTarget(*it)); 126 } 127 } 128 151 152 // Change the PickupCarrier for all Pickupables this PickupCollection consists of. 153 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 154 { 155 if(this->getCarrier() == NULL) 156 (*it)->setCarrier(NULL); 157 else 158 (*it)->setCarrier(this->getCarrier()->getTarget(*it)); 159 } 160 } 161 129 162 /** 130 163 @brief … … 135 168 { 136 169 SUPER(PickupCollection, changedPickedUp); 137 138 //! Change the pickedUp status for all Pickupables this PickupCollection consists of. 139 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 140 { 141 (*it).get()->setPickedUp(this->isPickedUp()); 142 } 143 } 144 170 171 this->processingPickedUp_ = true; 172 // Change the pickedUp status for all Pickupables this PickupCollection consists of. 173 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 174 { 175 (*it)->setPickedUp(this->isPickedUp()); 176 } 177 this->processingPickedUp_ = false; 178 179 this->changedPickedUpAction(); 180 } 181 182 /** 183 @brief 184 Helper method. 185 Checks whether due to changes in the picked up status of the pickups of this PickupCollection the picked up status of this PickupCollection has to change as well. 186 */ 187 void PickupCollection::changedPickedUpAction(void) 188 { 189 if(this->processingPickedUp_) 190 return; 191 192 // If at least all the enabled pickups of this PickupCollection are no longer picked up. 193 if(this->pickedUpCounter_ <= this->disabledCounter_ && this->isPickedUp()) 194 this->Pickupable::destroy(); 195 196 // If the PickupCollection is no longer picked up. 197 if(!this->isPickedUp()) 198 this->pickedUpCounter_ = 0; 199 } 200 145 201 /** 146 202 @brief … … 154 210 if(item == NULL) 155 211 item = new PickupCollection(this); 156 212 157 213 SUPER(PickupCollection, clone, item); 158 214 159 215 PickupCollection* pickup = dynamic_cast<PickupCollection*>(item); 160 //! Clone all Pickupables this PickupCollection consist of. 161 for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 162 { 163 Pickupable* newPickup = (*it).get()->clone(); 164 pickup->addPickupable(newPickup); 216 // Clone all Pickupables this PickupCollection consist of. 217 for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 218 { 219 Pickupable* newPickup = (*it)->clone(); 220 CollectiblePickup* collectible = static_cast<CollectiblePickup*>(newPickup); 221 pickup->addPickupable(collectible); 165 222 } 166 223 167 224 pickup->initializeIdentifier(); 168 225 } 169 226 170 227 /** 171 228 @brief … … 178 235 bool PickupCollection::isTarget(PickupCarrier* carrier) const 179 236 { 180 for(std::vector< WeakPtr<Pickupable>>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)181 { 182 if(!carrier->isTarget( (*it).get()))237 for(std::vector<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++) 238 { 239 if(!carrier->isTarget(*it)) 183 240 return false; 184 241 } 185 242 186 243 return true; 187 244 } 188 245 189 246 /** 190 247 @brief … … 198 255 return this->pickupCollectionIdentifier_; 199 256 } 200 257 201 258 /** 202 259 @brief … … 207 264 Returns true if successful, 208 265 */ 209 bool PickupCollection::addPickupable( Pickupable* pickup)266 bool PickupCollection::addPickupable(CollectiblePickup* pickup) 210 267 { 211 268 if(pickup == NULL) 212 269 return false; 213 214 WeakPtr<Pickupable> ptr = pickup; //!< Create a weak pointer to be able to test in the constructor if the Pointer is still valid.215 this->pickups_.push_back(p tr);270 271 pickup->addToCollection(this); 272 this->pickups_.push_back(pickup); 216 273 return true; 217 274 } 218 275 219 276 /** 220 277 @brief … … 227 284 const Pickupable* PickupCollection::getPickupable(unsigned int index) 228 285 { 229 return this->pickups_[index].get(); 230 } 231 286 return this->pickups_[index]; 287 } 288 289 /** 290 @brief 291 Informs the PickupCollection, that one of its pickups has changed its used status to the input value. 292 This is used internally by the CollectiblePickup class. 293 @param changed 294 The value the used status has changed to. 295 */ 296 void PickupCollection::pickupChangedUsed(bool changed) 297 { 298 if(changed) 299 this->usedCounter_++; 300 else 301 this->usedCounter_--; 302 303 this->changedUsedAction(); 304 } 305 306 /** 307 @brief 308 Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value. 309 This is used internally by the CollectiblePickup class. 310 @param changed 311 The value the picked up status has changed to. 312 */ 313 void PickupCollection::pickupChangedPickedUp(bool changed) 314 { 315 if(changed) 316 this->pickedUpCounter_++; 317 else 318 this->pickedUpCounter_--; 319 320 this->changedPickedUpAction(); 321 } 322 323 /** 324 @brief 325 Informs the PickupCollection, that one of its pickups has been disabled. 326 This is used internally by the CollectiblePickup class. 327 */ 328 void PickupCollection::pickupDisabled(void) 329 { 330 this->disabledCounter_++; 331 } 332 232 333 /** 233 334 @brief … … 245 346 return true; 246 347 } 247 348 248 349 } -
code/trunk/src/modules/pickup/PickupCollection.h
r6731 r7163 37 37 #include "PickupPrereqs.h" 38 38 39 #include "interfaces/Pickupable.h"40 39 #include "core/BaseObject.h" 40 #include "CollectiblePickup.h" 41 41 42 42 #include <list> … … 47 47 /** 48 48 @brief 49 The PickupCollection combines different Pickupables to a coherent, single pickup and makes the seem (from the outside looking in) just as if they were just one Pickupable.49 The PickupCollection combines different Pickupables to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one Pickupable. 50 50 @author 51 51 Damian 'Mozork' Frick 52 52 */ 53 class _PickupExport PickupCollection : public Pickupable, public BaseObject53 class _PickupExport PickupCollection : public CollectiblePickup, public BaseObject 54 54 { 55 55 56 56 public: 57 58 57 PickupCollection(BaseObject* creator); //!< Default Constructor. 59 58 virtual ~PickupCollection(); //!< Destructor. 60 59 61 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates an instance of this Class through XML. 62 61 … … 64 63 virtual void changedCarrier(void); //!< Is called when the pickup has changed its PickupCarrier. 65 64 virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around. 66 65 67 66 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 68 67 69 68 virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. 70 69 71 70 virtual const PickupIdentifier* getPickupIdentifier(void); //!< Get the PickupIdentifier of this PickupCollection. 72 73 bool addPickupable( Pickupable* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.71 72 bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection. 74 73 const Pickupable* getPickupable(unsigned int index); //!< Get the Pickupable at the given index. 75 74 75 void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value. 76 void pickupChangedPickedUp(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value. 77 void pickupDisabled(void); //!< Informs the PickupCollection, that one of its pickups has been disabled. 78 76 79 protected: 77 80 void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup. 81 82 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 83 84 PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves. 85 86 private: 87 void changedUsedAction(void); //!< Helper method. 88 void changedPickedUpAction(void); //!< Helper method. 78 89 79 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 80 81 PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves. 82 83 private: 84 85 std::vector<WeakPtr<Pickupable> > pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid. 86 90 std::vector<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid. 91 92 unsigned int usedCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are in use. 93 unsigned int pickedUpCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are picked up. 94 unsigned int disabledCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are disabled. 95 96 bool processingUsed_; //!< Boolean to ensure, that the PickupCollection doesn't update its used status while its internal state is inconsistent. 97 bool processingPickedUp_; //!< Boolean to ensure, that the PickupCollection doesn't update its picked upp status while its internal state is inconsistent. 98 87 99 }; 88 100 89 101 } 90 102 -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
- Property svn:eol-style set to native
r6538 r7163 38 38 namespace orxonox 39 39 { 40 40 41 41 /** 42 42 @brief … … 47 47 RegisterObject(PickupCollectionIdentifier); 48 48 } 49 49 50 50 /** 51 51 @brief … … 54 54 PickupCollectionIdentifier::~PickupCollectionIdentifier() 55 55 { 56 56 57 57 } 58 58 … … 67 67 int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const 68 68 { 69 // !Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier.69 // Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier. 70 70 PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier); 71 71 const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp); 72 73 // !If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.72 73 // If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared. 74 74 if(collectionIdentifier == NULL) 75 75 { 76 76 return this->PickupIdentifier::compare(identifier); 77 77 } 78 79 // !If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller.78 79 // If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller. 80 80 if(this->identifiers_.size() != collectionIdentifier->identifiers_.size()) 81 81 return this->identifiers_.size()-collectionIdentifier->identifiers_.size(); 82 83 // !Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller.82 83 // Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller. 84 84 std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it2 = collectionIdentifier->identifiers_.begin(); 85 85 for(std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); it++) 86 86 { 87 87 88 88 if((*it)->compare(*it2) < 0) 89 89 return -1; … … 91 91 return 1; 92 92 } 93 93 94 94 //! Means they are equal. 95 95 return 0; 96 96 } 97 97 98 98 /** 99 99 @brief … … 106 106 this->identifiers_.insert(identifier); 107 107 } 108 108 109 109 } 110 110 -
code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
- Property svn:eol-style set to native
r6538 r7163 54 54 class _PickupExport PickupCollectionIdentifier : public PickupIdentifier 55 55 { 56 56 57 57 public: 58 58 PickupCollectionIdentifier(Pickupable* pickup); //!< Constructor. 59 59 ~PickupCollectionIdentifier(); //!< Destructor. 60 60 61 61 virtual int compare(const PickupIdentifier* identifier) const; //!< Compares a PickupCollectionIdentifier with a PickupIdentifier. 62 62 63 63 void addPickup(const PickupIdentifier* identifier); //!< Add a Pickupable to the PickupCollectionIdentifier. 64 64 65 65 private: 66 66 std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the Pickupables the PickupCollection with this PickupCollectionIdentifier consists of, ordered by the rule set by PickupIdentifierCompare. 67 67 68 68 }; 69 69 70 70 } 71 71 -
code/trunk/src/modules/pickup/PickupManager.cc
- Property svn:eol-style set to native
r6752 r7163 39 39 #include "core/ScopedSingletonManager.h" 40 40 #include "core/Identifier.h" 41 #include "util/Convert.h" 41 42 #include "interfaces/PickupCarrier.h" 42 43 #include "infos/PlayerInfo.h" 43 44 #include "worldentities/pawns/Pawn.h" 45 #include "CollectiblePickup.h" 44 46 #include "PickupRepresentation.h" 45 47 … … 50 52 // Register tolua_open function when loading the library 51 53 DeclareToluaInterface(Pickup); 52 53 ManageScopedSingleton(PickupManager, ScopeID:: Graphics, false);54 54 55 ManageScopedSingleton(PickupManager, ScopeID::Root, false); 56 55 57 /*static*/ const std::string PickupManager::guiName_s = "PickupInventory"; 56 58 57 59 /** 58 60 @brief … … 62 64 { 63 65 RegisterRootObject(PickupManager); 64 66 67 //TODO: This doesn't work, yet. 68 if( GameMode::showsGraphics() ) 69 { 70 GUIManager::getInstance().loadGUI(PickupManager::guiName_s); 71 } 65 72 this->defaultRepresentation_ = new PickupRepresentation(); 66 73 67 74 COUT(3) << "PickupManager created." << std::endl; 68 75 } 69 76 70 77 /** 71 78 @brief … … 77 84 if(this->defaultRepresentation_ != NULL) 78 85 this->defaultRepresentation_->destroy(); 79 86 80 87 this->representations_.clear(); 81 88 82 89 COUT(3) << "PickupManager destroyed." << std::endl; 83 90 } 84 91 85 92 /** 86 93 @brief … … 95 102 */ 96 103 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 97 { 104 { 98 105 if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered. 99 106 return false; 100 107 101 108 this->representations_[identifier] = representation; 102 109 103 110 COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl; 104 111 return true; 105 112 } 106 113 107 114 /** 108 115 @brief … … 116 123 */ 117 124 bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 118 { 125 { 119 126 if(identifier == NULL || representation == NULL) 120 127 return false; 121 128 122 129 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier); 123 130 if(it == this->representations_.end()) //!< If the Pickupable is not registered in the first place. 124 131 return false; 125 132 126 133 this->representations_.erase(it); 127 134 128 135 COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl; 129 136 return true; 130 137 } 131 138 132 139 /** 133 140 @brief … … 146 153 return this->defaultRepresentation_; 147 154 } 148 155 149 156 return it->second; 150 157 } 151 152 PickupCarrier* PickupManager::getPawn(void) 153 { 158 159 int PickupManager::getNumPickups(void) 160 { 161 this->pickupsList_.clear(); 162 154 163 PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s); 164 PickupCarrier* carrier = NULL; 155 165 if (player != NULL) 156 returndynamic_cast<PickupCarrier*>(player->getControllableEntity());166 carrier = dynamic_cast<PickupCarrier*>(player->getControllableEntity()); 157 167 else 158 return NULL;159 }160 161 int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)162 {163 if(carrier == NULL)164 168 return 0; 165 return carrier->getNumCarrierChildren(); 166 } 167 168 PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier) 169 { 170 if(carrier == NULL) 171 return NULL; 172 return carrier->getCarrierChild(index); 173 } 174 175 const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier) 176 { 177 if(carrier == NULL) 178 return BLANKSTRING; 179 return carrier->getCarrierName(); 180 } 181 182 PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier) 183 { 184 Pickupable* pickup = carrier->getPickup(index); 185 if(pickup == NULL) 186 return NULL; 187 188 return this->getRepresentation(pickup->getPickupIdentifier()); 189 } 190 191 int PickupManager::getNumPickups(PickupCarrier* carrier) 192 { 193 if(carrier == NULL) 194 return 0; 195 return carrier->getNumPickups(); 196 } 197 198 void PickupManager::dropPickup(int index, PickupCarrier* carrier) 199 { 200 Pickupable* pickup = carrier->getPickup(index); 201 if(pickup != NULL) 202 carrier->drop(pickup); 203 } 204 205 void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use) 206 { 207 Pickupable* pickup = carrier->getPickup(index); 208 if(pickup != NULL) 169 170 std::vector<PickupCarrier*>* carriers = this->getAllCarriers(carrier); 171 for(std::vector<PickupCarrier*>::iterator it = carriers->begin(); it != carriers->end(); it++) 172 { 173 std::set<Pickupable*> pickups = (*it)->getPickups(); 174 for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++) 175 { 176 CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(*pickup); 177 if(collectible == NULL || !collectible->isInCollection()) 178 this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup))); 179 } 180 } 181 delete carriers; 182 183 this->pickupsIterator_ = this->pickupsList_.begin(); 184 return this->pickupsList_.size(); 185 } 186 187 std::vector<PickupCarrier*>* PickupManager::getAllCarriers(PickupCarrier* carrier) 188 { 189 //TODO: More efficiently. 190 std::vector<PickupCarrier*>* carriers = new std::vector<PickupCarrier*>(); 191 carriers->insert(carriers->end(), carrier); 192 std::vector<PickupCarrier*>* children = carrier->getCarrierChildren(); 193 for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++) 194 { 195 std::vector<PickupCarrier*>* childrensChildren = this->getAllCarriers(*it); 196 for(std::vector<PickupCarrier*>::iterator it2 = childrensChildren->begin(); it2 != childrensChildren->end(); it2++) 197 { 198 carriers->insert(carriers->end(), *it2); 199 } 200 delete childrensChildren; 201 } 202 delete children; 203 return carriers; 204 } 205 206 void PickupManager::dropPickup(orxonox::Pickupable* pickup) 207 { 208 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 209 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 210 return; 211 212 if(!pickup->isPickedUp()) 213 return; 214 215 PickupCarrier* carrier = pickup->getCarrier(); 216 if(pickup != NULL && carrier != NULL) 217 { 218 pickup->drop(carrier); 219 } 220 } 221 222 void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use) 223 { 224 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 225 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 226 return; 227 228 if(!pickup->isPickedUp()) 229 return; 230 231 PickupCarrier* carrier = pickup->getCarrier(); 232 if(pickup != NULL && carrier != NULL) 209 233 pickup->setUsed(use); 210 234 } 211 235 212 236 } -
code/trunk/src/modules/pickup/PickupManager.h
- Property svn:eol-style set to native
r6725 r7163 39 39 #include <map> 40 40 #include "util/Singleton.h" 41 #include "core/WeakPtr.h" 41 42 #include "pickup/PickupIdentifier.h" 42 43 #include "PickupRepresentation.h" … … 59 60 { // tolua_export 60 61 friend class Singleton<PickupManager>; 61 62 62 63 public: 63 64 PickupManager(); 64 65 virtual ~PickupManager(); 65 66 66 67 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export 67 68 68 69 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 69 70 bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents. 70 71 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 71 72 72 73 // tolua_begin 73 orxonox::PickupCarrier* getPawn(void); 74 75 int getNumCarrierChildren(orxonox::PickupCarrier* carrier); 76 orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier); 77 78 const std::string& getCarrierName(orxonox::PickupCarrier* carrier); 79 80 int getNumPickups(orxonox::PickupCarrier* carrier); 81 PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier); 82 void dropPickup(int index, orxonox::PickupCarrier* carrier); 83 void usePickup(int index, orxonox::PickupCarrier* carrier, bool use); 74 int getNumPickups(void); 75 orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; } 76 orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; } 77 78 void dropPickup(orxonox::Pickupable* pickup); 79 void usePickup(orxonox::Pickupable* pickup, bool use); 80 bool isValidPickup(orxonox::Pickupable* pickup) { std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); if(it == this->pickupsList_.end()) return false; return it->second.get() != NULL; } 84 81 // tolua_end 85 82 86 83 private: 87 84 static PickupManager* singletonPtr_s; 88 85 static const std::string guiName_s; 89 86 90 87 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 91 88 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 92 89 90 std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_; 91 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_; 92 93 std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier); 94 93 95 }; // tolua_export 94 96 95 97 } // tolua_export 96 98 -
code/trunk/src/modules/pickup/PickupPrereqs.h
r6711 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( ORXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(PICKUP_STATIC_BUILD) 46 46 # ifdef PICKUP_SHARED_BUILD 47 47 # define _PickupExport __declspec(dllexport) … … 65 65 namespace orxonox 66 66 { 67 67 68 class CollectiblePickup; 68 69 class DroppedPickup; 69 70 class Pickup; … … 75 76 76 77 //items 78 class DronePickup; 77 79 class HealthPickup; 78 80 class InvisiblePickup; 79 81 class MetaPickup; 80 82 class SpeedPickup; 83 class ShieldPickup; 81 84 82 85 } -
code/trunk/src/modules/pickup/PickupRepresentation.cc
- Property svn:eol-style set to native
r6725 r7163 41 41 namespace orxonox 42 42 { 43 43 44 44 CreateFactory(PickupRepresentation); 45 45 46 46 /** 47 47 @brief … … 52 52 { 53 53 RegisterObject(PickupRepresentation); 54 54 55 55 this->initialize(); 56 56 } 57 57 58 58 /** 59 59 @brief … … 63 63 { 64 64 RegisterObject(PickupRepresentation); 65 65 66 66 this->initialize(); 67 67 } 68 68 69 69 /** 70 70 @brief … … 75 75 if(this->spawnerRepresentation_ != NULL) 76 76 this->spawnerRepresentation_->destroy(); 77 77 78 78 if(this->pickup_ != NULL) 79 79 PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this); 80 80 } 81 81 82 82 /** 83 83 @brief … … 91 91 this->inventoryRepresentation_ = "Default"; 92 92 } 93 93 94 94 /** 95 95 @brief … … 99 99 { 100 100 SUPER(PickupRepresentation, XMLPort, xmlelement, mode); 101 101 102 102 XMLPortParam(PickupRepresentation, "pickupName", setPickupName, getPickupName, xmlelement, mode); 103 103 XMLPortParam(PickupRepresentation, "pickupDescription", setPickupDescription, getPickupDescription, xmlelement, mode); … … 106 106 XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode); 107 107 XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode); 108 108 109 109 PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents. 110 110 111 111 if(this->spawnerRepresentation_ != NULL) 112 112 this->spawnerRepresentation_->setVisible(false); 113 113 114 114 COUT(4) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << std::endl; 115 115 } 116 116 117 117 /** 118 118 @brief … … 136 136 this->addTemplate(this->spawnerTemplate_); 137 137 } 138 138 139 139 StaticEntity* representation = this->spawnerRepresentation_; 140 140 representation->setVisible(true); 141 141 142 142 this->addTemplate(this->spawnerTemplate_); 143 143 this->spawnerRepresentation_->setVisible(false); 144 144 145 145 return representation; 146 146 } 147 147 148 148 /** 149 149 @brief … … 171 171 return representation; 172 172 } 173 173 174 174 } -
code/trunk/src/modules/pickup/PickupRepresentation.h
- Property svn:eol-style set to native
r6711 r7163 56 56 : public BaseObject 57 57 { // tolua_export 58 58 59 59 public: 60 60 PickupRepresentation(); //!< Constructor 61 61 PickupRepresentation(BaseObject* creator); //!< Default constructor. 62 62 virtual ~PickupRepresentation(); //!< Destructor. 63 63 64 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 65 65 66 66 /** 67 67 @brief Set the name of the Pickupable represented by this PickupRepresentation. … … 102 102 inline void setPickup(Pickupable* pickup) 103 103 { this->pickup_ = pickup; } 104 104 105 105 /** 106 106 @brief Get the name of the Pickupable represented by this PickupRepresentation. … … 138 138 inline const Pickupable* getPickup(unsigned int index) 139 139 { if(index == 0) return this->pickup_; return NULL; } 140 140 141 141 StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner. 142 142 143 143 private: 144 144 void initialize(void); //!< Initializes the member variables of this PickupRepresentation. 145 145 StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. 146 146 147 147 std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. 148 148 std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation. 149 149 std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation. 150 150 StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation. 151 std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image?152 151 std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. 152 153 153 Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation. 154 154 155 155 }; // tolua_export 156 156 157 157 } // tolua_export 158 158 159 159 #endif // _PickupRepresentation_H__ -
code/trunk/src/modules/pickup/PickupSpawner.cc
r6711 r7163 55 55 { 56 56 RegisterObject(PickupSpawner); 57 57 58 58 this->initialize(); 59 59 } … … 76 76 { 77 77 RegisterObject(PickupSpawner); 78 78 79 79 this->initialize(); 80 80 81 81 this->pickup_ = pickup; 82 82 … … 84 84 this->respawnTime_ = respawnTime; 85 85 this->setMaxSpawnedItems(maxSpawnedItems); 86 86 87 87 if(this->pickup_ == NULL) 88 88 { … … 107 107 this->maxSpawnedItems_ = INF; 108 108 this->spawnsRemaining_ = INF; 109 this->selfDestruct_ = false; 109 110 } 110 111 … … 115 116 PickupSpawner::~PickupSpawner() 116 117 { 117 if(this-> pickup_ != NULL)118 if(this->selfDestruct_ && this->pickup_ != NULL) 118 119 this->pickup_->destroy(); 119 120 } … … 132 133 133 134 XMLPortObject(PickupSpawner, Pickupable, "pickup", setPickupable, getPickupable, xmlelement, mode); 134 135 135 136 XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode); 136 137 XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode); 137 138 XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode); 138 139 139 140 if(this->pickup_ == NULL) 140 141 { … … 150 151 } 151 152 } 152 153 153 154 /** 154 155 @brief … … 161 162 this->setVisible(this->isActive()); 162 163 } 163 164 164 165 /** 165 166 @brief … … 172 173 { 173 174 SUPER(PickupSpawner, tick, dt); 174 175 175 176 //! If the PickupSpawner is active. 176 177 if (this->isActive()) 177 178 { 179 SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 180 178 181 //! Iterate trough all Pawns. 179 182 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) … … 189 192 } 190 193 } 191 194 192 195 /** 193 196 @brief … … 201 204 this->spawnsRemaining_ = items; 202 205 } 203 206 204 207 /** 205 208 @brief … … 223 226 else 224 227 { 225 COUT( 3) << "PickupSpawnerempty, selfdestruct initialized." << std::endl;228 COUT(4) << "PickupSpawner (&" << this << ") empty, selfdestruct initialized." << std::endl; 226 229 this->setActive(false); 227 230 this->destroy(); 228 231 } 229 232 } 230 233 231 234 /** 232 235 @brief … … 237 240 this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this))); 238 241 } 239 242 240 243 /** 241 244 @brief … … 248 251 if(this->pickup_ != NULL) 249 252 { 250 COUT(1) << "In PickupSpawner : setPickupable called, with this->pickup_ already set." << std::endl;253 COUT(1) << "In PickupSpawner (&" << this << "): setPickupable called, with this->pickup_ already set." << std::endl; 251 254 return; 252 255 } 253 256 if(pickup == NULL) 254 257 { 255 COUT(1) << "In PickupSpawner : Argument of setPickupable is NULL." << std::endl;258 COUT(1) << "In PickupSpawner (&" << this << "): Argument of setPickupable is NULL." << std::endl; 256 259 return; 257 260 } 258 261 259 262 this->pickup_ = pickup; 260 263 } 261 264 262 265 /** 263 266 @brief … … 282 285 if (this->isActive()) //!< Checks whether PickupSpawner is active. 283 286 { 284 COUT( 3) << "PickupSpawnertriggered and active." << std::endl;285 287 COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl; 288 286 289 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn); 287 290 if(carrier == NULL) … … 290 293 return; 291 294 } 292 295 293 296 if(!carrier->isTarget(this->pickup_)) 294 297 { 295 COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl;298 COUT(4) << "PickupSpawner (&" << this << ") triggered but Pawn wasn't a target of the Pickupable." << std::endl; 296 299 return; 297 300 } 298 301 299 302 PickupCarrier* target = carrier->getTarget(this->pickup_); 300 303 Pickupable* pickup = this->getPickup(); 301 304 302 305 if(target != NULL && pickup != NULL) 303 306 { 304 if(target->pickup(pickup)) 305 { 307 if(pickup->pickup(target)) 306 308 this->decrementSpawnsRemaining(); 307 }308 309 else 309 310 { 311 this->selfDestruct_ = true; 310 312 pickup->destroy(); 311 313 } … … 314 316 { 315 317 if(target == NULL) 316 COUT(1) << "PickupSpawner : Pickupable has no target." << std::endl;317 318 COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl; 319 318 320 if(pickup == NULL) 319 { 320 COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl; 321 } 321 COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl; 322 322 else 323 323 { 324 this->selfDestruct_ = true; 324 325 pickup->destroy(); 325 326 } … … 333 334 @return 334 335 The Pickupable created. 335 */ 336 */ 336 337 Pickupable* PickupSpawner::getPickup(void) 337 338 { … … 341 342 return NULL; 342 343 } 343 344 344 345 Pickupable* pickup = this->pickup_->clone(); 345 346 return pickup; … … 352 353 void PickupSpawner::respawnTimerCallback() 353 354 { 354 COUT( 3) << "PickupSpawnerreactivated." << std::endl;355 COUT(4) << "PickupSpawner (&" << this << ") reactivated." << std::endl; 355 356 356 357 this->setActive(true); -
code/trunk/src/modules/pickup/PickupSpawner.h
r6540 r7163 101 101 protected: 102 102 void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns. 103 103 104 104 void startRespawnTimer(void); 105 105 106 106 virtual Pickupable* getPickup(void); //!< Creates a new Pickupable. 107 107 108 108 void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn. 109 109 const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner. 110 110 111 111 Pickupable* pickup_; //!< The pickup to be spawned. 112 112 113 113 private: 114 114 void initialize(void); 115 115 116 116 void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough. 117 117 void respawnTimerCallback(); //!< Method called when the timer runs out. … … 125 125 Timer respawnTimer_; //!< Timer used for re-activating. 126 126 127 bool selfDestruct_; //!< True if the PickupSpawner is selfdestructing. 128 127 129 static const int INF = -1; //!< Constant for infinity. 128 130 }; -
code/trunk/src/modules/pickup/items/CMakeLists.txt
- Property svn:eol-style set to native
r6710 r7163 3 3 InvisiblePickup.cc 4 4 MetaPickup.cc 5 DronePickup.cc 5 6 SpeedPickup.cc 7 ShieldPickup.cc 6 8 ) -
code/trunk/src/modules/pickup/items/HealthPickup.cc
r6709 r7163 45 45 namespace orxonox 46 46 { 47 47 48 48 /*static*/ const std::string HealthPickup::healthTypeLimited_s = "limited"; 49 49 /*static*/ const std::string HealthPickup::healthTypeTemporary_s = "temporary"; 50 50 /*static*/ const std::string HealthPickup::healthTypePermanent_s = "permanent"; 51 51 52 52 CreateFactory(HealthPickup); 53 53 54 54 /** 55 55 @brief … … 59 59 { 60 60 RegisterObject(HealthPickup); 61 61 62 62 this->initialize(); 63 63 } 64 64 65 65 /** 66 66 @brief … … 69 69 HealthPickup::~HealthPickup() 70 70 { 71 72 } 73 74 /** 75 @brief 71 72 } 73 74 /** 75 @brief 76 76 Initializes the member variables. 77 77 */ 78 78 void HealthPickup::initialize(void) 79 { 79 { 80 80 this->health_ = 0; 81 81 this->healthRate_ = 0; … … 83 83 this->maxHealthSave_ = 0; 84 84 this->maxHealthOverwrite_ = 0; 85 85 86 86 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 87 87 } 88 88 89 89 /** 90 90 @brief … … 98 98 std::string val1 = stream.str(); 99 99 this->pickupIdentifier_->addParameter(type1, val1); 100 100 101 101 std::string val2 = this->getHealthType(); 102 102 std::string type2 = "healthType"; 103 103 this->pickupIdentifier_->addParameter(type2, val2); 104 104 105 105 stream.clear(); 106 106 stream << this->getHealthRate(); … … 109 109 this->pickupIdentifier_->addParameter(type3, val3); 110 110 } 111 111 112 112 /** 113 113 @brief … … 117 117 { 118 118 SUPER(HealthPickup, XMLPort, xmlelement, mode); 119 119 120 120 XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode); 121 121 XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode); 122 122 XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode); 123 123 124 124 if(!this->isContinuous()) 125 125 this->healthRate_ = 0.0; 126 126 127 127 this->initializeIdentifier(); 128 128 } 129 129 130 130 /** 131 131 @brief … … 138 138 { 139 139 SUPER(HealthPickup, tick, dt); 140 140 141 141 if(this->isContinuous() && this->isUsed()) 142 142 { 143 143 Pawn* pawn = this->carrierToPawnHelper(); 144 144 if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 145 this-> destroy();146 145 this->Pickupable::destroy(); 146 147 147 //! Calculate the health that is added this tick. 148 148 float health = dt*this->getHealthRate(); … … 152 152 float fullHealth = pawn->getHealth() + health; 153 153 this->setHealth(this->getHealth()-health); 154 154 155 155 switch(this->getHealthTypeDirect()) 156 156 { … … 173 173 COUT(1) << "Invalid healthType in HealthPickup." << std::endl; 174 174 } 175 175 176 176 //! If all health has been transfered. 177 177 if(this->getHealth() == 0) … … 181 181 } 182 182 } 183 183 184 184 /** 185 185 @brief … … 189 189 { 190 190 SUPER(HealthPickup, changedUsed); 191 191 192 192 //! If the pickup is not picked up nothing must be done. 193 if(!this->isPickedUp()) 193 if(!this->isPickedUp()) //TODO: Needed? 194 194 return; 195 195 196 196 //! If the pickup has transited to used. 197 197 if(this->isUsed()) … … 201 201 Pawn* pawn = this->carrierToPawnHelper(); 202 202 if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 203 this-> destroy();204 203 this->Pickupable::destroy(); 204 205 205 float health = 0; 206 206 switch(this->getHealthTypeDirect()) … … 226 226 COUT(1) << "Invalid healthType in HealthPickup." << std::endl; 227 227 } 228 228 229 229 //! The pickup has been used up. 230 230 this->setUsed(false); … … 237 237 PickupCarrier* carrier = this->getCarrier(); 238 238 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 239 239 240 240 if(pawn == NULL) 241 241 { 242 242 COUT(1) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << std::endl; 243 this-> destroy();243 this->Pickupable::destroy(); 244 244 return; 245 245 } 246 246 247 247 if(pawn->getMaxHealth() == this->maxHealthOverwrite_) 248 248 { … … 252 252 } 253 253 } 254 254 255 255 //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused. 256 256 if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0)) 257 257 { 258 this-> destroy();259 } 260 } 261 } 262 258 this->Pickupable::destroy(); 259 } 260 } 261 } 262 263 263 /** 264 264 @brief … … 271 271 PickupCarrier* carrier = this->getCarrier(); 272 272 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 273 273 274 274 if(pawn == NULL) 275 275 { 276 276 COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl; 277 277 } 278 278 279 279 return pawn; 280 280 } 281 281 282 282 /** 283 283 @brief … … 290 290 if(item == NULL) 291 291 item = new HealthPickup(this); 292 292 293 293 SUPER(HealthPickup, clone, item); 294 294 295 295 HealthPickup* pickup = dynamic_cast<HealthPickup*>(item); 296 296 pickup->setHealth(this->getHealth()); 297 297 pickup->setHealthRate(this->getHealthRate()); 298 298 pickup->setHealthTypeDirect(this->getHealthTypeDirect()); 299 299 300 300 pickup->initializeIdentifier(); 301 301 } 302 302 303 303 /** 304 304 @brief … … 322 322 } 323 323 } 324 324 325 325 /** 326 326 @brief … … 341 341 } 342 342 } 343 343 344 344 /** 345 345 @brief … … 356 356 else 357 357 { 358 COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl; 359 } 360 } 361 358 COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl; 359 } 360 } 361 362 362 /** 363 363 @brief -
code/trunk/src/modules/pickup/items/HealthPickup.h
r6709 r7163 45 45 46 46 namespace orxonox { 47 47 48 48 //! Enum for the type of the HealthPickup 49 49 namespace pickupHealthType … … 56 56 }; 57 57 } 58 58 59 59 /** 60 60 @brief … … 71 71 { 72 72 public: 73 73 74 74 HealthPickup(BaseObject* creator); //!< Constructor. 75 75 virtual ~HealthPickup(); //!< Destructor. 76 76 77 77 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML. 78 78 virtual void tick(float dt); //!< Is called every tick. 79 79 80 80 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 81 81 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 82 82 83 83 /** 84 84 @brief Get the health that is transfered to the Pawn upon usage of this pickup. … … 93 93 inline float getHealthRate(void) 94 94 { return this->healthRate_; } 95 95 96 96 /** 97 97 @brief Get the type of HealthPickup, this pickup is. 98 @return Returns the health type as an enum. 98 @return Returns the health type as an enum. 99 99 */ 100 100 inline pickupHealthType::Value getHealthTypeDirect(void) 101 101 { return this->healthType_; } 102 102 const std::string& getHealthType(void); //!< Get the health type of this pickup. 103 103 104 104 protected: 105 105 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. … … 107 107 void setHealth(float health); //!< Sets the health. 108 108 void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous. 109 109 110 110 /** 111 111 @brief Set the health type of this pickup. … … 115 115 { this->healthType_ = type; } 116 116 void setHealthType(std::string type); //!< Set the type of the HealthPickup. 117 117 118 118 private: 119 119 void initialize(void); //!< Initializes the member variables. 120 120 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 121 121 122 122 float health_; //!< The health that is transferred to the Pawn. 123 123 float healthRate_; //!< The rate at which the health is transferred. … … 125 125 float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well. 126 126 pickupHealthType::Value healthType_; //!< The type of the HealthPickup. 127 127 128 128 //! Strings for the health types. 129 129 static const std::string healthTypeLimited_s; 130 130 static const std::string healthTypeTemporary_s; 131 131 static const std::string healthTypePermanent_s; 132 132 133 133 }; 134 134 } -
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
- Property svn:eol-style set to native
r6755 r7163 34 34 #include "InvisiblePickup.h" 35 35 36 #include <sstream> 37 #include <OgreEntity.h> 38 #include <OgreAnimationState.h> 39 40 #include "util/StringUtils.h" 36 41 #include "core/CoreIncludes.h" 37 42 #include "core/XMLPort.h" 38 #include "util/StringUtils.h"39 43 40 44 #include "worldentities/pawns/Pawn.h" 41 45 #include "pickup/PickupIdentifier.h" 42 46 43 #include <sstream>44 45 47 namespace orxonox 46 48 { 47 49 48 50 CreateFactory(InvisiblePickup); 49 51 50 52 /** 51 53 @brief … … 56 58 RegisterObject(InvisiblePickup); 57 59 //! Defines who is allowed to pick up the pickup. 58 this->initialize(); 59 } 60 60 this->initialize(); 61 } 62 61 63 /** 62 64 @brief … … 64 66 */ 65 67 InvisiblePickup::~InvisiblePickup() 66 { 67 } 68 69 68 { 69 } 70 71 70 72 void InvisiblePickup::initializeIdentifier(void) 71 73 { … … 76 78 this->pickupIdentifier_->addParameter(type1, val1); 77 79 } 78 80 79 81 /** 80 82 @brief … … 93 95 void InvisiblePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) 94 96 { 95 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 97 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 96 98 XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode); 97 99 98 100 this->initializeIdentifier(); 99 101 } 100 102 101 103 /** 102 104 @brief … … 106 108 { 107 109 SUPER(InvisiblePickup, changedUsed); 108 110 109 111 //! If the pickup is not picked up nothing must be done. 110 112 if(!this->isPickedUp()) 111 113 return; 112 114 113 115 if (this->isUsed()) 114 116 { … … 121 123 this->startPickupTimer(this->getDuration()); 122 124 } 125 123 126 this->setInvisible(true); 127 124 128 } 125 129 else 126 130 { 127 131 this->setInvisible(false); 128 132 129 133 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration()) 130 134 { 131 this-> destroy();135 this->Pickupable::destroy(); 132 136 } 133 137 else … … 136 140 } 137 141 } 138 139 } 140 142 143 } 144 141 145 /** 142 146 @brief … … 149 153 PickupCarrier* carrier = this->getCarrier(); 150 154 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 151 155 152 156 if(pawn == NULL) 153 157 { … … 156 160 return pawn; 157 161 } 158 162 159 163 /** 160 164 @brief … … 167 171 if(item == NULL) 168 172 item = new InvisiblePickup(this); 169 173 170 174 SUPER(InvisiblePickup, clone, item); 171 175 172 176 InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item); 173 177 pickup->setDuration(this->getDuration()); 174 178 pickup->initializeIdentifier(); 175 179 } 176 180 177 181 /** 178 182 @brief … … 186 190 if(pawn == NULL) 187 191 return false; 188 192 189 193 pawn->setVisible(!invisibility); 194 pawn->setRadarVisibility(!invisibility); 195 196 // Test to change Material at runtime! 197 198 // Ogre::MaterialPtr mat = this->mesh_.getEntity()->getSubEntity(0)->getMaterial(); 199 // mat->setDiffuse(0.4, 0.3, 0.1, 0.1); 200 // mat->setAmbient(0.3, 0.7, 0.8); 201 // mat->setSpecular(0.5, 0.5, 0.5, 0.1); 202 // Ogre::SceneBlendType sbt = Ogre::SBT_ADD; 203 // 204 // mat->setSceneBlending(sbt); 205 190 206 return true; 191 207 } 192 208 193 209 /** 194 210 @brief … … 209 225 } 210 226 } 211 227 212 228 void InvisiblePickup::pickupTimerCallback(void) 213 229 { -
code/trunk/src/modules/pickup/items/InvisiblePickup.h
- Property svn:eol-style set to native
r6710 r7163 38 38 39 39 #include <string> 40 40 41 #include <worldentities/pawns/Pawn.h> 41 42 #include "worldentities/StaticEntity.h" 42 43 43 #include "pickup/Pickup.h" 44 44 45 45 namespace orxonox { 46 46 47 47 /** 48 48 @brief … … 57 57 { 58 58 public: 59 59 60 60 InvisiblePickup(BaseObject* creator); //!< Constructor. 61 61 virtual ~InvisiblePickup(); //!< Destructor. … … 63 63 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 64 64 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 65 65 66 66 /** 67 67 @brief Checks whether the Pawn is invisible. … … 72 72 inline float getDuration() 73 73 { return this->duration_; } 74 74 75 75 protected: 76 76 bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again. … … 78 78 void initializeIdentifier(void); 79 79 virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends. 80 80 81 81 private: 82 82 void initialize(void); //!< Initializes the member variables. -
code/trunk/src/modules/pickup/items/MetaPickup.cc
r6709 r7163 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 #include "worldentities/pawns/Pawn.h" 36 37 #include "interfaces/PickupCarrier.h" 37 38 #include "pickup/PickupIdentifier.h" … … 40 41 41 42 namespace orxonox { 42 43 43 44 CreateFactory(MetaPickup); 44 45 45 46 //! Setting the static variables to their values. 46 47 /*static*/ const std::string MetaPickup::metaTypeNone_s = "none"; 47 48 /*static*/ const std::string MetaPickup::metaTypeUse_s = "use"; 48 49 /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop"; 49 50 /*static*/ const std::string MetaPickup::metaTypeDestroy_s = "destroy"; 51 /*static*/ const std::string MetaPickup::metaTypeDestroyCarrier_s = "destroyCarrier"; 52 50 53 /** 51 54 @brief … … 55 58 { 56 59 RegisterObject(MetaPickup); 57 60 58 61 this->initialize(); 59 62 } 60 63 61 64 /** 62 65 @brief … … 65 68 MetaPickup::~MetaPickup() 66 69 { 67 68 } 69 70 71 } 72 70 73 /** 71 74 @brief … … 75 78 { 76 79 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 77 80 78 81 this->setActivationTypeDirect(pickupActivationType::immediate); 79 82 this->setDurationTypeDirect(pickupDurationType::once); 80 83 this->metaType_ = pickupMetaType::none; 81 84 } 82 85 83 86 /** 84 87 @brief … … 91 94 this->pickupIdentifier_->addParameter(type, val); 92 95 } 93 96 94 97 /** 95 98 @brief … … 99 102 { 100 103 SUPER(MetaPickup, XMLPort, xmlelement, mode); 101 104 102 105 XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode); 103 106 104 107 this->initializeIdentifier(); 105 108 } 106 109 107 110 /** 108 111 @brief … … 113 116 { 114 117 SUPER(MetaPickup, changedUsed); 115 118 116 119 //! If the MetaPickup transited to used. 117 120 if(this->isUsed()) … … 120 123 if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL) 121 124 { 125 if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier) 126 { 127 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 128 pawn->kill(); 129 return; 130 } 122 131 std::set<Pickupable*> pickups = carrier->getPickups(); 123 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending o the meta type.132 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending on the meta type. 124 133 for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++) 125 134 { … … 136 145 if(pickup != NULL && pickup != this) 137 146 { 138 carrier->drop(pickup); 147 pickup->drop(); 148 } 149 } 150 if(this->getMetaTypeDirect() == pickupMetaType::destroy) 151 { 152 if(pickup != NULL && pickup != this) 153 { 154 pickup->Pickupable::destroy(); 139 155 } 140 156 } 141 157 } 142 158 } 143 this-> destroy();144 } 145 } 146 159 this->Pickupable::destroy(); 160 } 161 } 162 147 163 /** 148 164 @brief … … 155 171 if(item == NULL) 156 172 item = new MetaPickup(this); 157 173 158 174 SUPER(MetaPickup, clone, item); 159 175 160 176 MetaPickup* pickup = dynamic_cast<MetaPickup*>(item); 161 177 pickup->setMetaTypeDirect(this->getMetaTypeDirect()); 162 178 163 179 pickup->initializeIdentifier(); 164 180 } 165 181 166 182 /** 167 183 @brief … … 180 196 case pickupMetaType::drop: 181 197 return MetaPickup::metaTypeDrop_s; 198 case pickupMetaType::destroy: 199 return MetaPickup::metaTypeDestroy_s; 200 case pickupMetaType::destroyCarrier: 201 return MetaPickup::metaTypeDestroyCarrier_s; 182 202 default: 183 203 return BLANKSTRING; 184 204 } 185 205 } 186 206 187 207 /** 188 208 @brief … … 205 225 this->setMetaTypeDirect(pickupMetaType::drop); 206 226 } 207 } 208 227 else if(type == MetaPickup::metaTypeDestroy_s) 228 { 229 this->setMetaTypeDirect(pickupMetaType::destroy); 230 } 231 else if(type == MetaPickup::metaTypeDestroyCarrier_s) 232 { 233 this->setMetaTypeDirect(pickupMetaType::destroyCarrier); 234 } 235 else 236 COUT(2) << "Invalid metaType '" << type << "' in MetaPickup." << std::endl; 237 } 238 209 239 } -
code/trunk/src/modules/pickup/items/MetaPickup.h
r6709 r7163 48 48 none, 49 49 use, 50 drop 50 drop, 51 destroy, 52 destroyCarrier 51 53 }; 52 54 } 53 55 54 56 /** 55 57 @brief 56 The MetaPickup is a pickup that can, depending on the parameters, either drop all pickups of the PickupCarrier that picks it up, or use all the unused pickups of the PickupCarrier, that picks it up. The parameter to set for this is the metaType and it can be used with the values 'none', 'drop' and 'use'. 58 The MetaPickup is a pickup that can, depending on the parameter 'metaType', do different things. If the 'metaType' is set to 59 1) 'use', all the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup. 60 2) 'drop', all the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup. 61 3) 'destroy', all the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup. 62 4) 'destroyCarrier', the PickupCarrier is immediately destroyed upon pickup of the MetaPickup. 57 63 @author 58 64 Damian 'Mozork' Frick … … 60 66 class _PickupExport MetaPickup : public Pickup 61 67 { 62 68 63 69 public: 64 70 MetaPickup(BaseObject* creator); //!< Constructor. Registers and initializes the object. 65 71 virtual ~MetaPickup(); //!< Destructor. 66 72 67 73 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MetaPickup object through XML. 68 74 69 75 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 70 76 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 71 77 72 78 /** 73 79 @brief Returns the meta type of the MetaPickup. … … 77 83 { return this->metaType_; } 78 84 const std::string& getMetaType(void); //!< Get the meta type of this MetaPickup. 79 85 80 86 protected: 81 87 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 82 88 83 89 /** 84 90 @brief Set the meta type of the MetaPickup. … … 88 94 { this->metaType_ = type; } 89 95 void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup. 90 96 91 97 private: 92 98 void initialize(void); //!< Initializes the member variables. 93 99 94 100 pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken. 95 101 96 102 //! Static strings for the meta types. 97 103 static const std::string metaTypeNone_s; 98 104 static const std::string metaTypeUse_s; 99 105 static const std::string metaTypeDrop_s; 100 101 106 static const std::string metaTypeDestroy_s; 107 static const std::string metaTypeDestroyCarrier_s; 108 109 102 110 }; 103 111 -
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r6755 r7163 136 136 Engine* engine = this->carrierToEngineHelper(); 137 137 if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed. 138 this-> destroy();139 138 this->Pickupable::destroy(); 139 140 140 //! If the pickup has transited to used. 141 141 if(this->isUsed()) … … 156 156 engine->setSpeedAdd(0.0f); 157 157 engine->setSpeedMultiply(1.0f); 158 158 159 159 if(this->isOnce()) 160 160 { 161 161 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration()) 162 162 { 163 this-> destroy();163 this->Pickupable::destroy(); 164 164 } 165 165 else … … 186 186 COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl; 187 187 } 188 188 189 189 return engine; 190 190 } … … 269 269 270 270 void SpeedPickup::pickupTimerCallback(void) 271 { 271 { 272 272 this->setUsed(false); 273 273 } -
code/trunk/src/modules/pickup/items/SpeedPickup.h
r6709 r7163 78 78 protected: 79 79 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 80 80 81 81 virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends. 82 82 -
code/trunk/src/modules/pong/CMakeLists.txt
r5929 r7163 14 14 MODULE 15 15 FIND_HEADER_FILES 16 DEFINE_SYMBOL17 "PONG_SHARED_BUILD"18 16 LINK_LIBRARIES 19 17 orxonox -
code/trunk/src/modules/pong/PongBall.h
r5929 r7163 45 45 virtual void tick(float dt); 46 46 47 void registerVariables();48 49 47 void setFieldDimension(float width, float height) 50 48 { this->fieldWidth_ = width; this->fieldHeight_ = height; } … … 74 72 75 73 private: 74 void registerVariables(); 75 76 76 float fieldWidth_; 77 77 float fieldHeight_; -
code/trunk/src/modules/pong/PongBat.h
r5781 r7163 41 41 virtual ~PongBat() {} 42 42 43 void registerVariables();44 43 virtual void tick(float dt); 45 44 … … 65 64 66 65 private: 66 void registerVariables(); 67 67 68 float movement_; 68 69 bool bMoveLocal_; -
code/trunk/src/modules/pong/PongPrereqs.h
r5929 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( ORXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(PONG_STATIC_BUILD) 46 46 # ifdef PONG_SHARED_BUILD 47 47 # define _PongExport __declspec(dllexport) -
code/trunk/src/modules/questsystem/AddQuest.cc
r5781 r7163 68 68 SUPER(AddQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "AddQuest on player: " << player << " ." << std::endl;89 COUT(5) << "AddQuest on player: " << player << " ." << std::endl; 90 90 91 91 try … … 103 103 } 104 104 105 COUT( 3) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;105 COUT(4) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl; 106 106 return true; 107 107 } -
code/trunk/src/modules/questsystem/AddQuestHint.cc
r6417 r7163 72 72 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 73 73 74 COUT( 3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;74 COUT(4) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl; 75 75 } 76 76 … … 85 85 bool AddQuestHint::setHintId(const std::string & id) 86 86 { 87 if( !QuestItem::isId(id))87 if(id.compare(BLANKSTRING) == 0) 88 88 { 89 89 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; … … 111 111 } 112 112 113 COUT( 3) << "AddQuestHint on player: " << player << " ." << std::endl;113 COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl; 114 114 115 115 try … … 127 127 } 128 128 129 COUT( 3) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;129 COUT(4) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl; 130 130 return true; 131 131 -
code/trunk/src/modules/questsystem/AddReward.cc
r6417 r7163 68 68 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 69 69 70 COUT( 3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;70 COUT(4) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl; 71 71 } 72 72 … … 103 103 bool AddReward::invoke(PlayerInfo* player) 104 104 { 105 COUT( 3) << "AddReward on player: " << player << " ." << std::endl;105 COUT(5) << "AddReward on player: " << player << " ." << std::endl; 106 106 107 107 bool check = true; … … 111 111 } 112 112 113 COUT( 3) << "Rewardable successfully added to player." << player << " ." << std::endl;113 COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl; 114 114 115 115 return check; -
code/trunk/src/modules/questsystem/CMakeLists.txt
r6800 r7163 12 12 QuestEffect.cc 13 13 QuestEffectBeacon.cc 14 QuestGUINode.cc15 QuestGUI.cc16 14 QuestHint.cc 17 15 QuestItem.cc … … 28 26 TOLUA_FILES 29 27 QuestManager.h 30 DEFINE_SYMBOL 31 "QUESTSYSTEM_SHARED_BUILD" 28 QuestDescription.h 29 Quest.h 30 QuestHint.h 32 31 PCH_FILE 33 32 QuestsystemPrecompiledHeaders.h -
code/trunk/src/modules/questsystem/ChangeQuestStatus.cc
r6417 r7163 78 78 bool ChangeQuestStatus::setQuestId(const std::string & id) 79 79 { 80 if( !QuestItem::isId(id))80 if(id.compare(BLANKSTRING) == 0) 81 81 { 82 82 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/modules/questsystem/CompleteQuest.cc
r6417 r7163 68 68 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "CompleteQuest on player: " << player << " ." << std::endl;89 COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl; 90 90 91 91 Quest* quest; … … 105 105 } 106 106 107 COUT( 3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;107 COUT(4) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl; 108 108 return true; 109 109 } -
code/trunk/src/modules/questsystem/FailQuest.cc
r6417 r7163 68 68 SUPER(FailQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;70 COUT(4) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 71 } 72 72 … … 87 87 } 88 88 89 COUT( 3) << "FailQuest on player: " << player << " ." << std::endl;89 COUT(4) << "FailQuest on player: " << player << " ." << std::endl; 90 90 91 91 Quest* quest; … … 104 104 } 105 105 106 COUT( 3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;106 COUT(4) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl; 107 107 return true; 108 108 } -
code/trunk/src/modules/questsystem/GlobalQuest.cc
r6417 r7163 70 70 XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode); 71 71 72 COUT( 3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;72 COUT(4) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 73 73 } 74 74 … … 253 253 this->rewards_.push_back(effect); //!< Add the QuestEffect to the list. 254 254 255 COUT( 3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;255 COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; 256 256 return true; 257 257 } -
code/trunk/src/modules/questsystem/LocalQuest.cc
r6417 r7163 68 68 SUPER(LocalQuest, XMLPort, xmlelement, mode); 69 69 70 COUT( 3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;70 COUT(4) << "New LocalQuest {" << this->getId() << "} created." << std::endl; 71 71 } 72 72 -
code/trunk/src/modules/questsystem/Quest.cc
r6417 r7163 61 61 Quest::~Quest() 62 62 { 63 63 if(this->isRegistered()) 64 QuestManager::getInstance().unregisterQuest(this); 64 65 } 65 66 … … 98 99 this->parentQuest_ = quest; 99 100 100 COUT( 3) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;101 COUT(4) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 101 102 return true; 102 103 } … … 121 122 this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests. 122 123 123 COUT( 3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;124 COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 124 125 return true; 125 126 } … … 145 146 this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints. 146 147 147 COUT( 3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;148 COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 148 149 return true; 149 150 } … … 167 168 this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects. 168 169 169 COUT( 3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;170 COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; 170 171 return true; 171 172 } … … 189 190 this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects. 190 191 191 COUT( 3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;192 COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; 192 193 return true; 193 194 } -
code/trunk/src/modules/questsystem/Quest.h
r5781 r7163 41 41 #include "QuestItem.h" 42 42 43 namespace orxonox 44 { 43 namespace orxonox // tolua_export 44 { // tolua_export 45 45 namespace QuestStatus 46 46 { … … 67 67 Damian 'Mozork' Frick 68 68 */ 69 class _QuestsystemExport Quest : public QuestItem 70 { 69 class _QuestsystemExport Quest // tolua_export 70 : public QuestItem 71 { // tolua_export 71 72 public: 72 73 Quest(BaseObject* creator); … … 97 98 98 99 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 99 bool isActive(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'active'.100 bool isFailed(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'failed'.101 bool isCompleted(const PlayerInfo* player) const;//!< Returns true if the quest status for the specific player is 'completed'.100 bool isActive(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'active'. 101 bool isFailed(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'failed'. 102 bool isCompleted(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'completed'. 102 103 103 104 bool start(PlayerInfo* player); //!< Sets a Quest to active. … … 151 152 bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects. 152 153 153 }; 154 }; // tolua_export 154 155 155 } 156 } // tolua_export 156 157 157 158 #endif /* _Quest_H__ */ -
code/trunk/src/modules/questsystem/QuestDescription.cc
r6417 r7163 74 74 XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); 75 75 76 COUT( 3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;76 COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 77 77 } 78 78 … … 89 89 Make sure the messages meet the conditions. 90 90 */ 91 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const91 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) 92 92 { 93 93 std::string message; … … 122 122 } 123 123 124 QuestNotification* notification = new QuestNotification( message);124 QuestNotification* notification = new QuestNotification(this, message); 125 125 notification->send(); 126 126 return true; -
code/trunk/src/modules/questsystem/QuestDescription.h
r5781 r7163 83 83 @return Returns a string containing the fail message of the QuestDescription. 84 84 */ 85 inline const std::string & getFailMessage(void) const85 inline const std::string & getFailMessage(void) 86 86 { return this->failMessage_; } 87 87 … … 90 90 @return Returns a string containing the complete message of the QuestDescription. 91 91 */ 92 inline const std::string & getCompleteMessage(void) const92 inline const std::string & getCompleteMessage(void) 93 93 { return this->completeMessage_; } 94 94 … … 97 97 @return Returns true if successful. 98 98 */ 99 inline bool sendAddHintNotification(void) const99 inline bool sendAddHintNotification(void) 100 100 { return notificationHelper("hint", ""); } 101 101 … … 104 104 @return Returns true if successful. 105 105 */ 106 inline bool sendAddQuestNotification(void) const106 inline bool sendAddQuestNotification(void) 107 107 { return notificationHelper("quest", "start"); } 108 108 … … 111 111 @return Returns true if successful. 112 112 */ 113 inline bool sendFailQuestNotification(void) const113 inline bool sendFailQuestNotification(void) 114 114 { return notificationHelper("quest", "fail"); } 115 115 … … 118 118 @return Returns true if successful. 119 119 */ 120 inline bool sendCompleteQuestNotification(void) const120 inline bool sendCompleteQuestNotification(void) 121 121 { return notificationHelper("quest", "complete"); } 122 122 … … 127 127 std::string completeMessage_; //!< The message displayed when the Quest is completed. 128 128 129 bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications.129 bool notificationHelper(const std::string & item, const std::string & status); //!< Helper for sending QuestDescriptions as Notifications. 130 130 131 131 /** -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r6906 r7163 78 78 XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 79 79 80 COUT( 3) << "New QuestEffectBeacon created." << std::endl;80 COUT(4) << "New QuestEffectBeacon created." << std::endl; 81 81 } 82 82 … … 112 112 MultiTriggerContainer* mTrigger = orxonox_cast<MultiTriggerContainer*>(trigger); 113 113 Pawn* pawn = NULL; 114 114 115 115 //! If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it. 116 116 if(pTrigger == NULL && mTrigger == NULL) 117 117 return false; 118 119 // If the trigger is a PlayerTrigger. 118 119 // If the trigger is a PlayerTrigger. 120 120 if(pTrigger != NULL) 121 121 { … … 125 125 pawn = pTrigger->getTriggeringPlayer(); 126 126 } 127 127 128 128 // If the trigger is a MultiTrigger (i.e. a MultiTriggerContainer) 129 129 if(mTrigger != NULL) … … 134 134 if(pawn == NULL) 135 135 { 136 COUT( 2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn." << std::endl;136 COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl; 137 137 return false; 138 138 } … … 147 147 } 148 148 149 COUT( 3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;149 COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 150 150 151 151 bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo. … … 249 249 this->effects_.push_back(effect); 250 250 251 COUT( 3) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;251 COUT(4) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl; 252 252 return true; 253 253 } -
code/trunk/src/modules/questsystem/QuestHint.cc
r6417 r7163 59 59 QuestHint::~QuestHint() 60 60 { 61 61 if(this->isRegistered()) 62 QuestManager::getInstance().unregisterHint(this); 62 63 } 63 64 … … 72 73 QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager. 73 74 74 COUT( 3) << "New QuestHint {" << this->getId() << "} created." << std::endl;75 COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl; 75 76 } 76 77 … … 125 126 else 126 127 { 127 COUT( 2) << "An already active questHint was trying to get activated." << std::endl;128 COUT(4) << "An already active questHint was trying to get activated." << std::endl; 128 129 return false; 129 130 } 130 131 } 131 132 132 COUT( 2) << "A hint of a non-active quest was trying to get activated." << std::endl;133 COUT(4) << "A hint of a non-active quest was trying to get activated." << std::endl; 133 134 return false; 134 135 } -
code/trunk/src/modules/questsystem/QuestHint.h
r5781 r7163 40 40 #include "QuestItem.h" 41 41 42 namespace orxonox 43 { 42 namespace orxonox // tolua_export 43 { // tolua_export 44 44 namespace QuestHintStatus 45 45 { … … 66 66 Damian 'Mozork' Frick 67 67 */ 68 class _QuestsystemExport QuestHint : public QuestItem 69 { 68 class _QuestsystemExport QuestHint // tolua_export 69 : public QuestItem 70 { // tolua_export 70 71 71 72 public: … … 91 92 std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key. 92 93 93 }; 94 }; // tolua_export 94 95 95 } 96 } // tolua_export 96 97 97 98 #endif /* _QuestHint_H__ */ -
code/trunk/src/modules/questsystem/QuestItem.cc
r6417 r7163 40 40 namespace orxonox 41 41 { 42 43 CreateUnloadableFactory(QuestItem); 44 42 45 /** 43 46 @brief … … 46 49 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 47 50 { 51 this->registered_ = false; 52 48 53 RegisterObject(QuestItem); 49 54 } … … 79 84 void QuestItem::setId(const std::string & id) 80 85 { 81 if( !isId(id)) //!< Checks whether the id is a valid id.86 if(id.compare(BLANKSTRING) == 0) //!< Checks whether the id is a valid id. 82 87 { 83 88 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; … … 88 93 } 89 94 90 /**91 @brief92 Checks whether an input id is of the required form.93 @param id94 The id to be checked.95 @return96 Returns true if the string is likely to be of the required form.97 */98 /*static*/ bool QuestItem::isId(const std::string & id)99 {100 return id.size() >= 32;101 }102 103 95 } -
code/trunk/src/modules/questsystem/QuestItem.h
r5781 r7163 41 41 #include <string> 42 42 #include "core/BaseObject.h" 43 #include "QuestManager.h" 43 44 44 45 namespace orxonox … … 71 72 @return Returns a pointer to the QuestDescription object of the QuestItem. 72 73 */ 73 inline constQuestDescription* getDescription(void) const74 inline QuestDescription* getDescription(void) const 74 75 { return this->description_; } 75 76 76 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 77 /** 78 @brief Check whether the QuestItem is registered with the QuestManager. 79 @return Returns true if the QuestItem is registered with the QuestManager. 80 */ 81 inline bool isRegistered(void) 82 { return this->registered_; } 83 /** 84 @brief Set the QuestItem as being registered with the QuestManager. 85 */ 86 inline void setRegistered(void) 87 { this->registered_ = true; } 77 88 78 89 protected: … … 90 101 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 91 102 103 bool registered_; 104 92 105 }; 93 106 -
code/trunk/src/modules/questsystem/QuestListener.cc
r6417 r7163 74 74 XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode); 75 75 76 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 77 78 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; 76 if(this->quest_ != NULL) 77 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 78 79 COUT(4) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; 79 80 } 80 81 -
code/trunk/src/modules/questsystem/QuestManager.cc
r6536 r7163 74 74 QuestManager::~QuestManager() 75 75 { 76 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++) 77 { 78 it->second->destroy(); 79 } 80 this->questGUIs_.clear(); 76 81 77 } 82 78 … … 114 110 if(result.second) //!< If inserting was a success. 115 111 { 116 COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; 112 quest->setRegistered(); 113 COUT(4) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; 117 114 return true; 118 115 } … … 122 119 return false; 123 120 } 121 } 122 123 /** 124 @brief 125 Unregisters a Quest in the QuestManager. 126 */ 127 bool QuestManager::unregisterQuest(Quest* quest) 128 { 129 return this->questMap_.erase(quest->getId()) == 1; 124 130 } 125 131 … … 146 152 if(result.second) //!< If inserting was a success. 147 153 { 148 COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; 154 hint->setRegistered(); 155 COUT(4) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; 149 156 return true; 150 157 } … … 154 161 return false; 155 162 } 163 } 164 165 /** 166 @brief 167 Unregisters a QuestHint in the QuestManager. 168 */ 169 bool QuestManager::unregisterHint(QuestHint* hint) 170 { 171 return this->hintMap_.erase(hint->getId()) == 1; 156 172 } 157 173 … … 169 185 Quest* QuestManager::findQuest(const std::string & questId) 170 186 { 171 if( !QuestItem::isId(questId)) //!< Check vor validity of the given id.187 if(questId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 172 188 { 173 189 ThrowException(Argument, "Invalid questId."); … … 203 219 QuestHint* QuestManager::findHint(const std::string & hintId) 204 220 { 205 if( !QuestItem::isId(hintId)) //!< Check vor validity of the given id.221 if(hintId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 206 222 { 207 223 ThrowException(Argument, "Invalid hintId."); … … 224 240 } 225 241 226 /** 227 @brief 228 Retreive the main window for the GUI. 229 This is for the use in the lua script tu start the QuestGUI. 230 @param guiName 231 The name of the GUI. 232 @return 233 Returns a CEGUI Window. 234 */ 235 CEGUI::Window* QuestManager::getQuestGUI(const std::string & guiName) 236 { 237 PlayerInfo* player = this->retrievePlayer(guiName); 238 239 if(this->questGUIs_.find(player) == this->questGUIs_.end()) //!< Create a new GUI, if there is none, yet. 240 this->questGUIs_[player] = new QuestGUI(player); 241 242 return this->questGUIs_[player]->getGUI(); 242 int QuestManager::getNumParentQuests(PlayerInfo* player) 243 { 244 int numQuests = 0; 245 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) 246 { 247 if(it->second->getParentQuest() == NULL && !it->second->isInactive(player)) 248 numQuests++; 249 } 250 return numQuests; 251 } 252 253 Quest* QuestManager::getParentQuest(PlayerInfo* player, int index) 254 { 255 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) 256 { 257 if(it->second->getParentQuest() == NULL && !it->second->isInactive(player) && index-- == 0) 258 return it->second; 259 } 260 return NULL; 261 } 262 263 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 264 { 265 std::list<Quest*> quests = quest->getSubQuestList(); 266 int numQuests = 0; 267 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 268 { 269 if(!(*it)->isInactive(player)) 270 numQuests++; 271 } 272 return numQuests; 273 } 274 275 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 276 { 277 std::list<Quest*> quests = quest->getSubQuestList(); 278 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) 279 { 280 if(!(*it)->isInactive(player) && index-- == 0) 281 return *it; 282 } 283 return NULL; 284 } 285 286 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) 287 { 288 std::list<QuestHint*> hints = quest->getHintsList(); 289 int numHints = 0; 290 for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++) 291 { 292 if((*it)->isActive(player)) 293 numHints++; 294 } 295 return numHints; 296 } 297 298 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) 299 { 300 std::list<QuestHint*> hints = quest->getHintsList(); 301 for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++) 302 { 303 if((*it)->isActive(player) && index-- == 0) 304 return *it; 305 } 306 return NULL; 307 } 308 309 QuestDescription* QuestManager::getDescription(Quest* item) 310 { 311 return item->getDescription(); 312 } 313 314 QuestDescription* QuestManager::getDescription(QuestHint* item) 315 { 316 return item->getDescription(); 243 317 } 244 318 -
code/trunk/src/modules/questsystem/QuestManager.h
r6536 r7163 36 36 37 37 #include "questsystem/QuestsystemPrereqs.h" 38 #include <CEGUIForwardRefs.h>39 38 40 39 #include <list> … … 44 43 #include "util/Singleton.h" 45 44 #include "core/OrxonoxClass.h" 46 47 #include "QuestGUI.h"48 45 49 46 // tolua_begin … … 63 60 64 61 friend class Singleton<QuestManager>; 65 friend class QuestGUI;66 62 67 63 public: … … 72 68 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 73 69 74 //! Retrieve the main window for the GUI. 75 CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export 70 // tolua_begin 71 int getNumParentQuests(orxonox::PlayerInfo* player); 72 Quest* getParentQuest(orxonox::PlayerInfo* player, int index); 73 74 int getNumSubQuests(Quest* quest, orxonox::PlayerInfo* player); 75 Quest* getSubQuest(Quest* quest, orxonox::PlayerInfo* player, int index); 76 77 int getNumHints(Quest* quest, orxonox::PlayerInfo* player); 78 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); 79 80 QuestDescription* getDescription(Quest* item); 81 QuestDescription* getDescription(QuestHint* item); 82 // tolua_end 76 83 77 84 bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 78 bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 85 bool unregisterQuest(Quest* quest); //!< Unregisters a Quest in the QuestManager. 86 bool registerHint(QuestHint* hint); //!< Registers a QuestHint in the QuestManager. 87 bool unregisterHint(QuestHint* hint); //!< Unregisters a QuestHint in the QuestManager. 79 88 80 89 Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id. … … 91 100 std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's. 92 101 93 std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.94 95 102 }; // tolua_export 96 103 -
code/trunk/src/modules/questsystem/QuestNotification.cc
r6417 r7163 32 32 namespace orxonox { 33 33 34 const std::string QuestNotification::SENDER("questsystem");34 /*static*/ const std::string QuestNotification::SENDER("questsystem"); 35 35 36 CreateUnloadableFactory(QuestNotification); 37 38 /** 39 @brief 40 Default Constructor. Creates a useless QuestNotification. 41 */ 36 42 QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator) 37 43 { 38 this->initialize();44 RegisterObject(QuestNotification); 39 45 } 40 46 41 QuestNotification::QuestNotification(const std::string & message) : Notification(message) 47 /** 48 @brief 49 Creates a QuestNotification with the input message. 50 @param message 51 The message to be sent. 52 */ 53 QuestNotification::QuestNotification(BaseObject* creator, const std::string & message) : Notification(creator, message) 42 54 { 43 this->initialize();55 RegisterObject(QuestNotification); 44 56 } 45 57 58 /** 59 @brief 60 Destructor. 61 */ 46 62 QuestNotification::~QuestNotification() 47 63 { … … 49 65 } 50 66 67 /** 68 @brief 69 Send the QuestNotification. 70 @return 71 Returns true if successful. 72 */ 51 73 bool QuestNotification::send(void) 52 74 { … … 54 76 } 55 77 56 void QuestNotification::initialize(void)57 {58 RegisterObject(QuestNotification);59 }60 61 78 62 79 } -
code/trunk/src/modules/questsystem/QuestNotification.h
- Property svn:executable deleted
r5781 r7163 39 39 /** 40 40 @brief 41 41 The QuestNotification is a special Notification that has the single property that it is only sent by the questsystem. 42 42 @author 43 43 Damian 'Mozork' Frick … … 46 46 { 47 47 public: 48 QuestNotification(BaseObject* creator); 49 QuestNotification( const std::string & message);50 virtual ~QuestNotification(); 48 QuestNotification(BaseObject* creator); //!< Default Constructor. 49 QuestNotification(BaseObject* creator, const std::string & message); //!< Constructor. 50 virtual ~QuestNotification(); //!< Destructor. 51 51 52 bool send(void); 52 bool send(void); //!< Send the QuestNotification. 53 53 54 54 private: 55 static const std::string SENDER; 56 57 void initialize(void); 55 static const std::string SENDER; //!< A string identifying the questsystem as the sender. 58 56 59 57 }; -
code/trunk/src/modules/questsystem/QuestsystemPrereqs.h
r5929 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( ORXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(QUESTSYSTEM_STATIC_BUILD) 46 46 # ifdef QUESTSYSTEM_SHARED_BUILD 47 47 # define _QuestsystemExport __declspec(dllexport) … … 77 77 class QuestEffect; 78 78 class QuestEffectBeacon; 79 class QuestGUI;80 class QuestGUINode;81 79 class QuestHint; 82 80 class QuestItem; -
code/trunk/src/modules/questsystem/notifications/Notification.cc
r6417 r7163 40 40 { 41 41 42 CreateUnloadableFactory(Notification); 43 42 44 /** 43 45 @brief … … 56 58 The message of the Notification. 57 59 */ 58 Notification::Notification( const std::string & message) : BaseObject(NULL)60 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator) 59 61 { 60 62 this->message_ = message; … … 67 69 Notification::~Notification() 68 70 { 71 69 72 } 70 73 -
code/trunk/src/modules/questsystem/notifications/Notification.h
r5781 r7163 53 53 public: 54 54 Notification(BaseObject* creator); 55 Notification( const std::string & message);55 Notification(BaseObject* creator, const std::string & message); 56 56 virtual ~Notification(); 57 57 -
code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
r6417 r7163 66 66 NotificationManager::~NotificationManager() 67 67 { 68 68 69 } 69 70 … … 101 102 this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener. 102 103 it->first->update(notification, time); //!< Update the listener. 104 std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(notification); 105 if(counterIt == this->listenerCounter_.end()) 106 this->listenerCounter_[notification] = 1; 107 else 108 this->listenerCounter_[notification] = counterIt->second + 1; 103 109 } 104 110 } 105 111 106 COUT( 3) << "Notification registered with the NotificationManager." << std::endl;112 COUT(4) << "Notification registered with the NotificationManager." << std::endl; 107 113 108 114 return true; 115 } 116 117 /** 118 @brief 119 Unregisters a Notification within the NotificationManager. 120 @param notification 121 A pointer to the Notification to be unregistered. 122 @param listener 123 A pointer to the NotificationListener the Notification is unregistered for. 124 */ 125 void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener) 126 { 127 assert(notification); 128 assert(listener); 129 130 // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented. 131 if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second))) 132 this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1; 133 134 // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed. 135 if(this->listenerCounter_[notification] == (unsigned int) 0) 136 { 137 this->removeNotification(notification, this->allNotificationsList_); 138 this->listenerCounter_.erase(notification); 139 notification->destroy(); 140 } 141 142 COUT(4) << "Notification unregistered with the NotificationManager." << std::endl; 143 } 144 145 /** 146 @brief 147 Helper method that removes an input notification form an input map. 148 @param notification 149 A pointer to the notification to be removed. 150 @param map 151 The map the notification should be removed from. 152 @return 153 Returns true if successful. 154 */ 155 bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map) 156 { 157 // Iterates through all items in the map until the Notification is found. 158 //TODO: Do more efficiently? 159 for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++) 160 { 161 if(it->second == notification) 162 { 163 map.erase(it); 164 return true; 165 } 166 } 167 return false; 109 168 } 110 169 … … 130 189 { 131 190 this->notificationLists_[index] = &this->allNotificationsList_; 132 COUT( 3) << "NotificationListener registered with the NotificationManager." << std::endl;191 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 133 192 return true; 134 193 } … … 142 201 if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target. 143 202 { 144 map.insert(std::pair<std::time_t,Notification*>(it->first, it->second)); 203 map.insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 204 std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(it->second); 205 if(counterIt == this->listenerCounter_.end()) 206 this->listenerCounter_[it->second] = 1; 207 else 208 this->listenerCounter_[it->second] = counterIt->second + 1; 145 209 } 146 210 } … … 148 212 listener->update(); //!< Update the listener. 149 213 150 COUT( 3) << "NotificationListener registered with the NotificationManager." << std::endl;214 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 151 215 152 216 return true; 217 } 218 219 /** 220 @brief 221 Unregisters a NotificationListener withing the NotificationManager. 222 */ 223 void NotificationManager::unregisterListener(NotificationListener* listener) 224 { 225 assert(listener); 226 227 int identifier = this->listenerList_.find(listener)->second; 228 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second; 229 230 // Make sure all Notifications are removed. 231 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 232 while(it != map->end()) 233 { 234 this->unregisterNotification(it->second, listener); 235 it = map->begin(); 236 } 237 238 this->listenerList_.erase(listener); 239 this->notificationLists_.erase(identifier); 240 241 // If the map is not the map of all notifications, delete it. 242 if(map != &this->allNotificationsList_) 243 delete map; 244 245 COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl; 153 246 } 154 247 -
code/trunk/src/modules/questsystem/notifications/NotificationManager.h
r5929 r7163 60 60 virtual ~NotificationManager(); 61 61 62 static const std::string ALL; 63 static const std::string NONE; 62 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. 63 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. 64 64 65 65 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 66 void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager. 66 67 bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. 68 void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager. 67 69 68 70 bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe. … … 90 92 static NotificationManager* singletonPtr_s; 91 93 92 int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that 94 int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. 93 95 94 std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).96 std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored. 95 97 std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. 96 98 std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. 99 std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with. 97 100 101 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map. 98 102 99 103 }; -
code/trunk/src/modules/questsystem/notifications/NotificationOverlay.cc
- Property svn:executable deleted
-
code/trunk/src/modules/questsystem/notifications/NotificationOverlay.h
- Property svn:executable deleted
-
code/trunk/src/modules/questsystem/notifications/NotificationQueue.cc
r6502 r7163 34 34 #include "NotificationQueue.h" 35 35 36 #include <sstream> 37 36 #include "util/Convert.h" 38 37 #include "core/CoreIncludes.h" 39 38 #include "core/XMLPort.h" … … 56 55 NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator) 57 56 { 57 this->registered_ = false; 58 58 59 RegisterObject(NotificationQueue); 59 60 this->initialize(); … … 68 69 this->targets_.clear(); 69 70 this->clear(); 71 72 if(this->registered_) 73 NotificationManager::getInstance().unregisterListener(this); 70 74 } 71 75 … … 81 85 82 86 NotificationManager::getInstance().registerListener(this); 87 this->registered_ = true; 83 88 } 84 89 … … 118 123 XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode); 119 124 120 COUT(3) << "NotificationQueue created." << std::endl;125 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 121 126 } 122 127 … … 173 178 delete notifications; 174 179 175 COUT( 3) << "NotificationQueueupdated." << std::endl;180 COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl; 176 181 } 177 182 … … 196 201 } 197 202 198 COUT( 3) << "NotificationQueueupdated. A new Notifications has been added." << std::endl;203 COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl; 199 204 } 200 205 … … 397 402 std::string timeString = std::ctime(&time); 398 403 timeString.erase(timeString.length()-1); 399 std::ostringstream stream; 400 stream << reinterpret_cast<unsigned long>(notification); 401 const std::string& addressString = stream.str(); 404 const std::string& addressString = multi_cast<std::string>(reinterpret_cast<unsigned long>(notification)); 402 405 container->name = "NotificationOverlay(" + timeString + ")&" + addressString; 403 406 … … 422 425 if(this->size_ == 0) //!< You cannot remove anything if the queue is empty. 423 426 return false; 427 428 // Unregister the NotificationQueue with the NotificationManager. 429 NotificationManager::getInstance().unregisterNotification(container->notification, this); 424 430 425 431 this->removeElement(container->overlay); … … 443 449 { 444 450 this->removeContainer(*it); 445 it = this->containers_.begin(); //TODO: Needed?451 it = this->containers_.begin(); 446 452 } 447 453 } -
code/trunk/src/modules/questsystem/notifications/NotificationQueue.h
r5781 r7163 71 71 72 72 Creating a NotificationQueue through XML goes as follows: 73 Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen. 73 74 <NotificationQueue 74 75 name = "SuperQueue" //Name of your OverlayQueue. … … 185 186 NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 186 187 188 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already. 189 187 190 void initialize(void); //!< Initializes the object. 188 191 void setDefaults(void); //!< Helper method to set the default values. -
code/trunk/src/modules/weapons/CMakeLists.txt
r5781 r7163 1 1 SET_SOURCE_FILES(WEAPONS_SRC_FILES 2 2 MuzzleFlash.cc 3 RocketController.cc 3 4 ) 4 5 … … 12 13 PCH_FILE 13 14 WeaponsPrecompiledHeaders.h 14 DEFINE_SYMBOL15 "WEAPONS_SHARED_BUILD"16 15 LINK_LIBRARIES 17 16 orxonox -
code/trunk/src/modules/weapons/WeaponsPrereqs.h
r5929 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( ORXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(WEAPONS_STATIC_BUILD) 46 46 # ifdef WEAPONS_SHARED_BUILD 47 47 # define _WeaponsExport __declspec(dllexport) -
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
r6417 r7163 5 5 LightningGunProjectile.cc 6 6 Rocket.cc 7 SimpleRocket.cc 7 8 ) -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r6540 r7163 41 41 #include "controllers/Controller.h" 42 42 #include "sound/WorldSound.h" 43 #include "Scene.h" 43 44 44 45 namespace orxonox … … 87 88 this->defSndWpnEngine_->setLooping(true); 88 89 this->defSndWpnEngine_->setSource("sounds/Rocket_engine.ogg"); 90 this->defSndWpnEngine_->setVolume(100); 89 91 this->attach(defSndWpnEngine_); 90 92 … … 92 94 this->defSndWpnLaunch_->setLooping(false); 93 95 this->defSndWpnLaunch_->setSource("sounds/Rocket_launch.ogg"); 96 this->defSndWpnLaunch_->setVolume(100); 94 97 this->attach(defSndWpnLaunch_); 95 98 } … … 114 117 if(this->isInitialized()) 115 118 { 116 if (GameMode::isMaster() && this->player_) 117 this->player_->stopTemporaryControl(); 119 if (GameMode::isMaster()) 120 { 121 this->destructionEffect(); 122 123 if (this->getPlayer() && this->getController()) 124 this->player_->stopTemporaryControl(); 125 } 118 126 119 127 if ( this->defSndWpnEngine_ ) … … 138 146 { 139 147 this->owner_ = owner; 140 this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();141 148 this->player_ = this->owner_->getPlayer(); 142 149 this->owner_->getPlayer()->startTemporaryControl(this); … … 164 171 this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() ); 165 172 this->localAngularVelocity_ = 0; 166 173 } 174 175 if( GameMode::isMaster() ) 176 { 167 177 if( this->bDestroy_ ) 168 178 this->destroy(); 179 169 180 } 170 181 } … … 222 233 void Rocket::fired(unsigned int firemode) 223 234 { 224 if (this->owner_) 225 { 226 { 227 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 228 effect->setPosition(this->getPosition()); 229 effect->setOrientation(this->getOrientation()); 230 effect->setDestroyAfterLife(true); 231 effect->setSource("Orxonox/explosion4"); 232 effect->setLifetime(2.0f); 233 } 234 235 { 236 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 237 effect->setPosition(this->getPosition()); 238 effect->setOrientation(this->getOrientation()); 239 effect->setDestroyAfterLife(true); 240 effect->setSource("Orxonox/smoke4"); 241 effect->setLifetime(3.0f); 242 } 235 // if (this->owner_) 236 // { 243 237 this->destroy(); 244 } 238 // } 239 } 240 241 void Rocket::destructionEffect() 242 { 243 ParticleSpawner *effect1, *effect2; 244 if( this->owner_ ) 245 { 246 effect1 = new ParticleSpawner(this->owner_->getCreator()); 247 effect2 = new ParticleSpawner(this->owner_->getCreator()); 248 } 249 else 250 { 251 effect1 = new ParticleSpawner(static_cast<BaseObject*>(this->getScene().get())); 252 effect2 = new ParticleSpawner(static_cast<BaseObject*>(this->getScene().get())); 253 } 254 255 effect1->setPosition(this->getPosition()); 256 effect1->setOrientation(this->getOrientation()); 257 effect1->setDestroyAfterLife(true); 258 effect1->setSource("Orxonox/explosion4"); 259 effect1->setLifetime(2.0f); 260 261 effect2->setPosition(this->getPosition()); 262 effect2->setOrientation(this->getOrientation()); 263 effect2->setDestroyAfterLife(true); 264 effect2->setSource("Orxonox/smoke4"); 265 effect2->setLifetime(3.0f); 245 266 } 246 267 -
code/trunk/src/modules/weapons/projectiles/Rocket.h
r6417 r7163 57 57 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 58 58 void destroyObject(); 59 void destructionEffect(); 59 60 60 61 virtual void moveFrontBack(const Vector2& value){} … … 119 120 float damage_; 120 121 bool bDestroy_; 121 ControllableEntity* originalControllableEntity_;122 122 123 123 WeakPtr<PlayerInfo> player_; -
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
r6417 r7163 6 6 LightningGun.cc 7 7 RocketFire.cc 8 SimpleRocketFire.cc 8 9 )
Note: See TracChangeset
for help on using the changeset viewer.