Changeset 1887 for code/trunk/src/core/input/Button.cc
- Timestamp:
- Oct 6, 2008, 12:31:32 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/input/Button.cc
r1783 r1887 34 34 35 35 #include "Button.h" 36 36 37 #include "util/Convert.h" 37 38 #include "util/SubString.h" … … 41 42 #include "core/CommandEvaluation.h" 42 43 #include "core/CommandExecutor.h" 43 #include " InputCommands.h"44 #include "core/ConfigValueContainer.h" 44 45 45 46 namespace orxonox 46 47 { 48 /** 49 @note 50 bButtonThresholdUser_: We set it to true so that setConfigValues in KeyBinder sets the value 51 correctly the first time. It is then set to false first and changed later in Button::parse(). 52 */ 53 Button::Button() 54 : configContainer_(0) 55 , bButtonThresholdUser_(false) 56 , paramCommandBuffer_(0) 57 { 58 nCommands_[0]=0; 59 nCommands_[1]=0; 60 nCommands_[2]=0; 61 clear(); 62 } 63 47 64 void Button::clear() 48 65 { … … 65 82 } 66 83 67 void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer) 68 { 84 void Button::readConfigValue() 85 { 86 // create/get ConfigValueContainer 87 if (!configContainer_) 88 { 89 configContainer_ = new ConfigValueContainer(CFT_Keybindings, 0, groupName_, name_, "", name_); 90 configContainer_->callback(this, &Button::parse); 91 } 92 configContainer_->getValue(&bindingString_, this); 93 } 94 95 void Button::parse() 96 { 97 // delete all commands 98 clear(); 99 69 100 if (isEmpty(bindingString_)) 70 {71 clear();72 101 return; 73 } 102 103 // reset this to false first when parsing (was true before when parsing for the first time) 104 bButtonThresholdUser_ = false; 74 105 75 106 // use std::vector for a temporary dynamic array 76 107 std::vector<BaseCommand*> commands[3]; 77 78 108 79 109 // separate the commands … … 112 142 parseError("Could not parse 'ButtonThreshold' argument. \ 113 143 Switching to default value.", true); 144 else 145 this->bButtonThresholdUser_ = true; 114 146 } 115 147 else if (token == "scale") … … 152 184 153 185 // add command to the buffer if not yet existing 154 for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer .size(); iParamCmd++)155 { 156 if (getLowercase( paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())186 for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++) 187 { 188 if (getLowercase((*paramCommandBuffer_)[iParamCmd]->evaluation_.getOriginalCommand()) 157 189 == getLowercase(commandStr)) 158 190 { 159 191 // already in list 160 cmd->paramCommand_ = paramCommandBuffer[iParamCmd];192 cmd->paramCommand_ = (*paramCommandBuffer_)[iParamCmd]; 161 193 break; 162 194 } … … 165 197 { 166 198 cmd->paramCommand_ = new BufferedParamCommand(); 167 paramCommandBuffer .push_back(cmd->paramCommand_);199 paramCommandBuffer_->push_back(cmd->paramCommand_); 168 200 cmd->paramCommand_->evaluation_ = eval; 169 201 cmd->paramCommand_->paramIndex_ = paramIndex; … … 208 240 } 209 241 210 bool Button::execute(KeybindMode::Enum mode, float abs, float rel)211 {212 // execute all the parsed commands in the string213 for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)214 commands_[mode][iCommand]->execute(abs, rel);215 return true;216 }217 218 242 inline void Button::parseError(std::string message, bool serious) 219 243 {
Note: See TracChangeset
for help on using the changeset viewer.