Changeset 6417 for code/trunk/src/orxonox/overlays/InGameConsole.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/overlays/InGameConsole.cc
r6105 r6417 44 44 #include "util/Convert.h" 45 45 #include "util/Math.h" 46 #include "util/ UTFStringConversions.h"46 #include "util/DisplayStringConversions.h" 47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" … … 61 61 SetConsoleCommand(InGameConsole, closeConsole, true); 62 62 63 InGameConsole* InGameConsole::singletonPtr_s = 0;64 63 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 65 64 … … 68 67 */ 69 68 InGameConsole::InGameConsole() 70 : shell_(new Shell("InGameConsole", true, true)) 69 : shell_(new Shell("InGameConsole", true)) 70 , bShowCursor_(false) 71 71 , consoleOverlay_(0) 72 72 , consoleOverlayContainer_(0) … … 218 218 font->addCodePointRange(Ogre::Font::CodePointRange(161, 255)); 219 219 220 // create noise 221 this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise")); 222 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 223 this->consoleOverlayNoise_->setPosition(5,0); 224 this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall"); 225 // comment following line to disable noise 226 this->consoleOverlayBorder_->addChild(this->consoleOverlayNoise_); 227 220 228 // create the text lines 221 229 this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES]; … … 229 237 this->consoleOverlayTextAreas_[i]->setLeft(8); 230 238 this->consoleOverlayTextAreas_[i]->setCaption(""); 231 this->consoleOverlay Container_->addChild(this->consoleOverlayTextAreas_[i]);239 this->consoleOverlayNoise_->addChild(this->consoleOverlayTextAreas_[i]); 232 240 } 233 241 … … 240 248 this->consoleOverlayCursor_->setLeft(7); 241 249 this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1)); 242 this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_); 243 244 // create noise 245 this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise")); 246 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 247 this->consoleOverlayNoise_->setPosition(5,0); 248 this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall"); 249 // comment following line to disable noise 250 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 250 this->consoleOverlayNoise_->addChild(this->consoleOverlayCursor_); 251 251 252 252 this->windowResized(this->getWindowWidth(), this->getWindowWidth()); … … 268 268 void InGameConsole::linesChanged() 269 269 { 270 std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();270 Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator(); 271 271 int max = 0; 272 272 for (int i = 1; i < LINES; ++i) … … 282 282 283 283 for (int i = LINES - 1; i > max; --i) 284 this->print("", i, true);284 this->print("", Shell::None, i, true); 285 285 286 286 for (int i = max; i >= 1; --i) 287 287 { 288 288 --it; 289 this->print( *it, i, true);289 this->print(it->first, it->second, i, true); 290 290 } 291 291 } … … 297 297 { 298 298 if (LINES > 1) 299 this->print( *this->shell_->getNewestLineIterator(), 1);299 this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1); 300 300 } 301 301 … … 316 316 { 317 317 if (LINES > 0) 318 this->print(this->shell_->getInput(), 0);319 320 if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)318 this->print(this->shell_->getInput(), Shell::Input, 0); 319 320 if (this->shell_->getInput().empty()) 321 321 this->inputWindowStart_ = 0; 322 322 } … … 340 340 void InGameConsole::executed() 341 341 { 342 this->shell_->addOutput Line(this->shell_->getInput());342 this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command); 343 343 } 344 344 … … 358 358 @brief Used to control the actual scrolling and the cursor. 359 359 */ 360 void InGameConsole:: update(const Clock& time)360 void InGameConsole::preUpdate(const Clock& time) 361 361 { 362 362 if (this->scroll_ != 0) … … 456 456 @param s String to be printed 457 457 */ 458 void InGameConsole::print(const std::string& text, int index, bool alwaysShift) 459 { 460 char level = 0; 461 if (text.size() > 0) 462 level = text[0]; 463 458 void InGameConsole::print(const std::string& text, Shell::LineType type, int index, bool alwaysShift) 459 { 464 460 std::string output = text; 465 466 if (level >= -1 && level <= 5)467 output.erase(0, 1);468 469 461 if (LINES > index) 470 462 { 471 this->colourLine( level, index);463 this->colourLine(type, index); 472 464 473 465 if (index > 0) … … 477 469 { 478 470 ++linesUsed; 479 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output.substr(0, this->maxCharsPerLine_)));471 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output.substr(0, this->maxCharsPerLine_))); 480 472 output.erase(0, this->maxCharsPerLine_); 481 473 output.insert(0, 1, ' '); 482 474 if (linesUsed > numLinesShifted_ || alwaysShift) 483 475 this->shiftLines(); 484 this->colourLine( level, index);476 this->colourLine(type, index); 485 477 } 486 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output));478 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output)); 487 479 this->displayedText_ = output; 488 480 this->numLinesShifted_ = linesUsed; … … 502 494 this->inputWindowStart_ = 0; 503 495 this->displayedText_ = output; 504 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre:: UTFString>(output));496 this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::DisplayString>(output)); 505 497 } 506 498 } … … 559 551 } 560 552 561 void InGameConsole::colourLine(int colourcode, int index) 562 { 563 if (colourcode == -1) 564 { 565 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.90, 0.90, 0.90, 1.00)); 566 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00)); 567 } 568 else if (colourcode == 1) 569 { 570 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.25, 0.25, 1.00)); 571 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00)); 572 } 573 else if (colourcode == 2) 574 { 575 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.95, 0.50, 0.20, 1.00)); 576 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00)); 577 } 578 else if (colourcode == 3) 579 { 580 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.50, 0.50, 0.95, 1.00)); 581 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00)); 582 } 583 else if (colourcode == 4) 584 { 585 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.65, 0.48, 0.44, 1.00)); 586 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00)); 587 } 588 else if (colourcode == 5) 589 { 590 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.40, 0.20, 0.40, 1.00)); 591 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00)); 592 } 593 else 594 { 595 this->consoleOverlayTextAreas_[index]->setColourTop (ColourValue(0.21, 0.69, 0.21, 1.00)); 596 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00)); 597 } 553 void InGameConsole::colourLine(Shell::LineType type, int index) 554 { 555 ColourValue colourTop, colourBottom; 556 switch (type) 557 { 558 case Shell::Error: colourTop = ColourValue(0.95, 0.25, 0.25, 1.00); 559 colourBottom = ColourValue(1.00, 0.50, 0.50, 1.00); break; 560 561 case Shell::Warning: colourTop = ColourValue(0.95, 0.50, 0.20, 1.00); 562 colourBottom = ColourValue(1.00, 0.70, 0.50, 1.00); break; 563 564 case Shell::Info: colourTop = ColourValue(0.50, 0.50, 0.95, 1.00); 565 colourBottom = ColourValue(0.80, 0.80, 1.00, 1.00); break; 566 567 case Shell::Debug: colourTop = ColourValue(0.65, 0.48, 0.44, 1.00); 568 colourBottom = ColourValue(1.00, 0.90, 0.90, 1.00); break; 569 570 case Shell::Verbose: colourTop = ColourValue(0.40, 0.20, 0.40, 1.00); 571 colourBottom = ColourValue(0.80, 0.60, 0.80, 1.00); break; 572 573 case Shell::Ultra: colourTop = ColourValue(0.21, 0.69, 0.21, 1.00); 574 colourBottom = ColourValue(0.80, 1.00, 0.80, 1.00); break; 575 576 case Shell::Command: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00); 577 colourBottom = ColourValue(0.90, 0.90, 0.90, 0.90); break; 578 579 case Shell::Hint: colourTop = ColourValue(0.80, 0.80, 0.80, 1.00); 580 colourBottom = ColourValue(0.90, 0.90, 0.90, 1.00); break; 581 582 default: colourTop = ColourValue(0.90, 0.90, 0.90, 1.00); 583 colourBottom = ColourValue(1.00, 1.00, 1.00, 1.00); break; 584 } 585 586 this->consoleOverlayTextAreas_[index]->setColourTop (colourTop); 587 this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom); 598 588 } 599 589
Note: See TracChangeset
for help on using the changeset viewer.