/*Copyright (C) 2010 Deveaux Duncan

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_MANAGER
#define DEF_ANIMATION_MANAGER

#include <SFML/Graphics.hpp>
#include <vector>
#include <string>
#include "Engines/Graphics/GraphicsEngine.hpp"
#include "extlibs/TinyXML/tinyxml.h"
#include "Animation.hpp"

//Class managing a list of animations. It can :
// -Start animations (blocking or not)
// -Edit animations parameters (direction, position...)
class AnimationManager
{
    public:
        AnimationManager();
        AnimationManager(const std::string &animationsPath, const std::string &animationsListPath);
        
        void load(const std::string &animationsPath, const std::string &animationsListPath);
        
        void startAnimation(int ixAnimation, bool blocking=false, int ixBackAnimation=0);
        void update();
        
        void startRendering(GraphicsEngine &renderEngine);
        void stopRendering(GraphicsEngine &renderEngine);
        
        Animation *getCurrentAnimation();
        const sf::Vector2f &getAnimationOrigin() const;
        
        bool isAnimationBlocking() const;
        
        void setDirection(int direction);
        int getDirection() const;
        
        float getWidth() const;
        float getHeight() const;
        
        void setXPosition(float position);
        float getXPosition() const;
        void setYPosition(float position);
        float getYPosition() const;
    
    private:
        void loadAnimationsList(const std::string &animationsPath, const std::string &animationsListPath);
        
        std::vector<Animation> m_animationsList;
        sf::Sprite m_renderImage;
        int m_direction;
        bool m_directionAltered;
        int m_ixAnimation;
        int m_ixBackAnimation;
        bool m_blockingAnimation;
};

#endif