GDBrowser/misc/icons/parseIconPlist.js
GDColon 84d02b7271 Icon code rewrite (mostly)
Rewrote the icon code so it's not nearly as bad. Spiders and robots still use the old code because I don't have the mental strength to pull it off
2021-12-03 16:30:58 -05:00

30 lines
No EOL
1.2 KiB
JavaScript

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