Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5251 in orxonox.OLD for trunk/src/lib/shell/shell.cc


Ignore:
Timestamp:
Sep 25, 2005, 1:13:19 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: saver change between fonts in Shell

File:
1 edited

Legend:

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

    r5249 r5251  
    6464  this->lineSpacing = 0;
    6565  this->bActive = false;
     66  this->fontFile = NULL;
     67  this->setFont("fonts/dpquake_.ttf");
    6668
    6769  // BUFFER
     
    8890  delete[] this->bufferText;
    8991  delete this->bufferIterator;
    90 
     92  delete[] this->fontFile;
    9193  // delete the inputLine
    9294  delete this->shellInput;
     
    123125void Shell::deactivate()
    124126{
     127   this->setFont("fonts/dark_crystal.ttf");
     128   this->rebuildText();
     129
    125130  if (this->bActive == false)
    126131    PRINTF(3)("The shell is already inactive\n");
     
    140145
    141146  this->bufferOffset = 0;
     147}
     148
     149/**
     150 * sets the File to load the fonts from
     151 * @param fontFile the file to load the font from
     152 */
     153void Shell::setFont(const char* fontFile)
     154{
     155  if (this->fontFile != NULL)
     156    delete[] this->fontFile;
     157
     158  this->fontFile = new char[strlen(fontFile)+1];
     159  strcpy(this->fontFile, fontFile);
     160
    142161}
    143162
     
    154173  this->textSize = textSize;
    155174  this->lineSpacing = lineSpacing;
    156   this->shellInput->setFont("fonts/dpquake_.ttf", this->textSize);
     175  this->shellInput->setFont(this->fontFile, this->textSize);
    157176
    158177//  this->rebuildText();
     
    166185void Shell::rebuildText()
    167186{
    168   this->shellInput->setFont("fonts/dpquake_.ttf", this->textSize);
     187  this->shellInput->setFont(this->fontFile, this->textSize);
    169188  this->shellInput->setColor(1, 0, 0);
    170189  this->shellInput->setAlignment(TEXT_ALIGN_LEFT);
     
    181200void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize)
    182201{
     202  Text** bufferText = this->bufferText;
     203  this->bufferText = NULL;
     204  if (bufferText != NULL)
     205  {
     206    for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
     207      delete bufferText[i];
     208    delete[] bufferText;
     209  }
     210
     211  bufferText = new Text*[bufferDisplaySize];
     212  for (unsigned int i = 0; i < bufferDisplaySize; i++)
     213  {
     214    bufferText[i] = TextEngine::getInstance()->createText(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC);
     215    bufferText[i]->setColor(1, 0, 0);
     216    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
     217    bufferText[i]->setRelCoor2D(calculateLinePosition(i));
     218    bufferText[i]->setText(NULL);
     219    bufferText[i]->setParent2D(this);
     220  }
     221  this->bufferDisplaySize = bufferDisplaySize;
     222
     223  this->bufferText = bufferText;
     224  this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
     225}
     226
     227/**
     228 * deletes all the Buffers
     229 */
     230void Shell::flush()
     231{
     232  // remove all chars from the BufferTexts.
    183233  if (this->bufferText != NULL)
    184   {
    185     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    186       delete this->bufferText[i];
    187     delete[] this->bufferText;
    188   }
    189 
    190   this->bufferText = new Text*[bufferDisplaySize];
    191   for (unsigned int i = 0; i < bufferDisplaySize; i++)
    192   {
    193     this->bufferText[i] = TextEngine::getInstance()->createText("fonts/dpquake_.ttf", this->textSize, TEXT_RENDER_DYNAMIC);
    194     this->bufferText[i]->setColor(1, 0, 0);
    195     this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    196     this->bufferText[i]->setRelCoor2D(calculateLinePosition(i));
    197     this->bufferText[i]->setText(NULL);
    198     this->bufferText[i]->setParent2D(this);
    199   }
    200   this->bufferDisplaySize = bufferDisplaySize;
    201 
    202   this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    203 }
    204 
    205 /**
    206  * deletes all the Buffers
    207  */
    208 void Shell::flush()
    209 {
    210   // remove all chars from the BufferTexts.
    211   if (this->bufferText)
    212234    for (int i = 0; i < this->bufferDisplaySize; i++)
    213235    {
Note: See TracChangeset for help on using the changeset viewer.