Changeset 5344 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 10, 2005, 12:39:21 AM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/graphics_engine.cc
r5318 r5344 27 27 #include "ini_parser.h" 28 28 #include "substring.h" 29 29 #include "text.h" 30 30 31 31 using namespace std; … … 564 564 if (this->geTextCFPS == NULL) 565 565 { 566 this->geTextCFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);566 this->geTextCFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 567 567 this->geTextCFPS->setName("curFPS"); 568 568 this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT); … … 571 571 if (this->geTextMaxFPS == NULL) 572 572 { 573 this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);573 this->geTextMaxFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 574 574 this->geTextMaxFPS->setName("MaxFPS"); 575 575 this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT); … … 578 578 if (this->geTextMinFPS == NULL) 579 579 { 580 this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);580 this->geTextMinFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC); 581 581 this->geTextMinFPS->setName("MinFPS"); 582 582 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); -
trunk/src/lib/graphics/text_engine/font.h
r5343 r5344 2 2 * @file font.h 3 3 * brief Definition of the FONT-loading class 4 * 5 * !! IMPORTANT !! When using ttf fonts clear the license issues prior to 6 * adding them to orxonox. This is really important, because we do not want 7 * to offend anyone. 4 8 */ 5 9 -
trunk/src/lib/graphics/text_engine/text.cc
r5343 r5344 38 38 if (fontFile != NULL) 39 39 this->setFont(fontFile, fontSize); 40 this->setType(type);41 }42 43 /**44 * creates a new Text Element45 * @param font the Font to render this text in46 * @param type The renderType to display this font in47 *48 * this constructor is private, because the user should initialize49 * a text with the TextEngine.50 */51 Text::Text(Font* font, TEXT_RENDER_TYPE type)52 {53 this->init();54 55 this->font = font;56 40 this->setType(type); 57 41 } … … 89 73 90 74 /** 91 * sets the Font of this Text to font92 * @param font the Font (normaly from the ResourceManager) to allocate to this Text93 */94 void Text::setFont(Font* font)95 {96 if (this->font != NULL)97 ResourceManager::getInstance()->unload(this->font);98 this->font = font;99 }100 101 /**102 75 * sets the Font of this Text to font from fontFile 103 76 * @param fontFile the File to load the Font from. … … 111 84 112 85 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize); 113 if (tmpFont == NULL) 86 if (tmpFont != NULL) 87 { 88 if (this->font != NULL) 89 ResourceManager::getInstance()->unload(this->font); 90 this->font = tmpFont; 91 } 92 93 else 114 94 { 115 95 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile); 116 this->setFont(NULL);117 }118 else119 this->setFont(tmpFont);96 if (this->font != NULL) 97 ResourceManager::getInstance()->unload(this->font); 98 this->font = NULL; 99 } 120 100 } 121 101 -
trunk/src/lib/graphics/text_engine/text.h
r5343 r5344 24 24 // FORWARD DECLARATION 25 25 class Font; 26 27 26 28 27 /** … … 57 56 class Text : public Element2D 58 57 { 59 friend class TextEngine;60 58 public: 61 59 Text(const char* fontFile, unsigned int fontSize = TEXT_DEFAULT_SIZE, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC); … … 86 84 87 85 private: 88 Text(Font* font = NULL, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);89 void setFont(Font* font);90 91 86 92 87 private: -
trunk/src/lib/graphics/text_engine/text_engine.cc
r5343 r5344 23 23 24 24 #include "text_engine.h" 25 #include "text.h" 26 #include "font.h" 25 27 26 28 using namespace std; … … 34 36 #include "class_list.h" 35 37 36 #include "p_node.h"37 #include "vector.h"38 38 #include "debug.h" 39 39 #include "list.h" … … 126 126 127 127 /** 128 * creates a new Text with a certain font.129 * @see Font::Font130 * @see Text::Text131 */132 Text* TextEngine::createText(const char* fontFile, unsigned int fontSize, int textType)133 {134 Font* tmpFont;135 Text* newText;136 Vector tmpVec;137 138 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize);139 if (!tmpFont)140 {141 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile);142 return NULL;143 }144 else145 return new Text(tmpFont, TEXT_RENDER_DYNAMIC);146 }147 148 /**149 128 * outputs some nice Debug information 150 129 -
trunk/src/lib/graphics/text_engine/text_engine.h
r5343 r5344 18 18 19 19 #include "base_object.h" 20 #include "font.h"21 #include "text.h"22 20 23 21 #include "vector.h" … … 26 24 class PNode; 27 25 class Font; 26 class Text; 28 27 29 28 /////////////////// … … 37 36 /** @returns a Pointer to the only object of this Class */ 38 37 inline static TextEngine* getInstance() { if (!singletonRef) singletonRef = new TextEngine(); return singletonRef; }; 39 40 Text* createText(const char* fontFile,41 unsigned int fontSize = TEXT_DEFAULT_SIZE,42 int textType = TEXT_RENDER_DYNAMIC);43 38 44 39 void debug() const; -
trunk/src/lib/shell/shell.cc
r5335 r5344 22 22 23 23 24 #include "text _engine.h"24 #include "text.h" 25 25 #include "list.h" 26 26 #include "graphics_engine.h" … … 225 225 for (unsigned int i = 0; i < bufferDisplaySize; i++) 226 226 { 227 bufferText[i] = TextEngine::getInstance()->createText(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC);227 bufferText[i] = new Text(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC); 228 228 bufferText[i]->setColor(1, 0, 0); 229 229 bufferText[i]->setAlignment(TEXT_ALIGN_LEFT); -
trunk/src/lib/shell/shell_input.h
r5254 r5344 10 10 #define _SHELL_INPUT_H 11 11 12 #include "text _engine.h"12 #include "text.h" 13 13 #include "event_listener.h" 14 14
Note: See TracChangeset
for help on using the changeset viewer.