Gorgon Game Engine
Animation Class Reference

This class represents an animation resource. More...

Inheritance diagram for Animation:
[legend]

Public Member Functions

 Animation ()
 Default constructor. More...
 
 Animation (const Animation &)=delete
 Copy constructor is disabled, use Duplicate or DeepDuplicate. More...
 
 Animation (Graphics::BitmapAnimationProvider &&anim)
 Conversion constructor. More...
 
virtual GID::Type GetGID () const override
 Returns the Gorgon Identifier. More...
 
Graphics::RectangularAnimationStorage MoveOut ()
 Moves this animation out as a generic value type animation. More...
 
Graphics::BitmapAnimationProvider MoveOutAsBitmap ()
 Moves the animation out of the resource system. Use Prepare and Discard before moving out to avoid copying data. !!! More...
 
Graphics::BitmapAnimationProviderMoveOutProvider () override
 
Animationoperator= (const Animation &other)=delete
 Copy assignment is disabled, use Duplicate. More...
 
- Public Member Functions inherited from basic_TextureAnimationProvider< T_, A_, F_ >
 basic_TextureAnimationProvider ()=default
 
template<class C_ >
 basic_TextureAnimationProvider (C_ &&other)
 
 basic_TextureAnimationProvider (const basic_TextureAnimationProvider &)=delete
 
 ~basic_TextureAnimationProvider ()
 
void Add (const F_ &frame)
 
void Add (const Gorgon::Animation::Frame &frame) override
 
void Add (T_ &&image, unsigned duration=42)
 Adds the given image to the end of the animation. More...
 
void Add (T_ &image, unsigned duration=42, bool own=false)
 Adds the given image to the end of the animation. More...
 
Iterator begin ()
 Returns an iterator to the beginning of the animation frames. More...
 
ConstIterator begin () const
 Returns an iterator to the beginning of the animation frames. More...
 
void Clear () override
 Removes all images from the animation. More...
 
virtual AnimationTypeCreateAnimation (bool create=true) const override
 Creates a new animation from this resource. More...
 
virtual AnimationTypeCreateAnimation (Gorgon::Animation::ControllerBase &controller) const override
 Creates a new animation from this resource. More...
 
basic_TextureAnimationProvider Duplicate () const
 
Iterator end ()
 Returns an iterator to the end of the animation frames. More...
 
ConstIterator end () const
 Returns an iterator to the end of the animation frames. More...
 
const F_ & FrameAt (int index) const override
 Returns the frame at specific point. More...
 
unsigned FrameIndexAt (unsigned time) const
 Returns which frame is at the given time. More...
 
int GetCount () const override
 Returns number of frames. More...
 
unsigned GetDuration () const override
 Returns the duration of the animation. More...
 
unsigned GetDuration (unsigned frame) const override
 Returns the duration of the given frame. More...
 
int GetHeight () const
 Returns the size of the first image. More...
 
Geometry::Size GetSize () const override
 Returns the size of the first image. More...
 
int GetWidth () const
 Returns the size of the first image. More...
 
T_ & ImageAt (unsigned time) const
 Returns the image that is to be shown at the given time. More...
 
void Insert (const F_ &frm, int before)
 Inserts the given image before the given frame. More...
 
void Insert (const Gorgon::Animation::Frame &frame, int before) override
 Inserts the given image before the given frame. More...
 
void Insert (T_ &&img, int before, unsigned duration=42)
 Inserts the given image before the given frame. More...
 
void Insert (T_ &image, int before, unsigned duration=42)
 Inserts the given image before the given frame. More...
 
void MoveBefore (unsigned index, int before) override
 Moves a frame that has the index before the given position. More...
 
template<class C_ >
basic_TextureAnimationProvideroperator= (C_ &&other)
 
basic_TextureAnimationProvideroperator= (const basic_TextureAnimationProvider &)=delete
 
T_ & operator[] (int frame) const
 Returns the image at the given frame. More...
 
void Own (T_ &image)
 Owns the given image so that it would be destroyed with this animation. More...
 
void ReleaseAll ()
 Releases ownership of all images in the animation without destroying them. More...
 
void Remove (ConstIterator it)
 Removes an image from the animation. More...
 
void Remove (unsigned frame) override
 Removes an image from the animation. More...
 
unsigned StartOf (unsigned frame) const override
 Returns the starting time of the given frame. More...
 
- Public Member Functions inherited from AnimationStorage
Graphics::RectangularAnimationStorage MoveOut ()
 Moves this animation out as a generic value type animation. More...
 
- Public Member Functions inherited from Base
 Base ()
 Default constructor. More...
 
const Containers::Collection< Base >::ConstIterator begin () const
 Allows easy iteration through range based fors. More...
 
const Containers::Collection< Base >::ConstIterator cbegin () const
 Beginning of children. More...
 
const Containers::Collection< Base >::ConstIterator cend () const
 End of children. More...
 
bool DeleteResource ()
 Safely deletes the resource. More...
 
virtual void Discard ()
 This function shall discard any transitional data which is not vital after Prepare function is issued. More...
 
const Containers::Collection< Base >::ConstIterator end () const
 Allows easy iteration through range based fors. More...
 
virtual SGuid GetGuid () const
 Returns the guid of the object. More...
 
const std::string & GetName () const
 Returns the name of this object. More...
 
BaseGetParent () const
 Returns the parent. If no parent set, this function throws std::runtime_error. More...
 
BaseGetParentPtr () const
 Returns the pointer to the parent. This function may return nullptr. More...
 
const BaseGetRoot () const
 Returns the root of this resource. More...
 
