mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-21 10:28:44 -05:00
Added functionality to print all keybindings to file when a scene is loaded
This commit is contained in:
@@ -51,6 +51,8 @@ const string ConfigurationManager::KeyPropertyDocumentationType =
|
||||
"PropertyDocumentationFile.Type";
|
||||
const string ConfigurationManager::KeyPropertyDocumentationFile =
|
||||
"PropertyDocumentationFile.File";
|
||||
const string ConfigurationManager::KeyKeyboardShortcutsType = "KeyboardShortcuts.Type";
|
||||
const string ConfigurationManager::KeyKeyboardShortcutsFile = "KeyboardShortcuts.File";
|
||||
const string ConfigurationManager::KeyConfigScene = "Scene";
|
||||
const string ConfigurationManager::KeySpiceTimeKernel = "SpiceKernel.Time";
|
||||
const string ConfigurationManager::KeySpiceLeapsecondKernel = "SpiceKernel.LeapSecond";
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "InteractionHandler";
|
||||
}
|
||||
@@ -1151,6 +1153,24 @@ void InteractionHandler::bindKey(Key key, KeyModifier modifier, std::string lua)
|
||||
lua
|
||||
});
|
||||
}
|
||||
|
||||
void InteractionHandler::writeKeyboardDocumentation(const std::string& type, const std::string& file)
|
||||
{
|
||||
if (type == "text") {
|
||||
std::ofstream f(absPath(file));
|
||||
|
||||
for (const auto& p : _keyLua) {
|
||||
f << std::to_string(p.first) << ": " <<
|
||||
p.second << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ghoul::RuntimeError(
|
||||
"Unsupported keyboard documentation type '" + type + "'",
|
||||
"InteractionHandler"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary InteractionHandler::luaLibrary() {
|
||||
return{
|
||||
|
||||
+16
-2
@@ -87,14 +87,28 @@ bool Scene::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool ONCE = false;
|
||||
|
||||
void Scene::update(const UpdateData& data) {
|
||||
if (!_sceneGraphToLoad.empty()) {
|
||||
OsEng.renderEngine().scene()->clearSceneGraph();
|
||||
try {
|
||||
loadSceneInternal(_sceneGraphToLoad);
|
||||
_sceneGraphToLoad = "";
|
||||
|
||||
// After loading the scene, the keyboard bindings have been set
|
||||
|
||||
std::string type;
|
||||
std::string file;
|
||||
bool hasType = OsEng.configurationManager().getValue(
|
||||
ConfigurationManager::KeyKeyboardShortcutsType, type
|
||||
);
|
||||
|
||||
bool hasFile = OsEng.configurationManager().getValue(
|
||||
ConfigurationManager::KeyKeyboardShortcutsFile, file
|
||||
);
|
||||
|
||||
if (hasType && hasFile) {
|
||||
OsEng.interactionHandler().writeKeyboardDocumentation(type, file);
|
||||
}
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
|
||||
Reference in New Issue
Block a user