Skip to content

Commit bc1c9a0

Browse files
committed
better loggin + fixed empty mods loading
1 parent e0ac406 commit bc1c9a0

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
88
### Changed
99
### Fixed
1010

11-
## [1.7.1, 1.7.2] 2020-09-23
11+
## [1.7.4] 2020-10-01
12+
### Added
13+
- Added a notification when CD path is saved.
14+
- Added some better console logging for better debugging.
15+
### Fixed
16+
- Empty mod folders are not loaded from workshop folder now (thanks OutBlast).
17+
18+
## [1.7.1, 1.7.2, 1.7.3] 2020-09-23
1219
Fixed build errors?
1320

1421
## [1.7.0] 2020-09-23

app/img/icon.png

76.3 KB
Loading

app/js/renderer.js

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ $('#cd-file-path').on('change', function() {
5353
else collectionConfig['CrashdayPath'] = p
5454

5555
SaveConfig()
56+
57+
$.toast({title: 'CD Path saved!',
58+
type: 'success', delay: 5000, container: $('#toaster')})
5659
})
5760

5861
LoadWorkshop()
@@ -133,10 +136,18 @@ function PrepareMissingModsModal(){
133136
Http.open('GET', url)
134137
Http.send()
135138

139+
console.groupCollapsed('Sent a request to Steam')
140+
console.log(url)
141+
console.groupEnd()
142+
136143
Http.onreadystatechange=function(){
137144
if(this.readyState==4 && this.status==200){
138145
var answer = JSON.parse(Http.responseText)['response']
139146

147+
console.groupCollapsed('Steam answer')
148+
console.log(answer)
149+
console.groupEnd()
150+
140151
$('#missing-mods-modal-list').html('')
141152
for(i in answer['publishedfiledetails']){
142153
$('#missing-mods-modal-list').append(
@@ -189,12 +200,18 @@ function LoadWorkshop(){
189200
Http.open('GET', url)
190201
Http.send()
191202

203+
console.groupCollapsed('Sent a request to Steam')
192204
console.log(url)
205+
console.groupEnd()
193206

194207
Http.onreadystatechange=function(){
195208
if(this.readyState==4 && this.status==200){
196209
steamAnswer = JSON.parse(Http.responseText)['response']
197210

211+
console.groupCollapsed('Steam answer')
212+
console.log(steamAnswer)
213+
console.groupEnd()
214+
198215
const table = {}
199216
table['search'] = true
200217
table['clickToSelect'] = true
@@ -493,10 +510,18 @@ function GetCollectionFromLink(){
493510
Http.open('GET', url)
494511
Http.send()
495512

513+
console.groupCollapsed('Sent a request to Steam')
514+
console.log(url)
515+
console.groupEnd()
516+
496517
Http.onreadystatechange=function(){
497518
if(this.readyState==4 && this.status==200){
498519
var response = JSON.parse(Http.responseText)['response']
499520

521+
console.groupCollapsed('Steam answer')
522+
console.log(response)
523+
console.groupEnd()
524+
500525
if(response['publishedfiledetails'][0]['result'] != 1){
501526
$.toast({title: 'Collection import error',
502527
content: 'Steam could not find collection with id ' + collectionUrl,
@@ -767,31 +792,52 @@ function LoadConfig(){
767792

768793
//check for new mods in the workshop folder
769794
var p = path.join(colls['CrashdayPath'], '../../workshop/content/508980')
770-
var foundNewMods = 0
795+
var unlistedMods = 0
796+
var listedMods = 0
797+
var emptyFolders = 0
798+
var otherFiles = 0
771799
if(fs.existsSync(p)){
772800
fs.readdirSync(p).forEach(file => {
773801
var foundFile = false
774802
var name = parseInt(file, 10)
775-
//skip not numbered .cpk's
776-
if(name == NaN) return
803+
//skip not numbered folder names
804+
if(name == NaN) {
805+
otherFiles++
806+
return
807+
}
808+
809+
folder = fs.statSync(path.join(p, file))
810+
if(!folder.isDirectory()) {
811+
otherFiles++
812+
return
813+
}
814+
//check there is a mod file in mod folder
815+
files = fs.readdirSync(path.join(p, file))
816+
if(files.length == 0) {
817+
emptyFolders++
818+
return
819+
}
777820

778821
for(n in cfg['WorkshopItems'])
779822
{
780823
if(cfg['WorkshopItems'][n][0] == name)
781824
{
825+
listedMods++
782826
foundFile = true
783827
}
784828
}
785829
if(!foundFile){
786830
cfg['WorkshopItems'].push([name, false])
787-
foundNewMods += 1
831+
unlistedMods++
788832
}
789833
})
790834
}
791835

792-
if(foundNewMods > 0){
836+
console.log(`Found ${listedMods} listed mods, ${unlistedMods} unlisted mods, ${emptyFolders} empty folders and ${otherFiles} other files in Workshop folder`)
837+
838+
if(unlistedMods > 0){
793839
$.toast({title: 'New mods found',
794-
content: 'Launcher found and added ' + foundNewMods + ' new mods.',
840+
content: 'Launcher found and added ' + unlistedMods + ' new mods.',
795841
type: 'info', delay: 5000, container: $('#toaster')})
796842
}
797843

main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Modules to control application life and create native browser window
2-
const {app, BrowserWindow, ipcMain } = require('electron')
2+
const {nativeImage, app, BrowserWindow, ipcMain } = require('electron')
33
const {autoUpdater} = require('electron-updater')
44

55
// Keep a global reference of the window object, if you don't, the window will
@@ -10,7 +10,8 @@ function createWindow () {
1010
// Create the browser window.
1111
mainWindow = new BrowserWindow({width: 1280, height: 720, webPreferences: {
1212
nodeIntegration: true,
13-
}})
13+
}, icon: nativeImage.createFromPath(__dirname + '/img/icon.png')
14+
})
1415

1516
// and load the index.html of the app.
1617
mainWindow.loadFile('app/index.html')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
]
2121
},
2222
"name": "crashday-smart-launcher",
23-
"version": "1.7.3",
23+
"version": "1.7.4",
2424
"description": "A better launcher for Crashday:Redline edition",
2525
"author": "Wurunduk",
2626
"license": "MIT",

0 commit comments

Comments
 (0)