Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5253 in orxonox.OLD for trunk


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

orxonox/trunk: real safe, and smooth now in the resize-mode of the Shell
→ no more segfaults
→ more dynamic

Location:
trunk/src/lib/shell
Files:
2 edited

Legend:

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

    r5251 r5253  
    4242    ->setAlias("hide");
    4343SHELL_COMMAND(textsize, Shell, setTextSize)
    44     ->describe("Sets the size of the Text (size, linespacing)");
     44    ->describe("Sets the size of the Text (size, linespacing)")
     45    ->defaultValues(15, 0);
    4546
    4647/**
     
    6465  this->lineSpacing = 0;
    6566  this->bActive = false;
    66   this->fontFile = NULL;
    67   this->setFont("fonts/dpquake_.ttf");
     67  this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1];
     68  strcpy(this->fontFile, SHELL_DEFAULT_FONT);
    6869
    6970  // BUFFER
     
    125126void Shell::deactivate()
    126127{
    127    this->setFont("fonts/dark_crystal.ttf");
    128    this->rebuildText();
    129 
    130128  if (this->bActive == false)
    131129    PRINTF(3)("The shell is already inactive\n");
     
    133131
    134132  EventHandler::getInstance()->setState(ES_GAME);
    135   this->setRelCoorSoft2D(0, -400, 1, 5);
     133  this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5);
    136134
    137135  tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
     
    159157  strcpy(this->fontFile, fontFile);
    160158
     159  this->rebuildText();
    161160}
    162161
     
    175174  this->shellInput->setFont(this->fontFile, this->textSize);
    176175
    177 //  this->rebuildText();
     176  this->rebuildText();
    178177}
    179178
     
    188187  this->shellInput->setColor(1, 0, 0);
    189188  this->shellInput->setAlignment(TEXT_ALIGN_LEFT);
    190   this->shellInput->setParent2D(this);
     189  if (shellInput->getParent() != this)
     190    this->shellInput->setParent2D(this);
    191191  this->shellInput->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
    192192
     
    209209  }
    210210
     211  tIterator<char>* it = ShellBuffer::getInstance()->getBuffer()->getIterator();
     212  char* text = it->lastElement();
    211213  bufferText = new Text*[bufferDisplaySize];
    212214  for (unsigned int i = 0; i < bufferDisplaySize; i++)
     
    216218    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    217219    bufferText[i]->setRelCoor2D(calculateLinePosition(i));
    218     bufferText[i]->setText(NULL);
     220    bufferText[i]->setText(text);
    219221    bufferText[i]->setParent2D(this);
    220   }
     222    text = it->prevElement();
     223  }
     224  delete it;
    221225  this->bufferDisplaySize = bufferDisplaySize;
    222226
  • trunk/src/lib/shell/shell.h

    r5251 r5253  
    1313
    1414#include <stdarg.h>
     15
     16#define         SHELL_DEFAULT_FONT      "fonts/dpquake_.ttf"
    1517
    1618// FORWARD DECLARATION
Note: See TracChangeset for help on using the changeset viewer.