Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 22, 2008, 5:25:01 AM (16 years ago)
Author:
landauf
Message:

added several new classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/overlays/OverlayText.cc

    r1784 r1993  
    3131
    3232#include <OgreOverlayManager.h>
    33 #include <OgreTextAreaOverlayElement.h>
    3433#include <OgrePanelOverlayElement.h>
    3534
     
    6867
    6968        XMLPortParam(OverlayText, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
     69        XMLPortParam(OverlayText, "colour",   setColour,   getColour,   xmlElement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    7070        XMLPortParam(OverlayText, "caption",  setCaption,  getCaption,  xmlElement, mode).defaultValues("");
    7171        XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f);
     72        XMLPortParamTemplate(OverlayText, "align", setAlignment, getAlignment, xmlElement, mode, const std::string&).defaultValues("left");
    7273    }
    7374
     
    8485        else
    8586            return blankString;
     87    }
     88
     89    void OverlayText::setColour(const ColourValue& colour)
     90    {
     91        if (this->text_)
     92            this->text_->setColour(colour);
     93    }
     94
     95    const ColourValue& OverlayText::getColour() const
     96    {
     97        if (this->text_)
     98            return this->text_->getColour();
     99        else
     100            return ColourValue::White;
     101    }
     102
     103    void OverlayText::setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment)
     104    {
     105        if (this->text_)
     106            this->text_->setAlignment(alignment);
     107    }
     108
     109    void OverlayText::setAlignment(const std::string& alignment)
     110    {
     111        if (alignment == "right")
     112            this->setAlignment(Ogre::TextAreaOverlayElement::Right);
     113        else if (alignment == "center")
     114            this->setAlignment(Ogre::TextAreaOverlayElement::Center);
     115        else // "left" and default
     116            this->setAlignment(Ogre::TextAreaOverlayElement::Left);
     117    }
     118
     119    std::string OverlayText::getAlignment() const
     120    {
     121        if (this->text_)
     122        {
     123            Ogre::TextAreaOverlayElement::Alignment alignment = this->text_->getAlignment();
     124
     125            switch (alignment)
     126            {
     127                case Ogre::TextAreaOverlayElement::Right:
     128                    return "right";
     129                case Ogre::TextAreaOverlayElement::Center:
     130                    return "center";
     131                case Ogre::TextAreaOverlayElement::Left:
     132                default:;
     133            }
     134        }
     135        return "left";
     136    }
     137
     138    void OverlayText::setCaption(const std::string& caption)
     139    {
     140        this->caption_ = caption;
     141        this->text_->setCaption(caption);
    86142    }
    87143
Note: See TracChangeset for help on using the changeset viewer.