mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
First implementation of moving the startup scripts into the scene description files
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
function initialize ()
|
||||
openspace.setInvertRoll(true);
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
openspace.time.setDeltaTime(0)
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
function setup()
|
||||
openspace.printInfo("Setting default values")
|
||||
openspace.setPropertyValue("Sun.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", true)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", true)
|
||||
--openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTrail.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTexture.renderable.enabled", false)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.75)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.enabled", false)
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
ScenePath = ".",
|
||||
CommonFolder = "common",
|
||||
@@ -30,4 +55,3 @@ return {
|
||||
--"gridEquatorial",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
void enableBarrier();
|
||||
void disableBarrier();
|
||||
|
||||
void runSettingsScripts();
|
||||
void runSettingsScripts(const std::string& sceneDescription);
|
||||
|
||||
private:
|
||||
OpenSpaceEngine(std::string programName, std::unique_ptr<WindowWrapper> windowWrapper);
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
bool loadSpiceKernels();
|
||||
void loadFonts();
|
||||
void runScripts(const ghoul::Dictionary& scripts);
|
||||
void runStartupScripts();
|
||||
void runStartupScripts(const std::string& sceneDescription);
|
||||
void configureLogging();
|
||||
|
||||
// Components
|
||||
|
||||
@@ -31,12 +31,6 @@ return {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf"
|
||||
},
|
||||
StartupScripts = {
|
||||
"${SCRIPTS}/default_startup.lua"
|
||||
},
|
||||
SettingsScripts = {
|
||||
"${SCRIPTS}/default_settings.lua"
|
||||
},
|
||||
Logging = {
|
||||
LogLevel = "Debug",
|
||||
ImmediateFlush = false,
|
||||
|
||||
@@ -50,8 +50,6 @@ const string ConfigurationManager::KeyPropertyDocumentationType =
|
||||
const string ConfigurationManager::KeyPropertyDocumentationFile =
|
||||
"PropertyDocumentationFile.File";
|
||||
const string ConfigurationManager::KeyConfigScene = "Scene";
|
||||
const string ConfigurationManager::KeyStartupScript = "StartupScripts";
|
||||
const string ConfigurationManager::KeySettingsScript = "SettingsScripts";
|
||||
const string ConfigurationManager::KeySpiceTimeKernel = "SpiceKernel.Time";
|
||||
const string ConfigurationManager::KeySpiceLeapsecondKernel = "SpiceKernel.LeapSecond";
|
||||
const string ConfigurationManager::KeyLogLevel = "Logging.LogLevel";
|
||||
|
||||
@@ -398,7 +398,7 @@ bool OpenSpaceEngine::initialize() {
|
||||
_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
|
||||
// Run start up scripts
|
||||
runStartupScripts();
|
||||
runStartupScripts(sceneDescriptionPath);
|
||||
|
||||
// Load a light and a monospaced font
|
||||
loadFonts();
|
||||
@@ -504,18 +504,45 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
|
||||
}
|
||||
|
||||
|
||||
void OpenSpaceEngine::runStartupScripts() {
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeyStartupScript, scripts);
|
||||
runScripts(scripts);
|
||||
void OpenSpaceEngine::runStartupScripts(const std::string& sceneDescription) {
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OsEng.scriptEngine().initializeLuaState(state);
|
||||
|
||||
// Above we generated a ghoul::Dictionary from the scene file; now we run the scene
|
||||
// file again to load any variables defined inside into the state that is passed to
|
||||
// the modules. This allows us to specify global variables that can then be used
|
||||
// inside the modules to toggle settings
|
||||
ghoul::lua::runScriptFile(state, absPath(sceneDescription));
|
||||
|
||||
lua_getglobal(state, "initialize");
|
||||
if (lua_pcall(state, 0, 0, 0) != 0)
|
||||
LERROR("error running function `f': %s",
|
||||
lua_tostring(L, -1));
|
||||
|
||||
ghoul::lua::destroyLuaState(state);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::runSettingsScripts() {
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeySettingsScript, scripts);
|
||||
runScripts(scripts);
|
||||
void OpenSpaceEngine::runSettingsScripts(const std::string& sceneDescription) {
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OsEng.scriptEngine().initializeLuaState(state);
|
||||
|
||||
// Above we generated a ghoul::Dictionary from the scene file; now we run the scene
|
||||
// file again to load any variables defined inside into the state that is passed to
|
||||
// the modules. This allows us to specify global variables that can then be used
|
||||
// inside the modules to toggle settings
|
||||
ghoul::lua::runScriptFile(state, absPath(sceneDescription));
|
||||
|
||||
lua_getglobal(state, "setup");
|
||||
if (lua_pcall(state, 0, 0, 0) != 0)
|
||||
LERROR("error running function `f': %s",
|
||||
lua_tostring(L, -1));
|
||||
|
||||
ghoul::lua::destroyLuaState(state);
|
||||
|
||||
//ghoul::Dictionary scripts;
|
||||
//configurationManager().getValue(
|
||||
// ConfigurationManager::KeySettingsScript, scripts);
|
||||
//runScripts(scripts);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::loadFonts() {
|
||||
|
||||
@@ -328,7 +328,7 @@ bool Scene::loadSceneInternal(const std::string& sceneDescriptionFilePath) {
|
||||
}
|
||||
|
||||
|
||||
OsEng.runSettingsScripts();
|
||||
OsEng.runSettingsScripts(sceneDescriptionFilePath);
|
||||
|
||||
OsEng.enableBarrier();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user