mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-12 15:49:28 -08:00
make rewind buffering timeout configurable (#5227)
* update settingsCache * implement thing * add new setting to window * rename setting * make it compile on qt5 * fix typo * somehow changing the order here fixes a bug? The loaded value was getting clamped to 99
This commit is contained in:
@@ -106,20 +106,13 @@ void ReplayTimelineWidget::handleBackwardsSkip(bool doRewindBuffering)
|
||||
// The rewind only happens once the timer runs out.
|
||||
// If another backwards skip happens, the timer will just get reset instead of rewinding.
|
||||
rewindBufferingTimer->stop();
|
||||
rewindBufferingTimer->start(calcRewindBufferingTimeout());
|
||||
rewindBufferingTimer->start(SettingsCache::instance().getRewindBufferingMs());
|
||||
} else {
|
||||
// otherwise, process the rewind immediately
|
||||
processRewind();
|
||||
}
|
||||
}
|
||||
|
||||
/// The timeout scales based on the current event number, up to a limit
|
||||
int ReplayTimelineWidget::calcRewindBufferingTimeout() const
|
||||
{
|
||||
int extraTime = currentEvent / 100;
|
||||
return std::min(BASE_REWIND_BUFFERING_TIMEOUT_MS + extraTime, MAX_REWIND_BUFFERING_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
void ReplayTimelineWidget::processRewind()
|
||||
{
|
||||
// stop any queued-up rewinds
|
||||
|
||||
@@ -28,8 +28,6 @@ private:
|
||||
|
||||
static constexpr int TIMER_INTERVAL_MS = 200;
|
||||
static constexpr int BIN_LENGTH = 5000;
|
||||
static constexpr int BASE_REWIND_BUFFERING_TIMEOUT_MS = 180;
|
||||
static constexpr int MAX_REWIND_BUFFERING_TIMEOUT_MS = 280;
|
||||
|
||||
QTimer *replayTimer;
|
||||
QTimer *rewindBufferingTimer;
|
||||
@@ -42,7 +40,6 @@ private:
|
||||
|
||||
void skipToTime(int newTime, bool doRewindBuffering);
|
||||
void handleBackwardsSkip(bool doRewindBuffering);
|
||||
int calcRewindBufferingTimeout() const;
|
||||
void processRewind();
|
||||
void processNewEvents(PlaybackMode playbackMode);
|
||||
private slots:
|
||||
|
||||
@@ -508,12 +508,26 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
deckEditorGroupBox = new QGroupBox;
|
||||
deckEditorGroupBox->setLayout(deckEditorGrid);
|
||||
|
||||
// replay settings
|
||||
rewindBufferingMsBox.setRange(0, 9999);
|
||||
rewindBufferingMsBox.setValue(SettingsCache::instance().getRewindBufferingMs());
|
||||
connect(&rewindBufferingMsBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance(),
|
||||
&SettingsCache::setRewindBufferingMs);
|
||||
|
||||
auto *replayGrid = new QGridLayout;
|
||||
replayGrid->addWidget(&rewindBufferingMsLabel, 0, 0, 1, 1);
|
||||
replayGrid->addWidget(&rewindBufferingMsBox, 0, 1, 1, 1);
|
||||
|
||||
replayGroupBox = new QGroupBox;
|
||||
replayGroupBox->setLayout(replayGrid);
|
||||
|
||||
// putting it all together
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(generalGroupBox);
|
||||
mainLayout->addWidget(notificationsGroupBox);
|
||||
mainLayout->addWidget(animationGroupBox);
|
||||
mainLayout->addWidget(deckEditorGroupBox);
|
||||
mainLayout->addWidget(replayGroupBox);
|
||||
mainLayout->addStretch();
|
||||
|
||||
setLayout(mainLayout);
|
||||
@@ -544,6 +558,9 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
||||
deckEditorGroupBox->setTitle(tr("Deck editor settings"));
|
||||
openDeckInNewTabCheckBox.setText(tr("Always open deck in new tab"));
|
||||
replayGroupBox->setTitle(tr("Replay settings"));
|
||||
rewindBufferingMsLabel.setText(tr("Buffer time for backwards skip via shortcut:"));
|
||||
rewindBufferingMsBox.setSuffix(tr(" ms"));
|
||||
}
|
||||
|
||||
DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||
|
||||
@@ -125,10 +125,13 @@ private:
|
||||
QCheckBox useTearOffMenusCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
QCheckBox openDeckInNewTabCheckBox;
|
||||
QLabel rewindBufferingMsLabel;
|
||||
QSpinBox rewindBufferingMsBox;
|
||||
QGroupBox *generalGroupBox;
|
||||
QGroupBox *notificationsGroupBox;
|
||||
QGroupBox *animationGroupBox;
|
||||
QGroupBox *deckEditorGroupBox;
|
||||
QGroupBox *replayGroupBox;
|
||||
|
||||
public:
|
||||
UserInterfaceSettingsPage();
|
||||
|
||||
@@ -245,6 +245,7 @@ SettingsCache::SettingsCache()
|
||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
|
||||
rewindBufferingMs = settings->value("replay/rewindBufferingMs", 200).toInt();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
|
||||
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||
@@ -545,6 +546,12 @@ void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab)
|
||||
settings->setValue("editor/openDeckInNewTab", openDeckInNewTab);
|
||||
}
|
||||
|
||||
void SettingsCache::setRewindBufferingMs(int _rewindBufferingMs)
|
||||
{
|
||||
rewindBufferingMs = _rewindBufferingMs;
|
||||
settings->setValue("replay/rewindBufferingMs", rewindBufferingMs);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T _chatMention)
|
||||
{
|
||||
chatMention = static_cast<bool>(_chatMention);
|
||||
|
||||
@@ -103,6 +103,7 @@ private:
|
||||
int minPlayersForMultiColumnLayout;
|
||||
bool tapAnimation;
|
||||
bool openDeckInNewTab;
|
||||
int rewindBufferingMs;
|
||||
bool chatMention;
|
||||
bool chatMentionCompleter;
|
||||
QString chatMentionColor;
|
||||
@@ -312,6 +313,10 @@ public:
|
||||
{
|
||||
return openDeckInNewTab;
|
||||
}
|
||||
int getRewindBufferingMs() const
|
||||
{
|
||||
return rewindBufferingMs;
|
||||
}
|
||||
bool getChatMention() const
|
||||
{
|
||||
return chatMention;
|
||||
@@ -566,6 +571,7 @@ public slots:
|
||||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||
void setTapAnimation(QT_STATE_CHANGED_T _tapAnimation);
|
||||
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
|
||||
void setRewindBufferingMs(int _rewindBufferingMs);
|
||||
void setChatMention(QT_STATE_CHANGED_T _chatMention);
|
||||
void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter);
|
||||
void setChatMentionForeground(QT_STATE_CHANGED_T _chatMentionForeground);
|
||||
|
||||
@@ -166,6 +166,9 @@ void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T /* _tapAnimation */)
|
||||
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setRewindBufferingMs(int /* _rewindBufferingMs */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -170,6 +170,9 @@ void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T /* _tapAnimation */)
|
||||
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setRewindBufferingMs(int /* _rewindBufferingMs */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user