Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 28, 2009, 11:10:37 PM (14 years ago)
Author:
rgrieder
Message:

Changed config value handling in the KeyBinder. Doesn't change the interface though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/input/Button.cc

    r6417 r6428  
    4242#include "core/CommandEvaluation.h"
    4343#include "core/CommandExecutor.h"
    44 #include "core/ConfigValueContainer.h"
    4544
    4645namespace orxonox
     
    5251    */
    5352    Button::Button()
    54         : configContainer_(0)
    55         , bButtonThresholdUser_(false)
     53        : bButtonThresholdUser_(false)
    5654        , paramCommandBuffer_(0)
    5755    {
     
    6462    {
    6563        this->clear();
    66 
    67         if (this->configContainer_)
    68             delete this->configContainer_;
    6964    }
    7065
     
    8378            }
    8479        }
    85     }
    86 
    87     void Button::readConfigValue(ConfigFileType configFile)
    88     {
    89         // create/get ConfigValueContainer
    90         if (!configContainer_)
    91         {
    92             configContainer_ = new ConfigValueContainer(configFile, 0, groupName_, name_, "", name_);
    93             configContainer_->callback(this, &Button::parse);
    94         }
    95         configContainer_->getValue(&bindingString_, this);
    96     }
    97 
    98     void Button::parse()
    99     {
     80        this->bindingString_.clear();
     81    }
     82
     83    void Button::readBinding(ConfigFileType type)
     84    {
     85        const std::string& binding = ConfigFileManager::getInstance().getValue(type, groupName_, name_, "", true);
     86        this->parse(binding);
     87    }
     88
     89    void Button::setBinding(ConfigFileType type, const std::string& binding, bool bTemporary)
     90    {
     91        if (!bTemporary)
     92            ConfigFileManager::getInstance().setValue(type, groupName_, name_, binding, true);
     93        this->parse(binding);
     94    }
     95
     96    void Button::parse(const std::string& binding)
     97    {
     98        if (binding == this->bindingString_)
     99            return;
     100
    100101        // delete all commands
    101102        clear();
     103        this->bindingString_ = binding;
    102104
    103105        if (isEmpty(bindingString_))
Note: See TracChangeset for help on using the changeset viewer.