Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5080 in orxonox.OLD


Ignore:
Timestamp:
Aug 19, 2005, 11:28:29 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: shell is now scrolling through the information

Location:
trunk/src/util
Files:
2 edited

Legend:

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

    r5079 r5080  
    3535  this->setName("Shell");
    3636
    37   this->bufferText = new tList<Text>;
    3837  this->buffer = new tList<char>;
    3938
     39  this->textSize = 10;
     40
    4041  //this->bufferSize = 0;
    41   //this->bufferDisplaySize = 0;
     42  this->bufferText = NULL;
    4243  this->setBufferSize(100);
    43   this->setBufferDisplaySize(1);
    44 
    45 //  this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 0, 255, 0);
    46 //  this->inputLineText->setText(NULL);
     44  this->setBufferDisplaySize(10);
     45
     46  this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0);
     47  this->inputLineText->setText(NULL);
    4748
    4849  //this->addBufferLineStatic("asjflksjdvklasmv %s", "doom");
     
    5960{
    6061  // delete what has to be deleted here
    61   tIterator<Text>* textIterator = this->bufferText->getIterator();
    62   Text* textElem = textIterator->nextElement();
    63 
    64   while (textElem != NULL)
    65   {
    66     delete textElem;
    67 
    68     textElem = textIterator->nextElement();
    69   }
    70   delete textIterator;
     62  for (int i = 0; i < this->bufferDisplaySize; i++)
     63    delete this->bufferText[i];
    7164  delete this->bufferText;
     65  delete this->inputLineText;
    7266
    7367  Shell::singletonRef = NULL;
     
    8074void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
    8175{
     76  if (this->bufferText != NULL)
     77  {
     78    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
     79      delete this->bufferText[i];
     80    delete this->bufferText;
     81  }
     82
     83  this->bufferText = new Text*[bufferDisplaySize];
     84  for (unsigned int i = 0; i < bufferDisplaySize; i++)
     85  {
     86    this->bufferText[i] = TextEngine::getInstance()->createText("fonts/earth.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0);
     87    this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
     88    this->bufferText[i]->setPosition2D(5, 400 + 12*i);
     89    this->bufferText[i]->setText(NULL);
     90  }
     91
     92
    8293  this->bufferDisplaySize = bufferDisplaySize;
    83 
    84   while (bufferDisplaySize < this->bufferText->getSize())
    85   {
    86     delete this->bufferText->lastElement();
    87     this->bufferText->removeLast();
    88   }
    89   while(bufferDisplaySize > this->bufferText->getSize())
    90   {
    91     Text* newText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 0, 255, 0);
    92     newText->setAlignment(TEXT_ALIGN_LEFT);
    93     newText->setPosition2D(5, 500);
    94     newText->setText("");
    95     this->bufferText->add(newText);
    96   }
    9794}
    9895
     
    103100{
    104101  // remove all chars from the BufferTexts.
    105   tIterator<Text>* textIterator = this->bufferText->getIterator();
    106   Text* textElem = textIterator->nextElement();
    107 
    108   while (textElem != NULL)
    109   {
    110     textElem->setText(NULL);
    111 
    112     textElem = textIterator->nextElement();
    113   }
    114   delete textIterator;
     102  if (this->bufferText)
     103    for (int i; i < this->bufferDisplaySize; i++)
     104    {
     105      this->bufferText[i]->setText(NULL);
     106    }
    115107
    116108
     
    146138  return true;
    147139}
    148 
     140int curr = 0;
     141
     142/**
     143 * add a Line to the List of Buffers
     144 * @param line
     145 * @param arguments
     146 *
     147 * This function Adds one line to the buffer.
     148 * and displays the line as the First Line of the display-buffer
     149 */
    149150void Shell::addBufferLine(const char* line, va_list arguments)
    150151{
     
    154155   strcpy(newLine, this->bufferArray);
    155156
    156 //   this->buffer->add(newLine);
    157 //
    158 //   if (this->buffer->getSize() > this->bufferSize)
    159 //   {
    160 //     delete this->buffer->firstElement();
    161 //     this->buffer->remove(this->buffer->firstElement());
    162 //   }
    163 
    164   this->bufferText->firstElement()->setText(newLine);
    165 //  this->inputLineText->setText(line);
     157   this->buffer->add(newLine);
     158
     159   if (this->buffer->getSize() > this->bufferSize)
     160   {
     161     delete this->buffer->firstElement();
     162     this->buffer->remove(this->buffer->firstElement());
     163   }
     164
     165   if (likely(bufferText != NULL))
     166   {
     167     Text* moveText = this->bufferText[this->bufferDisplaySize-1];
     168     for (int i = this->bufferDisplaySize-1; i > 0; i--)
     169     {
     170       this->bufferText[i] = this->bufferText[i-1];
     171     // this->bufferText[i]
     172     }
     173     this->bufferText[0] = moveText;
     174   }
     175   this->bufferText[0]->setText(newLine);
     176   // this->bufferText->
     177//  this->inputLineText->setText(newLine);
    166178}
    167179
  • trunk/src/util/shell.h

    r5075 r5080  
    7878    tList<char>*           buffer;                 //!< A list of stored char-arrays(strings) to store the history
    7979
    80     tList<Text>*           bufferText;             //!< A list of stored bufferTexts for the display of the buffer
     80    Text**                 bufferText;             //!< A list of stored bufferTexts for the display of the buffer
    8181    Text*                  inputLineText;          //!< The inputLine of the Shell
     82    unsigned int           textSize;               //!< The size of the text.
     83    unsigned int           lineSpacing;            //!< The Spacing between lines.
    8284
    8385    char                   bufferArray[10000];     //!< a BUFFER for fast writing
    84 
    8586};
    8687
Note: See TracChangeset for help on using the changeset viewer.