Changeset 5251 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Sep 25, 2005, 1:13:19 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.