Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2008, 7:38:53 AM (16 years ago)
Author:
dafrick
Message:
  • QuestListener works now.
  • Rearranged the places Notifications are sent from, and also created actually meaningfull Notification messages
  • Done some changes to Notifications
Location:
code/branches/questsystem3/src/orxonox/objects/quest
Files:
10 edited

Legend:

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

    r2328 r2346  
    4242
    4343#include "orxonox/objects/infos/PlayerInfo.h"
    44 #include "orxonox/overlays/notifications/Notification.h"
    4544#include "QuestManager.h"
    4645#include "Quest.h"
     
    111110
    112111        COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl;
    113         Notification* notification = new Notification("Crazy Message...", "Title", 30);
    114         notification->send();
    115112        return true;
    116113    }
  • code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.cc

    r2280 r2346  
    4242#include "QuestManager.h"
    4343#include "Quest.h"
    44 #include "orxonox/overlays/notifications/Notification.h"
    4544
    4645namespace orxonox {
     
    111110
    112111        COUT(3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;
    113         Notification* notification = new Notification("Crazy Message...", "Title", 30);
    114         notification->send();
    115112        return true;
    116113    }
  • code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.cc

    r2328 r2346  
    4040
    4141#include "orxonox/objects/infos/PlayerInfo.h"
    42 #include "orxonox/overlays/notifications/Notification.h"
    4342#include "QuestManager.h"
    4443#include "Quest.h"
  • code/branches/questsystem3/src/orxonox/objects/quest/Quest.cc

    r2328 r2346  
    377377        QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
    378378        this->setStatus(player, questStatus::failed);
     379       
     380        this->getDescription()->sendFailQuestNotification();
    379381        return true;
    380382    }
     
    392394        QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
    393395        this->setStatus(player, questStatus::completed);
     396       
     397        this->getDescription()->sendCompleteQuestNotification();
    394398        return true;
    395399    }
     
    414418       
    415419        this->setStatus(player, questStatus::active);
     420       
     421        this->getDescription()->sendAddQuestNotification();
    416422        return true;
    417423    }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc

    r2328 r2346  
    3838
    3939#include "core/CoreIncludes.h"
     40#include "orxonox/overlays/notifications/Notification.h"
    4041
    4142namespace orxonox {
     
    7576        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
    7677        XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
    77         XMLPortParam(QuestDescription, "failMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
     78        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
    7879
    7980        COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
     81    }
     82   
     83    /**
     84    @brief
     85        This method is a helper for sending QuestDescriptions as Notifications.
     86    @param item
     87        The item the QuestDescription is for.
     88    @param status
     89        The status the QuestDescription us for.
     90    @return
     91        Returns true if successful.
     92    */
     93    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
     94    {
     95        std::string message = "";
     96        std::string title = "";
     97        if(item == "hint")
     98        {
     99            title = "You received a hint: '" + this->title_ + "'";
     100            message = this->description_;
     101        }
     102        else if(item == "quest")
     103        {
     104            if(status == "start")
     105            {
     106                title = "You received a new quest: '" + this->title_ + "'";
     107                message = this->description_;
     108            }
     109            else if(status == "fail")
     110            {
     111                title = "You failed the quest: '" + this->title_ + "'";
     112                message = this->failMessage_;
     113            }
     114            else if(status == "complete")
     115            {
     116                title = "You successfully completed the quest: '" + this->title_ + "'";
     117                message = this->completeMessage_;
     118            }
     119            else
     120            {
     121                COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     122                return false;
     123            }
     124        }
     125        else
     126        {
     127            COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     128            return false;
     129        }
     130       
     131        Notification* notification = new Notification(message, title, 10);
     132        notification->send();
     133        return true;
    80134    }
    81135
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.h

    r2328 r2346  
    9191            inline const std::string & getCompleteMessage(void) const
    9292                { return this->completeMessage_; }
     93           
     94            /**
     95            @brief Sends a Notification displaying that a QuestHint was added.
     96            @return Returns true if successful.
     97            */
     98            inline bool sendAddHintNotification(void) const
     99                { return notificationHelper("hint", ""); }
     100           
     101            /**
     102            @brief Sends a Notification displaying that a Quest was added.
     103            @return Returns true if successful.
     104            */
     105            inline bool sendAddQuestNotification(void) const
     106                { return notificationHelper("quest", "start"); }
     107           
     108            /**
     109            @brief Sends a Notification displaying that a Quest was failed.
     110            @return Returns true if successful.
     111            */
     112            inline bool sendFailQuestNotification(void) const
     113                { return notificationHelper("quest", "fail"); }
     114           
     115            /**
     116            @brief Sends a Notification displaying that a Quest was completed.
     117            @return Returns true if successful.
     118            */
     119            inline bool sendCompleteQuestNotification(void) const
     120                { return notificationHelper("quest", "complete"); }
    93121
    94122        private:
     
    97125            std::string failMessage_; //!< The message displayed when the Quest is failed.
    98126            std::string completeMessage_; //!< The message displayed when the Quest is completed.
     127
     128            bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications.
    99129
    100130            /**
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.cc

    r2261 r2346  
    4141#include "orxonox/objects/infos/PlayerInfo.h"
    4242#include "QuestManager.h"
     43#include "QuestDescription.h"
    4344#include "Quest.h"
    4445
     
    122123            {
    123124                this->playerStatus_[player] = questHintStatus::active;
     125               
     126                this->getDescription()->sendAddHintNotification();
    124127                return true;
    125128            }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.h

    r2261 r2346  
    6767            /**
    6868            @brief Returns the id of this QuestItem.
    69         @return Returns the id of the QuestItem.
     69            @return Returns the id of the QuestItem.
    7070            */
    7171            inline const std::string & getId(void) const
    7272                { return this->id_; }
    73         /**
    74         @brief Returns the QuestDescription of the QuestItem.
    75         @return Returns a pointer to the QuestDescription object of the QuestItem.
    76         */
     73            /**
     74            @brief Returns the QuestDescription of the QuestItem.
     75            @return Returns a pointer to the QuestDescription object of the QuestItem.
     76            */
    7777            inline const QuestDescription* getDescription(void) const
    7878                { return this->description_; }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.cc

    r2333 r2346  
    4343    {
    4444        RegisterObject(QuestListener);
     45       
     46        this->status_ = questListenerStatus::start;
     47        this->quest_ = NULL;
    4548    }
    4649   
     
    6265        this->quest_->addListener(this);
    6366       
    64         COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this->status_ << "'." << std::endl;
     67        COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this->getQuestStatus() << "'." << std::endl;
    6568    }
    6669   
     
    8083    {
    8184        this->fireEvent(true); //TDO This' right?
    82        
    83         COUT(3) << "QuestListener fired Event, expect for something to happen." << std::endl; //TDO remove
    84        
    8585        return true;
    8686    }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.h

    r2329 r2346  
    8080            questListenerStatus::Enum status_;
    8181            Quest* quest_;
    82             BaseObject* target_;
    8382   
    8483    };
Note: See TracChangeset for help on using the changeset viewer.