-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatsScreen.qml
More file actions
127 lines (110 loc) · 4.01 KB
/
Copy pathStatsScreen.qml
File metadata and controls
127 lines (110 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import QtQuick
import QtQuick.Controls
Item {
id:statsPage
signal backToMenu()
// Функція для форматування часу
function formatTime(s) {
if (s === 0) return "--:--"
let m = Math.floor(s / 60)
let sec = s % 60
return (m < 10 ? "0" : "") + m + ":" + (sec < 10 ? "0" : "") + sec
}
//Данні оновлюється при вході в статистику
StackView.onActivated: {
updateStats()
}
//Заголовок
Text {
text: "ТВОЯ СТАТИСТИКА"
font.pointSize: 30; font.bold: true
anchors.top: parent.top; anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
}
function updateStats() {
// Легко
easyBlock.vGames = gameLogic.getGamesWon(0)
easyBlock.vScore = gameLogic.getBestScore(0)
easyBlock.vTime = formatTime(gameLogic.getBestTime(0))
easyBlock.vTotal = gameLogic.getTotalScore(0)
// Нормально
normalBlock.vGames = gameLogic.getGamesWon(1)
normalBlock.vScore = gameLogic.getBestScore(1)
normalBlock.vTime = formatTime(gameLogic.getBestTime(1))
normalBlock.vTotal = gameLogic.getTotalScore(1)
// Складно
hardBlock.vGames = gameLogic.getGamesWon(2)
hardBlock.vScore = gameLogic.getBestScore(2)
hardBlock.vTime = formatTime(gameLogic.getBestTime(2))
hardBlock.vTotal = gameLogic.getTotalScore(2)
}
Column {
anchors.centerIn: parent
spacing: 40
// Легко
StatBlock {
id: easyBlock
title: "ЛЕГКИЙ РІВЕНЬ"; borderColor: "#27ae60"
}
StatBlock {
id: normalBlock
title: "НОРМАЛЬНИЙ РІВЕНЬ"; borderColor: "#f39c12"
}
StatBlock {
id: hardBlock
title: "СКЛАДНИЙ РІВЕНЬ"; borderColor: "#e74c3c"
}
Button {
text: "ОЧИСТИТИ СТАТИСТИКУ"
width: 250; height: 50
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
gameLogic.resetStats()
}
}
}
component StatBlock : Rectangle {
property string title: ""
property color borderColor: "grey"
property string vGames: "0"
property string vScore: "0"
property string vTime: "--:--"
property string vTotal: "0"
width: 650; height: 140; radius: 12
color: "#ffffff"; border.color: borderColor; border.width: 2
//Назва рівня
Text {
text: title; font.bold: true; font.pointSize: 14; color: borderColor
anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 12
}
Row {
anchors.centerIn: parent
anchors.verticalCenterOffset: 10
spacing: 50
// Кількість ігор та рекорд очок
Row {
spacing: 10
Column { spacing: 8; Text { text: "Ігор:" } Text { text: "Рекорд (очки):" } }
Column { spacing: 8
Text { text: vGames; font.bold: true }
Text { text: vScore; font.bold: true; color: "#27ae60" }
}
}
// Рекорд часу та загальний рахунок
Row {
spacing: 10
Column { spacing: 8; Text { text: "Рекорд (час):" } Text { text: "Загальний рахунок:" } }
Column { spacing: 8
Text { text: vTime; font.bold: true }
Text { text: vTotal; font.bold: true; color: "#2980b9" }
}
}
}
}
Button {
text: "← Меню"
width: 100; height: 50
anchors.left: parent.left; anchors.top: parent.top
anchors.margins: 20; onClicked: backToMenu()
}
}