[Orxonox-commit 2693] r7398 - in code/branches/notifications: data/gui/scripts src/modules/notifications
dafrick at orxonox.net
dafrick at orxonox.net
Fri Sep 10 19:50:06 CEST 2010
Author: dafrick
Date: 2010-09-10 19:50:06 +0200 (Fri, 10 Sep 2010)
New Revision: 7398
Modified:
code/branches/notifications/data/gui/scripts/NotificationLayer.lua
code/branches/notifications/src/modules/notifications/NotificationManager.cc
code/branches/notifications/src/modules/notifications/NotificationQueue.cc
code/branches/notifications/src/modules/notifications/NotificationQueue.h
Log:
Done some selective testing and it finally seems to work.
Modified: code/branches/notifications/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-10 12:30:21 UTC (rev 7397)
+++ code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-10 17:50:06 UTC (rev 7398)
@@ -39,7 +39,7 @@
if queue ~= nil then
winMgr:destroyWindow(queue.window)
end
- queue = nil
+ P.queueList[name] = nil
end
function P.pushNotification(queueName, notification)
@@ -193,7 +193,8 @@
local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. name)
local frame = tolua.cast(window, "CEGUI::FrameWindow")
- frame:setCloseButtonEnabled(false)
+ frame:setCloseButtonEnabled(true)
+ orxonox.GUIManager:subscribeEventHelper(frame, "CloseClicked", P.name .. ".closeQueue_clicked")
frame:setText("NotificationQueue \"" .. name .. "\"")
root:addChildWindow(window)
local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/ScrollingPane")
@@ -220,7 +221,6 @@
size = getMinTextSize(P.sampleWindow)
targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
- cout(0, horzOffset .. "|" .. targets:getXPosition():asAbsolute(1) .. "|" .. size[2]*2+20)
horzOffset = horzOffset + size[2]*2+20 + 5
pane:addChildWindow(targets)
local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Targets/Save")
@@ -230,7 +230,6 @@
local saveTextWidth = size[2]+20
save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
- cout(0, horzOffset .. "|" .. save:getXPosition():asAbsolute(1))
orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
pane:addChildWindow(save)
horzOffset = horzOffset + saveTextWidth
@@ -334,7 +333,7 @@
local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
- local width = window:getXPosition():asAbsolute(1)
+ local width = window:getWidth():asAbsolute(1)
local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
queue:setTargets(window:getText())
@@ -344,7 +343,6 @@
P.sampleWindow:setText(targets)
local size = getMinTextSize(P.sampleWindow)
window:setWidth(CEGUI.UDim(0, size[2]*2+20))
- cout(0, width .. "|" .. size[2]*2+20 .. "|" .. window:getWidth():asAbsolute(1) .. "|" .. save:getXPosition():asAbsolute(1))
save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
end
@@ -358,7 +356,7 @@
local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
- local width = window:getXPosition():asAbsolute(1)
+ local width = window:getWidth():asAbsolute(1)
local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
queue:setMaxSize(tonumber(window:getText()))
@@ -381,7 +379,7 @@
local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
- local width = window:getXPosition():asAbsolute(1)
+ local width = window:getWidth():asAbsolute(1)
local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
queue:setDisplayTime(tonumber(window:getText()))
@@ -418,6 +416,19 @@
hideMenuSheet(P.name)
end
+function P.closeQueue_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+
+ local match = string.gmatch(name, "EditMode/.*")
+ local nameStr = match()
+ local queueName = string.sub(nameStr, 10, string.len(nameStr))
+
+ winMgr:destroyWindow(P.queueList[queueName].edit)
+ P.queueList[queueName].edit = nil
+ orxonox.NotificationManager:getInstance():getQueue(queueName):destroy()
+end
+
function P.queueHeightHelper(queue, size)
local listbox = CEGUI.toListbox(queue)
local item = CEGUI.createListboxTextItem("Text")
Modified: code/branches/notifications/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-10 12:30:21 UTC (rev 7397)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-10 17:50:06 UTC (rev 7398)
@@ -164,7 +164,7 @@
if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second)))
this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
- COUT(4) << "Notification (&" << notification << ")unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
+ COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
}
/**
@@ -211,13 +211,13 @@
// If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
bool bAll = set.find(NotificationManager::ALL) != set.end();
- std::multimap<std::time_t, Notification*> map;
+ std::multimap<std::time_t, Notification*>* map;
if(bAll)
this->notificationLists_[index] = &this->allNotificationsList_;
else
{
this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
- map = *this->notificationLists_[index];
+ map = this->notificationLists_[index];
}
// Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
@@ -226,7 +226,7 @@
if(bAll || set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current notification as target.
{
if(!bAll)
- map.insert(std::pair<std::time_t, Notification*>(it->first, it->second));
+ map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(it->second);
if(counterIt == this->listenerCounter_.end())
this->listenerCounter_[it->second] = 1;
@@ -253,21 +253,21 @@
int identifier = this->listenerList_.find(listener)->second;
std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second;
- // Make sure all Notifications are removed.
+ // If the map is not the map of all notifications, make sure all Notifications are removed and delete it.
std::multimap<std::time_t, Notification*>::iterator it = map->begin();
- while(it != map->end())
+ if(map != &this->allNotificationsList_)
{
- this->unregisterNotification(it->second, listener);
- it = map->begin();
+ while(it != map->end())
+ {
+ this->unregisterNotification(it->second, listener);
+ it = map->begin();
+ }
+ delete map;
}
this->listenerList_.erase(listener);
this->notificationLists_.erase(identifier);
- // If the map is not the map of all notifications, delete it.
- if(map != &this->allNotificationsList_)
- delete map;
-
COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
}
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-10 12:30:21 UTC (rev 7397)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-10 17:50:06 UTC (rev 7398)
@@ -99,6 +99,8 @@
NotificationManager::getInstance().unregisterListener(this);
NotificationManager::getInstance().unregisterQueue(this);
+
+ GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")");
}
}
@@ -359,6 +361,7 @@
{
this->targets_.clear();
+ //TODO: Do with SubString.
std::string* pTemp;
unsigned int index = 0;
while(index < targets.size()) // Go through the string, character by character until the end is reached.
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-10 12:30:21 UTC (rev 7397)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-10 17:50:06 UTC (rev 7398)
@@ -75,6 +75,8 @@
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();
+ void destroy(void) { this->OrxonoxClass::destroy(); } // tolua_export
+
virtual void tick(float dt); //!< To update from time to time.
void update(void); //!< Updates the queue.
More information about the Orxonox-commit
mailing list