Wire up editor: input bindings, frame hooks, launcher script

init.lua loads the work map, binds hotkeys (E/R/S/Esc), tracks
mouse-cell per frame, dispatches clicks to the UI hit-tester
and falls through to paint-cell for unconsumed map-area clicks.
run-map-editor.sh handles copy-in/copy-out for a real target map
or runs in-place against the module's work slot.
This commit is contained in:
Calic
2026-05-24 01:22:49 +02:00
parent f8ce43784f
commit 6d2d3ea26d
3 changed files with 167 additions and 12 deletions

51
scripts/run-map-editor.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# run-map-editor.sh — launcher for sporel-module-map-editor
# Usage: bash scripts/run-map-editor.sh [target_map.json]
#
# If a target is given, copy it into the editor's work-slot before
# launching, then copy the edited result back to the target after exit.
# Without a target, edits the in-place work.map.json.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EDITOR_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
WORK_SLOT="$EDITOR_DIR/maps/work.map.json"
SPOREL_ROOT="$(cd "$EDITOR_DIR/../.." && pwd)"
SPOREL_BIN="${SPOREL_BIN:-$SPOREL_ROOT/sporel-engine/build/Sporel.exe}"
if [ ! -x "$SPOREL_BIN" ]; then
echo "error: Sporel binary not found at $SPOREL_BIN" >&2
echo "set SPOREL_BIN env-var or build the engine first" >&2
exit 1
fi
TARGET="${1:-}"
if [ -n "$TARGET" ]; then
if [ ! -f "$TARGET" ]; then
echo "error: target map not found: $TARGET" >&2
exit 1
fi
echo "copying $TARGET -> $WORK_SLOT"
cp "$TARGET" "$WORK_SLOT"
fi
echo "launching map-editor on $WORK_SLOT"
export SPOREL_LIBS_DIR="$SPOREL_ROOT/sporel-libs"
export SPOREL_MODULES_DIR="$SPOREL_ROOT/sporel-modules"
export SPOREL_MODULE=map-editor
LOG_FILE="${SPOREL_LOG:-/tmp/sporel-last-run.log}"
set +e
"$SPOREL_BIN" "$@" 2> >(tee "$LOG_FILE" >&2)
rc=$?
set -e
if [ -n "$TARGET" ] && [ $rc -eq 0 ]; then
echo "copying $WORK_SLOT -> $TARGET"
cp "$WORK_SLOT" "$TARGET"
fi
echo "done (exit $rc)"
exit $rc