Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5118 in orxonox.OLD for trunk


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

orxonox/trunk: semi-active buffers

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5115 r5118  
    598598      PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    599599      if (this->bRelCoorChanged)
     600      {
     601        this->prevRelCoordinate = this->relCoordinate;
    600602        this->absCoordinate = this->relCoordinate;
     603      }
    601604      if (this->bRelDirChanged)
     605      {
     606        this->prevRelDirection = this->relDirection;
    602607        this->absDirection = this->getAbsDir () * this->relDirection;
     608      }
    603609    }
    604610
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5117 r5118  
    618618
    619619
    620     if( this->parentMode & PNODE_LOCAL_ROTATE && this->bRelDirChanged)
     620    if( this->parentMode & E2D_PARENT_LOCAL_ROTATE && this->bRelDirChanged)
    621621    {
    622622      /* update the current absDirection - remember * means rotation around sth.*/
     
    677677    PRINTF(5)("Element2D::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    678678    if (this->bRelCoorChanged)
     679    {
     680      this->prevRelCoordinate = this->relCoordinate;
    679681      this->absCoordinate = this->relCoordinate;
     682    }
    680683    if (this->bRelDirChanged)
     684    {
     685      this->prevRelDirection = this->relDirection;
    681686      this->absDirection = this->getAbsDir2D() * this->relDirection;
     687    }
    682688  }
    683689
  • trunk/src/lib/util/list.h

    r5115 r5118  
    333333
    334334    T* firstElement();
     335    T* lastElement();
    335336    T* nextElement();
     337    T* prevElement();
    336338    T* seekElement(T* element);
    337339    T* iteratorElement(const tIterator<T>* iterator);
     
    375377    inline tIterator<T>::~tIterator ()
    376378{
    377   this->currentEl = NULL;
    378379}
    379380
     
    382383{
    383384  this->currentEl = this->list->first;
    384   if (this->currentEl == NULL)
    385     return NULL;
    386   else
     385  if (this->currentEl != NULL)
    387386    return this->currentEl->curr;
     387  else
     388    return NULL;
     389}
     390
     391template<class T>
     392    inline T* tIterator<T>::lastElement ()
     393{
     394  this->currentEl = this->list->last;
     395  if (this->currentEl != NULL)
     396    return this->currentEl->curr;
     397  else
     398    return NULL;
    388399}
    389400
     
    405416    return NULL;
    406417}
     418
     419/**
     420 *  use it to iterate backwards through the list
     421 * @returns next list element
     422 */
     423template<class T>
     424    inline T* tIterator<T>::prevElement ()
     425{
     426  if( this->currentEl == NULL)
     427    return NULL;
     428
     429  this->currentEl = this->currentEl->prev;
     430  if (this->currentEl != NULL)
     431    return this->currentEl->curr;
     432  else
     433    return NULL;
     434}
     435
    407436
    408437/**
  • 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
  • trunk/src/util/shell.h

    r5113 r5118  
    1515class Text;
    1616template<class T> class tList;
     17template<class T> class tIterator;
    1718
    1819//! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands
     
    4849    static bool addBufferLineStatic(const char* line, ...);
    4950    void addBufferLine(const char* line, va_list arg);
     51    void printToDisplayBuffer(const char* text);
    5052    void moveBuffer(int lineCount);
    5153    const char* getBufferLine(unsigned int lineNumber);
     
    9698
    9799    tList<char>*           buffer;                 //!< A list of stored char-arrays(strings) to store the history
     100    tIterator<char>*       bufferIterator;         //!< An iterator for the Shells main buffer.
    98101
    99102    Text**                 bufferText;             //!< A list of stored bufferTexts for the display of the buffer
Note: See TracChangeset for help on using the changeset viewer.