Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
replay_manager.h
Go to the documentation of this file.
1#ifndef COCKATRICE_REPLAY_MANAGER_H
2#define COCKATRICE_REPLAY_MANAGER_H
3
5
6#include <QObject>
7#include <libcockatrice/protocol/pb/game_replay.pb.h>
8
9class GameReplay;
10class QTimer;
11
15class ReplayManager : public QObject
16{
17 Q_OBJECT
18
25
27 QList<int> replayTimeline;
29
30 QTimer *replayTimer;
32
33 qreal timeScaleFactor = 1.0;
34 bool skipEmptySections = false;
35
39 int currentEvent = 0;
40
41 void skipToTime(int newTime, bool doRewindBuffering);
42 void handleBackwardsSkip(bool doRewindBuffering);
43 void processRewind();
44 void processNewEvents(PlaybackMode playbackMode);
46
47private slots:
48 void replayTimerTimeout();
49
50public:
51 static constexpr int SMALL_SKIP_MS = 1000;
52 static constexpr int BIG_SKIP_MS = 10000;
53
58 explicit ReplayManager(QObject *parent, GameReplay *replay);
59
60 ~ReplayManager() override;
61
62 const QList<int> &getReplayTimeline() const
63 {
64 return replayTimeline;
65 }
66
67 void setTimeScaleFactor(qreal _timeScaleFactor);
68 void setSkipEmptySections(bool value);
69
70public slots:
71 void startReplay();
72 void stopReplay();
73 void setTime(int time);
74 void skipByAmount(int amount); // use a negative amount to skip backwards
75
76signals:
77 void timeChanged(int time);
78 void eventReplayed(const GameEventContainer &cont, EventProcessingOptions options);
80 void rewound();
81};
82
83#endif // COCKATRICE_REPLAY_MANAGER_H
bool skipEmptySections
Definition replay_manager.h:34
void processNewEvents(PlaybackMode playbackMode)
Processes all unprocessed events up to the current time.
Definition replay_manager.cpp:131
void replayFinished()
PlaybackMode
Definition replay_manager.h:20
@ BACKWARD_SKIP
Definition replay_manager.h:23
@ NORMAL_PLAYBACK
Definition replay_manager.h:21
@ FORWARD_SKIP
Definition replay_manager.h:22
GameReplay * replay
Definition replay_manager.h:26
static constexpr int SMALL_SKIP_MS
Definition replay_manager.h:51
QTimer * rewindBufferingTimer
Definition replay_manager.h:31
void handleSkipEmptySection()
Definition replay_manager.cpp:173
const QList< int > & getReplayTimeline() const
Definition replay_manager.h:62
void timeChanged(int time)
int maxTime
Definition replay_manager.h:28
qreal timeScaleFactor
Definition replay_manager.h:33
void skipToTime(int newTime, bool doRewindBuffering)
Definition replay_manager.cpp:62
static constexpr int BIG_SKIP_MS
Definition replay_manager.h:52
int currentEvent
current event's index
Definition replay_manager.h:39
void skipByAmount(int amount)
Definition replay_manager.cpp:231
QTimer * replayTimer
Definition replay_manager.h:30
~ReplayManager() override
Definition replay_manager.cpp:57
void handleBackwardsSkip(bool doRewindBuffering)
Handles a backwards skip in the replay timeline.
Definition replay_manager.cpp:92
void processRewind()
Definition replay_manager.cpp:106
void setSkipEmptySections(bool value)
Definition replay_manager.cpp:210
void setTimeScaleFactor(qreal _timeScaleFactor)
Definition replay_manager.cpp:203
void setTime(int time)
Definition replay_manager.cpp:225
int currentProcessedTime
Definition replay_manager.h:37
void replayTimerTimeout()
Definition replay_manager.cpp:117
int currentVisualTime
time currently displayed by the timeline
Definition replay_manager.h:36
void startReplay()
Definition replay_manager.cpp:215
void stopReplay()
Definition replay_manager.cpp:220
void eventReplayed(const GameEventContainer &cont, EventProcessingOptions options)
ReplayManager(QObject *parent, GameReplay *replay)
Definition replay_manager.cpp:43
QList< int > replayTimeline
timestamp of each event, with the indexes corresponding
Definition replay_manager.h:27
static constexpr int amount
Definition deck_hash_performance_test.cpp:5
Definition game_event_container.proto:4
Definition game_replay.proto:4