1// SuperTux
2// Copyright (C) 2017 Tobias Markus <tobbi.bugs@googlemail.com>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef HEADER_SUPERTUX_SUPERTUX_GAME_SESSION_RECORDER_HPP
18#define HEADER_SUPERTUX_SUPERTUX_GAME_SESSION_RECORDER_HPP
19
20#include <memory>
21#include <string>
22
23#include "control/codecontroller.hpp"
24
25class GameSessionRecorder
26{
27public:
28 GameSessionRecorder();
29 virtual ~GameSessionRecorder();
30
31 void start_recording();
32 void record_demo(const std::string& filename);
33 int get_demo_random_seed(const std::string& filename) const;
34 void play_demo(const std::string& filename);
35 void process_events();
36
37 /** Re-sets the demo controller in case the sector (and thus the
38 Player instance) changes. */
39 void reset_demo_controller();
40
41 bool is_playing_demo() const { return m_playing; }
42
43private:
44 void capture_demo_step();
45
46private:
47 std::string m_capture_file;
48 std::unique_ptr<std::ostream> m_capture_demo_stream;
49 std::unique_ptr<std::istream> m_playback_demo_stream;
50 std::unique_ptr<CodeController> m_demo_controller;
51 bool m_playing;
52
53private:
54 GameSessionRecorder(const GameSessionRecorder&) = delete;
55 GameSessionRecorder& operator=(const GameSessionRecorder&) = delete;
56};
57
58#endif
59
60/* EOF */
61