adding merged sorted zip
This commit is contained in:
87
.github/workflows/main.yml
vendored
87
.github/workflows/main.yml
vendored
@@ -1,10 +1,10 @@
|
|||||||
name: sorting
|
name: sorting
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- '_sprites/**'
|
- "_sprites/**"
|
||||||
- 'scripts/**'
|
- "scripts/**"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -14,40 +14,59 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: "20"
|
||||||
|
|
||||||
- name: requirments
|
- name: requirments
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: scripts
|
- name: setup python
|
||||||
working-directory: ./scripts
|
uses: actions/setup-python@v5
|
||||||
run: |
|
with:
|
||||||
rm -rf ../_sprites/unready
|
python-version: "3.13"
|
||||||
npx tsx write.ts
|
|
||||||
npx tsx sort.ts
|
|
||||||
npx tsx unready_delete.ts
|
|
||||||
|
|
||||||
- name: commit changes (exclude sorted)
|
- name: install python deps
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "action@github.com"
|
python -m pip install --upgrade pip
|
||||||
git config --local user.name "GitHub Action"
|
pip install pillow
|
||||||
git add -A .
|
|
||||||
git reset _sprites/sorted
|
|
||||||
git commit -m "actions update" || exit 0
|
|
||||||
git push
|
|
||||||
|
|
||||||
- name: upload
|
- name: scripts
|
||||||
uses: actions/upload-artifact@v4
|
working-directory: ./scripts
|
||||||
with:
|
run: |
|
||||||
name: sorted
|
rm -rf ../_sprites/unready
|
||||||
path: ./_sprites/sorted
|
npx tsx write.ts
|
||||||
retention-days: 15
|
npx tsx sort.ts
|
||||||
|
npx tsx unready.ts
|
||||||
|
|
||||||
- name: remove temp sorted folder
|
- name: commit changes (exclude sorted)
|
||||||
run: rm -rf ./_sprites/sorted
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git add -A .
|
||||||
|
git reset _sprites/sorted
|
||||||
|
git commit -m "actions update" || exit 0
|
||||||
|
git push
|
||||||
|
|
||||||
|
- name: upload
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: sorted
|
||||||
|
path: ./_sprites/sorted
|
||||||
|
retention-days: 15
|
||||||
|
|
||||||
|
- name: upload-merged
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: sorted
|
||||||
|
path: ./_sprites/sorted-merged
|
||||||
|
retention-days: 15
|
||||||
|
|
||||||
|
- name: remove temp sorted folder
|
||||||
|
run: |
|
||||||
|
rm -rf ./_sprites/sorted
|
||||||
|
rm -rf ./_sprites/sorted-merged
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
!! CAUTION !!
|
|
||||||
Deleting files listed here is IRREVERSIBLE. You won’t be able to restore a deleted file just by removing it from the list. Choose files wisely and don’t regret what you’ve done.
|
|
||||||
You can still get the files back using Git, but it will be a bit harder.
|
|
||||||
|
|
||||||
To delete a file, write its full path.
|
|
||||||
Examples:
|
|
||||||
translation/sp_spr_btrouxls - will delete sprite `sp_spr_btrouxls` in `translation`
|
|
||||||
original/chapter2/bg_dw_bakery.png - will delete sprite `bg_dw_bakery` in `chapter2` inside `original`
|
|
||||||
|
|
||||||
|
|
||||||
DELETE:
|
|
||||||
@@ -1,14 +1,3 @@
|
|||||||
To have a sprite added to the `sorted` folder, you must write its name and chapter in the “UNIQUE FOR SORTING" list!
|
|
||||||
Examples:
|
|
||||||
chapter3/img1 – Adds sprite `img1` to the `chapter3` folder (whether it’s an animation folder or just a single sprite)
|
|
||||||
chapter2/anim2 – Adds sprite `anim2` to the `chapter2` folder (whether it’s an animation folder or just a single sprite)
|
|
||||||
|
|
||||||
If the frame count of an animated sprite differs from the original, you must write its name in the “UNIQUE FRAME COUNT” list!
|
|
||||||
!! ATTENTION !!
|
|
||||||
Do this only if the ENTIRE animation of the sprite is different.
|
|
||||||
If, for example, just one frame is translated and the rest should remain THE SAME, you DO NOT need to add it to the list!
|
|
||||||
|
|
||||||
|
|
||||||
UNIQUE FOR SORTING:
|
UNIQUE FOR SORTING:
|
||||||
chapter1/spr_blockler_и
|
chapter1/spr_blockler_и
|
||||||
chapter1/spr_blockler_с
|
chapter1/spr_blockler_с
|
||||||
|
|||||||
60
scripts/merge.py
Executable file
60
scripts/merge.py
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
in_dir = sys.argv[1]
|
||||||
|
out_dir = sys.argv[2]
|
||||||
|
|
||||||
|
os.makedirs(in_dir, exist_ok=True)
|
||||||
|
os.makedirs(out_dir, exist_ok=True)
|
||||||
|
|
||||||
|
sprs = {}
|
||||||
|
|
||||||
|
for item in os.listdir(in_dir):
|
||||||
|
item_path = os.path.join(in_dir, item)
|
||||||
|
|
||||||
|
if os.path.isfile(item_path) and item.lower().endswith('.png'):
|
||||||
|
shutil.copy2(item_path, os.path.join(out_dir, item))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not os.path.isdir(item_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
frames = []
|
||||||
|
for frame_file in os.listdir(item_path):
|
||||||
|
if not frame_file.lower().endswith('.png'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
frame_num = int(frame_file.split('_')[-1].split('.')[0])
|
||||||
|
frames.append((frame_num, frame_file))
|
||||||
|
except (IndexError, ValueError):
|
||||||
|
continue
|
||||||
|
|
||||||
|
frames.sort(key=lambda x: x[0])
|
||||||
|
sprs[item] = []
|
||||||
|
|
||||||
|
for _, frame_file in frames:
|
||||||
|
try:
|
||||||
|
img = Image.open(os.path.join(item_path, frame_file))
|
||||||
|
sprs[item].append(img)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Ошибка загрузки {frame_file}: {e}")
|
||||||
|
|
||||||
|
for spr_name, images in sprs.items():
|
||||||
|
if not images:
|
||||||
|
continue
|
||||||
|
|
||||||
|
width = images[0].width
|
||||||
|
height = images[0].height
|
||||||
|
total_width = width * len(images)
|
||||||
|
|
||||||
|
sprite_sheet = Image.new('RGBA', (total_width, height))
|
||||||
|
|
||||||
|
for i, img in enumerate(images):
|
||||||
|
sprite_sheet.paste(img, (i * width, 0))
|
||||||
|
|
||||||
|
output_path = os.path.join(out_dir, f"{spr_name}.png")
|
||||||
|
sprite_sheet.save(output_path)
|
||||||
|
print(f"Создан: {output_path} ({len(images)} кадров)")
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
|
import { spawn } from "child_process";
|
||||||
|
|
||||||
const SPECIALS = ["sp", "spm"];
|
const SPECIALS = ["sp", "spm"];
|
||||||
const DATA = JSON.parse(fs.readFileSync("./data.json", "utf-8"));
|
const DATA = JSON.parse(fs.readFileSync("./data.json", "utf-8"));
|
||||||
@@ -19,8 +20,6 @@ UNIQUES_FRAMES?.shift();
|
|||||||
while (UNIQUES_NAMES?.at(-1) == "") UNIQUES_NAMES?.pop();
|
while (UNIQUES_NAMES?.at(-1) == "") UNIQUES_NAMES?.pop();
|
||||||
while (UNIQUES_FRAMES?.at(-1) == "") UNIQUES_FRAMES?.pop();
|
while (UNIQUES_FRAMES?.at(-1) == "") UNIQUES_FRAMES?.pop();
|
||||||
|
|
||||||
export const SHARED = UNIQUES_FRAMES;
|
|
||||||
|
|
||||||
function add_singles(chapter, sprite_name) {
|
function add_singles(chapter, sprite_name) {
|
||||||
const img_name = `${sprite_name}.png`;
|
const img_name = `${sprite_name}.png`;
|
||||||
if (!fs.existsSync(`../_sprites/translation/${img_name}`)) return;
|
if (!fs.existsSync(`../_sprites/translation/${img_name}`)) return;
|
||||||
@@ -141,3 +140,11 @@ if (UNIQUES_NAMES != undefined) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const chapter of chapters) {
|
||||||
|
spawn("python3", [
|
||||||
|
"merge.py",
|
||||||
|
`../_sprites/sorted/${chapter}`,
|
||||||
|
`../_sprites/sorted-merged/${chapter}`,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,30 +2,6 @@ import fs from "node:fs";
|
|||||||
|
|
||||||
const CHAPTERS = JSON.parse(fs.readFileSync("./data.json", "utf-8"));
|
const CHAPTERS = JSON.parse(fs.readFileSync("./data.json", "utf-8"));
|
||||||
|
|
||||||
const DELETE = fs
|
|
||||||
.readFileSync("../_sprites/delete.txt", "utf-8")
|
|
||||||
.split("DELETE:")
|
|
||||||
.at(-1)
|
|
||||||
?.split("\n");
|
|
||||||
|
|
||||||
DELETE?.shift();
|
|
||||||
if (DELETE?.at(-1) == "") DELETE?.pop();
|
|
||||||
|
|
||||||
if (DELETE != undefined) {
|
|
||||||
for (const del of DELETE) {
|
|
||||||
if (fs.existsSync(`../_sprites/${del}`))
|
|
||||||
fs.rmSync(`../_sprites/${del}`, {
|
|
||||||
recursive: true,
|
|
||||||
force: true,
|
|
||||||
});
|
|
||||||
else if (fs.existsSync(`../_sprites/${del}.png`))
|
|
||||||
fs.rmSync(`../_sprites/${del}.png`, {
|
|
||||||
recursive: true,
|
|
||||||
force: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const UNIQUES = fs
|
const UNIQUES = fs
|
||||||
.readFileSync("../_sprites/unique.txt", "utf-8")
|
.readFileSync("../_sprites/unique.txt", "utf-8")
|
||||||
.split("UNIQUE FOR SORTING:")
|
.split("UNIQUE FOR SORTING:")
|
||||||
Reference in New Issue
Block a user