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/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
Note: See TracChangeset for help on using the changeset viewer.