Code Search for Developers
 
 
  

Recorder.h from palisma2d at Krugle


Show Recorder.h syntax highlighted

#pragma once
#include "EventManager.h"
#include "game/EntityManager.h"
// for recording
#include "Console.h"
/**
========================
Record play
========================
*/
class Recorder;
class Record_f : public ICommand
{
public:
    Record_f() { };
    void Exec(std::string &s);
    void Set(Recorder* r) { m_recorder =r; };
    ~Record_f() {};
private:
    Recorder* m_recorder;
};


/**
========================
Stop play
========================
*/
class StopRecording_f : public ICommand
{
public:
    StopRecording_f() { };
    void Exec(std::string &s);
    void Set(Recorder* r) { m_recorder =r; };
    ~StopRecording_f() {};
private:
        Recorder* m_recorder;
};

/**
========================
Play recording
========================
*/
class PlayRecording_f : public ICommand
{
public:
    PlayRecording_f() { };
    void Exec(std::string &s);
    void Set(Recorder* r) { m_recorder =r; };
    ~PlayRecording_f() {};
private:
        Recorder* m_recorder;
};


/**
================
Recorder Listener
================
*/
class Recorder : public IEventListener
{
public:
    Recorder();
    /* Get the Name of the Listener */
    std::string GetName() { return "recorder"; };
    /** Get Listener Type - Events this listener listens too */
    int GetListenerType() { return LT_ALL; };

    /** Update, pop events in play mode */
    void Update(long dt);
    /** Handle an event */
    bool HandleEvent( IEvent* e );

    /** Enable recording */
    void StartRecording(const std::string &fileName); 
    /** Stop recording */
    void StopRecording() { m_record = false; Save(); };

    /** Save to file */
    void Save();
    /** Load File */
    void Load(const std::string &fileName);

    virtual ~Recorder();
private:
    // queue of events to record
    typedef std::queue< IEvent > type_EventQueue;
    type_EventQueue     m_events;
    // recording
    bool        m_record;
   // playing back demo
    bool    m_playing;

    // time started
    float   m_startTime;
    // player to record
    struct player_t {
        std::string name;
        std::string state;
        Vector2f    pos;
        Vector2f    vel;
        int         hp;
    } player;

    // file name
    std::string m_fileName;
 

    // console functions
    Record_f    record_f;
    PlayRecording_f playrec_f;
    StopRecording_f stoprec_f;
};




See more files for this project here

palisma2d

The University of Wisconsin-Parkside Developers Union first product. More info to come. Code name Palisma.

Project homepage: http://code.google.com/p/palisma2d/
Programming language(s): C,C++
License: gpl2

  Data/
    entities/
      link/
        finallink.tga
      objects/
        pot.tga
        torchpit.bmp
      soldier/
        soldier_01.png
        soldier_01.tga
        soldier_011.tga
      sryion.tga
    maps/
      dialogs/
        test.dialog
      tiles/
        layer2/
          fence.bmp
          fence.tga
          stump.tga
        grass_01.bmp
        street_01.bmp
        street_02.bmp
        street_03.bmp
        tile_a.bmp
        tile_b.bmp
        tile_c.bmp
        tile_d.bmp
        tile_e.bmp
        tile_f.bmp
        tile_g.bmp
        tile_h.bmp
        tile_i.bmp
      map01.dfn
      map01.ents
      map01.evt
      map01.ly1
      map01.ly2
      test.dfn
      test.ly1
      test.ly1.big
      test.ly2
    misc/
      rain1.tga
      rain2.tga
      rain3.tga
      rain4.tga
    scripts/
      hitman_mission/
        hitman.dialog
        hitman.lua
        hitman.msn
        hitman_inprogress.dialog
        hitman_reward.dialog
        hitman_reward.lua
        hitman_setup.lua
      test_mission/
        HitPotSetup.lua
        m_hitPot.dialog
        m_hitPot.lua
        m_hitPot.msn
        m_hitPot_inprogress.dialog
        m_hitPot_reward.lua
        reward.dialog
      mission_check.lua
    sounds/
      weather/
      hurt.wav
      lift.wav
      stroke.wav
      theme.wav
      throw.wav
    weapons/
      shotgun/
  Lib/
    LUA/
    OpenAL/
    SDL/
    Zlib/
  game/
    DialogModel.cpp
    DialogModel.h
    DialogState.cpp
    DialogState.h
    Enemy.cpp
    Enemy.h
    EntityController.cpp
    EntityController.h
    EntityEvents.cpp
    EntityEvents.h
    EntityFactory.cpp
    EntityFactory.h
    EntityManager.cpp
    EntityManager.h
    EntityStates.cpp
    EntityStates.h
    Event.h
    HUD.cpp
    HUD.h
    IEntity.cpp
    IEntity.h
    IWeapon.cpp
    IWeapon.h
    InGameState.cpp
    InGameState.h
    Inventory.cpp
    Inventory.h
    MissionHolder.cpp
    MissionHolder.h
    Player.cpp
    Player.h
    PlayerConfig.cpp
    PlayerConfig.h
    PlayerController.cpp
    PlayerController.h
    QuestImporter.cpp
    QuestImporter.h
    ReadMe.txt
    Scene.cpp
    Scene.h
    Shotgun.cpp
    Shotgun.h
    State.h
    StateFactory.cpp
    StateFactory.h
  gui/
  input/
  render/
  script/
  shared/
  sound/
  Console.cpp
  Console.h
  ConsoleFunctions.h
  Cvars.cpp
  Cvars.h
  EventManager.cpp
  EventManager.h
  Exec_f.cpp
  GameManager.cpp
  GameManager.h
  IConsole.h
  IGameState.h
  IProcess.h
  Kernel.cpp
  Kernel.h
  Log.cpp
  Log.h
  Myriad.cpp
  Myriad.h
  ReadMe.txt
  Recorder.cpp
  Recorder.h
  Resource.cpp
  Resource.h
  Timer.cpp
  Timer.h
  client.log
  game01.zip
  mmanager.cpp
  mmanager.h
  stdafx.cpp
  stdafx.h