Changeset 6996 for code/branches/presentation3/src
- Timestamp:
- May 27, 2010, 10:44:10 PM (14 years ago)
- Location:
- code/branches/presentation3/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/libraries/core/GUIManager.h
r6749 r6996 84 84 //! Creates a new InputState to be used with a GUI Sheet 85 85 const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export 86 LuaState* getLuaState(void) 87 { return this->luaState_.get(); } 86 88 87 89 //! Returns the root window for all menu sheets … … 102 104 103 105 static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export 104 106 105 107 private: 106 108 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 107 108 109 void executeCode(const std::string& str); 110 109 111 template <typename FunctionType> 110 112 bool protectedCall(FunctionType function); -
code/branches/presentation3/src/modules/pickup/PickupManager.cc
r6965 r6996 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" … … 64 65 65 66 this->defaultRepresentation_ = new PickupRepresentation(); 66 this->pickupsIndex_ = 0;67 67 68 68 COUT(3) << "PickupManager created." << std::endl; … … 154 154 { 155 155 this->pickupsList_.clear(); 156 this->pickupsIndex_ = 0;157 156 158 157 PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s); … … 169 168 for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++) 170 169 { 171 this->pickupsList_.insert( *pickup);170 this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup))); 172 171 } 173 172 } … … 199 198 void PickupManager::dropPickup(orxonox::Pickupable* pickup) 200 199 { 200 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 201 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 202 return; 203 201 204 if(!pickup->isPickedUp()) 202 205 return; 203 206 204 207 PickupCarrier* carrier = pickup->getCarrier(); 205 208 if(pickup != NULL && carrier != NULL) 209 { 206 210 carrier->drop(pickup); 211 } 207 212 } 208 213 209 214 void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use) 210 215 { 216 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 217 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 218 return; 219 211 220 if(!pickup->isPickedUp()) 212 221 return; -
code/branches/presentation3/src/modules/pickup/PickupManager.h
r6965 r6996 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" … … 72 73 // tolua_begin 73 74 int getNumPickups(void); 74 orxonox::Pickupable* popPickup(void) { this->pickupsIndex_++; return *(this->pickupsIterator_++); } 75 int getPickupIndex(void) { return this->pickupsIndex_-1; } 75 orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; } 76 76 orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; } 77 77 78 78 void dropPickup(orxonox::Pickupable* pickup); 79 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; } 80 81 // tolua_end 81 82 … … 87 88 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 88 89 89 std::set<Pickupable*> pickupsList_; 90 std::set<Pickupable*>::iterator pickupsIterator_; 91 int pickupsIndex_; 90 std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_; 91 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_; 92 92 93 93 std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier); -
code/branches/presentation3/src/orxonox/gametypes/Gametype.cc
r6417 r6996 309 309 if (this->spawnpoints_.size() > 0) 310 310 { 311 SpawnPoint* fallbackSpawnPoint = NULL; 311 312 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 312 313 unsigned int index = 0; 314 std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_; 313 315 for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it) 316 { 317 if (index == randomspawn) 318 fallbackSpawnPoint = (*it); 319 320 if (!(*it)->isActive()) 321 activeSpawnPoints.erase(*it); 322 323 ++index; 324 } 325 326 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 327 index = 0; 328 for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it) 314 329 { 315 330 if (index == randomspawn) 316 331 return (*it); 317 332 318 333 ++index; 319 334 } 335 336 return fallbackSpawnPoint; 320 337 } 321 338 return 0; -
code/branches/presentation3/src/orxonox/interfaces/Pickupable.cc
r6901 r6996 34 34 #include "Pickupable.h" 35 35 36 #include "core/LuaState.h" 37 #include "core/GUIManager.h" 36 38 #include "core/Identifier.h" 37 39 #include "core/CoreIncludes.h" 40 #include "util/Convert.h" 41 #include "infos/PlayerInfo.h" 38 42 #include "pickup/PickupIdentifier.h" 43 #include "worldentities/pawns/Pawn.h" 39 44 #include "PickupCarrier.h" 40 45 … … 91 96 this->used_ = used; 92 97 this->changedUsed(); 98 99 GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()"); 93 100 return true; 94 101 } … … 196 203 this->pickedUp_ = pickedUp; 197 204 this->changedPickedUp(); 205 GUIManager::getInstance().getLuaState()->doString("PickupInventory.update()"); 198 206 return true; 199 207 } … … 273 281 SUPER(Pickupable, clone, item); 274 282 } 283 284 /** 285 @brief 286 Method to transcribe a Pickupable as a Rewardable to the player. 287 @param player 288 A pointer to the PlayerInfo, do whatever you want with it. 289 @return 290 Return true if successful. 291 */ 292 bool Pickupable::reward(PlayerInfo* player) 293 { 294 ControllableEntity* entity = player->getControllableEntity(); 295 Pawn* pawn = static_cast<Pawn*>(entity); 296 PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn); 297 return carrier->pickup(this); 298 } 275 299 276 300 } -
code/branches/presentation3/src/orxonox/interfaces/Pickupable.h
r6965 r6996 41 41 42 42 #include "core/OrxonoxClass.h" 43 #include "Rewardable.h" 43 44 44 45 namespace orxonox // tolua_export … … 52 53 */ 53 54 class _OrxonoxExport Pickupable // tolua_export 54 : virtual public OrxonoxClass 55 : virtual public OrxonoxClass, public Rewardable 55 56 { // tolua_export 56 57 protected: … … 141 142 std::list<Identifier*> targets_; //!< The possible targets of this pickup. 142 143 144 // For implementing the Rewardable interface: 145 public: 146 virtual bool reward(PlayerInfo* player); //!< Method to transcribe a Pickupable as a Rewardable to the player. 147 143 148 }; // tolua_export 144 149 -
code/branches/presentation3/src/orxonox/interfaces/Rewardable.h
r6417 r6996 48 48 Damian 'Mozork' Frick 49 49 */ 50 class _OrxonoxExport Rewardable : public OrxonoxClass50 class _OrxonoxExport Rewardable : virtual public OrxonoxClass 51 51 { 52 52 public: … … 59 59 Must be implemented by every class inheriting from Rewardable. 60 60 @param player 61 A pointer to the ControllableEntity, do whatever you want with it.61 A pointer to the PlayerInfo, do whatever you want with it. 62 62 @return 63 63 Return true if successful.
Note: See TracChangeset
for help on using the changeset viewer.