Changeset 955 for code/branches/core2/src/orxonox/core/CommandExecutor.cc
- Timestamp:
- Mar 30, 2008, 12:12:18 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.