Triforce v0.3.4

The slowdown in fights and the controller whose buttons stopped arriving are fixed; the checks' file names; groundwork for Linux.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
ruckus7382sfgsgdf
2026-11-12 13:58:36 -06:00
parent 83b5be58d6
commit e33a732651
19 changed files with 266 additions and 127 deletions

View File

@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Name=Hookshot Builder
Name=Triforce Builder
Comment=Builds Ocarina of Time for PC from your own copy of the game
Exec=AppRun
Icon=hookshot

View File

@@ -1,14 +1,14 @@
#!/bin/sh
# The game folder's launcher, what hookshot.exe is on Windows: Play, and Update when a newer release is out.
# The game itself is bin/hookshot. This file is copied to hookshot in the folder (nx2/make_game.py).
# The game folder's launcher, what Triforce.exe is on Windows: Play, and Update when a newer release is out.
# The game itself is bin/triforce. This file is copied to triforce in the folder (nx2/make_game.py).
#
# It starts the builder installed by an update ($XDG_DATA_HOME/hookshot/builder), or the builder= line in
# hookshot_version.txt (the AppImage that built the folder). With neither, it starts the game.
# It starts the builder installed by an update ($XDG_DATA_HOME/triforce/builder), or the builder= line in
# triforce_version.txt (the AppImage that built the folder; hookshot_version.txt in a folder that still has that). With neither, it starts the game.
set -eu
HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
installed() {
root=${HOOKSHOT_BUILDER_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}}/hookshot/builder
root=${HOOKSHOT_BUILDER_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}}/triforce/builder
[ -f "$root/current" ] || return 1
tag=$(tr -d ' \r\n' < "$root/current")
[ -n "$tag" ] && [ -x "$root/versions/$tag/AppRun" ] || return 1
@@ -16,13 +16,15 @@ installed() {
}
builder_line() {
[ -f "$HERE/hookshot_version.txt" ] || return 1
file=$HERE/triforce_version.txt
[ -f "$file" ] || file=$HERE/hookshot_version.txt
[ -f "$file" ] || return 1
path=
while IFS= read -r line || [ -n "$line" ]; do
case $line in
builder=*) path=${line#builder=} ;;
esac
done < "$HERE/hookshot_version.txt"
done < "$file"
[ -n "$path" ] && [ -x "$path" ] || return 1
printf '%s\n' "$path"
}
@@ -34,9 +36,11 @@ fi
if [ -n "$run" ]; then
exec "$run" --launch "$HERE"
fi
if [ -x "$HERE/bin/hookshot" ]; then
cd "$HERE"
exec ./bin/hookshot
fi
echo "Hookshot: the game (bin/hookshot) is missing from this folder. Build it again with Hookshot Builder." >&2
for game in bin/triforce bin/hookshot; do
if [ -x "$HERE/$game" ]; then
cd "$HERE"
exec "./$game"
fi
done
echo "Triforce: the game (bin/triforce) is missing from this folder. Build it again with Triforce Builder." >&2
exit 1

View File