bool HasParent () const
 Returns whether this object has a parent. More...
 
virtual bool IsEqual (const SGuid &guid) const
 This function tests whether this object has the given SGuid. More...
 
virtual void Prepare ()
 This function shall prepare this resource to be used after resource is loaded. More...
 
virtual void Resolve (File &file)
 This function shall resolve links or similar constructs. More...
 
void Save (Writer &writer)
 Saves this object into the given writer. The writer should be open prior to this call. More...
 
virtual void SetGuid (SGuid guid)
 Changes the guid of the object. More...
 
virtual void SetName (const std::string &name)
 Sets the name of the object. More...
 

Static Public Member Functions

static AnimationLoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
 This function loads an animation resource from the given file. More...
 
static bool LoadResourceWith (Animation &anim, std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size, std::function< Base *(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, GID::Type, unsigned long)> loadfn)
 This function allows loading animation with a function to load unknown resources. More...
 
static void SaveThis (Writer &writer, const Graphics::BitmapAnimationProvider &anim, GID::Type type=GID::Animation, std::function< void(Writer &writer)> extra={})
 Saves the given animation as a resource. More...
 

Protected Member Functions

virtual ~Animation ()
 
virtual Graphics::RectangularAnimationStorage animmoveout () override
 
void save (Writer &writer) const override
 
void savedata (Writer &writer) const
 
- Protected Member Functions inherited from Base
virtual ~Base ()
 Destructor, Always children gets destroyed first. More...
 
void destroychildren ()
 Destroys the children of this resource. More...
 
void setparenttonullptr (Base &base)
 Sets the parent of an object to nullptr, provides access. More...
 

Additional Inherited Members

- Public Types inherited from basic_TextureAnimationProvider< T_, A_, F_ >
using AnimationType = basic_TextureAnimation< T_, basic_TextureAnimationProvider< T_, A_, F_ >, F_ >
 
using ConstIterator = typename std::vector< basic_AnimationFrame< T_ > >::const_iterator
 
using FrameType = F_
 
using Iterator = typename std::vector< basic_AnimationFrame< T_ > >::iterator
 
- Public Attributes inherited from Base
const Containers::Collection< Base > & Children
 The children this object have. More...
 
unsigned long refcount
 INTERNAL, Reference count, used in linking mechanism. More...
 
- Protected Attributes inherited from basic_TextureAnimationProvider< T_, A_, F_ >
Containers::Collection< T_ > destroylist
 
unsigned duration
 
std::vector< basic_AnimationFrame< T_ > > frames
 
- Protected Attributes inherited from Base
Containers::Collection< Basechildren
 Child objects that this resource object have. More...
 
SGuid guid
 SGuid to identify this resource object. More...
 
std::string name
 Name of this resource object, may not be loaded. More...
 
Baseparent
 Immediate parent of this resource. More...
 
const Baseroot
 Root of this resource. More...
 

Detailed Description

This class represents an animation resource.

Image animations can be created using this object. An animation object can be moved. Duplicate function should be used to copy an animation.

Constructor & Destructor Documentation

◆ Animation() [1/3]

Animation ( )

Default constructor.

◆ Animation() [2/3]

Conversion constructor.

◆ Animation() [3/3]

Animation ( const Animation )
delete

Copy constructor is disabled, use Duplicate or DeepDuplicate.

◆ ~Animation()

virtual ~Animation ( )
protectedvirtual

Member Function Documentation

◆ animmoveout()

Graphics::RectangularAnimationStorage animmoveout ( )
overrideprotectedvirtual

◆ GetGID()

virtual GID::Type GetGID ( ) const
overridevirtual

Returns the Gorgon Identifier.

Implements Base.

References Gorgon::Resource::GID::Animation.

◆ LoadResource()

static Animation* LoadResource ( std::weak_ptr< File file,
std::shared_ptr< Reader reader,
unsigned long  size 
)
static

This function loads an animation resource from the given file.

References Animation::Animation(), Base::DeleteResource(), and Animation::LoadResourceWith().

◆ LoadResourceWith()

bool LoadResourceWith ( Animation anim,
std::weak_ptr< File file,
std::shared_ptr< Reader reader,
unsigned long  size,
std::function< Base *(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, GID::Type, unsigned long)>  loadfn 
)
static

This function allows loading animation with a function to load unknown resources.

The supplied function should call LoadObject function of File class if the given GID is unknown.

◆ MoveOut()

Moves this animation out as a generic value type animation.

◆ MoveOutAsBitmap()

Graphics::BitmapAnimationProvider MoveOutAsBitmap ( )

Moves the animation out of the resource system. Use Prepare and Discard before moving out to avoid copying data. !!!

References basic_TextureAnimationProvider< T_, A_, F_ >::Add(), Base::children, basic_TextureAnimationProvider< T_, A_, F_ >::duration, and basic_TextureAnimationProvider< T_, A_, F_ >::frames.

◆ MoveOutProvider()

Graphics::BitmapAnimationProvider & MoveOutProvider ( )
overridevirtual

◆ operator=()

Animation& operator= ( const Animation other)
delete

Copy assignment is disabled, use Duplicate.

◆ save()

void save ( Writer writer) const
overrideprotectedvirtual

◆ savedata()

◆ SaveThis()

void SaveThis ( Writer writer,
const Graphics::BitmapAnimationProvider anim,
GID::Type  type = GID::Animation,
std::function< void(Writer &writer)>  extra = {} 
)
static

Saves the given animation as a resource.

If the given animation is already a resource, its own save function will be used. Extra function can be used to save extra data related with this resource.


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