Changeset 1502 for code/trunk/src/core/ConfigFileManager.cc
- Timestamp:
- Jun 1, 2008, 3:54:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/ConfigFileManager.cc
r1056 r1502 38 38 namespace orxonox 39 39 { 40 ConsoleCommandShortcutExtern(reloadConfig, AccessLevel::None); 41 ConsoleCommandShortcutExtern(cleanConfig, AccessLevel::None); 42 ConsoleCommandShortcutExtern(loadSettings, AccessLevel::None); 43 ConsoleCommandShortcutExtern(loadKeybindings, AccessLevel::None); 40 SetConsoleCommandShortcutExtern(config).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue()); 41 SetConsoleCommandShortcutExtern(tconfig).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue()); 42 SetConsoleCommandShortcutExtern(reloadConfig); 43 SetConsoleCommandShortcutExtern(cleanConfig); 44 SetConsoleCommandShortcutExtern(loadSettings).setArgumentCompleter(0, autocompletion::files()); 45 SetConsoleCommandShortcutExtern(loadKeybindings).setArgumentCompleter(0, autocompletion::files()); 46 47 bool config(const std::string& classname, const std::string& varname, const std::string& value) 48 { 49 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname)); 50 if (identifier != Identifier::getLowercaseIdentifierMapEnd()) 51 { 52 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); 53 if (variable != (*identifier).second->getLowercaseConfigValueMapEnd()) 54 return (*variable).second->set(value); 55 } 56 return false; 57 } 58 59 bool tconfig(const std::string& classname, const std::string& varname, const std::string& value) 60 { 61 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname)); 62 if (identifier != Identifier::getLowercaseIdentifierMapEnd()) 63 { 64 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); 65 if (variable != (*identifier).second->getLowercaseConfigValueMapEnd()) 66 return (*variable).second->tset(value); 67 } 68 return false; 69 } 44 70 45 71 void reloadConfig() … … 336 362 337 363 COUT(4) << "Saved config file \"" << this->filename_ << "\"." << std::endl; 364 } 365 366 void ConfigFile::save(const std::string& filename) 367 { 368 std::string temp = this->filename_; 369 this->filename_ = filename; 370 this->save(); 371 this->filename_ = temp; 338 372 } 339 373 … … 473 507 } 474 508 509 void ConfigFileManager::save(ConfigFileType type, const std::string& filename) 510 { 511 this->getFile(type)->save(filename); 512 } 513 475 514 void ConfigFileManager::clean(ConfigFileType type, bool bCleanComments) 476 515 {
Note: See TracChangeset
for help on using the changeset viewer.