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

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() };
}