#pragma once

#include <Resource/FolderResource.h>
#include <Resource/ImageResource.h>
#include <Resource/DataResource.h>
#include <Engine/Layer.h>
#include <Utils/Size2D.h>
#include <Utils/Point2D.h>
#include <Utils/LinkedList.h>


namespace gaming { namespace background {

	//Supposed to handle dynamic backgrounds
	class Background {
	public:

		//When resizable object rolls in replace
		//by tiling properties
		enum ObjectTiling {
			Single=0,
			Tile
		};


		//Should have animation props
		class Object {
		public:
			ImageResource *Image;

			ObjectTiling Tiling;

			Point Coordinates;

			Size2D Size;

			Object() : Image(NULL), Tiling(Tile), Coordinates(0,0), Size(main->W,main->H), item(NULL)
			{ }

			LinkedListItem<Object, int, 5>*item;

			int getOrder() { if(item) return item->getOrder(); else return 0; }
		};

		//Holds background objects
		LinkedList<Object, int, 5> Objects;


		Background() : layer(NULL) { 
			Objects.IterationType=LinkedList<Object, int, 5>::OrderedReverse;
		}

		void ObtainFrom(gge::resource::FolderResource *);

		void UseLayer(gge::LayerBase &layer);

		void Refresh();

		//***************
		//!TODO:
		//Should have pause etc... maybe will be bound to
		//AnimatorBase


	protected:

		struct {

			Basic2DLayer BackgroundLayer;

		} LayerStructure;

		void ConstructLayerStructure();

		void BeforeRender();

		gge::LayerBase *layer;

	};



} }
