Nebula
Loading...
Searching...
No Matches
Scripting::PropertyLevelExtension Class Reference

#include <propertyextension.h>

Detailed Description

The level formats' contribution for managed properties.

This is the side that knows what the json means, and the formats only know the extension by name.

The managed entry points are resolved once at registration and cached here, which is what keeps the level format from resolving them through hostfxr for every entity it writes.

The text is the entity as one node per property. It is the only shape the formats can use, because they cannot read the text and cannot group it, and it is the shape an editor command holds as well: a command applies the entity's whole text, which is what makes a change that took a property off read as a change rather than as an addition.

What an editor knows that this side cannot read is handed over as callbacks: the change the managed write path reported, the key a marker was pressed on, and whether a row is the instance's own. These are the editor's half of the contract, and they are null in a build that has no editor.

See also
Game::LevelExtension

Public Types

using ChangeFunc = void(*)(uint64_t entityId, const char* path, const char* oldText, const char* newText)
 what an editor hands the extension when it attaches.
using RevertFunc = void(*)(uint64_t entityId, const char* path)
 what an editor hands the extension for a revert request.
using AuthoredFunc = bool(*)(uint64_t entityId, const char* path)
 what an editor hands the extension for the override marker.

Static Public Member Functions

static void SetChangeCallback (ChangeFunc func)
 An editor attaches itself here.
static void SetRevertCallback (RevertFunc func)
 An editor attaches itself here.
static void SetAuthoredCallback (AuthoredFunc func)
 An editor attaches itself here.
static void Register (Scripting::NSharpServer *server, Scripting::AssemblyId assemblyId)
 resolve the managed entry points and register the extension with the level formats
static void Capture (Game::Entity entity, Util::String &out)
 the json for one entity, as the managed runtime produces it
static void Apply (Game::Entity entity, const char *json)
 one entity, put back from the json the file carried for it
static void CaptureKeys (Game::Entity entity, const Util::Array< Util::String > &keys, Util::String &out)
 the json for one entity with only the named keys, which is what a linked entity writes
static void TextKeys (const char *text, Util::Array< Util::String > &out)
 the keys a text carries, as the paths this extension names them by
static void Merge (const char *base, const char *over, Util::String &out)
 what the base text gives when the keys the other text carries are put over it
static void Resolve (const char *base, const Util::Array< Util::String > &keys, Util::String &out)
 the text for the named keys, each value read from the base text, or the field's default when the base has nothing.
static void SetRefContext (const char *pairs)
 the file's guid map, as "guid:entityId" pairs.
static void TextRefs (const char *text, Util::Array< Game::TextRef > &out)
 the entity references a text names, as the paths this extension names its fields by.
static void Remap (const char *text, const char *pairs, Util::String &out)
 the text with the named paths' references put as the given guids, as "path\tguid" pairs
static void ClearMirror (uint32_t worldId)
 the mirror this extension keeps of a world, dropped.
static void Draw (Game::Entity entity)
 the property section, drawn by the managed side through the editor's ImGui surface.
static Util::StringAtom ExtensionName ()
 the name the extension registered under, which is what the editor's override marker is keyed by
static void RecordChange (Game::Entity entity, const char *path, const char *oldText, const char *newText)
 the change the managed write path reported.
static void RequestRevert (Game::Entity entity, const char *path)
 the key the managed side pressed the override marker on.
static bool IsAuthored (Game::Entity entity, const char *path)
 whether the editor's marker says this entity authored the path.
static void AddPropertyName (const char *propertyName)
 One of the names the editor's dropdown lists.
static void ClearPropertyNames ()
static const Util::Array< Util::String > & PropertyNames ()
static bool HasProperty (Game::Entity entity, const char *propertyName)
 true when the entity has the property, which is what makes a dropdown row read as already added
static void DefaultPropertyJson (const char *propertyName, Util::String &out)
 the text a default instance of the property produces, which is what an add writes

Static Private Attributes

