Added functionality to print all keybindings to file when a scene is loaded

This commit is contained in:
Alexander Bock
2016-07-14 00:28:09 -04:00
parent b9237cb787
commit dc32dfe075
7 changed files with 47 additions and 3 deletions
+2
View File
@@ -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";
+20
View File
@@ -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
View File
@@ -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());