Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud/src/orxonox/overlays/HUDText.cc @ 1614

Last change on this file since 1614 was 1614, checked in by rgrieder, 16 years ago
  • Dots on the Radar actually disappear now when a Ship gets destroyed…
  • svn save to keep History of HUDText when renaming AND moving
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "HUDText.h"
31
32#include <OgreOverlayManager.h>
33#include <OgreTextAreaOverlayElement.h>
34#include <OgrePanelOverlayElement.h>
35
36#include "util/Convert.h"
37
38namespace orxonox
39{
40  CreateFactory(HUDText);
41
42  using namespace Ogre;
43
44  HUDText::HUDText()
45    : text_(0)
46  {
47    RegisterObject(HUDText);
48  }
49
50  HUDText::~HUDText()
51  {
52    if (this->isInitialized())
53    {
54      if (this->text_)
55          OverlayManager::getSingleton().destroyOverlayElement(this->text_);
56    }
57  }
58
59  void HUDText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
60  {
61    OrxonoxOverlay::XMLPort(xmlElement, mode);
62
63    if (mode == XMLPort::LoadObject)
64    {
65      this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
66      this->text_->setCharHeight(1.0f);
67      this->text_->setFontName("Monofur");
68
69      this->background_->addChild(this->text_);
70    }
71
72    XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode);
73    XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
74
75    if (mode == XMLPort::LoadObject)
76    {
77      this->text_->setCaption(this->caption_);
78    }
79  }
80
81  void HUDText::setCaption(const std::string& caption)
82  {
83    this->caption_ = caption;
84  }
85
86  const std::string& HUDText::getCaption() const
87  {
88    return this->caption_;
89  }
90
91  void HUDText::setFont(const std::string& font)
92  {
93    if (this->text_ && font != "")
94      this->text_->setFontName(font);
95  }
96
97  std::string HUDText::getFont() const
98  {
99    if (this->text_)
100      return this->text_->getFontName();
101    else
102      return "";
103  }
104}
Note: See TracBrowser for help on using the repository browser.