Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d36def3e8e | ||
|
|
fc3eb2b65f | ||
|
|
3f1b939993 | ||
|
|
a699f0d41d | ||
|
|
712e99ed57 | ||
|
|
c797ea22c2 | ||
|
|
7417c15912 | ||
|
|
8af5a37b04 | ||
|
|
35ae14131c | ||
|
|
91819cf7b2 | ||
|
|
148b6f7d84 | ||
|
|
24fc03b7c8 | ||
|
|
02912c2ac3 | ||
|
|
91f79bdda7 | ||
|
|
4192ea74c9 | ||
|
|
720f352f8e | ||
|
|
068f3312ff | ||
|
|
cb84f07471 | ||
|
|
8d8d909913 | ||
|
|
83a75f938f | ||
|
|
178791301f | ||
|
|
5268b9513b | ||
|
|
7b65b8a0ea | ||
|
|
9f900e4512 | ||
|
|
df2d05bef6 | ||
|
|
228bdcc821 | ||
|
|
ef7d07d6ac |
No files matched your search
@@ -0,0 +1,49 @@
|
||||
name: Export locked games
|
||||
description: Prepare game-owned exports, downloading Wurm's compiled release unchanged.
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: games
|
||||
shell: bash
|
||||
working-directory: waozixyz/arcade
|
||||
run: |
|
||||
python3 - <<'PY' >> "$GITHUB_OUTPUT"
|
||||
import json
|
||||
lock = json.load(open('ziran.lock'))
|
||||
for name in ('shovey', 'wurm', 'choano'):
|
||||
identifier = lock['root']['dependencies'][name]
|
||||
print(name + '=' + next(p['commit'] for p in lock['packages'] if p['id'] == identifier))
|
||||
PY
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
repository: waozixyz/shovey
|
||||
ref: ${{ steps.games.outputs.shovey }}
|
||||
path: waozixyz/shovey
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
repository: waozixyz/wurm
|
||||
ref: ${{ steps.games.outputs.wurm }}
|
||||
path: waozixyz/wurm
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
repository: waozixyz/choano
|
||||
ref: ${{ steps.games.outputs.choano }}
|
||||
path: waozixyz/choano
|
||||
- shell: bash
|
||||
working-directory: waozixyz/arcade
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
for name in ('shovey', 'choano'):
|
||||
(Path('..') / name / 'ziran.local.toml').write_text('[overrides]\nziran = "../../ziranlang/ziran"\n')
|
||||
Path('ziran.local.toml').write_text('[overrides]\nziran = "../../ziranlang/ziran"\nshovey = "../shovey"\nwurm = "../wurm"\nchoano = "../choano"\n')
|
||||
PY
|
||||
(cd ../shovey && make levels landscape && python3 scripts/player.py collection --web)
|
||||
(cd ../choano && make portable)
|
||||
- name: Download the pinned Wurm portable release
|
||||
shell: bash
|
||||
working-directory: waozixyz/arcade
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
WURM_COMMIT: ${{ steps.games.outputs.wurm }}
|
||||
run: python3 scripts/fetch-wurm-export.py --source ../wurm --commit "$WURM_COMMIT"
|
||||
@@ -119,11 +119,12 @@ jobs:
|
||||
# The game is generated in its own checkout at the locked release.
|
||||
printf '[overrides]\nshovey = "../shovey"\nziran = "../../ziranlang/ziran"\n' > ziran.local.toml
|
||||
../../ziranlang/ziran/build/bin/ziran fetch
|
||||
- name: Export games in their owning repositories
|
||||
uses: ./waozixyz/arcade/.github/actions/game-exports
|
||||
- name: Build the APK
|
||||
env:
|
||||
EDITION: ${{ matrix.edition }}
|
||||
run: |
|
||||
make -C ../shovey levels landscape
|
||||
if [ "$EDITION" = direct ]; then make android; else make "android-$EDITION"; fi
|
||||
- name: Keep Google libraries out of the normal and F-Droid APK
|
||||
if: matrix.edition != 'gplay'
|
||||
|
||||
@@ -36,6 +36,7 @@ jobs:
|
||||
run: |
|
||||
python3 tests/game_updates_test.py
|
||||
python3 tests/catalog_versions_test.py
|
||||
python3 tests/wurm_export_test.py
|
||||
- name: Find newer game releases
|
||||
id: updates
|
||||
env:
|
||||
@@ -62,7 +63,7 @@ jobs:
|
||||
- name: Install build dependencies
|
||||
if: steps.updates.outputs.changed == 'true'
|
||||
working-directory: .
|
||||
run: sh ziranlang/ziran/scripts/ci_packages.sh build-essential python3-pil python3-cryptography
|
||||
run: sh ziranlang/ziran/scripts/ci_packages.sh build-essential python3-pil python3-numpy python3-cryptography
|
||||
- name: Build the locked toolchain and pin game dependencies
|
||||
id: pin
|
||||
if: steps.updates.outputs.changed == 'true'
|
||||
@@ -99,10 +100,12 @@ jobs:
|
||||
python3 scripts/follow-game-releases.py art
|
||||
echo "version=$(cat catalog/VERSION)" >> "$GITHUB_OUTPUT"
|
||||
head -12 catalog/CHANGELOG.md
|
||||
- name: Prepare game-owned exports
|
||||
if: steps.updates.outputs.changed == 'true'
|
||||
uses: ./waozixyz/arcade/.github/actions/game-exports
|
||||
- name: Build and check the collection
|
||||
if: steps.updates.outputs.changed == 'true'
|
||||
run: |
|
||||
make -C ../shovey levels landscape
|
||||
make collection
|
||||
python3 tests/collection_test.py
|
||||
python3 tests/publisher_test.py
|
||||
@@ -126,7 +129,7 @@ jobs:
|
||||
SHA: ${{ steps.commit.outputs.sha }}
|
||||
run: |
|
||||
set -eu
|
||||
gh release create "node-arcade-$VERSION" build/node-apps/arcade.zx build/node-apps/arcade.games.tar build/games/wurm.zx \
|
||||
gh release create "node-arcade-$VERSION" build/node-apps/arcade.zx build/node-apps/arcade.games.tar \
|
||||
--target "$SHA" --title "Arcade $VERSION" \
|
||||
--notes 'Arcade downloads the selected game separately and preserves earned progress.'
|
||||
echo "Arcade $VERSION is ready for the node: sha256 $(sha256sum build/node-apps/arcade.zx | cut -d' ' -f1)"
|
||||
|
||||
@@ -64,11 +64,12 @@ jobs:
|
||||
# Generate the game in its own checkout, never in the package cache.
|
||||
printf '[overrides]\nshovey = "../shovey"\nziran = "../../ziranlang/ziran"\n' > ziran.local.toml
|
||||
../../ziranlang/ziran/build/bin/ziran fetch
|
||||
- name: Export games in their owning repositories
|
||||
uses: ./waozixyz/arcade/.github/actions/game-exports
|
||||
- name: Build and verify the node catalog
|
||||
env:
|
||||
EXPECTED_SHA256: ${{ inputs.sha256 }}
|
||||
run: |
|
||||
make -C ../shovey levels landscape
|
||||
make collection
|
||||
python3 tests/collection_test.py
|
||||
python3 tests/publisher_test.py
|
||||
@@ -86,7 +87,6 @@ jobs:
|
||||
waozixyz/arcade/build/node-apps/arcade.zx
|
||||
waozixyz/arcade/build/node-apps/arcade.json
|
||||
waozixyz/arcade/build/node-apps/arcade.games.tar
|
||||
waozixyz/arcade/build/games/wurm.zx
|
||||
waozixyz/arcade/build/apps-ui/apps.zx
|
||||
if-no-files-found: ignore
|
||||
retention-days: 1
|
||||
@@ -99,12 +99,11 @@ jobs:
|
||||
tag="node-arcade-$version"
|
||||
if gh release view "$tag" >/dev/null 2>&1; then
|
||||
mkdir -p build/prior-node-release
|
||||
gh release download "$tag" --pattern arcade.zx --pattern arcade.games.tar --pattern wurm.zx --dir build/prior-node-release
|
||||
gh release download "$tag" --pattern arcade.zx --pattern arcade.games.tar --dir build/prior-node-release
|
||||
cmp build/prior-node-release/arcade.zx build/node-apps/arcade.zx
|
||||
cmp build/prior-node-release/arcade.games.tar build/node-apps/arcade.games.tar
|
||||
cmp build/prior-node-release/wurm.zx build/games/wurm.zx
|
||||
else
|
||||
gh release create "$tag" build/node-apps/arcade.zx build/node-apps/arcade.games.tar build/games/wurm.zx \
|
||||
gh release create "$tag" build/node-apps/arcade.zx build/node-apps/arcade.games.tar \
|
||||
--target "$GITHUB_SHA" --title "Arcade $version" \
|
||||
--notes 'Arcade downloads the selected game separately and preserves earned progress.'
|
||||
fi
|
||||
@@ -3,7 +3,9 @@ name: Website
|
||||
# https://arcade.waozi.xyz runs Arcade in the browser: the latest published
|
||||
# arcade.zx, the same one Inner Breeze downloads, with Arcade's own host
|
||||
# compiled to WebAssembly. Every push to master and every Arcade release,
|
||||
# manual or automatic, rebuilds and publishes it.
|
||||
# manual or automatic, rebuilds and publishes it. The host builds from the
|
||||
# source and toolchain that release was tagged at: master may already lock a
|
||||
# newer program format the published arcade.zx does not carry yet.
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
@@ -34,6 +36,23 @@ jobs:
|
||||
path: waozixyz/arcade
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
- name: Check out the published Arcade's source
|
||||
id: published
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
tag=$(gh release list --repo waozixyz/arcade --limit 50 --json tagName,isDraft \
|
||||
-q '[.[] | select(.isDraft | not) | .tagName | select(startswith("node-arcade-"))][0]')
|
||||
test -n "$tag"
|
||||
git fetch --force origin "refs/tags/$tag:refs/tags/$tag"
|
||||
# Keep the current smoke gate while building the release's exact host.
|
||||
smoke_test=$(mktemp)
|
||||
cp tests/web_site_test.mjs "$smoke_test"
|
||||
git checkout --detach "refs/tags/$tag"
|
||||
cp "$smoke_test" tests/web_site_test.mjs
|
||||
rm "$smoke_test"
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${tag#node-arcade-}" >> "$GITHUB_OUTPUT"
|
||||
- name: Read the locked toolchain
|
||||
id: toolchain
|
||||
run: |
|
||||
@@ -60,18 +79,13 @@ jobs:
|
||||
printf '[overrides]\nziran = "../../ziranlang/ziran"\n' > ziran.local.toml
|
||||
../../ziranlang/ziran/build/bin/ziran fetch
|
||||
- name: Download the published Arcade
|
||||
id: published
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
tag=$(gh release list --repo waozixyz/arcade --limit 50 --json tagName,isDraft \
|
||||
-q '[.[] | select(.isDraft | not) | .tagName | select(startswith("node-arcade-"))][0]')
|
||||
test -n "$tag"
|
||||
mkdir -p build/published
|
||||
# Its game archive holds the library art the site serves itself.
|
||||
gh release download "$tag" --repo waozixyz/arcade --pattern arcade.zx \
|
||||
--pattern arcade.games.tar --dir build/published
|
||||
echo "version=${tag#node-arcade-}" >> "$GITHUB_OUTPUT"
|
||||
gh release download '${{ steps.published.outputs.tag }}' --repo waozixyz/arcade \
|
||||
--pattern arcade.zx --pattern arcade.games.tar --dir build/published
|
||||
- name: Build the browser edition
|
||||
run: |
|
||||
python3 tests/web_library_art_test.py
|
||||
|
||||
@@ -2,10 +2,44 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Use Entity's reviewed account authorization and shared Apps controller.
|
||||
- Keep the full game collection within the host payload limit by packing opaque pictures without redundant alpha data; decoded pixels stay identical.
|
||||
- On Android, Continue as can use the account from another signed-in Waozi app, once you approve it there.
|
||||
- Arcade and its games open again in Breeze builds that read the previous app bundle format.
|
||||
- Download standalone Wurm from its own releases; Arcade keeps its catalog and game archive.
|
||||
|
||||
- Open the full Arcade catalog in Breeze and keep Choano progress available in the hosted game.
|
||||
|
||||
- Build on Ziran 0.5.0 and Kryon b45cc524 with its namespaced widgets. Game
|
||||
exports are read as one-format ZX 28 through `build/zx-metadata`, which
|
||||
verifies a bundle without running it. Add-ons carry their game's code, so
|
||||
collections no longer mark `shared_code` and `apps.json` no longer accepts
|
||||
`shared_code` or `library_entries`. The unused game module-path helper is
|
||||
removed, and the Profile bundle comes from Entity's own `native-profile`
|
||||
artifact.
|
||||
|
||||
- `arcade --check` opens the collection beside the binary without a window.
|
||||
`make`, `make test` and the install run it, so a binary is never left next
|
||||
to a collection it refuses; Arcade had closed right after opening from
|
||||
Harmony's Apps when its build folder held a binary and a collection from
|
||||
two different toolchains.
|
||||
- Close Profile directly from its X button while keeping Back navigation through account pages.
|
||||
- Use a neutral profile icon instead of the Shovey portrait.
|
||||
- Remember completed account backups when reopening Arcade or using the same desktop account in another app.
|
||||
|
||||
- Runs games built for the latest Inner Breeze.
|
||||
|
||||
## 0.7.120
|
||||
|
||||
- Library covers show their original painted artwork again.
|
||||
- Landscape uses the same cover carousel as portrait, on a scenic background.
|
||||
- Clicking or tapping a cover beside the centre selects it; the centre cover starts the game.
|
||||
- Missing games download on their cover with a progress bar while you keep browsing.
|
||||
- Updating Arcade no longer brings back an older saved library with the wrong artwork.
|
||||
- Shovey opens its proper title with the daily chest, profile and swipeable covers.
|
||||
|
||||
## 0.7.119
|
||||
|
||||
- Browse an artwork-led console shelf in portrait or landscape, with painted profile and Dew controls.
|
||||
- Download games from their launch screens and return Home with progress saved; editors and drafts stay inside their games.
|
||||
- Improve account sign-in, password entry and Android chest reminders.
|
||||
- Preserve installed games and saves across library, host and Breeze updates.
|
||||
|
||||
## 0.7.117
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ 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))
|
||||
# Optional manifest of already exported game artifacts (never compiler inputs).
|
||||
GAME_ARTIFACT_MANIFEST ?=
|
||||
APPS_BUNDLE := build/apps-ui/apps.zx
|
||||
APPS_SHA256 := $(shell cat apps-controller.sha256)
|
||||
INBE_SOURCE ?= $(shell $(ZIRAN) pkg path inbe $(LOCK_FLAGS))
|
||||
@@ -17,11 +19,11 @@ 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.zx build/arcade build/shovey
|
||||
all: collection build/entity.zx build/arcade build/shovey collection-check
|
||||
|
||||
games:
|
||||
games: build/zx-metadata
|
||||
python3 scripts/check-games.py --ziran '$(ZIRAN)' $(LOCK_FLAGS)
|
||||
python3 scripts/build-games.py --ziran '$(ZIRAN)' $(LOCK_FLAGS)
|
||||
python3 scripts/build-games.py --ziran '$(ZIRAN)' $(LOCK_FLAGS) $(if $(GAME_ARTIFACT_MANIFEST),--artifact-manifest '$(GAME_ARTIFACT_MANIFEST)')
|
||||
|
||||
$(APPS_BUNDLE): ziran.lock apps-controller.sha256 scripts/build-apps.py Makefile
|
||||
$(ZIRAN) version > /dev/null
|
||||
@@ -33,9 +35,34 @@ collection: games $(APPS_BUNDLE)
|
||||
python3 scripts/build-collection.py --ziran '$(ZIRAN)' $(LOCK_FLAGS) \
|
||||
--apps-bundle '$(APPS_BUNDLE)' --apps-sha256 '$(APPS_SHA256)'
|
||||
|
||||
# Reads a game export's entry and assets for build-games.py; nothing runs.
|
||||
build/zx-metadata: scripts/zx_metadata.zi ziran.lock build/ziran/libziran.a
|
||||
rm -rf build/zx-metadata-c
|
||||
$(ZIRAN) build $(PROJECT) --target=c --root scripts --entry zx_metadata:main \
|
||||
-o build/zx-metadata-c scripts/zx_metadata.zi
|
||||
$(CC) -std=c11 -O1 -Wno-main -I'$(ZIRAN_ROOT)/include' -Ibuild/zx-metadata-c \
|
||||
build/zx-metadata-c/*.c build/ziran/libziran.a -lm -lpthread -o $@
|
||||
|
||||
.PHONY: game-artifacts-test
|
||||
game-artifacts-test: build/zx-metadata
|
||||
python3 tests/game_artifacts_test.py
|
||||
python3 tests/wurm_export_test.py
|
||||
|
||||
collection-test:
|
||||
python3 tests/collection_test.py
|
||||
|
||||
.PHONY: collection-notifications-test
|
||||
collection-notifications-test:
|
||||
python3 tests/game_host_compatibility_test.py
|
||||
python3 tests/collection_notifications_test.py
|
||||
|
||||
# The desktop binary opens the collection beside it and refuses one that a
|
||||
# newer toolchain built (owner, 2026-11-15: Arcade closed right after opening
|
||||
# from Harmony's Apps). Build and check the pair together, with private data.
|
||||
.PHONY: collection-check
|
||||
collection-check: collection build/arcade
|
||||
ARCADE_DATA='$(CURDIR)/build/collection-check' ./build/arcade --check
|
||||
|
||||
src/catalog.zi: games
|
||||
|
||||
build/entity.zx: ziran.lock $(wildcard $(ENTITY_DIR)/src/*.zi)
|
||||
@@ -54,7 +81,11 @@ run: all
|
||||
./build/arcade
|
||||
|
||||
test: all
|
||||
python3 tests/game_module_paths_test.py
|
||||
python3 tests/catalog_versions_test.py
|
||||
python3 tests/game_artifacts_test.py
|
||||
python3 tests/wurm_export_test.py
|
||||
python3 tests/game_host_compatibility_test.py
|
||||
python3 tests/collection_notifications_test.py
|
||||
python3 tests/game_resource_packing_test.py
|
||||
python3 tests/game_translation_keys_test.py
|
||||
python3 tests/android_catalog_test.py
|
||||
@@ -69,7 +100,6 @@ test: all
|
||||
python3 tests/web_library_art_test.py
|
||||
./build/arcade --list
|
||||
sh tests/chess_engine_zi_test.sh '$(ZIRAN)'
|
||||
sh tests/chess_app_test.sh '$(ZIRAN)'
|
||||
python3 tests/sound_test.py
|
||||
sh tests/collection_loading_test.sh
|
||||
|
||||
@@ -114,14 +144,17 @@ navigation-ui-test: all
|
||||
--binary '$(CURDIR)/build/arcade' --binary '$(CURDIR)/build/shovey' --inbe-source '$(INBE_SOURCE)'
|
||||
|
||||
.PHONY: install-arcade
|
||||
install-arcade: collection build/entity.zx build/arcade
|
||||
install-arcade: collection build/entity.zx build/arcade collection-check
|
||||
mkdir -p '$(BIN_DIR)' '$(LIB_DIR)' '$(DATA_DIR)/applications'
|
||||
install -m 0755 build/arcade '$(LIB_DIR)/arcade.new'
|
||||
mv -f '$(LIB_DIR)/arcade.new' '$(LIB_DIR)/arcade'
|
||||
install -m 0644 build/entity.zx build/arcade.zx build/arcade.json '$(LIB_DIR)/'
|
||||
install -m 0644 '$(APPS_BUNDLE)' '$(LIB_DIR)/apps.zx'
|
||||
mkdir -p '$(LIB_DIR)/assets/hud'
|
||||
install -m 0644 build/assets/hud/profile.webp build/assets/hud/dew.webp '$(LIB_DIR)/assets/hud/'
|
||||
ln -sfn '$(LIB_DIR)/arcade' '$(BIN_DIR)/arcade'
|
||||
install -m 0644 packaging/xyz.waozi.arcade.desktop '$(DATA_DIR)/applications/'
|
||||
ARCADE_DATA='$(CURDIR)/build/collection-check' '$(LIB_DIR)/arcade' --check
|
||||
|
||||
install: all install-arcade
|
||||
mkdir -p '$(BIN_DIR)' '$(LIB_DIR)/games' '$(DATA_DIR)/applications'
|
||||
@@ -133,6 +166,8 @@ install: all install-arcade
|
||||
mv -f '$(LIB_DIR)/shovey.new' '$(LIB_DIR)/shovey'
|
||||
install -m 0644 build/entity.zx build/arcade.zx build/arcade.json build/shovey.zx build/shovey.json '$(LIB_DIR)/'
|
||||
install -m 0644 '$(APPS_BUNDLE)' '$(LIB_DIR)/apps.zx'
|
||||
mkdir -p '$(LIB_DIR)/assets/hud'
|
||||
install -m 0644 build/assets/hud/profile.webp build/assets/hud/dew.webp '$(LIB_DIR)/assets/hud/'
|
||||
ln -sfn '$(LIB_DIR)/arcade' '$(BIN_DIR)/arcade'
|
||||
ln -sfn '$(LIB_DIR)/shovey' '$(BIN_DIR)/shovey'
|
||||
mkdir -p '$(DATA_DIR)/icons/hicolor/256x256/apps'
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
# Arcade
|
||||
|
||||
Games and entertainment, alongside Werkzeug for practical tools and Inner
|
||||
Breeze for personal growth. Arcade opens on a dark grid of large rounded
|
||||
title-screen covers from the shared Apps controller. Click a cover to open
|
||||
an installed game or download it first. There are no separate launch buttons.
|
||||
Breeze for personal growth. Arcade opens on a console home from the shared Apps controller.
|
||||
Landscape fills the screen with the selected game’s screenshot above one bottom
|
||||
row of wide covers. Portrait centers a large tall cover, with neighbours peeking
|
||||
in and the same game colouring the background. A glowing outline marks focus. There is no home title or cover caption.
|
||||
Arrow keys, controller D-pad or left stick, swipes and the wheel select games;
|
||||
Enter or controller A opens the selection. Click a cover to open
|
||||
an installed game or open its artwork launch page first. Download consent,
|
||||
progress and retry stay in that page, without a modal. Back keeps the transfer
|
||||
running and returns to the same selected cover. Verified games open their own
|
||||
title screen. A house-shaped Arcade control stays above hosted games and editors;
|
||||
F1 or a controller’s View/Select button returns directly to the library after saving.
|
||||
Standalone Shovey opens on its own cover carousel;
|
||||
swipe, use the arrows or scroll the wheel to choose, then press Play/Open.
|
||||
Its desktop startup first draws a small full-colour title preview, then uses
|
||||
@@ -13,16 +21,21 @@ 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.
|
||||
|
||||
The published Arcade carries only its catalog, well under one megabyte. Its host supplies the shared Apps controller (Inner Breeze its own, standalone Arcade the `apps.zx` installed beside it), and the covers and previews download once as one separate art bundle. Library covers use thumbnails up to 640 pixels on their longest side, and logos up to 512 pixels, preserving full colours and transparency. Games keep their original artwork. The verified art bundle stays cached across restarts and is replaced when its content changes. The art lives in `assets/arcade/library/` (`python3 scripts/library-art.py` refreshes it when a game's art changes; the build stops until it does). Inner Breeze needs host interface 35 for it. Each game
|
||||
The published Arcade carries only its catalog, well under one megabyte. Its host supplies the shared Apps controller (Inner Breeze its own, standalone Arcade the `apps.zx` installed beside it), and the covers and previews download once as one separate art bundle. Library previews stay at 256 pixels. Real gameplay screenshots supply landscape heroes up to 1600 pixels and portrait covers up to 1080 pixels on the longest side, encoded as quality-80 WebP. The complete separate art bundle has a 2 MiB budget for the current games. Full-size originals stay in their game repositories. The verified art bundle stays cached across restarts and is replaced when its content changes. The art lives in `assets/arcade/library/` (`python3 scripts/library-art.py` refreshes it when a game's art changes; the build stops until it does). Inner Breeze needs host interface 35 for it. Each game
|
||||
downloads when opened, with its existing identity and saved progress. This
|
||||
catalog requires Inner Breeze host API 41. Downloaded games work offline;
|
||||
catalog requires Inner Breeze host API 43. Downloaded games work offline;
|
||||
standalone Shovey keeps its complete offline collection. Apfelwurm comes from
|
||||
its own package, with the same game identity and private editor records.
|
||||
|
||||
Shovey Editor is an add-on to Shovey. Its install dialog lists Shovey when it
|
||||
is needed and shows the total download size. Once Shovey is installed, only
|
||||
Arcade lists games only. Each game opens on its own normal title screen.
|
||||
Editors open from inside their games; installed editor add-ons and saved drafts
|
||||
keep their existing identities and records. Shovey’s Classic editor remains an
|
||||
add-on. Its named install dialog lists Shovey when needed and shows the total
|
||||
download size. The Island editor stays private. Once Shovey is installed, only
|
||||
the editor’s additions download. The editor reuses the original game’s art
|
||||
and sounds, and both remain available offline.
|
||||
and sounds, and both remain available offline. The top-right HUD uses the shared
|
||||
painted Dew jewel and a neutral profile icon in one frame. Its two icons ship with the
|
||||
host independently of the remote library, so they also work offline.
|
||||
|
||||
Chess’s retained implementation can choose a side and one of four computer
|
||||
levels. A local game
|
||||
@@ -48,16 +61,17 @@ review are not implemented.
|
||||
|
||||
Arcade includes the reviewed shared `apps.zx` controller and a small seed
|
||||
catalog. It asks before connecting to its node for the signed app library
|
||||
and compressed previews. The connection control can switch back to offline;
|
||||
and compressed previews. Profile’s Library connection control can switch back to offline;
|
||||
verified cached apps, previews and saved progress remain available.
|
||||
The catalog fixes the digest of every separately downloaded game. 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`
|
||||
cover's portrait art, landscape art 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. Library refreshes use the reusable Apps signed catalog
|
||||
presents the games directly, and a cover opens the game's normal title screen.
|
||||
Editor add-ons remain declared for verified installation and save compatibility,
|
||||
and open from inside their game. Shovey’s separate standalone collection uses
|
||||
the same game identities and saves. The shared Apps console handles navigation
|
||||
and painting with Kryon widgets. Library refreshes use the reusable Apps signed catalog
|
||||
loader and do not update the native host. Inbe supplies its own account and package policy.
|
||||
Arcade's launcher icon is MingCute's `game_2` gamepad (Apache-2.0).
|
||||
|
||||
@@ -170,9 +184,39 @@ release. An APK's embedded seed catalog may have a different version from
|
||||
its native host.
|
||||
|
||||
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.
|
||||
`apps.json`. Arcade is a catalog and downloader: games build and publish
|
||||
in their own repositories. `scripts/build-games.py` imports their portable
|
||||
exports byte for byte and generates catalog metadata; it never compiles game
|
||||
source, prepares assets, or runs game payloads. Disabled entries remain catalog
|
||||
metadata only, and private external editions (including Island) stay excluded.
|
||||
|
||||
Before a local integrated build, export in each owning repository:
|
||||
|
||||
- Shovey: `build-queue -- python3 scripts/player.py collection --web` exports
|
||||
`build/player/games/{shovey,shovey-editor}.zx` and `-resources.json`.
|
||||
- Wurm: `build-queue -- python3 tools/build_portable.py` exports
|
||||
`build/games/{wurm,wurm-editor}.zx`, `-resources.json` and `-preview.png`.
|
||||
- Choano: `build-queue -- make portable` exports `build/choano.zx`.
|
||||
|
||||
Shovey and Choano previews come unchanged from their declared game preview
|
||||
paths. Every payload must embed its public app catalog at
|
||||
`assets/NAME/catalog.json`; add-ons must also embed `requirements.json` naming
|
||||
the exact imported dependency hashes. Import rejects identity, entry, resource
|
||||
link and dependency mismatches and payloads over 64 MiB before replacing prior
|
||||
staged games or catalogs. No compiler fallback exists.
|
||||
|
||||
Clean locked/downloaded packages may have no local exports. Supply
|
||||
`--artifact-manifest PATH` to the importer (or `make
|
||||
GAME_ARTIFACT_MANIFEST=PATH`) with already exported artifacts. The JSON shape
|
||||
is `{"apps":{"APP_ID":{"bundle":"exports/game.zx",
|
||||
"preview":"exports/preview.png","resources":"exports/game-resources.json"}}}`.
|
||||
Paths are relative to the manifest or absolute; name exactly the enabled public
|
||||
IDs, including editor add-ons. `resources` may be omitted only for apps with
|
||||
no dependencies. Payloads and supplied sidecars are copied unchanged.
|
||||
Automatic remote release artifact retrieval/export wiring is not currently
|
||||
available here: obtain exports from the game owner or run its command above.
|
||||
The existing published web catalog build does not invoke game builds.
|
||||
Inbe remains a dependency for the existing shared interface and signed publisher.
|
||||
|
||||
## Saved games
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
4bed077eacf6879f44fd581d59cfff20b15a813cfbe6c4eecd16535693b99329
|
||||
0dc9b6f9ae8a11731d51fa4e118f9a545cee0575d742517f209413fdfa93df95
|
||||
@@ -1,5 +1,9 @@
|
||||
# Chess changelog
|
||||
|
||||
## [1.2.2] - 2026-11-07
|
||||
|
||||
- Runs in the latest Inner Breeze and Arcade.
|
||||
|
||||
## [1.2.1] - 2026-10-29
|
||||
|
||||
- Runs in Inner Breeze 2.1.61's smaller app format.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"kind": "game",
|
||||
"contract_version": 1,
|
||||
"module_api": 2,
|
||||
"host_api": 41,
|
||||
"host_api": 43,
|
||||
"save_schema": 1,
|
||||
"harnesses": ["arcade", "inbe"],
|
||||
"entry": "chess:Main",
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
{
|
||||
"host_api": 41,
|
||||
"oldest_host_api": 41,
|
||||
"host_api": 43,
|
||||
"oldest_host_api": 43,
|
||||
"module_api": 2,
|
||||
"node_apps": {
|
||||
"chess": {
|
||||
"id": "inbe.chess",
|
||||
"title": "Chess",
|
||||
"version": "1.2.1",
|
||||
"sequence": 6,
|
||||
"host_api": 41
|
||||
"version": "1.2.2",
|
||||
"sequence": 7,
|
||||
"host_api": 43
|
||||
},
|
||||
"choano": {
|
||||
"id": "xyz.waozi.choano",
|
||||
"title": "Choano",
|
||||
"version": "0.1.8",
|
||||
"sequence": 3,
|
||||
"host_api": 41
|
||||
"version": "0.1.9",
|
||||
"sequence": 4,
|
||||
"host_api": 43
|
||||
},
|
||||
"shovey": {
|
||||
"id": "arcade.shovey",
|
||||
"title": "Shovey",
|
||||
"version": "0.6.163",
|
||||
"sequence": 170,
|
||||
"host_api": 41
|
||||
"version": "0.6.171",
|
||||
"sequence": 176,
|
||||
"host_api": 43
|
||||
},
|
||||
"shovey-editor": {
|
||||
"id": "arcade.shovey-editor",
|
||||
"title": "Shovey Editor",
|
||||
"version": "0.2.147",
|
||||
"sequence": 149,
|
||||
"host_api": 41
|
||||
"version": "0.2.150",
|
||||
"sequence": 152,
|
||||
"host_api": 43
|
||||
},
|
||||
"arcade": {
|
||||
"id": "inbe.arcade",
|
||||
"title": "Arcade",
|
||||
"version": "0.7.118",
|
||||
"sequence": 197,
|
||||
"host_api": 41
|
||||
"version": "0.7.126",
|
||||
"sequence": 205,
|
||||
"host_api": 43
|
||||
},
|
||||
"wurm": {
|
||||
"id": "xyz.waozi.wurm",
|
||||
"title": "Apfelwurm",
|
||||
"version": "0.2.28",
|
||||
"sequence": 23,
|
||||
"host_api": 41
|
||||
"version": "0.2.34",
|
||||
"sequence": 28,
|
||||
"host_api": 43
|
||||
},
|
||||
"wurm-editor": {
|
||||
"id": "xyz.waozi.wurm-editor",
|
||||
"title": "Apfelwurm Editor",
|
||||
"version": "0.1.1",
|
||||
"sequence": 2,
|
||||
"host_api": 41
|
||||
"version": "0.1.2",
|
||||
"sequence": 3,
|
||||
"host_api": 43
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 37 KiB |
@@ -1,53 +1,78 @@
|
||||
{
|
||||
"choano-landscape": {
|
||||
"source_sha256": "1ca6e31c1062a7cca41bace4cf1bb221291988aea4a1dd61271899c2f5f28307"
|
||||
"source_sha256": "dfea1e328a0f386d0b5e323a59bbbc3cfa926f1dbdceaa09a9858a43b0949091",
|
||||
"crop_top": 0
|
||||
},
|
||||
"choano-portrait": {
|
||||
"source_sha256": "47b07722c474a67ee4a06b7644a3aff211503674391e363c17eb06a34ce60d6c"
|
||||
"source_sha256": "10be8a3d9251deeede9080c715a7a5dadc1b1641db16aa3a04b874a266302ea9",
|
||||
"crop_top": 0
|
||||
},
|
||||
"choano-preview": {
|
||||
"source_sha256": "1ca6e31c1062a7cca41bace4cf1bb221291988aea4a1dd61271899c2f5f28307"
|
||||
"source_sha256": "dfea1e328a0f386d0b5e323a59bbbc3cfa926f1dbdceaa09a9858a43b0949091",
|
||||
"crop_top": 0
|
||||
},
|
||||
"hud-dew": {
|
||||
"source_sha256": "5a08721b436dcbe99ce69758d02dd56d84f7f3b9990856528990e0ce11a77443",
|
||||
"crop_top": 0
|
||||
},
|
||||
"hud-profile": {
|
||||
"source_sha256": "0c38b54870cd7a921e6a63126724c4877d81bc5edbdf61e4baefe860e82b2c39",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-editor-landscape": {
|
||||
"source_sha256": "7b1eae4209ede14807806a4cbce1e2bf7a14d342e75c89042958a524cf60d67e"
|
||||
"source_sha256": "7b1eae4209ede14807806a4cbce1e2bf7a14d342e75c89042958a524cf60d67e",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-editor-logo": {
|
||||
"source_sha256": "5417341ed432c49d4ce1df45e5e6bf7e07e11a81face45cb93d7cc9fa976f7a5"
|
||||
"source_sha256": "5417341ed432c49d4ce1df45e5e6bf7e07e11a81face45cb93d7cc9fa976f7a5",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-editor-portrait": {
|
||||
"source_sha256": "bf0bbeb15249f3d73c1b410e9737f7fd207310dcb5f28b7c3ce45401b77c8f9e"
|
||||
"source_sha256": "bf0bbeb15249f3d73c1b410e9737f7fd207310dcb5f28b7c3ce45401b77c8f9e",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-editor-preview": {
|
||||
"source_sha256": "bcbf63563187f9dcdb6c7580f638e2fb2770b221240ee5699e54dc3c00be172c"
|
||||
"source_sha256": "bcbf63563187f9dcdb6c7580f638e2fb2770b221240ee5699e54dc3c00be172c",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-landscape": {
|
||||
"source_sha256": "40c01eb8300e4c5db52b2d75373e17cdaf7f68140c33c0a225613fc174660747"
|
||||
"source_sha256": "40c01eb8300e4c5db52b2d75373e17cdaf7f68140c33c0a225613fc174660747",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-logo": {
|
||||
"source_sha256": "e47781aa3328f68077589f95d813e9c2e6fff10ebd62a9d003773bb2c2f7a092"
|
||||
"source_sha256": "e47781aa3328f68077589f95d813e9c2e6fff10ebd62a9d003773bb2c2f7a092",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-portrait": {
|
||||
"source_sha256": "ddcbf989eab5971157d8cdc73494ed03660bb4c7a7679543248f45be260777e3"
|
||||
"source_sha256": "ddcbf989eab5971157d8cdc73494ed03660bb4c7a7679543248f45be260777e3",
|
||||
"crop_top": 0
|
||||
},
|
||||
"shovey-preview": {
|
||||
"source_sha256": "96db251f36835c76cd03cd0104a6e1b5096e4c442d410960457edcd8e2377a38"
|
||||
"source_sha256": "96db251f36835c76cd03cd0104a6e1b5096e4c442d410960457edcd8e2377a38",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-editor-landscape": {
|
||||
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5"
|
||||
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-editor-portrait": {
|
||||
"source_sha256": "07ff2ff0142c262cdcba3643bbc4d7d3d71643b7f9f4e678a910fee2bfd3eba1"
|
||||
"source_sha256": "07ff2ff0142c262cdcba3643bbc4d7d3d71643b7f9f4e678a910fee2bfd3eba1",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-editor-preview": {
|
||||
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5"
|
||||
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-landscape": {
|
||||
"source_sha256": "472773b7c106325e12777a81a29209496e22e0853782ca76955b6587824b1b30"
|
||||
"source_sha256": "472773b7c106325e12777a81a29209496e22e0853782ca76955b6587824b1b30",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-portrait": {
|
||||
"source_sha256": "e8962c969f554567d598eb0b54db5836f7f1ed7462619463040c6cc2887a5a47"
|
||||
"source_sha256": "e8962c969f554567d598eb0b54db5836f7f1ed7462619463040c6cc2887a5a47",
|
||||
"crop_top": 0
|
||||
},
|
||||
"wurm-preview": {
|
||||
"source_sha256": "472773b7c106325e12777a81a29209496e22e0853782ca76955b6587824b1b30"
|
||||
"source_sha256": "472773b7c106325e12777a81a29209496e22e0853782ca76955b6587824b1b30",
|
||||
"crop_top": 0
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1 @@
|
||||
Profile uses MingCute user_2 (Apache-2.0), recolored to the HUD text color. profile.webp is a lossless 128px rendering of profile.svg. Dew continues to come from the shared Apps assets.
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M16 14C18.7614 14 21 16.2386 21 19V20C21 21.1046 20.1046 22 19 22H5C3.89543 22 3 21.1046 3 20V19C3 16.2386 5.23858 14 8 14H16ZM12 2C14.7614 2 17 4.23858 17 7C17 9.76142 14.7614 12 12 12C9.23858 12 7 9.76142 7 7C7 4.23858 9.23858 2 12 2Z" fill="#ffeec1"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 367 B |
|
After Width: | Height: | Size: 926 B |
@@ -1,5 +1,56 @@
|
||||
# Arcade catalog changelog
|
||||
|
||||
## 0.7.126
|
||||
|
||||
- Shovey 0.6.171: Runs in the latest Inner Breeze and Arcade.
|
||||
- Apfelwurm 0.2.34: Replace campaign levels 1–50 with authored gardens that teach route planning, growth, portals, keys, switches and readable patrols in a paced progression.
|
||||
- Choano, Shovey and Apfelwurm run as one-format ZX 28 on Ziran 0.6.0 in the current Inner Breeze.
|
||||
|
||||
## 0.7.125
|
||||
|
||||
- Shovey 0.6.169: Runs in the latest Inner Breeze and Arcade.
|
||||
|
||||
## 0.7.124
|
||||
|
||||
- Apfelwurm 0.2.33: Runs in the latest Inner Breeze and Arcade.
|
||||
- Choano 0.1.9: Runs in the latest Inner Breeze and Arcade.
|
||||
- Choano 0.1.9: Supply genuine gameplay screenshots and a self-identifying portable bundle for Arcade’s console library.
|
||||
- Choano 0.1.9: Keep the Profile title bar clear of the camera and status bar on Android.
|
||||
- Choano 0.1.9: Let the Android app reach the network, so online sign-in, backups and Friends work.
|
||||
- Choano 0.1.9: Keep the account key out of Android system backups, which have no passphrase.
|
||||
- Choano 0.1.9: Use Entity's reviewed account authorization and the shared game navigation modules.
|
||||
- Choano 0.1.9: On Android, Continue as can use the account from another signed-in Waozi app, once you approve it there.
|
||||
- Choano 0.1.9: Continue as no longer crashes the other app when it was closed.
|
||||
|
||||
## 0.7.123
|
||||
|
||||
- Arcade and its games run in the latest Inner Breeze: Shovey 0.6.169, Apfelwurm 0.2.33 and Choano 0.1.9.
|
||||
|
||||
## 0.7.122
|
||||
|
||||
- Shovey 0.6.168: Play the first 30 Island levels with working downloads and a working Play button.
|
||||
- Shovey 0.6.168: Start Classic or Island levels of your own from the Editor.
|
||||
- Shovey 0.6.168: Follow Shovey in his map circle, with more water along the landscape coast and a secret on the beach.
|
||||
|
||||
## 0.7.121
|
||||
|
||||
- Keep Apfelwurm and its editor available when the game library updates.
|
||||
- Shovey 0.6.167: The level result, book, shop and item texts show again in every language.
|
||||
- Shovey 0.6.167: Your account's progress arrives quietly and quickly; the map no longer says it is loading.
|
||||
- Apfelwurm 0.2.32: Include Apfelwurm and its editor in Arcade's automatic game updates.
|
||||
|
||||
## 0.7.120
|
||||
|
||||
- Show the original painted covers for Shovey, Apfelwurm and Choano.
|
||||
- Browse covers on a scenic background in portrait and landscape; a side cover selects, the centre cover plays.
|
||||
- Download missing games on their cover with a progress bar while browsing.
|
||||
- Shovey opens its proper title with the daily chest, profile and swipeable covers.
|
||||
|
||||
## 0.7.119
|
||||
|
||||
- Browse the new console shelf, open games from their artwork and return Home with progress saved.
|
||||
- Keep editors and saved drafts inside their games.
|
||||
|
||||
## 0.7.118
|
||||
|
||||
- Apfelwurm 0.2.28: The editor title painting includes the Apfelwurm Editor logo in portrait and landscape.
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.7.118
|
||||
0.7.126
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"packages": ["shovey", "wurm", "choano"],
|
||||
"artwork": {"wurm": "wurm_art"}
|
||||
"packages": [
|
||||
"shovey",
|
||||
"wurm",
|
||||
"choano"
|
||||
],
|
||||
"artwork": {
|
||||
"wurm": "wurm_art"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
196
|
||||
198
|
||||
@@ -0,0 +1,13 @@
|
||||
# Arcade on the released graph — open work
|
||||
|
||||
- The raylib-free lane left uncommitted native work in this checkout: Ziran
|
||||
515449986e40, Kryon 028d42cb157a, and changes to the Android, packaging,
|
||||
app, main, sound and Windows sources, the game-updates workflow, the
|
||||
README, `mk/` and the game-update commit script and test. It builds on
|
||||
newer Ziran and Kryon than the graph the catalog now uses (Ziran 0.6.0
|
||||
d17c7aa1, Kryon 1b290f19, Apps 7854da88). Move those pins onto that graph,
|
||||
or onto a new Ziran release, before committing that work.
|
||||
- `scripts/android_catalog.py` reads only the ZX 26 and 27 bundle layout, so
|
||||
`tests/android_catalog_test.py` rejects the ZX 28 catalog. Read the seed
|
||||
catalog's assets through the Ziran runtime, as `build/zx-metadata` reads
|
||||
their index, before the next Android host release.
|
||||
@@ -7,6 +7,7 @@ import subprocess
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from node_config import node_source
|
||||
from hud_assets import HUD_PATHS, hud_asset_hashes
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ESSENTIALS = {'arcade.zx', 'arcade.json', 'apps.zx', 'entity.zx', 'kryon-font.ttf'}
|
||||
@@ -26,6 +27,15 @@ def profile_asset_hashes():
|
||||
return result
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def hud_hashes():
|
||||
flags = [] if (ROOT / 'ziran.local.toml').is_file() else ['--locked']
|
||||
package = Path(subprocess.check_output(
|
||||
[str(ROOT / 'scripts/ziran.sh'), 'pkg', 'path', 'apps', *flags],
|
||||
cwd=ROOT, text=True).strip())
|
||||
return hud_asset_hashes(package)
|
||||
|
||||
|
||||
def profile_assets():
|
||||
return set(profile_asset_hashes())
|
||||
|
||||
@@ -73,11 +83,12 @@ def catalog_assets(payload):
|
||||
|
||||
|
||||
def verify_assets(assets, essentials=True, edition='direct'):
|
||||
expected = ESSENTIALS if essentials else ESSENTIALS - {'entity.zx', 'kryon-font.ttf'}
|
||||
expected = (ESSENTIALS if essentials else ESSENTIALS - {'entity.zx', 'kryon-font.ttf'}) | set(HUD_PATHS)
|
||||
if essentials and edition == 'gplay':
|
||||
# AndroidX's generated ART startup profiles accompany Play Billing.
|
||||
expected = expected | {'dexopt/baseline.prof', 'dexopt/baseline.profm'}
|
||||
assert set(assets) == expected, 'Unexpected or missing Android asset: ' + str(set(assets) ^ expected)
|
||||
assert {name: hashlib.sha256(assets[name]).hexdigest() for name in HUD_PATHS} == hud_hashes(), 'HUD icons differ from the pinned shared assets'
|
||||
metadata = json.loads(assets['arcade.json'])
|
||||
assert metadata['id'] == 'inbe.arcade' and metadata.get('games') != 'packed'
|
||||
assert metadata.get('node') == node_source(ROOT), 'Node publisher binding differs from the reviewed host configuration'
|
||||
|
||||
@@ -57,8 +57,11 @@ def stage_arcade():
|
||||
for name in ('arcade.zx', 'arcade.json'):
|
||||
shutil.copyfile(ROOT / 'build' / name, assets / name)
|
||||
shutil.copyfile(collection / 'assets/apps/apps.zx', assets / 'apps.zx')
|
||||
from hud_assets import stage_hud_assets
|
||||
stage_hud_assets(package('apps'), assets)
|
||||
from android_catalog import verify_assets
|
||||
metadata = verify_assets({p.name: p.read_bytes() for p in assets.iterdir()}, essentials=False)
|
||||
metadata = verify_assets({p.relative_to(assets).as_posix(): p.read_bytes()
|
||||
for p in assets.rglob('*') if p.is_file()}, essentials=False)
|
||||
if metadata['version'] != release['version']:
|
||||
raise ValueError('The thin catalog version changed; rebuild the collection first')
|
||||
# Android before 10 has no font lookup; the Windows build ships the same font.
|
||||
@@ -108,7 +111,8 @@ def main():
|
||||
sdk = Path(os.environ.get('ANDROID_SDK_ROOT') or os.environ.get('ANDROID_HOME') or Path.home() / 'Android/Sdk')
|
||||
env = {key: value for key, value in os.environ.items() if key not in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY', 'DBUS_SESSION_BUS_ADDRESS')}
|
||||
env.update(ANDROID_HOME=str(sdk), ANDROID_SDK_ROOT=str(sdk),
|
||||
LIBOQS_DIR=str(package('liboqs')), MONOCYPHER_DIR=str(package('monocypher')))
|
||||
LIBOQS_DIR=str(package('liboqs')), MONOCYPHER_DIR=str(package('monocypher')),
|
||||
KRYON_ANDROID_WEBP_DIR=str(package('libwebp')))
|
||||
command = ['sh', str(ROOT / 'droid/gradlew'), '-p', str(ROOT / 'droid'), '--no-daemon', '--max-workers=2',
|
||||
'-Papp.product=' + args.product, '-Papp.abis=' + args.abis,
|
||||
'-Pkryon.dir=' + str(package('kryon')), '-Pziran.dir=' + str(package('ziran')),
|
||||
|
||||
@@ -47,27 +47,11 @@ def build(root, output):
|
||||
controller_context(root, context)
|
||||
package = Path(subprocess.check_output(
|
||||
['ziran', 'pkg', 'path', 'apps', '--locked'], cwd=context, text=True).strip())
|
||||
subprocess.run([sys.executable, str(package / 'scripts/generate-ui-locales.py'), '--check'],
|
||||
cwd=root, check=True)
|
||||
toolchain = Path(subprocess.check_output(
|
||||
['ziran', 'pkg', 'path', 'ziran', '--locked'], cwd=context, text=True).strip())
|
||||
compiler = toolchain / 'build/bin/ziran'
|
||||
if not compiler.is_file():
|
||||
compiler = root / 'build/toolchain/bin/ziran'
|
||||
subprocess.run(['make', '-s', '-C', str(toolchain),
|
||||
'BUILD_DIR=' + str(root / 'build/toolchain'), 'all'], check=True)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
kryon = Path(subprocess.check_output(
|
||||
['ziran', 'pkg', 'path', 'kryon', '--locked'], cwd=context, text=True).strip())
|
||||
# Keep Apps' supported source entry mode with this host's exact graph.
|
||||
subprocess.run([str(compiler), 'bundle',
|
||||
'--module-path', str(package / 'src'),
|
||||
'--module-path', 'kryon=' + str(kryon / 'src/ui'),
|
||||
'--module-path', 'kryon=' + str(kryon / 'src/backend'),
|
||||
'--module-path', str(toolchain / 'std'),
|
||||
'--root', str(package / 'ui'), '--entry', 'apps:Main',
|
||||
'--define', 'KRYON_HOSTED_UI', '-o', str(output.resolve() / 'apps.zx'),
|
||||
str(package / 'ui/apps.zi')], cwd=context, check=True)
|
||||
# Every consumer trusts the same package-owned build, including its
|
||||
# compiler and module identities. Recompiling with host-specific raw
|
||||
# search paths changes the bytes and breaks nested collection trust.
|
||||
subprocess.run([sys.executable, str(package / 'scripts/build-ui.py'),
|
||||
'--output', str(output.resolve())], cwd=context, check=True)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -17,6 +17,7 @@ from node_config import node_source
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MAX_PAYLOAD_BYTES = 64 * 1024 * 1024
|
||||
MAX_GAMES = 16
|
||||
MAX_LIBRARY_ART_BYTES = 2 * 1024 * 1024
|
||||
|
||||
|
||||
def payload_limit(size, label):
|
||||
@@ -68,16 +69,18 @@ def catalog_version(root):
|
||||
return version
|
||||
|
||||
|
||||
def library_art(root, name, key, source):
|
||||
def library_art(root, name, key, source, crop_top=0):
|
||||
"""Arcade's committed library thumbnail (scripts/library-art.py), as
|
||||
(bytes, suffix): a PNG, or a JPEG for opaque cover art. Never pack a copy
|
||||
(bytes, suffix): a bounded WebP image. Never pack a copy
|
||||
of outdated art."""
|
||||
library = Path(root) / "assets/arcade/library"
|
||||
sources = json.loads((library / "sources.json").read_text())
|
||||
copy = f"{name}-{key}"
|
||||
if sources.get(copy, {}).get("source_sha256") != hashlib.sha256(source).hexdigest():
|
||||
raise ValueError(f"{copy} art changed; run scripts/library-art.py")
|
||||
for suffix in (".png", ".jpg"):
|
||||
if sources.get(copy, {}).get("crop_top", 0) != crop_top:
|
||||
raise ValueError(f"{copy} crop changed; run scripts/library-art.py")
|
||||
for suffix in (".webp",):
|
||||
if (library / (copy + suffix)).is_file():
|
||||
return (library / (copy + suffix)).read_bytes(), suffix
|
||||
raise ValueError(f"{copy} has no library copy; run scripts/library-art.py")
|
||||
@@ -101,6 +104,10 @@ def stage(root, controller, expected_controller_digest, output):
|
||||
raise ValueError("Arcade needs 1 to 16 games")
|
||||
ledger = json.loads((root / "apps/versions.json").read_text())["node_apps"]
|
||||
children, copies, identities = [], [], set()
|
||||
shared_apps = Path(subprocess.check_output([str(root / 'scripts/ziran.sh'), 'pkg', 'path', 'apps', *lock_flags], cwd=root, text=True).strip())
|
||||
for icon in ('profile', 'dew'):
|
||||
contents, suffix = library_art(root, 'hud', icon, (shared_apps / 'assets/hud' / (icon + '.webp')).read_bytes())
|
||||
copies.append((contents, Path('arcade/library') / ('hud-' + icon + suffix)))
|
||||
collection_ids = {package["id"] for package in packages}
|
||||
for package in packages:
|
||||
package["children"] = []
|
||||
@@ -141,9 +148,6 @@ def stage(root, controller, expected_controller_digest, output):
|
||||
bytes=len(bundle_bytes),
|
||||
preview=f"assets/arcade/previews/{name}{preview_suffix}",
|
||||
icon=f"assets/arcade/previews/{name}{preview_suffix}")
|
||||
# A thin add-on links its required games' verified code as libraries.
|
||||
if app.get('shared_code'):
|
||||
child['shared_code'] = True
|
||||
if app.get('shared_records'):
|
||||
child['shared_records'] = app['shared_records']
|
||||
if app.get('requires'):
|
||||
@@ -161,9 +165,9 @@ def stage(root, controller, expected_controller_digest, output):
|
||||
if key not in cover:
|
||||
continue
|
||||
relative = Path(cover[key])
|
||||
if relative.is_absolute() or ".." in relative.parts or relative.suffix not in {".png", ".jpg"}:
|
||||
if relative.is_absolute() or ".." in relative.parts or relative.suffix not in {".png", ".jpg", ".avif"}:
|
||||
raise ValueError("Invalid cover asset path")
|
||||
contents, suffix = library_art(root, name, key, (app["art_source"] / relative).read_bytes())
|
||||
contents, suffix = library_art(root, name, key, (app["art_source"] / relative).read_bytes(), app.get("cover_crops", {}).get(key, 0))
|
||||
destination = Path("arcade/covers") / f"{name}-{key}{suffix}"
|
||||
packed_cover[key] = "assets/" + destination.as_posix()
|
||||
copies.append((contents, destination))
|
||||
@@ -242,6 +246,10 @@ def stage_downloads(catalog, source, output, games, art):
|
||||
destination = art / relative
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.move(output / relative, destination)
|
||||
for picture in (output / 'assets/arcade/library').glob('hud-*.webp'):
|
||||
destination = art / picture.relative_to(output)
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.move(picture, destination)
|
||||
for digest, data in payloads.items():
|
||||
(games / (digest + ".zx")).write_bytes(data)
|
||||
|
||||
@@ -250,6 +258,8 @@ def add_art(output, games, art_bundle):
|
||||
"""Publish the art bundle beside the games and name it in the catalog."""
|
||||
data = art_bundle.read_bytes()
|
||||
payload_limit(len(data), "Library art bundle")
|
||||
if len(data) > MAX_LIBRARY_ART_BYTES:
|
||||
raise ValueError("Library art bundle exceeds the 2 MiB art budget")
|
||||
digest = hashlib.sha256(data).hexdigest()
|
||||
(games / (digest + ".zx")).write_bytes(data)
|
||||
path = output / "assets/apps/catalog.json"
|
||||
@@ -323,7 +333,10 @@ def main():
|
||||
bundle(command, ROOT, "art.zi", "art:Main", art_assets / "assets", node_apps / "arcade-art.zx", env)
|
||||
art = add_art(catalog_assets, game_downloads, node_apps / "arcade-art.zx")
|
||||
archive_downloads(game_downloads, node_apps / "arcade.games.tar")
|
||||
bundle(command, ROOT, "collection.zi", "collection:Main", catalog_assets / "assets", node_apps / "arcade.zx", env)
|
||||
# The node catalog is hosted by the consumer's trusted Apps controller.
|
||||
# Compile its bootstrap without Kryon's standalone UI implementation.
|
||||
bundle([*command, "--define", "KRYON_HOSTED_UI"], ROOT, "collection.zi", "collection:Main",
|
||||
catalog_assets / "assets", node_apps / "arcade.zx", env)
|
||||
shutil.copyfile(node_apps / "arcade.zx", ROOT / "build/arcade.zx")
|
||||
# The desktop host supplies its controller from beside the collection.
|
||||
shutil.copyfile(args.apps_bundle, ROOT / "build/apps.zx")
|
||||
|
||||
@@ -68,6 +68,8 @@ def main():
|
||||
str(package('monocypher') / 'src/optional/monocypher-ed25519.c'), str(oqs / 'lib/liboqs.a'),
|
||||
'-Wl,--gc-sections', *libraries, '-lX11', '-l:libcurl.so.4', '-lz', '-lm', '-lpthread', '-o', str(temporary)], check=True)
|
||||
temporary.replace(output)
|
||||
from hud_assets import stage_hud_assets
|
||||
stage_hud_assets(package('apps'), output.parent)
|
||||
if args.standalone_shovey:
|
||||
from PIL import Image
|
||||
source = Path(subprocess.check_output([ZIRAN, 'pkg', 'path', 'shovey', *lock], cwd=ROOT, text=True).strip())
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build Entity once for the outer native host; never pack it into a game."""
|
||||
"""Build Entity once for the outer native host; never pack it into a game.
|
||||
|
||||
Entity owns its Profile bundle and the assets embedded in it: the locked
|
||||
toolchain's artifact helper asks Entity's project tool for
|
||||
entity:native-profile, as Shovey's player does.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import importlib.util
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ZIRAN = str(ROOT / 'scripts/ziran.sh')
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--locked', action='store_true')
|
||||
args = parser.parse_args()
|
||||
flags = ['--locked'] if args.locked or not (ROOT / 'ziran.local.toml').exists() else []
|
||||
def package(name):
|
||||
return Path(subprocess.check_output([ZIRAN, 'pkg', 'path', name, *flags], cwd=ROOT, text=True).strip())
|
||||
entity, kryon, toolchain, qrcode = map(package, ('entity', 'kryon', 'ziran', 'qrcode'))
|
||||
staged = ROOT / 'build/entity-profile-source'
|
||||
subprocess.run(['python3', str(entity / 'scripts/stage-assets.py'), '--group', 'profile',
|
||||
'--output', str(staged)], cwd=ROOT, check=True)
|
||||
subprocess.run([ZIRAN, 'bundle', '--root', str(entity),
|
||||
'--module-path', str(entity / 'src'),
|
||||
'--module-path', str(kryon / 'src/ui'),
|
||||
'--module-path', 'kryon=' + str(kryon / 'src/ui'),
|
||||
'--module-path', 'kryon=' + str(kryon / 'src/backend'),
|
||||
'--module-path', 'qrcode=' + str(qrcode / 'src'),
|
||||
'--module-path', str(toolchain / 'std'),
|
||||
'--define', 'KRYON_HOSTED_UI', '--asset-dir', 'assets=' + str(staged / 'assets'),
|
||||
'--entry', 'entity:Main', '-o', str(ROOT / 'build/entity.zx'), str(entity / 'src/entity.zi')],
|
||||
cwd=entity, check=True)
|
||||
ZIRAN = ROOT / 'scripts/ziran.sh'
|
||||
flags = [] if (ROOT / 'ziran.local.toml').exists() else ['--locked']
|
||||
toolchain = Path(subprocess.check_output([str(ZIRAN), 'pkg', 'path', 'ziran', *flags],
|
||||
cwd=ROOT, text=True).strip().splitlines()[-1])
|
||||
spec = importlib.util.spec_from_file_location('ziran_artifacts', toolchain / 'scripts/ziran_artifacts.py')
|
||||
artifacts = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(artifacts)
|
||||
profile = artifacts.request('entity:native-profile', 'linux-x86_64-gnu', project=ROOT, ziran=ZIRAN)
|
||||
shutil.copyfile(profile.output('entity.zx'), ROOT / 'build/entity.zx')
|
||||
|
||||
assets = ROOT / 'build/entity-assets'
|
||||
assets.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -1,168 +1,199 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the apps Arcade and its game packages declare, without copying source."""
|
||||
"""Import game-owned portable exports unchanged; never build games in Arcade."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from game_packages import declared_apps
|
||||
from game_module_paths import kryon_module_paths
|
||||
from game_resources import dependency_order, pack_opaque_pngs, share_resources
|
||||
from game_packages import declared_apps, portable_artifacts
|
||||
from game_resources import dependency_order
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MAX_PAYLOAD_BYTES = 64 * 1024 * 1024
|
||||
MAX_ASSET_BYTES = 16 * 1024 * 1024
|
||||
METADATA_LIMIT = 1024 * 1024
|
||||
# Built by `make build/zx-metadata` from scripts/zx_metadata.zi.
|
||||
METADATA_TOOL = Path(__file__).resolve().parents[1] / 'build/zx-metadata'
|
||||
|
||||
|
||||
def leave_out(rules_path, resources, release):
|
||||
"""Removes what the game's bundle.json says its bundle leaves out (top-level
|
||||
glob patterns of its assets), so the collection and the games a host opens
|
||||
fit its memory budget; the manifest keeps only what remains."""
|
||||
rules = json.loads(rules_path.read_text()) if rules_path.exists() else {}
|
||||
patterns = rules.get("leave_out", []) + (rules.get("release_leave_out", []) if release else [])
|
||||
for pattern in patterns:
|
||||
for path in resources.glob(pattern):
|
||||
if path.is_dir():
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
path.unlink()
|
||||
art_path = resources / "art.json"
|
||||
if patterns and art_path.exists():
|
||||
art = json.loads(art_path.read_text())
|
||||
art["files"] = [item for item in art["files"] if (resources / item["path"]).is_file()]
|
||||
art_path.write_text(json.dumps(art, indent=2) + "\n")
|
||||
def digest(path):
|
||||
result = hashlib.sha256()
|
||||
with path.open('rb') as source:
|
||||
for block in iter(lambda: source.read(1024 * 1024), b''):
|
||||
result.update(block)
|
||||
return result.hexdigest()
|
||||
|
||||
|
||||
def build(ziran, lock_flags):
|
||||
def package(name):
|
||||
return Path(subprocess.check_output(
|
||||
[ziran, "pkg", "path", name, *lock_flags], cwd=ROOT, text=True).strip())
|
||||
def bundle_metadata(path, name):
|
||||
"""Read a ZX 28 export's entry, asset index and bounded metadata.
|
||||
|
||||
kryon = package("kryon")
|
||||
game2d = package("game2d")
|
||||
toolchain = package("ziran")
|
||||
entity = package("entity")
|
||||
compiler = toolchain / "build/bin/ziran"
|
||||
if not compiler.is_file():
|
||||
compiler = ROOT / "build/toolchain/bin/ziran"
|
||||
# Resolve transitive packages from Arcade's lock, never their private graphs.
|
||||
daochi_client = package("daochi_client")
|
||||
crypto = package("crypto")
|
||||
# Shared KSS themes (Choano 0.1.5 and later import kss/Kss).
|
||||
kss = package("kss")
|
||||
entries = []
|
||||
apps = dependency_order(declared_apps(ROOT, ziran, lock_flags))
|
||||
by_id = {app['descriptor']['id']: app for app in apps}
|
||||
for app in apps:
|
||||
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"]
|
||||
if not name.isascii() or not name.replace("-", "").isalnum():
|
||||
raise ValueError("Invalid game name")
|
||||
staged = ROOT / "build/game-assets" / name
|
||||
# Start empty: files a game no longer has must not reach its bundle.
|
||||
shutil.rmtree(staged, ignore_errors=True)
|
||||
resources = staged / "assets" / name
|
||||
resources.mkdir(parents=True)
|
||||
shutil.copytree(source / descriptor["assets"], resources, dirs_exist_ok=True)
|
||||
shared = manifest.with_name("shared_assets.json")
|
||||
for copy in json.loads(shared.read_text())["copies"] if shared.exists() else []:
|
||||
asset_source, target = source / copy["from"], resources / copy["to"]
|
||||
build/zx-metadata opens and verifies the bundle with the Ziran runtime;
|
||||
none of its code runs.
|
||||
"""
|
||||
size = path.stat().st_size
|
||||
if not 0 < size <= MAX_PAYLOAD_BYTES:
|
||||
raise ValueError(f'{path}: exceeds the host payload limit')
|
||||
if not METADATA_TOOL.is_file():
|
||||
raise ValueError(f'{METADATA_TOOL} is missing; run make build/zx-metadata')
|
||||
result = subprocess.run([str(METADATA_TOOL), str(path), name], capture_output=True, text=True)
|
||||
if result.returncode:
|
||||
raise ValueError(f'{path}: truncated or invalid bundle')
|
||||
report = json.loads(result.stdout)
|
||||
assets = report['assets']
|
||||
if not 1 <= len(assets) <= 2048:
|
||||
raise ValueError(f'{path}: invalid game asset count')
|
||||
paths = set()
|
||||
for asset, length in assets:
|
||||
if length > MAX_ASSET_BYTES:
|
||||
raise ValueError(f'{path}: asset exceeds the host asset limit')
|
||||
if asset in paths or asset.startswith('/') or '..' in Path(asset).parts:
|
||||
raise ValueError(f'{path}: invalid or duplicate bundle asset {asset}')
|
||||
paths.add(asset)
|
||||
metadata = {}
|
||||
for key in ('catalog.json', 'requirements.json'):
|
||||
length = next((size for asset, size in assets if asset == f'assets/{name}/{key}'), None)
|
||||
if length is None:
|
||||
continue
|
||||
if length > METADATA_LIMIT or key not in report['metadata']:
|
||||
raise ValueError(f'{path}: oversized metadata')
|
||||
metadata[key] = json.loads(report['metadata'][key])
|
||||
return report['entry'], metadata, paths
|
||||
|
||||
|
||||
def validate_artifact(app, bundle, resources, imported):
|
||||
descriptor = app['descriptor']
|
||||
name, identifier = descriptor['name'], descriptor['id']
|
||||
entry, metadata, paths = bundle_metadata(bundle, name)
|
||||
if any(not path.startswith(f'assets/{name}/') or path == f'assets/{name}/' for path in paths):
|
||||
raise ValueError(f'{identifier}: exported assets escape the game namespace; re-export in its game repository')
|
||||
public = {key: value for key, value in descriptor.items()
|
||||
if key not in ('build_defines', 'prepare_assets')}
|
||||
if entry != descriptor['entry'] or metadata.get('catalog.json') != public:
|
||||
raise ValueError(f'{identifier}: embedded catalog/entry mismatch or missing; '
|
||||
're-export the portable bundle in its game repository with its app catalog')
|
||||
requires = app['requires']
|
||||
if (not isinstance(resources, dict) or set(resources) != {'dependencies', 'resources'}
|
||||
or resources['dependencies'] != requires):
|
||||
raise ValueError(f'{identifier}: exported dependency identities mismatch')
|
||||
links = resources['resources']
|
||||
if not isinstance(links, list) or len(links) > 16:
|
||||
raise ValueError(f'{identifier}: invalid resource links')
|
||||
targets = set()
|
||||
for link in links:
|
||||
if not isinstance(link, dict) or set(link) != {'dependency', 'path', 'source'}:
|
||||
raise ValueError(f'{identifier}: invalid resource link')
|
||||
dependency, target, original = link['dependency'], link['path'], link['source']
|
||||
if not isinstance(dependency, str) or dependency not in requires or dependency not in imported:
|
||||
raise ValueError(f'{identifier}: undeclared resource dependency')
|
||||
base = imported[dependency]
|
||||
for value in (target, original):
|
||||
if not isinstance(value, str) or value.startswith('/') or '..' in Path(value).parts:
|
||||
raise ValueError(f'{identifier}: unsafe resource link')
|
||||
if (not target.startswith(f'assets/{name}/') or target in targets
|
||||
or not original.startswith(f'assets/{base["name"]}/')
|
||||
or target.endswith('/') != original.endswith('/')):
|
||||
raise ValueError(f'{identifier}: invalid resource namespace')
|
||||
targets.add(target)
|
||||
if not any(p.startswith(original) if original.endswith('/') else p == original for p in base['paths']):
|
||||
raise ValueError(f'{identifier}: missing dependency resource')
|
||||
if any(p.startswith(target) if target.endswith('/') else p == target for p in paths):
|
||||
raise ValueError(f'{identifier}: resource link shadows bundled data')
|
||||
expected = resources | {'sha256': {dep: imported[dep]['sha256'] for dep in requires}}
|
||||
if requires and metadata.get('requirements.json') != expected:
|
||||
raise ValueError(f'{identifier}: embedded requirements/hash mismatch')
|
||||
if not requires and metadata.get('requirements.json') not in (None, expected):
|
||||
raise ValueError(f'{identifier}: unexpected embedded requirements')
|
||||
return dict(name=name, paths=paths, sha256=digest(bundle))
|
||||
|
||||
|
||||
def promote(replacements, scratch):
|
||||
"""Rollback all prior outputs if promotion fails; validation precedes writes."""
|
||||
completed = []
|
||||
try:
|
||||
for index, (candidate, target) in enumerate(replacements):
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
if asset_source.is_dir():
|
||||
shutil.copytree(asset_source, target)
|
||||
else:
|
||||
shutil.copyfile(asset_source, target)
|
||||
# Build flags are source metadata, not part of the signed node/2
|
||||
# descriptor schema accepted by existing hosts.
|
||||
(resources / 'catalog.json').write_text(json.dumps(
|
||||
{key: value for key, value in descriptor.items() if key not in ('build_defines', 'prepare_assets')}, indent=2) + '\n')
|
||||
defines = descriptor.get('build_defines', [])
|
||||
if 'SHOVEY_RELEASE' in defines:
|
||||
subprocess.run(["python3", str(source / 'scripts/release_assets.py'), str(resources)], check=True)
|
||||
leave_out(manifest.with_name("bundle.json"), resources, 'SHOVEY_RELEASE' in defines)
|
||||
locales = resources / "locales"
|
||||
locales.mkdir(exist_ok=True)
|
||||
translations = {}
|
||||
for locale in sorted((source / descriptor["locales"]).glob("*.txt")):
|
||||
blocks = []
|
||||
values = {}
|
||||
for block in locale.read_text().split("---\n"):
|
||||
lines = block.splitlines()
|
||||
heading = next((line for line in lines if line), "")
|
||||
if heading.startswith("[" + descriptor["locale_prefix"]):
|
||||
blocks.append(heading + "\n" + "\n".join(lines[lines.index(heading) + 1:]).rstrip() + "\n---\n")
|
||||
values[heading[1:-1]] = "\n".join(lines[lines.index(heading) + 1:]).rstrip()
|
||||
(locales / locale.name).write_text("".join(blocks))
|
||||
translations[locale.stem] = values
|
||||
# Text also lives in the game itself: released legacy hosts only know
|
||||
# their own locale file and cannot provide newly added game strings.
|
||||
generated = ROOT / 'build/game-generated' / name
|
||||
generated.mkdir(parents=True, exist_ok=True)
|
||||
if descriptor.get('prepare_assets'):
|
||||
prepare = Path(descriptor['prepare_assets'])
|
||||
if prepare.is_absolute() or '..' in prepare.parts or prepare.suffix not in ('.py', '.zi'):
|
||||
raise ValueError('Invalid game asset preparation script')
|
||||
if prepare.suffix == '.zi':
|
||||
# A Ziran preparation program builds with Arcade's compiler and
|
||||
# runs from the game's checkout, where its own files are.
|
||||
tool = ROOT / 'build/game-tools' / name
|
||||
subprocess.run([str(compiler), 'build', '--target=c', '--exe', '--root', str((source / prepare).parent),
|
||||
'--module-path', 'std=' + str(toolchain / 'std'), '--entry', prepare.stem + ':main',
|
||||
'-o', str(tool), str(source / prepare)], cwd=ROOT, check=True)
|
||||
subprocess.run([str(tool / prepare.stem), str(resources), str(generated)], cwd=source, check=True)
|
||||
else:
|
||||
subprocess.run(['python3', str(source / prepare), str(resources), str(generated)], check=True)
|
||||
pack_opaque_pngs(resources)
|
||||
shared = share_resources(app, apps, resources, ROOT / 'build/game-assets')
|
||||
metadata = ROOT / 'build/games' / (name + '-resources.json')
|
||||
metadata.parent.mkdir(parents=True, exist_ok=True)
|
||||
metadata.write_text(json.dumps(shared, indent=2) + '\n')
|
||||
if shared['dependencies']:
|
||||
# A base-art update must also invalidate cached editor images.
|
||||
originals = {item['descriptor']['id']: item['descriptor']['name'] for item in apps}
|
||||
required = shared | {'sha256': {identifier: hashlib.sha256(
|
||||
(ROOT / 'build/games' / (originals[identifier] + '.zx')).read_bytes()).hexdigest()
|
||||
for identifier in shared['dependencies']}}
|
||||
(resources / 'requirements.json').write_text(json.dumps(required, sort_keys=True) + '\n')
|
||||
code = 'GameLocaleText :: (language: string, key: string) -> string {\n'
|
||||
for language, values in sorted(translations.items(), key=lambda item: item[0] == 'en'):
|
||||
if language != 'en':
|
||||
code += ' if language == ' + json.dumps(language) + ' {\n'
|
||||
for key, value in values.items():
|
||||
code += (' ' if language != 'en' else ' ') + 'if key == ' + json.dumps(key) + ' { return ' + json.dumps(value, ensure_ascii=False) + ' }\n'
|
||||
if language != 'en':
|
||||
code += ' }\n'
|
||||
code += ' return ""\n}\n'
|
||||
(generated / 'translations.zi').write_text(code)
|
||||
bundle = ROOT / "build/games" / (name + ".zx")
|
||||
bundle.parent.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run([
|
||||
ziran, "bundle", "--root", str((source / descriptor["source"]).parent),
|
||||
# Game packages without a src folder (Shovey) keep sources beside their catalogs.
|
||||
*(["--module-path", str(source / "src")] if (source / "src").is_dir() else []),
|
||||
"--module-path", str(generated),
|
||||
*kryon_module_paths(source, descriptor, kryon),
|
||||
"--module-path", "game2d=" + str(game2d / "src"),
|
||||
"--module-path", "std=" + str(toolchain / "std"),
|
||||
"--module-path", str(toolchain / "std"),
|
||||
"--module-path", "apps=" + str(package("apps") / "src"),
|
||||
"--module-path", "mingcute=" + str(package("mingcute") / "src"),
|
||||
"--module-path", "entity=" + str(entity / "src"),
|
||||
"--module-path", "daochi_client=" + str(daochi_client),
|
||||
"--module-path", "crypto=" + str(crypto / "src"),
|
||||
"--module-path", "kss=" + str(kss / "src"),
|
||||
*[flag for name in defines for flag in ('--define', name)],
|
||||
*[flag for entry in app['library_entries'] for flag in ('--retain', entry)],
|
||||
*[flag for dependency_id in app['requires'] if app['shared_code']
|
||||
for flag in ('--library', str(ROOT / 'build/games' /
|
||||
(by_id[dependency_id]['descriptor']['name'] + '.zx')))],
|
||||
"--define", "KRYON_HOSTED_UI", "--asset-dir", "assets=" + str(staged / "assets"),
|
||||
"--entry", descriptor["entry"], "-o", str(bundle),
|
||||
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": app["enabled"], "package": app["package"]})
|
||||
backup = scratch / f'previous-{index}'
|
||||
existed = target.exists()
|
||||
if existed:
|
||||
os.replace(target, backup)
|
||||
completed.append((target, backup, existed))
|
||||
os.replace(candidate, target)
|
||||
except BaseException:
|
||||
for target, backup, existed in reversed(completed):
|
||||
if target.is_dir():
|
||||
shutil.rmtree(target)
|
||||
elif target.exists():
|
||||
target.unlink()
|
||||
if existed:
|
||||
os.replace(backup, target)
|
||||
raise
|
||||
|
||||
|
||||
def build(ziran, lock_flags, artifact_manifest=None):
|
||||
apps = declared_apps(ROOT, ziran, lock_flags)
|
||||
if not 1 <= len(apps) <= 16 or len({a['descriptor']['id'] for a in apps}) != len(apps):
|
||||
raise ValueError('Arcade needs 1 to 16 distinct games')
|
||||
if len({a['descriptor']['name'] for a in apps}) != len(apps):
|
||||
raise ValueError('Duplicate game name')
|
||||
apps = dependency_order(apps)
|
||||
exports = None
|
||||
if artifact_manifest is not None:
|
||||
artifact_manifest = Path(artifact_manifest).resolve()
|
||||
exports = json.loads(artifact_manifest.read_text())
|
||||
if not isinstance(exports, dict) or set(exports) != {'apps'} or not isinstance(exports['apps'], dict):
|
||||
raise ValueError('Artifact manifest must contain an apps mapping')
|
||||
expected_ids = {a['descriptor']['id'] for a in apps if a['enabled']}
|
||||
if set(exports['apps']) != expected_ids:
|
||||
raise ValueError('Artifact manifest must name exactly the enabled public app IDs')
|
||||
scratch_root = ROOT / 'work/console-redesign'
|
||||
scratch_root.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(prefix='game-import-', dir=scratch_root) as directory:
|
||||
scratch = Path(directory)
|
||||
games = scratch / 'games'
|
||||
games.mkdir()
|
||||
entries, imported = [], {}
|
||||
for app in apps:
|
||||
descriptor = app['descriptor']
|
||||
name = descriptor['name']
|
||||
if not re.fullmatch(r'[a-z0-9][a-z0-9-]*', name):
|
||||
raise ValueError('Invalid game name')
|
||||
if descriptor['kind'] != 'game' or 'arcade' not in descriptor['harnesses']:
|
||||
raise ValueError('Only games registered for Arcade belong in its catalog')
|
||||
entries.append(descriptor | {'enabled': app['enabled'], 'package': app['package']})
|
||||
if not app['enabled']:
|
||||
continue
|
||||
locations, instruction = portable_artifacts(app, artifact_manifest, exports)
|
||||
for kind, source in locations.items():
|
||||
if not source.is_file():
|
||||
raise ValueError(f'{descriptor["id"]}: missing {kind} export: {source}. {instruction}')
|
||||
limit = METADATA_LIMIT if kind == 'resources' else MAX_PAYLOAD_BYTES
|
||||
if not 0 < source.stat().st_size <= limit:
|
||||
raise ValueError(f'{source}: exceeds the host payload limit')
|
||||
suffix = {'bundle': '.zx', 'preview': '-preview.png', 'resources': '-resources.json'}[kind]
|
||||
target = games / (name + suffix)
|
||||
shutil.copyfile(source, target)
|
||||
if not 0 < target.stat().st_size <= limit:
|
||||
raise ValueError(f'{source}: export changed or exceeds the host payload limit')
|
||||
resource_file = games / (name + '-resources.json')
|
||||
if not resource_file.exists():
|
||||
if app['requires']:
|
||||
raise ValueError(f'{name}: dependencies require exported resources metadata')
|
||||
resource_file.write_text(json.dumps(dict(dependencies=[], resources=[]), indent=2) + '\n')
|
||||
resources = json.loads(resource_file.read_text())
|
||||
imported[descriptor['id']] = validate_artifact(app, games / (name + '.zx'), resources, imported)
|
||||
text, catalog = catalog_outputs(entries)
|
||||
(scratch / 'catalog.zi').write_text(text)
|
||||
(scratch / 'catalog.json').write_text(catalog)
|
||||
promote([(games, ROOT / 'build/games'), (scratch / 'catalog.zi', ROOT / 'src/catalog.zi'),
|
||||
(scratch / 'catalog.json', ROOT / 'build/catalog.json')], scratch)
|
||||
print(f'Imported {len(imported)} verified game-owned artifacts unchanged')
|
||||
|
||||
|
||||
def catalog_outputs(entries):
|
||||
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 the apps.json of Arcade and its game packages.\n"
|
||||
@@ -176,13 +207,16 @@ def build(ziran, lock_flags):
|
||||
fields += ", .enabled = " + str(entry["enabled"]).lower()
|
||||
text += f" if index == {index} {{ return Game.{{{fields}}} }}\n"
|
||||
text += " return Game.{}\n}\n"
|
||||
(ROOT / "src/catalog.zi").write_text(text)
|
||||
(ROOT / "build/catalog.json").write_text(json.dumps({"games": entries}, indent=2) + "\n")
|
||||
return text, json.dumps({"games": entries}, indent=2) + "\n"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--ziran", default="ziran")
|
||||
parser.add_argument("--locked", action="store_true")
|
||||
parser.add_argument('--ziran', default='ziran', help='package path resolver only')
|
||||
parser.add_argument('--locked', action='store_true')
|
||||
parser.add_argument('--artifact-manifest', type=Path, help='explicit already-exported app artifact paths')
|
||||
args = parser.parse_args()
|
||||
build(args.ziran, ["--locked"] if args.locked else [])
|
||||
try:
|
||||
build(args.ziran, ['--locked'] if args.locked else [], args.artifact_manifest)
|
||||
except (ValueError, OSError) as error:
|
||||
parser.exit(1, f'Game artifact import failed: {error}\n')
|
||||
@@ -34,7 +34,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
ZIRAN = str(ROOT / 'scripts/ziran.sh')
|
||||
ART_LIMIT = 64 * 1024 * 1024
|
||||
# The committed library copies are at most this large (scripts/library-art.py).
|
||||
PICTURE_LONGEST = 640
|
||||
PICTURE_LONGEST = 1600
|
||||
COVER_QUALITY = 80
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ def stage_web_library_art(bundle, output):
|
||||
covers = {path for child in catalog['children'] for key, path in child.get('cover', {}).items()
|
||||
if key in ('portrait', 'landscape', 'logo')}
|
||||
copies = {}
|
||||
for path in sorted(previews | covers):
|
||||
hud = {path for path in pictures if path.startswith('assets/arcade/library/hud-') and path.endswith('.webp')}
|
||||
for path in sorted(previews | covers | hud):
|
||||
if path not in pictures:
|
||||
raise ValueError(f'The art bundle lacks {path}')
|
||||
copies[path] = web_picture(pictures[path], path in previews)
|
||||
@@ -183,7 +184,8 @@ def version_assets(output, receipt):
|
||||
if '__ARCADE_ASSET_REVISION__' not in html:
|
||||
return
|
||||
digest = hashlib.sha256()
|
||||
for name in ('runtime.js', 'runtime.wasm', 'runtime.data', 'arcade.json', 'apps.zx', 'library.json'):
|
||||
for name in ('runtime.js', 'runtime.wasm', 'runtime.data', 'arcade.json', 'apps.zx', 'library.json',
|
||||
'assets/hud/profile.webp', 'assets/hud/dew.webp'):
|
||||
path = output / name
|
||||
if path.is_file():
|
||||
digest.update(name.encode() + b'\0')
|
||||
@@ -253,6 +255,8 @@ def main():
|
||||
print('No matching Apps controller beside the collection; it must pack its own')
|
||||
if not args.shovey and stage_web_library_art(bundle, output) is None:
|
||||
print('The collection packs its own library art')
|
||||
from hud_assets import stage_hud_assets
|
||||
stage_hud_assets(package('apps'), output)
|
||||
version_assets(output, receipt)
|
||||
print(f'{"Shovey" if args.shovey else "Arcade"} {args.version} for the browser in {output}')
|
||||
|
||||
|
||||
@@ -18,6 +18,13 @@ def translation_keys(code, prefix):
|
||||
return set(re.findall(r'"(' + re.escape(prefix) + r'[a-z0-9_]+)"', code))
|
||||
|
||||
|
||||
def compatible(game, standard):
|
||||
for field in ('contract_version', 'module_api'):
|
||||
assert game[field] == standard[field], f'{game["name"]}: incompatible {field}'
|
||||
assert type(game['host_api']) is int and standard['oldest_host_api'] <= game['host_api'] <= standard['host_api'], \
|
||||
f'{game["name"]}: incompatible host_api'
|
||||
|
||||
|
||||
def check(ziran, lock_flags):
|
||||
standard = json.loads((ROOT / 'standards/game-v1.json').read_text())
|
||||
ledger = json.loads((ROOT / 'apps/versions.json').read_text())
|
||||
@@ -26,10 +33,12 @@ def check(ziran, lock_flags):
|
||||
player = re.search(r'^GAME_HOST_API :: (\d+)$', (ROOT / 'src/game_contract.zi').read_text(), re.M)
|
||||
assert player and int(player[1]) == standard['host_api'] == ledger['host_api'], \
|
||||
'src/game_contract.zi GAME_HOST_API, standards/game-v1.json and apps/versions.json must name the same host interface'
|
||||
oldest = re.search(r'^GAME_OLDEST_HOST_API :: (\d+)$', (ROOT / 'src/game_contract.zi').read_text(), re.M)
|
||||
assert oldest and int(oldest[1]) == standard['oldest_host_api'] == ledger['oldest_host_api'], \
|
||||
'The player, standard and ledger must agree on the oldest supported host interface'
|
||||
for app in declared_apps(ROOT, ziran, lock_flags):
|
||||
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}'
|
||||
compatible(game, standard)
|
||||
component = ledger['node_apps'][game['name']]
|
||||
assert game['id'] == component['id'] and game['host_api'] == component['host_api']
|
||||
assert game['kind'] == 'game' and 'arcade' in game['harnesses']
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Download Wurm's portable exports from its exact pinned release; compile nothing."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
|
||||
EXPORT_FILES = {name + suffix for name in ('wurm', 'wurm-editor')
|
||||
for suffix in ('.zx', '-resources.json', '-catalog.json', '-preview.png')}
|
||||
MAX_FILE_BYTES = 64 * 1024 * 1024
|
||||
|
||||
|
||||
def unpack(archive, source):
|
||||
build = source / 'build'
|
||||
build.mkdir(parents=True, exist_ok=True)
|
||||
with tarfile.open(archive, 'r:gz') as bundle:
|
||||
members = bundle.getmembers()
|
||||
if len(members) != len(EXPORT_FILES) or {m.name for m in members} != EXPORT_FILES:
|
||||
raise ValueError('Wurm release must contain exactly its eight portable exports')
|
||||
if any(not m.isfile() or not 0 < m.size <= MAX_FILE_BYTES for m in members):
|
||||
raise ValueError('Wurm release contains an invalid portable export')
|
||||
# Validate the complete member list before any output is replaced.
|
||||
with tempfile.TemporaryDirectory(prefix='portable-export-', dir=build) as directory:
|
||||
stage = Path(directory)
|
||||
for member in members:
|
||||
with bundle.extractfile(member) as incoming, (stage / member.name).open('wb') as output:
|
||||
shutil.copyfileobj(incoming, output)
|
||||
exports = build / 'games'
|
||||
exports.mkdir(exist_ok=True)
|
||||
for name in EXPORT_FILES:
|
||||
(stage / name).replace(exports / name)
|
||||
|
||||
|
||||
def fetch(source, commit):
|
||||
version = json.loads((source / 'version.json').read_text())['version']
|
||||
if not re.fullmatch(r'\d+\.\d+\.\d+', version) or not re.fullmatch(r'[0-9a-f]{40}', commit):
|
||||
raise ValueError('Invalid Wurm release identity')
|
||||
tag = 'v' + version
|
||||
released = subprocess.check_output(['gh', 'api', f'repos/waozixyz/wurm/commits/{tag}',
|
||||
'--jq', '.sha'], text=True).strip()
|
||||
if released != commit:
|
||||
raise ValueError('Wurm release does not match Arcade\'s pinned commit')
|
||||
downloads = source / 'build/downloads'
|
||||
downloads.mkdir(parents=True, exist_ok=True)
|
||||
name = f'wurm-portable-{tag}.tar.gz'
|
||||
subprocess.run(['gh', 'release', 'download', tag, '--repo', 'waozixyz/wurm',
|
||||
'--pattern', name, '--dir', str(downloads), '--clobber'], check=True)
|
||||
unpack(downloads / name, source)
|
||||
print(f'Imported Wurm {version} portable release at {commit}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--source', type=Path, required=True)
|
||||
parser.add_argument('--commit', required=True)
|
||||
args = parser.parse_args()
|
||||
fetch(args.source.resolve(), args.commit)
|
||||
@@ -150,8 +150,10 @@ def art():
|
||||
library = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(library)
|
||||
recorded = json.loads((library.LIBRARY / 'sources.json').read_text())
|
||||
current = {f'{name}-{key}': hashlib.sha256(data).hexdigest() for name, key, data in library.art()}
|
||||
if {copy: item['source_sha256'] for copy, item in recorded.items()} != current:
|
||||
# A changed source or cover crop rewrites the library copies.
|
||||
current = {f'{name}-{key}': (hashlib.sha256(data).hexdigest(), crop_top)
|
||||
for name, key, data, crop_top in library.art()}
|
||||
if {copy: (item['source_sha256'], item.get('crop_top', 0)) for copy, item in recorded.items()} != current:
|
||||
library.main()
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
"""Select Kryon namespaces from a game's own source imports."""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
_TOKENS = re.compile(r'//[^\n]*|/\*.*?\*/|"(?:\\.|[^"\\])*"|#import\b|\S', re.DOTALL)
|
||||
|
||||
|
||||
def _imports(text):
|
||||
previous = None
|
||||
for match in _TOKENS.finditer(text):
|
||||
token = match.group()
|
||||
if token.startswith(('//', '/*')):
|
||||
continue
|
||||
if previous == '#import' and token.startswith('"'):
|
||||
yield token[1:-1]
|
||||
previous = token
|
||||
|
||||
|
||||
def _module_names(root):
|
||||
return ({path.stem for path in root.glob('*.zi')} |
|
||||
{path.parent.name for path in root.glob('*/module.zi')})
|
||||
|
||||
|
||||
def kryon_module_paths(source: Path, descriptor: dict, kryon: Path) -> list[str]:
|
||||
"""Keep qualified UI imports scoped unless game code needs short imports.
|
||||
|
||||
Registering the UI directory both plain and named makes Ziran load Kryon
|
||||
into the application's flat namespace. Only direct imports of UI modules
|
||||
the application does not own justify that legacy mode.
|
||||
"""
|
||||
ui = kryon / 'src/ui'
|
||||
roots = {source / 'src' if (source / 'src').is_dir() else source,
|
||||
(source / descriptor['source']).parent}
|
||||
owned = set().union(*(_module_names(root) for root in roots))
|
||||
shared = _module_names(ui) - owned
|
||||
needs_plain = any(name in shared for root in roots for path in root.rglob('*.zi')
|
||||
for name in _imports(path.read_text()))
|
||||
paths = [str(ui)] if needs_plain else []
|
||||
paths += ['kryon=' + str(ui), 'kryon=' + str(kryon / 'src/backend')]
|
||||
return [flag for path in paths for flag in ('--module-path', path)]
|
||||
@@ -9,7 +9,7 @@ import re
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
APP_KEYS = {'manifest', 'cover', 'enabled', 'requires', 'shared_code', 'library_entries', 'shared_records'}
|
||||
APP_KEYS = {'manifest', 'cover', 'enabled', 'requires', 'shared_records', 'external', 'standalone_bundle'}
|
||||
COVER_KEYS = {'portrait', 'landscape', 'logo', 'caption', 'action'}
|
||||
|
||||
|
||||
@@ -48,31 +48,35 @@ def declared_packages(root, ziran=None, lock_flags=()):
|
||||
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')
|
||||
if app.get('external', False):
|
||||
# Independently published editions stay in their own game.
|
||||
if app['external'] is not True or not str(relative_path(app.get('standalone_bundle', ''))).endswith('.zx'):
|
||||
raise ValueError(f'{name}: invalid external game edition')
|
||||
continue
|
||||
manifest = source / relative_path(app['manifest'])
|
||||
requires = app.get('requires', [])
|
||||
if not isinstance(requires, list) or len(requires) > 8 or \
|
||||
any(not isinstance(item, str) or not item for item in requires) or \
|
||||
len(set(requires)) != len(requires):
|
||||
raise ValueError(f'{name}: invalid app dependencies')
|
||||
shared_code = app.get('shared_code', False)
|
||||
if type(shared_code) is not bool or (shared_code and not requires):
|
||||
raise ValueError(f'{name}: shared code needs declared dependencies')
|
||||
shared_records = app.get('shared_records', [])
|
||||
if not isinstance(shared_records, list) or len(shared_records) > 8 or any(
|
||||
not isinstance(item, str) or not re.fullmatch(r'[A-Za-z0-9_.-]{1,63}', item) or
|
||||
item in ('.', '..') for item in shared_records) or len(set(shared_records)) != len(shared_records):
|
||||
raise ValueError(f'{name}: invalid shared records')
|
||||
library_entries = app.get('library_entries', [])
|
||||
if not isinstance(library_entries, list) or len(library_entries) > 64 or \
|
||||
any(not isinstance(item, str) or len(item) > 253 or
|
||||
not re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]*:[A-Za-z_][A-Za-z0-9_]*', item)
|
||||
for item in library_entries) or len(set(library_entries)) != len(library_entries):
|
||||
raise ValueError(f'{name}: invalid portable library entries')
|
||||
apps.append(dict(package=name, source=source, art_source=art_source, manifest=manifest,
|
||||
descriptor=json.loads(manifest.read_text()),
|
||||
cover=app.get('cover'), requires=requires, shared_code=shared_code,
|
||||
shared_records=shared_records,
|
||||
library_entries=library_entries, enabled=app.get('enabled', True)))
|
||||
app_art_source = art_source
|
||||
descriptor = json.loads(manifest.read_text())
|
||||
cover_crops = {}
|
||||
cover = app.get('cover')
|
||||
internal = descriptor['name'].endswith('-editor')
|
||||
if cover:
|
||||
cover = dict(cover)
|
||||
if internal:
|
||||
cover['action'] = 'internal'
|
||||
apps.append(dict(package=name, source=source, art_source=app_art_source, manifest=manifest,
|
||||
descriptor=descriptor,
|
||||
cover=cover, cover_crops=cover_crops, internal=internal, requires=requires,
|
||||
shared_records=shared_records, enabled=app.get('enabled', True)))
|
||||
packages.append(dict(name=name, source=source, id=declaration['id'],
|
||||
title=declaration['title'], apps=apps))
|
||||
return packages
|
||||
@@ -80,3 +84,40 @@ def declared_packages(root, ziran=None, lock_flags=()):
|
||||
|
||||
def declared_apps(root, ziran=None, lock_flags=()):
|
||||
return [app for package in declared_packages(root, ziran, lock_flags) for app in package['apps']]
|
||||
|
||||
|
||||
def portable_artifacts(app, manifest=None, exports=None):
|
||||
"""Locate game-owned exports. Resolving paths never builds or runs a game.
|
||||
|
||||
An explicit manifest is useful with clean locked/downloaded packages whose
|
||||
source cache deliberately has no build outputs. Paths are relative to it.
|
||||
"""
|
||||
descriptor, source = app['descriptor'], app['source']
|
||||
name, package = descriptor['name'], app['package']
|
||||
instruction = ('Supply --artifact-manifest with exports from the game owner; '
|
||||
'Arcade never compiles games.')
|
||||
if exports is not None:
|
||||
record = exports['apps'][descriptor['id']]
|
||||
if (not isinstance(record, dict) or not {'bundle', 'preview'} <= set(record)
|
||||
or not set(record) <= {'bundle', 'preview', 'resources'}):
|
||||
raise ValueError(f'{name}: artifact entry needs bundle, preview and optional resources paths')
|
||||
locations = {}
|
||||
for kind, value in record.items():
|
||||
if not isinstance(value, str) or not value:
|
||||
raise ValueError(f'{name}: invalid artifact path')
|
||||
path = Path(value)
|
||||
locations[kind] = path if path.is_absolute() else manifest.parent / path
|
||||
return locations, instruction
|
||||
folders = {'shovey': 'build/player/games', 'wurm': 'build/games', 'choano': 'build'}
|
||||
commands = {'shovey': 'build-queue -- python3 scripts/player.py collection --web',
|
||||
'wurm': 'build-queue -- python3 tools/build_portable.py',
|
||||
'choano': 'build-queue -- make portable'}
|
||||
if package not in folders:
|
||||
raise ValueError(f'{name}: no game-owned artifact location. {instruction}')
|
||||
folder = source / folders[package]
|
||||
locations = dict(bundle=folder / (name + '.zx'),
|
||||
preview=folder / (name + '-preview.png') if package == 'wurm'
|
||||
else source / relative_path(descriptor['preview']))
|
||||
if package in ('shovey', 'wurm'):
|
||||
locations['resources'] = folder / (name + '-resources.json')
|
||||
return locations, f'In {source}, run {commands[package]}. {instruction}'
|
||||
@@ -0,0 +1,23 @@
|
||||
"""Host HUD icons, independent of downloaded catalogs."""
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
HUD_PATHS = ('assets/hud/profile.webp', 'assets/hud/dew.webp')
|
||||
|
||||
|
||||
def hud_source(apps, name):
|
||||
if name == "assets/hud/profile.webp":
|
||||
return Path(__file__).resolve().parents[1] / name
|
||||
return Path(apps) / name
|
||||
|
||||
|
||||
def hud_asset_hashes(apps):
|
||||
return {name: hashlib.sha256(hud_source(apps, name).read_bytes()).hexdigest() for name in HUD_PATHS}
|
||||
|
||||
|
||||
def stage_hud_assets(apps, output):
|
||||
for name in HUD_PATHS:
|
||||
target = Path(output) / name
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(hud_source(apps, name), target)
|
||||
@@ -2,9 +2,8 @@
|
||||
"""Stage bounded thumbnails for every game's library covers and previews.
|
||||
|
||||
Library covers retain full colour and transparency at thumbnail resolution:
|
||||
opaque cover art is a JPEG, a sixth of its PNG size, while logos keep their
|
||||
transparency and previews their pixel art as PNG. Games keep their own
|
||||
original title artwork. Arcade downloads this small art
|
||||
opaque art uses quality-80 WebP, while transparent art uses lossless WebP.
|
||||
Games keep their own original title artwork. Arcade downloads this small art
|
||||
bundle separately from its launcher and caches it by its content digest.
|
||||
|
||||
The copies and sources.json, which records the SHA-256 of the art each copy
|
||||
@@ -15,19 +14,25 @@ game's art changes until this script makes fresh copies.
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageOps
|
||||
from game_packages import declared_packages
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LIBRARY = ROOT / 'assets/arcade/library'
|
||||
PREVIEW_LONGEST = 480
|
||||
COVER_LONGEST = 640
|
||||
LOGO_LONGEST = 512
|
||||
# Previews stay at 256 px. Separately fetched painted covers are sized for
|
||||
# full-screen landscape and focused portrait art, with a total 2 MiB budget.
|
||||
PREVIEW_LONGEST = 256
|
||||
LANDSCAPE_LONGEST = 1600
|
||||
PORTRAIT_LONGEST = 1080
|
||||
COVER_LONGEST = 256
|
||||
ART_BUDGET = 2 * 1024 * 1024
|
||||
LOGO_LONGEST = 256
|
||||
|
||||
|
||||
COVER_QUALITY = 85
|
||||
SUFFIXES = ('.png', '.jpg')
|
||||
COVER_QUALITY = 80
|
||||
SUFFIXES = ('.webp', '.png', '.jpg')
|
||||
|
||||
|
||||
def copy_path(name):
|
||||
@@ -38,68 +43,71 @@ def copy_path(name):
|
||||
raise FileNotFoundError(f'{name} has no library copy; run scripts/library-art.py')
|
||||
|
||||
|
||||
def small_copy(data, key):
|
||||
def small_copy(data, key, crop_top=0):
|
||||
"""(bytes, suffix) of the library's copy of one picture."""
|
||||
image = Image.open(io.BytesIO(data))
|
||||
image.load()
|
||||
# The shared library cards are 2:3. Keep the top of taller paintings,
|
||||
# where their title lives, rather than letting the card centre-crop it.
|
||||
# Originals remain untouched; this framing belongs to the thumbnail.
|
||||
if key == 'portrait' and image.height > image.width * 1.5:
|
||||
image = image.crop((0, 0, image.width, round(image.width * 1.5)))
|
||||
longest = PREVIEW_LONGEST if key == 'preview' else LOGO_LONGEST if key == 'logo' else COVER_LONGEST
|
||||
if not 0 <= crop_top < image.height:
|
||||
raise ValueError('Gameplay crop exceeds screenshot')
|
||||
if crop_top:
|
||||
image = image.crop((0, crop_top, image.width, image.height))
|
||||
# Frame the original painted artwork for the shelf, never gameplay captures.
|
||||
# Portrait paintings keep their title near the top; landscape art is centred.
|
||||
if key in ('portrait', 'landscape'):
|
||||
ratio = 2 / 3 if key == 'portrait' else 16 / 9
|
||||
width = min(image.width, round(image.height * ratio))
|
||||
height = min(image.height, round(image.width / ratio))
|
||||
image = ImageOps.fit(image, (width, height), Image.Resampling.LANCZOS,
|
||||
centering=(0.5, 0.0 if key == 'portrait' else 0.5))
|
||||
longest = {'preview': PREVIEW_LONGEST, 'logo': LOGO_LONGEST, 'landscape': LANDSCAPE_LONGEST, 'portrait': PORTRAIT_LONGEST}.get(key, COVER_LONGEST)
|
||||
scale = min(1.0, longest / max(image.size))
|
||||
alpha = 'A' in image.getbands() or 'transparency' in image.info
|
||||
photo = key in ('portrait', 'landscape') and not alpha
|
||||
if scale == 1.0 and key != 'preview' and not photo:
|
||||
return data, '.png'
|
||||
alpha = ('A' in image.getbands() or 'transparency' in image.info) and key not in ('landscape', 'portrait')
|
||||
image = image.convert('RGBA' if alpha else 'RGB')
|
||||
if scale < 1.0:
|
||||
size = (max(1, round(image.width * scale)), max(1, round(image.height * scale)))
|
||||
image = image.resize(size, Image.Resampling.LANCZOS)
|
||||
if key == 'preview':
|
||||
if alpha:
|
||||
image = image.quantize(256, method=Image.Quantize.FASTOCTREE, dither=Image.Dither.FLOYDSTEINBERG)
|
||||
else:
|
||||
image = image.quantize(256, dither=Image.Dither.FLOYDSTEINBERG)
|
||||
output = io.BytesIO()
|
||||
if photo:
|
||||
image.save(output, 'JPEG', quality=COVER_QUALITY, optimize=True, progressive=True)
|
||||
return output.getvalue(), '.jpg'
|
||||
image.save(output, 'PNG', optimize=True)
|
||||
return output.getvalue(), '.png'
|
||||
# Lossless WebP preserves every resized alpha value and logo colour.
|
||||
image.save(output, 'WEBP', quality=COVER_QUALITY, lossless=alpha, method=6, exact=True)
|
||||
return output.getvalue(), '.webp'
|
||||
|
||||
|
||||
def art(root=ROOT):
|
||||
"""(copy name, key, source bytes) for every enabled game's library art."""
|
||||
flags = [] if (root / 'ziran.local.toml').exists() else ['--locked']
|
||||
apps = Path(subprocess.check_output([str(root / 'scripts/ziran.sh'), 'pkg', 'path', 'apps', *flags], cwd=root, text=True).strip())
|
||||
for icon in ('profile', 'dew'):
|
||||
yield 'hud', icon, (apps / 'assets/hud' / (icon + '.webp')).read_bytes(), 0
|
||||
for package in declared_packages(root)[1:]:
|
||||
for app in package['apps']:
|
||||
if not app['enabled']:
|
||||
continue
|
||||
name = app['descriptor']['name']
|
||||
yield name, 'preview', (app['art_source'] / app['descriptor']['preview']).read_bytes()
|
||||
yield name, 'preview', (app['art_source'] / app['descriptor']['preview']).read_bytes(), 0
|
||||
for key in ('portrait', 'landscape', 'logo'):
|
||||
if app['cover'] and key in app['cover']:
|
||||
yield name, key, (app['art_source'] / app['cover'][key]).read_bytes()
|
||||
yield name, key, (app['art_source'] / app['cover'][key]).read_bytes(), app.get('cover_crops', {}).get(key, 0)
|
||||
|
||||
|
||||
def main():
|
||||
LIBRARY.mkdir(parents=True, exist_ok=True)
|
||||
sources = {}
|
||||
written = set()
|
||||
for name, key, data in art():
|
||||
for name, key, data, crop_top in art():
|
||||
copy = f'{name}-{key}'
|
||||
contents, suffix = small_copy(data, key)
|
||||
contents, suffix = small_copy(data, 'preview' if name.endswith('-editor') else key, crop_top)
|
||||
(LIBRARY / (copy + suffix)).write_bytes(contents)
|
||||
written.add(copy + suffix)
|
||||
sources[copy] = {'source_sha256': hashlib.sha256(data).hexdigest()}
|
||||
sources[copy] = {'source_sha256': hashlib.sha256(data).hexdigest(), 'crop_top': crop_top}
|
||||
for suffix in SUFFIXES:
|
||||
for stale in LIBRARY.glob('*' + suffix):
|
||||
if stale.name not in written:
|
||||
stale.unlink()
|
||||
(LIBRARY / 'sources.json').write_text(json.dumps(dict(sorted(sources.items())), indent=2) + '\n')
|
||||
total = sum((LIBRARY / name).stat().st_size for name in written)
|
||||
print(f'{len(sources)} library images, {total / 1048576:.1f} MiB')
|
||||
if total > ART_BUDGET:
|
||||
raise ValueError(f'Library art exceeds {ART_BUDGET} bytes: {total}')
|
||||
print(f'{len(sources)} library images, {total / 1048576:.1f} MiB (budget 2 MiB)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Prints a game export's entry and asset index as JSON for
|
||||
// scripts/build-games.py:
|
||||
// zx-metadata BUNDLE NAME
|
||||
// Opening verifies the whole bundle; none of its code runs. The texts of
|
||||
// assets/NAME/catalog.json and assets/NAME/requirements.json are included.
|
||||
#import "std/bundle_host"
|
||||
#import "std/byte_text_linux"
|
||||
#import "std/c_string"
|
||||
#import "std/json_quote"
|
||||
#import "std/stdio_linux"
|
||||
#import "std/text_buffer"
|
||||
#import "std/vec"
|
||||
|
||||
METADATA_LIMIT :: 1048576
|
||||
|
||||
AssetText :: (bundle: *void, index: u64) -> string {
|
||||
return TextFromBytes(BytesFromPointer(BundleAssetBytes(bundle, index), BundleAssetLength(bundle, index)))
|
||||
}
|
||||
|
||||
#program_export
|
||||
main :: (argc: s32, argv: **u8) -> s32 {
|
||||
if argc != 3 {
|
||||
unused PrintError("usage: zx-metadata BUNDLE NAME\n")
|
||||
return 2
|
||||
}
|
||||
bundle := OpenBundle(argv[1])
|
||||
if bundle == null {
|
||||
unused PrintError("zx-metadata: not a valid bundle\n")
|
||||
return 1
|
||||
}
|
||||
defer { CloseBundle(bundle) }
|
||||
name := TextFromCString(argv[2])
|
||||
catalog: Vec(u8)
|
||||
BuilderPrint(*catalog, "assets/%/catalog.json", name)
|
||||
catalog_path := BuilderFinish(catalog)
|
||||
requirements: Vec(u8)
|
||||
BuilderPrint(*requirements, "assets/%/requirements.json", name)
|
||||
requirements_path := BuilderFinish(requirements)
|
||||
entry: Vec(u8)
|
||||
BuilderPrint(*entry, "%:%", TextFromCString(BundleEntryModule(bundle)),
|
||||
TextFromCString(BundleEntryFunction(bundle)))
|
||||
output: Vec(u8)
|
||||
BuilderPrint(*output, "{\"entry\":%,\"assets\":[", JsonQuote(BuilderFinish(entry)))
|
||||
metadata: Vec(u8)
|
||||
count := BundleAssets(bundle)
|
||||
index: u64 = 0
|
||||
while index < count {
|
||||
path := TextFromCString(BundleAssetPath(bundle, index))
|
||||
length := BundleAssetLength(bundle, index)
|
||||
if index > 0 { BuilderPrint(*output, ",") }
|
||||
BuilderPrint(*output, "[%,%]", JsonQuote(path), length)
|
||||
if (path == catalog_path || path == requirements_path) && length <= cast(u64)METADATA_LIMIT {
|
||||
if metadata.count > 0 { BuilderPrint(*metadata, ",") }
|
||||
BuilderPrint(*metadata, "%:%", JsonQuote(path[name.count + 8:]), JsonQuote(AssetText(bundle, index)))
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
BuilderPrint(*output, "],\"metadata\":{%}}\n", BuilderFinish(metadata))
|
||||
return ifx WriteOutput(BuilderFinish(output)) then 0 else 1
|
||||
}
|
||||
@@ -153,12 +153,19 @@
|
||||
}),
|
||||
bundle('apps.zx'),
|
||||
bundle('runtime.data'),
|
||||
library()
|
||||
library(),
|
||||
Promise.all(['profile.webp', 'dew.webp'].map(function (name) {
|
||||
return file('assets/hud/' + name);
|
||||
}))
|
||||
]).then(function (loaded) {
|
||||
Module.arcadeReceipt = loaded[0];
|
||||
Module.preRun = [function () {
|
||||
if (loaded[1]) FS.writeFile('/apps.zx', new Uint8Array(loaded[1]));
|
||||
if (loaded[3]) writeLibrary(loaded[3]);
|
||||
FS.mkdirTree('/assets/hud');
|
||||
['profile.webp', 'dew.webp'].forEach(function (name, index) {
|
||||
FS.writeFile('/assets/hud/' + name, new Uint8Array(loaded[4][index]));
|
||||
});
|
||||
}];
|
||||
// The runtime's file package, already here, is not fetched again.
|
||||
if (loaded[2]) {
|
||||
|
||||
@@ -14,22 +14,23 @@
|
||||
#import "kryon/geometry"
|
||||
#import "kryon/drawing_props"
|
||||
#import "kryon/control_props"
|
||||
#import "kryon/box_widget"
|
||||
#import "kryon/box_props"
|
||||
#import "kryon/text_widget"
|
||||
#import "kryon/text_props"
|
||||
#import "kryon/button_widget"
|
||||
#import "kryon/button_props"
|
||||
Box :: #import "kryon/box";
|
||||
Text :: #import "kryon/text";
|
||||
Button :: #import "kryon/button";
|
||||
#import "kryon/hosted_values"
|
||||
#import "kryon/hosted_app"
|
||||
#import "kryon/widget_host"
|
||||
#import "kryon/app_files"
|
||||
#import "kryon/app_protocol"
|
||||
#import "kryon/app_context_host"
|
||||
#import "kryon/notification_schedule_host"
|
||||
#import "collection_notification_platform"
|
||||
#if !#defined(PLATFORM_DESKTOP) && !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
CollectionHost :: #import "kryon/app_context";
|
||||
}
|
||||
#import "kryon/key_input"
|
||||
#import "kryon/tree"
|
||||
#import "kryon/tree_input"
|
||||
#import "kryon/system_clipboard"
|
||||
#import "apps/host"
|
||||
#import "apps/tree"
|
||||
@@ -51,14 +52,16 @@ Codec :: #import "apps/node_codec";
|
||||
#import "entity/leaderboard_native"
|
||||
#import "kryon/widget_palette"
|
||||
#import "kryon/image_raster"
|
||||
#import "kryon/loading_indicator"
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
#import "kryon/app_asset"
|
||||
}
|
||||
LoadingIndicator :: #import "kryon/loading_indicator";
|
||||
#import, file "collection_loading.zi";
|
||||
#import "apps/connection"
|
||||
#import "apps/remote_catalog"
|
||||
Labels :: #import "apps/words";
|
||||
#import "shovey/shovey_theme"
|
||||
ProfileIcon :: #import "mingcute/mingcute_regular_user_4";
|
||||
DewIcon :: #import "mingcute/mingcute_filled_drop";
|
||||
#import "profile_palette"
|
||||
#import "apps/game_hud"
|
||||
collection_dew_text: [32]u8;
|
||||
|
||||
using HostValueKind;
|
||||
@@ -98,6 +101,24 @@ collection_leave_to_library: bool;
|
||||
// covers and passed to the games as arcade.updates. -1 unread, 0 off, 1 on,
|
||||
// 2 not answered yet.
|
||||
collection_updates: s32 = -1;
|
||||
collection_notification_node: *AppNode;
|
||||
collection_notification_requested: bool;
|
||||
|
||||
// Called by Apps only after its verified identity/frame checks. Native focus
|
||||
// alone is insufficient: Profile, library and other games own no opened marker.
|
||||
CollectionNotificationFocused :: (context: *void, node: *AppNode) -> bool {
|
||||
return node != null && node == collection_notification_node && !node.collection &&
|
||||
!entity_visible && AppTreeNode(*collection_host.tree, collection_host.tree.active) == node &&
|
||||
CollectionNotificationsForeground()
|
||||
}
|
||||
|
||||
CollectionRunFrame :: () -> bool {
|
||||
runtime := AppHostActiveRuntime(*collection_host)
|
||||
if runtime == null { return false }
|
||||
collection_notification_node = runtime.node
|
||||
defer { collection_notification_node = null }
|
||||
return AppHostRun(*collection_host, APP_FRAME)
|
||||
}
|
||||
|
||||
// Whether the device's main input is a keyboard and mouse. A native build
|
||||
// knows its platform; the collection running as a bundle inside Breeze asks
|
||||
@@ -145,8 +166,28 @@ CollectionRecordsFor :: (id: string) -> *CollectionRecords {
|
||||
return saved
|
||||
}
|
||||
|
||||
CollectionDocuments :: (context: *void, node: *AppNode) -> *AppFiles {
|
||||
unused context
|
||||
if node == null || node.collection { return null }
|
||||
saved := CollectionRecordsFor(TextUntilNul(node.identity.id[:]))
|
||||
return ifx saved == null then null else *saved.files
|
||||
}
|
||||
|
||||
CollectionAllows :: (context: *void, node: *AppNode, name: string) -> bool {
|
||||
if name == KRYON_NOTIFICATION_SCHEDULE {
|
||||
if node == null || node.collection { return false }
|
||||
// Ask only when a game actually uses reminders in its native focused
|
||||
// frame. Loading an older game or opening the library never prompts.
|
||||
if CollectionNotificationFocused(context, node) && !collection_notification_requested {
|
||||
collection_notification_requested = true
|
||||
if !CollectionNotificationsAllowed() { CollectionNotificationsRequest() }
|
||||
}
|
||||
return CollectionNotificationsAllowed()
|
||||
}
|
||||
return name == "AppRecordHost" || name == "SaveAppRecordHost" ||
|
||||
(node != null && !node.collection && (name == "DocumentReadHost" ||
|
||||
name == "DocumentStorageReadyHost" || name == "DocumentFlushHost" ||
|
||||
name == "DocumentStatusHost" || name == "DocumentWriteHost")) ||
|
||||
name == "AppFriendHost" || name == "AppSharedHost" || name == "AppSharedItemHost" ||
|
||||
name == "AppInvitationHost" || name == "RefreshAppSharedHost" || name == "SendAppSharedHost" ||
|
||||
name == "SmoothFramesHost" || name == "AppLocaleHost" || name == "AppSoundHost" || name == "AppNowHost" ||
|
||||
@@ -158,14 +199,56 @@ CollectionAllows :: (context: *void, node: *AppNode, name: string) -> bool {
|
||||
(name == COLLECTION_INPUT_DESKTOP && CollectionInputDesktop())
|
||||
}
|
||||
|
||||
// The old Choano document shares this game's record directory. Only the
|
||||
// current linked account may read its original 64-hex key for migration.
|
||||
CollectionChoanoLegacyRecord :: (node: *AppNode, record: string, owner: string) -> bool {
|
||||
if node == null || node.collection || TextUntilNul(node.identity.id[:]) != "xyz.waozi.choano" ||
|
||||
record.count != 81 || record[:14] != "choano.earned." || record[78:] != ".v1" ||
|
||||
owner.count != 64 || record[14:78] != owner { return false }
|
||||
for byte: owner {
|
||||
if !((byte >= #char "a" && byte <= #char "f") ||
|
||||
(byte >= #char "0" && byte <= #char "9")) { return false }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
CollectionCall :: (context: *void, node: *AppNode, module: *u8, function: *u8,
|
||||
arguments: *HostValue, count: s32, result: *HostValue) -> s32 {
|
||||
name := TextFromCString(function)
|
||||
if name == "DocumentReadHost" && count == 1 &&
|
||||
HostScalarValid(arguments[0], "string", cast(s32)HostString) {
|
||||
record := CollectionRecordsFor(TextUntilNul(node.identity.id[:]))
|
||||
if record == null || node.collection { return 0 }
|
||||
AppFileFree(record.text)
|
||||
record.text = AppFileRead(*record.files, AppArgumentText(arguments[0]))
|
||||
result.* = AppHostText(record.text)
|
||||
return 1
|
||||
}
|
||||
if name == "DocumentWriteHost" && count == 2 &&
|
||||
HostScalarValid(arguments[0], "string", cast(s32)HostString) &&
|
||||
HostScalarValid(arguments[1], "string", cast(s32)HostString) {
|
||||
saved := CollectionDocuments(context, node)
|
||||
if saved == null {
|
||||
result.* = HostScalar("bool", 0)
|
||||
return 1
|
||||
}
|
||||
saved_document := AppFileWrite(saved, AppArgumentText(arguments[0]), AppArgumentText(arguments[1]))
|
||||
result.* = HostScalar("bool", ifx saved_document then 1 else 0)
|
||||
return 1
|
||||
}
|
||||
if name == "DocumentStatusHost" && count == 0 {
|
||||
saved := CollectionDocuments(context, node)
|
||||
if saved == null { return 0 }
|
||||
result.* = HostScalar("s32", cast(s64)saved.status)
|
||||
return 1
|
||||
}
|
||||
if name == "AppRecordHost" && count == 1 &&
|
||||
HostScalarValid(arguments[0], "string", cast(s32)HostString) {
|
||||
record := AppArgumentText(arguments[0])
|
||||
if record.count >= 64 && !CollectionChoanoLegacyRecord(node, record, RecordsOwnerNow()) { return 0 }
|
||||
if !AppFileNameValid(record) { return 0 }
|
||||
saved := CollectionRecordsFor(TextUntilNul(node.identity.id[:]))
|
||||
if saved == null || !AppFileNameValid(record) || record.count >= 64 { return 0 }
|
||||
if saved == null { return 0 }
|
||||
AppFileFree(saved.text)
|
||||
saved.text = AppFileRead(*saved.files, record)
|
||||
if saved.files.status == -1 || saved.text.count >= 65536 { return 0 }
|
||||
@@ -509,6 +592,8 @@ CollectionOpen :: (bundle: string, digest: string, harness_digest: string,
|
||||
CollectionStart :: (bundle: string, digest: string, harness_digest: string,
|
||||
locale: string, packed: bool) -> bool {
|
||||
platform := AppPlatform.{.allows = CollectionAllows, .call = CollectionCall,
|
||||
.focused = CollectionNotificationFocused,
|
||||
.documents = CollectionDocuments,
|
||||
.widgets = CollectionWidgets, .save = CollectionSave, .state = CollectionState,
|
||||
.effect = CollectionEffect, .host_api = GAME_HOST_API,
|
||||
// Covers show only the art; the download dialog names the size.
|
||||
@@ -568,7 +653,7 @@ CollectionOpenBytes :: (bytes: string, metadata: string, data: string) -> bool {
|
||||
selected_digest := TextUntilNul(digest[:])
|
||||
if !packed {
|
||||
if !CollectionNodeOpen(metadata, data, bytes, selected_digest, TextUntilNul(harness[:]), language) { return false }
|
||||
if collection_node.ready {
|
||||
if collection_node_remote {
|
||||
selected = collection_node.bytes
|
||||
selected_digest = TextUntilNul(collection_node.release.artifacts[0].sha256[:])
|
||||
}
|
||||
@@ -619,6 +704,8 @@ CollectionOpenShoveyBytes :: (bytes: string, metadata: string, data: string) ->
|
||||
locale := EnvironmentText("LANG")
|
||||
language := ifx locale.count >= 2 then locale[:2] else "en"
|
||||
platform := AppPlatform.{.allows = CollectionAllows, .call = CollectionCall,
|
||||
.focused = CollectionNotificationFocused,
|
||||
.documents = CollectionDocuments,
|
||||
.widgets = CollectionWidgets, .save = CollectionSave, .state = CollectionState,
|
||||
.effect = CollectionEffect, .host_api = GAME_HOST_API}
|
||||
collection_ready = AppHostStart(*collection_host, bytes, "arcade.local", "arcade.shovey-player",
|
||||
@@ -690,7 +777,8 @@ CollectionOpenGame :: (id: string) -> bool {
|
||||
if root == null || !root.collection { Report("Arcade: no collection is open to start "); Report(id); Report("\n"); return false }
|
||||
entry := AppCatalogAt(*root.catalog, AppCatalogFind(*root.catalog, id))
|
||||
plan: AppInstallPlan
|
||||
if entry != null && AppHostInstallPlan(*collection_host, root, entry, *plan) && plan.count > 0 {
|
||||
if entry != null && (TextUntilNul(entry.cover.action[:]) == "title" ||
|
||||
(AppHostInstallPlan(*collection_host, root, entry, *plan) && plan.count > 0)) {
|
||||
unused CopyCString(id, collection_host.platform.presentation.download_id[:])
|
||||
collection_host.platform.presentation.download_request += 1
|
||||
return true
|
||||
@@ -759,26 +847,26 @@ CollectionUpdatesSet :: (on: bool) -> bool {
|
||||
// input until it is answered.
|
||||
CollectionUpdatesQuestion :: (session: Session, viewport: Rectangle) {
|
||||
question := "Download new levels when they come out?"
|
||||
Box(session, BoxProps.{.key = cast(u64)49300, .bounds = viewport, .fill = Color.{0, 0, 0, 160}})
|
||||
unused Button(session, ButtonProps.{.key = cast(u64)49301, .id = 49301, .label = question,
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49300, .bounds = viewport, .fill = Color.{0, 0, 0, 160}})
|
||||
unused Button.Draw(session, Button.Props.{.key = cast(u64)49301, .id = 49301, .label = question,
|
||||
.bounds = viewport, .invisible = true})
|
||||
width := ifx viewport.width - 24.0 < 480.0 then viewport.width - 24.0 else 480.0
|
||||
height: float32 = 200.0
|
||||
x := viewport.x + (viewport.width - width) / 2.0
|
||||
y := viewport.y + (viewport.height - height) / 2.0
|
||||
Box(session, BoxProps.{.key = cast(u64)49302, .bounds = Rectangle.{x, y, width, height},
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49302, .bounds = Rectangle.{x, y, width, height},
|
||||
.fill = Color.{59, 64, 63, 255}, .border = Color.{93, 98, 97, 255}, .radius = 18.0})
|
||||
Text(session, TextProps.{.key = cast(u64)49303, .text = question, .font = 20, .wrap = TextWrap.TextWrapAuto,
|
||||
Text.Draw(session, Text.Props.{.key = cast(u64)49303, .text = question, .size = 20, .wrap = Text.Wrap.TextWrapAuto,
|
||||
.bounds = Rectangle.{x + 16.0, y + 16.0, width - 32.0, 60.0}})
|
||||
Text(session, TextProps.{.key = cast(u64)49304, .text = "You can change this anytime in a game's Help.", .font = 14,
|
||||
.wrap = TextWrap.TextWrapAuto, .bounds = Rectangle.{x + 16.0, y + 80.0, width - 32.0, 44.0}})
|
||||
Text.Draw(session, Text.Props.{.key = cast(u64)49304, .text = "You can change this anytime in a game's Help.", .size = 14,
|
||||
.wrap = Text.Wrap.TextWrapAuto, .bounds = Rectangle.{x + 16.0, y + 80.0, width - 32.0, 44.0}})
|
||||
button_width := (width - 48.0 - 12.0) / 2.0
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49305, .id = 49305, .label = "Not now",
|
||||
if Button.Draw(session, Button.Props.{.key = cast(u64)49305, .id = 49305, .label = "Not now",
|
||||
.bounds = Rectangle.{x + 24.0, y + 136.0, button_width, 44.0},
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
unused CollectionUpdatesSet(false)
|
||||
}
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49306, .id = 49306, .label = "Download",
|
||||
if Button.Draw(session, Button.Props.{.key = cast(u64)49306, .id = 49306, .label = "Download",
|
||||
.bounds = Rectangle.{x + 36.0 + button_width, y + 136.0, button_width, 44.0},
|
||||
.tone = ButtonTone.ButtonToneAccent}) != 0 {
|
||||
unused CollectionUpdatesSet(true)
|
||||
@@ -789,7 +877,12 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
|
||||
collection_toolbar_visible = true
|
||||
defer { CollectionToolbar(session, viewport) }
|
||||
if CollectionNodeScreen(session, viewport) { collection_toolbar_visible = false; return true }
|
||||
if entity_visible { return EntityFrame(session, viewport, key, modifiers) }
|
||||
if entity_visible {
|
||||
collection_toolbar_visible = false
|
||||
return EntityFrame(session, viewport, key, modifiers,
|
||||
Labels.AppsLabel(TextUntilNul(collection_node_locale[:]), "library_connection"),
|
||||
ifx collection_node.files != null then *collection_node_notice else null)
|
||||
}
|
||||
runtime := AppHostActiveRuntime(*collection_host)
|
||||
if runtime == null { Report("Arcade: no app is running\n"); return false }
|
||||
opening := !runtime.node.collection && (!collection_loading.shown ||
|
||||
@@ -805,13 +898,32 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
|
||||
// The covers ask about new levels once; the question takes every key.
|
||||
asking := runtime.node.collection && !collection_host.platform.presentation.cover_grid && CollectionUpdates() == 2
|
||||
if asking { key = 0 }
|
||||
top: s32 = ifx !covered && !runtime.node.collection && (entity_ready || nested) then 56 else 0
|
||||
if runtime.node.collection && collection_node.files != null { top = 88 }
|
||||
// Console guest Home and its opaque strip are composed by shared Apps,
|
||||
// including in Inner Breeze; the ordinary non-console host bar stays here.
|
||||
top: s32 = ifx !covered && !runtime.node.collection && !collection_host.platform.presentation.cover_grid && (entity_ready || nested) then 56 else 0
|
||||
if runtime.node.collection && collection_node.files != null && !collection_host.platform.presentation.cover_grid { top = 88 }
|
||||
// The guest paints only its bounds below this host-owned bar. Paint an
|
||||
// opaque base before its controls and any translucent navigation surface.
|
||||
if top > 0 {
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49190,
|
||||
.bounds = Rectangle.{viewport.x, viewport.y, viewport.width, cast(float32)top},
|
||||
.fill = ColorFromPacked(ifx entity_shovey then ShoveyHostPalette().background else AppCoversPalette().background)})
|
||||
}
|
||||
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}
|
||||
runtime.app.scale = 1.0
|
||||
runtime.app.font = 16
|
||||
// Enter/Space routed to a focused host HUD action must not also activate
|
||||
// the guest console's selected game. Kryon retains the HUD activation.
|
||||
if key == 257 || key == 32 {
|
||||
hud_index: s32
|
||||
while hud_index < TreeCount(session) {
|
||||
hud_node := TreeInputAt(session, hud_index)
|
||||
if (hud_node.key == cast(u64)49200 || hud_node.key == cast(u64)49202 || hud_node.key == cast(u64)49210) && TreeFocusedAt(session, hud_index) { key = 0 }
|
||||
hud_index += 1
|
||||
}
|
||||
}
|
||||
runtime.app.key = key
|
||||
runtime.app.modifiers = modifiers
|
||||
// A focused text field in the game edits with what was typed this frame,
|
||||
@@ -834,12 +946,16 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
|
||||
}
|
||||
WidgetHostBegin(session, CollectionAssetAllowed, CollectionAssetPath)
|
||||
collection_pictures_missing = false
|
||||
drawn := AppHostRun(*collection_host, APP_FRAME)
|
||||
drawn_handle := collection_host.tree.active
|
||||
drawn := CollectionRunFrame()
|
||||
WidgetHostEnd()
|
||||
if !drawn {
|
||||
Report("collection frame failed\n")
|
||||
return false
|
||||
}
|
||||
// Shared host navigation can retire this guest after its frame. Its node
|
||||
// no longer belongs to this route; the next frame draws the new page.
|
||||
if !AppHandleEqual(collection_host.tree.active, drawn_handle) { return true }
|
||||
if collection_leave_to_library {
|
||||
collection_leave_to_library = false
|
||||
unused AppHostBack(*collection_host)
|
||||
@@ -855,20 +971,19 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
|
||||
if CollectionNeedsCover(*collection_loading, collection_host.tree.active.slot,
|
||||
collection_host.tree.active.generation, pictures_ready) {
|
||||
collection_toolbar_visible = false
|
||||
Box(session, BoxProps.{.key = cast(u64)49400, .bounds = viewport,
|
||||
.fill = ColorFromPacked(ifx entity_shovey then ShoveyPalette().background else AppCoversPalette().background)})
|
||||
unused Button(session, ButtonProps.{.key = cast(u64)49401, .id = 49401,
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49400, .bounds = viewport,
|
||||
.fill = ColorFromPacked(ifx entity_shovey then ShoveyHostPalette().background else AppCoversPalette().background)})
|
||||
unused Button.Draw(session, Button.Props.{.key = cast(u64)49401, .id = 49401,
|
||||
.bounds = viewport, .invisible = true})
|
||||
LoadingIndicator(session, LoadingIndicatorProps.{.key = cast(u64)49402,
|
||||
LoadingIndicator.Draw(session, LoadingIndicator.Props.{.key = cast(u64)49402,
|
||||
.bounds = viewport, .now = now, .scale = 1.5})
|
||||
return true
|
||||
}
|
||||
} else if runtime.node.collection {
|
||||
collection_loading = .{}
|
||||
CollectionNodeToolbar(session, viewport)
|
||||
}
|
||||
if asking {
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyPalette() else AppCoversPalette())
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyHostPalette() else AppCoversPalette())
|
||||
CollectionUpdatesQuestion(session, viewport)
|
||||
unused WidgetPaletteRestore(session)
|
||||
return true
|
||||
@@ -878,40 +993,51 @@ CollectionFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers:
|
||||
BuilderPrint(*title_bytes, "%", TextUntilNul(runtime.node.entry.title[:]))
|
||||
title := BuilderFinish(title_bytes)
|
||||
if !VecPush(collection_frame_paths, title) { AppFileFree(title); return false }
|
||||
Box(session, BoxProps.{.key = cast(u64)6, .bounds = Rectangle.{viewport.x, viewport.y, viewport.width, 56.0},
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)6, .bounds = Rectangle.{viewport.x, viewport.y, viewport.width, 56.0},
|
||||
.fill = Color.{128, 140, 136, 40}})
|
||||
if Button(session, ButtonProps.{.key = cast(u64)7, .id = 7, .label = "Back",
|
||||
.bounds = Rectangle.{viewport.x + 8.0, viewport.y + 6.0, 76.0, 44.0},
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
unused AppHostBack(*collection_host)
|
||||
}
|
||||
Text(session, TextProps.{.key = cast(u64)8,
|
||||
.text = title, .font = 20,
|
||||
.bounds = Rectangle.{viewport.x + 100.0, viewport.y + 12.0, viewport.width - 116.0, 36.0}})
|
||||
Text.Draw(session, Text.Props.{.key = cast(u64)8,
|
||||
.text = title, .size = 20,
|
||||
.bounds = Rectangle.{viewport.x + 150.0, viewport.y + 12.0, viewport.width - 166.0, 36.0}})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// The HUD is part of the native shell, so it also works before library consent.
|
||||
CollectionHudPath :: (icon: string) -> string {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
relative := Join("assets/hud", icon)
|
||||
defer { AppFileFree(relative) }
|
||||
bytes := ReadAppAsset(relative)
|
||||
defer { FreeAppAsset(bytes) }
|
||||
if bytes != "" { unused AppFileWrite(*collection_resources, relative, bytes) }
|
||||
path := Join(collection_resources.root, relative)
|
||||
if !VecPush(collection_frame_paths, path) { AppFileFree(path); return "" }
|
||||
return path
|
||||
} else #if #defined(PLATFORM_WEB) {
|
||||
return ifx icon == "profile.webp" then "/assets/hud/profile.webp" else "/assets/hud/dew.webp"
|
||||
} else {
|
||||
directory := ExecutableDirectory()
|
||||
defer { AppFileFree(directory) }
|
||||
relative := Join("assets/hud", icon)
|
||||
defer { AppFileFree(relative) }
|
||||
path := Join(directory, relative)
|
||||
if !VecPush(collection_frame_paths, path) { AppFileFree(path); return "" }
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
CollectionToolbar :: (session: Session, viewport: Rectangle) {
|
||||
if !entity_ready || !collection_toolbar_visible { return }
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyPalette() else AppCoversPalette())
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyHostPalette() else AppCoversPalette())
|
||||
defer { unused WidgetPaletteRestore(session) }
|
||||
// The account's Dew beside the Profile: a drop and the number, 0 until an
|
||||
// account is connected; it opens the Profile too.
|
||||
dew := EntityDewBalanceText(collection_dew_text[:])
|
||||
dew_width := 52.0 + 10.0 * cast(float32)dew.count
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49201, .id = 49201, .label = dew,
|
||||
.bounds = Rectangle.{viewport.x + viewport.width - 64.0 - dew_width, viewport.y + 6.0, dew_width, 44.0},
|
||||
.icon_shape = DewIcon.Shape, .tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
unused EntityShow()
|
||||
}
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49200, .id = 49200, .label = "Profile",
|
||||
.bounds = Rectangle.{viewport.x + viewport.width - 56.0, viewport.y + 6.0, 44.0, 44.0},
|
||||
.icon_shape = ProfileIcon.Shape, .icon_only = true,
|
||||
.selected = entity_visible,
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
unused EntityShow()
|
||||
}
|
||||
width := 144.0 + 10.0 * cast(float32)dew.count
|
||||
profile_path := CollectionHudPath("profile.webp")
|
||||
dew_path := CollectionHudPath("dew.webp")
|
||||
if AppGameHud(session, AppGameHudProps.{.key = cast(u64)49200,
|
||||
.bounds = Rectangle.{viewport.x + viewport.width - width - 12.0, viewport.y + 12.0, width, 56.0},
|
||||
.dew_text = dew, .profile_label = Labels.AppsLabel(TextUntilNul(collection_host.locale[:]), "profile"), .dew_label = "Dew",
|
||||
.profile_image = profile_path, .dew_image = dew_path}) != 0 { unused EntityShow() }
|
||||
}
|
||||
|
||||
c :: #system_library "c";
|
||||
@@ -931,6 +1057,35 @@ collection_seed: string;
|
||||
collection_seed_digest: [65]u8;
|
||||
collection_harness_digest: [65]u8;
|
||||
collection_node_locale: [16]u8;
|
||||
// The version of the catalog this build carries; "" when its receipt has none.
|
||||
collection_seed_version: [32]u8;
|
||||
|
||||
CollectionVersionPart :: (text: string, at: *s64) -> s64 {
|
||||
value: s64
|
||||
while at.* < text.count && text[at.*] >= cast(u8)48 && text[at.*] <= cast(u8)57 {
|
||||
value = value * 10 + cast(s64)(text[at.*] - cast(u8)48)
|
||||
at.* += 1
|
||||
}
|
||||
if at.* < text.count && text[at.*] == cast(u8)46 { at.* += 1 }
|
||||
return value
|
||||
}
|
||||
|
||||
// A saved or fetched signed release replaces the catalog this build carries
|
||||
// only when it is newer. An older or equal cached release never hides the
|
||||
// build's own library, artwork or games.
|
||||
CollectionNodeNewer :: () -> bool {
|
||||
current := TextUntilNul(collection_seed_version[:])
|
||||
if current == "" { return true }
|
||||
candidate := TextUntilNul(collection_node.release.version[:])
|
||||
left: s64
|
||||
right: s64
|
||||
for part: cast(s32)0..2 {
|
||||
a := CollectionVersionPart(candidate, *left)
|
||||
b := CollectionVersionPart(current, *right)
|
||||
if a != b { return a > b }
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
collection_signature :: #system_library "c";
|
||||
CollectionCheckSignature :: (signature: *u8, public_key: *u8, message: *u8,
|
||||
@@ -941,7 +1096,7 @@ CollectionVerifyRelease :: (signature: *u8, public_key: *u8, message: *u8,
|
||||
CollectionNodeOpen :: (metadata: string, data: string, seed: string,
|
||||
digest: string, harness: string, locale: string) -> bool {
|
||||
source: AppRemoteSource
|
||||
source.oldest_host_api = 1
|
||||
source.oldest_host_api = GAME_OLDEST_HOST_API
|
||||
source.host_api = GAME_HOST_API
|
||||
source.module_api = 2
|
||||
at := FieldAt(metadata, 0, "node")
|
||||
@@ -959,13 +1114,15 @@ CollectionNodeOpen :: (metadata: string, data: string, seed: string,
|
||||
unused CopyCString(digest, collection_seed_digest[:])
|
||||
unused CopyCString(harness, collection_harness_digest[:])
|
||||
unused CopyCString(locale, collection_node_locale[:])
|
||||
collection_seed_version[0] = 0
|
||||
unused AppsReadText(metadata, 0, "version", collection_seed_version[:])
|
||||
collection_package_origin = AppRemoteCopy(TextUntilNul(collection_node.source.origin[:]))
|
||||
collection_node_choice = AppConnectionRead(*collection_node_files, collection_package_origin)
|
||||
collection_node_notice = collection_node_choice == APP_CONNECTION_UNDECIDED
|
||||
allowed := collection_node_choice == APP_CONNECTION_ALLOWED
|
||||
CollectionDownloadsAllow(allowed)
|
||||
AppRemoteCatalogAllow(*collection_node, allowed)
|
||||
collection_node_remote = collection_node.ready
|
||||
collection_node_remote = collection_node.ready && CollectionNodeNewer()
|
||||
if allowed { unused AppRemoteCatalogRefresh(*collection_node) }
|
||||
return true
|
||||
}
|
||||
@@ -1022,7 +1179,18 @@ CollectionNodeActivate :: () -> bool {
|
||||
CollectionNodePump :: () {
|
||||
if collection_node.files == null { return }
|
||||
AppRemoteCatalogPump(*collection_node)
|
||||
if collection_node_apply && collection_node.stage == 0 {
|
||||
// A newer library applies on its own once the background fetch finishes.
|
||||
if (collection_node_apply || collection_node_choice == APP_CONNECTION_ALLOWED) && collection_node.stage == 0 {
|
||||
// The build's own newer catalog stays; the fetched release stays cached.
|
||||
if collection_node.changed && !collection_node_remote && !CollectionNodeNewer() {
|
||||
AppRemoteCatalogCollect(*collection_node)
|
||||
}
|
||||
// A newer signed release can reuse cached verified bytes without a
|
||||
// download, so the catalog does not report it as changed.
|
||||
if !collection_node.changed && !collection_node_remote && collection_node.ready &&
|
||||
!collection_node.failed && CollectionNodeNewer() {
|
||||
collection_node.changed = true
|
||||
}
|
||||
if collection_node.changed && !CollectionNodeActivate() { return }
|
||||
collection_node_apply = false
|
||||
collection_node_initial = false
|
||||
@@ -1039,10 +1207,10 @@ CollectionNodeScreen :: (session: Session, viewport: Rectangle) -> bool {
|
||||
return true
|
||||
}
|
||||
if collection_node_initial && collection_node.stage != 0 {
|
||||
Box(session, BoxProps.{.key = cast(u64)49510, .bounds = viewport, .fill = Color.{17, 18, 35, 255}})
|
||||
Text(session, TextProps.{.key = cast(u64)49511, .text = Labels.AppsLabel(TextUntilNul(collection_node_locale[:]), "loading_library"),
|
||||
.font = 20, .bounds = Rectangle.{viewport.x + 24.0, viewport.y + viewport.height / 2.0, viewport.width - 48.0, 64.0}})
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49512, .id = 49512,
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49510, .bounds = viewport, .fill = Color.{17, 18, 35, 255}})
|
||||
Text.Draw(session, Text.Props.{.key = cast(u64)49511, .text = Labels.AppsLabel(TextUntilNul(collection_node_locale[:]), "loading_library"),
|
||||
.size = 20, .bounds = Rectangle.{viewport.x + 24.0, viewport.y + viewport.height / 2.0, viewport.width - 48.0, 64.0}})
|
||||
if Button.Draw(session, Button.Props.{.key = cast(u64)49512, .id = 49512,
|
||||
.label = Labels.AppsLabel(TextUntilNul(collection_node_locale[:]), "stay_offline"),
|
||||
.bounds = Rectangle.{viewport.x + 24.0, viewport.y + viewport.height / 2.0 + 72.0, viewport.width - 48.0, 44.0},
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
@@ -1053,36 +1221,6 @@ CollectionNodeScreen :: (session: Session, viewport: Rectangle) -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
CollectionNodeToolbar :: (session: Session, viewport: Rectangle) {
|
||||
if collection_node.files == null { return }
|
||||
unused WidgetPaletteUse(session, AppCoversPalette())
|
||||
defer { unused WidgetPaletteRestore(session) }
|
||||
Box(session, BoxProps.{.key = cast(u64)49519,
|
||||
.bounds = Rectangle.{viewport.x, viewport.y, viewport.width, 88.0},
|
||||
.fill = Color.{17, 18, 35, 255}})
|
||||
locale := TextUntilNul(collection_node_locale[:])
|
||||
allowed := collection_node_choice == APP_CONNECTION_ALLOWED
|
||||
status := ifx !allowed then "offline_library" else ifx collection_node.stage != 0 then "loading_library" else ifx collection_node.failed then "library_unavailable" else "saved_library"
|
||||
width := ifx viewport.width - 180.0 < 320.0 then viewport.width - 180.0 else 320.0
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49520, .id = 49520,
|
||||
.label = Labels.AppsLabel(locale, ifx allowed then "refresh_library" else "connect_node"),
|
||||
.bounds = Rectangle.{viewport.x + 8.0, viewport.y + 6.0, width, 44.0},
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
if !allowed { collection_node_notice = true }
|
||||
else if collection_node.changed { collection_node_apply = true }
|
||||
else { collection_node_apply = true; unused AppRemoteCatalogRefresh(*collection_node) }
|
||||
}
|
||||
// A separate connection control keeps revocation available after consent.
|
||||
if Button(session, ButtonProps.{.key = cast(u64)49521, .id = 49521,
|
||||
.label = Labels.AppsLabel(locale, "node_connection"),
|
||||
.bounds = Rectangle.{viewport.x + viewport.width - 170.0, viewport.y + 52.0, 158.0, 28.0},
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 {
|
||||
collection_node_notice = true
|
||||
}
|
||||
Text(session, TextProps.{.key = cast(u64)49522, .text = Labels.AppsLabel(locale, status), .font = 12, .wrap = TextWrap.TextWrapAuto,
|
||||
.bounds = Rectangle.{viewport.x + 16.0, viewport.y + 58.0, viewport.width - 196.0, 26.0}})
|
||||
}
|
||||
|
||||
CollectionNodeClose :: () {
|
||||
CollectionDownloadsAllow(false)
|
||||
AppFileFree(collection_package_origin)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Native facts only. Portable games never request OS permission themselves.
|
||||
// Persistent alarms currently have an Android provider; other hosts fail closed.
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
#import "kryon/notification_android"
|
||||
}
|
||||
|
||||
CollectionNotificationsAllowed :: () -> bool {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
return AndroidNotificationAllowedHost()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
CollectionNotificationsForeground :: () -> bool {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
return AndroidNotificationWindowFocusedHost()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
CollectionNotificationsRequest :: () {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
// Kryon's native permission flow remembers refusal across launches.
|
||||
unused AndroidNotificationRequestHost()
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
#import "std/c_string"
|
||||
#import "std/byte_text_linux"
|
||||
#import "std/timer_linux"
|
||||
#import "kryon/Desktop"
|
||||
#import "kryon/Widgets"
|
||||
#import "kryon/desktop_runtime"
|
||||
#import "kryon/Cairo"
|
||||
#import "kryon/session"
|
||||
#import "kryon/geometry"
|
||||
#import "kryon/drawing_props"
|
||||
#import "kryon/tree"
|
||||
#import "kryon/tree_input"
|
||||
#import "kryon/Frame"
|
||||
#import "kryon/test_driver"
|
||||
#import "kryon/ScrollDevice"
|
||||
@@ -11,9 +16,11 @@
|
||||
#import "collection_host"
|
||||
#import "entity_host"
|
||||
#import "entity/model"
|
||||
#import "kryon/carousel"
|
||||
Carousel :: #import "kryon/carousel";
|
||||
#import "apps/appearance"
|
||||
#import "kryon/widget_palette"
|
||||
Box :: #import "kryon/box";
|
||||
LoadingIndicator :: #import "kryon/loading_indicator";
|
||||
|
||||
sdl :: #system_library "SDL2";
|
||||
SetTitle :: (window: *void, title: *u8) #foreign sdl "SDL_SetWindowTitle";
|
||||
@@ -30,12 +37,12 @@ DrawStartup :: (session: Session, directory: string, standalone: bool = true) ->
|
||||
defer { EntityFree(art); EntityFree(logo) }
|
||||
if BeginFrame(session, cast(u64)1, viewport) != FrameStatus.FrameOk { return false }
|
||||
if standalone {
|
||||
unused CarouselArtwork(session, viewport, cast(u64)48000, art, logo, "Shovey")
|
||||
unused Carousel.CarouselArtwork(session, viewport, cast(u64)48000, art, logo, "Shovey")
|
||||
} else {
|
||||
unused WidgetPaletteUse(session, AppCoversPalette())
|
||||
Box(session, BoxProps.{.key = cast(u64)48000, .bounds = viewport, .fill = Color.{17, 18, 35, 255}})
|
||||
Text(session, TextProps.{.key = cast(u64)48001, .text = "Arcade", .font = 32,
|
||||
.bounds = Rectangle.{20.0, 20.0, viewport.width - 40.0, 44.0}})
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)48000, .bounds = viewport, .fill = Color.{17, 18, 35, 255}})
|
||||
LoadingIndicator.Draw(session, LoadingIndicator.Props.{.key = cast(u64)48001,
|
||||
.bounds = viewport, .now = cast(float64)MonotonicMilliseconds() / 1000.0})
|
||||
unused WidgetPaletteRestore(session)
|
||||
}
|
||||
if EndFrame(session) != FrameStatus.FrameOk { return false }
|
||||
@@ -46,19 +53,10 @@ DrawStartup :: (session: Session, directory: string, standalone: bool = true) ->
|
||||
|
||||
Draw :: (session: Session) -> bool {
|
||||
BeginDesktopFrame()
|
||||
KeyboardModifiersSend(session, DesktopModifiers())
|
||||
key := DesktopPressedKey()
|
||||
for candidate: cast(s32)0..269 {
|
||||
if TestDriverKeyPressed(candidate) { key = candidate; break }
|
||||
}
|
||||
key, modifiers := DesktopInputTake(session)
|
||||
KeyboardModifiersSend(session, modifiers)
|
||||
if key == 256 && CollectionBack() { key = 0 }
|
||||
KeyboardSend(session, key)
|
||||
// Text typed on the keyboard reaches the game's focused field.
|
||||
codepoint := DesktopTypedCodepoint()
|
||||
while codepoint != 0 {
|
||||
unused TypedCodepointSend(session, codepoint)
|
||||
codepoint = DesktopTypedCodepoint()
|
||||
}
|
||||
if key != 0 { KeyboardSend(session, key) }
|
||||
viewport := DesktopViewport()
|
||||
pointer := TestDriverPointer(session, PollPointer())
|
||||
TreePointerUpdate(session, pointer)
|
||||
@@ -69,7 +67,7 @@ Draw :: (session: Session) -> bool {
|
||||
pointer.down, pointer.released, wheel,
|
||||
cast(float64)MonotonicMilliseconds() / 1000.0)
|
||||
if BeginFrame(session, cast(u64)1, viewport) != FrameStatus.FrameOk { return false }
|
||||
collection := CollectionFrame(session, viewport, key, DesktopModifiers())
|
||||
collection := CollectionFrame(session, viewport, key, modifiers)
|
||||
if !collection {
|
||||
TreeCancel(session)
|
||||
Report("collection frame returned false\n")
|
||||
@@ -114,10 +112,21 @@ main :: (argc: s32, argv: **u8) -> s32 {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
// --check opens the collection beside this binary without a window, so a
|
||||
// build or install proves the two match: a binary cannot read a
|
||||
// collection that a newer toolchain built.
|
||||
if argc == 2 && TextFromCString(argv[1]) == "--check" {
|
||||
data := DataDirectory()
|
||||
opened := data != "" && (ifx standalone then CollectionOpenShovey(ExecutableDirectory(), data) else CollectionOpenFiles(ExecutableDirectory(), data))
|
||||
unused CollectionClose()
|
||||
Report(product)
|
||||
Report(ifx opened then ": the collection opens with this binary\n" else ": this binary cannot open the collection beside it\n")
|
||||
return ifx opened then 0 else 1
|
||||
}
|
||||
first: s32 = -1
|
||||
if argc != 1 {
|
||||
if argc != 3 || TextFromCString(argv[1]) != "--app" {
|
||||
Report(ifx standalone then "Usage: shovey [--list | --app GAME]\n" else "Usage: arcade [--list | --app GAME]\n")
|
||||
Report(ifx standalone then "Usage: shovey [--list | --check | --app GAME]\n" else "Usage: arcade [--list | --check | --app GAME]\n")
|
||||
return 1
|
||||
}
|
||||
for index: cast(s32)0..GameCount - 1 {
|
||||
|
||||
@@ -9,19 +9,15 @@
|
||||
#import "kryon/session"
|
||||
#import "kryon/geometry"
|
||||
#import "kryon/key_input"
|
||||
#import "kryon/button_props"
|
||||
#import "kryon/button_widget"
|
||||
Button :: #import "kryon/button";
|
||||
#import "platform"
|
||||
#import "shovey/shovey_theme"
|
||||
#import "profile_palette"
|
||||
#import "kryon/widget_palette"
|
||||
#import "apps/appearance"
|
||||
#import "kryon/drawing_props"
|
||||
#import "kryon/box_widget"
|
||||
#import "kryon/box_props"
|
||||
#import "kryon/text_widget"
|
||||
#import "kryon/text_props"
|
||||
#import "kryon/modal_props"
|
||||
#import "kryon/modal_frame_widget"
|
||||
Box :: #import "kryon/box";
|
||||
Text :: #import "kryon/text";
|
||||
Modal :: #import "kryon/modal";
|
||||
#import "kryon/tree"
|
||||
|
||||
entity_bundle: string;
|
||||
@@ -84,19 +80,37 @@ EntityBack :: () -> bool {
|
||||
return true
|
||||
}
|
||||
|
||||
EntityFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers: s32) -> bool {
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyPalette() else AppCoversPalette())
|
||||
EntityDismiss :: () -> bool {
|
||||
if !EntityHostSave() { return false }
|
||||
// Clear secure fields and cancel any pending device-link/import route as
|
||||
// ordinary Back would, after preserving the profile edits.
|
||||
for depth: cast(s32)0..15 { if !EntityHostBack() { break } }
|
||||
entity_visible = false
|
||||
return true
|
||||
}
|
||||
|
||||
EntityFrame :: (session: Session, viewport: Rectangle, key: s32, modifiers: s32,
|
||||
connection_label: string = "", connection: *bool = null) -> bool {
|
||||
unused WidgetPaletteUse(session, ifx entity_shovey then ShoveyHostPalette() else AppCoversPalette())
|
||||
defer { unused WidgetPaletteRestore(session) }
|
||||
Box(session, BoxProps.{.key = cast(u64)49010, .bounds = viewport,
|
||||
unused Box.Draw(session, Box.Props.{.key = cast(u64)49010, .bounds = viewport,
|
||||
.fill = StyleTokenColorOr("canvas", Color.{239, 246, 244, 255})})
|
||||
width := viewport.width - 32.0
|
||||
height := viewport.height - 32.0
|
||||
if width > 560.0 { width = 560.0 }
|
||||
if height > 720.0 { height = 720.0 }
|
||||
modal := ModalFrame(session, ModalFrameProps.{.key = cast(u64)49000, .id = 49000,
|
||||
modal := Modal.Draw(session, Modal.Props.{.key = cast(u64)49000, .id = 49000,
|
||||
.title = "Profile", .width = cast(s32)width, .height = cast(s32)height, .scale = 1.0,
|
||||
.has_left_action = connection != null, .left_label = connection_label,
|
||||
.has_right_action = true, .right_label = "Back"})
|
||||
if modal.dismissed || modal.right_clicked { unused EntityBack() }
|
||||
if modal.left_clicked && connection != null && EntityDismiss() {
|
||||
connection.* = true
|
||||
}
|
||||
// The frame's X/outside dismissal closes the whole profile. System Back
|
||||
// still walks Entity's pages through EntityBack before leaving.
|
||||
if modal.dismissed || modal.right_clicked {
|
||||
unused EntityDismiss()
|
||||
}
|
||||
if !modal.opened { return true }
|
||||
input := TextFieldInputFor(key, modifiers, TypedTextTake(session, entity_typed[:]))
|
||||
ok := EntityHostFrame(session, modal.layout.content, key, modifiers, input, true)
|
||||
|
||||
@@ -3,4 +3,8 @@
|
||||
// that declares a newer one is refused. scripts/check-games.py fails while it
|
||||
// differs from the standard and the ledger.
|
||||
GAME_CONTRACT_VERSION :: 1
|
||||
GAME_HOST_API :: 41
|
||||
GAME_OLDEST_HOST_API :: 43
|
||||
GAME_HOST_API :: 43
|
||||
// The older direct loader has no verified reminder dispatch. Products use
|
||||
// CollectionHost; do not advertise its API42 authority from the direct loader.
|
||||
GAME_DIRECT_HOST_API :: 41
|
||||
@@ -245,7 +245,7 @@ GameAssetsValid :: () -> bool {
|
||||
if !id.valid || manifest.data[id.start:id.end] != GameAt(host.index).id ||
|
||||
!contract.valid || contract.value != GAME_CONTRACT_VERSION ||
|
||||
!module_api.valid || module_api.value != MODULE_ABI ||
|
||||
!host_api.valid || host_api.value < 1 || host_api.value > GAME_HOST_API ||
|
||||
!host_api.valid || host_api.value < 1 || host_api.value > GAME_DIRECT_HOST_API ||
|
||||
!save_schema.valid || save_schema.value < 1 { return false }
|
||||
read: bool
|
||||
write: bool
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
GameTheme :: #import "shovey/shovey_theme";
|
||||
HostPalette :: #import "kryon/widget_palette";
|
||||
|
||||
// A separately pinned game owns its colours; the native host owns the
|
||||
// widget types used to draw them.
|
||||
ShoveyHostPalette :: () -> HostPalette.WidgetPalette {
|
||||
game := GameTheme.ShoveyPalette()
|
||||
return HostPalette.WidgetPalette.{
|
||||
.background = game.background, .base = game.base, .text = game.text,
|
||||
.selected = game.selected, .selected_text = game.selected_text,
|
||||
.border = game.border, .danger = game.danger, .warning = game.warning,
|
||||
.success = game.success, .material = game.material}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "kryon-node-app",
|
||||
"contract_version": 1,
|
||||
"module_api": 2,
|
||||
"host_api": 41,
|
||||
"host_api": 43,
|
||||
"oldest_host_api": 43,
|
||||
"identity": "Stable signed package ID; moving source must not rename installed games",
|
||||
"frames": {
|
||||
"matching": "Fields match by name",
|
||||
@@ -11,7 +12,7 @@
|
||||
"input": "Only the supervised game receives its frame and input"
|
||||
},
|
||||
"required_host_calls": ["ReadAppHost", "WriteAppHost", "ReadAppUiHost", "AppLocaleHost", "AppRecordHost", "SaveAppRecordHost"],
|
||||
"optional_features": {"friends": "Explicitly unavailable without a connected account; never report an unsent action as sent"},
|
||||
"optional_features": {"friends": "Explicitly unavailable without a connected account; never report an unsent action as sent", "notifications": "API42: kryon.notification.schedule uses the verified active game's identity, an explicit native permission grant and native selected-game focus; unsupported or denied returns false. Guests cannot request OS permission or address another game's reminders."},
|
||||
"resources": {"root": "assets/<game>/", "locales": "assets/<game>/locales/<locale>.txt", "preview": "Required real game preview; no host files or texture handles"},
|
||||
"records": {"scope": "Game and account", "name_bytes_less_than": 64, "value_bytes_less_than": 65536, "save_schema": "Versioned by the game; upgrades preserve older saves"},
|
||||
"updates": {"signature": "Existing Ed25519 publisher", "identity": "Preserve package ID and publisher pins", "order": "Increasing version and sequence; immutable payload hashes", "gate": "Check the exact bundle in Arcade and an intended Inbe host, including its VM format, before node publication"}
|
||||
|
||||
@@ -50,11 +50,22 @@ class AndroidCatalogTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.assets = {name: (ROOT / 'build' / name).read_bytes()
|
||||
for name in ('arcade.zx', 'arcade.json', 'apps.zx', 'entity.zx')}
|
||||
self.assets.update({name: (ROOT / 'build/android-assets' / name).read_bytes()
|
||||
for name in android_catalog.HUD_PATHS})
|
||||
self.assets['kryon-font.ttf'] = b'font' # Content boundary, not a font renderer.
|
||||
|
||||
def test_standard_catalog(self):
|
||||
verify_assets(self.assets)
|
||||
|
||||
def test_reject_modified_or_missing_startup_hud(self):
|
||||
for name in android_catalog.HUD_PATHS:
|
||||
with self.subTest(path=name), self.assertRaisesRegex(AssertionError, 'HUD icons differ'):
|
||||
verify_assets(self.assets | {name: b'changed'})
|
||||
without = dict(self.assets)
|
||||
del without[name]
|
||||
with self.assertRaisesRegex(AssertionError, 'Unexpected or missing'):
|
||||
verify_assets(without)
|
||||
|
||||
def test_reject_changed_node_trust_binding(self):
|
||||
for key, value in (('origin', 'https://example.org'), ('public_key', 'a' * 64),
|
||||
('app_id', 'inbe.other'), ('minimum_sequence', 0)):
|
||||
|
||||
@@ -14,7 +14,7 @@ import time
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(root / 'scripts'))
|
||||
from android_catalog import verify_assets
|
||||
from collection_ui_test import package_server, answer_library_question, answer_level_updates
|
||||
from collection_ui_test import package_server, answer_library_question, answer_level_updates, enter_shovey_play, campaign_progress
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--binary', type=Path, required=True)
|
||||
@@ -23,7 +23,7 @@ args = parser.parse_args()
|
||||
assert int(os.environ['DISPLAY'].split(':')[-1].split('.')[0]) >= 400
|
||||
assert os.environ['YUE_DESKTOP_RECOVERY'] == '0'
|
||||
assets = root / 'build/android-assets'
|
||||
metadata = verify_assets({p.name: p.read_bytes() for p in assets.iterdir() if p.is_file()} |
|
||||
metadata = verify_assets({p.relative_to(assets).as_posix(): p.read_bytes() for p in assets.rglob('*') if p.is_file()} |
|
||||
{'entity.zx': (root / 'build/entity.zx').read_bytes()})
|
||||
entries = {entry['expected_id']: entry for entry in metadata['children']}
|
||||
sys.path.insert(0, str(args.inbe_source / 'tests'))
|
||||
@@ -38,6 +38,7 @@ with tempfile.TemporaryDirectory(prefix='host-', dir=output) as temporary, packa
|
||||
shutil.copy2(args.binary, install / 'arcade')
|
||||
for name in ('arcade.zx', 'arcade.json', 'apps.zx'):
|
||||
shutil.copyfile(assets / name, install / name)
|
||||
shutil.copytree(assets / 'assets/hud', install / 'assets/hud')
|
||||
shutil.copyfile(root / 'build/entity.zx', install / 'entity.zx')
|
||||
profile = Path(temporary) / 'profile'
|
||||
retained = profile / 'games/inbe.chess/records/computer'
|
||||
@@ -68,33 +69,47 @@ with tempfile.TemporaryDirectory(prefix='host-', dir=output) as temporary, packa
|
||||
driver.press(key=action['key'], role='button')
|
||||
|
||||
def play():
|
||||
enter_shovey_play(driver)
|
||||
answer_level_updates(driver)
|
||||
if driver.find(label='How do you want to move?', role='text'):
|
||||
driver.press(label='Swipe and tap')
|
||||
driver.wait(label='Restart', role='button', timeout=60)
|
||||
assert not driver.find(label='Download', role='button')
|
||||
|
||||
def library():
|
||||
for _ in range(8):
|
||||
if driver.find(label='Shovey', role='button'):
|
||||
return
|
||||
driver.key('escape')
|
||||
driver.wait_idle(frames=5)
|
||||
raise driver._failure('Back did not return to the library')
|
||||
|
||||
def editor():
|
||||
driver.wait(label='Editor', role='button')
|
||||
driver.press(label='Editor', role='button')
|
||||
if driver.find(label='Cancel', role='button'):
|
||||
download()
|
||||
driver.wait(label='Levels', role='button', timeout=60)
|
||||
|
||||
with application('install'):
|
||||
answer_library_question(driver)
|
||||
games = {entry['sha256'] for entry in metadata['children']}
|
||||
assert not games & set(server['requests']), 'No game before download consent'
|
||||
driver.press(label='Shovey Editor', role='button')
|
||||
assert not driver.find(label='Shovey Editor', role='button'), 'Editors belong inside their game'
|
||||
driver.press(label='Shovey', role='button')
|
||||
driver.wait(label='Cancel', role='button')
|
||||
driver.press(label='Cancel', role='button')
|
||||
assert not games & set(server['requests']), 'Cancel must download nothing'
|
||||
driver.press(label='Shovey Editor', role='button')
|
||||
driver.press(label='Shovey', role='button')
|
||||
server['corrupt_shovey'] = True
|
||||
download()
|
||||
driver.wait(label='Try again', role='button', timeout=60)
|
||||
assert not driver.find(label='New level', role='text'), 'Corrupt dependency must not open'
|
||||
assert not driver.find(label='Play', role='button'), 'Corrupt game must not open'
|
||||
server['corrupt_shovey'] = False
|
||||
download('Try again')
|
||||
driver.wait(label='New level', role='text', timeout=60)
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
assert server['requests'].count(entries['shovey']['sha256']) == 2
|
||||
assert server['requests'].count(entries['shovey-editor']['sha256']) == 1
|
||||
driver.key('escape')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
driver.press(label='Shovey', role='button')
|
||||
assert entries['shovey-editor']['sha256'] not in server['requests']
|
||||
play()
|
||||
driver.key('right')
|
||||
deadline = time.monotonic() + 20
|
||||
@@ -102,28 +117,16 @@ with tempfile.TemporaryDirectory(prefix='host-', dir=output) as temporary, packa
|
||||
driver.wait_idle(frames=5)
|
||||
assert record.exists(), 'Game must persist progress'
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
driver.wait(label='Editor', role='button')
|
||||
editor()
|
||||
assert server['requests'].count(entries['shovey-editor']['sha256']) == 1
|
||||
library()
|
||||
driver.press(label='Apfelwurm', role='button')
|
||||
download()
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
driver.key('escape')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label='Leaderboard', role='button')
|
||||
driver.wait(label='Apfelwurm', role='button')
|
||||
driver.press(label='Apfelwurm', role='button')
|
||||
# The profile stays usable with its optional game sheets omitted.
|
||||
driver.wait(label='Back', role='button')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.key('escape')
|
||||
driver.wait(label='Node connection', role='button')
|
||||
driver.press(label='Node connection', role='button')
|
||||
driver.wait(label='Stay offline', role='button')
|
||||
driver.press(label='Stay offline', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
library()
|
||||
assert not driver.find(label='Node connection', role='button'), 'The library has no node controls'
|
||||
assert not driver.find(label='Refresh library', role='button'), 'The library refreshes by itself'
|
||||
saved = record.read_bytes()
|
||||
for name in ('shovey', 'shovey-editor', 'wurm'):
|
||||
entry = entries[name]
|
||||
@@ -133,18 +136,18 @@ with tempfile.TemporaryDirectory(prefix='host-', dir=output) as temporary, packa
|
||||
requested = list(server['requests'])
|
||||
server['offline'] = True
|
||||
with application('offline'):
|
||||
answer_library_question(driver)
|
||||
driver.wait(label='Shovey', role='button')
|
||||
assert not driver.find(label='Allow fetching content and automatic app updates?', role='text'), 'Consent stays saved'
|
||||
driver.press(label='Shovey', role='button')
|
||||
play()
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Shovey Editor', role='button')
|
||||
driver.press(label='Shovey Editor', role='button')
|
||||
driver.wait(label='New level', role='text', timeout=60)
|
||||
driver.key('escape')
|
||||
driver.wait(label='Apfelwurm', role='button')
|
||||
driver.wait(label='Editor', role='button')
|
||||
editor()
|
||||
library()
|
||||
driver.press(label='Apfelwurm', role='button')
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
assert server['requests'] == requested, 'Installed apps/art must reopen offline without requests'
|
||||
assert record.read_bytes() == saved, 'Offline restart must preserve saved progress'
|
||||
cached_payloads = games | {metadata['art']['sha256']}
|
||||
assert not cached_payloads & set(server['requests'][len(requested):]), 'Installed apps/art must reopen offline without requests'
|
||||
assert campaign_progress(record.read_bytes()) == campaign_progress(saved), 'Offline restart must preserve saved progress'
|
||||
assert retained.read_bytes() == b'existing private save'
|
||||
print('Android catalog: consent, dependency verification/retry, install/open, cached offline and retained saves passed')
|
||||
@@ -32,13 +32,10 @@ class ControllerSourceTests(unittest.TestCase):
|
||||
(root / 'ziran.local.toml').write_text('unreviewed local dependency')
|
||||
package = root / 'cached-apps'
|
||||
output = root / 'output'
|
||||
compiler = root / 'cached-ziran/build/bin/ziran'
|
||||
compiler.parent.mkdir(parents=True)
|
||||
compiler.write_text('fixture compiler path; subprocess calls are mocked')
|
||||
contexts = []
|
||||
|
||||
def resolve(command, *, cwd, text):
|
||||
self.assertIn(command, [['ziran', 'pkg', 'path', name, '--locked'] for name in ('apps', 'ziran', 'kryon')])
|
||||
self.assertEqual(command, ['ziran', 'pkg', 'path', 'apps', '--locked'])
|
||||
self.assertTrue(text)
|
||||
self.assertNotIn('dependencies.wurm', (cwd / 'ziran.toml').read_text())
|
||||
selected = json.loads((cwd / 'ziran.lock').read_text())
|
||||
@@ -47,18 +44,17 @@ class ControllerSourceTests(unittest.TestCase):
|
||||
self.assertEqual(selected['toolchain'], lock['toolchain'])
|
||||
self.assertEqual({p.name for p in cwd.iterdir()}, {'ziran.toml', 'ziran.lock'})
|
||||
contexts.append(cwd)
|
||||
return str(package if command[3] == 'apps' else root / ('cached-' + command[3])) + '\n'
|
||||
return str(package) + '\n'
|
||||
|
||||
with patch.object(builder.subprocess, 'check_output', side_effect=resolve), \
|
||||
patch.object(builder.subprocess, 'run') as run:
|
||||
builder.build(root, output)
|
||||
self.assertEqual(run.call_count, 2)
|
||||
self.assertEqual(run.call_count, 1)
|
||||
command = run.call_args.args[0]
|
||||
self.assertEqual(command[0], str(compiler))
|
||||
self.assertIn(str(package / 'ui/apps.zi'), command)
|
||||
self.assertIn('kryon=' + str(root / 'cached-kryon/src/ui'), command)
|
||||
self.assertIn(str(root / 'cached-ziran/std'), command)
|
||||
self.assertNotIn('--project', command)
|
||||
self.assertEqual(command, [builder.sys.executable,
|
||||
str(package / 'scripts/build-ui.py'),
|
||||
'--output', str(output.resolve())])
|
||||
self.assertEqual(run.call_args.kwargs, {'cwd': contexts[0], 'check': True})
|
||||
self.assertFalse(contexts[0].exists())
|
||||
self.assertEqual((root / 'ziran.toml').read_text(), manifest)
|
||||
self.assertEqual(json.loads((root / 'ziran.lock').read_text()), lock)
|
||||
|
||||
@@ -25,7 +25,7 @@ assert chess["kind"] == "game"
|
||||
assert (ROOT / "apps/chess/engine.zi").is_file(), "Arcade must own the game"
|
||||
assert not (inbe / "apps/chess").exists(), "Inbe must consume Chess, not own another copy"
|
||||
assert chess["contract_version"] == 1 and chess["module_api"] == 2
|
||||
assert chess["host_api"] == 41 and chess["save_schema"] == 1
|
||||
assert chess["host_api"] == 43 and chess["save_schema"] == 1
|
||||
assert (ROOT / chess["preview"]).is_file()
|
||||
env = {key: value for key, value in os.environ.items()
|
||||
if key not in {"DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS"}}
|
||||
@@ -37,10 +37,9 @@ assert b"xyz.waozi.choano\n" in listed_output
|
||||
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.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 not (ROOT / 'build/games/chess.zx').exists(), 'Disabled Chess must not be exported'
|
||||
assert {child['id'] for child in metadata['children']} == {
|
||||
'arcade.shovey', 'arcade.shovey-editor', 'xyz.waozi.choano',
|
||||
'xyz.waozi.wurm', 'xyz.waozi.wurm-editor'
|
||||
|
||||
@@ -157,6 +157,7 @@ class AndroidVerifierTests(Fixture):
|
||||
(self.root / 'apps/versions.json').write_text(json.dumps(ledger))
|
||||
self.metadata['node'] = builder.node_source(self.root)
|
||||
self.assets = {'assets/arcade.zx': payload, 'assets/apps.zx': controller,
|
||||
**{'assets/' + name: b'fixture-hud' for name in android_catalog.HUD_PATHS},
|
||||
'assets/entity.zx': bundle({}), 'assets/kryon-font.ttf': b'font',
|
||||
'res/icon.png': b'icon', 'lib/arm64-v8a/libmain.so': b'arm64',
|
||||
'lib/armeabi-v7a/libmain.so': b'arm', 'classes.dex': b'normal'}
|
||||
@@ -181,6 +182,8 @@ class AndroidVerifierTests(Fixture):
|
||||
|
||||
with patch.object(release, 'ROOT', self.root), patch.object(android_catalog, 'ROOT', self.root), \
|
||||
patch.object(android_catalog, 'profile_asset_hashes', return_value={}), \
|
||||
patch.object(android_catalog, 'hud_hashes', return_value={
|
||||
name: hashlib.sha256(b'fixture-hud').hexdigest() for name in android_catalog.HUD_PATHS}), \
|
||||
patch.object(release, 'verify_launcher'), \
|
||||
patch.object(release.subprocess, 'check_output', side_effect=command), \
|
||||
patch.object(release.subprocess, 'run'):
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Recording OS boundary only; CollectionAllows/Focused/RunFrame stay production.
|
||||
allowed: bool = true;
|
||||
foreground: bool;
|
||||
requests: s32;
|
||||
CollectionNotificationsAllowed :: () -> bool { return allowed }
|
||||
CollectionNotificationsForeground :: () -> bool { return foreground }
|
||||
CollectionNotificationsRequest :: () { requests += 1 }
|
||||
@@ -0,0 +1,185 @@
|
||||
#import, file "../src/collection_host.zi";
|
||||
#import "kryon/Frame"
|
||||
#import "kryon/tree"
|
||||
#import "kryon/session"
|
||||
#import "kryon/geometry"
|
||||
#import "kryon/widget_host"
|
||||
#import "kryon/hosted_values"
|
||||
#import "kryon/app_files"
|
||||
#import "kryon/app_protocol"
|
||||
#import "apps/host"
|
||||
#import "apps/tree"
|
||||
#import "apps/protocol"
|
||||
#import "kryon/notification_schedule_host"
|
||||
#import "std/file"
|
||||
#import "std/bundle_host"
|
||||
#import "std/c_string"
|
||||
#import "std/vec"
|
||||
#import "std/text_buffer"
|
||||
#import "game_contract"
|
||||
#import "entity_host"
|
||||
Node :: #import "apps/node_types";
|
||||
using HostValueKind;
|
||||
Provider :: #import "kryon/notification_schedule";
|
||||
OS :: #import "collection_notification_platform";
|
||||
|
||||
test_session: Session;
|
||||
|
||||
Open :: (game: string, protocol: s32, wrong: bool = false, api: s32 = GAME_HOST_API) -> bool {
|
||||
path: Vec(u8); hash: Vec(u8)
|
||||
BuilderPrint(*path, "work/notification-api42/%-%.zx", game, protocol)
|
||||
BuilderPrint(*hash, "work/notification-api42/%-%.sha256", game, protocol)
|
||||
key := BuilderFinish(path); hash_key := BuilderFinish(hash)
|
||||
bytes, found := ReadEntireFile(key); digest, hash_found := ReadEntireFile(hash_key)
|
||||
AppFileFree(key); AppFileFree(hash_key)
|
||||
if !found || !hash_found { return false }
|
||||
defer { AppFileFree(bytes); AppFileFree(digest) }
|
||||
id := ifx game == "wurm" then "xyz.waozi.wurm" else "arcade.shovey"
|
||||
if wrong { id = "other.game" }
|
||||
platform := AppPlatform.{.host_api = api, .allows = CollectionAllows,
|
||||
.call = CollectionCall, .focused = CollectionNotificationFocused}
|
||||
return AppHostStart(*collection_host, bytes, "fixture.arcade", id, "notification", digest,
|
||||
"account-a", platform, "", "en", protocol)
|
||||
}
|
||||
|
||||
Draw :: (scenario: s32) -> bool {
|
||||
runtime := AppHostActiveRuntime(*collection_host)
|
||||
runtime.app.session = test_session
|
||||
runtime.app.bounds = Rectangle.{0.0, 0.0, cast(float32)(100 + scenario), 100.0}
|
||||
runtime.legacy.frame.session = test_session
|
||||
runtime.legacy.frame.width = 100 + scenario
|
||||
runtime.legacy.frame.height = 100
|
||||
runtime.legacy.message.screen = scenario
|
||||
BeginFrame(test_session, cast(u64)1, runtime.app.bounds)
|
||||
WidgetHostBegin(test_session, CollectionAssetAllowed)
|
||||
ran := CollectionRunFrame()
|
||||
WidgetHostEnd()
|
||||
return EndFrame(test_session) == FrameStatus.FrameOk && ran && collection_notification_node == null
|
||||
}
|
||||
|
||||
Denied :: (runtime: *AppRuntime) -> bool {
|
||||
answer: HostValue
|
||||
unused AppHostNotifications(cast(*void)runtime, HostTextData("notification_schedule"),
|
||||
HostTextData("DailyNotificationsSupportedHost"), null, 0, *answer)
|
||||
return answer.kind == cast(s32)HostInteger && answer.integer == 0
|
||||
}
|
||||
|
||||
Boundaries :: () -> bool {
|
||||
runtime := AppHostActiveRuntime(*collection_host)
|
||||
if !Denied(runtime) { return false } // out of run
|
||||
if !AppTreeBegin(*collection_host.tree, collection_host.tree.active) { return false }
|
||||
runtime.busy = true
|
||||
runtime.app.mode = APP_FRAME
|
||||
runtime.legacy.message.action = Node.APP_FRAME
|
||||
forged: AppRuntime
|
||||
forged.host = *collection_host; forged.node = runtime.node; forged.busy = true
|
||||
if !Denied(*forged) { return false }
|
||||
runtime.controller = true
|
||||
if !Denied(runtime) { return false }
|
||||
runtime.controller = false; runtime.retired = true
|
||||
if !Denied(runtime) { return false }
|
||||
runtime.retired = false
|
||||
if runtime.protocol == APPS_NODE_PROTOCOL {
|
||||
saved := runtime.legacy.id
|
||||
unused CopyCString("forged.game", runtime.legacy.id[:])
|
||||
refused := Denied(runtime)
|
||||
runtime.legacy.id = saved
|
||||
if !refused { return false }
|
||||
} else {
|
||||
saved := runtime.app.expected_id
|
||||
runtime.app.expected_id = "forged.game"
|
||||
refused := Denied(runtime)
|
||||
runtime.app.expected_id = saved
|
||||
if !refused { return false }
|
||||
}
|
||||
runtime.app.mode = APP_BACK; runtime.legacy.message.action = Node.APP_BACK
|
||||
if !Denied(runtime) { return false }
|
||||
runtime.app.mode = APP_FRAME; runtime.legacy.message.action = Node.APP_FRAME
|
||||
active := collection_host.tree.active; collection_host.tree.active = AppHandle.{}
|
||||
refused := Denied(runtime)
|
||||
collection_host.tree.active = active
|
||||
if !refused { return false }
|
||||
runtime.busy = false
|
||||
return AppTreeEnd(*collection_host.tree, collection_host.tree.active)
|
||||
}
|
||||
|
||||
#if #defined(ARCADE_API41_GAMES) {
|
||||
OldGame :: (name: string, id: string) -> bool {
|
||||
path: Vec(u8); hash: Vec(u8)
|
||||
BuilderPrint(*path, "build/games/%.zx", name)
|
||||
BuilderPrint(*hash, "work/notification-api42/%-41.sha256", name)
|
||||
key := BuilderFinish(path); hash_key := BuilderFinish(hash)
|
||||
bytes, found := ReadEntireFile(key); digest, hash_found := ReadEntireFile(hash_key)
|
||||
AppFileFree(key); AppFileFree(hash_key)
|
||||
if !found || !hash_found { return false }
|
||||
defer { AppFileFree(bytes); AppFileFree(digest) }
|
||||
platform := AppPlatform.{.host_api = GAME_HOST_API, .allows = CollectionAllows,
|
||||
.call = CollectionCall, .focused = CollectionNotificationFocused}
|
||||
opened := AppHostStart(*collection_host, bytes, "fixture.arcade", id, name, digest,
|
||||
"account-a", platform, "", "en", APPS_NODE_PROTOCOL)
|
||||
AppHostStop(*collection_host); AppHostCollect(*collection_host)
|
||||
return opened
|
||||
}
|
||||
}
|
||||
|
||||
#program_export
|
||||
Check :: () -> s32 {
|
||||
test_session = SessionOpen()
|
||||
if !SessionValid(test_session) { return 1 }
|
||||
for protocol: cast(s32)1..2 {
|
||||
for game: cast(s32)0..1 {
|
||||
key := ifx game == 0 then "wurm" else "shovey"
|
||||
OS.allowed = true; OS.foreground = false
|
||||
if !Open(key, protocol) { return 10 + protocol }
|
||||
runtime := AppHostActiveRuntime(*collection_host)
|
||||
Provider.expected_tag = ifx game == 0 then "hosted:xyz.waozi.wurm:wurm.daily_chest" else "hosted:arcade.shovey:shovey.daily-chest"
|
||||
if !Boundaries() { return 20 + protocol }
|
||||
collection_notification_requested = false
|
||||
OS.allowed = false
|
||||
requests := OS.requests
|
||||
if !Draw(1) || OS.requests != requests { return 25 + protocol }
|
||||
OS.foreground = true
|
||||
if !Draw(1) || !Draw(1) || OS.requests != requests + 1 { return 27 + protocol }
|
||||
OS.allowed = true; OS.foreground = false
|
||||
// Real production frame grants permission and forwards typed schedules.
|
||||
if !Draw(0) { return 30 + protocol }
|
||||
before := Provider.opened
|
||||
if !Draw(3) || Provider.opened != before { return 40 + protocol }
|
||||
OS.foreground = true
|
||||
if !Draw(2) || Provider.opened != before + 1 { return 50 + protocol }
|
||||
// Native focus alone, or another selected node, cannot mark opened.
|
||||
collection_notification_node = runtime.node
|
||||
other: AppNode
|
||||
if CollectionNotificationFocused(null, *other) { return 60 + protocol }
|
||||
entity_visible = true
|
||||
if CollectionNotificationFocused(null, runtime.node) { return 70 + protocol }
|
||||
entity_visible = false; collection_notification_node = null
|
||||
if CollectionNotificationFocused(null, runtime.node) { return 80 + protocol }
|
||||
no_focus: AppPlatform
|
||||
collection_host.platform.focused = no_focus.focused
|
||||
if !Draw(3) || Provider.opened != before + 1 { return 90 + protocol }
|
||||
collection_host.platform.focused = CollectionNotificationFocused
|
||||
OS.allowed = false
|
||||
if !Draw(1) || !Draw(3) || !Draw(4) { return 100 + protocol }
|
||||
Provider.expected_tag = ifx game == 0 then "hosted:xyz.waozi.wurm:hosted:arcade.shovey:shovey.daily-chest" else "hosted:arcade.shovey:hosted:arcade.shovey:shovey.daily-chest"
|
||||
if !Draw(5) { return 110 + protocol }
|
||||
AppHostStop(*collection_host); AppHostCollect(*collection_host)
|
||||
if protocol == APPS_NODE_PROTOCOL {
|
||||
if Open(key, protocol, true) { return 120 }
|
||||
AppHostStop(*collection_host); AppHostCollect(*collection_host)
|
||||
if Open(key, protocol, false, 42) { return 121 }
|
||||
AppHostStop(*collection_host); AppHostCollect(*collection_host)
|
||||
}
|
||||
}
|
||||
}
|
||||
if CollectionAllows(null, null, KRYON_NOTIFICATION_SCHEDULE) { return 122 }
|
||||
controller: AppNode; controller.collection = true; OS.allowed = true
|
||||
if CollectionAllows(null, *controller, KRYON_NOTIFICATION_SCHEDULE) { return 123 }
|
||||
#if #defined(ARCADE_API41_GAMES) {
|
||||
if !OldGame("chess", "inbe.chess") || !OldGame("shovey", "arcade.shovey") { return 125 }
|
||||
}
|
||||
unused SessionClose(test_session)
|
||||
if Provider.failures != 0 || Provider.daily != 4 || Provider.dated != 4 || Provider.queued != 4 ||
|
||||
Provider.cancelled != 8 || Provider.opened != 4 { return 124 }
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// A real portable guest; only the native fixture substitutes OS effects.
|
||||
#import "kryon/notification"
|
||||
#import "kryon/notification_schedule"
|
||||
#import "kryon/app_context"
|
||||
#import "kryon/app_protocol"
|
||||
#if #defined(APPS_NOTIFICATION_NODE) {
|
||||
#import "apps/node_types"
|
||||
#import "apps/node_app"
|
||||
host_api :: #system_library "host_api";
|
||||
ReadAppUiHost :: () -> AppUiFrame #foreign host_api;
|
||||
}
|
||||
|
||||
Exercise :: (scenario: s32) -> bool {
|
||||
tag := "wurm.daily_chest"
|
||||
#if #defined(APPS_NOTIFICATION_SHOVEY) {
|
||||
tag = "shovey.daily-chest"
|
||||
}
|
||||
props := NotificationProps.{.title = "Chest", .body = "Ready", .tag = tag, .id = 1}
|
||||
if scenario == 0 || scenario == 1 {
|
||||
allowed := scenario == 0
|
||||
dates: [2]s32 = .[20280229, 20300101]
|
||||
return DailyNotificationsSupported() == allowed &&
|
||||
ScheduleDailyNotification(props, 19, 0, true, 1793700000000, 127, 20261102) == allowed &&
|
||||
ScheduleNotificationAt(props, 2028, 2, 29, 19) == allowed &&
|
||||
ScheduleNotificationDates(props, dates[:], 19) == allowed
|
||||
}
|
||||
if scenario == 2 || scenario == 3 { return NotificationAppOpened(tag, 1) == (scenario == 2) }
|
||||
if scenario == 4 { return CancelDailyNotification(tag, 1) }
|
||||
return scenario == 5 && CancelDailyNotification("hosted:arcade.shovey:shovey.daily-chest", 1)
|
||||
}
|
||||
|
||||
#if #defined(APPS_NOTIFICATION_NODE) {
|
||||
Draw :: (message: AppMessage) -> bool {
|
||||
unused ReadAppUiHost()
|
||||
return Exercise(message.screen)
|
||||
}
|
||||
}
|
||||
|
||||
#program_export
|
||||
Main :: () -> s32 {
|
||||
#if #defined(APPS_NOTIFICATION_NODE) {
|
||||
return RunNodeApp(Draw)
|
||||
} else {
|
||||
if AppMode() == APP_IDENTIFY {
|
||||
AppIdentity("notification")
|
||||
AppDescribe("Arcade notification fixture", "")
|
||||
return APP_PROTOCOL
|
||||
}
|
||||
if AppMode() == APP_FRAME { return ifx Exercise(cast(s32)AppBounds().width - 100) then 0 else -1 }
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Portable guests through Arcade's production Collection notification boundary."""
|
||||
import hashlib
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
WORK = ROOT / 'work/notification-api42'
|
||||
ZIRAN = ROOT / 'scripts/ziran.sh'
|
||||
LOCK = [] if (ROOT / 'ziran.local.toml').exists() else ['--locked']
|
||||
|
||||
|
||||
def run(*args):
|
||||
subprocess.run(list(map(str, args)), cwd=ROOT, check=True)
|
||||
|
||||
|
||||
def package(name):
|
||||
return Path(subprocess.check_output([ZIRAN, 'pkg', 'path', name, *LOCK],
|
||||
cwd=ROOT, text=True).strip())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--api41-games', action='store_true', help='Also identify the built API41 Chess and Shovey games')
|
||||
args = parser.parse_args()
|
||||
for key in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY', 'DBUS_SESSION_BUS_ADDRESS',
|
||||
'SESSION_MANAGER', 'DESKTOP_SESSION', 'XDG_SESSION_ID', 'XDG_SESSION_TYPE'):
|
||||
os.environ.pop(key, None)
|
||||
os.environ.update(YUE_DESKTOP_RECOVERY='0', SDL_AUDIODRIVER='dummy', ZIRAN_JOBS='1')
|
||||
run('git', 'check-ignore', '-q', 'work/')
|
||||
WORK.mkdir(parents=True, exist_ok=True)
|
||||
if args.api41_games:
|
||||
for name in ('chess', 'shovey'):
|
||||
path = ROOT / 'build/games' / (name + '.zx')
|
||||
(WORK / (name + '-41.sha256')).write_text(hashlib.sha256(path.read_bytes()).hexdigest())
|
||||
apps = package('apps')
|
||||
toolchain = package('ziran')
|
||||
compiler = toolchain / 'build/bin/zi2c'
|
||||
if not compiler.is_file():
|
||||
compiler = ROOT / 'build/toolchain/bin/zi2c'
|
||||
zx = compiler.with_name('zi2zx')
|
||||
# Reuse the locked package's maintained recording scheduler provider.
|
||||
# No package source or cache is modified; only OS effects are substituted.
|
||||
source = ROOT / 'tests/collection_notifications_guest.zi'
|
||||
for game, identifier in [('wurm', 'xyz.waozi.wurm'), ('shovey', 'arcade.shovey')]:
|
||||
assets = WORK / game / 'assets/notification'
|
||||
assets.mkdir(parents=True, exist_ok=True)
|
||||
(assets / 'catalog.json').write_text(json.dumps(dict(id=identifier, name='notification',
|
||||
contract_version=1, module_api=2, host_api=43, save_schema=1)))
|
||||
for protocol in (1, 2):
|
||||
defines = ['--define', 'KRYON_HOSTED_UI']
|
||||
if protocol == 2:
|
||||
defines += ['--define', 'APPS_NOTIFICATION_NODE']
|
||||
if game == 'shovey':
|
||||
defines += ['--define', 'APPS_NOTIFICATION_SHOVEY']
|
||||
common = ['--project', *LOCK, '--root', ROOT / 'tests',
|
||||
'--entry', 'collection_notifications_guest:Main', *defines]
|
||||
path = WORK / f'{game}-{protocol}.zx'
|
||||
run(ZIRAN, 'bundle', *common, '--asset-dir', 'assets=' + str(assets.parent),
|
||||
'-o', path, source)
|
||||
(WORK / f'{game}-{protocol}.sha256').write_text(hashlib.sha256(path.read_bytes()).hexdigest())
|
||||
ir = WORK / f'ir-{game}-{protocol}'
|
||||
run(ZIRAN, 'ir', *common, '-o', ir, source)
|
||||
saved = WORK / f'{game}-{protocol}-saved.zx'
|
||||
run(zx, '--root', ir, '--module-path', ir,
|
||||
'--entry', 'collection_notifications_guest:Main', '--asset-dir', 'assets=' + str(assets.parent),
|
||||
'-o', saved, ir / 'collection_notifications_guest.zir')
|
||||
if path.read_bytes() != saved.read_bytes():
|
||||
raise RuntimeError(f'Source/saved guest differs: {game} protocol {protocol}')
|
||||
lines = (ROOT / 'build/.ziran/module-map.tsv').read_text().splitlines()
|
||||
replacements = {'notification_schedule': apps / 'tests/notification_provider.zi',
|
||||
'collection_notification_platform': ROOT / 'tests/collection_notification_native_fixture.zi'}
|
||||
kryon_id = next(fields[3] for line in lines
|
||||
if len(fields := line.split('\t')) == 5
|
||||
and fields[:3] == ['D', 'root', 'kryon/notification_schedule'])
|
||||
replaced = dict.fromkeys(replacements, 0)
|
||||
for index, line in enumerate(lines):
|
||||
fields = line.split('\t')
|
||||
if len(fields) == 4 and fields[0] == 'M' and fields[2] in replacements:
|
||||
# Replace only Arcade's own OS facts and its resolved Kryon provider.
|
||||
if fields[2] == 'collection_notification_platform' and fields[1] != 'root':
|
||||
continue
|
||||
if fields[2] == 'notification_schedule' and fields[1] != kryon_id:
|
||||
continue
|
||||
fields[3] = str(replacements[fields[2]])
|
||||
replaced[fields[2]] += 1
|
||||
lines[index] = '\t'.join(fields)
|
||||
if any(count != 1 for count in replaced.values()):
|
||||
raise RuntimeError(f'Expected unique OS providers: {replaced}')
|
||||
# Reuse Apps' display-free raster exports without exposing test modules
|
||||
# through either package's production module roots.
|
||||
lines.append(f'M\troot\tgame_hud_host\t{apps / "tests/game_hud_host.zi"}')
|
||||
mapping = WORK / 'module-map.tsv'
|
||||
mapping.write_text('\n'.join(lines) + '\n')
|
||||
os.environ['ZIRAN_PACKAGE_MAP'] = str(mapping)
|
||||
output = WORK / 'c'
|
||||
run(compiler, '--prune-stale', '--module-path', toolchain / 'std', '--no-main',
|
||||
'--define', 'PLATFORM_DESKTOP', *(['--define', 'ARCADE_API41_GAMES'] if args.api41_games else []),
|
||||
'--entry', 'collection_notifications_behavior:Check',
|
||||
'--root', ROOT / 'tests', '-o', output, ROOT / 'tests/collection_notifications_behavior.zi',
|
||||
apps / 'tests/game_hud_host.zi')
|
||||
(output / 'entry.c').write_text('#include <stdio.h>\n#include "collection_notifications_behavior.h"\n'
|
||||
'int main(void) { int r=Check(); if(r) fprintf(stderr,"Arcade notification test %d failed\\n",r); return r; }\n')
|
||||
runtime = ROOT / 'build/ziran/libziran.a'
|
||||
run('make', '-j1', 'build/ziran/libziran.a')
|
||||
oqs_source = package('liboqs')
|
||||
oqs = ROOT / 'build' / ('entity-oqs-' + oqs_source.name)
|
||||
if not (oqs / 'lib/liboqs.a').is_file():
|
||||
run('cmake', '-S', oqs_source, '-B', 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;KEM_ml_kem_768')
|
||||
run('cmake', '--build', oqs, '--target', 'oqs', '--', '-j1')
|
||||
libraries = subprocess.check_output(['pkg-config', '--libs', 'sdl2', 'cairo', 'freetype2',
|
||||
'fontconfig', 'pangocairo', 'gtk+-3.0'], text=True).split()
|
||||
monocypher = package('monocypher')
|
||||
includes = [arg for p in [output, *sorted(output.rglob('*'))] if p.is_dir()
|
||||
for arg in ('-iquote', str(p))]
|
||||
temporary = WORK / 'test.new'
|
||||
run(os.environ.get('CC', 'cc'), '-std=c11', '-O1', '-ffunction-sections', '-fdata-sections',
|
||||
'-I' + str(toolchain / 'include'), *includes, *sorted(output.rglob('*.c')),
|
||||
runtime, '-I' + str(monocypher / 'src'), monocypher / 'src/monocypher.c',
|
||||
monocypher / 'src/optional/monocypher-ed25519.c', oqs / 'lib/liboqs.a',
|
||||
'-Wl,--gc-sections', *libraries, '-lX11', '-l:libcurl.so.4', '-lz', '-lm', '-lpthread', '-o', temporary)
|
||||
temporary.replace(WORK / 'test')
|
||||
run(WORK / 'test')
|
||||
print('Arcade Collection API42: source/saved node/2 + app/1 guests, native schedules, verified identity, permission, focus and tag isolation passed')
|
||||
if args.api41_games:
|
||||
print('Arcade API42 host also identified the built API41 Chess and Shovey games')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,4 +1,5 @@
|
||||
#import, file "../src/collection_host.zi";
|
||||
#import "apps/tree"
|
||||
#import "entity/publications"
|
||||
#import "entity/publications_read"
|
||||
#import "std/bundle_host"
|
||||
@@ -23,8 +24,24 @@ BorrowedText :: (value: HostValue) -> string {
|
||||
return TextFromBytes(BytesFromPointer(value.data, cast(u64)value.length))
|
||||
}
|
||||
|
||||
CheckChoanoLegacyRecord :: () -> bool {
|
||||
owner := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
record := "choano.earned.0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef.v1"
|
||||
traversal := "choano.earned./123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef.v1"
|
||||
node: AppNode
|
||||
if !CopyText("xyz.waozi.choano", node.identity.id[:]) || !CollectionChoanoLegacyRecord(*node, record, owner) { return false }
|
||||
if CollectionChoanoLegacyRecord(*node, record, "") || CollectionChoanoLegacyRecord(*node, traversal, traversal[14:78]) ||
|
||||
CollectionChoanoLegacyRecord(*node, record, "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") { return false }
|
||||
node.collection = true
|
||||
if CollectionChoanoLegacyRecord(*node, record, owner) { return false }
|
||||
node.collection = false
|
||||
if !CopyText("arcade.shovey", node.identity.id[:]) { return false }
|
||||
return !CollectionChoanoLegacyRecord(*node, record, owner)
|
||||
}
|
||||
|
||||
#program_export
|
||||
Check :: () -> s32 {
|
||||
if !CheckChoanoLegacyRecord() { return 7 }
|
||||
if !CollectionAllows(null, null, PUBLICATIONS_SERVICE) { return 1 }
|
||||
if !CollectionAllows(null, null, PUBLICATIONS_READ_SERVICE) { return 2 }
|
||||
function: [32]u8
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Check that Arcade routes writable publications through Entity's account gate."""
|
||||
"""Check Arcade’s account-scoped publication and legacy record guards."""
|
||||
import fcntl
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -37,7 +37,10 @@ def main():
|
||||
"collection_publications_host_behavior:Check", "-o", str(generated),
|
||||
"tests/collection_publications_host_behavior.zi")
|
||||
main_c = generated / "main.c"
|
||||
# The account checks link the collection dispatcher without a UI backend.
|
||||
main_c.write_text('#include "collection_publications_host_behavior.h"\n'
|
||||
'int32_t ImageWidth(String path) { (void)path; return 0; }\n'
|
||||
'int32_t ImageHeight(String path) { (void)path; return 0; }\n'
|
||||
'int main(void) { return Check(); }\n')
|
||||
toolchain = Path(subprocess.check_output(
|
||||
[ziran, "pkg", "path", "ziran", *lock], cwd=ROOT, text=True,
|
||||
@@ -83,7 +86,7 @@ def main():
|
||||
if result.returncode != 42:
|
||||
raise SystemExit(
|
||||
f"collection publications host check returned {result.returncode}")
|
||||
print("Arcade publications host: writable service dispatches through Entity's account gate")
|
||||
print("Arcade collection host: publication and Choano legacy record account guards passed")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -23,39 +23,21 @@ spec.loader.exec_module(builder)
|
||||
art_spec = importlib.util.spec_from_file_location("library_art", ROOT / "scripts/library-art.py")
|
||||
artist = importlib.util.module_from_spec(art_spec)
|
||||
art_spec.loader.exec_module(artist)
|
||||
spec = importlib.util.spec_from_file_location("published_games", ROOT / "scripts/wait-published-games.py")
|
||||
published_games = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(published_games)
|
||||
|
||||
|
||||
def bundle_asset_paths(path):
|
||||
"""Read the actual bundle index without loading its images or executing it."""
|
||||
with published_games.Reader(path) as reader:
|
||||
if reader.take(8) not in (b"ZX\0\0\x1a\0\0\0", b"ZX\0\0\x1b\0\0\0"):
|
||||
raise ValueError("Unsupported game bundle")
|
||||
reader.text()
|
||||
reader.text()
|
||||
for _ in range(reader.number()):
|
||||
reader.text()
|
||||
reader.text()
|
||||
for _ in range(reader.number()):
|
||||
for _ in range(7):
|
||||
reader.text()
|
||||
reader.take(8)
|
||||
reader.text()
|
||||
reader.take(4)
|
||||
for _ in range(reader.number()):
|
||||
for _ in range(3):
|
||||
reader.text()
|
||||
reader.skip(reader.number())
|
||||
paths = set()
|
||||
for _ in range(reader.number()):
|
||||
name = reader.text().decode()
|
||||
if name in paths:
|
||||
raise ValueError("Duplicate game asset: " + name)
|
||||
paths.add(name)
|
||||
reader.skip(reader.number())
|
||||
reader.finish()
|
||||
"""Read the actual bundle index without loading its images or executing it.
|
||||
|
||||
build/zx-metadata opens and verifies the ZX 28 bundle with the Ziran
|
||||
runtime; none of its code runs.
|
||||
"""
|
||||
result = subprocess.run([str(ROOT / "build/zx-metadata"), str(path), path.stem],
|
||||
capture_output=True, text=True, check=True)
|
||||
paths = set()
|
||||
for name, _ in json.loads(result.stdout)["assets"]:
|
||||
if name in paths:
|
||||
raise ValueError("Duplicate game asset: " + name)
|
||||
paths.add(name)
|
||||
return paths
|
||||
|
||||
|
||||
@@ -64,8 +46,8 @@ class CollectionTests(unittest.TestCase):
|
||||
# Fixed runtime references catch a doubled namespace in the real
|
||||
# compiled payload, independently of the packaging declaration.
|
||||
assets = bundle_asset_paths(ROOT / "build/games/choano.zx")
|
||||
for path in ("assets/choano/background-inside.png", "assets/choano/organisms-hd.png",
|
||||
"assets/choano/title-landscape.jpg", "assets/choano/fish/sea.png"):
|
||||
for path in ("assets/choano/background-inside.avif", "assets/choano/organisms-hd.avif",
|
||||
"assets/choano/title-landscape.avif", "assets/choano/fish/sea.avif"):
|
||||
self.assertTrue(path in assets, "Choano runtime image missing from its bundle: " + path)
|
||||
|
||||
def setUp(self):
|
||||
@@ -117,15 +99,16 @@ class CollectionTests(unittest.TestCase):
|
||||
for path in (self.root / "build/games").glob("*.zx"):
|
||||
path.write_bytes(b"game fixture".ljust(32 * 1024, b"\0"))
|
||||
for path in (self.root / "assets/arcade/library").iterdir():
|
||||
if path.suffix in (".png", ".jpg"):
|
||||
if path.suffix in (".webp",):
|
||||
path.write_bytes(b"art fixture".ljust(128, b"\0"))
|
||||
|
||||
def test_separately_loaded_games_can_exceed_one_root_limit_together(self):
|
||||
# The registered games exceed 64 MiB together; each game and the
|
||||
# Shovey standalone pair still fit. Never alter the real build outputs.
|
||||
# Five bounded fixture payloads exceed 64 MiB together, while every
|
||||
# game and the Shovey standalone pair fit. Their sizes are independent
|
||||
# of future game-art growth. Never alter the real build outputs.
|
||||
for path in (self.root / "build/games").glob("*.zx"):
|
||||
with path.open("r+b") as data:
|
||||
data.truncate(max(path.stat().st_size, 16 * 1024 * 1024))
|
||||
data.truncate(16 * 1024 * 1024)
|
||||
catalog = self.stage()
|
||||
self.assertGreater(sum(child["bytes"] for child in catalog["children"]), 64 * 1024 * 1024)
|
||||
small, games, art = (self.root / name for name in ("small", "downloads", "art"))
|
||||
@@ -168,7 +151,7 @@ class CollectionTests(unittest.TestCase):
|
||||
path.write_bytes(b"game")
|
||||
# Art is one separately loaded root, even though it has many files.
|
||||
pictures = [path for path in (self.root / "assets/arcade/library").iterdir()
|
||||
if path.suffix in (".png", ".jpg")]
|
||||
if path.suffix in (".webp",)]
|
||||
for path in pictures:
|
||||
path.write_bytes(b"x" * 8192)
|
||||
with patch.object(builder, "MAX_PAYLOAD_BYTES", 48 * 1024):
|
||||
@@ -205,10 +188,25 @@ class CollectionTests(unittest.TestCase):
|
||||
compile_art()
|
||||
self.assertEqual(target.read_bytes(), previous)
|
||||
|
||||
def test_oversized_art_bundle_is_not_published(self):
|
||||
output = self.root / "art-budget-catalog"
|
||||
games = self.root / "art-budget-downloads"
|
||||
(output / "assets/apps").mkdir(parents=True)
|
||||
games.mkdir()
|
||||
catalog = output / "assets/apps/catalog.json"
|
||||
catalog.write_text('{"children": []}\n')
|
||||
bundle = self.root / "over-budget-art.zx"
|
||||
bundle.write_bytes(b"art" + bytes(builder.MAX_LIBRARY_ART_BYTES))
|
||||
with self.assertRaisesRegex(ValueError, "2 MiB art budget"):
|
||||
builder.add_art(output, games, bundle)
|
||||
self.assertEqual(catalog.read_text(), '{"children": []}\n')
|
||||
self.assertEqual(list(games.iterdir()), [])
|
||||
|
||||
def test_staging_uses_locked_packages_unless_local_overrides_exist(self):
|
||||
packages = builder.declared_packages(self.root, lock_flags=self.lock_flags)
|
||||
artwork = json.loads((self.root / "games.json").read_text()).get("artwork", {})
|
||||
sources = {package["name"]: package["source"] for package in packages[1:]}
|
||||
sources["apps"] = Path(subprocess.check_output([str(ROOT / "scripts/ziran.sh"), "pkg", "path", "apps", *self.lock_flags], cwd=ROOT, text=True).strip())
|
||||
for package in packages[1:]:
|
||||
if package["name"] in artwork:
|
||||
sources[artwork[package["name"]]] = package["apps"][0]["art_source"]
|
||||
@@ -245,12 +243,12 @@ class CollectionTests(unittest.TestCase):
|
||||
expected_children.append((
|
||||
descriptor["id"], descriptor["title"], descriptor["name"],
|
||||
ledger[descriptor["name"]]["version"], cover.get("caption", ""),
|
||||
cover.get("action"), tuple(app["requires"]), app["shared_code"],
|
||||
cover.get("action"), tuple(app["requires"]),
|
||||
))
|
||||
self.assertEqual([(
|
||||
child["id"], child["title"], child["expected_id"], child["version"],
|
||||
child.get("cover", {}).get("caption", ""), child.get("cover", {}).get("action"),
|
||||
tuple(child.get("dependencies", [])), child.get("shared_code", False),
|
||||
tuple(child.get("dependencies", [])),
|
||||
) for child in catalog["children"]], expected_children)
|
||||
self.assertEqual([(p["name"], p["id"], p["children"]) for p in packages],
|
||||
[(package["name"], package["id"],
|
||||
@@ -288,9 +286,12 @@ class CollectionTests(unittest.TestCase):
|
||||
(library / "sources.json").write_text(json.dumps(sources))
|
||||
|
||||
def stage_four_leaf_wurm_fixture(self):
|
||||
ledger_path = self.root / "apps/versions.json"
|
||||
ledger = json.loads(ledger_path.read_text())
|
||||
registration = self.root / 'games.json'
|
||||
value = json.loads(registration.read_text())
|
||||
value.pop('artwork', None)
|
||||
value.get('screenshots', {}).pop('wurm', None)
|
||||
registration.write_text(json.dumps(value))
|
||||
source = self.root / "fixture-packages/wurm"
|
||||
(source / "editor").mkdir(parents=True)
|
||||
@@ -303,12 +304,13 @@ class CollectionTests(unittest.TestCase):
|
||||
|
||||
(source / "catalog.json").write_text(json.dumps({
|
||||
"id": "xyz.waozi.wurm", "name": "wurm", "title": "Apfelwurm",
|
||||
"kind": "game", "contract_version": 1, "module_api": 2, "host_api": 41,
|
||||
"kind": "game", "contract_version": 1, "module_api": 2,
|
||||
"host_api": ledger["node_apps"]["wurm"]["host_api"],
|
||||
"harnesses": ["arcade"], "preview": "assets/wurm-preview.png",
|
||||
}))
|
||||
(source / "editor/catalog.json").write_text(json.dumps({
|
||||
"id": "xyz.waozi.wurm-editor", "name": "wurm-editor", "title": "Apfelwurm Editor",
|
||||
"kind": "game", "contract_version": 1, "module_api": 2, "host_api": 41,
|
||||
"kind": "game", "contract_version": 1, "module_api": 2, "host_api": 43,
|
||||
"harnesses": ["arcade"], "preview": "assets/wurm-editor-preview.png",
|
||||
}))
|
||||
images = {
|
||||
@@ -340,11 +342,9 @@ class CollectionTests(unittest.TestCase):
|
||||
for name, key in (("wurm", "preview"), ("wurm", "portrait"),
|
||||
("wurm-editor", "preview"), ("wurm-editor", "portrait")):
|
||||
self.add_library_copy(name, key, images[f"{name}-{key}"])
|
||||
ledger_path = self.root / "apps/versions.json"
|
||||
ledger = json.loads(ledger_path.read_text())
|
||||
ledger["node_apps"]["wurm-editor"] = {
|
||||
"id": "xyz.waozi.wurm-editor", "title": "Apfelwurm Editor", "version": "0.1.0",
|
||||
"sequence": 1, "host_api": 41,
|
||||
"sequence": 1, "host_api": 43,
|
||||
}
|
||||
ledger_path.write_text(json.dumps(ledger))
|
||||
resolver = self.root / "scripts/ziran.sh"
|
||||
@@ -386,7 +386,7 @@ class CollectionTests(unittest.TestCase):
|
||||
self.assertEqual(children["xyz.waozi.wurm"]["cover"]["caption"], "Classic")
|
||||
self.assertEqual(children["xyz.waozi.wurm-editor"]["cover"]["caption"], "Editor")
|
||||
self.assertEqual(children["xyz.waozi.wurm-editor"]["dependencies"], ["xyz.waozi.wurm"])
|
||||
self.assertFalse(children["xyz.waozi.wurm-editor"].get("shared_code", False))
|
||||
self.assertNotIn("shared_code", children["xyz.waozi.wurm-editor"])
|
||||
self.assertEqual(children["xyz.waozi.wurm-editor"]["resources"], [{
|
||||
"dependency": "xyz.waozi.wurm", "path": "assets/wurm/classic/",
|
||||
"source": "assets/wurm-preview.png"}])
|
||||
@@ -451,7 +451,16 @@ class CollectionTests(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'Invalid artwork package'):
|
||||
self.stage()
|
||||
|
||||
def test_every_library_cover_uses_a_bounded_thumbnail(self):
|
||||
def test_library_covers_use_original_painted_art(self):
|
||||
approved = json.loads((ROOT / 'tests/library_art_sources.json').read_text())
|
||||
sources = json.loads((self.root / 'assets/arcade/library/sources.json').read_text())
|
||||
for game in ('shovey', 'wurm', 'choano'):
|
||||
for view in ('portrait', 'landscape'):
|
||||
name = game + '-' + view
|
||||
self.assertEqual(sources[name]['source_sha256'], approved[name])
|
||||
self.assertNotIn('screenshots', json.loads((self.root / 'games.json').read_text()))
|
||||
|
||||
def test_library_heroes_are_bounded_and_editor_art_stays_small(self):
|
||||
catalog, packages = builder.stage(self.root, self.controller, self.controller_digest, self.output)
|
||||
children = {child['id']: child for child in catalog['children']}
|
||||
for package in packages:
|
||||
@@ -466,19 +475,16 @@ class CollectionTests(unittest.TestCase):
|
||||
with self.subTest(app=child['id'], image=key):
|
||||
with Image.open(io.BytesIO(original)) as source:
|
||||
with Image.open(self.output / child['cover'][key]) as thumbnail:
|
||||
limit = 512 if key == 'logo' else 640
|
||||
limit = 256 if app['internal'] or key == 'logo' else (1600 if key == 'landscape' else 1080)
|
||||
self.assertLessEqual(max(thumbnail.size), limit)
|
||||
self.assertLessEqual(thumbnail.width, source.width)
|
||||
self.assertLessEqual(thumbnail.height, source.height)
|
||||
expected_ratio = source.width / source.height
|
||||
if key == 'portrait':
|
||||
expected_ratio = max(2 / 3, expected_ratio)
|
||||
expected_ratio = 2 / 3 if key == 'portrait' else 16 / 9 if key == 'landscape' else source.width / source.height
|
||||
if app['internal']: expected_ratio = source.width / source.height
|
||||
self.assertAlmostEqual(thumbnail.width / thumbnail.height,
|
||||
expected_ratio, delta=0.01)
|
||||
expected_ratio, delta=(1 + expected_ratio) / thumbnail.height)
|
||||
self.assertIn(thumbnail.mode, ('RGB', 'RGBA'))
|
||||
# Opaque cover art is a JPEG; transparency stays PNG.
|
||||
self.assertEqual(thumbnail.format, 'JPEG' if key != 'logo' and
|
||||
thumbnail.mode == 'RGB' else 'PNG')
|
||||
self.assertEqual(thumbnail.format, 'WEBP')
|
||||
|
||||
def test_editor_download_reuses_verified_shovey_assets(self):
|
||||
catalog = self.stage()
|
||||
@@ -631,11 +637,11 @@ class LibraryThumbnailTests(unittest.TestCase):
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
contents, suffix = artist.small_copy(data.getvalue(), 'portrait')
|
||||
self.assertEqual(suffix, '.jpg')
|
||||
self.assertEqual(suffix, '.webp')
|
||||
with Image.open(io.BytesIO(contents)) as thumbnail:
|
||||
self.assertEqual(thumbnail.size, (427, 640))
|
||||
self.assertEqual(thumbnail.size, (720, 1080))
|
||||
# The real card's centred cover fit now leaves the title intact.
|
||||
red, green, blue = thumbnail.getpixel((213, 85))
|
||||
red, green, blue = thumbnail.getpixel((360, 144))
|
||||
self.assertGreater(red, 200)
|
||||
self.assertGreater(green, 160)
|
||||
self.assertLess(blue, 60)
|
||||
@@ -647,47 +653,63 @@ class LibraryThumbnailTests(unittest.TestCase):
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
contents, suffix = artist.small_copy(data.getvalue(), 'portrait')
|
||||
self.assertEqual(suffix, '.jpg')
|
||||
self.assertEqual(suffix, '.webp')
|
||||
with Image.open(io.BytesIO(contents)) as thumbnail:
|
||||
self.assertEqual(thumbnail.format, 'JPEG')
|
||||
self.assertEqual(thumbnail.size, (480, 640))
|
||||
self.assertEqual(thumbnail.format, 'WEBP')
|
||||
self.assertEqual(thumbnail.size, (720, 1080))
|
||||
self.assertEqual(thumbnail.mode, 'RGB')
|
||||
self.assertIsNone(thumbnail.getcolors(256))
|
||||
|
||||
def test_gameplay_crop_removes_only_the_game_toolbar(self):
|
||||
source = Image.new('RGB', (1440, 900), (20, 100, 180))
|
||||
source.paste((240, 20, 220), (0, 0, 1440, 52))
|
||||
encoded = io.BytesIO()
|
||||
source.save(encoded, 'PNG')
|
||||
contents, _ = artist.small_copy(encoded.getvalue(), 'landscape', crop_top=52)
|
||||
with Image.open(io.BytesIO(contents)) as cover:
|
||||
self.assertEqual(cover.size, (1440, 810))
|
||||
red, green, blue = cover.getpixel((720, 0))
|
||||
self.assertLess(red, 40)
|
||||
self.assertGreater(blue, 150)
|
||||
self.assertEqual(source.getpixel((720, 0)), (240, 20, 220))
|
||||
|
||||
def test_logo_retains_transparency(self):
|
||||
source = Image.new('RGBA', (1200, 400), (45, 155, 90, 0))
|
||||
source.paste((200, 35, 100, 255), (100, 50, 1100, 350))
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
contents, suffix = artist.small_copy(data.getvalue(), 'logo')
|
||||
self.assertEqual(suffix, '.png')
|
||||
self.assertEqual(suffix, '.webp')
|
||||
with Image.open(io.BytesIO(contents)) as thumbnail:
|
||||
self.assertEqual(thumbnail.size, (512, 171))
|
||||
self.assertEqual(thumbnail.size, (256, 85))
|
||||
self.assertEqual(thumbnail.mode, 'RGBA')
|
||||
self.assertEqual(thumbnail.getpixel((0, 0))[3], 0)
|
||||
self.assertEqual(thumbnail.getpixel((256, 85))[3], 255)
|
||||
self.assertEqual(thumbnail.getpixel((128, 42))[3], 255)
|
||||
|
||||
def test_small_covers_are_not_enlarged(self):
|
||||
source = Image.new('RGB', (120, 180), (25, 50, 75))
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
contents, suffix = artist.small_copy(data.getvalue(), 'portrait')
|
||||
self.assertEqual(suffix, '.jpg')
|
||||
self.assertEqual(suffix, '.webp')
|
||||
with Image.open(io.BytesIO(contents)) as thumbnail:
|
||||
self.assertEqual(thumbnail.size, (120, 180))
|
||||
|
||||
def test_small_transparent_art_is_not_reencoded(self):
|
||||
def test_small_transparent_art_keeps_exact_pixels(self):
|
||||
source = Image.new('RGBA', (120, 60), (25, 50, 75, 128))
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
self.assertEqual(artist.small_copy(data.getvalue(), 'logo'), (data.getvalue(), '.png'))
|
||||
contents, suffix = artist.small_copy(data.getvalue(), 'logo')
|
||||
self.assertEqual(suffix, '.webp')
|
||||
with Image.open(io.BytesIO(contents)) as thumbnail:
|
||||
self.assertEqual(thumbnail.tobytes(), source.tobytes())
|
||||
|
||||
def test_thin_logos_keep_at_least_one_pixel(self):
|
||||
source = Image.new('RGBA', (4096, 1), (25, 50, 75, 255))
|
||||
data = io.BytesIO()
|
||||
source.save(data, 'PNG')
|
||||
with Image.open(io.BytesIO(artist.small_copy(data.getvalue(), 'logo')[0])) as thumbnail:
|
||||
self.assertEqual(thumbnail.size, (512, 1))
|
||||
self.assertEqual(thumbnail.size, (256, 1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Exercise the real shared library and both unchanged games privately."""
|
||||
"""Exercise the real shared library and normal game titles and console navigation privately."""
|
||||
import argparse
|
||||
import contextlib
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
@@ -19,14 +19,12 @@ LEVEL_UPDATES = 'Download new levels when they come out?'
|
||||
|
||||
def answer_library_question(driver):
|
||||
"""Consent to the loopback library, keeping bundled game levels."""
|
||||
deadline = time.monotonic() + 60
|
||||
while time.monotonic() < deadline:
|
||||
if driver.find(label='Connect', role='button', visible=True):
|
||||
driver.press(label='Connect', role='button')
|
||||
break
|
||||
if driver.find(label='Shovey', role='button', visible=True):
|
||||
break
|
||||
driver.wait_idle(frames=3)
|
||||
question = 'Allow fetching content and automatic app updates?'
|
||||
driver.wait(label=question, role='text')
|
||||
driver.wait(label='The app library, previews and the apps you’ve downloaded stay up to date automatically.', role='text')
|
||||
driver.wait(label='Stay offline', role='button')
|
||||
driver.press(label='Allow', role='button')
|
||||
driver.wait_gone(label=question, role='text')
|
||||
driver.wait(label='Shovey', role='button', timeout=60)
|
||||
if driver.find(label=LEVEL_UPDATES, role='text'):
|
||||
driver.press(label='Not now', role='button')
|
||||
@@ -48,11 +46,58 @@ def answer_level_updates(driver, timeout=20):
|
||||
return
|
||||
time.sleep(0.05)
|
||||
|
||||
def campaign_progress(data):
|
||||
# Keep unlocks/completions and the player/move state, allowing decorative
|
||||
# animals to animate independently while an installed game is open.
|
||||
value = data.decode()
|
||||
assert value[:2] in ("C2", "C3", "C4", "C5", "C6")
|
||||
start = value.index("P")
|
||||
state = value[start:]
|
||||
assert state[:2] in ("P1", "P2", "P3")
|
||||
return value[:start], state[:32]
|
||||
|
||||
|
||||
def enter_shovey_play(driver):
|
||||
"""Use the game's normal title and, where present, its world map."""
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
driver.press(label='Play', role='button')
|
||||
deadline = time.monotonic() + 30
|
||||
while time.monotonic() < deadline:
|
||||
if driver.find(key=20105, visible=True):
|
||||
driver.press(key=33001, role='button')
|
||||
driver.press(key=20122, role='button')
|
||||
return
|
||||
if driver.find(label='Restart', role='button') or driver.find(label=LEVEL_UPDATES, role='text'):
|
||||
return
|
||||
if driver.find(label='Continue', role='button'):
|
||||
driver.press(label='Continue', role='button')
|
||||
return
|
||||
time.sleep(.05)
|
||||
raise driver._failure('Shovey did not enter its normal map or gameplay')
|
||||
|
||||
|
||||
def enter_wurm_play(driver):
|
||||
"""The title opens the stage chooser, whose Play starts the game."""
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
deadline = time.monotonic() + 30
|
||||
while time.monotonic() < deadline:
|
||||
if driver.find(label='Pause', role='button'):
|
||||
return
|
||||
if driver.find(label='How do you want to move?', role='text'):
|
||||
driver.press(label='Swipe', role='button')
|
||||
elif driver.find(label='Play', role='button'):
|
||||
driver.press(label='Play', role='button')
|
||||
elif driver.find(label='Start', role='button'):
|
||||
driver.press(label='Start', role='button')
|
||||
time.sleep(.05)
|
||||
raise driver._failure('Apfelwurm did not enter play through its title and stages')
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def package_server(root):
|
||||
metadata = json.loads((root / 'build/arcade.json').read_text())
|
||||
by_digest = {entry['sha256']: entry for entry in metadata['children']}
|
||||
state = {'requests': [], 'corrupt_wurm': False, 'corrupt_shovey': False, 'offline': False}
|
||||
state = {'requests': [], 'corrupt_wurm': False, 'corrupt_shovey': False, 'offline': False, 'game_delay': 0}
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
@@ -68,6 +113,8 @@ def package_server(root):
|
||||
data = published.read_bytes()
|
||||
if (state['corrupt_wurm'] and entry.get('expected_id') == 'wurm') or (state['corrupt_shovey'] and entry.get('expected_id') == 'shovey'):
|
||||
data = data[:-1] + bytes([data[-1] ^ 1])
|
||||
if entry and state['game_delay']:
|
||||
time.sleep(state['game_delay'])
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Length', str(len(data)))
|
||||
self.end_headers()
|
||||
@@ -87,6 +134,7 @@ def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--binary", type=Path, required=True)
|
||||
parser.add_argument("--inbe-source", type=Path, required=True)
|
||||
parser.add_argument("--output", type=Path, help="Private test receipts and captures")
|
||||
args = parser.parse_args()
|
||||
assert int(os.environ["DISPLAY"].split(":")[-1].split(".")[0]) >= 400
|
||||
assert os.environ["YUE_DESKTOP_RECOVERY"] == "0"
|
||||
@@ -98,7 +146,7 @@ def main():
|
||||
def size_text(size):
|
||||
return f"{(size * 10 + 500000) // 1000000 / 10:.1f} MB"
|
||||
sizes = {name: size_text(entry['bytes']) for name, entry in by_name.items()}
|
||||
output = root / "build/collection-ui-test"
|
||||
output = args.output or root / "work/collection-ui-test"
|
||||
# The Classic heading counts its levels, which Shovey's level file lists.
|
||||
shovey = Path(subprocess.check_output([str(root / "scripts/ziran.sh"), "pkg", "path", "shovey"], text=True).strip())
|
||||
classic = len(json.loads((shovey / "levels/approved.json").read_text())["levels"])
|
||||
@@ -114,12 +162,20 @@ def main():
|
||||
child = subprocess.Popen([str(args.binary.resolve()), *arguments], cwd=root,
|
||||
env=os.environ | driver.environment() |
|
||||
{"ARCADE_DATA": str(profile), "ENTITY_DATA": str(profile / "entity"),
|
||||
"XDG_DATA_HOME": str(profile / "share"),
|
||||
"XDG_CONFIG_HOME": str(profile / "config"),
|
||||
"XDG_CACHE_HOME": str(profile / "cache"),
|
||||
"LANG": "en_US.UTF-8", "ARCADE_PACKAGE_ORIGIN": origin},
|
||||
stdout=log, stderr=subprocess.STDOUT)
|
||||
driver.attach(child, log_path)
|
||||
try:
|
||||
driver.tree()
|
||||
yield child
|
||||
except Exception:
|
||||
driver.tree()
|
||||
(output / (name + '-failure-tree.json')).write_text(json.dumps(driver.last, indent=2) + '\n')
|
||||
capture(child, name + '-failure')
|
||||
raise
|
||||
finally:
|
||||
if child.poll() is None:
|
||||
child.terminate()
|
||||
@@ -141,33 +197,52 @@ def main():
|
||||
|
||||
def grid(child, name, phone=False):
|
||||
driver.wait_idle(frames=20)
|
||||
driver.wait(label="Arcade", role="text")
|
||||
assert not driver.find(label="Arcade", role="text"), "Home has no app-name header"
|
||||
assert not driver.find(label="Chess"), "Chess is temporarily disabled"
|
||||
assert not driver.find(label="Monkey"), "Monkey does not belong in Arcade"
|
||||
assert not driver.find(label="Next", role="button"), "Arcade must open on its app grid"
|
||||
classic_card = driver.wait(label="Shovey", role="button")
|
||||
editor_card = driver.wait(label="Shovey Editor", role="button")
|
||||
assert classic_card['y'] == editor_card['y'], "Apps must share a grid row"
|
||||
assert classic_card['x'] != editor_card['x']
|
||||
if phone:
|
||||
# Phones show small covers, two or three a row.
|
||||
wurm_card = driver.wait(label='Apfelwurm', role='button')
|
||||
assert wurm_card['y'] == classic_card['y'], 'A phone row holds all three covers'
|
||||
assert 100 <= classic_card['width'] < 200, 'Phone covers must be small cards'
|
||||
else:
|
||||
assert classic_card['width'] >= 200 and classic_card['height'] >= 350
|
||||
covers = [node for node in driver.find(role="button", visible=True)
|
||||
if node['height'] > 100 and node['selected']]
|
||||
assert len(covers) == 1
|
||||
cover = covers[0]
|
||||
ratio = cover['width'] / cover['height']
|
||||
assert abs(ratio - (2 / 3 if phone else 16 / 9)) < .02, (name, ratio)
|
||||
assert cover['width'] >= (250 if phone else 200)
|
||||
assert cover['selected'], "A console always has a focused game"
|
||||
assert not driver.find(label='Play', role='button')
|
||||
assert not driver.find(label='Open', role='button')
|
||||
for label in ('Shovey', 'Shovey Editor', 'Apfelwurm'):
|
||||
assert driver.find(label=label, role='text'), 'Every library cover shows its declared title'
|
||||
driver.wait(label='Apfelwurm', role='button', visible=False)
|
||||
smallest = (100, 140) if phone else (180, 200)
|
||||
covers = [node for node in driver.find(role='image', visible=True)
|
||||
if node['width'] >= smallest[0] and node['height'] >= smallest[1]]
|
||||
assert len(covers) >= 2, "Apps must use large title-screen artwork"
|
||||
for label in ('Shovey', 'Apfelwurm', 'Choano'):
|
||||
assert not driver.find(label=label, role='text'), "Artwork replaces cover captions"
|
||||
if not phone or label == cover['label']:
|
||||
assert driver.find(label=label, role='button'), "Names stay accessible in the shelf"
|
||||
assert not driver.find(label='Shovey Editor', role='button'), 'Editors open from inside their game'
|
||||
assert not driver.find(label='Apfelwurm Editor', role='button')
|
||||
assert len([node for node in driver.find(role='image', visible=True)
|
||||
if node['width'] >= 150 and node['height'] >= 100]) >= 1
|
||||
capture(child, name)
|
||||
with Image.open(output / (name + ".png")) as image:
|
||||
assert len(image.convert("RGB").getcolors(1000000) or []) > 100, "App icons were not painted"
|
||||
assert len(image.convert("RGB").getcolors(1000000) or []) > 100, "Cover artwork was not painted"
|
||||
# Full viewport art must cover the former light host reservation.
|
||||
top = image.convert('RGB').crop((0, 0, image.width // 2, 88))
|
||||
pixels = list(top.resize((30, 10)).getdata())
|
||||
clear = sum(all(abs(a-b) <= 3 for a,b in zip(pixel, (248, 250, 252))) for pixel in pixels)
|
||||
assert clear < len(pixels) // 2, "Home leaves a light header band"
|
||||
assert len(set(pixels)) > 20, "Focused art must color the background"
|
||||
|
||||
def open_game(label):
|
||||
order = ['Shovey', 'Apfelwurm', 'Choano']
|
||||
current = next(n for n in driver.tree() if n['kind']=='button' and n['selected'] and n['height']>100)
|
||||
while current['label'] != label:
|
||||
driver.key('right' if order.index(current['label']) < order.index(label) else 'left')
|
||||
driver.wait_idle(frames=20)
|
||||
current = next(n for n in driver.tree() if n['kind']=='button' and n['selected'] and n['height']>100)
|
||||
driver.press(key=current['key'],role='button')
|
||||
|
||||
def finish_download(label):
|
||||
entry = next(e for e in by_name.values() if e['title']==label)
|
||||
wait(lambda: (profile/'resources/downloads'/(entry['sha256']+'.zx')).exists() and
|
||||
not driver.find(label='Downloading',role='text'), 'Download did not finish on shelf')
|
||||
assert driver.find(label=label,role='button'), 'Download left the shelf'
|
||||
open_game(label)
|
||||
|
||||
def primary_download(label='Download'):
|
||||
driver.wait(label=label, role='button')
|
||||
@@ -177,31 +252,6 @@ def main():
|
||||
|
||||
with package_server(root) as (origin, server), tempfile.TemporaryDirectory(prefix="profile-", dir=output) as temporary:
|
||||
profile = Path(temporary)
|
||||
dependency_profile = profile / 'editor-first'
|
||||
with application(dependency_profile, 'editor-dependencies') as child:
|
||||
answer_library_question(driver)
|
||||
driver.press(label='Shovey Editor', role='button')
|
||||
driver.wait(label='Shovey (required) · ' + sizes['shovey'], role='text')
|
||||
driver.wait(label='Shovey Editor · ' + sizes['shovey-editor'], role='text')
|
||||
total = size_text(by_name['shovey']['bytes'] + by_name['shovey-editor']['bytes'])
|
||||
driver.wait(label='Download size: ' + total, role='text')
|
||||
capture(child, 'editor-download-plan')
|
||||
driver.press(label='Cancel', role='button')
|
||||
assert not games & set(server['requests']), 'Dependency consent must precede every download'
|
||||
driver.press(label='Shovey Editor', role='button')
|
||||
server['corrupt_shovey'] = True
|
||||
primary_download()
|
||||
driver.wait(label='Try again', role='button', timeout=60)
|
||||
assert not driver.find(label='New level', role='text'), 'An editor must not open with a corrupt dependency'
|
||||
server['corrupt_shovey'] = False
|
||||
primary_download('Try again')
|
||||
driver.wait(label='New level', role='text', timeout=60)
|
||||
capture(child, 'editor-shared-assets')
|
||||
assert server['requests'].count(by_name['shovey']['sha256']) == 2
|
||||
assert server['requests'].count(by_name['shovey-editor']['sha256']) == 1
|
||||
assert len([digest for digest in server['requests'] if digest in games]) == 3, 'Retry must reuse the already downloaded editor'
|
||||
assert by_name['shovey-editor']['bytes'] < by_name['shovey']['bytes'], 'The editor must carry only its additions'
|
||||
server['requests'].clear()
|
||||
# Disabling an entry must leave a person's older Chess save untouched.
|
||||
chess = profile / "games/inbe.chess/records/computer"
|
||||
chess.parent.mkdir(parents=True)
|
||||
@@ -209,14 +259,6 @@ def main():
|
||||
# Active play stays on this device; account sync shares completions.
|
||||
record = profile / "games/arcade.shovey/records/local.campaign"
|
||||
|
||||
def progress(data):
|
||||
# Unlocks, completion marks and the board in play.
|
||||
value = data.decode()
|
||||
assert value[:2] in ("C2", "C3", "C4", "C5")
|
||||
start = value.index("P")
|
||||
state = value[start:]
|
||||
assert state[:2] in ("P1", "P2", "P3")
|
||||
return value[:start], state[:32]
|
||||
|
||||
with application(profile, "grid") as child:
|
||||
# A fresh profile asks for consent before it shows the library.
|
||||
@@ -224,105 +266,123 @@ def main():
|
||||
window = subprocess.check_output(['xdotool', 'search', '--onlyvisible', '--pid', str(child.pid)], text=True).splitlines()[0]
|
||||
subprocess.run(['xdotool', 'windowsize', window, '480', '820'], check=True)
|
||||
grid(child, "apps-portrait", phone=True)
|
||||
driver.key('right')
|
||||
driver.wait_idle(frames=20)
|
||||
editor = [n for n in driver.find(label='Apfelwurm', role='button') if n['height'] > 100]
|
||||
assert editor and editor[0]['selected'], 'Right selects the next game'
|
||||
driver.key('left')
|
||||
driver.wait_idle(frames=20)
|
||||
subprocess.run(['xdotool', 'windowsize', window, '1120', '700'], check=True)
|
||||
grid(child, "apps-landscape")
|
||||
subprocess.run(['xdotool', 'windowsize', window, '900', '420'], check=True)
|
||||
grid(child, "apps-short-landscape")
|
||||
selected = [n for n in driver.find(role='button') if n['selected'] and n['height'] > 100][0]
|
||||
cx, cy = UiDriver.center(selected)
|
||||
driver.pointer(cx, cy, wheel=-1)
|
||||
driver.wait_idle(frames=20)
|
||||
assert any(n['selected'] and n['height'] > 100 for n in driver.find(label='Apfelwurm', role='button')), 'Wheel selects the next game'
|
||||
driver.drag((cx - 100, cy), (cx + 100, cy))
|
||||
driver.wait_idle(frames=20)
|
||||
assert any(n['selected'] and n['height'] > 100 for n in driver.find(label='Shovey', role='button')), 'Swipe returns to the previous game'
|
||||
assert not driver.find(role='modal'), 'A swipe selects without opening an install dialog'
|
||||
subprocess.run(['xdotool', 'windowsize', window, '480', '820'], check=True)
|
||||
grid(child, "apps-portrait-return", phone=True)
|
||||
assert not games & set(server['requests']), "Covers must not predownload games"
|
||||
# Covers show only the art; the download dialog names the size.
|
||||
cover_sizes = dict(sizes, **{'shovey-editor': size_text(by_name['shovey']['bytes'] + by_name['shovey-editor']['bytes'])})
|
||||
for text in cover_sizes.values():
|
||||
assert not driver.find(label=text, role='text'), "Covers must not show download sizes"
|
||||
driver.press(label='Profile', role='button')
|
||||
(output / 'before-profile-tree.json').write_text(json.dumps(driver.tree(), indent=2))
|
||||
reply = driver.press(label='Profile', role='button')
|
||||
(output / 'profile-press.json').write_text(json.dumps(reply, indent=2))
|
||||
driver.wait(label='Account', role='text')
|
||||
capture(child, 'arcade-profile')
|
||||
driver.press(label='Leaderboard', role='button')
|
||||
driver.wait(label='Leaderboard', role='text')
|
||||
driver.wait(label='No leaderboard data yet.', role='text')
|
||||
capture(child, 'leaderboard-empty')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label="Back", role="button")
|
||||
driver.wait(label='Shovey', role='button')
|
||||
assert not [path for path in (profile / 'resources/downloads').glob('*.zx') if path.stem in games]
|
||||
driver.press(label="Shovey", role="button")
|
||||
driver.wait(label='Cancel', role='button')
|
||||
driver.press(label='Cancel', role='button')
|
||||
assert not games & set(server['requests']), 'Cancel must download nothing'
|
||||
driver.press(label="Shovey", role="button")
|
||||
primary_download()
|
||||
server['game_delay'] = 3
|
||||
open_game('Shovey')
|
||||
driver.wait(label='Downloading',role='text')
|
||||
assert driver.find(label='Apfelwurm',role='button'), 'Download must keep the carousel available'
|
||||
assert not driver.find(role='modal'), 'Transfer progress must not capture modal focus'
|
||||
assert any(n['selected'] and n['height']>100 for n in driver.find(label='Shovey',role='button'))
|
||||
finish_download('Shovey')
|
||||
server['game_delay'] = 0
|
||||
driver.wait(label='Play',role='button',timeout=60)
|
||||
assert not driver.find(label="Restart", role="button"), "A game opens its own title"
|
||||
capture(child, "shovey-title")
|
||||
enter_shovey_play(driver)
|
||||
driver.wait(label=f"Level 1 / {classic}")
|
||||
answer_level_updates(driver)
|
||||
driver.wait(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")
|
||||
assert not driver.find(label="Play", role="button"), "Arcade must skip the second title screen"
|
||||
# Desktop input already chooses keyboard controls; touch hosts
|
||||
# still ask before the first level.
|
||||
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")
|
||||
driver.wait(label='Restart', role='button')
|
||||
assert not driver.find(label="Play", role="button"), "Play enters gameplay from the game title"
|
||||
assert len(driver.find(label="Back", role="button", visible=True)) == 1
|
||||
driver.press(label="Levels", role="button")
|
||||
driver.wait(label="Continue", role="button")
|
||||
back = driver.wait(label="Back", role="button", visible=True)
|
||||
assert back['width'] >= 100 and back['height'] >= 48
|
||||
scroll = driver.wait(role="scroll")
|
||||
driver.pointer(*UiDriver.center(scroll), wheel=-200)
|
||||
driver.wait_idle(frames=20)
|
||||
assert driver.find(label="Back", role="button", visible=True)[0]['y'] == back['y']
|
||||
driver.press(label="Back", role="button")
|
||||
driver.wait(label="Restart", role="button")
|
||||
driver.press(label="Levels", role="button")
|
||||
driver.wait(label="Continue", role="button")
|
||||
driver.key("escape")
|
||||
driver.wait(label="Restart", role="button")
|
||||
home = driver.find(label='Arcade', role='button', visible=True)[0]
|
||||
back = driver.find(label='Back', role='button', visible=True)[0]
|
||||
assert back['y'] >= home['y'] + home['height'], 'Home must not overlap game navigation'
|
||||
capture(child, "classic-playing")
|
||||
for direction in ("left", "right", "up", "down"):
|
||||
driver.key(direction)
|
||||
driver.wait_idle(frames=5)
|
||||
saved = wait(lambda: record.read_bytes() if record.exists() else None, "Classic did not save")
|
||||
driver.press(label="Back", role="button")
|
||||
driver.wait(label="Shovey Editor", role="button")
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.press(label='Leaderboard', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
assert not driver.find(label='Apfelwurm', role='button'), 'An undownloaded game has a board'
|
||||
assert not driver.find(label='Shovey Editor', role='button'), 'An unranked editor has a board'
|
||||
capture(child, 'leaderboard-installed')
|
||||
state = profile / 'resources/state/arcade.shovey.json'
|
||||
state.parent.mkdir(parents=True, exist_ok=True)
|
||||
state.write_text('{"v":1,"installed":0,"favorite":0}')
|
||||
driver.wait(label='No leaderboard data yet.', role='text')
|
||||
assert not driver.find(label='Shovey', role='button'), 'A retained score kept an uninstalled board visible'
|
||||
state.write_text('{"v":1,"installed":1,"favorite":0}')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Shovey Editor', role='button')
|
||||
driver.wait(label="Play", role="button")
|
||||
driver.key(290)
|
||||
driver.wait(key=50400,visible=True)
|
||||
saved = wait(lambda: record.read_bytes() if record.exists() else None, "Classic did not save")
|
||||
assert not driver.find(label=sizes["shovey"], role="text"), "Installed games must omit their download size"
|
||||
driver.press(label="Shovey Editor", role="button")
|
||||
open_game('Shovey')
|
||||
driver.wait(label='Next',role='button')
|
||||
driver.press(label='Next',role='button')
|
||||
driver.wait_idle(frames=20)
|
||||
driver.press(label='Open',role='button')
|
||||
driver.wait(label='Download size: ' + sizes['shovey-editor'], role='text')
|
||||
primary_download()
|
||||
assert server['requests'].count(by_name['shovey']['sha256']) == 1, 'Installed dependencies must not download again'
|
||||
# The editor opens on a blank board.
|
||||
driver.wait(label="New level", role="text")
|
||||
driver.press(label="Levels", role="button")
|
||||
driver.wait(label="Story levels", role="text")
|
||||
driver.wait(label="Your levels", role="text")
|
||||
back = driver.wait(label="Back", role="button", visible=True)
|
||||
assert back['width'] >= 100 and back['height'] >= 48
|
||||
assert back['width'] >= 64 and back['height'] >= 40
|
||||
driver.press(label="Back", role="button")
|
||||
driver.wait(label="New level", role="text")
|
||||
capture(child, "editor-open")
|
||||
driver.key("escape")
|
||||
driver.wait(label="Shovey Editor", role="button")
|
||||
driver.wait(label='Open',role='button')
|
||||
driver.press(label='Previous',role='button')
|
||||
driver.wait(label='Play',role='button')
|
||||
assert not driver.find(key=50400,visible=True), 'Editor Back returns to the game title'
|
||||
driver.key(290)
|
||||
driver.wait(key=50400,visible=True)
|
||||
window = subprocess.check_output(["xdotool", "search", "--onlyvisible", "--pid", str(child.pid)], text=True).splitlines()[0]
|
||||
subprocess.run(["xdotool", "windowsize", window, "900", "540"], check=True)
|
||||
grid(child, "apps-landscape")
|
||||
server['corrupt_wurm'] = True
|
||||
driver.press(label='Apfelwurm', role='button')
|
||||
primary_download()
|
||||
driver.wait(label='Try again', role='button', timeout=60)
|
||||
open_game('Apfelwurm')
|
||||
driver.wait(label='Download failed',role='text',timeout=60)
|
||||
assert not driver.find(label='Pause', role='button'), 'Unverified bytes must never run'
|
||||
server['corrupt_wurm'] = False
|
||||
primary_download('Try again')
|
||||
# The hosted player opens its title before its first steering choice.
|
||||
open_game('Apfelwurm')
|
||||
finish_download('Apfelwurm')
|
||||
# Both the built-in editor and retained add-on open inside Wurm.
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
driver.press(label='Play', role='button')
|
||||
driver.wait(label='How do you want to move?', role='text')
|
||||
driver.press(label='Swipe', role='button')
|
||||
driver.press(label='Level editor', role='button')
|
||||
driver.wait(label='My levels', role='button')
|
||||
driver.press(label='Apfelwurm Editor', role='button')
|
||||
driver.wait(label='Cancel', role='button')
|
||||
primary_download()
|
||||
driver.wait(label='My levels', role='button', timeout=60)
|
||||
assert not driver.find(label='Apfelwurm Editor', role='button'), 'A legacy add-on must not link to itself'
|
||||
driver.key('escape')
|
||||
driver.wait(label='Apfelwurm Editor', role='button')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Play', role='button')
|
||||
enter_wurm_play(driver)
|
||||
driver.wait(label='Pause', role='button')
|
||||
capture(child, 'wurm-playing')
|
||||
driver.press(label='Pause', role='button')
|
||||
@@ -330,22 +390,47 @@ def main():
|
||||
driver.press(label='Back to title', role='button')
|
||||
driver.wait(label='Play', role='button')
|
||||
capture(child, 'wurm-title')
|
||||
driver.key('escape')
|
||||
driver.key(290)
|
||||
driver.wait(label='Shovey', role='button')
|
||||
for entry in json.loads((root / 'build/arcade.json').read_text())['children']:
|
||||
open_game('Choano')
|
||||
finish_download('Choano')
|
||||
driver.wait(label='Play', role='button', timeout=60)
|
||||
assert not driver.find(label='Pause', role='button'), 'Choano keeps its own title screen'
|
||||
driver.press(label='Play', role='button')
|
||||
if driver.find(label='Swipe', role='button'):
|
||||
driver.press(label='Swipe', role='button')
|
||||
driver.wait(label='Pause', role='button', timeout=60)
|
||||
driver.key('right')
|
||||
driver.press(label='Pause', role='button')
|
||||
driver.press(label='Title screen', role='button')
|
||||
driver.wait(label='New game', role='button')
|
||||
capture(child, 'choano-title')
|
||||
subprocess.run(['xdotool', 'windowsize', window, '480', '820'], check=True)
|
||||
driver.wait_idle(frames=15)
|
||||
driver.press(label='Arcade', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
exercised = [by_name[name] for name in ('shovey', 'shovey-editor', 'wurm', 'wurm-editor', 'choano')]
|
||||
expected_downloads = {entry['sha256'] for entry in exercised}
|
||||
actual_downloads = {path.stem for path in (profile / 'resources/downloads').glob('*.zx') if path.stem in games}
|
||||
assert actual_downloads == expected_downloads, 'Only the games opened with consent may download'
|
||||
for entry in exercised:
|
||||
path = profile / 'resources/downloads' / (entry['sha256'] + '.zx')
|
||||
assert hashlib.sha256(path.read_bytes()).hexdigest() == entry['sha256']
|
||||
requested = list(server['requests'])
|
||||
server['offline'] = True
|
||||
with application(profile, "restore", "--app", "arcade.shovey"):
|
||||
driver.wait(label=f"Level 1 / {classic}")
|
||||
assert progress(record.read_bytes()) == progress(saved), "Classic progress changed on restart"
|
||||
assert server['requests'] == requested, 'A cached game must reopen offline without downloading'
|
||||
driver.wait(label="Play", role="button")
|
||||
assert not driver.find(label="Restart", role="button"), "Offline reopen retains normal title entry"
|
||||
assert campaign_progress(record.read_bytes()) == campaign_progress(saved), "Classic progress changed on restart"
|
||||
# Allowed automatic library refresh may retry its metadata while
|
||||
# offline. Cached game/art bytes must never be requested again.
|
||||
cached_payloads = games | {json.loads((root / 'build/arcade.json').read_text())['art']['sha256']}
|
||||
assert not cached_payloads & set(server['requests'][len(requested):]), 'A cached game must reopen offline without downloading'
|
||||
assert chess.read_bytes() == b"existing private Chess save"
|
||||
assert not (profile / "inbe.db").exists()
|
||||
refused = subprocess.run([str(args.binary.resolve()), "--app", "chess"], env=os.environ | {"ARCADE_DATA": str(profile)}, capture_output=True, timeout=10)
|
||||
assert refused.returncode == 1 and b"unknown game" in refused.stderr
|
||||
print("Arcade: rounded covers, download consent/cancel, digest failure/retry, Shovey and Apfelwurm play, Back, rotation, offline reopen and retained saves passed")
|
||||
print("Arcade: console covers, selection and in-place downloads, digest failure/retry, all three game titles/play, in-game editors, Back, rotation, offline reopen and retained saves passed")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
"""Real console home, artwork pixels, rotation, input and profile roundtrip privately."""
|
||||
import argparse, contextlib, json, os, subprocess, sys, tempfile, time
|
||||
from pathlib import Path
|
||||
from PIL import Image, ImageOps, ImageChops, ImageStat
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--binary', type=Path, default=root / 'build/arcade')
|
||||
parser.add_argument('--inbe-source', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
assert int(os.environ['DISPLAY'].split(':')[-1].split('.')[0]) >= 400
|
||||
assert os.environ['YUE_DESKTOP_RECOVERY'] == '0'
|
||||
sys.path.insert(0, str(root / 'tests'))
|
||||
sys.path.insert(0, str(args.inbe_source / 'tests'))
|
||||
from collection_ui_test import package_server, answer_library_question
|
||||
from ui_driver import UiDriver
|
||||
out = root / 'backup/console-fixes/results'
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
driver = UiDriver(out / 'driver')
|
||||
metadata = json.loads((root / 'build/arcade.json').read_text())
|
||||
approved = json.loads((root / 'tests/library_art_sources.json').read_text())
|
||||
sources = json.loads((root / 'assets/arcade/library/sources.json').read_text())
|
||||
for name, digest in approved.items():
|
||||
assert sources[name]['source_sha256'] == digest, 'Cover replaced the original painted artwork: ' + name
|
||||
assert metadata['art']['bytes'] <= 2 * 1024 * 1024
|
||||
|
||||
def selected_cover():
|
||||
return next(n for n in driver.tree() if n['kind'] == 'button' and n['selected'] and n['height'] > 100)
|
||||
|
||||
def viewport_width():
|
||||
# Scenery shapes may extend past the window; the window-sized background starts at its origin.
|
||||
return max(n['width'] for n in driver.tree() if n['x'] == 0 and n['y'] == 0)
|
||||
|
||||
def tap_cover(label, mouse):
|
||||
cover = next(n for n in driver.find(label=label, role='button') if n['height'] > 100 and n['visible'])
|
||||
width = viewport_width()
|
||||
x = max(4, min(width - 4, cover['x'] + cover['width'] / 2))
|
||||
y = cover['y'] + cover['height'] / 2
|
||||
if mouse:
|
||||
# A real X11 click held like a person's: SDL sees the move, press and release.
|
||||
subprocess.run(['xdotool', 'mousemove', '--window', window, str(int(x)), str(int(y))], check=True)
|
||||
time.sleep(.25)
|
||||
subprocess.run(['xdotool', 'mousedown', '1'], check=True)
|
||||
time.sleep(.15)
|
||||
subprocess.run(['xdotool', 'mouseup', '1'], check=True)
|
||||
time.sleep(.3)
|
||||
else:
|
||||
driver.pointer(x, y)
|
||||
driver.pointer(x, y, down=True)
|
||||
driver.wait_idle(frames=2)
|
||||
driver.pointer(x, y, down=False)
|
||||
driver.release_pointer()
|
||||
driver.wait_idle(frames=20)
|
||||
|
||||
with package_server(root) as (origin, server), tempfile.TemporaryDirectory(dir=out) as temporary, (out / 'capture.log').open('w') as log:
|
||||
profile = Path(temporary)
|
||||
child = subprocess.Popen([str(args.binary.resolve())], cwd=root, env=os.environ | driver.environment() | {
|
||||
'ARCADE_DATA': str(profile), 'ENTITY_DATA': str(profile / 'entity'), 'XDG_DATA_HOME': str(profile / 'share'),
|
||||
'XDG_CONFIG_HOME': str(profile / 'config'), 'XDG_CACHE_HOME': str(profile / 'cache'),
|
||||
'LANG': 'en_US.UTF-8', 'ARCADE_PACKAGE_ORIGIN': origin}, stdout=log, stderr=subprocess.STDOUT)
|
||||
driver.attach(child, out / 'capture.log')
|
||||
try:
|
||||
answer_library_question(driver)
|
||||
art = json.loads((root / 'build/arcade.json').read_text())['art']['sha256']
|
||||
deadline = time.monotonic() + 60
|
||||
while not (profile / 'resources/downloads' / (art + '.zx')).exists():
|
||||
assert time.monotonic() < deadline, 'Library art did not download'
|
||||
time.sleep(.1)
|
||||
window = subprocess.check_output(['xdotool', 'search', '--onlyvisible', '--pid', str(child.pid)], text=True).splitlines()[0]
|
||||
assert int(subprocess.check_output(['xdotool', 'getwindowpid', window], text=True)) == child.pid
|
||||
for name, width, height in [('home-landscape', 1200, 720), ('home-portrait', 480, 820)]:
|
||||
subprocess.run(['xdotool', 'windowsize', window, str(width), str(height)], check=True)
|
||||
# Keep the whole window on the private screen so captures are never clipped.
|
||||
subprocess.run(['xdotool', 'windowmove', window, '0', '0'], check=True)
|
||||
deadline = time.monotonic() + 10
|
||||
while viewport_width() != width:
|
||||
assert time.monotonic() < deadline
|
||||
time.sleep(.05)
|
||||
driver.wait_idle(frames=30)
|
||||
nodes = driver.tree()
|
||||
assert not driver.find(label='Arcade', role='text'), 'No app-name header'
|
||||
assert not [n for n in nodes if n['kind'] in ('button', 'text') and 'Editor' in n['label']], 'Games only'
|
||||
for title in ('Shovey', 'Apfelwurm', 'Choano'):
|
||||
assert driver.find(label=title, role='button'), 'Accessible game name missing'
|
||||
assert not driver.find(label=title, role='text'), 'No captions under artwork'
|
||||
# Both orientations draw the same scenic pattern, never game art behind the covers.
|
||||
scenery = next(n for n in nodes if n['key'] == 50400)
|
||||
assert (scenery['x'], scenery['y'], scenery['width'], scenery['height']) == (0, 0, width, height)
|
||||
assert not any(n['key'] == 50021 for n in nodes), 'No full-screen game artwork behind the covers'
|
||||
assert not [n for n in nodes if n['role'] == 'image' and n['width'] >= width * .9 and n['height'] >= height * .9], 'No hero image'
|
||||
selected = [n for n in nodes if n['kind'] == 'button' and n['selected'] and n['height'] > 100]
|
||||
(out / 'latest-debug-tree.json').write_text(json.dumps(nodes,indent=2))
|
||||
assert len(selected) == 1, [(n['label'],n['selected'],n['width'],n['height']) for n in nodes if n['kind']=='button']
|
||||
selected = selected[0]
|
||||
assert abs(selected['width'] / selected['height'] - (16/9 if width > height else 2/3)) < .02
|
||||
covers = [n for n in nodes if n['role'] == 'image' and n['label'] in ('Shovey','Apfelwurm','Choano') and n['visible']]
|
||||
assert len(covers) >= 2, 'Real neighbouring covers must be visible'
|
||||
# The portrait carousel layout in landscape too: one large centred cover,
|
||||
# neighbours cut by the screen edges and the small cover markers below.
|
||||
assert abs(selected['x'] + selected['width'] / 2 - width / 2) < 2, 'Selected cover is centred'
|
||||
assert selected['width'] >= width * (.55 if width > height else .65)
|
||||
assert height * .15 < selected['y'] and selected['y'] + selected['height'] < height * .9
|
||||
neighbours = [n for n in covers if n['label'] != selected['label']]
|
||||
assert neighbours and all(n['x'] <= 0 or n['x'] + n['width'] >= width for n in neighbours), 'Neighbours peek in from the sides'
|
||||
assert all(abs(n['y'] + n['height'] / 2 - (selected['y'] + selected['height'] / 2)) < 2 for n in neighbours)
|
||||
markers = [n for n in nodes if 50300 <= n['key'] <= 50302 and n['role'] == 'image']
|
||||
assert len(markers) == 3 and all(n['y'] > selected['y'] + selected['height'] for n in markers)
|
||||
assert all(n['detail'].endswith(('landscape.webp' if width > height else 'portrait.webp')) for n in markers)
|
||||
for icon in ('profile', 'dew'):
|
||||
assert any(n['role'] == 'image' and n['detail'].endswith('/assets/hud/' + icon + '.webp') for n in nodes), 'Painted startup icon missing'
|
||||
subprocess.run(['import', '-window', window, str(out / (name + '.png'))], check=True)
|
||||
(out / (name + '-tree.json')).write_text(json.dumps(driver.tree(), indent=2))
|
||||
with Image.open(out / (name + '.png')) as im:
|
||||
rgb = im.convert('RGB')
|
||||
# The sky above the covers is the dusk scenic pattern, not a white band or game art.
|
||||
sky = ImageStat.Stat(rgb.crop((0, 0, width - 260, 80))).mean
|
||||
assert sky[2] > sky[0] + 15 and max(sky) < 170 and min(sky) > 12, ('Scenic sky must fill the top', sky)
|
||||
hills = ImageStat.Stat(rgb.crop((0, int(height * .93), width, height))).mean
|
||||
assert hills[1] > hills[0] and max(hills) < 140, ('Scenic hills must fill the bottom', hills)
|
||||
for cover in covers:
|
||||
x,y,w,h = (cover[k] for k in ('x','y','width','height'))
|
||||
crop = rgb.crop((max(0,x),max(0,y),min(width,x+w),min(height,y+h)))
|
||||
assert len(crop.getcolors(1000000) or []) > 100, 'A neighbour became a blank grey block'
|
||||
# Compare the rendered focused cover to the approved painted asset.
|
||||
view = 'landscape' if width > height else 'portrait'
|
||||
game = {'Shovey':'shovey', 'Apfelwurm':'wurm', 'Choano':'choano'}[selected['label']]
|
||||
asset = root / 'assets/arcade/library' / (game + '-' + view + '.webp')
|
||||
with Image.open(asset) as painting:
|
||||
expected = ImageOps.fit(painting.convert('RGB'), (round(selected['width']), round(selected['height'])))
|
||||
actual = rgb.crop(tuple(round(v) for v in (selected['x'],selected['y'],selected['x']+selected['width'],selected['y']+selected['height'])))
|
||||
# Ignore the rounded corners and lower action icon.
|
||||
region = (20,20,expected.width-20,expected.height-50)
|
||||
error = ImageStat.Stat(ImageChops.difference(actual.crop(region),expected.crop(region))).mean
|
||||
assert sum(error)/3 < 12, ('Rendered cover must show the original painting',game,error)
|
||||
mint = rgb.getpixel((int(selected['x'])-2,int(selected['y']+selected['height']/2)))
|
||||
assert mint[0] > 160 and mint[1] > 200 and mint[2] > 180, ('Missing focus glow',mint)
|
||||
before = selected['label']
|
||||
driver.key('right')
|
||||
driver.wait_idle(frames=20)
|
||||
changed = selected_cover()['label']
|
||||
assert changed != before, 'Keyboard selection moves to the next cover'
|
||||
assert not any(n['key'] == 50021 for n in driver.tree()), 'Selection never adds a game background'
|
||||
# Physical mouse and the held pointer/touch path both select only.
|
||||
requests = list(server['requests'])
|
||||
for mouse in (True, False):
|
||||
tap_cover('Shovey', mouse)
|
||||
assert selected_cover()['label'] == 'Shovey'
|
||||
tap_cover('Apfelwurm', mouse)
|
||||
assert selected_cover()['label'] == 'Apfelwurm'
|
||||
assert any(n['key'] == 50400 for n in driver.tree()), 'A side-cover tap stays on the carousel'
|
||||
assert server['requests'] == requests, 'Side-cover tap launched/downloaded a game'
|
||||
assert not driver.find(label='Cancel',role='button')
|
||||
tap_cover('Shovey', False)
|
||||
driver.wait_idle(frames=20)
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
driver.wait_idle(frames=20)
|
||||
|
||||
# Native keyboard focus reaches the HUD without opening a game too.
|
||||
for _ in range(16):
|
||||
driver.key('tab')
|
||||
driver.wait_idle(frames=3)
|
||||
if any(n['label']=='Profile' and n['focused'] for n in driver.tree()):
|
||||
break
|
||||
else:
|
||||
raise AssertionError('Tab cannot reach Profile')
|
||||
driver.key('enter')
|
||||
driver.wait(label='Account', role='text')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Shovey', role='button')
|
||||
assert not driver.find(role='modal'), 'HUD keyboard activation also opened a game dialog'
|
||||
|
||||
with Image.open(out / 'home-landscape.png') as im:
|
||||
im.crop((im.width - 240, 0, im.width, 90)).resize((960, 360), Image.Resampling.LANCZOS).save(out / 'dew-profile-closeup.png')
|
||||
assert not any(entry['sha256'] in server['requests'] for entry in metadata['children']), 'Browsing does not predownload games'
|
||||
# Each orientation starts a missing game on the same shelf, immediately.
|
||||
for label, width, height in [('Apfelwurm',1200,720),('Shovey',480,820)]:
|
||||
subprocess.run(['xdotool','windowsize',window,str(width),str(height)],check=True)
|
||||
driver.wait_idle(frames=30)
|
||||
if selected_cover()['label'] != label: tap_cover(label, False)
|
||||
entry = next(e for e in metadata['children'] if e['title'] == label)
|
||||
server['game_delay'] = 3
|
||||
tap_cover(label, width > height)
|
||||
driver.wait(label='Downloading',role='text',timeout=10)
|
||||
nodes = driver.tree()
|
||||
assert any(n['key']==50400 for n in nodes), 'Download left the carousel'
|
||||
assert selected_cover()['label'] == label, 'Download moved selection'
|
||||
assert not driver.find(role='modal') and not driver.find(label='Cancel',role='button')
|
||||
cover = selected_cover()
|
||||
track = next(n for n in nodes if n['key']==cover['key']+14)
|
||||
assert track['width'] > 40 and cover['y'] < track['y'] < cover['y']+cover['height'], 'Progress bar must be on the downloading cover'
|
||||
other = 'Shovey' if label=='Apfelwurm' else 'Apfelwurm'
|
||||
tap_cover(other,False)
|
||||
assert selected_cover()['label']==other, 'Download blocked browsing'
|
||||
deadline = time.monotonic()+60
|
||||
while driver.find(label='Downloading',role='text') or not (profile/'resources/downloads'/(entry['sha256']+'.zx')).exists():
|
||||
assert time.monotonic()<deadline,'Background installation did not finish'
|
||||
time.sleep(.1)
|
||||
assert any(n['key']==50400 for n in driver.tree()), 'Finishing download interrupted browsing'
|
||||
assert server['requests'].count(entry['sha256'])==1,'Repeated activation queued duplicate transfers'
|
||||
server['game_delay']=0
|
||||
# A fresh activation now opens the installed game through its real title.
|
||||
tap_cover('Shovey',False)
|
||||
tap_cover('Shovey',False)
|
||||
driver.wait(label='Play',role='button',timeout=60)
|
||||
assert not any(n['key']==50400 for n in driver.tree()), 'Centred installed cover did not launch'
|
||||
print('PASS console home: original painted cover pixels, scenic pattern with no game-art backdrop, same centred carousel in landscape and portrait, no title/captions/editors, focus glow, keyboard, side-cover mouse/touch selection only, immediate inline download and browsing, installed title, Profile roundtrip')
|
||||
print('Captured only owned private-Xvfb window:', child.pid)
|
||||
for name in ('home-landscape.png', 'home-portrait.png', 'dew-profile-closeup.png'):
|
||||
print(out / name)
|
||||
finally:
|
||||
if child.poll() is None: child.terminate()
|
||||
child.wait(timeout=10)
|
||||
@@ -0,0 +1,99 @@
|
||||
"""Standalone Shovey's editor keeps custom levels as the account's entity
|
||||
records: levels in the editor's old records are copied over once and stay
|
||||
in place, new levels are saved as records, and a restart lists each one
|
||||
once. Runs privately with a throwaway profile and no account."""
|
||||
import argparse
|
||||
import contextlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def board():
|
||||
cells = []
|
||||
for y in range(20):
|
||||
for x in range(12):
|
||||
cells.append(12 if x in (0, 11) or y in (0, 19) else 0)
|
||||
cells[4 * 12 + 6], cells[15 * 12 + 6] = 10, 7
|
||||
return ''.join(f'{value:02x}' for value in cells)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--binary', type=Path, required=True)
|
||||
parser.add_argument('--inbe-source', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
assert int(os.environ['DISPLAY'].split(':')[-1].split('.')[0]) >= 400
|
||||
assert os.environ['YUE_DESKTOP_RECOVERY'] == '0'
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
output = root / 'build/editor-records-ui-test'
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
sys.path.insert(0, str(args.inbe_source / 'tests'))
|
||||
from ui_driver import UiDriver
|
||||
driver = UiDriver(output / 'driver')
|
||||
profile = output / 'profile'
|
||||
subprocess.run(['rm', '-rf', str(profile)], check=True)
|
||||
old = profile / 'games/arcade.shovey-editor/records'
|
||||
old.mkdir(parents=True, mode=0o700)
|
||||
index = 'I1\nnext 2\nlevel 1 0 - 0 - Kept garden\n'
|
||||
level = f'E1\nboard {board()}\nroute \n'
|
||||
(old / 'classic-levels').write_text(index)
|
||||
(old / 'classic-1').write_text(level)
|
||||
records = profile / 'entity/records/local/levels'
|
||||
|
||||
def documents():
|
||||
return {path.stem: json.loads(path.read_text()) for path in records.glob('*.json')}
|
||||
|
||||
@contextlib.contextmanager
|
||||
def editor(name):
|
||||
log_path = output / (name + '.log')
|
||||
with log_path.open('w') as log:
|
||||
child = subprocess.Popen([str(args.binary.resolve())], cwd=args.binary.resolve().parent,
|
||||
env=os.environ | driver.environment() |
|
||||
{'ARCADE_DATA': str(profile), 'LANG': 'en_US.UTF-8'},
|
||||
stdout=log, stderr=subprocess.STDOUT)
|
||||
driver.attach(child, log_path)
|
||||
try:
|
||||
driver.wait(label='Play', role='button')
|
||||
driver.press(label='Next', role='button')
|
||||
driver.press(label='Open', role='button')
|
||||
driver.wait(label='Explore', role='button')
|
||||
driver.press(label='Classic', role='button')
|
||||
driver.wait(label='Story levels', role='text')
|
||||
yield child
|
||||
finally:
|
||||
if child.poll() is None:
|
||||
child.terminate()
|
||||
child.wait(timeout=10)
|
||||
|
||||
with editor('first'):
|
||||
driver.wait(label='Kept garden', role='button')
|
||||
saved = documents()
|
||||
assert len(saved) == 1, saved
|
||||
document = next(iter(saved.values()))
|
||||
assert document['format'] == 'shovey-levels-1' and document['edition'] == 'classic', document
|
||||
assert document['title'] == 'Kept garden' and document['proof'] == '-', document
|
||||
assert ''.join(document['levels'][0]['cells']) == board(), 'The copied board changed'
|
||||
assert isinstance(document['updated_at'], int) and document['updated_at'] > 1700000000
|
||||
assert (old / 'entity-moved').read_text() == 'M1\nclassic 1\n'
|
||||
assert (old / 'classic-levels').read_text() == index and (old / 'classic-1').read_text() == level, \
|
||||
'The old records must stay for older editors'
|
||||
driver.press(label='New level', role='button')
|
||||
driver.wait(label='Play', role='button')
|
||||
driver.key('escape')
|
||||
driver.wait(label='Kept garden', role='button')
|
||||
assert len(documents()) == 2, documents()
|
||||
for path in [profile / 'entity', *(profile / 'entity').rglob('*')]:
|
||||
assert path.stat().st_mode & 0o077 == 0, f'Non-private record path: {path}'
|
||||
with editor('again'):
|
||||
driver.wait(label='Kept garden', role='button')
|
||||
assert len(driver.find(label='Kept garden', role='button')) == 1, 'The old level was copied twice'
|
||||
assert len(documents()) == 2, documents()
|
||||
print("Standalone Shovey's editor: old custom levels copied once into private entity records, kept in place, "
|
||||
'new levels saved as records and listed once after a restart passed')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Verify standalone Shovey reuses Entity without losing the game."""
|
||||
"""Verify native Arcade and standalone Shovey reuse the shared Entity profile."""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
@@ -6,23 +6,152 @@ from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageChops
|
||||
|
||||
|
||||
def arcade_profile(binary, inbe_source, root):
|
||||
"""Exercise the production Arcade entry without accounts or public services."""
|
||||
sys.path.insert(0, str(inbe_source / 'tests'))
|
||||
from ui_driver import UiDriver
|
||||
out = root / 'backup/entity-ui-test'
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(dir=out) as temporary:
|
||||
data = Path(temporary)
|
||||
driver = UiDriver(data / 'driver')
|
||||
env = os.environ | driver.environment() | {
|
||||
'ARCADE_DATA': str(data / 'arcade'), 'ENTITY_DATA': str(data / 'entity'),
|
||||
'HOME': str(data), 'XDG_DATA_HOME': str(data / 'share'),
|
||||
'XDG_CONFIG_HOME': str(data / 'config'), 'XDG_CACHE_HOME': str(data / 'cache'),
|
||||
'LANG': 'en_US.UTF-8', 'APP_NO_TRAY': '1',
|
||||
'ARCADE_PACKAGE_ORIGIN': 'http://127.0.0.1:9'}
|
||||
log_path = out / 'app.log'
|
||||
with log_path.open('w') as log:
|
||||
child = subprocess.Popen([str(binary.resolve())], cwd=binary.resolve().parent,
|
||||
env=env, stdout=log, stderr=subprocess.STDOUT)
|
||||
driver.attach(child, log_path)
|
||||
try:
|
||||
driver.wait(label='Stay offline', role='button')
|
||||
driver.press(label='Stay offline', role='button')
|
||||
driver.wait(label='Profile', role='button')
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.press(label='Sign in', role='button')
|
||||
# The native sign-in page includes file recovery before the
|
||||
# online password. Scroll only this test's private window.
|
||||
for _ in range(20):
|
||||
if driver.find(label='Password', role='text_field', visible=True):
|
||||
break
|
||||
driver.pointer(500, 650, wheel=-3)
|
||||
field = driver.wait(label='Password', role='text_field')
|
||||
assert field['secure'] and field['value'] == '' and field['cursor'] == 0
|
||||
windows = subprocess.check_output(
|
||||
['xdotool', 'search', '--onlyvisible', '--pid', str(child.pid)],
|
||||
env=env, text=True).split()
|
||||
assert len(windows) == 1
|
||||
window = windows[0]
|
||||
assert subprocess.check_output(['xdotool', 'getwindowpid', window],
|
||||
env=env, text=True).strip() == str(child.pid)
|
||||
subprocess.run(['xdotool', 'windowfocus', '--sync', window], env=env, check=True)
|
||||
|
||||
def keyboard(*keys):
|
||||
subprocess.run(['xdotool', 'key', '--clearmodifiers', *keys], env=env, check=True)
|
||||
driver.wait_idle(frames=3)
|
||||
|
||||
def field_image(name):
|
||||
driver.press(label='Username or public ID', role='text_field')
|
||||
driver.wait_idle(frames=3)
|
||||
node = driver.wait(label='Password', role='text_field')
|
||||
path = out / (name + '.png')
|
||||
subprocess.run(['import', '-window', window, str(path)], env=env, check=True)
|
||||
with Image.open(path) as picture:
|
||||
return picture.convert('RGB').crop((round(node['x'] + 14), round(node['y'] + 12),
|
||||
round(node['x'] + node['width'] - 14), round(node['y'] + node['height'] - 12)))
|
||||
|
||||
def star_count(image):
|
||||
# Bright text stands above the muted placeholder. Each
|
||||
# ASCII star occupies one separate run of pixel columns.
|
||||
background = image.getpixel((image.width - 1, image.height // 2))
|
||||
columns = [any(max(abs(a - b) for a, b in zip(image.getpixel((x, y)), background)) > 90
|
||||
for y in range(image.height)) for x in range(image.width)]
|
||||
return sum(lit and (x == 0 or not columns[x - 1]) for x, lit in enumerate(columns))
|
||||
|
||||
empty = field_image('empty')
|
||||
assert star_count(empty) == 0, 'An empty password must not prefill stars'
|
||||
counts = []
|
||||
for name, text in [('twelve', 'Ab3defghijkl'), ('thirty-two', 'Ab3' + 'x' * 29),
|
||||
('unicode', 'Ab3é中🙂')]:
|
||||
driver.press(label='Password', role='text_field')
|
||||
assert driver.wait(label='Password', role='text_field')['focused'], 'Password must take focus'
|
||||
keyboard('ctrl+a')
|
||||
# Arcade forwards the physical SDL text/modifier path;
|
||||
# its entry does not consume UiDriver's typed-text queue.
|
||||
if text.isascii():
|
||||
subprocess.run(['xdotool', 'type', '--clearmodifiers', '--delay', '20', text],
|
||||
env=env, check=True)
|
||||
else:
|
||||
# Xvfb has no Unicode keyboard layout. Exercise native
|
||||
# clipboard paste rather than synthesizing unmapped keys.
|
||||
subprocess.run(['xclip', '-selection', 'clipboard'], input=text.encode(), env=env, check=True)
|
||||
keyboard('ctrl+v')
|
||||
image = field_image(name)
|
||||
groups = star_count(image)
|
||||
assert groups == len(text), (name, groups, len(text))
|
||||
counts.append(groups)
|
||||
assert driver.wait(label='Password', role='text_field')['value'] == ''
|
||||
driver.press(label='Password', role='text_field')
|
||||
keyboard('BackSpace')
|
||||
assert star_count(field_image('backspace')) == 5, 'Backspace removes one Unicode symbol'
|
||||
driver.press(label='Password', role='text_field')
|
||||
keyboard('ctrl+a', 'BackSpace')
|
||||
cleared = field_image('cleared')
|
||||
assert ImageChops.difference(empty, cleared).getbbox() is None, 'Clearing must restore the empty field'
|
||||
driver.press(label='Password', role='text_field')
|
||||
subprocess.run(['xdotool', 'type', '--clearmodifiers', 'Ab3-not-retained'], env=env, check=True)
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Profile', role='button')
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.press(label='Sign in', role='button')
|
||||
assert driver.wait(label='Password', role='text_field')['cursor'] == 0
|
||||
assert star_count(field_image('reopened')) == 0, 'Returning must not prefill the old password'
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Profile', role='button')
|
||||
# Escape goes back one page, then exits from the profile root.
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.press(label='Sign in', role='button')
|
||||
driver.key('escape')
|
||||
driver.wait_gone(label='Password', role='text_field')
|
||||
assert not driver.find(label='Profile', role='button'), 'Back must stay inside Profile first'
|
||||
driver.key('escape')
|
||||
driver.wait(label='Profile', role='button')
|
||||
(out / 'result.json').write_text(json.dumps({'rendered_stars': counts,
|
||||
'empty_initially': True, 'empty_after_clear': True,
|
||||
'empty_after_reopen': True, 'returned_to_library': True}) + '\n')
|
||||
finally:
|
||||
if child.poll() is None:
|
||||
child.terminate()
|
||||
child.wait(timeout=10)
|
||||
print('Arcade native Profile: empty password, 12/32/Unicode stars, editing and direct close from sign-in passed')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--binary', type=Path, required=True)
|
||||
parser.add_argument('--inbe-source', type=Path, required=True)
|
||||
parser.add_argument('--product', choices=('arcade', 'shovey'), default='shovey')
|
||||
args = parser.parse_args()
|
||||
assert int(os.environ['DISPLAY'].split(':')[-1].split('.')[0]) >= 400
|
||||
assert os.environ['YUE_DESKTOP_RECOVERY'] == '0'
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
out = root / 'build/entity-ui-test'
|
||||
if args.product == 'arcade':
|
||||
arcade_profile(args.binary, args.inbe_source, root)
|
||||
sys.exit(0)
|
||||
out = root / 'work/entity-ui-test-shovey'
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
sys.path.insert(0, str(args.inbe_source / 'tests'))
|
||||
from ui_driver import UiDriver
|
||||
with tempfile.TemporaryDirectory(dir=out) as temporary:
|
||||
data = Path(temporary)
|
||||
driver = UiDriver(out / 'driver')
|
||||
env = os.environ | driver.environment() | {'ARCADE_DATA': str(data), 'ENTITY_DATA': str(data / 'shared'), 'LANG': 'en_US.UTF-8'}
|
||||
env = os.environ | driver.environment() | {'ARCADE_DATA': str(data), 'ENTITY_DATA': str(data / 'shared'),
|
||||
'XDG_DATA_HOME': str(data / 'share'), 'XDG_CONFIG_HOME': str(data / 'config'),
|
||||
'XDG_CACHE_HOME': str(data / 'cache'), 'LANG': 'en_US.UTF-8'}
|
||||
log_path = out / 'app.log'
|
||||
with log_path.open('w') as log:
|
||||
child = subprocess.Popen([str(args.binary.resolve())], cwd=args.binary.resolve().parent,
|
||||
@@ -51,7 +180,7 @@ with tempfile.TemporaryDirectory(dir=out) as temporary:
|
||||
title.crop((round(profile_button['x']), round(profile_button['y']),
|
||||
round(profile_button['x'] + profile_button['width']), round(profile_button['y'] + profile_button['height']))).save(out / 'profile-icon.png')
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.wait(label='Connect an account', role='button')
|
||||
driver.wait(label='Sign in', role='button')
|
||||
driver.wait(label='Profile', role='text')
|
||||
driver.wait_idle(frames=3)
|
||||
subprocess.run(['import', '-window', window, str(out / 'profile.png')], env=env, check=True)
|
||||
@@ -71,7 +200,7 @@ with tempfile.TemporaryDirectory(dir=out) as temporary:
|
||||
driver.wait(label='Profile', role='button')
|
||||
before = record.read_bytes() if record.exists() else b''
|
||||
driver.press(label='Profile', role='button')
|
||||
driver.wait(label='Connect an account', role='button')
|
||||
driver.wait(label='Sign in', role='button')
|
||||
driver.press(label='Back', role='button')
|
||||
driver.wait(label='Play', role='button')
|
||||
assert (record.read_bytes() if record.exists() else b'') == before
|
||||
|
||||