Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Utils.CodecPropertyString Class Reference

Provides support for encoding/decoding various data types from/to property strings. More...

Inheritance diagram for Dragengine.Utils.CodecPropertyString:

Public Member Functions

CollisionFilter decodeCollisionFilter (String value, Dictionary filterBitMap)
 Decode CollisionFilter using filter bit names.
Color decodeColor3 (String string)
 Decode property string into a 3-component color.
Color decodeColor4 (String string)
 Decode property string into a 4-component color.
DVector decodeDVector (String string)
 Decode property string into a 3-component dvector.
Array decodeFixedIntList (String string, int valueCount)
 Decode property string into a fixed sized list of integer point values.
Array decodeFloatList (String string)
 Decode property string into a list of floating point values.
FloatRectArea decodeFloatRectArea (String string)
 Decode property string into a 4-component vector.
LayerMask decodeLayerMask (String value)
 Decode LayerMask.
Point decodePoint (String string)
 Decode property string into a 2-component point.
RectArea decodeRectArea (String string)
 Decode property string into a rectangular area.
ShapeList decodeShapeList (String string)
 Decode property string into a shape list.
Dictionary decodeStringDictionary (String string)
 Decode property string into a dictionary of key/value strings.
Array decodeStringList (String string)
 Decode property string into a list of strings.
Vector2 decodeVector2 (String string)
 Decode property string into a 2-component vector.
String encodeCollisionFilter (CollisionFilter collisionFilter, Dictionary filterBitMap)
 Encode CollisionFilter using filter bit map.
String encodeColor3 (Color color)
 Encode a 3-component color into a property string.
String encodeColor4 (Color color)
 Encode a 4-component color into a property string.
String encodeDVector (DVector vector)
 Encode a 3-component dvector into a property string.
String encodeFloatRectArea (FloatRectArea area)
 Encode a 4-component vector into a property string.
String encodeLayerMask (LayerMask mask)
 Encode LayerMask.
String encodeLayerMask (LayerMask mask, Dictionary layerMap)
 Encode LayerMask using layer bit map.
String encodePoint (Point point)
 Encode a 2-component point into a property string.
String encodeRectArea (RectArea area)
 Encode a rectangular area into a property string.
String encodeShapeList (ShapeList list)
 Encode shape list into a property string.
String encodeStringDictionary (Dictionary dict)
 Encode a string dictionary into a property string.
String encodeStringList (Array list)
 Encode a string list into a property string.
String encodeVector2 (Vector2 vector)
 Encode a 2-component vector into a property string.
byte getEncodeTokenSeparator ()
 Character to separate tokens with for encoding.
byte getKeyValueSeparator ()
 Separator for key and value in dictionaries.
byte getShapeParameterSeparator ()
 Shape parameter separator character.
byte getShapeValueSeparator ()
 Shape value separator character.
String getTokenSeparators ()
 Basic separators for tokens in property strings containing multiple values.
bool isFalse (String value)
 Value does not equal "true", "yes" or "1".
bool isTrue (String value)
 Value equals "true", "yes" or "1".
CodecPropertyString new ()
 Create codec.
void setEncodeTokenSeparator (byte separator)
 Set character to separate tokens with for encoding.
void setKeyValueSeparator (byte separator)
 Set separator for key and value in dictionaries.
void setShapeParameterSeparator (byte separator)
 Set shape parameter separator character.
void setShapeValueSeparator (byte separator)
 Set shape value separator character.
void setTokenSeparators (String separators)
 Set basic separators for tokens in property strings containing multiple values.

Public Attributes

byte pEncodeTokenSeparator
 Character to separate tokens with for encoding.
byte pKeyValueSeparator
 Separator for key and value in dictionaries.
byte pShapeParameterSeparator
 Shape parameter separator character.
byte pShapeValueSeparator
 Shape value separator character.
String pTokenSeparators
 Basic separators for tokens in property strings containing multiple values.

Static Public Attributes

static final Array pTrueValues = Array.newWith("true", "yes", "1")

Detailed Description

Provides support for encoding/decoding various data types from/to property strings.

Shape List Encoding

Shape list strings contain one or more shape definitions separated by whitespaces. The accepted separaters can be modified using CodecPropertyString.setTokenSeparators().

shape1 whitespaces shape2 whitespaces ... shapeN

Shape definitions contain the shape type and a list of parameters separated by colons without spaces. The separator can be modified using CodecPropertyString.setShapeParameterSeparator().

shapeType : parameter1 : parameter2 : ... parameterN

Shape parameters contain the parameter name and the parameter values separated by comma without spaces. The separator can be modified using CodecPropertyString.setShapeValueSeparator().

parameterName , value1 , value2 , ... valueN

Values are decimal or integer values. An example box shape definition would look like this:

box:position,0,0.5,0:extends,2,1,0.5

The following table show the supported shapes and parameters. The shape type and parameter name colon contains the exact string to use for the shapeType and parameterName.

Shape Type Parameter Name Values Description
sphere position x, y, z Position of center of shape
sphere rotation x, y, z Rotation of sphere in degrees applied in the order Z-Axis then X-Axis then Y-Axis
sphere radius radius Radius of sphere
sphere axisScaling x, y Axis scaling of sphere to create ellipsoid
box position x, y, z Position of center of box
box rotation x, y, z Rotation of box in degrees applied in the order Z-Axis then X-Axis then Y-Axis
box extends x, y, z Extends from center to box border. These are half the dimension of the box
box tapering x, y Tapering of box scaling the top side.
cylinder position x, y, z Position of center of cylinder
cylinder rotation x, y, z Rotation of cylinder in degrees applied in the order Z-Axis then X-Axis then Y-Axis
cylinder height height Height of cylinder from center to the top respective bottom
cylinder radius top, bottom Radius of top and bottom cap of cylinder. Use different radi for tapered cylinders
cylinder topAxisScaling x, y Scaling of top cap of cylinder. Allows for squeezed cylinders
cylinder bottomAxisScaling x, y Scaling of bottom cap of cylinder. Allows for squeezed cylinders
capsule position x, y, z Position of center of capsule
capsule rotation x, y, z Rotation of capsule in degrees applied in the order Z-Axis then X-Axis then Y-Axis
capsule height height Height of capsule from center to the top respective bottom
capsule radius top, bottom Radius of top and bottom cap of capsule. Use different radi for tapered capsules
capsule topAxisScaling x, y Scaling of top cap of capsule. Allows for squeezed capsules
capsule bottomAxisScaling x, y Scaling of bottom cap of capsule. Allows for squeezed capsules
hull position x, y, z Position of center of hull
hull rotation x, y, z Rotation of hull in degrees applied in the order Z-Axis then X-Axis then Y-Axis
hull points x1, y1, z1, ..., xN, yN, zN Hull points

Member Function Documentation

◆ decodeCollisionFilter()

CollisionFilter Dragengine.Utils.CodecPropertyString.decodeCollisionFilter ( String value,
Dictionary filterBitMap )

Decode CollisionFilter using filter bit names.

Version
1.35

Value is encoded either as "category:filter", "category" or empty string.

Empty string creates collision filter with empty category and full filter.

Second form is the same as first form with filter equal to category.

Category and filter decode the same way as #decodeLayerMask(String,Dictionary).

References pTokenSeparators.

Referenced by encodeCollisionFilter().

◆ decodeColor3()

Color Dragengine.Utils.CodecPropertyString.decodeColor3 ( String string)

Decode property string into a 3-component color.

Referenced by encodeCollisionFilter().

◆ decodeColor4()

Color Dragengine.Utils.CodecPropertyString.decodeColor4 ( String string)

Decode property string into a 4-component color.

Accepts also 3-component color in which case alpha is 1.

Referenced by encodeCollisionFilter().

◆ decodeDVector()

DVector Dragengine.Utils.CodecPropertyString.decodeDVector ( String string)

Decode property string into a 3-component dvector.

References pTrueValues.

Referenced by encodeCollisionFilter().

◆ decodeFixedIntList()

Array Dragengine.Utils.CodecPropertyString.decodeFixedIntList ( String string,
int valueCount )

Decode property string into a fixed sized list of integer point values.

References setEncodeTokenSeparator().

Referenced by decodeShapeList(), and encodeCollisionFilter().

◆ decodeFloatList()

Array Dragengine.Utils.CodecPropertyString.decodeFloatList ( String string)

Decode property string into a list of floating point values.

Version
1.26

Referenced by decodeVector2().

◆ decodeFloatRectArea()

FloatRectArea Dragengine.Utils.CodecPropertyString.decodeFloatRectArea ( String string)

Decode property string into a 4-component vector.

Decode property string into a 4-component dvector.

Decode property string into a floating point rectangular area.

Referenced by encodeCollisionFilter().

◆ decodeLayerMask()

LayerMask Dragengine.Utils.CodecPropertyString.decodeLayerMask ( String value)

Decode LayerMask.

Version
1.25

Value is encoded as "bit1 bit2 ... bitN".

Deprecated
Use #decodeLayerMask(String,Dictionary) instead.

References decodeStringList(), and new().

Referenced by encodeCollisionFilter().

