Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2011, 10:45:56 PM (13 years ago)
Author:
dafrick
Message:

Extending NotificationQueueCEGUI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc

    r8446 r8448  
    3636#include "core/command/ConsoleCommand.h"
    3737#include "core/CoreIncludes.h"
    38 #include "core/GameMode.h"
    39 #include "core/GUIManager.h"
    4038#include "core/LuaState.h"
    41 #include "util/Convert.h"
    4239#include "util/ScopedSingletonManager.h"
    4340
     
    4845#include "NotificationQueueCEGUI.h"
    4946
    50 #include "ToluaBindNotifications.h"
    51 
    5247namespace orxonox
    5348{
    54 
    55     // Register tolua_open function when loading the library.
    56     DeclareToluaInterface(Notifications);
    5749
    5850    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
     
    108100    @param sender
    109101        The name of the entity (of the collective) that sent the new Notification.
     102    @param type
     103        The type of the new Notification.
    110104    @return
    111105        Returns true if successful.
     
    126120    @param sender
    127121        The The name of the entity (of the collective) that sent the command.
     122    @return
     123        Returns true if the command was successfully executed.
    128124    */
    129125    bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender)
    130126    {
     127        bool commandExecuted = false;
    131128        if(command == notificationCommand::clear)
    132129        {
    133             this->commandClear(sender);
    134             return true;
    135         }
    136 
    137         return false;
     130            if(this->commandClear(sender))
     131                commandExecuted = true;
     132        }
     133
     134        if(commandExecuted)
     135            COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
     136
     137        return commandExecuted;
    138138    }
    139139
     
    143143    @param sender
    144144        The sender of the clear command.
    145     */
    146     void NotificationManager::commandClear(const std::string& sender)
     145    @return
     146        Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed.
     147    */
     148    bool NotificationManager::commandClear(const std::string& sender)
    147149    {
    148150        bool all = (sender == NotificationListener::ALL);
     151        bool executed = false;
    149152        // Clear all NotificationQueues that have the input sender as target.
    150153        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     
    153156            // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target.
    154157            if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end())
    155                 it->second->tidy();
    156         }
     158                executed = it->second->tidy() || executed;
     159        }
     160
     161        return executed;
    157162    }
    158163   
     
    385390    /**
    386391    @brief
    387         Loads all the NotificationQueues that should exist.
    388     */
    389     void NotificationManager::loadQueues(void)
    390     {
    391         NotificationQueue* allQueue = new NotificationQueueCEGUI("all");
    392         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");
    393         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
    394 
    395         NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
    396         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")");
    397         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
    398         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)");
    399         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueAlignment(\"info\", \"HorzCentred\")");
    400     }
    401 
    402     /**
    403     @brief
    404         Creates a new NotificationQueue.
    405         This is used in lua.
    406     @param name
    407         The name of the new NotificationQueue.
    408     */
    409     void NotificationManager::createQueue(const std::string& name)
    410     {
    411         new NotificationQueue(name);
    412     }
    413 
    414     /**
    415     @brief
    416392        Get the NotificationQueue with the input name.
    417393    @param name
     
    430406    }
    431407
     408    /**
     409    @brief
     410        Loads all the NotificationQueues that should exist.
     411    */
     412    void NotificationManager::loadQueues(void)
     413    {
     414        NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
     415        allQueue->setDisplaySize(Vector2(0.5, 0));
     416        allQueue->setPosition(Vector4(0.0, 10, 0.3, 0));
     417
     418        NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
     419        infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0));
     420        infoQueue->setFontSize(24);
     421        infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8));
     422        infoQueue->setAlignment("HorzCentred");
     423        infoQueue->setDisplaySize(Vector2(0.6, 0.0));
     424    }
     425
    432426}
Note: See TracChangeset for help on using the changeset viewer.