Changeset 6428
- Timestamp:
- Dec 28, 2009, 11:10:37 PM (15 years ago)
- Location:
- code/trunk/src/libraries/core/input
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/input/Button.cc
r6417 r6428 42 42 #include "core/CommandEvaluation.h" 43 43 #include "core/CommandExecutor.h" 44 #include "core/ConfigValueContainer.h"45 44 46 45 namespace orxonox … … 52 51 */ 53 52 Button::Button() 54 : configContainer_(0) 55 , bButtonThresholdUser_(false) 53 : bButtonThresholdUser_(false) 56 54 , paramCommandBuffer_(0) 57 55 { … … 64 62 { 65 63 this->clear(); 66 67 if (this->configContainer_)68 delete this->configContainer_;69 64 } 70 65 … … 83 78 } 84 79 } 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 100 101 // delete all commands 101 102 clear(); 103 this->bindingString_ = binding; 102 104 103 105 if (isEmpty(bindingString_)) -
code/trunk/src/libraries/core/input/Button.h
r6417 r6428 52 52 virtual void clear(); 53 53 virtual bool addParamCommand(ParamCommand* command) { return false; } 54 void parse(); 55 void readConfigValue(ConfigFileType configFile); 54 void parse(const std::string& binding); 55 void readBinding(ConfigFileType type); 56 void setBinding(ConfigFileType type, const std::string& binding, bool bTemporary); 56 57 bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f); 57 58 58 //! Container to allow for better configValue support59 ConfigValueContainer* configContainer_;60 59 //! The configured string value 61 60 std::string bindingString_; -
code/trunk/src/libraries/core/input/KeyBinder.cc
r6422 r6428 57 57 RegisterRootObject(KeyBinder); 58 58 59 // in tialise all buttons and half axes to avoid creating everything with 'new'59 // initialise all buttons and half axes to avoid creating everything with 'new' 60 60 // keys 61 61 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) … … 168 168 { 169 169 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i) 170 (*joyStickButtons_[iDev])[i].read ConfigValue(this->configFile_);170 (*joyStickButtons_[iDev])[i].readBinding(this->configFile_); 171 171 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i) 172 (*joyStickAxes_[iDev])[i].read ConfigValue(this->configFile_);172 (*joyStickAxes_[iDev])[i].readBinding(this->configFile_); 173 173 } 174 174 } … … 257 257 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 258 258 { 259 it->second->read ConfigValue(this->configFile_);259 it->second->readBinding(this->configFile_); 260 260 addButtonToCommand(it->second->bindingString_, it->second); 261 261 } … … 270 270 { 271 271 addButtonToCommand(binding, it->second); 272 if (bTemporary) 273 it->second->configContainer_->tset(binding); 274 else 275 it->second->configContainer_->set(binding); 276 it->second->configContainer_->getValue(&(it->second->bindingString_), it->second); 272 it->second->setBinding(this->configFile_, binding, bTemporary); 277 273 return true; 278 274 } -
code/trunk/src/libraries/core/input/KeyBinder.h
r6417 r6428 38 38 #include <boost/shared_ptr.hpp> 39 39 40 #include "core/ConfigFileManager.h" 40 41 #include "InputHandler.h" 41 42 #include "Button.h" -
code/trunk/src/libraries/core/input/KeyDetector.cc
r6417 r6428 64 64 { 65 65 // Assign every button/axis the same command, but with its name as argument 66 clearBindings();67 66 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 68 { 69 it->second->bindingString_ = callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_; 70 it->second->parse(); 71 } 67 it->second->parse(callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_); 72 68 } 73 69
Note: See TracChangeset
for help on using the changeset viewer.