2022-06-16 20:37:24 -04:00
"use strict" ;
const gdPath = 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Geometry Dash\\Resources\\'
2021-12-03 16:30:58 -05:00
2022-06-16 20:37:24 -04:00
const plist = require ( 'plist' )
const fs = require ( 'fs' )
2021-12-03 16:30:58 -05:00
const forms = require ( './forms.json' )
2022-06-16 20:37:24 -04:00
const data = plist . parse ( fs . readFileSync ( gdPath + 'GJ_GameSheet02-uhd.plist' , 'utf8' ) )
const glowSheet = plist . parse ( fs . readFileSync ( gdPath + 'GJ_GameSheetGlow-uhd.plist' , 'utf8' ) )
2021-12-03 16:30:58 -05:00
let formList = Object . values ( forms ) . map ( x => x . form )
let frames = { }
function addIcons ( data ) {
2022-06-16 20:37:24 -04:00
Object . keys ( data )
. filter ( k => formList . includes ( k . split ( "_" ) [ 0 ] ) )
. forEach ( k => frames [ k ] = data [ k ] )
2021-12-03 16:30:58 -05:00
}
addIcons ( data . frames )
addIcons ( glowSheet . frames )
for ( let key in frames ) {
if ( key . startsWith ( "." ) ) delete frames [ key ]
2022-06-16 20:37:24 -04:00
else {
let fileData = frames [ key ]
for ( let innerKey in fileData ) {
2021-12-03 16:30:58 -05:00
if ( ! [ "spriteSize" , "spriteOffset" ] . includes ( innerKey ) ) delete fileData [ innerKey ] // remove useless stuff
2022-06-16 21:06:49 -04:00
else fileData [ innerKey ] = JSON . parse ( fileData [ innerKey ] . replaceAll ( '{' , '[' ) . replaceAll ( '}' , ']' ) )
2021-12-03 16:30:58 -05:00
}
}
2022-06-16 20:37:24 -04:00
}
fs . writeFileSync ( './parsed/gameSheet.json' , JSON . stringify ( frames , null , 2 ) . replace ( /\[\n.+?(-?\d+),\n.+?(-?\d+)\n.+]/g , "[$1, $2]" ) ) ; // regex to make it easier to read
2022-06-16 21:06:49 -04:00
console . log ( "Successfully parsed!" )