Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 16, 2010, 11:22:36 AM (15 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:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • 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
Note: See TracChangeset for help on using the changeset viewer.