Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2349


Ignore:
Timestamp:
Dec 6, 2008, 9:46:11 PM (15 years ago)
Author:
dafrick
Message:
  • Completed the message clipping method for Notifications.
  • Some other minor changes…
Location:
code/branches/questsystem3/src/orxonox
Files:
5 edited

Legend:

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

    r2346 r2349  
    129129        }
    130130       
    131         Notification* notification = new Notification(message, title, 10);
     131        Notification* notification = new Notification(message, title, 30);
    132132        notification->send();
    133133        return true;
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2262 r2349  
    9191        SUPER(QuestEffectBeacon, processEvent, event);
    9292   
    93     SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
     93        SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
    9494    }
    9595   
     
    167167        if(activate)
    168168        {
    169         this->status_ = QuestEffectBeaconStatus::active;
    170         return true;
     169            this->status_ = QuestEffectBeaconStatus::active;
     170            return true;
    171171        }
    172172       
     
    193193       
    194194        this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed.
    195     if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
    196     {
    197             this->status_ = QuestEffectBeaconStatus::inactive;
    198     }
    199        
     195        if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
     196        {
     197                this->status_ = QuestEffectBeaconStatus::inactive;
     198        }
     199           
    200200        return true;
    201201    }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2262 r2349  
    6464   
    6565    <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
    66             <effects>
    67                 <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
    68                 ...
    69                 <QuestEffect />
    70             </effects>
    71             <events>
     66        <effects>
     67            <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
     68            ...
     69            <QuestEffect />
     70        </effects>
     71        <events>
    7272        <execute>
    7373            <EventListener event=eventIdString />
     
    103103       
    104104    protected:
    105             bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
    106            
    107             /**
    108             @brief Returns the number of times the QUestEffectBeacon can still be executed.
    109             @return Returns the number of times the QUestEffectBeacon can still be executed.
    110             */
    111             inline const int & getTimes(void) const
    112                 { return this->times_; }
     105        bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
     106       
     107        /**
     108        @brief Returns the number of times the QUestEffectBeacon can still be executed.
     109        @return Returns the number of times the QUestEffectBeacon can still be executed.
     110        */
     111        inline const int & getTimes(void) const
     112            { return this->times_; }
    113113
    114         private:
    115             static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
    116        
    117             std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    118             int times_; //!< Number of times the beacon can be exectued.
    119             QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
    120            
    121             bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
    122             bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
    123            
    124             const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
     114    private:
     115        static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
     116   
     117        std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
     118        int times_; //!< Number of times the beacon can be exectued.
     119        QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
     120       
     121        bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
     122        bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
     123       
     124        const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
    125125   
    126126    };
  • code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.cc

    r2346 r2349  
    104104                continue;
    105105           
    106             text = text + "\n\n\n------------\n\n" + container->notification->getTitle() + "\n\n" + container->notification->getMessage();
     106            text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage());
    107107        }
    108108       
     
    110110    }
    111111   
    112     const std::string & NotificationManager::clipMessage(const std::string & message)
     112    const std::string NotificationManager::clipMessage(const std::string & str)
    113113    {
    114         std::string* clippedMessageP = new std::string();
    115         std::string clippedMessage = *clippedMessageP;
    116         clippedMessage = "";
    117         std::string tempWord = "";
     114   
     115        std::string message = str;
     116        unsigned int i = 0;
     117       
     118        unsigned int found = message.find("\\n", i);
     119        while(found != std::string::npos)
     120        {
     121            message.replace(found, 2, "\n");
     122            i = found+2;
     123            found = message.find("\\n", i);
     124        }
     125   
     126        std::string clippedMessage = "";
    118127        int wordLength = 0;
    119         signed int i = 0;
     128        i = 0;
    120129        int widthLeft = NotificationQueue::queue_s->getWidth();
    121130        while(i < message.length())
     
    123132            while(i < message.length() && message[i] != ' ' && message[i] != '\n')
    124133            {
    125                 tempWord = tempWord + message[i];
    126134                i++;
    127135                wordLength++;
     
    130138            if(wordLength <= widthLeft)
    131139            {
    132                 clippedMessage = clippedMessage + tempWord + message[i];
     140                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
     141                if(i < message.length())
     142                {
     143                    clippedMessage = clippedMessage + message.substr(i,1);
     144                }
    133145                widthLeft -= (wordLength+1);
     146                if(message[i] == '\n')
     147                {
     148                    widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1);
     149                }
    134150                wordLength = 0;
    135                 tempWord = "";
    136151                i++;
    137152            }
    138153            else
    139154            {
    140                 clippedMessage = clippedMessage + '\n' + tempWord + message[i];
     155                clippedMessage.push_back('\n');
     156                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
     157                if(i < message.length())
     158                {
     159                    clippedMessage = clippedMessage + message.substr(i,1);
     160                }
    141161                widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1);
    142162                i++;
    143163                wordLength = 0;
    144                 tempWord = "";
    145164            }
    146165        }
  • code/branches/questsystem3/src/orxonox/overlays/notifications/NotificationManager.h

    r2346 r2349  
    6666           
    6767            static void updateQueue(void);
    68             static const std::string & clipMessage(const std::string & message);
     68            static const std::string clipMessage(const std::string & message);
    6969
    7070    };
Note: See TracChangeset for help on using the changeset viewer.