Skip to content

Commit 8885105

Browse files
committed
added palette support
1 parent c8201cc commit 8885105

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ definition([
2020
])
2121

2222
// project files
23+
// check palette copy to file works correctly
2324

2425
/* https://unix.stackexchange.com/questions/585645/launch-an-application-by-a-double-click */
2526
// provide a custom definition, but have a default

development/sonlvl.js

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,15 @@ const base = __dirname + '/../../flex2_test/s1disasm/SonLVL INI Files/';
77
const format = 'Sonic 1.js';
88
const projectName = 'Sonic 1';
99
const defaultCmp = 'Nemesis';
10-
const levels = ['obj.ini'];
10+
const folders = ['objGHZ.ini'];
1111
const pathMod = (str) => str.slice(3);
12-
const palettes = []; // TODO - use SonLVL.ini
12+
const basePalette = [
13+
{ path: 'palette/Sonic.bin', length: 1 }
14+
];
1315

14-
const objects = [];
15-
16-
levels.forEach(filename => {
17-
const folder = {
18-
name: filename,
19-
children: [],
20-
isDirectory: true,
21-
expanded: false,
22-
};
23-
24-
ini = readFileSync(join(base, filename), 'utf8');
16+
function parseINI(ini) {
2517
ini = ini.match(/\[.+\][^[]+/gm);
26-
ini.forEach(sect => {
18+
return ini.map(sect => {
2719
const obj = {};
2820
sect.split('\n')
2921
.forEach(line => {
@@ -32,7 +24,35 @@ levels.forEach(filename => {
3224
obj[name] = prop;
3325
}
3426
})
27+
return obj;
28+
});
29+
}
30+
31+
const paletteLookup = {};
32+
33+
const sonlvl = readFileSync(join(base, 'SonLVL.ini'), 'utf8')
34+
35+
parseINI(sonlvl).forEach(obj => {
36+
if (obj.objlst && obj.palette) {
37+
paletteLookup[obj.objlst] = pathMod(obj.palette.split('|').pop().replace(/:.+/, ''));
38+
}
39+
})
40+
41+
const objects = [];
42+
43+
folders.forEach(filename => {
44+
const palettes = paletteLookup[filename]
45+
? [...basePalette, { path: paletteLookup[filename], length: 3 }]
46+
: basePalette;
47+
const folder = {
48+
name: filename,
49+
children: [],
50+
isDirectory: true,
51+
expanded: false,
52+
};
3553

54+
const ini = readFileSync(join(base, filename), 'utf8');
55+
parseINI(ini).forEach(obj => {
3656
if (obj.xmlfile) {
3757
const xml = readFileSync(join(base, obj.xmlfile), 'utf8');
3858
const flexObj = {

0 commit comments

Comments
 (0)