This repository was archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.js
More file actions
462 lines (427 loc) · 13.3 KB
/
index.js
File metadata and controls
462 lines (427 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
453
454
455
456
457
458
459
460
461
462
const App = angular.module('App', ['720kb.tooltips']).run(($rootScope) => {
$rootScope.downloading = false
$rootScope.AppLoaded = true
$rootScope.ArmaPath = ''
$rootScope.slide = 0
$rootScope.theme = 'dark'
$rootScope.updating = false
$rootScope.update_ready = false
$rootScope.player_data = null
$rootScope.apiKey = ''
$rootScope.logged_in = false
$rootScope.logging_in = false
$rootScope.map = null
$rootScope.uploadingRPT = false
$rootScope.reloadClass = 'glyphicon glyphicon-refresh'
$rootScope.reloadDisabled = false
if (typeof process.env.PORTABLE_EXECUTABLE_DIR !== 'undefined') {
$rootScope.portable = true
$rootScope.store = false
$rootScope.AppTitle = 'RealLifeRPG Launcher - ' + app.getVersion() + ' Portable - Mods'
} else if (typeof process.windowsStore !== 'undefined') {
$rootScope.portable = false
$rootScope.store = true
$rootScope.AppTitle = 'RealLifeRPG Launcher - ' + app.getVersion() + ' Windows Store - Mods'
} else {
$rootScope.portable = false
$rootScope.store = false
$rootScope.AppTitle = 'RealLifeRPG Launcher - ' + app.getVersion() + ' - Mods'
}
storage.get('settings', (err, data) => {
if (err) {
$rootScope.theme = 'dark'
throw err
}
if (typeof data.theme !== 'undefined') {
$rootScope.theme = data.theme
}
})
/*
storage.get('agreement', (err, data) => {
if (err) {
ipcRenderer.send('open-agreement')
throw err
}
if (data.version !== config.PRIVACY_POLICY_VERSION) {
ipcRenderer.send('open-agreement')
}
})
*/
storage.get('player', (err, data) => {
if (err) throw err
if (typeof data.apikey !== 'undefined') {
$rootScope.apiKey = data.apikey
$rootScope.logging_in = true
helpers.getPlayerData($rootScope.apiKey)
} else {
storage.get('settings', (err, data) => {
if (err) throw err
$rootScope.ArmaPath = data.armapath
$rootScope.getMods()
})
}
})
$rootScope.relaunchUpdate = () => {
ipcRenderer.send('quitAndInstall')
}
$rootScope.refresh = (ui) => {
if (!$rootScope.reloadDisabled || !ui) {
storage.get('settings', (err) => {
if (err) throw err
$rootScope.getMods()
})
helpers.getServers()
helpers.getChangelog()
helpers.getTwitch()
if ($rootScope.logged_in) {
helpers.getPlayerData($rootScope.apiKey)
}
$rootScope.reloadClass = 'fa fa-spin fa-spinner'
$rootScope.reloadDisabled = true
setTimeout(() => {
$rootScope.reloadDisabled = false
$rootScope.reloadClass = 'glyphicon glyphicon-refresh'
$rootScope.$apply()
}, 3000)
}
}
$rootScope.login = () => {
alertify.set({labels: {ok: 'Ok', cancel: 'Abbrechen'}})
alertify.prompt('Bitte füge deinen Login-Schlüssel ein', (e, str) => {
if (e) {
if (str) {
$.ajax({
url: config.APIBaseURL + config.APIValidatePlayerURL + str,
type: 'GET',
success: (data) => {
if (data.status === 'Success') {
alertify.success('Willkommen ' + data.name)
storage.set('player', {apikey: str}, (err) => {
if (err) throw err
})
$rootScope.apiKey = str
$rootScope.logging_in = true
helpers.getPlayerData(str)
$rootScope.$apply()
} else {
$rootScope.login()
alertify.log('Falscher Schlüssel', 'danger')
$rootScope.login()
}
}
})
} else {
$rootScope.login()
}
}
}, '')
}
$rootScope.logout = () => {
storage.remove('player', (err) => {
if (err) throw err
})
$rootScope.ApiKey = ''
$rootScope.player_data = null
$rootScope.logged_in = false
storage.get('settings', (err) => {
if (err) throw err
$rootScope.getMods()
})
}
$rootScope.getMods = () => {
let url = config.APIBaseURL + config.APIModsURL
if ($rootScope.logged_in) {
url += '/' + $rootScope.apiKey
}
ipcRenderer.send('to-web', {
type: 'get-url',
callback: 'mod-callback',
url: url,
callBackTarget: 'to-app'
})
}
ipcRenderer.on('to-app', (event, args) => {
if (typeof args.args !== 'undefined') {
if (args.args.callback === 'player-callback') {
$rootScope.player_data = args.data.data[0]
$rootScope.player_data.last_seen.date = moment(new Date($rootScope.player_data.last_seen.date)).format('H:mm, DD.MM.YYYY')
$rootScope.player_data.cash_readable = $rootScope.player_data.cash.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.')
$rootScope.player_data.bankacc_readable = $rootScope.player_data.bankacc.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.')
$rootScope.player_data.exp_readable = $rootScope.player_data.exp.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.')
if ($rootScope.player_data.level !== 30) {
$rootScope.player_data.exp_progress = Math.round(($rootScope.player_data.exp - (($rootScope.player_data.level - 1) * ($rootScope.player_data.level - 1) * 1000)) / (($rootScope.player_data.level * $rootScope.player_data.level * 1000) - (($rootScope.player_data.level - 1) * ($rootScope.player_data.level - 1) * 1000)) * 100)
} else {
$rootScope.player_data.exp_progress = 100
}
$rootScope.logged_in = true
$rootScope.logging_in = false
storage.get('settings', (err, data) => {
if (err) throw err
$rootScope.ArmaPath = data.armapath
$rootScope.getMods()
})
$rootScope.$apply()
}
}
if (args.type === 'rpt_upload_callback') {
if (args.success) {
alertify.set({
labels: {
ok: 'Link kopieren <span class="glyphicon glyphicon-copy"></span>',
cancel: 'Abbrechen'
}
})
alertify.confirm('Hochladen erfolgreich, sende den Link dem Dev/Admin/Support', (e) => {
if (e) {
helpers.copyToClipboard(args.url)
alertify.log('Kopiert', 'success')
$rootScope.uploadingRPT = false
$rootScope.$apply()
} else {
alertify.log('Abgebrochen', 'danger')
$rootScope.uploadingRPT = false
$rootScope.$apply()
}
})
} else {
alertify.log('Fehler', 'danger')
$rootScope.uploadingRPT = false
$rootScope.$apply()
}
}
})
ipcRenderer.on('checking-for-update', () => {
alertify.log('Suche nach Updates...', 'primary')
$rootScope.updating = true
$rootScope.$apply()
})
ipcRenderer.on('update-not-available', () => {
alertify.log('Launcher ist aktuell', 'primary')
$rootScope.updating = false
$rootScope.$apply()
})
ipcRenderer.on('update-available', () => {
helpers.spawnNotification('Update verfügbar, wird geladen...')
alertify.log('Update verfügbar, wird geladen...', 'primary')
$rootScope.updating = true
$rootScope.$apply()
})
ipcRenderer.on('update-downloaded', (event, args) => {
helpers.spawnNotification('Update zur Version ' + args.releaseName + ' bereit.')
$rootScope.updating = false
$rootScope.update_ready = true
$rootScope.$apply()
})
$rootScope.$on('ngRepeatFinished', () => {
$rootScope.tour = new Shepherd.Tour({
defaults: {
classes: 'shepherd-theme-square-dark'
}
})
$rootScope.tour.addStep('start', {
title: 'Willkommen',
text: 'Hallo! Du hast dir gerade unseren Launcher geladen, wir wollen dich auf eine kleine Tour einladen um dich mit ihm vetraut zu machen.',
buttons: [{
text: 'Nein Danke',
classes: 'shepherd-button-secondary',
action: $rootScope.endTour
}, {
text: 'Weiter',
action: $rootScope.tour.next
}]
})
$rootScope.tour.addStep('mods', {
title: 'Mods',
text: 'Hier kannst du unsere Mods downloaden und prüfen, sowie das Spiel starten.',
attachTo: '.modsTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 0
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('servers', {
title: 'Server',
text: 'Hier findest du alle unsere Server und Informationen zu ihnen, auch kannst du von diesem Tab direkt auf einen Server joinen.',
attachTo: '.serversTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 1
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('player', {
title: 'Spieler',
text: 'Nachdem du dich eingeloggt hast, findest du hier deine Spielerdaten.',
attachTo: '.playerTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 2
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('changelog', {
title: 'Changelog',
text: 'Hier findest du immer alle Änderungen an der Mission, der Map und den Mods.',
attachTo: '.changelogTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 3
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('tfar', {
title: 'Task Force Radio',
text: 'Hier kannst du das Task Force Radio Plugin für deinen Teamspeak 3 Client installieren, sowie einen Skin, der im ReallifeRPG Stil gehalten ist.',
attachTo: '.tfarTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 4
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('settings', {
title: 'Einstellungen',
text: 'Hier findest du Einstellungen wie den Arma 3 Pfad, CPU Anzahl, Theme des Launchers und vieles mehr.',
attachTo: '.settingsTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 5
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('faq', {
title: 'FAQ',
text: 'Hier werden viele oft gestellte Fragen direkt beantwortet. Schau kurz mal hier nach, bevor du dich im Support meldest - vielleicht wird deine Frage ja direkt beantwortet.',
attachTo: '.faqTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 6
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('Twitch', {
title: 'Über',
text: 'Hier findest du immer Streamer, die gerade auf unserem Server spielen.',
attachTo: '.twitchTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 7
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('map', {
title: 'Karte',
text: 'Hier findest du eine Karte von Havenborn auf der du dir den Füllstand aller Tankstellen anzeigen lassen kannst.',
attachTo: '.mapTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 8
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('about', {
title: 'Über',
text: 'Hier kannst du allgemeine Informationen zum Launcher finden.',
attachTo: '.aboutTabBtn bottom',
buttons: {
text: 'Weiter',
action: $rootScope.tour.next
},
when: {
show: () => {
$rootScope.slide = 9
$rootScope.$apply()
}
}
})
$rootScope.tour.addStep('end', {
title: 'Viel Spaß!',
text: 'Genug gelesen, lad dir unseren Mod runter, installier Task Force Radio, betritt den Server und entdecke deine ganz eigene Weise, auf ReallifeRPG zu spielen. Viel Spaß von unserem ganzen Team!',
buttons: {
text: 'Beenden',
action: $rootScope.endTour
},
when: {
show: () => {
$rootScope.slide = 0
$rootScope.$apply()
}
}
})
storage.get('tour', (err, data) => {
if (err) {
throw err
}
if (typeof data.tour === 'undefined' || data.tour === null) {
$rootScope.tour.start()
}
})
})
$rootScope.endTour = () => {
$rootScope.tour.cancel()
storage.set('tour', {tour: true}, (err) => {
if (err) throw err
})
}
})
App.directive('onFinishRender', ($timeout) => {
return {
restrict: 'A',
link: (scope, element, attr) => {
if (scope.$last === true) {
$timeout(() => {
scope.$emit(attr.onFinishRender)
helpers.appLoaded()
})
}
}
}
})
document.addEventListener('dragover', event => event.preventDefault())
document.addEventListener('drop', event => event.preventDefault())