Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc

    r2907 r2908  
    6363    OverlayGroup::~OverlayGroup()
    6464    {
    65         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    66             delete (*it);
     65        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     66            delete it->second;
    6767    }
    6868
     
    8383    }
    8484
    85     //! Scales every element in the set.
     85    //! Scales every element in the map.
    8686    void OverlayGroup::setScale(const Vector2& scale)
    8787    {
    88         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    89             (*it)->scale(scale / this->scale_);
     88        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     89            (*it).second->scale(scale / this->scale_);
    9090        this->scale_ = scale;
    9191    }
    9292
    93     //! Scrolls every element in the set.
     93    //! Scrolls every element in the map.
    9494    void OverlayGroup::setScroll(const Vector2& scroll)
    9595    {
    96         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    97             (*it)->scroll(scroll - this->scroll_);
     96        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     97            (*it).second->scroll(scroll - this->scroll_);
    9898        this->scroll_ = scroll;
    9999    }
     
    101101    /**
    102102    @brief
    103         Adds an element to the set (used when loading with XMLPort).
     103        Adds an element to the map (used when loading with XMLPort).
    104104    @remarks
    105105        The names of the OrxonoxOverlays have to be unique!
     
    107107    void OverlayGroup::addElement(OrxonoxOverlay* element)
    108108    {
    109         hudElements_.insert(element);
    110         element->setVisible(this->isVisible());
    111         if (this->owner_)
    112             element->setOwner(this->owner_);
    113     }
    114 
    115     /**
     109        this->insertElement(element, element->getName());
     110    }
     111
     112        /**
     113    @brief
     114        Adds an element to the map.
     115    @param element
     116        The element to be added.
     117    @param name
     118        The name of the element.
     119    @remarks
     120        The names of the OrxonoxOverlays have to be unique!
     121    */
     122    void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name)
     123    {
     124        element->setName(name);
     125        if (hudElements_.find(name) != hudElements_.end())
     126        {
     127            COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
     128        }
     129        else
     130        {
     131            hudElements_[name] = element;
     132            element->setVisible(this->isVisible());
     133                        if (this->owner_)
     134                element->setOwner(this->owner_);
     135        }
     136    }
     137
     138        /**
    116139    @brief
    117140        Removes an element from the map.
    118     @param element
    119         The element that is to be removed.
     141    @param name
     142        The name of the element that is removed.
    120143    @return
    121144        Returns true if there was such an element to remove, false if not.
    122145    */
    123     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
    124     {
    125         if(this->hudElements_.erase(element) == 0)
     146    bool OverlayGroup::removeElement(const std::string & name)
     147    {
     148        if(this->hudElements_.erase(name) == 0)
    126149            return false;
    127150        return true;
     
    133156        if (index < this->hudElements_.size())
    134157        {
    135             std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
     158            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
    136159            for (unsigned int i = 0; i != index; ++it, ++i)
    137160                ;
    138             return (*it);
     161            return (*it).second;
    139162        }
    140163        else
     
    145168    void OverlayGroup::changedVisibility()
    146169    {
    147         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    148             (*it)->setVisible(this->isVisible());
    149     }
    150 
    151     void OverlayGroup::setOwner(BaseObject* owner)
     170        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     171            (*it).second->setVisible(this->isVisible());
     172    }
     173
     174    void OverlayGroup::setOwner(ControllableEntity* owner)
    152175    {
    153176        this->owner_ = owner;
    154177
    155         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    156             (*it)->setOwner(owner);
     178        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     179            (*it).second->setOwner(owner);
    157180    }
    158181
Note: See TracChangeset for help on using the changeset viewer.