Files
Triforce-Source/builder/linux/hookshot-launch
ruckus7382sfgsgdf 861702476a Triforce v0.7.1
Crash fixes (a load crash from the virtual cores' escape, the upscaler-before-the-bloom crash, out of memory at a file's open), slow motion after a movie fixed, three save files with per-save achievements (ZakyPew), ten more achievements and their own menu group, N64 Classic, native ultrawide output (Kaefergeneral), the community AMD frame-time fixes, the helper threads' calm-scene tuner and benchmark test, update and Linux launcher fixes.
2026-11-23 13:12:59 -06:00

79 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
# Start the game Triforce Builder wrote, from that folder, without the AppImage's libraries.
# The builder AppImage calls this for --play. The window's Play button does the same thing.
#
# hookshot-launch the out= folder in ~/.config/triforce/builder.ini
# hookshot-launch /path/to/the/game that folder
# HOOKSHOT_LAUNCH_CONFIG=<file> read that ini instead (a test)
set -eu
ini_path() {
if [ -n "${HOOKSHOT_LAUNCH_CONFIG:-}" ]; then
printf '%s\n' "$HOOKSHOT_LAUNCH_CONFIG"
else
printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/triforce/builder.ini"
fi
}
# the last out= line, as the builder keeps the last value it wrote
out_of() {
out=
while IFS= read -r line || [ -n "$line" ]; do
case $line in
out=*) out=${line#out=} ;;
esac
done < "$1"
[ -n "$out" ] || return 1
printf '%s\n' "$out"
}
ready() {
# (bin/triforce under the launcher, or triforce in a folder built without one; Hookshot's names after them)
[ -n "${1:-}" ] && [ -f "$1/image.bin" ] &&
{ [ -x "$1/bin/triforce" ] || [ -x "$1/bin/hookshot" ] || [ -f "$1/triforce" ] || [ -f "$1/hookshot" ]; }
}
folder=${1:-}
if [ -z "$folder" ]; then
ini=$(ini_path)
if [ -f "$ini" ]; then
folder=$(out_of "$ini") || folder=
fi
fi
if ! ready "$folder"; then
echo "Triforce: no built game to start. Build one with Triforce Builder, or pass its folder." >&2
# (HOOKSHOT_LAUNCH_CONFIG is a test: it must not open a dialog)
if [ -z "${HOOKSHOT_LAUNCH_CONFIG:-}" ]; then
if command -v zenity >/dev/null 2>&1; then
zenity --error --title=Triforce --text="No built game to start. Build one with Triforce Builder first." || true
elif command -v kdialog >/dev/null 2>&1; then
kdialog --error "No built game to start. Build one with Triforce Builder first." || true
fi
fi
exit 1
fi
# The AppImage runtime and the builder put their own libraries on the search path. The game loads
# SDL from beside itself, so those names go before it starts. Same set as the builder's Play button.
names=$(env | awk -F= '$1 ~ /^(HOOKSHOT_|PYTHON|APPDIR|APPIMAGE|ARGV0|OWD)/ || $1 == "LD_LIBRARY_PATH" { print $1 }')
for name in $names; do
unset "$name"
done
cd "$folder"
# (--play already chose Play. The game's own update question stays for a bin/triforce the player started themselves)
export HOOKSHOT_NO_UPDATE_CHECK=1
# ((Triforce, 11-23) the log into triforce_log.txt whatever stderr is (a terminal, a pipe, ~/.xsession-errors), as the
# launcher's Play does: the game writes its log file only when stderr is none. HOS_LOG_FILE=0: stderr, as before)
export HOS_LOG_FILE="${HOS_LOG_FILE:-1}"
for game in ./bin/triforce ./bin/hookshot; do
if [ -x "$game" ]; then
exec "$game"
fi
done
if [ -f ./triforce ]; then
exec ./triforce
fi
exec ./hookshot