Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 22, 2008, 12:06:55 AM (16 years ago)
Author:
rgrieder
Message:
  • added blankString to String so you can return ""; even if it's a const std::string&
  • fixed several bugs with aspect correct and margin alignment
  • added console commands for OrxonoxOverlays and OverlayGroups for rotate, scale and scroll (you can access the by name (from name=.. in xml file), e.g. "OrxonoxOverlay rotateOverlay SpeedBar 90)
  • converted everything in overlays/ to 4 spaces/tab ;)
  • removed all using namespace Ogre;
  • added background_ Panel to OrxonoxOverlay, since most of the derived classes can use that
  • should work now, but I'll have to test on a tardis box first
File:
1 edited

Legend:

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

    r1614 r1615  
    3535
    3636#include "util/Math.h"
     37#include "util/String.h"
    3738#include "core/ConsoleCommand.h"
    3839#include "objects/SpaceShip.h"
     
    4546    CreateFactory(HUDNavigation);
    4647
    47     //HUDNavigation* HUDNavigation::instance_s = 0;
    48 
    49     using namespace Ogre;
    50 
    5148    HUDNavigation::HUDNavigation()
    52       : container_(0)
    53       , navMarker_(0)
    54       , aimMarker_(0)
    55       , navText_(0)
     49        : navMarker_(0)
     50        , aimMarker_(0)
     51        , navText_(0)
    5652    {
    5753        RegisterObject(HUDNavigation);
    58        
    59         /*assert(instance_s == 0); // singleton class
    60         HUDNavigation::instance_s = this;*/
    6154    }
    6255
    6356    HUDNavigation::~HUDNavigation()
    6457    {
    65         if (this->isInitialized())
    66         {
    67             if (this->navMarker_)
    68                 OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
    69             if (this->navText_)
    70                 OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
    71             if (this->aimMarker_)
    72                 OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
    73             if (this->container_)
    74                 OverlayManager::getSingleton().destroyOverlayElement(this->container_);
    75         }
    76 
    77         //HUDNavigation::instance_s = 0;
     58        if (this->navMarker_)
     59            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
     60        if (this->navText_)
     61            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
     62        if (this->aimMarker_)
     63            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
    7864    }
    7965
     
    8470        if (mode == XMLPort::LoadObject)
    8571        {
    86             // create container because we cannot add a Text element to an Overlay
    87             container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer"));
    88 
    8972            // create nav text
    90             navText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_navText"));
     73            navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
     74                .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr()));
    9175            navText_->setCharHeight(0.05f);
    9276            navText_->setFontName("Monofur");
    9377
    9478            // create nav marker
    95             navMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navMarker"));
     79            navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     80                .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr()));
    9681            navMarker_->setMaterialName("Orxonox/NavArrows");
    9782            navMarkerSize_ = 0.05; //default
     
    9984
    10085            // create aim marker
    101             aimMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_aimMarker"));
     86            aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     87                .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr()));
    10288            aimMarker_->setMaterialName("Orxonox/NavCrosshair");
    10389            aimMarkerSize_ = 0.04; // default
    10490           
    105             container_->addChild(navMarker_);
    106             container_->addChild(aimMarker_);
    107             container_->addChild(navText_);
    108             container_->show();
    109 
    110             overlay_->add2D(container_);
     91            background_->addChild(navMarker_);
     92            background_->addChild(aimMarker_);
     93            background_->addChild(navText_);
     94
     95            // hide at first
     96            this->setVisibility(false);
    11197        }
    11298
     
    122108    }
    123109
    124     void HUDNavigation::setNavMarkerSize(float size)
    125     {
    126         this->navMarkerSize_ = size;
    127     }
    128 
    129     float HUDNavigation::getNavMarkerSize() const
    130     {
    131         return this->navMarkerSize_;
    132     }
    133 
    134     void HUDNavigation::setAimMarkerSize(float size)
    135     {
    136         this->aimMarkerSize_ = size;
    137     }
    138 
    139     float HUDNavigation::getAimMarkerSize() const
    140     {
    141         return this->aimMarkerSize_;
    142     }
    143 
    144110    void HUDNavigation::setFont(const std::string& font)
    145111    {
     
    148114    }
    149115
    150     std::string HUDNavigation::getFont() const
     116    const std::string& HUDNavigation::getFont() const
    151117    {
    152118        if (this->navText_)
    153119            return this->navText_->getFontName();
    154120        else
    155             return "";
     121            return blankString;
    156122    }
    157123
     
    310276            navText_->setCharHeight(navText_->getCharHeight() * yScale);
    311277    }
    312 
    313     /*static*/ /*HUDNavigation& HUDNavigation::getInstance()
    314     {
    315         assert(instance_s);
    316         return *instance_s;
    317     }*/
    318278}
Note: See TracChangeset for help on using the changeset viewer.