Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2008, 12:22:42 AM (16 years ago)
Author:
rgrieder
Message:

Merged r2101 (objecthierarchy) to trunk.

Location:
code/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/core/input/Button.cc

    r2087 r2103  
    8282    }
    8383
    84     void Button::readConfigValue()
     84    void Button::readConfigValue(ConfigFileType configFile)
    8585    {
    8686        // create/get ConfigValueContainer
    8787        if (!configContainer_)
    8888        {
    89             configContainer_ = new ConfigValueContainer(CFT_Keybindings, 0, groupName_, name_, "", name_);
     89            configContainer_ = new ConfigValueContainer(configFile, 0, groupName_, name_, "", name_);
    9090            configContainer_->callback(this, &Button::parse);
    9191        }
  • code/trunk/src/core/input/Button.h

    r1887 r2103  
    4141#include <vector>
    4242#include "InputCommands.h"
     43#include "core/ConfigFileManager.h"
    4344
    4445namespace orxonox
     
    5253        virtual bool addParamCommand(ParamCommand* command) { return false; }
    5354        void parse();
    54         void readConfigValue();
     55        void readConfigValue(ConfigFileType configFile);
    5556        bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
    5657
  • code/trunk/src/core/input/InputManager.cc

    r1934 r2103  
    405405            if (!cont)
    406406            {
    407                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
     407                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
    408408                getIdentifier()->addConfigValueContainer("CoeffPos", cont);
    409409            }
     
    413413            if (!cont)
    414414            {
    415                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
     415                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
    416416                getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
    417417            }
     
    421421            if (!cont)
    422422            {
    423                 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
     423                cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
    424424                getIdentifier()->addConfigValueContainer("Zero", cont);
    425425            }
  • code/trunk/src/core/input/KeyBinder.cc

    r2087 r2103  
    106106        }
    107107
     108        // Get a new ConfigFileType from the ConfigFileManager
     109        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     110
    108111        // initialise joy sticks separatly to allow for reloading
    109112        numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks();
     
    133136    void KeyBinder::setConfigValues()
    134137    {
    135         SetConfigValue(defaultKeybindings_, "def_keybindings.ini")
    136             .description("Filename of default keybindings.");
    137138        SetConfigValue(analogThreshold_, 0.05f)
    138139            .description("Threshold for analog axes until which the state is 0.");
     
    173174
    174175        // load the bindings if required
    175         if (!configFile_.empty())
     176        if (configFile_ != ConfigFileType::NoType)
    176177        {
    177178            for (unsigned int iDev = oldValue; iDev < numberOfJoySticks_; ++iDev)
    178179            {
    179180                for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i)
    180                     joyStickButtons_[iDev][i].readConfigValue();
     181                    joyStickButtons_[iDev][i].readConfigValue(this->configFile_);
    181182                for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i)
    182                     joyStickAxes_[iDev][i].readConfigValue();
     183                    joyStickAxes_[iDev][i].readConfigValue(this->configFile_);
    183184            }
    184185        }
     
    250251        True if loading succeeded.
    251252    */
    252     void KeyBinder::loadBindings(const std::string& filename)
     253    void KeyBinder::loadBindings(const std::string& filename, const std::string& defaultFilename)
    253254    {
    254255        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
    255256
    256         configFile_ = filename;
    257         if (configFile_.empty())
     257        if (filename.empty())
    258258            return;
    259259
    260260        // get bindings from default file if filename doesn't exist.
    261261        std::ifstream infile;
    262         infile.open(configFile_.c_str());
     262        infile.open(filename.c_str());
    263263        if (!infile)
    264264        {
    265             ConfigFileManager::getInstance().setFile(CFT_Keybindings, defaultKeybindings_);
    266             ConfigFileManager::getInstance().save(CFT_Keybindings, configFile_);
     265            ConfigFileManager::getInstance().setFilename(this->configFile_, defaultFilename);
     266            ConfigFileManager::getInstance().saveAs(this->configFile_, filename);
    267267        }
    268268        else
    269269            infile.close();
    270         ConfigFileManager::getInstance().setFile(CFT_Keybindings, configFile_);
     270        ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
    271271
    272272        // Parse bindings and create the ConfigValueContainers if necessary
    273273        clearBindings();
    274274        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    275             it->second->readConfigValue();
     275            it->second->readConfigValue(this->configFile_);
    276276
    277277        COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
  • code/trunk/src/core/input/KeyBinder.h

    r2087 r2103  
    4444#include "InputCommands.h"
    4545#include "JoyStickDeviceNumberListener.h"
     46#include "core/ConfigFileManager.h"
    4647
    4748namespace orxonox
     
    5960        virtual ~KeyBinder();
    6061
    61         void loadBindings(const std::string& filename);
     62        void loadBindings(const std::string& filename, const std::string& defaultFilename);
    6263        void clearBindings();
    6364        bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
     
    142143        float deriveTime_;
    143144
    144         //! Config file used. "" in case of KeyDetector. Also indicates whether we've already loaded.
    145         std::string configFile_;
     145        //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
     146        ConfigFileType configFile_;
    146147
    147148    private:
    148149        //##### ConfigValues #####
    149         //! Filename of default keybindings.
    150         std::string defaultKeybindings_;
    151150        //! Whether to filter small value analog input
    152151        bool bFilterAnalogNoise_;
Note: See TracChangeset for help on using the changeset viewer.