mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -07:00
Do not open card reveal windows when skipping in replays (#5157)
* create EventProcessingOption QFlag * pass EventProcessingOption all the way down * implement reveal skipping logic
This commit is contained in:
parent
dd04c610ec
commit
e894e78346
7 changed files with 58 additions and 22 deletions
|
|
@ -93,7 +93,7 @@ void ReplayTimelineWidget::skipToTime(int newTime, bool doRewindBuffering)
|
|||
if (isBackwardsSkip) {
|
||||
handleBackwardsSkip(doRewindBuffering);
|
||||
} else {
|
||||
processNewEvents();
|
||||
processNewEvents(FORWARD_SKIP);
|
||||
}
|
||||
|
||||
update();
|
||||
|
|
@ -130,7 +130,7 @@ void ReplayTimelineWidget::processRewind()
|
|||
// process the rewind
|
||||
currentEvent = 0;
|
||||
emit rewound();
|
||||
processNewEvents();
|
||||
processNewEvents(BACKWARD_SKIP);
|
||||
}
|
||||
|
||||
QSize ReplayTimelineWidget::sizeHint() const
|
||||
|
|
@ -147,17 +147,24 @@ void ReplayTimelineWidget::replayTimerTimeout()
|
|||
{
|
||||
currentTime += 200;
|
||||
|
||||
processNewEvents();
|
||||
processNewEvents(NORMAL_PLAYBACK);
|
||||
|
||||
if (!(currentTime % 1000))
|
||||
update();
|
||||
}
|
||||
|
||||
/// Processes all unprocessed events up to the current time.
|
||||
void ReplayTimelineWidget::processNewEvents()
|
||||
void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
|
||||
{
|
||||
while ((currentEvent < replayTimeline.size()) && (replayTimeline[currentEvent] < currentTime)) {
|
||||
emit processNextEvent();
|
||||
Player::EventProcessingOptions options;
|
||||
|
||||
// backwards skip => always skip reveal windows
|
||||
// forwards skip => skip reveal windows that don't happen within 10 seconds of the target
|
||||
if (playbackMode == BACKWARD_SKIP || currentTime - replayTimeline[currentEvent] > 10000)
|
||||
options |= Player::EventProcessingOption::SKIP_REVEAL_WINDOW;
|
||||
|
||||
emit processNextEvent(options);
|
||||
++currentEvent;
|
||||
}
|
||||
if (currentEvent == replayTimeline.size()) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef REPLAY_TIMELINE_WIDGET
|
||||
#define REPLAY_TIMELINE_WIDGET
|
||||
|
||||
#include "../../game/player/player.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QMouseEvent>
|
||||
#include <QWidget>
|
||||
|
|
@ -12,11 +14,18 @@ class ReplayTimelineWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void processNextEvent();
|
||||
void processNextEvent(Player::EventProcessingOptions options);
|
||||
void replayFinished();
|
||||
void rewound();
|
||||
|
||||
private:
|
||||
enum PlaybackMode
|
||||
{
|
||||
NORMAL_PLAYBACK,
|
||||
FORWARD_SKIP,
|
||||
BACKWARD_SKIP
|
||||
};
|
||||
|
||||
QTimer *replayTimer;
|
||||
static constexpr int BASE_REWIND_BUFFERING_TIMEOUT_MS = 180;
|
||||
static constexpr int MAX_REWIND_BUFFERING_TIMEOUT_MS = 280;
|
||||
|
|
@ -33,7 +42,7 @@ private:
|
|||
void handleBackwardsSkip(bool doRewindBuffering);
|
||||
int calcRewindBufferingTimeout() const;
|
||||
void processRewind();
|
||||
void processNewEvents();
|
||||
void processNewEvents(PlaybackMode playbackMode);
|
||||
private slots:
|
||||
void replayTimerTimeout();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue