Enable the ability to run setting scripts that are executed after the scene has been loaded

This commit is contained in:
Alexander Bock
2015-02-17 20:10:50 +01:00
parent 3651c64af4
commit a0fc77a893
8 changed files with 51 additions and 24 deletions

View File

@@ -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<std::string>(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<std::string>(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;