mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 08:24:39 -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,16 +8,19 @@
|
|||
#define TABLEZONE_H
|
||||
|
||||
#include "../../game/zones/table_zone_logic.h"
|
||||
#include "../animated_item.h"
|
||||
#include "../board/abstract_card_item.h"
|
||||
#include "select_zone.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
/**
|
||||
* @brief TableZone is the grid based rect where CardItems may be placed.
|
||||
*
|
||||
* It is the main play zone and can be customized with background images.
|
||||
*/
|
||||
//! \todo Refactor methods to make more readable, extract logic to private methods (especially reorganizeCards()).
|
||||
class TableZone : public SelectZone
|
||||
class TableZone : public SelectZone, public IAnimatedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -121,6 +124,16 @@ public:
|
|||
*/
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
/**
|
||||
Flashes the table surface after a player loses life.
|
||||
|
||||
Wired up through the life counter so the battlefield glows when life drops.
|
||||
*/
|
||||
void triggerDamageShimmer();
|
||||
|
||||
/** @brief Decays the damage shimmer by one timer tick. */
|
||||
bool animationEvent() override;
|
||||
|
||||
/**
|
||||
Toggles the selected items as tapped.
|
||||
*/
|
||||
|
|
@ -185,6 +198,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static constexpr qreal shimmerDurationMs = 450.0;
|
||||
|
||||
QElapsedTimer shimmerClock;
|
||||
qreal damageShimmerAlpha = 0.0;
|
||||
|
||||
void paintZoneOutline(QPainter *painter);
|
||||
void paintLandDivider(QPainter *painter);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue