Find each game package's apps from its declaration and build Arcade as ZX

games.json now names game packages; each package lists its apps in its own
apps.json, with the cover art, caption and action the library shows. Arcade
packs every declared app generically, opens it directly from its cover, and
builds a package's standalone collection from the same declaration.
Standalone Shovey now starts on its covers like Arcade. Apps opened from a
cover fill the screen with their own navigation; Profile stays on the
covers. Bundles, the collection and the Apps controller are .zx on Ziran
0.3.1, with the reviewed controller from Apps 12e52c0.

Parallel builds of Arcade and standalone Shovey now take turns building
their shared liboqs instead of configuring it at the same time.
This commit is contained in:
waozi committed 2026-10-23 21:57:43 -03:00
1 parent efb3077955
commit ccc36bfc63
37 files changed
+439 -446

No files matched your search

+9 -9
View File
@@ -7,7 +7,7 @@ KRYON_DIR = $(shell $(ZIRAN) pkg path kryon $(LOCK_FLAGS))
# The shared Apps controller is built from the locked Apps package. Arcade
# trusts only the reviewed digest committed in apps-controller.sha256.
ENTITY_DIR = $(shell $(ZIRAN) pkg path entity $(LOCK_FLAGS))
APPS_BUNDLE := build/apps-ui/apps.zib
APPS_BUNDLE := build/apps-ui/apps.zx
APPS_SHA256 := $(shell cat apps-controller.sha256)
INBE_SOURCE ?= $(shell $(ZIRAN) pkg path inbe $(LOCK_FLAGS))
RUNTIME_SOURCES = $(wildcard $(ZIRAN_ROOT)/cmd/zir/*.[ch] $(ZIRAN_ROOT)/include/*.h $(ZIRAN_ROOT)/cmd/compiler*.zi)
@@ -17,7 +17,7 @@ LIB_DIR ?= $(HOME)/.local/lib/arcade
DATA_DIR ?= $(if $(XDG_DATA_HOME),$(XDG_DATA_HOME),$(HOME)/.local/share)
.PHONY: all build/arcade build/shovey standalone-ui-test collection-ui-test scroll-ui-test navigation-ui-test games collection collection-test run test chess-engine-test chess-app-test ui-test inbe-ui-test compatibility-test install
all: collection build/entity.zib build/arcade build/shovey
all: collection build/entity.zx build/arcade build/shovey
games:
python3 scripts/check-games.py
@@ -38,16 +38,16 @@ collection-test:
src/catalog.zi: games
build/entity.zib: ziran.lock $(wildcard $(ENTITY_DIR)/src/*.zi)
build/entity.zx: ziran.lock $(wildcard $(ENTITY_DIR)/src/*.zi)
python3 scripts/build-entity.py
build/ziran/libziran.a: ziran.lock $(RUNTIME_SOURCES)
$(MAKE) -C '$(ZIRAN_ROOT)' BUILD_DIR='$(abspath build/ziran)' '$(abspath $@)'
build/arcade: build/entity.zib $(wildcard src/*.zi) src/catalog.zi ziran.toml ziran.lock Makefile scripts/build-desktop.py build/ziran/libziran.a
build/arcade: build/entity.zx $(wildcard src/*.zi) src/catalog.zi ziran.toml ziran.lock Makefile scripts/build-desktop.py build/ziran/libziran.a
python3 scripts/build-desktop.py --output '$@'
build/shovey: build/entity.zib $(wildcard src/*.zi) src/catalog.zi ziran.toml ziran.lock Makefile scripts/build-desktop.py build/ziran/libziran.a
build/shovey: build/entity.zx $(wildcard src/*.zi) src/catalog.zi ziran.toml ziran.lock Makefile scripts/build-desktop.py build/ziran/libziran.a
python3 scripts/build-desktop.py --standalone-shovey --output '$@'
run: all
@@ -112,8 +112,8 @@ install: all
mv -f '$(LIB_DIR)/arcade.new' '$(LIB_DIR)/arcade'
install -m 0755 build/shovey '$(LIB_DIR)/shovey.new'
mv -f '$(LIB_DIR)/shovey.new' '$(LIB_DIR)/shovey'
install -m 0644 build/entity.zib build/arcade.zib build/arcade.json build/shovey.zib build/shovey.json '$(LIB_DIR)/'
install -m 0644 build/games/*.zib '$(LIB_DIR)/games/'
install -m 0644 build/entity.zx build/arcade.zx build/arcade.json build/shovey.zx build/shovey.json '$(LIB_DIR)/'
install -m 0644 build/games/*.zx '$(LIB_DIR)/games/'
install -m 0644 build/games/*-preview.png '$(LIB_DIR)/games/'
ln -sfn '$(LIB_DIR)/arcade' '$(BIN_DIR)/arcade'
ln -sfn '$(LIB_DIR)/shovey' '$(BIN_DIR)/shovey'
@@ -132,10 +132,10 @@ android-shovey-bundle: collection
python3 scripts/build-android.py --bundle
.PHONY: shovey-linux-download shovey-windows-download
shovey-linux-download: collection build/entity.zib build/shovey
shovey-linux-download: collection build/entity.zx build/shovey
python3 scripts/package-shovey.py linux
# Cross-builds with MinGW (x86_64-w64-mingw32-gcc, -windres and CMake).
shovey-windows-download: collection build/entity.zib
shovey-windows-download: collection build/entity.zx
python3 scripts/build-windows.py
python3 scripts/package-shovey.py windows
+18 -16
View File
@@ -4,8 +4,8 @@ Games and entertainment, alongside Werkzeug for practical tools and Inner
Breeze for personal growth. The library opens Shovey Classic and Editor
directly from full-screen covers.
Swipe, turn the arrows, scroll the wheel, or use the arrow keys to choose;
press Play/Open or Enter to launch. Standalone Shovey uses the same carousel
on its title screen. Chess is temporarily disabled in Arcade; its code and
press Play/Open or Enter to launch. Standalone Shovey opens on the same
carousel with its own covers. Chess is temporarily disabled in Arcade; its code and
existing saved games remain available for a later return.
Each edition has a separate save and earned unlocks. Unlocked puzzles show
their whole board; locked puzzles keep their lock until earned.
@@ -32,12 +32,14 @@ review are not implemented.
## Shared Apps library
Arcade embeds the shared `apps.zib` controller and exact game bundles in a
verified collection. Arcade presents the verified Classic and Editor leaves
directly, without
a second chooser. Shovey’s separate standalone collection uses the same
leaves and saves. Cover entries declare portrait art, landscape art, logo,
caption and action in `games.json`; Kryon’s shared `Carousel` handles
Arcade embeds the shared `apps.zx` controller and exact game bundles in a
verified collection. Each game package lists its apps in its own `apps.json`:
the app's `catalog.json`, and for an app the library opens from a cover, the
cover's portrait art, landscape art, logo, caption and action. `games.json`
names the game packages, and Arcade's own `apps.json` its own apps. Arcade
presents every declared leaf directly, without a second chooser, and a cover
opens its app straight into play or editing. Shovey’s separate standalone
collection uses the same leaves and saves. Kryon’s shared `Carousel` handles
navigation and painting. The local player does not offer node updates or OS
actions it
cannot perform. Inbe supplies its own account and package policy.
@@ -51,14 +53,14 @@ assets, translations and release ledger at `apps/chess/`. Inbe consumes the
same signed package from its node. Both harnesses recognize `inbe.chess`.
The game's `catalog.json` declares its membership in both harnesses.
Arcade builds that source into a `.zib` and runs it through the same bounded
Arcade builds that source into a `.zx` and runs it through the same bounded
app and Kryon widget interface Inbe uses. The bundle contains its existing
piece images and translated Chess text. Arcade validates its game identity,
capabilities and resource paths before opening it.
Standalone Arcade and Shovey provide Profile at the top right, with the Dew
balance directly inside it for connected Waozi-node accounts. Shovey overlays its title controls on the
cover artwork; Help, level selection and play use that same header space.
Standalone Arcade and Shovey provide Profile at the top right of their
covers, with the Dew balance directly inside it for connected Waozi-node
accounts. A game opened from a cover fills the screen with its own header.
They use the shared Entity profile for account creation, key recovery and device
connection. Connected Waozi-node accounts see Dew directly in Profile and can
get a funding address and confirm a storage-plan purchase. These services belong
@@ -94,9 +96,9 @@ and desktop-menu entry for the current user; it does not publish a release.
Harmony registry delivery and Android builds are not implemented in this first
desktop version.
Games are registered in `games.json`, which points to the owning package's
game descriptor. `scripts/build-games.py` generates the catalog and bundles
the owned game. Inbe remains a dependency for the existing shared interface
Game packages are registered in `games.json`; each declares its apps in its
`apps.json`. `scripts/build-games.py` generates the catalog and bundles
every declared app. Inbe remains a dependency for the existing shared interface
and signed publisher, rather than for the Chess implementation.
## Saved games
@@ -160,7 +162,7 @@ puzzle. Shovey also runs as its own desktop app.
## Shared Entity profile
Standalone Shovey's title-screen Profile control opens the shared `entity.zib`
Standalone Shovey's Profile control on its covers opens the shared `entity.zx`
supplied by the Entity package. The host keeps account keys and native file
access behind Entity's versioned management service. Returning from Profile
keeps the current game and its existing save directory. Account connection does
+1 -1
View File
@@ -1 +1 @@
dfb623d79dc1907dd274564c7b87da094f44c9a7293aecfd2d4d9fe8a33a243b
b8733db7256c4e96f8f8bd198072dcc2c3fc4e66b266a9e396c40e88949d8011
+10
View File
@@ -0,0 +1,10 @@
{
"id": "inbe.arcade",
"title": "Arcade",
"apps": [
{
"manifest": "apps/chess/catalog.json",
"enabled": false
}
]
}
+6 -6
View File
@@ -34,8 +34,8 @@ android {
targetSdk 36
versionCode Integer.parseInt((project.findProperty('app.versionCode') ?: appRelease.sequence).toString())
versionName project.findProperty('app.versionName') ?: appRelease.version
manifestPlaceholders = [appLabel: standaloneShovey ? 'Shovey' : 'Arcade', appIcon: standaloneShovey ? '@mipmap/ic_launcher' : '@android:drawable/sym_def_app_icon', zibPlayer: (appCodegen == 'zib').toString(),
nativeLaunchMode: appCodegen == 'zib' ? 'singleTask' : 'standard']
manifestPlaceholders = [appLabel: standaloneShovey ? 'Shovey' : 'Arcade', appIcon: standaloneShovey ? '@mipmap/ic_launcher' : '@android:drawable/sym_def_app_icon', zxPlayer: (appCodegen == 'zx').toString(),
nativeLaunchMode: appCodegen == 'zx' ? 'singleTask' : 'standard']
ndk {
abiFilters += androidAbis
}
@@ -64,10 +64,10 @@ android {
sourceSets.main.res.srcDir "${rootProject.projectDir}/../build/android-shovey-res"
}
if (appCodegen == 'zib') {
sourceSets.main.assets.srcDir "${rootProject.projectDir}/../build/android/zib-assets"
sourceSets.debug.manifest.srcFile 'src/zib/AndroidManifest.xml'
sourceSets.release.manifest.srcFile 'src/zib/AndroidManifest.xml'
if (appCodegen == 'zx') {
sourceSets.main.assets.srcDir "${rootProject.projectDir}/../build/android/zx-assets"
sourceSets.debug.manifest.srcFile 'src/zx/AndroidManifest.xml'
sourceSets.release.manifest.srcFile 'src/zx/AndroidManifest.xml'
}
buildTypes {
+3 -3
View File
@@ -28,10 +28,10 @@
</intent-filter>
</activity>
<activity-alias
android:name=".Zib"
android:name=".Zx"
android:targetActivity=".ArcadeActivity"
android:label="ZIB"
android:enabled="${zibPlayer}"
android:label="ZX"
android:enabled="${zxPlayer}"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -135,8 +135,8 @@ public class ArcadeActivity extends NativeActivity {
private synchronized void stageBundle(Intent intent) {
if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) return;
File incoming = new File(getCacheDir(), "zib-incoming");
File selected = new File(getCacheDir(), "zib-selected");
File incoming = new File(getCacheDir(), "zx-incoming");
File selected = new File(getCacheDir(), "zx-selected");
try (InputStream source = getContentResolver().openInputStream(intent.getData());
FileOutputStream output = new FileOutputStream(incoming)) {
if (source == null) throw new java.io.IOException("Unavailable document");
@@ -153,7 +153,7 @@ public class ArcadeActivity extends NativeActivity {
pendingBundle = selected.getAbsolutePath();
} catch (Exception error) {
incoming.delete();
Log.w("ZIB", "Could not read the selected bundle", error);
Log.w("ZX", "Could not read the selected bundle", error);
}
}
@@ -165,11 +165,11 @@ public class ArcadeActivity extends NativeActivity {
public void bundleResult(int accepted) {
if (accepted != 0) {
Log.i("ZIB", "Bundle loaded");
Log.i("ZX", "Bundle loaded");
} else {
Log.w("ZIB", "Bundle rejected");
Log.w("ZX", "Bundle rejected");
runOnUiThread(() -> android.widget.Toast.makeText(this,
"Could not open this ZIB file", android.widget.Toast.LENGTH_LONG).show());
"Could not open this ZX file", android.widget.Toast.LENGTH_LONG).show());
}
}
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The generic player implements explicit HTTP requests and media URLs.
This overlay is active only for portable ZIB builds. -->
This overlay is active only for portable ZX builds. -->
<uses-permission android:name="android.permission.INTERNET" />
<application android:usesCleartextTraffic="true" />
</manifest>
+1 -34
View File
@@ -1,36 +1,3 @@
{
"games": [
{
"package": "self",
"manifest": "apps/chess/catalog.json",
"enabled": false
},
{
"package": "shovey",
"manifest": "src/catalog.json",
"cover": {
"portrait": "assets/shovey/title-portrait.png",
"landscape": "assets/shovey/title-landscape.png",
"logo": "assets/shovey/logo.png",
"caption": "Classic",
"action": "play"
}
},
{
"package": "shovey",
"manifest": "src/island/catalog.json",
"enabled": false
},
{
"package": "shovey",
"manifest": "src/editor/catalog.json",
"cover": {
"portrait": "assets/shovey/editor-portrait.png",
"landscape": "assets/shovey/editor-landscape.png",
"logo": "assets/shovey/logo.png",
"caption": "Editor",
"action": "open"
}
}
]
"packages": ["shovey"]
}
+3 -3
View File
@@ -20,9 +20,9 @@ def main():
parser.add_argument('--bundle', action='store_true', help='Build an unsigned release Android App Bundle for Google Play')
parser.add_argument('--application-id', help='Use an isolated package for device tests')
args = parser.parse_args()
subprocess.run(['make', 'build/entity.zib'], cwd=ROOT, check=True)
subprocess.run(['make', 'build/entity.zx'], cwd=ROOT, check=True)
metadata = json.loads((ROOT / 'build/shovey.json').read_text())
payload = (ROOT / 'build/shovey.zib').read_bytes()
payload = (ROOT / 'build/shovey.zx').read_bytes()
if hashlib.sha256(payload).hexdigest() != metadata['sha256']:
raise ValueError('The Shovey payload changed; rebuild the collection first')
release = json.loads((ROOT / 'apps/versions.json').read_text())['node_apps']['shovey']
@@ -30,7 +30,7 @@ def main():
raise ValueError('The Shovey version changed; rebuild the collection first')
assets = ROOT / 'build/android-shovey-assets'
assets.mkdir(parents=True, exist_ok=True)
for suffix in ('zib', 'json'):
for suffix in ('zx', 'json'):
shutil.copyfile(ROOT / f'build/shovey.{suffix}', assets / f'arcade.{suffix}')
# Android before 10 has no font lookup; the Windows build ships the same font.
shutil.copyfile(package('kryon') / 'assets/fonts/LiberationSans-Regular.ttf', assets / 'kryon-font.ttf')
+105 -102
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Pack Arcade's unchanged game bundles and the shared Apps controller."""
"""Pack the apps Arcade and its game packages declare, unchanged, with the
shared Apps controller."""
import argparse
import hashlib
import json
@@ -8,10 +9,9 @@ from pathlib import Path
import re
import shutil
import subprocess
from game_manifest import game_manifest
from game_packages import declared_packages
ROOT = Path(__file__).resolve().parents[1]
COLLECTION_ID = "inbe.arcade"
MAX_PAYLOAD_BYTES = 64 * 1024 * 1024
MAX_GAMES = 16
@@ -21,90 +21,95 @@ def digest(path):
def stage(root, controller, expected_controller_digest, output):
"""Validate before replacing a previously staged collection."""
"""Validate before replacing a previously staged collection. Returns the
catalog and each game package with the IDs of its packed apps."""
if not re.fullmatch(r"[0-9a-f]{64}", expected_controller_digest):
raise ValueError("An exact trusted Apps controller SHA-256 is required")
controller_bytes = controller.read_bytes()
if hashlib.sha256(controller_bytes).hexdigest() != expected_controller_digest:
raise ValueError("Apps controller differs from the trusted SHA-256")
registrations = json.loads((root / "games.json").read_text())["games"]
if not 1 <= len(registrations) <= MAX_GAMES:
packages = declared_packages(root)
arcade = packages[0]
if not 1 <= sum(len(package["apps"]) for package in packages) <= MAX_GAMES:
raise ValueError("Arcade needs 1 to 16 games")
ledger = json.loads((root / "apps/versions.json").read_text())["node_apps"]
children, copies, identities = [], [], set()
collection_ids = {package["id"] for package in packages}
total = len(controller_bytes)
for registration in registrations:
if not registration.get("enabled", True):
continue
# Arcade's own games live here; Shovey comes from its package.
source = root if registration["package"] == "self" else Path(subprocess.check_output(
[str(root / "scripts/ziran.sh"), "pkg", "path", registration["package"]], cwd=root, text=True).strip())
manifest = game_manifest(source, registration)
game = json.loads(manifest.read_text())
name, identifier = game["name"], game["id"]
if not re.fullmatch(r"[a-z0-9][a-z0-9-]*", name):
raise ValueError("Invalid game name")
if not re.fullmatch(r"[a-z0-9][a-z0-9._-]*", identifier) or len(identifier) >= 128:
raise ValueError("Invalid game identity")
if identifier in identities or identifier == COLLECTION_ID:
raise ValueError("Duplicate or recursive game identity")
identities.add(identifier)
component = ledger[name]
if (component["id"] != identifier or game["kind"] != "game"
or "arcade" not in game["harnesses"]
or game["contract_version"] != 1 or game["module_api"] != 2
or game["host_api"] != component["host_api"]):
raise ValueError("Incompatible game descriptor or version ledger")
bundle = root / "build/games" / (name + ".zib")
preview = root / "build/games" / (name + "-preview.png")
# The game build embeds this exact legacy descriptor. Its verified
# name binds node/2's legacy handshake to the stable signed app ID.
bundle_bytes, preview_bytes = bundle.read_bytes(), preview.read_bytes()
if not bundle_bytes or not preview_bytes:
raise ValueError("Game bundles and previews must be built first")
total += len(bundle_bytes) + len(preview_bytes)
children.append(dict(
id=identifier, title=game["title"],
bundle=f"assets/arcade/games/{name}.zib", protocol="node/2",
expected_id=name, version=component["version"],
sha256=hashlib.sha256(bundle_bytes).hexdigest(),
preview=f"assets/arcade/previews/{name}.png"))
cover = registration.get("cover")
if cover:
packed_cover = {key: cover[key] for key in ("caption", "action") if key in cover}
for key in ("portrait", "landscape", "logo"):
if key not in cover:
continue
relative = Path(cover[key])
if relative.is_absolute() or ".." in relative.parts or relative.suffix != ".png":
raise ValueError("Invalid cover asset path")
contents = (source / relative).read_bytes()
destination = Path("arcade/covers") / f"{name}-{key}.png"
packed_cover[key] = "assets/" + destination.as_posix()
copies.append((contents, destination))
total += len(contents)
children[-1]["cover"] = packed_cover
copies += [(bundle_bytes, Path("arcade/games") / (name + ".zib")),
(preview_bytes, Path("arcade/previews") / (name + ".png"))]
for package in packages:
package["children"] = []
for app in package["apps"]:
if not app["enabled"]:
continue
game = app["descriptor"]
name, identifier = game["name"], game["id"]
if not re.fullmatch(r"[a-z0-9][a-z0-9-]*", name):
raise ValueError("Invalid game name")
if not re.fullmatch(r"[a-z0-9][a-z0-9._-]*", identifier) or len(identifier) >= 128:
raise ValueError("Invalid game identity")
if identifier in identities or identifier in collection_ids:
raise ValueError("Duplicate or recursive game identity")
identities.add(identifier)
component = ledger[name]
if (component["id"] != identifier or game["kind"] != "game"
or "arcade" not in game["harnesses"]
or game["contract_version"] != 1 or game["module_api"] != 2
or game["host_api"] != component["host_api"]):
raise ValueError("Incompatible game descriptor or version ledger")
bundle = root / "build/games" / (name + ".zx")
preview = root / "build/games" / (name + "-preview.png")
# The game build embeds this exact legacy descriptor. Its verified
# name binds node/2's legacy handshake to the stable signed app ID.
bundle_bytes, preview_bytes = bundle.read_bytes(), preview.read_bytes()
if not bundle_bytes or not preview_bytes:
raise ValueError("Game bundles and previews must be built first")
total += len(bundle_bytes) + len(preview_bytes)
child = dict(
id=identifier, title=game["title"],
bundle=f"assets/arcade/games/{name}.zx", protocol="node/2",
expected_id=name, version=component["version"],
sha256=hashlib.sha256(bundle_bytes).hexdigest(),
preview=f"assets/arcade/previews/{name}.png")
# The package's declared cover: the library opens the app from it.
cover = app["cover"]
if cover:
packed_cover = {key: cover[key] for key in ("caption", "action") if key in cover}
for key in ("portrait", "landscape", "logo"):
if key not in cover:
continue
relative = Path(cover[key])
if relative.is_absolute() or ".." in relative.parts or relative.suffix != ".png":
raise ValueError("Invalid cover asset path")
contents = (app["source"] / relative).read_bytes()
destination = Path("arcade/covers") / f"{name}-{key}.png"
packed_cover[key] = "assets/" + destination.as_posix()
copies.append((contents, destination))
total += len(contents)
child["cover"] = packed_cover
children.append(child)
package["children"].append(identifier)
copies += [(bundle_bytes, Path("arcade/games") / (name + ".zx")),
(preview_bytes, Path("arcade/previews") / (name + ".png"))]
if total > MAX_PAYLOAD_BYTES:
raise ValueError("Arcade collection exceeds the host's payload limit")
catalog = dict(schema=1, id=COLLECTION_ID, title="Arcade",
harness="assets/apps/apps.zib", children=children)
catalog = dict(schema=1, id=arcade["id"], title=arcade["title"],
harness="assets/apps/apps.zx", children=children)
# This stable directory contains disposable build output only. Clear it
# after all inputs validate so removed registrations cannot linger.
if output.exists():
shutil.rmtree(output)
assets = output / "assets"
(assets / "apps").mkdir(parents=True)
(assets / "apps/apps.zib").write_bytes(controller_bytes)
(assets / "apps/apps.zx").write_bytes(controller_bytes)
(assets / "apps/catalog.json").write_text(json.dumps(catalog, indent=2) + "\n")
for contents, relative in copies:
destination = assets / relative
destination.parent.mkdir(parents=True, exist_ok=True)
destination.write_bytes(contents)
# Inbe draws Arcade's launcher icon from assets/arcade/sidebar.shape.
(assets / "arcade").mkdir(exist_ok=True)
(assets / "arcade/sidebar.shape").write_bytes((root / "assets/arcade/sidebar.shape").read_bytes())
return catalog
return catalog, packages[1:]
def main():
@@ -115,7 +120,7 @@ def main():
parser.add_argument("--apps-sha256", required=True)
args = parser.parse_args()
output = ROOT / "build/collection"
catalog = stage(ROOT, args.apps_bundle, args.apps_sha256, output)
catalog, packages = stage(ROOT, args.apps_bundle, args.apps_sha256, output)
command = [args.ziran, "bundle", "--project", *(["--locked"] if args.locked else [])]
env = os.environ.copy()
def bundle(source, entry, assets, target):
@@ -123,44 +128,42 @@ def main():
"--asset-dir", "assets=" + str(assets), "-o", str(target),
str(ROOT / "src" / source)], cwd=ROOT, env=env, check=True)
# One Shovey collection is both the standalone payload and the exact child
# embedded in Arcade. Its leaves keep their independent verified IDs.
editions = [child.copy() for child in catalog["children"]
if child["id"] in {"arcade.shovey", "arcade.shovey-editor"}]
if len(editions) != 2:
raise ValueError("Shovey requires verified Classic and Editor leaves")
for child in editions:
if child["id"] == "arcade.shovey":
child["title"] = "Shovey Classic"
shovey_output = ROOT / "build/shovey-collection"
if shovey_output.exists():
shutil.rmtree(shovey_output)
assets = shovey_output / "assets"
(assets / "apps").mkdir(parents=True)
shutil.copyfile(output / "assets/apps/apps.zib", assets / "apps/apps.zib")
shovey_catalog = dict(schema=1, id="arcade.shovey-player", title="Shovey",
harness="assets/apps/apps.zib", children=editions)
(assets / "apps/catalog.json").write_text(json.dumps(shovey_catalog, indent=2) + "\n")
for child in editions:
resources = [child[field] for field in ("bundle", "preview")]
resources += [value for field, value in child.get("cover", {}).items()
if field in ("portrait", "landscape", "logo")]
for relative in resources:
destination = shovey_output / relative
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(output / relative, destination)
bundle("shovey_collection.zi", "shovey_collection:Main", assets, ROOT / "build/shovey.zib")
shovey_version = next(child["version"] for child in editions if child["id"] == "arcade.shovey")
shovey_metadata = dict(id="arcade.shovey-player", version=shovey_version,
sha256=digest(ROOT / "build/shovey.zib"), apps_sha256=args.apps_sha256,
children=editions, source_mode="project")
(ROOT / "build/shovey.json").write_text(json.dumps(shovey_metadata, indent=2) + "\n")
# Arcade exposes the same verified leaves directly. The standalone
# Shovey collection remains independent; there is no nested chooser.
(output / "assets/apps/catalog.json").write_text(json.dumps(catalog, indent=2) + "\n")
bundle("collection.zi", "collection:Main", output / "assets", ROOT / "build/arcade.zib")
receipt = dict(id=COLLECTION_ID, version=(ROOT / "VERSION").read_text().strip(),
sha256=digest(ROOT / "build/arcade.zib"),
# A game package with a standalone player (src/NAME_collection.zi) also
# gets its own collection of exactly the leaves Arcade packs, with their
# independent verified IDs; it takes its first app's version.
for package in packages:
name = package["name"]
if not (ROOT / "src" / f"{name}_collection.zi").is_file():
continue
children = [child for child in catalog["children"] if child["id"] in package["children"]]
if not children:
raise ValueError(f"{name} declares no enabled apps")
standalone = ROOT / f"build/{name}-collection"
if standalone.exists():
shutil.rmtree(standalone)
assets = standalone / "assets"
(assets / "apps").mkdir(parents=True)
shutil.copyfile(output / "assets/apps/apps.zx", assets / "apps/apps.zx")
standalone_catalog = dict(schema=1, id=package["id"], title=package["title"],
harness="assets/apps/apps.zx", children=children)
(assets / "apps/catalog.json").write_text(json.dumps(standalone_catalog, indent=2) + "\n")
for child in children:
resources = [child[field] for field in ("bundle", "preview")]
resources += [value for field, value in child.get("cover", {}).items()
if field in ("portrait", "landscape", "logo")]
for relative in resources:
destination = standalone / relative
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(output / relative, destination)
bundle(f"{name}_collection.zi", f"{name}_collection:Main", assets, ROOT / f"build/{name}.zx")
metadata = dict(id=package["id"], version=children[0]["version"],
sha256=digest(ROOT / f"build/{name}.zx"), apps_sha256=args.apps_sha256,
children=children, source_mode="project")
(ROOT / f"build/{name}.json").write_text(json.dumps(metadata, indent=2) + "\n")
# Arcade exposes every declared leaf directly; there is no nested chooser.
bundle("collection.zi", "collection:Main", output / "assets", ROOT / "build/arcade.zx")
receipt = dict(id=catalog["id"], version=(ROOT / "VERSION").read_text().strip(),
sha256=digest(ROOT / "build/arcade.zx"),
apps_sha256=args.apps_sha256, children=catalog["children"],
source_mode="project")
(output / "receipt.json").write_text(json.dumps(receipt, indent=2) + "\n")
+10 -5
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Build native Arcade, or standalone Shovey, from the project's locked packages."""
import argparse
import fcntl
import os
from pathlib import Path
import shutil
@@ -33,11 +34,15 @@ def main():
return Path(subprocess.check_output([ZIRAN, 'pkg', 'path', name, *lock], cwd=ROOT, text=True).strip())
oqs_source = package('liboqs')
oqs = ROOT / 'build' / ('entity-oqs-' + oqs_source.name)
subprocess.run(['cmake', '-S', str(oqs_source), '-B', str(oqs),
'-DCMAKE_BUILD_TYPE=MinSizeRel', '-DBUILD_SHARED_LIBS=OFF',
'-DOQS_BUILD_ONLY_LIB=ON', '-DOQS_USE_OPENSSL=OFF', '-DOQS_DIST_BUILD=OFF',
'-DOQS_OPT_TARGET=generic', '-DOQS_MINIMAL_BUILD=SIG_ml_dsa_44'], check=True)
subprocess.run(['cmake', '--build', str(oqs), '--target', 'oqs', '-j2'], check=True)
# Arcade and standalone Shovey share this library; parallel make builds
# both, so only one may configure and build it at a time.
with open(oqs.with_name(oqs.name + '.lock'), 'w') as exclusive:
fcntl.flock(exclusive, fcntl.LOCK_EX)
subprocess.run(['cmake', '-S', str(oqs_source), '-B', str(oqs),
'-DCMAKE_BUILD_TYPE=MinSizeRel', '-DBUILD_SHARED_LIBS=OFF',
'-DOQS_BUILD_ONLY_LIB=ON', '-DOQS_USE_OPENSSL=OFF', '-DOQS_DIST_BUILD=OFF',
'-DOQS_OPT_TARGET=generic', '-DOQS_MINIMAL_BUILD=SIG_ml_dsa_44'], check=True)
subprocess.run(['cmake', '--build', str(oqs), '--target', 'oqs', '-j2'], check=True)
temporary = output.with_suffix('.new')
output.parent.mkdir(parents=True, exist_ok=True)
subprocess.run([os.environ.get('CC', 'cc'), '-std=c11', '-O2', '-ffunction-sections',
+2 -2
View File
@@ -22,9 +22,9 @@ subprocess.run([ZIRAN, 'bundle', '--root', str(entity),
'--module-path', 'qrcode=' + str(qrcode / 'src'),
'--module-path', str(toolchain / 'std'),
'--define', 'KRYON_HOSTED_UI', '--asset-dir', 'assets=' + str(entity / 'assets'),
'--entry', 'entity:Main', '-o', str(ROOT / 'build/entity.zib'), str(entity / 'src/entity.zi')],
'--entry', 'entity:Main', '-o', str(ROOT / 'build/entity.zx'), str(entity / 'src/entity.zi')],
cwd=entity, check=True)
assets = ROOT / 'build/entity-assets'
assets.mkdir(parents=True, exist_ok=True)
shutil.copyfile(ROOT / 'build/entity.zib', assets / 'entity.zib')
shutil.copyfile(ROOT / 'build/entity.zx', assets / 'entity.zx')
+10 -12
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
"""Build registered games from their owning Ziran packages, without copying source."""
"""Build the apps Arcade and its game packages declare, without copying source."""
import argparse
import json
import shutil
import subprocess
from pathlib import Path
from game_manifest import game_manifest
from game_packages import declared_apps
ROOT = Path(__file__).resolve().parents[1]
@@ -18,10 +18,8 @@ def build(ziran, lock_flags):
kryon = package("kryon")
toolchain = package("ziran")
entries = []
for registration in json.loads((ROOT / "games.json").read_text())["games"]:
source = ROOT if registration["package"] == "self" else package(registration["package"])
manifest = game_manifest(source, registration)
descriptor = json.loads(manifest.read_text())
for app in declared_apps(ROOT, ziran, lock_flags):
source, manifest, descriptor = app["source"], app["manifest"], app["descriptor"]
if descriptor["kind"] != "game" or "arcade" not in descriptor["harnesses"]:
raise ValueError("Only games registered for Arcade belong in its catalog")
name = descriptor["name"]
@@ -76,7 +74,7 @@ def build(ziran, lock_flags):
code += ' }\n'
code += ' return ""\n}\n'
(generated / 'translations.zi').write_text(code)
bundle = ROOT / "build/games" / (name + ".zib")
bundle = ROOT / "build/games" / (name + ".zx")
bundle.parent.mkdir(parents=True, exist_ok=True)
subprocess.run([
ziran, "bundle", "--root", str(source),
@@ -96,17 +94,17 @@ def build(ziran, lock_flags):
str(source / descriptor["source"])], cwd=ROOT, check=True)
preview = ROOT / "build/games" / (name + "-preview.png")
shutil.copyfile(source / descriptor["preview"], preview)
entries.append(descriptor | {"enabled": registration.get("enabled", True)})
entries.append(descriptor | {"enabled": app["enabled"], "package": app["package"]})
if not entries or len(entries) > 16 or len({entry["id"] for entry in entries}) != len(entries):
raise ValueError("Arcade needs 1 to 16 distinct games")
text = ("// Generated from games.json and the owning packages' game catalogs.\n"
"Game :: struct {\n id: string\n name: string\n title: string\n bundle: string\n preview: string\n enabled: bool\n}\n\n"
text = ("// Generated from the apps.json of Arcade and its game packages.\n"
"Game :: struct {\n id: string\n name: string\n title: string\n bundle: string\n preview: string\n package: string\n enabled: bool\n}\n\n"
f"GameCount :: {len(entries)}\n\nGameAt :: (index: s32) -> Game {{\n")
for index, entry in enumerate(entries):
fields = ", ".join("." + field + " = " + json.dumps(value, ensure_ascii=False)
for field, value in [("id", entry["id"]), ("name", entry["name"]),
("title", entry["title"]), ("bundle", entry["name"] + ".zib"),
("preview", entry["name"] + "-preview.png")])
("title", entry["title"]), ("bundle", entry["name"] + ".zx"),
("preview", entry["name"] + "-preview.png"), ("package", entry["package"])])
fields += ", .enabled = " + str(entry["enabled"]).lower()
text += f" if index == {index} {{ return Game.{{{fields}}} }}\n"
text += " return Game.{}\n}\n"
+5 -14
View File
@@ -3,25 +3,16 @@
import json
from pathlib import Path
import re
import subprocess
from game_packages import declared_apps
ROOT = Path(__file__).resolve().parents[1]
def package_root(name):
"""Arcade's own games live here; others come from their packages."""
if name == 'self':
return ROOT
return Path(subprocess.check_output([str(ROOT / 'scripts/ziran.sh'), 'pkg', 'path', name],
cwd=ROOT, text=True).strip())
def check():
standard = json.loads((ROOT / 'standards/game-v1.json').read_text())
ledger = json.loads((ROOT / 'apps/versions.json').read_text())
for registration in json.loads((ROOT / 'games.json').read_text())['games']:
source = package_root(registration['package'])
game = json.loads((source / registration['manifest']).read_text())
for app in declared_apps(ROOT):
source, manifest, game = app['source'], app['manifest'], app['descriptor']
for field in ['contract_version', 'module_api', 'host_api']:
assert game[field] == standard[field], f'{game["name"]}: incompatible {field}'
component = ledger['node_apps'][game['name']]
@@ -30,12 +21,12 @@ def check():
assert set(game['harnesses']) <= {'arcade', 'inbe'}
assert game['save_schema'] == 1
assert (source / game['source']).is_file() and (source / game['preview']).is_file()
changelog = (source / registration['manifest']).with_name('CHANGELOG.md').read_text()
changelog = manifest.with_name('CHANGELOG.md').read_text()
version = re.search(r'^## \[(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}$', changelog, re.M)
assert version and version[1] == component['version'], 'Run ./update_version.sh'
assert component['sequence'] > 0
required = set()
for file in (source / registration['manifest']).parent.glob('*.zi'):
for file in manifest.parent.glob('*.zi'):
required.update(re.findall(r'"(' + re.escape(game['locale_prefix']) + r'[a-z0-9_]+)"', file.read_text()))
locales = {}
for file in (source / game['locales']).glob('*.txt'):
-16
View File
@@ -1,16 +0,0 @@
"""Resolve game catalogs across Shovey's standalone source-layout move."""
from pathlib import Path
def game_manifest(source, registration):
source = Path(source)
relative = Path(registration['manifest'])
manifest = source / relative
if manifest.is_file():
return manifest
# Retain clean builds with Arcade's existing locked Shovey revision.
if registration['package'] == 'shovey' and relative.parts[0] == 'src':
previous = source / 'apps/shovey' / relative.relative_to('src')
if previous.is_file():
return previous
raise FileNotFoundError(manifest)
+53
View File
@@ -0,0 +1,53 @@
"""Find the apps Arcade and each registered game package declare.
Every package lists its apps in apps.json: the app's own catalog.json and,
for an app the library opens from a full-screen cover, that cover's art,
caption and action. games.json names the game packages Arcade includes.
"""
import json
from pathlib import Path
import subprocess
APP_KEYS = {'manifest', 'cover', 'enabled'}
COVER_KEYS = {'portrait', 'landscape', 'logo', 'caption', 'action'}
def package_root(root, name, ziran=None, lock_flags=()):
"""Arcade's own apps live in its root; game packages come from its pins."""
if name == 'self':
return Path(root)
command = [str(ziran or Path(root) / 'scripts/ziran.sh'), 'pkg', 'path', name, *lock_flags]
return Path(subprocess.check_output(command, cwd=root, text=True).strip())
def relative_path(text):
path = Path(text)
if path.is_absolute() or '..' in path.parts or not path.parts:
raise ValueError(f'Invalid package path: {text}')
return path
def declared_packages(root, ziran=None, lock_flags=()):
"""Arcade first, then each registered game package, with their apps."""
names = ['self', *json.loads((Path(root) / 'games.json').read_text())['packages']]
if len(set(names)) != len(names):
raise ValueError('Duplicate game package')
packages = []
for name in names:
source = package_root(root, name, ziran, lock_flags)
declaration = json.loads((source / 'apps.json').read_text())
apps = []
for app in declaration['apps']:
if not set(app) <= APP_KEYS or not set(app.get('cover', {})) <= COVER_KEYS:
raise ValueError(f'{name}: unknown apps.json field')
manifest = source / relative_path(app['manifest'])
apps.append(dict(package=name, source=source, manifest=manifest,
descriptor=json.loads(manifest.read_text()),
cover=app.get('cover'), enabled=app.get('enabled', True)))
packages.append(dict(name=name, source=source, id=declaration['id'],
title=declaration['title'], apps=apps))
return packages
def declared_apps(root, ziran=None, lock_flags=()):
return [app for package in declared_packages(root, ziran, lock_flags) for app in package['apps']]
+1 -1
View File
@@ -15,7 +15,7 @@ if __name__ == '__main__':
component = json.loads((ROOT / 'apps/versions.json').read_text())['node_apps']['chess']
valid = all(receipt.get(key) == component[field] for key, field in
[('app_id', 'id'), ('version', 'version'), ('sequence', 'sequence')])
valid = valid and receipt.get('sha256') == sha256((ROOT / 'build/games/chess.zib').read_bytes()).hexdigest()
valid = valid and receipt.get('sha256') == sha256((ROOT / 'build/games/chess.zx').read_bytes()).hexdigest()
valid = valid and all(receipt.get(key) is True for key in
['arcade', 'inbe', 'oldest_inbe', 'rules', 'friend_protocol', 'rendering', 'save_restore'])
except (OSError, ValueError, KeyError):
+3 -3
View File
@@ -12,9 +12,9 @@ import time
import zipfile
ROOT = Path(__file__).resolve().parents[1]
DATA = ['shovey.zib', 'shovey.json', 'entity.zib', 'startup/shovey/title-portrait.png',
DATA = ['shovey.zx', 'shovey.json', 'entity.zx', 'startup/shovey/title-portrait.png',
'startup/shovey/title-landscape.png', 'startup/shovey/logo.png']
WINDOWS_DATA = [('arcade.zib', 'shovey.zib'), ('arcade.json', 'shovey.json'), ('entity.zib', 'entity.zib'),
WINDOWS_DATA = [('arcade.zx', 'shovey.zx'), ('arcade.json', 'shovey.json'), ('entity.zx', 'entity.zx'),
('kryon-font.ttf', 'kryon-font.ttf')]
@@ -25,7 +25,7 @@ def main():
parser.add_argument('--output-dir', type=Path, default=ROOT / 'build/downloads')
args = parser.parse_args()
metadata = json.loads((ROOT / 'build/shovey.json').read_text())
if hashlib.sha256((ROOT / 'build/shovey.zib').read_bytes()).hexdigest() != metadata['sha256']:
if hashlib.sha256((ROOT / 'build/shovey.zx').read_bytes()).hexdigest() != metadata['sha256']:
raise ValueError('The Shovey payload changed; rebuild the collection first')
version = metadata['version']
if args.platform == 'linux':
+1 -1
View File
@@ -18,7 +18,7 @@ if __name__ == '__main__':
subprocess.run(['make', '-s', 'test', 'ui-test'], cwd=ROOT, check=True)
inbe = Path(subprocess.check_output([str(ROOT / 'scripts/ziran.sh'), 'pkg', 'path', 'inbe'],
cwd=ROOT, text=True).strip())
bundle = ROOT / 'build/games/chess.zib'
bundle = ROOT / 'build/games/chess.zx'
subprocess.run(['sh', str(inbe / 'tests/chess_ui_test.sh'), str(binary), str(bundle)],
cwd=inbe, check=True)
subprocess.run(['make', '-s', 'inbe-ui-test', 'INBE_BINARY=' + str(binary)], cwd=ROOT, check=True)
+4 -4
View File
@@ -28,7 +28,7 @@ ArcadeStart :: () -> bool {
}
}
data := DataDirectory()
bundle := ReadAppAsset("arcade.zib")
bundle := ReadAppAsset("arcade.zx")
metadata := ReadAppAsset("arcade.json")
defer { FreeAppAsset(bundle); FreeAppAsset(metadata) }
if data == "" || bundle.count == 0 || metadata.count == 0 {
@@ -37,8 +37,8 @@ ArcadeStart :: () -> bool {
}
opened := false
#if #defined(SHOVEY_STANDALONE) {
// Standalone Shovey opens on the game's title screen.
opened = CollectionOpenShoveyBytes(bundle, metadata, data) && CollectionOpenGame("arcade.shovey")
// Standalone Shovey opens on its covers, as Arcade opens on its library.
opened = CollectionOpenShoveyBytes(bundle, metadata, data)
} else {
opened = CollectionOpenBytes(bundle, metadata, data)
}
@@ -46,7 +46,7 @@ ArcadeStart :: () -> bool {
Report("Arcade: could not open the collection")
return false
}
entity := ReadAppAsset("entity.zib")
entity := ReadAppAsset("entity.zx")
defer { FreeAppAsset(entity) }
#if #defined(SHOVEY_STANDALONE) {
return entity.count > 0 && EntityOpen(entity, data, true)
+6 -5
View File
@@ -1,19 +1,20 @@
// Generated from games.json and the owning packages' game catalogs.
// Generated from the apps.json of Arcade and its game packages.
Game :: struct {
id: string
name: string
title: string
bundle: string
preview: string
package: string
enabled: bool
}
GameCount :: 4
GameAt :: (index: s32) -> Game {
if index == 0 { return Game.{.id = "inbe.chess", .name = "chess", .title = "Chess", .bundle = "chess.zib", .preview = "chess-preview.png", .enabled = false} }
if index == 1 { return Game.{.id = "arcade.shovey", .name = "shovey", .title = "Shovey", .bundle = "shovey.zib", .preview = "shovey-preview.png", .enabled = true} }
if index == 2 { return Game.{.id = "arcade.shovey-island", .name = "shovey-island", .title = "Shovey Island", .bundle = "shovey-island.zib", .preview = "shovey-island-preview.png", .enabled = false} }
if index == 3 { return Game.{.id = "arcade.shovey-editor", .name = "shovey-editor", .title = "Shovey Editor", .bundle = "shovey-editor.zib", .preview = "shovey-editor-preview.png", .enabled = true} }
if index == 0 { return Game.{.id = "inbe.chess", .name = "chess", .title = "Chess", .bundle = "chess.zx", .preview = "chess-preview.png", .package = "self", .enabled = false} }
if index == 1 { return Game.{.id = "arcade.shovey", .name = "shovey", .title = "Shovey", .bundle = "shovey.zx", .preview = "shovey-preview.png", .package = "shovey", .enabled = true} }
if index == 2 { return Game.{.id = "arcade.shovey-island", .name = "shovey-island", .title = "Shovey Island", .bundle = "shovey-island.zx", .preview = "shovey-island-preview.png", .package = "shovey", .enabled = false} }
if index == 3 { return Game.{.id = "arcade.shovey-editor", .name = "shovey-editor", .title = "Shovey Editor", .bundle = "shovey-editor.zx", .preview = "shovey-editor-preview.png", .package = "shovey", .enabled = true} }
return Game.{}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Arcade owns its catalog and games. The verified shared apps.zib controller
// Arcade owns its catalog and games. The verified shared apps.zx controller
// supplies the library; the native host owns child navigation and storage.
#import "kryon/app_context"
#import "kryon/app_protocol"
+15 -72
View File
@@ -1,5 +1,5 @@
// Arcade's native provider for the shared Apps runtime. Children retain
// their original game record directories; the library belongs to apps.zib.
// their original game record directories; the library belongs to apps.zx.
#import "std/file"
#import "std/bundle_host"
#import "std/vec"
@@ -73,10 +73,6 @@ collection_item_codec: Codec.WidgetAppSharedItemCodec;
collection_invitation_codec: Codec.WidgetAppInvitationCodec;
collection_ready: bool;
collection_leave_to_library: bool;
// Standalone Shovey has no library: its title screen is the start.
collection_standalone: bool;
// A game another one asked for, opened after the frame.
collection_open_next: [64]u8;
CollectionTouchFirst :: () -> bool {
#if #defined(PLATFORM_DESKTOP) {
@@ -171,26 +167,12 @@ CollectionCall :: (context: *void, node: *AppNode, module: *u8, function: *u8,
result.* = AppHostText(ifx EntityShow() then "queued" else "unavailable")
return 1
}
// A game leaves for the cover that opened it after its frame.
if service == "arcade.navigation" && request == "back" {
if collection_standalone { unused CopyCString("arcade.shovey", collection_open_next[:]) }
else { collection_leave_to_library = true }
collection_leave_to_library = true
result.* = AppHostText("queued")
return 1
}
if service == "arcade.navigation" && request == "library" {
result.* = AppHostText(ifx collection_standalone then "none" else "available")
return 1
}
if service == "arcade.navigation" && request == "editor" {
unused CopyCString("arcade.shovey-editor", collection_open_next[:])
result.* = AppHostText("queued")
return 1
}
if service == "arcade.navigation" && request == "toolbar" {
collection_toolbar_visible = true
result.* = AppHostText("overlay")
return 1
}
if service == "arcade.sound" {
saved := CollectionRecordsFor("arcade.shovey-player")
if saved == null { return 0 }
@@ -380,7 +362,7 @@ CollectionOpen :: (bundle: string, digest: string, harness_digest: string,
}
CollectionOpenFiles :: (directory: string, data: string) -> bool {
bundle_path := Join(directory, "arcade.zib")
bundle_path := Join(directory, "arcade.zx")
metadata_path := Join(directory, "arcade.json")
defer { AppFileFree(bundle_path); AppFileFree(metadata_path) }
bytes, found := ReadEntireFile(bundle_path)
@@ -412,7 +394,7 @@ CollectionOpenBytes :: (bytes: string, metadata: string, data: string) -> bool {
// stable identity and existing record directory are shared with Arcade.
CollectionOpenShovey :: (directory: string, data: string) -> bool {
if collection_ready { return false }
payload_path := Join(directory, "shovey.zib")
payload_path := Join(directory, "shovey.zx")
metadata_path := Join(directory, "shovey.json")
defer { AppFileFree(payload_path); AppFileFree(metadata_path) }
bytes, found := ReadEntireFile(payload_path)
@@ -430,7 +412,6 @@ CollectionOpenShoveyBytes :: (bytes: string, metadata: string, data: string) ->
!AppsReadText(metadata, 0, "id", id[:]) || TextUntilNul(id[:]) != "arcade.shovey-player" ||
!AppsReadText(metadata, 0, "sha256", digest[:]) ||
!AppsReadText(metadata, 0, "apps_sha256", harness[:]) { return false }
collection_standalone = true
collection_directory = data
collection_resource_root = Join(data, "resources")
if !AppFilesOpen(*collection_resources, collection_resource_root) { return false }
@@ -444,32 +425,11 @@ CollectionOpenShoveyBytes :: (bytes: string, metadata: string, data: string) ->
return collection_ready
}
// Steps back from a game to its library, as Android's Back key does.
// Steps back from a game to its library, as Android's Back key does. At the
// library it is unused, so the app closes.
CollectionBack :: () -> bool {
if EntityBack() { return true }
runtime := AppHostActiveRuntime(*collection_host)
leaving := runtime != null && TextUntilNul(runtime.node.identity.id[:]) == "arcade.shovey"
if AppHostBack(*collection_host) <= 0 { return false }
if !collection_standalone || !CollectionAtLibrary() { return true }
// Back on Shovey's title screen leaves the app; from another game it
// returns to that title screen.
return !leaving && CollectionOpenGame("arcade.shovey")
}
CollectionAtLibrary :: () -> bool {
runtime := AppHostActiveRuntime(*collection_host)
return runtime != null && runtime.node.collection
}
// Opens the game another one asked for, from the library.
CollectionOpenNext :: () -> bool {
id: [64]u8
for at: cast(s32)0..63 { id[at] = collection_open_next[at] }
collection_open_next[0] = 0
while !CollectionAtLibrary() {
if AppHostBack(*collection_host) <= 0 { break }
}
return CollectionOpenGame(TextUntilNul(id[:]))
return AppHostBack(*collection_host) > 0
}
CollectionCollect :: () {
@@ -510,20 +470,6 @@ CollectionClose :: () -> bool {
}
CollectionOpenGame :: (id: string) -> bool {
root := AppTreeNode(*collection_host.tree, collection_host.tree.active)
if root == null || !root.collection { Report("Arcade: no collection is open to start "); Report(id); Report("\n"); return false }
shovey_ids: [3]string = .["arcade.shovey", "arcade.shovey-island", "arcade.shovey-editor"]
if AppCatalogFind(*root.catalog, id) < 0 {
child := false
for game: shovey_ids {
if id == game { child = true }
}
if child && !CollectionOpenChild("arcade.shovey-player") { return false }
}
return CollectionOpenChild(id)
}
CollectionOpenChild :: (id: string) -> bool {
root := AppTreeNode(*collection_host.tree, collection_host.tree.active)
if root == null || !root.collection { Report("Arcade: no collection is open to start "); Report(id); Report("\n"); return false }
request: AppsRequest
@@ -561,14 +507,12 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
runtime := AppHostActiveRuntime(*collection_host)
if runtime == null { Report("Arcade: no app is running\n"); return false }
nested := runtime.node.parent.generation != 0 && !runtime.node.collection
identifier := TextUntilNul(runtime.node.identity.id[:])
owns_chrome := identifier == "arcade.shovey" || identifier == "arcade.shovey-island" ||
identifier == "arcade.shovey-editor"
classic := identifier == "arcade.shovey"
// Classic owns one full-width header. Its title requests the native
// account controls over the cover; Help and play replace that row.
collection_toolbar_visible = !classic
top: s32 = ifx (entity_ready && !runtime.node.collection && !classic) || (nested && !owns_chrome) then 56 else 0
// An app opened from its cover fills the screen with its own navigation.
// Other apps get a bar with Back and their title; the library and that
// bar keep Profile at the top right.
covered := runtime.node.entry.cover.portrait[0] != 0
collection_toolbar_visible = !covered
top: s32 = ifx !covered && !runtime.node.collection && (entity_ready || nested) then 56 else 0
now := cast(float64)MonotonicMilliseconds() / 1000.0
runtime.app.session = session
runtime.app.bounds = Rectangle.{viewport.x, viewport.y + cast(float32)top, viewport.width, viewport.height - cast(float32)top}
@@ -601,13 +545,12 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
Report("collection frame failed\n")
return false
}
if collection_open_next[0] != 0 { return CollectionOpenNext() }
if collection_leave_to_library {
collection_leave_to_library = false
unused AppHostBack(*collection_host)
return true
}
if nested && !owns_chrome {
if nested && !covered {
title_bytes: Vec(u8)
BuilderPrint(*title_bytes, "%", TextUntilNul(runtime.node.entry.title[:]))
title := BuilderFinish(title_bytes)
+18 -27
View File
@@ -11,7 +11,7 @@
#import "collection_host"
#import "entity_host"
#import "entity/model"
Title :: #import "shovey/title_art";
#import "kryon/carousel"
sdl :: #system_library "SDL2";
SetTitle :: (window: *void, title: *u8) #foreign sdl "SDL_SetWindowTitle";
@@ -25,7 +25,7 @@ DrawStartup :: (session: Session, directory: string) -> bool {
logo := Join(directory, "startup/shovey/logo.png")
defer { EntityFree(art); EntityFree(logo) }
if BeginFrame(session, cast(u64)1, viewport) != FrameStatus.FrameOk { return false }
unused Title.TitleArtwork(session, viewport, cast(u64)48000, art, logo, "Shovey")
unused CarouselArtwork(session, viewport, cast(u64)48000, art, logo, "Shovey")
if EndFrame(session) != FrameStatus.FrameOk { return false }
ok := EndDesktopFrame()
TestDriverFrame(session)
@@ -78,6 +78,15 @@ Draw :: (session: Session) -> bool {
return ok
}
// Standalone Shovey offers only the apps Shovey's package declares.
GameAvailable :: (game: Game) -> bool {
#if #defined(SHOVEY_STANDALONE) {
return game.enabled && game.package == "shovey"
} else {
return game.enabled
}
}
#program_export
main :: (argc: s32, argv: **u8) -> s32 {
standalone := false
@@ -86,13 +95,8 @@ main :: (argc: s32, argv: **u8) -> s32 {
}
product := ifx standalone then "Shovey" else "Arcade"
if argc == 2 && TextFromCString(argv[1]) == "--list" {
if standalone {
shovey_ids: [3]string = .["arcade.shovey", "arcade.shovey-island", "arcade.shovey-editor"]
for game: shovey_ids { Report(game); Report("\n") }
return 0
}
for index: cast(s32)0..GameCount - 1 {
if !GameAt(index).enabled { continue }
if !GameAvailable(GameAt(index)) { continue }
Report(GameAt(index).id)
Report("\n")
}
@@ -106,18 +110,11 @@ main :: (argc: s32, argv: **u8) -> s32 {
}
for index: cast(s32)0..GameCount - 1 {
game := GameAt(index)
if game.enabled && (TextFromCString(argv[2]) == game.name || TextFromCString(argv[2]) == game.id) {
if GameAvailable(game) && (TextFromCString(argv[2]) == game.name || TextFromCString(argv[2]) == game.id) {
first = index
}
}
standalone_game := false
if standalone && first >= 0 {
shovey_names: [3]string = .["shovey", "shovey-island", "shovey-editor"]
for game: shovey_names {
if GameAt(first).name == game { standalone_game = true }
}
}
if first < 0 || (standalone && !standalone_game) {
if first < 0 {
Report(product)
Report(": unknown game\n")
return 1
@@ -142,16 +139,10 @@ main :: (argc: s32, argv: **u8) -> s32 {
if !SessionValid(session) { return 1 }
defer { SessionClose(session) }
if standalone && !DrawStartup(session, directory) { return 0 }
opened := false
if standalone {
// Standalone Shovey opens on the game's title screen.
opened = CollectionOpenShovey(directory, data)
if opened && !DrawStartup(session, directory) { unused CollectionClose(); return 0 }
opened = opened && CollectionOpenGame(ifx first < 0 then "arcade.shovey" else GameAt(first).id)
} else {
opened = CollectionOpenFiles(directory, data) &&
(first < 0 || CollectionOpenGame(GameAt(first).id))
}
// Both open on their library's covers, or straight into a named game.
opened := ifx standalone then CollectionOpenShovey(directory, data) else CollectionOpenFiles(directory, data)
if opened && standalone && !DrawStartup(session, directory) { unused CollectionClose(); return 0 }
opened = opened && (first < 0 || CollectionOpenGame(GameAt(first).id))
if !opened {
Report(product)
Report(": could not open collection or game\n")
+1 -1
View File
@@ -47,7 +47,7 @@ EntityOpen :: (bytes: string, data: string, shovey: bool = false) -> bool {
}
EntityOpenFile :: (directory: string, data: string, shovey: bool = false) -> bool {
path := Join(directory, "entity.zib")
path := Join(directory, "entity.zx")
defer { EntityFree(path) }
file := OpenRead(path)
if !file.valid { return false }
+3 -3
View File
@@ -30,14 +30,14 @@ assert b"arcade.shovey\n" in listed.stderr + listed.stdout
unknown = subprocess.run([str(ROOT / "build/arcade"), "--app", "unknown"],
env=env, capture_output=True, timeout=10)
assert unknown.returncode == 1 and b"unknown game" in unknown.stderr
original = (ROOT / 'build/games/chess.zib').read_bytes()
container = (ROOT / 'build/arcade.zib').read_bytes()
original = (ROOT / 'build/games/chess.zx').read_bytes()
container = (ROOT / 'build/arcade.zx').read_bytes()
metadata = json.loads((ROOT / 'build/arcade.json').read_text())
assert original not in container, 'Disabled Chess must not remain in the published collection'
assert {child['id'] for child in metadata['children']} == {'arcade.shovey', 'arcade.shovey-editor'}
for child in metadata['children']:
name = child['expected_id']
exact = (ROOT / f'build/games/{name}.zib').read_bytes()
exact = (ROOT / f'build/games/{name}.zx').read_bytes()
assert container.count(exact) == 1, 'A game must be packed once without a nested chooser'
assert hashlib.sha256(exact).hexdigest() == child['sha256']
assert child['cover']['portrait'] and child['cover']['landscape'] and child['cover']['logo']
+1 -1
View File
@@ -793,7 +793,7 @@ InvitationChecks :: () -> s32 {
#program_export
main :: () -> s32 {
bytes, read := ReadEntireFile("chess.zib")
bytes, read := ReadEntireFile("chess.zx")
if !read {
return 1
}
+1 -1
View File
@@ -13,7 +13,7 @@ work=${CHESS_APP_TEST_DIR:-"$root/build/chess-app-test"}
unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
rm -rf "$work"
mkdir -p "$work/c"
cp "$root/build/games/chess.zib" "$work/chess.zib"
cp "$root/build/games/chess.zx" "$work/chess.zx"
"$ziran" build --target=c --no-main --entry chess_app_behavior:main --root "$root/tests" \
--module-path "$root/src" --module-path "apps=$apps/src" \
--module-path "$root/build/game-generated/chess" \
+1 -1
View File
@@ -36,7 +36,7 @@ def wait(predicate, message):
def application(profile, name):
log_path = OUTPUT / (name + '.log')
env = os.environ | driver.environment() | {
'APP_DATA_ROOT': str(profile), 'INBE_NODE_APP_FILE': str(ROOT / 'build/games/chess.zib')}
'APP_DATA_ROOT': str(profile), 'INBE_NODE_APP_FILE': str(ROOT / 'build/games/chess.zx')}
with log_path.open('w') as log:
child = subprocess.Popen([str(BINARY)], cwd=INBE, env=env,
stdout=log, stderr=subprocess.STDOUT)
+28 -19
View File
@@ -22,12 +22,11 @@ class CollectionTests(unittest.TestCase):
self.addCleanup(self.directory.cleanup)
self.root = Path(self.directory.name)
(self.root / "apps").mkdir()
shutil.copyfile(ROOT / "games.json", self.root / "games.json")
shutil.copyfile(ROOT / "apps/versions.json", self.root / "apps/versions.json")
for registration in json.loads((ROOT / "games.json").read_text())["games"]:
if registration["package"] != "self":
continue
manifest = Path(registration["manifest"])
for name in ("games.json", "apps.json", "apps/versions.json"):
shutil.copyfile(ROOT / name, self.root / name)
# Arcade's own apps are declared beside it.
for app in json.loads((ROOT / "apps.json").read_text())["apps"]:
manifest = Path(app["manifest"])
(self.root / manifest).parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(ROOT / manifest, self.root / manifest)
# Games from another package (Shovey) resolve through Arcade's own pins.
@@ -40,16 +39,16 @@ class CollectionTests(unittest.TestCase):
shutil.copyfile(ROOT / "assets/arcade/sidebar.shape", self.root / "assets/arcade/sidebar.shape")
# Only a native VM identity gate can trust a controller. This fixture
# tests packing and its exact-content requirement, not that handshake.
self.controller = self.root / "controller.zib"
self.controller = self.root / "controller.zx"
self.controller.write_bytes(b"controller exact-content fixture")
self.controller_digest = builder.digest(self.controller)
self.output = self.root / "staged"
def stage(self):
return builder.stage(self.root, self.controller, self.controller_digest, self.output)
return builder.stage(self.root, self.controller, self.controller_digest, self.output)[0]
def test_unchanged_games_keep_canonical_identity_and_version(self):
catalog = self.stage()
catalog, packages = builder.stage(self.root, self.controller, self.controller_digest, self.output)
self.assertEqual(catalog["id"], "inbe.arcade")
# Inbe draws the launcher icon from the collection's own assets.
self.assertEqual((self.output / "assets/arcade/sidebar.shape").read_bytes(),
@@ -58,10 +57,14 @@ class CollectionTests(unittest.TestCase):
ledger = json.loads((ROOT / "apps/versions.json").read_text())["node_apps"]
self.assertEqual({c["id"] for c in catalog["children"]},
{"arcade.shovey", "arcade.shovey-editor"})
# Each leaf keeps the cover its own package declares.
self.assertEqual([c["cover"]["caption"] for c in catalog["children"]], ["Classic", "Editor"])
self.assertEqual([(p["name"], p["id"], p["children"]) for p in packages],
[("shovey", "arcade.shovey-player", ["arcade.shovey", "arcade.shovey-editor"])])
for child in catalog["children"]:
name = child["expected_id"]
packed = self.output / child["bundle"]
self.assertEqual(packed.read_bytes(), (ROOT / f"build/games/{name}.zib").read_bytes())
self.assertEqual(packed.read_bytes(), (ROOT / f"build/games/{name}.zx").read_bytes())
self.assertEqual(builder.digest(packed), child["sha256"])
self.assertEqual(child["version"], ledger[name]["version"])
self.assertEqual(child["protocol"], "node/2")
@@ -85,11 +88,11 @@ class CollectionTests(unittest.TestCase):
def test_duplicate_game_rejected_before_replacing_stage(self):
self.stage()
registrations = json.loads((self.root / "games.json").read_text())
registrations["games"].append(registrations["games"][1])
registrations["packages"].append(registrations["packages"][0])
(self.root / "games.json").write_text(json.dumps(registrations))
with self.assertRaisesRegex(ValueError, "Duplicate"):
self.stage()
self.assertTrue((self.output / "assets/arcade/games/shovey.zib").is_file())
self.assertTrue((self.output / "assets/arcade/games/shovey.zx").is_file())
def test_ledger_identity_mismatch_rejected(self):
ledger_path = self.root / "apps/versions.json"
@@ -100,14 +103,20 @@ class CollectionTests(unittest.TestCase):
self.stage()
self.assertFalse(self.output.exists())
def test_removed_game_leaves_no_stale_payload(self):
def test_removed_package_leaves_no_stale_payload(self):
self.stage()
registrations = json.loads((self.root / "games.json").read_text())
registrations["games"] = registrations["games"][3:]
(self.root / "games.json").write_text(json.dumps(registrations))
self.stage()
self.assertFalse((self.output / "assets/arcade/games/shovey.zib").exists())
self.assertFalse((self.output / "assets/arcade/previews/shovey-island.png").exists())
(self.root / "games.json").write_text(json.dumps({"packages": []}))
self.assertEqual(self.stage()["children"], [])
self.assertFalse((self.output / "assets/arcade/games/shovey.zx").exists())
self.assertFalse((self.output / "assets/arcade/covers/shovey-portrait.png").exists())
def test_unknown_declaration_field_rejected(self):
declaration = json.loads((self.root / "apps.json").read_text())
declaration["apps"][0]["cover_art"] = "assets/chess/preview.png"
(self.root / "apps.json").write_text(json.dumps(declaration))
with self.assertRaisesRegex(ValueError, "unknown apps.json field"):
self.stage()
self.assertFalse(self.output.exists())
if __name__ == "__main__":
+1 -1
View File
@@ -41,7 +41,7 @@ with tempfile.TemporaryDirectory(prefix='arcade-publisher-') as directory:
value = stage()
assert stage() == value
assert value['app_id'] == 'inbe.chess'
assert value['artifacts'][0]['sha256'] == sha256((ROOT / 'build/games/chess.zib').read_bytes()).hexdigest()
assert value['artifacts'][0]['sha256'] == sha256((ROOT / 'build/games/chess.zx').read_bytes()).hexdigest()
key.public_key().verify(bytes.fromhex(value['signature']), publisher.signing_message(value))
# The upload carries the release files; the node writes its own history.
entries = {str(path.relative_to(store)): path.read_bytes() for path in store.rglob('*')
+23 -8
View File
@@ -54,13 +54,23 @@ def main():
while driver.tree()[0]['width'] != width:
assert time.monotonic() < deadline
time.sleep(.03)
for label in ('Levels', 'Help', 'Mute', 'Profile'):
control = driver.wait(label=label, role='button')
assert control['y'] < 16 and control['height'] >= 44, (label, control)
# The covers keep only Profile over the full artwork.
profile = driver.wait(label='Profile', role='button')
assert profile['y'] < 16 and profile['height'] >= 44, profile
assert not driver.find(label='Settings', role='button')
assert not driver.find(key=49202), 'The native header must not cover the artwork'
covers = driver.find(role='image', visible=True)
assert any(image['y'] == 0 and image['height'] == height for image in covers), covers
# Play opens the level directly, with the game's own header.
driver.press(label='Play', role='button')
driver.wait(label='Restart', role='button')
if driver.find(label='How do you want to move?', role='text'):
driver.press(label='Swipe and tap')
driver.wait_gone(label='How do you want to move?', role='text')
for label in ('Back', 'Levels', 'Help', 'Mute'):
control = driver.wait(label=label, role='button')
assert control['y'] < 16 and control['height'] >= 44, (label, control)
assert not driver.find(label='Profile', role='button', visible=True), 'Play fills the screen'
driver.press(label='Help', role='button')
header = driver.wait(label='Help', role='text')
back = driver.wait(label='Back', role='button')
@@ -78,20 +88,25 @@ def main():
if driver.find(label='Tree stump', role='text', visible=True):
break
driver.wait(label='Tree stump', role='text')
# Back closes the guide, then returns from the level to the covers.
driver.press(label='Back', role='button')
driver.wait(label='Restart', role='button')
driver.press(label='Back', role='button')
driver.wait(label='Play', role='button')
driver.press(label='Play', role='button')
driver.press(label='Levels', role='button')
assert driver.wait(label='Back', role='button')['y'] < 16
driver.press(label='Back', role='button')
driver.wait(label='Restart', role='button')
driver.press(label='Back', role='button')
driver.wait(label='Play', role='button')
driver.press(label='Profile', role='button')
driver.wait(label='Dew balance', role='text')
driver.wait(label='Not signed in', role='text')
assert not driver.find(label='Intention', role='text')
assert not driver.find(label='Name', role='text')
driver.press(label='Connect an account', role='button')
driver.press(label='Create account', role='button')
driver.wait(contains='Account connected on this device', timeout=30)
driver.press(key=49001)
driver.wait(label='Account connected', role='text', timeout=30)
driver.wait(label='Dew balance', role='text')
driver.press(key=49001)
driver.wait(label='Play', role='button')
assert not driver.find(label='Dew', role='button')
@@ -111,7 +126,7 @@ def main():
if child.poll() is None:
child.terminate()
child.wait(timeout=10)
print('Shovey: full-cover top controls, one Help row, 137 guide entries, shared Profile and inline Dew passed')
print('Shovey: Profile over the covers, game header in play, one Help row, 137 guide entries, shared Profile and inline Dew passed')
if __name__ == '__main__':
+16 -3
View File
@@ -1,5 +1,6 @@
"""Check the real level selector's wheel, content drag and scrollbar privately."""
import argparse
import json
import os
from pathlib import Path
import subprocess
@@ -17,6 +18,9 @@ def main():
assert os.environ['YUE_DESKTOP_RECOVERY'] == '0'
sys.path.insert(0, str(args.inbe_source / 'tests'))
from ui_driver import UiDriver
root = Path(__file__).resolve().parents[1]
shovey = Path(subprocess.check_output([str(root / 'scripts/ziran.sh'), 'pkg', 'path', 'shovey'], text=True).strip())
last = str(len(json.loads((shovey / 'levels/approved.json').read_text())['levels']))
def wait(predicate, message):
deadline = time.monotonic() + 5
@@ -39,13 +43,22 @@ def main():
driver.attach(child, log_path)
try:
driver.press(label='Play', role='button')
# The first level asks how to move before its bar takes input.
driver.press(label='Swipe and tap')
driver.wait_gone(label='How do you want to move?', role='text')
driver.press(label='Levels', role='button')
driver.wait(label='Continue', role='button')
numbers = [int(n['label']) for n in driver.find(role='button') if n['label'].isdigit()]
last = str(max(numbers))
def first_y():
return driver.find(label='1', role='button')[0]['y']
"""Where level 1's row is, from whichever cards are built:
only the cards in view exist."""
cards = [n for n in driver.find(role='button')
if n['label'].isdigit() and 33000 < n['key'] < 34000]
columns = len({round(card['x']) for card in cards})
rows = sorted({round(card['y']) for card in cards})
pitch = rows[1] - rows[0] if len(rows) > 1 else 0
card = min(cards, key=lambda card: int(card['label']))
return card['y'] - (int(card['label']) - 1) // columns * pitch
for width, height in ((480, 820), (960, 600)):
windows = subprocess.check_output(
+8 -5
View File
@@ -1,5 +1,5 @@
"""Run the standalone Shovey app privately: the title pages, Classic and Editor
opening directly, Island's status screen, and independent saves."""
"""Run the standalone Shovey app privately: its covers, Classic and Editor
opening directly from them, Island staying unavailable, and independent saves."""
import argparse
import contextlib
import json
@@ -174,10 +174,10 @@ def main():
landscape_preview = driver.find(label='1', role='image', visible=True)[0]
assert abs(landscape_preview['width'] / landscape_preview['height'] - 5 / 3) < .01
subprocess.run(['import', '-window', window, str(output / 'level-selector-landscape.png')], check=True)
# Back from the level list returns to the level, then to the covers.
driver.press(key=20022)
driver.wait(label='Play', role='button')
driver.press(label='Play', role='button')
driver.wait(label=f'Level 1 / {classic_levels}')
assert not driver.find(label='Continue', role='button', visible=True)
driver.press(label='Back', role='button')
driver.wait(label='Play', role='button')
driver.press(label='Play', role='button')
@@ -232,11 +232,14 @@ def main():
driver.press(label='Next', role='button')
driver.press(label='Open', role='button')
driver.wait(label='Explore', role='button')
# Escape returns to the editor's cover, which stays selected.
driver.key('escape')
driver.wait(label='Open', role='button')
driver.press(label='Previous', role='button')
driver.press(label='Play', role='button')
driver.wait(label=f'Level 1 / {classic_levels}')
assert campaign_progress(classic.read_bytes()) == classic_saved
print('Standalone Shovey: portrait/landscape boards, swipe directions, rotation saves, title pages and independent saves passed')
print('Standalone Shovey: portrait/landscape boards, swipe directions, rotation saves, covers and independent saves passed')
if __name__ == '__main__':
+30 -25
View File
@@ -1,4 +1,4 @@
"""Check native Profile/Settings navigation without touching owner data."""
"""Check native Profile and cover navigation without touching owner data."""
import argparse
import os
from pathlib import Path
@@ -18,13 +18,13 @@ output = Path(__file__).resolve().parents[1] / 'build/standalone-navigation-ui-t
output.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(prefix='native-navigation-') as temporary:
for binary in args.binary:
profile = Path(temporary) / binary.name
profile_root = Path(temporary) / binary.name
driver = UiDriver(output / binary.name / 'driver')
log_path = output / (binary.name + '.log')
with log_path.open('w') as log:
child = subprocess.Popen([str(binary.resolve())], cwd=binary.resolve().parent,
env=os.environ | driver.environment() |
{'ARCADE_DATA': str(profile), 'LANG': 'en_US.UTF-8'},
{'ARCADE_DATA': str(profile_root), 'LANG': 'en_US.UTF-8'},
stdout=log, stderr=subprocess.STDOUT)
driver.attach(child, log_path)
try:
@@ -32,12 +32,12 @@ with tempfile.TemporaryDirectory(prefix='native-navigation-') as temporary:
def toolbar():
screen = driver.tree()[0]
for label in ('Profile', 'Settings'):
buttons = driver.find(label=label, role='button', visible=True)
assert len(buttons) == 1, (label, buttons)
button = buttons[0]
assert button['y'] <= 12 and button['width'] >= 44 and button['height'] >= 44
assert button['x'] >= screen['width'] - 112, 'Action is not at the top right'
buttons = driver.find(label='Profile', role='button', visible=True)
assert len(buttons) == 1, buttons
button = buttons[0]
assert button['y'] <= 12 and button['width'] >= 44 and button['height'] >= 44
assert button['x'] >= screen['width'] - 112, 'Profile is not at the top right'
assert not driver.find(label='Settings', role='button', visible=True)
def capture(name):
windows = subprocess.check_output(['xdotool', 'search', '--onlyvisible', '--pid', str(child.pid)], text=True).split()
@@ -45,35 +45,40 @@ with tempfile.TemporaryDirectory(prefix='native-navigation-') as temporary:
assert int(subprocess.check_output(['xdotool', 'getwindowpid', windows[0]], text=True)) == child.pid
subprocess.run(['import', '-window', windows[0], str(output / (binary.name + '-' + name + '.png'))], check=True)
def profile_and_settings(return_label):
def profile():
toolbar()
driver.press(label='Profile', role='button')
driver.wait(label='Profile', role='text')
driver.wait(label='Change picture', role='button')
toolbar()
driver.press(label='Settings', role='button')
driver.wait(label='Settings', role='text')
driver.wait(label='Nodes', role='text', visible=False)
toolbar()
capture('settings')
driver.press(label='Back', role='button')
driver.wait(label=return_label, role='button')
driver.wait(label='Account', role='text')
capture('profile')
driver.press(key=49001)
driver.wait(label='Play', role='button')
# The library's covers carry Profile at the top right.
toolbar()
capture('home')
profile_and_settings('Play')
profile()
driver.press(label='Play', role='button')
driver.wait(label='Restart', role='button')
if driver.find(label='How do you want to move?', role='text'):
driver.press(label='Swipe and tap')
driver.wait_gone(label='How do you want to move?', role='text')
for direction in ('left', 'up', 'right', 'down'):
driver.key(direction)
record = profile / 'games/arcade.shovey/records/campaign'
record = profile_root / 'games/arcade.shovey/records/campaign'
driver.wait_idle(frames=5)
before = record.read_bytes()
profile_and_settings('Restart')
assert record.read_bytes() == before, 'Native pages changed game progress'
toolbar()
# Play fills the screen; its one Back returns to the covers.
assert not driver.find(label='Profile', role='button', visible=True)
assert len(driver.find(label='Back', role='button', visible=True)) == 1
capture('playing')
print(f'PASS: {binary.name}: top-right Profile/Settings, shared pages, return navigation, retained save')
driver.press(label='Back', role='button')
driver.wait(label='Play', role='button')
profile()
assert record.read_bytes() == before, 'Native pages changed game progress'
driver.press(label='Play', role='button')
driver.wait(label='Restart', role='button')
print(f'PASS: {binary.name}: top-right Profile on the covers, full-screen play, return navigation, retained save')
finally:
if child.poll() is None:
child.terminate()
+34 -34
View File
@@ -28,7 +28,7 @@
},
{
"commit": "1cb9df183089a77c8a16448a556186f30b261a98",
"dependencies": {"kryon": "p62b1df489d9e5c45"},
"dependencies": {"kryon": "pac3bbc70c330905a"},
"id": "p1b13dda539ed2a39",
"name": "Kss",
"ref": "master",
@@ -36,7 +36,7 @@
},
{
"commit": "bad2caaa84ef3eae61e40c99bf572d2b060d0ca2",
"dependencies": {"kryon": "p62b1df489d9e5c45"},
"dependencies": {"kryon": "pac3bbc70c330905a"},
"id": "p20eb23d3e6db3711",
"name": "Game2D",
"ref": "master",
@@ -51,6 +51,22 @@
"source": true,
"url": "https://github.com/sqlite/sqlite.git"
},
{
"commit": "e726597f219fddd88997a1b8ddaf96dd1cefe57e",
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "pac3bbc70c330905a", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "p24f8c24d10ef55eb",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "bd5decac8ed868382b3014fc978a74213c2ebe00",
"dependencies": {"apps": "pbc99e0ac3699631f", "entity": "p24f8c24d10ef55eb", "kryon": "pac3bbc70c330905a", "mingcute": "pe1027b9d16704793"},
"id": "p2802862be0857a94",
"name": "Shovey",
"ref": "master",
"url": "https://github.com/waozixyz/shovey.git"
},
{
"commit": "eb2b201a2da3bfc6fefd7ff2d8e476e3cb9e5bcb",
"dependencies": {},
@@ -62,7 +78,7 @@
},
{
"commit": "2f6f1f57d7de742ef7ebc01159c2315acf793d5b",
"dependencies": {"apps": "pae8cbf8fa0578bfc", "crypto": "pf039d7a776333200", "curl": "p2f75403ea4cb61e4", "daochi_client": "p0cff069893bdc938", "game2d": "p20eb23d3e6db3711", "kryon": "p62b1df489d9e5c45", "kss": "p1b13dda539ed2a39", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pe8e21a1f2b5ff52c", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "self": "pa4da0de6c3c44e61", "sqlite": "p219661bf4be659ed"},
"dependencies": {"apps": "pbc99e0ac3699631f", "crypto": "pf039d7a776333200", "curl": "p2f75403ea4cb61e4", "daochi_client": "p0cff069893bdc938", "game2d": "p20eb23d3e6db3711", "kryon": "pac3bbc70c330905a", "kss": "p1b13dda539ed2a39", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pe8e21a1f2b5ff52c", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "self": "pa4da0de6c3c44e61", "sqlite": "p219661bf4be659ed"},
"id": "p48228a6b7e2920d3",
"name": "Inbe",
"ref": "master",
@@ -77,14 +93,6 @@
"source": true,
"url": "https://github.com/open-quantum-safe/liboqs.git"
},
{
"commit": "e726597f219fddd88997a1b8ddaf96dd1cefe57e",
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "p62b1df489d9e5c45", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "p594ecc48e8bf4b50",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e",
"dependencies": {},
@@ -94,14 +102,6 @@
"source": true,
"url": "https://github.com/raysan5/raylib.git"
},
{
"commit": "55af1b53b186f5eaaf7249ac7653da3ef1e606d0",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p62b1df489d9e5c45",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
"dependencies": {"liboqs": "p4b0a50b49959e674"},
@@ -121,28 +121,28 @@
},
{
"commit": "357a71d1ee2c7c9526c2af18793ea8628c505034",
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "p62b1df489d9e5c45", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "pac3bbc70c330905a", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "pa4da0de6c3c44e61",
"name": "Self",
"ref": "master",
"url": "https://github.com/waozixyz/self.git"
},
{
"commit": "33f888e50ebefdbee532731fe2aad9ea6f5ab964",
"dependencies": {"crypto": "pf039d7a776333200", "kryon": "p62b1df489d9e5c45"},
"id": "pae8cbf8fa0578bfc",
"commit": "809a0f09d9860fcf3aa37ca4a4b9e29cfe1e116b",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "pac3bbc70c330905a",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "12e52c0599f2c6b9375202ff678f5125c10d0e6a",
"dependencies": {"crypto": "pf039d7a776333200", "kryon": "pac3bbc70c330905a"},
"id": "pbc99e0ac3699631f",
"name": "Apps",
"ref": "master",
"url": "https://github.com/waozixyz/apps.git"
},
{
"commit": "61043fcc02ddf4aa007da0556132e913c17b22ad",
"dependencies": {"apps": "pae8cbf8fa0578bfc", "entity": "p594ecc48e8bf4b50", "kryon": "p62b1df489d9e5c45", "mingcute": "pe1027b9d16704793"},
"id": "pc4ee9051554a3442",
"name": "Shovey",
"ref": "master",
"url": "https://github.com/waozixyz/shovey.git"
},
{
"commit": "9cc6872f75447c3a24c16764f9829d0f58751cb0",
"dependencies": {},
@@ -153,7 +153,7 @@
},
{
"commit": "4b0e25bd2df86b54a8f5af3db48282bd41daab1a",
"dependencies": {"kryon": "p62b1df489d9e5c45"},
"dependencies": {"kryon": "pac3bbc70c330905a"},
"id": "pe8e21a1f2b5ff52c",
"name": "plot",
"ref": "master",
@@ -169,11 +169,11 @@
}
],
"root": {
"dependencies": {"apps": "pae8cbf8fa0578bfc", "entity": "p594ecc48e8bf4b50", "inbe": "p48228a6b7e2920d3", "kryon": "p62b1df489d9e5c45", "mingcute": "pe1027b9d16704793", "shovey": "pc4ee9051554a3442"},
"dependencies": {"apps": "pbc99e0ac3699631f", "entity": "p24f8c24d10ef55eb", "inbe": "p48228a6b7e2920d3", "kryon": "pac3bbc70c330905a", "mingcute": "pe1027b9d16704793", "shovey": "p2802862be0857a94"},
"name": "Arcade"
},
"toolchain": {
"commit": "6be888add06a729145dbe63554e29c1f1c26aaa3",
"commit": "620c4077a801d63984fa4bc6893e857659a5e7e9",
"ref": "master",
"url": "https://github.com/ziranlang/ziran.git"
}