/*****************************************************************************
 * $Id: eng_event.hh,v 1.5 2006/11/15 18:31:13 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Engine events.
 *//*
 * LEGAL:	COPYRIGHT (C) 2006 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#ifndef ENG_EVENT_HH
#define ENG_EVENT_HH 1

#include "eng_dyna.hh"

class Sorted;

////////////////////////////////////////////////////////////////////////////////
/// @brief Engine event nexus.
/// @remarks The engine broadcasts events out to listener functions in other modules.
/// Using this event mechanism helps make the engine modular.
///
/// Example of client registering as a listener:
///
///     Client function is called when enginer becomes ready.
///     void ListenerEngineReady(void);
///     gEngineEvent.mEngineReady.Listen( ListenerEngineReady, true );
///
class EngineEvents
{
public:
	Event<void>			mEngineReady;		// other modules should listen for this, not gfxsysReady
	Event<void>			mGfxsysReady;
	Event<void>			mExit;
	Event<void>			mAnimate;
	Event<void>			mTick;
	Event<void>     	mNeedTextureDirVec;
	Event<string&>		mTextureFilter;  // opportunity for a module to filter a texture being loaded
	Event<void>			mDrawObjects;
	Event<void>			mResetScene;
	Event<void>			mPreDrawViews;
	Event<void>			mPostDrawViews;
	Event<Geom<int>&>	mReshape;
	Event<void>			mLodUserChange;
	Event< std::pair<eMouseEvent,bool> > mMouseButton;
	Event< std::pair<int,int> >			 mMouseMotion;

	// Events that disrupt sorted objects.
	// Dyna events also disrupt sorted objects as well as pointers to Dynas.
	// Any Dyna ptr held across frames may turn invalid so listen for this event.
    enum eEyeChange
	{
		eEyeChange_TOTAL,  // both rotation/translation changed
		eEyeChange_TRANSLATE_X_POS,
        eEyeChange_TRANSLATE_Y_POS,
        eEyeChange_TRANSLATE_Z_POS,  // forward
		eEyeChange_TRANSLATE_X_NEG,
        eEyeChange_TRANSLATE_Y_NEG,
        eEyeChange_TRANSLATE_Z_NEG,  // backward
        eEyeChange_PITCH,
        eEyeChange_YAW,
        eEyeChange_ROLL,
	};
	static eEyeChange   EyeChangeEnumRotate( uint axis );
	static eEyeChange	EyeChangeEnumTranslate( uint axis, int dir );
	Event<eEyeChange>	mEyeChange;
	Event<void>			mLocusChange;
	Event<DynaPtr>		mDynaChangeConstructing; // NOTICE the "ing" tense: Dyna is not fully constructed yet
	Event<DynaPtr>		mDynaChangeDestructing;  // specific events adds more kinds of listener functions
	Event<DynaPtr>		mDynaChangeQuadrant;     // but avoids listeners having to filter out unwanted events
	Event<void>			mVisibilityChange;       // event that disrupts visibility tests (indirectly, the sorted pile too)
};

#endif // ENG_EVENT_HH
