Changeset 953
- Timestamp:
- Mar 29, 2008, 3:38:10 PM (17 years ago)
- Location:
- code/branches/core2/src/orxonox/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/CommandExecutor.cc
r952 r953 45 45 ConsoleCommandShortcutGeneric(keyword3, createExecutor((FunctorStatic*)0, "bind", AccessLevel::User)); 46 46 47 48 /////////////////////// 49 // CommandEvaluation // 50 /////////////////////// 51 KeybindMode CommandEvaluation::getKeybindMode() 52 { 53 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 54 { 55 // if (this->shortcut_ != 0) 56 // return this->shortcut_->getKeybindMode(); 57 } 58 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 59 { 60 // if (this->function_ != 0) 61 // return this->function_->getKeybindMode(); 62 } 63 else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished) 64 { 65 // return KeybindMode::onPress; 66 } 67 else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished) 68 { 69 // return KeybindMode::onPress; 70 } 71 else 72 { 73 // return KeybindMode::onPress; 74 } 75 } 76 77 void CommandEvaluation::setAdditionalParameter(const std::string& param) 78 { 79 this->additionalParameter_ = param; 80 } 81 82 bool CommandEvaluation::isValid() const 83 { 84 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 85 { 86 return (this->shortcut_ != 0); 87 } 88 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 89 { 90 return ((this->functionclass_ != 0) && (this->function_ != 0)); 91 } 92 else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished) 93 { 94 return ((this->configvalueclass_ != 0) && (this->configvalue_ != 0)); 95 } 96 else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished) 97 { 98 return (this->key_ != 0); 99 } 100 else 101 { 102 return false; 103 } 104 } 105 106 107 ///////////////////// 108 // CommandExecutor // 109 ///////////////////// 47 110 CommandExecutor& CommandExecutor::getInstance() 48 111 { … … 111 174 break; 112 175 case CS_Shortcut_Params: 113 // not enough parameters 176 // not enough parameters but lets hope there are some additional parameters 177 if (evaluation.shortcut_ != 0) 178 return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_); 114 179 break; 115 180 case CS_Shortcut_Finished: 116 181 // call the shortcut 117 182 if (evaluation.shortcut_ != 0) 118 return evaluation.shortcut_->parse(tokens.subSet(1).join() );183 return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_); 119 184 break; 120 185 case CS_Function: 121 186 break; 122 187 case CS_Function_Params: 123 // not enough parameters 188 // not enough parameters but lets hope there are some additional parameters 189 if (evaluation.function_ != 0) 190 return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_); 124 191 break; 125 192 case CS_Function_Finished: 126 193 // call the shortcut 127 194 if (evaluation.function_ != 0) 128 return evaluation.function_->parse(tokens.subSet(2).join() );195 return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_); 129 196 break; 130 197 case CS_ConfigValueClass: … … 133 200 break; 134 201 case CS_ConfigValueType: 135 // not enough parameters 202 // not enough parameters but lets hope there are some additional parameters 203 if (evaluation.configvalue_ != 0) 204 return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 136 205 break; 137 206 case CS_ConfigValueFinished: 138 207 // set the config value 139 208 if (evaluation.configvalue_ != 0) 140 return evaluation.configvalue_->parseString(tokens.subSet(3).join() );209 return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 141 210 break; 142 211 case CS_KeybindKey: 143 212 break; 144 213 case CS_KeybindCommand: 145 // not enough parameters 214 // not enough parameters but lets hope there are some additional parameters 146 215 break; 147 216 case CS_KeybindFinished: … … 296 365 } 297 366 298 const CommandEvaluation&CommandExecutor::evaluate(const std::string& command)367 CommandEvaluation CommandExecutor::evaluate(const std::string& command) 299 368 { 300 369 CommandExecutor::parse(command, true); … … 308 377 309 378 if (bInitialize) 310 CommandExecutor::initialize( );379 CommandExecutor::initialize(command); 311 380 312 381 switch (CommandExecutor::getEvaluation().state_) … … 654 723 } 655 724 656 void CommandExecutor::initialize() 657 { 725 void CommandExecutor::initialize(const std::string& command) 726 { 727 CommandExecutor::getEvaluation().processedCommand_ = command; 728 CommandExecutor::getEvaluation().additionalParameter_ = ""; 729 658 730 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.clear(); 659 731 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.clear(); -
code/branches/core2/src/orxonox/core/CommandExecutor.h
r952 r953 59 59 }; 60 60 61 enum KeybindMode {}; // temporary 62 63 /////////////////////// 64 // CommandEvaluation // 65 /////////////////////// 61 66 class _CoreExport CommandEvaluation 62 67 { 63 68 public: 69 KeybindMode getKeybindMode(); 70 void setAdditionalParameter(const std::string& param); 71 bool isValid() const; 72 64 73 std::string processedCommand_; 65 74 SubString tokens_; 75 std::string additionalParameter_; 76 66 77 std::list<const std::string*> listOfPossibleFunctionClasses_; 67 78 std::list<const std::string*> listOfPossibleShortcuts_; … … 82 93 }; 83 94 95 ///////////////////// 96 // CommandExecutor // 97 ///////////////////// 84 98 class _CoreExport CommandExecutor 85 99 { … … 94 108 static std::string hint(const CommandEvaluation& evaluation); 95 109 96 static const CommandEvaluation&evaluate(const std::string& command);110 static CommandEvaluation evaluate(const std::string& command); 97 111 98 112 static bool addConsoleCommandShortcut(ExecutorStatic* executor); … … 123 137 124 138 static void parse(const std::string& command, bool bInitialize = true); 125 static void initialize( );139 static void initialize(const std::string& command); 126 140 127 141 static bool argumentsGiven(unsigned int num);
Note: See TracChangeset
for help on using the changeset viewer.