Changeset 6432 for code/branches/gamestate/src/libraries/core/input
- Timestamp:
- Dec 29, 2009, 10:30:19 PM (15 years ago)
- Location:
- code/branches/gamestate/src/libraries/core/input
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/src/libraries/core/input/Button.cc
r6428 r6432 42 42 #include "core/CommandEvaluation.h" 43 43 #include "core/CommandExecutor.h" 44 #include "core/ConfigFileManager.h" 44 45 45 46 namespace orxonox … … 81 82 } 82 83 83 void Button::readBinding(ConfigFile Type type)84 { 85 const std::string& binding = ConfigFileManager::getInstance().getValue(type,groupName_, name_, "", true);84 void Button::readBinding(ConfigFile* configFile) 85 { 86 const std::string& binding = configFile->getOrCreateValue(groupName_, name_, "", true); 86 87 this->parse(binding); 87 88 } 88 89 89 void Button::setBinding(ConfigFile Type type, const std::string& binding, bool bTemporary)90 void Button::setBinding(ConfigFile* configFile, const std::string& binding, bool bTemporary) 90 91 { 91 92 if (!bTemporary) 92 ConfigFileManager::getInstance().setValue(type,groupName_, name_, binding, true);93 configFile->setValue(groupName_, name_, binding, true); 93 94 this->parse(binding); 94 95 } -
code/branches/gamestate/src/libraries/core/input/Button.h
r6428 r6432 41 41 #include <vector> 42 42 #include "InputCommands.h" 43 #include "core/ConfigFileManager.h"44 43 45 44 namespace orxonox … … 53 52 virtual bool addParamCommand(ParamCommand* command) { return false; } 54 53 void parse(const std::string& binding); 55 void readBinding(ConfigFile Type type);56 void setBinding(ConfigFile Type type, const std::string& binding, bool bTemporary);54 void readBinding(ConfigFile* configFile); 55 void setBinding(ConfigFile* configFile, const std::string& binding, bool bTemporary); 57 56 bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f); 58 57 -
code/branches/gamestate/src/libraries/core/input/JoyStick.cc
r6417 r6432 106 106 { 107 107 list.resize(size); 108 unsigned int configValueVectorSize = ConfigFileManager::getInstance().get VectorSize(ConfigFileType::JoyStickCalibration,sectionName, valueName);108 unsigned int configValueVectorSize = ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration)->getVectorSize(sectionName, valueName); 109 109 if (configValueVectorSize > size) 110 110 configValueVectorSize = size; … … 112 112 for (unsigned int i = 0; i < configValueVectorSize; ++i) 113 113 { 114 list[i] = multi_cast<int>(ConfigFileManager::getInstance().get Value(115 ConfigFileType::JoyStickCalibration,sectionName, valueName, i, multi_cast<std::string>(defaultValue), false));114 list[i] = multi_cast<int>(ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration) 115 ->getOrCreateValue(sectionName, valueName, i, multi_cast<std::string>(defaultValue), false)); 116 116 } 117 117 … … 153 153 if (configMinValues_[i] == INT_MAX) 154 154 configMinValues_[i] = -32768; 155 ConfigFileManager::getInstance(). setValue(ConfigFileType::JoyStickCalibration,156 deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false);155 ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration) 156 ->getOrCreateValue(deviceName_, "MinValue", i, multi_cast<std::string>(configMinValues_[i]), false); 157 157 158 158 // Maximum values 159 159 if (configMaxValues_[i] == INT_MIN) 160 160 configMaxValues_[i] = 32767; 161 ConfigFileManager::getInstance(). setValue(ConfigFileType::JoyStickCalibration,162 deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false);161 ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration) 162 ->getOrCreateValue(deviceName_, "MaxValue", i, multi_cast<std::string>(configMaxValues_[i]), false); 163 163 164 164 // Middle values 165 ConfigFileManager::getInstance(). setValue(ConfigFileType::JoyStickCalibration,166 deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false);165 ConfigFileManager::getInstance().getConfigFile(ConfigFileType::JoyStickCalibration) 166 ->getOrCreateValue(deviceName_, "ZeroValue", i, multi_cast<std::string>(configZeroValues_[i]), false); 167 167 } 168 168 -
code/branches/gamestate/src/libraries/core/input/KeyBinder.cc
r6428 r6432 49 49 : deriveTime_(0.0f) 50 50 , filename_(filename) 51 , configFile_(NULL) 51 52 { 52 53 mouseRelative_[0] = 0; … … 93 94 mouseAxes_[i].groupName_ = "MouseAxes"; 94 95 } 95 96 // We might not even load any bindings at all (KeyDetector for instance)97 this->configFile_ = ConfigFileType::NoType;98 96 99 97 // initialise joy sticks separatly to allow for reloading … … 163 161 164 162 // load the bindings if required 165 if (configFile_ != ConfigFileType::NoType)163 if (configFile_ != NULL) 166 164 { 167 165 for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev) … … 249 247 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl; 250 248 251 // Get a new ConfigFileType from the ConfigFileManager 252 this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType(); 253 254 ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_); 249 this->configFile_ = new ConfigFile(this->filename_); 250 this->configFile_->load(); 255 251 256 252 // Parse bindings and create the ConfigValueContainers if necessary -
code/branches/gamestate/src/libraries/core/input/KeyBinder.h
r6428 r6432 38 38 #include <boost/shared_ptr.hpp> 39 39 40 #include "core/ConfigFileManager.h"41 40 #include "InputHandler.h" 42 41 #include "Button.h" … … 157 156 //! Name of the file used in this KeyBinder (constant!) 158 157 const std::string filename_; 159 //! Config file used. ConfigFileType::NoTypein case of KeyDetector. Also indicates whether we've already loaded.160 ConfigFile TypeconfigFile_;158 //! Config file used. NULL in case of KeyDetector. Also indicates whether we've already loaded. 159 ConfigFile* configFile_; 161 160 162 161 private:
Note: See TracChangeset
for help on using the changeset viewer.