Changeset 7738 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- May 20, 2006, 12:23:05 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r7737 r7738 51 51 ->describe("Sets the font of the Shell") 52 52 ->defaultValues(SHELL_DEFAULT_FONT) 53 53 ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/")); 54 54 55 55 /** … … 74 74 this->setLayer(E2D_LAYER_ABOVE_ALL); 75 75 this->shellInput.setLayer(E2D_LAYER_ABOVE_ALL); 76 77 this->backgroundMaterial = new Material;78 76 79 77 // Element2D and generals … … 108 106 this->bufferText.pop_front(); 109 107 } 110 111 // delete the inputLine112 delete this->backgroundMaterial;113 108 } 114 109 … … 172 167 void Shell::setFont(const std::string& fontFile) 173 168 { 174 // if (!ResourceManager::isInDataDir(fontFile))175 // return false;176 177 169 this->fontFile = fontFile; 178 170 179 this-> resetValues();171 this->applySettings(); 180 172 } 181 173 … … 193 185 this->lineSpacing = lineSpacing; 194 186 195 this-> resetValues();187 this->applySettings(); 196 188 } 197 189 … … 210 202 this->textColor[3] = a; 211 203 212 this->resetValues(); 213 } 214 204 this->applySettings(); 205 } 215 206 216 207 /** … … 223 214 void Shell::setBackgroundColor(float r, float g, float b, float a) 224 215 { 225 this->backgroundMaterial ->setDiffuse(r, g, b);226 this->backgroundMaterial ->setTransparency(a);216 this->backgroundMaterial.setDiffuse(r, g, b); 217 this->backgroundMaterial.setTransparency(a); 227 218 } 228 219 … … 233 224 void Shell::setBackgroundImage(const std::string& fileName) 234 225 { 235 this->backgroundMaterial->setDiffuseMap(fileName); 236 } 237 238 239 /** 240 * @brief resets the Values of all visible shell's commandos to the Shell's stored values 241 * 242 * this functions synchronizes the stored Data with the visible one. 243 */ 244 void Shell::resetValues() 245 { 246 this->resetText(&this->shellInput, 0); 247 this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize)); 248 249 unsigned int i = 0; 250 /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some 251 * output is routed from Some other Thread or by Changing any Values. 252 */ 253 std::list<MultiLineText*> bufferTextCopy = this->bufferText; 254 for (std::list<MultiLineText*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i) 255 { 256 this->resetText(*text, i); 257 (*text)->setRelCoor2D( calculateLinePosition(i) ); 258 } 259 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); 260 } 261 262 void Shell::resetText(Text* text, unsigned int position) 226 this->backgroundMaterial.setDiffuseMap(fileName); 227 } 228 229 /** 230 * @brief repositiones all the Texts to their position. 231 */ 232 void Shell::repositionText() 233 { 234 int linePos = -1; 235 std::list<MultiLineText*>::iterator textIt; 236 for (textIt = this->bufferText.begin() ; textIt != this->bufferText.end(); ++textIt ) 237 { 238 linePos += (*textIt)->getLineCount(); 239 (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); 240 } 241 } 242 243 244 /** 245 * @brief applies the Shells Settings to a single Text of the Shell. 246 * @param text the Text to apply the settings to. 247 */ 248 void Shell::applyTextSettings(Text* text) 263 249 { 264 250 text->setFont(this->fontFile, this->textSize); 251 text->setSize(this->textSize); 265 252 text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 266 253 text->setBlending(this->textColor[3]); … … 270 257 } 271 258 259 /** 260 * @brief resets the Values of all visible shell's commandos to the Shell's stored values 261 * 262 * this functions synchronizes the stored Data with the visible one. 263 */ 264 void Shell::applySettings() 265 { 266 this->applyTextSettings(&this->shellInput); 267 this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize)); 268 269 /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some 270 * output is routed from Some other Thread or by Changing any Values. 271 */ 272 std::list<MultiLineText*> bufferTextCopy = this->bufferText; 273 for (std::list<MultiLineText*>::iterator textIt = bufferTextCopy.begin(); textIt != bufferTextCopy.end(); ++textIt) 274 { 275 this->applyTextSettings(*textIt); 276 (*textIt)->setLineSpacing(this->lineSpacing); 277 (*textIt)->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX()); 278 } 279 this->repositionText(); 280 281 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); 282 } 272 283 273 284 /** … … 291 302 { 292 303 this->bufferText.push_back(new MultiLineText); 293 this->bufferText.back()->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX());294 this->bufferText.back()->setLineSpacing(0);295 304 } 296 305 } 297 306 this->bufferDisplaySize = bufferDisplaySize; 298 this-> resetValues();307 this->applySettings(); 299 308 } 300 309 … … 304 313 void Shell::flush() 305 314 { 306 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)307 { 308 (*text )->setText(""); // remove all chars from the BufferTexts.315 for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) 316 { 317 (*textIt)->setText(""); // remove all chars from the BufferTexts. 309 318 } 310 319 ShellBuffer::getInstance()->flush(); … … 326 335 327 336 // The LineCount will be started here. 328 int linePos = -1;329 337 330 338 // The First Line gets a special Animation 331 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition( linePos)- Vector2D(-1000,0));339 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0)); 332 340 333 341 // Move all lines one Entry up. 334 for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) 335 { 336 linePos += (*textIt)->getLineCount(); 337 (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); 338 } 339 340 341 /* FANCY EFFECTS :) 342 1: 343 lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0)); 344 lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10); 345 2: 346 lastText->setRelDir2D(-90); 347 lastText->setRelDirSoft2D(0, 20); 348 */ 349 350 } 351 352 /** 353 * moves the Display buffer (up + or down - ) 342 this->repositionText(); 343 } 344 345 346 /** 347 * @brief moves the Display buffer (up + or down - ) 354 348 * @param lineCount the count by which to shift the InputBuffer. 355 349 * … … 409 403 410 404 /** 411 * clears the Shell (empties all buffers)405 * @brief clears the Shell (empties all buffers) 412 406 */ 413 407 void Shell::clear() … … 418 412 419 413 /** 420 * listens for some event414 * @brief listens for some event 421 415 * @param event the Event happened 422 416 */ … … 451 445 // setting the Blending effects 452 446 453 this->backgroundMaterial ->select();447 this->backgroundMaterial.select(); 454 448 455 449 glBegin(GL_TRIANGLE_STRIP); … … 481 475 Vector2D Shell::calculateLinePosition(unsigned int lineNumber) 482 476 { 483 Vector2D val(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize); 484 val.debug(); 485 return val; 477 return Vector2D(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize); 486 478 } 487 479 -
trunk/src/lib/shell/shell.h
r7737 r7738 14 14 15 15 #include "shell_input.h" 16 #include "material.h" 16 17 17 18 #define SHELL_DEFAULT_FONT "fonts/final_frontier.ttf" … … 79 80 80 81 private: 81 void resetValues(); 82 void resetText(Text* text, unsigned int position); 82 void repositionText(); 83 void applyTextSettings(Text* text); 84 void applySettings(); 83 85 // helpers // 84 86 Vector2D calculateLinePosition(unsigned int lineNumber); … … 98 100 float textColor[4]; //!< The text's color [r,g,b,a]. 99 101 std::string fontFile; //!< The file containing the font. 100 Material *backgroundMaterial; //!< A material for the background.102 Material backgroundMaterial; //!< A material for the background. 101 103 102 104 // HANDLING TEXT INPUT
Note: See TracChangeset
for help on using the changeset viewer.