RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2AnimationFrameState.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QObject>
6#include <QMetaObject>
7#include <QPointer>
8#include <QRectF>
9#include <QVariant>
10#include <QVector2D>
11#include <QVector4D>
12#include <QtQml/qqmlregistration.h>
13
14class Lr2SkinClock;
15
16class Lr2AnimationFrameState : public QObject {
17 Q_OBJECT
18 QML_ELEMENT
19 Q_PROPERTY(QObject* skinClock READ skinClock WRITE setSkinClock NOTIFY skinClockChanged)
20 Q_PROPERTY(int clockMode READ clockMode WRITE setClockMode NOTIFY clockModeChanged)
21 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
22 Q_PROPERTY(QVariant sourceData READ sourceData WRITE setSourceData NOTIFY sourceDataChanged)
23 Q_PROPERTY(int skinTime READ skinTime WRITE setSkinTime NOTIFY skinTimeChanged)
24 Q_PROPERTY(QVariant timers READ timers WRITE setTimers NOTIFY timersChanged)
25 Q_PROPERTY(int timerFire READ timerFire WRITE setTimerFire NOTIFY timerFireChanged)
26 Q_PROPERTY(int sourceTimeOffset READ sourceTimeOffset WRITE setSourceTimeOffset NOTIFY sourceTimeOffsetChanged)
27 Q_PROPERTY(int frameOverride READ frameOverride WRITE setFrameOverride NOTIFY frameOverrideChanged)
28 Q_PROPERTY(int frameGroupSize READ frameGroupSize WRITE setFrameGroupSize NOTIFY frameGroupSizeChanged)
29 Q_PROPERTY(int textureWidth READ textureWidth WRITE setTextureWidth NOTIFY textureWidthChanged)
30 Q_PROPERTY(int textureHeight READ textureHeight WRITE setTextureHeight NOTIFY textureHeightChanged)
31 Q_PROPERTY(QVector2D textureSize READ textureSize NOTIFY textureSizeChanged)
32 Q_PROPERTY(qreal sourceHeightRatio READ sourceHeightRatio WRITE
33 setSourceHeightRatio NOTIFY sourceHeightRatioChanged)
34 Q_PROPERTY(int frameIndex READ frameIndex NOTIFY frameIndexChanged)
35 Q_PROPERTY(QVector4D sourceRect READ sourceRect NOTIFY sourceRectChanged)
36 Q_PROPERTY(QRectF sourceClipRect READ sourceClipRect NOTIFY sourceClipRectChanged)
37 Q_PROPERTY(QVector4D effectiveSourceRect READ effectiveSourceRect NOTIFY
38 effectiveSourceRectChanged)
40 effectiveSourceClipRectChanged)
41 Q_PROPERTY(bool sourceRegionExceedsTextureBounds READ
42 sourceRegionExceedsTextureBounds NOTIFY
43 sourceRegionExceedsTextureBoundsChanged)
44
45public:
46 enum ClockMode {
47 ManualClock = 0,
48 RenderClock = 1,
49 SelectSourceClock = 2,
50 BarClock = 3,
51 GlobalClock = 4,
52 SelectLiveClock = 5,
53 SelectInfoClock = 6
54 };
55 Q_ENUM(ClockMode)
56
57 explicit Lr2AnimationFrameState(QObject* parent = nullptr);
58
59 QObject* skinClock() const;
60 void setSkinClock(QObject* clock);
61
62 int clockMode() const;
63 void setClockMode(int mode);
64
65 bool isEnabled() const;
66 void setEnabled(bool enabled);
67
68 QVariant sourceData() const;
69 void setSourceData(const QVariant& sourceData);
70
71 int skinTime() const;
72 void setSkinTime(int skinTime);
73
74 QVariant timers() const;
75 void setTimers(const QVariant& timers);
76
77 int timerFire() const;
78 void setTimerFire(int timerFire);
79
80 int sourceTimeOffset() const;
81 void setSourceTimeOffset(int offset);
82
83 int frameOverride() const;
84 void setFrameOverride(int frameOverride);
85
86 int frameGroupSize() const;
87 void setFrameGroupSize(int frameGroupSize);
88
89 int textureWidth() const;
90 void setTextureWidth(int textureWidth);
91
92 int textureHeight() const;
93 void setTextureHeight(int textureHeight);
94 QVector2D textureSize() const;
95
96 qreal sourceHeightRatio() const;
97 void setSourceHeightRatio(qreal ratio);
98
99 int frameIndex() const;
100 QVector4D sourceRect() const;
101 QRectF sourceClipRect() const;
102 QVector4D effectiveSourceRect() const;
103 QRectF effectiveSourceClipRect() const;
104 bool sourceRegionExceedsTextureBounds() const;
105
106signals:
107 void skinClockChanged();
108 void clockModeChanged();
109 void enabledChanged();
110 void sourceDataChanged();
111 void skinTimeChanged();
112 void timersChanged();
113 void timerFireChanged();
114 void sourceTimeOffsetChanged();
115 void frameOverrideChanged();
116 void frameGroupSizeChanged();
117 void textureWidthChanged();
118 void textureHeightChanged();
119 void textureSizeChanged();
120 void sourceHeightRatioChanged();
121 void frameIndexChanged();
122 void sourceRectChanged();
123 void sourceClipRectChanged();
124 void effectiveSourceRectChanged();
125 void effectiveSourceClipRectChanged();
126 void sourceRegionExceedsTextureBoundsChanged();
127
128private:
129 using Source = lr2skin::runtime::Source;
130
131 void rebuildSource();
132 void updateSourceRegionExceedsTextureBounds();
133 void updateEffectiveSourceRects();
134 void reconnectClock();
135 void updateSkinTimeFromClock();
136 void updateFrameIndex();
137 int clockSkinTime() const;
138 qreal effectiveTimerFire() const;
139 static int frameCount(const Source& source);
140 static QVector4D sourceRectFor(const Source& source, int frameIndex, int textureWidth, int textureHeight);
141 static QRectF sourceClipRectFor(const Source& source, int frameIndex);
142
143 bool m_enabled = true;
144 QPointer<Lr2SkinClock> m_skinClock;
145 QMetaObject::Connection m_clockConnection;
146 int m_clockMode = ManualClock;
147 QVariant m_sourceData;
148 Source m_source;
149 int m_skinTime = 0;
150 QVariant m_timers;
151 int m_timerFire = -2147483648;
152 int m_sourceTimeOffset = 0;
153 int m_frameOverride = -1;
154 int m_frameGroupSize = 1;
155 int m_textureWidth = 0;
156 int m_textureHeight = 0;
157 qreal m_sourceHeightRatio = 1.0;
158 int m_frameIndex = 0;
159 QVector4D m_sourceRect = QVector4D(0.0f, 0.0f, 1.0f, 1.0f);
160 QRectF m_sourceClipRect = QRectF(0.0, 0.0, 0.0, 0.0);
161 QVector4D m_effectiveSourceRect = QVector4D(0.0f, 0.0f, 1.0f, 1.0f);
162 QRectF m_effectiveSourceClipRect = QRectF(0.0, 0.0, 0.0, 0.0);
163 bool m_sourceRegionExceedsTextureBounds = false;
164};
ReplaySource source
Definition BeatorajaReplayImporter.cpp:71
Definition Lr2AnimationFrameState.h:16
QML_ELEMENTQObject * skinClock
Definition Lr2AnimationFrameState.h:19
QVector4D sourceRect
Definition Lr2AnimationFrameState.h:35
QRectF sourceClipRect
Definition Lr2AnimationFrameState.h:36
int clockMode
Definition Lr2AnimationFrameState.h:20
QVector4D effectiveSourceRect
Definition Lr2AnimationFrameState.h:38
int frameOverride
Definition Lr2AnimationFrameState.h:27
int textureWidth
Definition Lr2AnimationFrameState.h:29
bool enabled
Definition Lr2AnimationFrameState.h:21
int frameGroupSize
Definition Lr2AnimationFrameState.h:28
int timerFire
Definition Lr2AnimationFrameState.h:25
int skinTime
Definition Lr2AnimationFrameState.h:23
int sourceTimeOffset
Definition Lr2AnimationFrameState.h:26
QVector2D textureSize
Definition Lr2AnimationFrameState.h:31
int frameIndex
Definition Lr2AnimationFrameState.h:34
QVariant timers
Definition Lr2AnimationFrameState.h:24
qreal sourceHeightRatio
Definition Lr2AnimationFrameState.h:33
int textureHeight
Definition Lr2AnimationFrameState.h:30
QRectF effectiveSourceClipRect
Definition Lr2AnimationFrameState.h:40
QVariant sourceData
Definition Lr2AnimationFrameState.h:22
Definition Lr2SkinClock.h:7
Definition Lr2SkinRuntimeTypes.h:59