◆ decodePoint()

Point Dragengine.Utils.CodecPropertyString.decodePoint ( String string)

Decode property string into a 2-component point.

Referenced by encodeCollisionFilter().

◆ decodeRectArea()

RectArea Dragengine.Utils.CodecPropertyString.decodeRectArea ( String string)

Decode property string into a rectangular area.

References new(), and pTokenSeparators.

Referenced by encodeCollisionFilter().

◆ decodeShapeList()

ShapeList Dragengine.Utils.CodecPropertyString.decodeShapeList ( String string)

Decode property string into a shape list.

References decodeFixedIntList(), new(), and pTokenSeparators.

Referenced by encodeCollisionFilter().

◆ decodeStringDictionary()

Dictionary Dragengine.Utils.CodecPropertyString.decodeStringDictionary ( String string)

Decode property string into a dictionary of key/value strings.

Key/value pairs are obtained using decodeStringList(). Key and value are separated by pKeyValueSeparator.

References isTrue().

Referenced by encodeCollisionFilter().

◆ decodeStringList()

Array Dragengine.Utils.CodecPropertyString.decodeStringList ( String string)

Decode property string into a list of strings.

References pEncodeTokenSeparator.

Referenced by decodeLayerMask(), and encodeCollisionFilter().

◆ decodeVector2()

Vector2 Dragengine.Utils.CodecPropertyString.decodeVector2 ( String string)

Decode property string into a 2-component vector.

References decodeFloatList(), isFalse(), pTokenSeparators, and pTrueValues.

Referenced by encodeCollisionFilter().

◆ encodeCollisionFilter()

◆ encodeColor3()

String Dragengine.Utils.CodecPropertyString.encodeColor3 ( Color color)

Encode a 3-component color into a property string.

Referenced by encodeCollisionFilter().

◆ encodeColor4()

String Dragengine.Utils.CodecPropertyString.encodeColor4 ( Color color)

Encode a 4-component color into a property string.

Referenced by encodeCollisionFilter().

◆ encodeDVector()

String Dragengine.Utils.CodecPropertyString.encodeDVector ( DVector vector)

Encode a 3-component dvector into a property string.

Referenced by encodeCollisionFilter().

◆ encodeFloatRectArea()

String Dragengine.Utils.CodecPropertyString.encodeFloatRectArea ( FloatRectArea area)

Encode a 4-component vector into a property string.

Encode a 4-component vector into a property string.

Encode a floating point rectangular area into a property string.

Referenced by encodeCollisionFilter().

◆ encodeLayerMask() [1/2]

String Dragengine.Utils.CodecPropertyString.encodeLayerMask ( LayerMask mask)

Encode LayerMask.

Version
1.25
See also
decodeLayerMask()
Deprecated
Use encodeLayerMask(LayerMask,Dictionary) instead.

Referenced by encodeCollisionFilter().

◆ encodeLayerMask() [2/2]

String Dragengine.Utils.CodecPropertyString.encodeLayerMask ( LayerMask mask,
Dictionary layerMap )

Encode LayerMask using layer bit map.

Version
1.25
See also
#decodeLayerMask(String,Dictionary).

◆ encodePoint()

String Dragengine.Utils.CodecPropertyString.encodePoint ( Point point)

Encode a 2-component point into a property string.

Referenced by encodeCollisionFilter().

◆ encodeRectArea()

String Dragengine.Utils.CodecPropertyString.encodeRectArea ( RectArea area)

Encode a rectangular area into a property string.

Referenced by encodeCollisionFilter().

◆ encodeShapeList()

String Dragengine.Utils.CodecPropertyString.encodeShapeList ( ShapeList list)

Encode shape list into a property string.

References pTokenSeparators.

Referenced by encodeCollisionFilter().

◆ encodeStringDictionary()

String Dragengine.Utils.CodecPropertyString.encodeStringDictionary ( Dictionary dict)

Encode a string dictionary into a property string.

Referenced by encodeCollisionFilter().

◆ encodeStringList()

String Dragengine.Utils.CodecPropertyString.encodeStringList ( Array list)

Encode a string list into a property string.

Referenced by encodeCollisionFilter().

◆ encodeVector2()

String Dragengine.Utils.CodecPropertyString.encodeVector2 ( Vector2 vector)

Encode a 2-component vector into a property string.

Referenced by encodeCollisionFilter().

◆ getEncodeTokenSeparator()

byte Dragengine.Utils.CodecPropertyString.getEncodeTokenSeparator ( )

Character to separate tokens with for encoding.

Version
1.23

References pShapeParameterSeparator, and setShapeParameterSeparator().

