Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 29, 2008, 11:55:37 AM (16 years ago)
Author:
rgrieder
Message:

Changed initialisation of overlay classes to the new convention.
The default values of the XML parameters are set in the constructor with the setter functions!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDRadar.cc

    r2019 r2046  
    4646    CreateFactory(HUDRadar);
    4747
    48     HUDRadar::HUDRadar(BaseObject* creator) : OrxonoxOverlay(creator), marker_(0)
     48    HUDRadar::HUDRadar(BaseObject* creator)
     49        : OrxonoxOverlay(creator)
    4950    {
    5051        RegisterObject(HUDRadar);
     52
     53        marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     54            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
     55        marker_->setMaterialName("Orxonox/RadarMarker");
     56        overlay_->add2D(marker_);
     57        marker_->hide();
     58
     59        setRadarSensitivity(1.0f);
     60        setHalfDotSizeDistance(3000.0f);
     61        setMaximumDotSize(0.1f);
     62
     63        shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
     64        shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     65        shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
    5166    }
    5267
    5368    HUDRadar::~HUDRadar()
    5469    {
    55         if (this->marker_)
     70        if (this->isInitialized())
     71        {
    5672            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
    57         for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
    58             it != this->radarDots_.end(); ++it)
    59         {
    60             Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
     73            for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
     74                it != this->radarDots_.end(); ++it)
     75            {
     76                Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
     77            }
    6178        }
    6279    }
     
    6683        SUPER(HUDRadar, XMLPort, xmlElement, mode);
    6784
    68         if (mode == XMLPort::LoadObject)
    69         {
    70             marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    71                 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
    72             marker_->setMaterialName("Orxonox/RadarMarker");
    73             overlay_->add2D(marker_);
    74             marker_->hide();
    75         }
    76 
    77         XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode)
    78             .defaultValues(1.0f);
    79         XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance,
    80             xmlElement, mode).defaultValues(3000.0f);
    81         XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode)
    82             .defaultValues(0.1f);
    83 
    84         shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
    85         shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
    86         shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     85        XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode);
     86        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode);
     87        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode);
    8788    }
    8889
Note: See TracChangeset for help on using the changeset viewer.