add for actions tab tools

This commit is contained in:
snus xD
2025-07-20 16:23:48 +05:00
parent b1732a14c7
commit c21c444a7b
6874 changed files with 60577 additions and 8 deletions

4332
scripts/data.json Normal file

File diff suppressed because it is too large Load Diff

52
scripts/sort.ts Normal file
View File

@@ -0,0 +1,52 @@
import fs from "node:fs";
const DATA = JSON.parse(fs.readFileSync("data.json", "utf-8"));
const chapters = fs.readdirSync("./sprites/original");
function add_singles(chapter, sprite_name) {
const img_name = `${sprite_name}.png`;
if (!fs.existsSync(`../sprites/translation/${img_name}`)) return;
fs.copyFileSync(
`../sprites/translation/${img_name}`,
`../sprites/sorted/${chapter}/${img_name}`
);
}
function add_animations(chapter, sprite_name) {
if (
fs.existsSync(`../sprites/translation/${sprite_name}`) &&
!fs.existsSync(`../sprites/sorted/${chapter}/${sprite_name}`)
) {
fs.cpSync(
`../sprites/original/${chapter}/${sprite_name}`,
`../sprites/sorted/${chapter}/${sprite_name}`
);
} else return;
const sprite_frames = DATA[chapter][sprite_name];
for (let frame of sprite_frames) {
const img_name = `${sprite_name}_${frame}.png`;
if (!fs.existsSync(`../sprites/translation/${sprite_name}/${img_name}`))
continue;
fs.copyFileSync(
`../sprites/translation/${sprite_name}/${img_name}`,
`../sprites/sorted/${chapter}/${sprite_name}/${img_name}`
);
}
}
for (const chapter of chapters) {
if (!chapter.endsWith(".DS_Store")) {
if (!fs.existsSync(`../sprites/sorted`)) fs.mkdirSync(`../sprites/sorted`);
if (!fs.existsSync(`../sprites/sorted/${chapter}`))
fs.mkdirSync(`../sprites/sorted/${chapter}`);
for (const sprite of Object.keys(DATA[chapter])) {
const frames: any[] = DATA[chapter][sprite];
if (frames.length == 1) add_singles(chapter, sprite);
else add_animations(chapter, sprite);
}
}
}

56
scripts/write.ts Normal file
View File

@@ -0,0 +1,56 @@
import fs from "node:fs";
const PATHS = {
ORIGINAL: "../sprites/original",
TRANSLATE: "../sprites/translation",
};
let DATA = {};
// Сбор списка глав
for (const chapter of fs.readdirSync(PATHS.ORIGINAL)) {
if (chapter != ".DS_Store") DATA[chapter] = {};
}
// Внос всех одно-кадровых спрайтов
function add_singles(path) {
const chapter_dir = fs.readdirSync(path, "utf-8");
let temp = {};
for (const sprite of chapter_dir)
if (sprite.includes(".png")) temp[sprite.slice(0, -4)] = [0];
return temp;
}
// Внос всех много-кадровых спрайтов
function add_animations(path) {
const chapter_dir = fs.readdirSync(path, "utf-8");
let temp = {};
for (const sprite of chapter_dir) {
if (!(sprite.endsWith(".png") || sprite.endsWith(".DS_Store"))) {
let frames = new Array();
const animation_dir = fs.readdirSync(`${path}/${sprite}`, "utf-8");
for (let frame of animation_dir) {
let frame_number = frame.split("_").at(-1) ?? "fuck";
if (frame.endsWith(".png"))
frames.push(Number(frame_number.slice(0, -4)));
}
temp[sprite] = frames.sort();
}
}
return temp;
}
for (const chapter of Object.keys(DATA)) {
const chapter_path = `${PATHS.ORIGINAL}/${chapter}`;
DATA[chapter] = {
...add_animations(chapter_path),
...add_singles(chapter_path),
};
}
fs.writeFileSync("./data.json", JSON.stringify(DATA));