Referenced by isFalse().

◆ getKeyValueSeparator()

byte Dragengine.Utils.CodecPropertyString.getKeyValueSeparator ( )

Separator for key and value in dictionaries.

Version
1.23

References setTokenSeparators().

Referenced by getShapeParameterSeparator().

◆ getShapeParameterSeparator()

byte Dragengine.Utils.CodecPropertyString.getShapeParameterSeparator ( )

Shape parameter separator character.

Version
1.23

References getKeyValueSeparator(), and pKeyValueSeparator.

Referenced by getShapeValueSeparator().

◆ getShapeValueSeparator()

byte Dragengine.Utils.CodecPropertyString.getShapeValueSeparator ( )

Shape value separator character.

Version
1.23

References getShapeParameterSeparator().

Referenced by setEncodeTokenSeparator().

◆ getTokenSeparators()

String Dragengine.Utils.CodecPropertyString.getTokenSeparators ( )

Basic separators for tokens in property strings containing multiple values.

Version
1.23

Referenced by setTokenSeparators().

◆ isFalse()

bool Dragengine.Utils.CodecPropertyString.isFalse ( String value)

Value does not equal "true", "yes" or "1".

Version
1.25

References getEncodeTokenSeparator(), and pEncodeTokenSeparator.

Referenced by decodeVector2().

◆ isTrue()

bool Dragengine.Utils.CodecPropertyString.isTrue ( String value)

Value equals "true", "yes" or "1".

Version
1.25

References pShapeValueSeparator, and setShapeValueSeparator().

Referenced by decodeStringDictionary().

◆ new()

◆ setEncodeTokenSeparator()

void Dragengine.Utils.CodecPropertyString.setEncodeTokenSeparator ( byte separator)

Set character to separate tokens with for encoding.

Version
1.23

References getShapeValueSeparator(), and pShapeValueSeparator.

Referenced by decodeFixedIntList().

◆ setKeyValueSeparator()

void Dragengine.Utils.CodecPropertyString.setKeyValueSeparator ( byte separator)

Set separator for key and value in dictionaries.

Version
1.23

References pTokenSeparators.

Referenced by setShapeParameterSeparator().

◆ setShapeParameterSeparator()

void Dragengine.Utils.CodecPropertyString.setShapeParameterSeparator ( byte separator)

Set shape parameter separator character.

Version
1.23

References pKeyValueSeparator, and setKeyValueSeparator().

Referenced by getEncodeTokenSeparator().

◆ setShapeValueSeparator()

void Dragengine.Utils.CodecPropertyString.setShapeValueSeparator ( byte separator)

Set shape value separator character.

Version
1.23

References pShapeParameterSeparator.

Referenced by isTrue().

◆ setTokenSeparators()

void Dragengine.Utils.CodecPropertyString.setTokenSeparators ( String separators)

Set basic separators for tokens in property strings containing multiple values.

Version
1.23

References getTokenSeparators(), and pTokenSeparators.

Referenced by getKeyValueSeparator().

Member Data Documentation

◆ pEncodeTokenSeparator

byte Dragengine.Utils.CodecPropertyString.pEncodeTokenSeparator

Character to separate tokens with for encoding.

Referenced by decodeStringList(), encodeCollisionFilter(), isFalse(), and new().

◆ pKeyValueSeparator

byte Dragengine.Utils.CodecPropertyString.pKeyValueSeparator

Separator for key and value in dictionaries.

Referenced by encodeCollisionFilter(), getShapeParameterSeparator(), new(), and setShapeParameterSeparator().

◆ pShapeParameterSeparator

byte Dragengine.Utils.CodecPropertyString.pShapeParameterSeparator

Shape parameter separator character.

Referenced by encodeCollisionFilter(), getEncodeTokenSeparator(), new(), and setShapeValueSeparator().

◆ pShapeValueSeparator

byte Dragengine.Utils.CodecPropertyString.pShapeValueSeparator

Shape value separator character.

Referenced by encodeCollisionFilter(), isTrue(), new(), and setEncodeTokenSeparator().

◆ pTokenSeparators

String Dragengine.Utils.CodecPropertyString.pTokenSeparators

Basic separators for tokens in property strings containing multiple values.

Referenced by decodeCollisionFilter(), decodeRectArea(), decodeShapeList(), decodeVector2(), encodeCollisionFilter(), encodeShapeList(), new(), setKeyValueSeparator(), and setTokenSeparators().

◆ pTrueValues

final Array Dragengine.Utils.CodecPropertyString.pTrueValues = Array.newWith("true", "yes", "1")
static

Referenced by decodeDVector(), and decodeVector2().


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