[2200] | 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 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
| 43 | CreateFactory(CreateLines); |
---|
| 44 | |
---|
| 45 | /** |
---|
[2320] | 46 | @brief Constructor: Creates a line. |
---|
[2200] | 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 | |
---|
[2222] | 62 | /** |
---|
| 63 | @brief Ensures that the number of OverlayElements is equal to numberOfColumns. |
---|
| 64 | */ |
---|
[2320] | 65 | void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) { |
---|
[2200] | 66 | |
---|
[2222] | 67 | Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); |
---|
[2200] | 68 | |
---|
[2386] | 69 | unsigned int colIndex = 0; |
---|
| 70 | |
---|
[2320] | 71 | while (textColumns_.size() < numberOfColumns) { |
---|
[2200] | 72 | |
---|
[2386] | 73 | Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex))); |
---|
[2222] | 74 | textColumns_.push_back(tempTextArea); |
---|
[2320] | 75 | this->background_->addChild(tempTextArea); |
---|
[2222] | 76 | |
---|
[2386] | 77 | colIndex++; |
---|
| 78 | |
---|
[2222] | 79 | } |
---|
| 80 | |
---|
[2320] | 81 | while (textColumns_.size() > numberOfColumns) { |
---|
[2222] | 82 | |
---|
[2320] | 83 | this->background_->_removeChild(textColumns_.back()); |
---|
| 84 | ovMan->destroyOverlayElement(textColumns_.back()); |
---|
[2222] | 85 | textColumns_.pop_back(); |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|
[2200] | 89 | } |
---|
| 90 | |
---|
[2320] | 91 | void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset) { |
---|
[2222] | 92 | |
---|
[2320] | 93 | this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset); |
---|
[2222] | 94 | |
---|
| 95 | } |
---|
| 96 | |
---|
[2320] | 97 | void CreateLines::setColumnText(int columnIndex, std::string columnText) { |
---|
[2222] | 98 | |
---|
| 99 | this->textColumns_[columnIndex]->setCaption(columnText); |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | |
---|
[2200] | 103 | } |
---|