Drag[en]gine Script Module DragonScript
1.23
|
Persistency environment for reading and writing for complex objects. More...
Public Member Functions | |
void | forEachVariable (Block ablock) |
Visit variables with block with parameters String name and Object value. More... | |
Persistency | getPersistency () |
Persistency with factories. More... | |
Object | getVariable (String name) |
Variable value. More... | |
Object | getVariable (String name, Object defaultValue) |
Variable value or default value if absent. More... | |
int | getVersion () |
File version number. More... | |
PersistencyEnvironment | new (Persistency persistency) |
Create persistency environment. More... | |
PersistencyEnvironment | new (Persistency persistency, int version) |
Create persistency environment. More... | |
PersistencyEnvironment | new (PersistencyEnvironment environment) |
Create copy of persistency environment. More... | |
bool | readBool (FileReader reader) |
Read boolean. More... | |
Persistable | readObject (FileReader reader) |
Read object using factory and file reader. More... | |
Persistable | readObjectOrNull (FileReader reader) |
Read object using factory and file reader or null if empty factory name. More... | |
String | readString16OrNullIfEmpty (FileReader reader) |
Read string with 16-bit length or null if empty. More... | |
String | readString8OrNullIfEmpty (FileReader reader) |
Read string with 8-bit length or null if empty. More... | |
StringID | readStringIDOrNullIfEmpty (FileReader reader) |
Read StringID with 8-bit length or null if empty. More... | |
void | removeAllVariables () |
Remove all variables. More... | |
void | removeVariable (String name) |
Remove variable if present. More... | |
void | setVariable (String name, Object value) |
Set variable. More... | |
void | setVariables (PersistencyEnvironment environment) |
Set variables from another environment. More... | |
void | writeBool (FileWriter writer, bool value) |
Write boolean. More... | |
void | writeObject (FileWriter writer, Persistable object) |
Write object using file writer. More... | |
void | writeObjectOrNull (FileWriter writer, Persistable object) |
Write object or null using file writer. More... | |
void | writeString16OrEmptyIfNull (FileWriter writer, String string) |
Write string with 16-bit length or empty string if null. More... | |
void | writeString8OrEmptyIfNull (FileWriter writer, String string) |
Write string with 8-bit length or empty string if null. More... | |
void | writeStringIDOrEmptyIfNull (FileWriter writer, StringID string) |
Write StringID with 8-bit length or empty string if null. More... | |
Public Attributes | |
Persistency | pPersistency |
Persistency with factories. More... | |
Dictionary | pVariables |
Variables. More... | |
int | pVersion |
File version number. More... | |
Static Public Attributes | |
static final String | varConvoPlayback = "conversationPlayback" |
Variable conversation playback. More... | |
static final String | varLoadAnimator = "loadAnimator" |
Variable animation loader. More... | |
static final String | varLoadConversation = "loadConversation" |
Variable conversation loader. More... | |
Persistency environment for reading and writing for complex objects.
Carries information required to properly restore complex objects. Stores a file version number which can be used to track file format changes. The file version is static during the lifetime of the object instance. Provides also helper methods to reduce code lines for typical persistency tasks.
Variables can be set by the user to temporarily store additional information specific persistency factories required to properly restore objects. Variables are identified by a string name and can contain any type of object. Best practice is to create a copy of a persistency environment if temporary variables have to be modified and use this new environment for subsequent restoring. You can also set and restore the temporary variables but using a copy of a persistency environment is simpler.
void Dragengine.LoadSave.PersistencyEnvironment.forEachVariable | ( | Block | ablock | ) |
Visit variables with block with parameters String name and Object value.
Persistency Dragengine.LoadSave.PersistencyEnvironment.getPersistency | ( | ) |
Persistency with factories.
Object Dragengine.LoadSave.PersistencyEnvironment.getVariable | ( | String | name | ) |
Variable value.
EInvalidParam | Named variable is absent. |
Object Dragengine.LoadSave.PersistencyEnvironment.getVariable | ( | String | name, |
Object | defaultValue | ||
) |
Variable value or default value if absent.
int Dragengine.LoadSave.PersistencyEnvironment.getVersion | ( | ) |
File version number.
PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new | ( | Persistency | persistency | ) |
Create persistency environment.
PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new | ( | Persistency | persistency, |
int | version | ||
) |
Create persistency environment.
PersistencyEnvironment Dragengine.LoadSave.PersistencyEnvironment.new | ( | PersistencyEnvironment | environment | ) |
Create copy of persistency environment.
bool Dragengine.LoadSave.PersistencyEnvironment.readBool | ( | FileReader | reader | ) |
Read boolean.
Persistable Dragengine.LoadSave.PersistencyEnvironment.readObject | ( | FileReader | reader | ) |
Read object using factory and file reader.
EInvalidParam | reader is null. |
EInvalidParam | Read factory name is absent in getPersistency(). |
Persistable Dragengine.LoadSave.PersistencyEnvironment.readObjectOrNull | ( | FileReader | reader | ) |
Read object using factory and file reader or null if empty factory name.
EInvalidParam | Read factory name is absent in getPersistency(). |
String Dragengine.LoadSave.PersistencyEnvironment.readString16OrNullIfEmpty | ( | FileReader | reader | ) |
Read string with 16-bit length or null if empty.
String Dragengine.LoadSave.PersistencyEnvironment.readString8OrNullIfEmpty | ( | FileReader | reader | ) |
Read string with 8-bit length or null if empty.
StringID Dragengine.LoadSave.PersistencyEnvironment.readStringIDOrNullIfEmpty | ( | FileReader | reader | ) |
Read StringID with 8-bit length or null if empty.
void Dragengine.LoadSave.PersistencyEnvironment.removeAllVariables | ( | ) |
Remove all variables.
void Dragengine.LoadSave.PersistencyEnvironment.removeVariable | ( | String | name | ) |
Remove variable if present.
void Dragengine.LoadSave.PersistencyEnvironment.setVariable | ( | String | name, |
Object | value | ||
) |
Set variable.
void Dragengine.LoadSave.PersistencyEnvironment.setVariables | ( | PersistencyEnvironment | environment | ) |
Set variables from another environment.
void Dragengine.LoadSave.PersistencyEnvironment.writeBool | ( | FileWriter | writer, |
bool | value | ||
) |
Write boolean.
void Dragengine.LoadSave.PersistencyEnvironment.writeObject | ( | FileWriter | writer, |
Persistable | object | ||
) |
Write object using file writer.
Writes persistency factory name as string with 8-bit length and then calls Persistable.writeToFile().
EInvalidParam | writer is null. |
EInvalidParam | object is null. |
EInvalidParam | object.persistencyFactoryName() is empty. |
void Dragengine.LoadSave.PersistencyEnvironment.writeObjectOrNull | ( | FileWriter | writer, |
Persistable | object | ||
) |
Write object or null using file writer.
If object is null writes empty string with 8-bit length. Otherwise writes persistency factory name as string with 8-bit length and then calls Persistable.writeToFile().
EInvalidParam | writer is null. |
EInvalidParam | object is not null and object.persistencyFactoryName() is empty. |
void Dragengine.LoadSave.PersistencyEnvironment.writeString16OrEmptyIfNull | ( | FileWriter | writer, |
String | string | ||
) |
Write string with 16-bit length or empty string if null.
void Dragengine.LoadSave.PersistencyEnvironment.writeString8OrEmptyIfNull | ( | FileWriter | writer, |
String | string | ||
) |
Write string with 8-bit length or empty string if null.
void Dragengine.LoadSave.PersistencyEnvironment.writeStringIDOrEmptyIfNull | ( | FileWriter | writer, |
StringID | string | ||
) |
Write StringID with 8-bit length or empty string if null.
Persistency Dragengine.LoadSave.PersistencyEnvironment.pPersistency |
Persistency with factories.
Dictionary Dragengine.LoadSave.PersistencyEnvironment.pVariables |
Variables.
int Dragengine.LoadSave.PersistencyEnvironment.pVersion |
File version number.
|
static |
Variable conversation playback.
Used by some factories to call one of the methods subclassed by a game class. If variable is not set factories will use null objects where possible while in other cases it might fail loading. In this case subclasses are responsible to restore the missing objects.
If set has to be an instance of ConversationPlayback.
|
static |
Variable animation loader.
Used by some factories to load animators. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:
If set has to be an instance of LoadAnimator.
|
static |
Variable conversation loader.
Used by some factories to load conversations. If variable is not set factories will consider loading the resource having failed. Some can cope with this while others throw an exception. The following factories are known to use this variable:
If set has to be an instance of LoadConversation.