#ifndef _CSPRITE_HPP_
#define _CSPRITE_HPP_

/*** SDL Header Files ***/
#include <SDL.h> 

/*** Custom Header Files ***/
#include "cImage.hpp"
#include "cCamera.hpp"

#include "../TextTypeEngine/cText.hpp"
#include "../MathEngine/iVector/iVector2.hpp"
#include "../MathEngine/iVector/iVector4.hpp"

#include "../UtilityEngine/cString.hpp"

/*** DLL Header File ***/
#include "dllExport.h"

using UtilityEngine::cString;

namespace VideoEngine {
	class EXPORT_FROM_MYDLL cSprite
	{
	public:
		cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera = nullptr );
		cSprite( const signed long int xpos = 0, const signed long int ypos = 0, const signed long int xarea = 0,
			const signed long int yarea = 0, const unsigned long int warea = 0, const unsigned long int harea = 0,
			VideoEngine::cImage** image = nullptr, VideoEngine::cCamera** camera = nullptr );
		
		cSprite& operator=( const cSprite& copy );
		~cSprite();
		
		///Functions
		/* Draws the sprite to the video buffer */
		void Draw();
		/* Draws the sprite to the camera */
		void CameraDraw();
		/* Draws the sprite to a SDL_Renderer */
		/*void RendererDraw( SDL_Renderer* rend );*/
		/* Draws the sprite to the video buffer with out positioning it */
		void DefaltDraw();

		void AddPosX( const signed long int x );
		void AddPosY( const signed long int y );

		void SaveImage( const cString& fileName, const cString& dir = "" );

		///Sets
		/* Sets the X position of the sprite on the surface, camera or video buffer */
		void setPosX( const signed long int x );
		/* Sets the Y position of the sprite on the surface, camera or video buffer */
		void setPosY( const signed long int y );
		/* Sets the position of the sprite on the surface, camera or video buffer */
		void setPosition( const signed long int x, const signed long int y );
		/* Sets the position of the sprite on the surface, camera or video buffer */
		void setPosition( const MathEngine::iVector2& position = MathEngine::iVector2(0,0) );
		
		/* Sets the start and end of the image area */
		void setImageArea( const MathEngine::iVector4& area = MathEngine::iVector4(0,0,0,0) );
		/* Sets the top left of the area to take from the image */
		void setStartImageArea( const signed long int x, const signed long int y );		/// Top left starting area.
		/* Sets the bottom right of the area to take from the image */
		void setEndImageArea( const unsigned long int w, const unsigned long int h );	/// Bottom right image ends.

		/* Sets the pointer to a pointer for the image that the sprite will use */
		void setImage( VideoEngine::cImage** image );
		/* Sets the pointer to a pointer for the camera the sprite will be draw on */
		void setCamera( VideoEngine::cCamera** camera );
		
		///Gets
		/* Gets the X position of the sprite on the surface, camera or video buffer */
		const signed long int getPosX() const;
		/* Gets the Y position of the sprite on the surface, camera of video buffer */
		const signed long int getPosY() const;
		/* Gets the position of the sprite on the surface, camera or video buffer */
		void getPosition( signed long int& x, signed long int& y ) const;
		/* Gets the position of the sprite on the surface, camera or video buffer */
		const MathEngine::iVector4 getPosition() const;
		
		/* Gets the top left of the area to take from the image */
		void getStartImageArea( signed long int& x, signed long int& y ) const;
		/* Gets the bottom right of the area to take from the image */
		void getEndImageArea( unsigned long int& w, unsigned long int& h ) const;
		/* Gets the area of the image */
		const SDL_Rect& getImageArea() const;

		/* Gets the width of the sprite */
		const unsigned long int getWidth() const;
		/* Gets the height of the sprite */
		const unsigned long int getHeight() const;

		/* Gets a pointer to the image used by the sprite */
		VideoEngine::cImage* getImage() const;
		/* Gets a pointer to the camera used by the sprite */
		VideoEngine::cCamera* getCamera() const;

		/* Gets returns true if image pointer is not null other wise returns false */
		const bool getImageSetup() const;
		/* Gets returns true if camera pointer is not null other wise returns false */
		const bool getCameraSetup() const;

	private:
		void setPositionEnd();		

	private:
		///Variables
		SDL_Rect m_position;	/// Were the Sprite will be position on the screen (Upper Left)
		
		SDL_Rect m_imageArea;	/// What part of the image to take

		VideoEngine::cImage** mpp_image;// = nullptr
		VideoEngine::cCamera** mpp_camera;// = nullptr
	};/// END CLASS DEFINITION cSprite
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CSPRITE_HPP_
