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/keymapper/keymapper.h"
00040 #include "backends/mixer/sdl/sdl-mixer.h"
00041 #include "common/hashmap.h"
00042 #include "common/hash-str.h"
00043 #include "backends/timer/sdl/sdl-timer.h"
00044 #include "common/config-manager.h"
00045 #include "common/recorderfile.h"
00046 #include "backends/saves/recorder/recorder-saves.h"
00047 #include "backends/mixer/nullmixer/nullsdl-mixer.h"
00048 #include "backends/saves/default/default-saves.h"
00049 
00050 
00051 #define g_eventRec (GUI::EventRecorder::instance())
00052 
00053 namespace GUI {
00054     class OnScreenDialog;
00055 }
00056 
00057 namespace GUI {
00058 class RandomSource;
00059 class SeekableReadStream;
00060 class WriteStream;
00061 
00062 
00068 class EventRecorder : private Common::EventSource, public Common::Singleton<EventRecorder>, private Common::DefaultEventMapper {
00069     friend class Common::Singleton<SingletonBaseType>;
00070     EventRecorder();
00071     ~EventRecorder();
00072 public:
00074     enum RecordMode {
00075         kPassthrough = 0,       
00076         kRecorderRecord = 1,        
00077         kRecorderPlayback = 2,      
00078         kRecorderPlaybackPause = 3  
00079     };
00080 
00081     void init(Common::String recordFileName, RecordMode mode);
00082     void deinit();
00083     bool processDelayMillis();
00084     uint32 getRandomSeed(const Common::String &name);
00085     void processMillis(uint32 &millis, bool skipRecord);
00086     bool processAudio(uint32 &samples, bool paused);
00087     void processGameDescription(const ADGameDescription *desc);
00088     Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
00089 
00092     void preDrawOverlayGui();
00093     void postDrawOverlayGui();
00094 
00099     void setAuthor(const Common::String &author) {
00100         _author = author;
00101     }
00102 
00107     void setNotes(const Common::String &desc){
00108         _desc = desc;
00109     }
00110 
00115     void setName(const Common::String &name) {
00116         _name = name;
00117     }
00118 
00123     const Common::String getAuthor() {
00124         return _author;
00125     }
00126 
00131     const Common::String getNotes() {
00132         return _desc;
00133     }
00134 
00139     const Common::String getName() {
00140         return _name;
00141     }
00142     void setRedraw(bool redraw) {
00143         _needRedraw = redraw;
00144     }
00145 
00146     void registerMixerManager(SdlMixerManager *mixerManager);
00147     void registerTimerManager(DefaultTimerManager *timerManager);
00148 
00149     SdlMixerManager *getMixerManager();
00150     DefaultTimerManager *getTimerManager();
00151 
00152     void deleteRecord(const Common::String& fileName);
00153     bool checkForContinueGame();
00154 
00155     void suspendRecording() {
00156         _savedState = _initialized;
00157         _initialized = false;
00158     }
00159 
00160     void resumeRecording() {
00161         _initialized = _savedState;
00162     }
00163 
00164     Common::StringArray listSaveFiles(const Common::String &pattern);
00165     Common::String generateRecordFileName(const Common::String &target);
00166 
00167     Common::SaveFileManager *getSaveManager(Common::SaveFileManager *realSaveManager);
00168     SDL_Surface *getSurface(int width, int height);
00169     void RegisterEventSource();
00170 
00172     bool grabScreenAndComputeMD5(Graphics::Surface &screen, uint8 md5[16]);
00173 
00174     void updateSubsystems();
00175     bool switchMode();
00176     void switchFastMode();
00177 
00178 private:
00179     virtual Common::List<Common::Event> mapEvent(const Common::Event &ev, Common::EventSource *source);
00180     bool notifyPoll();
00181     bool pollEvent(Common::Event &ev);
00182     bool _initialized;
00183     volatile uint32 _fakeTimer;
00184     bool _savedState;
00185     bool _needcontinueGame;
00186     int _temporarySlot;
00187     Common::String _author;
00188     Common::String _desc;
00189     Common::String _name;
00190 
00191     Common::SaveFileManager *_realSaveManager;
00192     SdlMixerManager *_realMixerManager;
00193     DefaultTimerManager *_timerManager;
00194     RecorderSaveFileManager _fakeSaveManager;
00195     NullSdlMixerManager *_fakeMixerManager;
00196     GUI::OnScreenDialog *_controlPanel;
00197     Common::RecorderEvent _nextEvent;
00198 
00199     void setFileHeader();
00200     void setGameMd5(const ADGameDescription *gameDesc);
00201     void getConfig();
00202     void getConfigFromDomain(const Common::ConfigManager::Domain *domain);
00203     void removeDifferentEntriesInDomain(Common::ConfigManager::Domain *domain);
00204     void applyPlaybackSettings();
00205 
00206     void switchMixer();
00207     void switchTimerManagers();
00208 
00209     void togglePause();
00210 
00211     void takeScreenshot();
00212 
00213     bool openRecordFile(const Common::String &fileName);
00214 
00215     bool checkGameHash(const ADGameDescription *desc);
00216 
00217     void checkForKeyCode(const Common::Event &event);
00218     bool allowMapping() const { return false; }
00219 
00220     volatile uint32 _lastMillis;
00221     uint32 _lastScreenshotTime;
00222     uint32 _screenshotPeriod;
00223     Common::PlaybackFile *_playbackFile;
00224 
00225     void saveScreenShot();
00226     void checkRecordedMD5();
00227     void deleteTemporarySave();
00228     volatile RecordMode _recordMode;
00229     Common::String _recordFileName;
00230     bool _fastPlayback;
00231     bool _needRedraw;
00232 };
00233 
00234 } // End of namespace GUI
00235 
00236 #endif // ENABLE_EVENTRECORDER
00237 
00238 #endif


Generated on Sat Jun 15 2019 05:01:20 for ResidualVM by doxygen 1.7.1
curved edge   curved edge