forked from PlayingKarrde/switchOS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme.qml
More file actions
452 lines (394 loc) · 13.3 KB
/
theme.qml
File metadata and controls
452 lines (394 loc) · 13.3 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
// skylineOS
import QtQuick 2.12
import QtQuick.Layouts 1.11
import SortFilterProxyModel 0.2
import QtMultimedia 5.9
import QtGraphicalEffects 1.12
import "qrc:/qmlutils" as PegasusUtils
import "utils.js" as Utils
import "layer_home"
import "layer_grid"
import "layer_settings"
import "layer_help"
import "Lists"
import "resources" as Resources
FocusScope
{
id: root
// Load settings
property var settings: {
return {
gameBackground: api.memory.has("Game Background") ? api.memory.get("Game Background") : "Screenshot",
timeFormat: api.memory.has("Time Format") ? api.memory.get("Time Format") : "12hr",
wordWrap: api.memory.has("Word Wrap on Titles") ? api.memory.get("Word Wrap on Titles") : "Yes",
batteryPercentSetting: api.memory.has("Display Battery Percentage") ? api.memory.get("Display Battery Percentage") : "No",
enableDropShadows: api.memory.has("Enable DropShadows") ? api.memory.get("Enable DropShadows") : "Yes",
playBGM: api.memory.has("Background Music") ? api.memory.get("Background Music"): "No"
}
}
// number of games that appear on the homescreen, not including the All Software button
property int softCount: 12
ListLastPlayed { id: listRecent; max: softCount}
ListLastPlayed { id: listByLastPlayed}
ListMostPlayed { id: listByMostPlayed}
ListPublisher { id: listByPublisher}
ListFavorites { id: listFavorites}
ListAllGames { id: listByTitle}
Resources.Music { id: music}
property int currentCollection: api.memory.has('Last Collection') ? api.memory.get('Last Collection') : -1
property int nextCollection: api.memory.has('Last Collection') ? api.memory.get('Last Collection') : -1
property var currentGame
property var softwareList: [listByLastPlayed, listByMostPlayed, listByTitle, listByPublisher, listFavorites]
property int sortByIndex: api.memory.has('sortIndex') ? api.memory.get('sortIndex') : 0
property string searchtext
property bool wordWrap: (settings.wordWrap === "Yes") ? true : false;
property bool showPercent: (settings.batteryPercentSetting === "Yes") ? true : false;
property bool enableDropShadows: (settings.enableDropShadows === "Yes") ? true: false;
property bool playBGM: (settings.playBGM === "Yes") ? true : false;
onNextCollectionChanged: { changeCollection() }
function changeCollection() {
if (nextCollection != currentCollection) {
currentCollection = nextCollection;
searchtext = ""
//gameGrid.currentIndex = 0;
}
}
property int collectionIndex: 0
property int currentGameIndex: 0
property int screenmargin: vpx(30)
property real screenwidth: width
property real screenheight: height
property bool widescreen: ((height/width) < 0.7)
property real helpbarheight: Math.round(screenheight * 0.1041) // Calculated manually based on mockup
property bool darkThemeActive
function showSoftwareScreen()
{
/*homeScreen.visible = false;
softwareScreen.visible = true;*/
softwareScreen.focus = true;
toSoftware.play();
}
function showSettingsScreen()
{
settingsScreen.focus = true;
settingsSfx.play();
}
function showHomeScreen()
{
homeScreen.focus = true;
currentCollection = -1
homeSfx.play()
}
function playGame()
{
root.state = "playgame"
launchSfx.play()
}
function playSoftware()
{
root.state = "playsoftware"
launchSfx.play()
}
// Launch the current game from HomeBar
function launchGame(game) {
api.memory.set('Last Collection', currentCollection);
if (game != null)
game.launch();
else
currentGame.launch();
}
// Launch current game from SoftwareScreen
function launchSoftware() {
api.memory.set('Last Collection', currentCollection);
softwareList[sortByIndex].currentGame(currentGameIndex).launch();
//currentGame.launch();
}
// Preference order for Game Backgrounds, tiles always come first due to assumption that it's set manually
function getGameBackground(gameData, preference){
switch (preference) {
case "Screenshot":
return gameData ? gameData.assets.tile || gameData.assets.screenshots[0] || gameData.assets.background || gameData.assets.boxFront || "" : "";
case "Fanart":
return gameData ? gameData.assets.tile || gameData.assets.background || gameData.assets.screenshots[0] || gameData.assets.boxFront || "" : "";
case "Boxart":
return gameData ? gameData.assets.tile || gameData.assets.boxFront || gameData.assets.screenshots[0] || gameData.assets.background || "" : "";
default:
return ""
}
}
// Theme settings
FontLoader { id: titleFont; source: "assets/fonts/Nintendo_Switch_UI_Font.ttf" }
property var themeLight: {
return {
main: "#EBEBEB",
secondary: "#2D2D2D",
accent: "#10AEBE",
highlight: "white",
text: "#2C2C2C",
button: "white",
icon: "#7e7e7e",
press: "#7Fc0f0f3"
}
}
property var themeDark: {
return {
main: "#2D2D2D",
secondary: "#EBEBEB",
accent: "#1d9bf3",
highlight: "black",
text: "white",
button: "#515151",
icon: "white",
press: "#591d9bf3"
}
}
property var theme : api.memory.get('theme') === 'themeLight' ? themeLight : themeDark ;
function toggleDarkMode(){
if(theme === themeLight){
api.memory.set('theme', 'themeDark');
}else{
api.memory.set('theme', 'themeLight');
}
}
// State settings
states: [
State {
name: "homescreen"; when: homeScreen.focus == true
},
State {
name: "softwarescreen"; when: softwareScreen.focus == true
},
State {
name: "settingsscreen"; when: settingsScreen.focus == true
},
State {
name: "playgame";
},
State {
name: "playsoftware";
}
]
property int currentScreenID: -3
transitions: [
Transition {
from: "homescreen"; to: "softwarescreen"
SequentialAnimation {
PropertyAnimation { target: homeScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: homeScreen; property: "visible"; value: false }
PropertyAction { target: softwareScreen; property: "visible"; value: true }
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "homescreen"; to: "settingsscreen"
SequentialAnimation {
PropertyAnimation { target: homeScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: homeScreen; property: "visible"; value: false }
PropertyAction { target: settingsScreen; property: "visible"; value: true }
PropertyAnimation { target: settingsScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "softwarescreen"; to: "homescreen"
SequentialAnimation {
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: softwareScreen; property: "visible"; value: false }
PropertyAction { target: homeScreen; property: "visible"; value: true }
PropertyAnimation { target: homeScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "settingsscreen"; to: "homescreen"
SequentialAnimation {
PropertyAnimation { target: settingsScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: settingsScreen; property: "visible"; value: false }
PropertyAction { target: homeScreen; property: "visible"; value: true }
PropertyAnimation { target: homeScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
to: "playgame"
SequentialAnimation {
PropertyAnimation { target: homeScreen; property: "opacity"; to: 0; duration: 200}
PauseAnimation { duration: 200 }
ScriptAction { script: launchGame(currentGame) }
}
},
Transition {
to: "playsoftware"
SequentialAnimation {
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 0; duration: 200}
PauseAnimation { duration: 200 }
ScriptAction { script: launchSoftware() }
}
},
Transition {
from: ""; to: "homescreen"
ParallelAnimation {
NumberAnimation { target: homeScreen; property: "scale"; from: 1.2; to: 1.0; duration: 200; easing.type: Easing.OutQuad }
NumberAnimation { target: homeScreen; property: "opacity"; from: 0; to: 1; duration: 200 }
}
}
]
// Background
Rectangle {
id: background
anchors
{
left: parent.left; right: parent.right
top: parent.top; bottom: parent.bottom
}
color: theme.main
}
//starting collection is set here
Component.onCompleted: {
state: "homescreen"
currentCollection = -1
api.memory.unset('Last Collection');
homeSfx.play()
}
// Home screen
HomeScreen
{
id: homeScreen
focus: true
anchors
{
left: parent.left; right: parent.right
top: parent.top; bottom: helpBar.top
}
}
// List specific input
/*Keys.onPressed: {
// disabled
/*if (api.keys.isFilters(event) && !event.isAutoRepeat) {
event.accepted = true;
toggleDarkMode();
}
}*/
SettingsScreen {
id: settingsScreen
opacity: 0
visible: false
anchors
{
left: parent.left; leftMargin: screenmargin
right: parent.right; rightMargin: screenmargin
top: parent.top; bottom: helpBar.top
}
}
// All Software screen
SoftwareScreen {
id: softwareScreen
opacity: 0
visible: false
anchors
{
left: parent.left;// leftMargin: screenmargin
right: parent.right;// rightMargin: screenmargin
top: parent.top; bottom: helpBar.top
}
}
//Changes Sort Option
function cycleSort() {
selectSfx.play();
if (sortByIndex < softwareList.length - 1)
sortByIndex++;
else
sortByIndex = 0;
api.memory.set('sortIndex', sortByIndex)
}
// Help bar
Item
{
id: helpBar
anchors
{
left: parent.left; leftMargin: screenmargin
right: parent.right; rightMargin: screenmargin
bottom: parent.bottom
}
height: helpbarheight
Rectangle {
anchors.fill: parent
color: theme.main
}
Rectangle {
anchors.left: parent.left; anchors.right: parent.right
height: 1
color: theme.secondary
}
ControllerHelp {
id: controllerHelp
width: parent.width
height: parent.height
anchors {
bottom: parent.bottom;
}
showBack: !homeScreen.focus
showCollControls: softwareScreen.focus
showFav: softwareScreen.focus || homeScreen.focus
}
}
SoundEffect {
id: navSound
source: "assets/audio/Klick.wav"
volume: 1.0
}
SoundEffect {
id: toSoftware
source: "assets/audio/EnterBack.wav"
volume: 1.0
}
SoundEffect {
id: fillList
source: "assets/audio/Icons.wav"
volume: 1.0
}
SoundEffect {
id: backSfx
source: "assets/audio/Nock.wav"
volume: 1.0
}
SoundEffect {
id: launchSfx
source: "assets/audio/PopupRunTitle.wav"
volume: 1.0
}
SoundEffect {
id: homeSfx
source: "assets/audio/Home.wav"
volume: 1.0
}
SoundEffect {
id: turnOnSfx
source: "assets/audio/Turn On.wav"
volume: 1.0
}
SoundEffect {
id: turnOffSfx
source: "assets/audio/Turn Off.wav"
volume: 1.0
}
SoundEffect {
id: selectSfx
source: "assets/audio/This One.wav"
volume: 1.0
}
SoundEffect {
id: settingsSfx
source: "assets/audio/Settings.wav"
volume: 1.0
}
/* This sound effect is broken on RetroPie on Raspberry Pi 4. Reason unknown.
SoundEffect {
id: menuNavSfx
source: "assets/audio/Tick.wav"
volume: 1.0
}*/
SoundEffect {
id: borderSfx
source: "assets/audio/Border.wav"
volume: 0.25
}
}