Gorgon
Show / Hide Table of Contents

Class Gorgon2DFileSystemExtensions

Extension methods for loading sprite data from file systems.

Inheritance
object
Gorgon2DFileSystemExtensions
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.IO.Extensions
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public static class Gorgon2DFileSystemExtensions

Methods

| Edit this page View Source

LoadAnimationFromFileSystem(GorgonFileSystem, Gorgon2D, string, GorgonTexture2DLoadOptions, IEnumerable<IGorgonAnimationCodec>, IEnumerable<IGorgonImageCodec>)

Function to load a IGorgonAnimation from a GorgonFileSystem.

Declaration
public static IGorgonAnimation LoadAnimationFromFileSystem(this GorgonFileSystem fileSystem, Gorgon2D renderer, string path, GorgonTexture2DLoadOptions textureOptions = null, IEnumerable<IGorgonAnimationCodec> animationCodecs = null, IEnumerable<IGorgonImageCodec> imageCodecs = null)
Parameters
Type Name Description
GorgonFileSystem fileSystem

The file system to load the animation from.

Gorgon2D renderer

The renderer for the animation.

string path

The path to the animation file in the file system.

GorgonTexture2DLoadOptions textureOptions

[Optional] Options for the texture loaded associated the sprite.

IEnumerable<IGorgonAnimationCodec> animationCodecs

The list of animation codecs to try and load the animation with.

IEnumerable<IGorgonImageCodec> imageCodecs

The list of image codecs to try and load the animation texture(s) with.

Returns
Type Description
IGorgonAnimation

The animation data in the file as a IGorgonAnimation.

Remarks

This method extends a GorgonFileSystem so that animations can be loaded by calling a method on the file system object itself. This negates the need for users to create complex code for loading an animation.

When loading an animation, the method will attempt to locate any GorgonTexture2DView objects associated with the animation (if they exist). When loading, it will check:

  1. For a texture resource with the same name that is already loaded into memory.
  2. Use the local IGorgonVirtualDirectory for the sprite file and search for the texture in that directory.
  3. Check the entire fileSystem for a file if the texture name contains path information (this is done by the GorgonEditor from v2).
If the file is found, and can be loaded by one of the imageCodecs, then it is loaded and assigned to the sprite.

The animationCodecs is a list of codecs for loading sprite data. If the user specifies this parameter, the only the codecs provided will be used for determining if an animation can be read. If it is not supplied, then all built-in (i.e. not plug in based) sprite codecs will be used.

The imageCodecs is a list of codecs for loading image data. If the user specifies this parameter, the only the codecs provided will be used for determining if an image can be read. If it is not supplied, then all built-in (i.e. not plug in based) image codecs will be used.

Exceptions
Type Condition
ArgumentNullException

Thrown when the fileSystem, renderer, or path parameter is null.

ArgumentEmptyException

Thrown when the path parameter is empty.

FileNotFoundException

Thrown if the file in the path was not found.

GorgonException

Thrown if the animation data in the file system could not be loaded because a suitable codec was not found.

See Also
GorgonFileSystem
GorgonTexture2DView
IGorgonAnimation
| Edit this page View Source

LoadPolySpriteFromFileSystem(GorgonFileSystem, Gorgon2D, string, GorgonTexture2DLoadOptions, IEnumerable<IGorgonPolySpriteCodec>, IEnumerable<IGorgonImageCodec>)

Function to load a GorgonPolySprite from a GorgonFileSystem.

Declaration
public static GorgonPolySprite LoadPolySpriteFromFileSystem(this GorgonFileSystem fileSystem, Gorgon2D renderer, string path, GorgonTexture2DLoadOptions textureOptions = null, IEnumerable<IGorgonPolySpriteCodec> spriteCodecs = null, IEnumerable<IGorgonImageCodec> imageCodecs = null)
Parameters
Type Name Description
GorgonFileSystem fileSystem

The file system to load the sprite from.

Gorgon2D renderer

The renderer for the sprite.

string path

The path to the sprite file in the file system.

GorgonTexture2DLoadOptions textureOptions

[Optional] Options for the texture loaded associated the sprite.

IEnumerable<IGorgonPolySpriteCodec> spriteCodecs

The list of polygonal sprite codecs to try and load the sprite with.

IEnumerable<IGorgonImageCodec> imageCodecs

The list of image codecs to try and load the sprite texture with.

Returns
Type Description
GorgonPolySprite

