- Timestamp:
- Jun 5, 2008, 4:09:04 AM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/Shell.cc
r1535 r1540 36 36 37 37 #define SHELL_UPDATE_LISTENERS(function) \ 38 for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) \39 (* it)->function()38 for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) \ 39 (*(it++))->function() 40 40 41 41 namespace orxonox -
code/trunk/src/orxonox/console/InGameConsole.cc
r1539 r1540 71 71 RegisterObject(InGameConsole); 72 72 73 this-> active_ = false;73 this->bActive_ = false; 74 74 this->cursor_ = 0.0; 75 75 this->cursorSymbol_ = '|'; … … 201 201 // for the beginning, don't scroll 202 202 this->scroll_ = 0; 203 this->scrollTimer_ = 0;204 203 this->cursor_ = 0; 205 204 … … 307 306 void InGameConsole::tick(float dt) 308 307 { 309 this->scrollTimer_ += dt; 310 if (this->scrollTimer_ >= 0.01) 311 { 312 float top = this->consoleOverlayContainer_->getTop(); 313 float timePassed = scrollTimer_; 314 this->scrollTimer_ = 0; 315 if (this->scroll_ != 0) 316 { 317 // scroll 318 top = top + timePassed * this->scroll_; 319 this->consoleOverlayContainer_->setTop(top); 320 } 321 if (top <= -1.2 * InGameConsole::REL_HEIGHT) 308 if (this->scroll_ != 0) 309 { 310 float top = this->consoleOverlayContainer_->getTop() + dt * this->scroll_; 311 this->consoleOverlayContainer_->setTop(top); 312 313 if (this->scroll_ < 0 && top <= -1.2 * InGameConsole::REL_HEIGHT) 322 314 { 323 315 // window has completely scrolled up 324 316 this->scroll_ = 0; 325 317 this->consoleOverlay_->hide(); 326 this->active_ = false; 327 Shell::getInstance().unregisterListener(this); 328 } 329 if (top >= 0) 318 } 319 320 if (this->scroll_ > 0 && top >= 0) 330 321 { 331 322 // window has completely scrolled down 332 323 this->scroll_ = 0; 333 324 this->consoleOverlayContainer_->setTop(0); 334 this->active_ = true; 335 } 336 } 337 338 this->cursor_ += dt; 339 if (this->cursor_ >= InGameConsole::BLINK) 340 { 341 this->cursor_ = 0; 342 bShowCursor_ = !bShowCursor_; 343 if (bShowCursor_) 344 this->consoleOverlayCursor_->show(); 345 else 346 this->consoleOverlayCursor_->hide(); 347 } 348 349 /*if (this->cursor_ >= 2 * InGameConsole::BLINK) 350 this->cursor_ = 0; 351 352 if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|') 353 { 354 this->cursorSymbol_ = ' '; 325 } 326 } 327 328 if (this->bActive_) 329 { 330 this->cursor_ += dt; 331 if (this->cursor_ >= InGameConsole::BLINK) 332 { 333 this->cursor_ = 0; 334 bShowCursor_ = !bShowCursor_; 335 if (bShowCursor_) 336 this->consoleOverlayCursor_->show(); 337 else 338 this->consoleOverlayCursor_->hide(); 339 } 340 341 /*if (this->cursor_ >= 2 * InGameConsole::BLINK) 342 this->cursor_ = 0; 343 344 if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|') 345 { 346 this->cursorSymbol_ = ' '; 347 this->cursorChanged(); 348 } 349 else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ') 350 { 351 this->cursorSymbol_ = '|'; 352 this->cursorChanged(); 353 }*/ 354 355 // this creates a flickering effect 356 this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1); 357 } 358 } 359 360 /** 361 @brief Shows the InGameConsole. 362 */ 363 void InGameConsole::activate() 364 { 365 if (!this->bActive_) 366 { 367 this->bActive_ = true; 368 InputManager::setInputState(InputManager::IS_CONSOLE); 369 Shell::getInstance().registerListener(this); 370 371 this->resize(); 372 this->linesChanged(); 355 373 this->cursorChanged(); 356 } 357 else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ') 358 { 359 this->cursorSymbol_ = '|'; 360 this->cursorChanged(); 361 }*/ 362 363 // this creates a flickering effect 364 this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1); 365 } 366 367 /** 368 @brief Shows the InGameConsole. 369 */ 370 void InGameConsole::activate() 371 { 372 InputManager::setInputState(InputManager::IS_CONSOLE); 373 Shell::getInstance().registerListener(this); 374 this->linesChanged(); 375 this->cursorChanged(); 376 377 this->consoleOverlay_->show(); 378 // just in case window size has changed... 379 this->resize(); 380 // scroll down 381 this->scroll_ = 1; 382 // the rest is done by tick 374 this->consoleOverlay_->show(); 375 376 // scroll down 377 this->scroll_ = 1; 378 // the rest is done by tick 379 } 383 380 } 384 381 … … 388 385 void InGameConsole::deactivate() 389 386 { 390 // scroll up 391 this->scroll_ = -1; 392 // the rest is done by tick 393 InputManager::setInputState(InputManager::IS_NORMAL); 387 if (this->bActive_) 388 { 389 this->bActive_ = false; 390 InputManager::setInputState(InputManager::IS_NORMAL); 391 Shell::getInstance().unregisterListener(this); 392 393 // scroll up 394 this->scroll_ = -1; 395 // the rest is done by tick 396 } 394 397 } 395 398 -
code/trunk/src/orxonox/console/InGameConsole.h
r1538 r1540 50 50 void tick(float dt); 51 51 52 void activate();53 void deactivate();54 52 void resize(); 55 56 53 static void openConsole(); 57 54 static void closeConsole(); … … 61 58 InGameConsole(const InGameConsole& other); 62 59 ~InGameConsole(); 60 61 void activate(); 62 void deactivate(); 63 63 64 64 virtual void linesChanged(); … … 80 80 static float BLINK; 81 81 82 bool bActive_; 82 83 int windowW_; 83 84 int windowH_; … … 86 87 unsigned int numLinesShifted_; 87 88 int scroll_; 88 float scrollTimer_;89 89 float cursor_; 90 90 unsigned int inputWindowStart_; 91 91 char cursorSymbol_; 92 bool active_;93 92 bool bShowCursor_; 94 93 std::string displayedText_;
Note: See TracChangeset
for help on using the changeset viewer.