- Timestamp:
- Aug 21, 2005, 11:50:07 PM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell.cc
r5094 r5095 46 46 this->setBufferSize(100); 47 47 this->setBufferDisplaySize(10); 48 this->setAbsCoor2D(2, GraphicsEngine::getInstance()->getResolutionY()); 49 this->setAbsDir2D(0); 48 this->setAbsCoor2D(3, GraphicsEngine::getInstance()->getResolutionY()); 49 this->repeatDelay = .15; 50 this->delayed = 0; 51 this->pressedKey = SDLK_FIRST; 50 52 51 53 this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0); 54 this->inputLineText->setAlignment(TEXT_ALIGN_LEFT); 52 55 this->inputLineText->setText(NULL); 53 56 this->inputLine = new char[1]; 54 57 this->inputLine[0] = '\0'; 55 56 EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_BACKQUOTE); 58 this->inputLineText->setParent2D(this); 59 57 60 58 61 EventHandler* evh = EventHandler::getInstance(); 59 for (int i = 1; i < EV_NUMBER; i++) 60 EventHandler::getInstance()->subscribe(this, ES_SHELL, i); 62 evh->subscribe(this, ES_GAME, SDLK_BACKQUOTE); 63 for (int i = 1; i < SDLK_F15; i++) 64 evh->subscribe(this, ES_SHELL, i); 61 65 } 62 66 … … 97 101 this->bufferText[i] = TextEngine::getInstance()->createText("fonts/earth.ttf", this->textSize, TEXT_DYNAMIC, 255, 0, 0); 98 102 this->bufferText[i]->setAlignment(TEXT_ALIGN_LEFT); 99 this->bufferText[i]->setRelCoor2D(5, 12 *i);103 this->bufferText[i]->setRelCoor2D(5, 12+12*i); 100 104 this->bufferText[i]->setText(NULL); 101 105 this->bufferText[i]->setParent2D(this); … … 320 324 this->autoComplete(); 321 325 else if (event.type == SDLK_BACKSPACE) 326 { 327 this->delayed = this->repeatDelay; 328 this->pressedKey = SDLK_BACKSPACE; 322 329 this->removeCharacters(1); 330 } 323 331 else if (event.type < 127) 332 { 333 this->delayed = this->repeatDelay; 334 this->pressedKey = event.type; 324 335 this->addCharacter(event.type); 336 } 337 } 338 else // if(!event.bPressed) 339 { 340 if (this->pressedKey == event.type) 341 this->pressedKey = SDLK_FIRST; 342 this->delayed = 0.0; 325 343 } 326 344 } … … 330 348 * @param dt the elapsed time since the last tick(); 331 349 */ 332 //void Shell::tick(float dt) 333 //{ 334 //} 350 void Shell::tick(float dt) 351 { 352 if (this->delayed > 0.0) 353 this->delayed -= dt; 354 else if (this->pressedKey != SDLK_FIRST ) 355 { 356 this->delayed = this->repeatDelay; 357 if (this->pressedKey == SDLK_BACKSPACE) 358 this->removeCharacters(1); 359 else if (pressedKey < 127) 360 this->addCharacter(this->pressedKey); 361 } 362 } 335 363 336 364 /** -
trunk/src/util/shell.h
r5080 r5095 58 58 59 59 // Element2D-functions 60 //void tick(float dt);60 void tick(float dt); 61 61 virtual void draw() const; 62 62 … … 74 74 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters) 75 75 76 Text* inputLineText; //!< The inputLine of the Shell 76 77 char* inputLine; //!< the Char-Array of the Buffer 78 float repeatDelay; //!< The Repeat-Delay. 79 float delayed; //!< how much of the delay is remaining. 80 int pressedKey; //!< the pressed key that will be repeated. 77 81 78 82 tList<char>* buffer; //!< A list of stored char-arrays(strings) to store the history 79 83 80 84 Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer 81 Text* inputLineText; //!< The inputLine of the Shell82 85 unsigned int textSize; //!< The size of the text. 83 86 unsigned int lineSpacing; //!< The Spacing between lines.
Note: See TracChangeset
for help on using the changeset viewer.