//msimg32.lib winmm.lib
#pragma once
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <sys/stat.h>
#include <conio.h>
#include <string>
#include <time.h>

using std::string;
using std::ifstream;
using namespace::std;

int WINAPI			WinMain				(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR szCmd, int iCmd);
LRESULT CALLBACK	WndProc				(HWND hWnd, UINT msg, WPARAM wPar, LPARAM lPar);
BOOL				GameInitialize		(HINSTANCE hInst);
void				GameStart			(HWND hWin);
void				GameEnd				();
void				GamePaint			(HDC hDC);
void				GameCycle			();
int					HandleKeys			();
void				HandleTyping		(char Letter);
void				SetWasMinimized		(bool value);
//void	GameActivate		(HWND hWin);
//void	GameDeactivate		(HWND hWin);
bool exists (const std::string& filename);
class Engine
{
public:
	// Constructor(s)/Destructor
						Engine(HINSTANCE hInstance, LPTSTR szWindowClass, LPTSTR szTitle,
								WORD wIcon, WORD wSmallIcon, DWORD Style, int iWidth, int iHeight, int ShwCmd);
	virtual				~Engine	();
	static Engine*		GetEngine		()					{ return m_pEngine;						};
	BOOL                Initialize		(int iCmdShow);
	LRESULT             HandleEvent		(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam);

	HINSTANCE			GetInstance		()					{ return m_hInstance;					};
	HWND				GetWindow		()					{ return m_hWindow;						};
	void				SetWindow		(HWND hWindow)		{ m_hWindow = hWindow;					};
	LPTSTR				GetTitle		()					{ return m_szTitle;						};
	WORD				GetIcon			()					{ return m_wIcon;						};
	WORD				GetSmallIcon	()					{ return m_wSmIcon;						};
	int					GetWidth		()					{ return m_iWidth;						};
	int					GetHeight		()					{ return m_iHeight;						};
	int					GetFrameDelay	()					{ return m_iFPS;						};
	void				SetFrameRate	(int iFrameRate)	{ m_iFPS = 1000 / iFrameRate;			};
	BOOL				GetSleep		()					{ return m_bSleep;						};
	void				SetSleep		(BOOL bSleep)		{ m_bSleep = bSleep;					};

	void				MouseButtonDN	(int x, int y, BOOL bLeft);
	void				MouseButtonUP	(int x, int y, BOOL bLeft);
	void				MouseMove		(int x, int y);
	int					GetMouseX		()					{ return m_iMouseX;						};
	int					GetMouseY		()					{ return m_iMouseY;						};
	bool				GetMouseLeft	()					{ return m_bLeft;						};
	void				SetMouseDrag	(bool data)			{ m_bMouseDrag = data;					};
	bool				GetMouseDrag	()					{ return m_bMouseDrag;					};
	bool				GetMouseUP		()					{ return m_bMouseUp;					};
	void				SetMouseUP		(bool data)			{ m_bMouseUp = data;					};
	void				SetIsTyping		(bool data)			{ m_bTyping = data;						};
	bool				GetIsTyping		()					{ return m_bTyping;						};

	void				SetIsGame		(bool data)			{ m_IsGame = data;						};
	bool				GetIsGame		() const			{ return m_IsGame;						};

	void				SetWinStyle		(DWORD data)		{ m_Style = data;						};
	DWORD				GetWinStyle		() const			{ return m_Style;						};

protected:
	static Engine*		m_pEngine;
	HINSTANCE			m_hInstance;
	HWND				m_hWindow;
	TCHAR				m_szWindowClass[32];
	TCHAR				m_szTitle[32];
	DWORD				m_Style;//This is declared on a per project basis...
	WORD				m_wIcon;
	WORD				m_wSmIcon;
	int					m_iWidth;
	int					m_iHeight;
	int                 m_iFPS;
	int					m_iMouseX;
	int					m_iMouseY;
	int					m_ShwCmd;
	bool				m_bLeft;
	bool				m_bMouseDrag;
	bool				m_bMouseUp;
	bool				m_bTyping;
	bool				m_IsGame;
	BOOL                m_bSleep;
};