mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Added functionality to print all keybindings to file when a scene is loaded
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -154,3 +154,4 @@ data/scene/juno/juno/textures
|
||||
data/scene/juno/juno/spice
|
||||
data/scene/juno/juno/Juno.mtl
|
||||
data/scene/juno/juno/Juno.obj
|
||||
KeyboardMapping.txt
|
||||
|
||||
Submodule ext/ghoul updated: cafbe9c243...3c60705400
@@ -61,6 +61,10 @@ public:
|
||||
static const std::string KeyPropertyDocumentationType;
|
||||
/// The key that stores the save location of the Property documentation
|
||||
static const std::string KeyPropertyDocumentationFile;
|
||||
/// The key that stores the type of keyboard bindings that should be stored
|
||||
static const std::string KeyKeyboardShortcutsType;
|
||||
/// The key that stores the save location of the keyboard bindings file
|
||||
static const std::string KeyKeyboardShortcutsFile;
|
||||
/// The key that stores the location of the scene file that is initially loaded
|
||||
static const std::string KeyConfigScene;
|
||||
/// The key that stores the subdirectory containing a list of all startup scripts to
|
||||
|
||||
@@ -109,6 +109,7 @@ public:
|
||||
void distanceDelta(const PowerScaledScalar& distance, size_t iterations = 0);
|
||||
void lookAt(const glm::quat& rotation);
|
||||
void setRotation(const glm::quat& rotation);
|
||||
|
||||
|
||||
private:
|
||||
// Remove copy and move constructors
|
||||
@@ -349,6 +350,8 @@ public:
|
||||
void mousePositionCallback(double x, double y);
|
||||
void mouseScrollWheelCallback(double pos);
|
||||
|
||||
void writeKeyboardDocumentation(const std::string& type, const std::string& file);
|
||||
|
||||
private:
|
||||
void setInteractionMode(std::shared_ptr<InteractionMode> interactionMode);
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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