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:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2

  • code/branches/tutoriallevel2/src/libraries/core/GUIManager.cc

    r8351 r8371  
    3737#include <CEGUIDefaultLogger.h>
    3838#include <CEGUIExceptions.h>
     39#include <CEGUIFontManager.h>
    3940#include <CEGUIInputEvent.h>
    4041#include <CEGUIMouseCursor.h>
     
    4344#include <CEGUIWindow.h>
    4445#include <CEGUIWindowManager.h>
     46#include <CEGUIXMLAttributes.h>
    4547#include <elements/CEGUIListbox.h>
    4648#include <elements/CEGUIListboxItem.h>
     
    649651    }
    650652
     653    /**
     654    @brief
     655        Adds a new freetype font to the CEGUI system.
     656    @param name
     657        The name of the new font.
     658    @param size
     659        The font size of the new font in pixels.
     660        @param fontName
     661        The filename of the font.
     662    */
     663    /*static*/ void GUIManager::addFontHelper(const std::string& name, int size, const std::string& fontName)
     664    {
     665        if(CEGUI::FontManager::getSingleton().isFontPresent(name)) // If a font with that name already exists.
     666            return;
     667
     668        CEGUI::Font* font = NULL;
     669        CEGUI::XMLAttributes xmlAttributes;
     670
     671        // Attributes specified within CEGUIFont
     672        xmlAttributes.add("Name", name);
     673        xmlAttributes.add("Filename", fontName);
     674        xmlAttributes.add("ResourceGroup", "");
     675        xmlAttributes.add("AutoScaled", "true");
     676        xmlAttributes.add("NativeHorzRes", "800");
     677        xmlAttributes.add("NativeVertRes", "600");
     678
     679        // Attributes specified within CEGUIXMLAttributes
     680        xmlAttributes.add("Size", multi_cast<std::string>(size));
     681        xmlAttributes.add("AntiAlias", "true");
     682
     683        font = CEGUI::FontManager::getSingleton().createFont("FreeType", xmlAttributes);
     684        if(font != NULL)
     685            font->load();
     686    }
     687
    651688}
  • code/branches/tutoriallevel2/src/libraries/core/GUIManager.h

    r8351 r8371  
    125125
    126126        // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
    127         static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
    128         static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); //tolua_export
    129         static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); //tolua_export
     127        static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); // tolua_export
     128        static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); // tolua_export
     129        static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); // tolua_export
     130        static void addFontHelper(const std::string& name, int size, const std::string& fontName); // tolua_export
    130131
    131132        static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
  • 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
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h

    r7552 r8371  
    9898                { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
    9999
     100            void getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); //!< Fetches the newest Notifications for a specific NotificationListener and stores them in the input map.
     101
    100102            void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.
    101103
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc

    r8079 r8371  
    161161    {
    162162        this->tickTime_ += dt; // Add the time interval that has passed to the time counter.
    163         if(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.
     163        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.
    164164        {
    165165            this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containig the current time.
     
    188188        std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>;
    189189        // Get the Notifications sent in the interval from now to now minus the display time.
    190         NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
     190        if(this->displayTime_ == INF)
     191            NotificationManager::getInstance().getNewestNotifications(this, notifications, this->getMaxSize());
     192        else
     193            NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
    191194
    192195        if(!notifications->empty())
     
    364367        Sets the maximum number of seconds a Notification is displayed.
    365368    @param time
    366         The number of seconds the Notifications is displayed.
    367     @return
    368         Returns true if successful.
    369     */
    370     void NotificationQueue::setDisplayTime(unsigned int time)
     369        The number of seconds a Notification is displayed.
     370    */
     371    void NotificationQueue::setDisplayTime(int time)
    371372    {
    372373        if(this->displayTime_ == time)
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h

    r7552 r8371  
    121121                { return this->maxSize_; }
    122122
    123             void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
     123            void setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
    124124            /**
    125125            @brief Returns the time interval the Notification is displayed.
    126126            @return Returns the display time.
    127127            */
    128             inline unsigned int getDisplayTime() const
     128            inline int getDisplayTime() const
    129129                { return this->displayTime_; }
    130130            // tolua_end
     
    152152            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    153153            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
     154            static const int INF = -1; //!< Constant denoting infinity.
    154155
    155156            std::string name_; //!< The name of the NotificationQueue.
     
    157158            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    158159            unsigned int size_; //!< The number of Notifications displayed.
    159             unsigned int displayTime_; //!< The time a Notification is displayed.
     160            int displayTime_; //!< The time a Notification is displayed.
    160161
    161162            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
  • code/branches/tutoriallevel2/src/modules/objects/triggers/MultiTrigger.cc

    r8213 r8371  
    198198                        if(bActive ^ this->isActive(state->originator))
    199199                        {
    200 
    201200                            bool bFire = true;
    202201
  • code/branches/tutoriallevel2/src/modules/objects/triggers/TriggerBase.h

    r8213 r8371  
    133133            inline int getActivations(void) const
    134134                { return this->remainingActivations_; }
     135            /**
     136            @brief Check whether the trigger has still at least one remaining activation.
     137            @return Returns true if the trigger has remaining activations (i.e. the number of remaining activations is not zero).
     138            */
     139            inline bool hasRemainingActivations(void) const
     140                { return this->remainingActivations_ > 0 || this->remainingActivations_ == INF_s; }
    135141
    136142            /**
  • code/branches/tutoriallevel2/src/modules/questsystem/QuestManager.cc

    r8079 r8371  
    274274    int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player)
    275275    {
     276        if(quest == NULL)
     277            return this->getNumRootQuests(player);
     278
    276279        std::list<Quest*> quests = quest->getSubQuestList();
    277280        int numQuests = 0;
     
    296299    Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index)
    297300    {
     301        if(quest == NULL)
     302            return this->getRootQuest(player, index);
     303
    298304        std::list<Quest*> quests = quest->getSubQuestList();
    299305        for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
     
    349355    /**
    350356    @brief
     357        Get the parent-quest of the input Quest for the input player.
     358    @param quest
     359        The Quest to get the parent-quest of.
     360    @param player
     361        The player.
     362    */
     363    Quest* QuestManager::getParentQuest(Quest* quest)
     364    {
     365        return quest->getParentQuest();
     366    }
     367
     368    /**
     369    @brief
    351370        Get the QuestDescription of the input Quest.
    352371    @param item
     
    375394    /**
    376395    @brief
     396        Get the id of the input Quest.
     397    @param item
     398        The Quest to get the id of.
     399    @return
     400        Returns the id of the input Quest.
     401    */
     402    const std::string QuestManager::getId(Quest* item) const
     403    {
     404        return item->getId();
     405    }
     406
     407    /**
     408    @brief
     409        Get the id of the input QuestHint.
     410    @param item
     411        The QuestHint to get the id of.
     412    @return
     413        Returns the id of the input QuestHint.
     414    */
     415    const std::string QuestManager::getId(QuestHint* item) const
     416    {
     417        return item->getId();
     418    }
     419
     420    /**
     421    @brief
    377422        Retrieve the player for a certain GUI.
    378423    @param guiName
  • code/branches/tutoriallevel2/src/modules/questsystem/QuestManager.h

    r7552 r8371  
    8181            QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player.
    8282
    83             QuestDescription* getDescription(Quest* item);
    84             QuestDescription* getDescription(QuestHint* item);
     83            Quest* getParentQuest(Quest* quest); //!< Get the parent-quest of the input Quest.
     84
     85            QuestDescription* getDescription(Quest* item); //!< Get the QuestDescription of the input Quest.
     86            QuestDescription* getDescription(QuestHint* item); //!< Get the QuestDescription of the input QuestHint.
     87
     88            const std::string getId(Quest* item) const; //!< Get the id of the input Quest.
     89            const std::string getId(QuestHint* item) const; //!< Get the id of the input QuestHint.
    8590            // tolua_end
    8691
  • code/branches/tutoriallevel2/src/orxonox/LevelManager.cc

    r8079 r8371  
    222222                this->nextLevel_ = this->availableLevels_.begin();
    223223            }
     224
    224225            while(this->nextIndex_ != index)
    225226            {
Note: See TracChangeset for help on using the changeset viewer.