/*Copyright (C) 2010-2012 Duncan Deveaux

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEF_ANIMATION_GROUP
#define DEF_ANIMATION_GROUP

#include "Animation.hpp"
#include "Structs/Box.hpp"
#include <vector>
#include <string>

//static loadFromXML method
#include "extlibs/TinyXML/tinyxml.h"
#include "Engines/Resources/TextureManager.hpp"

//Class managing a list of animations. It can :
// -Start animations (blocking or not)
// -Edit animations parameters (direction, position...)
class AnimationGroup : public Drawable
{
    public:
        AnimationGroup();
        void draw();
        
        void addAnimation(const Animation &animation, int animationIx = -1);
        void removeAnimation(int animationIx);
        
        void startAnimation(int animationIx, bool blocking = false, int ixBackAnimation = 0, bool force = false);
        
        void update(float frameTime);
        void updateOrigin();
        
        //Get and set methods
        bool animationBlocking() const;
        bool animationFinished() const;
        
        void setXFlip(bool flip);
        Box getBox(int animationIx = -1) const;
        
        //Static methods
        static AnimationGroup loadFromXML(const std::string &xmlPath, const std::string &animationsPath, TextureManager &textureManager);
    
    private:
        std::vector<Animation> m_animationsList;
        
        int m_ixAnimation;
        int m_ixBackAnimation;
        bool m_blockingAnimation;
};

#endif
