// PopView.h : interface of the CPopView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_POPVIEW_H__89C2B64F_322E_11D3_AD90_000000000000__INCLUDED_)
#define AFX_POPVIEW_H__89C2B64F_322E_11D3_AD90_000000000000__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "popdoc.h"

class cGraphics; //for _pgraphics member.
class cGraphicsMFC; //for _pgraphicsMFCsingleton member.
class cGraphicsOpenGL; //for _pgraphicsOpenGLsingleton member.
class cCritterViewer; //for _pviewpointcritter member.
class cCritter; //for the pixelToCritterPlaneVector method argument.

class CPopView : public CView
{
protected: // create from serialization only
	CPopView();
	DECLARE_DYNCREATE(CPopView)

// Attributes
public:
	CPopDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPopView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CPopView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CPopView)
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnViewColoredbubbles();
	afx_msg void OnUpdateViewColoredbubbles(CCmdUI* pCmdUI);
	afx_msg void OnViewXraybubbles();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnViewDraggercursor();
	afx_msg void OnUpdateViewDraggercursor(CCmdUI* pCmdUI);
	afx_msg void OnViewPincursor();
	afx_msg void OnUpdateViewPincursor(CCmdUI* pCmdUI);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnUpdateViewXraybubbles(CCmdUI* pCmdUI);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnViewArrowcursor();
	afx_msg void OnUpdateViewArrowcursor(CCmdUI* pCmdUI);
	afx_msg void OnViewSpawncursor();
	afx_msg void OnUpdateViewSpawncursor(CCmdUI* pCmdUI);
	afx_msg void OnViewZapcursor();
	afx_msg void OnUpdateViewZapcursor(CCmdUI* pCmdUI);
	afx_msg void OnViewReplicatecursor();
	afx_msg void OnUpdateViewReplicatecursor(CCmdUI* pCmdUI);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnGameBackground();
	afx_msg void OnUpdateGameBackground(CCmdUI* pCmdUI);
	afx_msg void OnViewShootcursor();
	afx_msg void OnUpdateViewShootcursor(CCmdUI* pCmdUI);
	afx_msg void OnViewOpenglgraphics();
	afx_msg void OnUpdateViewOpenglgraphics(CCmdUI* pCmdUI);
	afx_msg void OnViewMfcgraphics();
	afx_msg void OnUpdateViewMfcgraphics(CCmdUI* pCmdUI);
	afx_msg void OnViewTranslate();
	afx_msg void OnUpdateViewTranslate(CCmdUI* pCmdUI);
	afx_msg void OnViewRide();
	afx_msg void OnUpdateViewRide(CCmdUI* pCmdUI);
	afx_msg void OnViewFly();
	afx_msg void OnUpdateViewFly(CCmdUI* pCmdUI);
	afx_msg void OnViewKeepplayerinview();
	afx_msg void OnUpdateViewKeepplayerinview(CCmdUI* pCmdUI);
	afx_msg void OnViewOrbit();
	afx_msg void OnUpdateViewOrbit(CCmdUI* pCmdUI);
	afx_msg void OnViewSolidbackground();
	afx_msg void OnUpdateViewSolidbackground(CCmdUI* pCmdUI);
	afx_msg void OnViewNobackground();
	afx_msg void OnUpdateViewNobackground(CCmdUI* pCmdUI);
	afx_msg void OnViewRestoreViewpoint();
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
//==========Human Written code starts here============  RR.
public: //Statics
	static BOOL STARTBITMAPBACKGROUNDFLAG;
	static BOOL STARTSOLIDBACKGROUNDFLAG;
	static COLORREF GAMEOVEREDGECOLOR;
	static COLORREF GAMEACTIVEEDGECOLOR;
 /*DF stands for drawflags.  Used by all the draw(cGraphics, drawflags) methods in cGame,
		cBiota, cCritter, and cSprite. */
	static const int DF_STANDARD; //Setting drawflags = DF_STANDARD does a standard draw.
	static const int DF_FOCUS; //Draw a dotted-line circle around the sprite.
	static const int DF_THINEDGE; //Use single-pixel pens for lines.
	static const int DF_WIREFRAME; //Means fill with NULL_BRUSH.
	static const int DF_USEBACKGROUNDBITMAP; //Means to fill the game border with a bitmap.
	static const int DF_USESOLIDBACKGROUND; //Means to fill the game border with a solid
		//color provided that DF_USEBACKGROUNDBITMAP isn't on.
