| 1 | /* |
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 3 | |
|---|
| 4 | Copyright (C) 2004 orx |
|---|
| 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
|---|
| 9 | any later version. |
|---|
| 10 | |
|---|
| 11 | ### File Specific: |
|---|
| 12 | main-programmer: Patrick Boenzli |
|---|
| 13 | co-programmer: ... |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
|---|
| 17 | |
|---|
| 18 | #include "text_element.h" |
|---|
| 19 | |
|---|
| 20 | #include "util/loading/load_param.h" |
|---|
| 21 | #include "util/loading/factory.h" |
|---|
| 22 | |
|---|
| 23 | #include "graphics_engine.h" |
|---|
| 24 | #include "state.h" |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | ObjectListDefinition(TextElement); |
|---|
| 31 | CREATE_FACTORY(TextElement); |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * standart constructor |
|---|
| 36 | */ |
|---|
| 37 | TextElement::TextElement (const TiXmlElement* root) |
|---|
| 38 | { |
|---|
| 39 | this->registerObject(this, TextElement::_objectList); |
|---|
| 40 | this->setName("TextElement"); |
|---|
| 41 | |
|---|
| 42 | this->setLayer(E2D_LAYER_TOP); |
|---|
| 43 | this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); |
|---|
| 44 | |
|---|
| 45 | this->setSize(20); |
|---|
| 46 | this->setFont("fonts/final_frontier.ttf"); |
|---|
| 47 | this->setAlignment(TEXT_ALIGN_CENTER); |
|---|
| 48 | |
|---|
| 49 | if(root != NULL) |
|---|
| 50 | this->loadParams(root); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | /** |
|---|
| 55 | * destroys a TextElement |
|---|
| 56 | */ |
|---|
| 57 | TextElement::~TextElement () |
|---|
| 58 | { |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | void TextElement::loadParams(const TiXmlElement* root) |
|---|
| 63 | { |
|---|
| 64 | Element2D::loadParams(root); |
|---|
| 65 | |
|---|
| 66 | LoadParam(root, "size", this, Text, setSize); |
|---|
| 67 | |
|---|
| 68 | LoadParam(root, "text", this, TextElement, setText); |
|---|
| 69 | |
|---|
| 70 | LoadParam(root, "font", this, TextElement, setFont); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | void TextElement::setText(const std::string& text) |
|---|
| 74 | { |
|---|
| 75 | Text::setText(text); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | void TextElement::setFont(const std::string& font) |
|---|
| 79 | { |
|---|
| 80 | Text::setFont(font, (unsigned int)this->getSizeY2D()); |
|---|
| 81 | } |
|---|