Guest User

Untitled

a guest
Sep 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.63 KB | None | 0 0
  1. diff --git a/common/EventRecorder.h b/common/EventRecorder.h
  2. index 43a08b0..51ac5e9 100644
  3. --- a/common/EventRecorder.h
  4. +++ b/common/EventRecorder.h
  5. @@ -28,81 +28,163 @@
  6.  #include "common/singleton.h"
  7.  #include "common/mutex.h"
  8.  #include "common/array.h"
  9. +#include "common/queue.h"
  10. +#include "common/memstream.h"
  11. +#include "common/savefile.h"
  12. +#include "backends/keymapper/keymapper.h"
  13. +#include "backends/mixer/sdl/sdl-mixer.h"
  14. +#include "backends/mixer/nullmixer/nullsdl-mixer.h"
  15. +#include "backends/timer/sdl/sdl-timer.h"
  16. +#include "backends/timer/default/default-timer.h"
  17. +#include "engines/advancedDetector.h"
  18. +#include "common/config-manager.h"
  19. +#include "common/recorderfile.h"
  20. +#include "backends/saves/default/default-saves.h"
  21. +#include "backends/saves/recorder/recorder-saves.h"
  22. +
  23.  
  24.  #define g_eventRec (Common::EventRecorder::instance())
  25.  
  26. -namespace Common {
  27. +namespace GUI {
  28. +   class OnScreenDialog;
  29. +}
  30.  
  31. +namespace Common {
  32.  class RandomSource;
  33.  class SeekableReadStream;
  34.  class WriteStream;
  35.  
  36. +
  37. +
  38. +
  39.  /**
  40.   * Our generic event recorder.
  41.   *
  42.   * TODO: Add more documentation.
  43.   */
  44. -class EventRecorder : private EventSource, private EventObserver, public Singleton<EventRecorder> {
  45. +class EventRecorder : private EventSource, public Singleton<EventRecorder>, private DefaultEventMapper {
  46.     friend class Singleton<SingletonBaseType>;
  47.     EventRecorder();
  48.     ~EventRecorder();
  49.  public:
  50. +   enum RecordMode {
  51. +       kPassthrough = 0,
  52. +       kRecorderRecord = 1,
  53. +       kRecorderPlayback = 2,
  54. +       kRecorderPlaybackPause = 3
  55. +   };
  56.     void init();
  57. +   void init(Common::String recordFileName, RecordMode mode);
  58. +   void init(const ADGameDescription *desc, RecordMode mode);
  59.     void deinit();
  60. -
  61. -   /** Register random source so it can be serialized in game test purposes */
  62. -   void registerRandomSource(RandomSource &rnd, const String &name);
  63. +   bool delayMillis(uint &msecs, bool logged = false);
  64. +   void takeScreenshot();
  65. +   void preDrawOverlayGui();
  66. +   void postDrawOverlayGui();
  67.  
  68.     /** TODO: Add documentation, this is only used by the backend */
  69.     void processMillis(uint32 &millis);
  70.  
  71. -   /** TODO: Add documentation, this is only used by the backend */
  72. -   bool processDelayMillis(uint &msecs);
  73. -
  74. +   GUI::OnScreenDialog *controlPanel;
  75. +   bool processAudio(uint32 &samples, bool paused);
  76. +   SdlMixerManager *getMixerManager();
  77. +   DefaultTimerManager *getTimerManager();
  78. +   void setAuthor(const Common::String &author);
  79. +   void setNotes(const Common::String &desc);
  80. +   void setName(const Common::String &name);
  81. +   const Common::String getAuthor() {
  82. +       return _author;
  83. +   }
  84. +   const Common::String getNotes() {
  85. +       return _desc;
  86. +   }
  87. +   const Common::String getName() {
  88. +       return _name;
  89. +   }
  90. +   /** Register random source so it can be serialized in game test purposes */
  91. +   uint32 getRandomSeed(const String &name);
  92. +   void processGameDescription(const ADGameDescription *desc);
  93. +   void registerMixerManager(SdlMixerManager *mixerManager);
  94. +   void registerTimerManager(DefaultTimerManager *timerManager);
  95. +   uint32 getTimer() {return _fakeTimer;}
  96. +   void deleteRecord(const String& fileName);
  97. +   bool isRecording() {
  98. +       return _initialized;
  99. +   }
  100. +   bool _savedState;
  101. +   void suspendRecording() {
  102. +       _savedState = _initialized;
  103. +       _initialized = false;
  104. +   }
  105. +   void resumeRecording() {
  106. +       _initialized = _savedState;
  107. +   }
  108. +   Common::StringArray listSaveFiles(const Common::String &pattern);
  109. +   void saveStream(Common::OutSaveFile *saveStream);
  110. +   Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
  111. +   void RegisterEventSource();
  112. +   Common::String generateRecordFileName(const String &target);
  113. +   SaveFileManager *getSaveManager(SaveFileManager *realSaveManager);
  114. +   void togglePause();
  115. +   bool grabScreenAndComputeMD5(Graphics::Surface &screen, uint8 md5[16]);
  116. +   SDL_Surface *getSurface(int width, int height);
  117. +   bool checkForContinueGame();
  118. +   void deleteTemporarySave();
  119. +   bool switchMode();
  120. +   void updateSubsystems();
  121. +   void setRedraw(bool redraw) {
  122. +       _needRedraw = redraw;
  123. +   }
  124. +   void switchFastMode();
  125.  private:
  126. -   bool notifyEvent(const Event &ev);
  127. +   bool _needRedraw;
  128. +   bool _fastPlayback;
  129. +   Common::String _author;
  130. +   Common::String _desc;
  131. +   Common::String _name;
  132. +   void setFileHeader();
  133. +   bool _enableDrag;
  134. +   int _temporarySlot;
  135. +   bool _needcontinueGame;
  136. +   Common::Point dragPoint;
  137. +   SaveFileManager *_realSaveManager;
  138. +   RecorderSaveFileManager _fakeSaveManager;
  139. +   virtual List<Event> mapEvent(const Event &ev, EventSource *source);
  140. +   bool _initialized;
  141. +   void setGameMd5(const ADGameDescription *gameDesc);
  142. +   void getConfig();
  143. +   void applyPlaybackSettings();
  144. +   void removeDifferentEntriesInDomain(ConfigManager::Domain *domain);
  145. +   void getConfigFromDomain(ConfigManager::Domain *domain);
  146. +   MutexRef _recorderMutex;
  147. +   SdlMixerManager *_realMixerManager;
  148. +   NullSdlMixerManager *_fakeMixerManager;
  149. +   DefaultTimerManager *_timerManager;
  150. +   void switchMixer();
  151. +   void switchTimerManagers();
  152. +   bool openRecordFile(const String &fileName);
  153. +   bool checkGameHash(const ADGameDescription *desc);
  154. +   String findMD5ByFileName(const ADGameDescription *gameDesc, const String &fileName);
  155.     bool notifyPoll();
  156.     bool pollEvent(Event &ev);
  157.     bool allowMapping() const { return false; }
  158. -
  159. -   class RandomSourceRecord {
  160. -   public:
  161. -       String name;
  162. -       uint32 seed;
  163. -   };
  164. -   Array<RandomSourceRecord> _randomSourceRecords;
  165. -
  166. -   bool _recordSubtitles;
  167. -   volatile uint32 _recordCount;
  168. -   volatile uint32 _lastRecordEvent;
  169. -   volatile uint32 _recordTimeCount;
  170. -   volatile uint32 _lastEventMillis;
  171. -   WriteStream *_recordFile;
  172. -   WriteStream *_recordTimeFile;
  173. +   void checkForKeyCode(const Event &event);
  174. +   void writeAudioEvent(uint32 samplesCount);
  175. +   void writeGameSettings();
  176. +   void readAudioEvent();
  177. +   void increaseEngineSpeed();
  178. +   void decreaseEngineSpeed();
  179. +   RecorderEvent _nextEvent;
  180. +   uint8 _engineSpeedMultiplier;
  181.     MutexRef _timeMutex;
  182. -   MutexRef _recorderMutex;
  183.     volatile uint32 _lastMillis;
  184. -
  185. -   volatile uint32 _playbackCount;
  186. -   volatile uint32 _playbackDiff;
  187. -   volatile bool _hasPlaybackEvent;
  188. -   volatile uint32 _playbackTimeCount;
  189. -   Event _playbackEvent;
  190. -   SeekableReadStream *_playbackFile;
  191. -   SeekableReadStream *_playbackTimeFile;
  192. -
  193. -   volatile uint32 _eventCount;
  194. -   volatile uint32 _lastEventCount;
  195. -
  196. -   enum RecordMode {
  197. -       kPassthrough = 0,
  198. -       kRecorderRecord = 1,
  199. -       kRecorderPlayback = 2
  200. -   };
  201. +   volatile uint32 _fakeTimer;
  202. +   uint32 _lastScreenshotTime;
  203. +   uint32 _screenshotPeriod;
  204. +   PlaybackFile *_playbackFile;
  205. +   void saveScreenShot();
  206. +   void checkRecordedMD5();
  207.     volatile RecordMode _recordMode;
  208. -   String _recordFileName;
  209. -   String _recordTempFileName;
  210. -   String _recordTimeFileName;
  211.  };
  212.  
  213.  } // End of namespace Common
Add Comment
Please, Sign In to add comment