/*****************************************************************************
 * $Id: mod_pony_gui.hh,v 1.1 2006/11/24 21:56:58 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Lightweight GUI inside viewport.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#if COMPILING_MODULE_PONY
#ifndef MOD_PONY_GUI_HH
#define MOD_PONY_GUI_HH 1

#if GFXSYS_OPENGL
#	include "gfx_font_opengl.hh"
#	include "gfx_gui_opengl.hh"
#else
#	error
#endif

////////////////////////////////////////////////////////////////////////////////
/// GUI class.
///
class ModulePonyGui
{
	PREVENT_COPYING(ModulePonyGui)
public:
	// This must be a single static object!
	// This NOP constructor relies on the object being static to auto-zero all members.
	ModulePonyGui( void ) { }
	void			Init( void );
	void			Delete( void );
	void			Reset( void );
	void			Render( void );
	void			Reshape( const Geom<int>& viewport, const Geom<int>& window );
	void			SplashOff( void );
	void			SetZoom( fp z );
	fp				GetZoom( void );
	void			ToggleMenu( void );
	void			PrintStatus( const char* str );
	void			Update( void );
	void			UpdateFlightView( void );
	void			UpdatePause( void );
	void			UpdateInputDevice( void );
	void			UpdateJoystickAxis3( void );
	void			UpdateJoycal( void );
	void			UpdateFogDensity( void );
	void			UpdateCollisions( void );
	void			UpdateControlResponse( void );
	void			UpdateLod( void );
	void			UpdateGuiZoom( void );
	bool			IfAnyMouseButtonPressed( void ) { return mMouseButtonWasPressed; }
	void			TimerOneSecond( void );
	void			MouseMotionHandler( float x, float y );
	void			MouseButtonHandler( eMouseEvent button, bool down );

private:
	void			StartStopListeners( bool start );
	void			InitScreens( void );
	void			InitScreenMain( void );
	void			InitScreenMenu( void );
	void			InitScreenHelp( void );
	void			InitScreenAbout( void );
	void			InitScreenJoycal( void );
	void			RenderScreens( void );
	void			RenderScreenMain( void );
	void			RenderScreenMenu( void );
	void			RenderScreenHelp( void );
	void			RenderScreenAbout( void );
	void			RenderScreenJoycal( void );
	void			GuiButtonCallback( GuiObject* obj, uint buttons );
	void			WriteJoycalConfig( GuiButton* button, const char* str, int val, const string& key );
	void			ResetJoycalConfig( void );
	void			TurnScreensOff( GuiScreen* notme );

	bool				mReady;
	bool				mMouseButtonWasPressed;
	bool				mAboutButtonWasToggled;

	Gui*				mGui;
	GuiScreen*			mScreenMain;
	GuiScreen*			mScreenMenu;
	GuiScreen*			mScreenHelp;
	GuiScreen*			mScreenAbout;
	GuiScreen*			mScreenJoycal;
	// Main screen:
	GuiButton*			mButtonMenu;
	GuiButton*			mButtonPause;
	// Menu screen:
	GuiButton*			mButtonExit;
	GuiButton*			mButtonSave;
	GuiButton*			mButtonHelp;
	GuiButton*			mButtonAbout;
	GuiButton*			mButtonCollisions;
	GuiButton*			mButtonLod;
	GuiButton*			mButtonGuiZoomPlus;
	GuiButton*			mButtonGuiZoomMinus;
	GuiButton*			mButtonFogDensityPlus;
	GuiButton*			mButtonFogDensityMinus;
	GuiButton*			mButtonResponsePlus;
	GuiButton*			mButtonResponseMinus;
	GuiButton*			mButtonInputDevice;
	GuiButton*			mButtonJoyaxis3;
	GuiButton*			mButtonJoycal;
	// Joystick calibration screen:
	GuiButton*			mButtonJoycalReset;
	GuiButton*			mButtonJoycalLeftMax;
	GuiButton*			mButtonJoycalLeftMin;
	GuiButton*			mButtonJoycalRightMax;
	GuiButton*			mButtonJoycalRightMin;
	GuiButton*			mButtonJoycalUpMax;
	GuiButton*			mButtonJoycalUpMin;
	GuiButton*			mButtonJoycalDownMax;
	GuiButton*			mButtonJoycalDownMin;
	GuiButton*			mButtonJoycalSlowMax;
	GuiButton*			mButtonJoycalSlowMin;
	GuiButton*			mButtonJoycalFastMax;
	GuiButton*			mButtonJoycalFastMin;

friend void ModulePonyGui_GuiButtonCallback( GuiObject* obj, uint buttons ); // Gui button clicked
friend void Listener_ModulePonyGui_Reset( void );
friend void Listener_ModulePonyGui_PostDrawViews( void );
friend void Listener_ModulePonyGui_Reshape( Geom<int>& geom );
friend void Listener_ModulePonyGui_MouseMotionHandler( std::pair<int,int> duo );
friend void Listener_ModulePonyGui_MouseButtonHandler( std::pair<eMouseEvent,bool> duo );
};
extern ModulePonyGui gGui;

void ModulePonyGui_GuiButtonCallback( GuiObject* obj, uint buttons ); // Gui button clicked
void Listener_ModulePonyGui_Reset( void );
void Listener_ModulePonyGui_PostDrawViews( void );
void Listener_ModulePonyGui_Reshape( Geom<int>& geom );
void Listener_ModulePonyGui_MouseMotionHandler( std::pair<int,int> duo );
void Listener_ModulePonyGui_MouseButtonHandler( std::pair<eMouseEvent,bool> duo );

#endif // MOD_PONY_GUI_HH
#endif // COMPILING_MODULE_PONY