protected:
	cCritterViewer *_pviewpointcritter;
	cGraphics *_pgraphics; /* _pgraphics is the currently active cGraphics* pointer, and will
		either be _pgraphicsMFCsingleton or _pgraphicsOpenGLsingleton.  The latter two start
		as NULL and get	allocated when first needed by setGraphicsClass.  The reason we keep
		them around is so that we don't have to repeatedly delete and reallocate them if
		we flip between MFC grpahics and OpenGL graphics.  The reason to reduce the flipping
		cost is that we've been having a (non-crash) error message in the cGraphicsOpenGL
		destructor that we'd rather not have to see as often. Note that keeping both MFC
		and OpenGL graphics objects around could be a bit of a strain on memory, but we'll
		try it for now. */
	cGraphicsMFC *_pgraphicsMFCsingleton;
	cGraphicsOpenGL *_pgraphicsOpenGLsingleton;
	int _drawflags;
	HCURSOR _hCursor;
	//Functions
	void updateStatusBar();
	BOOL isActiveView(); //Useful in the OnSetCursor call.
public:
//Accessors
	cGraphics *pgraphics();
	CRuntimeClass* pgraphicsclass();
	BOOL useBackgroundBitmap(){return _drawflags & CPopView::DF_USEBACKGROUNDBITMAP?TRUE:FALSE;}
	BOOL useSolidBackground(){return _drawflags & CPopView::DF_USESOLIDBACKGROUND?TRUE:FALSE;}
	HCURSOR hcursor(){return _hCursor;}
	int drawflags(){return _drawflags;}
	int cx();
	int cy();
	cGame* pgame();
	cCritterViewer* pviewpointcritter()
		{ASSERT(_pviewpointcritter); return _pviewpointcritter;}
//Mutators
	void setGraphicsClass(CRuntimeClass *pruntimegraphicsclass); /* Feed in either
		RUNTIME_CLASS(cGraphicsMFC) or RUNTIME_CLASS(cGraphicsOpenGL).  Don't
		call this in the constructor as CPopView isn't complete enough yet to
		support intializeOpenGL.  Call in OnCreate or perhaps in response to a 
		View menu selection that asks to change the graphics type. */
	void setUseBackgroundBitmap(BOOL onoff); //Changes _drawflags
	void setUseSolidBackground(BOOL onoff); //Changes _drawflags
	void setCursor(HCURSOR hcursor){_hCursor = hcursor;}//Use in PopDoc when chaging gametype.
	void setCursorPosToCritter(cCritter *pcritter); 
//Methods that make a simple call to _pgraphics
	//Vector/pixel methods
	void setRealBox(cRealBox border);
	void vectorToPixel(cVector position, int &xpix, int &ypix, Real &zbuff);
	cVector pixelToVector( int xpix, int ypix, Real zbuff = 0.0);
	cVector pixelToCritterPlaneVector(int xpix, int ypix, cCritter *pcritter);
	cVector pixelToPlayerPlaneVector(int xpix, int ypix);
	cVector pixelToCritterYonWallVector(int xpix, int ypix, cCritter *pcritter, Real distancetoyon);
	cVector pixelToPlayerYonWallVector(int xpix, int ypix, Real distancetoyon);
	COLORREF sniff(cVector sniffpoint);
//Serialize
	virtual void Serialize(CArchive& ar);
};

#ifndef _DEBUG  // debug version in PopView.cpp
inline CPopDoc* CPopView::GetDocument()
   { return (CPopDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_POPVIEW_H__89C2B64F_322E_11D3_AD90_000000000000__INCLUDED_)
