Changeset 955
- Timestamp:
- Mar 30, 2008, 12:12:18 AM (17 years ago)
- Location:
- code/branches/core2/src/orxonox
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/Orxonox.cc
r874 r955 86 86 #include "objects/test3.h" 87 87 88 #include "core/CommandExecutor.h" 89 #include "core/InputBuffer.h" 90 88 91 #include "Orxonox.h" 89 92 90 93 namespace orxonox 91 94 { 95 class Testlistener : public InputBufferListener 96 { 97 public: 98 Testlistener(InputBuffer* ib) : ib_(ib) {} 99 void listen() const 100 { 101 std::cout << "> -->" << this->ib_->get() << "<--" << std::endl; 102 } 103 void execute() const 104 { 105 std::cout << "### EXECUTE!" << std::endl; 106 CommandExecutor::execute(this->ib_->get()); 107 this->ib_->clear(); 108 } 109 void hintandcomplete() const 110 { 111 std::cout << "### HINT!" << std::endl; 112 std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl; 113 this->ib_->set(CommandExecutor::complete(this->ib_->get())); 114 } 115 void clear() const 116 { 117 std::cout << "### CLEAR!" << std::endl; 118 this->ib_->clear(); 119 } 120 void removeLast() const 121 { 122 std::cout << "### REMOVELAST!" << std::endl; 123 this->ib_->removeLast(); 124 } 125 126 private: 127 InputBuffer* ib_; 128 }; 129 92 130 // put this in a seperate Class or solve the problem in another fashion 93 131 class OrxListener : public Ogre::FrameListener … … 1146 1184 std::cout << "2\n"; 1147 1185 */ 1186 InputBuffer* ib = new InputBuffer(this->getKeyboard()); 1187 Testlistener* testlistener = new Testlistener(ib); 1188 ib->registerListener(testlistener, &Testlistener::listen, true); 1189 ib->registerListener(testlistener, &Testlistener::execute, '\r', false); 1190 ib->registerListener(testlistener, &Testlistener::hintandcomplete, '\t', true); 1191 ib->registerListener(testlistener, &Testlistener::clear, '§', true); 1192 ib->registerListener(testlistener, &Testlistener::removeLast, '\b', true); 1193 1148 1194 startRenderLoop(); 1149 1195 } … … 1364 1410 try 1365 1411 { 1366 keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));1412 keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, true)); 1367 1413 mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true)); 1368 1414 } -
code/branches/core2/src/orxonox/core/CMakeLists.txt
r947 r955 20 20 NamespaceNode.cc 21 21 CommandExecutor.cc 22 InputBuffer.cc 22 23 ) 23 24 -
code/branches/core2/src/orxonox/core/CommandExecutor.cc
r953 r955 49 49 // CommandEvaluation // 50 50 /////////////////////// 51 CommandEvaluation::CommandEvaluation() 52 { 53 this->processedCommand_ = ""; 54 this->additionalParameter_ = ""; 55 56 this->functionclass_ = 0; 57 this->configvalueclass_ = 0; 58 this->shortcut_ = 0; 59 this->function_ = 0; 60 this->configvalue_ = 0; 61 this->key_ = 0; 62 63 this->errorMessage_ = ""; 64 this->state_ = CS_Uninitialized; 65 } 66 51 67 KeybindMode CommandEvaluation::getKeybindMode() 52 68 { … … 156 172 bool CommandExecutor::execute(const std::string& command) 157 173 { 158 if ( CommandExecutor::getEvaluation().processedCommand_ != command)174 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 159 175 CommandExecutor::parse(command); 160 176 … … 169 185 switch (evaluation.state_) 170 186 { 187 case CS_Uninitialized: 188 break; 171 189 case CS_Empty: 172 190 break; … … 227 245 std::string CommandExecutor::complete(const std::string& command) 228 246 { 229 if ( CommandExecutor::getEvaluation().processedCommand_ != command)247 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 230 248 CommandExecutor::parse(command); 231 249 … … 246 264 switch (evaluation.state_) 247 265 { 266 case CS_Uninitialized: 267 break; 248 268 case CS_Empty: 249 return ( tokens.subSet(0, tokens.size() - 1).join() + " " +CommandExecutor::getCommonBegin(temp));269 return (CommandExecutor::getCommonBegin(temp)); 250 270 break; 251 271 case CS_FunctionClass_Or_Shortcut_Or_Keyword: … … 258 278 break; 259 279 case CS_Function: 260 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_)); 280 if (tokens.size() >= 1) 281 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_); 261 282 break; 262 283 case CS_Function_Params: … … 267 288 break; 268 289 case CS_ConfigValueClass: 269 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_)); 290 if (tokens.size() >= 1) 291 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_); 270 292 break; 271 293 case CS_ConfigValue: 272 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_)); 294 if (tokens.size() >= 2) 295 return tokens[0] + " " + tokens[1] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_); 273 296 break; 274 297 case CS_ConfigValueType: … … 279 302 break; 280 303 case CS_KeybindKey: 281 return (tokens.subSet(0, tokens.size() - 1).join() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_)); 304 if (tokens.size() >= 1) 305 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_); 282 306 break; 283 307 case CS_KeybindCommand: … … 296 320 std::string CommandExecutor::hint(const std::string& command) 297 321 { 298 if ( CommandExecutor::getEvaluation().processedCommand_ != command)322 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 299 323 CommandExecutor::parse(command); 300 324 … … 308 332 switch (evaluation.state_) 309 333 { 334 case CS_Uninitialized: 335 break; 310 336 case CS_Empty: 311 337 return (CommandExecutor::dump(evaluation.listOfPossibleShortcuts_) + "\n" + CommandExecutor::dump(evaluation.listOfPossibleFunctionClasses_)); … … 358 384 break; 359 385 case CS_Error: 360 return "Error";386 return CommandExecutor::getEvaluation().errorMessage_; 361 387 break; 362 388 } … … 381 407 switch (CommandExecutor::getEvaluation().state_) 382 408 { 409 case CS_Uninitialized: 410 // Impossible 411 break; 383 412 case CS_Empty: 384 413 if (CommandExecutor::argumentsGiven() == 0) … … 635 664 { 636 665 CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_); 637 if (CommandExecutor::getEvaluation().configvalue class_ != 0)666 if (CommandExecutor::getEvaluation().configvalue_ != 0) 638 667 { 639 668 // There is a perfect match: Add a whitespace and continue parsing … … 791 820 if ((*it).second->hasConsoleCommands()) 792 821 { 793 if ((*it).first.find(getLowercase(fragment)) == 0 )822 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 794 823 { 795 824 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.push_back(&(*it).first); … … 805 834 for (std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it) 806 835 { 807 if ((*it).first.find(getLowercase(fragment)) == 0 )836 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 808 837 { 809 838 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.push_back(&(*it).first); … … 818 847 for (std::map<std::string, ExecutorStatic*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it) 819 848 { 820 if ((*it).first.find(getLowercase(fragment)) == 0 )849 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 821 850 { 822 851 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(&(*it).first); … … 833 862 if ((*it).second->hasConfigValues()) 834 863 { 835 if ((*it).first.find(getLowercase(fragment)) == 0 )864 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 836 865 { 837 866 CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.push_back(&(*it).first); … … 847 876 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMapBegin(); it != identifier->getLowercaseConfigValueMapEnd(); ++it) 848 877 { 849 if ((*it).first.find(getLowercase(fragment)) == 0 )878 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 850 879 { 851 880 CommandExecutor::getEvaluation().listOfPossibleConfigValues_.push_back(&(*it).first); … … 908 937 std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->getLowercaseConfigValueMap().find(getLowercase(name)); 909 938 if (it != identifier->getLowercaseConfigValueMapEnd()) 939 { 910 940 return (*it).second; 941 } 911 942 912 943 return 0; -
code/branches/core2/src/orxonox/core/CommandExecutor.h
r953 r955 34 34 35 35 #include "util/SubString.h" 36 #include "util/MultiTypeMath.h" 36 37 #include "CorePrereqs.h" 37 38 … … 42 43 enum CommandState 43 44 { 45 CS_Uninitialized, 44 46 CS_Empty, 45 47 CS_FunctionClass_Or_Shortcut_Or_Keyword, … … 67 69 { 68 70 public: 71 CommandEvaluation(); 72 69 73 KeybindMode getKeybindMode(); 70 74 void setAdditionalParameter(const std::string& param); -
code/branches/core2/src/orxonox/core/Functor.h
r947 r955 52 52 #define CreateTypeToStringTemplate(type) \ 53 53 template <> \ 54 inline std::string typeToString<type>() { return #type; } 54 inline std::string typeToString<type>() { return #type; } \ 55 template <> \ 56 inline std::string typeToString<type&>() { return #type; } \ 57 template <> \ 58 inline std::string typeToString<const type>() { return #type; } \ 59 template <> \ 60 inline std::string typeToString<const type&>() { return #type; } 55 61 56 62 CreateTypeToStringTemplate(int); … … 66 72 CreateTypeToStringTemplate(long double); 67 73 CreateTypeToStringTemplate(bool); 68 CreateTypeToStringTemplate(std::string); 69 CreateTypeToStringTemplate(orxonox::Vector2); 70 CreateTypeToStringTemplate(orxonox::Vector3); 71 CreateTypeToStringTemplate(orxonox::Quaternion); 72 CreateTypeToStringTemplate(orxonox::ColourValue); 73 CreateTypeToStringTemplate(orxonox::Radian); 74 CreateTypeToStringTemplate(orxonox::Degree); 75 74 CreateTypeToStringTemplate(Vector2); 75 CreateTypeToStringTemplate(Vector3); 76 CreateTypeToStringTemplate(Quaternion); 77 CreateTypeToStringTemplate(ColourValue); 78 CreateTypeToStringTemplate(Radian); 79 CreateTypeToStringTemplate(Degree); 80 81 template <> \ 82 inline std::string typeToString<std::string>() { return "string"; } \ 83 template <> \ 84 inline std::string typeToString<std::string&>() { return "string"; } \ 85 template <> \ 86 inline std::string typeToString<const std::string>() { return "string"; } \ 87 template <> \ 88 inline std::string typeToString<const std::string&>() { return "string"; } 76 89 77 90 class _CoreExport Functor … … 88 101 inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; } 89 102 90 std::string getTypenameParam(unsigned int param) const { return (param > 0 && param <= 5) ? this->typeParam_[param-1] : ""; }103 std::string getTypenameParam(unsigned int param) const { return (param >= 0 && param < 5) ? this->typeParam_[param] : ""; } 91 104 std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; } 92 105 -
code/branches/core2/src/orxonox/core/OutputHandler.h
r949 r955 61 61 /** @brief Puts some text on the outstream. @param text The text */ 62 62 static inline void log(const std::string& text) 63 { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text ); }63 { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); } 64 64 65 65 /** @brief Returns a reference to the logfile. @return The logfile */ -
code/branches/core2/src/orxonox/objects/SpaceShip.cc
r947 r955 52 52 { 53 53 ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false); 54 ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false); 55 ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false); 56 ConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl", AccessLevel::Debug), false); 54 57 55 58 CreateFactory(SpaceShip);
Note: See TracChangeset
for help on using the changeset viewer.