Skip to content

Class UiDataModel

Namespace: Apogee.UI
Assembly: Apogee.UI.dll

A data model: a script's table tied to documents. <p data-model="stats">{{score}}</p> shows score of the table; data-if, data-for, data-class-, data-style- and data-value (which writes back what the player types) use it too, and data-event-click="buy(1)" calls the table's function buy. The table is read when RmlUi needs a value: change it and say so with (or change a top-level field with ), and the elements that show it are updated at the next frame.

public sealed class UiDataModel : EngineObject

Inheritance

object ← EngineObject ← UiDataModel

Inherited Members

EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

The top-level fields are bound when the model is opened, so each has to exist then (use false, 0, "" or {} for a value that comes later). A field keeps its kind: a number stays a number, a list a list.

Properties

Class

What the registry knows about this object's class.

public override ClassInfo Class { get; }

Property Value

ClassInfo

IsOpen

Whether the model still exists (it is closed with , when the module that opened it reloads, and when the UI ends).

public bool IsOpen { get; }

Property Value

bool

Name

The name documents use in data-model.

public string Name { get; }

Property Value

string

Methods

Close()

Removes the model. Close the documents that use it first.

public void Close()

Dirty(string?)

Says that the field (a top-level one) or, with no name, everything changed: the elements that show it are updated at the next frame. A change inside a list or struct needs the name of the whole.

public void Dirty(string? name = null)

Parameters

name string?

IsDirty(string)

Whether the field changed since the last frame updated the documents.

public bool IsDirty(string name)

Parameters

name string

Returns

bool

OnDestroyed()

protected override void OnDestroyed()

Set(string, Value)

Sets a top-level field of the table and marks it dirty.

public bool Set(string name, Value value)

Parameters

name string

value Value

Returns

bool