/*****************************************************************************
 * $Id: game_pony_gui.hh,v 1.9 2006/08/03 02:17:22 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_GAME_PONY
#ifndef GAME_PONY_GUI_HH
#define GAME_PONY_GUI_HH 1

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

////////////////////////////////////////////////////////////////////////////////
// @brief Game Gui.
class GamePonyGui
{
	PREVENT_COPYING(GamePonyGui)
public:
	// This must be a single static object!
	// This NOP constructor relies on the object being static to auto-zero all members.
	GamePonyGui( 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			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 char* 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 GamePonyGui_GuiButtonCallback( GuiObject* obj, uint buttons ); // Gui button clicked
friend void Listener_GamePonyGui_Reset( void );
friend void Listener_GamePonyGui_PostDrawViews( void );
friend void Listener_GamePonyGui_Reshape( Geom<int>& geom );
friend void Listener_GamePonyGui_MouseMotionHandler( std::pair<int,int> duo );
friend void Listener_GamePonyGui_MouseButtonHandler( std::pair<eMouseEvent,bool> duo );
};
extern GamePonyGui gGui;

void GamePonyGui_GuiButtonCallback( GuiObject* obj, uint buttons ); // Gui button clicked
void Listener_GamePonyGui_Reset( void );
void Listener_GamePonyGui_PostDrawViews( void );
void Listener_GamePonyGui_Reshape( Geom<int>& geom );
void Listener_GamePonyGui_MouseMotionHandler( std::pair<int,int> duo );
void Listener_GamePonyGui_MouseButtonHandler( std::pair<eMouseEvent,bool> duo );

#endif // GAME_PONY_GUI_HH
#endif // COMPILING_GAME_PONY
