Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 4:05:25 AM (15 years ago)
Author:
rgrieder
Message:

Added stats overlay. "OverlayGroup toggleVisibility Stats" will do what it says.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/overlays/stats/CreateLines.cc

    • Property svn:eol-style set to native
    r2492 r2495  
    3939#include "core/ConfigValueIncludes.h"
    4040
     41#include "overlays/OverlayText.h"
     42#include "overlays/stats/Stats.h"
     43
    4144namespace orxonox
    4245{
    43     CreateFactory(CreateLines);
    44 
    4546    /**
    4647        @brief Constructor: Creates a line.
    4748    */
    48     CreateLines::CreateLines(BaseObject* creator)
    49         : OrxonoxOverlay(creator)
     49    CreateLines::CreateLines(float leftOffset, float topOffset, float width, float height)
    5050    {
    51         RegisterObject(CreateLines);
     51        playerNameText_ = new OverlayText(0);
     52        playerNameText_->setTextSize(0.04);
     53        playerNameText_->setColour(ColourValue(0, 0.75, 0.2, 1));
     54        playerNameText_->setPosition(Vector2(0.1, topOffset + 0.01));
     55
     56        scoreText_ = new OverlayText(0);
     57        scoreText_->setTextSize(0.04);
     58        scoreText_->setColour(ColourValue(0, 0.75, 0.2, 1));
     59        scoreText_->setPosition(Vector2(0.6, topOffset + 0.01));
     60
     61        deathsText_ = new OverlayText(0);
     62        deathsText_->setTextSize(0.04);
     63        deathsText_->setColour(ColourValue(0, 0.75, 0.2, 1));
     64        deathsText_->setPosition(Vector2(0.8, topOffset + 0.01));
     65
     66        background_ = new Stats(0);
     67        background_->setPosition(Vector2(leftOffset, topOffset));
     68        background_->setSize(Vector2(width, height));
    5269    }
    5370
    54     /**
    55         @brief Initializes the lines.
    56     */
    57     void CreateLines::XMLPort(Element& xmlElement, XMLPort::Mode mode)
     71    CreateLines::~CreateLines()
    5872    {
    59         SUPER(CreateLines, XMLPort, xmlElement, mode);
     73        delete this->playerNameText_;
     74        delete this->scoreText_;
     75        delete this->deathsText_;
     76        delete this->background_;
     77    }
     78
     79    void CreateLines::setPlayerName(const std::string& str)
     80    {
     81        this->playerNameText_->setCaption(str);
     82    }
     83
     84    void CreateLines::setScore(const std::string& str)
     85    {
     86        this->scoreText_->setCaption(str);
     87    }
     88
     89    void CreateLines::setDeaths(const std::string& str)
     90    {
     91        this->deathsText_->setCaption(str);
     92    }
     93
     94    void CreateLines::setVisibility(bool visible)
     95    {
     96        this->scoreText_->setVisible(visible);
     97        this->deathsText_->setVisible(visible);
     98        this->playerNameText_->setVisible(visible);
     99        this->background_->setVisible(visible);
    60100    }
    61101
     
    63103        @brief Ensures that the number of OverlayElements is equal to numberOfColumns.
    64104    */
    65     void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) {
     105    //void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) {
    66106
    67         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     107    //    Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    68108
    69         unsigned int colIndex = 0;
     109    //    unsigned int colIndex = 0;
    70110
    71         while (textColumns_.size() < numberOfColumns) {
     111    //    while (textColumns_.size() < numberOfColumns)
     112    //    {
     113    //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex)));
     114    //        textColumns_.push_back(tempTextArea);
     115    //        this->background_->addChild(tempTextArea);
    72116
    73             Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex)));
    74             textColumns_.push_back(tempTextArea);
    75             this->background_->addChild(tempTextArea);
     117    //        colIndex++;
     118    //    }
    76119
    77             colIndex++;
     120    //    while (textColumns_.size() > numberOfColumns)
     121    //    {
     122    //        this->background_->_removeChild(textColumns_.back());
     123    //        ovMan->destroyOverlayElement(textColumns_.back());
     124    //        textColumns_.pop_back();
     125    //    }
     126    //}
    78127
    79         }
     128    //void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset)
     129    //{
     130    //    this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset);
     131    //}
    80132
    81         while (textColumns_.size() > numberOfColumns) {
    82 
    83             this->background_->_removeChild(textColumns_.back());
    84             ovMan->destroyOverlayElement(textColumns_.back());
    85             textColumns_.pop_back();
    86 
    87         }
    88 
    89     }
    90 
    91     void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset) {
    92 
    93         this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset);
    94 
    95     }
    96 
    97     void CreateLines::setColumnText(int columnIndex, std::string columnText) {
    98 
    99         this->textColumns_[columnIndex]->setCaption(columnText);
    100 
    101     }
    102 
     133    //void CreateLines::setColumnText(int columnIndex, std::string columnText)
     134    //{
     135    //    this->textColumns_[columnIndex]->setCaption(columnText);
     136    //}
    103137}
Note: See TracChangeset for help on using the changeset viewer.