mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
Merge 231122edb9 into f3b41432cb
This commit is contained in:
commit
44312346a1
9 changed files with 95 additions and 7 deletions
|
|
@ -228,6 +228,7 @@ set(cockatrice_SOURCES
|
|||
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_popup_widget.cpp
|
||||
src/interface/widgets/replay/replay_quick_settings_widget.cpp
|
||||
src/interface/widgets/replay/replay_manager.cpp
|
||||
src/interface/widgets/replay/replay_timeline_widget.cpp
|
||||
src/interface/widgets/server/chat_view/chat_view.cpp
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ SettingsCache::SettingsCache()
|
|||
|
||||
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
|
||||
rewindBufferingMs = settings->value("replay/rewindBufferingMs", 200).toInt();
|
||||
fastForwardSpeed = settings->value("replay/fastForwardSpeed", 10).toReal();
|
||||
styleUserList = settings->value("appearance/styleUserList", true).toBool();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
|
||||
|
|
@ -1047,6 +1048,12 @@ void SettingsCache::setRewindBufferingMs(int _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)
|
||||
{
|
||||
styleUserList = static_cast<bool>(_styleUserList);
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ private:
|
|||
bool autoRotateSidewaysLayoutCards;
|
||||
bool openDeckInNewTab;
|
||||
int rewindBufferingMs;
|
||||
qreal fastForwardSpeed;
|
||||
bool styleUserList;
|
||||
bool chatMention;
|
||||
bool chatMentionCompleter;
|
||||
|
|
@ -745,6 +746,10 @@ public:
|
|||
{
|
||||
return rewindBufferingMs;
|
||||
}
|
||||
[[nodiscard]] qreal getFastForwardSpeed() const
|
||||
{
|
||||
return fastForwardSpeed;
|
||||
}
|
||||
[[nodiscard]] bool getStyleUserList() const
|
||||
{
|
||||
return styleUserList;
|
||||
|
|
@ -1124,6 +1129,7 @@ public slots:
|
|||
void setAutoRotateSidewaysLayoutCards(QT_STATE_CHANGED_T _autoRotateSidewaysLayoutCards);
|
||||
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
|
||||
void setRewindBufferingMs(int _rewindBufferingMs);
|
||||
void setFastForwardSpeed(qreal _value);
|
||||
void setStyleUserList(QT_STATE_CHANGED_T _styleUserList);
|
||||
void setChatMention(QT_STATE_CHANGED_T _chatMention);
|
||||
void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "replay_manager.h"
|
||||
|
||||
#include "../interface/widgets/tabs/tab_game.h"
|
||||
#include "replay_quick_settings_widget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
|
|
@ -78,13 +79,19 @@ ReplayManager::ReplayManager(TabGame *parent, GameReplay *_replay)
|
|||
replayFastForwardButton->setIconSize(QSize(32, 32));
|
||||
replayFastForwardButton->setIcon(QPixmap("theme:replay/fastforward"));
|
||||
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
|
||||
auto replayControlLayout = new QHBoxLayout;
|
||||
replayControlLayout->addWidget(timelineWidget, 10);
|
||||
replayControlLayout->addWidget(replayPlayButton);
|
||||
replayControlLayout->addWidget(replayFastForwardButton);
|
||||
replayControlLayout->addWidget(settingsWidget);
|
||||
|
||||
setObjectName("replayControlWidget");
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <QWidget>
|
||||
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
||||
|
||||
class ReplayQuickSettingsWidget;
|
||||
class TabGame;
|
||||
|
||||
class ReplayManager : public QWidget
|
||||
|
|
@ -35,13 +36,14 @@ private:
|
|||
QList<int> replayTimeline;
|
||||
ReplayTimelineWidget *timelineWidget;
|
||||
QToolButton *replayPlayButton, *replayFastForwardButton;
|
||||
ReplayQuickSettingsWidget *settingsWidget;
|
||||
QAction *aReplaySkipForward, *aReplaySkipBackward, *aReplaySkipForwardBig, *aReplaySkipBackwardBig;
|
||||
|
||||
private slots:
|
||||
void replayNextEvent(EventProcessingOptions options);
|
||||
void replayFinished();
|
||||
void replayPlayButtonToggled(bool checked);
|
||||
void replayFastForwardButtonToggled(bool checked);
|
||||
void updateTimeScaleFactor(bool checked);
|
||||
void replayRewind();
|
||||
void refreshShortcuts();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -11,6 +11,7 @@ ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent)
|
|||
currentEvent(0)
|
||||
{
|
||||
replayTimer = new QTimer(this);
|
||||
replayTimer->setInterval(TIMER_INTERVAL_MS);
|
||||
connect(replayTimer, &QTimer::timeout, this, &ReplayTimelineWidget::replayTimerTimeout);
|
||||
|
||||
rewindBufferingTimer = new QTimer(this);
|
||||
|
|
@ -186,12 +187,13 @@ void ReplayTimelineWidget::processNewEvents(PlaybackMode playbackMode)
|
|||
void ReplayTimelineWidget::setTimeScaleFactor(qreal _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()
|
||||
{
|
||||
replayTimer->start(static_cast<int>(TIMER_INTERVAL_MS / timeScaleFactor));
|
||||
replayTimer->start();
|
||||
}
|
||||
|
||||
void ReplayTimelineWidget::stopReplay()
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ private slots:
|
|||
public:
|
||||
static constexpr int SMALL_SKIP_MS = 1000;
|
||||
static constexpr int BIG_SKIP_MS = 10000;
|
||||
static constexpr qreal FAST_FORWARD_SCALE_FACTOR = 10.0;
|
||||
|
||||
explicit ReplayTimelineWidget(QWidget *parent = nullptr);
|
||||
void setTimeline(const QList<int> &_replayTimeline);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue