[Orxonox-commit 2649] r7354 - in code/branches/notifications: data/gui/scripts data/levels data/levels/old src/modules/notifications
dafrick at orxonox.net
dafrick at orxonox.net
Sun Sep 5 12:42:54 CEST 2010
Author: dafrick
Date: 2010-09-05 12:42:54 +0200 (Sun, 05 Sep 2010)
New Revision: 7354
Modified:
code/branches/notifications/data/gui/scripts/NotificationLayer.lua
code/branches/notifications/data/levels/Fight in our Back.oxw
code/branches/notifications/data/levels/Quest_PirateAttack.oxw
code/branches/notifications/data/levels/old/princessaeryn.oxw
code/branches/notifications/data/levels/old/questsystem.oxw
code/branches/notifications/data/levels/princessaeryn.oxw
code/branches/notifications/data/levels/tutorial.oxw
code/branches/notifications/src/modules/notifications/CMakeLists.txt
code/branches/notifications/src/modules/notifications/NotificationManager.cc
code/branches/notifications/src/modules/notifications/NotificationManager.h
code/branches/notifications/src/modules/notifications/NotificationQueue.cc
code/branches/notifications/src/modules/notifications/NotificationQueue.h
Log:
Started work on edit mode. ConsoleCommand is not yet working.
Some additional cleanup. All the NotificationQueues generated by the NotificationManager now are destroyed upon destruction of the NotificationManager.
Removed NotificationQueue from level files.
Modified: code/branches/notifications/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-05 10:42:54 UTC (rev 7354)
@@ -5,11 +5,13 @@
P.queueList = {}
P.nameList = {}
P.visible = nil
+P.editMode = false
+P.editList = {}
function P.createQueue(name, size)
local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
- queue:setProperty("BackgroundColor", "66FFFFFF")
+ queue:setProperty("BackgroundColor", "00FFFFFF")
root:addChildWindow(queue)
queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
@@ -122,6 +124,42 @@
P.visible = visible
end
+function P.enterEditMode()
+ P.editMode = true
+
+ local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
+ --Replace all queues with FrameWindows
+ for k,v in pairs(P.queueList) do
+ if v ~= nil then
+ root:removeChildWindow(v)
+ local frame = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. P.nameList(k))
+ frame:setArea(v:getArea())
+ P.editList[k] = frame
+ end
+ end
+end
+
+function P.leaveEditMode()
+ P.editMode = false
+
+ local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
+ --Replace all queues with FrameWindows
+ for k,v in pairs(P.queueList) do
+ if v ~= nil then
+ root:addChildWindow(v)
+ v:setArea(P.editList[k]:getArea())
+ winMgr:destroyWindow(P.editList[k])
+ P.editList[k] = nil
+ end
+ end
+end
+
+function P.onHide()
+ if P.editMode then
+ P.leaveEditMode()
+ end
+end
+
function P.nameToQueueHelper(name)
local queue = nil
for k,v in pairs(P.nameList) do
Modified: code/branches/notifications/data/levels/Fight in our Back.oxw
===================================================================
--- code/branches/notifications/data/levels/Fight in our Back.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/Fight in our Back.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -7,15 +7,6 @@
include("templates/spaceship_Transporter.oxt")
?>
-<NotificationQueue
- name = "notification"
- position = "0.40, 0.05"
- font = "VeraMono"
- textsize = 0.020
- length = 3
- width = 50
-/>
-
<!--*****************************************************************************************************************************************************************************************-->
<!--Including Template for triggering on player-->
Modified: code/branches/notifications/data/levels/Quest_PirateAttack.oxw
===================================================================
--- code/branches/notifications/data/levels/Quest_PirateAttack.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/Quest_PirateAttack.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -18,18 +18,7 @@
<?lua
dofile("includes/CuboidSpaceStation.lua")
?>
-
-<NotificationQueue
- name = "notification"
- position = "0.40, 0.05"
- font = "VeraMono"
- textsize = 0.020
- length = 3
- width = 50
-/>
-
-
<Level
name="Dani's Testlevel"
description="Erste Versuche mit den Quests"
Modified: code/branches/notifications/data/levels/old/princessaeryn.oxw
===================================================================
--- code/branches/notifications/data/levels/old/princessaeryn.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/old/princessaeryn.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -8,12 +8,6 @@
dofile("includes/CuboidSpaceStation.lua")
?>
-<NotificationQueue
- name = "notification"
- position = "1.0, 1.0"
- targets = "questsystem"
-/>
-
<Level
name = "The Tale of Princess Aeryn"
description = "The Tale of Princess Aeryn"
Modified: code/branches/notifications/data/levels/old/questsystem.oxw
===================================================================
--- code/branches/notifications/data/levels/old/questsystem.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/old/questsystem.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -4,12 +4,6 @@
include("templates/spaceship_assff.oxt")
?>
-<NotificationQueue
- name = "notification"
- position = "1.0, 1.0"
- targets = "all"
-/>
-
<Level
name = "Questsystem"
description = "Just a few tests"
Modified: code/branches/notifications/data/levels/princessaeryn.oxw
===================================================================
--- code/branches/notifications/data/levels/princessaeryn.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/princessaeryn.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -14,15 +14,6 @@
description = "The Tale of Princess Aeryn"
>
- <NotificationQueue
- name = "notification"
- position = "0.55, 0.05"
- font = "VeraMono"
- textsize = 0.020
- length = 3
- width = 50
- />
-
<templates>
<Template link=lodtemplate_default />
</templates>
Modified: code/branches/notifications/data/levels/tutorial.oxw
===================================================================
--- code/branches/notifications/data/levels/tutorial.oxw 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/data/levels/tutorial.oxw 2010-09-05 10:42:54 UTC (rev 7354)
@@ -13,15 +13,6 @@
<Template link=lodtemplate_default />
</templates>
- <NotificationQueue
- name = "notification"
- position = "0.05, 0.05"
- font = "VeraMono"
- textsize = 0.020
- length = 3
- width = 50
- />
-
<Scene
ambientlight = "0.5, 0.5, 0.5"
skybox = "Orxonox/skypanoramagen1"
Modified: code/branches/notifications/src/modules/notifications/CMakeLists.txt
===================================================================
--- code/branches/notifications/src/modules/notifications/CMakeLists.txt 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/src/modules/notifications/CMakeLists.txt 2010-09-05 10:42:54 UTC (rev 7354)
@@ -11,6 +11,7 @@
MODULE
FIND_HEADER_FILES
TOLUA_FILES
+ NotificationManager.h
PCH_FILE
NotificationsPrecompiledHeaders.h
LINK_LIBRARIES
Modified: code/branches/notifications/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-05 10:42:54 UTC (rev 7354)
@@ -33,8 +33,10 @@
#include "NotificationManager.h"
+#include "core/command/ConsoleCommand.h"
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
+#include "core/LuaState.h"
#include "util/ScopedSingletonManager.h"
#include "interfaces/NotificationListener.h"
#include "Notification.h"
@@ -48,6 +50,9 @@
ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false);
+ //TODO: Make work.
+ //SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode).description("Enter the NotificationLayer edit mode.");
+
/**
@brief
Constructor. Registers the Object.
@@ -63,7 +68,7 @@
GUIManager::getInstance().loadGUI("NotificationLayer");
// Create first queue:
- this->queue_ = new NotificationQueue("all");
+ this->queues_.push_back(new NotificationQueue("all"));
}
}
@@ -73,9 +78,16 @@
*/
NotificationManager::~NotificationManager()
{
- //this->queue_->destroy();
+
}
+ void NotificationManager::preDestroy(void)
+ {
+ for(std::vector<NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
+ (*it)->destroy();
+ this->queues_.clear();
+ }
+
/**
@brief
Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
@@ -290,4 +302,9 @@
return true;
}
+ void NotificationManager::createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime)
+ {
+ this->queues_.push_back(new NotificationQueue(name, targets, size, displayTime));
+ }
+
}
Modified: code/branches/notifications/src/modules/notifications/NotificationManager.h
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.h 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.h 2010-09-05 10:42:54 UTC (rev 7354)
@@ -39,12 +39,14 @@
#include <ctime>
#include <map>
#include <string>
+#include <vector>
#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
+
/**
@brief
The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners.
@@ -52,13 +54,18 @@
@author
Damian 'Mozork' Frick
*/
- class _NotificationsExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
- {
+ class _NotificationsExport NotificationManager // tolua_export
+ : public Singleton<NotificationManager>, public OrxonoxClass
+ { // tolua_export
friend class Singleton<NotificationManager>;
public:
NotificationManager();
virtual ~NotificationManager();
+ virtual void preDestroy(void);
+
+ static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
+
static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
@@ -79,10 +86,14 @@
bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
{ return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
+ void enterEditMode(void);
+
+ void createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime); // tolua_export
+
private:
static NotificationManager* singletonPtr_s;
- NotificationQueue* queue_; //!< Initial, first, NotificationQueue.
+ std::vector<NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
@@ -93,8 +104,8 @@
bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif /* _NotificationManager_H__ */
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-05 10:42:54 UTC (rev 7354)
@@ -44,13 +44,11 @@
namespace orxonox
{
- const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0);
-
/**
@brief
Constructor. Creates and initializes the object.
*/
- NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, const Vector2& position, unsigned int displayTime)
+ NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime)
{
this->registered_ = false;
@@ -61,11 +59,9 @@
this->setTargets(senders);
this->name_ = name;
this->maxSize_ = size;
- this->position_ = position;
this->setDisplayTime(displayTime);
this->create();
- this->positionChanged();
NotificationManager::getInstance().registerListener(this);
this->registered_ = true;
@@ -248,15 +244,6 @@
/**
@brief
- Adjusts the NotificationQueue, when the position has changed.
- */
- void NotificationQueue::positionChanged(void)
- {
- GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");
- }
-
- /**
- @brief
Sets the name of the NotificationQueue.
@param name
The name to be set.
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-05 00:15:47 UTC (rev 7353)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-05 10:42:54 UTC (rev 7354)
@@ -42,7 +42,6 @@
#include <vector>
#include "tools/interfaces/Tickable.h"
-#include "util/Math.h"
#include "interfaces/NotificationListener.h"
#include "NotificationManager.h"
@@ -72,7 +71,7 @@
{
public:
- NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, const Vector2& position = NotificationQueue::DEFAULT_POSITION, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
+ NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::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.
@@ -105,12 +104,6 @@
*/
inline float getDisplayTime() const
{ return this->displayTime_; }
- /**
- @brief Returns the position of the NotificationQueue.
- @return Returns the position.
- */
- inline const Vector2 & getPosition() const
- { return this->position_; }
/**
@brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
@@ -120,25 +113,15 @@
{ return this->targets_; }
bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
- /**
- @brief Sets the position of the NotificationQueue.
- @param pos The position.
- */
- inline void setPosition(Vector2 pos)
- { this->position_ = pos; this->positionChanged(); }
-
private:
static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
- static const Vector2 DEFAULT_POSITION; //!< the default position.
std::string name_; //!< The name of the NotificationQueue.
unsigned int maxSize_; //!< The maximal number of Notifications displayed.
unsigned int size_; //!< The number of Notifications displayed.
- unsigned int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
unsigned int displayTime_; //!< The time a Notification is displayed.
- Vector2 position_; //!< The position of the NotificationQueue.
std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
@@ -160,7 +143,6 @@
bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
- void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed.
void push(Notification* notification, const std::time_t & time); //!< Add a Notification to the NotificationQueue.
More information about the Orxonox-commit
mailing list