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 | /** |
---|
30 | @file NotificationQueueCEGUI.cc |
---|
31 | @brief Implementation of the NotificationQueueCEGUI class. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "NotificationQueueCEGUI.h" |
---|
35 | |
---|
36 | #include "core/CoreIncludes.h" |
---|
37 | #include "core/GameMode.h" |
---|
38 | #include "core/GUIManager.h" |
---|
39 | #include "core/LuaState.h" |
---|
40 | #include "util/Convert.h" |
---|
41 | |
---|
42 | #include "Notification.h" |
---|
43 | |
---|
44 | namespace orxonox |
---|
45 | { |
---|
46 | |
---|
47 | NotificationQueueCEGUI::NotificationQueueCEGUI(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) : NotificationQueue(name, senders, size, displayTime) |
---|
48 | { |
---|
49 | RegisterObject(NotificationQueueCEGUI); |
---|
50 | |
---|
51 | // Create the NotificationQueueCEGUI in lua. |
---|
52 | this->create(); |
---|
53 | } |
---|
54 | |
---|
55 | NotificationQueueCEGUI::~NotificationQueueCEGUI() |
---|
56 | { |
---|
57 | |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | @brief |
---|
62 | Destroys the NotificationQueueCEGUI. |
---|
63 | Used in lua and NotificationManager. |
---|
64 | @param noGraphics |
---|
65 | If this is set to true (false is default), then the queue is not removed in lua. This is used to destroy the queue, after the GUIManager has been destroyed. |
---|
66 | */ |
---|
67 | void NotificationQueueCEGUI::destroy(bool noGraphics) |
---|
68 | { |
---|
69 | // Remove the NotificationQueue in lua. |
---|
70 | if(GameMode::showsGraphics() && !noGraphics) |
---|
71 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); |
---|
72 | |
---|
73 | NotificationQueue::destroy(); |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | @brief |
---|
78 | Is called by the NotificationQueue when a notification was pushed. |
---|
79 | @param notification |
---|
80 | The Notification that was pushed. |
---|
81 | */ |
---|
82 | void NotificationQueueCEGUI::notificationPushed(Notification* notification) |
---|
83 | { |
---|
84 | // Push the Notification to the GUI. |
---|
85 | if(GameMode::showsGraphics()) |
---|
86 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); |
---|
87 | } |
---|
88 | |
---|
89 | /** |
---|
90 | @brief |
---|
91 | Is called by the NotificationQueue when a notification was popped. |
---|
92 | */ |
---|
93 | void NotificationQueueCEGUI::notificationPopped(void) |
---|
94 | { |
---|
95 | // Pops the Notification from the GUI. |
---|
96 | if(GameMode::showsGraphics()) |
---|
97 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | @brief Is called when a notification was removed. |
---|
102 | @param index The index the removed notification was at. |
---|
103 | */ |
---|
104 | void NotificationQueueCEGUI::notificationRemoved(unsigned int index) |
---|
105 | { |
---|
106 | // Removes the Notification from the GUI. |
---|
107 | if(GameMode::showsGraphics()) |
---|
108 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")"); |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | @brief |
---|
113 | Clears the NotificationQueue by removing all NotificationContainers. |
---|
114 | @param noGraphics |
---|
115 | If this is set to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally. |
---|
116 | */ |
---|
117 | void NotificationQueueCEGUI::clear(bool noGraphics) |
---|
118 | { |
---|
119 | NotificationQueue::clear(noGraphics); |
---|
120 | |
---|
121 | // Clear the NotificationQueue in the GUI. |
---|
122 | if(GameMode::showsGraphics() && !noGraphics) |
---|
123 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")"); |
---|
124 | } |
---|
125 | |
---|
126 | /** |
---|
127 | @brief |
---|
128 | Creates the NotificationQueue in lua. |
---|
129 | */ |
---|
130 | void NotificationQueueCEGUI::create(void) |
---|
131 | { |
---|
132 | if(GameMode::showsGraphics()) |
---|
133 | GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")"); |
---|
134 | } |
---|
135 | |
---|
136 | } |
---|
137 | |
---|