Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1002 for code/branches


Ignore:
Timestamp:
Apr 8, 2008, 11:12:22 AM (17 years ago)
Author:
chaiy
Message:

BarFactory created, but doesn't work yet

Location:
code/branches/hud2/src/orxonox
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud2/src/orxonox/Orxonox.cc

    r991 r1002  
    375375      // show the current time in the HUD
    376376      //orxonoxHUD_->setTime((int)now, 0);
    377       orxonoxHUD_->energyCounter->reset(20);
     377//      orxonoxHUD_->energyCounter->reset(20);
    378378
    379379
  • code/branches/hud2/src/orxonox/hud/Bar.cc

    r1000 r1002  
    2626*/
    2727
    28 #include "OrxonoxStableHeaders.h"
    29 
    3028#include <OgreOverlayManager.h>
    3129#include <OgreOverlayElement.h>
    32 #include <OgreTextAreaOverlayElement.h>
    3330#include <OgreStringConverter.h>
     31#include <OgreColourValue.h>
    3432#include <string.h>
    3533
    36 #include "Bar.h"
     34#include "BarV1.h"
    3735
    3836namespace orxonox
    3937{
    4038  using namespace Ogre;
    41    
    42   Bar::Bar(Real left, Real top, Real width, Real height,
    43           int dir,  int colour, std::string name){
    44     Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
    45     element = overlayManager.createOverlayElement("Panel",name);
    46     element->setMetricsMode(Ogre::GMM_PIXELS);
    47     dir_ = dir;
    48     left_ = left;
    49     top_ = top;
    50     width_ = width;
    51     height_ = height;
    52     element->setPosition(left_,top_);
    53     element->setDimensions(width_,height_);
    54     setColour(colour);
    55   }
     39
     40    Bar::Bar(const String& name):Ogre::OverlayElement(name){}
     41
     42
     43
     44
     45
     46
     47/*  Bar::Bar(const Ogre::String& s){}
    5648 
    5749  Bar::~Bar(void){}
    5850 
    59  
    60   void Bar::reset(int percentage){
    61     switch(dir_){
    62       case 1:
    63         element->setPosition(left_,top_);
    64         element->setDimensions(width_,height_*percentage/100);
    65         break;
    66       case 2:
    67         element->setPosition(left_+width_-width_*percentage/100,top_);
    68         element->setDimensions(width_*percentage/100,height_);
    69         break;
    70       case 3:
    71         element->setPosition(left_,top_+height_-height_*percentage/100);
    72         element->setDimensions(width_,height_*percentage/100);
    73         break;
    74       default:
    75         element->setPosition(left_,top_);
    76         element->setDimensions(width_*percentage/100,height_); 
     51  */
     52/*  void Bar::setPercentage(float percentage){
     53    percentage_=percentage;
     54    if(dir_){setWidth(int(percentage_* getWidth()));}
     55        else {setHeight(int(percentage_ * getHeight()));}
    7756    }
     57
     58
     59  void Bar::setPercentage(float percentage){
     60    percentage_ = percentage;
     61//    setWidth(getWidth());
    7862  }
    7963
    80   void Bar::setColour(int colour){
    81     switch(colour){
    82      case 0:
    83         element->setMaterialName("Orxonox/Red");
    84         break;
    85      case 1:
    86         element->setMaterialName("Orxonox/Yellow");
    87         break;
    88      case 2:
    89         element->setMaterialName("Orxonox/Green");
    90     }
    91   }
    92 
    93   void Bar::show(){element->show();}
    94 
    95   void Bar::hide(){element->hide();}
    96 
    97   SmartBar::SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
    98         int dir, std::string name) : Bar(left, top, width, height, dir, Bar::YELLOW, name){
    99   }
    100 
    101   SmartBar::~SmartBar(void){}
    10264
    10365
    104   void SmartBar::reset(int percentage){
    105     if (percentage>50) {setColour(Bar::GREEN);}
    106     else if (percentage>25) {setColour(Bar::YELLOW);}
    107     else setColour(Bar::RED);
    108     Bar::reset(percentage);
     66 
     67  void Bar::setColor(ColourValue color){
     68    color_=color;
     69    setColour(color);
    10970  }
    110 
     71*/       
     72       
    11173}
    11274
  • code/branches/hud2/src/orxonox/hud/Bar.h

    r991 r1002  
    3030#define _BAR_H__
    3131
     32#include <string>
     33#include <OgreColourValue.h>
     34#include <OgreOverlayElement.h>
     35#include <OgrePrerequisites.h>
    3236#include <string.h>
    33 #include <OgreOverlayElement.h>
    34 #include <OgreTextAreaOverlayElement.h>
    35 #include <OgrePrerequisites.h>
    3637#include "../OrxonoxPrereqs.h"
    3738
     
    4041namespace orxonox
    4142{
    42   class _OrxonoxExport Bar
     43  class Bar : public Ogre::OverlayElement
    4344  {
    4445  private:
    45     int percentage_;
    46     int dir_;   
    47     int left_;
    48     int top_;
    49     int width_;
    50     int height_;
     46    float percentage_;
     47    bool dir_;
     48    Ogre::ColourValue color_;
     49       
    5150       
    5251  public:
    53     static const int LEFT = 0;
    54     static const int UP = 1;
    55     static const int RIGHT = 2;
    56     static const int DOWN = 3;
    5752
    58     static const int RED = 0;
    59     static const int YELLOW = 1;
    60     static const int GREEN = 2;
    61 
    62     Ogre::OverlayElement* element;
    63 
    64     Bar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
    65         int dir, int colour, std::string name);
    66     ~Bar(void);
    67     void reset(int percentage);
    68     void setColour(int colour);
    69     void show();
    70     void hide();
    71    
    72   };
     53    Bar(const Ogre::String& name);
     54//    virtual ~Bar();
    7355
    7456
    75   class _OrxonoxExport SmartBar : public Bar
    76   {
    77   private:
    7857
    79   public:
    80     SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
    81         int dir, std::string name);
    82     ~SmartBar(void);
    83     void reset(int percentage);
    84   };
     58
     59/*    Bar(const Ogre::String& s);
     60    ~Bar(void);
     61    void setPercentage(float percentage);
     62    void setColor(Ogre::ColourValue color);
     63*/  };
    8564}
    8665
  • code/branches/hud2/src/orxonox/hud/HUD.cc

    r1000 r1002  
    3535#include "HUD.h"
    3636#include "Bar.h"
    37 #include "TestElement.h"
     37#include "Factories.h"
    3838// ugly hack
    3939#include "Orxonox.h"
     
    5252    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
    5353
    54     energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter");
     54//    energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter");
    5555
    5656    Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
     
    6262    energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);       
    6363    energyCounterPanel->show();
    64     energyCounterPanel->addChild(energyCounter->element);
    65 
    66     TestOverlayElementFactory *factory = new TestOverlayElementFactory();
     64//    energyCounterPanel->addChild(energyCounter->element);
     65
     66    BarOverlayElementFactory *factory = new BarOverlayElementFactory();
    6767    overlayManager.addOverlayElementFactory(factory);
    68     Ogre::OverlayElement* testElement = overlayManager.createOverlayElementFromFactory("Test", "testElement");
     68    Ogre::OverlayElement* BarElement = overlayManager.createOverlayElementFromFactory("Bar", "BarElement");
     69
     70
     71
     72
    6973
    7074    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
Note: See TracChangeset for help on using the changeset viewer.