Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2008, 6:37:12 PM (16 years ago)
Author:
rgrieder
Message:
  • new folder structure for overlays:

orxonox/


overlays/

console/
hud/

  • Navigation —> HUDNavigation
  • HUD —> OverlayGroup (not yet begun with that except renaming and getHUD() instead of getSingleton())
  • moved HUD.oxo (file ending should stand for orxonox overlay) to media repository in overlay folder
  • fixed a bug with console noiseSize_ config value (was inverted..)
File:
1 moved

Legend:

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

    r1600 r1601  
    2828
    2929#include "OrxonoxStableHeaders.h"
    30 #include "HUD.h"
     30#include "OverlayGroup.h"
    3131
    3232#include <string>
     
    4444#include "objects/WorldEntity.h"
    4545#include "GraphicsEngine.h"
    46 #include "HUDBar.h"
    47 #include "RadarObject.h"
    48 #include "RadarOverlayElement.h"
    49 #include "Navigation.h"
     46#include "hud/HUDBar.h"
     47#include "hud/RadarObject.h"
     48#include "hud/RadarOverlayElement.h"
     49#include "hud/HUDNavigation.h"
    5050
    5151namespace orxonox
    5252{
    53     CreateFactory(HUD);
    54 
    55     SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
    56     SetConsoleCommandShortcut(HUD, releaseNavigationFocus).setAccessLevel(AccessLevel::User);
    57     SetConsoleCommand(HUD, toggleVisibility, false).setAccessLevel(AccessLevel::User);
    58 
    59     HUD* HUD::instance_s = 0;
     53    CreateFactory(OverlayGroup);
     54
     55    SetConsoleCommandShortcut(OverlayGroup, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
     56    SetConsoleCommandShortcut(OverlayGroup, releaseNavigationFocus).setAccessLevel(AccessLevel::User);
     57    SetConsoleCommand(OverlayGroup, toggleVisibility, false).setAccessLevel(AccessLevel::User);
     58
     59    OverlayGroup* OverlayGroup::hudInstance_s = 0;
    6060
    6161    using namespace Ogre;
    6262
    63     HUD::HUD()
    64     {
    65         assert(instance_s == 0);
    66         instance_s = this;
    67         RegisterObject(HUD);
     63    OverlayGroup::OverlayGroup()
     64    {
     65        assert(hudInstance_s == 0);
     66        hudInstance_s = this;
     67        RegisterObject(OverlayGroup);
    6868
    6969        // Singleton like in Ogre. Constructor and destructor are public,
     
    8282    }
    8383
    84     HUD::~HUD()
     84    OverlayGroup::~OverlayGroup()
    8585    {
    8686        if (this->isInitialized())
     
    109109        }
    110110
    111         instance_s = 0;
    112     }
    113 
    114     void HUD::XMLPort(Element& xmlElement, XMLPort::Mode mode)
     111        hudInstance_s = 0;
     112    }
     113
     114    void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode)
    115115    {
    116116        BaseObject::XMLPort(xmlElement, mode);
     
    119119        showRenderTime_ = true;
    120120
    121         XMLPortObject(HUD, HUDOverlay, "", addHUDElement, getHUDElement, xmlElement, mode, false, true);
     121        XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode, false, true);
    122122
    123123        // create Factories
     
    156156    }
    157157
    158     void HUD::addHUDElement(HUDOverlay* element)
     158    void OverlayGroup::addElement(OrxonoxOverlay* element)
    159159    {
    160160        if (hudElements_.find(element->getName()) != hudElements_.end())
     
    166166    }
    167167
    168     HUDOverlay* HUD::getHUDElement(unsigned int index)
     168    OrxonoxOverlay* OverlayGroup::getElement(unsigned int index)
    169169    {
    170170        if (index < this->hudElements_.size())
    171171        {
    172           std::map<std::string, HUDOverlay*>::const_iterator it = hudElements_.begin();
     172          std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
    173173          for (unsigned int i = 0; i != index; ++it, ++i)
    174174            ;
     
    179179    }
    180180
    181     void HUD::tick(float dt)
     181    void OverlayGroup::tick(float dt)
    182182    {
    183183        radar_->update();
    184184    }
    185185
    186     void HUD::windowResized(int newWidth, int newHeight)
     186    void OverlayGroup::windowResized(int newWidth, int newHeight)
    187187    {
    188188        this->radar_->resize();
    189189    }
    190190
    191     void HUD::addRadarObject(WorldEntity* object, const ColourValue& colour){
     191    void OverlayGroup::addRadarObject(WorldEntity* object, const ColourValue& colour){
    192192        RadarObject* obj = new RadarObject(container_, object, colour);
    193193        roSet_.insert(roSet_.end(), obj);
     
    203203    }
    204204
    205     void HUD::removeRadarObject(WorldEntity* object){
     205    void OverlayGroup::removeRadarObject(WorldEntity* object){
    206206        for(std::list<RadarObject*>::iterator it=roSet_.begin(); it!=roSet_.end(); ++it){
    207207            if ((*it)->getObject() == object)
     
    217217    }
    218218
    219     /*static*/ HUD& HUD::getSingleton()
    220     {
    221         assert(instance_s);
    222         return *instance_s;
    223     }
    224 
    225     /*static*/ void HUD::toggleVisibility(const std::string& name)
    226     {
    227         if (HUD::getSingleton().hudElements_.find(name) != HUD::getSingleton().hudElements_.end())
    228         {
    229             HUD::getSingleton().hudElements_[name]->setVisibility(!HUD::getSingleton().hudElements_[name]->isVisible());
    230         }
    231     }
    232 
    233     /*static*/ void HUD::setEnergy(float value){
    234         HUD::getSingleton().energyBar_->setValue(value);
    235     }
    236 
    237     /*static*/ void HUD::cycleNavigationFocus()
    238     {
    239         if (HUD::getSingleton().hudElements_.find("Navigation") != HUD::getSingleton().hudElements_.end())
    240         {
    241             Navigation* navi = dynamic_cast<Navigation*>(HUD::getSingleton().hudElements_["Navigation"]);
     219    /*static*/ OverlayGroup& OverlayGroup::getHUD()
     220    {
     221        assert(hudInstance_s);
     222        return *hudInstance_s;
     223    }
     224
     225    /*static*/ void OverlayGroup::toggleVisibility(const std::string& name)
     226    {
     227        if (OverlayGroup::getHUD().hudElements_.find(name) != OverlayGroup::getHUD().hudElements_.end())
     228        {
     229            OverlayGroup::getHUD().hudElements_[name]->setVisibility(!OverlayGroup::getHUD().hudElements_[name]->isVisible());
     230        }
     231    }
     232
     233    /*static*/ void OverlayGroup::setEnergy(float value){
     234        OverlayGroup::getHUD().energyBar_->setValue(value);
     235    }
     236
     237    /*static*/ void OverlayGroup::cycleNavigationFocus()
     238    {
     239        if (OverlayGroup::getHUD().hudElements_.find("Navigation") != OverlayGroup::getHUD().hudElements_.end())
     240        {
     241            HUDNavigation* navi = dynamic_cast<HUDNavigation*>(OverlayGroup::getHUD().hudElements_["Navigation"]);
    242242            navi->cycleFocus();
    243243        }
    244244    }
    245245
    246     /*static*/ void HUD::releaseNavigationFocus(){
    247         //HUD::getSingleton().nav_->releaseFocus();
     246    /*static*/ void OverlayGroup::releaseNavigationFocus(){
     247        //OverlayGroup::getHUD().nav_->releaseFocus();
    248248    }
    249249}
Note: See TracChangeset for help on using the changeset viewer.