Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 1, 2011, 2:43:33 PM (13 years ago)
Author:
dafrick
Message:

Merging tutoriallevel branch into tutoriallevel2 branch.

Location:
code/branches/tutoriallevel2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2

  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc

    r8079 r8371  
    4040#include "network/Host.h"
    4141#include "network/NetworkFunction.h"
     42#include "util/Convert.h"
    4243#include "util/ScopedSingletonManager.h"
    4344
     
    342343    /**
    343344    @brief
     345        Fetches the newest Notifications for a specific NotificationListener and stores them in the input map.
     346    @param listener
     347        The NotificationListener the Notifications are fetched for.
     348    @param map
     349        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     350    @param numberOfNotifications
     351        The number of newest Notifications to be got.
     352    @return
     353        Returns true if successful.
     354    */
     355    void NotificationManager::getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)
     356    {
     357        assert(listener);
     358        assert(map);
     359
     360        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.
     361
     362        if(!notifications->empty()) // If the list of Notifications is not empty.
     363        {
     364            std::multimap<std::time_t,Notification*>::iterator it = notifications->end();
     365            for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications.
     366            {
     367                it--;
     368                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map.
     369                if(it == notifications->begin())
     370                    break;
     371            }
     372        }
     373    }
     374
     375    /**
     376    @brief
    344377        Enters the edit mode of the NotificationLayer.
    345378    */
     
    387420    void NotificationManager::loadQueues(void)
    388421    {
    389         new NotificationQueue("all");
     422        NotificationQueue* allQueue = new NotificationQueue("all");
     423        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");
     424        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
     425
     426        NotificationQueue* infoQueue = new NotificationQueue("info", NotificationManager::ALL, 1, -1);
     427        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"FFFFFF00\")");
     428        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
     429        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)");
    390430    }
    391431
Note: See TracChangeset for help on using the changeset viewer.