forked from rosebudai/OpenRCT2-Web
Add web upload asset reskin pipeline scripts and docs
This commit is contained in:
8 files changed
+863
No files matched your search
@@ -0,0 +1,67 @@
|
||||
# Object Authoring Workflow (PNG -> images.dat -> .parkobj)
|
||||
|
||||
This guide uses scripts in this repo to create editable object workspaces from an existing web upload package.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Input upload zip (example: `/Users/meiliu/Downloads/openrct2-upload.zip`)
|
||||
- Docker available (used by `scripts/openrct2-cli-docker.sh`)
|
||||
- `build-native/openrct2-cli` built once (the wrapper prints the exact build command if missing)
|
||||
|
||||
## 1) Initialize an editable workspace
|
||||
|
||||
```bash
|
||||
scripts/init-reskin-object-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
|
||||
```
|
||||
|
||||
Workspace contents:
|
||||
|
||||
- `object.json`: object metadata and IDs
|
||||
- `images.dat`: current sprite archive
|
||||
- `object-path-in-assets-zip.txt`: target file path inside `assets/assets.zip`
|
||||
- `sprites/*.png`: editable sprite frames
|
||||
- `sprites.json`: sprite manifest used to rebuild `images.dat`
|
||||
- `rebuild-object.sh`: one-command rebuild and pack
|
||||
|
||||
## 2) Edit sprite PNGs
|
||||
|
||||
Edit files in:
|
||||
|
||||
`/Users/meiliu/git/rosebud/OpenRCT2-Web/reskin-workbench/support-structure-half/sprites/`
|
||||
|
||||
Keep sprite count/order stable unless you intentionally update `object.json` image ranges.
|
||||
|
||||
## 3) Rebuild the object
|
||||
|
||||
```bash
|
||||
/Users/meiliu/git/rosebud/OpenRCT2-Web/reskin-workbench/support-structure-half/rebuild-object.sh
|
||||
```
|
||||
|
||||
Outputs:
|
||||
|
||||
- `images.dat`
|
||||
- `reskinned.parkobj`
|
||||
|
||||
## 4) Build a patched upload zip
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
/Users/meiliu/git/rosebud/OpenRCT2-Web/reskin-workbench/support-structure-half
|
||||
```
|
||||
|
||||
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`
|
||||
|
||||
## Notes
|
||||
|
||||
- `scripts/openrct2-cli-docker.sh` runs `openrct2-cli` inside Docker and mirrors your current repo subdirectory as container working directory.
|
||||
- `init-reskin-object-workspace.sh` filters non-JSON log lines from export output so `sprites.json` stays valid.
|
||||
- Objects that depend on `$RCT2:OBJDATA/...` can need additional base game data to export perfectly. Start with self-contained `.parkobj` objects (those using `$LGX:images.dat[...]`) for easiest iteration.
|
||||
@@ -0,0 +1,77 @@
|
||||
# Reskin Pipeline (Workspace -> Upload Zip)
|
||||
|
||||
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`
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Input upload zip (example: `/Users/meiliu/Downloads/openrct2-upload.zip`)
|
||||
- Docker available (for `scripts/openrct2-cli-docker.sh`)
|
||||
- `build-native/openrct2-cli` built once
|
||||
|
||||
## 1) Initialize one or more workspaces
|
||||
|
||||
```bash
|
||||
scripts/init-reskin-object-workspace.sh \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
|
||||
./reskin-workbench/support-structure-half
|
||||
```
|
||||
|
||||
The initializer writes `object-path-in-assets-zip.txt` in each workspace so the pipeline can map output files automatically.
|
||||
|
||||
## 2) Edit sprites
|
||||
|
||||
Edit PNGs under each workspace `sprites/` directory.
|
||||
|
||||
## 3) Build a patched upload zip (single command)
|
||||
|
||||
For one workspace:
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half
|
||||
```
|
||||
|
||||
For multiple workspaces:
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half \
|
||||
./reskin-workbench/another-object
|
||||
```
|
||||
|
||||
If you already rebuilt the workspace artifacts, omit `--rebuild`.
|
||||
|
||||
## Optional: Keep the generated overlay for inspection
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
--overlay-dir /tmp/reskin-overlay \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half
|
||||
```
|
||||
|
||||
## Optional: Use a custom `openrct2-cli` command
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
--cli-cmd ./scripts/openrct2-cli-docker.sh \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half
|
||||
```
|
||||
@@ -0,0 +1,70 @@
|
||||
# Reskinning OpenRCT2 Web Uploads
|
||||
|
||||
This repo's web package is typically distributed as:
|
||||
|
||||
- `index.html`
|
||||
- `index.js`
|
||||
- `assets/assets.zip`
|
||||
- `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.
|
||||
|
||||
If your inputs come from initialized object workspaces (`reskin-workbench/...`), prefer:
|
||||
`scripts/build-reskin-object-upload.sh` (see `docs/reskin-pipeline.md`).
|
||||
|
||||
For creating/editing object sprite files first, see:
|
||||
`docs/object-authoring-workflow.md`
|
||||
|
||||
## Overlay Structure
|
||||
|
||||
Create an overlay directory with any of these subfolders:
|
||||
|
||||
- `upload/` files merged into the top-level upload package.
|
||||
- `assets/` files merged into `assets/assets.zip`.
|
||||
- `rct2-content/` files merged into `assets/rct2-content.zip`.
|
||||
- `openrct2/` files merged into `assets/openrct2.zip`.
|
||||
|
||||
Only include files you want to replace or add.
|
||||
|
||||
## Command
|
||||
|
||||
```bash
|
||||
scripts/build-reskin-upload.sh \
|
||||
/path/to/openrct2-upload.zip \
|
||||
/path/to/overlay \
|
||||
/tmp/openrct2-upload-reskinned.zip
|
||||
```
|
||||
|
||||
If output is omitted, it defaults to `/tmp/openrct2-upload-reskinned.zip`.
|
||||
|
||||
## Common Reskin Targets
|
||||
|
||||
1. Replace OpenRCT2 object visuals:
|
||||
- Put replacement `.parkobj` or `.json` files under:
|
||||
`overlay/assets/object/...`
|
||||
- Example:
|
||||
`overlay/assets/object/official/ride/openrct2.ride.modern_twister.parkobj`
|
||||
|
||||
2. Replace UI sprite data:
|
||||
- Build new `g2.dat` from a modified sprite manifest (using `openrct2-cli sprite build`).
|
||||
- Place it at:
|
||||
`overlay/assets/g2.dat`
|
||||
|
||||
3. Replace font/palette data:
|
||||
- `overlay/assets/fonts.dat`
|
||||
- `overlay/assets/palettes.dat`
|
||||
|
||||
4. Replace legacy RCT2 DAT assets:
|
||||
- Place replacements under:
|
||||
`overlay/rct2-content/Data/...` or `overlay/rct2-content/ObjData/...`
|
||||
|
||||
## Notes
|
||||
|
||||
- The script validates core boot files remain present after patching.
|
||||
- For object replacements, keep object IDs stable unless you intentionally add new IDs and update content that references them.
|
||||
- To inspect paths inside an archive, use:
|
||||
|
||||
```bash
|
||||
unzip -Z1 /path/to/assets.zip | head -200
|
||||
```
|
||||
Executable
+173
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
build-reskin-object-upload.sh [options] <input-upload-zip> <output-upload-zip> <workspace-dir> [workspace-dir...]
|
||||
|
||||
Description:
|
||||
End-to-end object reskin pipeline:
|
||||
1) Optionally rebuild each workspace artifact.
|
||||
2) Assemble an overlay from workspace metadata.
|
||||
3) Produce a patched upload zip.
|
||||
|
||||
Options:
|
||||
--rebuild Run <workspace>/rebuild-object.sh before packaging.
|
||||
--cli-cmd <path> openrct2-cli command passed to rebuild-object.sh (only with --rebuild).
|
||||
--overlay-dir <path> Keep/use this overlay directory instead of a temporary one.
|
||||
-h, --help Show this help message.
|
||||
|
||||
Examples:
|
||||
build-reskin-object-upload.sh \
|
||||
--rebuild \
|
||||
/path/to/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half
|
||||
|
||||
build-reskin-object-upload.sh \
|
||||
--overlay-dir /tmp/reskin-overlay \
|
||||
/path/to/openrct2-upload.zip \
|
||||
/tmp/openrct2-upload-reskinned.zip \
|
||||
./reskin-workbench/support-structure-half \
|
||||
./reskin-workbench/another-object
|
||||
EOF
|
||||
}
|
||||
|
||||
rebuild=0
|
||||
cli_cmd=""
|
||||
overlay_dir=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--rebuild)
|
||||
rebuild=1
|
||||
shift
|
||||
;;
|
||||
--cli-cmd)
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Missing value for --cli-cmd." >&2
|
||||
exit 1
|
||||
fi
|
||||
cli_cmd="$2"
|
||||
shift 2
|
||||
;;
|
||||
--overlay-dir)
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Missing value for --overlay-dir." >&2
|
||||
exit 1
|
||||
fi
|
||||
overlay_dir="$2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $# -lt 3 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_zip="$1"
|
||||
output_zip="$2"
|
||||
shift 2
|
||||
workspace_dirs=("$@")
|
||||
|
||||
if [[ ! -f "$input_zip" ]]; then
|
||||
echo "Input upload zip not found: $input_zip" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$rebuild" -eq 0 && -n "$cli_cmd" ]]; then
|
||||
echo "--cli-cmd requires --rebuild." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$rebuild" -eq 1 && -n "$cli_cmd" && ! -x "$cli_cmd" ]]; then
|
||||
echo "openrct2-cli command is not executable: $cli_cmd" >&2
|
||||
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"
|
||||
|
||||
if [[ ! -x "$overlay_builder" ]]; then
|
||||
echo "Missing executable script: $overlay_builder" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -x "$upload_builder" ]]; then
|
||||
echo "Missing executable script: $upload_builder" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for workspace_dir in "${workspace_dirs[@]}"; do
|
||||
if [[ ! -d "$workspace_dir" ]]; then
|
||||
echo "Workspace directory not found: $workspace_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
cleanup_overlay=0
|
||||
if [[ -z "$overlay_dir" ]]; then
|
||||
overlay_dir="$(mktemp -d /tmp/openrct2-reskin-overlay.XXXXXX)"
|
||||
cleanup_overlay=1
|
||||
else
|
||||
mkdir -p "$overlay_dir"
|
||||
if [[ -n "$(find "$overlay_dir" -mindepth 1 -maxdepth 1 -print -quit 2>/dev/null || true)" ]]; then
|
||||
echo "Overlay directory must be empty: $overlay_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
if [[ "$cleanup_overlay" -eq 1 ]]; then
|
||||
rm -rf "$overlay_dir"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ "$rebuild" -eq 1 ]]; then
|
||||
echo "Rebuilding workspace artifacts..."
|
||||
for workspace_dir in "${workspace_dirs[@]}"; do
|
||||
rebuild_script="$workspace_dir/rebuild-object.sh"
|
||||
if [[ ! -x "$rebuild_script" ]]; then
|
||||
echo "Missing executable rebuild script: $rebuild_script" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "$cli_cmd" ]]; then
|
||||
"$rebuild_script" "$cli_cmd"
|
||||
else
|
||||
"$rebuild_script"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Assembling overlay at: $overlay_dir"
|
||||
"$overlay_builder" "$overlay_dir" "${workspace_dirs[@]}"
|
||||
|
||||
echo "Building patched upload: $output_zip"
|
||||
"$upload_builder" "$input_zip" "$overlay_dir" "$output_zip"
|
||||
|
||||
echo
|
||||
echo "Pipeline complete."
|
||||
echo "Output: $output_zip"
|
||||
if [[ "$cleanup_overlay" -eq 0 ]]; then
|
||||
echo "Overlay: $overlay_dir"
|
||||
fi
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
build-reskin-upload.sh <input-upload-zip> <overlay-dir> [output-zip]
|
||||
|
||||
Description:
|
||||
Creates a reskinned OpenRCT2 web upload package by applying file overlays.
|
||||
|
||||
Overlay layout:
|
||||
<overlay-dir>/upload/ -> merged into upload root (index.html, index.js, etc.)
|
||||
<overlay-dir>/assets/ -> merged into assets/assets.zip
|
||||
<overlay-dir>/rct2-content/ -> merged into assets/rct2-content.zip
|
||||
<overlay-dir>/openrct2/ -> merged into assets/openrct2.zip
|
||||
|
||||
Examples:
|
||||
build-reskin-upload.sh \
|
||||
/path/to/openrct2-upload.zip \
|
||||
/path/to/overlay
|
||||
|
||||
build-reskin-upload.sh \
|
||||
/path/to/openrct2-upload.zip \
|
||||
/path/to/overlay \
|
||||
/tmp/openrct2-upload-reskinned.zip
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $# -lt 2 || $# -gt 3 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_zip="$1"
|
||||
overlay_dir="$2"
|
||||
output_zip="${3:-/tmp/openrct2-upload-reskinned.zip}"
|
||||
|
||||
if [[ ! -f "$input_zip" ]]; then
|
||||
echo "Input file not found: $input_zip" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "$overlay_dir" ]]; then
|
||||
echo "Overlay directory not found: $overlay_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
workdir="$(mktemp -d /tmp/openrct2-reskin-upload.XXXXXX)"
|
||||
cleanup() {
|
||||
rm -rf "$workdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
merge_tree() {
|
||||
local src="$1"
|
||||
local dst="$2"
|
||||
local label="$3"
|
||||
|
||||
if [[ ! -d "$src" ]]; then
|
||||
echo "No overlay for $label ($src)."
|
||||
return 0
|
||||
fi
|
||||
|
||||
local copied=0
|
||||
while IFS= read -r -d '' rel; do
|
||||
rel="${rel#./}"
|
||||
mkdir -p "$dst/$(dirname "$rel")"
|
||||
cp -f "$src/$rel" "$dst/$rel"
|
||||
copied="$((copied + 1))"
|
||||
done < <(cd "$src" && find . -type f ! -name '.DS_Store' ! -name '._*' -print0)
|
||||
|
||||
echo "Applied $copied file(s) to $label."
|
||||
}
|
||||
|
||||
repack_zip_from_dir() {
|
||||
local source_dir="$1"
|
||||
local zip_path="$2"
|
||||
local repacked_zip="$zip_path.repacked"
|
||||
local list_file
|
||||
list_file="$(mktemp "$workdir/files.XXXXXX")"
|
||||
|
||||
(
|
||||
cd "$source_dir"
|
||||
LC_ALL=C find . -type f | sed 's#^\./##' | sort > "$list_file"
|
||||
if [[ ! -s "$list_file" ]]; then
|
||||
echo "Refusing to create empty archive: $zip_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$repacked_zip"
|
||||
zip -q -X "$repacked_zip" -@ < "$list_file"
|
||||
)
|
||||
|
||||
mv -f "$repacked_zip" "$zip_path"
|
||||
rm -f "$list_file"
|
||||
}
|
||||
|
||||
apply_overlay_to_nested_zip() {
|
||||
local zip_path="$1"
|
||||
local nested_overlay="$2"
|
||||
local label="$3"
|
||||
local tmp_dir="$workdir/${label//[^a-zA-Z0-9._-]/_}"
|
||||
|
||||
if [[ ! -f "$zip_path" ]]; then
|
||||
echo "Missing required archive: $zip_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$nested_overlay" ]]; then
|
||||
echo "No overlay for $label ($nested_overlay)."
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p "$tmp_dir"
|
||||
unzip -q "$zip_path" -d "$tmp_dir"
|
||||
merge_tree "$nested_overlay" "$tmp_dir" "$label"
|
||||
repack_zip_from_dir "$tmp_dir" "$zip_path"
|
||||
}
|
||||
|
||||
require_zip_entry() {
|
||||
local zip_path="$1"
|
||||
local entry="$2"
|
||||
|
||||
if ! grep -Fxq "$entry" < <(unzip -Z1 "$zip_path"); then
|
||||
echo "Missing required entry in $(basename "$zip_path"): $entry" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Working directory: $workdir"
|
||||
echo "Input: $input_zip"
|
||||
echo "Overlay: $overlay_dir"
|
||||
echo "Output: $output_zip"
|
||||
|
||||
unzip -q "$input_zip" -d "$workdir/in"
|
||||
|
||||
assets_zip="$workdir/in/assets/assets.zip"
|
||||
rct2_zip="$workdir/in/assets/rct2-content.zip"
|
||||
openrct2_zip="$workdir/in/assets/openrct2.zip"
|
||||
|
||||
merge_tree "$overlay_dir/upload" "$workdir/in" "upload root"
|
||||
apply_overlay_to_nested_zip "$assets_zip" "$overlay_dir/assets" "assets.zip"
|
||||
apply_overlay_to_nested_zip "$rct2_zip" "$overlay_dir/rct2-content" "rct2-content.zip"
|
||||
apply_overlay_to_nested_zip "$openrct2_zip" "$overlay_dir/openrct2" "openrct2.zip"
|
||||
|
||||
# Keep the required files used by the web loader.
|
||||
require_zip_entry "$assets_zip" "language/en-US.txt"
|
||||
require_zip_entry "$assets_zip" "g2.dat"
|
||||
require_zip_entry "$assets_zip" "object/official/footpath_surface/openrct2.footpath_surface.invisible.json"
|
||||
require_zip_entry "$assets_zip" "sequence/openrct2.parkseq"
|
||||
require_zip_entry "$rct2_zip" "Data/ch.dat"
|
||||
require_zip_entry "$rct2_zip" "ObjData/BALLN.DAT"
|
||||
|
||||
mkdir -p "$(dirname "$output_zip")"
|
||||
rm -f "$output_zip"
|
||||
(
|
||||
cd "$workdir/in"
|
||||
LC_ALL=C find . -type f | sed 's#^\./##' | sort | zip -q -X "$output_zip" -@
|
||||
)
|
||||
|
||||
input_bytes="$(stat -f%z "$input_zip")"
|
||||
output_bytes="$(stat -f%z "$output_zip")"
|
||||
delta_bytes="$((input_bytes - output_bytes))"
|
||||
|
||||
echo
|
||||
echo "Done."
|
||||
echo "Input size : $input_bytes bytes"
|
||||
echo "Output size: $output_bytes bytes"
|
||||
echo "Delta : $delta_bytes bytes"
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
create-reskin-overlay.sh <overlay-dir> <workspace-dir> [workspace-dir...]
|
||||
|
||||
Description:
|
||||
Assembles an overlay directory from one or more initialized reskin workspaces.
|
||||
|
||||
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.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
overlay_dir="$1"
|
||||
shift
|
||||
|
||||
mkdir -p "$overlay_dir/assets"
|
||||
|
||||
copied=0
|
||||
for workspace_dir in "$@"; do
|
||||
if [[ ! -d "$workspace_dir" ]]; then
|
||||
echo "Workspace directory not found: $workspace_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
object_path="$(<"$object_path_file")"
|
||||
object_path="${object_path%$'\r'}"
|
||||
|
||||
if [[ -z "$object_path" ]]; then
|
||||
echo "Empty object path in metadata: $object_path_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$object_path" = /* || "$object_path" == *"/../"* || "$object_path" == "../"* || "$object_path" == *"/.." ]]; then
|
||||
echo "Unsafe object path in metadata: $object_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
artifact_path=""
|
||||
case "$object_path" in
|
||||
*.parkobj)
|
||||
artifact_path="$workspace_dir/reskinned.parkobj"
|
||||
if [[ ! -f "$artifact_path" ]]; then
|
||||
echo "Missing artifact for $workspace_dir: $artifact_path" >&2
|
||||
echo "Run: $workspace_dir/rebuild-object.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*.json)
|
||||
artifact_path="$workspace_dir/object.json"
|
||||
if [[ ! -f "$artifact_path" ]]; then
|
||||
echo "Missing artifact for $workspace_dir: $artifact_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported object target path extension: $object_path" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
target_path="$overlay_dir/assets/$object_path"
|
||||
mkdir -p "$(dirname "$target_path")"
|
||||
cp -f "$artifact_path" "$target_path"
|
||||
copied="$((copied + 1))"
|
||||
|
||||
echo "Mapped workspace:"
|
||||
echo " $workspace_dir"
|
||||
echo " -> assets/$object_path"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Overlay ready: $overlay_dir"
|
||||
echo "Objects mapped: $copied"
|
||||
Executable
+172
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
init-reskin-object-workspace.sh <input-upload-zip> <object-path-in-assets-zip> <workspace-dir> [openrct2-cli-cmd]
|
||||
|
||||
Description:
|
||||
Creates an editable object authoring workspace from an object contained in assets/assets.zip.
|
||||
|
||||
Output workspace includes:
|
||||
- object.json (source metadata)
|
||||
- images.dat (if present in source .parkobj)
|
||||
- object-path-in-assets-zip.txt (target location for upload overlay)
|
||||
- source-object/ (original extracted source object file)
|
||||
- sprites/ (exported PNG sprite frames)
|
||||
- sprites.json (sprite build manifest wrapping exported entries)
|
||||
- rebuild-object.sh (rebuild images.dat + pack reskinned.parkobj)
|
||||
|
||||
Examples:
|
||||
init-reskin-object-workspace.sh \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
|
||||
./reskin-workbench/support-structure-half
|
||||
|
||||
init-reskin-object-workspace.sh \
|
||||
/Users/meiliu/Downloads/openrct2-upload.zip \
|
||||
object/official/scenery_small/official.scenery_small.support_structure_half.parkobj \
|
||||
./reskin-workbench/support-structure-half \
|
||||
./scripts/openrct2-cli-docker.sh
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $# -lt 3 || $# -gt 4 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_zip="$1"
|
||||
object_path="$2"
|
||||
workspace_dir="$3"
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cli_cmd="${4:-$repo_root/scripts/openrct2-cli-docker.sh}"
|
||||
|
||||
if [[ ! -f "$input_zip" ]]; then
|
||||
echo "Input upload zip not found: $input_zip" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -x "$cli_cmd" ]]; then
|
||||
echo "openrct2-cli command is not executable: $cli_cmd" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -e "$workspace_dir" && -n "$(find "$workspace_dir" -mindepth 1 -maxdepth 1 2>/dev/null || true)" ]]; then
|
||||
echo "Workspace directory already exists and is not empty: $workspace_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
workdir="$(mktemp -d /tmp/openrct2-object-init.XXXXXX)"
|
||||
cleanup() {
|
||||
rm -rf "$workdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Working directory: $workdir"
|
||||
echo "Input zip: $input_zip"
|
||||
echo "Object path: $object_path"
|
||||
echo "Workspace: $workspace_dir"
|
||||
echo "CLI command: $cli_cmd"
|
||||
|
||||
unzip -q "$input_zip" assets/assets.zip -d "$workdir/in"
|
||||
assets_zip="$workdir/in/assets/assets.zip"
|
||||
|
||||
if [[ ! -f "$assets_zip" ]]; then
|
||||
echo "Missing assets/assets.zip in upload: $input_zip" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -Fxq "$object_path" < <(unzip -Z1 "$assets_zip"); then
|
||||
echo "Object path not found in assets/assets.zip: $object_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$workspace_dir"
|
||||
mkdir -p "$workspace_dir/source-object"
|
||||
mkdir -p "$workspace_dir/sprites"
|
||||
|
||||
source_basename="$(basename "$object_path")"
|
||||
source_object_path="$workspace_dir/source-object/$source_basename"
|
||||
unzip -p "$assets_zip" "$object_path" > "$source_object_path"
|
||||
|
||||
printf '%s\n' "$object_path" > "$workspace_dir/object-path-in-assets-zip.txt"
|
||||
|
||||
if [[ "$source_basename" == *.parkobj ]]; then
|
||||
unzip -p "$source_object_path" object.json > "$workspace_dir/object.json"
|
||||
if grep -Fxq "images.dat" < <(unzip -Z1 "$source_object_path"); then
|
||||
unzip -p "$source_object_path" images.dat > "$workspace_dir/images.dat"
|
||||
else
|
||||
echo "Warning: source .parkobj has no images.dat."
|
||||
fi
|
||||
elif [[ "$source_basename" == *.json ]]; then
|
||||
cp -f "$source_object_path" "$workspace_dir/object.json"
|
||||
else
|
||||
echo "Unsupported object source extension: $source_basename" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
raw_entries="$workdir/sprite_entries.raw"
|
||||
clean_entries="$workdir/sprite_entries.clean"
|
||||
(
|
||||
cd "$workspace_dir"
|
||||
"$cli_cmd" sprite exportobject "source-object/$source_basename" "sprites" > "$raw_entries" 2>&1 || true
|
||||
)
|
||||
|
||||
grep -E '^[[:space:]]*(""{1}|\{)' "$raw_entries" > "$clean_entries" || true
|
||||
|
||||
if [[ ! -s "$clean_entries" ]]; then
|
||||
echo "Failed to extract valid sprite entries from export output." >&2
|
||||
echo "--- begin raw export output ---" >&2
|
||||
sed -n '1,120p' "$raw_entries" >&2
|
||||
echo "--- end raw export output ---" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
{
|
||||
echo "{"
|
||||
echo " \"images\": ["
|
||||
sed 's/^/ /' "$clean_entries"
|
||||
echo " ]"
|
||||
echo "}"
|
||||
} > "$workspace_dir/sprites.json"
|
||||
|
||||
cat > "$workspace_dir/rebuild-object.sh" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
||||
CLI_CMD="\${1:-$cli_cmd}"
|
||||
|
||||
if [[ ! -x "\$CLI_CMD" ]]; then
|
||||
echo "openrct2-cli command is not executable: \$CLI_CMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "\$SCRIPT_DIR"
|
||||
"\$CLI_CMD" sprite build "images.dat" "sprites.json" silent
|
||||
zip -q -X "reskinned.parkobj" "object.json" "images.dat"
|
||||
)
|
||||
|
||||
echo "Rebuilt:"
|
||||
echo " \$SCRIPT_DIR/images.dat"
|
||||
echo " \$SCRIPT_DIR/reskinned.parkobj"
|
||||
EOF
|
||||
chmod +x "$workspace_dir/rebuild-object.sh"
|
||||
|
||||
echo
|
||||
echo "Workspace ready."
|
||||
echo "Next steps:"
|
||||
echo " 1) Edit PNGs in: $workspace_dir/sprites/"
|
||||
echo " 2) Rebuild object: $workspace_dir/rebuild-object.sh"
|
||||
echo " 3) Overlay output file into upload package:"
|
||||
echo " overlay/assets/object/.../<your file>.parkobj"
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
host_pwd="$(pwd -P)"
|
||||
container_wd="/workspaces/OpenRCT2"
|
||||
cli_host_path="$repo_root/build-native/openrct2-cli"
|
||||
|
||||
if [[ ! -x "$cli_host_path" ]]; then
|
||||
cat >&2 <<EOF
|
||||
Missing required CLI binary:
|
||||
$cli_host_path
|
||||
|
||||
Build it first with:
|
||||
docker run --rm -v "$repo_root:/workspaces/OpenRCT2" -w /workspaces/OpenRCT2 openrct2/openrct2-build:25-noble bash -lc 'cmake -S . -B build-native -G Ninja -DDISABLE_DISCORD_RPC=ON -DDOWNLOAD_TITLE_SEQUENCES=OFF -DDOWNLOAD_OBJECTS=OFF -DDOWNLOAD_OPENSFX=OFF -DDOWNLOAD_OPENMUSIC=OFF -DDOWNLOAD_REPLAYS=OFF -DDISABLE_GOOGLE_BENCHMARK=ON -DWITH_TESTS=OFF && cmake --build build-native -j4 --target openrct2-cli'
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$host_pwd" == "$repo_root" ]]; then
|
||||
container_wd="/workspaces/OpenRCT2"
|
||||
elif [[ "$host_pwd" == "$repo_root/"* ]]; then
|
||||
rel="${host_pwd#"$repo_root"}"
|
||||
container_wd="/workspaces/OpenRCT2$rel"
|
||||
fi
|
||||
|
||||
exec docker run --rm \
|
||||
--platform linux/amd64 \
|
||||
-v "$repo_root:/workspaces/OpenRCT2" \
|
||||
-w "$container_wd" \
|
||||
openrct2/openrct2-build:25-noble \
|
||||
/workspaces/OpenRCT2/build-native/openrct2-cli "$@"
|
||||
Reference in new issue
Block a user