Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/stats/CreateLines.cc @ 11071

Last change on this file since 11071 was 11071, checked in by landauf, 8 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 4.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 "CreateLines.h"
28
29#include "overlays/OverlayText.h"
30#include "overlays/stats/Stats.h"
31
32namespace orxonox
33{
34    /**
35        @brief Constructor: Creates a line.
36    */
37    CreateLines::CreateLines(float leftOffset, float topOffset, float width, float height)
38    {
39        playerNameText_ = new OverlayText(nullptr);
40        playerNameText_->setTextSize(0.04f);
41        playerNameText_->setColour(ColourValue(0.0f, 0.75f, 0.2f, 1.0f));
42        playerNameText_->setPosition(Vector2(0.1f, topOffset + 0.01f));
43
44        scoreText_ = new OverlayText(nullptr);
45        scoreText_->setTextSize(0.04f);
46        scoreText_->setColour(ColourValue(0.0f, 0.75f, 0.2f, 1.0f));
47        scoreText_->setPosition(Vector2(0.6f, topOffset + 0.01f));
48
49        deathsText_ = new OverlayText(nullptr);
50        deathsText_->setTextSize(0.04f);
51        deathsText_->setColour(ColourValue(0, 0.75f, 0.2f, 1.0f));
52        deathsText_->setPosition(Vector2(0.8f, topOffset + 0.01f));
53
54        background_ = new Stats(nullptr);
55        background_->setPosition(Vector2(leftOffset, topOffset));
56        background_->setSize(Vector2(width, height));
57    }
58
59    CreateLines::~CreateLines()
60    {
61        this->playerNameText_->destroy();
62        this->scoreText_->destroy();
63        this->deathsText_->destroy();
64        this->background_->destroy();
65    }
66
67    void CreateLines::setPlayerName(const std::string& str)
68    {
69        this->playerNameText_->setCaption(str);
70    }
71
72    void CreateLines::setScore(const std::string& str)
73    {
74        this->scoreText_->setCaption(str);
75    }
76
77    void CreateLines::setDeaths(const std::string& str)
78    {
79        this->deathsText_->setCaption(str);
80    }
81
82    void CreateLines::setVisibility(bool visible)
83    {
84        this->scoreText_->setVisible(visible);
85        this->deathsText_->setVisible(visible);
86        this->playerNameText_->setVisible(visible);
87        this->background_->setVisible(visible);
88    }
89    void CreateLines::changedVisibility()
90    {
91        this->scoreText_->changedVisibility();
92        this->deathsText_->changedVisibility();
93        this->playerNameText_->changedVisibility();
94        this->background_->changedVisibility();
95    }
96
97    void CreateLines::setOverlayGroup( OverlayGroup* group )
98    {
99        this->scoreText_->setOverlayGroup( group );
100        this->deathsText_->setOverlayGroup( group );
101        this->playerNameText_->setOverlayGroup( group );
102        this->background_->setOverlayGroup( group );
103    }
104
105    /**
106        @brief Ensures that the number of OverlayElements is equal to numberOfColumns.
107    */
108    //void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) {
109
110    //    Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
111
112    //    unsigned int colIndex = 0;
113
114    //    while (textColumns_.size() < numberOfColumns)
115    //    {
116    //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + multi_cast<std::string>(lineIndex) + multi_cast<std::string>(colIndex)));
117    //        textColumns_.push_back(tempTextArea);
118    //        this->background_->addChild(tempTextArea);
119
120    //        colIndex++;
121    //    }
122
123    //    while (textColumns_.size() > numberOfColumns)
124    //    {
125    //        this->background_->_removeChild(textColumns_.back());
126    //        ovMan->destroyOverlayElement(textColumns_.back());
127    //        textColumns_.pop_back();
128    //    }
129    //}
130
131    //void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset)
132    //{
133    //    this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset);
134    //}
135
136    //void CreateLines::setColumnText(int columnIndex, std::string columnText)
137    //{
138    //    this->textColumns_[columnIndex]->setCaption(columnText);
139    //}
140}
Note: See TracBrowser for help on using the repository browser.