Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5106 in orxonox.OLD for trunk


Ignore:
Timestamp:
Aug 23, 2005, 8:09:58 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: top-down shell, as proposed by patrick. This makes sense, becuase the general people knows only shells comming top down

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine.cc

    r5090 r5106  
    592592          if( glyphSurf != NULL )
    593593            {
    594 
    595594              SDL_SetAlpha(glyphSurf, 0, 0);
    596595
     
    598597              TexCoord tmpTexCoord;
    599598              tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
    600               tmpTexCoord.maxU = (float)(tmpRect.x +1 +tmpGlyph->width)/(float)tmpSurf->w;
     599              tmpTexCoord.maxU = (float)(tmpRect.x +1 + tmpGlyph->width)/(float)tmpSurf->w;
    601600              tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w;
    602601              tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
     
    620619
    621620              // Outputting Glyphs to BMP-files.
    622               /*
    623                 char outname[64];
     621/*
     622                char outname[512];
    624623                if (i < 10)
    625                 sprintf( outname, "glyph-00%d.bmp", i );
     624                sprintf( outname, "%s-glyph-00%d.bmp", this->getName(), i );
    626625                else if (i <100)
    627                 sprintf( outname, "glyph-0%d.bmp", i );
     626                  sprintf( outname, "%s-glyph-0%d.bmp", this->getName(), i );
    628627                else
    629                 sprintf( outname, "glyph-%d.bmp", i );
    630                 SDL_SaveBMP(tmpSurf, outname);
    631               */
     628                  sprintf( outname, "%s-glyph-%d.bmp", this->getName(), i );
     629                SDL_SaveBMP(tmpSurf, outname);*/
     630
    632631            }
    633632        }
     
    712711                  x = 0;
    713712                  y = y + maxLineHeight;
    714                   maxLineHeight = 0;
     713                  //maxLineHeight = 0;
    715714                }
    716715              if (y + maxLineHeight + 1 > size)
  • trunk/src/lib/lang/class_list.cc

    r5105 r5106  
    285285}
    286286
     287/**
     288 * converts a ClassID into a string
     289 * @param classID the ClassID to search for
     290 * @return a String containing the name of the Class, NULL if the Class was not found
     291 */
    287292const char* ClassList::IDToString(ClassID classID)
    288293{
     
    300305}
    301306
     307/**
     308 * converts a String into a ClassID
     309 * @param className the name of the class to search for
     310 * @return the ClassID. CL_NULL, if the class was not found.
     311 */
    302312long ClassList::StringToID(const char* className)
    303313{
  • trunk/src/util/shell.cc

    r5105 r5106  
    2525#include "load_param.h"
    2626#include "class_list.h"
     27
     28#include "key_names.h"
    2729#include "debug.h"
    2830#include <stdarg.h>
     
    4042  this->setName("Shell");
    4143
     44  this->shellHeight = 400;
    4245  this->buffer = new tList<char>;
    4346
    44   this->textSize = 10;
     47  this->textSize = 15;
     48  this->lineSpacing = 5;
    4549
    4650  //this->bufferSize = 0;
    4751  this->bufferText = NULL;
    4852  this->setBufferSize(100);
     53  this->bufferDisplaySize = 10;
    4954  this->setBufferDisplaySize(10);
    50   this->setAbsCoor2D(3, GraphicsEngine::getInstance()->getResolutionY());
     55  this->setAbsCoor2D(3, -400);
    5156  this->delayed = 0;
    5257  this->setRepeatDelay(.3, .05);
    5358  this->pressedKey = SDLK_FIRST;
    5459
    55   this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0);
    56   this->inputLineText->setAlignment(TEXT_ALIGN_LEFT);
    57   this->inputLineText->setText(NULL);
     60  this->inputLineText = NULL;
    5861  this->inputLine = new char[1];
    5962  this->inputLine[0] = '\0';
    60   this->inputLineText->setParent2D(this);
    61 
     63
     64  this->rebuildText();
    6265  this->completionList = NULL;
    6366
     67  // EVENT-Handler subscription of '`' to all States, and all other keyboard commands to ES_SEHLL
    6468  EventHandler* evh = EventHandler::getInstance();
    6569  evh->subscribe(this, ES_ALL, SDLK_BACKQUOTE);
     
    7882  for (int i = 0; i < this->bufferDisplaySize; i++)
    7983    delete this->bufferText[i];
    80   delete this->bufferText;
     84  delete[] this->bufferText;
    8185
    8286  // delete the inputLine
     
    100104}
    101105
     106
     107void Shell::activate()
     108{
     109  EventHandler::getInstance()->setState(ES_SHELL);
     110  this->setRelCoorSoft2D(0, 0, 1, 5);
     111}
     112
     113void Shell::deactivate()
     114{
     115  EventHandler::getInstance()->setState(ES_GAME);
     116  this->setRelCoorSoft2D(0, -400, 1, 5);
     117}
     118
     119void Shell::setTextSize(unsigned int textSize, unsigned int lineSpacing)
     120{
     121  this->textSize = textSize;
     122  this->lineSpacing = lineSpacing;
     123
     124  this->rebuildText();
     125}
     126
     127void Shell::rebuildText()
     128{
     129  if (this->inputLineText == NULL)
     130    delete this->inputLineText;
     131  this->inputLineText = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0);
     132  this->inputLineText->setAlignment(TEXT_ALIGN_LEFT);
     133  this->inputLineText->setText(NULL);
     134  this->inputLineText->setParent2D(this);
     135  this->inputLineText->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize);
     136
     137  this->setBufferDisplaySize(this->bufferDisplaySize);
     138}
     139
     140
     141
    102142/**
    103143 * sets The count of Lines to display in the buffer.
     
    110150    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    111151      delete this->bufferText[i];
    112     delete this->bufferText;
     152    delete[] this->bufferText;
    113153  }
    114154
     
    116156  for (unsigned int i = 0; i < bufferDisplaySize; i++)
    117157  {
    118     this->bufferText[i] = TextEngine::getInstance()->createText("fonts/earth.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0);
     158    this->bufferText[i] = TextEngine::getInstance()->createText("fonts/Aniron_Bold.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0);
    119159    this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    120     this->bufferText[i]->setRelCoor2D(5, 12+12*i);
     160    this->bufferText[i]->setRelCoor2D(5, (this->textSize + this->lineSpacing)*i);
    121161    this->bufferText[i]->setText(NULL);
    122162    this->bufferText[i]->setParent2D(this);
    123163  }
    124 
    125 
    126164  this->bufferDisplaySize = bufferDisplaySize;
     165
     166  this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    127167}
    128168
     
    157197 * @param line the Line as in the first argument in printf
    158198 * @param args the arguments as a va_list
    159  *
    160  * @todo optimize
    161199 */
    162200bool Shell::addBufferLineStatic(const char* line, ...)
     
    178216  return true;
    179217}
    180 int curr = 0;
    181218
    182219/**
     
    213250   }
    214251   this->bufferText[0]->setText(newLine);
    215    // this->bufferText->
    216 //  this->inputLineText->setText(newLine);
    217252}
    218253
     
    250285}
    251286
    252 
    253287/**
    254288 * deletes the InputLine
     
    262296  this->inputLine = new char[1];
    263297  *this->inputLine = '\0';
    264 
    265298}
    266299
     
    320353bool Shell::executeCommand()
    321354{
    322 
    323355  this->addBufferLineStatic("Execute Command: %s\n", this->inputLine);
    324356  delete this->inputLine;
     
    341373}
    342374
    343 
    344 #include "key_names.h"
    345375/**
    346376 * listens for some event
     
    356386      if (EventHandler::getInstance()->getState() == ES_GAME)
    357387      {
    358         EventHandler::getInstance()->setState(ES_SHELL);
    359         this->setRelCoorSoft2D(0, GraphicsEngine::getInstance()->getResolutionY()-150, 1, 5);
     388        this->activate();
    360389      }
    361390
    362391      else
    363392      {
    364         EventHandler::getInstance()->setState(ES_GAME);
    365         this->setRelCoorSoft2D(0, GraphicsEngine::getInstance()->getResolutionY()+10, 1, 5);
     393        this->deactivate();
    366394      }
    367395    }
     
    432460
    433461//  glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
    434   glVertex2f(this->getAbsCoor2D().x + 800, this->getAbsCoor2D().y  );
     462  glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y  );
    435463
    436464//  glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
    437   glVertex2f(this->getAbsCoor2D().x + 800, this->getAbsCoor2D().y + 150);
     465  glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    438466
    439467//  glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
    440   glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + 150);
     468  glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    441469
    442470  glEnd();
     
    655683}
    656684
    657 
    658 
    659685/**
    660686 * displays some nice output from the Shell
  • trunk/src/util/shell.h

    r5105 r5106  
    3636
    3737
    38     void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
     38    void activate();
     39    void deactivate();
    3940
    40     void setBufferDisplaySize(unsigned int bufferDisplaySize);
     41    void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1);
     42    void rebuildText();
    4143
    4244    // BUFFER //
     45    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
     46    void setBufferDisplaySize(unsigned int bufferDisplaySize);
    4347    void flushBuffers();
    4448    static bool addBufferLineStatic(const char* line, ...);
     
    96100    unsigned int           textSize;               //!< The size of the text.
    97101    unsigned int           lineSpacing;            //!< The Spacing between lines.
     102    unsigned int           shellHeight;            //!< The hight of the Shell in Pixels
    98103
    99104    char                   bufferArray[10000];     //!< a BUFFER for fast writing
Note: See TracChangeset for help on using the changeset viewer.