MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / BindCategory

Method BindCategory

source/game/StarInput.cpp:277–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277Input::BindCategory::BindCategory(String categoryId, Json const& categoryConfig) {
278 id = categoryId;
279 config = categoryConfig;
280 name = config.getString("name", id);
281
282 ConfigurationPtr userConfig = Root::singletonPtr()->configuration();
283 auto userBindings = userConfig->get(InputBindingConfigRoot);
284
285 for (auto& pair : config.getObject("binds", {})) {
286 String const& bindId = pair.first;
287 Json const& bindConfig = pair.second;
288 if (!bindConfig.isType(Json::Type::Object))
289 continue;
290
291 BindEntry& entry = entries.try_emplace(bindId, bindId, bindConfig, *this).first->second;
292
293 if (userBindings.isType(Json::Type::Object)) {
294 for (auto& jBind : userBindings.queryArray(strf("{}.{}", id, bindId), {})) {
295 try
296 { entry.customBinds.emplace_back(bindFromJson(jBind)); }
297 catch (JsonException const& e)
298 { Logger::error("Binds: Error loading user bind in {}.{}: {}", id, bindId, e.what()); }
299 }
300 }
301
302 if (entry.customBinds.empty())
303 entry.customBinds = entry.defaultBinds;
304 }
305}
306
307List<Input::BindEntry*> Input::filterBindEntries(List<Input::BindRef> const& binds, KeyMod mods) const {
308 uint8_t maxPriority = 0;

Callers

nothing calls this directly

Calls 11

strfFunction · 0.85
errorFunction · 0.85
getStringMethod · 0.80
configurationMethod · 0.80
queryArrayMethod · 0.80
getMethod · 0.45
getObjectMethod · 0.45
isTypeMethod · 0.45
emplace_backMethod · 0.45
whatMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected