mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
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:
@@ -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);
|
||||
|
||||
@@ -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() };
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user