mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 09:35:08 -07:00
[Game] Animate life counter manipulation (#7100)
* Add animations toggles for the life counter and battlefield Per-effect toggles plus Enable/Disable-all buttons: a life-counter flash on loss and a crimson battlefield shimmer on damage. Took 24 seconds * Animate life changes with a counter flash and battlefield shimmer - Life loss/gain pulses the player life counter with a brief flash - The battlefield table zone shimmers crimson on damage - Respects the per-effect animation toggles Both effects drive their decay from GameScene's shared animation timer through the IAnimatedItem interface (QElapsedTimer based), instead of owning per-item QTimers. Took 8 minutes * Revert unintentional cherry picks Took 2 minutes * Lambda to re-use path calculation. Took 8 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
12a5b34e42
commit
9d26e07165
12 changed files with 196 additions and 12 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "../board/arrow_item.h"
|
||||
#include "../board/card_drag_item.h"
|
||||
#include "../board/card_item.h"
|
||||
#include "../game_scene.h"
|
||||
#include "../z_values.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
|
@ -47,6 +48,31 @@ void TableZone::updateBg()
|
|||
update();
|
||||
}
|
||||
|
||||
void TableZone::triggerDamageShimmer()
|
||||
{
|
||||
if (!SettingsCache::instance().userInterface().getBattlefieldFlashEnabled()) {
|
||||
damageShimmerAlpha = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
damageShimmerAlpha = 1.0;
|
||||
shimmerClock.start();
|
||||
if (scene()) {
|
||||
static_cast<GameScene *>(scene())->registerAnimationItem(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool TableZone::animationEvent()
|
||||
{
|
||||
damageShimmerAlpha = 1.0 - shimmerClock.elapsed() / shimmerDurationMs;
|
||||
if (damageShimmerAlpha <= 0.0) {
|
||||
damageShimmerAlpha = 0.0;
|
||||
return false;
|
||||
}
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
|
||||
QRectF TableZone::boundingRect() const
|
||||
{
|
||||
return QRectF(0, 0, width, height);
|
||||
|
|
@ -77,6 +103,13 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*opti
|
|||
painter->fillRect(boundingRect(), FADE_MASK);
|
||||
}
|
||||
|
||||
// Decaying crimson wash from taking damage.
|
||||
if (damageShimmerAlpha > 0.0) {
|
||||
QColor shimmerColor(239, 68, 68);
|
||||
shimmerColor.setAlphaF(0.22 * damageShimmerAlpha);
|
||||
painter->fillRect(boundingRect(), shimmerColor);
|
||||
}
|
||||
|
||||
paintLandDivider(painter);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue