#pragma once

/* Windows version of soccer client		*/
/* updated 8/8/03						*/
/* Dan Maynes-Aminzade <monzy@mit.edu>	*/

#include "precomp.h"
#include "UDPPeer.h"
#include "SoccerField.h"

typedef CWinTraits<WS_OVERLAPPEDWINDOW|WS_VISIBLE,0> SoccerClientTraits;
class CSoccerClient: public CWindowImpl<CSoccerClient,CWindow,SoccerClientTraits>
{
public:
	static CWndClassInfo& GetWndClassInfo()
	{
		static CWndClassInfo wc =
		{
			{ sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, 
			StartWindowProc,
			0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1), NULL, 
			_T("SoccerClient"), LoadIcon(_Module.m_hInst, MAKEINTRESOURCE(ICON_SOCCER)) },
			NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
		};
		return wc;
	}

	BEGIN_MSG_MAP( CMyWindow )
		MESSAGE_HANDLER( WM_CHAR, OnChar )
		MESSAGE_HANDLER( WM_KEYDOWN, OnKeydown )
		MESSAGE_HANDLER( WM_PAINT, OnPaint )
		MESSAGE_HANDLER( WM_CREATE, OnCreate )
		MESSAGE_HANDLER( WM_DESTROY, OnDestroy )
		MESSAGE_HANDLER( WM_SOCKETREAD, OnSocketRead )
		MESSAGE_HANDLER( WM_TIMER, OnTimer )
	END_MSG_MAP()
 
	LRESULT OnChar( UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnKeydown( UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnPaint( UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnCreate(UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnDestroy( UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnSocketRead(UINT, WPARAM, LPARAM, BOOL& );
	LRESULT OnTimer(UINT, WPARAM, LPARAM, BOOL& );

private:
	UDPClient *client;
	UDPServer *server;
	int currentplayer, currentteam;
	SoccerField field;
};
