RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2SelectDetailState.h
Go to the documentation of this file.
1#pragma once
2
3#include <QObject>
4#include <QAbstractListModel>
5#include <QHash>
6#include <QString>
7#include <QVariant>
8#include <QVariantList>
9#include <QtQml/qqmlregistration.h>
10
12 int play = 0;
13 int clear = 0;
14 int fail = 0;
15 int noplay = 0;
16 int assist = 0;
17 int easy = 0;
18 int normal = 0;
19 int hard = 0;
20 int exhard = 0;
21 int fc = 0;
22 int perfect = 0;
23 int max = 0;
24 int minBadPoor = 0;
25};
26
27class Lr2SelectScoreCounts : public QObject {
28 Q_OBJECT
29 Q_PROPERTY(int play READ play NOTIFY changed)
30 Q_PROPERTY(int clear READ clear NOTIFY changed)
31 Q_PROPERTY(int fail READ fail NOTIFY changed)
32 Q_PROPERTY(int noplay READ noplay NOTIFY changed)
33 Q_PROPERTY(int assist READ assist NOTIFY changed)
34 Q_PROPERTY(int easy READ easy NOTIFY changed)
35 Q_PROPERTY(int normal READ normal NOTIFY changed)
36 Q_PROPERTY(int hard READ hard NOTIFY changed)
37 Q_PROPERTY(int exhard READ exhard NOTIFY changed)
38 Q_PROPERTY(int fc READ fc NOTIFY changed)
39 Q_PROPERTY(int perfect READ perfect NOTIFY changed)
40 Q_PROPERTY(int max READ max NOTIFY changed)
41 Q_PROPERTY(int minBadPoor READ minBadPoor NOTIFY changed)
42
43public:
44 explicit Lr2SelectScoreCounts(QObject* parent = nullptr);
45
46 int play() const;
47 int clear() const;
48 int fail() const;
49 int noplay() const;
50 int assist() const;
51 int easy() const;
52 int normal() const;
53 int hard() const;
54 int exhard() const;
55 int fc() const;
56 int perfect() const;
57 int max() const;
58 int minBadPoor() const;
59
60 bool hasValues() const;
61 bool setValues(const Lr2SelectScoreCountsData& values);
62 void clearValues();
63
64signals:
65 void changed();
66
67private:
68 int m_play = 0;
69 int m_clear = 0;
70 int m_fail = 0;
71 int m_noplay = 0;
72 int m_assist = 0;
73 int m_easy = 0;
74 int m_normal = 0;
75 int m_hard = 0;
76 int m_exhard = 0;
77 int m_fc = 0;
78 int m_perfect = 0;
79 int m_max = 0;
80 int m_minBadPoor = 0;
81};
82
83Q_DECLARE_METATYPE(Lr2SelectScoreCounts*)
84
86 bool valid = false;
87 int pg = 0;
88 int gr = 0;
89 int gd = 0;
90 int bd = 0;
91 int poor = 0;
92 int miss = 0;
93 int pr = 0;
94 int totalJudgements = 1;
95 int comboBreak = 0;
96 int badPoor = 0;
97 int maxCombo = 0;
98 double score = 0.0;
99 double exscore = 0.0;
100 double maxPoints = 0.0;
101 QVariant early;
102 QVariant late;
103 int totalEarly = 0;
104 int totalLate = 0;
105
106 bool operator==(const Lr2SelectScoreStatsData& other) const;
107};
108
109class Lr2SelectScoreStats : public QObject {
110 Q_OBJECT
111 Q_PROPERTY(int pg READ pg NOTIFY changed)
112 Q_PROPERTY(int gr READ gr NOTIFY changed)
113 Q_PROPERTY(int gd READ gd NOTIFY changed)
114 Q_PROPERTY(int bd READ bd NOTIFY changed)
115 Q_PROPERTY(int poor READ poor NOTIFY changed)
116 Q_PROPERTY(int miss READ miss NOTIFY changed)
117 Q_PROPERTY(int pr READ pr NOTIFY changed)
118 Q_PROPERTY(int totalJudgements READ totalJudgements NOTIFY changed)
119 Q_PROPERTY(int comboBreak READ comboBreak NOTIFY changed)
120 Q_PROPERTY(int badPoor READ badPoor NOTIFY changed)
121 Q_PROPERTY(int maxCombo READ maxCombo NOTIFY changed)
122 Q_PROPERTY(double score READ score NOTIFY changed)
123 Q_PROPERTY(double exscore READ exscore NOTIFY changed)
124 Q_PROPERTY(double maxPoints READ maxPoints NOTIFY changed)
125 Q_PROPERTY(QVariant early READ early NOTIFY changed)
126 Q_PROPERTY(QVariant late READ late NOTIFY changed)
127 Q_PROPERTY(int totalEarly READ totalEarly NOTIFY changed)
128 Q_PROPERTY(int totalLate READ totalLate NOTIFY changed)
129
130public:
131 explicit Lr2SelectScoreStats(QObject* parent = nullptr);
132
133 bool hasValues() const;
134 int pg() const;
135 int gr() const;
136 int gd() const;
137 int bd() const;
138 int poor() const;
139 int miss() const;
140 int pr() const;
141 int totalJudgements() const;
142 int comboBreak() const;
143 int badPoor() const;
144 int maxCombo() const;
145 double score() const;
146 double exscore() const;
147 double maxPoints() const;
148 QVariant early() const;
149 QVariant late() const;
150 int totalEarly() const;
151 int totalLate() const;
152
153 const Lr2SelectScoreStatsData& values() const;
154 bool setValues(const Lr2SelectScoreStatsData& value);
155 void clearValues();
156
157signals:
158 void changed();
159
160private:
162};
163
164Q_DECLARE_METATYPE(Lr2SelectScoreStats*)
165
167 QVariant bestScore;
170 QString clearType = QStringLiteral("NOPLAY");
171 int lamp = 0;
172 int rank = 0;
173 double scoreRate = 0.0;
174 QVariantList optionIds;
175};
176
178 QString identifier;
179 int scoreGeneration = 0;
180
181 bool operator==(const Lr2SelectScoreSummaryCacheKey& other) const {
182 return identifier == other.identifier
183 && scoreGeneration == other.scoreGeneration;
184 }
185};
186
187inline size_t qHash(const Lr2SelectScoreSummaryCacheKey& key, size_t seed = 0) {
188 seed = qHash(key.identifier, seed);
189 return qHash(key.scoreGeneration, seed);
190}
191
192class Lr2SelectScoreSummary : public QObject {
193 Q_OBJECT
194 Q_PROPERTY(QVariant bestScore READ bestScore NOTIFY changed)
195 Q_PROPERTY(bool hasScore READ hasScore NOTIFY changed)
196 Q_PROPERTY(QObject* bestStats READ bestStatsObject NOTIFY changed)
197 Q_PROPERTY(QObject* scoreCounts READ scoreCountsObject NOTIFY changed)
198 Q_PROPERTY(QString clearType READ clearType NOTIFY changed)
199 Q_PROPERTY(int lamp READ lamp NOTIFY changed)
200 Q_PROPERTY(int rank READ rank NOTIFY changed)
201 Q_PROPERTY(double scoreRate READ scoreRate NOTIFY changed)
202 Q_PROPERTY(QVariant optionIds READ optionIds NOTIFY changed)
203
204public:
205 explicit Lr2SelectScoreSummary(QObject* parent = nullptr);
206
207 QVariant bestScore() const;
208 bool hasScore() const;
209 QObject* bestStatsObject() const;
210 Lr2SelectScoreStats* bestStatsStats() const;
211 QObject* scoreCountsObject() const;
212 Lr2SelectScoreCounts* scoreCounts() const;
213 QString clearType() const;
214 int lamp() const;
215 int rank() const;
216 double scoreRate() const;
217 QVariant optionIds() const;
218
219 bool setValues(const Lr2SelectScoreSummaryData& values);
220 void clearValues();
221
222signals:
223 void changed();
224
225private:
226 QVariant m_bestScore;
227 Lr2SelectScoreStats m_bestStats;
228 Lr2SelectScoreCounts m_scoreCounts;
229 QString m_clearType = QStringLiteral("NOPLAY");
230 int m_lamp = 0;
231 int m_rank = 0;
232 double m_scoreRate = 0.0;
233 QVariantList m_optionIds;
234};
235
236Q_DECLARE_METATYPE(Lr2SelectScoreSummary*)
237
238class Lr2SelectDifficultyModel : public QAbstractListModel {
239 Q_OBJECT
240 QML_ELEMENT
241
242public:
243 enum Role {
244 DifficultyRole = Qt::UserRole + 1,
248 };
249 Q_ENUM(Role)
250
251 explicit Lr2SelectDifficultyModel(QObject* parent = nullptr);
252
253 int rowCount(const QModelIndex& parent = {}) const override;
254 QVariant data(const QModelIndex& index, int role) const override;
255 QHash<int, QByteArray> roleNames() const override;
256
257 Q_INVOKABLE int countForDifficulty(int difficulty) const;
258 Q_INVOKABLE int playLevelForDifficulty(int difficulty) const;
259 Q_INVOKABLE int lampForDifficulty(int difficulty) const;
260 Q_INVOKABLE QVariantList optionIdsForKeymode(int keymode, bool includeLamps) const;
261
262 bool setRows(const QVariantList& counts,
263 const QVariantList& levels,
264 const QVariantList& lamps,
265 int selectedDifficulty = 0,
266 int selectedLamp = 0);
267
268private:
269 struct Row {
270 int difficulty = 0;
271 int count = 0;
272 int playLevel = 0;
273 int lamp = 0;
274
275 bool operator==(const Row& other) const;
276 };
277
278 bool setRows(QList<Row> nextRows);
279 const Row* rowForDifficulty(int difficulty) const;
280 static QList<Row> rowsFromValues(const QVariantList& counts,
281 const QVariantList& levels,
282 const QVariantList& lamps,
283 int selectedDifficulty,
284 int selectedLamp);
285 QList<Row> m_rows;
286};
287
288class Lr2SelectDetailState : public QObject {
289 Q_OBJECT
290 QML_ELEMENT
291 Q_PROPERTY(int scoreGeneration READ scoreGeneration WRITE setScoreGeneration NOTIFY scoreGenerationChanged)
292 Q_PROPERTY(int listGeneration READ listGeneration WRITE setListGeneration NOTIFY listGenerationChanged)
293 Q_PROPERTY(QVariant item READ item WRITE setItem NOTIFY itemChanged)
294 Q_PROPERTY(QVariant chartData READ chartData WRITE setChartData NOTIFY chartDataChanged)
295 Q_PROPERTY(QObject* summary READ summaryObject CONSTANT)
296 Q_PROPERTY(QObject* bestStats READ bestStatsObject NOTIFY bestStatsChanged)
297 Q_PROPERTY(QObject* scoreCounts READ scoreCountsObject CONSTANT)
298 Q_PROPERTY(QVariant scoreOptionIds READ scoreOptionIds WRITE setScoreOptionIds NOTIFY scoreOptionIdsChanged)
299 Q_PROPERTY(Lr2SelectDifficultyModel* difficultyModel READ difficultyModel CONSTANT)
300 Q_PROPERTY(int selectedItemRevision READ selectedItemRevision NOTIFY selectedItemRevisionChanged)
301 Q_PROPERTY(int selectedChartRevision READ selectedChartRevision NOTIFY selectedChartRevisionChanged)
302 Q_PROPERTY(int selectedScoreRevision READ selectedScoreRevision NOTIFY selectedScoreRevisionChanged)
303 Q_PROPERTY(int selectedDifficultyRevision READ selectedDifficultyRevision NOTIFY selectedDifficultyRevisionChanged)
304
305public:
306 explicit Lr2SelectDetailState(QObject* parent = nullptr);
307
308 int scoreGeneration() const;
309 void setScoreGeneration(int value);
310
311 int listGeneration() const;
312 void setListGeneration(int value);
313
314 QVariant item() const;
315 void setItem(const QVariant& value);
316
317 QVariant chartData() const;
318 void setChartData(const QVariant& value);
319
320 QObject* summaryObject() const;
321 Lr2SelectScoreSummary* summary() const;
322
323 QObject* bestStatsObject() const;
324
325 QObject* scoreCountsObject() const;
326 Lr2SelectScoreCounts* scoreCounts() const;
327
328 QVariant scoreOptionIds() const;
329 void setScoreOptionIds(const QVariant& value);
330
331 Lr2SelectDifficultyModel* difficultyModel();
332 int selectedItemRevision() const;
333 int selectedChartRevision() const;
334 int selectedScoreRevision() const;
335 int selectedDifficultyRevision() const;
336
337 Q_INVOKABLE bool selectedIdentityMatches(const QString& itemKey,
338 const QString& targetItemKey,
339 bool rankingMode,
340 int scoreGeneration,
341 int listGeneration,
342 bool useBeatorajaSemantics,
343 bool buildScoreOptionIds,
344 bool difficultyStateUsed,
345 bool difficultyLampStateUsed) const;
346 Q_INVOKABLE bool refreshSelectedFromVariantIdentityForIdentifier(const QString& itemKey,
347 const QString& targetItemKey,
348 bool rankingMode,
349 int scoreGeneration,
350 int listGeneration,
351 const QVariant& item,
352 const QVariant& chartData,
353 const QVariantList& scoreList,
354 const QString& scoreIdentifier,
355 int selectedDifficulty,
356 const QVariantList& difficultyCounts,
357 const QVariantList& difficultyLevels,
358 const QVariantList& difficultyLamps,
359 bool useBeatorajaSemantics,
360 bool buildScoreOptionIds,
361 bool difficultyStateUsed,
362 bool difficultyLampStateUsed);
363 Q_INVOKABLE QObject* cachedScoreSummaryForIdentifier(const QString& identifier,
364 int scoreGeneration,
365 const QVariantList& scoreList,
366 bool useBeatorajaSemantics,
367 bool buildScoreOptionIds);
368 Q_INVOKABLE bool hasCachedScoreSummaryForIdentifier(const QString& identifier,
369 int scoreGeneration,
370 bool useBeatorajaSemantics,
371 bool buildScoreOptionIds);
372 Q_INVOKABLE bool resolvesSelectedNumberValue(int num) const;
373 Q_INVOKABLE QVariant resolvedSelectedNumberValue(int num) const;
374 Q_INVOKABLE int selectedNumberValue(int num) const;
375 Q_INVOKABLE double selectedBarGraphValue(int type) const;
376 Q_INVOKABLE void clearScoreSummaryCache();
377 Q_INVOKABLE void clear();
378
379signals:
380 void scoreGenerationChanged();
381 void listGenerationChanged();
382 void itemChanged();
383 void chartDataChanged();
384 void summaryChanged();
385 void bestStatsChanged();
386 void scoreCountsChanged();
387 void scoreOptionIdsChanged();
388 void selectedItemRevisionChanged();
389 void selectedChartRevisionChanged();
390 void selectedScoreRevisionChanged();
391 void selectedDifficultyRevisionChanged();
392
393private:
394 bool selectedRefreshMatches(const QString& itemKey,
395 const QString& targetItemKey,
396 bool rankingMode,
397 int scoreGeneration,
398 int listGeneration,
399 bool useBeatorajaSemantics,
400 bool buildScoreOptionIds,
401 bool difficultyStateUsed,
402 bool difficultyLampStateUsed) const;
403 void rememberSelectedIdentity(const QString& itemKey,
404 const QString& targetItemKey,
405 bool rankingMode,
406 bool difficultyStateUsed,
407 bool difficultyLampStateUsed);
408 void clearSelectedIdentity();
409 bool applyRefreshData(int scoreGeneration,
410 int listGeneration,
411 const QVariant& item,
412 const QVariant& chartData,
413 bool useBeatorajaSemantics,
414 bool buildScoreOptionIds,
415 const Lr2SelectScoreSummaryData& scoreSummary,
416 bool& itemDidChange,
417 bool& chartDidChange,
418 bool& scoreDidChange);
419 const Lr2SelectScoreSummaryData& cachedScoreSummaryData(const Lr2SelectScoreSummaryCacheKey& cacheKey,
420 const QVariantList& scoreList,
421 bool useBeatorajaSemantics,
422 bool buildScoreOptionIds);
423 void ensureScoreSummaryCacheSemantics(bool useBeatorajaSemantics,
424 bool buildScoreOptionIds);
425 void advanceSelectedRevisions(bool itemDidChange,
426 bool chartDidChange,
427 bool scoreDidChange,
428 bool difficultyDidChange);
429
430 int m_scoreGeneration = -1;
431 int m_listGeneration = -1;
432 bool m_useBeatorajaSemantics = false;
433 bool m_buildScoreOptionIds = true;
434 bool m_selectedIdentityValid = false;
435 QString m_selectedItemKey;
436 QString m_selectedTargetItemKey;
437 bool m_selectedRankingMode = false;
438 bool m_selectedDifficultyStateUsed = true;
439 bool m_selectedDifficultyLampStateUsed = true;
440 QVariant m_item;
441 QVariant m_chartData;
442 Lr2SelectScoreSummary m_summary;
443 QVariant m_scoreOptionIds;
444 Lr2SelectDifficultyModel m_difficultyModel;
445 int m_selectedItemRevision = 0;
446 int m_selectedChartRevision = 0;
447 int m_selectedScoreRevision = 0;
448 int m_selectedDifficultyRevision = 0;
449 struct CachedScoreSummary {
451 Lr2SelectScoreSummary* object = nullptr;
452 };
453 QHash<Lr2SelectScoreSummaryCacheKey, CachedScoreSummary> m_scoreSummaryCache;
454 bool m_scoreSummaryCacheSemanticsInitialized = false;
455 bool m_scoreSummaryCacheUseBeatorajaSemantics = false;
456 bool m_scoreSummaryCacheBuildScoreOptionIds = true;
457};
Type type
Definition BmsNotesData.cpp:33
double value
Definition BmsNotesData.cpp:35
QString clearType
Definition ImportedScoreImporter.cpp:48
int keymode
Definition ImportedScoreImporter.cpp:40
int maxCombo
Definition ImportedScoreImporter.cpp:57
int poor
Definition ImportedScoreImporter.cpp:53
QByteArray data
Definition Lr2FontCache.cpp:25
size_t qHash(const Lr2SelectScoreSummaryCacheKey &key, size_t seed=0)
Definition Lr2SelectDetailState.h:187
int count
Definition Lr2SkinParser.cpp:1067
double maxPoints
Definition ScoreDb.cpp:71
bool hasScore
Definition ScoreDb.cpp:76
zip_uint64_t index
Definition SongAssetStore.cpp:436
Definition Lr2SelectDetailState.h:288
Definition Lr2SelectDetailState.h:238
Role
Definition Lr2SelectDetailState.h:243
@ PlayLevelRole
Definition Lr2SelectDetailState.h:246
@ LampRole
Definition Lr2SelectDetailState.h:247
@ CountRole
Definition Lr2SelectDetailState.h:245
Definition Lr2SelectDetailState.h:27
bool hasValues() const
Definition Lr2SelectDetailState.cpp:677
int fail
Definition Lr2SelectDetailState.h:31
int easy
Definition Lr2SelectDetailState.h:34
int exhard
Definition Lr2SelectDetailState.h:37
void clearValues()
Definition Lr2SelectDetailState.cpp:727
int perfect
Definition Lr2SelectDetailState.h:39
int minBadPoor
Definition Lr2SelectDetailState.h:41
int normal
Definition Lr2SelectDetailState.h:35
int play
Definition Lr2SelectDetailState.h:29
bool setValues(const Lr2SelectScoreCountsData &values)
Definition Lr2SelectDetailState.cpp:693
int noplay
Definition Lr2SelectDetailState.h:32
int assist
Definition Lr2SelectDetailState.h:33
int hard
Definition Lr2SelectDetailState.h:36
int clear
Definition Lr2SelectDetailState.h:30
int fc
Definition Lr2SelectDetailState.h:38
int max
Definition Lr2SelectDetailState.h:40
Definition Lr2SelectDetailState.h:109
Definition Lr2SelectDetailState.h:192
Definition Lr2SelectDetailState.h:11
int easy
Definition Lr2SelectDetailState.h:17
int minBadPoor
Definition Lr2SelectDetailState.h:24
int fc
Definition Lr2SelectDetailState.h:21
int perfect
Definition Lr2SelectDetailState.h:22
int normal
Definition Lr2SelectDetailState.h:18
int play
Definition Lr2SelectDetailState.h:12
int hard
Definition Lr2SelectDetailState.h:19
int assist
Definition Lr2SelectDetailState.h:16
int fail
Definition Lr2SelectDetailState.h:14
int noplay
Definition Lr2SelectDetailState.h:15
int max
Definition Lr2SelectDetailState.h:23
int exhard
Definition Lr2SelectDetailState.h:20
int clear
Definition Lr2SelectDetailState.h:13
Definition Lr2SelectDetailState.h:85
QVariant late
Definition Lr2SelectDetailState.h:102
QVariant early
Definition Lr2SelectDetailState.h:101
Definition Lr2SelectDetailState.h:177
bool operator==(const Lr2SelectScoreSummaryCacheKey &other) const
Definition Lr2SelectDetailState.h:181
QString identifier
Definition Lr2SelectDetailState.h:178
int scoreGeneration
Definition Lr2SelectDetailState.h:179
Definition Lr2SelectDetailState.h:166
QVariant bestScore
Definition Lr2SelectDetailState.h:167
QVariantList optionIds
Definition Lr2SelectDetailState.h:174
Lr2SelectScoreCountsData counts
Definition Lr2SelectDetailState.h:169
Lr2SelectScoreStatsData bestStats
Definition Lr2SelectDetailState.h:168