|
Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
|
Represents a scene containing objects and components. More...
#include <Scene.h>
Public Types | |
| using | OnObjectsAboutToBeDestroyedFn = std::function<void(const std::vector<DekiObject*>&)> |
Public Member Functions | |
| Scene () | |
| ~Scene () | |
| DekiObject * | Instantiate (Scene *targetScene) |
| Instantiate this scene into another scene. | |
| DekiObject * | Instantiate (Scene *targetScene, float x, float y) |
| Instantiate this scene with a specific position. | |
| void | AddObject (DekiObject *obj) |
| void | RemoveObject (DekiObject *obj) |
| const std::vector< DekiObject * > & | GetObjects () const |
| const std::vector< DekiBehaviour * > & | GetBehaviours () |
| void | InvalidateBehavioursCache () |
| DekiObject * | CreateDekiObject (const std::string &name="DekiObject") |
| void | DestroyDekiObject (DekiObject *dekiObject) |
| DekiObject * | FindDekiObject (const std::string &name) |
| DekiObject * | FindDekiObject (uint32_t id) |
| bool | LoadData (const uint8_t *data, size_t size) |
| void | InsertObjectAt (DekiObject *obj, size_t index) |
| int | GetObjectIndex (DekiObject *obj) const |
| bool | SaveToFile (const std::string &filePath) |
| bool | LoadFromFile (const std::string &filePath) |
| std::string | SaveToJsonString () |
| bool | LoadFromJsonString (const std::string &jsonStr) |
| DekiObject * | DuplicateObject (const DekiObject *source) |
| bool | ExpandInstance (DekiObject *instanceObj) |
| void | CollapseInstance (DekiObject *instanceObj) |
| void | ApplyOverrides (DekiObject *instanceObj, const nlohmann::json &overrides) |
| void | CollectOverrides (const DekiObject *instanceRoot, const DekiObject *obj, nlohmann::json &overrides) const |
| void | SetOnObjectsAboutToBeDestroyed (OnObjectsAboutToBeDestroyedFn fn) |
| Out of line: the callback is stored in a side table in Scene.cpp, not in a member, so that sizeof(Scene) does not depend on DEKI_EDITOR. | |
| const std::string & | GetName () const |
| void | SetName (const std::string &sceneName) |
| bool | IsLoaded () const |
Static Public Member Functions | |
| static Scene * | Load (const char *path, bool cache=false) |
| Load a scene by asset path through AssetManager. | |
| static Scene * | LoadInternal (const char *path) |
| Load a scene directly from the filesystem (binary MessagePack). | |
| static Scene * | LoadFromMemory (const uint8_t *data, size_t size) |
| Load a scene from memory buffer. | |
| static std::vector< std::pair< std::string, std::string > > | CollectUnknownProperties () |
| Property keys found in a scene file that no component's current metadata recognises, as {component type name, key}. | |
| static void | ClearUnknownProperties () |
| Forget everything collected so far, so a check can scope itself to the scenes it is about to load. | |
| static std::vector< std::pair< std::string, std::string > > | CollectLegacyProperties () |
| Property keys read through a DEKI_RENAMED_FROM alias since the last clear, as {component type name, old key}: the file still carries the name from before a rename. | |
| static nlohmann::json | ComponentPropertiesToJson (const DekiComponent *comp, const DekiComponentMeta &meta) |
| Every reflected property of comp — its base class's first, then its own — as the JSON a scene file holds for it, keyed by reflected name. | |
| static nlohmann::json | ComponentDefaultsToJson (const DekiComponentMeta &meta) |
| ComponentPropertiesToJson for a default-constructed instance of meta. | |
Static Public Attributes | |
| static constexpr const char * | AssetTypeName = "Scene" |
| Asset type name for AssetManager::Load<T>() lookup. | |
| static std::function< std::string(const std::string &guid)> | s_GuidToPathResolver |
Represents a scene containing objects and components.
A Scene is the fundamental content unit in Deki Engine. It can contain objects with components and can be:
This unified concept eliminates the scene/prefab distinction other engines draw - here everything is a scene.
| using Scene::OnObjectsAboutToBeDestroyedFn = std::function<void(const std::vector<DekiObject*>&)> |
| Scene::Scene | ( | ) |
| Scene::~Scene | ( | ) |
|
static |
Load a scene by asset path through AssetManager.
Always returns a fresh Scene instance with the original data.
| path | Asset-relative path without extension (e.g., "scenes/settings/settings") |
| cache | If true, pins the raw file bytes in RAM so subsequent loads skip disk I/O. If false (default), reads from disk every time. Either way, a fresh instance is returned — cached bytes are never mutated. |
|
static |
Load a scene directly from the filesystem (binary MessagePack).
| path | Resolved filesystem path to the compiled .scene binary |
|
static |
Load a scene from memory buffer.
| data | Pointer to scene data |
| size | Size of the data |
| DekiObject * Scene::Instantiate | ( | Scene * | targetScene | ) |
Instantiate this scene into another scene.
| targetScene | The scene to add the instanced objects to |
| DekiObject * Scene::Instantiate | ( | Scene * | targetScene, |
| float | x, | ||
| float | y ) |
Instantiate this scene with a specific position.
| targetScene | The scene to add the instanced objects to |
| x | X position for the root object |
| y | Y position for the root object |
| void Scene::AddObject | ( | DekiObject * | obj | ) |
| void Scene::RemoveObject | ( | DekiObject * | obj | ) |
|
inline |
| const std::vector< DekiBehaviour * > & Scene::GetBehaviours | ( | ) |
|
inline |
| DekiObject * Scene::CreateDekiObject | ( | const std::string & | name = "DekiObject" | ) |
| void Scene::DestroyDekiObject | ( | DekiObject * | dekiObject | ) |
| DekiObject * Scene::FindDekiObject | ( | const std::string & | name | ) |
| DekiObject * Scene::FindDekiObject | ( | uint32_t | id | ) |
| bool Scene::LoadData | ( | const uint8_t * | data, |
| size_t | size ) |
| void Scene::InsertObjectAt | ( | DekiObject * | obj, |
| size_t | index ) |
| int Scene::GetObjectIndex | ( | DekiObject * | obj | ) | const |
| bool Scene::SaveToFile | ( | const std::string & | filePath | ) |
| bool Scene::LoadFromFile | ( | const std::string & | filePath | ) |
| std::string Scene::SaveToJsonString | ( | ) |
| bool Scene::LoadFromJsonString | ( | const std::string & | jsonStr | ) |
| DekiObject * Scene::DuplicateObject | ( | const DekiObject * | source | ) |
| bool Scene::ExpandInstance | ( | DekiObject * | instanceObj | ) |
| void Scene::CollapseInstance | ( | DekiObject * | instanceObj | ) |
| void Scene::ApplyOverrides | ( | DekiObject * | instanceObj, |
| const nlohmann::json & | overrides ) |
| void Scene::CollectOverrides | ( | const DekiObject * | instanceRoot, |
| const DekiObject * | obj, | ||
| nlohmann::json & | overrides ) const |
|
static |
Property keys found in a scene file that no component's current metadata recognises, as {component type name, key}.
Reflected member names ARE the scene-file format: reflection_codegen emits each C++ identifier as a DekiHashString key, with no opt-in gate. So renaming a reflected member silently changes the on-disk key, the parser's switch falls through, and the property reverts to its default — no error, no log line. The value itself survives (unknown keys are re-emitted on save), but the behaviour is gone.
This is the detector for that. Load every scene in a project and assert this comes back empty; a missed rename names itself. Populated on load, so it reflects the scenes loaded so far in this session.
|
static |
Forget everything collected so far, so a check can scope itself to the scenes it is about to load.
Clears the legacy list too.
|
static |
Property keys read through a DEKI_RENAMED_FROM alias since the last clear, as {component type name, old key}: the file still carries the name from before a rename.
A save writes the current name, so this is a warning ("re-save to migrate"), not an error.
|
static |
Every reflected property of comp — its base class's first, then its own — as the JSON a scene file holds for it, keyed by reflected name.
The same writer SaveToFile uses, so a value prints exactly as it would be saved. The docs build reads default values through this.
|
static |
ComponentPropertiesToJson for a default-constructed instance of meta.
Null when the type is abstract or has no factory.
| void Scene::SetOnObjectsAboutToBeDestroyed | ( | OnObjectsAboutToBeDestroyedFn | fn | ) |
Out of line: the callback is stored in a side table in Scene.cpp, not in a member, so that sizeof(Scene) does not depend on DEKI_EDITOR.
std::function is 32 bytes here — too much to carry unconditionally on an embedded target that can never invoke it.
|
inline |
|
inline |
|
inline |
|
staticconstexpr |
Asset type name for AssetManager::Load<T>() lookup.
|
static |