Changeset 7426 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Apr 28, 2006, 10:27:28 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text.cc
r7355 r7426 65 65 void Text::setFont(const std::string& fontFile, unsigned int fontSize) 66 66 { 67 Font* tmpFont; 68 Text* newText; 69 Vector tmpVec; 70 71 // unloading the Font if we alrady have one loaded. 72 if (this->font != NULL && this->font != Font::getDefaultFont()) 73 ResourceManager::getInstance()->unload(this->font); 74 this->font = NULL; 67 Font* newFont; 68 Font* oldFont = this->font; 75 69 76 70 // load a new Font 77 71 if (!fontFile.empty()) 78 72 { 79 tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);80 if ( tmpFont != NULL)81 this->font = tmpFont;82 else73 newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize); 74 if (newFont == NULL) 75 { 76 newFont = Font::getDefaultFont(); 83 77 PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str()); 84 } 78 } 79 } 80 else 81 newFont = Font::getDefaultFont(); 82 83 // unloading the Font if we alrady have one loaded. 84 this->font = newFont; 85 if (oldFont != NULL && oldFont != Font::getDefaultFont()) 86 ResourceManager::getInstance()->unload(oldFont); 85 87 } 86 88 -
trunk/src/lib/shell/shell.cc
r7422 r7426 85 85 // Element2D and generals 86 86 this->setAbsCoor2D(3, -400); 87 this->textSize = 20;87 this->textSize = 15; 88 88 this->lineSpacing = 0; 89 89 this->bActive = true; … … 250 250 void Shell::resetValues() 251 251 { 252 this->shellInput.setFont(this->fontFile, this->textSize); 253 this->shellInput.setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 254 this->shellInput.setBlending(this->textColor[3]); 255 this->shellInput.setRelCoor2D(5, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize)); 256 this->shellInput.setLayer(this->getLayer()); 257 if (shellInput.getParent2D() != this) 258 this->shellInput.setParent2D(this); 252 this->resetText(&this->shellInput, 0); 253 this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize)); 259 254 260 255 unsigned int i = 0; 261 for (std::list<Text*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text, ++i) 262 { 263 (*text)->setFont(this->fontFile, this->textSize); 264 (*text)->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 265 (*text)->setBlending(this->textColor[3]); 256 /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some 257 * output is routed from Some other Thread or by Changing any Values. 258 */ 259 std::list<Text*> bufferTextCopy = this->bufferText; 260 for (std::list<Text*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i) 261 { 262 this->resetText(*text, i); 266 263 (*text)->setRelCoor2D( calculateLinePosition(i) ); 267 (*text)->setLayer(this->getLayer());268 if ((*text)->getParent2D() != this)269 (*text)->setParent2D(this);270 264 } 271 265 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); 266 } 267 268 void Shell::resetText(Text* text, unsigned int position) 269 { 270 text->setFont(this->fontFile, this->textSize); 271 text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 272 text->setBlending(this->textColor[3]); 273 text->setLayer(this->getLayer()); 274 if (text->getParent2D() != this) 275 text->setParent2D(this); 272 276 } 273 277 -
trunk/src/lib/shell/shell.h
r7377 r7426 62 62 void setBackgroundImage(const std::string& fileName); 63 63 64 void resetValues();65 66 64 // BUFFERS 67 65 void setBufferDisplaySize(unsigned int bufferDisplaySize); … … 81 79 82 80 private: 81 void resetValues(); 82 void resetText(Text* text, unsigned int position); 83 83 // helpers // 84 84 Vector2D calculateLinePosition(unsigned int lineNumber);
Note: See TracChangeset
for help on using the changeset viewer.