Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5118 in orxonox.OLD for trunk/src/util/shell.cc


Ignore:
Timestamp:
Aug 24, 2005, 2:45:46 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: semi-active buffers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/shell.cc

    r5115 r5118  
    4545  this->bActive = false;
    4646  this->buffer = new tList<char>;
     47  this->bufferIterator = this->buffer->getIterator();
    4748
    4849  this->textSize = 15;
     
    5354  this->setBufferSize(100);
    5455  this->bufferDisplaySize = 10;
    55   this->setBufferDisplaySize(10);
    5656  this->setAbsCoor2D(3, -400);
    5757  this->delayed = 0;
     
    9090
    9191  // delete all the Chars in the Buffers
    92   tIterator<char>* charIterator = this->buffer->getIterator();
    93   char* charElem = charIterator->firstElement();
     92  char* charElem = this->bufferIterator->firstElement();
    9493  while (charElem != NULL)
    9594  {
    9695    delete charElem;
    97     charElem = charIterator->nextElement();
    98   }
    99   delete charIterator;
     96    charElem = this->bufferIterator->nextElement();
     97  }
     98  delete this->bufferIterator;
    10099
    101100//  if (this->completionList != NULL)
     
    114113  EventHandler::getInstance()->setState(ES_SHELL);
    115114  this->setRelCoorSoft2D(0, 0, 1, 5);
     115
     116  this->bufferIterator->lastElement();
     117  for (int i = 0; i < this->bufferDisplaySize; i++)
     118    this->bufferText[i]->setText(this->bufferIterator->prevElement());
    116119}
    117120
     
    124127  EventHandler::getInstance()->setState(ES_GAME);
    125128  this->setRelCoorSoft2D(0, -400, 1, 5);
     129
    126130}
    127131
     
    249253   }
    250254
    251    if (this->bActive && likely(bufferText != NULL))
     255   if (this->bActive)
    252256   {
    253      Text* lastText = this->bufferText[this->bufferDisplaySize-1];
    254      Vector firstCoord = this->bufferText[0]->getRelCoorSoft2D();
    255 
    256      Text* swapText;
    257      Text* moveText = this->bufferText[0];
    258      this->bufferText[0]->setRelCoorSoft2D(this->bufferText[1]->getRelCoorSoft2D(), 5);
    259      for (unsigned int i = 1; i < this->bufferDisplaySize; i++)
    260      {
    261        if ( i < this->bufferDisplaySize-1)
    262          this->bufferText[i]->setRelCoorSoft2D(this->bufferText[i+1]->getRelCoorSoft2D(),5);
    263        swapText = this->bufferText[i];
    264        this->bufferText[i] = moveText;
    265        moveText = swapText;
    266      }
    267      lastText->setRelCoor2D(firstCoord);
    268      this->bufferText[0] = lastText;
    269 
    270      this->bufferText[0]->setText(newLine);
     257     this->printToDisplayBuffer(newLine);
    271258   }
     259}
     260
     261/**
     262 * prints out some text to the input-buffers
     263 * @param text the text to output.
     264 */
     265void Shell::printToDisplayBuffer(const char* text)
     266{
     267  if(likely(bufferText != NULL))
     268  {
     269    Text* lastText = this->bufferText[this->bufferDisplaySize-1];
     270    Vector firstCoord = this->bufferText[0]->getRelCoorSoft2D();
     271
     272    Text* swapText;
     273    Text* moveText = this->bufferText[0];
     274    this->bufferText[0]->setRelCoorSoft2D(this->bufferText[1]->getRelCoorSoft2D(), 5);
     275    for (unsigned int i = 1; i < this->bufferDisplaySize; i++)
     276    {
     277      if ( i < this->bufferDisplaySize-1)
     278        this->bufferText[i]->setRelCoorSoft2D(this->bufferText[i+1]->getRelCoorSoft2D(),5);
     279      swapText = this->bufferText[i];
     280      this  ->bufferText[i] = moveText;
     281      moveText = swapText;
     282    }
     283    lastText->setRelCoor2D(firstCoord);
     284    this->bufferText[0] = lastText;
     285
     286    this->bufferText[0]->setText(text);
     287  }
    272288}
    273289
Note: See TracChangeset for help on using the changeset viewer.