Changeset 6536 for code/trunk/src/libraries/core/input/KeyBinder.cc
- Timestamp:
- Mar 16, 2010, 11:22:36 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gamestate (added) merged: 6430-6432,6437,6439-6440
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/input/KeyBinder.cc
r6428 r6536 37 37 #include "core/CoreIncludes.h" 38 38 #include "core/ConfigFileManager.h" 39 #include "core/PathConfig.h" 39 40 #include "InputCommands.h" 40 41 #include "JoyStick.h" … … 49 50 : deriveTime_(0.0f) 50 51 , filename_(filename) 52 , configFile_(NULL) 53 , fallbackConfigFile_(NULL) 51 54 { 52 55 mouseRelative_[0] = 0; … … 94 97 } 95 98 96 // We might not even load any bindings at all (KeyDetector for instance)97 this->configFile_ = ConfigFileType::NoType;98 99 99 // initialise joy sticks separatly to allow for reloading 100 100 this->JoyStickQuantityChanged(this->getJoyStickList()); … … 116 116 // almost no destructors required because most of the arrays are static. 117 117 clearBindings(); // does some destruction work 118 if (this->configFile_) 119 delete this->configFile_; 120 if (this->fallbackConfigFile_) 121 delete this->fallbackConfigFile_; 118 122 } 119 123 … … 163 167 164 168 // load the bindings if required 165 if (configFile_ != ConfigFileType::NoType)169 if (configFile_ != NULL) 166 170 { 167 171 for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev) 168 172 { 169 173 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i) 170 (*joyStickButtons_[iDev])[i].readBinding(this->configFile_ );174 (*joyStickButtons_[iDev])[i].readBinding(this->configFile_, this->fallbackConfigFile_); 171 175 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i) 172 (*joyStickAxes_[iDev])[i].readBinding(this->configFile_ );176 (*joyStickAxes_[iDev])[i].readBinding(this->configFile_, this->fallbackConfigFile_); 173 177 } 174 178 } … … 249 253 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl; 250 254 251 // Get a new ConfigFileType from the ConfigFileManager 252 this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType(); 253 254 ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_); 255 this->configFile_ = new ConfigFile(this->filename_, !PathConfig::isDevelopmentRun()); 256 this->configFile_->load(); 257 258 if (PathConfig::isDevelopmentRun()) 259 { 260 // Dev users should have combined key bindings files 261 std::string defaultFilepath(PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_); 262 std::ifstream file(defaultFilepath.c_str()); 263 if (file.is_open()) 264 { 265 file.close(); 266 // Open the default file for later use (use absolute path!) 267 this->fallbackConfigFile_ = new ConfigFile(defaultFilepath, false); 268 this->fallbackConfigFile_->load(); 269 } 270 } 255 271 256 272 // Parse bindings and create the ConfigValueContainers if necessary 257 273 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 258 274 { 259 it->second->readBinding(this->configFile_ );275 it->second->readBinding(this->configFile_, this->fallbackConfigFile_); 260 276 addButtonToCommand(it->second->bindingString_, it->second); 261 277 } … … 270 286 { 271 287 addButtonToCommand(binding, it->second); 272 it->second->setBinding(this->configFile_, binding, bTemporary); 288 std::string str = binding; 289 if (PathConfig::isDevelopmentRun() && binding.empty()) 290 str = "NoBinding"; 291 it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary); 273 292 return true; 274 293 }
Note: See TracChangeset
for help on using the changeset viewer.