mirror of
https://github.com/smogon/sprites.git
synced 2026-03-21 17:35:13 -05:00
tools/ps-sheet -> tools/sheet, take js sheet spec as arg
This commit is contained in:
parent
9f3ccad640
commit
39eec46241
|
|
@ -26,9 +26,9 @@ rule{
|
|||
|
||||
rule{
|
||||
display="ps trainers sheet",
|
||||
input={},
|
||||
input={"ps-trainers.sheet.mjs"},
|
||||
command={
|
||||
"node tools/ps-sheet trainers src/canonical/trainers %o",
|
||||
"node tools/sheet %f %o",
|
||||
compresspng{config="SPRITESHEET"}
|
||||
},
|
||||
output={"build/ps/trainers-sheet.png"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Derived from pokemon-showdown-client/src/battle-dex-data.ts
|
||||
export default {
|
||||
const BattleAvatarNumbers = {
|
||||
1: 'lucas',
|
||||
2: 'dawn',
|
||||
3: 'youngster-gen4',
|
||||
|
|
@ -297,3 +302,17 @@ export default {
|
|||
// Not in the existing trainer sheet...
|
||||
// 294: 'ash',
|
||||
}
|
||||
|
||||
|
||||
const entries = [];
|
||||
|
||||
for (const [num, id] of Object.entries(BattleAvatarNumbers)) {
|
||||
entries[num - 1] = path.join(__dirname, "src/canonical/trainers", id + ".png");
|
||||
}
|
||||
|
||||
export default {
|
||||
width: 80,
|
||||
height: 80,
|
||||
tile: 16,
|
||||
entries
|
||||
};
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
import cp from 'child_process';
|
||||
import path from 'path';
|
||||
import BattleAvatarNumbers from './data-trainers.js';
|
||||
|
||||
const type = process.argv[2];
|
||||
const dir = process.argv[3];
|
||||
const dest = process.argv[4];
|
||||
|
||||
if (!dir || !dest) {
|
||||
throw new Error(`node tools/ps-sheet <type> <dir> <dest>`);
|
||||
}
|
||||
|
||||
if (type === 'trainers') {
|
||||
// Guaranteed to be in the right order by V8, but iirc not by other JS engines.
|
||||
const trainers = Object.values(BattleAvatarNumbers).map(t => path.join(dir, t) + ".png");
|
||||
|
||||
cp.execFileSync("montage", [
|
||||
...trainers,
|
||||
"-background", "transparent",
|
||||
"-geometry", "80x80>",
|
||||
"-gravity", "center",
|
||||
"-tile", "16x",
|
||||
"-depth", "8",
|
||||
dest
|
||||
]);
|
||||
} else {
|
||||
throw new Error(`unknown type: ${type}`);
|
||||
}
|
||||
25
tools/sheet/index.js
Normal file
25
tools/sheet/index.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
import cp from 'child_process';
|
||||
import path from 'path';
|
||||
|
||||
const sheetjs = process.argv[2];
|
||||
const dest = process.argv[3];
|
||||
|
||||
if (!sheetjs || !dest) {
|
||||
throw new Error(`node tools/ps-sheet <file.sheet.js> <dest>`);
|
||||
}
|
||||
|
||||
// Top-level await?
|
||||
(async() => {
|
||||
const {default: sheet} = await import(path.join(process.cwd(), sheetjs));
|
||||
|
||||
cp.execFileSync("montage", [
|
||||
...sheet.entries,
|
||||
"-background", "transparent",
|
||||
"-geometry", `${sheet.width}x${sheet.height}>`,
|
||||
"-gravity", "center",
|
||||
"-tile", `${sheet.tile}x`,
|
||||
"-depth", "8",
|
||||
dest
|
||||
]);
|
||||
})();
|
||||
Loading…
Reference in New Issue
Block a user