Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2328 was 2320, checked in by bhildebr, 16 years ago

Completed code for class Scoreboard and fixed some compiler and linker errors

File size: 2.8 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 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 CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) {
66
67        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
68
69        while (textColumns_.size() < numberOfColumns) {
70
71            Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex)));
72            textColumns_.push_back(tempTextArea);
73            this->background_->addChild(tempTextArea);
74
75        }
76
77        while (textColumns_.size() > numberOfColumns) {
78
79            this->background_->_removeChild(textColumns_.back());
80            ovMan->destroyOverlayElement(textColumns_.back());
81            textColumns_.pop_back();
82
83        }
84
85    }
86
87    void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset) {
88
89        this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset);
90
91    }
92
93    void CreateLines::setColumnText(int columnIndex, std::string columnText) {
94
95        this->textColumns_[columnIndex]->setCaption(columnText);
96
97    }
98
99}
Note: See TracBrowser for help on using the repository browser.