- Timestamp:
- May 22, 2006, 6:20:35 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r7757 r7762 62 62 this->setName("Shell"); 63 63 64 this->shellBuffer = ShellBuffer::getInstance(); 65 64 66 // EVENT-Handler subscription of '`' to all States. 65 67 EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE); … … 70 72 71 73 // BUFFER 72 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();74 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 73 75 74 76 // INPUT LINE … … 91 93 92 94 this->deactivate(); 93 // register the shell at the ShellBuffer94 ShellBuffer::getInstance()->registerShell(this);95 95 } 96 96 … … 100 100 Shell::~Shell () 101 101 { 102 ShellBuffer::getInstance()->unregisterShell(this);103 104 102 // delete the displayable Buffers 105 103 while (!this->bufferText.empty()) … … 120 118 PRINTF(3)("The shell is already active\n"); 121 119 this->bActive = true; 120 this->activate2D(); 122 121 123 122 EventHandler::getInstance()->pushState(ES_SHELL); … … 126 125 this->setRelCoorSoft2D(0, 0, 5); 127 126 128 std::list<std::string>::const_iterator textLine = ShellBuffer::getInstance()->getBuffer().begin(); 127 this->linesProcessed = this->shellBuffer->getLineCount(); 128 std::list<std::string>::const_iterator textLine = this->bufferIterator = this->shellBuffer->getBuffer().begin(); 129 129 for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) 130 130 { 131 131 (*text)->setVisibility(true); 132 if (textLine != ShellBuffer::getInstance()->getBuffer().end())132 if (textLine != this->shellBuffer->getBuffer().end()) 133 133 { 134 134 (*text)->setText((*textLine)); … … 150 150 PRINTF(3)("The shell is already inactive\n"); 151 151 this->bActive = false; 152 this->deactivate2D(); 152 153 153 154 EventHandler::getInstance()->withUNICODE(false); … … 159 160 (*text)->setVisibility(false); 160 161 // Go to the End again. 161 this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();162 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 162 163 } 163 164 … … 337 338 (*textIt)->setText(""); // remove all chars from the BufferTexts. 338 339 } 339 ShellBuffer::getInstance()->flush();340 this->shellBuffer->flush(); 340 341 // BUFFER FLUSHING 341 342 } … … 353 354 // Set the new Text. 354 355 this->bufferText.front()->setText(text); 356 this->bufferIterator = this->shellBuffer->getBuffer().begin(); 355 357 356 358 // The LineCount will be started here. … … 358 360 // The First Line gets a special Animation 359 361 this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0)); 362 360 363 361 364 // Move all lines one Entry up. … … 378 381 if (moves < lineCount) 379 382 { 380 if(this->bufferIterator == -- ShellBuffer::getInstance()->getBuffer().end())383 if(this->bufferIterator == --this->shellBuffer->getBuffer().end()) 381 384 break; 382 385 ++moves; … … 385 388 else 386 389 { 387 if (this->bufferIterator == ShellBuffer::getInstance()->getBuffer().begin())390 if (this->bufferIterator == this->shellBuffer->getBuffer().begin()) 388 391 break; 389 392 --moves; … … 414 417 for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, ++it) 415 418 { 416 if (it == ShellBuffer::getInstance()->getBuffer().end())419 if (it == this->shellBuffer->getBuffer().end()) 417 420 { 418 421 PRINTF(1)("LAST LINE REACHED\n"); … … 473 476 } 474 477 478 void Shell::tick(float dt) 479 { 480 if (this->linesProcessed < this->shellBuffer->getLineCount()) 481 { 482 unsigned int pollLines = this->shellBuffer->getLineCount() - this->linesProcessed; 483 if (this->bufferText.size() < pollLines) 484 pollLines = this->bufferText.size(); 485 if (unlikely(this->shellBuffer->getBuffer().size() < pollLines)) 486 pollLines = this->shellBuffer->getBuffer().size(); 487 488 std::list<std::string>::const_iterator line = this->shellBuffer->getBuffer().begin(); 489 unsigned int i; 490 for(i = 0; i < pollLines; i++) 491 line ++; 492 for (i = 0; i < pollLines; i++) 493 { 494 this->printToDisplayBuffer((*--line)); 495 } 496 } 497 this->linesProcessed = this->shellBuffer->getLineCount(); 498 } 499 500 475 501 /** 476 502 * displays the Shell … … 527 553 528 554 529 ShellBuffer::getInstance()->debug();555 this->shellBuffer->debug(); 530 556 } 531 557 -
trunk/src/lib/shell/shell.h
r7757 r7762 14 14 15 15 #include "shell_input.h" 16 #include "shell_buffer.h" 16 17 #include "material.h" 17 18 … … 75 76 virtual void process(const Event &event); 76 77 // Element2D-functions 78 virtual void tick(float dt); 77 79 virtual void draw() const; 80 78 81 79 82 void debug() const; … … 90 93 private: 91 94 // GENERAL 95 ShellBuffer* shellBuffer; //!< The local ShellBuffer. 96 92 97 bool bActive; //!< If the shell is active. 93 98 unsigned int shellHeight; //!< The hight of the Shell in Pixels. … … 104 109 std::list<MultiLineText*> bufferText; //!< A list of stored bufferTexts for the display of the buffer. 105 110 111 unsigned long linesProcessed; //!< How many Lines have been processed. 112 106 113 std::list<std::string>::const_iterator bufferIterator; //!< used to move through and print the Buffer 107 114 }; -
trunk/src/lib/shell/shell_buffer.cc
r7761 r7762 32 32 { 33 33 ShellBuffer::singletonRef = this; 34 this->shell = NULL;35 34 36 35 this->lineCount = 0; 37 36 this->bufferArray[0] = '\0'; 38 37 39 this->set BufferSize(100);38 this->setMaxBufferSize(100); 40 39 } 41 40 … … 48 47 ShellBuffer::~ShellBuffer () 49 48 { 50 if (this->shell != NULL)51 delete this->shell;52 53 49 ShellBuffer::singletonRef = NULL; 54 }55 56 /**57 * @brief registers the Shell to the Buffer58 * @param shell the Shell to register.59 */60 void ShellBuffer::registerShell(Shell* shell)61 {62 if (this->shell == NULL)63 this->shell = shell;64 else65 PRINTF(1)("already registered a Shell to the ShellBuffer\n");66 }67 68 /**69 * @brief unregisters the Shell from the Buffer70 * @param shell the Shell to unregister.71 */72 void ShellBuffer::unregisterShell(Shell* shell)73 {74 if (this->shell == shell)75 this->shell = NULL;76 else77 PRINTF(1)("cannot unregister shell, because it is not registered to the ShellBuffer\n");78 50 } 79 51 … … 136 108 { 137 109 this->lineCount++; 138 139 printf("Test:: %s \n", inputBuffer.substr(lineBegin, lineEnd - lineBegin).c_str());140 110 this->buffer.push_front(inputBuffer.substr(lineBegin, lineEnd - lineBegin)); 141 if (likely (this->shell != NULL) && unlikely (this->shell->isActive()))142 this->shell->printToDisplayBuffer(this->buffer.front());143 111 } 144 112 else // No end of Line reached. … … 148 116 } 149 117 150 151 152 if (this->buffer.size() > this->bufferSize) 118 if (this->buffer.size() > this->maxBufferSize) 153 119 this->buffer.pop_back(); 154 120 } -
trunk/src/lib/shell/shell_buffer.h
r7761 r7762 16 16 namespace OrxShell 17 17 { 18 // FORWARD DECLARATION19 class Shell;20 21 18 //! A class handling output from orxonox via debug.h 22 19 /** … … 35 32 inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; }; 36 33 37 void registerShell(Shell* shell);38 void unregisterShell(Shell* shell);39 40 34 static bool addBufferLineStatic(const char* line, ...); 41 35 void addBufferLine(const char* line, va_list arg); 42 36 43 // BUFFER //37 /// BUFFER 44 38 /** @param bufferSize the new Buffer-Size */ 45 void set BufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };39 void setMaxBufferSize(unsigned int maxBufferSize) { this->maxBufferSize = maxBufferSize; }; 46 40 void flush(); 47 41 … … 50 44 /** @returns the Count of lines processed by the Shell. */ 51 45 inline unsigned long getLineCount() const { return this->lineCount; }; 46 /** @returns the Current Buffer Size. */ 47 inline unsigned int getBufferSize() const { return this->buffer.size(); }; 52 48 53 49 void debug() const; … … 58 54 private: 59 55 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. 60 unsigned int bufferSize; //!< The Size of the buffer56 unsigned int maxBufferSize; //!< The Size of the buffer 61 57 62 Shell* shell; //!< the Registered Shell.63 58 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing 64 59 std::string keepBuffer; //!< a BUFFER to have multi-non-newLine commands be copied into the shell. -
trunk/src/story_entities/game_world.h
r7739 r7762 12 12 #include "playable.h" 13 13 14 class OrxShell::Shell;14 namespace OrxShell { class Shell; }; 15 15 class WorldEntity; 16 16 class GameRules;
Note: See TracChangeset
for help on using the changeset viewer.