Class TCastleVector2Persistent

Unit

Declaration

type TCastleVector2Persistent = class(TCastleComponent)

Description

TVector2 record represented as a TPersistent descendant, to be able to visually edit it (in Lazarus and Delphi visual designer, and Castle Game Engine visual designer) and to serialize it.

Normal user code does not need to deal with this class or it's instances. Instead directly operate on TVector2 values, which is faster and more natural. TVector2 are simple records, so they are naturally copied on assignment, and various operators like additions work in a natural way too.

Hierarchy

Overview

Fields

Public InternalGetValue: TGetVector2Event;
Public InternalSetValue: TSetVector2Event;
Public InternalDefaultValue: TVector2;

Methods

Protected procedure Loaded; override;
Public constructor Create(const AOwner: TComponent = nil); reintroduce;
Public function ValueIsStreamed: Boolean; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public function ToString: String; override;

Properties

Public property Value: TVector2 read GetValue write SetValue;
Published property X: Single read GetX write SetX stored XIsStored nodefault;
Published property Y: Single read GetY write SetY stored YIsStored nodefault;

Description

Fields

Public InternalGetValue: TGetVector2Event;

This item has no description.

Public InternalSetValue: TSetVector2Event;

This item has no description.

Public InternalDefaultValue: TVector2;

Default value, just like Pascal "default" property attribute, is only used to decide which vector components to write to file.

It is your responsibility to make sure that this is really the default (right after creation) state of the object, and the deserialization will just not modify components not specified (it will not reset them to InternalDefaultValue value).

Methods

Protected procedure Loaded; override;

This item has no description.

Public constructor Create(const AOwner: TComponent = nil); reintroduce;

This item has no description.

Public function ValueIsStreamed: Boolean; override;

This item has no description. Showing description inherited from TCastleComponent.ValueIsStreamed.

Whether the current value of this object should be written to the stream. This should be True if anything inside this object should be serialized (which means it has non-default value or "stored" specifier indicates that it should be serialized).

This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization.

In simple cases, this just says whether the current value of this object equals to some default value.

The default implementation of this class returns True (so always write).

Descendants that override this to sometimes return False (so no need to write) must be very careful: any addition of a new field requires extending this method, otherwise new field may not be saved sometimes (when all other fields are default). Descentants of such classes must also be aware of it. This check must include everything that is inside this object in JSON, including subcomponents and children objects (as done e.g. by TSerializationProcess.ReadWriteList). In practice, overriding this method is only reasonable for simple classes that will not change much in the future, like TCastleVector3Persistent.

The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Public function ToString: String; override;

This item has no description.

Properties

Public property Value: TVector2 read GetValue write SetValue;

This item has no description.

Published property X: Single read GetX write SetX stored XIsStored nodefault;

This item has no description.

Published property Y: Single read GetY write SetY stored YIsStored nodefault;

This item has no description.


Generated by PasDoc 0.16.0-snapshot.