refactor: just updated scripts for better reading

This commit is contained in:
snus xD
2025-12-24 09:35:53 +03:00
parent 14a1b9d5e7
commit f0b87a6da0
4 changed files with 95 additions and 105 deletions

View File

@@ -1,41 +1,32 @@
import fs from "node:fs";
import { PATHS } from "./shared";
const PATHS = {
ORIGINAL: "../_sprites/original",
TRANSLATE: "../_sprites/translation",
};
let DATA: { [key: string]: any } = {};
let DATA = {};
for (const chapter of fs.readdirSync(PATHS.ORIGINAL)) DATA[chapter] = {};
// Сбор списка глав
for (const chapter of fs.readdirSync(PATHS.ORIGINAL)) {
if (chapter != ".DS_Store") DATA[chapter] = {};
}
function add_singles(path: string) {
const chapter_sprites = fs.readdirSync(path, "utf-8");
const temp: { [key: string]: any } = {};
// Внос всех одно-кадровых спрайтов
function add_singles(path) {
const chapter_dir = fs.readdirSync(path, "utf-8");
let temp = {};
for (const sprite of chapter_dir)
for (const sprite of chapter_sprites)
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 = {};
function add_animations(path: string) {
const chapter_sprites = fs.readdirSync(path, "utf-8");
const temp: { [key: string]: any } = {};
for (const sprite of chapter_dir) {
if (!(sprite.endsWith(".png") || sprite.endsWith(".DS_Store"))) {
let frames = new Array();
for (const sprite of chapter_sprites) {
if (!sprite.endsWith(".png")) {
const 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"))
const animated_sprite = fs.readdirSync(`${path}/${sprite}`, "utf-8");
for (let frame of animated_sprite) {
let frame_number = frame.split("_").at(-1);
if (frame.endsWith(".png") && frame_number !== undefined)
frames.push(Number(frame_number.slice(0, -4)));
}