static void * serializeProperties = nullptr
static void * applyProperties = nullptr
static void * drawProperties = nullptr
static void * hasProperty = nullptr
static void * defaultPropertyJson = nullptr
static void * serializeKeys = nullptr
static void * jsonKeys = nullptr
static void * mergeJson = nullptr
static void * resolveJson = nullptr
static void * setRefContext = nullptr
static void * textRefs = nullptr
static void * remapRefs = nullptr
static void * clearWorldMirror = nullptr
static ChangeFunc changeCallback = nullptr
static RevertFunc revertCallback = nullptr
static AuthoredFunc authoredCallback = nullptr
static bool registered = false
static Util::StringAtom extensionName
static Util::Array< char > buffer
static Util::Array< Util::String > names

Member Typedef Documentation

◆ AuthoredFunc

using Scripting::PropertyLevelExtension::AuthoredFunc = bool(*)(uint64_t entityId, const char* path)

what an editor hands the extension for the override marker.

The marker is the editor's own and this side cannot read it, so a row asks rather than being told. Null when nothing is attached, which is what makes the managed call a no-op in a build that has no editor

◆ ChangeFunc

using Scripting::PropertyLevelExtension::ChangeFunc = void(*)(uint64_t entityId, const char* path, const char* oldText, const char* newText)

what an editor hands the extension when it attaches.

The managed write path calls the exported RecordPropertyChange, which comes here. Null when nothing is attached, which is what makes the managed call a no-op in a build that has no editor

◆ RevertFunc

using Scripting::PropertyLevelExtension::RevertFunc = void(*)(uint64_t entityId, const char* path)

what an editor hands the extension for a revert request.

The managed side can only say which key was pressed on; what a press means is the editor's decision, and this is the function it answers with

Member Function Documentation

◆ AddPropertyName()

void Scripting::PropertyLevelExtension::AddPropertyName ( const char * propertyName)
static

One of the names the editor's dropdown lists.

The panel has no way to read the managed registry, so the managed side mirrors it here.

◆ Apply()

void Scripting::PropertyLevelExtension::Apply ( Game::Entity entity,
const char * json )
static

one entity, put back from the json the file carried for it

One entity, put back from the json the file carried for it.

◆ Capture()

void Scripting::PropertyLevelExtension::Capture ( Game::Entity entity,
Util::String & out )
static

the json for one entity, as the managed runtime produces it

The json for one entity.

The managed side writes into the buffer this owns and answers with the length it needs when the buffer was too small, which is what makes the call be made again with a bigger one.

◆ CaptureKeys()

void Scripting::PropertyLevelExtension::CaptureKeys ( Game::Entity entity,
const Util::Array< Util::String > & keys,
Util::String & out )
static

the json for one entity with only the named keys, which is what a linked entity writes

The text for one entity with only the keys it authored.

The keys are joined here rather than passed as an array, because the managed side cannot read this side's containers, and the same buffer pattern as the entity capture is what makes the length come back right when the buffer was too small.

◆ ClearMirror()

void Scripting::PropertyLevelExtension::ClearMirror ( uint32_t worldId)
static

the mirror this extension keeps of a world, dropped.

The mirror this extension keeps of a world, dropped.

This is the only way the side that owns the mirror can be told that a world was emptied and refilled, because the formats cannot know which world an extension mirrors

The formats cannot know which world an extension mirrors, so this is how a build that empties and refills a world tells this side that the mirror has to go with the content it had.

◆ ClearPropertyNames()

void Scripting::PropertyLevelExtension::ClearPropertyNames ( )
static

◆ DefaultPropertyJson()

void Scripting::PropertyLevelExtension::DefaultPropertyJson ( const char * propertyName,
Util::String & out )
static

the text a default instance of the property produces, which is what an add writes

The text a default instance of the property produces, which is what an add writes.

Same buffer as the capture, because the managed side writes into it directly and nothing here is reentrant.

◆ Draw()

void Scripting::PropertyLevelExtension::Draw ( Game::Entity entity)
static

the property section, drawn by the managed side through the editor's ImGui surface.

The property section.

Only called from inside the editor's frame, which is the only place the surface is reachable from

The managed side draws through the editor's surface, so this has to be called from inside the editor's frame, and it does nothing when the entry point could not be resolved.

◆ ExtensionName()

Util::StringAtom Scripting::PropertyLevelExtension::ExtensionName ( )
static

the name the extension registered under, which is what the editor's override marker is keyed by

◆ HasProperty()

bool Scripting::PropertyLevelExtension::HasProperty ( Game::Entity entity,
const char * propertyName )
static

true when the entity has the property, which is what makes a dropdown row read as already added

Whether the entity has the property.

This is what makes a dropdown row read as already added, the same way a component that is already on the entity does.

◆ IsAuthored()

bool Scripting::PropertyLevelExtension::IsAuthored ( Game::Entity entity,
const char * path )
static

whether the editor's marker says this entity authored the path.

Whether the editor's marker says this entity authored the path.

A path with no field asks whether any field of the property is authored, which is what a section row answers with

The marker is the editor's own and this side cannot read it, so a row asks. Without a callback nothing is authored, which is what makes a game build a no-op.

◆ Merge()

void Scripting::PropertyLevelExtension::Merge ( const char * base,
const char * over,
Util::String & out )
static

what the base text gives when the keys the other text carries are put over it

What the base text gives when the keys the other text carries are put over it.

The formats compose the text without reading it, which is what keeps a merge from needing to know what a managed property is.

◆ PropertyNames()

const Util::Array< Util::String > & Scripting::PropertyLevelExtension::PropertyNames ( )
static

◆ RecordChange()

void Scripting::PropertyLevelExtension::RecordChange ( Game::Entity entity,
const char * path,
const char * oldText,
const char * newText )
static

the change the managed write path reported.

The change the managed write path reported.

Runs the callback, which is what builds the command. The path is the key inside the text the change is about, which is the only place the editor ever learns what a key means, and a path with no field is the whole property

The managed side does not write anything itself: it works out the text before and after and hands both here, and the callback is what runs the change through a command. Without a callback there is nothing to record, which is what makes a game build a no-op.

The path is the key inside the text the change is about. A path with no field is the whole property, which is what an add and a removal report.

◆ Register()

void Scripting::PropertyLevelExtension::Register ( Scripting::NSharpServer * server,
Scripting::AssemblyId assemblyId )
static

resolve the managed entry points and register the extension with the level formats

The extension is registered by the feature unit, which is what puts the hook in place before the plugin loads and what keeps the level formats from knowing anything about scripting.

◆ Remap()

void Scripting::PropertyLevelExtension::Remap ( const char * text,
const char * pairs,
Util::String & out )
static

the text with the named paths' references put as the given guids, as "path\tguid" pairs

The text with the named paths' references put as the given guids.

The same buffer pattern as the merge is what makes the length come back right when the buffer was too small.

◆ RequestRevert()

void Scripting::PropertyLevelExtension::RequestRevert ( Game::Entity entity,
const char * path )
static

the key the managed side pressed the override marker on.

The key the managed side pressed the override marker on.

Runs the callback, which is what builds the revert. A path with no field is the whole property

The managed side cannot know what a press means, so it only says which key it was, and the callback is what builds the revert. Without a callback there is nothing to do, which is what makes a game build a no-op.

◆ Resolve()

void Scripting::PropertyLevelExtension::Resolve ( const char * base,
const Util::Array< Util::String > & keys,
Util::String & out )
static

the text for the named keys, each value read from the base text, or the field's default when the base has nothing.

The text for the named keys, each value read from the base text, or the field's default when the base has nothing.

This is what a revert to the prefab writes, because a key the chain does not carry has no value to put back

This is what a revert to the prefab writes, and the same buffer pattern as the merge is what makes the length come back right when the buffer was too small.

◆ SetAuthoredCallback()

void Scripting::PropertyLevelExtension::SetAuthoredCallback ( AuthoredFunc func)
static

An editor attaches itself here.

A build that has no editor leaves the callback null, and the managed row is a no-op for that build.

◆ SetChangeCallback()

