Changeset 5251 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 25, 2005, 1:13:19 AM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r5215 r5251 36 36 /** 37 37 * standard constructor 38 * @ todo this constructor is not jet implemented - do it39 */38 * @param parent the Parent of this node (default NULL) 39 */ 40 40 Element2D::Element2D (Element2D* parent) 41 41 { … … 48 48 /** 49 49 * standard deconstructor 50 */50 */ 51 51 Element2D::~Element2D () 52 52 { … … 54 54 Render2D::getInstance()->unregisterElement2D(this); 55 55 56 if (this->parent) 57 this->parent->removeChild2D(this); 58 else 59 { 60 tIterator<Element2D>* iterator = this->children->getIterator(); 61 Element2D* pn = iterator->firstElement(); 62 while( pn != NULL) 63 { 64 delete pn; 65 pn = iterator->nextElement(); 66 } 67 delete iterator; 68 /* this deletes all children in the list */ 69 } 56 this->remove2D(); 57 // else 58 // { 59 // tIterator<Element2D>* iterator = this->children->getIterator(); 60 // Element2D* pn = iterator->firstElement(); 61 // while( pn != NULL) 62 // { 63 // delete pn; 64 // pn = iterator->nextElement(); 65 // } 66 // delete iterator; 67 // /* this deletes all children in the list */ 68 // } 70 69 delete this->children; 71 70 … … 90 89 this->bindNode = NULL; 91 90 91 // PNODE-stuff 92 this->children = new tList<Element2D>; 92 93 this->setParentMode2D(E2D_PARENT_ALL); 93 this->parent = NULL; 94 this->children = new tList<Element2D>; 94 if (NullElement2D::isInstanciated()) 95 { 96 this->parent = NullElement2D::getInstance(); 97 NullElement2D::getInstance()->children->add(this); 98 NullElement2D::getInstance()->debug(0); 99 } 100 else 101 this->parent = NULL; 95 102 this->absDirection = 0.0; 96 103 this->relDirection = 0.0; … … 442 449 if( likely(child->parent != NULL)) 443 450 { 444 PRINTF(4)("Element2D::addChild() - reparenting node: removing it and adding it again\n");445 451 child->parent->children->remove(child); 446 452 } … … 505 511 void Element2D::setParent2D (Element2D* parent) 506 512 { 507 parent->addChild2D(this); 513 if (parent != NULL) 514 parent->addChild2D(this); 508 515 } 509 516 … … 517 524 if (parentNode != NULL) 518 525 parentNode->addChild2D(this); 519 520 526 } 521 527 -
trunk/src/lib/graphics/render2D/element_2d.h
r5215 r5251 218 218 public: 219 219 /** @returns a Pointer to the only object of this Class */ 220 inline static NullElement2D* getInstance() { if (!singletonRef) singletonRef = new NullElement2D(); return singletonRef; }; 220 inline static NullElement2D* getInstance() { if (!NullElement2D::singletonRef) NullElement2D::singletonRef = new NullElement2D(); return NullElement2D::singletonRef; }; 221 inline static bool isInstanciated() { return (likely(NullElement2D::singletonRef != NULL))?true:false; }; 221 222 virtual ~NullElement2D (); 222 223 -
trunk/src/lib/shell/shell.cc
r5249 r5251 64 64 this->lineSpacing = 0; 65 65 this->bActive = false; 66 this->fontFile = NULL; 67 this->setFont("fonts/dpquake_.ttf"); 66 68 67 69 // BUFFER … … 88 90 delete[] this->bufferText; 89 91 delete this->bufferIterator; 90 92 delete[] this->fontFile; 91 93 // delete the inputLine 92 94 delete this->shellInput; … … 123 125 void Shell::deactivate() 124 126 { 127 this->setFont("fonts/dark_crystal.ttf"); 128 this->rebuildText(); 129 125 130 if (this->bActive == false) 126 131 PRINTF(3)("The shell is already inactive\n"); … … 140 145 141 146 this->bufferOffset = 0; 147 } 148 149 /** 150 * sets the File to load the fonts from 151 * @param fontFile the file to load the font from 152 */ 153 void Shell::setFont(const char* fontFile) 154 { 155 if (this->fontFile != NULL) 156 delete[] this->fontFile; 157 158 this->fontFile = new char[strlen(fontFile)+1]; 159 strcpy(this->fontFile, fontFile); 160 142 161 } 143 162 … … 154 173 this->textSize = textSize; 155 174 this->lineSpacing = lineSpacing; 156 this->shellInput->setFont( "fonts/dpquake_.ttf", this->textSize);175 this->shellInput->setFont(this->fontFile, this->textSize); 157 176 158 177 // this->rebuildText(); … … 166 185 void Shell::rebuildText() 167 186 { 168 this->shellInput->setFont( "fonts/dpquake_.ttf", this->textSize);187 this->shellInput->setFont(this->fontFile, this->textSize); 169 188 this->shellInput->setColor(1, 0, 0); 170 189 this->shellInput->setAlignment(TEXT_ALIGN_LEFT); … … 181 200 void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize) 182 201 { 202 Text** bufferText = this->bufferText; 203 this->bufferText = NULL; 204 if (bufferText != NULL) 205 { 206 for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 207 delete bufferText[i]; 208 delete[] bufferText; 209 } 210 211 bufferText = new Text*[bufferDisplaySize]; 212 for (unsigned int i = 0; i < bufferDisplaySize; i++) 213 { 214 bufferText[i] = TextEngine::getInstance()->createText(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC); 215 bufferText[i]->setColor(1, 0, 0); 216 bufferText[i]->setAlignment(TEXT_ALIGN_LEFT); 217 bufferText[i]->setRelCoor2D(calculateLinePosition(i)); 218 bufferText[i]->setText(NULL); 219 bufferText[i]->setParent2D(this); 220 } 221 this->bufferDisplaySize = bufferDisplaySize; 222 223 this->bufferText = bufferText; 224 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); 225 } 226 227 /** 228 * deletes all the Buffers 229 */ 230 void Shell::flush() 231 { 232 // remove all chars from the BufferTexts. 183 233 if (this->bufferText != NULL) 184 {185 for (unsigned int i = 0; i < this->bufferDisplaySize; i++)186 delete this->bufferText[i];187 delete[] this->bufferText;188 }189 190 this->bufferText = new Text*[bufferDisplaySize];191 for (unsigned int i = 0; i < bufferDisplaySize; i++)192 {193 this->bufferText[i] = TextEngine::getInstance()->createText("fonts/dpquake_.ttf", this->textSize, TEXT_RENDER_DYNAMIC);194 this->bufferText[i]->setColor(1, 0, 0);195 this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);196 this->bufferText[i]->setRelCoor2D(calculateLinePosition(i));197 this->bufferText[i]->setText(NULL);198 this->bufferText[i]->setParent2D(this);199 }200 this->bufferDisplaySize = bufferDisplaySize;201 202 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);203 }204 205 /**206 * deletes all the Buffers207 */208 void Shell::flush()209 {210 // remove all chars from the BufferTexts.211 if (this->bufferText)212 234 for (int i = 0; i < this->bufferDisplaySize; i++) 213 235 { -
trunk/src/lib/shell/shell.h
r5248 r5251 48 48 inline bool isActive() const { return this->bActive; }; 49 49 50 void setFont(const char* fontFile); 50 51 void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1); 51 52 void rebuildText(); … … 83 84 unsigned int lineSpacing; //!< The Spacing between lines. 84 85 unsigned int textSize; //!< The size of the text. 85 char* textFont; //!< The file containing the font.86 char* fontFile; //!< The file containing the font. 86 87 87 88 // HANDLING TEXT INPUT
Note: See TracChangeset
for help on using the changeset viewer.