#ifndef __ENGINE_H__
#define __ENGINE_H__

#include <deque>
#include <string>
#include "Python.h"
#include "SDL_mixer.h"
#include "SDL_ttf.h"
#include "SDL_framerate.h"

#include "guiapply.h"
#include "graphics.h"
#include "log.h"
#include "scenario.h"
#include "shop.h"
#include "units.h"

struct FFTFont
{
	TTF_Font *font;
	std::string name;
};
struct FFTGUI
{
	GUI *gui;
	std::string name;
};
struct FFTStars
{
	StarField *stars;
	bool above;
	int factor;
};
struct FFTSound
{
	Mix_Chunk *sound;
	std::string name;
};
struct FFTSurface
{
	SDL_Surface *surface;
	std::string name;
};

class Engine
{
public:
	Engine();
	~Engine();
	void Quit();
	bool StartGame();
	int InGameMenu();
	int MainLoop();
	void CleanUpGame();
	void Render();
	bool ShipSelect();
	FPKShip **LoadAllFPKShips();
	void SetMainModule(std::string modulename);
	Unit *GetMainShip();
	void SetMainShip(Unit *ship);
	void InControl(bool control);
	Scenario *GetMainScenario();
	void SetMainScenario(Scenario *scen);
	FFTInput *GetInput();
	void SetInput(FFTInput *input);
	Map *GetMap();
	void SetMap(Map* map);
	TTF_Font *GetFont(std::string name);
	void AddFont(std::string name, TTF_Font *font);
	Mix_Chunk *GetSound(std::string name);
	void AddSound(std::string name, Mix_Chunk *sound);
	GUI *GetGUI(std::string name);
	void AddGUI(std::string name, GUI *gui);
	SDL_Surface *GetSurface(std::string name);
	void AddSurface(std::string name, SDL_Surface *surface);
	void AddStarfield(StarField *stars, bool above, int factor);
	void ShowFPS();
private:
	bool showfps;
	bool running;
	bool incontrol;
	std::string mainmodule;
	Unit *mainship;
	Scenario *mainscen;
	FFTInput *maininput;
	Map *mainmap;
	std::deque<FFTFont> fonts;
	std::deque<FFTGUI> guis;
	std::deque<FFTSound> sounds;
	std::deque<FFTSurface> surfaces;
	std::deque<FFTStars> starfields;
};

#endif /* __ENGINE_H__ */

