ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

EventRecorder.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_EVENTRECORDER_H
00024 #define GUI_EVENTRECORDER_H
00025 
00026 #include "common/system.h"
00027 
00028 #include "common/events.h"
00029 #include "common/savefile.h"
00030 #include "common/singleton.h"
00031 
00032 #include "engines/advancedDetector.h"
00033 
00034 #ifdef ENABLE_EVENTRECORDER
00035 
00036 #include "common/mutex.h"
00037 #include "common/array.h"
00038 #include "common/memstream.h"
00039 #include "backends/mixer/sdl/sdl-mixer.h"
00040 #include "common/hashmap.h"
00041 #include "common/hash-str.h"
00042 #include "backends/timer/sdl/sdl-timer.h"
00043 #include "common/config-manager.h"
00044 #include "common/recorderfile.h"
00045 #include "backends/saves/recorder/recorder-saves.h"
00046 #include "backends/mixer/nullmixer/nullsdl-mixer.h"
00047 #include "backends/saves/default/default-saves.h"
00048 
00049 
00050 #define g_eventRec (GUI::EventRecorder::instance())
00051 
00052 namespace GUI {
00053     class OnScreenDialog;
00054 }
00055 
00056 namespace GUI {
00057 class RandomSource;
00058 class SeekableReadStream;
00059 class WriteStream;
00060 
00061 
00067 class EventRecorder : private Common::EventSource, public Common::Singleton<EventRecorder>, private Common::EventObserver {
00068     friend class Common::Singleton<SingletonBaseType>;
00069     EventRecorder();
00070     ~EventRecorder() override;
00071 public:
00073     enum RecordMode {
00074         kPassthrough = 0,       
00075         kRecorderRecord = 1,        
00076         kRecorderPlayback = 2,      
00077         kRecorderPlaybackPause = 3  
00078     };
00079 
00080     void init(Common::String recordFileName, RecordMode mode);
00081     void deinit();
00082     bool processDelayMillis();
00083     uint32 getRandomSeed(const Common::String &name);
00084     void processMillis(uint32 &millis, bool skipRecord);
00085     bool processAudio(uint32 &samples, bool paused);
00086     void processGameDescription(const ADGameDescription *desc);
00087     Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
00088 
00091     void preDrawOverlayGui();
00092     void postDrawOverlayGui();
00093 
00098     void setAuthor(const Common::String &author) {
00099         _author = author;
00100     }
00101 
00106     void setNotes(const Common::String &desc){
00107         _desc = desc;
00108     }
00109 
00114     void setName(const Common::String &name) {
00115         _name = name;
00116     }
00117 
00122     const Common::String getAuthor() {
00123         return _author;
00124     }
00125 
00130     const Common::String getNotes() {
00131         return _desc;
00132     }
00133 
00138     const Common::String getName() {
00139         return _name;
00140     }
00141     void setRedraw(bool redraw) {
00142         _needRedraw = redraw;
00143     }
00144 
00145     void registerMixerManager(SdlMixerManager *mixerManager);
00146     void registerTimerManager(DefaultTimerManager *timerManager);
00147 
00148     SdlMixerManager *getMixerManager();
00149     DefaultTimerManager *getTimerManager();
00150 
00151     void deleteRecord(const Common::String& fileName);
00152     bool checkForContinueGame();
00153 
00154     void suspendRecording() {
00155         _savedState = _initialized;
00156         _initialized = false;
00157     }
00158 
00159     void resumeRecording() {
00160         _initialized = _savedState;
00161     }
00162 
00163     Common::StringArray listSaveFiles(const Common::String &pattern);
00164     Common::String generateRecordFileName(const Common::String &target);
00165 
00166     Common::SaveFileManager *getSaveManager(Common::SaveFileManager *realSaveManager);
00167     SDL_Surface *getSurface(int width, int height);
00168     void RegisterEventSource();
00169 
00171     bool grabScreenAndComputeMD5(Graphics::Surface &screen, uint8 md5[16]);
00172 
00173     void updateSubsystems();
00174     bool switchMode();
00175     void switchFastMode();
00176 
00177 private:
00178     bool pollEvent(Common::Event &ev) override;
00179     bool notifyEvent(const Common::Event &event) override;
00180     bool _initialized;
00181     volatile uint32 _fakeTimer;
00182     bool _savedState;
00183     bool _needcontinueGame;
00184     int _temporarySlot;
00185     Common::String _author;
00186     Common::String _desc;
00187     Common::String _name;
00188 
00189     Common::SaveFileManager *_realSaveManager;
00190     SdlMixerManager *_realMixerManager;
00191     DefaultTimerManager *_timerManager;
00192     RecorderSaveFileManager _fakeSaveManager;
00193     NullSdlMixerManager *_fakeMixerManager;
00194     GUI::OnScreenDialog *_controlPanel;
00195     Common::RecorderEvent _nextEvent;
00196 
00197     void setFileHeader();
00198     void setGameMd5(const ADGameDescription *gameDesc);
00199     void getConfig();
00200     void getConfigFromDomain(const Common::ConfigManager::Domain *domain);
00201     void removeDifferentEntriesInDomain(Common::ConfigManager::Domain *domain);
00202     void applyPlaybackSettings();
00203 
00204     void switchMixer();
00205     void switchTimerManagers();
00206 
00207     void togglePause();
00208 
00209     void takeScreenshot();
00210 
00211     bool openRecordFile(const Common::String &fileName);
00212 
00213     bool checkGameHash(const ADGameDescription *desc);
00214 
00215     void checkForKeyCode(const Common::Event &event);
00216     bool allowMapping() const override { return false; }
00217 
00218     volatile uint32 _lastMillis;
00219     uint32 _lastScreenshotTime;
00220     uint32 _screenshotPeriod;
00221     Common::PlaybackFile *_playbackFile;
00222 
00223     void saveScreenShot();
00224     void checkRecordedMD5();
00225     void deleteTemporarySave();
00226     volatile RecordMode _recordMode;
00227     Common::String _recordFileName;
00228     bool _fastPlayback;
00229     bool _needRedraw;
00230 };
00231 
00232 } // End of namespace GUI
00233 
00234 #endif // ENABLE_EVENTRECORDER
00235 
00236 #endif


Generated on Sat Aug 8 2020 05:01:24 for ResidualVM by doxygen 1.7.1
curved edge   curved edge