Add enable property to the ScriptScheduler

* NOTE: A rebuild of the globals library will be required to make this
commit compile
This commit is contained in:
Malin Ejdbo
2021-09-14 17:11:30 +02:00
parent a7cc3a46bd
commit febd4c3b53
4 changed files with 25 additions and 3 deletions
+1
View File
@@ -381,6 +381,7 @@ void initialize() {
rootPropertyOwner->addPropertySubOwner(global::interactionMonitor);
rootPropertyOwner->addPropertySubOwner(global::sessionRecording);
rootPropertyOwner->addPropertySubOwner(global::timeManager);
rootPropertyOwner->addPropertySubOwner(global::scriptScheduler);
rootPropertyOwner->addPropertySubOwner(global::renderEngine);
rootPropertyOwner->addPropertySubOwner(global::screenSpaceRootPropertyOwner);
+16 -1
View File
@@ -33,6 +33,14 @@
#include "scriptscheduler_lua.inl"
namespace {
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
"EnabledInfo",
"Enabled",
"This enables or disables the ScriptScheduler. If disabled, no scheduled scripts "
"will be executed. If enabled, scheduled scripts will be executed at their given "
"time as normal."
};
struct [[codegen::Dictionary(ScheduledScript)]] Parameters {
// The time at which, when the in game time passes it, the two scripts will
// be executed. If the traversal is forwards (towards + infinity), the
@@ -65,6 +73,13 @@ documentation::Documentation ScriptScheduler::Documentation() {
return codegen::doc<Parameters>("core_scheduledscript");
}
ScriptScheduler::ScriptScheduler()
: properties::PropertyOwner({ "ScriptScheduler" })
, _enabled(EnabledInfo, true)
{
addProperty(_enabled);
}
ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict) {
const Parameters p = codegen::bake<Parameters>(dict);
@@ -132,7 +147,7 @@ void ScriptScheduler::clearSchedule() {
std::pair<ScriptScheduler::ScriptIt, ScriptScheduler::ScriptIt>
ScriptScheduler::progressTo(double newTime)
{
if (newTime == _currentTime) {
if (!_enabled || newTime == _currentTime) {
return { _forwardScripts.end(), _forwardScripts.end() };
}
+1 -1
View File
@@ -46,7 +46,7 @@ int loadFile(lua_State* L) {
for (size_t i = 1; i <= scriptsDict.size(); ++i) {
ghoul::Dictionary d = scriptsDict.value<ghoul::Dictionary>(std::to_string(i));
scripting::ScriptScheduler::ScheduledScript script =
scripting::ScriptScheduler::ScheduledScript script =
scripting::ScriptScheduler::ScheduledScript(d);
scripts.push_back(script);
}