Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5617


Ignore:
Timestamp:
Aug 11, 2009, 12:27:38 AM (15 years ago)
Author:
landauf
Message:

Reduced dependencies between orxonox and overlays: GUIOverlays send their owners to a map in the QuestManager instead of the QuestManager asking the GUIOverlays.

Location:
code/branches/libraries/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/libraries/src/orxonox/objects/quest/QuestManager.cc

    r3370 r5617  
    3838
    3939#include "objects/infos/PlayerInfo.h"
    40 #include "objects/infos/PlayerInfo.h"
    41 #include "overlays/GUIOverlay.h"
    4240#include "Quest.h"
    4341#include "QuestHint.h"
     
    203201    /**
    204202    @brief
    205        
     203
    206204    @param name
    207205    @return
     
    209207    QuestContainer* QuestManager::getQuestTree(std::string & name)
    210208    {
    211         GUIOverlay* gui = NULL;
    212         for (ObjectList<GUIOverlay>::iterator it = ObjectList<GUIOverlay>::begin(); it != ObjectList<GUIOverlay>::end(); ++it)
    213             if (it->getGUIName() == name)
    214                 gui = *it;
    215 
    216         PlayerInfo* player;
    217         if(gui == NULL)
    218         {
    219             COUT(1) << "Error: No GUIOverlay with the given name '" << name << "' present." << std::endl;
     209        PlayerInfo* player = this->players_[name];
     210        if(player == NULL)
     211        {
     212            COUT(1) << "Error: GUIOverlay with name '" << name << "' has no player." << std::endl;
    220213            return NULL;
    221214        }
    222         BaseObject* obj = gui->getOwner();
    223         if(obj == NULL)
    224         {
    225             COUT(1) << "Error: GUIOverlay has no owner. " << std::endl;
    226             return NULL;
    227         }
    228         player = orxonox_cast<PlayerInfo*>(obj);
    229    
     215
    230216        QuestContainer* root = NULL;
    231217        QuestContainer* current = NULL;
    232        
     218
    233219        std::list<Quest*>* rootQuests = new std::list<Quest*>();
    234220        getRootQuests(player, *rootQuests);
    235        
     221
    236222        for(std::list<Quest*>::iterator it = rootQuests->begin(); it != rootQuests->end(); it++)
    237223        {
     
    246232                current->next = container;
    247233            }
    248            
     234
    249235            current = container;
    250236
     
    260246    /**
    261247    @brief
    262        
     248
    263249    @param player
    264250    @param list
     
    279265    /**
    280266    @brief
    281        
     267
    282268    @param quest
    283269    @param player
     
    310296            COUT(1) << "An error occurred. A Quest of un-specified status wanted to be displayed." << std::endl;
    311297        }
    312        
     298
    313299        std::list<Quest*> quests = quest->getSubQuestList();
    314300        QuestContainer* current = NULL;
     
    329315                    current->next = subContainer;
    330316                }
    331                
     317
    332318                current = subContainer;
    333319            }
     
    336322            current->next = NULL;
    337323        container->subQuests = first;
    338        
     324
    339325        return container;
    340326    }
     
    342328    /**
    343329    @brief
    344        
     330
    345331    @param quest
    346332    @param player
     
    368354                    current->next = hint;
    369355                }
    370                
     356
    371357                current = hint;
    372358            }
  • code/branches/libraries/src/orxonox/objects/quest/QuestManager.h

    r3370 r5617  
    9292            QuestContainer* getQuestTree(std::string & name); // tolua_export
    9393
     94            inline void setPlayer(const std::string& guiname, PlayerInfo* player)
     95                { this->players_[guiname] = player; }
     96            inline PlayerInfo* getPlayer(const std::string& guiname) const
     97                { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
     98
    9499        private:
    95100            static QuestManager* singletonPtr_s;
     
    97102            std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
    98103            std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
     104            std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui
    99105
    100106            void getRootQuests(const PlayerInfo* player, std::list<Quest*> & list);
  • code/branches/libraries/src/orxonox/overlays/GUIOverlay.cc

    r3370 r5617  
    3636#include "core/GUIManager.h"
    3737#include "core/XMLPort.h"
     38#include "objects/quest/QuestManager.h"
     39#include "objects/infos/PlayerInfo.h"
    3840
    3941namespace orxonox
     
    7981    }
    8082
     83    void GUIOverlay::setGUIName(const std::string& name)
     84    {
     85        this->guiName_ = name;
     86        QuestManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner()));
     87    }
    8188}
  • code/branches/libraries/src/orxonox/overlays/GUIOverlay.h

    r3196 r5617  
    4646            virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4747
    48             inline void setGUIName(const std::string& name) { this->guiName_ = name; }
     48            void setGUIName(const std::string& name);
    4949            inline const std::string& getGUIName() const { return this->guiName_; }
    5050
Note: See TracChangeset for help on using the changeset viewer.