- Timestamp:
- Aug 25, 2010, 5:35:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
r7214 r7215 128 128 { 129 129 this->bActive_ = true; 130 this->bHidden_ = false; 131 this->accessLevel_ = AccessLevel::All; 132 130 133 this->baseName_ = name; 131 134 this->baseExecutor_ = executor; 135 136 this->argumentCompleter_[0] = 0; 137 this->argumentCompleter_[1] = 0; 138 this->argumentCompleter_[2] = 0; 139 this->argumentCompleter_[3] = 0; 140 this->argumentCompleter_[4] = 0; 141 142 this->keybindMode_ = KeybindMode::OnPress; 143 this->inputConfiguredParam_ = -1; 132 144 133 145 if (bInitialized) … … 246 258 command.executor_ = this->getExecutor(); 247 259 if (command.executor_) 248 command.functor_ = this->get Functor();260 command.functor_ = this->getExecutor()->getFunctor(); 249 261 250 262 if (this->setFunction(executor, bForce)) … … 257 269 command.executor_ = this->getExecutor(); 258 270 if (command.executor_) 259 command.functor_ = this->get Functor();271 command.functor_ = this->getExecutor()->getFunctor(); 260 272 261 273 if (this->setFunction(functor, bForce)) … … 288 300 { 289 301 return this->executor_; 290 }291 292 const FunctorPtr& _ConsoleCommand::getFunctor() const293 {294 return this->executor_->getFunctor();295 302 } 296 303 … … 339 346 } 340 347 348 _ConsoleCommand& _ConsoleCommand::defaultValues(const MultiType& param1) 349 { 350 if (this->executor_) 351 this->executor_->setDefaultValues(param1); 352 else 353 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 354 355 return *this; 356 } 357 358 _ConsoleCommand& _ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2) 359 { 360 if (this->executor_) 361 this->executor_->setDefaultValues(param1, param2); 362 else 363 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 364 365 return *this; 366 } 367 368 _ConsoleCommand& _ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 369 { 370 if (this->executor_) 371 this->executor_->setDefaultValues(param1, param2, param3); 372 else 373 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 374 375 return *this; 376 } 377 378 _ConsoleCommand& _ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 379 { 380 if (this->executor_) 381 this->executor_->setDefaultValues(param1, param2, param3, param4); 382 else 383 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 384 385 return *this; 386 } 387 388 _ConsoleCommand& _ConsoleCommand::defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 389 { 390 if (this->executor_) 391 this->executor_->setDefaultValues(param1, param2, param3, param4, param5); 392 else 393 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 394 395 return *this; 396 } 397 398 _ConsoleCommand& _ConsoleCommand::defaultValue(unsigned int index, const MultiType& param) 399 { 400 if (this->executor_) 401 this->executor_->setDefaultValue(index, param); 402 else 403 COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl; 404 405 return *this; 406 } 407 408 _ConsoleCommand& _ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer) 409 { 410 if (param < 5) 411 this->argumentCompleter_[param] = completer; 412 else 413 COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl; 414 415 return *this; 416 } 417 418 ArgumentCompleter* _ConsoleCommand::getArgumentCompleter(unsigned int param) const 419 { 420 if (param < 5) 421 return this->argumentCompleter_[param]; 422 else 423 return 0; 424 } 425 426 void _ConsoleCommand::createArgumentCompletionList(unsigned int param, const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5) 427 { 428 if (param < 5 && this->argumentCompleter_[param]) 429 this->argumentList_ = (*this->argumentCompleter_[param])(param1, param2, param3, param4, param5); 430 else 431 this->argumentList_.clear(); 432 } 433 434 _ConsoleCommand& _ConsoleCommand::description(const std::string& description) 435 { 436 this->description_ = std::string("ConsoleCommandDescription::" + this->baseName_ + "::function"); 437 AddLanguageEntry(this->description_, description); 438 return *this; 439 } 440 441 const std::string& _ConsoleCommand::getDescription() const 442 { 443 return GetLocalisation_noerror(this->description_); 444 } 445 446 _ConsoleCommand& _ConsoleCommand::descriptionParam(unsigned int param, const std::string& description) 447 { 448 if (param < MAX_FUNCTOR_ARGUMENTS) 449 { 450 this->descriptionParam_[param] = std::string("ConsoleCommandDescription::" + this->baseName_ + "::param" + multi_cast<std::string>(param)); 451 AddLanguageEntry(this->descriptionParam_[param], description); 452 } 453 return *this; 454 } 455 456 const std::string& _ConsoleCommand::getDescriptionParam(unsigned int param) const 457 { 458 if (param < MAX_FUNCTOR_ARGUMENTS) 459 return GetLocalisation_noerror(this->descriptionParam_[param]); 460 461 return this->descriptionParam_[0]; 462 } 463 464 _ConsoleCommand& _ConsoleCommand::descriptionReturnvalue(const std::string& description) 465 { 466 this->descriptionReturnvalue_ = std::string("ConsoleCommandDescription::" + this->baseName_ + "::returnvalue"); 467 AddLanguageEntry(this->descriptionReturnvalue_, description); 468 return *this; 469 } 470 471 const std::string& _ConsoleCommand::getDescriptionReturnvalue(int param) const 472 { 473 return GetLocalisation_noerror(this->descriptionReturnvalue_); 474 } 475 341 476 /* static */ const _ConsoleCommand* _ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError) 342 477 {
Note: See TracChangeset
for help on using the changeset viewer.