@@ -79,7 +79,7 @@ library.initializeEvents = async function() {
79
79
}
80
80
81
81
const gameCheckInterval = setInterval ( async function ( ) {
82
- const settings = library . getSettings ( ) ;
82
+ const settings = await library . getSettings ( ) ;
83
83
library . checkProcess ( settings . game_exe ) ;
84
84
} , 500 ) ;
85
85
@@ -96,22 +96,24 @@ library.initializeVariables = function() {
96
96
97
97
library . getSettings = function ( ) {
98
98
library . initializeVariables ( ) ;
99
- const resourcePath = await resourceDir ( ) ;
100
- return {
101
- updates_api_url : "https://updates.example.com/" ,
102
- dashboard_api_url : "https://example.com/dashboard/api/" ,
103
- gdps_name : "GDPS" ,
104
- game_exe : "GDPS.exe" ,
105
-
106
- update_time : localStorage . update_time ,
107
- resource_path : resourcePath
108
- }
99
+ return new Promise ( async function ( r ) {
100
+ const resourcePath = await resourceDir ( ) ;
101
+ r ( {
102
+ updates_api_url : "https://updates.gcs.icu/" ,
103
+ dashboard_api_url : "https://api.gcs.icu/" ,
104
+ gdps_name : "GreenCatsServer" ,
105
+ game_exe : "GreenCatsServer.exe" ,
106
+
107
+ update_time : localStorage . update_time ,
108
+ resource_path : resourcePath
109
+ } ) ;
110
+ } ) ;
109
111
}
110
112
111
113
library . checkUpdates = async function ( ) {
112
114
if ( window . isCheckingUpdate ) return ;
113
115
await library . changeIsCheckingUpdateState ( true ) ;
114
- const settings = library . getSettings ( ) ;
116
+ const settings = await library . getSettings ( ) ;
115
117
if ( settings . update_time == 0 ) {
116
118
console . log ( 'You should install game ;)' ) ;
117
119
await library . changeIsCheckingUpdateState ( false ) ;
@@ -124,7 +126,7 @@ library.checkUpdates = async function() {
124
126
library . changePendingUpdateState ( false ) ;
125
127
return true ;
126
128
} else {
127
- library . sendNotification ( settings . foundUpdate . title , settings . foundUpdate . description ) ;
129
+ library . sendNotification ( strings . foundUpdate . title , strings . foundUpdate . description ) ;
128
130
console . log ( "Updates were found!" ) ;
129
131
window . new_updates = response ;
130
132
library . changeIsCheckingUpdateState ( false ) ;
@@ -142,7 +144,7 @@ library.installGame = async function() {
142
144
if ( window . isUpdatingGame ) return ;
143
145
library . changeUpdatingGameState ( true ) ;
144
146
library . changePendingUpdateState ( false ) ;
145
- const settings = library . getSettings ( ) ;
147
+ const settings = await library . getSettings ( ) ;
146
148
const lastUpdateTimestamp = await library . getLatestUpdateTimestamp ( ) ;
147
149
const configPath = await resolve ( await appCacheDir ( ) + "/temp.7z" ) ;
148
150
console . log ( 'Starting downloading game...' ) ;
@@ -153,7 +155,7 @@ library.installGame = async function() {
153
155
if ( stdout === null ) {
154
156
console . log ( 'Adding all files to SQL... (that means it also calculates MD5 checksum for all files)' ) ;
155
157
await library . addFolderToSQL ( settings . resource_path ) ;
156
- library . sendNotification ( settings . gameInstalled . title , settings . gameInstalled . description ) ;
158
+ library . sendNotification ( strings . gameInstalled . title , strings . gameInstalled . description ) ;
157
159
console . log ( 'Game successfully downloaded!' ) ;
158
160
library . changeUpdatingGameState ( false ) ;
159
161
library . cleanTemporaryFiles ( ) ;
@@ -181,7 +183,7 @@ library.installGame = async function() {
181
183
}
182
184
183
185
library . cleanTemporaryFiles = async function ( patchTimestamp = 0 ) {
184
- const settings = library . getSettings ( ) ;
186
+ const settings = await library . getSettings ( ) ;
185
187
const configPath = await appCacheDir ( ) ;
186
188
await remove ( configPath + "/temp.7z" ) . catch ( err => { console . log ( "Temporary game archive was not found. Nothing to delete!" ) ; } ) ;
187
189
if ( patchTimestamp != 0 ) {
@@ -224,7 +226,7 @@ library.openOrInstallGame = async function() {
224
226
if ( isGameRunning ) return ;
225
227
if ( isPendingUpdate ) return library . updateGame ( ) ;
226
228
clearInterval ( gameCheckInterval ) ;
227
- const settings = library . getSettings ( ) ;
229
+ const settings = await library . getSettings ( ) ;
228
230
await library . changeIsGameStartingState ( true ) ;
229
231
await open ( await join ( settings . resource_path , settings . game_exe ) ) . then ( res => {
230
232
library . changeIsGameStartingState ( false ) ;
@@ -240,7 +242,7 @@ library.openOrInstallGame = async function() {
240
242
241
243
library . updateGame = async function ( ) {
242
244
if ( window . isUpdatingGame ) return ;
243
- const settings = library . getSettings ( ) ;
245
+ const settings = await library . getSettings ( ) ;
244
246
if ( settings . update_time == 0 ) return library . installGame ( ) ;
245
247
library . changePendingUpdateState ( false ) ;
246
248
library . changeUpdatingGameState ( true ) ;
@@ -249,15 +251,15 @@ library.updateGame = async function() {
249
251
await library . patchGame ( new_updates [ i ] ) ;
250
252
}
251
253
const lastUpdateTimestamp = new_updates [ new_updates . length - 1 ] ;
252
- library . sendNotification ( settings . gameUpdated . title , settings . gameUpdated . description ) ;
254
+ library . sendNotification ( strings . gameUpdated . title , strings . gameUpdated . description ) ;
253
255
console . log ( 'Game successfully updated!' ) ;
254
256
library . changeUpdatingGameState ( false ) ;
255
257
library . cleanTemporaryFiles ( ) ;
256
258
localStorage . update_time = lastUpdateTimestamp ;
257
259
}
258
260
259
261
library . getLatestUpdateTimestamp = async function ( ) {
260
- const settings = library . getSettings ( ) ;
262
+ const settings = await library . getSettings ( ) ;
261
263
return new Promise ( r => {
262
264
fetch ( settings . updates_api_url + "lastUpdate" ) . then ( res => res . json ( ) ) . then ( response => {
263
265
r ( response . timestamp ) ;
@@ -269,7 +271,7 @@ library.getLatestUpdateTimestamp = async function() {
269
271
}
270
272
271
273
library . patchGame = async function ( patchTimestamp ) {
272
- const settings = library . getSettings ( ) ;
274
+ const settings = await library . getSettings ( ) ;
273
275
const patchArchivePath = await resolve ( await appCacheDir ( ) + "/patch_" + patchTimestamp + ".7z" ) ;
274
276
const patchFolderPath = await resolve ( await appCacheDir ( ) + "/patch_" + patchTimestamp ) ;
275
277
console . log ( 'Downloading patch ' + patchTimestamp + '...' ) ;
@@ -368,7 +370,7 @@ library.addFolderToSQL = async function(folder) {
368
370
}
369
371
370
372
library . addFilesToSQL = async function ( allFiles ) {
371
- const settings = library . getSettings ( ) ;
373
+ const settings = await library . getSettings ( ) ;
372
374
var i = 0 ;
373
375
for ( i = 0 ; i < allFiles . length ; i ++ ) {
374
376
const fileRelativePath = allFiles [ i ] ;
@@ -378,7 +380,7 @@ library.addFilesToSQL = async function(allFiles) {
378
380
}
379
381
380
382
library . addGameFoldersToSQL = async function ( allFolders ) {
381
- const settings = library . getSettings ( ) ;
383
+ const settings = await library . getSettings ( ) ;
382
384
var i = 0 ;
383
385
for ( i = 0 ; i < allFolders . length ; i ++ ) {
384
386
const folderRelativePath = allFolders [ i ] ;
@@ -393,7 +395,7 @@ library.removeFilesFromSQL = async function(allFiles) {
393
395
394
396
library . uninstallGame = async function ( ) {
395
397
if ( window . isUpdatingGame ) return ;
396
- const settings = library . getSettings ( ) ;
398
+ const settings = await library . getSettings ( ) ;
397
399
console . log ( 'Deleting game...' ) ;
398
400
library . changeUpdatingGameState ( true ) ;
399
401
const gameFiles = await db . select ( "SELECT file FROM files" ) ;
@@ -409,15 +411,15 @@ library.uninstallGame = async function() {
409
411
await db . execute ( "DELETE FROM files" ) ;
410
412
await db . execute ( "DELETE FROM folders" ) ;
411
413
localStorage . update_time = 0 ;
412
- library . sendNotification ( settings . gameDeleted . title , settings . gameDeleted . description ) ;
414
+ library . sendNotification ( strings . gameDeleted . title , strings . gameDeleted . description ) ;
413
415
console . log ( 'Game was successfully deleted! ...' ) ;
414
416
library . changePendingUpdateState ( true ) ;
415
417
library . changeUpdatingGameState ( false ) ;
416
418
library . checkUpdates ( ) ;
417
419
}
418
420
419
421
library . removeEmptyFolders = async function ( ) {
420
- const settings = library . getSettings ( ) ;
422
+ const settings = await library . getSettings ( ) ;
421
423
var i = game_folders . length - 1 ;
422
424
for ( i = game_folders . length - 1 ; i >= 0 ; i -- ) {
423
425
const folderPath = game_folders [ i ] ;
@@ -440,7 +442,7 @@ library.checkProcess = async function(process) {
440
442
441
443
library . verifyGameFilesIntegrity = async function ( ) {
442
444
if ( window . isUpdatingGame ) return ;
443
- const settings = library . getSettings ( ) ;
445
+ const settings = await library . getSettings ( ) ;
444
446
console . log ( "Verifying game files integrity..." ) ;
445
447
library . changeUpdatingGameState ( true ) ;
446
448
const gameFiles = await db . select ( "SELECT * FROM files" ) ;
@@ -468,7 +470,7 @@ library.verifyGameFilesIntegrity = async function() {
468
470
469
471
library . downloadSpecificFiles = async function ( downloadFiles ) {
470
472
return new Promise ( async function ( r ) {
471
- const settings = library . getSettings ( ) ;
473
+ const settings = await library . getSettings ( ) ;
472
474
console . log ( "Downloading some specific files..." ) ;
473
475
const downloadArchivePath = await resolve ( await appCacheDir ( ) + "/download.7z" ) ;
474
476
invoke ( 'download_archive' , { url : settings . updates_api_url + "files" , tempPath : downloadArchivePath , files : JSON . stringify ( { files : downloadFiles } ) } ) . then ( stdout => {
@@ -494,15 +496,15 @@ library.downloadSpecificFiles = async function(downloadFiles) {
494
496
495
497
library . getProfile = function ( accountID ) {
496
498
return new Promise ( async function ( r ) {
497
- const settings = library . getSettings ( ) ;
499
+ const settings = await library . getSettings ( ) ;
498
500
fetch ( settings . dashboard_api_url + "profile.php?accountID=" + accountID ) . then ( res => res . json ( ) ) . then ( response => {
499
501
r ( response ) ;
500
502
} ) ;
501
503
} ) ;
502
504
}
503
505
504
506
library . openGameFolder = async function ( ) {
505
- const settings = library . getSettings ( ) ;
507
+ const settings = await library . getSettings ( ) ;
506
508
open ( settings . resource_path ) ;
507
509
}
508
510
@@ -511,9 +513,9 @@ library.sendNotification = async function(title, body) {
511
513
sendNotification ( { title : title . toString ( ) , body : body . toString ( ) } ) ;
512
514
}
513
515
514
- library . checkIfPlayerIsLoggedIn = function ( ) {
516
+ library . checkIfPlayerIsLoggedIn = async function ( ) {
515
517
if ( ! localStorage . auth . length ) return false ;
516
- const settings = library . getSettings ( ) ;
518
+ const settings = await library . getSettings ( ) ;
517
519
fetch ( settings . dashboard_api_url + "login.php?auth=" + localStorage . auth ) . then ( r => r . json ( ) ) . then ( response => {
518
520
if ( ! response . success ) {
519
521
library . logout ( ) ;
0 commit comments