-
Notifications
You must be signed in to change notification settings - Fork 2
/
Credits.qml
144 lines (125 loc) · 3.41 KB
/
Credits.qml
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import QtQuick 2.15
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.15
import Game 1.0 as Game
import "./ui"
Rectangle {
id: root
color: "black"
Game.Credits { id: credits }
CustomFlickable {
anchors.fill: parent
anchors.margins: 50
contentHeight: creditColumn.height
Timer {
running: !parent.flicking && !parent.dragging
repeat: true
interval: 75
onTriggered: parent.contentY = Math.min(parent.contentY + 1, parent.contentHeight - parent.height)
}
GridLayout {
id: creditColumn
anchors.horizontalCenter: parent.horizontalCenter
columns: 2
columnSpacing: 5
rowSpacing: 5
Item {
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.preferredHeight: root.height / 2
}
Repeater {
model: credits.categories
delegate: categoryComponent
}
}
}
Component {
id: categoryComponent
Repeater {
id: categoryRepeater
property string category: credits.categories[index]
model: credits.categoryCount(category) + 1
delegate: Repeater {
id: row
property QtObject person: credits.person(category, index - 1)
property bool hasArtwork: person && credits.categoryHasArtwork(category)
model: hasArtwork ? 2 : 1
delegate: Loader {
property string category: categoryRepeater.category
property QtObject person: row.person
Layout.columnSpan: row.hasArtwork ? 1 : 2
sourceComponent: {
if (person)
return index === 0 ? identityComponent : artworkComponent;
return titleComponent;
}
}
}
}
}
Component {
id: titleComponent
Text {
text: category
font.family: application.titleFont.name
font.pointSize: application.titleFont.bigSize
font.capitalization: Font.Capitalize
color: "orange"
Layout.alignment: Qt.AlignCenter
}
}
Component {
id: identityComponent
RowLayout {
AnimatedImage {
source: person.avatar
Layout.alignment: Qt.AlignTop
Layout.preferredWidth: 50
Layout.preferredHeight: 50
}
ColumnLayout {
Layout.columnSpan: person.assets.length ? 1 : 2
Label {
text: person.name
font.family: application.titleFont.name
font.pointSize: application.titleFont.tinySize
color: "white"
Layout.alignment: Qt.AlignLeft
}
TerminalToolButton {
iconName: "open"
text: "Homepage"
visible: person.url.length > 0
onClicked: Qt.openUrlExternally(person.url)
Layout.alignment: Qt.AlignLeft
}
Item {
Layout.preferredHeight: 20
Layout.preferredWidth: 20
}
}
}
}
Component {
id: artworkComponent
RowLayout {
Layout.alignment: Qt.AlignCenter
Repeater {
model: Math.min(3, person.assets.length)
delegate: Image {
source: person.assets[index]
Layout.preferredWidth: Math.min(150, sourceSize.width)
Layout.preferredHeight: width
fillMode: Image.PreserveAspectFit
}
}
}
}
MenuButton {
text: i18n.t("Back")
onClicked: application.popAllViews()
anchors.bottom: parent.bottom
anchors.right: parent.right
}
}