Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 3, 2008, 2:52:50 PM (16 years ago)
Author:
chaiy
Message:

hallo

File:
1 edited

Legend:

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

    r979 r980  
    33*
    44*
    5 *   License notice:asdf
     5*   License notice:
    66*
    77*   This program is free software; you can redistribute it and/or
     
    2828#include <OgreOverlayManager.h>
    2929#include <OgreOverlayElement.h>
     30#include <OgreTextAreaOverlayElement.h>
    3031#include <OgreStringConverter.h>
    31 #include <OgreColourValue.h>
    3232#include <string.h>
    3333
     
    3737{
    3838  using namespace Ogre;
     39   
     40  Bar::Bar(Real left, Real top, Real width, Real height,
     41          int dir,  int colour, std::string name){
     42    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
     43    element = overlayManager.createOverlayElement("Panel",name);
     44    element->setMetricsMode(Ogre::GMM_PIXELS);
     45    dir_ = dir;
     46    left_ = left;
     47    top_ = top;
     48    width_ = width;
     49    height_ = height;
     50    element->setPosition(left_,top_);
     51    element->setDimensions(width_,height_);
     52    setColour(colour);
     53  }
     54 
     55  Bar::~Bar(void){}
     56 
     57 
     58  void Bar::reset(int percentage){
     59    switch(dir_){
     60      case 1:
     61        element->setPosition(left_,top_);
     62        element->setDimensions(width_,height_*percentage/100);
     63        break;
     64      case 2:
     65        element->setPosition(left_+width_-width_*percentage/100,top_);
     66        element->setDimensions(width_*percentage/100,height_);
     67        break;
     68      case 3:
     69        element->setPosition(left_,top_+height_-height_*percentage/100);
     70        element->setDimensions(width_,height_*percentage/100);
     71        break;
     72      default:
     73        element->setPosition(left_,top_);
     74        element->setDimensions(width_*percentage/100,height_); 
     75    }
     76  }
    3977
    40   Bar::Bar(void){}
     78  void Bar::setColour(int colour){
     79    switch(colour){
     80     case 0:
     81        element->setMaterialName("Orxonox/Red");
     82        break;
     83     case 1:
     84        element->setMaterialName("Orxonox/Yellow");
     85        break;
     86     case 2:
     87        element->setMaterialName("Orxonox/Green");
     88    }
     89  }
    4190
    42   Bar::~Bar(void){}
     91  void Bar::show(){element->show();}
     92
     93  void Bar::hide(){element->hide();}
     94
     95  SmartBar::SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
     96        int dir, std::string name) : Bar::Bar(left, top, width, height, dir, Bar::YELLOW, name){
     97  }
     98
     99  SmartBar::~SmartBar(void){}
    43100
    44101
    45 /*  void Bar::setPercentage(Ogre::Real percentage){
    46     percentage_=percentage;
    47     if(horz_){setWidth(int(percentage_* maxLength_));}
    48         else {setHeight(int(percentage_ * maxHeight_));}
    49     }
    50 */
    51 
    52   void Bar::setPercentage(Ogre::Real percentage){
    53     percentage_ = percentage;
    54 //    setWidth(getWidth());
     102  void SmartBar::reset(int percentage){
     103    if (percentage>50) {setColour(Bar::GREEN);}
     104    else if (percentage>25) {setColour(Bar::YELLOW);}
     105    else setColour(Bar::RED);
     106    Bar::reset(percentage);
    55107  }
    56108
     109}
    57110
    58111
    59 
    60   void Bar::setColor(ColourValue color){
    61     color_=color;
    62     setColour(color);
    63   }
    64 
    65 
    66 }
Note: See TracChangeset for help on using the changeset viewer.