void Scripting::PropertyLevelExtension::SetChangeCallback ( ChangeFunc func)
static

An editor attaches itself here.

A build that has no editor leaves the callback null, and the managed write path is a no-op for that build.

◆ SetRefContext()

void Scripting::PropertyLevelExtension::SetRefContext ( const char * pairs)
static

the file's guid map, as "guid:entityId" pairs.

The file's guid map, as "guid:entityId" pairs.

Only valid for the duration of the call that sets it, which is what makes a merged text resolve against the files it names guids from

The formats cannot resolve what a text names, because they do not read it, so this is how the map gets to the side that does. It is only valid for the duration of the call that sets it.

◆ SetRevertCallback()

void Scripting::PropertyLevelExtension::SetRevertCallback ( RevertFunc func)
static

An editor attaches itself here.

A build that has no editor leaves the callback null, and the managed press is a no-op for that build.

◆ TextKeys()

void Scripting::PropertyLevelExtension::TextKeys ( const char * text,
Util::Array< Util::String > & out )
static

the keys a text carries, as the paths this extension names them by

The keys a text carries, as the paths this extension names them by.

This is the only thing the level formats can know about a text they cannot read, and it is what tells an authored field from one the entity accepts from its prefab.

◆ TextRefs()

void Scripting::PropertyLevelExtension::TextRefs ( const char * text,
Util::Array< Game::TextRef > & out )
static

the entity references a text names, as the paths this extension names its fields by.

The entity references a text names.

Only this side can answer, because the formats cannot read the text

The managed side answers them as "path\tguid" lines, because this side cannot read the text, and the buffer is the only thing that comes back across the boundary. The strings have to be copied out of the buffer before it is used for anything else.

Member Data Documentation

◆ applyProperties

void * Scripting::PropertyLevelExtension::applyProperties = nullptr
staticprivate

◆ authoredCallback

PropertyLevelExtension::AuthoredFunc Scripting::PropertyLevelExtension::authoredCallback = nullptr
staticprivate

◆ buffer

Util::Array< char > Scripting::PropertyLevelExtension::buffer
staticprivate

◆ changeCallback

PropertyLevelExtension::ChangeFunc Scripting::PropertyLevelExtension::changeCallback = nullptr
staticprivate

◆ clearWorldMirror

void * Scripting::PropertyLevelExtension::clearWorldMirror = nullptr
staticprivate

◆ defaultPropertyJson

void * Scripting::PropertyLevelExtension::defaultPropertyJson = nullptr
staticprivate

◆ drawProperties

void * Scripting::PropertyLevelExtension::drawProperties = nullptr
staticprivate

◆ extensionName

Util::StringAtom Scripting::PropertyLevelExtension::extensionName
staticprivate

◆ hasProperty

void * Scripting::PropertyLevelExtension::hasProperty = nullptr
staticprivate

◆ jsonKeys

void * Scripting::PropertyLevelExtension::jsonKeys = nullptr
staticprivate

◆ mergeJson

void * Scripting::PropertyLevelExtension::mergeJson = nullptr
staticprivate

◆ names

Util::Array< Util::String > Scripting::PropertyLevelExtension::names
staticprivate

◆ registered

bool Scripting::PropertyLevelExtension::registered = false
staticprivate

◆ remapRefs

void * Scripting::PropertyLevelExtension::remapRefs = nullptr
staticprivate

◆ resolveJson

void * Scripting::PropertyLevelExtension::resolveJson = nullptr
staticprivate

◆ revertCallback

PropertyLevelExtension::RevertFunc Scripting::PropertyLevelExtension::revertCallback = nullptr
staticprivate

◆ serializeKeys

void * Scripting::PropertyLevelExtension::serializeKeys = nullptr
staticprivate

◆ serializeProperties

void * Scripting::PropertyLevelExtension::serializeProperties = nullptr
staticprivate

◆ setRefContext

void * Scripting::PropertyLevelExtension::setRefContext = nullptr
staticprivate

◆ textRefs

void * Scripting::PropertyLevelExtension::textRefs = nullptr
staticprivate

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