[Orxonox-commit 3982] r8656 - in code/branches/presentation: data/levels src/modules/notifications
dafrick at orxonox.net
dafrick at orxonox.net
Sun May 29 11:24:31 CEST 2011
Author: dafrick
Date: 2011-05-29 11:24:31 +0200 (Sun, 29 May 2011)
New Revision: 8656
Modified:
code/branches/presentation/data/levels/presentationFS11.oxw
code/branches/presentation/src/modules/notifications/NotificationQueue.cc
code/branches/presentation/src/modules/notifications/NotificationQueue.h
code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc
code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h
Log:
Adding network callbacks. Still doesn't work yet, though.
Modified: code/branches/presentation/data/levels/presentationFS11.oxw
===================================================================
--- code/branches/presentation/data/levels/presentationFS11.oxw 2011-05-29 08:31:15 UTC (rev 8655)
+++ code/branches/presentation/data/levels/presentationFS11.oxw 2011-05-29 09:24:31 UTC (rev 8656)
@@ -36,7 +36,7 @@
displayTime=30
position="0.2, 0, 0.8, 0"
fontSize="24"
- fontColor="1, 1, 0, 0.8"
+ fontColor="0.3, 1, 0.2, 0.8"
alignment="HorzCentred"
displaySize="0.6, 0, 0, 0"
/>
@@ -52,21 +52,17 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
- <SimpleNotification message="Welcome to Earth Orbit" >
+ <SimpleNotification message="Welcome to Earth Orbit" sender="narrative" >
<events>
<trigger>
<EventListener event=spawntrigger />
</trigger>
</events>
</SimpleNotification>
- <EventMultiTrigger name=spawntrigger>
- <events>
- <trigger>
- <SpawnPoint position="0,0,0" lookat="-2,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
- </trigger>
- </events>
- </EventMultiTrigger>
+ <DistanceTrigger name="spawntrigger" position="0,0,0" target="Pawn" distance=10 stayActive="true" />
+ <SpawnPoint position="0,0,0" lookat="-2,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
<!-- PICKUPS -->
<PickupSpawner position="-50,50,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
<pickup>
Modified: code/branches/presentation/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/presentation/src/modules/notifications/NotificationQueue.cc 2011-05-29 08:31:15 UTC (rev 8655)
+++ code/branches/presentation/src/modules/notifications/NotificationQueue.cc 2011-05-29 09:24:31 UTC (rev 8656)
@@ -135,7 +135,7 @@
void NotificationQueue::tick(float dt)
{
this->tickTime_ += dt; // Add the time interval that has passed to the time counter.
- if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
+ if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
{
this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time.
@@ -170,9 +170,9 @@
*/
void NotificationQueue::registerVariables()
{
- registerVariable( this->maxSize_, VariableDirection::ToClient );
- registerVariable( this->targets_, VariableDirection::ToClient );
- registerVariable( this->displayTime_, VariableDirection::ToClient );
+ registerVariable( this->maxSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::maxSizeChanged));
+ registerVariable( this->targets_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::targetsChanged));
+ registerVariable( this->displayTime_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::displayTimeChanged));
}
@@ -228,7 +228,7 @@
/**
@brief
Adds (pushes) a Notification to the NotificationQueue.
- It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
+ It inserts it into the storage containers, creates a corresponding container and pushes the notification message to the GUI.
@param notification
The Notification to be pushed.
@param time
@@ -362,7 +362,15 @@
}
this->maxSize_ = size;
+ this->maxSizeChanged();
+ }
+ /**
+ @brief
+ Is called when the maximum number of displayed Notifications has changed.
+ */
+ void NotificationQueue::maxSizeChanged(void)
+ {
if(this->isRegistered())
this->update();
}
@@ -384,7 +392,15 @@
}
this->displayTime_ = time;
+ this->displayTimeChanged();
+ }
+ /**
+ @brief
+ Is called when the maximum number of seconds a Notification is displayed has changed.
+ */
+ void NotificationQueue::displayTimeChanged(void)
+ {
if(this->isRegistered())
this->update();
}
@@ -427,6 +443,15 @@
for(unsigned int i = 0; i < string.size(); i++)
this->targets_.insert(string[i]);
+ this->targetsChanged();
+ }
+
+ /**
+ @brief
+ Is called when the NotificationQueue's targets have changed.
+ */
+ void NotificationQueue::targetsChanged(void)
+ {
// TODO: Why?
if(this->isRegistered())
{
Modified: code/branches/presentation/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/branches/presentation/src/modules/notifications/NotificationQueue.h 2011-05-29 08:31:15 UTC (rev 8655)
+++ code/branches/presentation/src/modules/notifications/NotificationQueue.h 2011-05-29 09:24:31 UTC (rev 8656)
@@ -94,7 +94,6 @@
public:
NotificationQueue(BaseObject* creator);
- NotificationQueue(BaseObject* creator, const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
virtual ~NotificationQueue();
virtual void tick(float dt); // To update from time to time.
@@ -128,6 +127,8 @@
inline int getDisplayTime(void) const
{ return this->displayTime_; }
// tolua_end
+ void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed.
+ void displayTimeChanged(void);
/**
@brief Returns the current number of Notifications displayed.
@@ -145,6 +146,7 @@
void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
+ void targetsChanged(void); // Is called when the NotificationQueue's targets have changed.
/**
@brief Check whether the NotificationQueue is registered with the NotificationManager.
Modified: code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc
===================================================================
--- code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc 2011-05-29 08:31:15 UTC (rev 8655)
+++ code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc 2011-05-29 09:24:31 UTC (rev 8656)
@@ -94,11 +94,11 @@
void NotificationQueueCEGUI::registerVariables()
{
- registerVariable( this->position_, VariableDirection::ToClient );
- registerVariable( this->fontSize_, VariableDirection::ToClient );
- registerVariable( this->fontColor_, VariableDirection::ToClient );
- registerVariable( this->alignment_, VariableDirection::ToClient );
- registerVariable( this->displaySize_, VariableDirection::ToClient );
+ registerVariable( this->position_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::positionChanged));
+ registerVariable( this->fontSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontSizeChanged));
+ registerVariable( this->fontColor_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontColorChanged));
+ registerVariable( this->alignment_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::alignmentChanged));
+ registerVariable( this->displaySize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::displaySizeChanged));
}
/**
@@ -140,9 +140,18 @@
}
this->displaySize_ = size;
+ this->displaySizeChanged();
+ }
+
+ /**
+ @brief
+ Is called when the display size has changed.
+ */
+ void NotificationQueueCEGUI::displaySizeChanged(void)
+ {
if(GameMode::showsGraphics())
{
- if(size.z == 0.0 && size.w == 0.0)
+ if(this->displaySize_.z == 0.0 && this->displaySize_.w == 0.0)
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ")");
else
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ", " + multi_cast<std::string>(this->displaySize_.z) + ", " + multi_cast<std::string>(this->displaySize_.w) + ")");
@@ -171,6 +180,15 @@
}
this->position_ = position;
+ this->positionChanged();
+ }
+
+ /**
+ @brief
+ Is called when the NotificationQueue's position has changed.
+ */
+ void NotificationQueueCEGUI::positionChanged(void)
+ {
if(GameMode::showsGraphics())
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".moveQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->position_.x) + ", " + multi_cast<std::string>(this->position_.y) + ", " + multi_cast<std::string>(this->position_.z) + ", " + multi_cast<std::string>(this->position_.w) + ")");
}
@@ -189,6 +207,15 @@
// TODO: Check whether the alignment string is correct?
this->alignment_ = alignment;
+ this->alignmentChanged();
+ }
+
+ /**
+ @brief
+ Is called when the horizontal alignment of the Notifications text has changed.
+ */
+ void NotificationQueueCEGUI::alignmentChanged(void)
+ {
if(GameMode::showsGraphics())
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")");
}
@@ -205,6 +232,15 @@
return;
this->fontSize_ = size;
+ this->fontSizeChanged();
+ }
+
+ /**
+ @brief
+ Is called when the font size of the text displayed by this NotificationQueue has changed.
+ */
+ void NotificationQueueCEGUI::fontSizeChanged(void)
+ {
if(GameMode::showsGraphics())
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")");
}
@@ -221,11 +257,21 @@
return;
this->fontColor_ = color;
+ this->fontColorChanged();
+ }
+
+ /**
+ @brief
+ Is called when the font color if the text displayed by this NotificationQueue.
+ */
+ void NotificationQueueCEGUI::fontColorChanged(void)
+ {
// Convert to ARGB format.
std::stringstream stream;
for(unsigned int i = 0; i < 4; i++)
stream << std::hex << std::setw(2) << std::setfill('0') << int(this->fontColor_[(i+3)%4]*255);
this->fontColorStr_ = stream.str();
+
if(GameMode::showsGraphics())
GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")");
}
@@ -248,7 +294,7 @@
/**
@brief
- Is called by the NotificationQueue when a notification was pushed.
+ Is called by the NotificationQueue when a Notification was pushed.
@param notification
The Notification that was pushed.
*/
@@ -261,7 +307,7 @@
/**
@brief
- Is called by the NotificationQueue when a notification was popped.
+ Is called by the NotificationQueue when a Notification was popped.
*/
void NotificationQueueCEGUI::notificationPopped(void)
{
@@ -272,7 +318,7 @@
/**
@brief Is called when a notification was removed.
- @param index The index the removed notification was at.
+ @param index The index the removed Notification was at.
*/
void NotificationQueueCEGUI::notificationRemoved(unsigned int index)
{
Modified: code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h
===================================================================
--- code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h 2011-05-29 08:31:15 UTC (rev 8655)
+++ code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h 2011-05-29 09:24:31 UTC (rev 8656)
@@ -85,6 +85,7 @@
*/
inline const Vector4& getDisplaySize(void) const
{ return this->displaySize_; }
+ void displaySizeChanged(void); // Is called when the display size has changed.
void setPosition(const Vector4& position); // Set the position of the window that displays the NotificationQueue.
/**
@@ -93,6 +94,7 @@
*/
inline const Vector4& getPosition(void) const
{ return this->position_; }
+ void positionChanged(void); // Is called when the NotificationQueue's position has changed.
void setAlignment(const std::string& alignment); // Set the horizontal alignment of the Notifications text.
/**
@@ -101,6 +103,7 @@
*/
inline const std::string& getAlignment(void)
{ return this->alignment_; }
+ void alignmentChanged(void); // Is called when the horizontal alignment of the Notifications text has changed.
void setFontSize(unsigned int size); // Set the font size of the text displayed by this NotificationQueue.
/**
@@ -109,6 +112,7 @@
*/
inline unsigned int getFontSize(void)
{ return this->fontSize_; }
+ void fontSizeChanged(void); // Is called when the font size of the text displayed by this NotificationQueue has changed.
void setFontColor(const Vector4& color); // Set the font color if the text displayed by this NotificationQueue.
/**
@@ -123,15 +127,16 @@
*/
inline const std::string& getFontColorStr(void) const
{ return this->fontColorStr_; }
+ void fontColorChanged(void); // Is called when the font color if the text displayed by this NotificationQueue has changed.
static NotificationQueueCEGUI* getQueue(const std::string& name); // tolua_export // Get the NotificationQueueCEGUI with the input name.
protected:
virtual void create(void); // Creates the NotificationQueue in lua.
- virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a notification was pushed
- virtual void notificationPopped(void); // Is called by the NotificationQueue when a notification was popped.
- virtual void notificationRemoved(unsigned int index); // Is called when a notification was removed.
+ virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a Notification was pushed
+ virtual void notificationPopped(void); // Is called by the NotificationQueue when a Notification was popped.
+ virtual void notificationRemoved(unsigned int index); // Is called when a Notification was removed.
virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
More information about the Orxonox-commit
mailing list