Changeset 1214 for code/trunk/src
- Timestamp:
- May 2, 2008, 9:23:30 PM (17 years ago)
- Location:
- code/trunk/src
- Files:
-
- 17 edited
- 21 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/CMakeLists.txt
r1209 r1214 5 5 ADD_SUBDIRECTORY(tinyxml) 6 6 ADD_SUBDIRECTORY(tolua) 7 ADD_SUBDIRECTORY(cpptcl) 7 8 ADD_SUBDIRECTORY(util) 8 9 ADD_SUBDIRECTORY(core) -
code/trunk/src/core/CMakeLists.txt
r1209 r1214 28 28 tolua/tolua_bind.cc 29 29 #tolua/tolua_bind.h 30 TclBind.cc 30 31 ) 31 32 … … 49 50 50 51 TARGET_LINK_LIBRARIES(core 52 cpptcl 51 53 ${Lua_LIBRARIES} 52 54 ${OIS_LIBRARIES} -
code/trunk/src/core/CommandExecutor.cc
r1059 r1214 36 36 #include "Executor.h" 37 37 #include "ConfigValueContainer.h" 38 #include "TclBind.h" 38 39 39 40 #define COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE "set" … … 236 237 if (this->shortcut_) 237 238 { 238 if (this->shortcut_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " ")) 239 { 240 this->bEvaluatedParams_ = true; 241 this->evaluatedExecutor_ = this->shortcut_; 239 if (this->tokens_.size() <= 1) 240 { 241 if (this->shortcut_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 242 { 243 this->bEvaluatedParams_ = true; 244 this->evaluatedExecutor_ = this->shortcut_; 245 } 246 } 247 else if (this->tokens_.size() > 1) 248 { 249 if (this->shortcut_->evaluate(this->tokens_.subSet(1).join() + this->getAdditionalParameter(), this->param_, " ")) 250 { 251 this->bEvaluatedParams_ = true; 252 this->evaluatedExecutor_ = this->shortcut_; 253 } 242 254 } 243 255 } … … 247 259 if (this->function_) 248 260 { 249 if (this->function_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " ")) 250 { 251 this->bEvaluatedParams_ = true; 252 this->evaluatedExecutor_ = this->function_; 261 if (this->tokens_.size() <= 2) 262 { 263 if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 264 { 265 this->bEvaluatedParams_ = true; 266 this->evaluatedExecutor_ = this->function_; 267 } 268 } 269 else if (this->tokens_.size() > 2) 270 { 271 if (this->function_->evaluate(this->tokens_.subSet(2).join() + this->getAdditionalParameter(), this->param_, " ")) 272 { 273 this->bEvaluatedParams_ = true; 274 this->evaluatedExecutor_ = this->function_; 275 } 253 276 } 254 277 } … … 266 289 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) 267 290 return this->param_[index]; 291 292 return MT_null; 293 } 294 295 bool CommandEvaluation::hasReturnvalue() const 296 { 297 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 298 { 299 if (this->shortcut_) 300 return this->shortcut_->hasReturnvalue(); 301 } 302 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 303 { 304 if (this->function_) 305 return this->function_->hasReturnvalue(); 306 } 268 307 269 308 return MT_null; … … 297 336 298 337 CommandEvaluation& CommandExecutor::getEvaluation() 338 { 339 return CommandExecutor::getInstance().evaluation_; 340 } 341 342 const CommandEvaluation& CommandExecutor::getLastEvaluation() 299 343 { 300 344 return CommandExecutor::getInstance().evaluation_; … … 336 380 } 337 381 338 bool CommandExecutor::execute(const std::string& command) 339 { 340 std::string strippedCommand = stripEnclosingQuotes(command); 341 342 SubString tokensIO(strippedCommand, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0'); 343 if (tokensIO.size() >= 2) 344 { 345 if (tokensIO[tokensIO.size() - 2] == ">") 346 { 347 bool success = CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join()); 348 write(tokensIO[tokensIO.size() - 1], CommandExecutor::getEvaluation().getReturnvalue()); 349 return success; 350 } 351 else if (tokensIO[tokensIO.size() - 2] == "<") 352 { 353 std::string input = read(tokensIO[tokensIO.size() - 1]); 354 if (input == "" || input.size() == 0) 355 return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join()); 356 else 357 return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join() + " " + input); 358 } 359 } 360 361 362 SubString tokensPipeline(strippedCommand, "|", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0'); 363 if (tokensPipeline.size() > 1) 364 { 365 bool success = true; 366 std::string returnValue = ""; 367 for (int i = tokensPipeline.size() - 1; i >= 0; i--) 368 { 369 if (returnValue == "" || returnValue.size() == 0) 370 { 371 //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i]); 372 if (!CommandExecutor::execute(tokensPipeline[i])) 373 success = false; 374 } 375 else 376 { 377 //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i] + " " + returnValue); 378 if (!CommandExecutor::execute(tokensPipeline[i] + " " + returnValue)) 379 success = false; 380 } 381 382 //CommandExecutor::execute(evaluation); 383 //returnValue = evaluation.getReturnvalue(); 384 returnValue = CommandExecutor::getEvaluation().getReturnvalue().toString(); 385 } 386 return success; 387 } 388 389 if ((CommandExecutor::getEvaluation().processedCommand_ != strippedCommand) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 390 CommandExecutor::parse(strippedCommand); 391 392 return CommandExecutor::execute(CommandExecutor::getEvaluation()); 382 bool CommandExecutor::execute(const std::string& command, bool useTcl) 383 { 384 if (useTcl) 385 { 386 return TclBind::eval(command); 387 } 388 else 389 { 390 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 391 CommandExecutor::parse(command); 392 393 return CommandExecutor::execute(CommandExecutor::getEvaluation()); 394 } 393 395 } 394 396 … … 400 402 if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_) 401 403 { 404 std::cout << "CE_execute (evaluation): " << evaluation.evaluatedExecutor_->getName() << " " << evaluation.param_[0] << " " << evaluation.param_[1] << " " << evaluation.param_[2] << " " << evaluation.param_[3] << " " << evaluation.param_[4] << std::endl; 402 405 (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]); 403 } 404 406 return true; 407 } 408 409 std::cout << "CE_execute: " << evaluation.processedCommand_ << "\n"; 405 410 switch (evaluation.state_) 406 411 { … … 645 650 { 646 651 CommandExecutor::parse(command, true); 652 653 if (CommandExecutor::getEvaluation().tokens_.size() > 0) 654 { 655 std::string lastToken; 656 lastToken = CommandExecutor::getEvaluation().tokens_[CommandExecutor::getEvaluation().tokens_.size() - 1]; 657 lastToken = lastToken.substr(0, lastToken.size() - 1); 658 CommandExecutor::getEvaluation().tokens_.pop_back(); 659 CommandExecutor::getEvaluation().tokens_.append(SubString(lastToken, " ", "", true, '\0', false, '\0', false, '\0', '\0', false, '\0')); 660 } 661 647 662 CommandExecutor::getEvaluation().evaluateParams(); 648 663 return CommandExecutor::getEvaluation(); … … 1082 1097 CommandExecutor::getEvaluation().additionalParameter_ = ""; 1083 1098 1099 CommandExecutor::getEvaluation().bEvaluatedParams_ = false; 1100 CommandExecutor::getEvaluation().evaluatedExecutor_ = 0; 1101 1084 1102 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.clear(); 1085 1103 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.clear(); -
code/trunk/src/core/CommandExecutor.h
r1064 r1214 95 95 void evaluateParams(); 96 96 97 bool hasReturnvalue() const; 97 98 MultiTypeMath getReturnvalue() const; 98 99 … … 130 131 { 131 132 public: 132 static bool execute(const std::string& command );133 static bool execute(const std::string& command, bool useTcl = true); 133 134 static bool execute(const CommandEvaluation& evaluation); 134 135 … … 140 141 141 142 static CommandEvaluation evaluate(const std::string& command); 143 144 static const CommandEvaluation& getLastEvaluation(); 142 145 143 146 static Executor& addConsoleCommandShortcut(ExecutorStatic* executor); -
code/trunk/src/core/CorePrereqs.h
r1062 r1214 139 139 template <class T> 140 140 class SubclassIdentifier; 141 class TclBind; 141 142 class Tickable; 142 143 template <class T, class O> -
code/trunk/src/core/Functor.h
r1064 r1214 284 284 #define FUNCTOR_EVALUATE_PARAM0 285 285 #define FUNCTOR_EVALUATE_PARAM1 \ 286 if (index == 0) param = (P1)param286 if (index == 0) { P1 temp = param; param = temp; } 287 287 #define FUNCTOR_EVALUATE_PARAM2 \ 288 if (index == 0) param = (P1)param;\289 else if (index == 1) param = (P2)param288 if (index == 0) { P1 temp = param; param = temp; } \ 289 else if (index == 1) { P2 temp = param; param = temp; } 290 290 #define FUNCTOR_EVALUATE_PARAM3 \ 291 if (index == 0) param = (P1)param;\292 else if (index == 1) param = (P2)param;\293 else if (index == 2) param = (P3)param291 if (index == 0) { P1 temp = param; param = temp; } \ 292 else if (index == 1) { P2 temp = param; param = temp; } \ 293 else if (index == 2) { P3 temp = param; param = temp; } 294 294 #define FUNCTOR_EVALUATE_PARAM4 \ 295 if (index == 0) param = (P1)param;\296 else if (index == 1) param = (P2)param;\297 else if (index == 2) param = (P3)param;\298 else if (index == 3) param = (P4)param295 if (index == 0) { P1 temp = param; param = temp; } \ 296 else if (index == 1) { P2 temp = param; param = temp; } \ 297 else if (index == 2) { P3 temp = param; param = temp; } \ 298 else if (index == 3) { P4 temp = param; param = temp; } 299 299 #define FUNCTOR_EVALUATE_PARAM5 \ 300 if (index == 0) param = (P1)param;\301 else if (index == 1) param = (P2)param;\302 else if (index == 2) param = (P3)param;\303 else if (index == 3) param = (P4)param;\304 else if (index == 4) param = (P5)param300 if (index == 0) { P1 temp = param; param = temp; } \ 301 else if (index == 1) { P2 temp = param; param = temp; } \ 302 else if (index == 2) { P3 temp = param; param = temp; } \ 303 else if (index == 3) { P4 temp = param; param = temp; } \ 304 else if (index == 4) { P5 temp = param; param = temp; } 305 305 306 306 -
code/trunk/src/core/InputBuffer.cc
r1066 r1214 39 39 { 40 40 //this->bActivated_ = false; 41 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"() .:,;_-+*/=!?<>[|]";41 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^"; 42 42 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 43 43 this->buffer_ = ""; 44 44 45 45 //this->keyboard_->setEventCallback(this); 46 } 47 48 InputBuffer::InputBuffer(const std::string allowedChars) 49 { 50 //this->bActivated_ = false; 51 this->allowedChars_ = allowedChars; 52 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 53 this->buffer_ = ""; 46 54 } 47 55 /* -
code/trunk/src/core/InputBuffer.h
r1066 r1214 59 59 public: 60 60 InputBuffer(); 61 InputBuffer(const std::string allowedChars); 61 62 62 63 template <class T> -
code/trunk/src/core/InputHandler.cc
r1066 r1214 85 85 InputHandlerGame::callListeners(e); 86 86 } 87 else if (e.key == OIS::KC_ NUMPADENTER)87 else if (e.key == OIS::KC_UNASSIGNED || e.key == OIS::KC_NUMPADENTER) 88 88 { 89 89 InputManager::getSingleton().setInputMode(IM_KEYBOARD); -
code/trunk/src/orxonox/CMakeLists.txt
r1209 r1214 3 3 Main.cc 4 4 Orxonox.cc 5 console/InGameConsole.cc 5 6 # SpaceshipSteering.cc 6 7 hud/HUD.cc -
code/trunk/src/orxonox/GraphicsEngine.cc
r1090 r1214 40 40 #include <OgreLogManager.h> 41 41 #include <OgreTextureManager.h> 42 #include <OgreRenderWindow.h> 43 42 #include "core/InputManager.h" 44 43 #include "core/CoreIncludes.h" 45 44 #include "core/ConfigValueIncludes.h" 46 45 #include "core/Debug.h" 46 #include "core/TclBind.h" 47 47 48 48 … … 90 90 { 91 91 COUT(4) << "*** GraphicsEngine: Destroying objects..." << std::endl; 92 Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this); 92 93 if (this->root_) 93 94 delete this->root_; … … 112 113 SetConfigValue(ogreLogLevelNormal_ , 4).description("Corresponding orxonox debug level for ogre Normal"); 113 114 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); 115 116 TclBind::getInstance().setDataPath(this->dataPath_); 114 117 } 115 118 … … 184 187 { 185 188 this->renderWindow_ = root_->initialise(true, "OrxonoxV2"); 189 Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this); 186 190 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); 187 191 //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load... … … 289 293 << "*** Ogre: " << message << std::endl; 290 294 } 295 296 void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw){ 297 int w = rw->getWidth(); 298 int h = rw->getHeight(); 299 InputManager::getSingleton().setWindowExtents(w, h); 300 } 301 302 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw){ 303 int w = rw->getWidth(); 304 int h = rw->getHeight(); 305 InputManager::getSingleton().setWindowExtents(w, h); 306 } 307 308 void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw){ 309 int w = rw->getWidth(); 310 int h = rw->getHeight(); 311 InputManager::getSingleton().setWindowExtents(w, h); 312 } 291 313 } -
code/trunk/src/orxonox/GraphicsEngine.h
r1056 r1214 42 42 #include <OgrePrerequisites.h> 43 43 #include <OgreLog.h> 44 44 #include <OgreRenderWindow.h> 45 #include <OgreWindowEventUtilities.h> 45 46 #include "core/OrxonoxClass.h" 46 47 … … 48 49 namespace orxonox { 49 50 50 /**51 /** 51 52 @brief Graphics engine manager class 52 */53 class _OrxonoxExport GraphicsEngine :public OrxonoxClass, public Ogre::LogListener54 {55 friend class ClassIdentifier<GraphicsEngine>;56 public:57 void setConfigPath(std::string path) { this->configPath_ = path; };58 void setConfigValues();59 void setup();60 bool load(std::string path);61 void loadRessourceLocations(std::string path);62 Ogre::SceneManager* getSceneManager();63 void initialise();64 void destroy();53 */ 54 class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public OrxonoxClass, public Ogre::LogListener 55 { 56 friend class ClassIdentifier<GraphicsEngine>; 57 public: 58 void setConfigPath(std::string path) { this->configPath_ = path; }; 59 void setConfigValues(); 60 void setup(); 61 bool load(std::string path); 62 void loadRessourceLocations(std::string path); 63 Ogre::SceneManager* getSceneManager(); 64 void initialise(); 65 void destroy(); 65 66 66 // several window properties67 Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }68 size_t getWindowHandle();69 int getWindowWidth() const;70 int getWindowHeight() const;67 // several window properties 68 Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; } 69 size_t getWindowHandle(); 70 int getWindowWidth() const; 71 int getWindowHeight() const; 71 72 72 static GraphicsEngine& getSingleton();73 static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }73 static GraphicsEngine& getSingleton(); 74 static GraphicsEngine* getSingletonPtr() { return &getSingleton(); } 74 75 75 private: 76 // don't mess with singletons 77 GraphicsEngine(); 78 ~GraphicsEngine(); 79 GraphicsEngine(GraphicsEngine&) { } 76 void windowMoved(Ogre::RenderWindow* rw); 77 void windowResized(Ogre::RenderWindow* rw); 78 void windowFocusChanged(Ogre::RenderWindow* rw); 80 79 81 //! Method called by the LogListener from Ogre 82 void messageLogged(const std::string&, Ogre::LogMessageLevel, 83 bool, const std::string&); 80 private: 81 // don't mess with singletons 82 GraphicsEngine(); 83 ~GraphicsEngine(); 84 GraphicsEngine(GraphicsEngine&) { } 84 85 85 Ogre::Root* root_; //!< Ogre's root 86 Ogre::SceneManager* scene_; //!< scene manager of the game 87 Ogre::RenderWindow* renderWindow_;//!< the current render window 88 //bool bOverwritePath_; //!< overwrites path 89 std::string configPath_; //!< path to config file 90 std::string dataPath_; //!< path to data file 91 std::string ogreLogfile_; //!< log file name for Ogre log messages 92 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 93 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 94 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 86 //! Method called by the LogListener from Ogre 87 void messageLogged(const std::string&, Ogre::LogMessageLevel, 88 bool, const std::string&); 95 89 96 }; 97 90 Ogre::Root* root_; //!< Ogre's root 91 Ogre::SceneManager* scene_; //!< scene manager of the game 92 Ogre::RenderWindow* renderWindow_;//!< the current render window 93 //bool bOverwritePath_; //!< overwrites path 94 std::string configPath_; //!< path to config file 95 std::string dataPath_; //!< path to data file 96 std::string ogreLogfile_; //!< log file name for Ogre log messages 97 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 98 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 99 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 100 }; 98 101 } 99 102 -
code/trunk/src/orxonox/Main.cc
r1056 r1214 74 74 int main(int argc, char **argv) 75 75 { 76 try {76 //try { 77 77 SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); 78 78 Orxonox* orx = Orxonox::getSingleton(); … … 86 86 orx->start(); 87 87 orx->destroySingleton(); 88 }88 /*} 89 89 catch (std::exception &ex) 90 90 { … … 92 92 std::cerr << ex.what() << "\n"; 93 93 return 1; 94 } 94 }*/ 95 95 96 96 return 0; -
code/trunk/src/orxonox/Orxonox.cc
r1206 r1214 76 76 #include "tools/Timer.h" 77 77 #include "hud/HUD.h" 78 #include "console/InGameConsole.h" 78 79 79 80 // FIXME: is this really file scope? … … 128 129 { 129 130 public: 130 static voidcalculate(const std::string& calculation)131 static float calculate(const std::string& calculation) 131 132 { 132 133 ExprParser expr(calculation); … … 140 141 std::cout << "Warning: Expression could not be parsed to the end! Remains: '" 141 142 << expr.getRemains() << "'" << std::endl; 143 return expr.getResult(); 142 144 } 143 145 else 146 { 144 147 std::cout << "Cannot calculate expression: Parse error" << std::endl; 148 return 0; 149 } 145 150 } 146 151 }; … … 420 425 InputBuffer* ib = new InputBuffer(); 421 426 InputManager::getSingleton().feedInputBuffer(ib); 427 /* 422 428 Testconsole* console = new Testconsole(ib); 423 429 ib->registerListener(console, &Testconsole::listen, true); 424 430 ib->registerListener(console, &Testconsole::execute, '\r', false); 425 ib->registerListener(console, &Testconsole::execute, '\n', false);426 431 ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true); 427 432 ib->registerListener(console, &Testconsole::clear, '§', true); 428 433 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 429 434 ib->registerListener(console, &Testconsole::exit, (char)0x1B, true); 435 */ 436 437 orxonoxConsole_ = new InGameConsole(ib); 438 ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true); 439 ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\r', false); 440 ib->registerListener(orxonoxConsole_, &InGameConsole::hintandcomplete, '\t', true); 441 ib->registerListener(orxonoxConsole_, &InGameConsole::clear, '§', true); 442 ib->registerListener(orxonoxConsole_, &InGameConsole::removeLast, '\b', true); 443 ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true); 430 444 431 445 // first check whether ogre root object has been created … … 477 491 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 478 492 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 493 orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_); 479 494 480 495 // don't forget to call _fireFrameStarted in ogre to make sure -
code/trunk/src/orxonox/Orxonox.h
r1089 r1214 105 105 // TODO: make this a config-value by creating a config class for orxonox 106 106 float frameSmoothingTime_; 107 InGameConsole* orxonoxConsole_; 107 108 HUD* orxonoxHUD_; 108 109 bool bAbort_; //!< aborts the render loop if true -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r1056 r1214 96 96 // hud 97 97 class HUD; 98 //console 99 class InGameConsole; 98 100 } 99 101 -
code/trunk/src/orxonox/console/InGameConsole.cc
r1145 r1214 68 68 void InGameConsole::listen(){ 69 69 if(!active) activate(); 70 print( this->ib_->get());70 print(convert2UTF(this->ib_->get())); 71 71 } 72 72 … … 84 84 newline(); 85 85 this->ib_->set(CommandExecutor::complete(this->ib_->get())); 86 print( this->ib_->get());86 print(convert2UTF(this->ib_->get())); 87 87 } 88 88 … … 109 109 scrollTimer = 0; 110 110 cursor = 0; 111 111 112 // create overlay and elements 112 113 om = &Ogre::OverlayManager::getSingleton(); … … 195 196 cursor += dt; 196 197 if(cursor >= 2*BLINK) cursor = 0; 197 print( this->ib_->get());198 print(convert2UTF(this->ib_->get())); 198 199 199 200 // this creates a flickering effect … … 243 244 @param s string to be printed 244 245 */ 245 void InGameConsole::print( std::string s){246 void InGameConsole::print(Ogre::UTFString s){ 246 247 if(cursor>BLINK) consoleOverlayTextAreas[0]->setCaption(">" + s); 247 248 else consoleOverlayTextAreas[0]->setCaption(">" + s + "_"); … … 252 253 */ 253 254 void InGameConsole::newline(){ 254 255 std::string line; 255 Ogre::UTFString line; 256 256 for(int i = LINES-1; i>=1; i--){ 257 257 line = consoleOverlayTextAreas[i-1]->getCaption(); … … 263 263 consoleOverlayTextAreas[0]->setCaption(">"); 264 264 } 265 266 Ogre::UTFString InGameConsole::convert2UTF(std::string s){ 267 Ogre::UTFString utf; 268 int i; 269 Ogre::UTFString::code_point cp; 270 for (i=0; i<(int)s.size(); ++i){ 271 cp = s[i]; 272 cp &= 0xFF; 273 utf.append(1, cp); 274 } 275 return utf; 276 } 265 277 } -
code/trunk/src/orxonox/console/InGameConsole.h
r1145 r1214 60 60 private: 61 61 void resize(); 62 void print( std::string s);62 void print(Ogre::UTFString s); 63 63 void newline(); 64 Ogre::UTFString convert2UTF(std::string s); 64 65 65 66 int windowW; -
code/trunk/src/util/String.cc
r1111 r1214 272 272 std::string removeSlashes(const std::string& str) 273 273 { 274 if (str.size() == 0)274 if (str.size() <= 1) 275 275 return str; 276 else if (str.size() == 1)277 {278 //TODO: decide whether we need the commented code279 /*if (str[0] != '\\')280 return "";281 else*/282 return str;283 }284 276 285 277 std::string output = "";
Note: See TracChangeset
for help on using the changeset viewer.