Changeset 1317
- Timestamp:
- May 18, 2008, 1:28:08 AM (17 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/InputBuffer.cc
r1313 r1317 46 46 this->buffer_ = ""; 47 47 this->cursor_ = 0; 48 49 InputManager::getSingleton().feedInputBuffer(this); 48 50 } 49 51 … … 54 56 this->buffer_ = ""; 55 57 this->cursor_ = 0; 58 59 InputManager::getSingleton().feedInputBuffer(this); 56 60 } 57 61 -
code/branches/console/src/core/Shell.cc
r1313 r1317 48 48 49 49 this->clearLines(); 50 50 /* 51 51 this->inputBuffer_.registerListener(this, &Shell::inputChanged, true); 52 52 this->inputBuffer_.registerListener(this, &Shell::execute, '\r', false); … … 63 63 this->inputBuffer_.registerListener(this, &Shell::scroll_up, OIS::KC_PGUP); 64 64 this->inputBuffer_.registerListener(this, &Shell::scroll_down, OIS::KC_PGDOWN); 65 65 */ 66 66 this->setConfigValues(); 67 67 } … … 141 141 { 142 142 if (this->scrollPosition_) 143 { 143 144 return this->scrollIterator_; 145 } 144 146 else 145 return this->lines_.begin(); 147 { 148 if ((*this->lines_.begin()) == "" && this->lines_.size() > 1) 149 return (++this->lines_.begin()); 150 else 151 return this->lines_.begin(); 152 } 146 153 } 147 154 … … 169 176 while (this->outputBuffer_.getLine(&output)) 170 177 { 178 bool newline = false; 179 if ((*this->lines_.begin()) == "") 180 newline = true; 181 171 182 (*this->lines_.begin()) += output; 183 184 SHELL_UPDATE_LISTENERS(onlyLastLineChanged); 185 172 186 this->lines_.insert(this->lines_.begin(), ""); 173 187 … … 177 191 this->scrollIterator_ = this->lines_.begin(); 178 192 179 SHELL_UPDATE_LISTENERS(linesChanged); 180 SHELL_UPDATE_LISTENERS(lineAdded); 193 if (newline) 194 { 195 SHELL_UPDATE_LISTENERS(lineAdded); 196 } 181 197 } 182 198 -
code/branches/console/src/core/Shell.h
r1313 r1317 79 79 { return this->inputBuffer_.get(); } 80 80 81 inlinestd::list<std::string>::const_iterator getNewestLineIterator() const;82 inlinestd::list<std::string>::const_iterator getEndIterator() const;81 std::list<std::string>::const_iterator getNewestLineIterator() const; 82 std::list<std::string>::const_iterator getEndIterator() const; 83 83 84 84 void addLine(const std::string& line, unsigned int level); -
code/branches/console/src/orxonox/Orxonox.cc
r1313 r1317 76 76 #include "tools/Timer.h" 77 77 #include "hud/HUD.h" 78 #include "console/InGameConsole.h"78 //#include "console/InGameConsole.h" 79 79 80 80 // FIXME: is this really file scope? … … 88 88 ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0); 89 89 ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0); 90 90 /* 91 91 class Testconsole : public InputBufferListener 92 92 { … … 125 125 InputBuffer* ib_; 126 126 }; 127 127 */ 128 128 class Calculator 129 129 { … … 421 421 void Orxonox::startRenderLoop() 422 422 { 423 InputBuffer* ib = new InputBuffer(); 424 InputManager::getSingleton().feedInputBuffer(ib); 423 424 // InputBuffer* ib = new InputBuffer(); 425 // InputManager::getSingleton().feedInputBuffer(ib); 425 426 /* 426 427 Testconsole* console = new Testconsole(ib); … … 432 433 ib->registerListener(console, &Testconsole::exit, (char)0x1B, true); 433 434 */ 434 435 /* 435 436 orxonoxConsole_ = new InGameConsole(ib); 436 437 ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true); … … 440 441 ib->registerListener(orxonoxConsole_, &InGameConsole::removeLast, '\b', true); 441 442 ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true); 442 443 */ 443 444 // first check whether ogre root object has been created 444 445 if (Ogre::Root::getSingletonPtr() == 0) … … 489 490 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 490 491 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 491 orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);492 // orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_); 492 493 493 494 // don't forget to call _fireFrameStarted in ogre to make sure -
code/branches/console/src/orxonox/Orxonox.h
r1145 r1317 105 105 // TODO: make this a config-value by creating a config class for orxonox 106 106 float frameSmoothingTime_; 107 InGameConsole* orxonoxConsole_;107 // InGameConsole* orxonoxConsole_; 108 108 HUD* orxonoxHUD_; 109 109 bool bAbort_; //!< aborts the render loop if true -
code/branches/console/src/orxonox/console/InGameConsole.cc
r1313 r1317 23 23 * Felix Schulthess 24 24 * Co-authors: 25 * ...25 * Fabian 'x3n' Landau 26 26 * 27 27 */ … … 40 40 #include "core/Debug.h" 41 41 #include "core/CoreIncludes.h" 42 #include "core/ConfigValueIncludes.h" 42 43 #include "core/ConsoleCommand.h" 43 44 #include "GraphicsEngine.h" … … 49 50 using namespace Ogre; 50 51 51 const float REL_WIDTH = 0.8; 52 const float REL_HEIGHT = 0.4; 53 const float BLINK = 0.25; 54 55 InGameConsole::InGameConsole(InputBuffer* ib){ 56 //RegisterObject(InGameConsole); 57 ib_ = ib; 58 active = false; 59 cursor = 0.0; 60 init(); 61 } 62 63 InGameConsole::~InGameConsole(void){ 64 for(int i=0; i<LINES; i++) delete consoleOverlayTextAreas[i]; 65 delete consoleOverlayTextAreas; 66 } 67 68 void InGameConsole::listen(){ 69 if(!active) activate(); 70 print(convert2UTF(this->ib_->get())); 71 } 72 73 void InGameConsole::execute(){ 74 newline(); 75 if (!CommandExecutor::execute(this->ib_->get())){ 76 print("Error"); 77 newline(); 78 } 79 this->ib_->clear(); 80 } 81 82 void InGameConsole::hintandcomplete(){ 83 print(CommandExecutor::hint(this->ib_->get())); 84 newline(); 85 this->ib_->set(CommandExecutor::complete(this->ib_->get())); 86 print(convert2UTF(this->ib_->get())); 87 } 88 89 void InGameConsole::clear(){ 90 this->ib_->clear(); 91 } 92 93 void InGameConsole::removeLast(){ 94 this->ib_->removeBehindCursor(); 95 } 96 97 void InGameConsole::exit(){ 98 clear(); 99 deactivate(); 100 CommandExecutor::execute("setInputMode 2"); 101 } 102 103 /** 104 @brief called once by constructor 105 */ 106 void InGameConsole::init(){ 52 float InGameConsole::REL_WIDTH = 0.8; 53 float InGameConsole::REL_HEIGHT = 0.4; 54 float InGameConsole::BLINK = 0.25; 55 56 /** 57 @brief Constructor: Creates and initializes the InGameConsole. 58 */ 59 InGameConsole::InGameConsole() 60 { 61 RegisterObject(InGameConsole); 62 63 this->active_ = false; 64 this->cursor_ = 0.0; 65 66 this->init(); 67 this->setConfigValues(); 68 } 69 70 /** 71 @brief Destructor: Destroys the TextAreas. 72 */ 73 InGameConsole::~InGameConsole(void) 74 { 75 for (int i = 0; i < LINES; i++) 76 delete this->consoleOverlayTextAreas_[i]; 77 78 delete this->consoleOverlayTextAreas_; 79 } 80 81 /** 82 @brief Returns a reference to the only existing instance of InGameConsole. 83 */ 84 InGameConsole& InGameConsole::getInstance() 85 { 86 static InGameConsole instance; 87 return instance; 88 } 89 90 /** 91 @brief Sets the config values, describing the size of the console. 92 */ 93 void InGameConsole::setConfigValues() 94 { 95 SetConfigValue(REL_WIDTH, 0.8); 96 SetConfigValue(REL_HEIGHT, 0.4); 97 SetConfigValue(BLINK, 0.25); 98 } 99 100 /** 101 @brief Called if all output-lines have to be redrawn. 102 */ 103 void InGameConsole::linesChanged() 104 { 105 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; 110 } 111 } 112 113 /** 114 @brief Called if only the last output-line has changed. 115 */ 116 void InGameConsole::onlyLastLineChanged() 117 { 118 if (LINES > 1) 119 this->consoleOverlayTextAreas_[1]->setCaption(*Shell::getInstance().getNewestLineIterator()); 120 } 121 122 /** 123 @brief Called if a new output-line was added. 124 */ 125 void InGameConsole::lineAdded() 126 { 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()); 132 } 133 134 /** 135 @brief Called if the text in the input-line has changed. 136 */ 137 void InGameConsole::inputChanged() 138 { 139 if (LINES > 0) 140 this->consoleOverlayTextAreas_[0]->setCaption(Shell::getInstance().getInput()); 141 } 142 143 /** 144 @brief Called if the position of the cursor in the input-line has changed. 145 */ 146 void InGameConsole::cursorChanged() 147 { 148 std::string input = Shell::getInstance().getInput(); 149 input.insert(Shell::getInstance().getCursorPosition(), 1, '|'); 150 if (LINES > 0) 151 this->consoleOverlayTextAreas_[0]->setCaption(input); 152 } 153 154 /** 155 @brief Called if the console gets closed. 156 */ 157 void InGameConsole::exit() 158 { 159 this->deactivate(); 160 CommandExecutor::execute("set InputMode 2"); 161 } 162 163 /** 164 @brief Called once by constructor, initializes the InGameConsole. 165 */ 166 void InGameConsole::init() 167 { 107 168 // for the beginning, don't scroll 108 scroll= 0;109 scrollTimer= 0;110 cursor= 0;169 this->scroll_ = 0; 170 this->scrollTimer_ = 0; 171 this->cursor_ = 0; 111 172 112 173 // create overlay and elements 113 om= &Ogre::OverlayManager::getSingleton();174 this->om_ = &Ogre::OverlayManager::getSingleton(); 114 175 115 176 // create a container 116 consoleOverlayContainer = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", "container"));117 consoleOverlayContainer->setMetricsMode(Ogre::GMM_RELATIVE);118 consoleOverlayContainer->setPosition((1-REL_WIDTH)/2, 0);119 consoleOverlayContainer->setDimensions(REL_WIDTH,REL_HEIGHT);177 this->consoleOverlayContainer_ = static_cast<OverlayContainer*>(this->om_->createOverlayElement("Panel", "container")); 178 this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE); 179 this->consoleOverlayContainer_->setPosition((1 - InGameConsole::REL_WIDTH) / 2, 0); 180 this->consoleOverlayContainer_->setDimensions(InGameConsole::REL_WIDTH, InGameConsole::REL_HEIGHT); 120 181 121 182 // create BorderPanel 122 consoleOverlayBorder = static_cast<BorderPanelOverlayElement*>(om->createOverlayElement("BorderPanel", "borderPanel"));123 consoleOverlayBorder->setMetricsMode(Ogre::GMM_PIXELS);124 consoleOverlayBorder->setMaterialName("ConsoleCenter");183 this->consoleOverlayBorder_ = static_cast<BorderPanelOverlayElement*>(this->om_->createOverlayElement("BorderPanel", "borderPanel")); 184 this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS); 185 this->consoleOverlayBorder_->setMaterialName("ConsoleCenter"); 125 186 // set parameters for border 126 consoleOverlayBorder->setBorderSize(16, 16, 0, 16);127 consoleOverlayBorder->setBorderMaterialName("ConsoleBorder");128 consoleOverlayBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);129 consoleOverlayBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);130 consoleOverlayBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);131 consoleOverlayBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);132 consoleOverlayBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);187 this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16); 188 this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder"); 189 this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51); 190 this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5); 191 this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0); 192 this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0); 193 this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0); 133 194 134 195 // create the text lines 135 consoleOverlayTextAreas = new TextAreaOverlayElement*[LINES]; 136 for(int i = 0; i<LINES; i++){ 137 consoleOverlayTextAreas[i] = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "textArea"+Ogre::StringConverter::toString(i))); 138 consoleOverlayTextAreas[i]->setMetricsMode(Ogre::GMM_PIXELS); 139 consoleOverlayTextAreas[i]->setFontName("Console"); 140 consoleOverlayTextAreas[i]->setCharHeight(20); 141 consoleOverlayTextAreas[i]->setParameter("colour_top", "0.21 0.69 0.21"); 142 consoleOverlayTextAreas[i]->setLeft(8); 143 consoleOverlayTextAreas[i]->setCaption(""); 196 this->consoleOverlayTextAreas_ = new TextAreaOverlayElement*[LINES]; 197 for (int i = 0; i < LINES; i++) 198 { 199 this->consoleOverlayTextAreas_[i] = static_cast<TextAreaOverlayElement*>(this->om_->createOverlayElement("TextArea", "textArea" + Ogre::StringConverter::toString(i))); 200 this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS); 201 this->consoleOverlayTextAreas_[i]->setFontName("Console"); 202 this->consoleOverlayTextAreas_[i]->setCharHeight(20); 203 this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21"); 204 this->consoleOverlayTextAreas_[i]->setLeft(8); 205 this->consoleOverlayTextAreas_[i]->setCaption(""); 144 206 } 145 207 146 208 // create noise 147 consoleOverlayNoise = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "noise")); 148 consoleOverlayNoise->setMetricsMode(Ogre::GMM_PIXELS); 149 consoleOverlayNoise->setPosition(5,0); 150 consoleOverlayNoise->setMaterialName("ConsoleNoise"); 151 152 consoleOverlay = om->create("Console"); 153 consoleOverlay->add2D(consoleOverlayContainer); 154 consoleOverlayContainer->addChild(consoleOverlayBorder); 155 //comment following line to disable noise 156 consoleOverlayContainer->addChild(consoleOverlayNoise); 157 for(int i = 0; i<LINES; i++) consoleOverlayContainer->addChild(consoleOverlayTextAreas[i]); 158 resize(); 209 this->consoleOverlayNoise_ = static_cast<PanelOverlayElement*>(this->om_->createOverlayElement("Panel", "noise")); 210 this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS); 211 this->consoleOverlayNoise_->setPosition(5,0); 212 this->consoleOverlayNoise_->setMaterialName("ConsoleNoise"); 213 214 this->consoleOverlay_ = this->om_->create("Console"); 215 this->consoleOverlay_->add2D(this->consoleOverlayContainer_); 216 this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_); 217 //comment following line to disable noise 218 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 219 for (int i = 0; i < LINES; i++) 220 this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]); 221 222 this->resize(); 159 223 160 224 // move overlay "above" the top edge of the screen 161 225 // we take -1.2 because the border mkes the panel bigger 162 consoleOverlayContainer->setTop(-1.2*REL_HEIGHT);226 this->consoleOverlayContainer_->setTop(-1.2 * InGameConsole::REL_HEIGHT); 163 227 // show overlay 164 consoleOverlay->show();228 this->consoleOverlay_->show(); 165 229 166 230 COUT(3) << "Info: InGameConsole initialized" << std::endl; … … 168 232 169 233 /** 170 @brief used to control the actual scrolling and cursor 171 */ 172 void InGameConsole::tick(float dt){ 173 scrollTimer += dt; 174 if(scrollTimer >= 0.01){ 175 float top = consoleOverlayContainer->getTop(); 176 scrollTimer = 0; 177 if(scroll!=0){ 234 @brief Used to control the actual scrolling and the cursor. 235 */ 236 void InGameConsole::tick(float dt) 237 { 238 this->scrollTimer_ += dt; 239 if (this->scrollTimer_ >= 0.01) 240 { 241 float top = this->consoleOverlayContainer_->getTop(); 242 this->scrollTimer_ = 0; 243 if (this->scroll_ != 0) 244 { 178 245 // scroll 179 top = top + 0.02 *scroll;180 consoleOverlayContainer->setTop(top);246 top = top + 0.02 * this->scroll_; 247 this->consoleOverlayContainer_->setTop(top); 181 248 } 182 if(top <= -1.2*REL_HEIGHT){ 249 if (top <= -1.2 * InGameConsole::REL_HEIGHT) 250 { 183 251 // window has completely scrolled up 184 scroll= 0;185 consoleOverlay->hide();186 active= false;252 this->scroll_ = 0; 253 this->consoleOverlay_->hide(); 254 this->active_ = false; 187 255 } 188 if(top >= 0){ 256 if (top >= 0) 257 { 189 258 // window has completely scrolled down 190 scroll= 0;191 consoleOverlayContainer->setTop(0);192 active= true;259 this->scroll_ = 0; 260 this->consoleOverlayContainer_->setTop(0); 261 this->active_ = true; 193 262 } 194 263 } 195 264 196 cursor += dt; 197 if(cursor >= 2*BLINK) cursor = 0; 198 print(convert2UTF(this->ib_->get())); 199 200 // this creates a flickering effect 201 consoleOverlayNoise->setTiling(1, rand()%5+1); 202 } 203 204 /** 205 @brief resizes the console elements. call if window size changes 206 */ 207 void InGameConsole::resize(){ 208 windowW = GraphicsEngine::getSingleton().getWindowWidth(); 209 windowH = GraphicsEngine::getSingleton().getWindowHeight(); 210 consoleOverlayBorder->setWidth((int) windowW*REL_WIDTH); 211 consoleOverlayBorder->setHeight((int) windowH*REL_HEIGHT); 212 consoleOverlayNoise->setWidth((int) windowW*REL_WIDTH - 10); 213 consoleOverlayNoise->setHeight((int) windowH*REL_HEIGHT - 5); 265 this->cursor_ += dt; 266 if (this->cursor_ >= 2 * InGameConsole::BLINK) 267 this->cursor_ = 0; 268 // print(convert2UTF(this->ib_->get())); 269 270 // this creates a flickering effect 271 this->consoleOverlayNoise_->setTiling(1, rand() % 5 + 1); 272 } 273 274 /** 275 @brief Resizes the console elements. Call if window size changes. 276 */ 277 void InGameConsole::resize() 278 { 279 this->windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 280 this->windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 281 this->consoleOverlayBorder_->setWidth((int) this->windowW_* InGameConsole::REL_WIDTH); 282 this->consoleOverlayBorder_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT); 283 this->consoleOverlayNoise_->setWidth((int) this->windowW_ * InGameConsole::REL_WIDTH - 10); 284 this->consoleOverlayNoise_->setHeight((int) this->windowH_ * InGameConsole::REL_HEIGHT - 5); 214 285 // now adjust the text lines... 215 for(int i = 0; i<LINES; i++){ 216 consoleOverlayTextAreas[i]->setWidth(windowW*REL_WIDTH); 217 consoleOverlayTextAreas[i]->setTop((int)windowH*REL_HEIGHT - 24 - 16*i); 218 } 219 } 220 221 /** 222 @brief shows console 223 */ 224 void InGameConsole::activate(){ 225 consoleOverlay->show(); 286 for (int i = 0; i < LINES; i++) 287 { 288 this->consoleOverlayTextAreas_[i]->setWidth((int) this->windowW_ * InGameConsole::REL_WIDTH); 289 this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * InGameConsole::REL_HEIGHT - 24 - 16*i); 290 } 291 } 292 293 /** 294 @brief Shows the InGameConsole. 295 */ 296 void InGameConsole::activate() 297 { 298 this->consoleOverlay_->show(); 226 299 // just in case window size has changed... 227 resize();300 this->resize(); 228 301 // scroll down 229 scroll= 1;302 this->scroll_ = 1; 230 303 // the rest is done by tick 231 304 } 232 305 233 306 /** 234 @brief hides console 235 */ 236 void InGameConsole::deactivate(){ 307 @brief Hides the InGameConsole. 308 */ 309 void InGameConsole::deactivate() 310 { 237 311 // scroll up 238 scroll= -1;312 this->scroll_ = -1; 239 313 // the rest is done by tick 240 314 } 241 315 242 316 /** 243 @brief prints string to bottom line 244 @param s string to be printed 245 */ 246 void InGameConsole::print(Ogre::UTFString s){ 247 if(cursor>BLINK) consoleOverlayTextAreas[0]->setCaption(">" + s); 248 else consoleOverlayTextAreas[0]->setCaption(">" + s + "_"); 249 } 250 251 /** 252 @brief shifts all lines up and clears the bottom line 253 */ 254 void InGameConsole::newline(){ 317 @brief Activates the console. 318 */ 319 void InGameConsole::openConsole() 320 { 321 InGameConsole::getInstance().activate(); 322 } 323 324 /** 325 @brief Deactivates the console. 326 */ 327 void InGameConsole::closeConsole() 328 { 329 InGameConsole::getInstance().deactivate(); 330 } 331 332 /** 333 @brief Prints string to bottom line. 334 @param s String to be printed 335 */ 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 { 255 349 Ogre::UTFString line; 256 for(int i = LINES-1; i>=1; i--){ 257 line = consoleOverlayTextAreas[i-1]->getCaption(); 350 for (int i = LINES - 1; i >= 1; i--) 351 { 352 line = this->consoleOverlayTextAreas_[i - 1]->getCaption(); 258 353 // don't copy the cursor... 259 354 int l = line.length(); 260 if(!line.empty() && line.substr(l-1) == "_") line.erase(l-1); 261 consoleOverlayTextAreas[i]->setCaption(line); 262 } 263 consoleOverlayTextAreas[0]->setCaption(">"); 264 } 265 266 Ogre::UTFString InGameConsole::convert2UTF(std::string s){ 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(">"); 360 } 361 362 /** 363 @brief Converts a string into an Ogre::UTFString. 364 @param s The string to convert 365 @return The converted string 366 */ 367 Ogre::UTFString InGameConsole::convert2UTF(std::string s) 368 { 267 369 Ogre::UTFString utf; 268 int i;269 370 Ogre::UTFString::code_point cp; 270 for (i=0; i<(int)s.size(); ++i){ 371 for (unsigned int i = 0; i < s.size(); ++i) 372 { 271 373 cp = s[i]; 272 374 cp &= 0xFF; -
code/branches/console/src/orxonox/console/InGameConsole.h
r1181 r1317 37 37 38 38 #include "core/Tickable.h" 39 #include "core/ InputBuffer.h"39 #include "core/Shell.h" 40 40 41 41 42 42 namespace orxonox 43 43 { 44 class _OrxonoxExport InGameConsole : public InputBufferListener44 class _OrxonoxExport InGameConsole : public Tickable, public ShellListener 45 45 { 46 46 public: 47 InGameConsole(InputBuffer* ib); 48 ~InGameConsole(); 49 void listen(); 50 void execute(); 51 void hintandcomplete(); 52 void clear(); 53 void removeLast(); 54 void exit(); 55 void init(); 47 static InGameConsole& getInstance(); 48 49 void setConfigValues(); 50 51 virtual void linesChanged(); 52 virtual void onlyLastLineChanged(); 53 virtual void lineAdded(); 54 virtual void inputChanged(); 55 virtual void cursorChanged(); 56 virtual void exit(); 57 56 58 void tick(float dt); 59 57 60 void activate(); 58 61 void deactivate(); 59 62 63 static void openConsole(); 64 static void closeConsole(); 65 60 66 private: 67 InGameConsole(); 68 InGameConsole(const InGameConsole& other); 69 ~InGameConsole(); 70 71 void init(); 61 72 void resize(); 62 73 void print(Ogre::UTFString s); 63 74 void newline(); 64 Ogre::UTFString convert2UTF(std::string s);75 static Ogre::UTFString convert2UTF(std::string s); 65 76 66 int windowW; 67 int windowH; 68 int scroll; 69 float scrollTimer; 70 float cursor; 71 bool active; 72 InputBuffer* ib_; 73 Ogre::OverlayManager* om; 74 Ogre::Overlay* consoleOverlay; 75 Ogre::OverlayContainer* consoleOverlayContainer; 76 Ogre::PanelOverlayElement* consoleOverlayNoise; 77 Ogre::BorderPanelOverlayElement* consoleOverlayBorder; 78 Ogre::TextAreaOverlayElement** consoleOverlayTextAreas; 77 static float REL_WIDTH; 78 static float REL_HEIGHT; 79 static float BLINK; 80 81 int windowW_; 82 int windowH_; 83 int scroll_; 84 float scrollTimer_; 85 float cursor_; 86 bool active_; 87 Ogre::OverlayManager* om_; 88 Ogre::Overlay* consoleOverlay_; 89 Ogre::OverlayContainer* consoleOverlayContainer_; 90 Ogre::PanelOverlayElement* consoleOverlayNoise_; 91 Ogre::BorderPanelOverlayElement* consoleOverlayBorder_; 92 Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_; 79 93 }; 80 94 }
Note: See TracChangeset
for help on using the changeset viewer.