
#ifndef INC_GAME_LOOP
#define INC_GAME_LOOP
#endif

#ifndef INC_GAMELOOPIFC
#include "GameLoopIfc.h"
#endif
#ifndef INC_DISPLAYENGINE
#include "DisplayEngine.h"
#endif

#include <vector>

//----------------------------------------------------------------------------

class GameLoop
{
public:
    GameLoop( DisplayEngine& );
    ~GameLoop()
    {}
    void config( const char*ini_fn );
    void add_view_port( ViewPortIfc& );
    void add_kbd_handler( KbdHndlIfc& );
    void add_gcl_handler( GameClockIfc& );
    void add_scroll_handler( ScrollingIfc& );
    void loop();
private:
    friend class GameLoopDebugView;
    int cur_skip;
    int max_skip;
    int rest_dur_ms;
    int normal_fps;
    DisplayEngine&display_engine;
    std::vector<GameClockIfc*> v_game_clock_hndls;
    std::vector<ViewPortIfc*> v_viewports;
    std::vector<KbdHndlIfc*> v_kbd_hndls;
    std::vector<ScrollingIfc*> v_scroll_hndls;
};

//----------------------------------------------------------------------------

class GameLoopDebugView : public ViewPortBase
{
public:
    GameLoopDebugView( const ScreenRect&asr, const GameLoop&agl );
    virtual void display( BITMAP*const );
private:
    const GameLoop&game_loop;
};

//----------------------------------------------------------------------------