@@ -1,8 +1,8 @@
#!/bin/sh
# Start the game Hookshot Builder wrote, from that folder, without the AppImage's libraries.
# 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/hookshot/builder.ini
# 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
@@ -11,7 +11,7 @@ ini_path() {
if [ -n "${HOOKSHOT_LAUNCH_CONFIG:-}" ]; then
printf '%s\n' "$HOOKSHOT_LAUNCH_CONFIG"
else
printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/hookshot/builder.ini"
printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/triforce/builder.ini"
fi
}
@@ -28,7 +28,9 @@ out_of() {
}
ready() {
[ -n "${1:-}" ] && [ -f "$1/image.bin" ] && { [ -x "$1/bin/hookshot" ] || [ -f "$1/hookshot" ]; }
# (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:-}
@@ -40,13 +42,13 @@ if [ -z "$folder" ]; then
fi
if ! ready "$folder"; then
echo "Hookshot: no built game to start. Build one with Hookshot Builder, or pass its folder." >&2
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=Hookshot --text="No built game to start. Build one with Hookshot Builder first." || true
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 Hookshot Builder first." || true
kdialog --error "No built game to start. Build one with Triforce Builder first." || true
fi
fi
exit 1
@@ -60,9 +62,14 @@ for name in $names; do
done
cd "$folder"
# (--play already chose Play. The game's own update question stays for a bin/hookshot the player started themselves)
# (--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
if [ -x ./bin/hookshot ]; then
exec ./bin/hookshot
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

View File

@@ -1,4 +1,4 @@
"""Hookshot Builder for Linux: what builder/HookshotBuilder (WPF) is on Windows, in Tk. It runs nx2/make_game.py and
"""Triforce Builder for Linux: what builder/HookshotBuilder (WPF) is on Windows, in Tk. It runs nx2/make_game.py and
follows its @@ lines (make_game.py's docstring), then offers to start the game. The AppImage starts it (builder/linux/AppRun),
with the compiler, sysroot and libraries it brings in the environment.
@@ -29,15 +29,15 @@ import linux_update # noqa: E402 (the release check and the part download)
import make_game # noqa: E402 (LANGUAGES, BUILD_ID)
import toolchain # noqa: E402 (default_jobs: RX_JOBS)
CONFIG = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "hookshot", "builder.ini")
CONFIG = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "triforce", "builder.ini")
STAGES = {"read": "Reading your game files", "lift": "Translating the game to PC code", "compile": "Compiling",
"finish": "Putting the game folder together", "shaders": "Preparing shaders"}
DLSS_LICENSE = (
"NVIDIA DLSS is NVIDIA's, not Hookshot's. With it ticked, the build downloads NVIDIA's DLSS SDK (release v310.9.16) from "
"NVIDIA DLSS is NVIDIA's, not Triforce's. With it ticked, the build downloads NVIDIA's DLSS SDK (release v310.9.16) from "
"github.com/NVIDIA/DLSS, under NVIDIA's own license, the NVIDIA RTX SDKs license:\n\n"
"https://github.com/NVIDIA/DLSS/blob/9981c6350dc58c0ce21f024fd65e31e851c31689/LICENSE.txt\n\n"
"Its files stay on this PC (in the builder's ngx-sdk folder, and libnvidia-ngx-dlss.so in the game folder's ngx folder). "
"Hookshot never includes or shares them: never share a game folder built with them.\n\n"
"Triforce never includes or shares them: never share a game folder built with them.\n\n"
"Do you accept NVIDIA's license?"
)
@@ -142,14 +142,14 @@ def add_to_menu(folder):
shutil.copyfile(src, icon)
apps = os.path.join(os.environ.get("XDG_DATA_HOME") or os.path.expanduser("~/.local/share"), "applications")
os.makedirs(apps, exist_ok=True)
with open(os.path.join(apps, "hookshot.desktop"), "w", encoding="utf-8") as f:
f.write("[Desktop Entry]\nType=Application\nName=Hookshot\nComment=The Legend of Zelda: Ocarina of Time, built from your copy\n"
with open(os.path.join(apps, "triforce.desktop"), "w", encoding="utf-8") as f:
f.write("[Desktop Entry]\nType=Application\nName=Triforce\nComment=The Legend of Zelda: Ocarina of Time, built from your copy\n"
"Exec=%s\nPath=%s\nIcon=%s\nCategories=Game;\nTerminal=false\nStartupWMClass=%s\n"
% (desktop_exec(os.path.join(folder, "hookshot")), folder, icon, APP_ID))
% (desktop_exec(os.path.join(folder, "triforce")), folder, icon, APP_ID))
def free_gb(path):
path = os.path.expanduser(path or "") # (the field takes ~/Games/Hookshot, as build() and apply_mode() read it)
path = os.path.expanduser(path or "") # (the field takes ~/Games/Triforce, as build() and apply_mode() read it)
while path and not os.path.exists(path):
path = os.path.dirname(path)
try:
@@ -308,7 +308,7 @@ def _arg(name):
class Builder(tk.Tk):
def __init__(self, launch=None, update=None, fetched=False, tag=None):
super().__init__()
self.title("Hookshot Builder")
self.title("Triforce Builder")
self.apply_scale()
self.apply_theme()
self.minsize(self.px(760), self.px(520))
@@ -330,7 +330,7 @@ class Builder(tk.Tk):
self.nup = tk.StringVar(value=self.cfg.get("nup", ""))
self.romfs = tk.StringVar(value=self.cfg.get("romfs", ""))
self.exefs = tk.StringVar(value=self.cfg.get("exefs", ""))
self.out = tk.StringVar(value=self.cfg.get("out", os.path.expanduser("~/Games/Hookshot")))
self.out = tk.StringVar(value=self.cfg.get("out", os.path.expanduser("~/Games/Triforce")))
names = [n for _, n in make_game.LANGUAGES]
code = self.cfg.get("language", "en-US")
self.language = tk.StringVar(value=dict(make_game.LANGUAGES).get(code, names[0]))
@@ -578,8 +578,8 @@ class Builder(tk.Tk):
if self.images.get("logo") is not None:
canvas.create_image(x, px(32), image=self.images["logo"], anchor="w")
x += self.images["logo"].width() + px(10)
canvas.create_text(x, px(32), text="Hookshot", font="HsBrand", fill=INK, anchor="w")
x += int(self.tk.call("font", "measure", "HsBrand", "Hookshot"))
canvas.create_text(x, px(32), text="Triforce", font="HsBrand", fill=INK, anchor="w")
x += int(self.tk.call("font", "measure", "HsBrand", "Triforce"))
if chip:
canvas.create_text(x + px(12), px(32), text=chip, font="HsSmall", fill=INK_SOFT, anchor="w")
self.header_canvas = canvas
@@ -644,7 +644,7 @@ class Builder(tk.Tk):
# ---- the form ----
def show_form(self):
self.title("Hookshot Builder")
self.title("Triforce Builder")
if self.page:
self.page.destroy()
px = self.px
@@ -657,7 +657,7 @@ class Builder(tk.Tk):
f.columnconfigure(1, minsize=px(20))
f.columnconfigure(2, minsize=px(200))
ttk.Label(f, text="Build your game", style="Title.TLabel").grid(row=0, column=0, columnspan=3, sticky="w")
ttk.Label(f, text="Pick your game files and where the game goes. Hookshot does the rest, once.", style="Sub.TLabel",
ttk.Label(f, text="Pick your game files and where the game goes. Triforce does the rest, once.", style="Sub.TLabel",
wraplength=px(800)).grid(row=1, column=0, columnspan=3, sticky="w", pady=(px(6), 0))
if game_ready(self.cfg.get("out")):
ttk.Button(f, text="Play the game built in %s" % self.cfg["out"], command=lambda: self.play_and_close(self.cfg["out"])).grid(
@@ -819,14 +819,14 @@ class Builder(tk.Tk):
self.status.set("Update builds your game again %s NVIDIA DLSS."
% ("with" if self.dlss.get() else "without"))
elif self.mode == "update-game":
self.status.set("Hookshot %s is available. Your game is %s. Update downloads only what changed, then compiles what changed."
self.status.set("Triforce %s is available. Your game is %s. Update downloads only what changed, then compiles what changed."
% (target, game))
elif self.mode == "up-to-date" and self.latest is None:
self.status.set("Your game is %s, as this builder. GitHub did not answer, so newer versions could not be checked." % game)
elif self.mode == "up-to-date":
self.status.set("%s is the latest version." % game)
elif self.mode == "update-builder":
self.status.set("Hookshot Builder %s is available (this one is %s). Update it first, then build." % (self.latest, self.tools or "this one"))
self.status.set("Triforce Builder %s is available (this one is %s). Update it first, then build." % (self.latest, self.tools or "this one"))
else:
self.status.set("")
@@ -840,20 +840,20 @@ class Builder(tk.Tk):
self.launch_status.set("Update available: %s" % target)
show = True
elif target and game and game != target:
self.launch_status.set("%s is out. Build this folder again with Hookshot Builder to get it." % target)
self.launch_status.set("%s is out. Build this folder again with Triforce Builder to get it." % target)
elif game and self.latest is None:
self.launch_status.set("Up to date with this builder (GitHub did not answer)")
elif game:
self.launch_status.set("Up to date")
else:
self.launch_status.set("Could not check for updates (GitHub did not answer)" if self.latest is None else "Hookshot")
self.launch_status.set("Could not check for updates (GitHub did not answer)" if self.latest is None else "Triforce")
if hasattr(self, "launch_update"):
self.launch_update.pack(side="right", padx=self.px(4)) if show else self.launch_update.pack_forget()
def show_launch(self, folder):
if self.page:
self.page.destroy()
self.title("Hookshot")
self.title("Triforce")
px = self.px
page = self.page = ttk.Frame(self)
page.pack(fill="both", expand=True)
@@ -881,7 +881,7 @@ class Builder(tk.Tk):
def begin_update(self, folder=None):
if folder is not None:
self.update_folder = folder
self.show_progress("Updating your game" if self.update_folder else "Updating Hookshot Builder")
self.show_progress("Updating your game" if self.update_folder else "Updating Triforce Builder")
folder = self.update_folder
# (a game older than this builder is built again with it: nothing to download, and GitHub need not answer. So is one
# from a builder that is not an older release, e.g. from the Actions tab: issue 902)
@@ -952,20 +952,20 @@ class Builder(tk.Tk):
out = os.path.expanduser(self.out.get().strip())
if self.kind.get() == "nup":
if not os.path.isfile(self.nup.get()):
return messagebox.showerror("Hookshot", "Choose your game's .nup file.")
return messagebox.showerror("Triforce", "Choose your game's .nup file.")
src = ["--nup", self.nup.get()]
else:
if not (os.path.isdir(self.romfs.get()) and os.path.isdir(self.exefs.get())):
return messagebox.showerror("Hookshot", "Choose your game's romfs and exefs folders.")
return messagebox.showerror("Triforce", "Choose your game's romfs and exefs folders.")
src = ["--romfs", self.romfs.get(), "--exefs", self.exefs.get()]
if not out:
return messagebox.showerror("Hookshot", "Choose where to save the game.")
return messagebox.showerror("Triforce", "Choose where to save the game.")
try:
jobs = make_game.requested_jobs(os.environ.get("HOOKSHOT_JOBS"))
if jobs is None and os.environ.get("RX_JOBS"): # (the older setting, still honoured)
jobs = toolchain.default_jobs()
except ValueError as error:
return messagebox.showerror("Hookshot", str(error))
return messagebox.showerror("Triforce", str(error))
code = next((c for c, n in make_game.LANGUAGES if n == self.language.get()), "en-US")
dlss = bool(self.dlss.get()) if hasattr(self, "dlss") else False
self.cfg.update(kind=self.kind.get(), nup=self.nup.get(), romfs=self.romfs.get(), exefs=self.exefs.get(), out=out, language=code,
@@ -977,7 +977,7 @@ class Builder(tk.Tk):
([] if jobs is None else ["--jobs", str(jobs)]) + ([] if self.prepare.get() else ["--no-prepare-shaders"]) + \
(dlss_args(True) if dlss else [])
slow = slow_disk_warning(out) # (a warning, not a stop: a hard drive still builds, only much slower)
if slow is not None and not messagebox.askokcancel("Hookshot", slow):
if slow is not None and not messagebox.askokcancel("Triforce", slow):
return
self.show_progress()
self.started = time.time()
@@ -1182,7 +1182,7 @@ class Builder(tk.Tk):
def close(self):
if self.proc and self.proc.poll() is None:
if not messagebox.askyesno("Hookshot", "Stop the build and close?"):
if not messagebox.askyesno("Triforce", "Stop the build and close?"):
return
os.killpg(self.proc.pid, signal.SIGTERM)
self.destroy()

View File

@@ -1,8 +1,8 @@
"""Linux builder updates, the same way Windows installs (builder/setup/setup.c, scripts/make_setup_parts.py).
A release publishes hookshot-linux.txt. Each part is a zip named by its SHA-256 and kept on the linux-parts release, so a
A release publishes triforce-linux.txt. Each part is a zip named by its SHA-256 and kept on the linux-parts release, so a
part whose files did not change is not downloaded again. The player's copy lives at
$XDG_DATA_HOME/hookshot/builder/versions/<tag> (AppRun at its root, the same layout as the AppImage). An unchanged part
$XDG_DATA_HOME/triforce/builder/versions/<tag> (AppRun at its root, the same layout as the AppImage). An unchanged part
is copied from the builder that is running now (the mounted AppImage, or the version installed last time).
tag <tag>
@@ -22,9 +22,16 @@ import zipfile
from part_links import SYSROOT_PART, is_absolute_link, relative_sysroot_link
LIST_NAME = "hookshot-linux.txt"
LATEST_LIST = "https://github.com/NotRexed/Hookshot/releases/latest/download/" + LIST_NAME
LATEST_API = "https://api.github.com/repos/NotRexed/Hookshot/releases/latest"
LIST_NAME = "triforce-linux.txt"
REPO = "ruckus7382sfgsgdf/CBeta0.2" # (Triforce's releases)
LATEST_LIST = "https://github.com/%s/releases/latest/download/%s" % (REPO, LIST_NAME)
# (Triforce: the newest release, pre-releases too, as the Windows side asks: /releases/latest skips pre-releases, and
# every Triforce release so far is one. The answer is a list of one release)
LATEST_API = "https://api.github.com/repos/%s/releases?per_page=1" % REPO
# (the game folder's names, nx2/make_game.py's; Hookshot's after them, for a folder that still has those)
GAME_NAMES = ("triforce", "hookshot")
VERSION_FILES = ("triforce_version.txt", "hookshot_version.txt")
KEPT_EXEFS = (".triforce_exefs", ".hookshot_exefs")
class Part(object):
@@ -48,7 +55,7 @@ class Manifest(object):
def data_root():
base = os.environ.get("HOOKSHOT_BUILDER_HOME") or os.environ.get("XDG_DATA_HOME") or os.path.expanduser("~/.local/share")
return os.path.join(base, "hookshot", "builder")
return os.path.join(base, "triforce", "builder")
def parse_list(text, local=True):
@@ -173,29 +180,34 @@ def game_version(folder):
"""The release a folder was built with, when it still has the game files an update builds from."""
if not folder:
return None, False
kept = os.path.isdir(os.path.join(folder, ".hookshot_exefs")) and os.path.isdir(os.path.join(folder, "romfs"))
kept = (any(os.path.isdir(os.path.join(folder, name)) for name in KEPT_EXEFS)
and os.path.isdir(os.path.join(folder, "romfs")))
version = None
try:
with open(os.path.join(folder, "hookshot_version.txt"), encoding="utf-8") as f:
for line in f:
if line.startswith("version="):
version = line[8:].strip() or None
break
except OSError:
pass
for name in VERSION_FILES:
try:
with open(os.path.join(folder, name), encoding="utf-8") as f:
for line in f:
if line.startswith("version="):
version = line[8:].strip() or None
break
except OSError:
continue
break
return version, kept
def game_exe(folder):
"""bin/hookshot under the launcher, or hookshot in a folder built before the launcher."""
if not folder:
"""bin/triforce under the launcher, or triforce in a folder built without one (Hookshot's names after them)."""
if not folder or not os.path.isfile(os.path.join(folder, "image.bin")):
return None
nested = os.path.join(folder, "bin", "hookshot")
if os.path.isfile(nested) and os.path.isfile(os.path.join(folder, "image.bin")):
return nested
flat = os.path.join(folder, "hookshot")
if os.path.isfile(flat) and os.path.isfile(os.path.join(folder, "image.bin")):
return flat
for name in GAME_NAMES: # (under the launcher first: beside image.bin that name is the launcher itself)
nested = os.path.join(folder, "bin", name)
if os.path.isfile(nested):
return nested
for name in GAME_NAMES:
flat = os.path.join(folder, name)
if os.path.isfile(flat):
return flat
return None
@@ -218,7 +230,7 @@ def _https(url):
def _request(url, timeout, limit=MAX_DOWNLOAD):
# (no second argument: Request's second is the POST body, and a str body failed every download before connecting)
req = urllib.request.Request(_https(url), headers={"User-Agent": "Hookshot", "Accept": "application/vnd.github+json"})
req = urllib.request.Request(_https(url), headers={"User-Agent": "Triforce", "Accept": "application/vnd.github+json"})
with urllib.request.urlopen(req, timeout=timeout) as response:
return _read_at_most(response, limit)
@@ -238,7 +250,7 @@ def _api_download(url):
for asset in json.loads(info.decode("utf-8")).get("assets", []):
if asset.get("name") == name:
req = urllib.request.Request(_https(asset.get("url")), headers={
"User-Agent": "Hookshot", "Accept": "application/octet-stream"})
"User-Agent": "Triforce", "Accept": "application/octet-stream"})
with urllib.request.urlopen(req, timeout=120) as response:
return _read_at_most(response, MAX_DOWNLOAD)
return None
@@ -276,6 +288,8 @@ def latest_tag(get=None):
try:
import json
body = json.loads(get(LATEST_API).decode("utf-8"))
if isinstance(body, list): # (releases?per_page=1: the newest first)
body = body[0] if body else {}
tag = body.get("tag_name")
if tag:
return tag
@@ -529,6 +543,18 @@ def fetch_manifest(get=None):
if override:
with open(override, encoding="utf-8") as handle:
return parse_list(handle.read())
# (Triforce: the newest release's own list, by its tag, so a pre-release is found; /releases/latest is the fallback)
try:
import json
body = json.loads(get(LATEST_API).decode("utf-8"))
if isinstance(body, list):
body = body[0] if body else {}
tag = body.get("tag_name") or ""
if tag and all(ch.isalnum() or ch in "._-" for ch in tag):
url = "https://github.com/%s/releases/download/%s/%s" % (REPO, tag, LIST_NAME)
return parse_list(get(url).decode("utf-8"), local=False)
except Exception:
pass
return parse_list(get(LATEST_LIST).decode("utf-8"), local=False)