mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-25 05:29:41 -06:00
solve merge conflict with develop
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/systemcapabilities/systemcapabilities>
|
||||
#include <ghoul/misc/onscopeexit.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -91,6 +92,9 @@ namespace {
|
||||
const std::string _defaultCacheLocation = "${BASE_PATH}/cache";
|
||||
|
||||
const std::string _sgctConfigArgumentCommand = "-config";
|
||||
|
||||
const std::string PreInitializeFunction = "preInitialization";
|
||||
const std::string PostInitializationFunction = "postInitialization";
|
||||
|
||||
const int CacheVersion = 1;
|
||||
const int DownloadVersion = 1;
|
||||
@@ -410,7 +414,7 @@ bool OpenSpaceEngine::initialize() {
|
||||
_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
|
||||
// Run start up scripts
|
||||
runStartupScripts();
|
||||
runPreInitializationScripts(sceneDescriptionPath);
|
||||
|
||||
// Load a light and a monospaced font
|
||||
loadFonts();
|
||||
@@ -516,18 +520,64 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
|
||||
}
|
||||
|
||||
|
||||
void OpenSpaceEngine::runStartupScripts() {
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeyStartupScript, scripts);
|
||||
runScripts(scripts);
|
||||
void OpenSpaceEngine::runPreInitializationScripts(const std::string& sceneDescription) {
|
||||
LINFO("Running Initialization scripts");
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OnExit(
|
||||
// Delete the Lua state at the end of the scope, no matter what
|
||||
[state](){ghoul::lua::destroyLuaState(state);}
|
||||
);
|
||||
OsEng.scriptEngine().initializeLuaState(state);
|
||||
|
||||
// First execute the script to get all global variables
|
||||
ghoul::lua::runScriptFile(state, absPath(sceneDescription));
|
||||
|
||||
// Get the preinitialize function
|
||||
lua_getglobal(state, PreInitializeFunction.c_str());
|
||||
bool isFunction = lua_isfunction(state, -1);
|
||||
if (!isFunction) {
|
||||
LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" <<
|
||||
sceneDescription << "' does not have a function '" <<
|
||||
PreInitializeFunction << "'");
|
||||
return;
|
||||
}
|
||||
|
||||
// And execute the preinitialize function
|
||||
int success = lua_pcall(state, 0, 0, 0);
|
||||
if (success != 0) {
|
||||
LERROR("Error executing '" << PreInitializeFunction << "': " <<
|
||||
lua_tostring(state, -1));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::runSettingsScripts() {
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeySettingsScript, scripts);
|
||||
runScripts(scripts);
|
||||
void OpenSpaceEngine::runPostInitializationScripts(const std::string& sceneDescription) {
|
||||
LINFO("Running Setup scripts");
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OnExit(
|
||||
// Delete the Lua state at the end of the scope, no matter what
|
||||
[state](){ghoul::lua::destroyLuaState(state);}
|
||||
);
|
||||
OsEng.scriptEngine().initializeLuaState(state);
|
||||
|
||||
// First execute the script to get all global variables
|
||||
ghoul::lua::runScriptFile(state, absPath(sceneDescription));
|
||||
|
||||
// Get the preinitialize function
|
||||
lua_getglobal(state, PostInitializationFunction.c_str());
|
||||
bool isFunction = lua_isfunction(state, -1);
|
||||
if (!isFunction) {
|
||||
LERROR("Error executing startup script '" << sceneDescription << "'. Scene '" <<
|
||||
sceneDescription << "' does not have a function '" <<
|
||||
PostInitializationFunction << "'");
|
||||
return;
|
||||
}
|
||||
|
||||
// And execute the preinitialize function
|
||||
int success = lua_pcall(state, 0, 0, 0);
|
||||
if (success != 0) {
|
||||
LERROR("Error executing '" << PostInitializationFunction << "': " <<
|
||||
lua_tostring(state, -1));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::loadFonts() {
|
||||
@@ -652,8 +702,8 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
Time::ref().postSynchronizationPreDraw();
|
||||
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
_renderEngine->postSynchronizationPreDraw();
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
|
||||
if (_isMaster && _gui->isEnabled() && _windowWrapper->isRegularRendering()) {
|
||||
glm::vec2 mousePosition = _windowWrapper->mousePosition();
|
||||
|
||||
Reference in New Issue
Block a user