//Asura_XUI.h
//Copyright (c) 2008 Rebellion

//XUI class, to use:
//- Initialise (call Initialised() to check success)
//- Call RegisterClass with your callbacks provided, the class name is the one you supplied as the 'Class override'
//  to the xbox UI tool.
//- Call LoadSkin, LoadTypeface, LoadScene with the appropriate files
//- Call Enable() to enable
// Update() should be called every frame, also Render()

//external headers, we need 'new' to be undefined for this
#include "Core/Asura_MemoryManagement_DebugOff.h"
#include <xtl.h>
#include <xui.h>
#include "Core/Asura_MemoryManagement_DebugOn.h"

//Callbacks for passing to "RegisterClass"
typedef HRESULT(*Asura_XUI_CreateInstance_Callback)		( HXUIOBJ xObj, void** ppObj );
typedef HRESULT(*Asura_XUI_DestroyInstance_Callback)	( void* pObj );
typedef HRESULT(*Asura_XUI_ObjectProc_Callback)			( HXUIOBJ xObj, XUIMessage* pxMessage, void* pThis );

class Asura_Xbox360_XUI_System
{
	public:
		
		static void Initialise	();
		static void Update		(float fFrameLength);
		static void Render		();
		static void Shutdown	();

		static bool Initialised	();

		static bool RegisterClass		(	Asura_UnicodeChar*					pxClass, 
											Asura_XUI_ObjectProc_Callback		pfnObjectProc, 
											Asura_XUI_CreateInstance_Callback	pfnCreate = 0, 
											Asura_XUI_DestroyInstance_Callback	pfnDestroy = 0 );
		static bool LoadSkin			(Asura_UnicodeChar* pxSkinFile);
		static bool LoadTypeface		(Asura_UnicodeChar* pxTypeface, Asura_UnicodeChar* pxLocator);
		static bool LoadScene			(Asura_UnicodeChar* pxScene);

		static bool ShowFirstScene		();

		static void Enable				()	{ s_bEnabled = true;	}
		static void Disable				()	{ s_bEnabled = false;	}

		static HXUIOBJ GetSceneObject	()	{ return s_xScene;		}
		static HXUIOBJ GetCanvasObject	()	{ return s_xCanvas;		}

	private:

		static HXUIDC	s_sxDeviceContext;
		static HXUIOBJ  s_xCanvas;
		static HXUIOBJ	s_xScene;

		static u_int	s_uPreparedFlags;

		static bool		s_bEnabled;

		static u_int	s_uSceneWidth;
		static u_int	s_uSceneHeight;

		static u_int	s_uBackBufferWidth;
		static u_int	s_uBackBufferHeight;
};

//eof
