7 #include <nlohmann/json.hpp>
17 def->optional(properties.shortcutPath,
"ShortcutPath",
"");
22 SkillDashboard::loadShortcuts(
const std::string&
filename)
25 nlohmann::json jsonData;
34 for (
const auto& item : jsonData[
"shortcuts"])
36 SkillShortcut shortcut;
37 shortcut.skillArgs = item[
"skill_args"].dump(2);
38 shortcut.skillId = item[
"skill_id"];
39 shortcut.shortcutName = item[
"skill_shortcut_name"];
41 this->registeredShortcuts.push_back(shortcut);
49 this->registeredShortcuts = std::vector<SkillShortcut>();
50 this->properties.shortcutPath = getProperty<std::string>(
"ShortcutPath").getValue();
52 if (not properties.shortcutPath.empty())
54 loadShortcuts(properties.shortcutPath);
66 return this->registeredShortcuts;
72 for (
const SkillShortcut& shortcut : this->registeredShortcuts)
74 if (shortcut.shortcutName == name)
80 return SkillShortcut();
86 if (newShortcut.shortcutName !=
"")
88 if (
getShortcut(newShortcut.shortcutName).shortcutName ==
"")
91 this->registeredShortcuts.push_back(newShortcut);
92 ARMARX_INFO <<
"Added shortcut " << newShortcut.shortcutName;
96 for (SkillShortcut& shortcut : this->registeredShortcuts)
98 if (shortcut.shortcutName == newShortcut.shortcutName)
100 shortcut.skillId = newShortcut.skillId;
101 shortcut.skillArgs = newShortcut.skillArgs;
112 for (
auto it = this->registeredShortcuts.begin(); it != this->registeredShortcuts.end();
115 if (it->shortcutName == name)
117 this->registeredShortcuts.erase(it);