Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2010, 8:55:13 AM (14 years ago)
Author:
dafrick
Message:

Merged presentation3 branch into trunk.

Location:
code/trunk
Files:
4 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/questsystem/AddQuest.cc

    r5781 r7163  
    6868        SUPER(AddQuest, XMLPort, xmlelement, mode);
    6969
    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;
    7171    }
    7272
     
    8787        }
    8888
    89         COUT(3) << "AddQuest on player: " << player << " ." << std::endl;
     89        COUT(5) << "AddQuest on player: " << player << " ." << std::endl;
    9090
    9191        try
     
    103103        }
    104104
    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;
    106106        return true;
    107107    }
  • code/trunk/src/modules/questsystem/AddQuestHint.cc

    r6417 r7163  
    7272        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
    7373
    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;
    7575    }
    7676
     
    8585    bool AddQuestHint::setHintId(const std::string & id)
    8686    {
    87         if(!QuestItem::isId(id))
     87        if(id.compare(BLANKSTRING) == 0)
    8888        {
    8989            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
     
    111111        }
    112112
    113         COUT(3) << "AddQuestHint on player: " << player << " ." << std::endl;
     113        COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl;
    114114
    115115        try
     
    127127        }
    128128
    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;
    130130        return true;
    131131
  • code/trunk/src/modules/questsystem/AddReward.cc

    r6417 r7163  
    6868        XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
    6969
    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;
    7171    }
    7272
     
    103103    bool AddReward::invoke(PlayerInfo* player)
    104104    {
    105         COUT(3) << "AddReward on player: " << player << " ." << std::endl;
     105        COUT(5) << "AddReward on player: " << player << " ." << std::endl;
    106106
    107107        bool check = true;
     
    111111        }
    112112
    113         COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl;
     113        COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl;
    114114
    115115        return check;
  • code/trunk/src/modules/questsystem/CMakeLists.txt

    r6800 r7163  
    1212  QuestEffect.cc
    1313  QuestEffectBeacon.cc
    14   QuestGUINode.cc
    15   QuestGUI.cc
    1614  QuestHint.cc
    1715  QuestItem.cc
     
    2826  TOLUA_FILES
    2927    QuestManager.h
    30   DEFINE_SYMBOL
    31     "QUESTSYSTEM_SHARED_BUILD"
     28    QuestDescription.h
     29    Quest.h
     30    QuestHint.h
    3231  PCH_FILE
    3332    QuestsystemPrecompiledHeaders.h
  • code/trunk/src/modules/questsystem/ChangeQuestStatus.cc

    r6417 r7163  
    7878    bool ChangeQuestStatus::setQuestId(const std::string & id)
    7979    {
    80         if(!QuestItem::isId(id))
     80        if(id.compare(BLANKSTRING) == 0)
    8181        {
    8282            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
  • code/trunk/src/modules/questsystem/CompleteQuest.cc

    r6417 r7163  
    6868        SUPER(CompleteQuest, XMLPort, xmlelement, mode);
    6969
    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;
    7171    }
    7272
     
    8787        }
    8888
    89         COUT(3) << "CompleteQuest on player: " << player << " ." << std::endl;
     89        COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl;
    9090
    9191        Quest* quest;
     
    105105        }
    106106
    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;
    108108        return true;
    109109    }
  • code/trunk/src/modules/questsystem/FailQuest.cc

    r6417 r7163  
    6868        SUPER(FailQuest, XMLPort, xmlelement, mode);
    6969
    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;
    7171    }
    7272
     
    8787        }
    8888
    89         COUT(3) << "FailQuest on player: " << player << " ." << std::endl;
     89        COUT(4) << "FailQuest on player: " << player << " ." << std::endl;
    9090
    9191        Quest* quest;
     
    104104        }
    105105
    106         COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
     106        COUT(4) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
    107107        return true;
    108108    }
  • code/trunk/src/modules/questsystem/GlobalQuest.cc

    r6417 r7163  
    7070        XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode);
    7171
    72         COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
     72        COUT(4) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
    7373    }
    7474
     
    253253        this->rewards_.push_back(effect); //!< Add the QuestEffect to the list.
    254254
    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;
    256256        return true;
    257257    }
  • code/trunk/src/modules/questsystem/LocalQuest.cc

    r6417 r7163  
    6868        SUPER(LocalQuest, XMLPort, xmlelement, mode);
    6969
    70         COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
     70        COUT(4) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
    7171    }
    7272
  • code/trunk/src/modules/questsystem/Quest.cc

    r6417 r7163  
    6161    Quest::~Quest()
    6262    {
    63 
     63        if(this->isRegistered())
     64            QuestManager::getInstance().unregisterQuest(this);
    6465    }
    6566
     
    9899        this->parentQuest_ = quest;
    99100
    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;
    101102        return true;
    102103    }
     
    121122        this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests.
    122123
    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;
    124125        return true;
    125126    }
     
    145146        this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints.
    146147
    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;
    148149        return true;
    149150    }
     
    167168        this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects.
    168169
    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;
    170171        return true;
    171172    }
     
    189190        this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects.
    190191
    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;
    192193        return true;
    193194    }
  • code/trunk/src/modules/questsystem/Quest.h

    r5781 r7163  
    4141#include "QuestItem.h"
    4242
    43 namespace orxonox
    44 {
     43namespace orxonox // tolua_export
     44{ // tolua_export
    4545    namespace QuestStatus
    4646    {
     
    6767        Damian 'Mozork' Frick
    6868    */
    69     class _QuestsystemExport Quest : public QuestItem
    70     {
     69    class _QuestsystemExport Quest // tolua_export
     70        : public QuestItem
     71    { // tolua_export
    7172        public:
    7273            Quest(BaseObject* creator);
     
    9798
    9899            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'.
    102103
    103104            bool start(PlayerInfo* player); //!< Sets a Quest to active.
     
    151152            bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects.
    152153
    153     };
     154    }; // tolua_export
    154155
    155 }
     156} // tolua_export
    156157
    157158#endif /* _Quest_H__ */
  • code/trunk/src/modules/questsystem/QuestDescription.cc

    r6417 r7163  
    7474        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
    7575
    76         COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
     76        COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
    7777    }
    7878
     
    8989        Make sure the messages meet the conditions.
    9090    */
    91     bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
     91    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status)
    9292    {
    9393        std::string message;
     
    122122        }
    123123
    124         QuestNotification* notification = new QuestNotification(message);
     124        QuestNotification* notification = new QuestNotification(this, message);
    125125        notification->send();
    126126        return true;
  • code/trunk/src/modules/questsystem/QuestDescription.h

    r5781 r7163  
    8383            @return Returns a string containing the fail message of the QuestDescription.
    8484            */
    85             inline const std::string & getFailMessage(void) const
     85            inline const std::string & getFailMessage(void)
    8686                { return this->failMessage_; }
    8787
     
    9090            @return Returns a string containing the complete message of the QuestDescription.
    9191            */
    92             inline const std::string & getCompleteMessage(void) const
     92            inline const std::string & getCompleteMessage(void)
    9393                { return this->completeMessage_; }
    9494
     
    9797            @return Returns true if successful.
    9898            */
    99             inline bool sendAddHintNotification(void) const
     99            inline bool sendAddHintNotification(void)
    100100                { return notificationHelper("hint", ""); }
    101101
     
    104104            @return Returns true if successful.
    105105            */
    106             inline bool sendAddQuestNotification(void) const
     106            inline bool sendAddQuestNotification(void)
    107107                { return notificationHelper("quest", "start"); }
    108108
     
    111111            @return Returns true if successful.
    112112            */
    113             inline bool sendFailQuestNotification(void) const
     113            inline bool sendFailQuestNotification(void)
    114114                { return notificationHelper("quest", "fail"); }
    115115
     
    118118            @return Returns true if successful.
    119119            */
    120             inline bool sendCompleteQuestNotification(void) const
     120            inline bool sendCompleteQuestNotification(void)
    121121                { return notificationHelper("quest", "complete"); }
    122122
     
    127127            std::string completeMessage_; //!< The message displayed when the Quest is completed.
    128128
    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.
    130130
    131131            /**
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.cc

    r6906 r7163  
    7878        XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers.
    7979
    80         COUT(3) << "New QuestEffectBeacon created." << std::endl;
     80        COUT(4) << "New QuestEffectBeacon created." << std::endl;
    8181    }
    8282
     
    112112        MultiTriggerContainer* mTrigger = orxonox_cast<MultiTriggerContainer*>(trigger);
    113113        Pawn* pawn = NULL;
    114        
     114
    115115        //! If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it.
    116116        if(pTrigger == NULL && mTrigger == NULL)
    117117            return false;
    118        
    119         // If the trigger is a PlayerTrigger.       
     118
     119        // If the trigger is a PlayerTrigger.
    120120        if(pTrigger != NULL)
    121121        {
     
    125125                pawn = pTrigger->getTriggeringPlayer();
    126126        }
    127        
     127
    128128        // If the trigger is a MultiTrigger (i.e. a MultiTriggerContainer)
    129129        if(mTrigger != NULL)
     
    134134        if(pawn == NULL)
    135135        {
    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;
    137137            return false;
    138138        }
     
    147147        }
    148148
    149         COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
     149        COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
    150150
    151151        bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo.
     
    249249        this->effects_.push_back(effect);
    250250
    251         COUT(3) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;
     251        COUT(4) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;
    252252        return true;
    253253    }
  • code/trunk/src/modules/questsystem/QuestHint.cc

    r6417 r7163  
    5959    QuestHint::~QuestHint()
    6060    {
    61 
     61        if(this->isRegistered())
     62            QuestManager::getInstance().unregisterHint(this);
    6263    }
    6364
     
    7273        QuestManager::getInstance().registerHint(this); //!< Registers the QuestHint with the QuestManager.
    7374
    74         COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
     75        COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl;
    7576    }
    7677
     
    125126            else
    126127            {
    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;
    128129                return false;
    129130            }
    130131        }
    131132
    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;
    133134        return false;
    134135    }
  • code/trunk/src/modules/questsystem/QuestHint.h

    r5781 r7163  
    4040#include "QuestItem.h"
    4141
    42 namespace orxonox
    43 {
     42namespace orxonox // tolua_export
     43{ // tolua_export
    4444    namespace QuestHintStatus
    4545    {
     
    6666        Damian 'Mozork' Frick
    6767    */
    68     class _QuestsystemExport QuestHint : public QuestItem
    69     {
     68    class _QuestsystemExport QuestHint // tolua_export
     69        : public QuestItem
     70    { // tolua_export
    7071
    7172        public:
     
    9192            std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
    9293
    93     };
     94    }; // tolua_export
    9495
    95 }
     96} // tolua_export
    9697
    9798#endif /* _QuestHint_H__ */
  • code/trunk/src/modules/questsystem/QuestItem.cc

    r6417 r7163  
    4040namespace orxonox
    4141{
     42
     43    CreateUnloadableFactory(QuestItem);
     44
    4245    /**
    4346    @brief
     
    4649    QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator)
    4750    {
     51        this->registered_ = false;
     52
    4853        RegisterObject(QuestItem);
    4954    }
     
    7984    void QuestItem::setId(const std::string & id)
    8085    {
    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.
    8287        {
    8388            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
     
    8893    }
    8994
    90     /**
    91     @brief
    92         Checks whether an input id is of the required form.
    93     @param id
    94         The id to be checked.
    95     @return
    96         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 
    10395}
  • code/trunk/src/modules/questsystem/QuestItem.h

    r5781 r7163  
    4141#include <string>
    4242#include "core/BaseObject.h"
     43#include "QuestManager.h"
    4344
    4445namespace orxonox
     
    7172            @return Returns a pointer to the QuestDescription object of the QuestItem.
    7273            */
    73             inline const QuestDescription* getDescription(void) const
     74            inline QuestDescription* getDescription(void) const
    7475                { return this->description_; }
    7576
    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; }
    7788
    7889        protected:
     
    90101            QuestDescription* description_; //!< The QuestDescription of the QuestItem.
    91102
     103            bool registered_;
     104
    92105    };
    93106
  • code/trunk/src/modules/questsystem/QuestListener.cc

    r6417 r7163  
    7474        XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode);
    7575
    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;
    7980    }
    8081
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r6536 r7163  
    7474    QuestManager::~QuestManager()
    7575    {
    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
    8177    }
    8278
     
    114110        if(result.second) //!< If inserting was a success.
    115111        {
    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;
    117114            return true;
    118115        }
     
    122119           return false;
    123120        }
     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;
    124130    }
    125131
     
    146152        if(result.second) //!< If inserting was a success.
    147153        {
    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;
    149156            return true;
    150157        }
     
    154161           return false;
    155162        }
     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;
    156172    }
    157173
     
    169185    Quest* QuestManager::findQuest(const std::string & questId)
    170186    {
    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.
    172188        {
    173189            ThrowException(Argument, "Invalid questId.");
     
    203219    QuestHint* QuestManager::findHint(const std::string & hintId)
    204220    {
    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.
    206222        {
    207223            ThrowException(Argument, "Invalid hintId.");
     
    224240    }
    225241
    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();
    243317    }
    244318
  • code/trunk/src/modules/questsystem/QuestManager.h

    r6536 r7163  
    3636
    3737#include "questsystem/QuestsystemPrereqs.h"
    38 #include <CEGUIForwardRefs.h>
    3938
    4039#include <list>
     
    4443#include "util/Singleton.h"
    4544#include "core/OrxonoxClass.h"
    46 
    47 #include "QuestGUI.h"
    4845
    4946// tolua_begin
     
    6360
    6461            friend class Singleton<QuestManager>;
    65             friend class QuestGUI;
    6662
    6763        public:
     
    7268            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    7369
    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
    7683
    7784            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.
    7988
    8089            Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id.
     
    91100            std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
    92101
    93             std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.
    94 
    95102    }; // tolua_export
    96103
  • code/trunk/src/modules/questsystem/QuestNotification.cc

    r6417 r7163  
    3232namespace orxonox {
    3333
    34     const std::string QuestNotification::SENDER("questsystem");
     34    /*static*/ const std::string QuestNotification::SENDER("questsystem");
    3535
     36    CreateUnloadableFactory(QuestNotification);
     37
     38    /**
     39    @brief
     40        Default Constructor. Creates a useless QuestNotification.
     41    */
    3642    QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator)
    3743    {
    38         this->initialize();
     44        RegisterObject(QuestNotification);
    3945    }
    4046
    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)
    4254    {
    43         this->initialize();
     55        RegisterObject(QuestNotification);
    4456    }
    4557
     58    /**
     59    @brief
     60        Destructor.
     61    */
    4662    QuestNotification::~QuestNotification()
    4763    {
     
    4965    }
    5066
     67    /**
     68    @brief
     69        Send the QuestNotification.
     70    @return
     71        Returns true if successful.
     72    */
    5173    bool QuestNotification::send(void)
    5274    {
     
    5476    }
    5577
    56     void QuestNotification::initialize(void)
    57     {
    58         RegisterObject(QuestNotification);
    59     }
    60 
    6178
    6279}
  • code/trunk/src/modules/questsystem/QuestNotification.h

    • Property svn:executable deleted
    r5781 r7163  
    3939    /**
    4040    @brief
    41 
     41        The QuestNotification is a special Notification that has the single property that it is only sent by the questsystem.
    4242    @author
    4343        Damian 'Mozork' Frick
     
    4646    {
    4747        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.
    5151
    52             bool send(void);
     52            bool send(void); //!< Send the QuestNotification.
    5353
    5454        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.
    5856
    5957    };
  • code/trunk/src/modules/questsystem/QuestsystemPrereqs.h

    r5929 r7163  
    4343//-----------------------------------------------------------------------
    4444
    45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
     45#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(QUESTSYSTEM_STATIC_BUILD)
    4646#  ifdef QUESTSYSTEM_SHARED_BUILD
    4747#    define _QuestsystemExport __declspec(dllexport)
     
    7777    class QuestEffect;
    7878    class QuestEffectBeacon;
    79     class QuestGUI;
    80     class QuestGUINode;
    8179    class QuestHint;
    8280    class QuestItem;
  • code/trunk/src/modules/questsystem/notifications/Notification.cc

    r6417 r7163  
    4040{
    4141
     42    CreateUnloadableFactory(Notification);
     43
    4244    /**
    4345    @brief
     
    5658        The message of the Notification.
    5759    */
    58     Notification::Notification(const std::string & message) : BaseObject(NULL)
     60    Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator)
    5961    {
    6062        this->message_ = message;
     
    6769    Notification::~Notification()
    6870    {
     71
    6972    }
    7073
  • code/trunk/src/modules/questsystem/notifications/Notification.h

    r5781 r7163  
    5353        public:
    5454            Notification(BaseObject* creator);
    55             Notification(const std::string & message);
     55            Notification(BaseObject* creator, const std::string & message);
    5656            virtual ~Notification();
    5757
  • code/trunk/src/modules/questsystem/notifications/NotificationManager.cc

    r6417 r7163  
    6666    NotificationManager::~NotificationManager()
    6767    {
     68
    6869    }
    6970
     
    101102                this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener.
    102103                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;
    103109            }
    104110        }
    105111
    106         COUT(3) << "Notification registered with the NotificationManager." << std::endl;
     112        COUT(4) << "Notification registered with the NotificationManager." << std::endl;
    107113
    108114        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;
    109168    }
    110169
     
    130189        {
    131190            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;
    133192            return true;
    134193        }
     
    142201            if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
    143202            {
    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;
    145209            }
    146210        }
     
    148212        listener->update(); //!< Update the listener.
    149213
    150         COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
     214        COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
    151215
    152216        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;
    153246    }
    154247
  • code/trunk/src/modules/questsystem/notifications/NotificationManager.h

    r5929 r7163  
    6060            virtual ~NotificationManager();
    6161
    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.
    6464
    6565            bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
     66            void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager.
    6667            bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
     68            void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
    6769
    6870            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.
     
    9092            static NotificationManager* singletonPtr_s;
    9193
    92             int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that  no key appears twice.
     94            int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    9395
    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.
    9597            std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    9698            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.
    97100
     101            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
    98102
    99103    };
  • 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  
    3434#include "NotificationQueue.h"
    3535
    36 #include <sstream>
    37 
     36#include "util/Convert.h"
    3837#include "core/CoreIncludes.h"
    3938#include "core/XMLPort.h"
     
    5655    NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
    5756    {
     57        this->registered_ = false;
     58
    5859        RegisterObject(NotificationQueue);
    5960        this->initialize();
     
    6869        this->targets_.clear();
    6970        this->clear();
     71
     72        if(this->registered_)
     73            NotificationManager::getInstance().unregisterListener(this);
    7074    }
    7175
     
    8185
    8286        NotificationManager::getInstance().registerListener(this);
     87        this->registered_ = true;
    8388    }
    8489
     
    118123        XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
    119124
    120         COUT(3) << "NotificationQueue created." << std::endl;
     125        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    121126    }
    122127
     
    173178        delete notifications;
    174179
    175         COUT(3) << "NotificationQueue updated." << std::endl;
     180        COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
    176181    }
    177182
     
    196201        }
    197202
    198         COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
     203        COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl;
    199204    }
    200205
     
    397402        std::string timeString = std::ctime(&time);
    398403        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));
    402405        container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
    403406
     
    422425        if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
    423426            return false;
     427
     428        // Unregister the NotificationQueue with the NotificationManager.
     429        NotificationManager::getInstance().unregisterNotification(container->notification, this);
    424430
    425431        this->removeElement(container->overlay);
     
    443449        {
    444450            this->removeContainer(*it);
    445             it = this->containers_.begin(); //TODO: Needed?
     451            it = this->containers_.begin();
    446452        }
    447453    }
  • code/trunk/src/modules/questsystem/notifications/NotificationQueue.h

    r5781 r7163  
    7171
    7272        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.
    7374        <NotificationQueue
    7475            name = "SuperQueue" //Name of your OverlayQueue.
     
    185186            NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    186187
     188            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
     189
    187190            void initialize(void); //!< Initializes the object.
    188191            void setDefaults(void); //!< Helper method to set the default values.
Note: See TracChangeset for help on using the changeset viewer.