[6514] | 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 | |
---|
[7019] | 18 | #include "text_element.h" |
---|
[6514] | 19 | |
---|
[7193] | 20 | #include "util/loading/load_param.h" |
---|
| 21 | #include "util/loading/factory.h" |
---|
[6514] | 22 | |
---|
| 23 | #include "graphics_engine.h" |
---|
| 24 | #include "state.h" |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | using namespace std; |
---|
| 28 | |
---|
| 29 | |
---|
[7019] | 30 | CREATE_FACTORY(TextElement, CL_TEXT_ELEMENT); |
---|
[6514] | 31 | |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * standart constructor |
---|
| 35 | */ |
---|
[7019] | 36 | TextElement::TextElement (const TiXmlElement* root) |
---|
[6514] | 37 | { |
---|
[7019] | 38 | this->setClassID(CL_TEXT_ELEMENT, "TextElement"); |
---|
| 39 | this->setName("TextElement"); |
---|
| 40 | |
---|
| 41 | this->setLayer(E2D_LAYER_TOP); |
---|
| 42 | this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); |
---|
| 43 | |
---|
| 44 | this->setSize(20); |
---|
| 45 | this->setFont("fonts/earth.ttf"); |
---|
[7021] | 46 | this->setAlignment(TEXT_ALIGN_CENTER); |
---|
[7019] | 47 | |
---|
[6852] | 48 | if(root != NULL) |
---|
[6841] | 49 | this->loadParams(root); |
---|
[6514] | 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | /** |
---|
[7019] | 54 | * destroys a TextElement |
---|
[6514] | 55 | */ |
---|
[7019] | 56 | TextElement::~TextElement () |
---|
[6514] | 57 | { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
[7019] | 61 | void TextElement::loadParams(const TiXmlElement* root) |
---|
[6514] | 62 | { |
---|
[6851] | 63 | Element2D::loadParams(root); |
---|
[6514] | 64 | |
---|
[7019] | 65 | LoadParam(root, "size", this, Text, setSize); |
---|
[6514] | 66 | |
---|
[7019] | 67 | LoadParam(root, "text", this, TextElement, setText); |
---|
[6514] | 68 | |
---|
[7019] | 69 | LoadParam(root, "font", this, TextElement, setFont); |
---|
[6514] | 70 | } |
---|
| 71 | |
---|
[7221] | 72 | void TextElement::setText(const std::string& text) |
---|
[6514] | 73 | { |
---|
[7019] | 74 | Text::setText(text); |
---|
[6514] | 75 | } |
---|
| 76 | |
---|
[7221] | 77 | void TextElement::setFont(const std::string& font) |
---|
[6514] | 78 | { |
---|
[7019] | 79 | Text::setFont(font, (unsigned int)this->getSizeY2D()); |
---|
[6514] | 80 | } |
---|