Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8503 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 10:35:59 PM (18 years ago)
Author:
bensch
Message:

at least it compiles again :)

Location:
branches/gui/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/defs/class_id.h

    r8271 r8503  
    277277  CL_OBB                        =    0x00720000,
    278278  CL_BOUNDING_SPHERE            =    0x00740000,
    279  
     279
    280280
    281281
     
    304304  CL_HEIGHT_MAP                 =    0x0000090a,
    305305  CL_GRID                       =    0x0000090b,
    306   CL_BSP_MODEL                  =    0x0000090c, //!FIXME 
    307  
     306  CL_BSP_MODEL                  =    0x0000090c, //!FIXME
     307
    308308  CL_MATERIAL                   =    0x00000810,
    309309  CL_SHADER                     =    0x00000811,
     
    361361  CL_GLGUI_IMAGE                =    0x00000b70,
    362362
     363  CL_GLGUI_NOTIFIER             =    0x00000b80,
     364
    363365  // QT_GUI
    364366  CL_GUI_SAVEABLE               =    0x00b10000,
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc

    r8499 r8503  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL
    1717
    18 
     18#include "glgui_notifier.h"
    1919#include "multi_line_text.h"
    2020
    21 #include "graphics_engine.h"
    22 #include "material.h"
    23 #include "event_handler.h"
    2421#include "debug.h"
    2522
    26 namespace OrxShell
     23namespace OrxGui
    2724{
    2825
     
    3027   * standard constructor
    3128   */
    32   Shell::Shell ()
     29  GLGuiNotifier::GLGuiNotifier ()
    3330  {
    34     this->setClassID(CL_GLGUI_NOTIFIER, "Shell");
     31    this->setClassID(CL_GLGUI_NOTIFIER, "GLGuiNotifier");
    3532
    3633    // Element2D and generals
     
    4340   * @brief standard deconstructor
    4441   */
    45   Shell::~Shell ()
     42  GLGuiNotifier::~GLGuiNotifier ()
    4643  {
    4744    // delete the displayable Buffers
     
    5350  }
    5451
    55   /**
    56    * @brief activates the shell
    57    *
    58    * This also feeds the Last few lines from the main buffers into the displayBuffer
    59    */
    60   void Shell::activate()
    61   {
    62     if (this->bActive == true)
    63       PRINTF(3)("The shell is already active\n");
    64     this->bActive = true;
    65     this->activate2D();
    6652
    67     EventHandler::getInstance()->pushState(ES_SHELL);
    68 
    69     this->setRelCoorSoft2D(0, 0, 5);
    70 
    71     this->linesProcessed = this->shellBuffer->getLineCount();
    72     std::list<std::string>::const_iterator textLine = this->bufferIterator = this->shellBuffer->getBuffer().begin();
    73     for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
    74     {
    75       (*text)->setVisibility(true);
    76       if (textLine !=  this->shellBuffer->getBuffer().end())
    77       {
    78         (*text)->setText((*textLine));
    79         textLine++;
    80       }
    81       else
    82         (*text)->setText("");
    83     }
    84     this->shellInput.setVisibility(true);
    85     this->updateResolution( GraphicsEngine::getInstance()->getResolutionX());
    86     this->repositionText();
    87   }
    88 
    89   /**
    90    * @brief deactiveates the Shell.
    91    */
    92   void Shell::deactivate()
    93   {
    94     if (this->bActive == false)
    95       PRINTF(3)("The shell is already inactive\n");
    96     this->bActive = false;
    97     this->deactivate2D();
    98 
    99     EventHandler::getInstance()->popState();
    100 
    101     this->setRelCoorSoft2D(0, -(int)this->shellHeight, 5);
    102 
    103     for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
    104       (*text)->setVisibility(false);
    105     this->shellInput.setVisibility(false);
    106 
    107     // Go to the End again.
    108     this->bufferIterator = this->shellBuffer->getBuffer().begin();
    109   }
    110 
    111   /**
    112    * @brief sets the File to load the fonts from
    113    * @param fontFile the file to load the font from
    114    *
    115    * it is quite important, that the font pointed too really exists!
    116    * (be aware that within orxonox fontFile is relative to the Data-Dir)
    117    */
    118   void Shell::setFont(const std::string& fontFile)
    119   {
    120     this->fontFile = fontFile;
    121 
    122     this->applySettings();
    123   }
    124 
    125   /**
    126    * @brief sets the size of the text and spacing
    127    * @param textSize the size of the Text in Pixels
    128    * @param lineSpacing the size of the Spacing between two lines in pixels
    129    *
    130    * this also rebuilds the entire Text, inputLine and displayBuffer,
    131    * to be accurate again.
    132    */
    133   void Shell::setTextSize(unsigned int textSize, unsigned int lineSpacing)
    134   {
    135     this->textSize = textSize;
    136     this->lineSpacing = lineSpacing;
    137 
    138     this->applySettings();
    139   }
    140 
    141   /**
    142    * @brief sets the color of the Font.
    143    * @param r: red
    144    * @param g: green
    145    * @param b: blue
    146    * @param a: alpha-value.
    147    */
    148   void Shell::setTextColor(float r, float g, float b, float a)
    149   {
    150     this->textColor[0] = r;
    151     this->textColor[1] = g;
    152     this->textColor[2] = b;
    153     this->textColor[3] = a;
    154 
    155     this->applySettings();
    156   }
    157 
    158   /**
    159    * @brief sets the color of the Backgrond.
    160    * @param r: red
    161    * @param g: green
    162    * @param b: blue
    163    * @param a: alpha-value.
    164    */
    165   void Shell::setBackgroundColor(float r, float g, float b, float a)
    166   {
    167     this->backgroundMaterial.setDiffuse(r, g, b);
    168     this->backgroundMaterial.setTransparency(a);
    169   }
    170 
    171   /**
    172    * @brief sets a nice background image to the Shell's background
    173    * @param fileName the filename of the Image to load
    174    */
    175   void Shell::setBackgroundImage(const std::string& fileName)
    176   {
    177     this->backgroundMaterial.setDiffuseMap(fileName);
    178   }
    179 
    180 
    181   /**
    182    * @brief updates the Shell's Width
    183    * @param width the new Width.
    184    */
    185   void Shell::updateResolution(unsigned int width)
    186   {
    187     if (width == this->getSizeX2D())
    188       return;
    189     this->setSizeX2D(width);
    190     for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
    191     {
    192       (*textIt)->setLineWidth(width);
    193     }
    194   }
    19553
    19654  /**
    19755   * @brief repositiones all the Texts to their position.
    19856   */
    199   void Shell::repositionText()
     57  void GLGuiNotifier::repositionText()
    20058  {
    20159    int linePos = -1;
     
    21068
    21169  /**
    212    * @brief applies the Shells Settings to a single Text of the Shell.
     70   * @brief applies the GLGuiNotifiers Settings to a single Text of the GLGuiNotifier.
    21371   * @param text the Text to apply the settings to.
    21472   */
    215   void Shell::applyTextSettings(Text* text)
     73  void GLGuiNotifier::applyTextSettings(Text* text)
    21674  {
    217     text->setSize(this->textSize);
     75/*    text->setSize(this->textSize);
    21876    text->setFont(this->fontFile, this->textSize);
    21977    text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
     
    22179    text->setLayer(this->getLayer());
    22280    if (text->getParent2D() != this)
    223       text->setParent2D(this);
     81      text->setParent2D(this);*/
    22482  }
    22583
    226   /**
    227    * @brief resets the Values of all visible shell's commandos to the Shell's stored values
    228    *
    229    * this functions synchronizes the stored Data with the visible one.
    230    */
    231   void Shell::applySettings()
     84
     85  void GLGuiNotifier::tick(float dt)
    23286  {
    233     this->applyTextSettings(&this->shellInput);
    234     this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize));
    235 
    236     /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some
    237      * output is routed from Some other Thread or by Changing any Values.
    238      */
    239     std::list<MultiLineText*> bufferTextCopy = this->bufferText;
    240     for (std::list<MultiLineText*>::iterator textIt = bufferTextCopy.begin(); textIt != bufferTextCopy.end(); ++textIt)
    241     {
    242       this->applyTextSettings(*textIt);
    243       (*textIt)->setLineSpacing(this->lineSpacing);
    244       (*textIt)->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX());
    245     }
    246     this->repositionText();
    247 
    248     this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    249   }
    250 
    251   /**
    252    * @brief sets The count of Lines to display in the buffer.
    253    * @param bufferDisplaySize the count of lines to display in the Shell-Buffer.
    254    */
    255   void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
    256   {
    257     unsigned int oldSize = this->bufferText.size();
    258     if (oldSize > bufferDisplaySize)
    259     {
    260       for (unsigned int i = bufferDisplaySize; i <= oldSize; i++)
    261       {
    262         delete this->bufferText.back();
    263         this->bufferText.pop_back();
    264       }
    265     }
    266     else if (oldSize < bufferDisplaySize)
    267     {
    268       for (unsigned int i = oldSize; i <= bufferDisplaySize; i++)
    269       {
    270         this->bufferText.push_back(new MultiLineText);
    271       }
    272     }
    273     this->bufferDisplaySize = bufferDisplaySize;
    274     this->applySettings();
    275   }
    276 
    277   /**
    278    * @brief deletes all the Buffers
    279    */
    280   void Shell::flush()
    281   {
    282     for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
    283     {
    284       (*textIt)->setText("");  // remove all chars from the BufferTexts.
    285     }
    286     this->shellBuffer->flush();
    287     // BUFFER FLUSHING
    288   }
    289 
    290   /**
    291    * @brief prints out some text to the input-buffers
    292    * @param text the text to output.
    293    */
    294   void Shell::printToDisplayBuffer(const std::string& text)
    295   {
    296     // Remove Last Entry and prepend it to the front.
    297     this->bufferText.push_front(this->bufferText.back());
    298     this->bufferText.pop_back();
    299 
    300     // Set the new Text.
    301     this->bufferText.front()->setText(text);
    302     this->bufferIterator = this->shellBuffer->getBuffer().begin();
    303 
    304     // The LineCount will be started here.
    305 
    306     // The First Line gets a special Animation
    307     this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(0)- Vector2D(-1000,0));
    308 
    309     // Move all lines one Entry up.
    310     this->repositionText();
    31187  }
    31288
    31389
    31490  /**
    315    * @brief moves the Display buffer (up + or down - )
    316    * @param lineCount the count by which to shift the InputBuffer.
    317    *
    318    * @todo make this work
     91   * displays the GLGuiNotifier
    31992   */
    320   void Shell::moveDisplayBuffer(int lineCount)
    321   {
    322     // moving the iterator to the right position (counting the steps)
    323     int moves = 0;
    324     while (moves != lineCount)
    325     {
    326       if (moves < lineCount)
    327       {
    328         if(this->bufferIterator == --this->shellBuffer->getBuffer().end())
    329           break;
    330         ++moves;
    331         ++this->bufferIterator;
    332       }
    333       else
    334       {
    335         if (this->bufferIterator == this->shellBuffer->getBuffer().begin())
    336           break;
    337         --moves;
    338         --this->bufferIterator;
    339       }
    340     }
    341 
    342 
    343     // redisplay the buffers
    344     std::list<MultiLineText*>::iterator textIt;
    345 
    346     // Give a Graphical Representation that no move is possible.
    347     if (moves == 0)
    348     {
    349       int linePos = -1;
    350       for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt)
    351       {
    352         linePos += (*textIt)->getLineCount();
    353         (*textIt)->setRelCoor2D(this->calculateLinePosition(linePos)+ Vector2D(20,0));
    354         (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 10);
    355       }
    356       return;
    357     }
    358 
    359     // Move all the Lines.
    360     int linePos = moves;
    361     std::list<std::string>::const_iterator it = this->bufferIterator;
    362     for (textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt, ++it)
    363     {
    364       if (it == this->shellBuffer->getBuffer().end())
    365       {
    366         PRINTF(1)("LAST LINE REACHED\n");
    367         break;
    368       }
    369 
    370 
    371       (*textIt)->setRelCoor2D(calculateLinePosition( (linePos++ > 0) ? linePos : 0));
    372       (*textIt)->setText((*it));
    373     }
    374     while (textIt != this->bufferText.end())
    375     {
    376       (*textIt)->setText("");
    377       textIt++;
    378     }
    379 
    380     this->repositionText();
    381   }
    382 
    383   /**
    384    * @brief clears the Shell (empties all buffers)
    385    */
    386   void Shell::clear()
    387   {
    388     this->flush();
    389     ShellBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL);
    390   }
    391 
    392   /**
    393    * @brief listens for some event
    394    * @param event the Event happened
    395    */
    396   void Shell::process(const Event &event)
    397   {
    398     if (event.bPressed)
    399     {
    400       if (event.type == SDLK_BACKQUOTE || event.type == SDLK_F12)
    401       {
    402         if (this->bActive == false)
    403           this->activate();
    404         else
    405           this->deactivate();
    406       }
    407       else if (event.type == SDLK_PAGEUP)
    408       {
    409         this->moveDisplayBuffer(+this->bufferDisplaySize-1);
    410       }
    411       else if (event.type == SDLK_PAGEDOWN)
    412       {
    413         this->moveDisplayBuffer(-this->bufferDisplaySize+1);
    414       }
    415       else if (event.type == EV_VIDEO_RESIZE)
    416       {
    417         this->updateResolution(event.resize.w);
    418         this->repositionText();
    419       }
    420     }
    421   }
    422 
    423   void Shell::tick(float dt)
    424   {
    425     if (this->linesProcessed < this->shellBuffer->getLineCount())
    426     {
    427       unsigned int pollLines = this->shellBuffer->getLineCount() - this->linesProcessed;
    428       if (this->bufferText.size() < pollLines)
    429         pollLines = this->bufferText.size();
    430       if (unlikely(this->shellBuffer->getBuffer().size() < pollLines))
    431         pollLines = this->shellBuffer->getBuffer().size();
    432 
    433       std::list<std::string>::const_iterator line = this->shellBuffer->getBuffer().begin();
    434       unsigned int i;
    435       for(i = 0; i < pollLines; i++)
    436         line ++;
    437       for (i = 0; i < pollLines; i++)
    438       {
    439         this->printToDisplayBuffer((*--line));
    440       }
    441     }
    442     this->linesProcessed = this->shellBuffer->getLineCount();
    443   }
    444 
    445 
    446   /**
    447    * displays the Shell
    448    */
    449   void Shell::draw() const
     93  void GLGuiNotifier::draw() const
    45094  {
    45195    // transform for alignment.
    45296    // setting the Blending effects
     97    this->beginDraw();
    45398
    454     this->backgroundMaterial.select();
    455 
    456     glBegin(GL_TRIANGLE_STRIP);
    457 
    458     glTexCoord2f(0, 0);
    459     glVertex2f(this->getAbsCoor2D().x,   this->getAbsCoor2D().y  );
    460 
    461     glTexCoord2f(1, 0);
    462     glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y  );
    463 
    464     glTexCoord2f(0, 1);
    465     glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    466 
    467     glTexCoord2f(1, 1);
    468     glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    469 
    470     glEnd();
     99    this->backMaterial().select();
     100    this->drawRect(this->backRect());
     101    this->endDraw();
    471102  }
    472103
     
    480111   * @returns the Position of the Line.
    481112   */
    482   Vector2D Shell::calculateLinePosition(unsigned int lineNumber)
     113  Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber)
    483114  {
    484     return Vector2D(5.0f, (float)(this->textSize + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
     115//    return Vector2D(5.0f, (float)(this->textSize + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
     116    return Vector2D();
    485117  }
    486118
     
    488120
    489121  /**
    490    * @brief displays some nice output from the Shell
     122   * @brief displays some nice output from the GLGuiNotifier
    491123   */
    492   void Shell::debug() const
     124  void GLGuiNotifier::debug() const
    493125  {
    494126    PRINT(3)("Debugging output to console (not this shell)\n");
     
    496128    //   if (this->pressedKey != SDLK_FIRST)
    497129    //     printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
    498 
    499 
    500     this->shellBuffer->debug();
    501130  }
    502 
    503   /**
    504    * @brief a Handy Function, to Test the behaviour of the Shell.
    505    */
    506   void Shell::testShell() const
    507   {
    508     for (unsigned int i = 0; i < 100; i++)
    509       PRINT(0)("%d\n", i);
    510   }
    511   SHELL_COMMAND(test, Shell, testShell);
    512 
    513131}
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.h

    r8499 r8503  
    77 */
    88
    9 #ifndef _SHELL_H
    10 #define _SHELL_H
     9#ifndef _GLGUI_NOTIFIER_H
     10#define _GLGUI_NOTIFIER_H
    1111
    1212#include "glgui_widget.h"
     
    1515// FORWARD DECLARATION
    1616class MultiLineText;
     17class Text;
    1718
    18 //! Namespace of the Shell of ORXONOX.
     19//! Namespace of the GLGuiNotifier of ORXONOX.
    1920namespace OrxGui
    2021{
    21   class Shell : public GLGuiWidget
     22  class GLGuiNotifier : public GLGuiWidget
    2223  {
    2324
    2425  public:
    25     Shell();
    26     virtual ~Shell();
     26    GLGuiNotifier();
     27    virtual ~GLGuiNotifier();
    2728
    2829    void pushNotifyMessage(const std::string& message);
     
    6364}
    6465
    65 #endif /* _SHELL_H */
     66#endif /* _GLGUI_NOTIFIER_H */
Note: See TracChangeset for help on using the changeset viewer.