Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc @ 2781

Last change on this file since 2781 was 2781, checked in by dafrick, 15 years ago

Got the Notifications to work. Rudimentarily, at least… \nNow comes the polish…

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "NotificationOverlay.h"
31
32#include <OgreOverlayManager.h>
33#include <OgreTextAreaOverlayElement.h>
34#include <OgrePanelOverlayElement.h>
35
36#include "core/CoreIncludes.h"
37#include "util/Exception.h"
38
39#include "Notification.h"
40#include "NotificationQueue.h"
41
42namespace orxonox
43{
44
45    NotificationOverlay::NotificationOverlay(BaseObject* creator) : OverlayText(creator)
46    {
47        this->initialize();
48    }
49
50    NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OverlayText(this)
51    {
52        this->initialize();
53       
54        if(notification == NULL || queue == NULL)
55        {
56            ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
57        }
58
59        this->queue_ = queue;
60        this->defineOverlay();
61       
62        this->processNotification(notification);
63    }
64   
65    void NotificationOverlay::initialize(void)
66    {
67        RegisterObject(NotificationOverlay);
68       
69        this->queue_ = NULL;
70    }
71   
72    void NotificationOverlay::defineOverlay(void)
73    {
74        this->setFont(this->queue_->getFont());
75        this->setTextSize(this->queue_->getFontSize());
76    }
77
78    NotificationOverlay::~NotificationOverlay()
79    {
80    }
81
82    bool NotificationOverlay::processNotification(Notification* notification)
83    {
84        this->setCaption(clipMessage(notification->getMessage()));
85        this->notification_ = notification;
86        return true;
87    }
88
89    const std::string NotificationOverlay::clipMessage(const std::string & str)
90    {
91        if(str.length() <= (unsigned int)this->queue_->getNotificationLength())
92            return str;
93        return str.substr(0, this->queue_->getNotificationLength());
94    }
95
96}
Note: See TracBrowser for help on using the repository browser.