RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2SkinRuntime.h
Go to the documentation of this file.
1#pragma once
2
7#include "Lr2SkinTimerState.h"
8
9#include <QAbstractItemModel>
10#include <QHash>
11#include <QList>
12#include <QMetaObject>
13#include <QObject>
14#include <QPointer>
15#include <QSet>
16#include <QVariant>
17#include <QtQml/qqmlregistration.h>
18
19#include <array>
20
22
23class Lr2SkinRuntime : public QObject {
24 Q_OBJECT
25 QML_ELEMENT
26 Q_PROPERTY(QObject* skinModel READ skinModel WRITE setSkinModel NOTIFY skinModelChanged)
29 Q_PROPERTY(QString screenKey READ screenKey WRITE setScreenKey NOTIFY screenKeyChanged)
39
40public:
41 explicit Lr2SkinRuntime(QObject* parent = nullptr);
42
43 QObject* skinModel() const;
44 void setSkinModel(QObject* model);
45
46 QList<int> runtimeActiveOptions() const;
47 void setRuntimeActiveOptions(const QList<int>& value);
48
51
52 QString screenKey() const;
53 void setScreenKey(const QString& value);
54
55 bool gameplayScreen() const;
56 void setGameplayScreen(bool value);
57
58 qreal selectBarElementSortBase() const;
60
61 QVariantList elementDescriptors() const;
62 int descriptorRevision() const;
63 QVariantList elementTimerStates() const;
64 QVariantList noteDstTimerFires() const;
65 QVariantList lineDstTimerFires() const;
66
67 Q_INVOKABLE Lr2SkinElementDescriptorValue descriptor(int index) const;
68 Q_INVOKABLE QVariantList elementActiveOptionsForElement(int index) const;
71 Q_INVOKABLE Lr2TimelineStateValue stateForElement(int index, int skinTime) const;
72 Q_INVOKABLE Lr2TimelineStateValue sliderTrackStateForElement(int index, int skinTime) const;
73 Q_INVOKABLE Lr2TimelineStateValue noteDstState(int index, int skinTime) const;
74 Q_INVOKABLE Lr2TimelineStateValue lineDstState(int index, int skinTime) const;
75 Q_INVOKABLE Lr2TimelineStateValue noteDstStateForTimerFire(int index, int skinTime, int timerFire) const;
76 Q_INVOKABLE Lr2TimelineStateValue lineDstStateForTimerFire(int index, int skinTime, int timerFire) const;
77 Q_INVOKABLE bool noteDstStateUsesSkinTime(int index) const;
78 Q_INVOKABLE bool lineDstStateUsesSkinTime(int index) const;
79 Q_INVOKABLE int dstTimerFire(int index) const;
80 Q_INVOKABLE int srcTimerFire(int index) const;
81 Q_INVOKABLE bool dstTimerCanFire(int index) const;
82 Q_INVOKABLE bool srcTimerCanFire(int index) const;
83 Q_INVOKABLE QObject* elementTimerState(int index) const;
85 Q_INVOKABLE void refreshGameplayNumbers(int dirtyMask);
86 bool noteFieldUsesActiveOptions() const;
87 bool usesGameplayHitEvents() const;
88
89signals:
102
103private slots:
104 void rebuildDescriptors();
105 void updateTimerFires();
106 void updateGameplayTimerFires();
107 void updateSelectInfoTimerFires();
108
109private:
110 struct TimerSnapshot {
111 bool dstTimerCanFire = false;
112 bool srcTimerCanFire = false;
113 int dstTimerFire = -1;
114 int srcTimerFire = -1;
115 };
116
117 struct ElementDescriptor : public Lr2SkinElementDescriptorValue {
119 QVector<lr2skin::runtime::Dst> dsts;
121 bool elementActive = true;
122 QVariantList elementActiveOptions;
123 Lr2TimelineStateValue staticState;
124 TimerSnapshot timers;
125 };
126
127 struct LaneDescriptor {
128 QVector<lr2skin::runtime::Dst> dsts;
130 Lr2TimelineStateValue staticState;
131 };
132
133 QVariant modelData(int row, const char* roleName) const;
134 QVariantList modelListProperty(const char* name) const;
135 LaneDescriptor buildLaneDescriptor(const QVariant& dsts) const;
136 ElementDescriptor buildDescriptor(int index,
137 int type,
138 const QVariant& sourceValue,
139 const QVariantList& dstValues,
140 const QVariantList& noteDsts) const;
141 TimerSnapshot timerSnapshotFor(const ElementDescriptor& descriptor) const;
142 Lr2TimelineStateValue stateForLane(const QVector<LaneDescriptor>& lanes,
143 const QVariantList& timerFires,
144 int index,
145 int skinTime) const;
146 Lr2TimelineStateValue stateForLaneWithTimerFire(const QVector<LaneDescriptor>& lanes,
147 int index,
148 int skinTime,
149 int timerFire) const;
150 bool laneStateUsesSkinTime(const QVector<LaneDescriptor>& lanes, int index) const;
151 int laneTimerFire(const LaneDescriptor& lane) const;
152 QVariantList timerFiresForLanes(const QVector<LaneDescriptor>& lanes) const;
153 void updateNoteFieldTimerFires();
154 const ElementDescriptor* descriptorAt(int index) const;
155 void updateTimerFiresForIndexes(const QVector<int>& indexes);
156 void ensureElementTimerStateCount(int count);
157 void ensureElementNumberStateCount(int count);
158 void ensureElementActiveOptionsStateCount(int count);
159 void updateElementTimerState(int index, const TimerSnapshot& snapshot);
160 bool updateElementActiveOptionsState(int index, const QVariantList& activeOptions, bool active);
161 void updateSelectBarElementSortZ();
162 void resetElementTimerStates();
163 void resetElementNumberStates();
164 void resetElementActiveOptionsStates();
165 void reconnectSkinModel();
166 void reconnectTimerState();
167 void refreshActiveOptions(const QVector<int>& changedOptionIds = {});
168 void notifyElementDataChanged();
169
170 QPointer<QAbstractItemModel> m_skinModel;
171 QPointer<Lr2SkinTimerState> m_timerState;
172 QList<int> m_runtimeActiveOptions;
173 QSet<int> m_activeOptionSet;
174 QString m_screenKey;
175 bool m_gameplayScreen = false;
176 qreal m_selectBarElementSortBase = 0.0;
177 QVector<ElementDescriptor> m_descriptors;
178 int m_descriptorRevision = 0;
179 QVector<Lr2SkinElementTimerState*> m_elementTimerStates;
180 QVector<Lr2SkinElementNumberState*> m_elementNumberStates;
181 QVector<Lr2SkinElementActiveOptionsState*> m_elementActiveOptionsStates;
182 std::array<QVector<int>, 8> m_numberDescriptorIndexesByDependency;
183 QVector<int> m_numberRefreshIndexMarks;
184 int m_numberRefreshMark = 0;
185 QVector<int> m_activeOptionDescriptorIndexes;
186 QHash<int, QVector<int>> m_activeOptionDescriptorIndexesByOption;
187 QVector<int> m_activeOptionRefreshIndexMarks;
188 int m_activeOptionRefreshMark = 0;
189 QVector<int> m_timerDescriptorIndexes;
190 QVector<int> m_selectInfoTimerDescriptorIndexes;
191 QHash<int, QVector<int>> m_timerDescriptorIndexesByTimer;
192 QSet<int> m_noteFieldTimerIds;
193 QVector<LaneDescriptor> m_noteLaneDescriptors;
194 QVector<LaneDescriptor> m_lineLaneDescriptors;
195 QVariantList m_noteDstTimerFires;
196 QVariantList m_lineDstTimerFires;
197 bool m_noteFieldUsesActiveOptions = false;
198 bool m_usesGameplayHitEvents = false;
199 QList<QMetaObject::Connection> m_skinModelConnections;
200 QList<QMetaObject::Connection> m_timerStateConnections;
201};
ReplaySource source
Definition BeatorajaReplayImporter.cpp:71
Type type
Definition BmsNotesData.cpp:33
double value
Definition BmsNotesData.cpp:35
QMap< int, QVariantList > noteDsts
Definition Lr2SkinParser.cpp:130
std::set< int > activeOptions
Definition Lr2SkinParser.cpp:143
int count
Definition Lr2SkinParser.cpp:1067
zip_uint64_t index
Definition SongAssetStore.cpp:436
Definition Lr2SkinElementActiveOptionsState.h:8
Definition Lr2SkinElementDescriptorValue.h:7
Definition Lr2SkinElementNumberState.h:6
Definition Lr2SkinElementTimerState.h:5
Definition Lr2SkinRuntime.h:23
QList< int > runtimeActiveOptions
Definition Lr2SkinRuntime.h:27
Q_INVOKABLE void refreshGameplayNumbers(int dirtyMask)
Definition Lr2SkinRuntime.cpp:356
void elementTimerStatesChanged()
void runtimeActiveOptionsChanged()
Q_INVOKABLE bool noteDstStateUsesSkinTime(int index) const
Definition Lr2SkinRuntime.cpp:316
void setTimerState(Lr2SkinTimerState *value)
Definition Lr2SkinRuntime.cpp:157
void setSkinModel(QObject *model)
Definition Lr2SkinRuntime.cpp:112
void setGameplayScreen(bool value)
Definition Lr2SkinRuntime.cpp:184
QML_ELEMENTQObject * skinModel
Definition Lr2SkinRuntime.h:26
void gameplayScreenChanged()
void setScreenKey(const QString &value)
Definition Lr2SkinRuntime.cpp:171
void usesGameplayHitEventsChanged()
Q_INVOKABLE bool dstTimerCanFire(int index) const
Definition Lr2SkinRuntime.cpp:334
Q_INVOKABLE int srcTimerFire(int index) const
Definition Lr2SkinRuntime.cpp:329
bool noteFieldUsesActiveOptions
Definition Lr2SkinRuntime.h:37
Q_INVOKABLE Lr2TimelineStateValue noteDstStateForTimerFire(int index, int skinTime, int timerFire) const
Definition Lr2SkinRuntime.cpp:302
Q_INVOKABLE Lr2TimelineStateValue lineDstStateForTimerFire(int index, int skinTime, int timerFire) const
Definition Lr2SkinRuntime.cpp:309
Q_INVOKABLE QVariantList elementActiveOptionsForElement(int index) const
Definition Lr2SkinRuntime.cpp:246
Lr2SkinTimerState * timerState
Definition Lr2SkinRuntime.h:28
QVariantList lineDstTimerFires
Definition Lr2SkinRuntime.h:36
Q_INVOKABLE Lr2SkinElementActiveOptionsState * elementActiveOptionsState(int index) const
Definition Lr2SkinRuntime.cpp:251
bool gameplayScreen
Definition Lr2SkinRuntime.h:30
void elementDescriptorsChanged()
Q_INVOKABLE int dstTimerFire(int index) const
Definition Lr2SkinRuntime.cpp:324
void skinModelChanged()
Q_INVOKABLE bool srcTimerCanFire(int index) const
Definition Lr2SkinRuntime.cpp:339
void selectBarElementSortBaseChanged()
Q_INVOKABLE Lr2SkinElementNumberState * elementNumberState(int index) const
Definition Lr2SkinRuntime.cpp:350
void screenKeyChanged()
Q_INVOKABLE Lr2TimelineStateValue stateForElement(int index, int skinTime) const
Definition Lr2SkinRuntime.cpp:269
QString screenKey
Definition Lr2SkinRuntime.h:29
QVariantList noteDstTimerFires
Definition Lr2SkinRuntime.h:35
void timerStateChanged()
bool usesGameplayHitEvents
Definition Lr2SkinRuntime.h:38
Q_INVOKABLE Lr2TimelineStateValue noteDstState(int index, int skinTime) const
Definition Lr2SkinRuntime.cpp:294
Q_INVOKABLE Lr2TimelineStateValue staticStateForElement(int index) const
Definition Lr2SkinRuntime.cpp:257
Q_INVOKABLE Lr2SkinElementDescriptorValue descriptor(int index) const
Definition Lr2SkinRuntime.cpp:240
Q_INVOKABLE Lr2TimelineStateValue lineDstState(int index, int skinTime) const
Definition Lr2SkinRuntime.cpp:298
void setSelectBarElementSortBase(qreal value)
Definition Lr2SkinRuntime.cpp:197
void noteFieldUsesActiveOptionsChanged()
Q_INVOKABLE Lr2TimelineStateValue sliderTrackStateForElement(int index, int skinTime) const
Definition Lr2SkinRuntime.cpp:281
QVariantList elementTimerStates
Definition Lr2SkinRuntime.h:34
Q_INVOKABLE QObject * elementTimerState(int index) const
Definition Lr2SkinRuntime.cpp:344
void setRuntimeActiveOptions(const QList< int > &value)
Definition Lr2SkinRuntime.cpp:127
void lineDstTimerFiresChanged()
int descriptorRevision
Definition Lr2SkinRuntime.h:33
void noteDstTimerFiresChanged()
QVariantList elementDescriptors
Definition Lr2SkinRuntime.h:32
Q_INVOKABLE bool lineDstStateUsesSkinTime(int index) const
Definition Lr2SkinRuntime.cpp:320
qreal selectBarElementSortBase
Definition Lr2SkinRuntime.h:31
Definition Lr2SkinTimerState.h:17
Definition Lr2TimelineStateValue.h:8
Definition Lr2SkinRuntimeTypes.h:113
Definition Lr2SkinRuntimeTypes.h:59