1 #ifndef _HUD_H_
2 #define _HUD_H_
3 
4 #include	<map>
5 #include	"base.h"
6 #include	"Timer.h"
7 #include	"Renderer.h"
8 
9 namespace	Hud
10 {
11 
12 /*
13 */
14 class   CHudEntry
15 {
16 	bool	m_bVisible;
17 
18 	protected:
19 		Base::Math::CRect	m_Rect;
20 		fp8	m_StartTime, m_Duration, m_Delta;
21 
22 	public:
CHudEntry(Base::Math::CRect _rect)23 			CHudEntry( Base::Math::CRect _rect ) : m_Rect( _rect )	{};
~CHudEntry()24 			virtual ~CHudEntry()    {};
25 
SetTime(fp8 _startTime,fp8 _duration)26 			void	SetTime( fp8 _startTime, fp8 _duration )	{	m_StartTime = _startTime; m_Duration = _duration; m_Delta = 0; m_bVisible = false;	};
Render(const fp8 _time,DisplayOutput::spCRenderer)27 			virtual	bool	Render( const fp8 _time, DisplayOutput::spCRenderer /*_spRenderer*/ )
28 			{
29 				if( m_Duration > 0.0f )
30 				{
31 					m_Delta = (_time - m_StartTime) / m_Duration;
32 					if( m_Delta > 1.0 )
33 						return false;
34 				}
35 
36 				return true;
37 			};
38 
Visible(const bool _bState)39 			void Visible( const bool _bState )	{	m_bVisible = _bState;	};
Visible()40 			virtual bool	Visible() const	{	return m_bVisible;	};
41 };
42 
43 MakeSmartPointers( CHudEntry );
44 
45 /*
46 */
47 class   CHudManager
48 {
49 	//	Timer.
50 	Base::CTimer	m_Timer;
51 
52 	//	Entries.
53 	std::map<std::string, spCHudEntry> m_EntryMap;
54 
55 	public:
56 			CHudManager();
57 			~CHudManager();
58 
59 			//	Add/Remove hud entry. (duration -1 means infinite...)
60 			bool	Add( const std::string _name, spCHudEntry _entry, fp8 _duration = -1 );
61 			bool	Remove( const std::string _name );
62 
63 			//	Operators rule.
Get(const std::string _what)64 			spCHudEntry	Get( const std::string _what )	{	return m_EntryMap[ _what ];	}
65 
66 			bool	Render( DisplayOutput::spCRenderer _spRenderer );
67 			void	HideAll();
68 			void	Toggle( const std::string _name );
69 			void	Hide( const std::string _name );
70 };
71 
72 MakeSmartPointers( CHudManager );
73 
74 };
75 
76 #endif
77