forked from PlayingKarrde/switchOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.qml
337 lines (298 loc) · 9.81 KB
/
theme.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
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
// SwitchOS
import QtQuick 2.0
import SortFilterProxyModel 0.2
import QtMultimedia 5.9
import "qrc:/qmlutils" as PegasusUtils
import "utils.js" as Utils
import "layer_platform"
import "layer_grid"
import "layer_help"
import "layer_settings"
FocusScope
{
id: root
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.75)
property real helpbarheight: Math.round(screenheight * 0.1041) // Calculated manually based on mockup
// Load settings
property var settings: {
return {
bgTheme: api.memory.has("Theme") ? api.memory.get("Theme") : "Default",
currentUser: api.memory.has("Active User") ? api.memory.get("Active User") : "Hypertacos",
timeFormat: api.memory.has("Time Format") ? api.memory.get("Time Format") : "12hr",
batteryPercentSetting: api.memory.has("Display Battery Percentage") ? api.memory.get("Display Battery Percentage") : "No",
}
}
function modulo(a,n) {
return (a % n + n) % n;
}
function nextCollection () {
jumpToCollection(collectionIndex + 1);
}
function prevCollection() {
jumpToCollection(collectionIndex - 1);
}
function jumpToCollection(idx) {
api.memory.set('gameCollIndex' + collectionIndex, currentGameIndex); // save game index of current collection
collectionIndex = modulo(idx, api.collections.count); // new collection index
currentGameIndex = 0; // Jump to the top of the list each time collection is changed
}
function showSoftwareScreen()
{
/*platformScreen.visible = false;
softwareScreen.visible = true;*/
softwareScreen.focus = true;
toSoftware.play();
}
function showHomeScreen()
{
platformScreen.focus = true;
backSfx.play();
/*platformScreen.visible = true;
softwareScreen.visible = false;*/
//platformScreen.focus = true;
}
function showSettingsScreen()
{
settingsScreen.focus = true;
toSoftware.play();
/*platformScreen.visible = true;
softwareScreen.visible = false;*/
//platformScreen.focus = true;
}
function playGame()
{
root.state = "playgame"
launchSfx.play()
}
function launchGame()
{
api.allGames.get(currentGameIndex).launch();
}
// Theme settings
FontLoader { id: titleFont; source: "fonts/Nintendo_Switch_UI_Font.ttf" }
// Theme colors have actually been swapped. Wanted dark to be default but didn't wanna go modify every file
property var themeDark: {
return {
main: "#EBEBEB",
secondary: "#2D2D2D",
accent: "#10AEBE",
highlight: "white",
text: "#2C2C2C",
button: "white"
}
}
property var themeLight: {
return {
main: "#2D2D2D",
secondary: "#EBEBEB",
accent: "#10AEBE",
highlight: "black",
text: "white",
button: "#515151"
}
}
// Do this properly later
property var theme: {
return {
main: api.memory.get('themeBG') || themeLight.main,
secondary: api.memory.get('themeSecondary') || themeLight.secondary,
accent: api.memory.get('themeAccent') || themeLight.accent,
highlight: api.memory.get('themeHighlight') || themeLight.highlight,
text: api.memory.get('themeText') || themeLight.text,
button: api.memory.get('themeButton') || themeLight.button
}
}
// State settings
states: [
State {
name: "platformscreen"; when: platformScreen.focus == true
},
State {
name: "softwarescreen"; when: softwareScreen.focus == true
},
State {
name: "settingsscreen"; when: settingsScreen.focus == true
},
State {
name: "playgame";
}
]
transitions: [
Transition {
from: "platformscreen"; to: "softwarescreen"
SequentialAnimation {
PropertyAnimation { target: platformScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: platformScreen; property: "visible"; value: false }
PropertyAction { target: softwareScreen; property: "visible"; value: true }
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "platformscreen"; to: "settingsscreen"
SequentialAnimation {
PropertyAnimation { target: platformScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: platformScreen; property: "visible"; value: false }
PropertyAction { target: settingsScreen; property: "visible"; value: true }
PropertyAnimation { target: settingsScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "softwarescreen"; to: "platformscreen"
SequentialAnimation {
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: softwareScreen; property: "visible"; value: false }
PropertyAction { target: platformScreen; property: "visible"; value: true }
PropertyAnimation { target: platformScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
from: "settingsscreen"; to: "platformscreen"
SequentialAnimation {
PropertyAnimation { target: settingsScreen; property: "opacity"; to: 0; duration: 200}
PropertyAction { target: settingsScreen; property: "visible"; value: false }
PropertyAction { target: platformScreen; property: "visible"; value: true }
PropertyAnimation { target: platformScreen; property: "opacity"; to: 1; duration: 200}
}
},
Transition {
to: "playgame"
SequentialAnimation {
PropertyAnimation { target: softwareScreen; property: "opacity"; to: 0; duration: 200}
PauseAnimation { duration: 200 }
ScriptAction { script: launchGame() }
}
},
Transition {
from: ""; to: "platformscreen"
ParallelAnimation {
NumberAnimation { target: platformScreen; property: "scale"; from: 1.2; to: 1.0; duration: 200; easing.type: Easing.OutQuad }
NumberAnimation { target: platformScreen; property: "opacity"; from: 0; to: 1; duration: 200 }
}
}
]
// Background
Video {
id: background
anchors
{
left: parent.left; right: parent.right
top: parent.top; bottom: parent.bottom
}
source: "assets/themes/" + settings.bgTheme + "/bgv.mp4";
loops: MediaPlayer.Infinite
autoPlay: true
fillMode: VideoOutput.Stretch
flushMode: VideoOutput.LastFrame
}
Component.onCompleted: {
state: "platformscreen"
homeSfx.play()
bgmLoop.play()
}
// Platform screen
PlatformScreen
{
id: platformScreen
focus: true
anchors
{
left: parent.left; right: parent.right
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
}
}
// Settings screen
SettingsScreen {
id: settingsScreen
opacity: 0
visible: false
anchors
{
left: parent.left;// leftMargin: screenmargin
right: parent.right;// rightMargin: screenmargin
top: parent.top; bottom: helpBar.top
}
}
// 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: !platformScreen.focus
}
}
SoundEffect {
id: navSound
source: "assets/audio/move.wav"
volume: 1.0
}
SoundEffect {
id: toSoftware
source: "assets/audio/select.wav"
volume: 1.0
}
SoundEffect {
id: fillList
source: "assets/audio/Icons.wav"
volume: 1.0
}
SoundEffect {
id: backSfx
source: "assets/audio/back.wav"
volume: 1.0
}
SoundEffect {
id: launchSfx
source: "assets/audio/select.wav"
volume: 1.0
}
SoundEffect {
id: homeSfx
source: "assets/audio/startup.wav"
volume: 1.0
}
SoundEffect {
id: bgmLoop
source: "assets/themes/" + settings.bgTheme + "/bgmLoop.wav"; //change to .wav when finished
volume: 0.8
loops: SoundEffect.Infinite
}
}