mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 20:33:58 -07:00
Merge branch 'master' into tooomm-qt5
This commit is contained in:
commit
9d4cf57c70
593 changed files with 12518 additions and 6581 deletions
|
|
@ -19,16 +19,19 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
|
|||
const int eventCount = replay->event_list_size();
|
||||
for (int i = 0; i < eventCount; ++i) {
|
||||
int j = i + 1;
|
||||
while ((j < eventCount) && (replay->event_list(j).seconds_elapsed() == lastEventTimestamp))
|
||||
while ((j < eventCount) && (replay->event_list(j).seconds_elapsed() == lastEventTimestamp)) {
|
||||
++j;
|
||||
}
|
||||
|
||||
const int numberEventsThisSecond = j - i;
|
||||
for (int k = 0; k < numberEventsThisSecond; ++k)
|
||||
for (int k = 0; k < numberEventsThisSecond; ++k) {
|
||||
replayTimeline.append(replay->event_list(i + k).seconds_elapsed() * 1000 +
|
||||
(int)((qreal)k / (qreal)numberEventsThisSecond * 1000));
|
||||
}
|
||||
|
||||
if (j < eventCount)
|
||||
if (j < eventCount) {
|
||||
lastEventTimestamp = replay->event_list(j).seconds_elapsed();
|
||||
}
|
||||
i += numberEventsThisSecond - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* @file replay_manager.h
|
||||
* @ingroup Core
|
||||
* @ingroup Replay
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef REPLAY_MANAGER_H
|
||||
#define REPLAY_MANAGER_H
|
||||
|
|
|
|||
|
|
@ -27,20 +27,23 @@ void ReplayTimelineWidget::setTimeline(const QList<int> &_replayTimeline)
|
|||
for (int i : replayTimeline) {
|
||||
if (i > binEndTime) {
|
||||
histogram.append(binValue);
|
||||
if (binValue > maxBinValue)
|
||||
if (binValue > maxBinValue) {
|
||||
maxBinValue = binValue;
|
||||
}
|
||||
while (i > binEndTime + BIN_LENGTH) {
|
||||
histogram.append(0);
|
||||
binEndTime += BIN_LENGTH;
|
||||
}
|
||||
binValue = 1;
|
||||
binEndTime += BIN_LENGTH;
|
||||
} else
|
||||
} else {
|
||||
++binValue;
|
||||
}
|
||||
}
|
||||
histogram.append(binValue);
|
||||
if (!replayTimeline.isEmpty())
|
||||
if (!replayTimeline.isEmpty()) {
|
||||
maxTime = replayTimeline.last();
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
@ -53,8 +56,9 @@ void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */)
|
|||
qreal binWidth = (qreal)width() / histogram.size();
|
||||
QPainterPath path;
|
||||
path.moveTo(0, height() - 1);
|
||||
for (int i = 0; i < histogram.size(); ++i)
|
||||
for (int i = 0; i < histogram.size(); ++i) {
|
||||
path.lineTo(qRound(i * binWidth), (height() - 1) * (1.0 - (qreal)histogram[i] / maxBinValue));
|
||||
}
|
||||
path.lineTo(width() - 1, height() - 1);
|
||||
path.lineTo(0, height() - 1);
|
||||
painter.fillPath(path, Qt::black);
|
||||
|
|
@ -95,8 +99,12 @@ void ReplayTimelineWidget::skipToTime(int newTime, bool doRewindBuffering)
|
|||
update();
|
||||
}
|
||||
|
||||
/// @param doRewindBuffering When true, if multiple backward skips are made in quick succession, only a single rewind
|
||||
/// is processed at the end. When false, the backwards skip will always cause an immediate rewind
|
||||
/**
|
||||
* @brief Handles a backwards skip in the replay timeline.
|
||||
*
|
||||
* @param doRewindBuffering When true, if multiple backward skips are made in quick succession, only a single rewind
|
||||
* is processed at the end. When false, the backwards skip will always cause an immediate rewind.
|
||||
*/
|
||||
void ReplayTimelineWidget::handleBackwardsSkip(bool doRewindBuffering)
|
||||
{
|
||||
if (doRewindBuffering) {
|
||||
|
|
@ -138,11 +146,12 @@ void ReplayTimelineWidget::replayTimerTimeout()
|
|||
|
||||
processNewEvents(NORMAL_PLAYBACK);
|
||||
|
||||
if (!(currentVisualTime % 1000))
|
||||
if (!(currentVisualTime % 1000)) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/// Processes all unprocessed events up to the current time.
|
||||
/** @brief Processes all unprocessed events up to the current time. */
|
||||
void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
|
||||
{
|
||||
currentProcessedTime = currentVisualTime;
|
||||
|
|
@ -152,12 +161,14 @@ void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
|
|||
|
||||
// backwards skip => always skip reveal windows
|
||||
// forwards skip => skip reveal windows that don't happen within a big skip of the target
|
||||
if (playbackMode == BACKWARD_SKIP || currentProcessedTime - replayTimeline[currentEvent] > BIG_SKIP_MS)
|
||||
if (playbackMode == BACKWARD_SKIP || currentProcessedTime - replayTimeline[currentEvent] > BIG_SKIP_MS) {
|
||||
options |= SKIP_REVEAL_WINDOW;
|
||||
}
|
||||
|
||||
// backwards skip => always skip tap animation
|
||||
if (playbackMode == BACKWARD_SKIP)
|
||||
if (playbackMode == BACKWARD_SKIP) {
|
||||
options |= SKIP_TAP_ANIMATION;
|
||||
}
|
||||
|
||||
emit processNextEvent(options);
|
||||
++currentEvent;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file replay_timeline_widget.h
|
||||
* @ingroup Replay
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef REPLAY_TIMELINE_WIDGET
|
||||
#define REPLAY_TIMELINE_WIDGET
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue