Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::SceneFromDescription Class Reference

Constructs a scene tree (separate from the scene tree) based on its description in JSON. More...

#include <scene_loading.hpp>

Inheritance diagram for ToyMaker::SceneFromDescription:
ToyMaker::ResourceConstructor< SimObject, SceneFromDescription > ToyMaker::IResourceConstructor

Static Public Member Functions

static std::string getResourceConstructorName ()
 Gets this constructor's resource constructor type string.
 

Private Member Functions

void loadResources (const nlohmann::json &resourceList)
 Loads the resources listed in the resource section of this scene description.
 
std::shared_ptr< SimObjectloadSceneNodes (const nlohmann::json &nodeList)
 Loads the scene nodes listed in the "nodes" section of the scene description.
 
void loadConnections (const nlohmann::json &connectionList, std::shared_ptr< SceneNodeCore > localRoot)
 Loads connections between nodes (functioning as SignalTrackers) within a scene.
 
void overrideComponents (std::shared_ptr< SimObject > node, const nlohmann::json &componentList)
 (When used as a node in another scene) a list of overrides to ECSWorld components to be applied to the root node of an imported scene.
 
void overrideAspects (std::shared_ptr< SimObject > node, const nlohmann::json &aspectList)
 (When used as a node in another scene) a list of overrides to SimObjectAspects to be applied to the root node of an imported scene.
 
std::shared_ptr< IResourcecreateResource (const nlohmann::json &methodParams) override
 Actually creates a scene tree out of its JSON description.
 

Additional Inherited Members

- Public Member Functions inherited from ToyMaker::ResourceConstructor< SimObject, SceneFromDescription >
std::string getResourceConstructorName_ () const override
 Gets the resource constructor type string of the constructor.
 
- Public Member Functions inherited from ToyMaker::IResourceConstructor
virtual ~IResourceConstructor ()=default
 Destroys this resource constructor (when the application is terminated.)
 
- Protected Member Functions inherited from ToyMaker::ResourceConstructor< SimObject, SceneFromDescription >
 ResourceConstructor (int explicitlyInitializeMe)
 Construct a new ResourceConstructor object.
 
- Protected Member Functions inherited from ToyMaker::IResourceConstructor
 IResourceConstructor ()=default
 Construct a new IResourceConstructor object.
 
- Static Protected Member Functions inherited from ToyMaker::IResourceConstructor
template<typename TResource, typename TResourceConstructor>
static void RegisterResourceConstructor ()
 Registers this resource constructor against its respective ResourceFactory during static initialization.
 

Detailed Description

Constructs a scene tree (separate from the scene tree) based on its description in JSON.

It will have, as its root, a SimObject which serves (or is intended to serve) as the interface between it and the scene it was imported into.

An example of such a json description is given below:

{
"resources": [],
"nodes": [
{
"name": "ur_button",
"aspects": [
{
"type": "UIButton",
"anchor": [0.5, 0.5],
"scale": 1.0,
"value": "",
"text": "Default Text",
"font_resource_name": "Roboto_Mono_Regular_24",
"panel_active": "Bad_Panel",
"panel_inactive": "Bad_Panel",
"panel_hover": "Bad_Panel",
"panel_pressed": "Bad_Panel",
"has_highlight": false,
"highlight": "Bad_Panel",
"highlight_color": [0, 0, 0, 0]
}
],
"components": [
{
"orientation": [ 1.0, 0.0, 0.0, 0.0 ],
"position": [ 0.0, 0.0, 0.0, 1.0 ],
"scale": [ 1.0, 1.0, 1.0 ],
"type": "Placement"
}
],
"parent": "",
"type": "SimObject"
},
{
"name": "button_text",
"parent": "/",
"type": "SimObject",
"components": [
{
"orientation": [ 1.0, 0.0, 0.0, 0.0 ],
"position": [ 0.0, 0.0, 0.0, 1.0 ],
"scale": [ 1.0, 1.0, 1.0 ],
"type": "Placement"
}
],
"aspects": [
{
"type": "UIText",
"text": "Default Text",
"font_resource_name": "Roboto_Mono_Regular_24",
"scale": 1.0,
"anchor": [1.0, 1.0]
}
]
},
{
"name": "highlight",
"parent": "/",
"type": "SceneNode",
"components": [
{
"orientation": [1.0, 0.0, 0.0, 0.0],
"position": [ 0.0, 0.0, 0.0, 1.0 ],
"scale": [ 1.0, 1.0, 1.0 ],
"type": "Placement"
}
]
}
],
"connections": []
}
See also
SceneNodeFromDescription
SimObjectFromDescription
ViewportNodeFromDescription
SignalTracker

Member Function Documentation

◆ createResource()

std::shared_ptr< IResource > SceneFromDescription::createResource ( const nlohmann::json & methodParams)
overrideprivatevirtual

Actually creates a scene tree out of its JSON description.

Parameters
methodParamsThe scene's description in JSON.
Returns
std::shared_ptr<IResource> A handle to the base pointer of the root node of a newly created scene.

Implements ToyMaker::IResourceConstructor.

◆ getResourceConstructorName()

static std::string ToyMaker::SceneFromDescription::getResourceConstructorName ( )
inlinestatic

Gets this constructor's resource constructor type string.

Returns
std::string This constructor's resource constructor type string.

◆ loadConnections()

void SceneFromDescription::loadConnections ( const nlohmann::json & connectionList,
std::shared_ptr< SceneNodeCore > localRoot )
private

Loads connections between nodes (functioning as SignalTrackers) within a scene.

Parameters
connectionListA list of SimObjectAspect -> SimObjectAspect signal -> observer connections.
localRootThe root of the scene being constructed, relative to which scene paths are evaluated.

◆ loadResources()

void SceneFromDescription::loadResources ( const nlohmann::json & resourceList)
private

Loads the resources listed in the resource section of this scene description.

The resources used by this scene may have already been loaded by another scene, in which case they needn't be respecified here.

Parameters
resourceListList of Resource descriptions to load into the ResourceDatabase.

◆ loadSceneNodes()

std::shared_ptr< SimObject > SceneFromDescription::loadSceneNodes ( const nlohmann::json & nodeList)
private

Loads the scene nodes listed in the "nodes" section of the scene description.

Parameters
nodeListA list of SimObjects, SceneNodes, and ViewportNodes, describing this scene.
Returns
std::shared_ptr<SimObject> The root of the newly constructed scene tree.

◆ overrideAspects()

void SceneFromDescription::overrideAspects ( std::shared_ptr< SimObject > node,
const nlohmann::json & aspectList )
private

(When used as a node in another scene) a list of overrides to SimObjectAspects to be applied to the root node of an imported scene.

Parameters
nodeA node that was created from a scene file and imported into the present scene.
aspectListA list of aspect overrides to be applied to the imported node.

◆ overrideComponents()

void SceneFromDescription::overrideComponents ( std::shared_ptr< SimObject > node,
const nlohmann::json & componentList )
private

(When used as a node in another scene) a list of overrides to ECSWorld components to be applied to the root node of an imported scene.

Parameters
nodeA node that was created from a scene file and imported into the present scene.
componentListA list of component overrides to be applied to the imported node.

The documentation for this class was generated from the following files: