Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 1, 2010, 10:05:56 PM (14 years ago)
Author:
rgrieder
Message:

Added support for keybindings.ini merging:
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestate/src/libraries/core/ConfigFileManager.h

    r6432 r6437  
    3939
    4040#include "util/Singleton.h"
     41#include "util/StringUtils.h"
    4142
    4243namespace orxonox // tolua_export
     
    191192            inline void setValue(const std::string& name, const std::string& value, bool bString)
    192193                { this->getOrCreateEntry(name, value, bString)->setValue(value); }
    193             inline const std::string& getValue(const std::string& name, const std::string& fallback, bool bString) const
     194            inline const std::string& getValue(const std::string& name, bool bString)
    194195            {
    195196                ConfigFileEntry* entry = this->getEntry(name);
    196                 return (entry ? entry->getValue() : BLANKSTRING);
     197                if (entry)
     198                {
     199                    entry->setString(bString);
     200                    return entry->getValue();
     201                }
     202                return BLANKSTRING;
    197203            }
    198204            inline const std::string& getOrCreateValue(const std::string& name, const std::string& fallback, bool bString)
     
    201207            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
    202208                { this->getOrCreateEntry(name, index, value, bString)->setValue(value); }
    203             inline const std::string& getValue(const std::string& name, unsigned int index) const
     209            inline const std::string& getValue(const std::string& name, unsigned int index, bool bString)
    204210            {
    205211                ConfigFileEntry* entry = this->getEntry(name, index);
    206                 return (entry ? entry->getValue() : BLANKSTRING);
     212                if (entry)
     213                {
     214                    entry->setString(bString);
     215                    return entry->getValue();
     216                }
     217                return BLANKSTRING;
    207218            }
    208219            inline const std::string& getOrCreateValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
     
    222233                { return this->entries_.end(); }
    223234
    224             std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name) const;
    225             std::list<ConfigFileEntry*>::iterator       getOrCreateEntryIterator(const std::string& name, const std::string& fallback, bool bString);
    226             std::list<ConfigFileEntry*>::const_iterator getEntryIterator(const std::string& name, unsigned int index) const;
    227             std::list<ConfigFileEntry*>::iterator       getOrCreateEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
    228 
    229             inline ConfigFileEntry* getEntry(const std::string& name) const
    230                 { return (*this->getEntryIterator(name)); }
     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;
    231239            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, const std::string& fallback, bool bString)
    232240                { return (*this->getOrCreateEntryIterator(name, fallback, bString)); }
    233             inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const
    234                 { return (*this->getEntryIterator(name, index)); }
     241            ConfigFileEntry* getEntry(const std::string& name, unsigned int index) const;
    235242            inline ConfigFileEntry* getOrCreateEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
    236243                { return (*this->getOrCreateEntryIterator(name, index, fallback, bString)); }
     
    249256    {
    250257        public:
    251             ConfigFile(const std::string& filename);
     258            ConfigFile(const std::string& filename, bool bCopyFallbackFile = true);
    252259            virtual ~ConfigFile();
    253260
     
    265272                this->save();
    266273            }
    267             inline const std::string& getValue(const std::string& section, const std::string& name, bool bString) const
     274            inline const std::string& getValue(const std::string& section, const std::string& name, bool bString)
    268275            {
    269276                ConfigFileSection* sectionPtr = this->getSection(section);
     
    274281            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
    275282            {
    276                 this->getSection(section)->setValue(name, index, value, bString);
     283                this->getOrCreateSection(section)->setValue(name, index, value, bString);
    277284                this->save();
    278285            }
    279             inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index) const
     286            inline const std::string& getValue(const std::string& section, const std::string& name, unsigned int index, bool bString)
    280287            {
    281288                ConfigFileSection* sectionPtr = this->getSection(section);
    282                 return (sectionPtr ? sectionPtr->getValue(name, index) : BLANKSTRING);
     289                return (sectionPtr ? sectionPtr->getValue(name, index, bString) : BLANKSTRING);
    283290            }
    284291            const std::string& getOrCreateValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString);
     
    290297                return (sectionPtr ? sectionPtr->getVectorSize(name) : 0);
    291298            }
     299
     300            static const char* DEFAULT_CONFIG_FOLDER;
    292301
    293302        protected:
     
    300309            void saveIfUpdated();
    301310            const std::string filename_;
     311            const bool bCopyFallbackFile_;
    302312            bool bUpdated_;
    303313    };
Note: See TracChangeset for help on using the changeset viewer.