Gorilla.Utils.Dialogue.System
Unit Gorilla.Utils.Dialogue.System.pasThis unit represents an abstracted complex multi leveled Dialogue system
Classes
- TGorillaDialogueCustomItem = class ( TCollectionItem )
- TGorillaDialogueSystemCollection = class ( TOwnedCollection )
- TGorillaDialogueCustomCollection = class ( TGorillaDialogueSystemCollection )
- TGorillaDialogueParameterizedItem = class ( TGorillaDialogueCustomItem )
- TGorillaDialogueParentItem = class ( TGorillaDialogueParameterizedItem )
- TGorillaDialogueItemEvent = class ( TGorillaDialogueParameterizedItem )
- TGorillaDialogueItemEventCollection = class ( TGorillaDialogueCustomCollection )
- TGorillaDialogueItem = class ( TGorillaDialogueParentItem )
- TGorillaDialogueItemCollection = class ( TGorillaDialogueCustomCollection )
- TGorillaDialogueCharacter = class ( TGorillaDialogueParameterizedItem )
- TGorillaDialogueCharacterCollection = class ( TGorillaDialogueCustomCollection )
- TGorillaDialogue = class ( TGorillaDialogueParentItem )
- TGorillaDialogueCollection = class ( TGorillaDialogueSystemCollection )
- TGorillaDialogueSystem = class ( TComponent )
Mics. types
- type TGorillaDialogueCustomItemClass = class of TGorillaDialogueCustomItem;
TGorillaDialogueCustomItem
Custom dialogue collection item. This is the basis for all used entities inside of the dialogue system: Item, ItemEvent, Dialogue.
Ancestors
Members
Fields
- protected FIdent :
string
- protected FEnabled :
Boolean
- protected FUIElement :
TObject
- protected FPosition :
TPointF
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetDialogueSystem
(
)
: TGorillaDialogueSystem
;
Returns the parent dialogue system.
- protected procedure AssignTo
(
ADest :
TPersistent
)
;
override;
Assign routine for custom items.
- protected procedure DefineProperties ( Filer : TFiler ) ; override;
- protected procedure ReadPosition ( Reader : TReader ) ;
- protected procedure WritePosition ( Writer : TWriter ) ;
- public function GetRandomId
(
)
: string
;
Returns a random name for this item, based on the classname and a random number form 0 to 10000.
- public function Clone
(
)
: TGorillaDialogueCustomItem
;
abstract virtual;
Abstract method for cloning a specific dialogue collection item. This method gets overwritten by each dialogue class.
Properties
TGorillaDialogueSystemCollection
Custom dialogue system collection with a reference to the parent dialogue system.
Remarks
This collection is the basis for all further collections.Ancestors
Members
Properties
TGorillaDialogueCustomCollection
Custom dialogue collection for item and event collections.
Remarks
This collection holds a reference to the parent dialogue instance.Ancestors
Members
Properties
TGorillaDialogueParameterizedItem
Custom paramerized collection item which allows to store a list of parameters.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetParameters ( const AValue : TGorillaDialogueParameters ) ;
- protected procedure AssignTo ( ADest : TPersistent ) ; override;
- protected procedure DefineProperties ( Filer : TFiler ) ; override;
- protected procedure ReadParameters ( Reader : TReader ) ;
- protected procedure WriteParameters ( Writer : TWriter ) ;
- public procedure AddParameter
(
const
AName :
string; const
AValue :
TValue
)
;
Adds a parameter to the parameter list. If the parameter already exists the method overwrites the value.
- public procedure RemoveParameter
(
const
AName :
string
)
;
Removes a specific parameter from parameter list identified by its name.
- public function GetParameter
(
const
AName :
string
)
: TValue
;
Searches for a specific parameter identified by its name.
Properties
TGorillaDialogueParentItem
Custom dialogue collection item with a list of child items. This class is used by dialogue and item classes.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetItems ( const AValue : TGorillaDialogueItemCollection ) ;
- protected procedure AssignTo ( ADest : TPersistent ) ; override;
- public function GetAvailableItems
(
)
: TArray<Gorilla.Utils.Dialogue.System.TGorillaDialogueItem>
;
Returns an array of all available items.
- public procedure ClearItems
(
)
;
Clears all child items.
- public function FindItem
(
const
AId :
string
)
: TGorillaDialogueItem
;
Tries to find a specific dialogue item by its ident.
- public function FindItemIndex
(
const
AId :
string
)
: Integer
;
Tries to find a specific dialogue item by its ident. Instead of returning the item instance, it will return the index in the item list.
- public procedure UnrefCharacter
(
const
ACharacter :
TGorillaDialogueCharacter
)
;
virtual;
The routine scans all items for a reference of the specific character and removes the reference.
Properties
TGorillaDialogueItemEvent
Default item event class. This collection item is used for representing events of dialogue items.
Ancestors
Members
Fields
- protected FOwnerEvent :
string
- protected FKind :
TGorillaDialogueEventKind
- protected FTrigger :
TGorillaDialogueEventTrigger
- protected FScope :
string
- protected FData :
TGorillaLanguageMap
- protected FIterations :
Integer
- protected FIterationCount :
Integer
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetDialogueItem ( ) : TGorillaDialogueItem ;
- protected function GetScopeObject ( ) : TObject ;
- protected procedure AssignTo
(
ADest :
TPersistent
)
;
override;
Assigns this dialogue item event to another event.
- protected procedure DefineProperties ( Filer : TFiler ) ; override;
- protected procedure ReadEventData ( Reader : TReader ) ;
- protected procedure WriteEventData ( Writer : TWriter ) ;
- public function Clone
(
Collection :
TCollection
)
: TGorillaDialogueCustomItem
;
virtual;
Clones the dialogue item event. This method is used to clone events for separate execution instances. f.e. for sandboxing.
- public function GetCurrentData
(
)
: string
;
Returns the current data value depending on the current dialogue system language setting. The method checks the configured system language and automatically selects the correct translation.
- public procedure Execute
(
)
;
virtual;
Executes the specific event depending on the iteration settings and the kind of event.
Properties
- public DialogueItem : TGorillaDialogueItem
Returns the owner dialogue item. Every event need to have a parent item, to which it belongs to.
read GetDialogueItem - public IterationCount : Integer
- published OwnerEvent : string
It is possible to execute events by another event. For example for animations, where you have a starting and finish event.
read FOwnerEvent
write FOwnerEvent - published Kind : TGorillaDialogueEventKind
- published Trigger : TGorillaDialogueEventTrigger
- published Scope : string
- published Iterations : Integer
Defines a iteration trigger. If the property is set to zero, functionality is disabled. Values larger than zero, perform iteration checks inside Execute() method.
read FIterations
write FIterations - published Data : TGorillaLanguageMap
TGorillaDialogueItemEventCollection
Default event collection with a reference to the parent dialogue item.
Ancestors
Members
Properties
TGorillaDialogueItem
Custom dialogue item, which represents questions, answers, floating text or item links (references).
Ancestors
Members
Fields
- protected FKind :
TGorillaDialogueItemKind
- protected FDisplayName :
string
- protected FReference :
string
- protected FDisplayTime :
Integer
- protected FText :
TGorillaLanguageMap
- protected FEvents :
TGorillaDialogueItemEventCollection
- protected FCharacter :
string
- protected FCharacterRef :
TGorillaDialogueCharacter
- protected FStarted :
Boolean
- protected FExecTimer :
TTimer
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetEvents ( const AValue : TGorillaDialogueItemEventCollection ) ;
- protected function GetParent ( ) : TCollectionItem ; virtual;
- protected function GetDialogue ( ) : TGorillaDialogue ; virtual;
- protected function GetCharacterRef ( ) : TGorillaDialogueCharacter ; virtual;
- protected procedure SetCharacterRef ( const AValue : TGorillaDialogueCharacter ) ; virtual;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected function GetCharacter ( ) : string ; virtual;
- protected procedure SetCharacter ( const AValue : string ) ; virtual;
- protected procedure DoOnExecTimerEvent
(
ASender :
TObject
)
;
virtual;
Callback event which gets called on execution timer end. The execution time will only be started, if a display time is set.
- protected procedure ExecuteEvents
(
const
ATrigger :
TGorillaDialogueEventTrigger
)
;
Executes all enabled events depending on the submitted trigger kind.
- protected procedure AssignTo
(
ADest :
TPersistent
)
;
override;
Assigns this dialogue item to another dialogue item.
- protected procedure DefineProperties ( Filer : TFiler ) ; override;
- protected procedure ReadTextData ( Reader : TReader ) ;
- protected procedure WriteTextData ( Writer : TWriter ) ;
- public function Clone
(
Collection :
TCollection
)
: TGorillaDialogueCustomItem
;
virtual;
Creates a clone of the specific dialogue item. This is used for sandboxing and dialogue execution.
- public function GetAvailableEvents
(
const
ATrigger :
TGorillaDialogueEventTrigger
)
: TArray<Gorilla.Utils.Dialogue.System.TGorillaDialogueItemEvent>
;
virtual;
Returns an array of item event suitable with the given trigger event.
- public function FindEventById
(
const
AId :
string
)
: TGorillaDialogueItemEvent
;
virtual;
Tries to find a specific item event in that dialogue item, identified by its id.
- public function GetCurrentText
(
)
: string
;
virtual;
Returns the current text auto translated to the currently set language in the dialogue system.
- public procedure Start
(
)
;
virtual;
Starts the specific dialogue item.
- public procedure Stop
(
const
ADeep :
Boolean
=
False
)
;
virtual;
Stops execution of specific dialogue item.
- public procedure StopItems
(
const
AKind :
TGorillaDialogueItemKind
)
;
virtual;
Iterates through all child items. Each item that is enabled and is set to the submitted kind, will be stopped.
- public procedure StopEvents
(
)
;
virtual;
Stops all started events.
Properties
- public Parent : TCollectionItem
- public Dialogue : TGorillaDialogue
- public CharacterRef : TGorillaDialogueCharacter
- published Kind : TGorillaDialogueItemKind
- published DisplayName : string
Defines the display name of the item. This value should be unique, but is managed by the user.
read GetDisplayName
write SetDisplayName - published Character : string
- published Reference : string
In case the kind is set to TGorillaDialogueItemKind.Reference, this property needs to be set to the DisplayName of the linked item.
read FReference
write FReference - published DisplayTime : Integer
Defines a time, for how long an item is going to be displayed, before it gets automtically skipped by the system.
read FDisplayTime
write FDisplayTime - published Events : TGorillaDialogueItemEventCollection
- published Text : TGorillaLanguageMap
TGorillaDialogueItemCollection
Default item collection with reference to a parent dialogue or another item instance.
Ancestors
Members
Properties
TGorillaDialogueCharacter
Represents a dialogue person or figure which can be linked to specific items. If a character is set, the DisplayName will automatically be adapted.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure AssignTo ( ADest : TPersistent ) ; override;
- public function Clone
(
Collection :
TCollection
)
: TGorillaDialogueCustomItem
;
virtual;
Creates a clone of the specific dialogue character. This is used for sandboxing and dialogue execution.
Properties
TGorillaDialogueCharacterCollection
Defines a collection of characters.
Ancestors
TGorillaDialogue
Default dialogue class. This collection item is the root for every dialogue inside of the dialogue system.
Remarks
Multiple dialogues are allowed.Ancestors
Members
Fields
- protected FCurrentItem :
TGorillaDialogueItem
- protected FStarted :
Boolean
- protected FPaused :
Boolean
- protected FPausedItems :
TArray<Gorilla.Utils.Dialogue.System.TGorillaDialogueItem>
- protected FCharacters :
TGorillaDialogueCharacterCollection
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetCharacters ( const AValue : TGorillaDialogueCharacterCollection ) ;
- protected procedure AssignTo ( ADest : TPersistent ) ; override;
- public function Clone
(
Collection :
TCollection
)
: TGorillaDialogueCustomItem
;
virtual;
Clones the specific dialogue including all items, events and characters.
- public procedure Start
(
)
;
virtual;
Starts the Dialogue. Will throw the DialogueSystem.OnStartDialogue event, with a list of available starting items.
- public procedure Stop
(
)
;
virtual;
Stops a running dialogue and all of its active items. Will throw the DialogueSystem.OnStopDialogue event. Also will throw the DialogueSystem.OnEndDialogueItem for every active item. Use this method to abort hardly (not recommend)
- public procedure Pause
(
)
;
virtual;
Pauses a running dialogue and all of its active items. Will throw the DialogueSystem.OnPauseDialogue event. Use this method when activating a game menu and interrupting current game process.
- public procedure Skip
(
const
ASingleSkip :
Boolean
=
False
)
;
virtual;
Skips all floating items up to the next question-item. If no question-item occurs anymore, dialogue will automatically end. Use this method to skip long conversations and monologs. It only will work if current item is of floating type.
- public procedure StartItem
(
const
AItem :
TGorillaDialogueItem
)
;
virtual;
Execute an item process.
- public procedure SelectItem
(
const
AItem :
TGorillaDialogueItem
)
;
virtual;
use this method to select a answer item it only will work with those item kinds!
- public function FindCharacterById
(
const
AId :
string
)
: TGorillaDialogueCharacter
;
overload virtual;
Tries to find a specific character by its identifier.
- public function FindCharacterByName
(
const
AName :
string
)
: TGorillaDialogueCharacter
;
overload virtual;
Tries to find a specific character by its name.
Properties
- public CurrentItem : TGorillaDialogueItem
- public Started : Boolean
- public Paused : Boolean
- published Characters : TGorillaDialogueCharacterCollection
Returns the collection of all available characters in this dialogue.
read FCharacters
write SetCharacters
TGorillaDialogueCollection
Default dialogue collection used for organizing dialogue instances. The collection is extended from system collection with a reference to the parent dialogue system.
Ancestors
TGorillaDialogueSystem
Default dialogue system component. Use this component as basis for dialogue implementation. The component is able to create dialogues, items and events at runtime. It also allows to load and save the dialogue system to file (xml-format).
Ancestors
Members
Fields
- protected FId :
string
- protected FLanguage :
Integer
- protected FDialogues :
TGorillaDialogueCollection
- protected FVariables :
TGorillaDialogueVariables
- protected FOnBeginDialogueItemEvent :
TOnBeginDialogueItemEvent
- protected FOnEndDialogueItemEvent :
TOnEndDialogueItemEvent
- protected FOnBeginDialogueItem :
TOnBeginDialogueItem
- protected FOnEndDialogueItem :
TOnEndDialogueItem
- protected FOnStartDialogue :
TOnStartDialogue
- protected FOnStopDialogue :
TOnStopDialogue
- protected FOnPauseDialogue :
TOnPauseDialogue
- protected FOnSkippedDialogue :
TOnSkippedDialogue
- protected FOnSkipAvailability :
TOnSkipAvailability
- protected FOnBeginItemTimeout :
TOnBeginItemTimeout
- protected FOnEndItemTimeout :
TOnEndItemTimeout
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetDialogues ( const AValue : TGorillaDialogueCollection ) ;
- protected procedure SetVariables ( const AValue : TGorillaDialogueVariables ) ;
- protected function GetLanguageName ( ) : string ;
- protected procedure AssignTo ( ADest : TPersistent ) ; override;
- public function Clone
(
AOwner :
TComponent
)
: TGorillaDialogueSystem
;
Clones a complete dialogue system including all dialogues, items and events. The result is a new instance, which can be used independently from the original dialogue system.
- public function FindDialogue
(
const
AId :
string
)
: TGorillaDialogue
;
Tries to find a specific dialogue by its ident.
- public procedure AddVariable
(
const
AName :
string; const
AObject :
TObject
)
;
virtual;
Adds a variable to the dialogue system. Variables can be TObject instances and are identified by a unique name.
- public procedure RemoveVariable
(
const
AName :
string
)
;
virtual;
Removes a specific variable from dialogue system, identified by a name. If the method cannot find a variable with this name, nothing is done.
- public function GetVariable
(
const
AName :
string
)
: TObject
;
virtual;
Tries to find a variable by a specific name. If the routine cannot find a variable, it returns nil.
- public procedure LoadFromStream
(
const
AStream :
TStream
)
;
virtual;
Loads a complete dialogue system from stream. The method will load all dialogues with item- and event-hierarchy.
- public procedure LoadFromFile
(
const
AFileName :
string
)
;
virtual;
Loads a complete dialogue system from *.dia file. The method will load all dialogues with item- and event-hierarchy.
- public procedure SaveToStream
(
const
AStream :
TStream
)
;
virtual;
Stores a complete dialogue system to stream. All containing dialogues, items and events will be stored in xml-format.
- public procedure SaveToFile
(
const
AFileName :
string
)
;
virtual;
Stores a complete dialogue system to *.dia file. All containing dialogues, items and events will be stored in xml-format.
- public procedure ClearVariables
(
)
;
virtual;
Clears all assigned variables from system.
- public procedure ClearDialogues
(
)
;
virtual;
Clears all available dialogues with their containing items and events.
- public procedure ClearAll
(
)
;
virtual;
Clears all variables and dialogues with their containing items and events. It will also clear the system id field.
- public procedure UnrefCharacter
(
const
ACharacter :
TGorillaDialogueCharacter
)
;
virtual;
Iterates through all dialogues to unref a specific character;
Properties
- public LanguageName : string
Returns the current language identifier depending on the language property. Use this property to request a specific value from LanguageMaps.
read GetLanguageName - published Id : string
- published Language : Integer
- published Dialogues : TGorillaDialogueCollection
- published Variables : TGorillaDialogueVariables
A hashmap of [name],[TObject] pairs. Register variables to connect another environment with the dialogue system.
read FVariables
write SetVariables