mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
fix bug with phase highlighting in replays (#5161)
* fix bug with incorrectly highlighted phases * fix new bug with phases continuously darkening * use preincrement instead of postincrement * simplify conditional
This commit is contained in:
parent
0c4e8ca290
commit
6652012f4c
4 changed files with 51 additions and 6 deletions
|
|
@ -637,6 +637,19 @@ void TabGame::replayFastForwardButtonToggled(bool checked)
|
||||||
timelineWidget->setTimeScaleFactor(checked ? 10.0 : 1.0);
|
timelineWidget->setTimeScaleFactor(checked ? 10.0 : 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handles everything that needs to be reset when doing a replay rewind.
|
||||||
|
*/
|
||||||
|
void TabGame::replayRewind()
|
||||||
|
{
|
||||||
|
// reset chat log
|
||||||
|
messageLog->clearChat();
|
||||||
|
|
||||||
|
// reset phase markers
|
||||||
|
currentPhase = -1;
|
||||||
|
phasesToolbar->reset();
|
||||||
|
}
|
||||||
|
|
||||||
void TabGame::incrementGameTime()
|
void TabGame::incrementGameTime()
|
||||||
{
|
{
|
||||||
int seconds = ++secondsElapsed;
|
int seconds = ++secondsElapsed;
|
||||||
|
|
@ -1718,7 +1731,7 @@ void TabGame::createReplayDock()
|
||||||
timelineWidget->setTimeline(replayTimeline);
|
timelineWidget->setTimeline(replayTimeline);
|
||||||
connect(timelineWidget, SIGNAL(processNextEvent()), this, SLOT(replayNextEvent()));
|
connect(timelineWidget, SIGNAL(processNextEvent()), this, SLOT(replayNextEvent()));
|
||||||
connect(timelineWidget, SIGNAL(replayFinished()), this, SLOT(replayFinished()));
|
connect(timelineWidget, SIGNAL(replayFinished()), this, SLOT(replayFinished()));
|
||||||
connect(timelineWidget, &ReplayTimelineWidget::rewound, messageLog, &ChatView::clearChat);
|
connect(timelineWidget, &ReplayTimelineWidget::rewound, this, &TabGame::replayRewind);
|
||||||
|
|
||||||
// timeline skip shortcuts
|
// timeline skip shortcuts
|
||||||
aReplaySkipForward = new QAction(timelineWidget);
|
aReplaySkipForward = new QAction(timelineWidget);
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,7 @@ private slots:
|
||||||
void replayFinished();
|
void replayFinished();
|
||||||
void replayPlayButtonToggled(bool checked);
|
void replayPlayButtonToggled(bool checked);
|
||||||
void replayFastForwardButtonToggled(bool checked);
|
void replayFastForwardButtonToggled(bool checked);
|
||||||
|
void replayRewind();
|
||||||
|
|
||||||
void incrementGameTime();
|
void incrementGameTime();
|
||||||
void adminLockChanged(bool lock);
|
void adminLockChanged(bool lock);
|
||||||
|
|
|
||||||
|
|
@ -74,13 +74,32 @@ void PhaseButton::updateAnimation()
|
||||||
if (!highlightable)
|
if (!highlightable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (active) {
|
// the counter ticks up to 10 when active and down to 0 when inactive
|
||||||
if (++activeAnimationCounter >= 10)
|
if (active && activeAnimationCounter < 10) {
|
||||||
activeAnimationTimer->stop();
|
++activeAnimationCounter;
|
||||||
|
} else if (!active && activeAnimationCounter > 0) {
|
||||||
|
--activeAnimationCounter;
|
||||||
} else {
|
} else {
|
||||||
if (--activeAnimationCounter <= 0)
|
activeAnimationTimer->stop();
|
||||||
activeAnimationTimer->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Immediately resets the button to the inactive state, without going through the animation.
|
||||||
|
*/
|
||||||
|
void PhaseButton::reset()
|
||||||
|
{
|
||||||
|
activeAnimationTimer->stop();
|
||||||
|
active = false;
|
||||||
|
|
||||||
|
if (highlightable) {
|
||||||
|
activeAnimationCounter = 0;
|
||||||
|
} else {
|
||||||
|
activeAnimationCounter = 9;
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,6 +268,16 @@ void PhasesToolbar::phaseButtonClicked()
|
||||||
emit sendGameCommand(cmd, -1);
|
emit sendGameCommand(cmd, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Immediately resets the toolbar to its initial state, with all phases inactive.
|
||||||
|
*/
|
||||||
|
void PhasesToolbar::reset()
|
||||||
|
{
|
||||||
|
for (auto &i : buttonList) {
|
||||||
|
i->reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PhasesToolbar::actNextTurn()
|
void PhasesToolbar::actNextTurn()
|
||||||
{
|
{
|
||||||
emit sendGameCommand(Command_NextTurn(), -1);
|
emit sendGameCommand(Command_NextTurn(), -1);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ public:
|
||||||
{
|
{
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
void reset();
|
||||||
void triggerDoubleClickAction();
|
void triggerDoubleClickAction();
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
|
@ -85,6 +86,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void setActivePhase(int phase);
|
void setActivePhase(int phase);
|
||||||
void triggerPhaseAction(int phase);
|
void triggerPhaseAction(int phase);
|
||||||
|
void reset();
|
||||||
private slots:
|
private slots:
|
||||||
void phaseButtonClicked();
|
void phaseButtonClicked();
|
||||||
void actNextTurn();
|
void actNextTurn();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue