Gorgon Game Engine
Animation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Base.h"
4 #include "AnimationStorage.h"
5 #include "../Animation.h"
6 #include "Image.h"
7 #include "../Graphics/TextureAnimation.h"
8 
9 #pragma warning(push)
10 #pragma warning(disable:4250)
11 
12 namespace Gorgon { namespace Resource {
13  class File;
14  class Reader;
15 
16 
20  public:
22  Animation() {}
23 
26  }
27 
29  Animation(const Animation&) = delete;
30 
32  Animation &operator =(const Animation &other) = delete;
33 
35 
37  virtual GID::Type GetGID() const override {
38  return GID::Animation;
39  }
40 
43 
46  static bool LoadResourceWith(Animation &anim, std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long size,
47  std::function<Base*(std::weak_ptr<File> file, std::shared_ptr<Reader> reader,
48  GID::Type, unsigned long)> loadfn);
49 
51  static Animation *LoadResource(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long size) {
52  Animation *a = new Animation();
53 
54  auto res = LoadResourceWith(*a, file, reader, size, {});
55 
56  if(!res) {
57  a->DeleteResource();
58  a = nullptr;
59  }
60 
61  return a;
62  }
63 
66  static void SaveThis(Writer &writer, const Graphics::BitmapAnimationProvider &anim, GID::Type type = GID::Animation,
67  std::function<void(Writer &writer)> extra = {});
68 
70  protected:
71  virtual ~Animation() { }
72 
74 
75  void save(Writer &writer) const override;
76 
77  // Two part save system allows objects that are derived from animation to exist.
78  void savedata(Writer &writer) const;
79  };
80 } }
81 
82 #pragma warning(pop)
Gorgon::Resource::Base::DeleteResource
bool DeleteResource()
Safely deletes the resource.
Definition: Base.cpp:34
Gorgon::Animation::basic_Storage
This class stores animations as a part of itself so that it can be moved around as a value rather tha...
Definition: Storage.h:21
Gorgon::Resource::GID::File
constexpr Type File
File.
Definition: GID.h:84
Gorgon::Graphics::basic_TextureAnimationProvider
Definition: TextureAnimation.h:137
Gorgon::Graphics::BitmapAnimationProvider
basic_TextureAnimationProvider< Bitmap, basic_TextureAnimation, basic_AnimationFrame< Bitmap > > BitmapAnimationProvider
Definition: TextureAnimation.h:520
Gorgon::Resource::Animation::operator=
Animation & operator=(const Animation &other)=delete
Copy assignment is disabled, use Duplicate.
Gorgon::Resource::Animation::save
void save(Writer &writer) const override
Definition: Animation.cpp:92
Base.h
Gorgon::Resource::Animation::SaveThis
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.
Definition: Animation.cpp:100
Image.h
Gorgon::Resource::Animation::Animation
Animation(Graphics::BitmapAnimationProvider &&anim)
Conversion constructor.
Definition: Animation.h:25
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Resource::Animation::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon Identifier.
Definition: Animation.h:37
Gorgon::Resource::AnimationStorage
This class denotes the resource is an image animation storage.
Definition: AnimationStorage.h:12
AnimationStorage.h
Gorgon::Resource::GID::Animation
constexpr Type Animation
Definition: GID.h:187
Gorgon::Resource::Base
This class is the base for all Gorgon Resources.
Definition: Base.h:20
Gorgon::Resource::Animation::LoadResourceWith
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.
Definition: Animation.cpp:8
Gorgon::Resource::Animation::MoveOutProvider
Graphics::BitmapAnimationProvider & MoveOutProvider() override
Definition: Animation.cpp:150
Gorgon::Resource::Writer
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
Gorgon::Resource::Animation::Animation
Animation(const Animation &)=delete
Copy constructor is disabled, use Duplicate or DeepDuplicate.
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Gorgon::Resource::AnimationStorage::MoveOut
Graphics::RectangularAnimationStorage MoveOut()
Moves this animation out as a generic value type animation.
Definition: AnimationStorage.h:15
Gorgon::Resource::GID::Type
Type to store GID information.
Definition: GID.h:23
Gorgon::Resource::Animation::savedata
void savedata(Writer &writer) const
Definition: Animation.cpp:79
Gorgon::Resource::Animation::~Animation
virtual ~Animation()
Definition: Animation.h:71
Gorgon::Resource::Animation::MoveOutAsBitmap
Graphics::BitmapAnimationProvider MoveOutAsBitmap()
Moves the animation out of the resource system. Use Prepare and Discard before moving out to avoid co...
Definition: Animation.cpp:124
Gorgon::Resource::Animation::LoadResource
static Animation * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads an animation resource from the given file.
Definition: Animation.h:51
Gorgon::Resource::Animation::Animation
Animation()
Default constructor.
Definition: Animation.h:22
Gorgon::Resource::Animation::animmoveout
virtual Graphics::RectangularAnimationStorage animmoveout() override
Definition: Animation.cpp:154
Gorgon::Resource::Animation
This class represents an animation resource.
Definition: Animation.h:19