Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/overlay/src/orxonox/overlays/stats/CreateLines.cc @ 2225

Last change on this file since 2225 was 2222, checked in by bhildebr, 16 years ago

Created class CreateLines to display several text lines on the scoreboard

File size: 2.7 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 *      Benjamin Hildebrandt
24 *
25 */
26
27#include "OrxonoxStableHeaders.h"
28#include "CreateLines.h"
29
30#include <string>
31#include <OgreOverlay.h>
32#include <OgreOverlayElement.h>
33#include <OgreOverlayManager.h>
34#include <OgreOverlayContainer.h>
35
36#include "util/Convert.h"
37#include "util/Debug.h"
38#include "core/CoreIncludes.h"
39#include "core/ConfigValueIncludes.h"
40
41namespace orxonox
42{
43    CreateFactory(CreateLines);
44
45    /**
46        @brief Constructor: Creates and initializes a line.
47    */
48    CreateLines::CreateLines(BaseObject* creator)
49        : OrxonoxOverlay(creator)
50    {
51        RegisterObject(CreateLines);
52    }
53
54    /**
55        @brief Initializes the lines.
56    */
57    void CreateLines::XMLPort(Element& xmlElement, XMLPort::Mode mode)
58    {
59        SUPER(CreateLines, XMLPort, xmlElement, mode);
60    }
61
62    /**
63        @brief Ensures that the number of OverlayElements is equal to numberOfColumns.
64    */
65    void setNumberOfColumns(unsigned int numberOfColumns) {
66
67        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
68
69        while (textColumns_.getSize() < numberOfColumns) {
70
71            tempTextArea* = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex)));
72            textColumns_->add2D(tempTextArea);
73            textColumns_.push_back(tempTextArea);
74
75        }
76
77        while (textColumns_.getSize() > numberOfColumns) {
78
79            ovMan->destroy(textColumns_.back());
80            textColumns_.pop_back();
81
82        }
83
84    }
85
86    void alignColumn(int columnIndex, float leftOffset) {
87
88        this->textColumns_[columnIndex]->setPosition(leftOffset,0);
89
90    }
91
92    void setColumnText(int columnIndex, string columnText) {
93
94        this->textColumns_[columnIndex]->setCaption(columnText);
95
96    }
97
98}
Note: See TracBrowser for help on using the repository browser.