User Properties (#2064)

Add the ability to add user-defined properties using a new `openspace.addCustomProperty` function that takes an identifier and a type and creates a new property of that type.  The new property is then available under `UserProperties.<identifier>`
This commit is contained in:
Alexander Bock
2022-05-04 16:06:08 -07:00
committed by GitHub
parent 510e2795de
commit ee735618b4
4 changed files with 195 additions and 1 deletions

View File

@@ -98,6 +98,7 @@ namespace {
sizeof(interaction::SessionRecording) +
sizeof(properties::PropertyOwner) +
sizeof(properties::PropertyOwner) +
sizeof(properties::PropertyOwner) +
sizeof(scripting::ScriptEngine) +
sizeof(scripting::ScriptScheduler) +
sizeof(Profile);
@@ -345,6 +346,14 @@ void create() {
screenSpaceRootPropertyOwner = new properties::PropertyOwner({ "ScreenSpace" });
#endif // WIN32
#ifdef WIN32
userPropertyOwner = new (currentPos) properties::PropertyOwner({ "UserProperties" });
ghoul_assert(userPropertyOwner, "No userPropertyOwner");
currentPos += sizeof(properties::PropertyOwner);
#else // ^^^ WIN32 / !WIN32 vvv
userPropertyOwner = new properties::PropertyOwner({ "UserProperties" });
#endif // WIN32
#ifdef WIN32
scriptEngine = new (currentPos) scripting::ScriptEngine;
ghoul_assert(scriptEngine, "No scriptEngine");
@@ -375,7 +384,6 @@ void initialize() {
rootPropertyOwner->addPropertySubOwner(global::moduleEngine);
navigationHandler->setPropertyOwner(global::rootPropertyOwner);
// New property subowners also have to be added to the ImGuiModule callback!
rootPropertyOwner->addPropertySubOwner(global::navigationHandler);
rootPropertyOwner->addPropertySubOwner(global::interactionMonitor);
@@ -390,6 +398,8 @@ void initialize() {
rootPropertyOwner->addPropertySubOwner(global::luaConsole);
rootPropertyOwner->addPropertySubOwner(global::dashboard);
rootPropertyOwner->addPropertySubOwner(global::userPropertyOwner);
syncEngine->addSyncable(global::scriptEngine);
}