mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 08:24:39 -07:00
[Game] Animate Arrows (#7099)
* Add an arrow draw animation setting - New arrowDrawAnimation cards-display setting, default on - The arrow draw animation checkbox joins the animation settings group - Visual Deck Storage selection animation checkbox moves next to the other animation checkboxes, and the enable/disable-all buttons now cover it and the arrow animation Took 2 minutes Took 21 minutes Took 7 minutes Took 11 minutes Took 20 seconds * Animate arrows drawing from start to target - The arrow stroke reveals itself along the arc with an eased timing, followed by a short light sheen that sweeps down the shaft - The arrow head pops in once the reveal reaches it, then the whole arrow fades from its initial glow - Decay is driven by GameScene's shared animation timer through the IAnimatedItem interface (QElapsedTimer based), respecting the arrowDrawAnimation setting - GameScene adds the arrow item to the scene before starting its animation so the item is registered against a valid scene Took 6 minutes Took 1 minute * Defer animation start so arrows don't start halfway materialized Took 13 minutes * Don't draw tip/shaft outline Took 12 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
1eca89d75a
commit
404b0cdf28
9 changed files with 219 additions and 13 deletions
|
|
@ -2,9 +2,12 @@
|
|||
#define ARROWITEM_H
|
||||
|
||||
#include "../../game/board/arrow_data.h"
|
||||
#include "../animated_item.h"
|
||||
#include "arrow_target.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainterPath>
|
||||
#include <QPointer>
|
||||
#include <QSharedPointer>
|
||||
|
||||
|
|
@ -12,7 +15,7 @@ class CardItem;
|
|||
class QGraphicsSceneMouseEvent;
|
||||
class PlayerLogic;
|
||||
|
||||
class ArrowItem : public QObject, public QGraphicsItem
|
||||
class ArrowItem : public QObject, public QGraphicsItem, public IAnimatedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
|
|
@ -21,6 +24,19 @@ signals:
|
|||
|
||||
private:
|
||||
QPainterPath path;
|
||||
QPainterPath bodyPath;
|
||||
QPainterPath headPath;
|
||||
QPainterPath shaftOutlinePath;
|
||||
QPainterPath centerLine;
|
||||
qreal headBaseFraction = 1.0;
|
||||
QElapsedTimer animationClock;
|
||||
qreal strokeDurationMs = 0;
|
||||
qreal glowFadeDurationMs = 0;
|
||||
qreal drawProgress = 1.0;
|
||||
qreal glowAlpha = 0.0;
|
||||
bool animationStarted = false;
|
||||
|
||||
static constexpr qreal glowExtent = 12.0;
|
||||
|
||||
protected:
|
||||
QSharedPointer<const ArrowData> data;
|
||||
|
|
@ -33,16 +49,19 @@ protected:
|
|||
|
||||
public:
|
||||
ArrowItem(QSharedPointer<const ArrowData> _data, ArrowTarget *_startItem, ArrowTarget *_targetItem);
|
||||
~ArrowItem() override;
|
||||
|
||||
void onTargetDestroyed();
|
||||
void delArrow();
|
||||
void updatePath();
|
||||
void updatePath(const QPointF &endPoint);
|
||||
void startDrawAnimation();
|
||||
bool animationEvent() override;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
[[nodiscard]] QRectF boundingRect() const override
|
||||
{
|
||||
return path.boundingRect();
|
||||
return path.boundingRect().adjusted(-glowExtent, -glowExtent, glowExtent, glowExtent);
|
||||
}
|
||||
[[nodiscard]] QPainterPath shape() const override
|
||||
{
|
||||
|
|
@ -106,4 +125,4 @@ protected:
|
|||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue