mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -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
|
|
@ -74,13 +74,32 @@ void PhaseButton::updateAnimation()
|
|||
if (!highlightable)
|
||||
return;
|
||||
|
||||
if (active) {
|
||||
if (++activeAnimationCounter >= 10)
|
||||
activeAnimationTimer->stop();
|
||||
// the counter ticks up to 10 when active and down to 0 when inactive
|
||||
if (active && activeAnimationCounter < 10) {
|
||||
++activeAnimationCounter;
|
||||
} else if (!active && activeAnimationCounter > 0) {
|
||||
--activeAnimationCounter;
|
||||
} 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();
|
||||
}
|
||||
|
||||
|
|
@ -249,6 +268,16 @@ void PhasesToolbar::phaseButtonClicked()
|
|||
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()
|
||||
{
|
||||
emit sendGameCommand(Command_NextTurn(), -1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue