silphscope 1.4.6 → 1.4.7
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 +8 -0
- package/package.json +1 -1
- package/src/graphics/balls/render-balls.js +3 -3
- package/src/graphics/graphics-extractor-main.js +70 -22
- package/src/graphics/icons/render-icons.js +2 -2
- package/src/graphics/moves/render-moves.js +3 -3
- package/src/graphics/trainers/render-trainer-back-pics.js +5 -5
- package/src/graphics/trainers/render-trainers.js +2 -2
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ import { renderAllGraphics } from "silphscope"; // this is cool...
|
|
|
28
28
|
|
|
29
29
|
const rom = fs.readFileSync("pokefirered.gba"); // replace with path to your own firered rom
|
|
30
30
|
await renderAllGraphics(rom, {
|
|
31
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
31
32
|
outputMonDir: "./Assets/monImages", // must I explain?
|
|
32
33
|
outputIconDir: "./Assets/Icons", // same thing here :p
|
|
33
34
|
outputTrainerDir: "./Assets/Trainers", // ...
|
|
@@ -48,6 +49,7 @@ import { renderAllMons } from "silphscope"; // never gets old :p
|
|
|
48
49
|
|
|
49
50
|
const rom = fs.readFileSync("pokefirered.gba")// once again replace with the path to your own firered rom
|
|
50
51
|
await renderAllMons(rom, {
|
|
52
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
51
53
|
outputDir: "./Assets/monImages", // do I actually have to explain?
|
|
52
54
|
icon: true, // set to false if you don't want icons I guess...
|
|
53
55
|
footprint: true, // same as the above...
|
|
@@ -61,6 +63,7 @@ import { renderAllIcons } from "silphscope" // :D
|
|
|
61
63
|
|
|
62
64
|
const rom = fs.readFileSync("pokefirered.gba")// find your own rom and so on :l
|
|
63
65
|
await renderAllIcons(rom, {
|
|
66
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
64
67
|
outputDir: "./Assets/Icons" // no comment (wait... that was a comment :p)
|
|
65
68
|
});
|
|
66
69
|
```
|
|
@@ -72,6 +75,7 @@ import { renderAllTrainers } from "silphscope" // :O
|
|
|
72
75
|
|
|
73
76
|
const rom = fs.readFileSync("pokefirered.gba") // stuff stuff stuff
|
|
74
77
|
await renderAllTrainers(rom, {
|
|
78
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
75
79
|
outputDir: "./Assets/trainers", // more stuff
|
|
76
80
|
trainerBackPics: true, // renders the like 8 trainer back pics
|
|
77
81
|
})
|
|
@@ -84,6 +88,7 @@ import { renderAllMoves } from "silphscope" // :O
|
|
|
84
88
|
|
|
85
89
|
const rom = fs.readFileSync("pokefirered.gba") // stuff stuff stuff (more stuff!)
|
|
86
90
|
await renderAllMoves(rom, {
|
|
91
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
87
92
|
outputDir: "./Assets/trainers", // (incredibly) more stuff
|
|
88
93
|
renderMasterImage: true, // kinda forgot about this... basically it renders a uncut image of the move anim if you like
|
|
89
94
|
sortUnused: true, // sorts unused moves into a sub-directory
|
|
@@ -97,6 +102,9 @@ import { renderAllBalls } from "silphscope" // o-O
|
|
|
97
102
|
|
|
98
103
|
const rom = fs.readFileSync("./path/to/your/rom.gba") // the file path explains :/
|
|
99
104
|
await renderAllBalls(rom, {
|
|
105
|
+
concurrency: 4, // handles how many concurrent promises are run. Set to 1 to run sequentially and conversly increase to run more promises at once (don't set too high though if your CPU / I/O can't handle it then it might actually be slower...)
|
|
100
106
|
outputDir: "./Assets/Balls",
|
|
101
107
|
ballParticles: true, // set to false if you don't want the ball particles :p
|
|
108
|
+
renderMasterBallImage: true, // set to false if you don't want the uncut image
|
|
109
|
+
renderMasterBallParticleImage: true, // set to false if you also don't want the uncut particle image :p
|
|
102
110
|
})
|
package/package.json
CHANGED
|
@@ -79,9 +79,9 @@ export async function renderBall(ballName, balls, reader, rom, options = {}) {
|
|
|
79
79
|
|
|
80
80
|
if (outputDir) {
|
|
81
81
|
const dir = `${outputDir}/${ballName}`;
|
|
82
|
-
|
|
82
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
83
83
|
if (renderMasterBallImage) {
|
|
84
|
-
fs.
|
|
84
|
+
await fs.promises.writeFile(`${dir}/master-image.png`, pngBuffer)
|
|
85
85
|
}
|
|
86
86
|
for (let i = 0; i < ball.frames.length; i++) {
|
|
87
87
|
const frame = ball.frames[i];
|
|
@@ -92,7 +92,7 @@ export async function renderBall(ballName, balls, reader, rom, options = {}) {
|
|
|
92
92
|
const pngFrameBuffer = await streamToBuffer(png.pack());
|
|
93
93
|
|
|
94
94
|
const fileName = `${dir}/frame-${i}.png`;
|
|
95
|
-
fs.
|
|
95
|
+
await fs.promises.writeFile(fileName, pngFrameBuffer);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -46,7 +46,7 @@ export async function renderAllMons(rom, options = {}) {
|
|
|
46
46
|
const reader = new RomReader(rom, config);
|
|
47
47
|
|
|
48
48
|
if (concurrency > 1) {
|
|
49
|
-
await mapLimit(Object.keys(providedMons),
|
|
49
|
+
await mapLimit(Object.keys(providedMons), concurrency, async (monName) => { // so in theory we should be running the function 4 times concurrently now...
|
|
50
50
|
await renderMon(monName, providedMons, reader, rom, {
|
|
51
51
|
side: ["front", "back"],
|
|
52
52
|
variant: ["normal", "shiny"],
|
|
@@ -77,6 +77,7 @@ export async function renderAllIcons(rom, options = {}) {
|
|
|
77
77
|
|
|
78
78
|
const {
|
|
79
79
|
icons: providedIcons = icons,
|
|
80
|
+
concurrency = 4,
|
|
80
81
|
outputDir = "./out",
|
|
81
82
|
} = options;
|
|
82
83
|
|
|
@@ -85,9 +86,16 @@ export async function renderAllIcons(rom, options = {}) {
|
|
|
85
86
|
const config = getRomConfig(rom);
|
|
86
87
|
const reader = new RomReader(rom, config);
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
await
|
|
90
|
-
|
|
89
|
+
if (concurrency > 1) {
|
|
90
|
+
await mapLimit(Object.keys(providedIcons), concurrency, async (itemName) => {
|
|
91
|
+
await renderIcon(itemName, providedIcons, reader, rom, { outputDir });
|
|
92
|
+
console.log(`Done: ${itemName}`);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
for (const itemName of Object.keys(providedIcons)) {
|
|
96
|
+
await renderIcon(itemName, providedIcons, reader, rom, { outputDir });
|
|
97
|
+
console.log(`Done: ${itemName}`);
|
|
98
|
+
}
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
|
|
@@ -100,6 +108,7 @@ export async function renderAllTrainers(rom, options = {}) {
|
|
|
100
108
|
trainers: providedTrainers = trainers,
|
|
101
109
|
trainersBack: providedBackTrainers = trainersBack,
|
|
102
110
|
trainerBackPics = true,
|
|
111
|
+
concurrency = 4,
|
|
103
112
|
outputDir = "./out",
|
|
104
113
|
} = options;
|
|
105
114
|
|
|
@@ -108,18 +117,29 @@ export async function renderAllTrainers(rom, options = {}) {
|
|
|
108
117
|
const config = getRomConfig(rom);
|
|
109
118
|
const reader = new RomReader(rom, config);
|
|
110
119
|
|
|
111
|
-
|
|
112
|
-
await
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
if (concurrency > 1) {
|
|
121
|
+
await mapLimit(Object.keys(providedTrainers), concurrency, async (trainerName) => {
|
|
122
|
+
await renderTrainer(trainerName, providedTrainers, providedBackTrainers, reader, rom, {
|
|
123
|
+
trainerBackPics,
|
|
124
|
+
outputDir
|
|
125
|
+
});
|
|
115
126
|
});
|
|
116
127
|
console.log(`Done: ${trainerName}`);
|
|
128
|
+
} else {
|
|
129
|
+
for (const trainerName of Object.keys(providedTrainers)) {
|
|
130
|
+
await renderTrainer(trainerName, providedTrainers, providedBackTrainers, reader, rom, {
|
|
131
|
+
trainerBackPics,
|
|
132
|
+
outputDir
|
|
133
|
+
});
|
|
134
|
+
console.log(`Done: ${trainerName}`);
|
|
135
|
+
}
|
|
117
136
|
}
|
|
118
137
|
}
|
|
119
138
|
|
|
120
139
|
export async function renderAllMoves(rom, options = {}) {
|
|
121
140
|
const {
|
|
122
141
|
moves: providedMoves = moves,
|
|
142
|
+
concurrency = 4,
|
|
123
143
|
outputDir = "./out",
|
|
124
144
|
renderMasterImage = true,
|
|
125
145
|
sortUnused = true,
|
|
@@ -130,19 +150,31 @@ export async function renderAllMoves(rom, options = {}) {
|
|
|
130
150
|
const config = getRomConfig(rom);
|
|
131
151
|
const reader = new RomReader(rom, config);
|
|
132
152
|
|
|
133
|
-
|
|
134
|
-
await
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
153
|
+
if (concurrency > 1) {
|
|
154
|
+
await mapLimit(Object.keys(providedMoves), concurrency, async (moveName) => {
|
|
155
|
+
await renderMove(moveName, providedMoves, reader, rom, {
|
|
156
|
+
outputDir,
|
|
157
|
+
renderMasterImage,
|
|
158
|
+
sortUnused,
|
|
159
|
+
});
|
|
160
|
+
console.log(`Done: ${moveName}`);
|
|
138
161
|
});
|
|
139
|
-
|
|
162
|
+
} else {
|
|
163
|
+
for (const moveName of Object.keys(providedMoves)) {
|
|
164
|
+
await renderMove(moveName, providedMoves, reader, rom, {
|
|
165
|
+
outputDir,
|
|
166
|
+
renderMasterImage,
|
|
167
|
+
sortUnused,
|
|
168
|
+
});
|
|
169
|
+
console.log(`Done: ${moveName}`);
|
|
170
|
+
}
|
|
140
171
|
}
|
|
141
172
|
}
|
|
142
173
|
|
|
143
174
|
export async function renderAllBalls(rom, options = {}) {
|
|
144
175
|
const {
|
|
145
176
|
balls: providedBalls = balls,
|
|
177
|
+
concurrency = 4,
|
|
146
178
|
outputDir = "./out",
|
|
147
179
|
ballParticles = true,
|
|
148
180
|
renderMasterBallImage = true,
|
|
@@ -154,14 +186,26 @@ export async function renderAllBalls(rom, options = {}) {
|
|
|
154
186
|
const config = getRomConfig(rom);
|
|
155
187
|
const reader = new RomReader(rom, config);
|
|
156
188
|
|
|
157
|
-
|
|
158
|
-
await
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
189
|
+
if (concurrency > 1) {
|
|
190
|
+
await mapLimit(Object.keys(providedBalls), concurrency, async (ballName) => {
|
|
191
|
+
await renderBall(ballName, providedBalls, reader, rom, {
|
|
192
|
+
outputDir,
|
|
193
|
+
ballParticles,
|
|
194
|
+
renderMasterBallImage,
|
|
195
|
+
renderMasterBallParticleImage,
|
|
196
|
+
});
|
|
197
|
+
console.log(`Done: ${ballName}`);
|
|
198
|
+
})
|
|
199
|
+
} else {
|
|
200
|
+
for (const ballName of Object.keys(providedBalls)) {
|
|
201
|
+
await renderBall(ballName, providedBalls, reader, rom, {
|
|
202
|
+
outputDir,
|
|
203
|
+
ballParticles,
|
|
204
|
+
renderMasterBallImage,
|
|
205
|
+
renderMasterBallParticleImage,
|
|
206
|
+
});
|
|
207
|
+
console.log(`Done: ${ballName}`);
|
|
208
|
+
}
|
|
165
209
|
}
|
|
166
210
|
}
|
|
167
211
|
|
|
@@ -188,21 +232,25 @@ export async function renderAllGraphics(rom, options = {}) { // eventually I wil
|
|
|
188
232
|
});
|
|
189
233
|
|
|
190
234
|
await renderAllIcons(rom, {
|
|
235
|
+
concurrency,
|
|
191
236
|
outputDir: outputIconDir,
|
|
192
237
|
});
|
|
193
238
|
|
|
194
239
|
await renderAllTrainers(rom, {
|
|
240
|
+
concurrency,
|
|
195
241
|
outputDir: outputTrainerDir,
|
|
196
242
|
trainerBackPics: true,
|
|
197
243
|
});
|
|
198
244
|
|
|
199
245
|
await renderAllMoves(rom, {
|
|
246
|
+
concurrency,
|
|
200
247
|
outputDir: outputMoveDir,
|
|
201
248
|
renderMasterImage: true,
|
|
202
249
|
sortUnused: sortUnusedMoves,
|
|
203
250
|
});
|
|
204
251
|
|
|
205
252
|
await renderAllBalls(rom, {
|
|
253
|
+
concurrency,
|
|
206
254
|
outputDir: outputBallDir,
|
|
207
255
|
ballParticles: true,
|
|
208
256
|
renderMasterBallImage: true,
|
|
@@ -50,9 +50,9 @@ export async function renderIcon(itemName, items, reader, rom, options = {}) {
|
|
|
50
50
|
|
|
51
51
|
if (outputDir) {
|
|
52
52
|
const dir = `${outputDir}/${itemName}`;
|
|
53
|
-
|
|
53
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
54
54
|
const fileName = `${dir}/icon.png`;
|
|
55
|
-
fs.
|
|
55
|
+
await fs.promises.writeFile(fileName, pngBuffer);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return pngBuffer;
|
|
@@ -75,12 +75,12 @@ export async function renderMove(moveName, moves, reader, rom, options = {}) {
|
|
|
75
75
|
if (outputDir) { // I will update this later but in theory it should also work... eventually though it will need a split inside to handle full image generation :p
|
|
76
76
|
const rootDir = (sortUnused && move?.unused === true)? `${outputDir}/unused` : `${outputDir}`
|
|
77
77
|
const dir = `${rootDir}/${moveName}`;
|
|
78
|
-
|
|
78
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
79
79
|
if (renderMasterImage) {
|
|
80
80
|
const png = new PNG({ width, height });
|
|
81
81
|
png.data = image;
|
|
82
82
|
const pngBuffer = await streamToBuffer(png.pack());
|
|
83
|
-
fs.
|
|
83
|
+
await fs.promises.writeFile(`${dir}/master.png`, pngBuffer);
|
|
84
84
|
}
|
|
85
85
|
for (let i = 0; i < move.frames.length; i++) {
|
|
86
86
|
const frame = move.frames[i];
|
|
@@ -91,7 +91,7 @@ export async function renderMove(moveName, moves, reader, rom, options = {}) {
|
|
|
91
91
|
const pngBuffer = await streamToBuffer(png.pack());
|
|
92
92
|
|
|
93
93
|
const fileName = `${dir}/frame-${i}.png`;
|
|
94
|
-
fs.
|
|
94
|
+
await fs.promises.writeFile(fileName, pngBuffer);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -75,11 +75,11 @@ export async function renderTrainerBackPic(trainerName, trainers, reader, rom, o
|
|
|
75
75
|
|
|
76
76
|
if (outputDir) {
|
|
77
77
|
const dir = `${outputDir}/${trainerName}`;
|
|
78
|
-
|
|
79
|
-
fs.
|
|
80
|
-
fs.
|
|
81
|
-
fs.
|
|
82
|
-
fs.
|
|
78
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
79
|
+
await fs.promises.writeFile(`${dir}/trainer_back_frame_1.png`, buffer1);
|
|
80
|
+
await fs.promises.writeFile(`${dir}/trainer_back_frame_2.png`, buffer2);
|
|
81
|
+
await fs.promises.writeFile(`${dir}/trainer_back_frame_3.png`, buffer3);
|
|
82
|
+
await fs.promises.writeFile(`${dir}/trainer_back_frame_4.png`, buffer4);
|
|
83
83
|
if (frame5) {
|
|
84
84
|
const pngFrame5 = new PNG({ width, height: frameHeight });
|
|
85
85
|
pngFrame5.data = frame5;
|
|
@@ -66,9 +66,9 @@ export async function renderTrainer(trainerName, trainers, backTrainers, reader,
|
|
|
66
66
|
|
|
67
67
|
if (outputDir) {
|
|
68
68
|
const dir = `${outputDir}/${trainerName}`;
|
|
69
|
-
|
|
69
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
70
70
|
const fileName = `${dir}/trainer_front.png`;
|
|
71
|
-
fs.
|
|
71
|
+
await fs.promises.writeFile(fileName, pngBuffer);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
return pngBuffer;
|