Gorilla.AssetsManager
Unit Gorilla.AssetsManager.pasThe AssetsManager is the core component in effective media management inside your Gorilla3D application. Models, textures, audio and so on will be cached for faster access and reusage. You can build packages within the AssetsManager for modular media management. For example: you could build a package for the main character and reference to it in every scene package. Scene packages are extremly useful for compact and fast loading of all data of a specific scene.
Classes
- EGorillaAssetsException = class ( EAbort )
- TGorillaAsset = class ( TPersistent )
- TGorillaTextureAsset = class ( TGorillaAsset )
- TGorillaModelAsset = class ( TGorillaAsset )
- TGorillaStreamAsset = class ( TGorillaAsset )
- TGorillaAudioAsset = class ( TGorillaStreamAsset )
- TGorillaVideoAsset = class ( TGorillaStreamAsset )
- TGorillaMiscAsset = class ( TGorillaStreamAsset )
- TGorillaDialogueAsset = class ( TGorillaStreamAsset )
- TGorillaInventoryAsset = class ( TGorillaStreamAsset )
- TGorillaSkillsAsset = class ( TGorillaStreamAsset )
- TGorillaScriptAsset = class ( TGorillaStreamAsset )
- TGorillaPrefabAsset = class ( TGorillaStreamAsset )
- TGorillaAssetsGroup = class ( TCollectionItem )
- TGorillaAssetsGroupCollection = class ( TOwnedCollection )
- TGorillaArchiveReference = class ( TObject )
- TGorillaFileArchiveReference = class ( TGorillaArchiveReference )
- TGorillaInMemoryArchiveReference = class ( TGorillaArchiveReference )
- TGorillaArchiveReferences = class ( {System.Generics.Collections}TDictionary<System.string,Gorilla.AssetsManager.TGorillaArchiveReference> )
- TGorillaAssetsPackage = class ( TCollectionItem )
- TGorillaAssetsPackageCollection = class ( TOwnedCollection )
- TGorillaAssetsManager = class ( TComponent )
Enumerations
- enum TGorillaLevelOfDetail = ( LowQuality, MediumQuality, HighQuality, ExcellentQuality ) ;
- enum TAssetImportFlag = ( StrictFileName, Cached ) ;
- enum TGorillaPackageEvent = ( PackageModified, PackageInitialize, PackageClear, PackageName, PackageLoad, PackageAssign, GroupsModified, GroupAssign, GroupAdd, GroupRemove, GroupClear, AssetsModified, AssetAdd, AssetRemove, AssetClear ) ;
Constants
- const GORILLA_ASSETS_MODEL : Integer = $0;
- const GORILLA_ASSETS_TEXTURE : Integer = $1;
- const GORILLA_ASSETS_AUDIO : Integer = $2;
- const GORILLA_ASSETS_VIDEO : Integer = $3;
- const GORILLA_ASSETS_MISC : Integer = $4;
- const GORILLA_ASSETS_DIALOGUE : Integer = $5;
- const GORILLA_ASSETS_INVENTORY : Integer = $6;
- const GORILLA_ASSETS_SCRIPT : Integer = $7;
- const GORILLA_ASSETS_PREFAB : Integer = $8;
- const GORILLA_ASSETS_SKILLS : Integer = $9;
- const GORILLA_ASSETS_MODEL_DESCR : string = "MODEL";
- const GORILLA_ASSETS_TEXTURE_DESCR : string = "TEXTURE";
- const GORILLA_ASSETS_AUDIO_DESCR : string = "AUDIO";
- const GORILLA_ASSETS_VIDEO_DESCR : string = "VIDEO";
- const GORILLA_ASSETS_MISC_DESCR : string = "MISC";
- const GORILLA_ASSETS_DIALOGUE_DESCR : string = "DIALOGUE";
- const GORILLA_ASSETS_INVENTORY_DESCR : string = "INVENTORY";
- const GORILLA_ASSETS_SCRIPT_DESCR : string = "SCRIPT";
- const GORILLA_ASSETS_PREFAB_DESCR : string = "PREFAB";
- const GORILLA_ASSETS_SKILLS_DESCR : string = "SKILLS";
- const GORILLA_ASSETS_MODEL_DESCR_D : string = "MODELS";
- const GORILLA_ASSETS_TEXTURE_DESCR_D : string = "TEXTURES";
- const GORILLA_ASSETS_AUDIO_DESCR_D : string = "AUDIO";
- const GORILLA_ASSETS_VIDEO_DESCR_D : string = "VIDEO";
- const GORILLA_ASSETS_MISC_DESCR_D : string = "MISC";
- const GORILLA_ASSETS_DIALOGUE_DESCR_D : string = "DIALOGUES";
- const GORILLA_ASSETS_INVENTORY_DESCR_D : string = "INVENTORY";
- const GORILLA_ASSETS_SCRIPT_DESCR_D : string = "SCRIPTS";
- const GORILLA_ASSETS_PREFAB_DESCR_D : string = "PREFABS";
- const GORILLA_ASSETS_SKILLS_DESCR_D : string = "SKILLS";
- const GORILLA_PACKAGE_DEFAULT : string = "default";
- const GORILLA_PACKAGE_VERSION : string = "1.3";
- const GORILLA_ASSETCLASS_MAP : array[0..9] of TGorillaAssetClass = ;
- const GORILLA_ASSETS_GROUP_ID_DESCR : :32 = ;
- const GORILLA_ASSETS_GROUP_ID_DESCR_DEPRECATED : :42 = ;
Mics. types
- type TGorillaAssetGroupId = integer;
- type TGorillaAssetClass = class of TGorillaAsset;
TGorillaLevelOfDetail
The level of detail enumerator describes the rendering quality of assets. This could affect textures and models and will increase performance.
Remarks
This enumerator is implemented for future functionality and not operational yet!TGorillaAsset
Basic asset class. Every texture, model, audio-file, ... is based on this class inside the AssetsManager
Ancestors
Members
Fields
- protected FGroup :
TGorillaAssetsGroup
- protected FSubGroups :
TGorillaAssetsGroupCollection
- protected FId :
TGUID
- protected FFilename :
string
- protected FExtension :
string
- protected FCached :
Boolean
- protected FIsStandalone :
Boolean
- protected FReadingFromArchive :
Integer
Methods
- public constructor Create ( const AGroup : TGorillaAssetsGroup ) ;
- public destructor Destroy ( ) ;
- protected function GetArchivePath ( ) : string ; virtual;
- protected function GetArchiveFilePath ( const APath : string ) : string ; class virtual;
- protected procedure SaveToArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; virtual;
- protected procedure LoadFromArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; overload virtual;
- protected function LoadFromArchive ( AArchive : TGorillaArchiveReference; const AGroup : TGorillaAssetsGroup; const APath : string ) : TGorillaAsset ; class overload virtual;
- public function GetGroupId
(
)
: Integer
;
class abstract virtual;
Static function overwritten by the extended asset class for automatic group association.
- public function GetGroupDescr
(
)
: string
;
class abstract virtual;
Static function overwritten by the extended asset class to return group name.
- public function GetSupportedExtensions
(
)
: TArray<System.string>
;
class abstract virtual;
Static function overwritten by the extended asset class that returns a string array with all supported file extensions.
- public function IsExtensionSupported
(
const
AExt :
string
)
: Boolean
;
class virtual;
Static function that checks if a specific extension is supported by a specific asset class. The method uses the GetSupportedExtensions routine.
- public function GetSupportedAssetClass
(
const
AExt :
string
)
: TGorillaAssetClass
;
class virtual;
Static function to look up all asset classes for the extension to be supported. The first asset class that supports the extension will be returned. If no asset class can be found, the method returns nil.
- public function ImportFromFile
(
const
AGroup :
TGorillaAssetsGroup; const
AFilename :
string; const
AFlags :
TAssetImportFlags
=
[]
)
: TGorillaAsset
;
class overload virtual;
Loads an asset from supplied filename and stores it in supplied asset group.
- public function ImportFromStream
(
const
AGroup :
TGorillaAssetsGroup; const
AFilename :
string; const
AStream :
TStream; const
AFlags :
TAssetImportFlags
=
[]
)
: TGorillaAsset
;
class abstract overload virtual;
Loads an asset from stream with a supplied filename and stores it into the supplied asset group.
- public procedure ImportFromFile
(
const
AFilename :
string; const
AFlags :
TAssetImportFlags
=
[]
)
;
overload virtual;
Loads data for an existing asset by a supplied filename.
- public procedure ImportFromStream
(
const
AFilename :
string; const
AStream :
TStream; const
AFlags :
TAssetImportFlags
=
[]
)
;
abstract overload virtual;
Loads data from supplied stream for an existing asset by a supplied filename.
- public procedure UpdateInArchive
(
)
;
virtual;
Call this method to store the asset again in archive. Caution under some circumstances this may produce duplicated entries inside the archive.
- public function GetSize
(
)
: Int64
;
virtual;
Returns the size of the asset in bytes.
- public function ToJSON
(
)
: TJSONObject
;
virtual;
Returns a json object with all serialized fields to store within a assets manager package.
- public procedure FromJSON
(
const
AValue :
TJSONObject
)
;
virtual;
Allows to load field values from a json object.
- public function AddSubGroup
(
const
AClass :
TGorillaAssetClass
)
: TGorillaAssetsGroup
;
Adds a new asset group to the package depending on the supplied asset class type.
- public procedure RemoveSubGroup
(
const
AIdx :
Integer
)
;
overload;
Removes a specific asset group from package by the supplied asset group id. If the group do not exist, the routine will leave.
- public procedure RemoveSubGroup
(
const
ADescr :
string
)
;
overload;
Removes a specific asset group from package by the supplied asset group descriptin. If the group do not exist, the routine will leave.
- public function GetSubGroup
(
const
AIdx :
Integer
)
: TGorillaAssetsGroup
;
overload;
Tries to find a specific assets group by the supplied group id. If no group could be found, the routine returns nil.
- public function GetSubGroup
(
const
ADescr :
string
)
: TGorillaAssetsGroup
;
overload;
Tries to find a specific assets group by the supplied group description. If no group could be found, the routine returns nil.
- public function GetSubGroupIndex
(
const
ADescr :
string
)
: Integer
;
overload;
Returns the group index inside of the group collection by the supplied description. If the specific group could not be found, the routine returns -1.
- public function GetSubGroupIndex
(
const
ASubGroup :
TGorillaAssetsGroup
)
: Integer
;
overload;
Returns the group index inside of the group collection by the supplied instance. If the specific group could not be found, the routine returns -1.
- public function GetSubGroupByExtension
(
const
AExt :
string
)
: TGorillaAssetsGroup
;
Tries to find a valid assets group by a supplied file extension.
- public procedure ClearSubGroup
(
const
AIdx :
Integer
)
;
Removes all contained assets from a specific group. The method will lookup for the group by the supplied index. If no group could be found, the routine will leave.
- public function FindSubAsset
(
const
AFilename :
string; const
AStrictFilename :
Boolean
=
False
)
: TGorillaAsset
;
Selects the assets group by the supplied filename extension. And then scans all assets to find a suitable one.
- public function SubAssetExists
(
const
AFilename :
string; const
AStrictFilename :
Boolean
=
False
)
: Boolean
;
Tries to find an assets in a specific group by its filename. If it can be found the method returns true otherwise false.
- public function AddSubAssetFromFile
(
const
AFilename :
string
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The method automatically detects the asset group and searches for the asset. If no asset could be found, the routine imports the asset from supplied file.
- public function GetSubAssetFromId
(
const
ASubGroup :
Integer; const
AId :
TGUID
)
: TGorillaAsset
;
Returns an asset by a supplied unique identifier (GUID) in the supplied asset group. If not asset with this GUID could be found, the method returns nil.
- public function GetSubAssetFromFile
(
const
ASubGroup :
Integer; const
AFilename :
string
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group. If no asset could be found, the routine imports the asset from supplied file.
- public function GetSubAssetFromStream
(
const
ASubGroup :
Integer; const
AFilename :
string; const
AStream :
TStream
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group. If no asset could be found, the routine imports the asset from supplied stream.
- public function Log ( AIndent : string ) : string ;
Properties
- public Group : TGorillaAssetsGroup
- public Id : TGUID
- public Filename : string
The original filename of the asset. Optional it includes the path from where the asset was loaded.
read FFilename - public Extension : string
- public Cached : Boolean
- public IsStandalone : Boolean
Sometimes assets are created without reference to a group. Those assets are marked as standalone.
read FIsStandalone
write FIsStandalone - published SubGroups : TGorillaAssetsGroupCollection
Each assets can hold further subgroups for better organization. So example a model assets can have a group for textures to hold its own texture set. This is necessary to prevent invalid texture loading for duplicated texture-file names.
read FSubGroups
TGorillaTextureAsset
Textures are cached as FMX.Graphics.TBitmap.
Remarks
Files with extension *.bmp, *.jpg, *.jpeg, *.dds, *.gif, *.png, *.tif, *.tiff, *.tga are mapped to this assset type.
AssetsManager itself stores all image data as PNG inside of the package.
Ancestors
Members
Fields
Methods
- public constructor Create ( const AGroup : TGorillaAssetsGroup ) ;
- public destructor Destroy ( ) ;
- protected function GetBitmap ( ) : TBitmap ; virtual;
- protected function GetBitmapFromArchive ( AArchive : TGorillaArchiveReference ) : TBitmap ; virtual;
- protected procedure SaveToArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; override;
- public function GetGroupId ( ) : Integer ; class override;
- public function GetGroupDescr ( ) : string ; class override;
- public function GetSupportedExtensions ( ) : TArray<System.string> ; class override;
- public function ImportFromFile ( const AGroup : TGorillaAssetsGroup; const AFilename : string; const AFlags : TAssetImportFlags = [] ) : TGorillaAsset ; class overload override;
- public function ImportFromStream ( const AGroup : TGorillaAssetsGroup; const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) : TGorillaAsset ; class overload override;
- public procedure ImportFromStream ( const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) ; overload override;
- public procedure ImportFromCachedBitmap
(
const
AFilename :
string; ABitmap :
TBitmap
)
;
virtual;
This method sets the FCachedBitmap to the supplied bitmap reference. Call this method on loading texture assets from DFM binary storage.
- public function GetSize ( ) : Int64 ; override;
- public procedure FromJSON ( const AValue : TJSONObject ) ; override;
- public function ToJSON ( ) : TJSONObject ; override;
Properties
TGorillaModelAsset
Models are cached as Gorilla.DefTypes.TModelDef structure. When storing packages, models will be saved as G3D models.
Remarks
Files with extension *.obj, *.g3d, *.dae, *.fbx, *.gltf, *.stl, *.x3d, *.x3dvz, *.x3dz, *.babylon, *.ply, *.skp are mapped to this asset type.
AssetsManager stores all model format types as *.g3d format inside of the package when saved. But it keeps the file extension to allow reloading.
Ancestors
Members
Fields
Methods
- public constructor Create ( const AGroup : TGorillaAssetsGroup ) ;
- public destructor Destroy ( ) ;
- protected procedure SetModel ( const AValue : TObject ) ; virtual;
- protected procedure SaveToArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; override;
- protected procedure LoadFromArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; overload override;
- protected function GetLoadOptions
(
)
: TGorillaLoadOptions
;
Checks the package settings for overwritten load options, f.e. by user modification in OnModify event.
- protected function InternalLoadModelDefFromStream ( const AStream : TStream; const APackage : TGorillaAssetsPackage; const AFilename : string ) : TObject ; class;
- protected procedure InitializeSubGroups ( ) ;
- public function GetGroupId ( ) : Integer ; class override;
- public function GetGroupDescr ( ) : string ; class override;
- public function GetSupportedExtensions ( ) : TArray<System.string> ; class override;
- public function ImportFromStream ( const AGroup : TGorillaAssetsGroup; const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) : TGorillaAsset ; class overload override;
- public procedure ImportFromStream ( const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) ; overload override;
- public function GetSize ( ) : Int64 ; override;
Properties
TGorillaStreamAsset
This is the custom stream asset used for audio, video, misc, dialogue, inventory, scripts, prefabs, ... assets.
Remarks
Depending on the asset specific file extensions will be mapped for auto- detection.Ancestors
Members
Fields
Methods
- public constructor Create ( const AGroup : TGorillaAssetsGroup ) ;
- public destructor Destroy ( ) ;
- protected procedure SaveToArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; override;
- protected procedure LoadFromArchive ( AArchive : TGorillaArchiveReference; const APath : string ) ; overload override;
- public procedure ImportFromStream ( const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) ; overload override;
- public function GetSize ( ) : Int64 ; override;
- public function ToJSON ( ) : TJSONObject ; override;
Properties
- public Stream : TMemoryStream
Returns the buffered memory stream containing data, depending of the type of stream asset: audio, video, misc, dialogue, inventory,...
read FStream
TGorillaAudioAsset
Store and load audio files to the package archive.
Remarks
Files with extension *.aiff, *.asf, *.asx, *.dls, *.flac, *.fsb, *.it, *.m3u, *.midi, *.mod, *.mp2, *.mp3, *.ogg, *.pls, *.s3m, *.vag, *.wav, *.wax, *.wma, *.xm, *.xma are mapped with this asset type.Ancestors
Members
Methods
- public constructor Create ( const AGroup : TGorillaAssetsGroup ) ;
- public destructor Destroy ( ) ;
- public function GetGroupId ( ) : Integer ; class override;
- public function GetGroupDescr ( ) : string ; class override;
- public function GetSupportedExtensions ( ) : TArray<System.string> ; class override;
- public function ImportFromStream ( const AGroup : TGorillaAssetsGroup; const AFilename : string; const AStream : TStream; const AFlags : TAssetImportFlags = [] ) : TGorillaAsset ; class overload override;
TGorillaVideoAsset
Store and load video files to the package archive.
Remarks
Files with extension *.mp4, *.mpg and *.mpeg are mapped to this asset type.Ancestors
Members
TGorillaMiscAsset
This is multi type asset used for user specific data.
Remarks
Files with extension *.txt, *.json, *.xml, *.pdf are mapped to this asset type.Ancestors
Members
TGorillaDialogueAsset
Store and load assets containing a dialogue system.
Remarks
Files with extension *.dia or *.dlg are mapped to this asset type.Ancestors
Members
Fields
Properties
TGorillaInventoryAsset
Store and load assets containing an inventory declaration.
Remarks
Files with extension *.iff are mapped to this asset type.Ancestors
Members
TGorillaSkillsAsset
Store and load assets containing an skillsystem declaration.
Remarks
Files with extension *.ssf are mapped to this asset type.Ancestors
Members
TGorillaScriptAsset
Store and load assets containing a script.
Remarks
Files with extension *.pas are mapped to this asset type.Ancestors
Members
TGorillaPrefabAsset
Store and load assets containing a prefab.
Remarks
Files with extension *.prefab are mapped to this asset type.Ancestors
Members
TGorillaAssetsGroup
An assets group is a category for media types, like: textures, models, audio, ...
Ancestors
Members
Fields
- protected FDescr :
string
- protected FOwnerAsset :
TGorillaAsset
- protected FAssetClass :
TGorillaAssetClass
- protected FAssets :
TGorillaAssetsMap
Methods
- public constructor Create
(
ACollection :
TCollection
)
;
Default constructor
- public constructor CreateForAsset
(
ACollection :
TCollection; const
AAssetClass :
TGorillaAssetClass
)
;
Constructor with asset class type assignment.
- public destructor Destroy ( ) ;
- protected function GetPackage ( ) : TGorillaAssetsPackage ; virtual;
- protected function GetGroupIndex ( ) : Integer ; virtual;
- protected procedure DoOnAssetsValueNotify ( ASender : TObject; const AItem : TGorillaAsset; AAction : TCollectionNotification ) ; virtual;
- protected function GetArchivePath ( ) : string ; virtual;
- protected function GetArchiveFilePath ( const APath : string ) : string ; class virtual;
- protected procedure SaveToArchive ( AArchive : TGorillaArchiveReference ) ; virtual;
- protected function LoadFromArchive ( ACollection : TCollection; AArchive : TGorillaArchiveReference; APath : string ) : TGorillaAssetsGroup ; class virtual;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected function GetAssetClassName ( ) : string ; virtual;
- protected procedure SetAssetClassName ( const AValue : string ) ; virtual;
- public procedure Assign ( ASrc : TPersistent ) ; override;
- public procedure Initialize
(
AAssetClass :
TGorillaAssetClass
)
;
Initializes the asset group instance. Creating the assets hashmap and applying the assets class type.
- public function FindAssetByFilename
(
const
AFilename :
string; AStrictFilename :
Boolean
=
False
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename.
- public function GetAssetFromId
(
const
AId :
TGUID
)
: TGorillaAsset
;
Returns an asset by a supplied unique identifier (GUID). If not asset with this GUID could be found, the method returns nil.
- public function GetAssetFromFile
(
const
AFilename :
string; const
AStrictFilename :
Boolean
=
False
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. If no asset could be found, the routine imports the asset from supplied file.
- public function GetAssetFromStream
(
const
AFilename :
string; const
AStream :
TStream; const
AStrictFilename :
Boolean
=
False
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. If no asset could be found, the routine imports the asset from supplied stream and supplied filename.
- public procedure Clear
(
const
ADeleteInArchive :
Boolean
)
;
Removes all assets from the specific asset group. Supply an argument TRUE to also delete files in this group from zip-archive.
- public procedure Delete
(
)
;
Deletes all assets inside of the specific group and also deletes files and folders inside of zip-archive. The routine performs a Clear call with argument TRUE.
- public function AddAsset
(
const
AAsset :
TGorillaAsset
)
: Boolean
;
virtual;
Adds an existing asset instance to the specific asset group.
- public function AddEmptyAsset
(
const
AFileName :
string; const
AStrictFileName :
Boolean
)
: TGorillaAsset
;
overload;
Creates and adds an empty asset object to the specific group.
- public function AddEmptyAsset
(
const
AId :
TGUID
)
: TGorillaAsset
;
overload;
Creates and adds an empty asset object to the specific group.
- public function GetSize
(
)
: Int64
;
virtual;
Returns the size in bytes. The size contains the the number of bytes used by the asset group itself and all its contained assets.
- public function ToJSON
(
)
: TJSONObject
;
virtual;
Serializes an asset group to json format.
- public procedure FromJSON
(
const
AValue :
TJSONObject
)
;
virtual;
Applies field values of an asset group from supplied json format.
- public function Log ( AIndent : string ) : string ;
Properties
- public Package : TGorillaAssetsPackage
- public OwnerAsset : TGorillaAsset
Get or set an owner asset if the group is a subgroup of a specific asset.
read FOwnerAsset
write FOwnerAsset - public GroupIndex : Integer
- public Assets : TDictionary<System.TGUID,Gorilla.AssetsManager.TGorillaAsset>
- public AssetClass : TGorillaAssetClass
Returns the linked asset class type that is allowed to used within the specific asset group.
read FAssetClass
write FAssetClass - published DisplayName : string
Get or set a group description for identifying a specific group.
read GetDisplayName
write SetDisplayName - published AssetClassName : string
Returns the linked asset class type that is allowed to used within the specific asset group.
read GetAssetClassName
write SetAssetClassName
TGorillaAssetsGroupCollection
Ancestors
Members
Properties
- public Package : TGorillaAssetsPackage
Get the owner assets package. This property is needed to store all data in the zip package file.
read GetPackage
TGorillaArchiveReference
Its difficult to keep an archive opened through design time, because IDE destroys components itself and keeps components for some reason. Therefore we have manage archives globally to prevent from duplicated access, which destroys the archive.
Ancestors
Members
Fields
- protected FManager :
TGorillaAssetsManager
- protected FId :
string
- protected FRefCount :
Integer
- protected FOpenCount :
Integer
- protected FArchive :
TZipFile
Methods
- public constructor Create ( AMngr : TGorillaAssetsManager; AId : string ) ;
- public destructor Destroy ( ) ;
- protected function GetStream ( ) : TStream ; abstract virtual;
- protected function GetIsOpened ( ) : Boolean ; virtual;
- protected function GetFileNames ( ) : TArray<System.string> ;
- public procedure IncRef ( ) ;
- public procedure DecRef ( ) ;
- public procedure Open ( ) ; virtual;
- public procedure CloseArchive ( ) ;
- public procedure Close ( ) ; virtual;
- public function FileExists ( AFile : string ) : Boolean ; virtual;
- public procedure AddFromStream ( AStream : TStream; APath : string ) ; virtual;
- public procedure ReadToStream ( APath : string; AStream : TStream; out AHeader : TZipHeader ) ; virtual;
- public procedure DeleteFile ( AFile : string ) ; virtual;
- public procedure SaveToFile ( APckg : TGorillaAssetsPackage; AFilename : string ) ; virtual;
- public procedure SaveToStream ( APckg : TGorillaAssetsPackage; AStream : TStream ) ; virtual;
Properties
TGorillaFileArchiveReference
Reads/writes zip archive data from file.
Ancestors
Members
Fields
Methods
- public constructor Create ( AMngr : TGorillaAssetsManager; AId : string ) ;
- public destructor Destroy ( ) ;
- protected function GetStream ( ) : TStream ; override;
- protected function CreateFileStream ( ) : TFileStream ;
- public procedure Open ( ) ; override;
- public procedure Close ( ) ; override;
- public procedure SaveToFile ( APckg : TGorillaAssetsPackage; AFilename : string ) ; override;
- public procedure SaveToStream ( APckg : TGorillaAssetsPackage; AStream : TStream ) ; override;
TGorillaInMemoryArchiveReference
Reads/writes zip archive data from memory
Ancestors
Members
Fields
Methods
- public constructor Create ( AMngr : TGorillaAssetsManager; AId : string ) ;
- public destructor Destroy ( ) ;
- protected function GetStream ( ) : TStream ; override;
- public procedure Open ( ) ; override;
- public procedure Close ( ) ; override;
- public procedure ApplyStream ( AStream : TStream ) ;
- public procedure SaveToFile ( APckg : TGorillaAssetsPackage; AFilename : string ) ; override;
- public procedure SaveToStream ( APckg : TGorillaAssetsPackage; AStream : TStream ) ; override;
TGorillaArchiveReferences
Ancestors
Members
Fields
Methods
- public constructor Create ( AMngr : TGorillaAssetsManager ) ;
- public destructor Destroy ( ) ;
- protected procedure DoOnValueNotify ( Sender : TObject; const AItem : TGorillaArchiveReference; AAction : TCollectionNotification ) ;
- public function ArchiveExists ( AId : string ) : Boolean ;
- public function GetArchive ( AId : string ) : TGorillaArchiveReference ;
- public function CreateArchiveByFilename ( AFileName : string ) : TGorillaArchiveReference ;
- public function CreateArchiveByStream ( AId : string; AStream : TStream ) : TGorillaArchiveReference ;
- public function CreateArchiveInMemory ( AId : string ) : TGorillaArchiveReference ;
- public procedure CloseArchive ( AId : string ) ;
- public procedure ClearArchives ( ) ;
TGorillaAssetsPackage
Defining an asset package which stores media files inside of a zip packed file or stream. A package is very useful to reuse assets and pack assets together for easier rollout.
Ancestors
Members
Fields
- protected FArchive :
TGorillaArchiveReference
- protected FFilename :
TFileName
- protected FGUID :
TGUID
- protected FDescr :
string
- protected FGroups :
TGorillaAssetsGroupCollection
- protected FUserOptionsSet :
Boolean
- protected FUserOptions :
TGorillaLoadOptions
- protected FOnModifyBefore :
TOnPackageEvent
- protected FOnModifyAfter :
TOnPackageEvent
Methods
- public constructor Create
(
ACollection :
TCollection
)
;
Returns the internally used package file stream.
- public destructor Destroy ( ) ;
- protected procedure SetGroups ( const AValue : TGorillaAssetsGroupCollection ) ; virtual;
- protected function GetManager ( ) : TGorillaAssetsManager ; virtual;
- protected function GetArchive ( ) : TGorillaArchiveReference ; virtual;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected function GetFilename ( ) : TFileName ; virtual;
- protected procedure SetFilename ( const AValue : TFileName ) ; virtual;
- protected function GetPathVariable ( AVar : string ) : string ; class;
- protected function ReplacePathVariables ( AFilename : string ) : string ; class;
- protected function NormalizePath ( AFilename : string ) : string ; class;
- protected procedure LoadAllAssetsFromArchive ( ) ;
- public procedure Assign ( ASrc : TPersistent ) ; override;
- public procedure Refresh
(
)
;
Clears the current package and reloads completely from archive. This only works properly for file packages. It's not recommended to use for in-memory packages.
- public procedure Initialize
(
)
;
Initializes the assets package component by generating a guid and creating all default asset groups: GORILLA_ASSETS_MODEL, GORILLA_ASSETS_TEXTURE, GORILLA_ASSETS_AUDIO, GORILLA_ASSETS_VIDEO, GORILLA_ASSETS_MISC, GORILLA_ASSETS_DIALOGUE, GORILLA_ASSETS_INVENTORY
- public procedure Close
(
)
;
Closing zip archive to write correctly to the end.
- public procedure Clear
(
const
ADeleteInArchive :
Boolean
)
;
virtual;
Clears all group objects from package. Supply an argument TRUE to also clear group folders and files in zip archive.
- public procedure Delete
(
)
;
virtual;
Clears all group folders and files in zip archive. The routine will call clear with argument TRUE.
- public function AddGroup
(
const
AClass :
TGorillaAssetClass
)
: TGorillaAssetsGroup
;
Adds a new asset group to the package depending on the supplied asset class type.
- public procedure RemoveGroup
(
const
AIdx :
Integer
)
;
overload;
Removes a specific asset group from package by the supplied asset group id. If the group do not exist, the routine will leave.
- public procedure RemoveGroup
(
const
ADescr :
string
)
;
overload;
Removes a specific asset group from package by the supplied asset group descriptin. If the group do not exist, the routine will leave.
- public function GetGroup
(
const
AIdx :
Integer
)
: TGorillaAssetsGroup
;
overload;
Tries to find a specific assets group by the supplied group id. If no group could be found, the routine returns nil.
- public function GetGroup
(
const
ADescr :
string
)
: TGorillaAssetsGroup
;
overload;
Tries to find a specific assets group by the supplied group description. If no group could be found, the routine returns nil.
- public function GetGroupIndex
(
const
ADescr :
string
)
: Integer
;
overload;
Returns the group index inside of the group collection by the supplied description. If the specific group could not be found, the routine returns -1.
- public function GetGroupIndex
(
const
AGroup :
TGorillaAssetsGroup
)
: Integer
;
overload;
Returns the group index inside of the group collection by the supplied instance. If the specific group could not be found, the routine returns -1.
- public function GetGroupByExtension
(
const
AExt :
string
)
: TGorillaAssetsGroup
;
Tries to find a valid assets group by a supplied file extension.
- public procedure ClearGroup
(
const
AIdx :
Integer; const
ADeleteInArchive :
Boolean
=
False
)
;
Removes all contained assets from a specific group. The method will lookup for the group by the supplied index. If no group could be found, the routine will leave.
- public function FindAsset
(
const
AFilename :
string; const
AStrictFilename :
Boolean
=
False
)
: TGorillaAsset
;
Selects the assets group by the supplied filename extension. And then scans all assets to find a suitable one.
- public function FindAssetByArchivePath
(
const
APath :
string
)
: TGorillaAsset
;
Tries to find an asset by a specific archive path, f.e. "MODEL\84BE036B-A4D6-49B3-B90F-77740810A06C\..."
- public function AssetExists
(
const
AFilename :
string
)
: Boolean
;
Tries to find an assets in a specific group by its filename. If it can be found the method returns true otherwise false.
- public function AddAssetFromFile
(
const
AFilename :
string
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The method automatically detects the asset group and searches for the asset. If no asset could be found, the routine imports the asset from supplied file.
- public function GetAssetFromId
(
const
AGroup :
Integer; const
AId :
TGUID
)
: TGorillaAsset
;
Returns an asset by a supplied unique identifier (GUID) in the supplied asset group. If not asset with this GUID could be found, the method returns nil.
- public function GetOwnerAssetFromId
(
AOwner :
TGorillaAsset; const
AGroup :
Integer; const
AId :
TGUID
)
: TGorillaAsset
;
Returns an asset by a supplied unique identifier (GUID) in the supplied asset group of a specific owner. If no assets owner was supplied it will lookup the general groups. If not asset with this GUID could be found, the method returns nil.
- public function GetAssetFromFile
(
const
AGroup :
Integer; const
AFilename :
string
)
: TGorillaAsset
;
overload;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group (by id). If no asset could be found, the routine imports the asset from supplied file.
- public function GetAssetFromFile
(
const
AGroupName :
string; const
AFilename :
string
)
: TGorillaAsset
;
overload;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group (by name). If no asset could be found, the routine imports the asset from supplied file.
- public function GetOwnerAssetFromFile
(
const
AOwner :
TGorillaAsset; const
AGroup :
Integer; const
AFilename :
string
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group of a specific owner. If no assets owner was supplied it will lookup the general groups. If no asset could be found, the routine imports the asset from supplied file.
- public function GetAssetFromStream
(
const
AGroup :
Integer; const
AFilename :
string; const
AStream :
TStream
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group. If no asset could be found, the routine imports the asset from supplied stream.
- public function GetOwnerAssetFromStream
(
const
AOwner :
TGorillaAsset; const
AGroup :
Integer; const
AFilename :
string; const
AStream :
TStream
)
: TGorillaAsset
;
Tries to find a specific asset by a supplied filename. The routine searches in the supplied asset group of a specific owner. If no assets owner was supplied it will lookup the general groups. If no asset could be found, the routine imports the asset from supplied stream.
- public function GetSize
(
)
: Int64
;
virtual;
Returns the number of bytes of the package itself, all groups and all contained assets inside.
- public function HasArchive
(
)
: Boolean
;
Return TRUE if FArchive is available, otherwise false
- public procedure LoadFromFile
(
const
AFilename :
string
)
;
virtual;
Loads a package with all groups and assets from supplied file.
- public procedure LoadFromStream
(
const
AStream :
TStream
)
;
virtual;
Loads a package with all groups and assets from supplied stream.
- public procedure SaveToFile
(
const
AFilename :
string; AAutoReopen :
Boolean
=
True
)
;
virtual;
Stores a package with all groups and assets to a zip archive file.
- public procedure SaveToStream
(
const
AStream :
TStream
)
;
virtual;
Stores a package with all groups and assets to a zip archive stream.
- public procedure SetUserLoadOptions
(
const
AOpts :
TGorillaLoadOptions
)
;
Set the package relevant model load options on inserting model assets. Take care to setup up the record correctly, otherwise you may destroy the package.
- public procedure UnsetUserLoadOptions ( ) ;
- public function UserLoadOptionsActive ( ) : Boolean ;
- public function Log ( ) : string ;
Properties
- public Manager : TGorillaAssetsManager
- public GUID : TGUID
Returns the unique identifier of the specific package. This value is automatically set while construction.
read FGUID - public Archive : TGorillaArchiveReference
- published DisplayName : string
A description for the specific asset package to better identify different packages.
read GetDisplayName
write SetDisplayName - published Groups : TGorillaAssetsGroupCollection
- published Filename : TFileName
Get or set filename for file-packages. This property is available at designtime to load up packages in IDE. It uses the LoadFromFile() call and loads all containing assets. Caution: Depending on the size of the package, this may take a while.
read GetFilename
write SetFilename
TGorillaAssetsPackageCollection
Ancestors
Members
Properties
TGorillaAssetsManager
The AssetsManager is central access point to all of your media data. Use packages and groups to organize your data.
Ancestors
Members
Fields
- protected FArchiveReferences :
TGorillaArchiveReferences
- protected FLOD :
TGorillaLevelOfDetail
- protected FPackages :
TGorillaAssetsPackageCollection
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetPackages ( const AValue : TGorillaAssetsPackageCollection ) ;
- public procedure Refresh ( ) ;
- public procedure Loaded ( ) ; override;
- public function GetSize ( ) : Int64 ; virtual;
- public function AddEmptyPackage
(
const
ADescr :
string
=
)
: TGorillaAssetsPackage
;
virtual;
Creates a new and empty package. The package contains the default groups: MODELS, TEXTURES, AUDIO, VIDEO, ... without any assets.
- public function GetPackageIndex
(
const
AGUID :
TGUID
)
: Integer
;
overload virtual;
Returns the collection index of a specific assets package by its unique identifier.
- public function GetPackageIndex
(
const
ADescr :
string
)
: Integer
;
overload virtual;
Returns the collection index of a specific assets package by its description.
- public function GetPackage
(
const
AGUID :
TGUID
)
: TGorillaAssetsPackage
;
overload virtual;
Returns a package object by its unique identifier.
- public function GetPackage
(
const
ADescr :
string
)
: TGorillaAssetsPackage
;
overload virtual;
Returns a package object by its description.
- public procedure RemovePackage
(
const
AGUID :
TGUID
)
;
overload virtual;
Removes a specific package by its supplied unique identifier. The method destroys all groups and assets within. If the package could not be found, the routine will leave.
- public procedure RemovePackage
(
const
ADescr :
string
)
;
overload virtual;
Removes a specific package by its supplied description. The method destroys all groups and assets within. If the package could not be found, the routine will leave.
- public procedure ClearPackages
(
)
;
Destroys all contained packages with its groups and assets.
- public function LoadPackageFromFile
(
const
AFilename :
string
)
: TGorillaAssetsPackage
;
virtual;
Creates a new package and adds it to the manager. Afterwards the method will load the package from file.
Properties
- published LOD : TGorillaLevelOfDetail
- published Packages : TGorillaAssetsPackageCollection
Get or set the internal package collection component. Within this collection all created/loaded packages are available.
read FPackages
write SetPackages