This commit is contained in:
RickyRister 2026-07-05 22:40:04 -07:00 committed by GitHub
commit 44312346a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 95 additions and 7 deletions

View file

@ -228,6 +228,7 @@ set(cockatrice_SOURCES
src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp
src/interface/widgets/quick_settings/settings_button_widget.cpp src/interface/widgets/quick_settings/settings_button_widget.cpp
src/interface/widgets/quick_settings/settings_popup_widget.cpp src/interface/widgets/quick_settings/settings_popup_widget.cpp
src/interface/widgets/replay/replay_quick_settings_widget.cpp
src/interface/widgets/replay/replay_manager.cpp src/interface/widgets/replay/replay_manager.cpp
src/interface/widgets/replay/replay_timeline_widget.cpp src/interface/widgets/replay/replay_timeline_widget.cpp
src/interface/widgets/server/chat_view/chat_view.cpp src/interface/widgets/server/chat_view/chat_view.cpp

View file

@ -372,6 +372,7 @@ SettingsCache::SettingsCache()
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool(); openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
rewindBufferingMs = settings->value("replay/rewindBufferingMs", 200).toInt(); rewindBufferingMs = settings->value("replay/rewindBufferingMs", 200).toInt();
fastForwardSpeed = settings->value("replay/fastForwardSpeed", 10).toReal();
styleUserList = settings->value("appearance/styleUserList", true).toBool(); styleUserList = settings->value("appearance/styleUserList", true).toBool();
chatMention = settings->value("chat/mention", true).toBool(); chatMention = settings->value("chat/mention", true).toBool();
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool(); chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
@ -1047,6 +1048,12 @@ void SettingsCache::setRewindBufferingMs(int _rewindBufferingMs)
settings->setValue("replay/rewindBufferingMs", rewindBufferingMs); settings->setValue("replay/rewindBufferingMs", rewindBufferingMs);
} }
void SettingsCache::setFastForwardSpeed(qreal _value)
{
fastForwardSpeed = _value;
settings->setValue("replay/fastForwardSpeed", fastForwardSpeed);
}
void SettingsCache::setStyleUserList(QT_STATE_CHANGED_T _styleUserList) void SettingsCache::setStyleUserList(QT_STATE_CHANGED_T _styleUserList)
{ {
styleUserList = static_cast<bool>(_styleUserList); styleUserList = static_cast<bool>(_styleUserList);

View file

@ -285,6 +285,7 @@ private:
bool autoRotateSidewaysLayoutCards; bool autoRotateSidewaysLayoutCards;
bool openDeckInNewTab; bool openDeckInNewTab;
int rewindBufferingMs; int rewindBufferingMs;
qreal fastForwardSpeed;
bool styleUserList; bool styleUserList;
bool chatMention; bool chatMention;
bool chatMentionCompleter; bool chatMentionCompleter;
@ -745,6 +746,10 @@ public:
{ {
return rewindBufferingMs; return rewindBufferingMs;
} }
[[nodiscard]] qreal getFastForwardSpeed() const
{
return fastForwardSpeed;
}
[[nodiscard]] bool getStyleUserList() const [[nodiscard]] bool getStyleUserList() const
{ {
return styleUserList; return styleUserList;
@ -1124,6 +1129,7 @@ public slots:
void setAutoRotateSidewaysLayoutCards(QT_STATE_CHANGED_T _autoRotateSidewaysLayoutCards); void setAutoRotateSidewaysLayoutCards(QT_STATE_CHANGED_T _autoRotateSidewaysLayoutCards);
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab); void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
void setRewindBufferingMs(int _rewindBufferingMs); void setRewindBufferingMs(int _rewindBufferingMs);
void setFastForwardSpeed(qreal _value);
void setStyleUserList(QT_STATE_CHANGED_T _styleUserList); void setStyleUserList(QT_STATE_CHANGED_T _styleUserList);
void setChatMention(QT_STATE_CHANGED_T _chatMention); void setChatMention(QT_STATE_CHANGED_T _chatMention);
void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter); void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter);

View file

@ -1,6 +1,7 @@
#include "replay_manager.h" #include "replay_manager.h"
#include "../interface/widgets/tabs/tab_game.h" #include "../interface/widgets/tabs/tab_game.h"
#include "replay_quick_settings_widget.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QToolButton> #include <QToolButton>
@ -78,13 +79,19 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
replayFastForwardButton->setIconSize(QSize(32, 32)); replayFastForwardButton->setIconSize(QSize(32, 32));
replayFastForwardButton->setIcon(QPixmap("theme:replay/fastforward")); replayFastForwardButton->setIcon(QPixmap("theme:replay/fastforward"));
replayFastForwardButton->setCheckable(true); replayFastForwardButton->setCheckable(true);
connect(replayFastForwardButton, &QToolButton::toggled, this, &ReplayManager::replayFastForwardButtonToggled); connect(replayFastForwardButton, &QToolButton::toggled, this, &ReplayManager::updateTimeScaleFactor);
settingsWidget = new ReplayQuickSettingsWidget(this);
settingsWidget->setFixedSize(QSize(32, 32));
connect(settingsWidget, &ReplayQuickSettingsWidget::fastForwardSpeedChanged, this,
[this] { updateTimeScaleFactor(replayFastForwardButton->isChecked()); });
// putting everything together // putting everything together
auto replayControlLayout = new QHBoxLayout; auto replayControlLayout = new QHBoxLayout;
replayControlLayout->addWidget(timelineWidget, 10); replayControlLayout->addWidget(timelineWidget, 10);
replayControlLayout->addWidget(replayPlayButton); replayControlLayout->addWidget(replayPlayButton);
replayControlLayout->addWidget(replayFastForwardButton); replayControlLayout->addWidget(replayFastForwardButton);
replayControlLayout->addWidget(settingsWidget);
setObjectName("replayControlWidget"); setObjectName("replayControlWidget");
setLayout(replayControlLayout); setLayout(replayControlLayout);
@ -115,9 +122,10 @@ void ReplayManager::replayPlayButtonToggled(bool checked)
} }
} }
void ReplayManager::replayFastForwardButtonToggled(bool checked) void ReplayManager::updateTimeScaleFactor(bool isFastForward)
{ {
timelineWidget->setTimeScaleFactor(checked ? ReplayTimelineWidget::FAST_FORWARD_SCALE_FACTOR : 1.0); qreal factor = isFastForward ? SettingsCache::instance().getFastForwardSpeed() : 1.0;
timelineWidget->setTimeScaleFactor(factor);
} }
/** /**

View file

@ -14,6 +14,7 @@
#include <QWidget> #include <QWidget>
#include <libcockatrice/protocol/pb/game_replay.pb.h> #include <libcockatrice/protocol/pb/game_replay.pb.h>
class ReplayQuickSettingsWidget;
class TabGame; class TabGame;
class ReplayManager : public QWidget class ReplayManager : public QWidget
@ -35,13 +36,14 @@ private:
QList<int> replayTimeline; QList<int> replayTimeline;
ReplayTimelineWidget *timelineWidget; ReplayTimelineWidget *timelineWidget;
QToolButton *replayPlayButton, *replayFastForwardButton; QToolButton *replayPlayButton, *replayFastForwardButton;
ReplayQuickSettingsWidget *settingsWidget;
QAction *aReplaySkipForward, *aReplaySkipBackward, *aReplaySkipForwardBig, *aReplaySkipBackwardBig; QAction *aReplaySkipForward, *aReplaySkipBackward, *aReplaySkipForwardBig, *aReplaySkipBackwardBig;
private slots: private slots:
void replayNextEvent(EventProcessingOptions options); void replayNextEvent(EventProcessingOptions options);
void replayFinished(); void replayFinished();
void replayPlayButtonToggled(bool checked); void replayPlayButtonToggled(bool checked);
void replayFastForwardButtonToggled(bool checked); void updateTimeScaleFactor(bool checked);
void replayRewind(); void replayRewind();
void refreshShortcuts(); void refreshShortcuts();
}; };

View file

@ -0,0 +1,35 @@
#include "replay_quick_settings_widget.h"
#include "../../client/settings/cache_settings.h"
ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : SettingsButtonWidget(parent)
{
// fast forward speed
fastForwardSpeedBox.setMinimum(1);
fastForwardSpeedBox.setValue(SettingsCache::instance().getFastForwardSpeed());
connect(&fastForwardSpeedBox, &QDoubleSpinBox::valueChanged, this,
&ReplayQuickSettingsWidget::actUpdateFastForwardSpeed);
// putting it all together
auto *widget = new QWidget;
auto *grid = new QGridLayout(widget);
grid->setContentsMargins(0, 0, 0, 0);
grid->addWidget(&fastForwardSpeedLabel, 0, 0, 1, 1);
grid->addWidget(&fastForwardSpeedBox, 0, 1, 1, 1);
this->addSettingsWidget(widget);
retranslateUi();
}
void ReplayQuickSettingsWidget::retranslateUi()
{
fastForwardSpeedLabel.setText(tr("Fast forward speed:"));
fastForwardSpeedBox.setSuffix("x");
}
void ReplayQuickSettingsWidget::actUpdateFastForwardSpeed(qreal value)
{
SettingsCache::instance().setFastForwardSpeed(value);
emit fastForwardSpeedChanged(value);
}

View file

@ -0,0 +1,28 @@
#ifndef COCKATRICE_REPLAY_QUICK_SETTINGS_WIDGET_H
#define COCKATRICE_REPLAY_QUICK_SETTINGS_WIDGET_H
#include "../../interface/widgets/quick_settings/settings_button_widget.h"
#include <QDoubleSpinBox>
class ReplayQuickSettingsWidget : public SettingsButtonWidget
{
Q_OBJECT
public:
explicit ReplayQuickSettingsWidget(QWidget *parent);
void retranslateUi();
signals:
void fastForwardSpeedChanged(qreal speed);
private:
QLabel fastForwardSpeedLabel;
QDoubleSpinBox fastForwardSpeedBox;
private slots:
void actUpdateFastForwardSpeed(qreal value);
};
#endif // COCKATRICE_REPLAY_QUICK_SETTINGS_WIDGET_H

View file

@ -11,6 +11,7 @@ ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent)
currentEvent(0) currentEvent(0)
{ {
replayTimer = new QTimer(this); replayTimer = new QTimer(this);
replayTimer->setInterval(TIMER_INTERVAL_MS);
connect(replayTimer, &QTimer::timeout, this, &ReplayTimelineWidget::replayTimerTimeout); connect(replayTimer, &QTimer::timeout, this, &ReplayTimelineWidget::replayTimerTimeout);
rewindBufferingTimer = new QTimer(this); rewindBufferingTimer = new QTimer(this);
@ -186,12 +187,13 @@ void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
void ReplayTimelineWidget::setTimeScaleFactor(qreal _timeScaleFactor) void ReplayTimelineWidget::setTimeScaleFactor(qreal _timeScaleFactor)
{ {
timeScaleFactor = _timeScaleFactor; timeScaleFactor = _timeScaleFactor;
replayTimer->setInterval(static_cast<int>(TIMER_INTERVAL_MS / timeScaleFactor)); int interval = qRound(TIMER_INTERVAL_MS / timeScaleFactor);
replayTimer->setInterval(interval);
} }
void ReplayTimelineWidget::startReplay() void ReplayTimelineWidget::startReplay()
{ {
replayTimer->start(static_cast<int>(TIMER_INTERVAL_MS / timeScaleFactor)); replayTimer->start();
} }
void ReplayTimelineWidget::stopReplay() void ReplayTimelineWidget::stopReplay()

View file

@ -55,7 +55,6 @@ private slots:
public: public:
static constexpr int SMALL_SKIP_MS = 1000; static constexpr int SMALL_SKIP_MS = 1000;
static constexpr int BIG_SKIP_MS = 10000; static constexpr int BIG_SKIP_MS = 10000;
static constexpr qreal FAST_FORWARD_SCALE_FACTOR = 10.0;
explicit ReplayTimelineWidget(QWidget *parent = nullptr); explicit ReplayTimelineWidget(QWidget *parent = nullptr);
void setTimeline(const QList<int> &_replayTimeline); void setTimeline(const QList<int> &_replayTimeline);