Changeset 1470
- Timestamp:
- May 29, 2008, 2:56:17 AM (16 years ago)
- Location:
- code/branches/network/src/orxonox/console
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/console/InGameConsole.cc
r1469 r1470 47 47 48 48 #define LINES 30 49 #define CHAR_WIDTH 7.85 // fix this please - determine the char-width dynamically 49 #define CHAR_WIDTH1 7.34 // fix this please - determine the char-width dynamically 50 #define CHAR_WIDTH2 8.28 // fix this please - determine the char-width dynamically 51 #define CHAR_WIDTH3 7.78 // fix this please - determine the char-width dynamically 50 52 51 53 namespace orxonox … … 177 179 void InGameConsole::cursorChanged() 178 180 { 179 std::string input = Shell::getInstance().getInput();181 /*std::string input = Shell::getInstance().getInput(); 180 182 input.insert(Shell::getInstance().getCursorPosition(), 1, this->cursorSymbol_); 181 183 if (LINES > 0) 182 this->print(input, 0); 184 this->print(input, 0);*/ 185 this->setCursorPosition(Shell::getInstance().getCursorPosition() - inputWindowStart_); 183 186 } 184 187 … … 245 248 this->consoleOverlayCursor_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "InGameConsoleCursor")); 246 249 this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS); 247 this->consoleOverlayCursor_->setPosition( 40,217);248 this->consoleOverlayCursor_->setDimensions( 2, 20);249 this->consoleOverlayCursor_->setMaterialName(" ConsoleNoise");250 this->consoleOverlayCursor_->setPosition(5,219); 251 this->consoleOverlayCursor_->setDimensions(1, 14); 252 this->consoleOverlayCursor_->setMaterialName("Orxonox/GreenDot"); 250 253 251 254 this->consoleOverlay_ = this->om_->create("InGameConsoleConsole"); … … 285 288 286 289 if (LINES > 0) 287 this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH ));290 this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH3)); 288 291 else 289 292 this->maxCharsPerLine_ = 10; … … 333 336 334 337 this->cursor_ += dt; 335 if (this->cursor_ >= 2 * InGameConsole::BLINK) 338 if (this->cursor_ >= InGameConsole::BLINK) 339 { 336 340 this->cursor_ = 0; 341 bShowCursor_ = !bShowCursor_; 342 if (bShowCursor_) 343 this->consoleOverlayCursor_->show(); 344 else 345 this->consoleOverlayCursor_->hide(); 346 } 347 348 /*if (this->cursor_ >= 2 * InGameConsole::BLINK) 349 this->cursor_ = 0; 337 350 338 351 if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|') … … 345 358 this->cursorSymbol_ = '|'; 346 359 this->cursorChanged(); 347 } 360 }*/ 348 361 349 362 // this creates a flickering effect … … 445 458 this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00)); 446 459 } 460 } 461 462 void InGameConsole::setCursorPosition(int pos) 463 { 464 static std::string char1 = "bdefgilpqtzCEGIJKNOPQT5[}äü"; 465 static std::string char2 = "Z4"; 466 467 if (pos > maxCharsPerLine_) 468 pos = maxCharsPerLine_; 469 else if (pos < 0) 470 pos = 0; 471 472 float width = 0; 473 for (int i = 0; i < pos; ++i) 474 { 475 if (char1.find(displayedText_[i]) != std::string::npos) 476 width += CHAR_WIDTH1; 477 else if (char2.find(displayedText_[i]) != std::string::npos) 478 width += CHAR_WIDTH2; 479 else 480 width += CHAR_WIDTH3; 481 } 482 this->consoleOverlayCursor_->setPosition(width + 5, 219); 447 483 } 448 484 … … 480 516 } 481 517 this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output)); 518 this->displayedText_ = output; 482 519 this->numLinesShifted_ = linesUsed; 483 520 } … … 493 530 output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_); 494 531 } 532 else 533 this->inputWindowStart_ = 0; 534 this->displayedText_ = output; 495 535 this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output)); 496 536 } -
code/branches/network/src/orxonox/console/InGameConsole.h
r1469 r1470 72 72 void shiftLines(); 73 73 void colourLine(int colourcode, int index); 74 void setCursorPosition(int pos); 74 75 void print(const std::string& text, int index, bool alwaysShift = false); 75 76 static Ogre::UTFString convert2UTF(std::string s); … … 90 91 char cursorSymbol_; 91 92 bool active_; 93 bool bShowCursor_; 94 std::string displayedText_; 92 95 Ogre::OverlayManager* om_; 93 96 Ogre::Overlay* consoleOverlay_;
Note: See TracChangeset
for help on using the changeset viewer.