| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // Copyright (c) 2008-2017 the Urho3D project.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- #pragma once
- #include "../Container/ArrayPtr.h"
- #include "../Resource/Resource.h"
- #ifdef ATOMIC_SPINE
- struct spAtlas;
- struct spSkeletonData;
- struct spAnimationStateData;
- #endif
- namespace Atomic
- {
- namespace Spriter
- {
- struct SpriterData;
- }
- class Sprite2D;
- class SpriteSheet2D;
- /// Spriter animation set, it includes one or more animations, for more information please refer to http://www.esotericsoftware.com and http://www.brashmonkey.com/spriter.htm.
- class ATOMIC_API AnimationSet2D : public Resource
- {
- ATOMIC_OBJECT(AnimationSet2D, Resource);
- public:
- /// Construct.
- AnimationSet2D(Context* context);
- /// Destruct.
- virtual ~AnimationSet2D();
- /// Register object factory.
- static void RegisterObject(Context* context);
- /// Load resource from stream. May be called from a worker thread. Return true if successful.
- virtual bool BeginLoad(Deserializer& source);
- /// Finish resource loading. Always called from the main thread. Return true if successful.
- virtual bool EndLoad();
- /// Get number of animations.
- unsigned GetNumAnimations() const;
- /// Return animation name.
- String GetAnimation(unsigned index) const;
- /// Check has animation.
- bool HasAnimation(const String& animation) const;
-
- /// Return sprite.
- Sprite2D* GetSprite() const;
- #ifdef ATOMIC_SPINE
- /// Return spine skeleton data.
- spSkeletonData* GetSkeletonData() const { return skeletonData_; }
- #endif
- /// Return spriter data.
- Spriter::SpriterData* GetSpriterData() const { return spriterData_.Get(); }
- /// Return spriter file sprite.
- Sprite2D* GetSpriterFileSprite(int folderId, int fileId) const;
- private:
- /// Return sprite by hash.
- Sprite2D* GetSpriterFileSprite(const StringHash& hash) const;
- #ifdef ATOMIC_SPINE
- /// Begin load spine.
- bool BeginLoadSpine(Deserializer& source);
- /// Finish load spine.
- bool EndLoadSpine();
- #endif
- /// Begin load scml.
- bool BeginLoadSpriter(Deserializer& source);
- /// Finish load scml.
- bool EndLoadSpriter();
- /// Dispose all data.
- void Dispose();
-
- /// Spine sprite.
- SharedPtr<Sprite2D> sprite_;
-
- #ifdef ATOMIC_SPINE
- /// Spine json data.
- SharedArrayPtr<char> jsonData_;
- /// Spine skeleton data.
- spSkeletonData* skeletonData_;
- /// Spine atlas.
- spAtlas* atlas_;
- #endif
-
- /// Spriter data.
- UniquePtr<Spriter::SpriterData> spriterData_;
- /// Has sprite sheet.
- bool hasSpriteSheet_;
- /// Sprite sheet file path.
- String spriteSheetFilePath_;
- /// Sprite sheet.
- SharedPtr<SpriteSheet2D> spriteSheet_;
- /// Spriter sprites.
- HashMap<int, SharedPtr<Sprite2D> > spriterFileSprites_;
- };
- }
|