Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 4:19:44 PM (15 years ago)
Author:
dafrick
Message:

Merged questsystem3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/quest/QuestDescription.cc

    r2371 r2385  
    2929/**
    3030    @file QuestDescription.cc
    31     @brief
    32     Implementation of the QuestDescription class.
     31    @brief Implementation of the QuestDescription class.
    3332*/
    3433
     
    3837
    3938#include "core/CoreIncludes.h"
     39#include "orxonox/overlays/notifications/Notification.h"
    4040
    4141namespace orxonox {
     
    7474        XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode);
    7575        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
     76        XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
     77        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
    7678
    7779        COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
     80    }
     81   
     82    /**
     83    @brief
     84        This method is a helper for sending QuestDescriptions as Notifications.
     85    @param item
     86        The item the QuestDescription is for.
     87    @param status
     88        The status the QuestDescription us for.
     89    @return
     90        Returns true if successful.
     91    */
     92    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
     93    {
     94        std::string message = "";
     95        std::string title = "";
     96        if(item == "hint")
     97        {
     98            title = "You received a hint: '" + this->title_ + "'";
     99            message = this->description_;
     100        }
     101        else if(item == "quest")
     102        {
     103            if(status == "start")
     104            {
     105                title = "You received a new quest: '" + this->title_ + "'";
     106                message = this->description_;
     107            }
     108            else if(status == "fail")
     109            {
     110                title = "You failed the quest: '" + this->title_ + "'";
     111                message = this->failMessage_;
     112            }
     113            else if(status == "complete")
     114            {
     115                title = "You successfully completed the quest: '" + this->title_ + "'";
     116                message = this->completeMessage_;
     117            }
     118            else
     119            {
     120                COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     121                return false;
     122            }
     123        }
     124        else
     125        {
     126            COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     127            return false;
     128        }
     129       
     130        Notification* notification = new Notification(message, title, 30);
     131        notification->send();
     132        return true;
    78133    }
    79134
Note: See TracChangeset for help on using the changeset viewer.