Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6536


Ignore:
Timestamp:
Mar 16, 2010, 11:22:36 AM (14 years ago)
Author:
rgrieder
Message:

Merged revisions 6430-6440 from the gamestate branch to the trunk.
This adds keybindings merging functionality.

(from log of r6437)
When running development builds, the keybinder will merge the local file and the one from the data folder.
Catch: if you want to remove a binding, you'll have to write "NoBinding" (not case sensitive) to override the default command

The keybind command already does that for you though.

Location:
code/trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/lua/LuaStateInit.lua

    r6417 r6536  
    5858  orxonox.CommandExecutor:execute(command)
    5959end
     60
     61-- Convenience function for config values
     62orxonox.getConfig = function(section, entry)
     63  return orxonox.SettingsConfigFile:getInstance():getConfig(section, entry)
     64end
     65orxonox.config = function(section, entry, value)
     66  return orxonox.SettingsConfigFile:getInstance():config(section, entry, value)
     67end
     68orxonox.tconfig = function(section, entry, value)
     69  return orxonox.SettingsConfigFile:getInstance():tconfig(section, entry, value)
     70end
  • code/trunk/src/libraries/core/ArgumentCompletionFunctions.cc

    r6417 r6536  
    3636#include "util/StringUtils.h"
    3737#include "Identifier.h"
     38#include "ConfigFileManager.h"
    3839#include "ConfigValueContainer.h"
    3940#include "TclThreadManager.h"
     
    9697        }
    9798
    98         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)()
     99        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingssections)()
    99100        {
    100             ArgumentCompletionList classlist;
     101            ArgumentCompletionList sectionList;
    101102
    102             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    103                 if (it->second->hasConfigValues())
    104                     classlist.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
     103            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
     104            for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
     105                sectionList.push_back(ArgumentCompletionListElement(*it, getLowercase(*it)));
    105106
    106             return classlist;
     107            return sectionList;
    107108        }
    108109
    109         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
     110        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsentries)(const std::string& fragment, const std::string& section)
    110111        {
    111             ArgumentCompletionList configvalues;
    112             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     112            ArgumentCompletionList entryList;
     113            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
     114            const std::string& sectionLC = getLowercase(section);
    113115
    114             if (identifier != Identifier::getLowercaseStringIdentifierMapEnd() && identifier->second->hasConfigValues())
     116            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
     117            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
     118                entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
     119
     120            return entryList;
     121        }
     122
     123        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section)
     124        {
     125            ArgumentCompletionList oldValue;
     126            SettingsConfigFile& settings = SettingsConfigFile::getInstance();
     127            const std::string& sectionLC = getLowercase(section);
     128            const std::string& entryLC = getLowercase(entry);
     129
     130            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
     131            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
    115132            {
    116                 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = identifier->second->getConfigValueMapBegin(); it != identifier->second->getConfigValueMapEnd(); ++it)
    117                     configvalues.push_back(ArgumentCompletionListElement(it->first, getLowercase(it->first)));
     133                if (it->second.first == entryLC)
     134                {
     135                    const std::string& valuestring = it->second.second->toString();
     136                    oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
     137                }
    118138            }
    119139
    120             return configvalues;
    121         }
    122 
    123         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname)
    124         {
    125             ArgumentCompletionList oldvalue;
    126             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
    127             if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    128             {
    129                 std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
    130                 if (variable != identifier->second->getLowercaseConfigValueMapEnd())
    131                 {
    132                     const std::string& valuestring = variable->second->toString();
    133                     oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
    134                 }
    135             }
    136             return oldvalue;
     140            return oldValue;
    137141        }
    138142
  • code/trunk/src/libraries/core/ArgumentCompletionFunctions.h

    r5781 r6536  
    5454        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
    5555        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
    56         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalueclasses)();
    57         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& fragment, const std::string& classname);
    58         ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname);
     56        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingssections)();
     57        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsentries)(const std::string& fragment, const std::string& section);
     58        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(settingsvalue)(const std::string& fragment, const std::string& entry, const std::string& section);
    5959        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)();
    6060    }
  • code/trunk/src/libraries/core/ConfigFileManager.cc

    r6425 r6536  
    3333#include "util/Convert.h"
    3434#include "util/Math.h"
    35 #include "util/StringUtils.h"
    3635#include "ConsoleCommand.h"
    3736#include "ConfigValueContainer.h"
     
    4039namespace orxonox
    4140{
    42     SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
    43     SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
    44     SetConsoleCommandShortcutExtern(reloadConfig);
    45     SetConsoleCommandShortcutExtern(cleanConfig);
    46     SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
    47 
    48     bool config(const std::string& classname, const std::string& varname, const std::string& value)
    49     {
    50         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
    51         if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    52         {
    53             std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
    54             if (variable != identifier->second->getLowercaseConfigValueMapEnd())
    55                 return variable->second->set(value);
    56         }
    57         return false;
    58     }
    59 
    60     const std::string& getConfig(const std::string& classname, const std::string& varname)
    61     {
    62         return ConfigFileManager::getInstance().getValue(ConfigFileType::Settings, classname, varname, "", true);
    63     }
    64 
    65     bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
    66     {
    67         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
    68         if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    69         {
    70             std::map<std::string, ConfigValueContainer*>::const_iterator variable = identifier->second->getLowercaseConfigValueMap().find(getLowercase(varname));
    71             if (variable != identifier->second->getLowercaseConfigValueMapEnd())
    72                 return variable->second->tset(value);
    73         }
    74         return false;
    75     }
    76 
    77     void reloadConfig()
    78     {
    79         ConfigFileManager::getInstance().load();
    80     }
    81 
    82     void cleanConfig()
    83     {
    84         ConfigFileManager::getInstance().clean(false);
    85     }
    86 
    87     void loadSettings(const std::string& filename)
    88     {
    89         ConfigFileManager::getInstance().setFilename(ConfigFileType::Settings, filename);
    90     }
    91 
    9241    //////////////////////////
    9342    // ConfigFileEntryValue //
     
    10150        // Assemble the entry line
    10251        this->fileEntry_ = this->getKeyString() + " = ";
    103         if (this->bString_)
     52        if (this->bString_ && !this->value_.empty())
    10453            this->fileEntry_ += '"' + addSlashes(this->value_) + '"';
    10554        else
     
    14594    }
    14695
    147     unsigned int ConfigFileSection::getVectorSize(const std::string& name)
     96    unsigned int ConfigFileSection::getVectorSize(const std::string& name) const
    14897    {
    14998        unsigned int size = 0;
     
    166115    }
    167116
    168     std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString)
     117    ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name) const
     118    {
     119        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     120        {
     121            if ((*it)->getName() == name)
     122                return *it;
     123        }
     124        return NULL;
     125    }
     126
     127    ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name, unsigned int index) const
     128    {
     129        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     130        {
     131            if (((*it)->getName() == name) && ((*it)->getIndex() == index))
     132                return *it;
     133        }
     134        return NULL;
     135    }
     136
     137    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString)
    169138    {
    170139        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     
    179148        this->bUpdated_ = true;
    180149
    181         return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryValue(name, fallback, bString)));
    182     }
    183 
    184     std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     150        return this->entries_.insert(this->entries_.end(), new ConfigFileEntryValue(name, fallback, bString));
     151    }
     152
     153    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    185154    {
    186155        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     
    196165
    197166        if (index == 0)
    198             return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
     167            return this->entries_.insert(this->entries_.end(), new ConfigFileEntryVectorValue(name, index, fallback, bString));
    199168        else
    200             return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
     169            return this->entries_.insert(++this->getOrCreateEntryIterator(name, index - 1, "", bString), new ConfigFileEntryVectorValue(name, index, fallback, bString));
    201170    }
    202171
     
    205174    // ConfigFile //
    206175    ////////////////
     176
     177    const char* ConfigFile::DEFAULT_CONFIG_FOLDER = "defaultConfig";
     178
     179    ConfigFile::ConfigFile(const std::string& filename, bool bCopyFallbackFile)
     180        : filename_(filename)
     181        , bCopyFallbackFile_(bCopyFallbackFile)
     182        , bUpdated_(false)
     183    {
     184    }
     185
    207186    ConfigFile::~ConfigFile()
    208187    {
     
    210189    }
    211190
    212     void ConfigFile::load(bool bCreateIfNotExisting)
     191    void ConfigFile::load()
    213192    {
    214193        // Be sure we start from new in the memory
    215194        this->clear();
    216195
    217         // Get default file if necessary and available
    218         boost::filesystem::path filepath(PathConfig::getConfigPath() / this->filename_);
    219         if (!boost::filesystem::exists(filepath))
    220         {
    221             // Try to get default one from the data folder
    222             boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / "defaultConfig" / this->filename_);
    223             if (boost::filesystem::exists(defaultFilepath))
    224             {
    225                 COUT(3) << "Copied " << this->filename_ << " from the defaultConfig folder." << std::endl;
    226                 boost::filesystem::copy_file(defaultFilepath, filepath);
     196        boost::filesystem::path filepath(this->filename_);
     197        if (!filepath.is_complete())
     198        {
     199            filepath = PathConfig::getConfigPath() / filepath;
     200            if (this->bCopyFallbackFile_)
     201            {
     202                // Look for default file in the data folder
     203                if (!boost::filesystem::exists(filepath))
     204                {
     205                    boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
     206                    if (boost::filesystem::exists(defaultFilepath))
     207                    {
     208                        // Try to copy default file from the data folder
     209                        try
     210                        {
     211                            boost::filesystem::copy_file(defaultFilepath, filepath);
     212                            COUT(3) << "Copied " << this->filename_ << " from the default config folder." << std::endl;
     213                        }
     214                        catch (const boost::filesystem::filesystem_error& ex)
     215                        { COUT(1) << "Error in ConfigFile: " << ex.what() << std::endl; }
     216                    }
     217                }
    227218            }
    228219        }
     
    300291                                {
    301292                                    // New array
    302                                     std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
     293                                    std::list<ConfigFileEntry*>::iterator it = newsection->getOrCreateEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
    303294                                    (*it)->setValue(value);
    304295                                    (*it)->setComment(comment);
     
    319310            COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
    320311
    321             // Save the file in case something changed (like stripped whitespaces)
    322             this->save();
    323 
    324             // Update all ConfigValueContainers
    325             this->updateConfigValues();
     312            // DO NOT save the file --> we can open supposedly read only config files
    326313        } // end file.is_open()
    327314    }
     
    329316    void ConfigFile::save() const
    330317    {
     318        this->saveAs(this->filename_);
     319    }
     320
     321    void ConfigFile::saveAs(const std::string& filename) const
     322    {
     323        boost::filesystem::path filepath(filename);
     324        if (!filepath.is_complete())
     325            filepath = PathConfig::getConfigPath() / filename;
    331326        std::ofstream file;
    332         file.open((PathConfig::getConfigPathString() + filename_).c_str(), std::fstream::out);
     327        file.open(filepath.string().c_str(), std::fstream::out);
    333328        file.setf(std::ios::fixed, std::ios::floatfield);
    334329        file.precision(6);
     
    336331        if (!file.is_open())
    337332        {
    338             COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
    339             COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
     333            COUT(1) << "Error: Couldn't open config-file \"" << filename << "\"." << std::endl;
    340334            return;
    341335        }
     
    346340
    347341            for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
    348             {
    349342                file << (*it_entries)->getFileEntry() << std::endl;
    350             }
    351343
    352344            file << std::endl;
     
    355347        file.close();
    356348
    357         COUT(4) << "Saved config file \"" << this->filename_ << "\"." << std::endl;
    358     }
    359 
    360     void ConfigFile::saveAs(const std::string& filename)
    361     {
    362         std::string temp = this->filename_;
    363         this->filename_ = filename;
    364         this->save();
    365         this->filename_ = temp;
    366     }
    367 
    368     void ConfigFile::clean(bool bCleanComments)
    369     {
    370         for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
    371         {
    372             std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
    373             if (it2 != Identifier::getStringIdentifierMapEnd() && it2->second->hasConfigValues())
    374             {
    375                 // The section exists, delete comment
    376                 if (bCleanComments)
    377                     (*it1)->setComment("");
    378                 for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
    379                 {
    380                     std::map<std::string, ConfigValueContainer*>::const_iterator it4 = it2->second->getConfigValueMap().find((*it3)->getName());
    381                     if (it4 != it2->second->getConfigValueMapEnd())
    382                     {
    383                         // The config-value exists, delete comment
    384                         if (bCleanComments)
    385                             (*it3)->setComment("");
    386                         ++it3;
    387                     }
    388                     else
    389                     {
    390                         // The config-value doesn't exist
    391                         delete (*it3);
    392                         (*it1)->entries_.erase(it3++);
    393                     }
    394                 }
    395                 ++it1;
    396             }
    397             else
    398             {
    399                 // The section doesn't exist
    400                 delete (*it1);
    401                 this->sections_.erase(it1++);
    402             }
    403         }
    404 
    405         // Save the file
    406         this->save();
     349        COUT(4) << "Saved config file \"" << filename << "\"." << std::endl;
    407350    }
    408351
     
    414357    }
    415358
    416     ConfigFileSection* ConfigFile::getSection(const std::string& section)
     359    const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
     360    {
     361        const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, fallback, bString);
     362        this->saveIfUpdated();
     363        return output;
     364    }
     365
     366    const std::string& ConfigFile::getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     367    {
     368        const std::string& output = this->getOrCreateSection(section)->getOrCreateValue(name, index, fallback, bString);
     369        this->saveIfUpdated();
     370        return output;
     371    }
     372
     373    void ConfigFile::deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex)
     374    {
     375        if (ConfigFileSection* sectionPtr = this->getSection(section))
     376        {
     377            sectionPtr->deleteVectorEntries(name, startindex);
     378            this->save();
     379        }
     380    }
     381
     382    ConfigFileSection* ConfigFile::getSection(const std::string& section) const
     383    {
     384        for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
     385            if ((*it)->getName() == section)
     386                return (*it);
     387        return NULL;
     388    }
     389
     390    ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section)
    417391    {
    418392        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
     
    445419    }
    446420
    447     void ConfigFile::updateConfigValues()
    448     {
    449         if (this->type_ == ConfigFileType::Settings)
    450         {
    451             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    452             {
    453                 if (it->second->hasConfigValues())
     421
     422    ////////////////////////
     423    // SettingsConfigFile //
     424    ////////////////////////
     425
     426    SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;
     427
     428    SettingsConfigFile::SettingsConfigFile(const std::string& filename)
     429        : ConfigFile(filename)
     430    {
     431        ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings");
     432        CommandExecutor::addConsoleCommandShortcut(command);
     433        command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile");
     434        CommandExecutor::addConsoleCommandShortcut(command);
     435        command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config");
     436        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
     437        command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig");
     438        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
     439        command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig");
     440        CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries());
     441    }
     442
     443    SettingsConfigFile::~SettingsConfigFile()
     444    {
     445    }
     446
     447    void SettingsConfigFile::load()
     448    {
     449        ConfigFile::load();
     450        this->updateConfigValues();
     451    }
     452
     453    void SettingsConfigFile::setFilename(const std::string& filename)
     454    {
     455        ConfigFileManager::getInstance().setFilename(ConfigFileType::Settings, filename);
     456    }
     457
     458    void SettingsConfigFile::addConfigValueContainer(ConfigValueContainer* container)
     459    {
     460        if (container == NULL)
     461            return;
     462        std::pair<std::string, ConfigValueContainer*> second(getLowercase(container->getName()), container);
     463        this->containers_.insert(std::make_pair(getLowercase(container->getSectionName()), second));
     464        this->sectionNames_.insert(container->getSectionName());
     465    }
     466
     467    void SettingsConfigFile::removeConfigValueContainer(ConfigValueContainer* container)
     468    {
     469        if (container == NULL)
     470            return;
     471        const std::string& sectionLC = getLowercase(container->getSectionName());
     472        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
     473        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
     474        {
     475            if (it->second.second == container)
     476            {
     477                // Remove entry from section name set this was the last container for that section
     478                if (upper == this->containers_.lower_bound(sectionLC))
     479                    this->sectionNames_.erase(container->getSectionName());
     480                this->containers_.erase(it);
     481                break;
     482            }
     483        }
     484    }
     485
     486    void SettingsConfigFile::updateConfigValues()
     487    {
     488        for (ContainerMap::const_iterator it = this->containers_.begin(); it != this->containers_.end(); ++it)
     489        {
     490            it->second.second->update();
     491            it->second.second->getIdentifier()->updateConfigValues();
     492        }
     493    }
     494
     495    void SettingsConfigFile::clean(bool bCleanComments)
     496    {
     497        for (std::list<ConfigFileSection*>::iterator itSection = this->sections_.begin(); itSection != this->sections_.end(); )
     498        {
     499            const std::string& sectionLC = getLowercase((*itSection)->getName());
     500            ContainerMap::const_iterator lower = this->containers_.lower_bound(sectionLC);
     501            ContainerMap::const_iterator upper = this->containers_.upper_bound(sectionLC);
     502            if (lower != upper)
     503            {
     504                // The section exists, delete comment
     505                if (bCleanComments)
     506                    (*itSection)->setComment("");
     507                for (std::list<ConfigFileEntry*>::iterator itEntry = (*itSection)->entries_.begin(); itEntry != (*itSection)->entries_.end(); )
    454508                {
    455                     for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = it->second->getConfigValueMapBegin(); it2 != it->second->getConfigValueMapEnd(); ++it2)
    456                         it2->second->update();
    457 
    458                     it->second->updateConfigValues();
     509                    const std::string& entryLC = getLowercase((*itEntry)->getName());
     510                    bool bFound = false;
     511                    for (ContainerMap::const_iterator itContainer = lower; itContainer != upper; ++itContainer)
     512                    {
     513                        if (itContainer->second.first == entryLC)
     514                        {
     515                            // The config-value exists, delete comment
     516                            if (bCleanComments)
     517                                (*itEntry)->setComment("");
     518                            ++itEntry;
     519                            bFound = true;
     520                            break;
     521                        }
     522                    }
     523                    if (!bFound)
     524                    {
     525                        // The config-value doesn't exist
     526                        delete (*itEntry);
     527                        (*itSection)->entries_.erase(itEntry++);
     528                    }
    459529                }
    460             }
    461         }
     530                ++itSection;
     531            }
     532            else
     533            {
     534                // The section doesn't exist
     535                delete (*itSection);
     536                this->sections_.erase(itSection++);
     537            }
     538        }
     539
     540        // Save the file
     541        this->save();
     542    }
     543
     544    bool SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value)
     545    {
     546        return this->configImpl(section, entry, value, &ConfigValueContainer::set);
     547    }
     548
     549    bool SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value)
     550    {
     551        return this->configImpl(section, entry, value, &ConfigValueContainer::tset);
     552    }
     553
     554    bool SettingsConfigFile::configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&))
     555    {
     556        const std::string& sectionLC = getLowercase(section);
     557        const std::string& entryLC = getLowercase(entry);
     558        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
     559        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
     560        {
     561            // Note: Config value vectors cannot be supported
     562            if (it->second.first == entryLC && !it->second.second->isVector())
     563            {
     564                return (it->second.second->*function)(value);
     565            }
     566        }
     567        return false;
     568    }
     569
     570    std::string SettingsConfigFile::getConfig(const std::string& section, const std::string& entry)
     571    {
     572        const std::string& sectionLC = getLowercase(section);
     573        const std::string& entryLC = getLowercase(entry);
     574        ContainerMap::iterator upper = this->containers_.upper_bound(sectionLC);
     575        for (ContainerMap::iterator it = this->containers_.lower_bound(sectionLC); it != upper; ++it)
     576        {
     577            // Note: Config value vectors cannot be supported
     578            if (it->second.first == entryLC && ! it->second.second->isVector())
     579            {
     580                std::string value;
     581                it->second.second->getValue<std::string, OrxonoxClass>(&value, NULL);
     582                return value;
     583            }
     584        }
     585        return "";
    462586    }
    463587
     
    469593    ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;
    470594
    471     std::string ConfigFileManager::DEFAULT_CONFIG_FILE = "default.ini";
    472 
    473595    ConfigFileManager::ConfigFileManager()
    474          : mininmalFreeType_(ConfigFileType::numberOfReservedTypes)
    475     {
     596    {
     597        this->configFiles_.assign(NULL);
    476598    }
    477599
    478600    ConfigFileManager::~ConfigFileManager()
    479601    {
    480         for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); )
    481             delete (it++)->second;
    482     }
    483 
    484     void ConfigFileManager::setFilename(ConfigFileType type, const std::string& filename)
    485     {
    486         std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
    487         if (it != this->configFiles_.end())
    488         {
    489             assert(it->second);
    490             delete it->second;
    491         }
    492         this->configFiles_[type] = new ConfigFile(filename, type);
    493         this->load(type);
    494     }
    495 
    496     void ConfigFileManager::load()
    497     {
    498         for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
    499             it->second->load();
    500     }
    501 
    502     void ConfigFileManager::save()
    503     {
    504         for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
    505             it->second->save();
    506     }
    507 
    508     void ConfigFileManager::clean(bool bCleanComments)
    509     {
    510         for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
    511             this->clean(it->first, bCleanComments);
    512     }
    513 
    514     void ConfigFileManager::load(ConfigFileType type)
    515     {
    516         this->getFile(type)->load();
    517     }
    518 
    519     void ConfigFileManager::save(ConfigFileType type)
    520     {
    521         this->getFile(type)->save();
    522     }
    523 
    524     void ConfigFileManager::saveAs(ConfigFileType type, const std::string& saveFilename)
    525     {
    526         this->getFile(type)->saveAs(saveFilename);
    527     }
    528 
    529     void ConfigFileManager::clean(ConfigFileType type, bool bCleanComments)
    530     {
    531         this->getFile(type)->clean(bCleanComments);
    532     }
    533 
    534     void ConfigFileManager::updateConfigValues()
    535     {
    536         for (std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
    537             it->second->updateConfigValues();
    538     }
    539 
    540     void ConfigFileManager::updateConfigValues(ConfigFileType type)
    541     {
    542         this->getFile(type)->updateConfigValues();
    543     }
    544 
    545     const std::string& ConfigFileManager::getFilename(ConfigFileType type)
    546     {
    547         std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
    548         if (it != this->configFiles_.end())
    549             return it->second->getFilename();
    550         else
    551             return BLANKSTRING;
    552     }
    553 
    554     ConfigFile* ConfigFileManager::getFile(ConfigFileType type)
    555     {
    556         std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
    557         if (it != this->configFiles_.end())
    558             return it->second;
    559         else
    560         {
    561             COUT(1) << "ConfigFileManager: Can't find a config file for type with ID " << static_cast<int>(type) << std::endl;
    562             COUT(1) << "Using " << DEFAULT_CONFIG_FILE << " file." << std::endl;
    563             this->setFilename(type, DEFAULT_CONFIG_FILE);
    564             return getFile(type);
    565         }
     602        for (boost::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
     603            if (*it)
     604                delete (*it);
     605    }
     606
     607    void ConfigFileManager::setFilename(ConfigFileType::Value type, const std::string& filename)
     608    {
     609        if (this->getConfigFile(type))
     610            delete this->configFiles_[type];
     611        // Create and load config file
     612        switch (type)
     613        {
     614        case ConfigFileType::Settings:
     615            this->configFiles_[type] = new SettingsConfigFile(filename);
     616            break;
     617        case ConfigFileType::JoyStickCalibration:
     618        case ConfigFileType::CommandHistory:
     619            this->configFiles_[type] = new ConfigFile(filename);
     620            break;
     621        }
     622        this->configFiles_[type]->load();
    566623    }
    567624}
  • code/trunk/src/libraries/core/ConfigFileManager.h

    r6427 r6536  
    3232#include "CorePrereqs.h"
    3333
    34 #include <cassert>
    35 #include <string>
    3634#include <list>
    3735#include <map>
    38 
    39 #include "util/OrxEnum.h"
     36#include <set>
     37#include <string>
     38#include <boost/array.hpp>
     39
    4040#include "util/Singleton.h"
    41 
    42 // tolua_begin
    43 namespace orxonox
    44 {
    45     // tolua_end
    46     // Use int as config file type to have an arbitrary number of files
    47     struct ConfigFileType : OrxEnum<ConfigFileType>
    48     {
    49         OrxEnumConstructors(ConfigFileType);
    50 
    51         static const int NoType              = 0;
    52         static const int Settings            = 1;
    53         static const int JoyStickCalibration = 2;
    54         static const int CommandHistory      = 3;
    55 
    56         static const int numberOfReservedTypes = 1024;
    57     };
    58 
    59     _CoreExport bool config(const std::string& classname, const std::string& varname, const std::string& value); // tolua_export
    60     _CoreExport const std::string& getConfig(const std::string& classname, const std::string& varname); // tolua_export
    61     _CoreExport bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
    62     _CoreExport void reloadConfig();
    63     _CoreExport void saveConfig();
    64     _CoreExport void cleanConfig();
    65     _CoreExport void loadSettings(const std::string& filename);
    66 
     41#include "util/StringUtils.h"
     42
     43namespace orxonox // tolua_export
     44{ // tolua_export
    6745
    6846    /////////////////////
     
    196174    {
    197175        friend class ConfigFile;
     176        friend class SettingsConfigFile;
    198177
    199178        public:
     
    212191
    213192            inline void setValue(const std::string& name, const std::string& value, bool bString)
    214                 { this->getEntry(name, value, bString)->setValue(value); }
    215             inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString)
    216                 { return this->getEntry(name, fallback, bString)->getValue(); }
     193                { this->getOrCreateEntry(name, value, bString)->setValue(value); }
     194            inline const std::string& getValue(const std::string& name, bool bString)
     195            {
     196                ConfigFileEntry* entry = this->getEntry(name);
     197                if (entry)
     198                {
     199                    entry->setString(bString);
     200                    return entry->getValue();
     201                }
     202                return BLANKSTRING;
     203            }
     204            inline const std::string& getOrCreateValue(const std::string& name, const std::string& fallback, bool bString)
     205                { return this->getOrCreateEntry(name, fallback, bString)->getValue(); }
    217206
    218207            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
    219                 { this->getEntry(name, index, value, bString)->setValue(value); }
    220             inline const std::string& getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    221                 { return this->getEntry(name, index, fallback, bString)->getValue(); }
     208                { this->getOrCreateEntry(name, index, value, bString)->setValue(value); }
     209            inline const std::string& getValue(const std::string& name, unsigned int index, bool bString)
     210            {
     211                ConfigFileEntry* entry = this->getEntry(name, index);
     212                if (entry)
     213                {
     214                    entry->setString(bString);
     215                    return entry->getValue();
     216                }
     217                return BLANKSTRING;
     218            }
     219            inline const std::string& getOrCreateValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     220                { return this->getOrCreateEntry(name, index, fallback, bString)->getValue(); }
    222221
    223222            void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
    224             unsigned int getVectorSize(const std::string& name);
     223            unsigned int getVectorSize(const std::string& name) const;
    225224
    226225            std::string getFileEntry() const;
     
    234233                { return this->entries_.end(); }
    235234
    236             std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString);
    237             std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
    238 
    239             inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString)
    240                 { return (*this->getEntryIterator(name, fallback, bString)); }
    241             inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    242                 { return (*this->getEntryIterator(name, index, fallback, bString)); }
     235            std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString);
     236            std::list<ConfigFileEntry*>::iterator getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
     237
     238            ConfigFileEntry* getEntry(const std::string& name) const;
     239            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, const std::string& fallback, bool bString)
     240                { return (*this->getOrCreateEntryIterator(name, fallback, bString)); }
     241            ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const;
     242            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     243                { return (*this->getOrCreateEntryIterator(name, index, fallback, bString)); }
    243244
    244245            std::string name_;
     
    255256    {
    256257        public:
    257             inline ConfigFile(const std::string& filename, ConfigFileType type)
    258                 : filename_(filename)
    259                 , type_(type)
    260                 , bUpdated_(false)
    261             { }
    262             ~ConfigFile();
    263 
    264             void load(bool bCreateIfNotExisting = true);
    265             void save() const;
    266             void saveAs(const std::string& filename);
    267             void clean(bool bCleanComments = false);
    268             void clear();
    269 
    270             const std::string& getFilename() { return this->filename_; }
     258            ConfigFile(const std::string& filename, bool bCopyFallbackFile = true);
     259            virtual ~ConfigFile();
     260
     261            virtual void load();
     262            virtual void save() const;
     263            virtual void saveAs(const std::string& filename) const;
     264            virtual void clear();
     265
     266            inline const std::string& getFilename()
     267                { return this->filename_; }
    271268
    272269            inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
    273                 { this->getSection(section)->setValue(name, value, bString); this->save(); }
    274             inline const std::string& getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
    275                 { const std::string& output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
     270            {
     271                this->getOrCreateSection(section)->setValue(name, value, bString);
     272                this->save();
     273            }
     274            inline const std::string& getValue(const std::string& section, const std::string& name, bool bString)
     275            {
     276                ConfigFileSection* sectionPtr = this->getSection(section);
     277                return (sectionPtr ? sectionPtr->getValue(name, bString) : BLANKSTRING);
     278            }
     279            const std::string& getOrCreateValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString);
    276280
    277281            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
    278                 { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
    279             inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    280                 { const std::string& output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
    281 
    282             inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
    283                 { this->getSection(section)->deleteVectorEntries(name, startindex); }
    284             inline unsigned int getVectorSize(const std::string& section, const std::string& name)
    285                 { return this->getSection(section)->getVectorSize(name); }
    286 
     282            {
     283                this->getOrCreateSection(section)->setValue(name, index, value, bString);
     284                this->save();
     285            }
     286            inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, bool bString)
     287            {
     288                ConfigFileSection* sectionPtr = this->getSection(section);
     289                return (sectionPtr ? sectionPtr->getValue(name, index, bString) : BLANKSTRING);
     290            }
     291            const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString);
     292
     293            void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0);
     294            inline unsigned int getVectorSize(const std::string& section, const std::string& name) const
     295            {
     296                ConfigFileSection* sectionPtr = this->getSection(section);
     297                return (sectionPtr ? sectionPtr->getVectorSize(name) : 0);
     298            }
     299
     300            static const char* DEFAULT_CONFIG_FOLDER;
     301
     302        protected:
     303            ConfigFileSection* getSection(const std::string& section) const;
     304            ConfigFileSection* getOrCreateSection(const std::string& section);
     305
     306            std::list<ConfigFileSection*> sections_;
     307
     308        private:
     309            void saveIfUpdated();
     310            const std::string filename_;
     311            const bool bCopyFallbackFile_;
     312            bool bUpdated_;
     313    };
     314
     315
     316    ////////////////////////
     317    // SettingsConfigFile //
     318    ////////////////////////
     319    class _CoreExport SettingsConfigFile // tolua_export
     320        : public ConfigFile, public Singleton<SettingsConfigFile>
     321    { // tolua_export
     322        friend class Singleton<SettingsConfigFile>;
     323
     324        public:
     325            typedef std::multimap<std::string, std::pair<std::string, ConfigValueContainer*> > ContainerMap;
     326
     327            SettingsConfigFile(const std::string& filename);
     328            ~SettingsConfigFile();
     329
     330            void load(); // tolua_export
     331            void setFilename(const std::string& filename); // tolua_export
     332            void clean(bool bCleanComments = false); // tolua_export
     333
     334            bool config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
     335            bool tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
     336            std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
     337
     338            void addConfigValueContainer(ConfigValueContainer* container);
     339            void removeConfigValueContainer(ConfigValueContainer* container);
     340
     341            inline const std::set<std::string>& getSectionNames()
     342                { return this->sectionNames_; }
     343            inline ContainerMap::const_iterator getContainerLowerBound(const std::string section)
     344                { return this->containers_.lower_bound(section); }
     345            inline ContainerMap::const_iterator getContainerUpperBound(const std::string section)
     346                { return this->containers_.upper_bound(section); }
     347
     348            static SettingsConfigFile& getInstance() { return Singleton<SettingsConfigFile>::getInstance(); } // tolua_export
     349
     350        private:
    287351            void updateConfigValues();
    288 
    289         private:
    290             ConfigFileSection* getSection(const std::string& section);
    291             void saveIfUpdated();
    292 
    293             std::string filename_;
    294             ConfigFileType type_;
    295             std::list<ConfigFileSection*> sections_;
    296             bool bUpdated_;
    297     };
     352            bool configImpl(const std::string& section, const std::string& entry, const std::string& value, bool (ConfigValueContainer::*function)(const MultiType&));
     353
     354            ContainerMap containers_;
     355            std::set<std::string> sectionNames_;
     356            static SettingsConfigFile* singletonPtr_s;
     357    }; // tolua_export
    298358
    299359
     
    308368            ~ConfigFileManager();
    309369
    310             void load();
    311             void save();
    312             void clean(bool bCleanComments = false);
    313 
    314             void setFilename(ConfigFileType type, const std::string& filename);
    315             const std::string& getFilename(ConfigFileType type);
    316 
    317             ConfigFileType getNewConfigFileType() { return mininmalFreeType_++; }
    318 
    319             void load(ConfigFileType type);
    320             void save(ConfigFileType type);
    321             void saveAs(ConfigFileType type, const std::string& saveFilename);
    322             void clean(ConfigFileType type, bool bCleanComments = false);
    323 
    324             inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
    325                 { this->getFile(type)->setValue(section, name, value, bString); }
    326             inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
    327                 { return this->getFile(type)->getValue(section, name, fallback, bString); }
    328 
    329             inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
    330                 { this->getFile(type)->setValue(section, name, index, value, bString); }
    331             inline const std::string& getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    332                 { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
    333 
    334             inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
    335                 { this->getFile(type)->deleteVectorEntries(section, name, startindex); }
    336             inline unsigned int getVectorSize(ConfigFileType type, const std::string& section, const std::string& name)
    337                 { return this->getFile(type)->getVectorSize(section, name); }
    338 
    339             void updateConfigValues();
    340             void updateConfigValues(ConfigFileType type);
    341 
    342             static std::string DEFAULT_CONFIG_FILE;
     370            void setFilename(ConfigFileType::Value type, const std::string& filename);
     371
     372            inline ConfigFile* getConfigFile(ConfigFileType::Value type)
     373            {
     374                // Check array bounds
     375                return configFiles_.at(type);
     376            }
    343377
    344378        private:
    345379            ConfigFileManager(const ConfigFileManager&);
    346380
    347             ConfigFile* getFile(ConfigFileType type);
    348 
    349             std::map<ConfigFileType, ConfigFile*> configFiles_;
    350             unsigned int mininmalFreeType_;
    351 
     381            boost::array<ConfigFile*, 3> configFiles_;
    352382            static ConfigFileManager* singletonPtr_s;
    353383    };
  • code/trunk/src/libraries/core/ConfigValueContainer.cc

    r5738 r6536  
    3636#include "util/Convert.h"
    3737#include "util/SubString.h"
     38#include "ConfigFileManager.h"
    3839#include "Language.h"
    3940
     
    4344
    4445    /**
    45         @brief Initializes the ConfigValueContainer with defaultvalues.
    46     */
    47     void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname)
     46        @brief Initializes the ConfigValueContainer with default values.
     47    */
     48    void ConfigValueContainer::init(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname)
    4849    {
    4950        this->type_ = type;
     
    5556        this->bDoInitialCallback_ = false;
    5657        this->bAddedDescription_ = false;
     58
     59        // Register containers for general settings
     60        if (this->type_ == ConfigFileType::Settings)
     61            SettingsConfigFile::getInstance().addConfigValueContainer(this);
    5762    }
    5863
     
    7883        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
    7984        {
    80             ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
     85            ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
    8186            this->defvalueStringVector_.push_back(this->valueVector_[i]);
    8287        }
     
    9297        if (this->callback_)
    9398            delete this->callback_;
     99
     100        // Unregister general settings containers
     101        if (this->type_ == ConfigFileType::Settings && SettingsConfigFile::exists())
     102            SettingsConfigFile::getInstance().removeConfigValueContainer(this);
    94103    }
    95104
     
    109118            if (this->tset(input))
    110119            {
    111                 ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
     120                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
    112121                return true;
    113122            }
     
    128137            if (this->tset(index, input))
    129138            {
    130                 ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
     139                ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
    131140                return true;
    132141            }
     
    228237                this->valueVector_.erase(this->valueVector_.begin() + index);
    229238                for (unsigned int i = index; i < this->valueVector_.size(); i++)
    230                     ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
    231                 ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
     239                    ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
     240                ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->valueVector_.size());
    232241
    233242                return true;
     
    253262                if (!this->set(i, this->defvalueStringVector_[i]))
    254263                    success = false;
    255             ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
     264            ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->defvalueStringVector_.size());
    256265            return success;
    257266        }
     
    264273    {
    265274        if (!this->bIsVector_)
    266             this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
     275            this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
    267276        else
    268277        {
    269278            this->valueVector_.clear();
    270             unsigned int vectorSize = ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_);
     279            unsigned int vectorSize = ConfigFileManager::getInstance().getConfigFile(this->type_)->getVectorSize(this->sectionname_, this->varname_);
    271280            for (unsigned int i = 0; i < vectorSize; i++)
    272281            {
    273282                if (i < this->defvalueStringVector_.size())
    274283                {
    275                     this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
     284                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
    276285                }
    277286                else
    278287                {
    279                     this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
     288                    this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
    280289                }
    281290
  • code/trunk/src/libraries/core/ConfigValueContainer.h

    r6417 r6536  
    5050
    5151#include "util/MultiType.h"
    52 #include "ConfigFileManager.h"
    5352#include "Identifier.h"
    5453
     
    108107            */
    109108            template <class D, class V>
    110             ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
     109            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
    111110            {
    112111                this->init(type, identifier, sectionname, varname);
     
    122121            */
    123122            template <class D, class V>
    124             ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
     123            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
    125124            {
    126125                this->init(type, identifier, sectionname, varname);
     
    217216            inline const std::string& getName() const
    218217                { return this->varname_; }
    219             /** @brief Retuns the name of the section this config value is in. */
     218            /** @brief Returns the name of the section this config value is in. */
    220219            inline const std::string& getSectionName() const
    221220                { return this->sectionname_; }
     221            /** @brief Returns the associated identifier (can be NULL). */
     222            inline Identifier* getIdentifier() const
     223                { return this->identifier_; }
    222224            /** @brief Returns true if this config-value is a vector */
    223225            inline bool isVector() const
     
    271273
    272274        private:
    273             void init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname);
     275            void init(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname);
    274276            void initValue(const MultiType& defvalue);
    275277            void initVector();
     
    278280            bool                       bIsVector_;                  //!< True if the container contains a std::vector
    279281
    280             ConfigFileType             type_;                       //!< The type of the corresponding config-file
     282            ConfigFileType::Value      type_;                       //!< The type of the corresponding config-file
    281283            Identifier*                identifier_;                 //!< The identifier of the class
    282284            std::string                sectionname_;                //!< The name of the class the variable belongs to
  • code/trunk/src/libraries/core/ConfigValueIncludes.h

    r6423 r6536  
    4040#include "Identifier.h"
    4141#include "ConfigValueContainer.h"
    42 #include "ConfigFileManager.h"
    4342
    4443namespace orxonox
     
    6160    */
    6261    template <class T, class D, class V>
    63     inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
     62    inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType::Value type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
    6463    {
    6564        ConfigValueContainer* container = ClassIdentifier<T>::getIdentifier()->getConfigValueContainer(entryName);
  • code/trunk/src/libraries/core/CorePrereqs.h

    r6105 r6536  
    8484    }
    8585
     86    namespace ConfigFileType
     87    {
     88        enum Value
     89        {
     90            Settings,
     91            JoyStickCalibration,
     92            CommandHistory
     93            // Don't forget to adjust the array size in the ConfigFileManager when adding a new entry here!
     94        };
     95    }
     96
    8697    namespace KeybindMode
    8798    {
     
    124135    class ConfigFileManager;
    125136    class ConfigFileSection;
    126     struct ConfigFileType;
    127137    class ConfigValueContainer;
    128138    class ConsoleCommand;
     
    172182    class PathConfig;
    173183    struct ResourceInfo;
     184    class SettingsConfigFile;
    174185    class Shell;
    175186    class ShellListener;
  • code/trunk/src/libraries/core/Identifier.cc

    r6417 r6536  
    416416        this->bHasConfigValues_ = true;
    417417        this->configValues_[varname] = container;
    418         this->configValues_LC_[getLowercase(varname)] = container;
    419418    }
    420419
     
    428427        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
    429428        if (it != configValues_.end())
    430             return it->second;
    431         else
    432             return 0;
    433     }
    434 
    435     /**
    436         @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase.
    437         @param varname The name of the variable in lowercase
    438         @return The ConfigValueContainer
    439     */
    440     ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname)
    441     {
    442         std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
    443         if (it != configValues_LC_.end())
    444429            return it->second;
    445430        else
  • code/trunk/src/libraries/core/Identifier.h

    r6417 r6536  
    200200            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    201201
    202             /** @brief Returns the map that stores all config values. @return The const_iterator */
    203             inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; }
    204             /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */
    205             inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); }
    206             /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */
    207             inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); }
    208 
    209             /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */
    210             inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; }
    211             /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */
    212             inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); }
    213             /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */
    214             inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
    215 
    216202            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    217203            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
    218             ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
    219204
    220205
     
    320305            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
    321306            std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
    322             std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer
    323307
    324308            bool bHasConsoleCommands_;                                     //!< True if this class has at least one assigned console command
  • code/trunk/src/libraries/core/Language.h

    r6417 r6536  
    5252#include <cassert>
    5353#include "util/Singleton.h"
    54 
    55 #define AddLanguageEntry(label, fallbackstring) \
    56     orxonox::Language::getInstance().addEntry(label, fallbackstring)
    57 
    58 #define GetLocalisation(label) \
    59     orxonox::Language::getInstance().getLocalisation(label)
    60 
    6154
    6255namespace orxonox
     
    140133            static Language* singletonPtr_s;
    141134    };
     135
     136    //! Shortcut function for Language::addEntry
     137    inline void AddLanguageEntry(const LanguageEntryLabel& label, const std::string& fallbackString)
     138    {
     139        Language::getInstance().addEntry(label, fallbackString);
     140    }
     141
     142    //! Shortcut function for Language::getLocalisation
     143    inline const std::string& GetLocalisation(const LanguageEntryLabel& label)
     144    {
     145        return Language::getInstance().getLocalisation(label);
     146    }
    142147}
    143148
  • code/trunk/src/libraries/core/Shell.cc

    r6417 r6536  
    3434#include "CommandExecutor.h"
    3535#include "CoreIncludes.h"
     36#include "ConfigFileManager.h"
    3637#include "ConfigValueIncludes.h"
    3738#include "ConsoleCommand.h"
  • code/trunk/src/libraries/core/Shell.h

    r6417 r6536  
    3939#include "util/OutputHandler.h"
    4040#include "OrxonoxClass.h"
    41 #include "ConfigFileManager.h"
    4241#include "input/InputBuffer.h"
    4342
  • code/trunk/src/libraries/core/input/Button.cc

    r6428 r6536  
    4242#include "core/CommandEvaluation.h"
    4343#include "core/CommandExecutor.h"
     44#include "core/ConfigFileManager.h"
    4445
    4546namespace orxonox
     
    8182    }
    8283
    83     void Button::readBinding(ConfigFileType type)
    84     {
    85         const std::string& binding = ConfigFileManager::getInstance().getValue(type, groupName_, name_, "", true);
     84    void Button::readBinding(ConfigFile* configFile, ConfigFile* fallbackFile)
     85    {
     86        std::string binding = configFile->getOrCreateValue(groupName_, name_, "", true);
     87        if (binding.empty() && fallbackFile)
     88            binding = fallbackFile->getValue(groupName_, name_, true);
    8689        this->parse(binding);
    8790    }
    8891
    89     void Button::setBinding(ConfigFileType type, const std::string& binding, bool bTemporary)
     92    void Button::setBinding(ConfigFile* configFile, ConfigFile* fallbackFile, const std::string& binding, bool bTemporary)
    9093    {
    9194        if (!bTemporary)
    92             ConfigFileManager::getInstance().setValue(type, groupName_, name_, binding, true);
     95            configFile->setValue(groupName_, name_, binding, true);
    9396        this->parse(binding);
    9497    }
     
    103106        this->bindingString_ = binding;
    104107
    105         if (isEmpty(bindingString_))
     108        if (isEmpty(bindingString_) || removeTrailingWhitespaces(getLowercase(binding)) == "nobinding")
    106109            return;
    107110
  • code/trunk/src/libraries/core/input/Button.h

    r6428 r6536  
    4141#include <vector>
    4242#include "InputCommands.h"
    43 #include "core/ConfigFileManager.h"
    4443
    4544namespace orxonox
     
    5352        virtual bool addParamCommand(ParamCommand* command) { return false; }
    5453        void parse(const std::string& binding);
    55         void readBinding(ConfigFileType type);
    56         void setBinding(ConfigFileType type, const std::string& binding, bool bTemporary);
     54        void readBinding(ConfigFile* configFile, ConfigFile* fallbackFile);
     55        void setBinding(ConfigFile* configFile, ConfigFile* fallbackFile, const std::string& binding, bool bTemporary);
    5756        bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f);
    5857
  • code/trunk/src/libraries/core/input/JoyStick.cc

    r6417 r6536  
    106106    {
    107107        list.resize(size);
    108         unsigned int configValueVectorSize = ConfigFileManager::getInstance().getVectorSize(ConfigFileType::JoyStickCalibration, sectionName, valueName);
     108        unsigned int configValueVectorSize = ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)->getVectorSize(sectionName, valueName);
    109109        if (configValueVectorSize > size)
    110110            configValueVectorSize = size;
     
    112112        for (unsigned int i = 0; i < configValueVectorSize; ++i)
    113113        {
    114             list[i] = multi_cast<int>(ConfigFileManager::getInstance().getValue(
    115                 ConfigFileType::JoyStickCalibration, sectionName, valueName, i, multi_cast<std::string>(defaultValue), false));
     114            list[i] = multi_cast<int>(ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
     115                ->getOrCreateValue(sectionName, valueName, i, multi_cast<std::string>(defaultValue), false));
    116116        }
    117117
     
    153153            if (configMinValues_[i] == INT_MAX)
    154154                configMinValues_[i] = -32768;
    155             ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
    156                 deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false);
     155            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
     156                ->getOrCreateValue(deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false);
    157157
    158158            // Maximum values
    159159            if (configMaxValues_[i] == INT_MIN)
    160160                configMaxValues_[i] = 32767;
    161             ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
    162                 deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false);
     161            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
     162                ->getOrCreateValue(deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false);
    163163
    164164            // Middle values
    165             ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
    166                 deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false);
     165            ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)
     166                ->getOrCreateValue(deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false);
    167167        }
    168168
  • code/trunk/src/libraries/core/input/KeyBinder.cc

    r6428 r6536  
    3737#include "core/CoreIncludes.h"
    3838#include "core/ConfigFileManager.h"
     39#include "core/PathConfig.h"
    3940#include "InputCommands.h"
    4041#include "JoyStick.h"
     
    4950        : deriveTime_(0.0f)
    5051        , filename_(filename)
     52        , configFile_(NULL)
     53        , fallbackConfigFile_(NULL)
    5154    {
    5255        mouseRelative_[0] = 0;
     
    9497        }
    9598
    96         // We might not even load any bindings at all (KeyDetector for instance)
    97         this->configFile_ = ConfigFileType::NoType;
    98 
    9999        // initialise joy sticks separatly to allow for reloading
    100100        this->JoyStickQuantityChanged(this->getJoyStickList());
     
    116116        // almost no destructors required because most of the arrays are static.
    117117        clearBindings(); // does some destruction work
     118        if (this->configFile_)
     119            delete this->configFile_;
     120        if (this->fallbackConfigFile_)
     121            delete this->fallbackConfigFile_;
    118122    }
    119123
     
    163167
    164168        // load the bindings if required
    165         if (configFile_ != ConfigFileType::NoType)
     169        if (configFile_ != NULL)
    166170        {
    167171            for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev)
    168172            {
    169173                for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i)
    170                     (*joyStickButtons_[iDev])[i].readBinding(this->configFile_);
     174                    (*joyStickButtons_[iDev])[i].readBinding(this->configFile_, this->fallbackConfigFile_);
    171175                for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i)
    172                     (*joyStickAxes_[iDev])[i].readBinding(this->configFile_);
     176                    (*joyStickAxes_[iDev])[i].readBinding(this->configFile_, this->fallbackConfigFile_);
    173177            }
    174178        }
     
    249253        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
    250254
    251         // Get a new ConfigFileType from the ConfigFileManager
    252         this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
    253 
    254         ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_);
     255        this->configFile_ = new ConfigFile(this->filename_, !PathConfig::isDevelopmentRun());
     256        this->configFile_->load();
     257
     258        if (PathConfig::isDevelopmentRun())
     259        {
     260            // Dev users should have combined key bindings files
     261            std::string defaultFilepath(PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);
     262            std::ifstream file(defaultFilepath.c_str());
     263            if (file.is_open())
     264            {
     265                file.close();
     266                // Open the default file for later use (use absolute path!)
     267                this->fallbackConfigFile_ = new ConfigFile(defaultFilepath, false);
     268                this->fallbackConfigFile_->load();
     269            }
     270        }
    255271
    256272        // Parse bindings and create the ConfigValueContainers if necessary
    257273        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    258274        {
    259             it->second->readBinding(this->configFile_);
     275            it->second->readBinding(this->configFile_, this->fallbackConfigFile_);
    260276            addButtonToCommand(it->second->bindingString_, it->second);
    261277        }
     
    270286        {
    271287            addButtonToCommand(binding, it->second);
    272             it->second->setBinding(this->configFile_, binding, bTemporary);
     288            std::string str = binding;
     289            if (PathConfig::isDevelopmentRun() && binding.empty())
     290                str = "NoBinding";
     291            it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary);
    273292            return true;
    274293        }
  • code/trunk/src/libraries/core/input/KeyBinder.h

    r6428 r6536  
    3838#include <boost/shared_ptr.hpp>
    3939
    40 #include "core/ConfigFileManager.h"
    4140#include "InputHandler.h"
    4241#include "Button.h"
     
    157156        //! Name of the file used in this KeyBinder (constant!)
    158157        const std::string filename_;
    159         //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
    160         ConfigFileType configFile_;
     158        //! Config file used. NULL in case of KeyDetector. Also indicates whether we've already loaded.
     159        ConfigFile* configFile_;
     160        //! Config file from the data directory that only serves as fallback
     161        ConfigFile* fallbackConfigFile_;
    161162
    162163    private:
  • code/trunk/src/libraries/util/Singleton.h

    r6417 r6536  
    5151        static T& getInstance()
    5252        {
    53             assert(T::singletonPtr_s != 0);
     53            assert(T::singletonPtr_s != NULL);
    5454            return *T::singletonPtr_s;
     55        }
     56
     57        //! Tells whether the singleton has been created
     58        static bool exists()
     59        {
     60            return (T::singletonPtr_s != NULL);
    5561        }
    5662
     
    6874        Singleton()
    6975        {
    70             assert(T::singletonPtr_s == 0);
     76            assert(T::singletonPtr_s == NULL);
    7177            T::singletonPtr_s = static_cast<T*>(this);
    7278        }
     
    7581        ~Singleton()
    7682        {
    77             assert(T::singletonPtr_s != 0);
    78             T::singletonPtr_s = 0;
     83            assert(T::singletonPtr_s != NULL);
     84            T::singletonPtr_s = NULL;
    7985        }
    8086
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r6417 r6536  
    235235    CEGUI::Window* QuestManager::getQuestGUI(const std::string & guiName)
    236236    {
    237         PlayerInfo* player = this->retreivePlayer(guiName);
     237        PlayerInfo* player = this->retrievePlayer(guiName);
    238238
    239239        if(this->questGUIs_.find(player) == this->questGUIs_.end()) //!< Create a new GUI, if there is none, yet.
     
    253253        This very well might be outdated. So: Check if still needed, and update if necessary.
    254254    */
    255     PlayerInfo* QuestManager::retreivePlayer(const std::string & guiName)
     255    PlayerInfo* QuestManager::retrievePlayer(const std::string & guiName)
    256256    {
    257257        PlayerInfo* player = GUIManager::getInstance().getPlayer(guiName);
  • code/trunk/src/modules/questsystem/QuestManager.h

    r6417 r6536  
    5252    /**
    5353    @brief
    54         Is a Singleton and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).
     54        Is a Singleton and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessible (through findX()).
    5555        Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way.
    5656    @author
     
    7272            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    7373
    74             //! Retreive the main window for the GUI.
     74            //! Retrieve the main window for the GUI.
    7575            CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export
    7676
     
    8282
    8383        protected:
    84             std::map<std::string, Quest*> & getQuests(void); //!< Retreive all Quests.
     84            std::map<std::string, Quest*> & getQuests(void); //!< Retrieve all Quests.
    8585
    8686        private:
    8787            static QuestManager* singletonPtr_s;
    88             PlayerInfo* retreivePlayer(const std::string & guiName); //!< Retrieve the player for a certain GUI.
     88            PlayerInfo* retrievePlayer(const std::string & guiName); //!< Retrieve the player for a certain GUI.
    8989
    9090            std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
Note: See TracChangeset for help on using the changeset viewer.