Changeset 1322 for code/branches/console/src/orxonox
- Timestamp:
- May 19, 2008, 2:33:09 AM (17 years ago)
- Location:
- code/branches/console/src/orxonox/console
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/orxonox/console/InGameConsole.cc
r1317 r1322 42 42 #include "core/ConfigValueIncludes.h" 43 43 #include "core/ConsoleCommand.h" 44 #include "core/InputManager.h" 44 45 #include "GraphicsEngine.h" 45 46 … … 48 49 namespace orxonox 49 50 { 51 ConsoleCommand(InGameConsole, openConsole, AccessLevel::None, true); 52 ConsoleCommand(InGameConsole, closeConsole, AccessLevel::None, true); 53 50 54 using namespace Ogre; 51 55 52 56 float InGameConsole::REL_WIDTH = 0.8; 53 57 float InGameConsole::REL_HEIGHT = 0.4; 54 float InGameConsole::BLINK = 0. 25;58 float InGameConsole::BLINK = 0.5; 55 59 56 60 /** … … 63 67 this->active_ = false; 64 68 this->cursor_ = 0.0; 69 this->cursorSymbol_ = '|'; 65 70 66 71 this->init(); 67 72 this->setConfigValues(); 73 74 Shell::getInstance().registerListener(this); 68 75 } 69 76 … … 95 102 SetConfigValue(REL_WIDTH, 0.8); 96 103 SetConfigValue(REL_HEIGHT, 0.4); 97 SetConfigValue(BLINK, 0. 25);104 SetConfigValue(BLINK, 0.5); 98 105 } 99 106 … … 104 111 { 105 112 std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator(); 106 for (int i = 1; i < LINES && it != Shell::getInstance().getEndIterator(); i++) 107 { 108 this->consoleOverlayTextAreas_[i]->setCaption(*it); 109 ++it; 113 for (int i = 1; i < LINES; i++) 114 { 115 if (it != Shell::getInstance().getEndIterator()) 116 { 117 this->print(*it, i); 118 ++it; 119 } 120 else 121 { 122 this->print("", i); 123 } 110 124 } 111 125 } … … 117 131 { 118 132 if (LINES > 1) 119 this-> consoleOverlayTextAreas_[1]->setCaption(*Shell::getInstance().getNewestLineIterator());133 this->print(*Shell::getInstance().getNewestLineIterator(), 1); 120 134 } 121 135 … … 125 139 void InGameConsole::lineAdded() 126 140 { 127 for (int i = LINES - 1; i > 1; i--) 128 this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption()); 129 130 if (LINES > 1) 131 this->consoleOverlayTextAreas_[1]->setCaption(*Shell::getInstance().getNewestLineIterator()); 141 this->linesChanged(); 132 142 } 133 143 … … 138 148 { 139 149 if (LINES > 0) 140 this-> consoleOverlayTextAreas_[0]->setCaption(Shell::getInstance().getInput());150 this->print(Shell::getInstance().getInput(), 0); 141 151 } 142 152 … … 147 157 { 148 158 std::string input = Shell::getInstance().getInput(); 149 input.insert(Shell::getInstance().getCursorPosition(), 1, '|');159 input.insert(Shell::getInstance().getCursorPosition(), 1, this->cursorSymbol_); 150 160 if (LINES > 0) 151 this-> consoleOverlayTextAreas_[0]->setCaption(input);161 this->print(input, 0); 152 162 } 153 163 … … 158 168 { 159 169 this->deactivate(); 160 CommandExecutor::execute("set InputMode 2");170 InputManager::getSingleton().setInputMode(IM_INGAME); 161 171 } 162 172 … … 266 276 if (this->cursor_ >= 2 * InGameConsole::BLINK) 267 277 this->cursor_ = 0; 268 // print(convert2UTF(this->ib_->get())); 278 279 if (this->cursor_ >= InGameConsole::BLINK && this->cursorSymbol_ == '|') 280 { 281 this->cursorSymbol_ = ' '; 282 this->cursorChanged(); 283 } 284 else if (this->cursor_ < InGameConsole::BLINK && this->cursorSymbol_ == ' ') 285 { 286 this->cursorSymbol_ = '|'; 287 this->cursorChanged(); 288 } 269 289 270 290 // this creates a flickering effect … … 296 316 void InGameConsole::activate() 297 317 { 318 this->linesChanged(); 319 298 320 this->consoleOverlay_->show(); 299 321 // just in case window size has changed... … … 334 356 @param s String to be printed 335 357 */ 336 void InGameConsole::print(Ogre::UTFString s) 337 { 338 if (this->cursor_ > InGameConsole::BLINK) 339 this->consoleOverlayTextAreas_[0]->setCaption(">" + s); 340 else 341 this->consoleOverlayTextAreas_[0]->setCaption(">" + s + "_"); 342 } 343 344 /** 345 @brief Shifts all lines up and clears the bottom line. 346 */ 347 void InGameConsole::newline() 348 { 349 Ogre::UTFString line; 350 for (int i = LINES - 1; i >= 1; i--) 351 { 352 line = this->consoleOverlayTextAreas_[i - 1]->getCaption(); 353 // don't copy the cursor... 354 int l = line.length(); 355 if (!line.empty() && line.substr(l-1) == "_") 356 line.erase(l-1); 357 this->consoleOverlayTextAreas_[i]->setCaption(line); 358 } 359 this->consoleOverlayTextAreas_[0]->setCaption(">"); 358 void InGameConsole::print(const std::string& text, int index) 359 { 360 if (LINES > index) 361 this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(text)); 360 362 } 361 363 -
code/branches/console/src/orxonox/console/InGameConsole.h
r1317 r1322 71 71 void init(); 72 72 void resize(); 73 void print(Ogre::UTFString s); 74 void newline(); 73 void print(const std::string& text, int index); 75 74 static Ogre::UTFString convert2UTF(std::string s); 76 75 … … 84 83 float scrollTimer_; 85 84 float cursor_; 85 char cursorSymbol_; 86 86 bool active_; 87 87 Ogre::OverlayManager* om_;
Note: See TracChangeset
for help on using the changeset viewer.