silphscope 1.4.22 → 1.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -83
- package/docs/node/renderAllBalls.md +0 -0
- package/docs/node/renderAllGraphics.md +0 -0
- package/docs/node/renderAllIcons.md +0 -0
- package/docs/node/renderAllMons.md +0 -0
- package/docs/node/renderAllMoves.md +0 -0
- package/docs/node/renderAllTrainers.md +0 -0
- package/docs/node/renderAllX-options.md +0 -0
- package/item-data/itemData.json +376 -1128
- package/main.js +149 -5
- package/mon-data/monData.json +440 -4373
- package/move-data/moveData.json +0 -609
- package/package.json +3 -2
- package/silphscope.d.ts +579 -502
- package/src/graphics/balls/render-ball-particle.js +48 -26
- package/src/graphics/balls/render-balls.js +45 -22
- package/src/graphics/graphics-extractor-main.js +155 -294
- package/src/graphics/icons/render-icons.js +14 -4
- package/src/graphics/mons/render-mon-foot.js +17 -5
- package/src/graphics/mons/render-mon-icon.js +27 -6
- package/src/graphics/mons/render-mons.js +15 -6
- package/src/graphics/moves/render-moves.js +44 -29
- package/src/graphics/trainers/render-trainer-back-pics.js +52 -10
- package/src/graphics/trainers/render-trainers.js +16 -19
- package/src/is-valid-filter-type.js +15 -0
- package/src/run-with-concurrency.js +12 -0
- package/src/validate-render-options.js +28 -0
- package/trainer-data/trainerData.json +148 -444
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Licensed under the MIT License. See LICENSE file in project root.
|
|
3
3
|
|
|
4
4
|
import fs from "fs";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { mapLimit } from "../map-limit.js";
|
|
5
|
+
import { runWithConcurrency } from "../run-with-concurrency.js";
|
|
6
|
+
import { validateRenderOptions } from "../validate-render-options.js";
|
|
8
7
|
import { renderMon } from "./mons/render-mons.js";
|
|
9
8
|
import { renderIcon } from "./icons/render-icons.js";
|
|
10
9
|
import { renderTrainer } from "./trainers/render-trainers.js";
|
|
@@ -12,33 +11,12 @@ import { RomReader } from "../rom-reader.js";
|
|
|
12
11
|
import { getRomConfig } from "../get-rom-config.js";
|
|
13
12
|
import { renderMove } from "./moves/render-moves.js";
|
|
14
13
|
import { renderBall } from "./balls/render-balls.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const mons = loadDefaultJson("../mon-data/monData.json");
|
|
24
|
-
const icons = loadDefaultJson("../item-data/itemData.json");
|
|
25
|
-
const trainers = loadDefaultJson("../trainer-data/trainerData.json");
|
|
26
|
-
const trainersBack = loadDefaultJson("../trainer-data/trainerBackData.json");
|
|
27
|
-
const moves = loadDefaultJson("../move-data/moveData.json");
|
|
28
|
-
const balls = loadDefaultJson("../ball-data/ballData.json");
|
|
29
|
-
|
|
30
|
-
function isValidFilterType(filterTypeValue) {
|
|
31
|
-
if (Number.isInteger(filterTypeValue)) {
|
|
32
|
-
return filterTypeValue >= -1 && filterTypeValue <= 4;
|
|
33
|
-
}
|
|
34
|
-
if (Array.isArray(filterTypeValue)) {
|
|
35
|
-
return filterTypeValue.length > 0 && filterTypeValue.every(entry =>
|
|
36
|
-
Number.isInteger(entry) && entry >= 0 && entry <= 4
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
14
|
+
import mons from "../../mon-data/monData.json" with { type: "json" };
|
|
15
|
+
import icons from "../../item-data/itemData.json" with { type: "json" };
|
|
16
|
+
import trainers from "../../trainer-data/trainerData.json" with { type: "json" };
|
|
17
|
+
import trainersBack from "../../trainer-data/trainerBackData.json" with { type: "json" };
|
|
18
|
+
import moves from "../../move-data/moveData.json" with { type: "json" };
|
|
19
|
+
import balls from "../../ball-data/ballData.json" with { type: "json" };
|
|
42
20
|
|
|
43
21
|
export async function renderAllMons(rom, options = {}) {
|
|
44
22
|
const start = performance.now();
|
|
@@ -59,15 +37,11 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
59
37
|
footprint = true,
|
|
60
38
|
} = options;
|
|
61
39
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
69
|
-
throw new TypeError(`renderAllMons(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
70
|
-
}
|
|
40
|
+
validateRenderOptions("renderAllMons", {
|
|
41
|
+
concurrency,
|
|
42
|
+
filterType: pngFilterType,
|
|
43
|
+
compressionLevel: pngCompressionLevel,
|
|
44
|
+
});
|
|
71
45
|
|
|
72
46
|
if (outputDir) {
|
|
73
47
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -78,47 +52,25 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
78
52
|
let totalFileCount = 0;
|
|
79
53
|
const finalResults = returnFileBuffer? [] : null;
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
await
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
outputDir,
|
|
92
|
-
});
|
|
93
|
-
if (verboseLogs) {
|
|
94
|
-
console.log(`Done: ${monName}`);
|
|
95
|
-
}
|
|
96
|
-
totalFileCount += renderMonData.fullFileCount;
|
|
97
|
-
if (returnFileBuffer && renderMonData?.results) {
|
|
98
|
-
finalResults.push(...renderMonData.results);
|
|
99
|
-
}
|
|
55
|
+
await runWithConcurrency(Object.keys(providedMons), concurrency, async (monName) => {
|
|
56
|
+
const renderMonData = await renderMon(monName, providedMons, reader, rom, {
|
|
57
|
+
side: ["front", "back"],
|
|
58
|
+
variant: ["normal", "shiny"],
|
|
59
|
+
icon,
|
|
60
|
+
footprint,
|
|
61
|
+
pngFilterType,
|
|
62
|
+
pngCompressionLevel,
|
|
63
|
+
returnFileBuffer,
|
|
64
|
+
outputDir,
|
|
100
65
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const renderMonData = await renderMon(monName, providedMons, reader, rom, {
|
|
104
|
-
side: ["front", "back"],
|
|
105
|
-
variant: ["normal", "shiny"],
|
|
106
|
-
icon,
|
|
107
|
-
footprint,
|
|
108
|
-
pngFilterType,
|
|
109
|
-
pngCompressionLevel,
|
|
110
|
-
returnFileBuffer,
|
|
111
|
-
outputDir,
|
|
112
|
-
});
|
|
113
|
-
if (verboseLogs) {
|
|
114
|
-
console.log(`Done: ${monName}`);
|
|
115
|
-
}
|
|
116
|
-
totalFileCount += renderMonData.fullFileCount;
|
|
117
|
-
if (returnFileBuffer) {
|
|
118
|
-
finalResults.push(...renderMonData.results);
|
|
119
|
-
}
|
|
66
|
+
if (verboseLogs) {
|
|
67
|
+
console.log(`Done: ${monName}`);
|
|
120
68
|
}
|
|
121
|
-
|
|
69
|
+
totalFileCount += renderMonData.fullFileCount;
|
|
70
|
+
if (returnFileBuffer && renderMonData?.results) {
|
|
71
|
+
finalResults.push(...renderMonData.results);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
122
74
|
|
|
123
75
|
const elapsed = ((performance.now() - start) / 1000).toFixed(2);
|
|
124
76
|
|
|
@@ -153,15 +105,12 @@ export async function renderAllIcons(rom, options = {}) {
|
|
|
153
105
|
outputDir = "./out",
|
|
154
106
|
} = options;
|
|
155
107
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
163
|
-
throw new TypeError(`renderAllIcons(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
164
|
-
}
|
|
108
|
+
validateRenderOptions("renderAllIcons", {
|
|
109
|
+
concurrency,
|
|
110
|
+
filterType: pngFilterType,
|
|
111
|
+
compressionLevel: pngCompressionLevel,
|
|
112
|
+
});
|
|
113
|
+
|
|
165
114
|
|
|
166
115
|
if (outputDir) {
|
|
167
116
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -172,39 +121,21 @@ export async function renderAllIcons(rom, options = {}) {
|
|
|
172
121
|
let totalFileCount = 0;
|
|
173
122
|
const finalResults = returnFileBuffer? [] : null;
|
|
174
123
|
|
|
175
|
-
|
|
176
|
-
await
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
outputDir,
|
|
182
|
-
});
|
|
183
|
-
if (verboseLogs) {
|
|
184
|
-
console.log(`Done: ${itemName}`);
|
|
185
|
-
}
|
|
186
|
-
totalFileCount += renderIconData.fullFileCount;
|
|
187
|
-
if (returnFileBuffer && renderIconData?.pngBuffer) {
|
|
188
|
-
finalResults.push(renderIconData.pngBuffer);
|
|
189
|
-
}
|
|
124
|
+
await runWithConcurrency(Object.keys(providedIcons), concurrency, async (itemName) => {
|
|
125
|
+
const renderIconData = await renderIcon(itemName, providedIcons, reader, rom, {
|
|
126
|
+
pngFilterType,
|
|
127
|
+
pngCompressionLevel,
|
|
128
|
+
returnFileBuffer,
|
|
129
|
+
outputDir,
|
|
190
130
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const renderIconData = await renderIcon(itemName, providedIcons, reader, rom, {
|
|
194
|
-
pngFilterType,
|
|
195
|
-
pngCompressionLevel,
|
|
196
|
-
returnFileBuffer,
|
|
197
|
-
outputDir,
|
|
198
|
-
});
|
|
199
|
-
if (verboseLogs) {
|
|
200
|
-
console.log(`Done: ${itemName}`);
|
|
201
|
-
}
|
|
202
|
-
totalFileCount += renderIconData.fullFileCount;
|
|
203
|
-
if (returnFileBuffer && renderIconData?.pngBuffer) {
|
|
204
|
-
finalResults.push(renderIconData.pngBuffer);
|
|
205
|
-
}
|
|
131
|
+
if (verboseLogs) {
|
|
132
|
+
console.log(`Done: ${itemName}`);
|
|
206
133
|
}
|
|
207
|
-
|
|
134
|
+
totalFileCount += renderIconData.fullFileCount;
|
|
135
|
+
if (returnFileBuffer && renderIconData?.pngBuffer) {
|
|
136
|
+
finalResults.push(...renderIconData.results);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
208
139
|
|
|
209
140
|
const elapsed = ((performance.now() - start) / 1000).toFixed(2);
|
|
210
141
|
|
|
@@ -241,15 +172,12 @@ export async function renderAllTrainers(rom, options = {}) {
|
|
|
241
172
|
outputDir = "./out",
|
|
242
173
|
} = options;
|
|
243
174
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
251
|
-
throw new TypeError(`renderAllTrainers(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
252
|
-
}
|
|
175
|
+
validateRenderOptions("renderAllTrainers", {
|
|
176
|
+
concurrency,
|
|
177
|
+
filterType: pngFilterType,
|
|
178
|
+
compressionLevel: pngCompressionLevel,
|
|
179
|
+
});
|
|
180
|
+
|
|
253
181
|
|
|
254
182
|
if (outputDir) {
|
|
255
183
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -260,41 +188,22 @@ export async function renderAllTrainers(rom, options = {}) {
|
|
|
260
188
|
let totalFileCount = 0;
|
|
261
189
|
const finalResults = returnFileBuffer? [] : null;
|
|
262
190
|
|
|
263
|
-
|
|
264
|
-
await
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
outputDir
|
|
271
|
-
});
|
|
272
|
-
if (verboseLogs) {
|
|
273
|
-
console.log(`Done: ${trainerName}`);
|
|
274
|
-
}
|
|
275
|
-
totalFileCount += renderTrainerData.fullFileCount;
|
|
276
|
-
if (returnFileBuffer && renderTrainerData?.results) {
|
|
277
|
-
finalResults.push(...renderTrainerData.results);
|
|
278
|
-
}
|
|
191
|
+
await runWithConcurrency(Object.keys(providedTrainers), concurrency, async (trainerName) => {
|
|
192
|
+
const renderTrainerData = await renderTrainer(trainerName, providedTrainers, providedBackTrainers, reader, rom, {
|
|
193
|
+
trainerBackPics,
|
|
194
|
+
pngFilterType,
|
|
195
|
+
pngCompressionLevel,
|
|
196
|
+
returnFileBuffer,
|
|
197
|
+
outputDir
|
|
279
198
|
});
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const renderTrainerData = await renderTrainer(trainerName, providedTrainers, providedBackTrainers, reader, rom, {
|
|
283
|
-
trainerBackPics,
|
|
284
|
-
pngFilterType,
|
|
285
|
-
pngCompressionLevel,
|
|
286
|
-
returnFileBuffer,
|
|
287
|
-
outputDir
|
|
288
|
-
});
|
|
289
|
-
if (verboseLogs) {
|
|
290
|
-
console.log(`Done: ${trainerName}`);
|
|
291
|
-
}
|
|
292
|
-
totalFileCount += renderTrainerData.fullFileCount;
|
|
293
|
-
if (returnFileBuffer && renderTrainerData?.results) {
|
|
294
|
-
finalResults.push(...renderTrainerData.results);
|
|
295
|
-
}
|
|
199
|
+
if (verboseLogs) {
|
|
200
|
+
console.log(`Done: ${trainerName}`);
|
|
296
201
|
}
|
|
297
|
-
|
|
202
|
+
totalFileCount += renderTrainerData.fullFileCount;
|
|
203
|
+
if (returnFileBuffer && renderTrainerData?.results) {
|
|
204
|
+
finalResults.push(...renderTrainerData.results);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
298
207
|
|
|
299
208
|
const elapsed = ((performance.now() - start) / 1000).toFixed(2);
|
|
300
209
|
|
|
@@ -331,15 +240,12 @@ export async function renderAllMoves(rom, options = {}) {
|
|
|
331
240
|
sortUnused = true,
|
|
332
241
|
} = options;
|
|
333
242
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
341
|
-
throw new TypeError(`renderAllMoves(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
342
|
-
}
|
|
243
|
+
validateRenderOptions("renderAllMoves", {
|
|
244
|
+
concurrency,
|
|
245
|
+
filterType: pngFilterType,
|
|
246
|
+
compressionLevel: pngCompressionLevel,
|
|
247
|
+
});
|
|
248
|
+
|
|
343
249
|
|
|
344
250
|
if (outputDir) {
|
|
345
251
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -350,43 +256,23 @@ export async function renderAllMoves(rom, options = {}) {
|
|
|
350
256
|
let totalFileCount = 0;
|
|
351
257
|
const finalResults = returnFileBuffer? [] : null;
|
|
352
258
|
|
|
353
|
-
|
|
354
|
-
await
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
sortUnused,
|
|
362
|
-
});
|
|
363
|
-
if (verboseLogs) {
|
|
364
|
-
console.log(`Done: ${moveName}`);
|
|
365
|
-
}
|
|
366
|
-
totalFileCount += renderMoveData.fullFileCount;
|
|
367
|
-
if (returnFileBuffer && renderMoveData?.results) {
|
|
368
|
-
finalResults.push(...renderMoveData.results);
|
|
369
|
-
}
|
|
259
|
+
await runWithConcurrency(Object.keys(providedMoves), concurrency, async (moveName) => {
|
|
260
|
+
const renderMoveData = await renderMove(moveName, providedMoves, reader, rom, {
|
|
261
|
+
pngFilterType,
|
|
262
|
+
pngCompressionLevel,
|
|
263
|
+
returnFileBuffer,
|
|
264
|
+
outputDir,
|
|
265
|
+
renderMasterImage,
|
|
266
|
+
sortUnused,
|
|
370
267
|
});
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const renderMoveData = await renderMove(moveName, providedMoves, reader, rom, {
|
|
374
|
-
pngFilterType,
|
|
375
|
-
pngCompressionLevel,
|
|
376
|
-
returnFileBuffer,
|
|
377
|
-
outputDir,
|
|
378
|
-
renderMasterImage,
|
|
379
|
-
sortUnused,
|
|
380
|
-
});
|
|
381
|
-
if (verboseLogs) {
|
|
382
|
-
console.log(`Done: ${moveName}`);
|
|
383
|
-
}
|
|
384
|
-
totalFileCount += renderMoveData.fullFileCount;
|
|
385
|
-
if (returnFileBuffer && renderMoveData?.results) {
|
|
386
|
-
finalResults.push(...renderMoveData.results);
|
|
387
|
-
}
|
|
268
|
+
if (verboseLogs) {
|
|
269
|
+
console.log(`Done: ${moveName}`);
|
|
388
270
|
}
|
|
389
|
-
|
|
271
|
+
totalFileCount += renderMoveData.fullFileCount;
|
|
272
|
+
if (returnFileBuffer && renderMoveData?.results) {
|
|
273
|
+
finalResults.push(...renderMoveData.results);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
390
276
|
|
|
391
277
|
const elapsed = ((performance.now() - start) / 1000).toFixed(2);
|
|
392
278
|
|
|
@@ -424,15 +310,12 @@ export async function renderAllBalls(rom, options = {}) {
|
|
|
424
310
|
renderMasterBallParticleImage = true,
|
|
425
311
|
} = options;
|
|
426
312
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
434
|
-
throw new TypeError(`renderAllBalls(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
435
|
-
}
|
|
313
|
+
validateRenderOptions("renderAllBalls", {
|
|
314
|
+
concurrency,
|
|
315
|
+
filterType: pngFilterType,
|
|
316
|
+
compressionLevel: pngCompressionLevel,
|
|
317
|
+
});
|
|
318
|
+
|
|
436
319
|
|
|
437
320
|
if (outputDir) {
|
|
438
321
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
@@ -443,45 +326,24 @@ export async function renderAllBalls(rom, options = {}) {
|
|
|
443
326
|
let totalFileCount = 0;
|
|
444
327
|
const finalResults = returnFileBuffer? [] : null;
|
|
445
328
|
|
|
446
|
-
|
|
447
|
-
await
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
console.log(`Done: ${ballName}`);
|
|
459
|
-
}
|
|
460
|
-
totalFileCount += renderBallData.fullFileCount;
|
|
461
|
-
if (returnFileBuffer) {
|
|
462
|
-
finalResults.push(...renderBallData.results);
|
|
463
|
-
}
|
|
464
|
-
})
|
|
465
|
-
} else {
|
|
466
|
-
for (const ballName of Object.keys(providedBalls)) {
|
|
467
|
-
const renderBallData = await renderBall(ballName, providedBalls, reader, rom, {
|
|
468
|
-
pngFilterType,
|
|
469
|
-
pngCompressionLevel,
|
|
470
|
-
returnFileBuffer,
|
|
471
|
-
outputDir,
|
|
472
|
-
ballParticles,
|
|
473
|
-
renderMasterBallImage,
|
|
474
|
-
renderMasterBallParticleImage,
|
|
475
|
-
});
|
|
476
|
-
if (verboseLogs) {
|
|
477
|
-
console.log(`Done: ${ballName}`);
|
|
478
|
-
}
|
|
479
|
-
totalFileCount += renderBallData.fullFileCount;
|
|
480
|
-
if (returnFileBuffer) {
|
|
481
|
-
finalResults.push(...renderBallData.results);
|
|
482
|
-
}
|
|
329
|
+
await runWithConcurrency(Object.keys(providedBalls), concurrency, async (ballName) => {
|
|
330
|
+
const renderBallData = await renderBall(ballName, providedBalls, reader, rom, {
|
|
331
|
+
pngFilterType,
|
|
332
|
+
pngCompressionLevel,
|
|
333
|
+
returnFileBuffer,
|
|
334
|
+
outputDir,
|
|
335
|
+
ballParticles,
|
|
336
|
+
renderMasterBallImage,
|
|
337
|
+
renderMasterBallParticleImage,
|
|
338
|
+
});
|
|
339
|
+
if (verboseLogs) {
|
|
340
|
+
console.log(`Done: ${ballName}`);
|
|
483
341
|
}
|
|
484
|
-
|
|
342
|
+
totalFileCount += renderBallData.fullFileCount;
|
|
343
|
+
if (returnFileBuffer) {
|
|
344
|
+
finalResults.push(...renderBallData.results);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
485
347
|
|
|
486
348
|
const elapsed = ((performance.now() - start) / 1000).toFixed(2);
|
|
487
349
|
|
|
@@ -519,76 +381,75 @@ export async function renderAllGraphics(rom, options = {}) { // eventually I wil
|
|
|
519
381
|
outputBallDir = "./out/balls",
|
|
520
382
|
} = options;
|
|
521
383
|
|
|
522
|
-
|
|
523
|
-
throw new TypeError(`renderAllGraphics(rom, options = { concurrency, ... }) requires concurrency to be a integer greater than 0 (recieved ${concurrency})`);
|
|
524
|
-
}
|
|
525
|
-
if (!isValidFilterType(pngFilterType)) {
|
|
526
|
-
throw new Error(`renderAllGraphics(rom, options = { pngFilterType, ... }) requires pngFilterType to be a integer between -1 and 4 (received ${pngFilterType})`)
|
|
527
|
-
}
|
|
528
|
-
if (!Number.isInteger(pngCompressionLevel) || pngCompressionLevel < 0 || pngCompressionLevel > 9) {
|
|
529
|
-
throw new Error(`renderAllGraphics(rom, options = { pngCompressionLevel, ... }) requires pngCompressionLevel to be a integer between 0 and 9 (received ${pngCompressionLevel})`)
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
await renderAllMons(rom, {
|
|
384
|
+
const sharedOptions = {
|
|
533
385
|
concurrency,
|
|
534
386
|
pngFilterType,
|
|
535
387
|
pngCompressionLevel,
|
|
536
388
|
verboseLogs,
|
|
537
389
|
showSummary,
|
|
538
390
|
returnFileBuffer,
|
|
391
|
+
}
|
|
392
|
+
let totalFileCount = 0;
|
|
393
|
+
const finalResults = returnFileBuffer? [] : null;
|
|
394
|
+
|
|
395
|
+
validateRenderOptions("renderAllGraphics", {
|
|
396
|
+
concurrency,
|
|
397
|
+
filterType: pngFilterType,
|
|
398
|
+
compressionLevel: pngCompressionLevel,
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
const renderAllMonsData = await renderAllMons(rom, {
|
|
403
|
+
...sharedOptions,
|
|
539
404
|
outputDir: outputMonDir,
|
|
540
405
|
icon: true,
|
|
541
406
|
footprint: true,
|
|
542
407
|
});
|
|
543
408
|
|
|
544
|
-
await renderAllIcons(rom, {
|
|
545
|
-
|
|
546
|
-
pngFilterType,
|
|
547
|
-
pngCompressionLevel,
|
|
548
|
-
verboseLogs,
|
|
549
|
-
showSummary,
|
|
550
|
-
returnFileBuffer,
|
|
409
|
+
const renderAllIconsData = await renderAllIcons(rom, {
|
|
410
|
+
...sharedOptions,
|
|
551
411
|
outputDir: outputIconDir,
|
|
552
412
|
});
|
|
553
413
|
|
|
554
|
-
await renderAllTrainers(rom, {
|
|
555
|
-
|
|
556
|
-
pngFilterType,
|
|
557
|
-
pngCompressionLevel,
|
|
558
|
-
verboseLogs,
|
|
559
|
-
showSummary,
|
|
560
|
-
returnFileBuffer,
|
|
414
|
+
const renderAllTrainersData = await renderAllTrainers(rom, {
|
|
415
|
+
...sharedOptions,
|
|
561
416
|
outputDir: outputTrainerDir,
|
|
562
417
|
trainerBackPics: true,
|
|
563
418
|
});
|
|
564
419
|
|
|
565
|
-
await renderAllMoves(rom, {
|
|
566
|
-
|
|
567
|
-
pngFilterType,
|
|
568
|
-
pngCompressionLevel,
|
|
569
|
-
verboseLogs,
|
|
570
|
-
showSummary,
|
|
571
|
-
returnFileBuffer,
|
|
420
|
+
const renderAllMovesData = await renderAllMoves(rom, {
|
|
421
|
+
...sharedOptions,
|
|
572
422
|
outputDir: outputMoveDir,
|
|
573
423
|
renderMasterImage: true,
|
|
574
424
|
sortUnused: sortUnusedMoves,
|
|
575
425
|
});
|
|
576
426
|
|
|
577
|
-
await renderAllBalls(rom, {
|
|
578
|
-
|
|
579
|
-
pngFilterType,
|
|
580
|
-
pngCompressionLevel,
|
|
581
|
-
verboseLogs,
|
|
582
|
-
showSummary,
|
|
583
|
-
returnFileBuffer,
|
|
427
|
+
const renderAllBallsData = await renderAllBalls(rom, {
|
|
428
|
+
...sharedOptions,
|
|
584
429
|
outputDir: outputBallDir,
|
|
585
430
|
ballParticles: true,
|
|
586
431
|
renderMasterBallImage: true,
|
|
587
432
|
renderMasterBallParticleImage: true,
|
|
588
433
|
});
|
|
589
|
-
}
|
|
590
434
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
435
|
+
const results = [
|
|
436
|
+
renderAllMonsData,
|
|
437
|
+
renderAllIconsData,
|
|
438
|
+
renderAllTrainersData,
|
|
439
|
+
renderAllMovesData,
|
|
440
|
+
renderAllBallsData,
|
|
441
|
+
];
|
|
442
|
+
|
|
443
|
+
if (returnFileBuffer) {
|
|
444
|
+
finalResults.push(...results.flatMap(result => result.finalResults));
|
|
445
|
+
}
|
|
446
|
+
totalFileCount += results.reduce(
|
|
447
|
+
(sum, result) => sum + result.totalFileCount,
|
|
448
|
+
0
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
return {
|
|
452
|
+
...(returnFileBuffer && { finalResults }),
|
|
453
|
+
totalFileCount,
|
|
454
|
+
}
|
|
594
455
|
}
|
|
@@ -17,7 +17,7 @@ const streamToBuffer = (stream) => new Promise((resolve, reject) => {
|
|
|
17
17
|
export async function renderIcon(itemName, items, reader, rom, options = {}) {
|
|
18
18
|
const {
|
|
19
19
|
pngFilterType = null,
|
|
20
|
-
|
|
20
|
+
pngCompressionLevel = null,
|
|
21
21
|
returnFileBuffer = false,
|
|
22
22
|
outputDir = null
|
|
23
23
|
} = options;
|
|
@@ -27,6 +27,7 @@ export async function renderIcon(itemName, items, reader, rom, options = {}) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
let fullFileCount = 0;
|
|
30
|
+
const results = returnFileBuffer? [] : null;
|
|
30
31
|
const item = items[itemName];
|
|
31
32
|
if (!item) {
|
|
32
33
|
throw new Error(`Missing Item: ${itemName}`);
|
|
@@ -54,7 +55,7 @@ export async function renderIcon(itemName, items, reader, rom, options = {}) {
|
|
|
54
55
|
png.data = image;
|
|
55
56
|
const pngBuffer = PNG.sync.write(png, {
|
|
56
57
|
filterType: pngFilterType,
|
|
57
|
-
deflateLevel:
|
|
58
|
+
deflateLevel: pngCompressionLevel,
|
|
58
59
|
});
|
|
59
60
|
|
|
60
61
|
if (outputDir) {
|
|
@@ -64,9 +65,18 @@ export async function renderIcon(itemName, items, reader, rom, options = {}) {
|
|
|
64
65
|
await fs.promises.writeFile(fileName, pngBuffer);
|
|
65
66
|
fullFileCount += 1;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
if (returnFileBuffer) {
|
|
69
|
+
finalResults.push({
|
|
70
|
+
name: `${itemName}-sprite`,
|
|
71
|
+
category: "icon",
|
|
72
|
+
asset: "sprite",
|
|
73
|
+
path: `out/icons/${itemName}/icon`,
|
|
74
|
+
buffer: pngBuffer,
|
|
75
|
+
meta: {},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
68
78
|
return {
|
|
69
|
-
...(returnFileBuffer && {
|
|
79
|
+
...(returnFileBuffer && { results }),
|
|
70
80
|
fullFileCount,
|
|
71
81
|
};
|
|
72
82
|
}
|
|
@@ -18,7 +18,7 @@ export async function renderMonFoot(monName, mons, reader, rom, options = {}) {
|
|
|
18
18
|
const {
|
|
19
19
|
pngFilterType = null,
|
|
20
20
|
pngCompressionLevel = null,
|
|
21
|
-
returnFileBuffer,
|
|
21
|
+
returnFileBuffer = false,
|
|
22
22
|
outputDir = null,
|
|
23
23
|
} = options;
|
|
24
24
|
|
|
@@ -26,7 +26,8 @@ export async function renderMonFoot(monName, mons, reader, rom, options = {}) {
|
|
|
26
26
|
throw new TypeError("renderMonFoot(..., rom) requires a ROM Buffer/Uint8Array");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let
|
|
29
|
+
let fullFileCount = 0;
|
|
30
|
+
const results = returnFileBuffer? [] : null;
|
|
30
31
|
const mon = mons[monName];
|
|
31
32
|
if (!mon) {
|
|
32
33
|
throw new Error(`Missing mon entry for ${monName}`);
|
|
@@ -90,11 +91,22 @@ export async function renderMonFoot(monName, mons, reader, rom, options = {}) {
|
|
|
90
91
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
91
92
|
const fileName = `${dir}/footprint.png`;
|
|
92
93
|
await fs.promises.writeFile(fileName, pngBuffer);
|
|
93
|
-
|
|
94
|
+
fullFileCount += 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (returnFileBuffer) {
|
|
98
|
+
results.push({
|
|
99
|
+
name: `${monName}-footprint`,
|
|
100
|
+
category: "mon",
|
|
101
|
+
asset: "footprint",
|
|
102
|
+
path: `out/mons/${monName}/footprint`,
|
|
103
|
+
buffer: pngBuffer,
|
|
104
|
+
meta: {},
|
|
105
|
+
});
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
return {
|
|
97
|
-
...(returnFileBuffer && {
|
|
98
|
-
|
|
109
|
+
...(returnFileBuffer && { results }),
|
|
110
|
+
fullFileCount,
|
|
99
111
|
};
|
|
100
112
|
}
|