Previous | Tutorial | Next: Complete theme example
Goal: Show scores, judgement counts and graphs for a completed chart or course, with working Continue and Retry controls.
Install docs/examples/theme-tutorial/08-results/ and choose it for Result and Course Result. Each screen has its own QML file and can be selected separately.
Download 08-results or open the source folder.
{
"$schema": "https://raw.githubusercontent.com/Bobini1/RhythmGame/master/schemas/theme.json",
"scripts": {
"result": "Result.qml",
"courseResult": "CourseResult.qml"
}
}
Read a completed chart
Result.qml receives a ResultContext for one completed chart, including a course stage. Its chartData and stage fields stay fixed when gameplay advances to the next stage. The game owns the context and its scores for the result screen's lifetime; the theme presents them without destroying them.
required property ResultContext result
result.players contains one or two participants. Each ResultPlayer pairs a profile with a saved BmsScore.
Repeater {
model: screen.result.players
ColumnLayout {
id: playerResult
required property int index
required property ResultPlayer modelData
Layout.fillWidth: true
ScoreLine {
Layout.fillWidth: true
playerLabel: playerResult.modelData.profile.vars.generalVars.name
score: playerResult.modelData.score
}
// [result-ranking]
StandardRanking {
id: playerRanking
chartData: screen.result.chartData
profile: playerResult.modelData.profile
score: playerResult.modelData.score
}
GridLayout {
id: rankingControls
Layout.fillWidth: true
columns: width < 400 ? 2 : 3
ComboBox {
model: [
{ value: OnlineRankingModel.RhythmGame, text: "RhythmGame" },
{ value: OnlineRankingModel.Tachi, text: "Bokutachi" },
{ value: OnlineRankingModel.LR2IR, text: "LR2IR" }
]
textRole: "text"
valueRole: "value"
currentValue: playerRanking.provider
onActivated: playerRanking.profile.vars.generalVars.rankingProvider = currentValue
Accessible.name: qsTr("Ranking provider")
}
Label {
Layout.fillWidth: true
elide: Text.ElideRight
text: playerRanking.loading ? qsTr("Loading ranking...")
: playerRanking.position > 0
? qsTr("Rank %1 of %2").arg(playerRanking.position)
.arg(playerRanking.playerCount)
: qsTr("No online rank")
}
Button {
Layout.columnSpan: rankingControls.columns === 2 ? 2 : 1
Layout.alignment: Qt.AlignRight
text: qsTr("Open ranking")
enabled: playerRanking.available && !playerRanking.opening
onClicked: playerRanking.open()
}
}
// [result-ranking]
// [result-stats]
ResultStats {
Layout.fillWidth: true
score: playerResult.modelData.score
timingWindows: screen.result.chartData.timingWindows
}
// [result-stats]
}
}
The score's result property holds totals such as points and clear type. The score also provides replay and gauge history. Its totals stay fixed, although its online submission state can still change.
Add Continue and Retry controls
Pass result to StandardResultInput. It accepts both chart and course results. It briefly delays confirmation after the screen opens, then handles the standard keys. The Continue button calls confirm() and uses the same delay.
StandardResultInput {
id: resultInput
result: screen.result
}
Button {
Layout.alignment: Qt.AlignRight
text: qsTr("Continue")
enabled: resultInput.acceptsInput && resultInput.confirmEnabled
onClicked: resultInput.confirm()
}
For supported single charts, keys 5 and 7 retry with fresh randomization and the same pattern respectively. The component gets the originating play from the result context. A course summary has no single-chart retry.
The Retry button calls retry(false); Same random calls retry(true). retryAvailable includes the input delay and the restrictions on courses, autoplay, replay, battle and Arena, so the theme doesn't repeat those checks.
RowLayout {
Button {
text: qsTr("Retry")
enabled: resultInput.retryAvailable
onClicked: resultInput.retry(false)
}
Button {
text: qsTr("Same random")
enabled: resultInput.retryAvailable
onClicked: resultInput.retry(true)
}
}
Show judgement counts
ResultStats.qml displays the judgement counts and both graphs for one player. The normal result and course summary pass their scores to the same component.
ResultStats {
Layout.fillWidth: true
score: playerResult.modelData.score
timingWindows: screen.result.chartData.timingWindows
}
Read the counts from score.result.judgementCounts, using a Judgement value as the index. The example chooses a label and color for each displayed judgement. PGREAT uses Judgement.Perfect. EMPTY POOR counts presses too far from a note, and MINE counts mines hit. Some events such as LnEndSkip (the end of a long note whose start was missed) can be skipped in most cases.
ColumnLayout {
Layout.fillWidth: true
Layout.preferredWidth: 1
Layout.alignment: Qt.AlignTop
Label { text: qsTr("Judgements"); font.bold: true }
Repeater {
model: [
{ judgement: Judgement.Perfect, text: qsTr("PGREAT"), color: "#9de6ff" },
{ judgement: Judgement.Great, text: qsTr("GREAT"), color: "#ffe28a" },
{ judgement: Judgement.Good, text: qsTr("GOOD"), color: "#a8dcc9" },
{ judgement: Judgement.Bad, text: qsTr("BAD"), color: "#ef9ad0" },
{ judgement: Judgement.Poor, text: qsTr("POOR"), color: "#ef7777" },
{ judgement: Judgement.EmptyPoor, text: qsTr("EMPTY POOR"), color: "#ef7777" },
{ judgement: Judgement.MineHit, text: qsTr("MINE"), color: "#ef7777" }
]
RowLayout {
id: judgementRow
required property var modelData
Layout.fillWidth: true
Label {
Layout.fillWidth: true
text: judgementRow.modelData.text
color: judgementRow.modelData.color
}
Label {
text: stats.score.result.judgementCounts[judgementRow.modelData.judgement] ?? 0
}
}
}
}
The totals come from the saved result, so they remain available when a score has no replay or gauge history. The graph components handle their own missing data.
Group hits by timing
HitDistribution.qml draws a histogram, which groups hits with similar timing into bars. Early hits appear on the left, and late hits appear on the right. The middle bar contains hits close to zero deviation. Taller bars contain more hits.
The graph reads score.replayData.hitEvents. It includes Perfect, Great, Good and Bad judgements. Poor and Empty Poor events don't measure a successful note hit, so the graph excludes them, along with mines and the special long-note events. The deviation value is in nanoseconds, and dividing it by one million gives milliseconds.
readonly property real timingLimit: {
const windows = distribution.timingWindows ?? [];
const outerWindow = windows.find(window => window.judgement === "Bad") ?? windows[0];
const limitNs = Number(outerWindow?.lateNs ?? 0);
return (limitNs > 0 ? limitNs : 200000000) / 1000000;
}
readonly property var histogram: {
const judgements = [Judgement.Perfect, Judgement.Great, Judgement.Good, Judgement.Bad];
const limit = distribution.timingLimit;
const step = limit / 20;
const counts = Array(41).fill(0);
let total = 0;
for (const hit of replayData?.hitEvents ?? []) {
if (!judgements.includes(hit.judgement)) continue;
const millis = hit.deviation / 1000000;
const index = Math.max(0, Math.min(counts.length - 1,
Math.round(millis / step) + 20));
counts[index]++;
total++;
}
return { counts: counts, limit: limit, step: step,
total: total, peak: Math.max(1, ...counts) };
}
The graph uses the Bad window from ChartData.timingWindows as its outer limit. Its 41 bars use fixed timing intervals: one centered on zero and 20 on each side. This gives every score for the same chart the same scale.
Rectangle {
id: plot
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: 160
color: "#18232e"
Repeater {
model: distribution.histogram.counts
Rectangle {
required property int index
required property int modelData
x: index * plot.width / 41
y: plot.height - height
width: Math.max(0, plot.width / 41 - 1)
height: modelData / distribution.histogram.peak * plot.height
color: index < 20 ? "#9de6ff" : index > 20 ? "#e8bc89" : "#ffffff"
}
}
Rectangle {
x: (plot.width - width) / 2
width: 1
height: plot.height
color: "#708090"
}
Label {
anchors.fill: parent
anchors.margins: 8
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
visible: distribution.histogram.total === 0
text: distribution.replayData ? qsTr("No replay data") : distribution.unavailableText
}
}
A missing replay shows "Replay data unavailable". A replay with no included hits shows "No replay data".
Draw gauge history
LifeGraph.qml reads score.gaugeHistory.gaugeInfo. Each entry describes one gauge, including its name, maximum value, clear threshold and history. The dropdown lets the player inspect each gauge. It starts with the gauge whose name matches the clear type, or the last gauge in the list if none matches.
readonly property var gauges: score.gaugeHistory?.gaugeInfo ?? []
readonly property var gauge: gauges[gaugeChoice.currentIndex] ?? null
readonly property var history: gauge?.gaugeHistory ?? []
readonly property real duration: Math.max(1, score.result.length,
history[history.length - 1]?.offsetFromStart ?? 0)
Label { text: qsTr("Life graph"); font.bold: true }
ComboBox {
id: gaugeChoice
Layout.fillWidth: true
model: life.gauges.map(gauge => gauge.name)
currentIndex: {
const matching = life.gauges.findIndex(gauge => gauge.name === life.score.result.clearType);
return matching >= 0 ? matching : life.gauges.length - 1;
}
enabled: count > 0
Accessible.name: qsTr("Gauge")
}
Each history entry records a gauge value and its offsetFromStart in nanoseconds. The value stays constant until the next change, so the graph uses horizontal segments followed by vertical steps. The time axis covers the score's recorded length and any later gauge change.
readonly property var lifePoints: {
if (history.length === 0 || !gauge || gauge.maxGauge <= 0) return [];
const points = [];
let previous = 1 - history[0].gauge / gauge.maxGauge;
points.push(Qt.point(0, previous));
for (const entry of history) {
const x = Math.max(0, entry.offsetFromStart / duration);
const y = 1 - entry.gauge / gauge.maxGauge;
points.push(Qt.point(x, previous), Qt.point(x, y));
previous = y;
}
points.push(Qt.point(1, previous));
return points;
}
The points use coordinates from zero to one. A Canvas scales them to its current size and repaints when the points or size change. A horizontal line marks the clear threshold. A score without gauge history shows "Gauge history unavailable".
Canvas {
id: curve
anchors.fill: parent
anchors.margins: 1
readonly property var lifePoints: life.lifePoints
onLifePointsChanged: requestPaint()
onWidthChanged: requestPaint()
onHeightChanged: requestPaint()
onPaint: {
const context = getContext("2d");
context.reset();
if (lifePoints.length === 0) return;
context.strokeStyle = "#a8dcc9";
context.lineWidth = 2;
context.beginPath();
context.moveTo(lifePoints[0].x * width, lifePoints[0].y * height);
for (const point of lifePoints)
context.lineTo(point.x * width, point.y * height);
context.stroke();
}
}
Keep the result usable in a small window
The statistics use three columns when there is enough width, and stack vertically in a narrow window. A ScrollView holds the player displays, so battle results can show both players without shrinking the graphs. Retry and Continue stay outside the scroll area.
Show each player's online rank
The result uses the same StandardRanking that the select controller supplies. Here, each player's display creates its own instance with the result's chart and that player's profile and score.
StandardRanking {
id: playerRanking
chartData: screen.result.chartData
profile: playerResult.modelData.profile
score: playerResult.modelData.score
}
GridLayout {
id: rankingControls
Layout.fillWidth: true
columns: width < 400 ? 2 : 3
ComboBox {
model: [
{ value: OnlineRankingModel.RhythmGame, text: "RhythmGame" },
{ value: OnlineRankingModel.Tachi, text: "Bokutachi" },
{ value: OnlineRankingModel.LR2IR, text: "LR2IR" }
]
textRole: "text"
valueRole: "value"
currentValue: playerRanking.provider
onActivated: playerRanking.profile.vars.generalVars.rankingProvider = currentValue
Accessible.name: qsTr("Ranking provider")
}
Label {
Layout.fillWidth: true
elide: Text.ElideRight
text: playerRanking.loading ? qsTr("Loading ranking...")
: playerRanking.position > 0
? qsTr("Rank %1 of %2").arg(playerRanking.position)
.arg(playerRanking.playerCount)
: qsTr("No online rank")
}
Button {
Layout.columnSpan: rankingControls.columns === 2 ? 2 : 1
Layout.alignment: Qt.AlignRight
text: qsTr("Open ranking")
enabled: playerRanking.available && !playerRanking.opening
onClicked: playerRanking.open()
}
}
The dropdown beside the rank shows the provider's name and lets the player choose RhythmGame, Bokutachi or LR2IR. Its currentValue follows playerRanking.provider, and onActivated saves the choice in that player's profile.vars.generalVars.rankingProvider. The component follows the saved choice and refreshes when the score's submission state changes.
The label shows the current position; Open ranking opens the provider's website. previousPosition compares the player's earlier best score against the current opponents. It is not a historical ranking.
Normal results for course stages can use a ranking. Course summaries omit it because the online services rank individual charts. Arena standings are separate from online rankings and use the overlay described below.
Read a completed course
CourseResult.qml receives a CourseResultContext. Its course describes the course, and charts contains chart metadata in stage order. Each player's BmsScoreCourse combines their stage scores. The combined hit graph uses the widest available Bad window from the course's stages, so it can show every included hit on one fixed scale.
required property CourseResultContext result
For a saved course result, a chart may have been removed from the library. result.charts[index] is then null, while result.course.chartIds[index] still identifies that stage. Look up that identifier with Rg.tables.search() for a table title, or display the identifier itself. Keep the stage in the list. The course's recorded stages and combined graph data are still available.
Repeater {
model: screen.result.course.chartIds
Label {
required property int index
required property string modelData
readonly property ChartData chart: screen.result.charts[index]
readonly property var tableEntry: chart ? null
: Rg.tables.search(modelData)[0]?.entry
Layout.fillWidth: true
text: (index + 1) + ". " + (chart?.title || tableEntry?.title || modelData)
wrapMode: Text.Wrap
}
}
Repeater {
model: screen.result.players
ColumnLayout {
id: playerResult
required property int index
required property CourseResultPlayer modelData
Layout.fillWidth: true
ScoreLine {
Layout.fillWidth: true
playerLabel: playerResult.modelData.profile.vars.generalVars.name
score: playerResult.modelData.score
}
ResultStats {
Layout.fillWidth: true
score: playerResult.modelData.score
timingWindows: screen.courseTimingWindows
}
}
}
Both score types provide the totals used by ScoreLine.qml and ResultStats.qml. A course score combines hit events and gauge history across its stages, so the same graphs work for both screens.
2import QtQuick.Controls.FluentWinUI3
9 required property string playerLabel
10 required property var score
13 Layout.fillWidth: true
14 text: line.playerLabel
19 Layout.fillWidth: true
20 text: qsTr("%1 / %2 points, %3")
21 .arg(line.score.result.points)
22 .arg(line.score.result.maxPoints)
23 .arg(line.score.result.clearType)
Include Arena standings
Add StandardArenaResultOverlay to show standings and chat for the completed Arena round. It stays hidden for local results. StandardResultInput disables confirmation while this result's chat is open, so Enter sends the message without closing the screen.
StandardArenaResultOverlay {
id: arenaOverlay
parent: screen
result: screen.result
}
The course summary does not need an Arena overlay.