/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Game-related HUD widgets.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef GAME_HUD_HH
#define GAME_HUD_HH 1

#include <map>
#include "base/singleton.hh"
#include "base/module.hh"
#include "base/timer.hh"
using namespace base;
#include "object/module.hh"
#include "object/events.hh"
using namespace object;
#include "hud/module.hh"
using namespace hud;

namespace game {

#define GET_GAME_HUD() (game::Hud::GetInstance())

////////////////////////////////////////////////////////////////////////////////
/// @brief Game-related HUD widgets.
///
class Hud
{
PREVENT_COPYING(Hud)
private:
    Hud( void );
    ~Hud();

public:
                DEFINE_GetInstance( Hud )  // Singleton
    void        AttachTarget( shptr<Object> target, const string& text );
    void        DetachTarget( shptr<Object> target );
    void        SelectTarget( shptr<Object> target, const bool radarLock );
    void        DeselectTarget( void );
    void        RemoveRadarLock( void );

private:
    void        Tick( const Milliseconds millisecElapsed );
    void        SetTargetIndicator( shptr<Object> object, const RGBA color, const bool drawX );

private:
    /// @brief Target indicator box (graphical object).
    ///
    struct TargetIndicator
    {
        TargetIndicator( shptr<HudBox> hudBox, shptr<HudText> hudText )
        : mHudBox(hudBox), mHudText(hudText)
        { }

        shptr<HudBox>   mHudBox;
        shptr<HudText>  mHudText;
    };

private:
    /// @brief Timer-tick.
    CLASS_TICK_FUNCTOR_BASIC

private:
    CLASS_DESTROY_OBJECT_LISTENER( Hud, mHud )

private:
    CLASS_VAR Hud*                  msInstance;
    shptr<Object>                   mDummyTarget;               ///< to indicate no selected target
    shptr<Object>                   mSelectedTarget;
    typedef std::map<shptr<Object>,TargetIndicator> TargetIndicatorMap;
    TargetIndicatorMap              mTargetIndicatorMap;        ///< maps an Object to a TargetIndicator box
    shptr<TickFunctor>              mTickFunctor;
    shptr<DestroyObjectListener>    mDestroyObjectListener;     ///< listen for the destroying of trail-maker Object
};

} // namespace game

#endif // GAME_HUD_HH
