//-------------------------------------------------- 
// Title:		FieldEngine
// Author:		Tony Kim 
// Date:		2006 Nov 10 
// Description: Mainly background overhead
//-------------------------------------------------- 

#pragma once
#include <windows.h>

//-------------------------------------------------- 
// Windows Function Declarations
//-------------------------------------------------- 
int WINAPI			WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow);
LRESULT CALLBACK	WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

//-------------------------------------------------- 
// Application functions
// Note: Implemented outside of the class
//-------------------------------------------------- 
BOOL Initialize(HINSTANCE hInstance);
void Start(HWND hWindow);
void End();
void Activate(HWND hWindow);
void Deactivate(HWND hWindow);
void Cycle( bool noUpdate = false );

//--------------------------------------------------
// Mouse Input Handling
//--------------------------------------------------
void MouseButtonDown(int x, int y, BOOL bLeft);
void MouseButtonUp(int x, int y, BOOL bLeft);
void MouseMove(int x, int y);


//-------------------------------------------------- 
// FieldEngine Class
//-------------------------------------------------- 
class FieldEngine
{
protected:
	//-------------------------------------------------- 
	// Member variables
	//--------------------------------------------------
	static FieldEngine* m_pFieldEngine;
	HINSTANCE			m_hInstance;
	HWND				m_hWindow;
	TCHAR				m_szWindowClass[32];
	TCHAR				m_szTitle[32];
	WORD				m_wIcon, m_wSmallIcon;
	int					m_iWidth, m_iHeight;
	int					m_iFrameDelay;
	BOOL				m_bSleep;

public:
	//--------------------------------------------------
	// Constructor(s)/Destructor
	//--------------------------------------------------
	FieldEngine( HINSTANCE hInstance,
				 LPTSTR	szWindowClass,
				 LPTSTR	szTitle,
				 WORD wIcon,
				 WORD wSmallIcon,
				 int iWidth = 800,
				 int iHeight = 600 ); // Note: default window size
	virtual ~FieldEngine();

	//--------------------------------------------------
	// General methods
	//--------------------------------------------------
	static FieldEngine* GetEngine() { return m_pFieldEngine; }
	BOOL Initialize(int iCmdShow);
	LRESULT	HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam);


	//--------------------------------------------------
	// Accessor methods
	//--------------------------------------------------
	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_wSmallIcon; }
	int		  GetWidth()					{ return m_iWidth; }
	int		  GetHeight()					{ return m_iHeight; }
	int		  GetFrameDelay()				{ return m_iFrameDelay; }
	void	  SetFrameRate(int iFrameRate)	{ m_iFrameDelay = 1000 / iFrameRate; }
	BOOL	  GetSleep()					{ return m_bSleep; }
	void	  SetSleep(BOOL bSleep)			{ m_bSleep = bSleep; }
};

