Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 1:07:27 AM (15 years ago)
Author:
dafrick
Message:

Merging the QuestSystem branch to the trunk. Let's hope, this isn't a 'third time's the charm'-thing…

Location:
code/trunk/src/orxonox/objects/quest
Files:
2 added
35 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/quest/AddQuest.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddQuest.cc
    3131    @brief Implementation of the AddQuest class.
    3232*/
     
    4242#include "orxonox/objects/infos/PlayerInfo.h"
    4343#include "QuestManager.h"
     44#include "QuestDescription.h"
    4445#include "Quest.h"
    4546
     
    9697        try
    9798        {
    98             Quest* quest = QuestManager::findQuest(this->getQuestId());
     99            Quest* quest = QuestManager::getInstance().findQuest(this->getQuestId());
    99100            if(quest == NULL || !quest->start(player))
    100101            {
  • code/trunk/src/orxonox/objects/quest/AddQuest.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddQuest.h
    3131    @brief Definition of the AddQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddQuestHint.cc
    3131    @brief Implementation of the AddQuestHint class.
    3232*/
     
    117117        try
    118118        {
    119             QuestHint* hint = QuestManager::findHint(this->hintId_);
     119            QuestHint* hint = QuestManager::getInstance().findHint(this->hintId_);
    120120            if(hint == NULL || !hint->setActive(player))
    121121            {
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddQuestHint.h
    3131    @brief Definition of the AddQuestHint class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/AddReward.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddReward.cc
    3131    @brief Implementation of the AddReward class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/AddReward.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file AddReward.h
    3131    @brief Definition of the AddReward class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/CMakeLists.txt

    r2710 r2909  
    1616  QuestListener.cc
    1717  QuestManager.cc
     18  QuestNotification.cc
    1819  Rewardable.cc
    1920)
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file ChangeQuestStatus.cc
    3131    @brief Implementation of the ChangeQuestStatus class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file ChangeQuestStatus.h
    3131    @brief Definition of the ChangeQuestStatus class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file CompleteQuest.cc
    3131    @brief Implementation of the CompleteQuest class.
    3232*/
     
    9696        try
    9797        {
    98             quest = QuestManager::findQuest(this->getQuestId());
     98            quest = QuestManager::getInstance().findQuest(this->getQuestId());
    9999            if(quest == NULL || !quest->complete(player))
    100100            {
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file CompleteQuest.h
    3131    @brief Definition of the CompleteQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/FailQuest.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file FailQuest.cc
    3131    @brief Implementation of the FailQuest class.
    3232*/
     
    9595        try
    9696        {
    97             quest = QuestManager::findQuest(this->getQuestId());
     97            quest = QuestManager::getInstance().findQuest(this->getQuestId());
    9898            if(quest == NULL || !quest->fail(player))
    9999            {
  • code/trunk/src/orxonox/objects/quest/FailQuest.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file FailQuest.h
    3131    @brief Definition of the FailQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file GlobalQuest.cc
    3131    @brief Implementation of the GlobalQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file GlobalQuest.h
    3131    @brief Definition of the GlobalQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/LocalQuest.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file LocalQuest.cc
    3131    @brief Implementation of the LocalQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/LocalQuest.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file LocalQuest.h
    3131    @brief Definition of the LocalQuest class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/Quest.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file Quest.cc
    3131    @brief Implementation of the Quest class.
    3232*/
     
    7979        XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode);
    8080
    81         QuestManager::registerQuest(this); //!<Registers the Quest with the QuestManager.
     81        QuestManager::getInstance().registerQuest(this); //!<Registers the Quest with the QuestManager.
    8282    }
    8383
  • code/trunk/src/orxonox/objects/quest/Quest.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file Quest.h
    3131    @brief Definition of the Quest class.
    3232        The Quest is the parent class of LocalQuest and GlobalQuest.
  • code/trunk/src/orxonox/objects/quest/QuestDescription.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestDescription.cc
    3131    @brief Implementation of the QuestDescription class.
    3232*/
     
    3737
    3838#include "core/CoreIncludes.h"
    39 #include "orxonox/overlays/notifications/Notification.h"
     39#include "QuestNotification.h"
    4040
    4141namespace orxonox
     
    8989    @return
    9090        Returns true if successful.
     91    @todo
     92        Make sure the messages meet the conditions.
    9193    */
    9294    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
    9395    {
    9496        std::string message = "";
    95         std::string title = "";
    9697        if(item == "hint")
    9798        {
    98             title = "You received a hint: '" + this->title_ + "'";
    99             message = this->description_;
     99            message = "You received a hint: '" + this->title_ + "'";
    100100        }
    101101        else if(item == "quest")
     
    103103            if(status == "start")
    104104            {
    105                 title = "You received a new quest: '" + this->title_ + "'";
    106                 message = this->description_;
     105                message = "You received a new quest: '" + this->title_ + "'";
    107106            }
    108107            else if(status == "fail")
    109108            {
    110                 title = "You failed the quest: '" + this->title_ + "'";
    111                 message = this->failMessage_;
     109                message = "You failed the quest: '" + this->title_ + "'";
    112110            }
    113111            else if(status == "complete")
    114112            {
    115                 title = "You successfully completed the quest: '" + this->title_ + "'";
    116                 message = this->completeMessage_;
     113                message = "You successfully completed the quest: '" + this->title_ + "'";
    117114            }
    118115            else
     
    128125        }
    129126       
    130         Notification* notification = new Notification(0, message, title, 30);
     127        QuestNotification* notification = new QuestNotification(message);
    131128        notification->send();
    132129        return true;
  • code/trunk/src/orxonox/objects/quest/QuestDescription.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestDescription.h
    3131    @brief Definition of the QuestDescription class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestEffect.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestEffect.cc
    3131    @brief Implementation of the QuestEffect class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestEffect.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file QuestEffect.h
    3131    @brief Definition of the QuestEffect class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2662 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestEffectBeacon.cc
    3131    @brief Implementation of the QuestEffectBeacon class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2662 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestEffectBeacon.h
    3131    @brief Definition of the QuestEffectBeacon class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestHint.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file QuestHint.cc
    3131    @brief Implementation of the QuestHint class.
    3232*/
     
    7373        SUPER(QuestHint, XMLPort, xmlelement, mode);
    7474
    75         QuestManager::registerHint(this); //!< Registers the QuestHint with the QuestManager.
     75        QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager.
    7676       
    7777        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
  • code/trunk/src/orxonox/objects/quest/QuestHint.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file QuestHint.h
    3131    @brief Definition of the QuestHint class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestItem.cc

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file QuestItem.cc
    3131    @brief Implementation of the QuestItem class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestItem.h

    r2896 r2909  
    2828 
    2929/**
    30     @file
     30    @file QuestItem.h
    3131    @brief Definition of the QuestItem class.
    3232        The QuestItem is the parent class of Quest and QuestHint.
  • code/trunk/src/orxonox/objects/quest/QuestListener.cc

    r2662 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestListener.cc
    3131    @brief Implementation of the QuestListener class.
    3232*/
     
    112112    bool QuestListener::setQuestId(const std::string & id)
    113113    {
    114         this->quest_ = QuestManager::findQuest(id); //!< Find the Quest corresponding to the given questId.
     114        this->quest_ = QuestManager::getInstance().findQuest(id); //!< Find the Quest corresponding to the given questId.
    115115       
    116116        if(this->quest_ == NULL) //!< If there is no such Quest.
  • code/trunk/src/orxonox/objects/quest/QuestListener.h

    r2662 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestListener.h
    3131    @brief Definition of the QuestListener class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/QuestManager.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestManager.cc
    3131    @brief Implementation of the QuestManager class.
    3232*/
     
    4343namespace orxonox
    4444{
    45     //! All Quests registered by their id's.
    46     std::map<std::string, Quest*> QuestManager::questMap_s;
    47     //! All QuestHints registered by their id's.
    48     std::map<std::string, QuestHint*> QuestManager::hintMap_s;
     45    //! Pointer to the current (and single) instance of this class.
     46    QuestManager* QuestManager::singletonRef_s = NULL;
    4947
    5048    /**
    5149    @brief
    5250        Constructor. Registers the object.
    53     */
    54     QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator)
    55     {
    56         RegisterObject(QuestManager);
     51    @todo
     52        Is inheriting from BaseObject proper?
     53    */
     54    QuestManager::QuestManager()
     55    {
     56        RegisterRootObject(QuestManager);
     57
     58        assert(singletonRef_s == 0);
     59        singletonRef_s = this;
    5760    }
    5861
     
    6467    {
    6568
     69    }
     70
     71    /**
     72    @brief
     73        Returns a reference to the current (and single) instance of the QuestManager, and creates one if there isn't one to begin with.
     74    @return
     75        Returns a reference to the single instance of the Quest Manager.
     76    */
     77    /*static*/ QuestManager & QuestManager::getInstance()
     78    {
     79        assert(singletonRef_s);
     80        return *singletonRef_s;
    6681    }
    6782
     
    7590        Returns true if successful, false if not.
    7691    */
    77     /*static*/ bool QuestManager::registerQuest(Quest* quest)
     92    bool QuestManager::registerQuest(Quest* quest)
    7893    {
    7994        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
     
    8499
    85100        std::pair<std::map<std::string, Quest*>::iterator,bool> result;
    86         result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
     101        result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
    87102
    88103        if(result.second) //!< If inserting was a success.
     
    107122        Returns true if successful, false if not.
    108123    */
    109     /*static*/ bool QuestManager::registerHint(QuestHint* hint)
     124    bool QuestManager::registerHint(QuestHint* hint)
    110125    {
    111126        if(hint == NULL) //!< Still not liking NULL-pointers.
     
    116131
    117132        std::pair<std::map<std::string, QuestHint*>::iterator,bool> result;
    118         result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
     133        result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
    119134
    120135        if(result.second) //!< If inserting was a success.
     
    141156        Throws an exception if the given questId is invalid.
    142157    */
    143     /*static*/ Quest* QuestManager::findQuest(const std::string & questId)
     158    Quest* QuestManager::findQuest(const std::string & questId)
    144159    {
    145160        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
     
    149164
    150165        Quest* quest;
    151         std::map<std::string, Quest*>::iterator it = questMap_s.find(questId);
    152         if (it != questMap_s.end()) //!< If the Quest is registered.
     166        std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId);
     167        if (it != this->questMap_.end()) //!< If the Quest is registered.
    153168        {
    154169            quest = it->second;
     
    175190        Throws an exception if the given hintId is invalid.
    176191    */
    177     /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId)
     192    QuestHint* QuestManager::findHint(const std::string & hintId)
    178193    {
    179194        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
     
    183198
    184199        QuestHint* hint;
    185         std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId);
    186         if (it != hintMap_s.end()) //!< If the QuestHint is registered.
     200        std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId);
     201        if (it != this->hintMap_.end()) //!< If the QuestHint is registered.
    187202        {
    188203            hint = it->second;
  • code/trunk/src/orxonox/objects/quest/QuestManager.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestManager.h
    3131    @brief Definition of the QuestManager class.
    3232*/
     
    4040#include <string>
    4141
    42 #include "core/BaseObject.h"
     42#include "core/OrxonoxClass.h"
    4343
    4444namespace orxonox
     
    4646    /**
    4747    @brief
    48         Is a static class and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).
     48        Is a Singleton and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).
    4949        Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way.
    5050    @author
    5151        Damian 'Mozork' Frick
    5252    */
    53     class _OrxonoxExport QuestManager : public BaseObject
     53    class _OrxonoxExport QuestManager : public OrxonoxClass
    5454    {
    55 
    5655        public:
    57             QuestManager(BaseObject* creator);
     56            QuestManager();
    5857            virtual ~QuestManager();
    5958
    60             static bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
    61             static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
     59            static QuestManager& getInstance(); //!< Returns a reference to the single instance of the Quest Manager.
    6260
    63             static Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id.
    64             static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
     61            bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
     62            bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
     63
     64            Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id.
     65            QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
    6566
    6667        private:
    67             static std::map<std::string, Quest*> questMap_s; //!< All Quests registered by their id's.
    68             static std::map<std::string, QuestHint*> hintMap_s; //!< All QuestHints registered by their id's.
     68            static QuestManager* singletonRef_s;
     69
     70            std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
     71            std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
    6972
    7073    };
  • code/trunk/src/orxonox/objects/quest/Rewardable.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file Rewardable.cc
    3131    @brief Implementation of the Rewardable class.
    3232*/
  • code/trunk/src/orxonox/objects/quest/Rewardable.h

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file Rewardable.h
    3131    @brief Definition of the Rewardable class.
    3232*/
Note: See TracChangeset for help on using the changeset viewer.