/*!
	@file RuEntity_Widget_Label.h

	Copyright (c) 2004-2005 All rights reserved
*/

#ifndef _RUENTITY_WIDGET_LABEL_H_
#define _RUENTITY_WIDGET_LABEL_H_

#include "../../Scene/Base/RuEntityBase.h"
#include "../../Scene/Base/RuEntityModel.h"

#pragma unmanaged

// ************************************************************************************************************************************************************

/*!
	Label widget. Used for billboarded text in 3D space.

	@version 2005.05.24
*/
class CRuEntity_Widget_Label : public IRuEntity_Renderable
{
	ruRTTI_DECLARE
	ruHEAP_DECLARE
	ruCLASSGUID_DECLARE

protected:
	struct RowDescriptor
	{
		REAL								m_textWidth;									//!< Width of this row's text
		REAL								m_textHeight;									//!< Height of this row's text

		REAL								m_textScale;									//!< Scale of this row's text (texels per world unit)
		DWORD								m_textColor;									//!< RUCOLOR

		INT32								m_numGlyphs;									//!< Number of glyphs in this row
		CRuRectangle*						m_glyphRects;									//!< Glyph UV rects
	};

	CRuArrayList<RowDescriptor>				m_rowDescriptors;

	INT32									m_meshIterationNumber;
	BOOL									m_geometryDirty;
	IRuTexture*								m_texture;
	CRuDynamicMesh*							m_mesh;
	CRuMaterial*							m_material;

public:
											CRuEntity_Widget_Label();
	virtual									~CRuEntity_Widget_Label();

	void									SetTexture(IRuTexture *texture);
	void									AddRowText(INT32 numRects, const CRuRectangle *rects, REAL textScale, DWORD textColor);
	void									BuildGeometry();

	// Base entity interface
	virtual CRuEntity*						Clone(CRuEntity *clonedEntity = NULL);
	virtual BOOL							ResetStates();

	// Base interface
	virtual BOOL							Update(float elapsedTime);

	// IRuEntity_Renderable interface
	virtual INT32							GetNumMeshes() const;
	virtual BOOL							GetMesh(INT32 meshIndex, IRuMesh **meshOut, IRuMaterial **materialOut);
};

// ************************************************************************************************************************************************************

#pragma managed

#endif
