mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07: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:
parent
10f11213d3
commit
a39de270cd
8 changed files with 40 additions and 11 deletions
|
|
@ -106,20 +106,13 @@ void ReplayTimelineWidget::handleBackwardsSkip(bool doRewindBuffering)
|
||||||
// The rewind only happens once the timer runs out.
|
// The rewind only happens once the timer runs out.
|
||||||
// If another backwards skip happens, the timer will just get reset instead of rewinding.
|
// If another backwards skip happens, the timer will just get reset instead of rewinding.
|
||||||
rewindBufferingTimer->stop();
|
rewindBufferingTimer->stop();
|
||||||
rewindBufferingTimer->start(calcRewindBufferingTimeout());
|
rewindBufferingTimer->start(SettingsCache::instance().getRewindBufferingMs());
|
||||||
} else {
|
} else {
|
||||||
// otherwise, process the rewind immediately
|
// otherwise, process the rewind immediately
|
||||||
processRewind();
|
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()
|
void ReplayTimelineWidget::processRewind()
|
||||||
{
|
{
|
||||||
// stop any queued-up rewinds
|
// stop any queued-up rewinds
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ private:
|
||||||
|
|
||||||
static constexpr int TIMER_INTERVAL_MS = 200;
|
static constexpr int TIMER_INTERVAL_MS = 200;
|
||||||
static constexpr int BIN_LENGTH = 5000;
|
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 *replayTimer;
|
||||||
QTimer *rewindBufferingTimer;
|
QTimer *rewindBufferingTimer;
|
||||||
|
|
@ -42,7 +40,6 @@ private:
|
||||||
|
|
||||||
void skipToTime(int newTime, bool doRewindBuffering);
|
void skipToTime(int newTime, bool doRewindBuffering);
|
||||||
void handleBackwardsSkip(bool doRewindBuffering);
|
void handleBackwardsSkip(bool doRewindBuffering);
|
||||||
int calcRewindBufferingTimeout() const;
|
|
||||||
void processRewind();
|
void processRewind();
|
||||||
void processNewEvents(PlaybackMode playbackMode);
|
void processNewEvents(PlaybackMode playbackMode);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
||||||
|
|
@ -508,12 +508,26 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
deckEditorGroupBox = new QGroupBox;
|
deckEditorGroupBox = new QGroupBox;
|
||||||
deckEditorGroupBox->setLayout(deckEditorGrid);
|
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
|
// putting it all together
|
||||||
auto *mainLayout = new QVBoxLayout;
|
auto *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
mainLayout->addWidget(notificationsGroupBox);
|
mainLayout->addWidget(notificationsGroupBox);
|
||||||
mainLayout->addWidget(animationGroupBox);
|
mainLayout->addWidget(animationGroupBox);
|
||||||
mainLayout->addWidget(deckEditorGroupBox);
|
mainLayout->addWidget(deckEditorGroupBox);
|
||||||
|
mainLayout->addWidget(replayGroupBox);
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
@ -544,6 +558,9 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
||||||
deckEditorGroupBox->setTitle(tr("Deck editor settings"));
|
deckEditorGroupBox->setTitle(tr("Deck editor settings"));
|
||||||
openDeckInNewTabCheckBox.setText(tr("Always open deck in new tab"));
|
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()
|
DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||||
|
|
|
||||||
|
|
@ -125,10 +125,13 @@ private:
|
||||||
QCheckBox useTearOffMenusCheckBox;
|
QCheckBox useTearOffMenusCheckBox;
|
||||||
QCheckBox tapAnimationCheckBox;
|
QCheckBox tapAnimationCheckBox;
|
||||||
QCheckBox openDeckInNewTabCheckBox;
|
QCheckBox openDeckInNewTabCheckBox;
|
||||||
|
QLabel rewindBufferingMsLabel;
|
||||||
|
QSpinBox rewindBufferingMsBox;
|
||||||
QGroupBox *generalGroupBox;
|
QGroupBox *generalGroupBox;
|
||||||
QGroupBox *notificationsGroupBox;
|
QGroupBox *notificationsGroupBox;
|
||||||
QGroupBox *animationGroupBox;
|
QGroupBox *animationGroupBox;
|
||||||
QGroupBox *deckEditorGroupBox;
|
QGroupBox *deckEditorGroupBox;
|
||||||
|
QGroupBox *replayGroupBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserInterfaceSettingsPage();
|
UserInterfaceSettingsPage();
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ SettingsCache::SettingsCache()
|
||||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
||||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||||
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
|
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
|
||||||
|
rewindBufferingMs = settings->value("replay/rewindBufferingMs", 200).toInt();
|
||||||
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();
|
||||||
chatMentionForeground = settings->value("chat/mentionforeground", 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);
|
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)
|
void SettingsCache::setChatMention(QT_STATE_CHANGED_T _chatMention)
|
||||||
{
|
{
|
||||||
chatMention = static_cast<bool>(_chatMention);
|
chatMention = static_cast<bool>(_chatMention);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ private:
|
||||||
int minPlayersForMultiColumnLayout;
|
int minPlayersForMultiColumnLayout;
|
||||||
bool tapAnimation;
|
bool tapAnimation;
|
||||||
bool openDeckInNewTab;
|
bool openDeckInNewTab;
|
||||||
|
int rewindBufferingMs;
|
||||||
bool chatMention;
|
bool chatMention;
|
||||||
bool chatMentionCompleter;
|
bool chatMentionCompleter;
|
||||||
QString chatMentionColor;
|
QString chatMentionColor;
|
||||||
|
|
@ -312,6 +313,10 @@ public:
|
||||||
{
|
{
|
||||||
return openDeckInNewTab;
|
return openDeckInNewTab;
|
||||||
}
|
}
|
||||||
|
int getRewindBufferingMs() const
|
||||||
|
{
|
||||||
|
return rewindBufferingMs;
|
||||||
|
}
|
||||||
bool getChatMention() const
|
bool getChatMention() const
|
||||||
{
|
{
|
||||||
return chatMention;
|
return chatMention;
|
||||||
|
|
@ -566,6 +571,7 @@ public slots:
|
||||||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||||
void setTapAnimation(QT_STATE_CHANGED_T _tapAnimation);
|
void setTapAnimation(QT_STATE_CHANGED_T _tapAnimation);
|
||||||
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
|
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
|
||||||
|
void setRewindBufferingMs(int _rewindBufferingMs);
|
||||||
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);
|
||||||
void setChatMentionForeground(QT_STATE_CHANGED_T _chatMentionForeground);
|
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::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void SettingsCache::setRewindBufferingMs(int /* _rewindBufferingMs */)
|
||||||
|
{
|
||||||
|
}
|
||||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
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::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void SettingsCache::setRewindBufferingMs(int /* _rewindBufferingMs */)
|
||||||
|
{
|
||||||
|
}
|
||||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue