diff --git a/include/openspace/interaction/actionmanager.h b/include/openspace/interaction/actionmanager.h index b8c37637ad..c965a108fc 100644 --- a/include/openspace/interaction/actionmanager.h +++ b/include/openspace/interaction/actionmanager.h @@ -46,6 +46,7 @@ public: void triggerAction(const std::string& identifier, const ghoul::Dictionary& arguments, ShouldBeSynchronized shouldBeSynchronized) const; static scripting::LuaLibrary luaLibrary(); + nlohmann::json generateJson() const; private: std::unordered_map _actions; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 45bbafdd72..a0dca5e879 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1069,6 +1069,7 @@ void OpenSpaceEngine::writeDocumentation() { nlohmann::json license = writer.generateJsonGroupedByLicense(); nlohmann::json sceneProperties = settings.get(); nlohmann::json sceneGraph = scene.get(); + nlohmann::json actions = global::actionManager->generateJson(); sceneProperties["name"] = "Settings"; sceneGraph["name"] = "Scene"; @@ -1080,7 +1081,7 @@ void OpenSpaceEngine::writeDocumentation() { scriptingResult["data"] = scripting; nlohmann::json documentation = { - sceneGraph, sceneProperties, keybindings, license, scriptingResult, factory + sceneGraph, sceneProperties, actions, keybindings, license, scriptingResult, factory }; nlohmann::json result; diff --git a/src/interaction/actionmanager.cpp b/src/interaction/actionmanager.cpp index 608ce69005..454e292aa2 100644 --- a/src/interaction/actionmanager.cpp +++ b/src/interaction/actionmanager.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -129,4 +130,23 @@ scripting::LuaLibrary ActionManager::luaLibrary() { }; } +nlohmann::json ActionManager::generateJson() const { + nlohmann::json res; + res["name"] = "Actions"; + res["data"] = nlohmann::json::array(); + + for (const std::pair& a : _actions) { + const Action& action = a.second; + nlohmann::json d; + // Use identifier as name to make it more similar to scripting api + d["name"] = action.identifier; + d["guiName"] = action.name; + d["documentation"] = action.documentation; + d["command"] = action.command; + res["data"].push_back(d); + } + sortJson(res["data"], "name"); + return res; +} + } // namespace openspace::interaction