The sprite data in the file as a GorgonSprite.

Remarks

This method extends a GorgonFileSystem so that sprites can be loaded by calling a method on the file system object itself. This negates the need for users to create complex code for loading a sprite.

When loading a sprite, the method will attempt to locate the GorgonTexture2DView associated with the sprite (if it exists). When loading, it will check:

  1. For a texture resource with the same name that is already loaded into memory.
  2. Use the local IGorgonVirtualDirectory for the sprite file and search for the texture in that directory.
  3. Check the entire fileSystem for a file if the texture name contains path information (this is done by the GorgonEditor from v2).
If the file is found, and can be loaded by one of the imageCodecs, then it is loaded and assigned to the sprite.

The spriteCodecs is a list of codecs for loading polygonal sprite data. If the user specifies this parameter, the only the codecs provided will be used for determining if a sprite can be read. If it is not supplied, then all built-in (i.e. not plug in based) sprite codecs will be used.

The imageCodecs is a list of codecs for loading image data. If the user specifies this parameter, the only the codecs provided will be used for determining if an image can be read. If it is not supplied, then all built-in (i.e. not plug in based) image codecs will be used.

Exceptions
Type Condition
ArgumentNullException

Thrown when the fileSystem, renderer, or path parameter is null.

ArgumentEmptyException

Thrown when the path parameter is empty.

FileNotFoundException

Thrown if the file in the path was not found.

GorgonException

Thrown if the sprite data in the file system could not be loaded because a suitable codec was not found.

See Also
GorgonFileSystem
GorgonTexture2DView
GorgonPolySprite
| Edit this page View Source

LoadSpriteFromFileSystem(IGorgonFileSystem, Gorgon2D, string, GorgonTexture2DLoadOptions, IEnumerable<IGorgonSpriteCodec>, IEnumerable<IGorgonImageCodec>)

Function to load a GorgonSprite from a GorgonFileSystem.

Declaration
public static GorgonSprite LoadSpriteFromFileSystem(this IGorgonFileSystem fileSystem, Gorgon2D renderer, string path, GorgonTexture2DLoadOptions textureOptions = null, IEnumerable<IGorgonSpriteCodec> spriteCodecs = null, IEnumerable<IGorgonImageCodec> imageCodecs = null)
Parameters
Type Name Description
IGorgonFileSystem fileSystem

The file system to load the sprite from.

Gorgon2D renderer

The renderer for the sprite.

string path

The path to the sprite file in the file system.

GorgonTexture2DLoadOptions textureOptions

[Optional] Options for the texture loaded associated the sprite.

IEnumerable<IGorgonSpriteCodec> spriteCodecs

[Optional] The list of sprite codecs to try and load the sprite with.

IEnumerable<IGorgonImageCodec> imageCodecs

[Optional] The list of image codecs to try and load the sprite texture with.

Returns
Type Description
GorgonSprite

The sprite data in the file as a GorgonSprite.

Remarks

This method extends a GorgonFileSystem so that sprites can be loaded by calling a method on the file system object itself. This negates the need for users to create complex code for loading a sprite.

When loading a sprite, the method will attempt to locate the GorgonTexture2DView associated with the sprite (if it exists). When loading, it will check:

  1. For a texture resource with the same name that is already loaded into memory.
  2. Use the local IGorgonVirtualDirectory for the sprite file and search for the texture in that directory.
  3. Check the entire fileSystem for a file if the texture name contains path information (this is done by the GorgonEditor from v2).
If the file is found, and can be loaded by one of the imageCodecs, then it is loaded and assigned to the sprite.

The spriteCodecs is a list of codecs for loading sprite data. If the user specifies this parameter, the only the codecs provided will be used for determining if a sprite can be read. If it is not supplied, then all built-in (i.e. not plug in based) sprite codecs will be used.

The imageCodecs is a list of codecs for loading image data. If the user specifies this parameter, the only the codecs provided will be used for determining if an image can be read. If it is not supplied, then all built-in (i.e. not plug in based) image codecs will be used.

Exceptions
Type Condition
ArgumentNullException

Thrown when the fileSystem, renderer, or path parameter is null.

ArgumentEmptyException

Thrown when the path parameter is empty.

FileNotFoundException

Thrown if the file in the path was not found.

GorgonException

Thrown if the sprite data in the file system could not be loaded because a suitable codec was not found.

See Also
GorgonFileSystem
GorgonTexture2DView
GorgonSprite
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author