 |
Gorgon Game Engine
|
Go to the documentation of this file.
3 #include "../Graphics.h"
131 base(&base), ctrl(controller)
135 base(new A_(std::move(base))), ctrl(controller), own(true)
139 base(other.base), ctrl(other.ctrl)
141 other.base =
nullptr;
152 auto ret =
new typename std::remove_reference<decltype(*
this)>::type(std::move(*
this));
168 return base->CreateAnimation(
false);
206 if(base) base->Prepare();
223 base(parent.CreateBase()), ctrl(parent.GetController())
233 base(parent.CreateBase()), ctrl(parent.GetController())
242 base.DrawIn(target, ctrl, r, color);
247 base.DrawIn(target, controller, r, color);
258 base.Draw(target, p1, p2, p3, p4, tex1, tex2, tex3, tex4, color);
266 base.Draw(target, p1, p2, p3, p4, color);
271 return base.GetSize();
basic_ScalableObject< A_ > & CreateAnimation(bool create=true) const override
Definition: ScalableObject.h:157
virtual int GetDuration() const =0
Returns the duration of the animation if it is a known apriori.
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
~basic_ScalableObject()
Definition: ScalableObject.h:60
virtual void drawin(TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color) const override
This function should draw the object to the target area.
Definition: Rectangle.cpp:63
void SetBM(A_ *value)
Changes the BM animation, ownership semantics will not change.
Definition: Rectangle.h:500
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
Base(ControllerBase &controller)
Sets the controller for this animation to the given controller.
Definition: Animation.h:310
SizeController GetController() const override
Returns the size controller.
Definition: ScalableObject.h:181
This class allows control over a sizable object.
Definition: Graphics.h:161
A_ * GetML() const
Returns ML provider, may return nullptr.
Definition: Rectangle.h:415
static EmptyImage & Instance()
Returns the instance for empty image. Only one instance is enough.
Definition: EmptyImage.h:50
void SetTR(A_ *value)
Changes the TR animation, ownership semantics will not change.
Definition: Rectangle.h:460
virtual bool GetSideTiling() const
Returns if the middle part will be tiled.
Definition: Rectangle.h:65
A_ * GetBase() const
Returns the base component. Could return nullptr.
Definition: ScalableObject.h:176
A_ * GetMM() const
Returns MM provider, may return nullptr.
Definition: Rectangle.h:420
basic_TextureAnimationProvider< Bitmap, basic_TextureAnimation, basic_AnimationFrame< Bitmap > > BitmapAnimationProvider
Definition: TextureAnimation.h:520
constexpr Type Null
Null resource.
Definition: GID.h:105
A_ * GetBR() const
Returns BR provider, may return nullptr.
Definition: Rectangle.h:440
void SetBL(A_ *value)
Changes the BL animation, ownership semantics will not change.
Definition: Rectangle.h:492
T_ Right() const
Calculates and returns the rightmost coordinate.
Definition: Rectangle.h:143
basic_ScalableObject< A_ > & CreateAnimation(Gorgon::Animation::ControllerBase &timer) const override
Definition: ScalableObject.h:161
SizeController GetSizeController() const
Returns the size controller used in this scalable object.
Definition: ScalableObject.h:70
virtual void draw(TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color) const override
This method should draw to object inside the given quad with the given texture coordinates.
Definition: Rectangle.cpp:119
void SaveAnimation(Writer &writer, const Graphics::RectangularAnimationProvider &object)
Saves a given generic rectangular animation as resource.
Definition: Resource.cpp:22
Controllers are required to progress animations.
Definition: Animation.h:65
virtual bool GetCenterTiling() const
Returns if the middle part will be tiled.
Definition: Rectangle.h:53
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
void WriteChunkHeader(GID::Type type, unsigned long size)
Writes the header of a chunk.
Definition: Writer.h:364
virtual auto MoveOutProvider() -> decltype(*this) override
Definition: ScalableObject.h:151
Rectangle()=default
Creates an empty rectangle.
float Float
Represents floating point data type.
Definition: Types.h:16
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
int GetDuration() const override
Returns the duration of the animation if it is a known apriori.
Definition: ScalableObject.h:78
constexpr Type Image
Image resource.
Definition: GID.h:149
Marker WriteObjectStart(const Base &base)
Writes the start of an object. Should have a matching WriteEnd with the returned marker.
Definition: File.cpp:211
Interface for RectangleProviders.
Definition: Rectangle.h:12
void SetMM(A_ *value)
Changes the MM animation, ownership semantics will not change.
Definition: Rectangle.h:476
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
A_ * GetTM() const
Returns TM provider, may return nullptr.
Definition: Rectangle.h:405
For ease of use in resource system.
Definition: ScalableObject.h:11
void Prepare()
Prepares the providers.
Definition: ScalableObject.h:205
RectangularAnimation & CreateBase() const override
Creates a base animation without controller.
Definition: ScalableObject.h:166
basic_Size< T_ > GetSize() const
Returns the size of the rectangle.
Definition: Rectangle.h:218
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
void SetBR(A_ *value)
Changes the BR animation, ownership semantics will not change.
Definition: Rectangle.h:508
virtual void draw(TextureTarget &target, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color) const override
This method should draw to object inside the given quad with the given texture coordinates.
Definition: ScalableObject.h:253
basic_ScalableObject(const basic_ScalableObjectProvider< A_ > &parent, bool create=true)
Definition: ScalableObject.h:221
static Rectangle * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads a rectangle resource from the file.
Definition: Rectangle.cpp:83
@ Stretch
The drawing is stretched along this axis to cover the given size.
Definition: Graphics.h:171
typename A_::AnimationType AnimationType
Definition: ScalableObject.h:124
void SetTM(A_ *value)
Changes the TM animation, ownership semantics will not change.
Definition: Rectangle.h:452
Definition: ScalableObject.h:26
Bitmap Slice(Geometry::Bounds bounds) const
Returns a new bitmap containing a slice of this bitmap.
Definition: Bitmap.h:746
This object creates a scalable object from a graphic object.
Definition: ScalableObject.h:122
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
BitmapRectangleProvider SliceHorizontal(const Bitmap &source, int t, int b, int tl, int tr, int l, int r, int bl, int br)
Horizontally slices the given image.
Definition: Rectangle.cpp:135
virtual Geometry::Size calculatesize(const SizeController &controller, const Geometry::Size &s) const override
This function should return the size of the object when it is requested to be drawn in the given area...
Definition: ScalableObject.h:91
virtual bool Progress(unsigned &) override
This function should progress the animation.
Definition: ScalableObject.h:74
Marker WriteChunkStart(GID::Type type)
Writes the start of a chunk. Should have a matching WriteEnd.
Definition: Writer.h:351
constexpr Type Rectangle_Props_II
Definition: GID.h:240
A_ * GetTL() const
Returns TL provider, may return nullptr.
Definition: Rectangle.h:400
Rectangular drawable animation.
Definition: Animations.h:19
void SetBase(A_ *value)
Sets the base provider, ownership semantics will not be changed.
Definition: ScalableObject.h:191
void DrawIn(TextureTarget &target, Tiling tiling, int x, int y, int w, int h, RGBAf color=RGBAf(1.f)) const
Draws the object to the target using the given tiling information.
Definition: Drawables.h:157
Collection is a container for reference typed objects.
Definition: Collection.h:21
T_ Bottom() const
Calculates and returns the bottommost coordinate.
Definition: Rectangle.h:146
basic_RectangleProvider< BitmapAnimationProvider > AnimatedBitmapRectangleProvider
Definition: Rectangle.h:591
This object contains an bitmap image.
Definition: Bitmap.h:25
basic_ScalableObjectProvider(basic_ScalableObjectProvider &&other)
Definition: ScalableObject.h:138
constexpr Type Animation
Definition: GID.h:187
void SetController(const SizeController &value) override
Sets the controller.
Definition: ScalableObject.h:186
Tiling Horizontal
Horizontal tiling mode.
Definition: Graphics.h:470
void OwnProvider()
Assumes the ownership of the providers.
Definition: ScalableObject.h:199
~basic_ScalableObjectProvider()
Definition: ScalableObject.h:144
void SetML(A_ *value)
Changes the ML animation, ownership semantics will not change.
Definition: Rectangle.h:468
Iterator First()
returns the iterator to the first item
Definition: Collection.h:608
basic_Size< Float > Sizef
Definition: Size.h:388
virtual Geometry::Size calculatesize(const Geometry::Size &area) const override
This function should return the size of the object when it is requested to be drawn in the given area...
Definition: ScalableObject.h:87
This interface defines a class that can be used as a common target for texture based drawing.
Definition: TextureTargets.h:12
long GetCount() const
Returns number of elements.
Definition: Collection.h:236
virtual void SetController(const SizeController &value)=0
This class represents a 2D point.
Definition: Point.h:32
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
void SetMR(A_ *value)
Changes the MR animation, ownership semantics will not change.
Definition: Rectangle.h:484
virtual void DeleteAnimation() const
Deletes this animation.
Definition: Animation.h:379
Graphics::IRectangleProvider & MoveOutProvider() override
This function moves this animation provider into a new provider.
Definition: Rectangle.cpp:324
Rectangle(const IRectangleProvider &prov, Gorgon::Animation::ControllerBase &timer)
Definition: Rectangle.cpp:29
basic_RectangleProvider< RectangularAnimationProvider > RectangleProvider
Definition: Rectangle.h:588
Definition: Rectangle.h:11
basic_ScalableObject(RectangularAnimation &base, const SizeController &ctrl, Gorgon::Animation::ControllerBase &timer)
Creates a scalable object from two animations, these animations should not have controllers attached ...
Definition: ScalableObject.h:49
A_ * GetBL() const
Returns BL provider, may return nullptr.
Definition: Rectangle.h:430
A regular drawable animation.
Definition: Animations.h:14
void WriteEnd(Marker &marker)
This function performs writes necessary to end a chunk that is represented by the marker.
Definition: Writer.h:373
const Geometry::Size GetSize() const
Returns the size of this object.
Definition: Drawables.h:443
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
virtual Graphics::RectangularAnimationStorage animmoveout() override
Definition: Rectangle.cpp:320
This class provides rectangular animations.
Definition: Animations.h:48
virtual bool HasController() const
Returns whether this animation has a controller.
Definition: Animation.h:344
virtual Geometry::Size getsize() const override
Should return the exact size of this object.
Definition: ScalableObject.h:270
This class allows instancing of a rectangle like image that is made out of three parts.
Definition: Rectangle.h:185
virtual IScalableObjectProvider & MoveOutProvider() override=0
This function moves this animation provider into a new provider.
@ Graphics
Definition: Template.h:164
constexpr Type Rectangle
Definition: GID.h:238
virtual void RemoveController()
Removes the controller of this animation.
Definition: Animation.h:357
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
Gorgon::Animation::basic_Storage< RectangularAnimationProvider > RectangularAnimationStorage
Definition: Animations.h:374
basic_ScalableObjectProvider(A_ &base, const SizeController &controller=Tiling::Both)
Filling constructor.
Definition: ScalableObject.h:130
basic_RectangleProvider< Bitmap > BitmapRectangleProvider
Definition: Rectangle.h:590
Geometry::Size GetSize() const override
Definition: ScalableObject.h:209
basic_ScalableObjectProvider()=default
Empty constructor.
int GetHeight() const
Returns the height of the drawable.
Definition: Drawables.h:451
constexpr Type Rectangle_Props
Definition: GID.h:239
A_ * GetTR() const
Returns TR provider, may return nullptr.
Definition: Rectangle.h:410
void WriteBool(bool value)
Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers.
Definition: Writer.h:220
basic_ScalableObjectProvider(A_ &&base, const SizeController &controller=Tiling::Both)
Definition: ScalableObject.h:134
IRectangleProvider()
Definition: Rectangle.h:14
virtual void SetController(ControllerBase &controller)
Sets the controller to the given controller.
Definition: Animation.h:334
int GetWidth() const
Returns the width of the drawable.
Definition: Drawables.h:448
Containers::Collection< Base > children
Child objects that this resource object have.
Definition: Base.h:162
static void SaveThis(Writer &writer, const Graphics::IRectangleProvider &provider)
Definition: Rectangle.cpp:250
void SetTL(A_ *value)
Changes the TL animation, ownership semantics will not change.
Definition: Rectangle.h:444
virtual void drawin(TextureTarget &target, const Geometry::Rectanglef &r, RGBAf color) const override
This function should draw the object to the target area.
Definition: ScalableObject.h:241
A_ * GetMR() const
Returns MR provider, may return nullptr.
Definition: Rectangle.h:425
const Geometry::Size CalculateSize(const Geometry::Size &area) const
Calculates the adjusted size of this drawable depending on the given area.
Definition: Drawables.h:322
Geometry::Rectangle CalculateArea(const Geometry::Size &objectsize, const Geometry::Size &area) const
Calculates the drawing area of the object according to the tiling and placement rules.
Definition: Graphics.h:330
A_ * GetBM() const
Returns BM provider, may return nullptr.
Definition: Rectangle.h:435
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
ControllerBase * controller
Controller of this animation.
Definition: Animation.h:388
basic_ScalableObject(RectangularAnimation &base, const SizeController &ctrl, bool create=true)
Creates a scalable object from two animations, these animations should not have controllers attached ...
Definition: ScalableObject.h:35
void SetSizeController(SizeController value)
Changes the size controller used in this scalable object.
Definition: ScalableObject.h:65
BitmapRectangleProvider SliceVertical(const Bitmap &source, int l, int r, int tl, int bl, int t, int b, int tr, int br)
Vertically slices the given image.
Definition: Rectangle.cpp:149
virtual RectangularAnimation & CreateBase() const =0
Tiling Vertical
Vertical tiling mode.
Definition: Graphics.h:473
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
void save(Writer &writer) const override
Definition: Rectangle.cpp:231
virtual Geometry::Size getsize() const override
Should return the exact size of this object.
Definition: Rectangle.cpp:53
void Draw(TextureTarget &target, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, RGBAf color=RGBAf(1.f)) const
Draw the object to the target by specifying coordinates for four corners.
Definition: Drawables.h:132
virtual ControllerBase & GetController() const
Returns the controller of this animation.
Definition: Animation.h:347
virtual SizeController GetController() const =0