-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCollectionView.qml
More file actions
301 lines (241 loc) · 9.88 KB
/
CollectionView.qml
File metadata and controls
301 lines (241 loc) · 9.88 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQml.Models 2.10
import QtMultimedia 5.9
import "Lists"
import "utils.js" as Utils
FocusScope {
id: root
// Pull in our custom lists and define
ListAllGames { id: listNone; max: 0 }
ListAllGames { id: listAllGames; max: 15 }
ListFavorites { id: listFavorites; max: 15 }
ListLastPlayed { id: listLastPlayed; max: 15 }
ListTopGames { id: listTopGames; max: 15 }
property var gameData: (currentCollection != -1) ? api.collections.get(currentCollection).games.get(Math.floor(Math.random() * api.collections.get(currentCollection).games.count)) : api.allGames.get(Math.floor(Math.random() * api.allGames.count))
property alias menu: mainList
ObjectModel {
id: mainModel
Item {
id: featuredRecentGame
width: parent.width
height: vpx(350)
property bool selected: ListView.isCurrentItem && root.focus
Image {
id: gamebg
width: vpx(750)
height: vpx(750)
anchors {
right: parent.right; rightMargin: vpx(-75)
top: parent.top; topMargin: vpx(-275)
}
property var screenshotImage: (gameData && (gameData.collections.get(0).shortName === "retropie" || gameData.collections.get(0).shortName === "android")) ? gameData.assets.boxFront : (gameData.collections.get(0).shortName === "steam") ? Utils.fanArt(gameData) : gameData.assets.screenshots[0]
source: gameData.assets.screenshots[0] ? gameData.assets.screenshots[0] : ""//screenshotImage
fillMode: Image.PreserveAspectCrop
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
asynchronous: true
visible: false
}
// NOTE: Video Preview
Component {
id: videoPreviewWrapper
Video {
id: videocomponent
anchors.fill: parent
source: gameData.assets.videoList.length ? gameData.assets.videoList[0] : ""
fillMode: VideoOutput.PreserveAspectCrop
muted: true
loops: MediaPlayer.Infinite
autoPlay: true
//onPlaying: videocomponent.seek(5000)
}
}
Item {
id: videocontainer
anchors.fill: gamebg
// Video
Loader {
id: videoPreviewLoader
asynchronous: true
anchors { fill: parent }
sourceComponent: gameData.assets.videoList.length ? videoPreviewWrapper : undefined
}
visible: false
}
Image {
id: gamemask
anchors.fill: gamebg
visible: false
/*property string bgmask: {
if (currentCollection == -1) {
return "assets/images/bgmask.png";
} else {
var collectionName = Utils.processPlatformName(api.collections.get(currentCollection).shortName);
return "assets/images/logos/" + Utils.processPlatformName(api.collections.get(currentCollection).shortName) + ".svg"
}
}*/
source: "assets/images/bgmask.png"//bgmask
sourceSize: Qt.size(parent.width, parent.height)
fillMode: Image.PreserveAspectFit
}
OpacityMask {
property bool video: gameData.assets.videoList.length
anchors.fill: gamebg
source: video ? videocontainer : gamebg
maskSource: gamemask
opacity: video ? 0.4 : 0.2
}
/*Image {
id: favelogo
width: height
height: parent.height
anchors {
top: parent.top; topMargin: vpx(0)
right: parent.right; rightMargin: vpx(130)
}
property var logoImage: (gameData && gameData.collections.get(0).shortName === "retropie") ? gameData.assets.boxFront : (gameData.collections.get(0).shortName === "steam") ? Utils.logo(gameData) : gameData.assets.logo
source: gameData ? logoImage || "" : ""
sourceSize { width: vpx(350); height: vpx(350) }
fillMode: Image.PreserveAspectFit
asynchronous: true
smooth: true
}//*/
Text {
id: collectionName
text: gameData.collections.get(0).name//(gameData.playTime > 0) ? "Continue playing" : "Start playing"
font.pixelSize: vpx(24)
font.family: subtitleFont.name
anchors {
top: parent.top; topMargin: vpx(90)
left: parent.left;
}
color: theme.text
opacity: 0.7
}
Text {
id: gameName
text: gameData.title
font.pixelSize: vpx(40)
font.family: titleFont.name
color: theme.text
anchors {
top: collectionName.bottom; topMargin: vpx(-10)
left: parent.left;
}
}
Rectangle {
id: playButton
width: playIcon.width + playText.paintedWidth + vpx(56)
height: vpx(50)
radius: vpx(15)
anchors { top: gameName.bottom; topMargin: vpx(5)}
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop { position: 0.0; color: featuredRecentGame.selected ? "#f34225" : theme.secondary }
GradientStop { position: 1.0; color: featuredRecentGame.selected ? "#bb2960" : theme.secondary }
}
// Mouse/touch functionality
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { }
onExited: { }
onClicked: {
launchGame(gameData);
}
}
}
Item {
id: buttonContents
anchors {
verticalCenter: playButton.verticalCenter
left: playButton.left; leftMargin: vpx(25)
}
height: playIcon.height
Image {
id: playIcon
width: vpx(22)
height: width
fillMode: Image.PreserveAspectFit
sourceSize: Qt.size(playIcon.width, playIcon.height)
source: "assets/images/navigation/Play.png"
visible: false
}
ColorOverlay {
anchors.fill: playIcon
source: playIcon
color: darkMode && !featuredRecentGame.selected ? theme.main : "white"
}
Text {
id: playText
text: (gameData.playTime > 0) ? "Continue playing" : "Start playing"//"Play"
font.pixelSize: vpx(18)
font.family: bodyFont.name
font.bold: true
color: darkMode && !featuredRecentGame.selected ? theme.main : "white"
anchors {
left: playIcon.right; leftMargin: vpx(10)
top: parent.top
bottom: parent.bottom
}
verticalAlignment: Text.AlignVCenter
}
}
// List specific input
Keys.onPressed: {
// Accept
if (api.keys.isAccept(event) && !event.isAutoRepeat) {
event.accepted = true;
sfxAccept.play();
launchGame(gameData);
}
}
Keys.onLeftPressed: { sfxNav.play(); navigationMenu(); }
}
GameList {
id: recentList
property bool selected: ListView.isCurrentItem && root.focus
property var currentList
collectionData: listLastPlayed.games
height: vpx(285)
title: "Recent"
focus: selected
anchors { left: parent.left; right: parent.right }
}
GameList {
id: favouriteList
property bool selected: ListView.isCurrentItem && root.focus
property var currentList
collectionData: listFavorites.games
height: vpx(300)
title: "Favorites"
focus: selected
anchors { left: parent.left; right: parent.right }
}
GameList {
id: topList
property bool selected: ListView.isCurrentItem && root.focus
property var currentList
collectionData: listTopGames.games
height: vpx(300)
title: "Recommended"
focus: selected
anchors { left: parent.left; right: parent.right }
}
}
ListView {
id: mainList
anchors.fill: parent
anchors.margins: vpx(25)
model: mainModel
focus: true
preferredHighlightBegin: vpx(0)
preferredHighlightEnd: parent.height - vpx(60)
highlightRangeMode: ListView.ApplyRange
snapMode: ListView.SnapOneItem
highlightMoveDuration: 100
Keys.onUpPressed: { sfxNav.play(); decrementCurrentIndex() }
Keys.onDownPressed: { sfxNav.play(); incrementCurrentIndex() }
}
}