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!

Location:
code/branches/objecthierarchy/src/orxonox/overlays/hud
Files:
5 edited

Legend:

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

    r2042 r2046  
    4949    CreateFactory(ChatOverlay);
    5050
    51     ChatOverlay::ChatOverlay(BaseObject* creator) : OverlayText(creator)
     51    ChatOverlay::ChatOverlay(BaseObject* creator)
     52        : OverlayText(creator)
    5253    {
    5354        RegisterObject(ChatOverlay);
    5455
    55         this->displayTime_ = 0;
     56        this->displayTime_ = 0.0;
    5657
    5758        this->setConfigValues();
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDBar.cc

    r2019 r2046  
    4646    CreateFactory(BarColour);
    4747
    48     BarColour::BarColour(BaseObject* creator) : BaseObject(creator), position_(0.0)
     48    BarColour::BarColour(BaseObject* creator)
     49        : BaseObject(creator)
    4950    {
    5051        RegisterObject(BarColour);
     52
     53        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        setPosition(0.0);
    5155    }
    5256
     
    5559        SUPER(BarColour, XMLPort, xmlElement, mode);
    5660
    57         XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode)
    58             .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    59         XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f);
     61        XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode);
     62        XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode);
    6063    }
    6164
     
    6366    unsigned int HUDBar::materialcount_s = 0;
    6467
    65     HUDBar::HUDBar(BaseObject* creator) : OrxonoxOverlay(creator), bar_(0), textureUnitState_(0)
     68    HUDBar::HUDBar(BaseObject* creator)
     69        : OrxonoxOverlay(creator)
    6670    {
    6771        RegisterObject(HUDBar);
     72
     73        // create new material
     74        std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
     75        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
     76        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
     77        this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
     78        this->textureUnitState_->setTextureName("bar2.tga");
     79        // use the default colour
     80        this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
     81
     82        this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     83            .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString()));
     84        this->bar_->setMaterialName(materialname);
     85
     86        setValue(0.4567654f);
     87        setRightToLeft(false);
     88        setAutoColour(true);
     89
     90        this->background_->addChild(bar_);
    6891    }
    6992
    7093    HUDBar::~HUDBar()
    7194    {
    72         if (this->bar_)
     95        if (this->isInitialized())
    7396            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
    7497    }
     
    78101        SUPER(HUDBar, XMLPort, xmlElement, mode);
    79102
    80         if (mode == XMLPort::LoadObject)
    81         {
    82             // create new material
    83             std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
    84             Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
    85             material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    86             this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
    87             this->textureUnitState_->setTextureName("bar2.tga");
    88             // use the default colour
    89             this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
    90 
    91             this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    92                 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString()));
    93             this->bar_->setMaterialName(materialname);
    94             this->background_->addChild(bar_);
    95         }
    96 
    97         XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode).defaultValues(0.4567654f);
    98         XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false);
    99         XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode).defaultValues(true);
     103        XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
     104        XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
     105        XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
    100106        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    101107    }
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDNavigation.cc

    r2019 r2046  
    4848    HUDNavigation::HUDNavigation(BaseObject* creator)
    4949        : OrxonoxOverlay(creator)
    50         , navMarker_(0)
    51         , aimMarker_(0)
    52         , navText_(0)
    5350    {
    5451        RegisterObject(HUDNavigation);
     52
     53        // create nav text
     54        navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
     55            .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
     56
     57        // create nav marker
     58        navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     59            .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
     60        navMarker_->setMaterialName("Orxonox/NavArrows");
     61
     62        // create aim marker
     63        aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     64            .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
     65        aimMarker_->setMaterialName("Orxonox/NavCrosshair");
     66        this->wasOutOfView_ = true; // Ensure the material is changed right the first time..
     67
     68        setFont("Monofur");
     69        setTextSize(0.05f);
     70        setNavMarkerSize(0.05f);
     71        setAimMarkerSize(0.04f);
     72
     73        background_->addChild(navMarker_);
     74        background_->addChild(aimMarker_);
     75        background_->addChild(navText_);
     76
     77        // hide at first
     78        this->setVisible(false);
    5579    }
    5680
    5781    HUDNavigation::~HUDNavigation()
    5882    {
    59         if (this->navMarker_)
     83        if (this->isInitialized())
     84        {
    6085            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
    61         if (this->navText_)
    6286            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
    63         if (this->aimMarker_)
    6487            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
     88        }
    6589    }
    6690
     
    6993        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
    7094
    71         if (mode == XMLPort::LoadObject)
    72         {
    73             // create nav text
    74             navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
    75                 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
    76 
    77             // create nav marker
    78             navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    79                 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
    80             navMarker_->setMaterialName("Orxonox/NavArrows");
    81             wasOutOfView_ = true; // just to ensure the material is changed right the first time..
    82 
    83             // create aim marker
    84             aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    85                 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
    86             aimMarker_->setMaterialName("Orxonox/NavCrosshair");
    87 
    88             background_->addChild(navMarker_);
    89             background_->addChild(aimMarker_);
    90             background_->addChild(navText_);
    91 
    92             // hide at first
    93             this->setVisible(false);
    94         }
    95 
    96         XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
    97         XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f);
    98         XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode)
    99             .defaultValues(0.05f);
    100         XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode)
    101             .defaultValues(0.04f);
     95        XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode);
     96        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode);
     97        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
     98        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
    10299    }
    103100
  • 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
  • code/branches/objecthierarchy/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r2019 r2046  
    3636    CreateFactory(HUDSpeedBar);
    3737
    38     HUDSpeedBar::HUDSpeedBar(BaseObject* creator) : HUDBar(creator)
     38    HUDSpeedBar::HUDSpeedBar(BaseObject* creator)
     39        : HUDBar(creator)
    3940    {
    4041        RegisterObject(HUDSpeedBar);
Note: See TracChangeset for help on using the changeset viewer.