diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index d37ba7b72a..e00adfc509 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -86,7 +86,7 @@ public: void encode(); void decode(); - + void runSettingsScripts(); private: OpenSpaceEngine(std::string programName); @@ -95,8 +95,9 @@ private: void clearAllWindows(); bool gatherCommandlineArguments(); bool loadSpiceKernels(); - void runStartupScripts(); void loadFonts(); + void runScripts(const ghoul::Dictionary& scripts); + void runStartupScripts(); void configureLogging(); static OpenSpaceEngine* _engine; @@ -111,7 +112,6 @@ private: double _dt; SyncBuffer* _syncBuffer; - }; #define OsEng (openspace::OpenSpaceEngine::ref()) diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h index cd3e987c50..e200e53dde 100644 --- a/include/openspace/util/constants.h +++ b/include/openspace/util/constants.h @@ -47,6 +47,7 @@ namespace configurationmanager { const std::string keyConfigScene = "Scene"; const std::string keyEnableGui = "EnableGUI"; const std::string keyStartupScript = "StartupScripts"; + const std::string keySettingsScript = "SettingsScripts"; const std::string keySpiceTimeKernel = "SpiceKernel.Time"; const std::string keySpiceLeapsecondKernel = "SpiceKernel.LeapSecond"; const std::string keyLogLevel = "Logging.LogLevel"; diff --git a/openspace-data b/openspace-data index b090a44cd3..99380bdd39 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit b090a44cd304ba1e4393749f6f1688086a9d810c +Subproject commit 99380bdd3925859c9201257c93897fa97963fdc1 diff --git a/openspace.cfg b/openspace.cfg index 1346a2d1a9..8dc23e524f 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -22,6 +22,9 @@ return { StartupScripts = { "${SCRIPTS}/default_startup.lua" }, + SettingsScripts = { + "${SCRIPTS}/default_settings.lua" + }, Logging = { LogLevel = "Debug", ImmediateFlush = true, diff --git a/scripts/default_keybinding.lua b/scripts/default_keybinding.lua deleted file mode 100644 index 56943efb65..0000000000 --- a/scripts/default_keybinding.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - W = function() print("w") end, - S = function() print("s") end -} diff --git a/scripts/default_settings.lua b/scripts/default_settings.lua new file mode 100644 index 0000000000..96818e1a66 --- /dev/null +++ b/scripts/default_settings.lua @@ -0,0 +1,12 @@ +openspace.printInfo("Setting default values"); +openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false); + +openspace.setPropertyValue("Stars.renderable.magnitudeClamp", {0.941, 4.191}); +openspace.setPropertyValue("Stars.renderable.exponentialOffset", 6.180); +openspace.setPropertyValue("Stars.renderable.exponentialDampening", 0.838); +openspace.setPropertyValue("Stars.renderable.scaleFactor", 0.563); + +openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.65); +openspace.setPropertyValue("MilkyWay.renderable.segments", 50); + +openspace.printInfo("Done setting default values"); \ No newline at end of file diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 10956596b0..fbc52115fa 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -400,28 +400,41 @@ bool OpenSpaceEngine::loadSpiceKernels() { return true; } +void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) { + for (size_t i = 1; i <= scripts.size(); ++i) { + std::stringstream stream; + stream << i; + const std::string& key = stream.str(); + const bool hasKey = scripts.hasKeyAndValue(key); + if (!hasKey) { + LERROR("The startup scripts have to be declared in a simple array format." + " Startup scripts did not contain the key '" << key << "'"); + break; + } + + std::string scriptPath; + scripts.getValue(key, scriptPath); + std::string&& absoluteScriptPath = absPath(scriptPath); + _engine->scriptEngine()->runScriptFile(absoluteScriptPath); + } +} + + void OpenSpaceEngine::runStartupScripts() { ghoul::Dictionary scripts; configurationManager()->getValue( constants::configurationmanager::keyStartupScript, scripts); - for (size_t i = 1; i <= scripts.size(); ++i) { - std::stringstream stream; - stream << i; - const std::string& key = stream.str(); - const bool hasKey = scripts.hasKeyAndValue(key); - if (!hasKey) { - LERROR("The startup scripts have to be declared in a simple array format." - " Startup scripts did not contain the key '" << key << "'"); - break; - } - - std::string scriptPath; - scripts.getValue(key, scriptPath); - std::string&& absoluteScriptPath = absPath(scriptPath); - _engine->scriptEngine()->runScriptFile(absoluteScriptPath); - } + runScripts(scripts); } +void OpenSpaceEngine::runSettingsScripts() { + ghoul::Dictionary scripts; + configurationManager()->getValue( + constants::configurationmanager::keySettingsScript, scripts); + runScripts(scripts); +} + + void OpenSpaceEngine::loadFonts() { sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local; diff --git a/src/scenegraph/scenegraph.cpp b/src/scenegraph/scenegraph.cpp index a8f469d467..f399b9481a 100644 --- a/src/scenegraph/scenegraph.cpp +++ b/src/scenegraph/scenegraph.cpp @@ -446,6 +446,8 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) } } + OsEng.runSettingsScripts(); + return true; }