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:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • 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;
Note: See TracChangeset for help on using the changeset viewer.