MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / configure

Method configure

src/Core/Input/InputManager.cpp:132–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 }
131
132 void InputManager::configure(vili::node& config)
133 {
134 std::vector<std::string> alreadyInFile;
135 for (auto& [contextName, context] : config.items())
136 {
137 for (auto& [actionName, condition] : context.items())
138 {
139 if (!this->actionExists(actionName))
140 {
141 m_allActions.push_back(
142 std::make_unique<InputAction>(t_actions.get(), actionName));
143 }
144 else if (!Utils::Vector::contains(actionName, alreadyInFile))
145 {
146 this->getAction(actionName).clearConditions();
147 }
148 auto inputCondition
149 = [this](InputManager* inputManager, const std::string& action,
150 vili::node& condition) {
151 InputCondition actionCondition;
152 InputCombination combination;
153 try
154 {
155 combination = this->makeCombination(condition);
156 }
157 catch (const Exception& e)
158 {
159 throw Exceptions::InvalidInputCombinationCode(
160 action, condition, EXC_INFO)
161 .nest(e);
162 }
163
164 actionCondition.setCombination(combination);
165 Debug::Log->debug(
166 "<InputManager> Associated Key '{0}' for Action '{1}'",
167 condition, action);
168 inputManager->getAction(action).addCondition(actionCondition);
169 };
170 if (condition.is_primitive())
171 {
172 inputCondition(this, actionName, condition);
173 }
174 else if (condition.is<vili::array>())
175 {
176 for (vili::node& singleCondition : condition)
177 {
178 inputCondition(this, actionName, singleCondition);
179 }
180 }
181 this->getAction(actionName).addContext(contextName);
182 alreadyInFile.push_back(actionName);
183 }
184 }
185 // Add Context keys in real time <REVISION>
186 }
187
188 void InputManager::clearContexts()
189 {

Callers 2

initInputMethod · 0.45
initFramerateMethod · 0.45

Calls 13

actionExistsMethod · 0.95
makeCombinationMethod · 0.95
clearConditionsMethod · 0.80
nestMethod · 0.80
setCombinationMethod · 0.80
debugMethod · 0.80
addConditionMethod · 0.80
is_primitiveMethod · 0.80
addContextMethod · 0.80
containsFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected