refactor: move reskin pipeline from scripts/ to tools/reskin/

Move all reskin Python scripts, shell wrappers, and documentation
into a self-contained tools/reskin/ directory. All 44 tests pass
after the move with no path reference updates needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mike LiuandClaude Opus 4.6 committed 2026-03-03 21:09:06 +00:00
1 parent 7b480ede61
commit 73dbcbe581
25 files changed
+62 -62

No files matched your search

File renamed without changes.
@@ -104,9 +104,9 @@ if [[ "$rebuild" -eq 1 && -n "$cli_cmd" && ! -x "$cli_cmd" ]]; then
exit 1
fi
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
overlay_builder="$repo_root/scripts/create-reskin-overlay.sh"
upload_builder="$repo_root/scripts/build-reskin-upload.sh"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
overlay_builder="$repo_root/tools/reskin/create-overlay.sh"
upload_builder="$repo_root/tools/reskin/build-upload.sh"
if [[ ! -x "$overlay_builder" ]]; then
echo "Missing executable script: $overlay_builder" >&2
File renamed without changes.
File renamed without changes.
@@ -14,7 +14,7 @@ Each workspace must contain:
- object-path-in-assets-zip.txt
- reskinned.parkobj (for .parkobj targets) OR object.json (for .json targets)
The generated overlay can be consumed by scripts/build-reskin-upload.sh.
The generated overlay can be consumed by tools/reskin/build-upload.sh.
EOF
}
@@ -43,7 +43,7 @@ for workspace_dir in "$@"; do
object_path_file="$workspace_dir/object-path-in-assets-zip.txt"
if [[ ! -f "$object_path_file" ]]; then
echo "Missing workspace metadata file: $object_path_file" >&2
echo "Re-run scripts/init-reskin-object-workspace.sh for this workspace." >&2
echo "Re-run tools/reskin/init-workspace.sh for this workspace." >&2
exit 1
fi
File renamed without changes.
@@ -11,7 +11,7 @@ This guide uses scripts in this repo to create editable object workspaces from a
## 1) Initialize an editable workspace
```bash
scripts/init-reskin-object-workspace.sh \
tools/reskin/init-workspace.sh \
/Users/meiliu/Downloads/openrct2-upload.zip \
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
/Users/meiliu/git/rosebud/OpenRCT2-Web/reskin-workbench/support-structure-half
@@ -48,7 +48,7 @@ Outputs:
## 4) Build a patched upload zip
```bash
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
--rebuild \
/Users/meiliu/Downloads/openrct2-upload.zip \
/tmp/openrct2-upload-reskinned.zip \
@@ -58,7 +58,7 @@ scripts/build-reskin-object-upload.sh \
This command rebuilds the workspace artifact, maps it to the original object path from `object-path-in-assets-zip.txt`, and writes a patched upload zip.
For additional options and multi-object packaging, see:
`docs/reskin-pipeline.md`
`tools/reskin/docs/pipeline.md`
## Notes
@@ -4,9 +4,9 @@ This pipeline packages object reskins into a playable OpenRCT2 web upload zip.
It is built from these scripts:
- `scripts/init-reskin-object-workspace.sh`
- `scripts/build-reskin-object-upload.sh`
- `scripts/build-reskin-upload.sh`
- `tools/reskin/init-workspace.sh`
- `tools/reskin/build-object-upload.sh`
- `tools/reskin/build-upload.sh`
## Prerequisites
@@ -17,7 +17,7 @@ It is built from these scripts:
## 1) Initialize one or more workspaces
```bash
scripts/init-reskin-object-workspace.sh \
tools/reskin/init-workspace.sh \
/Users/meiliu/Downloads/openrct2-upload.zip \
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
./reskin-workbench/support-structure-half
@@ -34,7 +34,7 @@ Edit PNGs under each workspace `sprites/` directory.
For one workspace:
```bash
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
--rebuild \
/Users/meiliu/Downloads/openrct2-upload.zip \
/tmp/openrct2-upload-reskinned.zip \
@@ -44,7 +44,7 @@ scripts/build-reskin-object-upload.sh \
For multiple workspaces:
```bash
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
--rebuild \
/Users/meiliu/Downloads/openrct2-upload.zip \
/tmp/openrct2-upload-reskinned.zip \
@@ -57,7 +57,7 @@ If you already rebuilt the workspace artifacts, omit `--rebuild`.
## Optional: Keep the generated overlay for inspection
```bash
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
--rebuild \
--overlay-dir /tmp/reskin-overlay \
/Users/meiliu/Downloads/openrct2-upload.zip \
@@ -68,7 +68,7 @@ scripts/build-reskin-object-upload.sh \
## Optional: Use a custom `openrct2-cli` command
```bash
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
--rebuild \
--cli-cmd ./scripts/openrct2-cli-docker.sh \
/Users/meiliu/Downloads/openrct2-upload.zip \
@@ -11,11 +11,11 @@ The existing OpenRCT2-Web reskin workflow requires manual sprite editing. The ot
OR
Arbitrary sprite PNG directories
|
scripts/reskin/batch_sprites.py <- generic: creates 4x4 grids + manifest.json
tools/reskin/batch_sprites.py <- generic: creates 4x4 grids + manifest.json
|
scripts/reskin/generate_restyled.py <- generic: sends grids to FAL.ai Gemini 3 Pro
tools/reskin/generate_restyled.py <- generic: sends grids to FAL.ai Gemini 3 Pro
|
scripts/reskin/parse_restyled.py <- generic: extracts sprites, restores alpha, blends edges
tools/reskin/parse_restyled.py <- generic: extracts sprites, restores alpha, blends edges
|
Restyled PNGs back in workspace sprites/ dir
|
@@ -26,11 +26,11 @@ rebuild-object.sh -> create-reskin-overlay.sh -> build-reskin-upload.sh (existi
| File | Role |
|------|------|
| `scripts/reskin/categories.py` | Category configs: style prompts, tiling flags, description hints. Starts with scenery presets, extensible. |
| `scripts/reskin/batch_sprites.py` | Scans a sprite directory, groups by size into 4x4 grids (2048x2048), writes manifest.json. Game-agnostic. |
| `scripts/reskin/generate_restyled.py` | Reads manifest, sends each grid to FAL.ai Gemini 3 Pro, saves restyled grids. |
| `scripts/reskin/parse_restyled.py` | Extracts sprites from AI grids using manifest coordinates, restores original alpha masks, blends tile edges. |
| `scripts/reskin/reskin.py` | Orchestrator: chains batch -> generate -> parse. Supports `--step` and `--through`. |
| `tools/reskin/categories.py` | Category configs: style prompts, tiling flags, description hints. Starts with scenery presets, extensible. |
| `tools/reskin/batch_sprites.py` | Scans a sprite directory, groups by size into 4x4 grids (2048x2048), writes manifest.json. Game-agnostic. |
| `tools/reskin/generate_restyled.py` | Reads manifest, sends each grid to FAL.ai Gemini 3 Pro, saves restyled grids. |
| `tools/reskin/parse_restyled.py` | Extracts sprites from AI grids using manifest coordinates, restores original alpha masks, blends tile edges. |
| `tools/reskin/reskin.py` | Orchestrator: chains batch -> generate -> parse. Supports `--step` and `--through`. |
## Adaptations from ottd pipeline
@@ -55,32 +55,32 @@ rebuild-object.sh -> create-reskin-overlay.sh -> build-reskin-upload.sh (existi
```bash
# 1. Init workspace (existing)
scripts/init-reskin-object-workspace.sh \
tools/reskin/init-workspace.sh \
upload.zip \
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
./reskin-workbench/support-structure
# 2. AI reskin (NEW)
python3 scripts/reskin/reskin.py \
python3 tools/reskin/reskin.py \
--workspace ./reskin-workbench/support-structure \
--style "Cartoony hand-painted fantasy. Bold outlines, vibrant colors." \
--through generate
# 3. Review, then apply
python3 scripts/reskin/reskin.py \
python3 tools/reskin/reskin.py \
--workspace ./reskin-workbench/support-structure \
--step parse
# 4. Rebuild + package (existing)
./reskin-workbench/support-structure/rebuild-object.sh
scripts/build-reskin-object-upload.sh \
tools/reskin/build-object-upload.sh \
upload.zip /tmp/reskinned.zip ./reskin-workbench/support-structure
```
### Standalone mode (any PNGs)
```bash
python3 scripts/reskin/reskin.py \
python3 tools/reskin/reskin.py \
--sprites-dir ./my-sprites/ \
--style "Pixel art, 16-bit SNES style" \
--tiling
@@ -4,7 +4,7 @@
**Goal:** Add AI-powered sprite reskinning scripts that batch OpenRCT2 sprite PNGs into grids, send them to FAL.ai for restyling, and extract the results back — integrating with the existing workspace/overlay/upload pipeline.
**Architecture:** Five Python scripts under `scripts/reskin/`. The core pipeline is game-agnostic (batch PNGs into grids, call FAL.ai, extract results). An orchestrator script (`reskin.py`) provides both workspace mode (integrates with `init-reskin-object-workspace.sh` outputs) and standalone mode (any directory of PNGs). Category presets in `categories.py` provide reusable style configs.
**Architecture:** Five Python scripts under `tools/reskin/`. The core pipeline is game-agnostic (batch PNGs into grids, call FAL.ai, extract results). An orchestrator script (`reskin.py`) provides both workspace mode (integrates with `init-reskin-object-workspace.sh` outputs) and standalone mode (any directory of PNGs). Category presets in `categories.py` provide reusable style configs.
**Tech Stack:** Python 3.8+, Pillow, numpy, fal-client. FAL.ai Gemini 3 Pro image-edit API.
@@ -16,18 +16,18 @@ The source code being adapted lives at `/workspace/ottd-reskin-pipeline/`. Key f
| ottd file | Becomes | What changes |
|-----------|---------|--------------|
| `batch_env.py` | `scripts/reskin/batch_sprites.py` | Remove NFO parsing. Input is just a PNG directory. No sprite ID ranges — discover files from disk. |
| `generate_restyled.py` | `scripts/reskin/generate_restyled.py` | Nearly identical. Update default paths. Keep FAL.ai logic as-is. |
| `parse_and_replace.py` | `scripts/reskin/parse_restyled.py` | Remove GRF rebuild / sheet patching. Output is restyled PNGs to a target dir. Keep alpha restore + edge blending. |
| `restyle_env.py` | `scripts/reskin/reskin.py` | Replace subprocess calls with direct function imports. Add `--workspace` mode. |
| `env_categories.py` | `scripts/reskin/categories.py` | Replace zBase sprite ID ranges with OpenRCT2 style presets (scenery, terrain, rides). No ID ranges needed. |
| `batch_env.py` | `tools/reskin/batch_sprites.py` | Remove NFO parsing. Input is just a PNG directory. No sprite ID ranges — discover files from disk. |
| `generate_restyled.py` | `tools/reskin/generate_restyled.py` | Nearly identical. Update default paths. Keep FAL.ai logic as-is. |
| `parse_and_replace.py` | `tools/reskin/parse_restyled.py` | Remove GRF rebuild / sheet patching. Output is restyled PNGs to a target dir. Keep alpha restore + edge blending. |
| `restyle_env.py` | `tools/reskin/reskin.py` | Replace subprocess calls with direct function imports. Add `--workspace` mode. |
| `env_categories.py` | `tools/reskin/categories.py` | Replace zBase sprite ID ranges with OpenRCT2 style presets (scenery, terrain, rides). No ID ranges needed. |
## Reference: existing OpenRCT2-Web reskin scripts
- `scripts/init-reskin-object-workspace.sh` — creates `<workspace>/sprites/` with exported PNGs + `sprites.json`
- `tools/reskin/init-workspace.sh` — creates `<workspace>/sprites/` with exported PNGs + `sprites.json`
- `<workspace>/rebuild-object.sh` — rebuilds `images.dat` + `reskinned.parkobj` from sprites
- `scripts/create-reskin-overlay.sh` — maps workspaces into overlay dirs
- `scripts/build-reskin-upload.sh` — merges overlays into web upload zip
- `tools/reskin/create-overlay.sh` — maps workspaces into overlay dirs
- `tools/reskin/build-upload.sh` — merges overlays into web upload zip
The new Python pipeline slots in between steps 1 and the rebuild: it reads from `sprites/`, writes restyled PNGs back there (or to a separate output dir).
@@ -36,7 +36,7 @@ The new Python pipeline slots in between steps 1 and the rebuild: it reads from
### Task 1: `categories.py` — Style preset definitions
**Files:**
- Create: `scripts/reskin/categories.py`
- Create: `tools/reskin/categories.py`
**Step 1: Create the categories module**
@@ -108,7 +108,7 @@ CATEGORIES = {
**Step 2: Verify it imports cleanly**
Run: `python3 -c "import sys; sys.path.insert(0, 'scripts/reskin'); from categories import CATEGORIES; print(f'{len(CATEGORIES)} categories loaded')" `
Run: `python3 -c "import sys; sys.path.insert(0, 'tools/reskin'); from categories import CATEGORIES; print(f'{len(CATEGORIES)} categories loaded')" `
Expected: `6 categories loaded`
**Step 3: Commit**
@@ -122,7 +122,7 @@ Expected: `6 categories loaded`
### Task 2: `batch_sprites.py` — Grid batching
**Files:**
- Create: `scripts/reskin/batch_sprites.py`
- Create: `tools/reskin/batch_sprites.py`
This is adapted from `/workspace/ottd-reskin-pipeline/batch_env.py`. Key changes:
- No NFO parsing — sprites come from a flat PNG directory
@@ -373,7 +373,7 @@ if __name__ == "__main__":
**Step 2: Write a smoke test**
Create `scripts/reskin/test_batch_sprites.py`:
Create `tools/reskin/test_batch_sprites.py`:
```python
"""Smoke tests for batch_sprites.py."""
@@ -474,7 +474,7 @@ def test_batch_sprites_end_to_end():
**Step 3: Run tests**
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_batch_sprites.py -v`
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest tools/reskin/test_batch_sprites.py -v`
Expected: All 6 tests PASS.
**Step 4: Commit**
@@ -488,7 +488,7 @@ Expected: All 6 tests PASS.
### Task 3: `generate_restyled.py` — FAL.ai generation
**Files:**
- Create: `scripts/reskin/generate_restyled.py`
- Create: `tools/reskin/generate_restyled.py`
Adapted from `/workspace/ottd-reskin-pipeline/generate_restyled.py`. Changes:
- Update default paths to match our directory layout
@@ -724,7 +724,7 @@ if __name__ == "__main__":
**Step 2: Write tests for the non-API functions**
Add to `scripts/reskin/test_generate_restyled.py`:
Add to `tools/reskin/test_generate_restyled.py`:
```python
"""Tests for generate_restyled.py (non-API functions only)."""
@@ -787,7 +787,7 @@ def test_load_descriptions_missing_file():
**Step 3: Run tests**
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_generate_restyled.py -v`
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest tools/reskin/test_generate_restyled.py -v`
Expected: All 4 tests PASS.
**Step 4: Commit**
@@ -801,7 +801,7 @@ Expected: All 4 tests PASS.
### Task 4: `parse_restyled.py` — Extract and restore sprites
**Files:**
- Create: `scripts/reskin/parse_restyled.py`
- Create: `tools/reskin/parse_restyled.py`
Adapted from `/workspace/ottd-reskin-pipeline/parse_and_replace.py`. Changes:
- Remove `patch_sprite_sheets()` and `rebuild_grf()` — not needed for OpenRCT2
@@ -1091,7 +1091,7 @@ if __name__ == "__main__":
**Step 2: Write tests**
Create `scripts/reskin/test_parse_restyled.py`:
Create `tools/reskin/test_parse_restyled.py`:
```python
"""Tests for parse_restyled.py."""
@@ -1203,7 +1203,7 @@ def test_validate_sprite_transparent():
**Step 3: Run tests**
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_parse_restyled.py -v`
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest tools/reskin/test_parse_restyled.py -v`
Expected: All 7 tests PASS.
**Step 4: Commit**
@@ -1217,7 +1217,7 @@ Expected: All 7 tests PASS.
### Task 5: `reskin.py` — Orchestrator
**Files:**
- Create: `scripts/reskin/reskin.py`
- Create: `tools/reskin/reskin.py`
This chains batch -> generate -> parse and supports both workspace mode and standalone mode.
@@ -1478,7 +1478,7 @@ if __name__ == "__main__":
**Step 2: Write tests**
Create `scripts/reskin/test_reskin.py`:
Create `tools/reskin/test_reskin.py`:
```python
"""Tests for reskin.py orchestrator."""
@@ -1547,7 +1547,7 @@ def test_resolve_tiling_from_category():
**Step 3: Run tests**
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_reskin.py -v`
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest tools/reskin/test_reskin.py -v`
Expected: All 6 tests PASS.
**Step 4: Commit**
@@ -1562,22 +1562,22 @@ Expected: All 6 tests PASS.
**Step 1: Run all tests together**
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/ -v`
Run: `cd /workspace/OpenRCT2-Web && python3 -m pytest tools/reskin/ -v`
Expected: All tests pass (6 + 4 + 7 + 6 = 23 tests).
**Step 2: Verify CLI help works**
Run these four commands and verify each prints usage/help:
```bash
python3 scripts/reskin/batch_sprites.py --help
python3 scripts/reskin/generate_restyled.py --help
python3 scripts/reskin/parse_restyled.py --help
python3 scripts/reskin/reskin.py --help
python3 tools/reskin/batch_sprites.py --help
python3 tools/reskin/generate_restyled.py --help
python3 tools/reskin/parse_restyled.py --help
python3 tools/reskin/reskin.py --help
```
**Step 3: Verify category listing**
Run: `python3 scripts/reskin/reskin.py --list-categories`
Run: `python3 tools/reskin/reskin.py --list-categories`
Expected: Lists 6 categories with tiling flags.
**Step 4: Final commit with all files**
@@ -8,13 +8,13 @@ This repo's web package is typically distributed as:
- `assets/rct2-content.zip`
- `assets/openrct2.zip`
Use `scripts/build-reskin-upload.sh` to apply your own files on top of an existing upload zip.
Use `tools/reskin/build-upload.sh` to apply your own files on top of an existing upload zip.
If your inputs come from initialized object workspaces (`reskin-workbench/...`), prefer:
`scripts/build-reskin-object-upload.sh` (see `docs/reskin-pipeline.md`).
`tools/reskin/build-object-upload.sh` (see `tools/reskin/docs/pipeline.md`).
For creating/editing object sprite files first, see:
`docs/object-authoring-workflow.md`
`tools/reskin/docs/object-authoring.md`
## Overlay Structure
@@ -30,7 +30,7 @@ Only include files you want to replace or add.
## Command
```bash
scripts/build-reskin-upload.sh \
tools/reskin/build-upload.sh \
/path/to/openrct2-upload.zip \
/path/to/overlay \
/tmp/openrct2-upload-reskinned.zip
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.